@foxy.io/elements 1.22.0-beta.3 → 1.22.0-beta.5

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.
Files changed (226) hide show
  1. package/dist/cdn/foxy-access-recovery-form.js +1 -1
  2. package/dist/cdn/foxy-address-card.js +2 -2
  3. package/dist/cdn/foxy-address-form.js +1 -1
  4. package/dist/cdn/foxy-admin-subscription-card.js +1 -1
  5. package/dist/cdn/foxy-api-browser.js +1 -1
  6. package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
  7. package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
  8. package/dist/cdn/foxy-applied-tax-card.js +1 -1
  9. package/dist/cdn/foxy-attribute-card.js +1 -1
  10. package/dist/cdn/foxy-attribute-form.js +1 -1
  11. package/dist/cdn/foxy-cancellation-form.js +1 -1
  12. package/dist/cdn/foxy-cart-card.js +1 -1
  13. package/dist/cdn/foxy-cart-form.js +1 -1
  14. package/dist/cdn/foxy-collection-page.js +1 -1
  15. package/dist/cdn/foxy-collection-pages.js +1 -1
  16. package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
  17. package/dist/cdn/foxy-coupon-card.js +1 -1
  18. package/dist/cdn/foxy-coupon-code-form.js +1 -1
  19. package/dist/cdn/foxy-coupon-codes-form.js +1 -1
  20. package/dist/cdn/foxy-coupon-detail-card.js +1 -1
  21. package/dist/cdn/foxy-coupon-form.js +1 -1
  22. package/dist/cdn/foxy-custom-field-card.js +1 -1
  23. package/dist/cdn/foxy-custom-field-form.js +1 -1
  24. package/dist/cdn/foxy-customer-card.js +1 -1
  25. package/dist/cdn/foxy-customer-form.js +1 -1
  26. package/dist/cdn/foxy-customer-portal-settings.js +1 -1
  27. package/dist/cdn/foxy-customer-portal.js +1 -1
  28. package/dist/cdn/foxy-customer.js +1 -1
  29. package/dist/cdn/foxy-customers-table.js +1 -1
  30. package/dist/cdn/foxy-discount-builder.js +1 -1
  31. package/dist/cdn/foxy-discount-card.js +1 -1
  32. package/dist/cdn/foxy-discount-detail-card.js +1 -1
  33. package/dist/cdn/foxy-donation.js +1 -1
  34. package/dist/cdn/foxy-downloadable-card.js +1 -0
  35. package/dist/cdn/foxy-downloadable-form.js +505 -0
  36. package/dist/cdn/foxy-email-template-card.js +1 -1
  37. package/dist/cdn/foxy-email-template-form.js +1 -1
  38. package/dist/cdn/foxy-error-entry-card.js +1 -1
  39. package/dist/cdn/foxy-form-dialog.js +1 -1
  40. package/dist/cdn/foxy-generate-codes-form.js +1 -1
  41. package/dist/cdn/foxy-gift-card-card.js +1 -1
  42. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  43. package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
  44. package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
  45. package/dist/cdn/foxy-gift-card-form.js +1 -1
  46. package/dist/cdn/foxy-i18n-editor.js +2 -2
  47. package/dist/cdn/foxy-i18n.js +1 -1
  48. package/dist/cdn/foxy-integration-card.js +1 -1
  49. package/dist/cdn/foxy-integration-form.js +1 -1
  50. package/dist/cdn/foxy-item-card.js +1 -1
  51. package/dist/cdn/foxy-item-category-card.js +1 -1
  52. package/dist/cdn/foxy-item-category-form.js +1 -1
  53. package/dist/cdn/foxy-item-form.js +1 -1
  54. package/dist/cdn/foxy-item-option-card.js +1 -1
  55. package/dist/cdn/foxy-item-option-form.js +1 -1
  56. package/dist/cdn/foxy-items-form.js +1 -1
  57. package/dist/cdn/foxy-pagination.js +1 -1
  58. package/dist/cdn/foxy-payment-card.js +1 -1
  59. package/dist/cdn/foxy-payment-method-card.js +1 -1
  60. package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
  61. package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
  62. package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
  63. package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
  64. package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
  65. package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
  66. package/dist/cdn/foxy-query-builder.js +1 -1
  67. package/dist/cdn/foxy-report-form.js +2 -2
  68. package/dist/cdn/foxy-reports-table.js +1 -1
  69. package/dist/cdn/foxy-shipment-card.js +1 -1
  70. package/dist/cdn/foxy-shipping-method-card.js +1 -1
  71. package/dist/cdn/foxy-sign-in-form.js +1 -1
  72. package/dist/cdn/foxy-spinner.js +2 -2
  73. package/dist/cdn/foxy-store-card.js +1 -1
  74. package/dist/cdn/foxy-store-form.js +1 -1
  75. package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
  76. package/dist/cdn/foxy-subscription-card.js +1 -1
  77. package/dist/cdn/foxy-subscription-form.js +1 -1
  78. package/dist/cdn/foxy-subscription-settings-form.js +1 -1
  79. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  80. package/dist/cdn/foxy-table.js +1 -1
  81. package/dist/cdn/foxy-tax-card.js +1 -1
  82. package/dist/cdn/foxy-tax-form.js +1 -1
  83. package/dist/cdn/foxy-template-config-form.js +1 -1
  84. package/dist/cdn/foxy-template-form.js +1 -1
  85. package/dist/cdn/foxy-template-set-card.js +1 -1
  86. package/dist/cdn/foxy-template-set-form.js +1 -1
  87. package/dist/cdn/foxy-transaction-card.js +1 -1
  88. package/dist/cdn/foxy-transaction.js +1 -1
  89. package/dist/cdn/foxy-transactions-table.js +7 -7
  90. package/dist/cdn/foxy-user-card.js +1 -1
  91. package/dist/cdn/foxy-user-form.js +1 -1
  92. package/dist/cdn/foxy-users-table.js +1 -1
  93. package/dist/cdn/foxy-webhook-card.js +1 -1
  94. package/dist/cdn/foxy-webhook-form.js +1 -1
  95. package/dist/cdn/foxy-webhook-log-card.js +1 -1
  96. package/dist/cdn/foxy-webhook-status-card.js +1 -1
  97. package/dist/cdn/shared-014f1513.js +1 -0
  98. package/dist/cdn/{shared-e6d3d6f5.js → shared-01ad847f.js} +1 -1
  99. package/dist/cdn/{shared-698c9002.js → shared-03858aee.js} +1 -1
  100. package/dist/cdn/{shared-a306168b.js → shared-055ca9db.js} +1 -1
  101. package/dist/cdn/{shared-a19ce620.js → shared-06c64816.js} +1 -1
  102. package/dist/cdn/{shared-685ca959.js → shared-15c94a90.js} +1 -1
  103. package/dist/cdn/{shared-f628a723.js → shared-178f7222.js} +1 -1
  104. package/dist/cdn/{shared-aa5785d9.js → shared-1a6fb0f3.js} +1 -1
  105. package/dist/cdn/{shared-1bd28b9c.js → shared-1a9496d4.js} +1 -1
  106. package/dist/cdn/{shared-b590adb2.js → shared-1f4b9c6b.js} +1 -1
  107. package/dist/cdn/{shared-5c5d13bd.js → shared-24a762c1.js} +1 -1
  108. package/dist/cdn/{shared-f42077ab.js → shared-2c6ea96d.js} +1 -1
  109. package/dist/cdn/{shared-50c6daa1.js → shared-38ed7905.js} +1 -1
  110. package/dist/cdn/{shared-87405fc7.js → shared-3b8b5eda.js} +3 -3
  111. package/dist/cdn/{shared-26390fea.js → shared-3b9b9427.js} +1 -1
  112. package/dist/cdn/{shared-67790b63.js → shared-4055f94a.js} +1 -1
  113. package/dist/cdn/{shared-cf49ce0c.js → shared-473aaeff.js} +1 -1
  114. package/dist/cdn/{shared-fad30ff5.js → shared-499c6db5.js} +1 -1
  115. package/dist/cdn/{shared-5a09ad7e.js → shared-49b65f1e.js} +1 -1
  116. package/dist/cdn/{shared-ccfb87fb.js → shared-4ac2a677.js} +1 -1
  117. package/dist/cdn/{shared-9e18688d.js → shared-533c3914.js} +3 -3
  118. package/dist/cdn/{shared-83a12835.js → shared-5425e3d3.js} +3 -3
  119. package/dist/cdn/{shared-468eb208.js → shared-57c6cfd1.js} +2 -2
  120. package/dist/cdn/{shared-493b8bc1.js → shared-590d8dae.js} +1 -1
  121. package/dist/cdn/{shared-7163796c.js → shared-5fbda766.js} +1 -1
  122. package/dist/cdn/{shared-445dda5a.js → shared-668947de.js} +1 -1
  123. package/dist/cdn/{shared-ffb6c2d3.js → shared-6f4005e5.js} +1 -1
  124. package/dist/cdn/{shared-308e67f3.js → shared-72817759.js} +1 -1
  125. package/dist/cdn/{shared-a6deb2a4.js → shared-7e9c240a.js} +1 -1
  126. package/dist/cdn/{shared-5cf7e764.js → shared-809df8d2.js} +1 -1
  127. package/dist/cdn/{shared-53af541e.js → shared-82f873bd.js} +1 -1
  128. package/dist/cdn/{shared-6860c8d1.js → shared-8b0c77a7.js} +1 -1
  129. package/dist/cdn/{shared-d7b778b7.js → shared-9271a609.js} +1 -1
  130. package/dist/cdn/{shared-00d2cbe9.js → shared-950875f2.js} +1 -1
  131. package/dist/cdn/{shared-f8bcab5c.js → shared-963c4a87.js} +1 -1
  132. package/dist/cdn/{shared-5a445ebd.js → shared-9725c399.js} +1 -1
  133. package/dist/cdn/{shared-dfe7652e.js → shared-9e04b9c3.js} +1 -1
  134. package/dist/cdn/{shared-b2d6bbad.js → shared-9e8bff76.js} +1 -1
  135. package/dist/cdn/shared-b137f17a.js +1 -0
  136. package/dist/cdn/{shared-5897f089.js → shared-b23ccea9.js} +1 -1
  137. package/dist/cdn/{shared-2b1c3f7a.js → shared-b2474263.js} +1 -1
  138. package/dist/cdn/{shared-c5fe5675.js → shared-bc36bc72.js} +1 -1
  139. package/dist/cdn/{shared-643791c8.js → shared-bcc4cf7f.js} +1 -1
  140. package/dist/cdn/{shared-2bae351a.js → shared-be591e92.js} +1 -1
  141. package/dist/cdn/shared-c0816371.js +1 -0
  142. package/dist/cdn/{shared-5ec39f11.js → shared-c0ec65fa.js} +1 -1
  143. package/dist/cdn/{shared-2a9718a9.js → shared-c1dd32b6.js} +1 -1
  144. package/dist/cdn/{shared-01dd0fd6.js → shared-c27aaa05.js} +1 -1
  145. package/dist/cdn/{shared-3c20c295.js → shared-c2cfc26d.js} +1 -1
  146. package/dist/cdn/{shared-394981eb.js → shared-c2ec3291.js} +1 -1
  147. package/dist/cdn/{shared-46c6d1e6.js → shared-c3fa6df1.js} +1 -1
  148. package/dist/cdn/{shared-10f92654.js → shared-c5106979.js} +1 -1
  149. package/dist/cdn/shared-cb34d19f.js +1 -0
  150. package/dist/cdn/{shared-aa678ec4.js → shared-e2f4962c.js} +1 -1
  151. package/dist/cdn/{shared-14f0cf8e.js → shared-e9c81269.js} +1 -1
  152. package/dist/cdn/{shared-3a329baf.js → shared-f8e3be56.js} +1 -1
  153. package/dist/cdn/{shared-8db9452f.js → shared-fcce5337.js} +1 -1
  154. package/dist/cdn/translations/downloadable-card/en.json +7 -0
  155. package/dist/cdn/translations/downloadable-form/en.json +65 -0
  156. package/dist/cdn/translations/transaction/en.json +2 -0
  157. package/dist/elements/private/Choice/Choice.d.ts +3 -2
  158. package/dist/elements/private/Choice/Choice.js +5 -0
  159. package/dist/elements/private/Choice/Choice.js.map +1 -1
  160. package/dist/elements/private/Choice/machine.js +33 -0
  161. package/dist/elements/private/Choice/machine.js.map +1 -1
  162. package/dist/elements/public/CouponForm/CouponForm.d.ts +1 -5
  163. package/dist/elements/public/CouponForm/CouponForm.js +27 -289
  164. package/dist/elements/public/CouponForm/CouponForm.js.map +1 -1
  165. package/dist/elements/public/CouponForm/index.d.ts +1 -0
  166. package/dist/elements/public/CouponForm/index.js +1 -0
  167. package/dist/elements/public/CouponForm/index.js.map +1 -1
  168. package/dist/elements/public/CouponForm/types.d.ts +0 -24
  169. package/dist/elements/public/CouponForm/types.js.map +1 -1
  170. package/dist/elements/public/DiscountBuilder/DiscountBuilder.js +8 -4
  171. package/dist/elements/public/DiscountBuilder/DiscountBuilder.js.map +1 -1
  172. package/dist/elements/public/Donation/Donation.js +3 -3
  173. package/dist/elements/public/Donation/Donation.js.map +1 -1
  174. package/dist/elements/public/DownloadableCard/DownloadableCard.d.ts +21 -0
  175. package/dist/elements/public/DownloadableCard/DownloadableCard.js +84 -0
  176. package/dist/elements/public/DownloadableCard/DownloadableCard.js.map +1 -0
  177. package/dist/elements/public/DownloadableCard/index.d.ts +6 -0
  178. package/dist/elements/public/DownloadableCard/index.js +8 -0
  179. package/dist/elements/public/DownloadableCard/index.js.map +1 -0
  180. package/dist/elements/public/DownloadableCard/types.d.ts +8 -0
  181. package/dist/elements/public/DownloadableCard/types.js +2 -0
  182. package/dist/elements/public/DownloadableCard/types.js.map +1 -0
  183. package/dist/elements/public/DownloadableForm/DownloadableForm.d.ts +54 -0
  184. package/dist/elements/public/DownloadableForm/DownloadableForm.js +149 -0
  185. package/dist/elements/public/DownloadableForm/DownloadableForm.js.map +1 -0
  186. package/dist/elements/public/DownloadableForm/index.d.ts +8 -0
  187. package/dist/elements/public/DownloadableForm/index.js +10 -0
  188. package/dist/elements/public/DownloadableForm/index.js.map +1 -0
  189. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/InternalDownloadableFormUploadControl.d.ts +11 -0
  190. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/InternalDownloadableFormUploadControl.js +124 -0
  191. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/InternalDownloadableFormUploadControl.js.map +1 -0
  192. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/index.d.ts +6 -0
  193. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/index.js +8 -0
  194. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/index.js.map +1 -0
  195. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/style.d.ts +1 -0
  196. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/style.js +42 -0
  197. package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/style.js.map +1 -0
  198. package/dist/elements/public/DownloadableForm/types.d.ts +11 -0
  199. package/dist/elements/public/DownloadableForm/types.js +2 -0
  200. package/dist/elements/public/DownloadableForm/types.js.map +1 -0
  201. package/dist/elements/public/FormDialog/FormDialog.d.ts +4 -0
  202. package/dist/elements/public/FormDialog/FormDialog.js +18 -7
  203. package/dist/elements/public/FormDialog/FormDialog.js.map +1 -1
  204. package/dist/elements/public/I18n/format/discount.js +1 -1
  205. package/dist/elements/public/I18n/format/discount.js.map +1 -1
  206. package/dist/elements/public/I18n/format/percent.js +4 -3
  207. package/dist/elements/public/I18n/format/percent.js.map +1 -1
  208. package/dist/elements/public/ItemCard/ItemCard.js +1 -1
  209. package/dist/elements/public/ItemCard/ItemCard.js.map +1 -1
  210. package/dist/elements/public/Transaction/internal/InternalTransactionSummaryControl/InternalTransactionSummaryControl.js +25 -8
  211. package/dist/elements/public/Transaction/internal/InternalTransactionSummaryControl/InternalTransactionSummaryControl.js.map +1 -1
  212. package/dist/elements/public/Transaction/types.d.ts +5 -1
  213. package/dist/elements/public/Transaction/types.js.map +1 -1
  214. package/dist/elements/public/index.d.ts +2 -0
  215. package/dist/elements/public/index.defined.d.ts +2 -0
  216. package/dist/elements/public/index.defined.js +2 -0
  217. package/dist/elements/public/index.defined.js.map +1 -1
  218. package/dist/elements/public/index.js +2 -0
  219. package/dist/elements/public/index.js.map +1 -1
  220. package/dist/mixins/themeable.js +4 -0
  221. package/dist/mixins/themeable.js.map +1 -1
  222. package/package.json +1 -1
  223. package/dist/cdn/shared-095ad002.js +0 -1
  224. package/dist/cdn/shared-349bbd7e.js +0 -1
  225. package/dist/cdn/shared-7f47c677.js +0 -1
  226. package/dist/cdn/shared-9eeb2bec.js +0 -1
