@foxy.io/elements 1.14.2 → 1.15.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-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -0
- package/dist/cdn/foxy-coupon-code-form.js +1 -0
- package/dist/cdn/foxy-coupon-codes-form.js +1 -0
- package/dist/cdn/foxy-coupon-form.js +1 -0
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-api.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +4 -807
- package/dist/cdn/foxy-customer-portal.js +2 -2
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -0
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-nucleon-element.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -0
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -69
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +3 -3
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/{shared-74b9e1d1.js → shared-0bda8ecb.js} +1 -1
- package/dist/cdn/{shared-07abcd7b.js → shared-0fcdd1c4.js} +1 -1
- package/dist/cdn/{shared-a46edf4b.js → shared-30131f76.js} +1 -1
- package/dist/cdn/shared-36629ded.js +131 -0
- package/dist/cdn/{shared-bc2bfe52.js → shared-4038cb18.js} +1 -1
- package/dist/cdn/{shared-44cfc617.js → shared-423a4840.js} +1 -1
- package/dist/cdn/shared-4fa5f144.js +1 -0
- package/dist/cdn/shared-51b5e223.js +1 -0
- package/dist/cdn/{shared-593f7e2c.js → shared-51e28c83.js} +1 -1
- package/dist/cdn/shared-710ed658.js +134 -0
- package/dist/cdn/shared-800a5471.js +1 -0
- package/dist/cdn/{shared-8a7bee0d.js → shared-8f7a66c4.js} +1 -1
- package/dist/cdn/{shared-91e768be.js → shared-9af7b5f0.js} +1 -1
- package/dist/cdn/{shared-7a42073a.js → shared-a11160e7.js} +5 -5
- package/dist/cdn/{shared-5f54e916.js → shared-a4e6ecb0.js} +1 -1
- package/dist/cdn/{shared-6ebe3825.js → shared-a8d96c23.js} +1 -1
- package/dist/cdn/{shared-322e60b1.js → shared-b03b6d72.js} +1 -1
- package/dist/cdn/shared-b2330475.js +1 -0
- package/dist/cdn/{shared-1761daef.js → shared-c1dadefe.js} +1 -1
- package/dist/cdn/shared-c6a4b2d6.js +1 -0
- package/dist/cdn/shared-ccea5a33.js +69 -0
- package/dist/cdn/shared-cd3c902e.js +1 -0
- package/dist/cdn/{shared-34b2c1e2.js → shared-d3831f99.js} +1 -1
- package/dist/cdn/shared-d9a260f0.js +1 -0
- package/dist/cdn/{shared-b1fc5dc3.js → shared-f875a4f8.js} +1 -1
- package/dist/cdn/{shared-e7f8ffe9.js → shared-fb403e1f.js} +1 -1
- package/dist/cdn/shared-ff149b55.js +804 -0
- package/dist/cdn/translations/customer-portal/zh-hk.json +35 -0
- package/dist/cdn/translations/shared/en.json +105 -0
- package/dist/cdn/translations/shared/zh-hk.json +179 -0
- package/dist/elements/private/Checkbox/Checkbox.js +36 -22
- package/dist/elements/private/Checkbox/Checkbox.js.map +1 -1
- package/dist/elements/private/EditableList/EditableList.d.ts +20 -0
- package/dist/elements/private/EditableList/EditableList.js +123 -0
- package/dist/elements/private/EditableList/EditableList.js.map +1 -0
- package/dist/elements/public/CouponCard/CouponCard.d.ts +29 -0
- package/dist/elements/public/CouponCard/CouponCard.js +130 -0
- package/dist/elements/public/CouponCard/CouponCard.js.map +1 -0
- package/dist/elements/public/CouponCard/index.d.ts +5 -0
- package/dist/elements/public/CouponCard/index.js +7 -0
- package/dist/elements/public/CouponCard/index.js.map +1 -0
- package/dist/elements/public/CouponCard/types.d.ts +15 -0
- package/dist/elements/public/CouponCard/types.js +2 -0
- package/dist/elements/public/CouponCard/types.js.map +1 -0
- package/dist/elements/public/CouponCodeForm/CouponCodeForm.d.ts +45 -0
- package/dist/elements/public/CouponCodeForm/CouponCodeForm.js +218 -0
- package/dist/elements/public/CouponCodeForm/CouponCodeForm.js.map +1 -0
- package/dist/elements/public/CouponCodeForm/index.d.ts +8 -0
- package/dist/elements/public/CouponCodeForm/index.js +10 -0
- package/dist/elements/public/CouponCodeForm/index.js.map +1 -0
- package/dist/elements/public/CouponCodeForm/types.d.ts +15 -0
- package/dist/elements/public/CouponCodeForm/types.js +2 -0
- package/dist/elements/public/CouponCodeForm/types.js.map +1 -0
- package/dist/elements/public/CouponCodesForm/CouponCodesForm.d.ts +29 -0
- package/dist/elements/public/CouponCodesForm/CouponCodesForm.js +209 -0
- package/dist/elements/public/CouponCodesForm/CouponCodesForm.js.map +1 -0
- package/dist/elements/public/CouponCodesForm/index.d.ts +8 -0
- package/dist/elements/public/CouponCodesForm/index.js +12 -0
- package/dist/elements/public/CouponCodesForm/index.js.map +1 -0
- package/dist/elements/public/CouponCodesForm/internal/InternalCouponCodesFormListItem.d.ts +14 -0
- package/dist/elements/public/CouponCodesForm/internal/InternalCouponCodesFormListItem.js +48 -0
- package/dist/elements/public/CouponCodesForm/internal/InternalCouponCodesFormListItem.js.map +1 -0
- package/dist/elements/public/CouponCodesForm/types.d.ts +16 -0
- package/dist/elements/public/CouponCodesForm/types.js +2 -0
- package/dist/elements/public/CouponCodesForm/types.js.map +1 -0
- package/dist/elements/public/CouponForm/CouponForm.d.ts +77 -0
- package/dist/elements/public/CouponForm/CouponForm.js +1266 -0
- package/dist/elements/public/CouponForm/CouponForm.js.map +1 -0
- package/dist/elements/public/CouponForm/index.d.ts +19 -0
- package/dist/elements/public/CouponForm/index.js +21 -0
- package/dist/elements/public/CouponForm/index.js.map +1 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.d.ts +19 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.js +98 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.js.map +1 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.d.ts +19 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.js +51 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.js.map +1 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.d.ts +19 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.js +52 -0
- package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.js.map +1 -0
- package/dist/elements/public/CouponForm/types.d.ts +27 -0
- package/dist/elements/public/CouponForm/types.js +2 -0
- package/dist/elements/public/CouponForm/types.js.map +1 -0
- package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.d.ts +39 -0
- package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.js +197 -0
- package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.js.map +1 -0
- package/dist/elements/public/GenerateCodesForm/index.d.ts +8 -0
- package/dist/elements/public/GenerateCodesForm/index.js +10 -0
- package/dist/elements/public/GenerateCodesForm/index.js.map +1 -0
- package/dist/elements/public/GenerateCodesForm/types.d.ts +24 -0
- package/dist/elements/public/GenerateCodesForm/types.js +2 -0
- package/dist/elements/public/GenerateCodesForm/types.js.map +1 -0
- package/dist/elements/public/I18n/format/date.js +7 -6
- package/dist/elements/public/I18n/format/date.js.map +1 -1
- package/dist/elements/public/I18n/format/discount.d.ts +6 -0
- package/dist/elements/public/I18n/format/discount.js +20 -0
- package/dist/elements/public/I18n/format/discount.js.map +1 -0
- package/dist/elements/public/I18n/format/index.js +4 -0
- package/dist/elements/public/I18n/format/index.js.map +1 -1
- package/dist/elements/public/I18n/format/ordinal.d.ts +6 -0
- package/dist/elements/public/I18n/format/ordinal.js +9 -0
- package/dist/elements/public/I18n/format/ordinal.js.map +1 -0
- package/dist/elements/public/Pagination/Pagination.d.ts +37 -0
- package/dist/elements/public/Pagination/Pagination.js +154 -0
- package/dist/elements/public/Pagination/Pagination.js.map +1 -0
- package/dist/elements/public/Pagination/index.d.ts +6 -0
- package/dist/elements/public/Pagination/index.js +8 -0
- package/dist/elements/public/Pagination/index.js.map +1 -0
- package/dist/elements/public/Table/Table.js +20 -5
- package/dist/elements/public/Table/Table.js.map +1 -1
- package/dist/elements/public/index.d.ts +6 -0
- package/dist/elements/public/index.defined.d.ts +6 -0
- package/dist/elements/public/index.defined.js +6 -0
- package/dist/elements/public/index.defined.js.map +1 -1
- package/dist/elements/public/index.js +6 -0
- package/dist/elements/public/index.js.map +1 -1
- package/dist/mixins/themeable.js +80 -4
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-00563cb0.js +0 -1
- package/dist/cdn/shared-1f1734cb.js +0 -264
- package/dist/cdn/shared-66cb6a36.js +0 -1
- package/dist/cdn/shared-9a40309d.js +0 -1
- package/dist/cdn/shared-9c099da6.js +0 -1
- package/dist/cdn/shared-ce1da35d.js +0 -1
- package/dist/cdn/shared-f1dc1c6c.js +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Data, Templates } from './types';
|
|
2
|
+
import { TemplateResult } from 'lit-html';
|
|
3
|
+
import { NucleonElement } from '../NucleonElement/NucleonElement';
|
|
4
|
+
import { NucleonV8N } from '../NucleonElement/types';
|
|
5
|
+
declare const Base: typeof NucleonElement & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
6
|
+
defaultNS: string;
|
|
7
|
+
} & {
|
|
8
|
+
styles: import("lit-element").CSSResultArray;
|
|
9
|
+
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost>;
|
|
10
|
+
/**
|
|
11
|
+
* Form element for generating codes for coupons or gift cards (`fx:generate_codes`).
|
|
12
|
+
*
|
|
13
|
+
* @slot length:before
|
|
14
|
+
* @slot length:after
|
|
15
|
+
*
|
|
16
|
+
* @slot number-of-codes:before
|
|
17
|
+
* @slot number-of-codes:after
|
|
18
|
+
*
|
|
19
|
+
* @slot prefix:before
|
|
20
|
+
* @slot prefix:after
|
|
21
|
+
*
|
|
22
|
+
* @slot generate:before
|
|
23
|
+
* @slot generate:after
|
|
24
|
+
*
|
|
25
|
+
* @element foxy-generate-codes-form
|
|
26
|
+
* @since 1.15.0
|
|
27
|
+
*/
|
|
28
|
+
export declare class GenerateCodesForm extends Base<Data> {
|
|
29
|
+
static get v8n(): NucleonV8N<Data>;
|
|
30
|
+
templates: Templates;
|
|
31
|
+
render(): TemplateResult;
|
|
32
|
+
private __getErrorMessage;
|
|
33
|
+
private __getValidator;
|
|
34
|
+
private __renderLength;
|
|
35
|
+
private __renderNumberOfCodes;
|
|
36
|
+
private __renderPrefix;
|
|
37
|
+
private __renderGenerate;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { html } from 'lit-html';
|
|
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";
|
|
6
|
+
import { classMap } from "../../../utils/class-map.js";
|
|
7
|
+
const NS = 'generate-codes';
|
|
8
|
+
const Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)));
|
|
9
|
+
/**
|
|
10
|
+
* Form element for generating codes for coupons or gift cards (`fx:generate_codes`).
|
|
11
|
+
*
|
|
12
|
+
* @slot length:before
|
|
13
|
+
* @slot length:after
|
|
14
|
+
*
|
|
15
|
+
* @slot number-of-codes:before
|
|
16
|
+
* @slot number-of-codes:after
|
|
17
|
+
*
|
|
18
|
+
* @slot prefix:before
|
|
19
|
+
* @slot prefix:after
|
|
20
|
+
*
|
|
21
|
+
* @slot generate:before
|
|
22
|
+
* @slot generate:after
|
|
23
|
+
*
|
|
24
|
+
* @element foxy-generate-codes-form
|
|
25
|
+
* @since 1.15.0
|
|
26
|
+
*/
|
|
27
|
+
export class GenerateCodesForm extends Base {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.templates = {};
|
|
31
|
+
}
|
|
32
|
+
static get v8n() {
|
|
33
|
+
return [
|
|
34
|
+
({ number_of_codes: v }) => (v && v > 0) || 'number_of_codes_required',
|
|
35
|
+
({ length: v }) => (v && v > 0) || 'length_required',
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const { hiddenSelector, lang, ns } = this;
|
|
41
|
+
const isBusy = this.in('busy');
|
|
42
|
+
const isFail = this.in('fail');
|
|
43
|
+
const isSnapshot = this.in({ idle: 'snapshot' });
|
|
44
|
+
const isTemplate = this.in({ idle: 'template' });
|
|
45
|
+
const transition = 'transition-opacity duration-500';
|
|
46
|
+
const hidden = 'opacity-0 pointer-events-none';
|
|
47
|
+
return html `
|
|
48
|
+
<div aria-busy=${isBusy} aria-live="polite" class="relative">
|
|
49
|
+
<div
|
|
50
|
+
class=${classMap({
|
|
51
|
+
'grid grid-cols-2 gap-m': true,
|
|
52
|
+
[transition]: true,
|
|
53
|
+
[hidden]: isSnapshot,
|
|
54
|
+
})}
|
|
55
|
+
>
|
|
56
|
+
${hiddenSelector.matches('length', true) ? '' : this.__renderLength()}
|
|
57
|
+
${hiddenSelector.matches('number-of-codes', true) ? '' : this.__renderNumberOfCodes()}
|
|
58
|
+
${hiddenSelector.matches('prefix', true) ? '' : this.__renderPrefix()}
|
|
59
|
+
${hiddenSelector.matches('generate', true) ? '' : this.__renderGenerate()}
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
class=${classMap({
|
|
64
|
+
'absolute inset-0 flex flex-col items-center justify-center': true,
|
|
65
|
+
'text-center text-m text-secondary leading-m': true,
|
|
66
|
+
[transition]: true,
|
|
67
|
+
[hidden]: !isSnapshot,
|
|
68
|
+
})}
|
|
69
|
+
>
|
|
70
|
+
<div class="mx-auto flex mb-m w-l h-l rounded-t-l rounded-b-l bg-success">
|
|
71
|
+
<iron-icon icon="icons:done-all" class="m-auto text-success-contrast"></iron-icon>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<foxy-i18n class="block" lang=${lang} key="generate_codes_done" ns=${ns}></foxy-i18n>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div
|
|
78
|
+
class=${classMap({
|
|
79
|
+
'absolute inset-0 flex': true,
|
|
80
|
+
[transition]: true,
|
|
81
|
+
[hidden]: !isBusy && !isFail,
|
|
82
|
+
})}
|
|
83
|
+
>
|
|
84
|
+
<foxy-spinner
|
|
85
|
+
layout="vertical"
|
|
86
|
+
class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
|
|
87
|
+
state=${isFail ? 'error' : isTemplate ? 'empty' : 'busy'}
|
|
88
|
+
lang=${lang}
|
|
89
|
+
ns="${ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
|
|
90
|
+
>
|
|
91
|
+
</foxy-spinner>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
`;
|
|
95
|
+
}
|
|
96
|
+
__getErrorMessage(prefix) {
|
|
97
|
+
const error = this.errors.find(err => err.startsWith(prefix));
|
|
98
|
+
return error ? this.t(error.replace(prefix, 'v8n')) : '';
|
|
99
|
+
}
|
|
100
|
+
__getValidator(prefix) {
|
|
101
|
+
return () => !this.errors.some(err => err.startsWith(prefix));
|
|
102
|
+
}
|
|
103
|
+
__renderLength() {
|
|
104
|
+
const isTemplate = this.in({ idle: 'template' });
|
|
105
|
+
return html `
|
|
106
|
+
${this.renderTemplateOrSlot('length:before')}
|
|
107
|
+
|
|
108
|
+
<vaadin-integer-field
|
|
109
|
+
error-message=${this.__getErrorMessage('length')}
|
|
110
|
+
label=${this.t('length')}
|
|
111
|
+
class="w-full"
|
|
112
|
+
min="1"
|
|
113
|
+
?disabled=${!isTemplate || this.disabledSelector.matches('length', true)}
|
|
114
|
+
?readonly=${this.readonlySelector.matches('length', true)}
|
|
115
|
+
prevent-invalid-input
|
|
116
|
+
has-controls
|
|
117
|
+
.checkValidity=${this.__getValidator('length')}
|
|
118
|
+
.value=${isTemplate ? this.form.length : ''}
|
|
119
|
+
@change=${(evt) => {
|
|
120
|
+
const field = evt.currentTarget;
|
|
121
|
+
this.edit({ length: parseInt(field.value) });
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
</vaadin-integer-field>
|
|
125
|
+
|
|
126
|
+
${this.renderTemplateOrSlot('length:after')}
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
__renderNumberOfCodes() {
|
|
130
|
+
const isTemplate = this.in({ idle: 'template' });
|
|
131
|
+
return html `
|
|
132
|
+
${this.renderTemplateOrSlot('number-of-codes:before')}
|
|
133
|
+
|
|
134
|
+
<vaadin-integer-field
|
|
135
|
+
error-message=${this.__getErrorMessage('number_of_codes')}
|
|
136
|
+
label=${this.t('number_of_codes')}
|
|
137
|
+
class="w-full"
|
|
138
|
+
min="1"
|
|
139
|
+
?disabled=${!isTemplate || this.disabledSelector.matches('number-of-codes', true)}
|
|
140
|
+
?readonly=${this.readonlySelector.matches('number-of-codes', true)}
|
|
141
|
+
prevent-invalid-input
|
|
142
|
+
has-controls
|
|
143
|
+
.checkValidity=${this.__getValidator('number_of_codes')}
|
|
144
|
+
.value=${isTemplate ? this.form.number_of_codes : ''}
|
|
145
|
+
@change=${(evt) => {
|
|
146
|
+
const field = evt.currentTarget;
|
|
147
|
+
this.edit({ number_of_codes: parseInt(field.value) });
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
</vaadin-integer-field>
|
|
151
|
+
|
|
152
|
+
${this.renderTemplateOrSlot('number-of-codes:after')}
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
__renderPrefix() {
|
|
156
|
+
const isTemplate = this.in({ idle: 'template' });
|
|
157
|
+
return html `
|
|
158
|
+
${this.renderTemplateOrSlot('prefix:before')}
|
|
159
|
+
|
|
160
|
+
<vaadin-text-field
|
|
161
|
+
helper-text=${this.t('leave_empty_for_random_codes')}
|
|
162
|
+
label=${this.t('prefix')}
|
|
163
|
+
class="col-span-2"
|
|
164
|
+
min="1"
|
|
165
|
+
?disabled=${!isTemplate || this.disabledSelector.matches('prefix', true)}
|
|
166
|
+
?readonly=${this.readonlySelector.matches('prefix', true)}
|
|
167
|
+
clear-button-visible
|
|
168
|
+
.value=${isTemplate ? this.form.prefix : ''}
|
|
169
|
+
@change=${(evt) => {
|
|
170
|
+
const field = evt.currentTarget;
|
|
171
|
+
this.edit({ prefix: field.value });
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
</vaadin-text-field>
|
|
175
|
+
|
|
176
|
+
${this.renderTemplateOrSlot('prefix:after')}
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
__renderGenerate() {
|
|
180
|
+
const isValidTemplate = this.in({ idle: { template: { dirty: 'valid' } } });
|
|
181
|
+
return html `
|
|
182
|
+
${this.renderTemplateOrSlot('generate:before')}
|
|
183
|
+
|
|
184
|
+
<vaadin-button
|
|
185
|
+
class="col-span-2"
|
|
186
|
+
theme="success primary"
|
|
187
|
+
?disabled=${!isValidTemplate || this.disabledSelector.matches('generate', true)}
|
|
188
|
+
@click=${this.submit}
|
|
189
|
+
>
|
|
190
|
+
<foxy-i18n lang=${this.lang} key="generate" ns=${this.ns}></foxy-i18n>
|
|
191
|
+
</vaadin-button>
|
|
192
|
+
|
|
193
|
+
${this.renderTemplateOrSlot('create:after')}
|
|
194
|
+
`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=GenerateCodesForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateCodesForm.js","sourceRoot":"","sources":["../../../../src/elements/public/GenerateCodesForm/GenerateCodesForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAGlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC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AAC;;iBAEhD,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;kBACjC,CAAC,GAAgB,EAAE,EAAE;YAC7B,MAAM,KAAK,GAAG,GAAG,CAAC,aAAiC,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC;;;;QAID,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC;KAC5C,CAAC;IACJ,CAAC;IAEO,gBAAgB;QACtB,MAAM,eAAe,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAE5E,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;;;;;oBAKhC,CAAC,eAAe,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC;iBACtE,IAAI,CAAC,MAAM;;0BAEF,IAAI,CAAC,IAAI,sBAAsB,IAAI,CAAC,EAAE;;;QAGxD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC;KAC5C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Data, Templates } from './types';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { IntegerFieldElement } from '@vaadin/vaadin-text-field/vaadin-integer-field';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst NS = 'generate-codes';\nconst Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)));\n\n/**\n * Form element for generating codes for coupons or gift cards (`fx:generate_codes`).\n *\n * @slot length:before\n * @slot length:after\n *\n * @slot number-of-codes:before\n * @slot number-of-codes:after\n *\n * @slot prefix:before\n * @slot prefix:after\n *\n * @slot generate:before\n * @slot generate:after\n *\n * @element foxy-generate-codes-form\n * @since 1.15.0\n */\nexport class GenerateCodesForm extends Base<Data> {\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ number_of_codes: v }) => (v && v > 0) || 'number_of_codes_required',\n ({ length: v }) => (v && v > 0) || 'length_required',\n ];\n }\n\n templates: Templates = {};\n\n render(): TemplateResult {\n const { hiddenSelector, lang, ns } = this;\n\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n const isSnapshot = this.in({ idle: 'snapshot' });\n const isTemplate = this.in({ idle: 'template' });\n\n const transition = 'transition-opacity duration-500';\n const hidden = 'opacity-0 pointer-events-none';\n\n return html`\n <div aria-busy=${isBusy} aria-live=\"polite\" class=\"relative\">\n <div\n class=${classMap({\n 'grid grid-cols-2 gap-m': true,\n [transition]: true,\n [hidden]: isSnapshot,\n })}\n >\n ${hiddenSelector.matches('length', true) ? '' : this.__renderLength()}\n ${hiddenSelector.matches('number-of-codes', true) ? '' : this.__renderNumberOfCodes()}\n ${hiddenSelector.matches('prefix', true) ? '' : this.__renderPrefix()}\n ${hiddenSelector.matches('generate', true) ? '' : this.__renderGenerate()}\n </div>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex flex-col items-center justify-center': true,\n 'text-center text-m text-secondary leading-m': true,\n [transition]: true,\n [hidden]: !isSnapshot,\n })}\n >\n <div class=\"mx-auto flex mb-m w-l h-l rounded-t-l rounded-b-l bg-success\">\n <iron-icon icon=\"icons:done-all\" class=\"m-auto text-success-contrast\"></iron-icon>\n </div>\n\n <foxy-i18n class=\"block\" lang=${lang} key=\"generate_codes_done\" ns=${ns}></foxy-i18n>\n </div>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex': true,\n [transition]: true,\n [hidden]: !isBusy && !isFail,\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${isFail ? 'error' : isTemplate ? 'empty' : 'busy'}\n lang=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __getErrorMessage(prefix: string) {\n const error = this.errors.find(err => err.startsWith(prefix));\n return error ? this.t(error.replace(prefix, 'v8n')) : '';\n }\n\n private __getValidator(prefix: string) {\n return () => !this.errors.some(err => err.startsWith(prefix));\n }\n\n private __renderLength() {\n const isTemplate = this.in({ idle: 'template' });\n\n return html`\n ${this.renderTemplateOrSlot('length:before')}\n\n <vaadin-integer-field\n error-message=${this.__getErrorMessage('length')}\n label=${this.t('length')}\n class=\"w-full\"\n min=\"1\"\n ?disabled=${!isTemplate || this.disabledSelector.matches('length', true)}\n ?readonly=${this.readonlySelector.matches('length', true)}\n prevent-invalid-input\n has-controls\n .checkValidity=${this.__getValidator('length')}\n .value=${isTemplate ? this.form.length : ''}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as IntegerFieldElement;\n this.edit({ length: parseInt(field.value) });\n }}\n >\n </vaadin-integer-field>\n\n ${this.renderTemplateOrSlot('length:after')}\n `;\n }\n\n private __renderNumberOfCodes() {\n const isTemplate = this.in({ idle: 'template' });\n\n return html`\n ${this.renderTemplateOrSlot('number-of-codes:before')}\n\n <vaadin-integer-field\n error-message=${this.__getErrorMessage('number_of_codes')}\n label=${this.t('number_of_codes')}\n class=\"w-full\"\n min=\"1\"\n ?disabled=${!isTemplate || this.disabledSelector.matches('number-of-codes', true)}\n ?readonly=${this.readonlySelector.matches('number-of-codes', true)}\n prevent-invalid-input\n has-controls\n .checkValidity=${this.__getValidator('number_of_codes')}\n .value=${isTemplate ? this.form.number_of_codes : ''}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as IntegerFieldElement;\n this.edit({ number_of_codes: parseInt(field.value) });\n }}\n >\n </vaadin-integer-field>\n\n ${this.renderTemplateOrSlot('number-of-codes:after')}\n `;\n }\n\n private __renderPrefix() {\n const isTemplate = this.in({ idle: 'template' });\n\n return html`\n ${this.renderTemplateOrSlot('prefix:before')}\n\n <vaadin-text-field\n helper-text=${this.t('leave_empty_for_random_codes')}\n label=${this.t('prefix')}\n class=\"col-span-2\"\n min=\"1\"\n ?disabled=${!isTemplate || this.disabledSelector.matches('prefix', true)}\n ?readonly=${this.readonlySelector.matches('prefix', true)}\n clear-button-visible\n .value=${isTemplate ? this.form.prefix : ''}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as TextFieldElement;\n this.edit({ prefix: field.value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('prefix:after')}\n `;\n }\n\n private __renderGenerate() {\n const isValidTemplate = this.in({ idle: { template: { dirty: 'valid' } } });\n\n return html`\n ${this.renderTemplateOrSlot('generate:before')}\n\n <vaadin-button\n class=\"col-span-2\"\n theme=\"success primary\"\n ?disabled=${!isValidTemplate || this.disabledSelector.matches('generate', true)}\n @click=${this.submit}\n >\n <foxy-i18n lang=${this.lang} key=\"generate\" ns=${this.ns}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '@vaadin/vaadin-text-field/vaadin-integer-field';
|
|
2
|
+
import '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
3
|
+
import '@vaadin/vaadin-button';
|
|
4
|
+
import '../../internal/InternalSandbox/index';
|
|
5
|
+
import '../Spinner/index';
|
|
6
|
+
import '../I18n/index';
|
|
7
|
+
import { GenerateCodesForm } from './GenerateCodesForm';
|
|
8
|
+
export { GenerateCodesForm };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '@vaadin/vaadin-text-field/vaadin-integer-field';
|
|
2
|
+
import '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
3
|
+
import '@vaadin/vaadin-button';
|
|
4
|
+
import "../../internal/InternalSandbox/index.js";
|
|
5
|
+
import "../Spinner/index.js";
|
|
6
|
+
import "../I18n/index.js";
|
|
7
|
+
import { GenerateCodesForm } from "./GenerateCodesForm.js";
|
|
8
|
+
customElements.define('foxy-generate-codes-form', GenerateCodesForm);
|
|
9
|
+
export { GenerateCodesForm };
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/GenerateCodesForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAC;AACxD,OAAO,6CAA6C,CAAC;AACrD,OAAO,uBAAuB,CAAC;AAC/B,iDAA8C;AAC9C,6BAA0B;AAC1B,0BAAuB;AAEvB,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AAExD,cAAc,CAAC,MAAM,CAAC,0BAA0B,EAAE,iBAAiB,CAAC,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import '@vaadin/vaadin-text-field/vaadin-integer-field';\nimport '@vaadin/vaadin-text-field/vaadin-text-field';\nimport '@vaadin/vaadin-button';\nimport '../../internal/InternalSandbox/index';\nimport '../Spinner/index';\nimport '../I18n/index';\n\nimport { GenerateCodesForm } from './GenerateCodesForm';\n\ncustomElements.define('foxy-generate-codes-form', GenerateCodesForm);\n\nexport { GenerateCodesForm };\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GenerateCodesForm } from '.';
|
|
2
|
+
import { Rels } from '@foxy.io/sdk/backend';
|
|
3
|
+
import { Renderer } from '../../../mixins/configurable';
|
|
4
|
+
import { Resource } from '@foxy.io/sdk/core';
|
|
5
|
+
export declare type Data = Resource<Rels.GenerateCodes> & {
|
|
6
|
+
/** Present only in the response. */
|
|
7
|
+
_links: {
|
|
8
|
+
self: {
|
|
9
|
+
href: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/** Present only in the response. */
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export declare type Templates = {
|
|
16
|
+
'length:before'?: Renderer<GenerateCodesForm>;
|
|
17
|
+
'length:after'?: Renderer<GenerateCodesForm>;
|
|
18
|
+
'number-of-codes:before'?: Renderer<GenerateCodesForm>;
|
|
19
|
+
'number-of-codes:after'?: Renderer<GenerateCodesForm>;
|
|
20
|
+
'prefix:before'?: Renderer<GenerateCodesForm>;
|
|
21
|
+
'prefix:after'?: Renderer<GenerateCodesForm>;
|
|
22
|
+
'generate:before'?: Renderer<GenerateCodesForm>;
|
|
23
|
+
'generate:after'?: Renderer<GenerateCodesForm>;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/GenerateCodesForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GenerateCodesForm } from '.';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Renderer } from '../../../mixins/configurable';\nimport { Resource } from '@foxy.io/sdk/core';\n\nexport type Data = Resource<Rels.GenerateCodes> & {\n /** Present only in the response. */\n _links: { self: { href: string } };\n /** Present only in the response. */\n message: string;\n};\n\nexport type Templates = {\n 'length:before'?: Renderer<GenerateCodesForm>;\n 'length:after'?: Renderer<GenerateCodesForm>;\n 'number-of-codes:before'?: Renderer<GenerateCodesForm>;\n 'number-of-codes:after'?: Renderer<GenerateCodesForm>;\n 'prefix:before'?: Renderer<GenerateCodesForm>;\n 'prefix:after'?: Renderer<GenerateCodesForm>;\n 'generate:before'?: Renderer<GenerateCodesForm>;\n 'generate:after'?: Renderer<GenerateCodesForm>;\n};\n"]}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* i18next formatter that localizes ISO date.
|
|
3
3
|
* @see https://www.i18next.com/translation-function/formatting
|
|
4
4
|
*/
|
|
5
|
-
export const date = (value,
|
|
5
|
+
export const date = (value, _, lang) => {
|
|
6
|
+
if (!value)
|
|
7
|
+
return '$t(unknown)';
|
|
6
8
|
const valueAsDate = new Date(value);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
9
|
+
const month = 'long';
|
|
10
|
+
const year = new Date().getFullYear() === valueAsDate.getFullYear() ? undefined : 'numeric';
|
|
11
|
+
const day = 'numeric';
|
|
12
|
+
return valueAsDate.toLocaleDateString(lang, { month, year, day });
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/date.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAmB,CAAC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/date.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAmB,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAU,EAAE;IAC7D,IAAI,CAAC,KAAK;QAAE,OAAO,aAAa,CAAC;IAEjC,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC;IACrB,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5F,MAAM,GAAG,GAAG,SAAS,CAAC;IAEtB,OAAO,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACpE,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\n\n/**\n * i18next formatter that localizes ISO date.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const date: FormatFunction = (value, _, lang): string => {\n if (!value) return '$t(unknown)';\n\n const valueAsDate = new Date(value);\n const month = 'long';\n const year = new Date().getFullYear() === valueAsDate.getFullYear() ? undefined : 'numeric';\n const day = 'numeric';\n\n return valueAsDate.toLocaleDateString(lang, { month, year, day });\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18next formatter that returns a human-readable discount description for an API value.
|
|
3
|
+
* @see https://www.i18next.com/translation-function/formatting
|
|
4
|
+
*/
|
|
5
|
+
export const discount = ({ type, details }, format, lang) => {
|
|
6
|
+
const methods = ['allunits', 'incremental', 'repeat', 'single'];
|
|
7
|
+
const factor = type.endsWith('_percentage') ? 0.01 : 1;
|
|
8
|
+
const tiers = details.split('|');
|
|
9
|
+
const method = methods.includes(tiers[0]) ? tiers.shift() : 'single';
|
|
10
|
+
const i18nKey = `${method}_${type}_discount_summary`;
|
|
11
|
+
const translatedTiers = tiers.map(tier => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const signIndex = (_b = (_a = /[-+]/.exec(tier)) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : -1;
|
|
14
|
+
const adjustment = parseFloat(tier.substring(signIndex)) * factor;
|
|
15
|
+
const from = parseFloat(tier.substring(0, signIndex));
|
|
16
|
+
return `$t(${i18nKey}, ${JSON.stringify({ adjustment, from })})`;
|
|
17
|
+
});
|
|
18
|
+
return translatedTiers.join('; ');
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=discount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discount.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/discount.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAS,EAAE,MAAM,EAAE,IAAI,EAAU,EAAE;IACzF,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrE,MAAM,OAAO,GAAG,GAAG,MAAM,IAAI,IAAI,mBAAmB,CAAC;IAErD,MAAM,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;;QACvC,MAAM,SAAS,eAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,0CAAE,KAAK,mCAAI,CAAC,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC;QAClE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAEtD,OAAO,MAAM,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\n\ntype Value = { type: string; details: string };\n\n/**\n * i18next formatter that returns a human-readable discount description for an API value.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const discount: FormatFunction = ({ type, details }: Value, format, lang): string => {\n const methods = ['allunits', 'incremental', 'repeat', 'single'];\n const factor = type.endsWith('_percentage') ? 0.01 : 1;\n const tiers = details.split('|');\n const method = methods.includes(tiers[0]) ? tiers.shift() : 'single';\n const i18nKey = `${method}_${type}_discount_summary`;\n\n const translatedTiers = tiers.map(tier => {\n const signIndex = /[-+]/.exec(tier)?.index ?? -1;\n const adjustment = parseFloat(tier.substring(signIndex)) * factor;\n const from = parseFloat(tier.substring(0, signIndex));\n\n return `$t(${i18nKey}, ${JSON.stringify({ adjustment, from })})`;\n });\n\n return translatedTiers.join('; ');\n};\n"]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { date } from "./date.js";
|
|
2
|
+
import { discount } from "./discount.js";
|
|
3
|
+
import { ordinal } from "./ordinal.js";
|
|
2
4
|
import { percent } from "./percent.js";
|
|
3
5
|
import { price } from "./price.js";
|
|
4
6
|
import { time } from "./time.js";
|
|
5
7
|
const formatters = {
|
|
8
|
+
discount,
|
|
6
9
|
percent,
|
|
10
|
+
ordinal,
|
|
7
11
|
price,
|
|
8
12
|
date,
|
|
9
13
|
time,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,IAAI,EAAE,kBAAe;AAE9B,MAAM,UAAU,GAAmC;IACjD,OAAO;IACP,KAAK;IACL,IAAI;IACJ,IAAI;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,EAAE,EAAU,EAAE;IAC1F,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;;QACnD,mBAAO,UAAU,CAAC,IAAI,CAAC,+CAAhB,UAAU,EAAS,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,oCAAK,MAAM,CAAC;IAChE,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\nimport { date } from './date';\nimport { percent } from './percent';\nimport { price } from './price';\nimport { time } from './time';\n\nconst formatters: Record<string, FormatFunction> = {\n percent,\n price,\n date,\n time,\n};\n\n/**\n * Chooses the right i18next formatter for the given template.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const format: FormatFunction = (value, names = '', lang = 'en', opts = {}): string => {\n const parsedNames = names.split(' ').filter(v => !!v.trim());\n const applyFormat = (result: string, name: string) => {\n return formatters[name]?.(result, name, lang, opts) ?? result;\n };\n\n return parsedNames.reduce(applyFormat, value);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,QAAQ,EAAE,sBAAmB;AACtC,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,IAAI,EAAE,kBAAe;AAE9B,MAAM,UAAU,GAAmC;IACjD,QAAQ;IACR,OAAO;IACP,OAAO;IACP,KAAK;IACL,IAAI;IACJ,IAAI;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,EAAE,EAAU,EAAE;IAC1F,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;;QACnD,mBAAO,UAAU,CAAC,IAAI,CAAC,+CAAhB,UAAU,EAAS,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,oCAAK,MAAM,CAAC;IAChE,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\nimport { date } from './date';\nimport { discount } from './discount';\nimport { ordinal } from './ordinal';\nimport { percent } from './percent';\nimport { price } from './price';\nimport { time } from './time';\n\nconst formatters: Record<string, FormatFunction> = {\n discount,\n percent,\n ordinal,\n price,\n date,\n time,\n};\n\n/**\n * Chooses the right i18next formatter for the given template.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const format: FormatFunction = (value, names = '', lang = 'en', opts = {}): string => {\n const parsedNames = names.split(' ').filter(v => !!v.trim());\n const applyFormat = (result: string, name: string) => {\n return formatters[name]?.(result, name, lang, opts) ?? result;\n };\n\n return parsedNames.reduce(applyFormat, value);\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18next formatter that returns ordinal for a number.
|
|
3
|
+
* @see https://www.i18next.com/translation-function/formatting
|
|
4
|
+
*/
|
|
5
|
+
export const ordinal = (value, format, lang) => {
|
|
6
|
+
const rules = new Intl.PluralRules(lang, { type: 'ordinal' });
|
|
7
|
+
return `${value}$t(ordinal_${rules.select(value)})`;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=ordinal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordinal.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/ordinal.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAU,EAAE;IACrE,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9D,OAAO,GAAG,KAAK,cAAc,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AACtD,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\n\n/**\n * i18next formatter that returns ordinal for a number.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const ordinal: FormatFunction = (value, format, lang): string => {\n const rules = new Intl.PluralRules(lang, { type: 'ordinal' });\n return `${value}$t(ordinal_${rules.select(value)})`;\n};\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
|
+
declare const Base: typeof LitElement & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
3
|
+
defaultNS: string;
|
|
4
|
+
} & {
|
|
5
|
+
styles: import("lit-element").CSSResultArray;
|
|
6
|
+
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost>;
|
|
7
|
+
/**
|
|
8
|
+
* Helper element that adds pagination controls to elements
|
|
9
|
+
* representing Hypermedia API collection pages. Works with NucleonElement instances only.
|
|
10
|
+
* Page element **MUST** be a direct descendant of `foxy-pagination`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```html
|
|
14
|
+
* <foxy-pagination first="https://demo.api/hapi/customers?limit=3">
|
|
15
|
+
* <foxy-customers-table></foxy-customers-table>
|
|
16
|
+
* </foxy-pagination>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @element foxy-pagination
|
|
20
|
+
* @since 1.15.0
|
|
21
|
+
*/
|
|
22
|
+
export declare class Pagination extends Base {
|
|
23
|
+
static get properties(): PropertyDeclarations;
|
|
24
|
+
private __pageElement;
|
|
25
|
+
private __rerender;
|
|
26
|
+
private __first;
|
|
27
|
+
/** URL of the first page of the colletion. */
|
|
28
|
+
get first(): string;
|
|
29
|
+
set first(newValue: string);
|
|
30
|
+
connectedCallback(): void;
|
|
31
|
+
render(): TemplateResult;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
private __goTo;
|
|
34
|
+
private __disconnectPageElement;
|
|
35
|
+
private __connectPageElement;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { LitElement, html } from 'lit-element';
|
|
2
|
+
import { ConfigurableMixin } from "../../../mixins/configurable.js";
|
|
3
|
+
import { NucleonElement } from "../NucleonElement/NucleonElement.js";
|
|
4
|
+
import { ResponsiveMixin } from "../../../mixins/responsive.js";
|
|
5
|
+
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
6
|
+
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
7
|
+
import { classMap } from "../../../utils/class-map.js";
|
|
8
|
+
import get from 'lodash-es/get';
|
|
9
|
+
const NS = 'pagination';
|
|
10
|
+
const Base = ResponsiveMixin(ConfigurableMixin(ThemeableMixin(TranslatableMixin(LitElement, NS))));
|
|
11
|
+
/**
|
|
12
|
+
* Helper element that adds pagination controls to elements
|
|
13
|
+
* representing Hypermedia API collection pages. Works with NucleonElement instances only.
|
|
14
|
+
* Page element **MUST** be a direct descendant of `foxy-pagination`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```html
|
|
18
|
+
* <foxy-pagination first="https://demo.api/hapi/customers?limit=3">
|
|
19
|
+
* <foxy-customers-table></foxy-customers-table>
|
|
20
|
+
* </foxy-pagination>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @element foxy-pagination
|
|
24
|
+
* @since 1.15.0
|
|
25
|
+
*/
|
|
26
|
+
export class Pagination extends Base {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.__pageElement = null;
|
|
30
|
+
this.__rerender = () => this.requestUpdate();
|
|
31
|
+
this.__first = '';
|
|
32
|
+
}
|
|
33
|
+
static get properties() {
|
|
34
|
+
return {
|
|
35
|
+
...super.properties,
|
|
36
|
+
first: { type: String },
|
|
37
|
+
__pageElement: { attribute: false },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** URL of the first page of the colletion. */
|
|
41
|
+
get first() {
|
|
42
|
+
return this.__first;
|
|
43
|
+
}
|
|
44
|
+
set first(newValue) {
|
|
45
|
+
this.__first = newValue;
|
|
46
|
+
if (this.__pageElement)
|
|
47
|
+
this.__pageElement.href = newValue;
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
super.connectedCallback();
|
|
51
|
+
this.__connectPageElement();
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
var _a;
|
|
55
|
+
const data = (_a = this.__pageElement) === null || _a === void 0 ? void 0 : _a.data;
|
|
56
|
+
const { disabled, lang, ns } = this;
|
|
57
|
+
const returnedItemsValue = Number(get(data, 'returned_items'));
|
|
58
|
+
const returnedItems = Number.isNaN(returnedItemsValue) ? 0 : returnedItemsValue;
|
|
59
|
+
const totalItemsValue = Number(get(data, 'total_items'));
|
|
60
|
+
const totalItems = Number.isNaN(totalItemsValue) ? 0 : totalItemsValue;
|
|
61
|
+
const offsetValue = Number(get(data, 'offset'));
|
|
62
|
+
const offset = Number.isNaN(offsetValue) ? 0 : offsetValue;
|
|
63
|
+
const canGoBack = !disabled && offset > 0;
|
|
64
|
+
const canGoForth = !disabled && offset + returnedItems < totalItems;
|
|
65
|
+
const labelClass = 'sr-only sm-not-sr-only';
|
|
66
|
+
return html `
|
|
67
|
+
<slot @slotchange=${this.__connectPageElement}></slot>
|
|
68
|
+
|
|
69
|
+
<div class="grid grid-cols-3 gap-s items-center">
|
|
70
|
+
<div class="flex items-center space-x-s">
|
|
71
|
+
<vaadin-button
|
|
72
|
+
theme="contrast tertiary-inline"
|
|
73
|
+
?disabled=${!canGoBack}
|
|
74
|
+
@click=${() => this.__goTo('first')}
|
|
75
|
+
>
|
|
76
|
+
<iron-icon class="icon-inline text-s" icon="icons:first-page"></iron-icon>
|
|
77
|
+
<foxy-i18n class=${labelClass} lang=${lang} key="first" ns=${ns}></foxy-i18n>
|
|
78
|
+
</vaadin-button>
|
|
79
|
+
|
|
80
|
+
<vaadin-button
|
|
81
|
+
theme="contrast tertiary-inline"
|
|
82
|
+
?disabled=${!canGoBack}
|
|
83
|
+
@click=${() => this.__goTo('prev')}
|
|
84
|
+
>
|
|
85
|
+
<iron-icon class="icon-inline text-s" icon="icons:chevron-left"></iron-icon>
|
|
86
|
+
<foxy-i18n class=${labelClass} lang=${lang} key="previous" ns=${ns}></foxy-i18n>
|
|
87
|
+
</vaadin-button>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<foxy-i18n
|
|
91
|
+
options=${JSON.stringify({
|
|
92
|
+
total: totalItems,
|
|
93
|
+
from: offset ? offset + 1 : 0,
|
|
94
|
+
to: offset + returnedItems,
|
|
95
|
+
})}
|
|
96
|
+
class=${classMap({
|
|
97
|
+
'flex-1 text-xs text-tertiary text-center leading-xs': true,
|
|
98
|
+
'opacity-0': !data,
|
|
99
|
+
})}
|
|
100
|
+
lang=${lang}
|
|
101
|
+
key="pagination"
|
|
102
|
+
ns=${ns}
|
|
103
|
+
>
|
|
104
|
+
</foxy-i18n>
|
|
105
|
+
|
|
106
|
+
<div class="flex items-center justify-end space-x-s">
|
|
107
|
+
<vaadin-button
|
|
108
|
+
theme="contrast tertiary-inline"
|
|
109
|
+
?disabled=${!canGoForth}
|
|
110
|
+
@click=${() => this.__goTo('next')}
|
|
111
|
+
>
|
|
112
|
+
<foxy-i18n class=${labelClass} lang=${lang} key="next" ns=${ns}></foxy-i18n>
|
|
113
|
+
<iron-icon class="icon-inline text-s" icon="icons:chevron-right"></iron-icon>
|
|
114
|
+
</vaadin-button>
|
|
115
|
+
|
|
116
|
+
<vaadin-button
|
|
117
|
+
theme="contrast tertiary-inline"
|
|
118
|
+
?disabled=${!canGoForth}
|
|
119
|
+
@click=${() => this.__goTo('last')}
|
|
120
|
+
>
|
|
121
|
+
<foxy-i18n class=${labelClass} lang=${lang} key="last" ns=${ns}></foxy-i18n>
|
|
122
|
+
<iron-icon class="icon-inline text-s" icon="icons:last-page"></iron-icon>
|
|
123
|
+
</vaadin-button>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
disconnectedCallback() {
|
|
129
|
+
super.disconnectedCallback();
|
|
130
|
+
this.__disconnectPageElement();
|
|
131
|
+
}
|
|
132
|
+
__goTo(rel) {
|
|
133
|
+
var _a;
|
|
134
|
+
this.__pageElement.href = String(get((_a = this.__pageElement) === null || _a === void 0 ? void 0 : _a.data, `_links.${rel}.href`));
|
|
135
|
+
}
|
|
136
|
+
__disconnectPageElement() {
|
|
137
|
+
var _a;
|
|
138
|
+
(_a = this.__pageElement) === null || _a === void 0 ? void 0 : _a.removeEventListener('update', this.__rerender);
|
|
139
|
+
this.__pageElement = null;
|
|
140
|
+
}
|
|
141
|
+
__connectPageElement() {
|
|
142
|
+
var _a;
|
|
143
|
+
this.__disconnectPageElement();
|
|
144
|
+
const slot = this.renderRoot.querySelector('slot');
|
|
145
|
+
const assignedElements = (_a = slot === null || slot === void 0 ? void 0 : slot.assignedElements()) !== null && _a !== void 0 ? _a : [];
|
|
146
|
+
const firstNucleonElement = assignedElements.find(el => el instanceof NucleonElement);
|
|
147
|
+
if (firstNucleonElement) {
|
|
148
|
+
this.__pageElement = firstNucleonElement;
|
|
149
|
+
this.__pageElement.addEventListener('update', this.__rerender);
|
|
150
|
+
this.__pageElement.href = this.first;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=Pagination.js.map
|