Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release 1.34.0 #191

Merged
merged 14 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 118 additions & 37 deletions custom-elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -24242,6 +24242,9 @@
}
],
"events": [
{
"name": "input"
},
{
"name": "update",
"description": "Instance of `NucleonElement.UpdateEvent`. Dispatched on an element whenever it changes its state."
Expand Down Expand Up @@ -24607,6 +24610,10 @@
"path": "./src/elements/public/StoreForm/index.ts",
"description": "Form element for store settings (`fx:store`).",
"attributes": [
{
"name": "reporting-store-domain-exists",
"description": "URL of the `fx:reporting_store_domain_exists` endpoint."
},
{
"name": "customer-password-hash-types",
"description": "URL of the `fx:customer_password_hash_types` property helper resource."
Expand Down Expand Up @@ -24738,6 +24745,11 @@
}
],
"properties": [
{
"name": "reportingStoreDomainExists",
"attribute": "reporting-store-domain-exists",
"description": "URL of the `fx:reporting_store_domain_exists` endpoint."
},
{
"name": "customerPasswordHashTypes",
"attribute": "customer-password-hash-types",
Expand Down Expand Up @@ -27275,15 +27287,30 @@
"attributes": [
{
"name": "countries",
"description": "URI of the `fx:countries` hAPI resource.",
"type": "string",
"default": "\"\""
"description": "URI of the `fx:countries` hAPI resource."
},
{
"name": "regions",
"description": "URI of the `fx:regions` hAPI resource.",
"description": "URI of the `fx:regions` hAPI resource."
},
{
"name": "store",
"description": "URI of the `fx:store` hAPI resource related to this template config. If this property is `null`, a link relationship will be used when available."
},
{
"name": "simplify-ns-loading",
"type": "boolean",
"default": "false"
},
{
"name": "ns",
"type": "string",
"default": "\"\""
"default": "\"defaultNS\""
},
{
"name": "status",
"description": "Status message to render at the top of the form. If `null`, the message is hidden.",
"type": "object"
},
{
"name": "mode",
Expand Down Expand Up @@ -27317,16 +27344,6 @@
"name": "hiddencontrols",
"default": "\"False\""
},
{
"name": "simplify-ns-loading",
"type": "boolean",
"default": "false"
},
{
"name": "ns",
"type": "string",
"default": "\"defaultNS\""
},
{
"name": "lang",
"description": "Optional ISO 639-1 code describing the language element content is written in.\nChanging the `lang` attribute will update the value of this property.",
Expand Down Expand Up @@ -27370,16 +27387,71 @@
{
"name": "countries",
"attribute": "countries",
"description": "URI of the `fx:countries` hAPI resource.",
"type": "string",
"default": "\"\""
"description": "URI of the `fx:countries` hAPI resource."
},
{
"name": "regions",
"attribute": "regions",
"description": "URI of the `fx:regions` hAPI resource.",
"description": "URI of the `fx:regions` hAPI resource."
},
{
"name": "store",
"attribute": "store",
"description": "URI of the `fx:store` hAPI resource related to this template config. If this property is `null`, a link relationship will be used when available."
},
{
"name": "simplifyNsLoading",
"attribute": "simplify-ns-loading",
"type": "boolean",
"default": "false"
},
{
"name": "ns",
"attribute": "ns",
"type": "string",
"default": "\"\""
"default": "\"defaultNS\""
},
{
"name": "t",
"type": "Translator",
"default": "\"(key, options) => {\\n const I18nElement = customElements.get('foxy-i18n') as typeof I18n | undefined;\\n\\n if (!I18nElement) return key;\\n\\n let keys: string[];\\n\\n if (this.simplifyNsLoading) {\\n const namespaces = this.ns.split(' ').filter(v => v.length > 0);\\n const path = [...namespaces.slice(1), key].join('.');\\n keys = namespaces[0] ? [`${namespaces[0]}:${path}`] : [path];\\n } else {\\n keys = this.ns\\n .split(' ')\\n .reverse()\\n .map(v => v.trim())\\n .filter(v => v.length > 0)\\n .reverse()\\n .map((v, i, a) => `${v}:${[...a.slice(i + 1), key].join('.')}`);\\n }\\n\\n keys.push(key);\\n\\n return I18nElement.i18next.t(keys, { lng: this.lang, ...options }).toString();\\n }\""
},
{
"name": "generalErrorPrefix",
"description": "Validation errors with this prefix will show up at the top of the form.",
"type": "string",
"default": "\"error:\""
},
{
"name": "status",
"attribute": "status",
"description": "Status message to render at the top of the form. If `null`, the message is hidden.",
"type": "object"
},
{
"name": "headerTitleKey",
"description": "Getter that returns a i18n key for the optional form header title.",
"type": "string"
},
{
"name": "headerTitleOptions",
"description": "I18next options to pass to the header title translation function.",
"type": "Record<string, unknown>"
},
{
"name": "headerSubtitleKey",
"description": "Getter that returns a i18n key for the optional form header subtitle. Note that subtitle is shown only when data is avaiable.",
"type": "string"
},
{
"name": "headerSubtitleOptions",
"description": "I18next options to pass to the header subtitle translation function. Note that subtitle is shown only when data is avaiable.",
"type": "Record<string, unknown>"
},
{
"name": "headerCopyIdValue",
"description": "ID that will be written to clipboard when Copy ID button in header is clicked.",
"type": "string | number"
},
{
"name": "templates",
Expand Down Expand Up @@ -27436,23 +27508,6 @@
"name": "hiddenSelector",
"type": "BooleanSelector"
},
{
"name": "simplifyNsLoading",
"attribute": "simplify-ns-loading",
"type": "boolean",
"default": "false"
},
{
"name": "ns",
"attribute": "ns",
"type": "string",
"default": "\"defaultNS\""
},
{
"name": "t",
"type": "Translator",
"default": "\"(key, options) => {\\n const I18nElement = customElements.get('foxy-i18n') as typeof I18n | undefined;\\n\\n if (!I18nElement) return key;\\n\\n let keys: string[];\\n\\n if (this.simplifyNsLoading) {\\n const namespaces = this.ns.split(' ').filter(v => v.length > 0);\\n const path = [...namespaces.slice(1), key].join('.');\\n keys = namespaces[0] ? [`${namespaces[0]}:${path}`] : [path];\\n } else {\\n keys = this.ns\\n .split(' ')\\n .reverse()\\n .map(v => v.trim())\\n .filter(v => v.length > 0)\\n .reverse()\\n .map((v, i, a) => `${v}:${[...a.slice(i + 1), key].join('.')}`);\\n }\\n\\n keys.push(key);\\n\\n return I18nElement.i18next.t(keys, { lng: this.lang, ...options }).toString();\\n }\""
},
{
"name": "UpdateEvent",
"description": "Instances of this event are dispatched on an element whenever it changes its\nstate (e.g. when going from `busy` to `idle` or on `form` data change).\nThis event isn't cancelable, and it does not bubble.",
Expand Down Expand Up @@ -31247,6 +31302,14 @@
}
],
"properties": [
{
"name": "getStatusPageHref",
"description": "If set, renders Statuses list items as <a> tags."
},
{
"name": "getLogPageHref",
"description": "If set, renders Logs list items as <a> tags."
},
{
"name": "resourceUri",
"attribute": "resource-uri",
Expand Down Expand Up @@ -31461,6 +31524,10 @@
"path": "./src/elements/public/WebhookLogCard/index.ts",
"description": "Basic card displaying webhook log (`fx:webhook_log`) info.",
"attributes": [
{
"name": "layout",
"description": "When set to \"resource\", doesn't render resource type and ID."
},
{
"name": "simplify-ns-loading",
"type": "boolean",
Expand Down Expand Up @@ -31511,6 +31578,11 @@
}
],
"properties": [
{
"name": "layout",
"attribute": "layout",
"description": "When set to \"resource\", doesn't render resource type and ID."
},
{
"name": "simplifyNsLoading",
"attribute": "simplify-ns-loading",
Expand Down Expand Up @@ -31632,6 +31704,10 @@
"path": "./src/elements/public/WebhookStatusCard/index.ts",
"description": "Basic card displaying webhook status (`fx:webhook_status`) info.",
"attributes": [
{
"name": "layout",
"description": "When set to \"resource\", doesn't render resource type and ID."
},
{
"name": "simplify-ns-loading",
"type": "boolean",
Expand Down Expand Up @@ -31682,6 +31758,11 @@
}
],
"properties": [
{
"name": "layout",
"attribute": "layout",
"description": "When set to \"resource\", doesn't render resource type and ID."
},
{
"name": "simplifyNsLoading",
"attribute": "simplify-ns-loading",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ describe('InternalEditableControl', () => {
});
});

it('has a reactive property "jsonTemplate" (String)', () => {
expect(new InternalEditableControl()).to.have.property('jsonTemplate', null);
expect(InternalEditableControl).to.have.deep.nested.property('properties.jsonTemplate', {
attribute: 'json-template',
});
});

it('has a reactive property "placeholder" (String)', () => {
expect(InternalEditableControl).to.have.nested.property('properties.placeholder.type', String);
});
Expand All @@ -42,6 +49,13 @@ describe('InternalEditableControl', () => {
expect(InternalEditableControl).to.have.nested.property('properties.v8nPrefix.type', String);
});

it('has a reactive property "jsonPath" (String)', () => {
expect(new InternalEditableControl()).to.have.property('jsonPath', null);
expect(InternalEditableControl).to.have.deep.nested.property('properties.jsonPath', {
attribute: 'json-path',
});
});

it('has a reactive property "property" (String)', () => {
expect(InternalEditableControl).to.have.nested.property('properties.property.type', String);
});
Expand Down Expand Up @@ -164,6 +178,36 @@ describe('InternalEditableControl', () => {
expect(wrapper.firstElementChild).to.have.property('_value', testData.address_name);
});

it('supports retrieving values from serialized json', async () => {
const testData = await getTestData<any>('./hapi/customer_addresses/0');
testData.address_name = JSON.stringify({ foo: { bar: 'baz' } });

const wrapper = await fixture(html`
<foxy-nucleon .data=${testData}>
<foxy-internal-editable-control json-path="foo.bar" property="address_name" infer="bar">
</foxy-internal-editable-control>
</foxy-nucleon>
`);

expect(wrapper.firstElementChild).to.have.property('_value', 'baz');
});

it('supports default values for serialized json', async () => {
const testData = await getTestData<any>('./hapi/customer_addresses/0');
const wrapper = await fixture(html`
<foxy-nucleon .data=${testData}>
<foxy-internal-editable-control
json-template=${JSON.stringify({ foo: { bar: 'baz' } })}
json-path="foo.bar"
infer="some-unknown-property"
>
</foxy-internal-editable-control>
</foxy-nucleon>
`);

expect(wrapper.firstElementChild).to.have.property('_value', 'baz');
});

it('sends updates to the parent NucleonElement on value change', async () => {
const testData = await getTestData<any>('./hapi/customer_addresses/0');
const wrapper = await fixture(html`
Expand Down Expand Up @@ -199,6 +243,44 @@ describe('InternalEditableControl', () => {
expect(wrapper).to.have.nested.property('form.address_name', testData.address_name);
});

it('supports setting values in serialized json', async () => {
const testData = await getTestData<any>('./hapi/customer_addresses/0');
testData.address_name = JSON.stringify({ foo: { bar: 'baz' } });

const wrapper = await fixture(html`
<foxy-nucleon .data=${testData}>
<foxy-internal-editable-control json-path="foo.bar" property="address_name" infer="bar">
</foxy-internal-editable-control>
</foxy-nucleon>
`);

(wrapper.firstElementChild as InternalEditableControl)!.setValue('qux');
expect(wrapper).to.have.nested.property(
'form.address_name',
JSON.stringify({ foo: { bar: 'qux' } })
);
});

it('supports setting values in serialized json with default values', async () => {
const testData = await getTestData<any>('./hapi/customer_addresses/0');
const wrapper = await fixture(html`
<foxy-nucleon .data=${testData}>
<foxy-internal-editable-control
json-template=${JSON.stringify({ foo: { bar: 'baz' } })}
json-path="foo.bar"
infer="some-unknown-property"
>
</foxy-internal-editable-control>
</foxy-nucleon>
`);

(wrapper.firstElementChild as InternalEditableControl)!.setValue('qux');
expect(wrapper).to.have.nested.property(
'form.some_unknown_property',
JSON.stringify({ foo: { bar: 'qux' } })
);
});

it("has a protected shortcut for the first v8n error in a a nucleon form it's associated with", async () => {
const wrapper = await fixture<AddressForm>(html`
<foxy-address-form>
Expand Down
Loading