@@ -15,8 +15,6 @@ import { TranslatableMixin } from "../../../mixins/translatable.js";
15
15
  import { classMap } from "../../../utils/class-map.js";
16
16
  import { ifDefined } from 'lit-html/directives/if-defined';
17
17
  import { live } from 'lit-html/directives/live';
18
- import { operatorGreaterThanOrEqual } from "../QueryBuilder/icons/operatorGreaterThanOrEqual.js";
19
- import { repeat } from 'lit-html/directives/repeat';
20
18
  import { serializeDate } from "../../../utils/serialize-date.js";
21
19
  const NS = 'coupon-form';
22
20
  const Base = ScopedElementsMixin(ThemeableMixin(ConfigurableMixin(ResponsiveMixin(TranslatableMixin(NucleonElement, NS)))));
@@ -155,6 +153,7 @@ export class CouponForm extends Base {
155
153
  'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),
156
154
  'foxy-copy-to-clipboard': customElements.get('foxy-copy-to-clipboard'),
157
155
  'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
156
+ 'foxy-discount-builder': customElements.get('foxy-discount-builder'),
158
157
  'foxy-query-builder': customElements.get('foxy-query-builder'),
159
158
  'foxy-form-dialog': customElements.get('foxy-form-dialog'),
160
159
  'foxy-pagination': customElements.get('foxy-pagination'),
@@ -340,258 +339,6 @@ export class CouponForm extends Base {
340
339
  </label>
341
340
  `;
342
341
  }
343
- __renderRulesTierSelect({ label, value, options, onChange }) {
344
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
345
- const isReadonly = this.readonlySelector.matches('rules', true);
346
- const isInteractive = !isDisabled && !isReadonly;
347
- return html `
348
- <label
349
- class=${classMap({
350
- 'h-xs whitespace-nowrap block ring-primary-50 rounded-s pl-s transition-colors': true,
351
- 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,
352
- 'bg-primary-10 text-primary': isInteractive,
353
- 'bg-contrast-5 text-disabled': isDisabled,
354
- 'bg-contrast-5 text-secondary': isReadonly && !isDisabled,
355
- })}
356
- >
357
- <foxy-i18n class="sr-only" lang=${this.lang} key=${label} ns=${this.ns}></foxy-i18n>
358
-
359
- <span class="relative leading-none font-medium flex items-center h-full">
360
- <span class="truncate">${this.t(options[value])}</span>
361
- <iron-icon class="icon-inline text-xl ml-xs" icon="icons:expand-more"></iron-icon>
362
-
363
- <select
364
- data-testclass="interactive editable"
365
- class="opacity-0 absolute inset-0 focus-outline-none"
366
- ?disabled=${!isInteractive}
367
- @change=${(evt) => {
368
- const select = evt.currentTarget;
369
- onChange(select.options[select.selectedIndex].value);
370
- }}
371
- >
372
- ${Object.entries(options).map(([optionValue, optionKey]) => {
373
- return html `
374
- <option value=${optionValue} ?selected=${optionValue === value}>
375
- ${this.t(optionKey)}
376
- </option>
377
- `;
378
- })}
379
- </select>
380
- </span>
381
- </label>
382
- `;
383
- }
384
- __renderRulesTierSwitch({ value, options, onChange }) {
385
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
386
- const isReadonly = this.readonlySelector.matches('rules', true);
387
- const isInteractive = !isDisabled && !isReadonly;
388
- const name = `switch-${Math.floor(Math.random() * Math.pow(10, 10))}`;
389
- const dotStyle = 'width: 0.4rem; height: 0.4rem';
390
- return html `
391
- <div
392
- class=${classMap({
393
- 'h-xs px-xs space-x-xs flex items-center rounded-s transition-colors': true,
394
- 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,
395
- 'ring-primary-50 cursor-pointer bg-primary-10 text-primary': isInteractive,
396
- 'bg-contrast-5 text-disabled': isDisabled,
397
- 'bg-contrast-5 text-secondary': isReadonly && !isDisabled,
398
- })}
399
- @click=${(evt) => {
400
- if (!isInteractive)
401
- return;
402
- const target = evt.currentTarget;
403
- const firstInput = target.querySelector('input');
404
- firstInput.focus();
405
- onChange(value === 0 ? 1 : 0);
406
- }}
407
- >
408
- <div class="leading-none font-medium px-xs pointer-events-none">
409
- ${options.map((option, optionIndex) => {
410
- return html `
411
- <label>
412
- <foxy-i18n
413
- class=${classMap({ 'sr-only': optionIndex !== value })}
414
- lang=${this.lang}
415
- key=${option}
416
- ns=${this.ns}
417
- >
418
- </foxy-i18n>
419
-
420
- <input
421
- data-testclass="interactive editable"
422
- class="sr-only"
423
- value=${option}
424
- name=${name}
425
- type="radio"
426
- ?disabled=${!isInteractive}
427
- ?checked=${optionIndex === value}
428
- @change=${(evt) => {
429
- const input = evt.currentTarget;
430
- if (input.checked)
431
- onChange(optionIndex);
432
- }}
433
- />
434
- </label>
435
- `;
436
- })}
437
- </div>
438
-
439
- <div class="flex justify-evenly h-full ${value ? 'flex-col-reverse' : 'flex-col'}">
440
- <div style=${dotStyle} class="bg-current rounded-full"></div>
441
- <div style=${dotStyle} class="border border-current rounded-full"></div>
442
- </div>
443
- </div>
444
- `;
445
- }
446
- __renderRulesTierField({ value, label, onChange }) {
447
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
448
- const isReadonly = this.readonlySelector.matches('rules', true);
449
- const isInteractive = !isDisabled && !isReadonly;
450
- return html `
451
- <label>
452
- <foxy-i18n class="sr-only" lang=${this.lang} key=${label} ns=${this.ns}></foxy-i18n>
453
- <input
454
- data-testclass="interactive editable"
455
- class=${classMap({
456
- 'transition-colors border p-xs h-xs font-medium text-m rounded-s w-xl': true,
457
- 'ring-primary-50 text-body bg-contrast-10': isInteractive,
458
- 'hover-bg-contrast-20': isInteractive,
459
- 'focus-outline-none focus-ring-2': isInteractive,
460
- 'text-disabled bg-contrast-5': isDisabled,
461
- 'text-secondary': isReadonly && !isDisabled,
462
- 'border-transparent border-solid': !isReadonly,
463
- 'border-dashed border-contrast-30': isReadonly,
464
- })}
465
- type="number"
466
- min="0"
467
- ?disabled=${!isInteractive}
468
- .value=${value}
469
- @input=${(evt) => {
470
- const input = evt.currentTarget;
471
- onChange(input.value);
472
- }}
473
- />
474
- </label>
475
- `;
476
- }
477
- __renderRulesTier(params) {
478
- var _a;
479
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
480
- const isReadonly = this.readonlySelector.matches('rules', true);
481
- const tier = (_a = params.tier) !== null && _a !== void 0 ? _a : '0-0';
482
- const sign = tier.includes('+') ? '+' : '-';
483
- const [from, adjustment] = tier.split(/[-+]/).map(v => parseFloat(v));
484
- return html `
485
- <div
486
- data-testclass="rules:tier"
487
- aria-label=${this.t('tier')}
488
- class=${classMap({
489
- 'flex items-start justify-between rounded': true,
490
- 'border border-contrast-10': true,
491
- 'border-dashed': !params.tier,
492
- })}
493
- >
494
- <div
495
- class=${classMap({
496
- 'transition-colors flex flex-wrap items-center gap-s p-s': true,
497
- 'text-tertiary': !isDisabled,
498
- 'text-disabled': isDisabled,
499
- })}
500
- >
501
- <foxy-i18n
502
- class="uppercase text-s font-medium"
503
- lang=${this.lang}
504
- key="tier_if"
505
- ns=${this.ns}
506
- >
507
- </foxy-i18n>
508
-
509
- ${this.__renderRulesTierSwitch({
510
- options: ['total', 'quantity'],
511
- value: params.source === 'price' ? 0 : 1,
512
- onChange: i => params.onChange({ source: i ? 'quantity' : 'price' }),
513
- })}
514
-
515
- <div class="h-s w-s">${operatorGreaterThanOrEqual}</div>
516
-
517
- ${this.__renderRulesTierField({
518
- label: 'from',
519
- value: String(from),
520
- onChange: v => params.onChange({ tier: `${v}${sign}${adjustment}` }),
521
- })}
522
-
523
- <foxy-i18n
524
- class="uppercase text-s font-medium"
525
- lang=${this.lang}
526
- key="tier_then"
527
- ns=${this.ns}
528
- >
529
- </foxy-i18n>
530
-
531
- ${this.__renderRulesTierSwitch({
532
- options: ['reduce', 'increase'],
533
- value: sign === '-' ? 0 : 1,
534
- onChange: i => params.onChange({ tier: `${from}${i ? '+' : '-'}${adjustment}` }),
535
- })}
536
-
537
- <!---->
538
-
539
- ${this.__renderRulesTierSelect({
540
- options: {
541
- incremental: 'tier_incremental',
542
- allunits: 'tier_allunits',
543
- repeat: 'tier_repeat',
544
- single: 'tier_single',
545
- },
546
- value: params.method,
547
- label: 'target',
548
- onChange: v => params.onChange({ method: v }),
549
- })}
550
-
551
- <foxy-i18n
552
- class="uppercase text-s font-medium"
553
- lang=${this.lang}
554
- key="tier_by"
555
- ns=${this.ns}
556
- >
557
- </foxy-i18n>
558
-
559
- ${this.__renderRulesTierField({
560
- label: 'adjustment',
561
- value: String(adjustment),
562
- onChange: v => params.onChange({ tier: `${from}${sign}${v}` }),
563
- })}
564
-
565
- <!---->
566
-
567
- ${this.__renderRulesTierSwitch({
568
- value: params.units === 'percentage' ? 0 : 1,
569
- options: ['%', '¤'],
570
- onChange: i => params.onChange({ units: i ? 'amount' : 'percentage' }),
571
- })}
572
- </div>
573
-
574
- ${params.tier
575
- ? html `
576
- <button
577
- data-testclass="interactive"
578
- aria-label=${this.t('delete')}
579
- class=${classMap({
580
- 'w-s h-s m-s flex-shrink-0 rounded transition-colors ring-primary-50': true,
581
- 'text-tertiary hover-text-secondary focus-outline-none focus-ring-2': !isDisabled,
582
- 'text-disabled cursor-default': isDisabled,
583
- })}
584
- ?disabled=${isDisabled}
585
- ?hidden=${isReadonly}
586
- @click=${() => params.onDelete()}
587
- >
588
- <iron-icon icon="lumo:cross"></iron-icon>
589
- </button>
590
- `
591
- : ''}
592
- </div>
593
- `;
594
- }
595
342
  __renderRulesUrlParameter() {
596
343
  var _a, _b, _c;
597
344
  const name = (_a = this.form.name) !== null && _a !== void 0 ? _a : '';
@@ -655,14 +402,11 @@ export class CouponForm extends Base {
655
402
  `;
656
403
  }
657
404
  __renderRules() {
658
- var _a, _b, _c;
405
+ var _a, _b;
659
406
  const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
407
+ const isReadonly = this.readonlySelector.matches('rules', true);
660
408
  const details = (_a = this.form.coupon_discount_details) !== null && _a !== void 0 ? _a : '';
661
- const tiers = details.split('|').filter(v => !!v.trim());
662
- const method = (_b = (/[-+]/.test(tiers[0]) ? null : tiers.shift())) !== null && _b !== void 0 ? _b : 'single';
663
- const renderedTiers = method === 'repeat' ? [tiers[0]] : [...tiers, undefined];
664
- const type = (_c = this.form.coupon_discount_type) !== null && _c !== void 0 ? _c : 'quantity_amount';
665
- const [source, units] = type.split('_');
409
+ const type = (_b = this.form.coupon_discount_type) !== null && _b !== void 0 ? _b : 'quantity_amount';
666
410
  return html `
667
411
  <div data-testid="rules">
668
412
  ${this.renderTemplateOrSlot('rules:before')}
@@ -684,32 +428,23 @@ export class CouponForm extends Base {
684
428
  <div class="min-w-0">${this.__renderRulesPreset()}</div>
685
429
  </div>
686
430
 
687
- <div class="space-y-s">
688
- ${repeat(renderedTiers, (tier, tierIndex) => {
689
- const onChange = (changedParams) => {
690
- var _a, _b, _c;
691
- const newMethod = (_a = changedParams.method) !== null && _a !== void 0 ? _a : method;
692
- const newSource = (_b = changedParams.source) !== null && _b !== void 0 ? _b : source;
693
- const newUnits = (_c = changedParams.units) !== null && _c !== void 0 ? _c : units;
694
- const newTier = changedParams.tier;
695
- const newTiers = [...tiers];
696
- if (newTier) {
697
- const newTierIndex = tier ? tierIndex : newTiers.length;
698
- const oldTiersCount = tier ? 1 : 0;
699
- newTiers.splice(newTierIndex, oldTiersCount, newTier);
700
- }
701
- this.edit({
702
- coupon_discount_details: `${newMethod}|${newTiers.join('|')}`,
703
- coupon_discount_type: `${newSource}_${newUnits}`,
704
- });
705
- };
706
- const onDelete = () => {
707
- const newTiers = tiers.filter((_, i) => i !== tierIndex);
708
- this.edit({ coupon_discount_details: `${method}|${newTiers.join('|')}` });
709
- };
710
- return this.__renderRulesTier({ source, method, units, tier, onChange, onDelete });
711
- })}
712
- </div>
431
+ <foxy-discount-builder
432
+ data-testclass="interactive"
433
+ lang=${this.lang}
434
+ ns=${this.ns}
435
+ ?readonly=${isReadonly}
436
+ ?disabled=${isDisabled}
437
+ .parsedValue=${{ details, type, name: 'Rules' }}
438
+ @change=${(evt) => {
439
+ const builder = evt.currentTarget;
440
+ const newParsedValue = builder.parsedValue;
441
+ this.edit({
442
+ coupon_discount_details: newParsedValue.details,
443
+ coupon_discount_type: newParsedValue.type,
444
+ });
445
+ }}
446
+ >
447
+ </foxy-discount-builder>
713
448
 
714
449
  <div class="space-y-xs mt-m">
715
450
  ${this.__renderRulesUrlParameter()} ${this.__renderRulesDescription()}
@@ -981,10 +716,13 @@ export class CouponForm extends Base {
981
716
  ];
982
717
  if (restrictions) {
983
718
  restrictions.split(',').forEach(value => {
984
- const isBlocklistValue = value.startsWith('-');
719
+ const trimmedValue = value.trim();
720
+ if (!trimmedValue)
721
+ return;
722
+ const isBlocklistValue = trimmedValue.startsWith('-');
985
723
  const target = isBlocklistValue ? 1 : 0;
986
- const label = isBlocklistValue ? value.substring(1) : value;
987
- groups[target].items.push({ label, value });
724
+ const label = isBlocklistValue ? trimmedValue.substring(1) : trimmedValue;
725
+ groups[target].items.push({ label, value: trimmedValue });
988
726
  });
989
727
  }
990
728
  return html `