@foxy.io/elements 1.30.0-beta.4 → 1.30.0-beta.6
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-cart-form.js +2 -2
- package/dist/cdn/foxy-item-form.js +1 -179
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/translations/admin-subscription-form/en.json +179 -156
- package/dist/cdn/translations/cart-form/en.json +438 -413
- package/dist/cdn/translations/item-form/en.json +179 -156
- package/dist/cdn/translations/transaction/en.json +179 -156
- package/dist/elements/public/CartForm/CartForm.js +13 -14
- package/dist/elements/public/CartForm/CartForm.js.map +1 -1
- package/dist/elements/public/ItemForm/ItemForm.d.ts +9 -1
- package/dist/elements/public/ItemForm/ItemForm.js +152 -128
- package/dist/elements/public/ItemForm/ItemForm.js.map +1 -1
- package/dist/elements/public/ItemForm/index.d.ts +2 -3
- package/dist/elements/public/ItemForm/index.js +2 -3
- package/dist/elements/public/ItemForm/index.js.map +1 -1
- package/dist/elements/public/SubscriptionForm/SubscriptionForm.js +1 -1
- package/dist/elements/public/SubscriptionForm/SubscriptionForm.js.map +1 -1
- package/dist/elements/public/Transaction/Transaction.d.ts +2 -0
- package/dist/elements/public/Transaction/Transaction.js +18 -8
- package/dist/elements/public/Transaction/Transaction.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
2
|
+
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
2
3
|
import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
|
|
3
4
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
5
|
+
import { classMap } from "../../../utils/class-map.js";
|
|
4
6
|
import { html } from 'lit-html';
|
|
5
7
|
/**
|
|
6
8
|
* Form element for creating or editing items (`fx:item`).
|
|
@@ -19,15 +21,18 @@ export class ItemForm extends TranslatableMixin(InternalForm, 'item-form') {
|
|
|
19
21
|
this.localeCodes = null;
|
|
20
22
|
/** @deprecated Link to the collection of coupons that can be used with this item. */
|
|
21
23
|
this.coupons = null;
|
|
24
|
+
/** Link to `fx:store` this item belongs to. */
|
|
25
|
+
this.store = null;
|
|
22
26
|
this.__itemsLink = '';
|
|
23
27
|
}
|
|
24
28
|
static get properties() {
|
|
25
29
|
return {
|
|
26
30
|
...super.properties,
|
|
27
|
-
customerAddresses: {
|
|
28
|
-
itemCategories: {
|
|
31
|
+
customerAddresses: { attribute: 'customer-addresses' },
|
|
32
|
+
itemCategories: { attribute: 'item-categories' },
|
|
29
33
|
localeCodes: { attribute: 'locale-codes' },
|
|
30
|
-
coupons: {
|
|
34
|
+
coupons: {},
|
|
35
|
+
store: {},
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
static get v8n() {
|
|
@@ -43,139 +48,139 @@ export class ItemForm extends TranslatableMixin(InternalForm, 'item-form') {
|
|
|
43
48
|
var _a;
|
|
44
49
|
return { context: ((_a = this.data) === null || _a === void 0 ? void 0 : _a.is_future_line_item) ? 'future_line_item' : 'regular' };
|
|
45
50
|
}
|
|
46
|
-
|
|
51
|
+
get readonlySelector() {
|
|
52
|
+
const alwaysMatch = [super.readonlySelector.toString()];
|
|
53
|
+
if (this.href)
|
|
54
|
+
alwaysMatch.unshift('subscriptions');
|
|
55
|
+
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
56
|
+
}
|
|
57
|
+
get hiddenSelector() {
|
|
47
58
|
var _a, _b;
|
|
59
|
+
const alwaysMatch = [super.hiddenSelector.toString()];
|
|
60
|
+
if (!((_b = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.features_multiship))
|
|
61
|
+
alwaysMatch.unshift('general:shipto');
|
|
62
|
+
if (this.data && !this.data.subscription_frequency)
|
|
63
|
+
alwaysMatch.unshift('subscriptions');
|
|
64
|
+
if (!this.form.discount_name)
|
|
65
|
+
alwaysMatch.unshift('discount:discount-builder');
|
|
66
|
+
if (!this.href) {
|
|
67
|
+
alwaysMatch.unshift('discount-details', 'coupon-details', 'item-options', 'attributes');
|
|
68
|
+
}
|
|
69
|
+
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
70
|
+
}
|
|
71
|
+
renderBody() {
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
48
73
|
return html `
|
|
49
74
|
${this.renderHeader()}
|
|
50
75
|
|
|
51
|
-
<foxy-internal-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<foxy-internal-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
<foxy-internal-summary-control infer="general">
|
|
77
|
+
<foxy-internal-text-control layout="summary-item" infer="name"></foxy-internal-text-control>
|
|
78
|
+
<foxy-internal-number-control layout="summary-item" infer="price" min="0">
|
|
79
|
+
</foxy-internal-number-control>
|
|
80
|
+
<foxy-internal-number-control layout="summary-item" infer="quantity" step="1" min="1">
|
|
81
|
+
</foxy-internal-number-control>
|
|
82
|
+
<foxy-internal-resource-picker-control
|
|
83
|
+
layout="summary-item"
|
|
84
|
+
first=${ifDefined((_a = this === null || this === void 0 ? void 0 : this.itemCategories) !== null && _a !== void 0 ? _a : undefined)}
|
|
85
|
+
infer="item-category-uri"
|
|
86
|
+
item="foxy-item-category-card"
|
|
87
|
+
>
|
|
88
|
+
</foxy-internal-resource-picker-control>
|
|
89
|
+
<foxy-internal-text-control layout="summary-item" infer="code"></foxy-internal-text-control>
|
|
90
|
+
<foxy-internal-text-control layout="summary-item" infer="parent-code">
|
|
91
|
+
</foxy-internal-text-control>
|
|
92
|
+
<foxy-internal-text-control layout="summary-item" infer="shipto">
|
|
93
|
+
</foxy-internal-text-control>
|
|
94
|
+
</foxy-internal-summary-control>
|
|
95
|
+
|
|
96
|
+
<foxy-internal-summary-control infer="subscriptions">
|
|
97
|
+
<foxy-internal-frequency-control layout="summary-item" infer="subscription-frequency">
|
|
98
|
+
</foxy-internal-frequency-control>
|
|
99
|
+
<foxy-internal-date-control layout="summary-item" infer="subscription-start-date">
|
|
100
|
+
</foxy-internal-date-control>
|
|
101
|
+
<foxy-internal-date-control layout="summary-item" infer="subscription-end-date">
|
|
102
|
+
</foxy-internal-date-control>
|
|
103
|
+
</foxy-internal-summary-control>
|
|
104
|
+
|
|
105
|
+
<foxy-internal-async-list-control
|
|
106
|
+
infer="item-options"
|
|
107
|
+
first=${ifDefined((_b = this.data) === null || _b === void 0 ? void 0 : _b._links['fx:item_options'].href)}
|
|
108
|
+
form="foxy-item-option-form"
|
|
109
|
+
item="foxy-item-option-card"
|
|
110
|
+
alert
|
|
111
|
+
.related=${this.__itemOptionRelatedUrls}
|
|
112
|
+
.itemProps=${{ 'locale-codes': (_c = this.localeCodes) !== null && _c !== void 0 ? _c : '' }}
|
|
62
113
|
>
|
|
63
|
-
</foxy-internal-
|
|
64
|
-
|
|
65
|
-
<foxy-internal-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<foxy-internal-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<foxy-discount-builder
|
|
107
|
-
infer="discount-builder"
|
|
108
|
-
.parsedValue=${{
|
|
109
|
-
details: this.form.discount_details,
|
|
110
|
-
type: this.form.discount_type,
|
|
111
|
-
name: this.form.discount_name,
|
|
112
|
-
}}
|
|
113
|
-
@change=${(evt) => {
|
|
114
|
-
const builder = evt.currentTarget;
|
|
115
|
-
const value = builder.parsedValue;
|
|
116
|
-
this.edit({
|
|
117
|
-
discount_details: value.details,
|
|
118
|
-
discount_type: value.type,
|
|
119
|
-
discount_name: value.name,
|
|
120
|
-
});
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
</foxy-discount-builder>
|
|
124
|
-
</div>
|
|
125
|
-
</vaadin-details>
|
|
126
|
-
|
|
127
|
-
<foxy-internal-text-control infer="shipto"></foxy-internal-text-control>
|
|
128
|
-
<foxy-internal-date-control infer="expires" format="unix"></foxy-internal-date-control>
|
|
129
|
-
|
|
130
|
-
${this.data
|
|
131
|
-
? html `
|
|
132
|
-
<foxy-internal-async-list-control
|
|
133
|
-
label=${this.t('item-options.title')}
|
|
134
|
-
infer="item-options"
|
|
135
|
-
first=${this.data._links['fx:item_options'].href}
|
|
136
|
-
limit="5"
|
|
137
|
-
form="foxy-item-option-form"
|
|
138
|
-
item="foxy-item-option-card"
|
|
139
|
-
alert
|
|
140
|
-
.related=${this.__itemOptionRelatedUrls}
|
|
141
|
-
.props=${{ 'locale-codes': (_b = this.localeCodes) !== null && _b !== void 0 ? _b : '' }}
|
|
142
|
-
>
|
|
143
|
-
</foxy-internal-async-list-control>
|
|
144
|
-
`
|
|
145
|
-
: ''}
|
|
146
|
-
${this.data
|
|
147
|
-
? html `
|
|
148
|
-
<foxy-internal-async-list-control
|
|
149
|
-
label=${this.t('discount-details.title')}
|
|
150
|
-
infer="discount-details"
|
|
151
|
-
first=${this.data._links['fx:discount_details'].href}
|
|
152
|
-
limit="5"
|
|
153
|
-
item="foxy-discount-detail-card"
|
|
154
|
-
>
|
|
155
|
-
</foxy-internal-async-list-control>
|
|
114
|
+
</foxy-internal-async-list-control>
|
|
115
|
+
|
|
116
|
+
<foxy-internal-summary-control infer="dimensions">
|
|
117
|
+
<foxy-internal-number-control layout="summary-item" infer="weight" min="0">
|
|
118
|
+
</foxy-internal-number-control>
|
|
119
|
+
<foxy-internal-number-control layout="summary-item" infer="length" min="0">
|
|
120
|
+
</foxy-internal-number-control>
|
|
121
|
+
<foxy-internal-number-control layout="summary-item" infer="width" min="0">
|
|
122
|
+
</foxy-internal-number-control>
|
|
123
|
+
<foxy-internal-number-control layout="summary-item" infer="height" min="0">
|
|
124
|
+
</foxy-internal-number-control>
|
|
125
|
+
</foxy-internal-summary-control>
|
|
126
|
+
|
|
127
|
+
<foxy-internal-summary-control infer="meta">
|
|
128
|
+
<foxy-internal-text-control layout="summary-item" infer="url"></foxy-internal-text-control>
|
|
129
|
+
<foxy-internal-text-control layout="summary-item" infer="image">
|
|
130
|
+
</foxy-internal-text-control>
|
|
131
|
+
<foxy-internal-number-control layout="summary-item" infer="quantity-max" step="1" min="1">
|
|
132
|
+
</foxy-internal-number-control>
|
|
133
|
+
<foxy-internal-number-control layout="summary-item" infer="quantity-min" step="1" min="1">
|
|
134
|
+
</foxy-internal-number-control>
|
|
135
|
+
<foxy-internal-date-control layout="summary-item" infer="expires" format="unix">
|
|
136
|
+
</foxy-internal-date-control>
|
|
137
|
+
</foxy-internal-summary-control>
|
|
138
|
+
|
|
139
|
+
<foxy-internal-summary-control infer="discount">
|
|
140
|
+
<foxy-internal-text-control layout="summary-item" infer="discount-name">
|
|
141
|
+
</foxy-internal-text-control>
|
|
142
|
+
<foxy-discount-builder
|
|
143
|
+
infer="discount-builder"
|
|
144
|
+
class=${classMap({ hidden: this.hiddenSelector.matches('discount-builder', true) })}
|
|
145
|
+
.parsedValue=${this.__discountBuilderParsedValue}
|
|
146
|
+
@change=${this.__handleDiscountBuilderChange}
|
|
147
|
+
>
|
|
148
|
+
</foxy-discount-builder>
|
|
149
|
+
</foxy-internal-summary-control>
|
|
150
|
+
|
|
151
|
+
<foxy-internal-async-list-control
|
|
152
|
+
infer="discount-details"
|
|
153
|
+
first=${ifDefined((_d = this.data) === null || _d === void 0 ? void 0 : _d._links['fx:discount_details'].href)}
|
|
154
|
+
item="foxy-discount-detail-card"
|
|
155
|
+
>
|
|
156
|
+
</foxy-internal-async-list-control>
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
<foxy-internal-async-list-control
|
|
159
|
+
infer="coupon-details"
|
|
160
|
+
first=${ifDefined((_e = this.data) === null || _e === void 0 ? void 0 : _e._links['fx:coupon_details'].href)}
|
|
161
|
+
item="foxy-coupon-detail-card"
|
|
162
|
+
>
|
|
163
|
+
</foxy-internal-async-list-control>
|
|
164
|
+
|
|
165
|
+
<foxy-internal-async-list-control
|
|
166
|
+
infer="attributes"
|
|
167
|
+
first=${ifDefined((_f = this.data) === null || _f === void 0 ? void 0 : _f._links['fx:attributes'].href)}
|
|
168
|
+
item="foxy-attribute-card"
|
|
169
|
+
form="foxy-attribute-form"
|
|
170
|
+
alert
|
|
171
|
+
>
|
|
172
|
+
</foxy-internal-async-list-control>
|
|
165
173
|
|
|
166
|
-
<foxy-internal-async-list-control
|
|
167
|
-
label=${this.t('attributes.title')}
|
|
168
|
-
infer="attributes"
|
|
169
|
-
first=${this.data._links['fx:attributes'].href}
|
|
170
|
-
limit="5"
|
|
171
|
-
item="foxy-attribute-card"
|
|
172
|
-
form="foxy-attribute-form"
|
|
173
|
-
alert
|
|
174
|
-
>
|
|
175
|
-
</foxy-internal-async-list-control>
|
|
176
|
-
`
|
|
177
|
-
: ''}
|
|
178
174
|
${super.renderBody()}
|
|
175
|
+
|
|
176
|
+
<foxy-nucleon
|
|
177
|
+
class="hidden"
|
|
178
|
+
infer=""
|
|
179
|
+
href=${ifDefined((_g = this.store) !== null && _g !== void 0 ? _g : void 0)}
|
|
180
|
+
id="storeLoader"
|
|
181
|
+
@update=${() => this.requestUpdate()}
|
|
182
|
+
>
|
|
183
|
+
</foxy-nucleon>
|
|
179
184
|
`;
|
|
180
185
|
}
|
|
181
186
|
async _sendGet() {
|
|
@@ -200,6 +205,13 @@ export class ItemForm extends TranslatableMixin(InternalForm, 'item-form') {
|
|
|
200
205
|
}
|
|
201
206
|
return item;
|
|
202
207
|
}
|
|
208
|
+
get __discountBuilderParsedValue() {
|
|
209
|
+
return {
|
|
210
|
+
details: this.form.discount_details,
|
|
211
|
+
type: this.form.discount_type,
|
|
212
|
+
name: this.form.discount_name,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
203
215
|
get __itemOptionRelatedUrls() {
|
|
204
216
|
var _a, _b;
|
|
205
217
|
const links = ((_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a._links) !== null && _b !== void 0 ? _b : {});
|
|
@@ -216,5 +228,17 @@ export class ItemForm extends TranslatableMixin(InternalForm, 'item-form') {
|
|
|
216
228
|
urls.push(this.__itemsLink);
|
|
217
229
|
return urls;
|
|
218
230
|
}
|
|
231
|
+
get __storeLoader() {
|
|
232
|
+
return this.renderRoot.querySelector('#storeLoader');
|
|
233
|
+
}
|
|
234
|
+
__handleDiscountBuilderChange(evt) {
|
|
235
|
+
const builder = evt.currentTarget;
|
|
236
|
+
const value = builder.parsedValue;
|
|
237
|
+
this.edit({
|
|
238
|
+
discount_details: value.details,
|
|
239
|
+
discount_type: value.type,
|
|
240
|
+
discount_name: value.name,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
219
243
|
}
|
|
220
244
|
//# sourceMappingURL=ItemForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemForm.js","sourceRoot":"","sources":["../../../../src/elements/public/ItemForm/ItemForm.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OA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,WAAW;YAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAElD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { DiscountBuilder } from '../DiscountBuilder/DiscountBuilder';\nimport type { Data } from './types';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\n/**\n * Form element for creating or editing items (`fx:item`).\n *\n * @element foxy-item-form\n * @since 1.17.0\n */\nexport class ItemForm extends TranslatableMixin(InternalForm, 'item-form')<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n customerAddresses: { type: String, attribute: 'customer-addresses' },\n itemCategories: { type: String, attribute: 'item-categories' },\n localeCodes: { attribute: 'locale-codes' },\n coupons: { type: String },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ name: v }) => !!v || 'name:v8n_required',\n ({ name: v }) => (!!v && v.length <= 255) || 'name:v8n_too_long',\n ({ price: v }) => (typeof v === 'number' && !isNaN(v)) || 'price:v8n_required',\n ({ price: v }) => (typeof v === 'number' && v >= 0) || 'price:v8n_negative',\n ({ quantity: v }) => (typeof v === 'number' && v >= 1) || 'quantity:v8n_less_than_one',\n ];\n }\n\n /** @deprecated Link to the collection of customer addresses that can be used with this item. */\n customerAddresses: string | null = null;\n\n /** Link to the collection of item categories that can be used with this item. */\n itemCategories: string | null = null;\n\n /** Link to the `fx:locale_codes` property helper for currency formatting. */\n localeCodes: string | null = null;\n\n /** @deprecated Link to the collection of coupons that can be used with this item. */\n coupons: string | null = null;\n\n private __itemsLink = '';\n\n get headerSubtitleOptions(): Record<string, unknown> {\n return { context: this.data?.is_future_line_item ? 'future_line_item' : 'regular' };\n }\n\n renderBody(): TemplateResult {\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-text-control infer=\"name\"></foxy-internal-text-control>\n\n <div class=\"grid grid-cols-2 gap-s\">\n <foxy-internal-number-control infer=\"price\"></foxy-internal-number-control>\n <foxy-internal-integer-control infer=\"quantity\"></foxy-internal-integer-control>\n </div>\n\n <foxy-internal-resource-picker-control\n first=${ifDefined(this?.itemCategories ?? undefined)}\n infer=\"item-category-uri\"\n item=\"foxy-item-category-card\"\n >\n </foxy-internal-resource-picker-control>\n\n <foxy-internal-text-control infer=\"code\"></foxy-internal-text-control>\n <foxy-internal-text-control infer=\"parent-code\"></foxy-internal-text-control>\n\n <div class=\"grid grid-cols-2 gap-s\">\n <foxy-internal-integer-control infer=\"quantity-min\"></foxy-internal-integer-control>\n <foxy-internal-integer-control infer=\"quantity-max\"></foxy-internal-integer-control>\n </div>\n\n <div>\n <vaadin-details theme=\"reverse\">\n <foxy-i18n infer=\"\" slot=\"summary\" key=\"dimensions\"></foxy-i18n>\n <div class=\"grid grid-cols-2 gap-s pt-m\">\n <foxy-internal-number-control infer=\"weight\"></foxy-internal-number-control>\n <foxy-internal-number-control infer=\"width\"></foxy-internal-number-control>\n <foxy-internal-number-control infer=\"height\"></foxy-internal-number-control>\n <foxy-internal-number-control infer=\"length\"></foxy-internal-number-control>\n </div>\n </vaadin-details>\n\n <vaadin-details theme=\"reverse\">\n <foxy-i18n infer=\"\" slot=\"summary\" key=\"subscriptions\"></foxy-i18n>\n <div class=\"space-y-m pt-m\">\n <foxy-internal-frequency-control infer=\"subscription-frequency\">\n </foxy-internal-frequency-control>\n\n <foxy-internal-date-control infer=\"subscription-start-date\">\n </foxy-internal-date-control>\n\n <foxy-internal-date-control infer=\"subscription-end-date\"></foxy-internal-date-control>\n </div>\n </vaadin-details>\n </div>\n\n <foxy-internal-text-area-control infer=\"url\"></foxy-internal-text-area-control>\n <foxy-internal-text-area-control infer=\"image\"></foxy-internal-text-area-control>\n\n <vaadin-details theme=\"reverse\">\n <foxy-i18n infer=\"\" slot=\"summary\" key=\"discount\"></foxy-i18n>\n <div class=\"space-y-m pt-m\">\n <foxy-internal-text-control infer=\"discount-name\"></foxy-internal-text-control>\n\n <foxy-discount-builder\n infer=\"discount-builder\"\n .parsedValue=${{\n details: this.form.discount_details,\n type: this.form.discount_type,\n name: this.form.discount_name,\n }}\n @change=${(evt: CustomEvent) => {\n const builder = evt.currentTarget as DiscountBuilder;\n const value = builder.parsedValue;\n\n this.edit({\n discount_details: value.details,\n discount_type: value.type,\n discount_name: value.name,\n });\n }}\n >\n </foxy-discount-builder>\n </div>\n </vaadin-details>\n\n <foxy-internal-text-control infer=\"shipto\"></foxy-internal-text-control>\n <foxy-internal-date-control infer=\"expires\" format=\"unix\"></foxy-internal-date-control>\n\n ${this.data\n ? html`\n <foxy-internal-async-list-control\n label=${this.t('item-options.title')}\n infer=\"item-options\"\n first=${this.data._links['fx:item_options'].href}\n limit=\"5\"\n form=\"foxy-item-option-form\"\n item=\"foxy-item-option-card\"\n alert\n .related=${this.__itemOptionRelatedUrls}\n .props=${{ 'locale-codes': this.localeCodes ?? '' }}\n >\n </foxy-internal-async-list-control>\n `\n : ''}\n ${this.data\n ? html`\n <foxy-internal-async-list-control\n label=${this.t('discount-details.title')}\n infer=\"discount-details\"\n first=${this.data._links['fx:discount_details'].href}\n limit=\"5\"\n item=\"foxy-discount-detail-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n label=${this.t('coupon-details.title')}\n infer=\"coupon-details\"\n first=${this.data._links['fx:coupon_details'].href}\n limit=\"5\"\n item=\"foxy-coupon-detail-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n label=${this.t('attributes.title')}\n infer=\"attributes\"\n first=${this.data._links['fx:attributes'].href}\n limit=\"5\"\n item=\"foxy-attribute-card\"\n form=\"foxy-attribute-form\"\n alert\n >\n </foxy-internal-async-list-control>\n `\n : ''}\n ${super.renderBody()}\n `;\n }\n\n protected async _sendGet(): Promise<Data> {\n type TransactionTemplate = Resource<Rels.TransactionTemplate>;\n type Subscription = Resource<Rels.Subscription>;\n type Transaction = Resource<Rels.Transaction>;\n type Cart = Resource<Rels.Cart>;\n\n const item = await super._sendGet();\n\n if (item._links['fx:subscription']) {\n const subscriptionHref = item._links['fx:subscription'].href;\n const subscription = await super._fetch<Subscription>(subscriptionHref);\n\n const transactionTemplateHref = subscription._links['fx:transaction_template'].href;\n const transactionTemplate = await super._fetch<TransactionTemplate>(transactionTemplateHref);\n\n this.__itemsLink = transactionTemplate._links['fx:items'].href;\n return item;\n }\n\n if (item._links['fx:transaction']) {\n const transaction = await super._fetch<Transaction>(item._links['fx:transaction'].href);\n this.__itemsLink = transaction._links['fx:items'].href;\n return item;\n }\n\n if (item._links['fx:cart']) {\n const cart = await super._fetch<Cart>(item._links['fx:cart'].href);\n this.__itemsLink = cart._links['fx:items'].href;\n return item;\n }\n\n return item;\n }\n\n private get __itemOptionRelatedUrls() {\n const links = (this.data?._links ?? {}) as Record<string, { href: string }>;\n const urls: string[] = [];\n\n if (links['fx:subscription']) urls.push(links['fx:subscription'].href);\n if (links['fx:transaction']) urls.push(links['fx:transaction'].href);\n if (links['fx:shipment']) urls.push(links['fx:shipment'].href);\n if (links['fx:cart']) urls.push(links['fx:cart'].href);\n if (this.__itemsLink) urls.push(this.__itemsLink);\n\n return urls;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ItemForm.js","sourceRoot":"","sources":["../../../../src/elements/public/ItemForm/ItemForm.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OA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import type { DiscountBuilder } from '../DiscountBuilder/DiscountBuilder';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\n/**\n * Form element for creating or editing items (`fx:item`).\n *\n * @element foxy-item-form\n * @since 1.17.0\n */\nexport class ItemForm extends TranslatableMixin(InternalForm, 'item-form')<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n customerAddresses: { attribute: 'customer-addresses' },\n itemCategories: { attribute: 'item-categories' },\n localeCodes: { attribute: 'locale-codes' },\n coupons: {},\n store: {},\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ name: v }) => !!v || 'name:v8n_required',\n ({ name: v }) => (!!v && v.length <= 255) || 'name:v8n_too_long',\n ({ price: v }) => (typeof v === 'number' && !isNaN(v)) || 'price:v8n_required',\n ({ price: v }) => (typeof v === 'number' && v >= 0) || 'price:v8n_negative',\n ({ quantity: v }) => (typeof v === 'number' && v >= 1) || 'quantity:v8n_less_than_one',\n ];\n }\n\n /** @deprecated Link to the collection of customer addresses that can be used with this item. */\n customerAddresses: string | null = null;\n\n /** Link to the collection of item categories that can be used with this item. */\n itemCategories: string | null = null;\n\n /** Link to the `fx:locale_codes` property helper for currency formatting. */\n localeCodes: string | null = null;\n\n /** @deprecated Link to the collection of coupons that can be used with this item. */\n coupons: string | null = null;\n\n /** Link to `fx:store` this item belongs to. */\n store: string | null = null;\n\n private __itemsLink = '';\n\n get headerSubtitleOptions(): Record<string, unknown> {\n return { context: this.data?.is_future_line_item ? 'future_line_item' : 'regular' };\n }\n\n get readonlySelector(): BooleanSelector {\n const alwaysMatch = [super.readonlySelector.toString()];\n if (this.href) alwaysMatch.unshift('subscriptions');\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n\n if (!this.__storeLoader?.data?.features_multiship) alwaysMatch.unshift('general:shipto');\n if (this.data && !this.data.subscription_frequency) alwaysMatch.unshift('subscriptions');\n if (!this.form.discount_name) alwaysMatch.unshift('discount:discount-builder');\n if (!this.href) {\n alwaysMatch.unshift('discount-details', 'coupon-details', 'item-options', 'attributes');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\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-number-control layout=\"summary-item\" infer=\"price\" min=\"0\">\n </foxy-internal-number-control>\n <foxy-internal-number-control layout=\"summary-item\" infer=\"quantity\" step=\"1\" min=\"1\">\n </foxy-internal-number-control>\n <foxy-internal-resource-picker-control\n layout=\"summary-item\"\n first=${ifDefined(this?.itemCategories ?? undefined)}\n infer=\"item-category-uri\"\n item=\"foxy-item-category-card\"\n >\n </foxy-internal-resource-picker-control>\n <foxy-internal-text-control layout=\"summary-item\" infer=\"code\"></foxy-internal-text-control>\n <foxy-internal-text-control layout=\"summary-item\" infer=\"parent-code\">\n </foxy-internal-text-control>\n <foxy-internal-text-control layout=\"summary-item\" infer=\"shipto\">\n </foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"subscriptions\">\n <foxy-internal-frequency-control layout=\"summary-item\" infer=\"subscription-frequency\">\n </foxy-internal-frequency-control>\n <foxy-internal-date-control layout=\"summary-item\" infer=\"subscription-start-date\">\n </foxy-internal-date-control>\n <foxy-internal-date-control layout=\"summary-item\" infer=\"subscription-end-date\">\n </foxy-internal-date-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n infer=\"item-options\"\n first=${ifDefined(this.data?._links['fx:item_options'].href)}\n form=\"foxy-item-option-form\"\n item=\"foxy-item-option-card\"\n alert\n .related=${this.__itemOptionRelatedUrls}\n .itemProps=${{ 'locale-codes': this.localeCodes ?? '' }}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-summary-control infer=\"dimensions\">\n <foxy-internal-number-control layout=\"summary-item\" infer=\"weight\" min=\"0\">\n </foxy-internal-number-control>\n <foxy-internal-number-control layout=\"summary-item\" infer=\"length\" min=\"0\">\n </foxy-internal-number-control>\n <foxy-internal-number-control layout=\"summary-item\" infer=\"width\" min=\"0\">\n </foxy-internal-number-control>\n <foxy-internal-number-control layout=\"summary-item\" infer=\"height\" min=\"0\">\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"meta\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"url\"></foxy-internal-text-control>\n <foxy-internal-text-control layout=\"summary-item\" infer=\"image\">\n </foxy-internal-text-control>\n <foxy-internal-number-control layout=\"summary-item\" infer=\"quantity-max\" step=\"1\" min=\"1\">\n </foxy-internal-number-control>\n <foxy-internal-number-control layout=\"summary-item\" infer=\"quantity-min\" step=\"1\" min=\"1\">\n </foxy-internal-number-control>\n <foxy-internal-date-control layout=\"summary-item\" infer=\"expires\" format=\"unix\">\n </foxy-internal-date-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"discount\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"discount-name\">\n </foxy-internal-text-control>\n <foxy-discount-builder\n infer=\"discount-builder\"\n class=${classMap({ hidden: this.hiddenSelector.matches('discount-builder', true) })}\n .parsedValue=${this.__discountBuilderParsedValue}\n @change=${this.__handleDiscountBuilderChange}\n >\n </foxy-discount-builder>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n infer=\"discount-details\"\n first=${ifDefined(this.data?._links['fx:discount_details'].href)}\n item=\"foxy-discount-detail-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n infer=\"coupon-details\"\n first=${ifDefined(this.data?._links['fx:coupon_details'].href)}\n item=\"foxy-coupon-detail-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n infer=\"attributes\"\n first=${ifDefined(this.data?._links['fx:attributes'].href)}\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 class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.store ?? void 0)}\n id=\"storeLoader\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n protected async _sendGet(): Promise<Data> {\n type TransactionTemplate = Resource<Rels.TransactionTemplate>;\n type Subscription = Resource<Rels.Subscription>;\n type Transaction = Resource<Rels.Transaction>;\n type Cart = Resource<Rels.Cart>;\n\n const item = await super._sendGet();\n\n if (item._links['fx:subscription']) {\n const subscriptionHref = item._links['fx:subscription'].href;\n const subscription = await super._fetch<Subscription>(subscriptionHref);\n\n const transactionTemplateHref = subscription._links['fx:transaction_template'].href;\n const transactionTemplate = await super._fetch<TransactionTemplate>(transactionTemplateHref);\n\n this.__itemsLink = transactionTemplate._links['fx:items'].href;\n return item;\n }\n\n if (item._links['fx:transaction']) {\n const transaction = await super._fetch<Transaction>(item._links['fx:transaction'].href);\n this.__itemsLink = transaction._links['fx:items'].href;\n return item;\n }\n\n if (item._links['fx:cart']) {\n const cart = await super._fetch<Cart>(item._links['fx:cart'].href);\n this.__itemsLink = cart._links['fx:items'].href;\n return item;\n }\n\n return item;\n }\n\n private get __discountBuilderParsedValue() {\n return {\n details: this.form.discount_details,\n type: this.form.discount_type,\n name: this.form.discount_name,\n };\n }\n\n private get __itemOptionRelatedUrls() {\n const links = (this.data?._links ?? {}) as Record<string, { href: string }>;\n const urls: string[] = [];\n\n if (links['fx:subscription']) urls.push(links['fx:subscription'].href);\n if (links['fx:transaction']) urls.push(links['fx:transaction'].href);\n if (links['fx:shipment']) urls.push(links['fx:shipment'].href);\n if (links['fx:cart']) urls.push(links['fx:cart'].href);\n if (this.__itemsLink) urls.push(this.__itemsLink);\n\n return urls;\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>('#storeLoader');\n }\n\n private __handleDiscountBuilderChange(evt: CustomEvent) {\n const builder = evt.currentTarget as DiscountBuilder;\n const value = builder.parsedValue;\n\n this.edit({\n discount_details: value.details,\n discount_type: value.type,\n discount_name: value.name,\n });\n }\n}\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import '@vaadin/vaadin-details';
|
|
2
1
|
import '../../internal/InternalResourcePickerControl/index';
|
|
3
2
|
import '../../internal/InternalAsyncListControl/index';
|
|
4
3
|
import '../../internal/InternalFrequencyControl/index';
|
|
5
|
-
import '../../internal/
|
|
6
|
-
import '../../internal/InternalIntegerControl/index';
|
|
4
|
+
import '../../internal/InternalSummaryControl/index';
|
|
7
5
|
import '../../internal/InternalNumberControl/index';
|
|
8
6
|
import '../../internal/InternalTextControl/index';
|
|
9
7
|
import '../../internal/InternalDateControl/index';
|
|
@@ -14,6 +12,7 @@ import '../ItemCategoryCard/index';
|
|
|
14
12
|
import '../DiscountBuilder/index';
|
|
15
13
|
import '../ItemOptionCard/index';
|
|
16
14
|
import '../ItemOptionForm/index';
|
|
15
|
+
import '../NucleonElement/index';
|
|
17
16
|
import '../AttributeCard/index';
|
|
18
17
|
import '../AttributeForm/index';
|
|
19
18
|
import { ItemForm } from './ItemForm';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import '@vaadin/vaadin-details';
|
|
2
1
|
import "../../internal/InternalResourcePickerControl/index.js";
|
|
3
2
|
import "../../internal/InternalAsyncListControl/index.js";
|
|
4
3
|
import "../../internal/InternalFrequencyControl/index.js";
|
|
5
|
-
import "../../internal/
|
|
6
|
-
import "../../internal/InternalIntegerControl/index.js";
|
|
4
|
+
import "../../internal/InternalSummaryControl/index.js";
|
|
7
5
|
import "../../internal/InternalNumberControl/index.js";
|
|
8
6
|
import "../../internal/InternalTextControl/index.js";
|
|
9
7
|
import "../../internal/InternalDateControl/index.js";
|
|
@@ -14,6 +12,7 @@ import "../ItemCategoryCard/index.js";
|
|
|
14
12
|
import "../DiscountBuilder/index.js";
|
|
15
13
|
import "../ItemOptionCard/index.js";
|
|
16
14
|
import "../ItemOptionForm/index.js";
|
|
15
|
+
import "../NucleonElement/index.js";
|
|
17
16
|
import "../AttributeCard/index.js";
|
|
18
17
|
import "../AttributeForm/index.js";
|
|
19
18
|
import { ItemForm } from "./ItemForm.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/ItemForm/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/ItemForm/index.ts"],"names":[],"mappings":"AAAA,+DAA4D;AAC5D,0DAAuD;AACvD,0DAAuD;AACvD,wDAAqD;AACrD,uDAAoD;AACpD,qDAAkD;AAClD,qDAAkD;AAClD,8CAA2C;AAE3C,wCAAqC;AACrC,sCAAmC;AACnC,sCAAmC;AACnC,qCAAkC;AAClC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,mCAAgC;AAChC,mCAAgC;AAEhC,OAAO,EAAE,QAAQ,EAAE,sBAAmB;AAEtC,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import '../../internal/InternalResourcePickerControl/index';\nimport '../../internal/InternalAsyncListControl/index';\nimport '../../internal/InternalFrequencyControl/index';\nimport '../../internal/InternalSummaryControl/index';\nimport '../../internal/InternalNumberControl/index';\nimport '../../internal/InternalTextControl/index';\nimport '../../internal/InternalDateControl/index';\nimport '../../internal/InternalForm/index';\n\nimport '../DiscountDetailCard/index';\nimport '../CouponDetailCard/index';\nimport '../ItemCategoryCard/index';\nimport '../DiscountBuilder/index';\nimport '../ItemOptionCard/index';\nimport '../ItemOptionForm/index';\nimport '../NucleonElement/index';\nimport '../AttributeCard/index';\nimport '../AttributeForm/index';\n\nimport { ItemForm } from './ItemForm';\n\ncustomElements.define('foxy-item-form', ItemForm);\n\nexport { ItemForm };\n"]}
|
|
@@ -71,9 +71,9 @@ export class SubscriptionForm extends Base {
|
|
|
71
71
|
|
|
72
72
|
<foxy-internal-async-list-control
|
|
73
73
|
first=${ifDefined(itemsHref)}
|
|
74
|
-
limit="5"
|
|
75
74
|
infer="items"
|
|
76
75
|
item="foxy-item-card"
|
|
76
|
+
.itemProps=${{ 'locale-codes': this.localeCodes }}
|
|
77
77
|
>
|
|
78
78
|
</foxy-internal-async-list-control>
|
|
79
79
|
</div>
|