@foxy.io/elements 1.32.0-beta.2 → 1.32.0-beta.3
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-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -64
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/shared-f1b29592.js +64 -0
- package/dist/cdn/translations/coupon-form/en.json +8 -52
- package/dist/elements/internal/InternalArrayMapControl/InternalArrayMapControl.d.ts +12 -0
- package/dist/elements/internal/InternalArrayMapControl/InternalArrayMapControl.js +277 -0
- package/dist/elements/internal/InternalArrayMapControl/InternalArrayMapControl.js.map +1 -0
- package/dist/elements/internal/InternalArrayMapControl/index.d.ts +4 -0
- package/dist/elements/internal/InternalArrayMapControl/index.js +6 -0
- package/dist/elements/internal/InternalArrayMapControl/index.js.map +1 -0
- package/dist/elements/public/CouponForm/CouponForm.d.ts +2 -3
- package/dist/elements/public/CouponForm/CouponForm.js +51 -25
- package/dist/elements/public/CouponForm/CouponForm.js.map +1 -1
- package/dist/elements/public/CouponForm/index.d.ts +1 -0
- package/dist/elements/public/CouponForm/index.js +1 -0
- package/dist/elements/public/CouponForm/index.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/parse.js +3 -1
- package/dist/elements/public/QueryBuilder/utils/parse.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/stringify.js +10 -3
- package/dist/elements/public/QueryBuilder/utils/stringify.js.map +1 -1
- package/dist/elements/public/Transaction/index.d.ts +1 -0
- package/dist/elements/public/Transaction/index.js +1 -0
- package/dist/elements/public/Transaction/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
2
2
|
import { ResponsiveMixin } from "../../../mixins/responsive.js";
|
|
3
3
|
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
4
|
-
import { Operator, Type } from "../QueryBuilder/types.js";
|
|
5
4
|
import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
|
|
6
5
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
6
|
+
import { Type } from "../QueryBuilder/types.js";
|
|
7
7
|
import { html } from 'lit-html';
|
|
8
|
+
import { parse } from "../QueryBuilder/utils/parse.js";
|
|
9
|
+
import { stringify } from "../QueryBuilder/utils/stringify.js";
|
|
8
10
|
const NS = 'coupon-form';
|
|
9
11
|
const Base = ResponsiveMixin(TranslatableMixin(InternalForm, NS));
|
|
10
12
|
/**
|
|
@@ -17,6 +19,50 @@ export class CouponForm extends Base {
|
|
|
17
19
|
constructor() {
|
|
18
20
|
super(...arguments);
|
|
19
21
|
this.getTransactionPageHref = null;
|
|
22
|
+
this.__customerAttributeRestrictionsGetValue = () => {
|
|
23
|
+
var _a;
|
|
24
|
+
const params = new URLSearchParams(stringify(parse((_a = this.form.customer_attribute_restrictions) !== null && _a !== void 0 ? _a : '')
|
|
25
|
+
.filter(value => Array.isArray(value) || typeof value.name === 'string')
|
|
26
|
+
.map(value => {
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
return value
|
|
29
|
+
.filter(({ name }) => typeof name === 'string')
|
|
30
|
+
.map(({ name, operator, value }) => {
|
|
31
|
+
const output = { path: name, operator, value };
|
|
32
|
+
return output;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const output = {
|
|
36
|
+
operator: value.operator,
|
|
37
|
+
value: value.value,
|
|
38
|
+
path: value.name,
|
|
39
|
+
};
|
|
40
|
+
return output;
|
|
41
|
+
})));
|
|
42
|
+
params.delete('zoom');
|
|
43
|
+
return params.toString();
|
|
44
|
+
};
|
|
45
|
+
this.__customerAttributeRestrictionsSetValue = (newValue) => {
|
|
46
|
+
const params = new URLSearchParams(stringify(parse(newValue).map(value => {
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
return value.map(({ path, operator, value }) => {
|
|
49
|
+
const output = { name: path, path: 'attributes', operator, value };
|
|
50
|
+
return output;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const output = {
|
|
55
|
+
operator: value.operator,
|
|
56
|
+
value: value.value,
|
|
57
|
+
path: 'attributes',
|
|
58
|
+
name: value.path,
|
|
59
|
+
};
|
|
60
|
+
return output;
|
|
61
|
+
}
|
|
62
|
+
})));
|
|
63
|
+
params.delete('zoom');
|
|
64
|
+
this.edit({ customer_attribute_restrictions: params.toString() });
|
|
65
|
+
};
|
|
20
66
|
this.__customerSubscriptionRestrictionsGetValue = () => {
|
|
21
67
|
var _a;
|
|
22
68
|
const items = (_a = this.form.customer_subscription_restrictions) === null || _a === void 0 ? void 0 : _a.split(',').map(value => value.trim()).filter((value, index, values) => !!value && values.indexOf(value) === index).map(value => ({ value }));
|
|
@@ -51,22 +97,6 @@ export class CouponForm extends Base {
|
|
|
51
97
|
.join(','),
|
|
52
98
|
});
|
|
53
99
|
};
|
|
54
|
-
this.__itemOptionRestrictionsOperators = [Operator.In];
|
|
55
|
-
this.__itemOptionRestrictionsGetValue = () => {
|
|
56
|
-
var _a;
|
|
57
|
-
const query = new URLSearchParams();
|
|
58
|
-
const rules = (_a = this.form.item_option_restrictions) !== null && _a !== void 0 ? _a : {};
|
|
59
|
-
for (const key in rules) {
|
|
60
|
-
query.set(`${key}:in`, rules[key].join(','));
|
|
61
|
-
}
|
|
62
|
-
return query.toString();
|
|
63
|
-
};
|
|
64
|
-
this.__itemOptionRestrictionsSetValue = (newValue) => {
|
|
65
|
-
const rules = Object.fromEntries(Array.from(new URLSearchParams(newValue).entries()).map(([key, value]) => {
|
|
66
|
-
return [key.replace(':in', ''), value.split(',').filter(v => !!v.trim())];
|
|
67
|
-
}));
|
|
68
|
-
this.edit({ item_option_restrictions: rules });
|
|
69
|
-
};
|
|
70
100
|
this.__storeLoaderId = 'storeLoader';
|
|
71
101
|
this.__codesFilters = [
|
|
72
102
|
{ label: 'code', path: 'code', type: Type.String },
|
|
@@ -212,19 +242,15 @@ export class CouponForm extends Base {
|
|
|
212
242
|
>
|
|
213
243
|
</foxy-internal-editable-list-control>
|
|
214
244
|
|
|
215
|
-
<foxy-internal-
|
|
216
|
-
|
|
217
|
-
disable-or
|
|
218
|
-
.operators=${this.__itemOptionRestrictionsOperators}
|
|
219
|
-
.getValue=${this.__itemOptionRestrictionsGetValue}
|
|
220
|
-
.setValue=${this.__itemOptionRestrictionsSetValue}
|
|
221
|
-
>
|
|
222
|
-
</foxy-internal-query-builder-control>
|
|
245
|
+
<foxy-internal-array-map-control infer="item-option-restrictions">
|
|
246
|
+
</foxy-internal-array-map-control>
|
|
223
247
|
|
|
224
248
|
<foxy-internal-summary-control infer="customer-restrictions">
|
|
225
249
|
<foxy-internal-query-builder-control
|
|
226
250
|
layout="summary-item"
|
|
227
251
|
infer="customer-attribute-restrictions"
|
|
252
|
+
.getValue=${this.__customerAttributeRestrictionsGetValue}
|
|
253
|
+
.setValue=${this.__customerAttributeRestrictionsSetValue}
|
|
228
254
|
>
|
|
229
255
|
</foxy-internal-query-builder-control>
|
|
230
256
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CouponForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponForm/CouponForm.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,iCAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,aAAa,CAAC;AACzB,MAAM,I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,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,2BAA2B,EAAE,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA8DnE,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC;;;;;;;;;QAS1D,KAAK,CAAC,UAAU,EAAE;;;;;eAKX,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC;aAC/C,IAAI,CAAC,eAAe;kBACf,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;;;KAGvC,CAAC;IACJ,CAAC;IAED,IAAY,aAAa;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { TemplateResult, PropertyDeclarations } from 'lit-element';\nimport type { Data, TransactionPageHrefGetter } from './types';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { SwipeAction } from '../../internal/InternalAsyncListControl/types';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Option } from '../QueryBuilder/types';\nimport type { Item } from '../../internal/InternalEditableListControl/types';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { Operator, Type } from '../QueryBuilder/types';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'coupon-form';\nconst Base = ResponsiveMixin(TranslatableMixin(InternalForm, NS));\n\n/**\n * Form element for creating or editing coupons (`fx:coupon`).\n *\n * @element foxy-coupon-form\n * @since 1.15.0\n */\nexport class CouponForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getTransactionPageHref: { attribute: false },\n __couponCodesActions: { type: Array },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ name: v }) => !!v || 'name:v8n_required',\n ({ name: v }) => !v || v.length <= 50 || 'name:v8n_too_long',\n ({ inclusive_tax_rate: v }) => !v || v >= 0 || 'inclusive-tax-rate:v8n_too_small',\n ({ inclusive_tax_rate: v }) => !v || v <= 1 || 'inclusive-tax-rate:v8n_too_big',\n ({ number_of_uses_allowed: v }) => !v || v >= 0 || 'number-of-uses-allowed:v8n_too_small',\n ({ coupon_discount_details: v }) => !!v || 'rules:v8n_required',\n ({ coupon_discount_details: v }) => !v || v.length <= 200 || 'rules:v8n_too_long',\n ({ item_option_restrictions: v }) => {\n return !v || JSON.stringify(v).length <= 6000 || 'item-option-restrictions:v8n_too_long';\n },\n ({ product_code_restrictions: v }) => {\n return !v || v.length <= 5000 || 'product-code-restrictions:v8n_too_long';\n },\n ({ customer_attribute_restrictions: v }) => {\n return !v || v.length <= 2000 || 'customer-attribute-restrictions:v8n_too_long';\n },\n ({ number_of_uses_allowed_per_code: v }) => {\n return !v || v >= 0 || 'number-of-uses-allowed-per-code:v8n_too_small';\n },\n ({ customer_subscription_restrictions: v }) => {\n return !v || v.length <= 200 || 'customer-subscription-restrictions:v8n_too_long';\n },\n ({ number_of_uses_allowed_per_customer: v }) => {\n return !v || v >= 0 || 'number-of-uses-allowed-per-customer:v8n_too_small';\n },\n ];\n }\n\n getTransactionPageHref: TransactionPageHrefGetter | null = null;\n\n private readonly __customerSubscriptionRestrictionsGetValue = () => {\n const items = this.form.customer_subscription_restrictions\n ?.split(',')\n .map(value => value.trim())\n .filter((value, index, values) => !!value && values.indexOf(value) === index)\n .map(value => ({ value }));\n\n return items ?? [];\n };\n\n private readonly __customerSubscriptionRestrictionsSetValue = (newValue: Item[]) => {\n this.edit({\n customer_subscription_restrictions: newValue\n .map(({ value }) => value.trim())\n .filter((value, index, values) => !!value && values.indexOf(value) === index)\n .join(),\n });\n\n this.edit({\n customer_auto_apply:\n !!this.form.customer_subscription_restrictions ||\n !!this.form.customer_attribute_restrictions,\n });\n };\n\n private readonly __productCodeRestrictionsGetValue = () => {\n return this.form.product_code_restrictions\n ?.split(',')\n .filter(v => !!v.trim())\n .map(value => ({\n value,\n label: value.startsWith('-')\n ? this.t(`product-code-restrictions.label_block`, { value: value.substring(1) })\n : this.t(`product-code-restrictions.label_allow`, { value }),\n }));\n };\n\n private readonly __productCodeRestrictionsSetValue = (newValue: Item[]) => {\n this.edit({\n product_code_restrictions: newValue\n .map(({ value, unit }) => (unit === 'block' ? `-${value}` : value))\n .filter((v, i, a) => !!v && a.indexOf(v) === i)\n .join(','),\n });\n };\n\n private readonly __itemOptionRestrictionsOperators = [Operator.In];\n\n private readonly __itemOptionRestrictionsGetValue = () => {\n const query = new URLSearchParams();\n const rules = this.form.item_option_restrictions ?? {};\n\n for (const key in rules) {\n query.set(`${key}:in`, rules[key].join(','));\n }\n\n return query.toString();\n };\n\n private readonly __itemOptionRestrictionsSetValue = (newValue: string) => {\n const rules = Object.fromEntries(\n Array.from(new URLSearchParams(newValue).entries()).map(([key, value]) => {\n return [key.replace(':in', ''), value.split(',').filter(v => !!v.trim())];\n })\n );\n\n this.edit({ item_option_restrictions: rules });\n };\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __codesFilters: Option[] = [\n { label: 'code', path: 'code', type: Type.String },\n { label: 'used_codes', path: 'number_of_uses_to_date', type: Type.Number },\n { label: 'date_created', path: 'date_created', type: Type.Date },\n { label: 'date_modified', path: 'date_modified', type: Type.Date },\n ];\n\n private __couponCodesActions: SwipeAction<Resource<Rels.CouponCode>>[] = [\n {\n theme: 'contrast',\n state: 'idle',\n text: 'copy_button_text',\n onClick: async data => {\n this.__couponCodesActions[0].state = 'busy';\n this.__couponCodesActions = [...this.__couponCodesActions];\n\n try {\n await navigator.clipboard.writeText(data.code);\n this.__couponCodesActions[0].state = 'end';\n } catch {\n this.__couponCodesActions[0].state = 'error';\n } finally {\n this.__couponCodesActions = [...this.__couponCodesActions];\n setTimeout(() => {\n this.__couponCodesActions[0].state = 'idle';\n this.__couponCodesActions = [...this.__couponCodesActions];\n }, 1000);\n }\n },\n },\n ];\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n\n if (!this.data) {\n alwaysMatch.push('coupon-codes', 'category-restrictions', 'attributes');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n return { ...super.headerSubtitleOptions, id: this.headerCopyIdValue };\n }\n\n renderHeaderActions(data: Data): TemplateResult {\n return html`\n <foxy-internal-bulk-add-action-control\n parent=${data._links['fx:generate_codes'].href}\n infer=\"generate\"\n form=\"foxy-generate-codes-form\"\n .related=${[data._links['fx:coupon_codes'].href]}\n >\n </foxy-internal-bulk-add-action-control>\n\n <foxy-internal-bulk-add-action-control\n parent=${data._links['fx:coupon_codes'].href}\n infer=\"import\"\n form=\"foxy-coupon-codes-form\"\n .related=${[data._links['fx:coupon_codes'].href]}\n >\n </foxy-internal-bulk-add-action-control>\n\n ${super.renderHeaderActions(data)}\n `;\n }\n\n renderBody(): TemplateResult {\n let codesUrl: string | undefined;\n\n try {\n const url = new URL(this.data?._links['fx:coupon_codes'].href ?? '');\n url.searchParams.set('order', 'date_created desc');\n\n codesUrl = url.toString();\n } catch {\n codesUrl = undefined;\n }\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"name\"></foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-coupon-form-rules-control infer=\"rules\">\n </foxy-internal-coupon-form-rules-control>\n\n <foxy-internal-async-list-control\n first=${codesUrl}\n limit=\"5\"\n infer=\"coupon-codes\"\n item=\"foxy-coupon-code-card\"\n form=\"foxy-coupon-code-form\"\n alert\n .formProps=${{ '.getTransactionPageHref': this.getTransactionPageHref }}\n .actions=${this.__couponCodesActions}\n .filters=${this.__codesFilters}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-editable-list-control\n infer=\"product-code-restrictions\"\n .getValue=${this.__productCodeRestrictionsGetValue}\n .setValue=${this.__productCodeRestrictionsSetValue}\n .units=${[\n { label: this.t('product-code-restrictions.unit_allow'), value: 'allow' },\n { label: this.t('product-code-restrictions.unit_block'), value: 'block' },\n ]}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-query-builder-control\n infer=\"item-option-restrictions\"\n disable-or\n .operators=${this.__itemOptionRestrictionsOperators}\n .getValue=${this.__itemOptionRestrictionsGetValue}\n .setValue=${this.__itemOptionRestrictionsSetValue}\n >\n </foxy-internal-query-builder-control>\n\n <foxy-internal-summary-control infer=\"customer-restrictions\">\n <foxy-internal-query-builder-control\n layout=\"summary-item\"\n infer=\"customer-attribute-restrictions\"\n >\n </foxy-internal-query-builder-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"customer-subscription-restrictions\"\n .getValue=${this.__customerSubscriptionRestrictionsGetValue}\n .setValue=${this.__customerSubscriptionRestrictionsSetValue}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-switch-control infer=\"customer-auto-apply\"></foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-resource-link-list-control\n foreign-key-for-uri=\"item_category_uri\"\n foreign-key-for-id=\"item_category_id\"\n own-key-for-uri=\"coupon_uri\"\n own-uri=${ifDefined(this.data?._links.self.href)}\n embed-key=\"fx:coupon_item_categories\"\n options-href=${ifDefined(this.__storeLoader?.data?._links['fx:item_categories'].href)}\n links-href=${ifDefined(this.data?._links['fx:coupon_item_categories'].href)}\n infer=\"category-restrictions\"\n limit=\"5\"\n item=\"foxy-item-category-card\"\n >\n </foxy-internal-async-resource-link-list-control>\n\n <foxy-internal-summary-control infer=\"uses\">\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"number-of-uses-allowed\"\n step=\"1\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"number-of-uses-allowed-per-customer\"\n step=\"1\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"number-of-uses-allowed-per-code\"\n step=\"1\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"timeframe\">\n <foxy-internal-date-control layout=\"summary-item\" infer=\"start-date\">\n </foxy-internal-date-control>\n <foxy-internal-date-control layout=\"summary-item\" infer=\"end-date\">\n </foxy-internal-date-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"taxes\">\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"inclusive-tax-rate\"\n min=\"0\"\n max=\"1\"\n >\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"options\">\n <foxy-internal-switch-control infer=\"multiple-codes-allowed\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"combinable\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"exclude-category-discounts\">\n </foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"exclude-line-item-discounts\">\n </foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"is-taxable\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"shared-codes-allowed\"></foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n first=${ifDefined(this.data?._links['fx:attributes'].href)}\n limit=\"5\"\n infer=\"attributes\"\n item=\"foxy-attribute-card\"\n form=\"foxy-attribute-form\"\n alert\n >\n </foxy-internal-async-list-control>\n\n ${super.renderBody()}\n\n <foxy-nucleon\n infer=\"\"\n class=\"hidden\"\n href=${ifDefined(this.data?._links['fx:store'].href)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CouponForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponForm/CouponForm.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,iCAA8B;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,uCAAoC;AACpD,OAAO,EAAE,SAAS,EAAE,2CAAwC;AAE5D,MAAM,EAAE,GAAG,aAAa,CAAC;AACzB,MAAM,IAAI,GAAG,eAAe,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAElE;;;;;GAKG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAU;IAA1C;;QAuCE,2BAAsB,GAAqC,IAAI,CAAC;QAE/C,4CAAuC,GAAG,GAAG,EAAE;;YAC9D,MAAM,MAAM,GAAG,IAAI,eAAe,CAChC,SAAS,CACP,KAAK,OAAC,IAAI,CAAC,IAAI,CAAC,+BAA+B,mCAAI,EAAE,CAAC;iBACnD,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;iBACvE,GAAG,CAAC,KAAK,CAAC,EAAE;gBACX,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CA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AAO,EAAE;SAC1E;;;;;;;;;;;sBAWa,IAAI,CAAC,uCAAuC;sBAC5C,IAAI,CAAC,uCAAuC;;;;;;;sBAO5C,IAAI,CAAC,0CAA0C;sBAC/C,IAAI,CAAC,0CAA0C;;;;;;;;;;;kBAWnD,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;uBAEjC,SAAS,aAAC,IAAI,CAAC,aAAa,0CAAE,IAAI,0CAAE,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC;qBACxE,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,2BAA2B,EAAE,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA8DnE,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC;;;;;;;;;QAS1D,KAAK,CAAC,UAAU,EAAE;;;;;eAKX,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC;aAC/C,IAAI,CAAC,eAAe;kBACf,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;;;KAGvC,CAAC;IACJ,CAAC;IAED,IAAY,aAAa;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { TemplateResult, PropertyDeclarations } from 'lit-element';\nimport type { Data, TransactionPageHrefGetter } from './types';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { SwipeAction } from '../../internal/InternalAsyncListControl/types';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Option, ParsedValue } from '../QueryBuilder/types';\nimport type { Item } from '../../internal/InternalEditableListControl/types';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { Type } from '../QueryBuilder/types';\nimport { html } from 'lit-html';\nimport { parse } from '../QueryBuilder/utils/parse';\nimport { stringify } from '../QueryBuilder/utils/stringify';\n\nconst NS = 'coupon-form';\nconst Base = ResponsiveMixin(TranslatableMixin(InternalForm, NS));\n\n/**\n * Form element for creating or editing coupons (`fx:coupon`).\n *\n * @element foxy-coupon-form\n * @since 1.15.0\n */\nexport class CouponForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getTransactionPageHref: { attribute: false },\n __couponCodesActions: { type: Array },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ name: v }) => !!v || 'name:v8n_required',\n ({ name: v }) => !v || v.length <= 50 || 'name:v8n_too_long',\n ({ inclusive_tax_rate: v }) => !v || v >= 0 || 'inclusive-tax-rate:v8n_too_small',\n ({ inclusive_tax_rate: v }) => !v || v <= 1 || 'inclusive-tax-rate:v8n_too_big',\n ({ number_of_uses_allowed: v }) => !v || v >= 0 || 'number-of-uses-allowed:v8n_too_small',\n ({ coupon_discount_details: v }) => !!v || 'rules:v8n_required',\n ({ coupon_discount_details: v }) => !v || v.length <= 200 || 'rules:v8n_too_long',\n ({ item_option_restrictions: v }) => {\n return !v || JSON.stringify(v).length <= 6000 || 'item-option-restrictions:v8n_too_long';\n },\n ({ product_code_restrictions: v }) => {\n return !v || v.length <= 5000 || 'product-code-restrictions:v8n_too_long';\n },\n ({ customer_attribute_restrictions: v }) => {\n return !v || v.length <= 2000 || 'customer-attribute-restrictions:v8n_too_long';\n },\n ({ number_of_uses_allowed_per_code: v }) => {\n return !v || v >= 0 || 'number-of-uses-allowed-per-code:v8n_too_small';\n },\n ({ customer_subscription_restrictions: v }) => {\n return !v || v.length <= 200 || 'customer-subscription-restrictions:v8n_too_long';\n },\n ({ number_of_uses_allowed_per_customer: v }) => {\n return !v || v >= 0 || 'number-of-uses-allowed-per-customer:v8n_too_small';\n },\n ];\n }\n\n getTransactionPageHref: TransactionPageHrefGetter | null = null;\n\n private readonly __customerAttributeRestrictionsGetValue = () => {\n const params = new URLSearchParams(\n stringify(\n parse(this.form.customer_attribute_restrictions ?? '')\n .filter(value => Array.isArray(value) || typeof value.name === 'string')\n .map(value => {\n if (Array.isArray(value)) {\n return value\n .filter(({ name }) => typeof name === 'string')\n .map(({ name, operator, value }) => {\n const output: ParsedValue = { path: name as string, operator, value };\n return output;\n });\n }\n\n const output: ParsedValue = {\n operator: value.operator,\n value: value.value,\n path: value.name as string,\n };\n\n return output;\n })\n )\n );\n\n params.delete('zoom');\n return params.toString();\n };\n\n private readonly __customerAttributeRestrictionsSetValue = (newValue: string) => {\n const params = new URLSearchParams(\n stringify(\n parse(newValue).map(value => {\n if (Array.isArray(value)) {\n return value.map(({ path, operator, value }) => {\n const output: ParsedValue = { name: path, path: 'attributes', operator, value };\n return output;\n });\n } else {\n const output: ParsedValue = {\n operator: value.operator,\n value: value.value,\n path: 'attributes',\n name: value.path,\n };\n\n return output;\n }\n })\n )\n );\n\n params.delete('zoom');\n this.edit({ customer_attribute_restrictions: params.toString() });\n };\n\n private readonly __customerSubscriptionRestrictionsGetValue = () => {\n const items = this.form.customer_subscription_restrictions\n ?.split(',')\n .map(value => value.trim())\n .filter((value, index, values) => !!value && values.indexOf(value) === index)\n .map(value => ({ value }));\n\n return items ?? [];\n };\n\n private readonly __customerSubscriptionRestrictionsSetValue = (newValue: Item[]) => {\n this.edit({\n customer_subscription_restrictions: newValue\n .map(({ value }) => value.trim())\n .filter((value, index, values) => !!value && values.indexOf(value) === index)\n .join(),\n });\n\n this.edit({\n customer_auto_apply:\n !!this.form.customer_subscription_restrictions ||\n !!this.form.customer_attribute_restrictions,\n });\n };\n\n private readonly __productCodeRestrictionsGetValue = () => {\n return this.form.product_code_restrictions\n ?.split(',')\n .filter(v => !!v.trim())\n .map(value => ({\n value,\n label: value.startsWith('-')\n ? this.t(`product-code-restrictions.label_block`, { value: value.substring(1) })\n : this.t(`product-code-restrictions.label_allow`, { value }),\n }));\n };\n\n private readonly __productCodeRestrictionsSetValue = (newValue: Item[]) => {\n this.edit({\n product_code_restrictions: newValue\n .map(({ value, unit }) => (unit === 'block' ? `-${value}` : value))\n .filter((v, i, a) => !!v && a.indexOf(v) === i)\n .join(','),\n });\n };\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __codesFilters: Option[] = [\n { label: 'code', path: 'code', type: Type.String },\n { label: 'used_codes', path: 'number_of_uses_to_date', type: Type.Number },\n { label: 'date_created', path: 'date_created', type: Type.Date },\n { label: 'date_modified', path: 'date_modified', type: Type.Date },\n ];\n\n private __couponCodesActions: SwipeAction<Resource<Rels.CouponCode>>[] = [\n {\n theme: 'contrast',\n state: 'idle',\n text: 'copy_button_text',\n onClick: async data => {\n this.__couponCodesActions[0].state = 'busy';\n this.__couponCodesActions = [...this.__couponCodesActions];\n\n try {\n await navigator.clipboard.writeText(data.code);\n this.__couponCodesActions[0].state = 'end';\n } catch {\n this.__couponCodesActions[0].state = 'error';\n } finally {\n this.__couponCodesActions = [...this.__couponCodesActions];\n setTimeout(() => {\n this.__couponCodesActions[0].state = 'idle';\n this.__couponCodesActions = [...this.__couponCodesActions];\n }, 1000);\n }\n },\n },\n ];\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n\n if (!this.data) {\n alwaysMatch.push('coupon-codes', 'category-restrictions', 'attributes');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n return { ...super.headerSubtitleOptions, id: this.headerCopyIdValue };\n }\n\n renderHeaderActions(data: Data): TemplateResult {\n return html`\n <foxy-internal-bulk-add-action-control\n parent=${data._links['fx:generate_codes'].href}\n infer=\"generate\"\n form=\"foxy-generate-codes-form\"\n .related=${[data._links['fx:coupon_codes'].href]}\n >\n </foxy-internal-bulk-add-action-control>\n\n <foxy-internal-bulk-add-action-control\n parent=${data._links['fx:coupon_codes'].href}\n infer=\"import\"\n form=\"foxy-coupon-codes-form\"\n .related=${[data._links['fx:coupon_codes'].href]}\n >\n </foxy-internal-bulk-add-action-control>\n\n ${super.renderHeaderActions(data)}\n `;\n }\n\n renderBody(): TemplateResult {\n let codesUrl: string | undefined;\n\n try {\n const url = new URL(this.data?._links['fx:coupon_codes'].href ?? '');\n url.searchParams.set('order', 'date_created desc');\n\n codesUrl = url.toString();\n } catch {\n codesUrl = undefined;\n }\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"name\"></foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-coupon-form-rules-control infer=\"rules\">\n </foxy-internal-coupon-form-rules-control>\n\n <foxy-internal-async-list-control\n first=${codesUrl}\n limit=\"5\"\n infer=\"coupon-codes\"\n item=\"foxy-coupon-code-card\"\n form=\"foxy-coupon-code-form\"\n alert\n .formProps=${{ '.getTransactionPageHref': this.getTransactionPageHref }}\n .actions=${this.__couponCodesActions}\n .filters=${this.__codesFilters}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-editable-list-control\n infer=\"product-code-restrictions\"\n .getValue=${this.__productCodeRestrictionsGetValue}\n .setValue=${this.__productCodeRestrictionsSetValue}\n .units=${[\n { label: this.t('product-code-restrictions.unit_allow'), value: 'allow' },\n { label: this.t('product-code-restrictions.unit_block'), value: 'block' },\n ]}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-array-map-control infer=\"item-option-restrictions\">\n </foxy-internal-array-map-control>\n\n <foxy-internal-summary-control infer=\"customer-restrictions\">\n <foxy-internal-query-builder-control\n layout=\"summary-item\"\n infer=\"customer-attribute-restrictions\"\n .getValue=${this.__customerAttributeRestrictionsGetValue}\n .setValue=${this.__customerAttributeRestrictionsSetValue}\n >\n </foxy-internal-query-builder-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"customer-subscription-restrictions\"\n .getValue=${this.__customerSubscriptionRestrictionsGetValue}\n .setValue=${this.__customerSubscriptionRestrictionsSetValue}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-switch-control infer=\"customer-auto-apply\"></foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-resource-link-list-control\n foreign-key-for-uri=\"item_category_uri\"\n foreign-key-for-id=\"item_category_id\"\n own-key-for-uri=\"coupon_uri\"\n own-uri=${ifDefined(this.data?._links.self.href)}\n embed-key=\"fx:coupon_item_categories\"\n options-href=${ifDefined(this.__storeLoader?.data?._links['fx:item_categories'].href)}\n links-href=${ifDefined(this.data?._links['fx:coupon_item_categories'].href)}\n infer=\"category-restrictions\"\n limit=\"5\"\n item=\"foxy-item-category-card\"\n >\n </foxy-internal-async-resource-link-list-control>\n\n <foxy-internal-summary-control infer=\"uses\">\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"number-of-uses-allowed\"\n step=\"1\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"number-of-uses-allowed-per-customer\"\n step=\"1\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"number-of-uses-allowed-per-code\"\n step=\"1\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"timeframe\">\n <foxy-internal-date-control layout=\"summary-item\" infer=\"start-date\">\n </foxy-internal-date-control>\n <foxy-internal-date-control layout=\"summary-item\" infer=\"end-date\">\n </foxy-internal-date-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"taxes\">\n <foxy-internal-number-control\n layout=\"summary-item\"\n infer=\"inclusive-tax-rate\"\n min=\"0\"\n max=\"1\"\n >\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"options\">\n <foxy-internal-switch-control infer=\"multiple-codes-allowed\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"combinable\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"exclude-category-discounts\">\n </foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"exclude-line-item-discounts\">\n </foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"is-taxable\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"shared-codes-allowed\"></foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n first=${ifDefined(this.data?._links['fx:attributes'].href)}\n limit=\"5\"\n infer=\"attributes\"\n item=\"foxy-attribute-card\"\n form=\"foxy-attribute-form\"\n alert\n >\n </foxy-internal-async-list-control>\n\n ${super.renderBody()}\n\n <foxy-nucleon\n infer=\"\"\n class=\"hidden\"\n href=${ifDefined(this.data?._links['fx:store'].href)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import '../../internal/InternalAsyncResourceLinkListControl/index';
|
|
|
2
2
|
import '../../internal/InternalBulkAddActionControl/index';
|
|
3
3
|
import '../../internal/InternalEditableListControl/index';
|
|
4
4
|
import '../../internal/InternalQueryBuilderControl/index';
|
|
5
|
+
import '../../internal/InternalArrayMapControl/index';
|
|
5
6
|
import '../../internal/InternalSummaryControl/index';
|
|
6
7
|
import '../../internal/InternalSwitchControl/index';
|
|
7
8
|
import '../../internal/InternalNumberControl/index';
|
|
@@ -2,6 +2,7 @@ import "../../internal/InternalAsyncResourceLinkListControl/index.js";
|
|
|
2
2
|
import "../../internal/InternalBulkAddActionControl/index.js";
|
|
3
3
|
import "../../internal/InternalEditableListControl/index.js";
|
|
4
4
|
import "../../internal/InternalQueryBuilderControl/index.js";
|
|
5
|
+
import "../../internal/InternalArrayMapControl/index.js";
|
|
5
6
|
import "../../internal/InternalSummaryControl/index.js";
|
|
6
7
|
import "../../internal/InternalSwitchControl/index.js";
|
|
7
8
|
import "../../internal/InternalNumberControl/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponForm/index.ts"],"names":[],"mappings":"AAAA,sEAAmE;AACnE,8DAA2D;AAC3D,6DAA0D;AAC1D,6DAA0D;AAC1D,wDAAqD;AACrD,uDAAoD;AACpD,uDAAoD;AACpD,qDAAkD;AAClD,qDAAkD;AAClD,8CAA2C;AAE3C,uCAAoC;AACpC,sCAAmC;AACnC,qCAAkC;AAClC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,mCAAgC;AAChC,mCAAgC;AAEhC,4DAAyD;AAEzD,OAAO,EAAE,UAAU,EAAE,wBAAqB;AAE1C,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import '../../internal/InternalAsyncResourceLinkListControl/index';\nimport '../../internal/InternalBulkAddActionControl/index';\nimport '../../internal/InternalEditableListControl/index';\nimport '../../internal/InternalQueryBuilderControl/index';\nimport '../../internal/InternalSummaryControl/index';\nimport '../../internal/InternalSwitchControl/index';\nimport '../../internal/InternalNumberControl/index';\nimport '../../internal/InternalTextControl/index';\nimport '../../internal/InternalDateControl/index';\nimport '../../internal/InternalForm/index';\n\nimport '../GenerateCodesForm/index';\nimport '../ItemCategoryCard/index';\nimport '../CouponCodesForm/index';\nimport '../CouponCodeCard/index';\nimport '../CouponCodeForm/index';\nimport '../NucleonElement/index';\nimport '../AttributeForm/index';\nimport '../AttributeCard/index';\n\nimport './internal/InternalCouponFormRulesControl/index';\n\nimport { CouponForm } from './CouponForm';\n\ncustomElements.define('foxy-coupon-form', CouponForm);\n\nexport { CouponForm };\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponForm/index.ts"],"names":[],"mappings":"AAAA,sEAAmE;AACnE,8DAA2D;AAC3D,6DAA0D;AAC1D,6DAA0D;AAC1D,yDAAsD;AACtD,wDAAqD;AACrD,uDAAoD;AACpD,uDAAoD;AACpD,qDAAkD;AAClD,qDAAkD;AAClD,8CAA2C;AAE3C,uCAAoC;AACpC,sCAAmC;AACnC,qCAAkC;AAClC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,mCAAgC;AAChC,mCAAgC;AAEhC,4DAAyD;AAEzD,OAAO,EAAE,UAAU,EAAE,wBAAqB;AAE1C,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import '../../internal/InternalAsyncResourceLinkListControl/index';\nimport '../../internal/InternalBulkAddActionControl/index';\nimport '../../internal/InternalEditableListControl/index';\nimport '../../internal/InternalQueryBuilderControl/index';\nimport '../../internal/InternalArrayMapControl/index';\nimport '../../internal/InternalSummaryControl/index';\nimport '../../internal/InternalSwitchControl/index';\nimport '../../internal/InternalNumberControl/index';\nimport '../../internal/InternalTextControl/index';\nimport '../../internal/InternalDateControl/index';\nimport '../../internal/InternalForm/index';\n\nimport '../GenerateCodesForm/index';\nimport '../ItemCategoryCard/index';\nimport '../CouponCodesForm/index';\nimport '../CouponCodeCard/index';\nimport '../CouponCodeForm/index';\nimport '../NucleonElement/index';\nimport '../AttributeForm/index';\nimport '../AttributeCard/index';\n\nimport './internal/InternalCouponFormRulesControl/index';\n\nimport { CouponForm } from './CouponForm';\n\ncustomElements.define('foxy-coupon-form', CouponForm);\n\nexport { CouponForm };\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Operator } from "../types.js";
|
|
2
2
|
function parseGroup(search) {
|
|
3
3
|
var _a;
|
|
4
|
-
const
|
|
4
|
+
const separatorIndex = search.indexOf('=');
|
|
5
|
+
const fullPath = decodeURIComponent(search.substring(0, separatorIndex));
|
|
6
|
+
const value = decodeURIComponent(search.substring(separatorIndex + 1));
|
|
5
7
|
const operators = Object.values(Operator);
|
|
6
8
|
const operator = (_a = operators.find(operator => fullPath.endsWith(`:${operator}`))) !== null && _a !== void 0 ? _a : null;
|
|
7
9
|
let path = fullPath.substring(0, operator ? fullPath.lastIndexOf(':') : undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/utils/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,oBAAiB;AAEjD,SAAS,UAAU,CAAC,MAAc;;IAChC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/utils/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,oBAAiB;AAEjD,SAAS,UAAU,CAAC,MAAc;;IAChC,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC;IAEvE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAe,CAAC;IACxD,MAAM,QAAQ,SAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,mCA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AkB,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACP,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { Operator, ParsedValue } from '../types';\n\nfunction parseGroup(search: string): ParsedValue {\n const separatorIndex = search.indexOf('=');\n const fullPath = decodeURIComponent(search.substring(0, separatorIndex));\n const value = decodeURIComponent(search.substring(separatorIndex + 1));\n\n const operators = Object.values(Operator) as Operator[];\n const operator = operators.find(operator => fullPath.endsWith(`:${operator}`)) ?? null;\n\n let path = fullPath.substring(0, operator ? fullPath.lastIndexOf(':') : undefined);\n let name: string | undefined = undefined;\n\n const nameStart = fullPath.lastIndexOf('[');\n\n if (path.endsWith(']') && nameStart !== -1) {\n name = path.substring(nameStart + 1, path.length - 1);\n path = path.substring(0, nameStart);\n if (path.endsWith(':name')) path = path.substring(0, path.length - 5);\n }\n\n return { name, path, value, operator };\n}\n\nfunction parse(search: string): (ParsedValue | ParsedValue[])[] {\n return search\n .split('&')\n .filter(v => !!v)\n .map(entry => {\n const [name, value] = entry.split('=').map(decodeURIComponent);\n if (!value?.includes('|')) return parseGroup(entry);\n return `${encodeURIComponent(name)}=${value}`.split('|').map(v => parseGroup(v));\n });\n}\n\nexport { parse };\n"]}
|
|
@@ -10,9 +10,16 @@ function stringifyGroup(parsedValue) {
|
|
|
10
10
|
function stringify(newValue) {
|
|
11
11
|
const toQuery = (rules, rule) => {
|
|
12
12
|
if (Array.isArray(rule)) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
let key = rule[0].path;
|
|
14
|
+
if (rule[0].name)
|
|
15
|
+
key += `:name[${rule[0].name}]`;
|
|
16
|
+
if (rule[0].operator)
|
|
17
|
+
key += `:${rule[0].operator}`;
|
|
18
|
+
const alternatives = [
|
|
19
|
+
rule[0].value,
|
|
20
|
+
...rule.slice(1).map(or => decodeURIComponent(stringifyGroup(or))),
|
|
21
|
+
];
|
|
22
|
+
rules.push(`${key}=${encodeURIComponent(alternatives.join('|'))}`);
|
|
16
23
|
}
|
|
17
24
|
else if (rule.path !== 'zoom') {
|
|
18
25
|
rules.push(stringifyGroup(rule));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/utils/stringify.ts"],"names":[],"mappings":"AAEA,SAAS,cAAc,CAAC,WAAwB;IAC9C,IAAI,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC;IAC9B,IAAI,WAAW,CAAC,IAAI;QAAE,MAAM,IAAI,SAAS,WAAW,CAAC,IAAI,GAAG,CAAC;IAC7D,IAAI,WAAW,CAAC,QAAQ;QAAE,MAAM,IAAI,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC/D,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;IAClF,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACtC,CAAC;AAED,SAAS,SAAS,CAAC,QAAyC;IAC1D,MAAM,OAAO,GAAG,CAAC,KAAe,EAAE,IAAiC,EAAE,EAAE;QACrE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,
|
|
1
|
+
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/utils/stringify.ts"],"names":[],"mappings":"AAEA,SAAS,cAAc,CAAC,WAAwB;IAC9C,IAAI,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC;IAC9B,IAAI,WAAW,CAAC,IAAI;QAAE,MAAM,IAAI,SAAS,WAAW,CAAC,IAAI,GAAG,CAAC;IAC7D,IAAI,WAA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,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { ParsedValue } from '../types';\n\nfunction stringifyGroup(parsedValue: ParsedValue): string {\n let result = parsedValue.path;\n if (parsedValue.name) result += `:name[${parsedValue.name}]`;\n if (parsedValue.operator) result += `:${parsedValue.operator}`;\n result = `${encodeURIComponent(result)}=${encodeURIComponent(parsedValue.value)}`;\n return result === '=' ? '' : result;\n}\n\nfunction stringify(newValue: (ParsedValue | ParsedValue[])[]): string {\n const toQuery = (rules: string[], rule: ParsedValue | ParsedValue[]) => {\n if (Array.isArray(rule)) {\n let key = rule[0].path;\n if (rule[0].name) key += `:name[${rule[0].name}]`;\n if (rule[0].operator) key += `:${rule[0].operator}`;\n\n const alternatives = [\n rule[0].value,\n ...rule.slice(1).map(or => decodeURIComponent(stringifyGroup(or))),\n ];\n\n rules.push(`${key}=${encodeURIComponent(alternatives.join('|'))}`);\n } else if (rule.path !== 'zoom') {\n rules.push(stringifyGroup(rule));\n }\n\n return rules;\n };\n\n const query = newValue.reduce(toQuery, [] as string[]);\n const zoom = getZoomedRels(newValue).join(',');\n\n if (zoom) query.push(`zoom=${encodeURIComponent(zoom)}`);\n return query.join('&');\n}\n\nfunction getZoomedRels(value: (ParsedValue | ParsedValue[])[]): string[] {\n return value\n .map(rule => {\n if (Array.isArray(rule)) return getZoomedRels(rule);\n if (rule.name) return [rule.path];\n\n const pathMembers = rule.path.split(':');\n return pathMembers.slice(0, pathMembers.length - 1);\n })\n .flat()\n .sort((rel1, rel2) => rel2.length - rel1.length)\n .filter((rel, index, rels) => {\n return rels.every((_rel, _index) => {\n return (_index >= index || _rel !== rel) && !_rel.startsWith(`${rel}:`);\n });\n });\n}\n\nexport { stringify };\n"]}
|
|
@@ -9,6 +9,7 @@ import "../ShipmentCard/index.js";
|
|
|
9
9
|
import "../PaymentCard/index.js";
|
|
10
10
|
import "../WebhookCard/index.js";
|
|
11
11
|
import "../WebhookForm/index.js";
|
|
12
|
+
import "../AddressForm/index.js";
|
|
12
13
|
import "../ItemCard/index.js";
|
|
13
14
|
import "../ItemForm/index.js";
|
|
14
15
|
import "../I18n/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/Transaction/index.ts"],"names":[],"mappings":"AAAA,wCAAqC;AACrC,mCAAgC;AAChC,mCAAgC;AAChC,qCAAkC;AAClC,qCAAkC;AAClC,qCAAkC;AAClC,oCAAiC;AACjC,kCAA+B;AAC/B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,8BAA2B;AAC3B,8BAA2B;AAC3B,0BAAuB;AAEvB,0DAAuD;AACvD,wDAAqD;AACrD,uDAAoD;AACpD,8CAA2C;AAE3C,kEAA+D;AAC/D,gEAA6D;AAC7D,+DAA4D;AAC5D,+DAA4D;AAE5D,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAE5C,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import '../BillingAddressCard/index';\nimport '../AttributeCard/index';\nimport '../AttributeForm/index';\nimport '../CustomFieldForm/index';\nimport '../CustomFieldCard/index';\nimport '../CopyToClipboard/index';\nimport '../NucleonElement/index';\nimport '../ShipmentCard/index';\nimport '../PaymentCard/index';\nimport '../WebhookCard/index';\nimport '../WebhookForm/index';\nimport '../ItemCard/index';\nimport '../ItemForm/index';\nimport '../I18n/index';\n\nimport '../../internal/InternalAsyncListControl/index';\nimport '../../internal/InternalSummaryControl/index';\nimport '../../internal/InternalSwitchControl/index';\nimport '../../internal/InternalForm/index';\n\nimport './internal/InternalTransactionPostActionControl/index';\nimport './internal/InternalTransactionCustomerControl/index';\nimport './internal/InternalTransactionActionsControl/index';\nimport './internal/InternalTransactionSummaryControl/index';\n\nimport { Transaction } from './Transaction';\n\ncustomElements.define('foxy-transaction', Transaction);\n\nexport { Transaction };\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/Transaction/index.ts"],"names":[],"mappings":"AAAA,wCAAqC;AACrC,mCAAgC;AAChC,mCAAgC;AAChC,qCAAkC;AAClC,qCAAkC;AAClC,qCAAkC;AAClC,oCAAiC;AACjC,kCAA+B;AAC/B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,8BAA2B;AAC3B,8BAA2B;AAC3B,0BAAuB;AAEvB,0DAAuD;AACvD,wDAAqD;AACrD,uDAAoD;AACpD,8CAA2C;AAE3C,kEAA+D;AAC/D,gEAA6D;AAC7D,+DAA4D;AAC5D,+DAA4D;AAE5D,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAE5C,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import '../BillingAddressCard/index';\nimport '../AttributeCard/index';\nimport '../AttributeForm/index';\nimport '../CustomFieldForm/index';\nimport '../CustomFieldCard/index';\nimport '../CopyToClipboard/index';\nimport '../NucleonElement/index';\nimport '../ShipmentCard/index';\nimport '../PaymentCard/index';\nimport '../WebhookCard/index';\nimport '../WebhookForm/index';\nimport '../AddressForm/index';\nimport '../ItemCard/index';\nimport '../ItemForm/index';\nimport '../I18n/index';\n\nimport '../../internal/InternalAsyncListControl/index';\nimport '../../internal/InternalSummaryControl/index';\nimport '../../internal/InternalSwitchControl/index';\nimport '../../internal/InternalForm/index';\n\nimport './internal/InternalTransactionPostActionControl/index';\nimport './internal/InternalTransactionCustomerControl/index';\nimport './internal/InternalTransactionActionsControl/index';\nimport './internal/InternalTransactionSummaryControl/index';\n\nimport { Transaction } from './Transaction';\n\ncustomElements.define('foxy-transaction', Transaction);\n\nexport { Transaction };\n"]}
|