@foxy.io/elements 1.40.0-beta.3 → 1.40.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/elements/public/NativeIntegrationForm/NativeIntegrationForm.js +4 -7
- package/dist/elements/public/NativeIntegrationForm/NativeIntegrationForm.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.d.ts +2 -2
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +6 -9
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControl.d.ts +0 -1
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControl.js +24 -70
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControl.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControlItem.d.ts +8 -12
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControlItem.js +51 -89
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControlItem.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/index.d.ts +1 -0
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/index.js +1 -0
- package/dist/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,6 @@ export class InternalTemplateConfigFormFilterValuesControl extends InternalEdita
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
8
|
this.countries = null;
|
|
9
|
-
this.regions = null;
|
|
10
9
|
this.__newCountry = '';
|
|
11
10
|
}
|
|
12
11
|
static get properties() {
|
|
@@ -14,7 +13,6 @@ export class InternalTemplateConfigFormFilterValuesControl extends InternalEdita
|
|
|
14
13
|
...super.properties,
|
|
15
14
|
__newCountry: { attribute: false },
|
|
16
15
|
countries: {},
|
|
17
|
-
regions: {},
|
|
18
16
|
};
|
|
19
17
|
}
|
|
20
18
|
renderControl() {
|
|
@@ -24,23 +22,17 @@ export class InternalTemplateConfigFormFilterValuesControl extends InternalEdita
|
|
|
24
22
|
return html `
|
|
25
23
|
<div class="space-y-s" data-testid="countries">
|
|
26
24
|
${Object.entries(this._value).map(([country, regions]) => {
|
|
27
|
-
var _a
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const url = new URL((_a = this.regions) !== null && _a !== void 0 ? _a : '');
|
|
31
|
-
url.searchParams.set('country_code', country);
|
|
32
|
-
regionsLink = url.toString();
|
|
33
|
-
}
|
|
34
|
-
catch (_c) {
|
|
35
|
-
regionsLink = '';
|
|
36
|
-
}
|
|
25
|
+
var _a;
|
|
26
|
+
const option = options.find(o => o.cc2 === country);
|
|
37
27
|
return html `
|
|
38
28
|
<foxy-internal-template-config-form-filter-values-control-item
|
|
39
29
|
regions=${JSON.stringify(regions === '*' ? [] : regions)}
|
|
30
|
+
options=${
|
|
31
|
+
// @ts-expect-error SDK types are not up-to-date
|
|
32
|
+
JSON.stringify(Array.isArray(option === null || option === void 0 ? void 0 : option.regions) ? {} : (_a = option === null || option === void 0 ? void 0 : option.regions) !== null && _a !== void 0 ? _a : {})}
|
|
40
33
|
infer=""
|
|
41
34
|
code=${country}
|
|
42
|
-
name=${ifDefined(
|
|
43
|
-
href=${regionsLink}
|
|
35
|
+
name=${ifDefined(option === null || option === void 0 ? void 0 : option.default)}
|
|
44
36
|
?disabled=${this.disabled}
|
|
45
37
|
?readonly=${this.readonly}
|
|
46
38
|
@update:regions=${(evt) => {
|
|
@@ -71,62 +63,24 @@ export class InternalTemplateConfigFormFilterValuesControl extends InternalEdita
|
|
|
71
63
|
'hidden': this.readonly,
|
|
72
64
|
})}
|
|
73
65
|
>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<button
|
|
94
|
-
aria-label=${this.t('create')}
|
|
95
|
-
class=${classMap({
|
|
96
|
-
'mr-xs flex-shrink-0': true,
|
|
97
|
-
'flex items-center justify-center rounded-s transition-colors': true,
|
|
98
|
-
'text-transparent cursor-default': !this.__newCountry,
|
|
99
|
-
'bg-contrast-5 text-body cursor-pointer': !!this.__newCountry,
|
|
100
|
-
'hover-bg-success hover-text-success-contrast': !!this.__newCountry,
|
|
101
|
-
'focus-outline-none focus-ring-2 ring-inset ring-primary-50': !!this.__newCountry,
|
|
102
|
-
})}
|
|
103
|
-
style="width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)"
|
|
104
|
-
?disabled=${!this.__newCountry || this.disabled}
|
|
105
|
-
@click=${this.__addCountry}
|
|
106
|
-
>
|
|
107
|
-
<iron-icon icon="icons:add" class="icon-inline text-m"></iron-icon>
|
|
108
|
-
</button>
|
|
109
|
-
`
|
|
110
|
-
: html `
|
|
111
|
-
<select
|
|
112
|
-
class=${classMap({
|
|
113
|
-
'appearance-none bg-transparent h-m text-m px-s flex-1 font-medium': true,
|
|
114
|
-
'transition-colors rounded-s focus-outline-none': true,
|
|
115
|
-
'cursor-pointer hover-bg-contrast-5': !this.disabled,
|
|
116
|
-
'text-disabled': this.disabled,
|
|
117
|
-
})}
|
|
118
|
-
?disabled=${this.disabled}
|
|
119
|
-
@change=${(evt) => {
|
|
120
|
-
const target = evt.currentTarget;
|
|
121
|
-
this.__newCountry = target.value;
|
|
122
|
-
this.__addCountry();
|
|
123
|
-
target.value = '';
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
<option value="" disabled selected>${this.t('add_country')}</option>
|
|
127
|
-
${filteredOptions.map(option => html `<option value=${option.cc2}>${option.default}</option>`)}
|
|
128
|
-
</select>
|
|
129
|
-
`}
|
|
66
|
+
<select
|
|
67
|
+
class=${classMap({
|
|
68
|
+
'appearance-none bg-transparent h-m text-m px-s flex-1 font-medium': true,
|
|
69
|
+
'transition-colors rounded-s focus-outline-none': true,
|
|
70
|
+
'cursor-pointer hover-bg-contrast-5': !this.disabled,
|
|
71
|
+
'text-disabled': this.disabled,
|
|
72
|
+
})}
|
|
73
|
+
?disabled=${this.disabled}
|
|
74
|
+
@change=${(evt) => {
|
|
75
|
+
const target = evt.currentTarget;
|
|
76
|
+
this.__newCountry = target.value;
|
|
77
|
+
this.__addCountry();
|
|
78
|
+
target.value = '';
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<option value="" disabled selected>${this.t('add_country')}</option>
|
|
82
|
+
${filteredOptions.map(option => html `<option value=${option.cc2}>${option.default}</option>`)}
|
|
83
|
+
</select>
|
|
130
84
|
</div>
|
|
131
85
|
`}
|
|
132
86
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalTemplateConfigFormFilterValuesControl.js","sourceRoot":"","sources":["../../../../../../src/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControl.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,gFAA6E;AAC/G,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,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,CAAC;gBACpB,CAAC;;6DAEoC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC;0BACxD,eAAe,CAAC,GAAG,CACnB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA,iBAAiB,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,OAAO,WAAW,CACvE;;qBAEJ;;aAER;;;;;eAKE,SAAS,OAAC,IAAI,CAAC,SAAS,mCAAI,KAAK,CAAC,CAAC;;kBAEhC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;;;KAGvC,CAAC;IACJ,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;QAC3D,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,IAAY,iBAAiB;QAE3B,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,kBAAkB,CAAC,CAAC;IACnE,CAAC;IAED,IAAc,MAAM;;QAClB,OAAO,OAAC,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAmC,CAAC;IAChE,CAAC;IAED,IAAc,MAAM,CAAC,KAAqC;QACxD,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IACvB,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../../../NucleonElement/NucleonElement';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { InternalEditableControl } from '../../../../internal/InternalEditableControl/InternalEditableControl';\nimport { TemplateResult, html } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../../../utils/class-map';\nimport { InternalTemplateConfigFormFilterValuesControlItem } from './InternalTemplateConfigFormFilterValuesControlItem';\n\nexport class InternalTemplateConfigFormFilterValuesControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newCountry: { attribute: false },\n countries: {},\n regions: {},\n };\n }\n\n countries: string | null = null;\n\n regions: string | null = null;\n\n private __newCountry = '';\n\n renderControl(): TemplateResult {\n const options = Object.values(this.__countriesLoader?.data?.values ?? {});\n const filteredOptions = options.filter(c => !(c.cc2 in this._value));\n\n return html`\n <div class=\"space-y-s\" data-testid=\"countries\">\n ${Object.entries(this._value).map(([country, regions]) => {\n let regionsLink: string;\n\n try {\n const url = new URL(this.regions ?? '');\n url.searchParams.set('country_code', country);\n regionsLink = url.toString();\n } catch {\n regionsLink = '';\n }\n\n return html`\n <foxy-internal-template-config-form-filter-values-control-item\n regions=${JSON.stringify(regions === '*' ? [] : regions)}\n infer=\"\"\n code=${country}\n name=${ifDefined(options.find(o => o.cc2 === country)?.default)}\n href=${regionsLink}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @update:regions=${(evt: CustomEvent) => {\n const newCountries = { ...this._value };\n const newRegions = (\n evt.currentTarget as InternalTemplateConfigFormFilterValuesControlItem\n ).regions;\n\n newCountries[country] = newRegions.length ? newRegions : '*';\n this._value = newCountries;\n }}\n @delete=${() => {\n const newCountries = { ...this._value };\n delete newCountries[country];\n this._value = newCountries;\n }}\n >\n </foxy-internal-template-config-form-filter-values-control-item>\n `;\n })}\n ${filteredOptions.length === 0 && options.length !== 0\n ? ''\n : html`\n <div\n data-testid=\"new-country\"\n class=${classMap({\n 'h-m flex items-center rounded-s transition-colors': true,\n 'border border-contrast-10 ring-primary-50': true,\n 'focus-within-ring-1 focus-within-border-primary-50': !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n ${options.length === 0\n ? html`\n <input\n placeholder=${this.t('add_country')}\n class=\"w-full bg-transparent font-medium appearance-none h-m focus-outline-none\"\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n .value=${this.__newCountry}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.__newCountry) this.__addCountry();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.__newCountry = target.value;\n }}\n />\n\n <button\n aria-label=${this.t('create')}\n class=${classMap({\n 'mr-xs flex-shrink-0': true,\n 'flex items-center justify-center rounded-s transition-colors': true,\n 'text-transparent cursor-default': !this.__newCountry,\n 'bg-contrast-5 text-body cursor-pointer': !!this.__newCountry,\n 'hover-bg-success hover-text-success-contrast': !!this.__newCountry,\n 'focus-outline-none focus-ring-2 ring-inset ring-primary-50':\n !!this.__newCountry,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${!this.__newCountry || this.disabled}\n @click=${this.__addCountry}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n `\n : html`\n <select\n class=${classMap({\n 'appearance-none bg-transparent h-m text-m px-s flex-1 font-medium': true,\n 'transition-colors rounded-s focus-outline-none': true,\n 'cursor-pointer hover-bg-contrast-5': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n ?disabled=${this.disabled}\n @change=${(evt: Event) => {\n const target = evt.currentTarget as HTMLSelectElement;\n this.__newCountry = target.value;\n this.__addCountry();\n target.value = '';\n }}\n >\n <option value=\"\" disabled selected>${this.t('add_country')}</option>\n ${filteredOptions.map(\n option => html`<option value=${option.cc2}>${option.default}</option>`\n )}\n </select>\n `}\n </div>\n `}\n </div>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.countries ?? void 0)}\n id=\"countriesLoader\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private __addCountry() {\n this._value = { ...this._value, [this.__newCountry]: '*' };\n this.__newCountry = '';\n }\n\n private get __countriesLoader() {\n type Loader = NucleonElement<Resource<Rels.Countries>>;\n return this.renderRoot.querySelector<Loader>('#countriesLoader');\n }\n\n protected get _value(): Record<string, '*' | string[]> {\n return (super._value ?? {}) as Record<string, '*' | string[]>;\n }\n\n protected set _value(value: Record<string, '*' | string[]>) {\n super._value = value;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalTemplateConfigFormFilterValuesControl.js","sourceRoot":"","sources":["../../../../../../src/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControl.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,uBAAuB,EAAE,gFAA6E;AAC/G,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,0CAAuC;AAE1D,MAAM,OAAO,6CAA8C,SAAQ,uBAAuB;IAA1F;;QASE,cAAS,GAAkB,IAAI,CAAC;QAExB,iBAAY,GAAG,EAAE,CAAC;IAyG5B,CAAC;IAnHC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,YAAY,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YAClC,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAMD,aAAa;;QACX,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,mBAAC,IAAI,CAAC,iBAAiB,0CAAE,IAAI,0CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC;QAC1E,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAErE,OAAO,IAAI,CAAA;;UAEL,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;;YACvD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC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;IACnE,CAAC;IAED,IAAc,MAAM;;QAClB,OAAO,OAAC,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAmC,CAAC;IAChE,CAAC;IAED,IAAc,MAAM,CAAC,KAAqC;QACxD,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IACvB,CAAC;CACF","sourcesContent":["import type { InternalTemplateConfigFormFilterValuesControlItem } from './InternalTemplateConfigFormFilterValuesControlItem';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../../../NucleonElement/NucleonElement';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { InternalEditableControl } from '../../../../internal/InternalEditableControl/InternalEditableControl';\nimport { TemplateResult, html } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../../../utils/class-map';\n\nexport class InternalTemplateConfigFormFilterValuesControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newCountry: { attribute: false },\n countries: {},\n };\n }\n\n countries: string | null = null;\n\n private __newCountry = '';\n\n renderControl(): TemplateResult {\n const options = Object.values(this.__countriesLoader?.data?.values ?? {});\n const filteredOptions = options.filter(c => !(c.cc2 in this._value));\n\n return html`\n <div class=\"space-y-s\" data-testid=\"countries\">\n ${Object.entries(this._value).map(([country, regions]) => {\n const option = options.find(o => o.cc2 === country);\n\n return html`\n <foxy-internal-template-config-form-filter-values-control-item\n regions=${JSON.stringify(regions === '*' ? [] : regions)}\n options=${\n // @ts-expect-error SDK types are not up-to-date\n JSON.stringify(Array.isArray(option?.regions) ? {} : option?.regions ?? {})\n }\n infer=\"\"\n code=${country}\n name=${ifDefined(option?.default)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @update:regions=${(evt: CustomEvent) => {\n const newCountries = { ...this._value };\n const newRegions = (\n evt.currentTarget as InternalTemplateConfigFormFilterValuesControlItem\n ).regions;\n\n newCountries[country] = newRegions.length ? newRegions : '*';\n this._value = newCountries;\n }}\n @delete=${() => {\n const newCountries = { ...this._value };\n delete newCountries[country];\n this._value = newCountries;\n }}\n >\n </foxy-internal-template-config-form-filter-values-control-item>\n `;\n })}\n ${filteredOptions.length === 0 && options.length !== 0\n ? ''\n : html`\n <div\n data-testid=\"new-country\"\n class=${classMap({\n 'h-m flex items-center rounded-s transition-colors': true,\n 'border border-contrast-10 ring-primary-50': true,\n 'focus-within-ring-1 focus-within-border-primary-50': !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n <select\n class=${classMap({\n 'appearance-none bg-transparent h-m text-m px-s flex-1 font-medium': true,\n 'transition-colors rounded-s focus-outline-none': true,\n 'cursor-pointer hover-bg-contrast-5': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n ?disabled=${this.disabled}\n @change=${(evt: Event) => {\n const target = evt.currentTarget as HTMLSelectElement;\n this.__newCountry = target.value;\n this.__addCountry();\n target.value = '';\n }}\n >\n <option value=\"\" disabled selected>${this.t('add_country')}</option>\n ${filteredOptions.map(\n option => html`<option value=${option.cc2}>${option.default}</option>`\n )}\n </select>\n </div>\n `}\n </div>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.countries ?? void 0)}\n id=\"countriesLoader\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private __addCountry() {\n this._value = { ...this._value, [this.__newCountry]: '*' };\n this.__newCountry = '';\n }\n\n private get __countriesLoader() {\n type Loader = NucleonElement<Resource<Rels.Countries>>;\n return this.renderRoot.querySelector<Loader>('#countriesLoader');\n }\n\n protected get _value(): Record<string, '*' | string[]> {\n return (super._value ?? {}) as Record<string, '*' | string[]>;\n }\n\n protected set _value(value: Record<string, '*' | string[]>) {\n super._value = value;\n }\n}\n"]}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { Resource } from '@foxy.io/sdk/core';
|
|
6
|
-
declare const Base: typeof NucleonElement & import("lit-element").Constructor<import("../../../../../mixins/translatable").TranslatableMixinHost> & {
|
|
7
|
-
defaultNS: string;
|
|
8
|
-
} & {
|
|
9
|
-
styles: import("lit-element").CSSResultArray;
|
|
10
|
-
} & import("lit-element").Constructor<import("../../../../../mixins/configurable").ConfigurableMixinHost>;
|
|
11
|
-
export declare class InternalTemplateConfigFormFilterValuesControlItem extends Base<Resource<Rels.Regions>> {
|
|
1
|
+
import type { PropertyDeclarations } from 'lit-element';
|
|
2
|
+
import type { TemplateResult } from 'lit-html';
|
|
3
|
+
import { InternalControl } from '../../../../internal/InternalControl/InternalControl';
|
|
4
|
+
export declare class InternalTemplateConfigFormFilterValuesControlItem extends InternalControl {
|
|
12
5
|
static get properties(): PropertyDeclarations;
|
|
6
|
+
options: Record<string, {
|
|
7
|
+
n: string;
|
|
8
|
+
c: string;
|
|
9
|
+
}>;
|
|
13
10
|
regions: string[];
|
|
14
11
|
name: string;
|
|
15
12
|
code: string;
|
|
@@ -17,4 +14,3 @@ export declare class InternalTemplateConfigFormFilterValuesControlItem extends B
|
|
|
17
14
|
render(): TemplateResult;
|
|
18
15
|
private __addRegion;
|
|
19
16
|
}
|
|
20
|
-
export {};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConfigurableMixin } from "../../../../../mixins/configurable.js";
|
|
3
|
-
import { NucleonElement } from "../../../NucleonElement/NucleonElement.js";
|
|
4
|
-
import { ThemeableMixin } from "../../../../../mixins/themeable.js";
|
|
5
|
-
import { TranslatableMixin } from "../../../../../mixins/translatable.js";
|
|
1
|
+
import { InternalControl } from "../../../../internal/InternalControl/InternalControl.js";
|
|
6
2
|
import { classMap } from "../../../../../utils/class-map.js";
|
|
7
|
-
|
|
8
|
-
export class InternalTemplateConfigFormFilterValuesControlItem extends
|
|
3
|
+
import { html } from 'lit-html';
|
|
4
|
+
export class InternalTemplateConfigFormFilterValuesControlItem extends InternalControl {
|
|
9
5
|
constructor() {
|
|
10
6
|
super(...arguments);
|
|
7
|
+
this.options = {};
|
|
11
8
|
this.regions = [];
|
|
12
9
|
this.name = '';
|
|
13
10
|
this.code = '';
|
|
@@ -17,15 +14,15 @@ export class InternalTemplateConfigFormFilterValuesControlItem extends Base {
|
|
|
17
14
|
return {
|
|
18
15
|
...super.properties,
|
|
19
16
|
__newRegion: { attribute: false },
|
|
17
|
+
options: { type: Object },
|
|
20
18
|
regions: { type: Array },
|
|
21
19
|
name: { type: String },
|
|
22
20
|
code: { type: String },
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
render() {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const filteredOptions = options.filter(region => !this.regions.includes(region.code));
|
|
24
|
+
const options = Object.values(this.options);
|
|
25
|
+
const filteredOptions = options.filter(region => !this.regions.includes(region.c));
|
|
29
26
|
return html `
|
|
30
27
|
<div
|
|
31
28
|
class=${classMap({
|
|
@@ -56,85 +53,50 @@ export class InternalTemplateConfigFormFilterValuesControlItem extends Base {
|
|
|
56
53
|
</button>
|
|
57
54
|
</div>
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
${this.regions.map(region => {
|
|
61
|
-
var _a, _b;
|
|
62
|
-
const name = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.values[region]) === null || _b === void 0 ? void 0 : _b.default;
|
|
63
|
-
const code = region;
|
|
64
|
-
return html `
|
|
65
|
-
<div class="flex items-center rounded-s border border-contrast-10 h-s m-xs">
|
|
66
|
-
<span class="mx-s">${name || code}</span>
|
|
67
|
-
|
|
68
|
-
<button
|
|
69
|
-
aria-label=${this.t('delete')}
|
|
70
|
-
class=${classMap({
|
|
71
|
-
'items-center justify-center rounded-s transition-colors': true,
|
|
72
|
-
'hover-bg-error-10 hover-text-error': !this.disabled,
|
|
73
|
-
'focus-outline-none focus-ring-2 ring-inset ring-primary-50': !this.disabled,
|
|
74
|
-
'cursor-default': this.disabled,
|
|
75
|
-
'flex': !this.readonly,
|
|
76
|
-
'hidden': this.readonly,
|
|
77
|
-
})}
|
|
78
|
-
style="width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)"
|
|
79
|
-
?disabled=${this.disabled}
|
|
80
|
-
@click=${() => {
|
|
81
|
-
this.regions = this.regions.filter(value => value !== region);
|
|
82
|
-
this.dispatchEvent(new CustomEvent('update:regions'));
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
<iron-icon icon="icons:close" class="icon-inline text-m"></iron-icon>
|
|
86
|
-
</button>
|
|
87
|
-
</div>
|
|
88
|
-
`;
|
|
89
|
-
})}
|
|
90
|
-
${filteredOptions.length === 0 && options.length !== 0
|
|
56
|
+
${options.length === 0
|
|
91
57
|
? ''
|
|
92
58
|
: html `
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
'hidden': this.readonly,
|
|
100
|
-
})}
|
|
101
|
-
>
|
|
102
|
-
${options.length === 0
|
|
103
|
-
? html `
|
|
104
|
-
<input
|
|
105
|
-
placeholder=${this.t('add_region')}
|
|
106
|
-
class="bg-transparent appearance-none h-s text-s px-s font-medium focus-outline-none"
|
|
107
|
-
style="width: 8rem"
|
|
108
|
-
.value=${this.__newRegion}
|
|
109
|
-
?disabled=${this.disabled}
|
|
110
|
-
?readonly=${this.readonly}
|
|
111
|
-
@keydown=${(evt) => {
|
|
112
|
-
if (evt.key === 'Enter' && this.__newRegion)
|
|
113
|
-
this.__addRegion();
|
|
114
|
-
}}
|
|
115
|
-
@input=${(evt) => {
|
|
116
|
-
const target = evt.currentTarget;
|
|
117
|
-
this.__newRegion = target.value;
|
|
118
|
-
}}
|
|
119
|
-
/>
|
|
59
|
+
<div data-testid="regions" class="flex flex-wrap p-xs text-s">
|
|
60
|
+
${this.regions.map(region => {
|
|
61
|
+
var _a;
|
|
62
|
+
return html `
|
|
63
|
+
<div class="flex items-center rounded-s border border-contrast-10 h-s m-xs">
|
|
64
|
+
<span class="mx-s">${((_a = this.options[region]) === null || _a === void 0 ? void 0 : _a.n) || region}</span>
|
|
120
65
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
'
|
|
125
|
-
'
|
|
126
|
-
'
|
|
127
|
-
'
|
|
128
|
-
'
|
|
129
|
-
'
|
|
66
|
+
<button
|
|
67
|
+
aria-label=${this.t('delete')}
|
|
68
|
+
class=${classMap({
|
|
69
|
+
'items-center justify-center rounded-s transition-colors': true,
|
|
70
|
+
'hover-bg-error-10 hover-text-error': !this.disabled,
|
|
71
|
+
'focus-outline-none focus-ring-2 ring-inset ring-primary-50': !this.disabled,
|
|
72
|
+
'cursor-default': this.disabled,
|
|
73
|
+
'flex': !this.readonly,
|
|
74
|
+
'hidden': this.readonly,
|
|
130
75
|
})}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
76
|
+
style="width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)"
|
|
77
|
+
?disabled=${this.disabled}
|
|
78
|
+
@click=${() => {
|
|
79
|
+
this.regions = this.regions.filter(value => value !== region);
|
|
80
|
+
this.dispatchEvent(new CustomEvent('update:regions'));
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<iron-icon icon="icons:close" class="icon-inline text-m"></iron-icon>
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
`;
|
|
87
|
+
})}
|
|
88
|
+
${filteredOptions.length === 0
|
|
89
|
+
? ''
|
|
137
90
|
: html `
|
|
91
|
+
<div
|
|
92
|
+
data-testid="new-region"
|
|
93
|
+
class=${classMap({
|
|
94
|
+
'h-s m-xs items-center transition-colors border border-contrast-10 rounded-s': true,
|
|
95
|
+
'focus-within-ring-1 ring-primary-50 focus-within-border-primary-50': !this.disabled,
|
|
96
|
+
'flex': !this.readonly,
|
|
97
|
+
'hidden': this.readonly,
|
|
98
|
+
})}
|
|
99
|
+
>
|
|
138
100
|
<select
|
|
139
101
|
class=${classMap({
|
|
140
102
|
'appearance-none bg-transparent h-s text-s px-s font-medium': true,
|
|
@@ -150,12 +112,12 @@ export class InternalTemplateConfigFormFilterValuesControlItem extends Base {
|
|
|
150
112
|
}}
|
|
151
113
|
>
|
|
152
114
|
<option value="" disabled selected>${this.t('add_region')}</option>
|
|
153
|
-
${filteredOptions.map(region => html `<option value=${region.
|
|
115
|
+
${filteredOptions.map(region => html `<option value=${region.c}>${region.n}</option>`)}
|
|
154
116
|
</select>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
117
|
+
</div>
|
|
118
|
+
`}
|
|
119
|
+
</div>
|
|
120
|
+
`}
|
|
159
121
|
</div>
|
|
160
122
|
`;
|
|
161
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalTemplateConfigFormFilterValuesControlItem.js","sourceRoot":"","sources":["../../../../../../src/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControlItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,8CAA2C;AACvE,OAAO,EAAE,cAAc,EAAE,kDAA+C;AAIxE,OAAO,EAAE,cAAc,EAAE,2CAAwC;AACjE,OAAO,EAAE,iBAAiB,EAAE,8CAA2C;AACvE,OAAO,EAAE,QAAQ,EAAE,0CAAuC;AAE1D,MAAM,IAAI,GAAG,iBAAiB,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAElF,MAAM,OAAO,iDAAkD,SAAQ,IAEtE;IAFD;;QAaE,YAAO,GAAa,EAAE,CAAC;QAEvB,SAAI,GAAG,EAAE,CAAC;QAEV,SAAI,GAAG,EAAE,CAAC;QAEF,gBAAW,GAAG,EAAE,CAAC;IAqJ3B,CAAC;IArK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BACvD,eAAe,CAAC,GAAG,CACnB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA,iBAAiB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,WAAW,CACxE;;uBAEJ;;eAER;;;KAGV,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../../../mixins/configurable';\nimport { NucleonElement } from '../../../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { ThemeableMixin } from '../../../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../../../mixins/translatable';\nimport { classMap } from '../../../../../utils/class-map';\n\nconst Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement)));\n\nexport class InternalTemplateConfigFormFilterValuesControlItem extends Base<\n Resource<Rels.Regions>\n> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newRegion: { attribute: false },\n regions: { type: Array },\n name: { type: String },\n code: { type: String },\n };\n }\n\n regions: string[] = [];\n\n name = '';\n\n code = '';\n\n private __newRegion = '';\n\n render(): TemplateResult {\n const options = Object.values(this.data?.values ?? {});\n const filteredOptions = options.filter(region => !this.regions.includes(region.code));\n\n return html`\n <div\n class=${classMap({\n 'border border-contrast-5 rounded-s font-medium overflow-hidden': true,\n 'text-disabled': this.disabled,\n })}\n >\n <div data-testid=\"country\" class=\"h-m flex justify-between items-center bg-contrast-5\">\n <div style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\">\n <span>${this.name || this.code}</span>\n </div>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'mr-xs items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => this.dispatchEvent(new CustomEvent('delete'))}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <div data-testid=\"regions\" class=\"flex flex-wrap p-xs text-s\">\n ${this.regions.map(region => {\n const name = this.data?.values[region]?.default;\n const code = region;\n\n return html`\n <div class=\"flex items-center rounded-s border border-contrast-10 h-s m-xs\">\n <span class=\"mx-s\">${name || code}</span>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'items-center justify-center rounded-s transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-primary-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => {\n this.regions = this.regions.filter(value => value !== region);\n this.dispatchEvent(new CustomEvent('update:regions'));\n }}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n `;\n })}\n ${filteredOptions.length === 0 && options.length !== 0\n ? ''\n : html`\n <div\n data-testid=\"new-region\"\n class=${classMap({\n 'h-s m-xs items-center transition-colors border border-contrast-10 rounded-s':\n true,\n 'focus-within-ring-1 ring-primary-50 focus-within-border-primary-50':\n !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n ${options.length === 0\n ? html`\n <input\n placeholder=${this.t('add_region')}\n class=\"bg-transparent appearance-none h-s text-s px-s font-medium focus-outline-none\"\n style=\"width: 8rem\"\n .value=${this.__newRegion}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.__newRegion) this.__addRegion();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.__newRegion = target.value;\n }}\n />\n\n <button\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n class=${classMap({\n 'flex-shrink-0': true,\n 'flex items-center justify-center rounded-s transition-colors': true,\n 'text-transparent cursor-default': !this.__newRegion,\n 'bg-contrast-5 text-body cursor-pointer': !!this.__newRegion,\n 'hover-bg-success hover-text-success-contrast': !!this.__newRegion,\n 'focus-outline-none focus-ring-2 ring-inset ring-primary-50':\n !!this.__newRegion,\n })}\n ?disabled=${this.disabled || !this.__newRegion}\n @click=${this.__addRegion}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n `\n : html`\n <select\n class=${classMap({\n 'appearance-none bg-transparent h-s text-s px-s font-medium': true,\n 'transition-colors rounded-s focus-outline-none': true,\n 'cursor-pointer hover-bg-contrast-5': !this.disabled,\n })}\n ?disabled=${this.disabled}\n @change=${(evt: Event) => {\n const target = evt.currentTarget as HTMLSelectElement;\n this.__newRegion = target.value;\n this.__addRegion();\n target.value = '';\n }}\n >\n <option value=\"\" disabled selected>${this.t('add_region')}</option>\n ${filteredOptions.map(\n region => html`<option value=${region.code}>${region.default}</option>`\n )}\n </select>\n `}\n </div>\n `}\n </div>\n </div>\n `;\n }\n\n private __addRegion() {\n this.regions = [...new Set([...this.regions, this.__newRegion])];\n this.__newRegion = '';\n this.dispatchEvent(new CustomEvent('update:regions'));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalTemplateConfigFormFilterValuesControlItem.js","sourceRoot":"","sources":["../../../../../../src/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/InternalTemplateConfigFormFilterValuesControlItem.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,gEAA6D;AACvF,OAAO,EAAE,QAAQ,EAAE,0CAAuC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,OAAO,iDAAkD,SAAQ,eAAe;IAAtF;;QAYE,YAAO,GAA6C,EAAE,CAAC;QAEvD,YAAO,GAAa,EAAE,CAAC;QAEvB,SAAI,GAAG,EAAE,CAAC;QAEV,SAAI,GAAG,EAAE,CAAC;QAEF,gBAAW,GAAG,EAAE,CAAC;IAkH3B,CAAC;IArIC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,WAAW,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YACjC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACzB,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACtB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SACvB,CAAC;IACJ,CAAC;IAYD,MAAM;QACJ,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnF,OAAO,IAAI,CAAA;;gBAEC,QAAQ,CAAC;YACf,gEAAgE,EAAE,IAAI;YACtE,eAAe,EAAE,IAAI,CAAC,QAAQ;SAC/B,CAAC;;;;oBAIU,IAAI,CAA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AC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\n\nimport { InternalControl } from '../../../../internal/InternalControl/InternalControl';\nimport { classMap } from '../../../../../utils/class-map';\nimport { html } from 'lit-html';\n\nexport class InternalTemplateConfigFormFilterValuesControlItem extends InternalControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newRegion: { attribute: false },\n options: { type: Object },\n regions: { type: Array },\n name: { type: String },\n code: { type: String },\n };\n }\n\n options: Record<string, { n: string; c: string }> = {};\n\n regions: string[] = [];\n\n name = '';\n\n code = '';\n\n private __newRegion = '';\n\n render(): TemplateResult {\n const options = Object.values(this.options);\n const filteredOptions = options.filter(region => !this.regions.includes(region.c));\n\n return html`\n <div\n class=${classMap({\n 'border border-contrast-5 rounded-s font-medium overflow-hidden': true,\n 'text-disabled': this.disabled,\n })}\n >\n <div data-testid=\"country\" class=\"h-m flex justify-between items-center bg-contrast-5\">\n <div style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\">\n <span>${this.name || this.code}</span>\n </div>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'mr-xs items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => this.dispatchEvent(new CustomEvent('delete'))}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n ${options.length === 0\n ? ''\n : html`\n <div data-testid=\"regions\" class=\"flex flex-wrap p-xs text-s\">\n ${this.regions.map(region => {\n return html`\n <div class=\"flex items-center rounded-s border border-contrast-10 h-s m-xs\">\n <span class=\"mx-s\">${this.options[region]?.n || region}</span>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'items-center justify-center rounded-s transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-primary-50':\n !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => {\n this.regions = this.regions.filter(value => value !== region);\n this.dispatchEvent(new CustomEvent('update:regions'));\n }}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n `;\n })}\n ${filteredOptions.length === 0\n ? ''\n : html`\n <div\n data-testid=\"new-region\"\n class=${classMap({\n 'h-s m-xs items-center transition-colors border border-contrast-10 rounded-s':\n true,\n 'focus-within-ring-1 ring-primary-50 focus-within-border-primary-50':\n !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n <select\n class=${classMap({\n 'appearance-none bg-transparent h-s text-s px-s font-medium': true,\n 'transition-colors rounded-s focus-outline-none': true,\n 'cursor-pointer hover-bg-contrast-5': !this.disabled,\n })}\n ?disabled=${this.disabled}\n @change=${(evt: Event) => {\n const target = evt.currentTarget as HTMLSelectElement;\n this.__newRegion = target.value;\n this.__addRegion();\n target.value = '';\n }}\n >\n <option value=\"\" disabled selected>${this.t('add_region')}</option>\n ${filteredOptions.map(\n region => html`<option value=${region.c}>${region.n}</option>`\n )}\n </select>\n </div>\n `}\n </div>\n `}\n </div>\n `;\n }\n\n private __addRegion() {\n this.regions = [...new Set([...this.regions, this.__newRegion])];\n this.__newRegion = '';\n this.dispatchEvent(new CustomEvent('update:regions'));\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '../../../../internal/InternalEditableControl/index';
|
|
2
|
+
import '../../../../internal/InternalControl/index';
|
|
2
3
|
import '../../../NucleonElement/index';
|
|
3
4
|
import { InternalTemplateConfigFormFilterValuesControl } from './InternalTemplateConfigFormFilterValuesControl';
|
|
4
5
|
export { InternalTemplateConfigFormFilterValuesControl };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../../../../internal/InternalEditableControl/index.js";
|
|
2
|
+
import "../../../../internal/InternalControl/index.js";
|
|
2
3
|
import "../../../NucleonElement/index.js";
|
|
3
4
|
import { InternalTemplateConfigFormFilterValuesControlItem } from "./InternalTemplateConfigFormFilterValuesControlItem.js";
|
|
4
5
|
import { InternalTemplateConfigFormFilterValuesControl } from "./InternalTemplateConfigFormFilterValuesControl.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/index.ts"],"names":[],"mappings":"AAAA,+DAA4D;AAC5D,0CAAuC;AAEvC,OAAO,EAAE,iDAAiD,EAAE,+DAA4D;AACxH,OAAO,EAAE,6CAA6C,EAAE,2DAAwD;AAEhH,cAAc,CAAC,MAAM,CACnB,+DAA+D,EAC/D,iDAAiD,CAClD,CAAC;AAEF,cAAc,CAAC,MAAM,CACnB,0DAA0D,EAC1D,6CAA6C,CAC9C,CAAC;AAEF,OAAO,EAAE,6CAA6C,EAAE,CAAC","sourcesContent":["import '../../../../internal/InternalEditableControl/index';\nimport '../../../NucleonElement/index';\n\nimport { InternalTemplateConfigFormFilterValuesControlItem } from './InternalTemplateConfigFormFilterValuesControlItem';\nimport { InternalTemplateConfigFormFilterValuesControl } from './InternalTemplateConfigFormFilterValuesControl';\n\ncustomElements.define(\n 'foxy-internal-template-config-form-filter-values-control-item',\n InternalTemplateConfigFormFilterValuesControlItem\n);\n\ncustomElements.define(\n 'foxy-internal-template-config-form-filter-values-control',\n InternalTemplateConfigFormFilterValuesControl\n);\n\nexport { InternalTemplateConfigFormFilterValuesControl };\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/elements/public/TemplateConfigForm/internal/InternalTemplateConfigFormFilterValuesControl/index.ts"],"names":[],"mappings":"AAAA,+DAA4D;AAC5D,uDAAoD;AACpD,0CAAuC;AAEvC,OAAO,EAAE,iDAAiD,EAAE,+DAA4D;AACxH,OAAO,EAAE,6CAA6C,EAAE,2DAAwD;AAEhH,cAAc,CAAC,MAAM,CACnB,+DAA+D,EAC/D,iDAAiD,CAClD,CAAC;AAEF,cAAc,CAAC,MAAM,CACnB,0DAA0D,EAC1D,6CAA6C,CAC9C,CAAC;AAEF,OAAO,EAAE,6CAA6C,EAAE,CAAC","sourcesContent":["import '../../../../internal/InternalEditableControl/index';\nimport '../../../../internal/InternalControl/index';\nimport '../../../NucleonElement/index';\n\nimport { InternalTemplateConfigFormFilterValuesControlItem } from './InternalTemplateConfigFormFilterValuesControlItem';\nimport { InternalTemplateConfigFormFilterValuesControl } from './InternalTemplateConfigFormFilterValuesControl';\n\ncustomElements.define(\n 'foxy-internal-template-config-form-filter-values-control-item',\n InternalTemplateConfigFormFilterValuesControlItem\n);\n\ncustomElements.define(\n 'foxy-internal-template-config-form-filter-values-control',\n InternalTemplateConfigFormFilterValuesControl\n);\n\nexport { InternalTemplateConfigFormFilterValuesControl };\n"]}
|