@foxy.io/elements 1.27.0-beta.5 → 1.27.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.
Files changed (275) hide show
  1. package/dist/cdn/foxy-access-recovery-form.js +1 -1
  2. package/dist/cdn/foxy-address-card.js +1 -1
  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-billing-address-card.js +1 -1
  12. package/dist/cdn/foxy-cancellation-form.js +1 -1
  13. package/dist/cdn/foxy-cart-card.js +1 -1
  14. package/dist/cdn/foxy-cart-form.js +1 -1
  15. package/dist/cdn/foxy-client-card.js +1 -1
  16. package/dist/cdn/foxy-client-form.js +1 -1
  17. package/dist/cdn/foxy-collection-page.js +1 -1
  18. package/dist/cdn/foxy-collection-pages.js +1 -1
  19. package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
  20. package/dist/cdn/foxy-coupon-card.js +1 -1
  21. package/dist/cdn/foxy-coupon-code-card.js +1 -0
  22. package/dist/cdn/foxy-coupon-code-form.js +1 -1
  23. package/dist/cdn/foxy-coupon-codes-form.js +1 -1
  24. package/dist/cdn/foxy-coupon-detail-card.js +1 -1
  25. package/dist/cdn/foxy-coupon-form.js +1 -1
  26. package/dist/cdn/foxy-custom-field-card.js +1 -1
  27. package/dist/cdn/foxy-custom-field-form.js +1 -1
  28. package/dist/cdn/foxy-customer-api.js +1 -1
  29. package/dist/cdn/foxy-customer-card.js +1 -1
  30. package/dist/cdn/foxy-customer-form.js +1 -1
  31. package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
  32. package/dist/cdn/foxy-customer-portal-settings.js +1 -1
  33. package/dist/cdn/foxy-customer-portal.js +2 -2
  34. package/dist/cdn/foxy-customer.js +1 -1
  35. package/dist/cdn/foxy-customers-table.js +1 -1
  36. package/dist/cdn/foxy-discount-builder.js +1 -1
  37. package/dist/cdn/foxy-discount-card.js +1 -1
  38. package/dist/cdn/foxy-discount-detail-card.js +1 -1
  39. package/dist/cdn/foxy-donation.js +1 -1
  40. package/dist/cdn/foxy-downloadable-card.js +1 -1
  41. package/dist/cdn/foxy-downloadable-form.js +2 -2
  42. package/dist/cdn/foxy-email-template-card.js +1 -1
  43. package/dist/cdn/foxy-email-template-form.js +1 -1
  44. package/dist/cdn/foxy-error-entry-card.js +1 -1
  45. package/dist/cdn/foxy-filter-attribute-card.js +1 -1
  46. package/dist/cdn/foxy-filter-attribute-form.js +1 -1
  47. package/dist/cdn/foxy-form-dialog.js +1 -1
  48. package/dist/cdn/foxy-generate-codes-form.js +1 -1
  49. package/dist/cdn/foxy-gift-card-card.js +1 -1
  50. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  51. package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
  52. package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
  53. package/dist/cdn/foxy-gift-card-form.js +1 -1
  54. package/dist/cdn/foxy-i18n-editor.js +2 -2
  55. package/dist/cdn/foxy-i18n.js +1 -1
  56. package/dist/cdn/foxy-integration-card.js +1 -1
  57. package/dist/cdn/foxy-integration-form.js +1 -1
  58. package/dist/cdn/foxy-item-card.js +1 -1
  59. package/dist/cdn/foxy-item-category-card.js +1 -1
  60. package/dist/cdn/foxy-item-category-form.js +1 -1
  61. package/dist/cdn/foxy-item-form.js +3 -3
  62. package/dist/cdn/foxy-item-option-card.js +1 -1
  63. package/dist/cdn/foxy-item-option-form.js +1 -1
  64. package/dist/cdn/foxy-items-form.js +1 -1
  65. package/dist/cdn/foxy-native-integration-card.js +1 -1
  66. package/dist/cdn/foxy-native-integration-form.js +1 -1
  67. package/dist/cdn/foxy-nucleon-element.js +1 -1
  68. package/dist/cdn/foxy-pagination.js +1 -1
  69. package/dist/cdn/foxy-passkey-card.js +1 -1
  70. package/dist/cdn/foxy-passkey-form.js +1 -1
  71. package/dist/cdn/foxy-payment-card.js +1 -1
  72. package/dist/cdn/foxy-payment-method-card.js +1 -1
  73. package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
  74. package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
  75. package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
  76. package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
  77. package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
  78. package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
  79. package/dist/cdn/foxy-query-builder.js +1 -1
  80. package/dist/cdn/foxy-report-form.js +1 -1
  81. package/dist/cdn/foxy-reports-table.js +1 -1
  82. package/dist/cdn/foxy-shipment-card.js +1 -1
  83. package/dist/cdn/foxy-shipping-method-card.js +1 -1
  84. package/dist/cdn/foxy-sign-in-form.js +1 -1
  85. package/dist/cdn/foxy-spinner.js +1 -1
  86. package/dist/cdn/foxy-store-card.js +1 -1
  87. package/dist/cdn/foxy-store-form.js +1 -1
  88. package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
  89. package/dist/cdn/foxy-subscription-card.js +1 -1
  90. package/dist/cdn/foxy-subscription-form.js +1 -1
  91. package/dist/cdn/foxy-subscription-settings-form.js +1 -1
  92. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  93. package/dist/cdn/foxy-table.js +1 -1
  94. package/dist/cdn/foxy-tax-card.js +1 -1
  95. package/dist/cdn/foxy-tax-form.js +1 -1
  96. package/dist/cdn/foxy-template-config-form.js +1 -1
  97. package/dist/cdn/foxy-template-form.js +1 -1
  98. package/dist/cdn/foxy-template-set-card.js +1 -1
  99. package/dist/cdn/foxy-template-set-form.js +1 -1
  100. package/dist/cdn/foxy-transaction-card.js +1 -1
  101. package/dist/cdn/foxy-transaction.js +1 -1
  102. package/dist/cdn/foxy-transactions-table.js +1 -1
  103. package/dist/cdn/foxy-user-card.js +1 -1
  104. package/dist/cdn/foxy-user-form.js +1 -1
  105. package/dist/cdn/foxy-users-table.js +1 -1
  106. package/dist/cdn/foxy-webhook-card.js +1 -1
  107. package/dist/cdn/foxy-webhook-form.js +1 -1
  108. package/dist/cdn/foxy-webhook-log-card.js +1 -1
  109. package/dist/cdn/foxy-webhook-status-card.js +1 -1
  110. package/dist/cdn/{shared-20c4310b.js → shared-065dbdf6.js} +1 -1
  111. package/dist/cdn/{shared-0f49d9c3.js → shared-07d5e225.js} +1 -1
  112. package/dist/cdn/{shared-82435697.js → shared-0e8dceb8.js} +1 -1
  113. package/dist/cdn/{shared-6ef4ce19.js → shared-1a9e80fa.js} +1 -1
  114. package/dist/cdn/{shared-e4e0dc11.js → shared-1d6beb48.js} +1 -1
  115. package/dist/cdn/shared-208e37af.js +88 -0
  116. package/dist/cdn/shared-29f2468c.js +6 -0
  117. package/dist/cdn/shared-400240f8.js +1 -0
  118. package/dist/cdn/{shared-9db9528b.js → shared-589e5d06.js} +15 -15
  119. package/dist/cdn/{shared-6be0a096.js → shared-5dbb9630.js} +1 -1
  120. package/dist/cdn/{shared-6350f7d9.js → shared-5e35c5a5.js} +1 -1
  121. package/dist/cdn/{shared-3cbcd9cb.js → shared-5f09205d.js} +1 -1
  122. package/dist/cdn/{shared-d15c3e2d.js → shared-61f67b16.js} +1 -1
  123. package/dist/cdn/shared-683145e5.js +1 -0
  124. package/dist/cdn/shared-6c4affb9.js +1 -0
  125. package/dist/cdn/{shared-4fb9d21f.js → shared-77fd8dae.js} +1 -1
  126. package/dist/cdn/{shared-92cdd504.js → shared-80eb1fee.js} +1 -1
  127. package/dist/cdn/shared-850e2ae1.js +10 -0
  128. package/dist/cdn/{shared-872151f5.js → shared-85979316.js} +1 -1
  129. package/dist/cdn/{shared-4fd17baf.js → shared-8def6325.js} +1 -1
  130. package/dist/cdn/{shared-18d109f5.js → shared-93812e51.js} +1 -1
  131. package/dist/cdn/{shared-6a998243.js → shared-9a5da74d.js} +21 -27
  132. package/dist/cdn/{shared-e52280d9.js → shared-b30f9b10.js} +1 -1
  133. package/dist/cdn/shared-bb08b5ce.js +32 -0
  134. package/dist/cdn/{shared-89b42eef.js → shared-bba8ae80.js} +1 -1
  135. package/dist/cdn/{shared-bf132324.js → shared-befe135a.js} +1 -1
  136. package/dist/cdn/{shared-7ff496f6.js → shared-bfa30d93.js} +1 -1
  137. package/dist/cdn/shared-c5f57aa8.js +1 -0
  138. package/dist/cdn/{shared-3277bbf5.js → shared-ca15d510.js} +1 -1
  139. package/dist/cdn/{shared-46454866.js → shared-cab2aa63.js} +4 -4
  140. package/dist/cdn/shared-cc723108.js +12 -0
  141. package/dist/cdn/{shared-97793410.js → shared-d04c2e0c.js} +1 -1
  142. package/dist/cdn/{shared-59a5edee.js → shared-da7a0bfb.js} +9 -9
  143. package/dist/cdn/shared-e35297c9.js +1 -0
  144. package/dist/cdn/{shared-8778d784.js → shared-e48fbf50.js} +1 -1
  145. package/dist/cdn/shared-e84be1c2.js +64 -0
  146. package/dist/cdn/{shared-8dd03329.js → shared-e966f1ef.js} +1 -1
  147. package/dist/cdn/{shared-1122a125.js → shared-fb8c09b8.js} +1 -1
  148. package/dist/cdn/{shared-fcaf15e5.js → shared-fd041b18.js} +1 -1
  149. package/dist/cdn/{shared-1b0992cc.js → shared-fda63db8.js} +5 -5
  150. package/dist/cdn/{shared-51ac503d.js → shared-fe7b3ed2.js} +1 -1
  151. package/dist/cdn/translations/coupon-code-card/en.json +11 -0
  152. package/dist/cdn/translations/coupon-form/en.json +522 -297
  153. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControl.d.ts +10 -0
  154. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControl.js +81 -2
  155. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControl.js.map +1 -1
  156. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControlFilterOverlay.d.ts +11 -0
  157. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControlFilterOverlay.js +57 -0
  158. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControlFilterOverlay.js.map +1 -0
  159. package/dist/elements/internal/InternalAsyncListControl/index.d.ts +1 -0
  160. package/dist/elements/internal/InternalAsyncListControl/index.js +3 -0
  161. package/dist/elements/internal/InternalAsyncListControl/index.js.map +1 -1
  162. package/dist/elements/internal/InternalAsyncListControl/types.d.ts +8 -0
  163. package/dist/elements/internal/InternalAsyncListControl/types.js +2 -0
  164. package/dist/elements/internal/InternalAsyncListControl/types.js.map +1 -0
  165. package/dist/elements/internal/InternalAsyncResourceLinkListControl/InternalAsyncResourceLinkListControl.d.ts +23 -0
  166. package/dist/elements/internal/InternalAsyncResourceLinkListControl/InternalAsyncResourceLinkListControl.js +224 -0
  167. package/dist/elements/internal/InternalAsyncResourceLinkListControl/InternalAsyncResourceLinkListControl.js.map +1 -0
  168. package/dist/elements/internal/InternalAsyncResourceLinkListControl/index.d.ts +8 -0
  169. package/dist/elements/internal/InternalAsyncResourceLinkListControl/index.js +10 -0
  170. package/dist/elements/internal/InternalAsyncResourceLinkListControl/index.js.map +1 -0
  171. package/dist/elements/internal/InternalForm/InternalForm.d.ts +10 -0
  172. package/dist/elements/internal/InternalForm/InternalForm.js +44 -0
  173. package/dist/elements/internal/InternalForm/InternalForm.js.map +1 -1
  174. package/dist/elements/internal/InternalForm/index.d.ts +2 -0
  175. package/dist/elements/internal/InternalForm/index.js +2 -0
  176. package/dist/elements/internal/InternalForm/index.js.map +1 -1
  177. package/dist/elements/internal/InternalIntegerControl/InternalIntegerControl.d.ts +1 -0
  178. package/dist/elements/internal/InternalIntegerControl/InternalIntegerControl.js +3 -0
  179. package/dist/elements/internal/InternalIntegerControl/InternalIntegerControl.js.map +1 -1
  180. package/dist/elements/internal/InternalQueryBuilderControl/InternalQueryBuilderControl.d.ts +10 -0
  181. package/dist/elements/internal/InternalQueryBuilderControl/InternalQueryBuilderControl.js +51 -0
  182. package/dist/elements/internal/InternalQueryBuilderControl/InternalQueryBuilderControl.js.map +1 -0
  183. package/dist/elements/internal/InternalQueryBuilderControl/index.d.ts +4 -0
  184. package/dist/elements/internal/InternalQueryBuilderControl/index.js +6 -0
  185. package/dist/elements/internal/InternalQueryBuilderControl/index.js.map +1 -0
  186. package/dist/elements/public/CartForm/CartForm.js +81 -81
  187. package/dist/elements/public/CartForm/CartForm.js.map +1 -1
  188. package/dist/elements/public/CouponCodeCard/CouponCodeCard.d.ts +16 -0
  189. package/dist/elements/public/CouponCodeCard/CouponCodeCard.js +41 -0
  190. package/dist/elements/public/CouponCodeCard/CouponCodeCard.js.map +1 -0
  191. package/dist/elements/public/CouponCodeCard/index.d.ts +4 -0
  192. package/dist/elements/public/CouponCodeCard/index.js +6 -0
  193. package/dist/elements/public/CouponCodeCard/index.js.map +1 -0
  194. package/dist/elements/public/CouponCodeCard/types.d.ts +3 -0
  195. package/dist/elements/public/CouponCodeCard/types.js +2 -0
  196. package/dist/elements/public/CouponCodeCard/types.js.map +1 -0
  197. package/dist/elements/public/CouponForm/CouponForm.d.ts +65 -41
  198. package/dist/elements/public/CouponForm/CouponForm.js +320 -1035
  199. package/dist/elements/public/CouponForm/CouponForm.js.map +1 -1
  200. package/dist/elements/public/CouponForm/index.d.ts +15 -16
  201. package/dist/elements/public/CouponForm/index.js +15 -16
  202. package/dist/elements/public/CouponForm/index.js.map +1 -1
  203. package/dist/elements/public/CouponForm/internal/InternalCouponFormBulkAddControl/InternalCouponFormBulkAddControl.d.ts +9 -0
  204. package/dist/elements/public/CouponForm/internal/InternalCouponFormBulkAddControl/InternalCouponFormBulkAddControl.js +49 -0
  205. package/dist/elements/public/CouponForm/internal/InternalCouponFormBulkAddControl/InternalCouponFormBulkAddControl.js.map +1 -0
  206. package/dist/elements/public/CouponForm/internal/InternalCouponFormBulkAddControl/index.d.ts +6 -0
  207. package/dist/elements/public/CouponForm/internal/InternalCouponFormBulkAddControl/index.js +8 -0
  208. package/dist/elements/public/CouponForm/internal/InternalCouponFormBulkAddControl/index.js.map +1 -0
  209. package/dist/elements/public/CouponForm/internal/InternalCouponFormRulesControl/InternalCouponFormRulesControl.d.ts +7 -0
  210. package/dist/elements/public/CouponForm/internal/InternalCouponFormRulesControl/InternalCouponFormRulesControl.js +141 -0
  211. package/dist/elements/public/CouponForm/internal/InternalCouponFormRulesControl/InternalCouponFormRulesControl.js.map +1 -0
  212. package/dist/elements/public/CouponForm/internal/InternalCouponFormRulesControl/index.d.ts +6 -0
  213. package/dist/elements/public/CouponForm/internal/InternalCouponFormRulesControl/index.js +8 -0
  214. package/dist/elements/public/CouponForm/internal/InternalCouponFormRulesControl/index.js.map +1 -0
  215. package/dist/elements/public/CouponForm/types.d.ts +10 -1
  216. package/dist/elements/public/CouponForm/types.js.map +1 -1
  217. package/dist/elements/public/CustomerPortalSettingsForm/CustomerPortalSettingsForm.js +7 -3
  218. package/dist/elements/public/CustomerPortalSettingsForm/CustomerPortalSettingsForm.js.map +1 -1
  219. package/dist/elements/public/CustomerPortalSettingsForm/toOrigin.d.ts +1 -0
  220. package/dist/elements/public/CustomerPortalSettingsForm/toOrigin.js +9 -0
  221. package/dist/elements/public/CustomerPortalSettingsForm/toOrigin.js.map +1 -0
  222. package/dist/elements/public/DownloadableForm/DownloadableForm.js +9 -9
  223. package/dist/elements/public/DownloadableForm/DownloadableForm.js.map +1 -1
  224. package/dist/elements/public/I18n/format/discount.js +9 -2
  225. package/dist/elements/public/I18n/format/discount.js.map +1 -1
  226. package/dist/elements/public/I18n/format/ordinal.js +6 -2
  227. package/dist/elements/public/I18n/format/ordinal.js.map +1 -1
  228. package/dist/elements/public/IntegrationForm/IntegrationForm.js +8 -6
  229. package/dist/elements/public/IntegrationForm/IntegrationForm.js.map +1 -1
  230. package/dist/elements/public/ItemCategoryForm/ItemCategoryForm.js +27 -27
  231. package/dist/elements/public/ItemCategoryForm/ItemCategoryForm.js.map +1 -1
  232. package/dist/elements/public/QueryBuilder/QueryBuilder.d.ts +4 -0
  233. package/dist/elements/public/QueryBuilder/QueryBuilder.js +10 -2
  234. package/dist/elements/public/QueryBuilder/QueryBuilder.js.map +1 -1
  235. package/dist/elements/public/QueryBuilder/components/Group.d.ts +3 -1
  236. package/dist/elements/public/QueryBuilder/components/Group.js +8 -1
  237. package/dist/elements/public/QueryBuilder/components/Group.js.map +1 -1
  238. package/dist/elements/public/QueryBuilder/components/OperatorToggle.d.ts +2 -1
  239. package/dist/elements/public/QueryBuilder/components/OperatorToggle.js +5 -4
  240. package/dist/elements/public/QueryBuilder/components/OperatorToggle.js.map +1 -1
  241. package/dist/elements/public/QueryBuilder/components/Rule.d.ts +3 -1
  242. package/dist/elements/public/QueryBuilder/components/Rule.js +2 -1
  243. package/dist/elements/public/QueryBuilder/components/Rule.js.map +1 -1
  244. package/dist/elements/public/StoreForm/StoreForm.js +7 -8
  245. package/dist/elements/public/StoreForm/StoreForm.js.map +1 -1
  246. package/dist/elements/public/TemplateSetForm/TemplateSetForm.js +28 -28
  247. package/dist/elements/public/TemplateSetForm/TemplateSetForm.js.map +1 -1
  248. package/dist/elements/public/index.d.ts +1 -0
  249. package/dist/elements/public/index.defined.d.ts +1 -0
  250. package/dist/elements/public/index.defined.js +1 -0
  251. package/dist/elements/public/index.defined.js.map +1 -1
  252. package/dist/elements/public/index.js +1 -0
  253. package/dist/elements/public/index.js.map +1 -1
  254. package/dist/mixins/inferrable.js +8 -3
  255. package/dist/mixins/inferrable.js.map +1 -1
  256. package/package.json +1 -1
  257. package/dist/cdn/shared-20f65e73.js +0 -1
  258. package/dist/cdn/shared-27c7514d.js +0 -1
  259. package/dist/cdn/shared-669decee.js +0 -1
  260. package/dist/cdn/shared-afefe2ac.js +0 -113
  261. package/dist/cdn/shared-b33fd700.js +0 -1
  262. package/dist/cdn/shared-b51b9df7.js +0 -64
  263. package/dist/cdn/shared-b914895b.js +0 -1
  264. package/dist/cdn/shared-cce18690.js +0 -1
  265. package/dist/cdn/shared-d04dd602.js +0 -20
  266. package/dist/cdn/shared-df58b901.js +0 -1
  267. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.d.ts +0 -20
  268. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.js +0 -99
  269. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.js.map +0 -1
  270. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.d.ts +0 -18
  271. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.js +0 -50
  272. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.js.map +0 -1
  273. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.d.ts +0 -18
  274. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.js +0 -53
  275. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.js.map +0 -1
@@ -1,56 +1,79 @@
1
- import { Type } from "../QueryBuilder/types.js";
2
- import { html } from 'lit-element';
3
- import { ScopedElementsMixin } from '@open-wc/scoped-elements';
4
- import { CategoryRestrictionsPage } from "./private/CategoryRestrictionsPage.js";
5
- import { Checkbox } from "../../private/Checkbox/Checkbox.js";
6
- import { CheckboxChangeEvent } from "../../private/Checkbox/CheckboxChangeEvent.js";
7
- import { ConfigurableMixin } from "../../../mixins/configurable.js";
8
- import { EditableList } from "../../private/EditableList/EditableList.js";
9
- import { Group } from "../../private/Group/Group.js";
10
- import { NucleonElement } from "../NucleonElement/NucleonElement.js";
11
- import { Metadata } from "../../private/Metadata/Metadata.js";
12
- import { ResponsiveMixin } from "../../../mixins/responsive.js";
13
- import { ThemeableMixin } from "../../../mixins/themeable.js";
14
1
  import { TranslatableMixin } from "../../../mixins/translatable.js";
15
- import { classMap } from "../../../utils/class-map.js";
2
+ import { ResponsiveMixin } from "../../../mixins/responsive.js";
3
+ import { BooleanSelector } from '@foxy.io/sdk/core';
4
+ import { Operator, Type } from "../QueryBuilder/types.js";
5
+ import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
16
6
  import { ifDefined } from 'lit-html/directives/if-defined';
17
- import { live } from 'lit-html/directives/live';
18
- import { serializeDate } from "../../../utils/serialize-date.js";
7
+ import { html } from 'lit-html';
19
8
  const NS = 'coupon-form';
20
- const Base = ScopedElementsMixin(ThemeableMixin(ConfigurableMixin(ResponsiveMixin(TranslatableMixin(NucleonElement, NS)))));
9
+ const Base = ResponsiveMixin(TranslatableMixin(InternalForm, NS));
21
10
  /**
22
11
  * Form element for creating or editing coupons (`fx:coupon`).
23
12
  *
13
+ * @slot import:before
14
+ * @slot import:after
15
+ *
16
+ * @slot generate:before
17
+ * @slot generate:after
18
+ *
24
19
  * @slot name:before
25
20
  * @slot name:after
26
21
  *
27
22
  * @slot rules:before
28
23
  * @slot rules:after
29
24
  *
30
- * @slot codes:before
31
- * @slot codes:after
25
+ * @slot coupon-codes:before
26
+ * @slot coupon-codes:after
32
27
  *
33
- * @slot usage:before
34
- * @slot usage:after
28
+ * @slot item-option-restrictions:before
29
+ * @slot item-option-restrictions:after
35
30
  *
36
- * @slot product-restrictions:before
37
- * @slot product-restrictions:after
31
+ * @slot product-code-restrictions:before
32
+ * @slot product-code-restrictions:after
38
33
  *
39
34
  * @slot category-restrictions:before
40
35
  * @slot category-restrictions:after
41
36
  *
37
+ * @slot number-of-uses-allowed:before
38
+ * @slot number-of-uses-allowed:after
39
+ *
40
+ * @slot number-of-uses-allowed-per-customer:before
41
+ * @slot number-of-uses-allowed-per-customer:after
42
+ *
43
+ * @slot number-of-uses-allowed-per-code:before
44
+ * @slot number-of-uses-allowed-per-code:after
45
+ *
46
+ * @slot start-date:before
47
+ * @slot start-date:after
48
+ *
49
+ * @slot end-date:before
50
+ * @slot end-date:after
51
+ *
52
+ * @slot inclusive-tax-rate:before
53
+ * @slot inclusive-tax-rate:after
54
+ *
42
55
  * @slot options:before
43
56
  * @slot options:after
44
57
  *
45
- * @slot timestamps:before
46
- * @slot timestamps:after
58
+ * @slot customer-subscription-restrictions:before
59
+ * @slot customer-subscription-restrictions:after
47
60
  *
48
- * @slot delete:before
49
- * @slot delete:after
61
+ * @slot customer-attribute-restrictions:before
62
+ * @slot customer-attribute-restrictions:after
63
+ *
64
+ * @slot attributes:before
65
+ * @slot attributes:after
50
66
  *
51
67
  * @slot create:before
52
68
  * @slot create:after
53
69
  *
70
+ * @slot delete:before
71
+ * @slot delete:after
72
+ *
73
+ * @slot timestamps:before
74
+ * @slot timestamps:after
75
+ *
76
+ *
54
77
  * @element foxy-coupon-form
55
78
  * @since 1.15.0
56
79
  */
@@ -58,70 +81,6 @@ export class CouponForm extends Base {
58
81
  constructor() {
59
82
  super(...arguments);
60
83
  this.getTransactionPageHref = null;
61
- this.__codesTableColumns = [
62
- {
63
- header: ctx => html `<foxy-i18n lang=${ctx.lang} key="code" ns=${ctx.ns}></foxy-i18n>`,
64
- cell: ctx => {
65
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('codes', true);
66
- return html `
67
- <div class="flex items-center gap-xs">
68
- <vaadin-button
69
- theme="tertiary-inline contrast"
70
- class="p-0"
71
- ?disabled=${isDisabled}
72
- @click=${(evt) => {
73
- const dialog = this.renderRoot.querySelector('#code-dialog');
74
- const button = evt.currentTarget;
75
- dialog.href = ctx.data._links.self.href;
76
- dialog.show(button);
77
- }}
78
- >
79
- <span class="font-tnum">${ctx.data.code}</span>
80
- </vaadin-button>
81
-
82
- <foxy-copy-to-clipboard
83
- ?disabled=${isDisabled}
84
- text=${ctx.data.code}
85
- lang=${ctx.lang}
86
- ns="${ctx.ns} copy-to-clipboard"
87
- >
88
- </foxy-copy-to-clipboard>
89
- </div>
90
- `;
91
- },
92
- },
93
- {
94
- header: ctx => html `<foxy-i18n lang=${ctx.lang} key="date_created" ns=${ctx.ns}></foxy-i18n>`,
95
- cell: ctx => html `
96
- <foxy-i18n
97
- options=${JSON.stringify({ value: ctx.data.date_created })}
98
- class="text-tertiary"
99
- lang=${ctx.lang}
100
- key="date"
101
- ns=${ctx.ns}
102
- >
103
- </foxy-i18n>
104
- `,
105
- },
106
- {
107
- hideBelow: 'sm',
108
- header: c => html `<foxy-i18n lang=${c.lang} key="date_modified" ns=${c.ns}></foxy-i18n>`,
109
- cell: ctx => html `
110
- <foxy-i18n
111
- options=${JSON.stringify({ value: ctx.data.date_modified })}
112
- class="text-tertiary"
113
- lang=${ctx.lang}
114
- key="date"
115
- ns=${ctx.ns}
116
- >
117
- </foxy-i18n>
118
- `,
119
- },
120
- {
121
- header: c => html `<foxy-i18n lang=${c.lang} key="used_codes" ns=${c.ns}></foxy-i18n>`,
122
- cell: ctx => html `${ctx.data.number_of_uses_to_date}`,
123
- },
124
- ];
125
84
  this.__customerSubscriptionRestrictionsGetValue = () => {
126
85
  var _a;
127
86
  const items = (_a = this.form.customer_subscription_restrictions) === null || _a === void 0 ? void 0 : _a.split(',').map(value => value.trim()).filter((value, index, values) => !!value && values.indexOf(value) === index).map(value => ({ value }));
@@ -139,985 +98,311 @@ export class CouponForm extends Base {
139
98
  !!this.form.customer_attribute_restrictions,
140
99
  });
141
100
  };
142
- this.__codesTableQuery = null;
143
- this.__itemCategories = '';
144
- }
145
- static get scopedElements() {
146
- return {
147
- 'vaadin-integer-field': customElements.get('vaadin-integer-field'),
148
- 'vaadin-date-picker': customElements.get('vaadin-date-picker'),
149
- 'vaadin-text-field': customElements.get('vaadin-text-field'),
150
- 'vaadin-button': customElements.get('vaadin-button'),
151
- 'iron-dropdown': customElements.get('iron-dropdown'),
152
- 'iron-icon': customElements.get('iron-icon'),
153
- 'foxy-internal-editable-list-control': customElements.get('foxy-internal-editable-list-control'),
154
- 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),
155
- 'foxy-copy-to-clipboard': customElements.get('foxy-copy-to-clipboard'),
156
- 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
157
- 'foxy-discount-builder': customElements.get('foxy-discount-builder'),
158
- 'foxy-query-builder': customElements.get('foxy-query-builder'),
159
- 'foxy-form-dialog': customElements.get('foxy-form-dialog'),
160
- 'foxy-pagination': customElements.get('foxy-pagination'),
161
- 'foxy-spinner': customElements.get('foxy-spinner'),
162
- 'foxy-table': customElements.get('foxy-table'),
163
- 'foxy-i18n': customElements.get('foxy-i18n'),
164
- 'x-category-restrictions-page': CategoryRestrictionsPage,
165
- 'x-metadata': Metadata,
166
- 'x-editable-list': EditableList,
167
- 'x-checkbox': Checkbox,
168
- 'x-group': Group,
101
+ this.__productCodeRestrictionsGetValue = () => {
102
+ var _a;
103
+ return (_a = this.form.product_code_restrictions) === null || _a === void 0 ? void 0 : _a.split(',').filter(v => !!v.trim()).map(value => ({
104
+ value,
105
+ label: value.startsWith('-')
106
+ ? this.t(`product-code-restrictions.label_block`, { value: value.substring(1) })
107
+ : this.t(`product-code-restrictions.label_allow`, { value }),
108
+ }));
109
+ };
110
+ this.__productCodeRestrictionsSetValue = (newValue) => {
111
+ this.edit({
112
+ product_code_restrictions: newValue
113
+ .map(({ value, unit }) => (unit === 'block' ? `-${value}` : value))
114
+ .filter((v, i, a) => !!v && a.indexOf(v) === i)
115
+ .join(','),
116
+ });
117
+ };
118
+ this.__itemOptionRestrictionsOperators = [Operator.In];
119
+ this.__itemOptionRestrictionsGetValue = () => {
120
+ var _a;
121
+ const query = new URLSearchParams();
122
+ const rules = (_a = this.form.item_option_restrictions) !== null && _a !== void 0 ? _a : {};
123
+ for (const key in rules) {
124
+ query.set(`${key}:in`, rules[key].join(','));
125
+ }
126
+ return query.toString();
127
+ };
128
+ this.__itemOptionRestrictionsSetValue = (newValue) => {
129
+ const rules = Object.fromEntries(Array.from(new URLSearchParams(newValue).entries()).map(([key, value]) => {
130
+ return [key.replace(':in', ''), value.split(',').filter(v => !!v.trim())];
131
+ }));
132
+ this.edit({ item_option_restrictions: rules });
133
+ };
134
+ this.__optionsGetValue = () => {
135
+ const value = [];
136
+ if (this.form.multiple_codes_allowed)
137
+ value.push('multiple_codes_allowed');
138
+ if (this.form.combinable)
139
+ value.push('combinable');
140
+ if (this.form.exclude_category_discounts)
141
+ value.push('exclude_category_discounts');
142
+ if (this.form.exclude_line_item_discounts)
143
+ value.push('exclude_line_item_discounts');
144
+ if (this.form.is_taxable)
145
+ value.push('is_taxable');
146
+ if (this.form.shared_codes_allowed)
147
+ value.push('shared_codes_allowed');
148
+ if (this.form.customer_auto_apply)
149
+ value.push('customer_auto_apply');
150
+ return value;
169
151
  };
152
+ this.__optionsSetValue = (newValue) => {
153
+ this.edit({
154
+ multiple_codes_allowed: newValue.includes('multiple_codes_allowed'),
155
+ combinable: newValue.includes('combinable'),
156
+ exclude_category_discounts: newValue.includes('exclude_category_discounts'),
157
+ exclude_line_item_discounts: newValue.includes('exclude_line_item_discounts'),
158
+ is_taxable: newValue.includes('is_taxable'),
159
+ shared_codes_allowed: newValue.includes('shared_codes_allowed'),
160
+ customer_auto_apply: newValue.includes('customer_auto_apply'),
161
+ });
162
+ };
163
+ this.__optionsOptions = [
164
+ { value: 'multiple_codes_allowed', label: 'option_multiple_codes_allowed' },
165
+ { value: 'combinable', label: 'option_combinable' },
166
+ { value: 'exclude_category_discounts', label: 'option_exclude_category_discounts' },
167
+ { value: 'exclude_line_item_discounts', label: 'option_exclude_line_item_discounts' },
168
+ { value: 'is_taxable', label: 'option_is_taxable' },
169
+ { value: 'shared_codes_allowed', label: 'option_shared_codes_allowed' },
170
+ { value: 'customer_auto_apply', label: 'option_customer_auto_apply' },
171
+ ];
172
+ this.__storeLoaderId = 'storeLoader';
173
+ this.__codesFilters = [
174
+ { label: 'code', path: 'code', type: Type.String },
175
+ { label: 'used_codes', path: 'number_of_uses_to_date', type: Type.Number },
176
+ { label: 'date_created', path: 'date_created', type: Type.Date },
177
+ { label: 'date_modified', path: 'date_modified', type: Type.Date },
178
+ ];
179
+ this.__couponCodesActions = [
180
+ {
181
+ theme: 'contrast',
182
+ state: 'idle',
183
+ text: 'copy_button_text',
184
+ onClick: async (data) => {
185
+ this.__couponCodesActions[0].state = 'busy';
186
+ this.__couponCodesActions = [...this.__couponCodesActions];
187
+ try {
188
+ await navigator.clipboard.writeText(data.code);
189
+ this.__couponCodesActions[0].state = 'end';
190
+ }
191
+ catch (_a) {
192
+ this.__couponCodesActions[0].state = 'error';
193
+ }
194
+ finally {
195
+ this.__couponCodesActions = [...this.__couponCodesActions];
196
+ setTimeout(() => {
197
+ this.__couponCodesActions[0].state = 'idle';
198
+ this.__couponCodesActions = [...this.__couponCodesActions];
199
+ }, 1000);
200
+ }
201
+ },
202
+ },
203
+ ];
170
204
  }
171
205
  static get properties() {
172
206
  return {
173
207
  ...super.properties,
174
208
  getTransactionPageHref: { attribute: false },
175
- __codesTableQuery: { attribute: false },
176
- __itemCategories: { attribute: false },
209
+ __couponCodesActions: { type: Array },
177
210
  };
178
211
  }
179
212
  static get v8n() {
180
213
  return [
181
- ({ name: v }) => !!v || 'name_required',
182
- ({ name: v }) => !v || v.length <= 50 || 'name_too_long',
214
+ ({ name: v }) => !!v || 'name:v8n_required',
215
+ ({ name: v }) => !v || v.length <= 50 || 'name:v8n_too_long',
216
+ ({ inclusive_tax_rate: v }) => !v || v >= 0 || 'inclusive-tax-rate:v8n_too_small',
217
+ ({ inclusive_tax_rate: v }) => !v || v <= 1 || 'inclusive-tax-rate:v8n_too_big',
218
+ ({ number_of_uses_allowed: v }) => !v || v >= 0 || 'number-of-uses-allowed:v8n_too_small',
219
+ ({ coupon_discount_details: v }) => !!v || 'rules:v8n_required',
220
+ ({ coupon_discount_details: v }) => !v || v.length <= 200 || 'rules:v8n_too_long',
221
+ ({ item_option_restrictions: v }) => {
222
+ return !v || JSON.stringify(v).length <= 6000 || 'item-option-restrictions:v8n_too_long';
223
+ },
224
+ ({ product_code_restrictions: v }) => {
225
+ return !v || v.length <= 5000 || 'product-code-restrictions:v8n_too_long';
226
+ },
227
+ ({ customer_attribute_restrictions: v }) => {
228
+ return !v || v.length <= 2000 || 'customer-attribute-restrictions:v8n_too_long';
229
+ },
230
+ ({ number_of_uses_allowed_per_code: v }) => {
231
+ return !v || v >= 0 || 'number-of-uses-allowed-per-code:v8n_too_small';
232
+ },
233
+ ({ customer_subscription_restrictions: v }) => {
234
+ return !v || v.length <= 200 || 'customer-subscription-restrictions:v8n_too_long';
235
+ },
236
+ ({ number_of_uses_allowed_per_customer: v }) => {
237
+ return !v || v >= 0 || 'number-of-uses-allowed-per-customer:v8n_too_small';
238
+ },
183
239
  ];
184
240
  }
185
- render() {
186
- var _a, _b;
187
- const hidden = this.hiddenSelector;
188
- return html `
189
- <div class="relative space-y-l">
190
- ${hidden.matches('name', true) ? '' : this.__renderName()}
191
- ${hidden.matches('rules', true) ? '' : this.__renderRules()}
192
- ${hidden.matches('codes', true) || !this.data ? '' : this.__renderCodes()}
193
- ${hidden.matches('usage', true) ? '' : this.__renderUsage()}
194
- ${hidden.matches('product-restrictions', true) ? '' : this.__renderProductRestrictions()}
195
- ${hidden.matches('category-restrictions', true) || !this.data
196
- ? ''
197
- : this.__renderCategoryRestrictions()}
198
-
199
- <foxy-internal-editable-list-control
200
- infer="customer-subscription-restrictions"
201
- .getValue=${this.__customerSubscriptionRestrictionsGetValue}
202
- .setValue=${this.__customerSubscriptionRestrictionsSetValue}
203
- >
204
- </foxy-internal-editable-list-control>
205
-
206
- ${hidden.matches('customer-attribute-restrictions', true)
207
- ? ''
208
- : this.__renderCustomerAttributeRestrictions()}
209
- ${hidden.matches('options', true) ? '' : this.__renderOptions()}
210
- ${hidden.matches('timestamps', true) ? '' : this.__renderTimestamps()}
211
- ${hidden.matches('create', true) || !!this.data ? '' : this.__renderCreate()}
212
- ${hidden.matches('delete', true) || !this.data ? '' : this.__renderDelete()}
213
-
214
- <div
215
- data-testid="spinner"
216
- class=${classMap({
217
- 'transition duration-500 ease-in-out absolute inset-0 flex': true,
218
- 'opacity-0 pointer-events-none': this.in('idle'),
219
- })}
220
- >
221
- <foxy-spinner
222
- layout="vertical"
223
- class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
224
- state=${this.in('fail') ? 'error' : this.in('busy') ? 'busy' : 'empty'}
225
- lang=${this.lang}
226
- ns="${this.ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
227
- >
228
- </foxy-spinner>
229
- </div>
230
- </div>
231
- `;
232
- }
233
- async _sendGet() {
234
- const coupon = await super._sendGet();
235
- const store = await super._fetch(coupon._links['fx:store'].href);
236
- const categoriesURL = new URL(store._links['fx:item_categories'].href);
237
- categoriesURL.searchParams.set('limit', '5');
238
- this.__itemCategories = categoriesURL.toString();
239
- return coupon;
240
- }
241
- __getErrorMessage(prefix) {
242
- const error = this.errors.find(err => err.startsWith(prefix));
243
- return error ? this.t(error.replace(prefix, 'v8n')).toString() : '';
244
- }
245
- __getValidator(prefix) {
246
- return () => !this.errors.some(err => err.startsWith(prefix));
247
- }
248
- __renderName() {
249
- return html `
250
- <div>
251
- ${this.renderTemplateOrSlot('name:before')}
252
-
253
- <vaadin-text-field
254
- error-message=${this.__getErrorMessage('name')}
255
- helper-text=${this.t('coupon_name_helper_text')}
256
- data-testid="name"
257
- class="w-full"
258
- label=${this.t('name')}
259
- .checkValidity=${this.__getValidator('name')}
260
- .value=${this.form.name}
261
- ?disabled=${!this.in('idle') || this.disabledSelector.matches('name', true)}
262
- ?readonly=${this.readonlySelector.matches('name', true)}
263
- required
264
- @keydown=${(evt) => evt.key === 'Enter' && this.submit()}
265
- @input=${(evt) => {
266
- const newName = evt.currentTarget.value;
267
- this.edit({ name: newName });
268
- }}
269
- >
270
- </vaadin-text-field>
271
-
272
- ${this.renderTemplateOrSlot('name:after')}
273
- </div>
274
- `;
241
+ get hiddenSelector() {
242
+ const alwaysMatch = [super.hiddenSelector.toString()];
243
+ if (!this.data) {
244
+ alwaysMatch.push('coupon-codes', 'category-restrictions', 'attributes');
245
+ }
246
+ if (!this.form.customer_auto_apply) {
247
+ alwaysMatch.push('customer-attribute-restrictions', 'customer-subscription-restrictions');
248
+ }
249
+ return new BooleanSelector(alwaysMatch.join(' ').trim());
275
250
  }
276
- __renderRulesPreset() {
277
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
278
- const isReadonly = this.readonlySelector.matches('rules', true);
279
- const details = this.form.coupon_discount_details;
280
- const type = this.form.coupon_discount_type;
281
- const presets = [
282
- { type: 'quantity_amount', details: 'allunits|2-2' },
283
- { type: 'quantity_percentage', details: 'allunits|5-10|10-20' },
284
- { type: 'quantity_amount', details: 'incremental|3-5' },
285
- { type: 'quantity_percentage', details: 'incremental|11-10|51-15|101-20' },
286
- { type: 'quantity_percentage', details: 'repeat|2-100' },
287
- { type: 'quantity_percentage', details: 'repeat|4-50' },
288
- { type: 'quantity_amount', details: 'single|5-10' },
289
- { type: 'price_percentage', details: 'single|99.99-10' },
290
- ];
291
- const selectedPreset = presets.find(p => p.details === details && p.type === type);
251
+ renderHeaderActions(data) {
292
252
  return html `
293
- <label
294
- data-testid="rules:preset"
295
- class=${classMap({
296
- 'whitespace-nowrap block ring-primary-50 rounded px-xs -mx-xs transition-colors': true,
297
- 'text-body hover-text-primary focus-within-ring-2': !isDisabled && !isReadonly,
298
- 'text-disabled': isDisabled,
299
- 'text-secondary': isReadonly,
300
- })}
253
+ <foxy-internal-coupon-form-bulk-add-control
254
+ parent=${data._links['fx:generate_codes'].href}
255
+ infer="generate"
256
+ form="foxy-generate-codes-form"
301
257
  >
302
- <foxy-i18n class="sr-only" lang=${this.lang} key="preset" ns=${this.ns}></foxy-i18n>
303
-
304
- <span class="relative font-medium flex items-center">
305
- <span class="truncate">
306
- ${selectedPreset
307
- ? this.t('discount_summary', { params: { ...selectedPreset, ns: this.ns } })
308
- : this.t('custom_discount')}
309
- </span>
310
-
311
- <iron-icon class="icon-inline text-xl ml-xs -mr-xs" icon="icons:expand-more"></iron-icon>
312
-
313
- <select
314
- data-testclass="interactive editable"
315
- data-testid="rules:preset:select"
316
- class="opacity-0 absolute inset-0 focus-outline-none"
317
- ?disabled=${isDisabled || isReadonly}
318
- @change=${(evt) => {
319
- var _a, _b;
320
- const select = evt.currentTarget;
321
- const preset = presets[select.selectedIndex];
322
- this.edit({
323
- coupon_discount_details: (_a = preset === null || preset === void 0 ? void 0 : preset.details) !== null && _a !== void 0 ? _a : '',
324
- coupon_discount_type: (_b = preset === null || preset === void 0 ? void 0 : preset.type) !== null && _b !== void 0 ? _b : 'quantity_amount',
325
- });
326
- }}
327
- >
328
- ${presets.map(option => {
329
- return html `
330
- <option value=${option.details} ?selected=${option === selectedPreset}>
331
- ${this.t('discount_summary', { params: { ...option, ns: this.ns } })}
332
- </option>
333
- `;
334
- })}
335
-
336
- <option value="custom" ?selected=${!selectedPreset}>
337
- ${this.t('custom_discount')}
338
- </option>
339
- </select>
340
- </span>
341
- </label>
342
- `;
343
- }
344
- __renderRulesUrlParameter() {
345
- var _a, _b, _c;
346
- const name = (_a = this.form.name) !== null && _a !== void 0 ? _a : '';
347
- const type = (_b = this.form.coupon_discount_type) !== null && _b !== void 0 ? _b : 'quantity_amount';
348
- const details = (_c = this.form.coupon_discount_details) !== null && _c !== void 0 ? _c : '';
349
- const urlParameter = `discount_${type}=${encodeURIComponent(`${name}{${details}}`)}`;
350
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
351
- return html `
352
- <div data-testid="rules:url" class="text-xs flex space-x-xs">
353
- <span
354
- class=${classMap({
355
- 'flex-shrink-0 transition-colors': true,
356
- 'text-tertiary': !isDisabled,
357
- 'text-disabled': isDisabled,
358
- })}
359
- >
360
- <foxy-i18n lang=${this.lang} key="url_parameter" ns=${this.ns}></foxy-i18n>&#58;
361
- </span>
362
-
363
- <code
364
- class=${classMap({
365
- 'bg-contrast-5 transition-colors font-lumo truncate rounded-s px-xs': true,
366
- 'text-secondary': !isDisabled,
367
- 'text-disabled': isDisabled,
368
- })}
369
- >
370
- ${urlParameter}
371
- </code>
372
-
373
- <foxy-copy-to-clipboard
374
- data-testid="rules:url:copy"
375
- text=${urlParameter}
376
- lang=${this.lang}
377
- ns="${this.ns} copy-to-clipboard"
378
- ?disabled=${isDisabled}
379
- >
380
- </foxy-copy-to-clipboard>
381
- </div>
382
- `;
383
- }
384
- __renderRulesDescription() {
385
- var _a, _b;
386
- const type = (_a = this.form.coupon_discount_type) !== null && _a !== void 0 ? _a : 'quantity_amount';
387
- const details = (_b = this.form.coupon_discount_details) !== null && _b !== void 0 ? _b : '';
388
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
389
- return html `
390
- <div data-testid="rules:description" class="text-xs leading-m">
391
- <span class="transition-colors ${isDisabled ? 'text-disabled' : 'text-tertiary'}">
392
- <foxy-i18n lang=${this.lang} key="description" ns=${this.ns}></foxy-i18n>&#58;
393
- </span>
394
-
395
- <foxy-i18n
396
- options=${JSON.stringify({ params: { details, type, ns: this.ns } })}
397
- class="transition-colors ${isDisabled ? 'text-disabled' : 'text-secondary'}"
398
- lang=${this.lang}
399
- key="discount_summary"
400
- ns=${this.ns}
401
- >
402
- </foxy-i18n>
403
- </div>
404
- `;
405
- }
406
- __renderRules() {
407
- var _a, _b;
408
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('rules', true);
409
- const isReadonly = this.readonlySelector.matches('rules', true);
410
- const details = (_a = this.form.coupon_discount_details) !== null && _a !== void 0 ? _a : '';
411
- const type = (_b = this.form.coupon_discount_type) !== null && _b !== void 0 ? _b : 'quantity_amount';
412
- return html `
413
- <div data-testid="rules">
414
- ${this.renderTemplateOrSlot('rules:before')}
415
-
416
- <div>
417
- <div class="flex items-center justify-between space-x-m text-s mb-xs">
418
- <foxy-i18n
419
- class=${classMap({
420
- 'transition-colors font-medium flex-1': true,
421
- 'text-secondary': !isDisabled,
422
- 'text-disabled': isDisabled,
423
- })}
424
- lang=${this.lang}
425
- key="rule_plural"
426
- ns=${this.ns}
427
- >
428
- </foxy-i18n>
429
-
430
- <div class="min-w-0">${this.__renderRulesPreset()}</div>
431
- </div>
432
-
433
- <foxy-discount-builder
434
- data-testclass="interactive"
435
- lang=${this.lang}
436
- ns=${this.ns}
437
- ?readonly=${isReadonly}
438
- ?disabled=${isDisabled}
439
- .parsedValue=${{ details, type, name: 'Rules' }}
440
- @change=${(evt) => {
441
- const builder = evt.currentTarget;
442
- const newParsedValue = builder.parsedValue;
443
- this.edit({
444
- coupon_discount_details: newParsedValue.details,
445
- coupon_discount_type: newParsedValue.type,
446
- });
447
- }}
448
- >
449
- </foxy-discount-builder>
258
+ </foxy-internal-coupon-form-bulk-add-control>
450
259
 
451
- <div class="space-y-xs mt-m">
452
- ${this.__renderRulesUrlParameter()} ${this.__renderRulesDescription()}
453
- </div>
454
- </div>
260
+ <foxy-internal-coupon-form-bulk-add-control
261
+ parent=${data._links['fx:coupon_codes'].href}
262
+ infer="import"
263
+ form="foxy-coupon-codes-form"
264
+ >
265
+ </foxy-internal-coupon-form-bulk-add-control>
455
266
 
456
- ${this.renderTemplateOrSlot('rules:after')}
457
- </div>
267
+ ${super.renderHeaderActions(data)}
458
268
  `;
459
269
  }
460
- __renderCodes() {
461
- var _a, _b, _c, _d, _e;
462
- const { disabledSelector, group, data, lang, ns } = this;
463
- const isDisabled = !this.in('idle') || disabledSelector.matches('codes', true);
464
- const filters = this.__codesTableQuery;
465
- const url = new URL(data._links['fx:coupon_codes'].href);
466
- new URLSearchParams(filters !== null && filters !== void 0 ? filters : '').forEach((value, name) => url.searchParams.set(name, value));
467
- url.searchParams.set('limit', '5');
468
- const filterButtonLabel = filters === null ? 'filter' : 'clear_filters';
469
- const filterButtonIcon = `icons:${filters === null ? 'filter-list' : 'clear'}`;
270
+ renderBody() {
271
+ var _a, _b, _c, _d, _e, _f, _g, _h;
272
+ let codesUrl;
273
+ try {
274
+ const url = new URL((_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a._links['fx:coupon_codes'].href) !== null && _b !== void 0 ? _b : '');
275
+ url.searchParams.set('order', 'date_created desc');
276
+ codesUrl = url.toString();
277
+ }
278
+ catch (_j) {
279
+ codesUrl = undefined;
280
+ }
470
281
  return html `
471
- <div data-testid="codes">
472
- <foxy-form-dialog
473
- disabledcontrols=${disabledSelector.zoom('codes:generate:form').toString()}
474
- readonlycontrols=${this.readonlySelector.zoom('codes:generate:form').toString()}
475
- hiddencontrols="save-button current-balance ${this.hiddenSelector
476
- .zoom('codes:generate:form')
477
- .toString()}"
478
- related=${JSON.stringify([url.toString()])}
479
- header="generate"
480
- parent=${(_a = data === null || data === void 0 ? void 0 : data._links['fx:generate_codes'].href) !== null && _a !== void 0 ? _a : ''}
481
- group=${group}
482
- lang=${lang}
483
- form="foxy-generate-codes-form"
484
- ns=${ns}
485
- id="generate-codes-dialog"
486
- alert
487
- .related=${[url.toString()]}
488
- >
489
- </foxy-form-dialog>
490
-
491
- <foxy-form-dialog
492
- disabledcontrols=${disabledSelector.zoom('codes:form').toString()}
493
- readonlycontrols=${this.readonlySelector.zoom('codes:form').toString()}
494
- hiddencontrols=${this.hiddenSelector.zoom('codes:form').toString()}
495
- header="code"
496
- parent=${url.toString()}
497
- group=${group}
498
- lang=${lang}
499
- form="foxy-coupon-code-form"
500
- ns=${ns}
501
- id="code-dialog"
502
- alert
503
- .props=${{ '.getTransactionPageHref': this.getTransactionPageHref }}
504
- >
505
- </foxy-form-dialog>
506
-
507
- <foxy-form-dialog
508
- disabledcontrols=${disabledSelector.zoom('codes:import:form').toString()}
509
- readonlycontrols=${this.readonlySelector.zoom('codes:import:form').toString()}
510
- hiddencontrols="save-button ${this.hiddenSelector.zoom('codes:import:form').toString()}"
511
- header="import"
512
- parent=${data._links['fx:coupon_codes'].href}
513
- group=${group}
514
- lang=${lang}
515
- form="foxy-coupon-codes-form"
516
- ns=${ns}
517
- id="import-dialog"
518
- >
519
- </foxy-form-dialog>
520
-
521
- ${this.renderTemplateOrSlot('codes:before')}
522
-
523
- <div class="flex items-center justify-between mb-xs space-x-s">
524
- <foxy-i18n
525
- class="text-s font-medium text-secondary leading-none flex-1"
526
- lang=${lang}
527
- key="code_plural"
528
- ns=${ns}
529
- >
530
- </foxy-i18n>
531
-
532
- <vaadin-button
533
- data-testid="codes:generate-button"
534
- theme="success tertiary small"
535
- ?disabled=${isDisabled}
536
- @click=${(evt) => {
537
- const dialog = this.renderRoot.querySelector('#generate-codes-dialog');
538
- const button = evt.currentTarget;
539
- dialog === null || dialog === void 0 ? void 0 : dialog.show(button);
540
- }}
541
- >
542
- <foxy-i18n class="text-s" lang=${lang} key="generate" ns=${ns}></foxy-i18n>
543
- <iron-icon class="icon-inline text-s" icon="icons:add"></iron-icon>
544
- </vaadin-button>
545
-
546
- <vaadin-button
547
- data-testid="codes:import-button"
548
- theme="contrast tertiary small"
549
- ?disabled=${isDisabled}
550
- @click=${(evt) => {
551
- const dialog = this.renderRoot.querySelector('#import-dialog');
552
- const button = evt.currentTarget;
553
- dialog === null || dialog === void 0 ? void 0 : dialog.show(button);
554
- }}
555
- >
556
- <foxy-i18n class="text-s" lang=${lang} key="import" ns=${ns}></foxy-i18n>
557
- <iron-icon class="icon-inline text-s" icon="icons:open-in-browser"></iron-icon>
558
- </vaadin-button>
282
+ ${this.renderHeader()}
283
+
284
+ <foxy-internal-text-control infer="name"></foxy-internal-text-control>
285
+
286
+ <foxy-internal-coupon-form-rules-control infer="rules">
287
+ </foxy-internal-coupon-form-rules-control>
288
+
289
+ <foxy-internal-async-list-control
290
+ first=${codesUrl}
291
+ limit="5"
292
+ infer="coupon-codes"
293
+ item="foxy-coupon-code-card"
294
+ form="foxy-coupon-code-form"
295
+ alert
296
+ .formProps=${{ '.getTransactionPageHref': this.getTransactionPageHref }}
297
+ .actions=${this.__couponCodesActions}
298
+ .filters=${this.__codesFilters}
299
+ >
300
+ </foxy-internal-async-list-control>
301
+
302
+ <foxy-internal-query-builder-control
303
+ infer="item-option-restrictions"
304
+ disable-or
305
+ .operators=${this.__itemOptionRestrictionsOperators}
306
+ .getValue=${this.__itemOptionRestrictionsGetValue}
307
+ .setValue=${this.__itemOptionRestrictionsSetValue}
308
+ >
309
+ </foxy-internal-query-builder-control>
310
+
311
+ <foxy-internal-editable-list-control
312
+ infer="product-code-restrictions"
313
+ .getValue=${this.__productCodeRestrictionsGetValue}
314
+ .setValue=${this.__productCodeRestrictionsSetValue}
315
+ .units=${[
316
+ { label: this.t('product-code-restrictions.unit_allow'), value: 'allow' },
317
+ { label: this.t('product-code-restrictions.unit_block'), value: 'block' },
318
+ ]}
319
+ >
320
+ </foxy-internal-editable-list-control>
321
+
322
+ <foxy-internal-async-resource-link-list-control
323
+ foreign-key-for-uri="item_category_uri"
324
+ foreign-key-for-id="item_category_id"
325
+ own-key-for-uri="coupon_uri"
326
+ own-uri=${ifDefined((_c = this.data) === null || _c === void 0 ? void 0 : _c._links.self.href)}
327
+ embed-key="fx:coupon_item_categories"
328
+ options-href=${ifDefined((_e = (_d = this.__storeLoader) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e._links['fx:item_categories'].href)}
329
+ links-href=${ifDefined((_f = this.data) === null || _f === void 0 ? void 0 : _f._links['fx:coupon_item_categories'].href)}
330
+ infer="category-restrictions"
331
+ limit="5"
332
+ item="foxy-item-category-card"
333
+ >
334
+ </foxy-internal-async-resource-link-list-control>
559
335
 
560
- <vaadin-button
561
- data-testid="codes:filter-button"
562
- theme="contrast ${filters === null ? 'tertiary' : ''} small"
563
- ?disabled=${isDisabled}
564
- @click=${() => (this.__codesTableQuery = filters === null ? '' : null)}
565
- >
566
- <foxy-i18n class="text-s" lang=${lang} key=${filterButtonLabel} ns=${ns}></foxy-i18n>
567
- <iron-icon class="icon-inline text-s" icon=${filterButtonIcon}></iron-icon>
568
- </vaadin-button>
569
- </div>
336
+ <div class="grid gap-l sm-grid-cols-3">
337
+ <foxy-internal-integer-control infer="number-of-uses-allowed" min="0" show-controls>
338
+ </foxy-internal-integer-control>
570
339
 
571
- <foxy-query-builder
572
- class="my-s"
573
- lang=${lang}
574
- ns="${ns} ${(_c = (_b = customElements.get('foxy-query-builder')) === null || _b === void 0 ? void 0 : _b.defaultNS) !== null && _c !== void 0 ? _c : ''}"
575
- ?disabled=${isDisabled}
576
- ?hidden=${filters === null}
577
- .options=${CouponForm.__codesQueryOptions}
578
- .value=${filters}
579
- @change=${(evt) => {
580
- const queryBuilder = evt.currentTarget;
581
- this.__codesTableQuery = queryBuilder.value;
582
- }}
340
+ <foxy-internal-integer-control
341
+ infer="number-of-uses-allowed-per-customer"
342
+ min="0"
343
+ show-controls
583
344
  >
584
- </foxy-query-builder>
345
+ </foxy-internal-integer-control>
585
346
 
586
- <foxy-pagination
587
- first=${url.toString()}
588
- lang=${lang}
589
- ns="${ns} ${(_e = (_d = customElements.get('foxy-pagination')) === null || _d === void 0 ? void 0 : _d.defaultNS) !== null && _e !== void 0 ? _e : ''}"
590
- ?disabled=${isDisabled}
347
+ <foxy-internal-integer-control
348
+ infer="number-of-uses-allowed-per-code"
349
+ min="0"
350
+ show-controls
591
351
  >
592
- <foxy-table
593
- class="px-m mb-s border border-contrast-10 rounded"
594
- group=${group}
595
- lang=${lang}
596
- ns=${ns}
597
- .columns=${this.__codesTableColumns}
598
- >
599
- </foxy-table>
600
- </foxy-pagination>
601
-
602
- ${this.renderTemplateOrSlot('codes:after')}
603
- </div>
604
- `;
605
- }
606
- __renderUsage() {
607
- var _a, _b, _c;
608
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('usage', true);
609
- const isReadonly = this.readonlySelector.matches('usage', true);
610
- const usesPerCoupon = (_a = this.form.number_of_uses_allowed) !== null && _a !== void 0 ? _a : 0;
611
- const usesPerCustomer = (_b = this.form.number_of_uses_allowed_per_customer) !== null && _b !== void 0 ? _b : 0;
612
- const usesPerCouponCode = (_c = this.form.number_of_uses_allowed_per_code) !== null && _c !== void 0 ? _c : 0;
613
- return html `
614
- <div data-testid="usage">
615
- ${this.renderTemplateOrSlot('usage:before')}
616
-
617
- <div class="space-y-s">
618
- <div class="grid gap-m grid-cols-3">
619
- <vaadin-integer-field
620
- placeholder=${this.t('unlimited')}
621
- data-testid="usage:per-coupon"
622
- label=${this.t('uses_per_coupon')}
623
- class="w-full"
624
- min="0"
625
- prevent-invalid-input
626
- has-controls
627
- .value=${usesPerCoupon || ''}
628
- ?disabled=${isDisabled}
629
- ?readonly=${isReadonly}
630
- @change=${(evt) => {
631
- const field = evt.currentTarget;
632
- this.edit({ number_of_uses_allowed: parseInt(field.value) });
633
- }}
634
- >
635
- </vaadin-integer-field>
636
-
637
- <vaadin-integer-field
638
- placeholder=${this.t('unlimited')}
639
- data-testid="usage:per-coupon-code"
640
- label=${this.t('uses_per_coupon_code')}
641
- class="w-full"
642
- min="0"
643
- prevent-invalid-input
644
- has-controls
645
- .value=${usesPerCouponCode || ''}
646
- ?disabled=${isDisabled}
647
- ?readonly=${isReadonly}
648
- @change=${(evt) => {
649
- const field = evt.currentTarget;
650
- this.edit({ number_of_uses_allowed_per_code: parseInt(field.value) });
651
- }}
652
- >
653
- </vaadin-integer-field>
654
-
655
- <vaadin-integer-field
656
- placeholder=${this.t('unlimited')}
657
- data-testid="usage:per-customer"
658
- label=${this.t('uses_per_customer')}
659
- class="w-full"
660
- min="0"
661
- prevent-invalid-input
662
- has-controls
663
- .value=${usesPerCustomer || ''}
664
- ?disabled=${isDisabled}
665
- ?readonly=${isReadonly}
666
- @change=${(evt) => {
667
- const field = evt.currentTarget;
668
- this.edit({ number_of_uses_allowed_per_customer: parseInt(field.value) });
669
- }}
670
- >
671
- </vaadin-integer-field>
672
- </div>
673
-
674
- <div
675
- class=${classMap({
676
- 'transition-colors text-xs leading-s': true,
677
- 'text-secondary': !isDisabled,
678
- 'text-disabled': isDisabled,
679
- })}
680
- >
681
- <foxy-i18n
682
- options=${JSON.stringify({ count: usesPerCoupon })}
683
- lang=${this.lang}
684
- key="uses_per_coupon_summary${usesPerCoupon ? '' : '_0'}"
685
- ns=${this.ns}
686
- >
687
- </foxy-i18n>
688
-
689
- <foxy-i18n
690
- options=${JSON.stringify({ count: usesPerCouponCode })}
691
- lang=${this.lang}
692
- key="uses_per_coupon_code_summary${usesPerCouponCode ? '' : '_0'}"
693
- ns=${this.ns}
694
- >
695
- </foxy-i18n>
696
-
697
- <foxy-i18n
698
- options=${JSON.stringify({ count: usesPerCustomer })}
699
- lang=${this.lang}
700
- key="uses_per_customer_summary${usesPerCustomer ? '' : '_0'}"
701
- ns=${this.ns}
702
- >
703
- </foxy-i18n>
704
- </div>
705
- </div>
706
-
707
- ${this.renderTemplateOrSlot('usage:after')}
708
- </div>
709
- `;
710
- }
711
- __renderProductRestrictions() {
712
- var _a;
713
- const scope = 'product-restrictions';
714
- const isDisabled = !this.in('idle') || this.disabledSelector.matches(scope, true);
715
- const isReadonly = this.readonlySelector.matches(scope, true);
716
- const restrictions = (_a = this.form.product_code_restrictions) !== null && _a !== void 0 ? _a : '';
717
- const groups = [
718
- { header: 'allow', items: [] },
719
- { header: 'block', items: [] },
720
- ];
721
- if (restrictions) {
722
- restrictions.split(',').forEach(value => {
723
- const trimmedValue = value.trim();
724
- if (!trimmedValue)
725
- return;
726
- const isBlocklistValue = trimmedValue.startsWith('-');
727
- const target = isBlocklistValue ? 1 : 0;
728
- const label = isBlocklistValue ? trimmedValue.substring(1) : trimmedValue;
729
- groups[target].items.push({ label, value: trimmedValue });
730
- });
731
- }
732
- return html `
733
- <div data-testid="product-restrictions">
734
- ${this.renderTemplateOrSlot('product-restrictions:before')}
735
-
736
- <div class="space-y-s">
737
- <x-group frame>
738
- <foxy-i18n
739
- class=${isDisabled ? 'text-disabled' : 'text-secondary'}
740
- slot="header"
741
- lang=${this.lang}
742
- key="product_restrictions"
743
- ns=${this.ns}
744
- >
745
- </foxy-i18n>
746
-
747
- <div class="grid sm-grid-cols-2 bg-contrast-10" style="gap: 1px">
748
- ${groups.map((group, index) => {
749
- return html `
750
- <x-group class="bg-base pt-m">
751
- <foxy-i18n
752
- class=${isDisabled ? 'text-disabled' : 'text-tertiary'}
753
- slot="header"
754
- lang=${this.lang}
755
- key=${group.header}
756
- ns=${this.ns}
757
- >
758
- </foxy-i18n>
759
-
760
- <x-editable-list
761
- data-testid="product-restrictions:${group.header}"
762
- lang=${this.lang}
763
- ns=${this.ns}
764
- ?disabled=${isDisabled}
765
- ?readonly=${isReadonly}
766
- .items=${group.items}
767
- @change=${(evt) => {
768
- const newItemsByGroup = [
769
- index === 0 ? evt.currentTarget.items : groups[0].items,
770
- index === 1 ? evt.currentTarget.items : groups[1].items,
771
- ];
772
- const newSanitizedItemsByGroup = newItemsByGroup
773
- .map(list => list.map(v => v.value.replace(/^[\s-]*/, '').trimEnd()))
774
- .map(list => list.filter(v => !!v))
775
- .map(list => Array.from(new Set(list)));
776
- const newRestrictions = newSanitizedItemsByGroup[0]
777
- .concat(newSanitizedItemsByGroup[1].map(v => `-${v}`))
778
- .join(',');
779
- this.edit({ product_code_restrictions: newRestrictions });
780
- }}
781
- >
782
- </x-editable-list>
783
- </x-group>
784
- `;
785
- })}
786
- </div>
787
- </x-group>
788
-
789
- <foxy-i18n
790
- class=${classMap({
791
- 'block text-xs leading-s transition-colors': true,
792
- 'text-secondary': !isDisabled,
793
- 'text-disabled': isDisabled,
794
- })}
795
- lang=${this.lang}
796
- key="product_restrictions_explainer"
797
- ns=${this.ns}
798
- >
799
- </foxy-i18n>
800
- </div>
801
-
802
- ${this.renderTemplateOrSlot('product-restrictions:after')}
803
- </div>
804
- `;
805
- }
806
- __renderCategoryRestrictions() {
807
- var _a, _b, _c;
808
- const scope = 'category-restrictions';
809
- const isDisabled = !this.in('idle') || this.disabledSelector.matches(scope, true);
810
- const isReadonly = this.readonlySelector.matches(scope, true);
811
- return html `
812
- <div data-testid="category-restrictions">
813
- ${this.renderTemplateOrSlot('category-restrictions:before')}
814
-
815
- <div class="space-y-xs">
816
- <foxy-pagination
817
- first=${this.__itemCategories}
818
- lang=${this.lang}
819
- ns="${this.ns} ${(_b = (_a = customElements.get('foxy-pagination')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
820
- ?disabled=${isDisabled}
821
- >
822
- <foxy-i18n
823
- class="block text-s font-medium text-secondary leading-none mb-s"
824
- lang=${this.lang}
825
- key="category_restrictions"
826
- ns=${this.ns}
827
- >
828
- </foxy-i18n>
829
-
830
- <x-category-restrictions-page
831
- coupon-item-categories=${ifDefined((_c = this.data) === null || _c === void 0 ? void 0 : _c._links['fx:coupon_item_categories'].href)}
832
- data-testid="category-restrictions:page"
833
- coupon=${this.href}
834
- class="border border-contrast-10 rounded mb-s"
835
- group=${this.group}
836
- lang=${this.lang}
837
- ns=${this.ns}
838
- ?disabled=${isDisabled}
839
- ?readonly=${isReadonly}
840
- >
841
- </x-category-restrictions-page>
842
- </foxy-pagination>
843
-
844
- <foxy-i18n
845
- class="block text-xs leading-s text-tertiary"
846
- lang=${this.lang}
847
- key="category_restrictions_helper_text"
848
- ns=${this.ns}
849
- >
850
- </foxy-i18n>
851
- </div>
852
-
853
- ${this.renderTemplateOrSlot('category-restrictions:after')}
352
+ </foxy-internal-integer-control>
854
353
  </div>
855
- `;
856
- }
857
- __renderCustomerAttributeRestrictions() {
858
- var _a;
859
- const scope = 'customer-attribute-restrictions';
860
- const isDisabled = this.disabledSelector.matches(scope, true);
861
- const isReadonly = this.readonlySelector.matches(scope, true);
862
- return html `
863
- <div data-testid="customer-attribute-restrictions">
864
- ${this.renderTemplateOrSlot(`${scope}:before`)}
865
-
866
- <div
867
- class=${classMap({
868
- 'grid gap-xs leading-xs transition-colors': true,
869
- 'text-secondary hover-text-body': !isDisabled && !isReadonly,
870
- 'text-disabled': isDisabled,
871
- 'text-body': isReadonly,
872
- })}
873
- >
874
- <foxy-i18n class="text-s font-medium" infer=${scope} key="label"></foxy-i18n>
875
-
876
- <foxy-query-builder
877
- infer=${scope}
878
- .value=${(_a = this.form.customer_attribute_restrictions) !== null && _a !== void 0 ? _a : null}
879
- @change=${(evt) => {
880
- var _a;
881
- const queryBuilder = evt.currentTarget;
882
- this.edit({ customer_attribute_restrictions: (_a = queryBuilder.value) !== null && _a !== void 0 ? _a : '' });
883
- this.edit({
884
- customer_auto_apply: !!this.form.customer_subscription_restrictions ||
885
- !!this.form.customer_attribute_restrictions,
886
- });
887
- }}
888
- >
889
- </foxy-query-builder>
890
354
 
891
- <foxy-i18n class="text-xs" infer=${scope} key="helper_text"></foxy-i18n>
892
- </div>
893
-
894
- ${this.renderTemplateOrSlot(`${scope}:after`)}
355
+ <div class="grid gap-l sm-grid-cols-2">
356
+ <foxy-internal-date-control infer="start-date"></foxy-internal-date-control>
357
+ <foxy-internal-date-control infer="end-date"></foxy-internal-date-control>
895
358
  </div>
896
- `;
897
- }
898
- __renderOptions() {
899
- const isDisabled = !this.in('idle') || this.disabledSelector.matches('options', true);
900
- const isReadonly = this.readonlySelector.matches('options', true);
901
- const options = [
902
- { param: 'multiple_codes_allowed' },
903
- { param: 'combinable' },
904
- { param: 'exclude_category_discounts', label: 'combine_with_category_discounts', flip: true },
905
- { param: 'exclude_line_item_discounts', label: 'combine_with_line_discounts', flip: true },
906
- { param: 'is_taxable', label: 'apply_taxes_before_coupon' },
907
- ];
908
- return html `
909
- <div data-testid="options">
910
- ${this.renderTemplateOrSlot('options:before')}
911
-
912
- <x-group frame>
913
- <foxy-i18n
914
- class="transition-colors ${isDisabled ? 'text-disabled' : 'text-secondary'}"
915
- slot="header"
916
- lang=${this.lang}
917
- key="option_plural"
918
- ns=${this.ns}
919
- >
920
- </foxy-i18n>
921
-
922
- ${options.map(option => {
923
- var _a;
924
- const value = this.form[option.param];
925
- const label = (_a = option.label) !== null && _a !== void 0 ? _a : option.param;
926
- const color = isDisabled ? 'text-disabled' : 'text-secondary';
927
- return html `
928
- <x-checkbox
929
- data-testclass="inputs"
930
- data-testid="options:${option.param.replace(/_/g, '-')}"
931
- ?disabled=${isDisabled}
932
- ?readonly=${isReadonly}
933
- ?checked=${option.flip ? !value : value}
934
- class="m-m"
935
- @change=${(evt) => {
936
- this.edit({ [option.param]: option.flip ? !evt.detail : evt.detail });
937
- }}
938
- >
939
- <div class="flex flex-col">
940
- <foxy-i18n lang=${this.lang} key=${label} ns=${this.ns}></foxy-i18n>
941
- <foxy-i18n
942
- class="transition-colors text-xs leading-s ${color}"
943
- lang=${this.lang}
944
- key="${label}_explainer"
945
- ns=${this.ns}
946
- >
947
- </foxy-i18n>
948
- </div>
949
- </x-checkbox>
950
-
951
- <div style="margin-left: calc(1.125rem + (var(--lumo-space-m) * 2))">
952
- <div class="border-b border-contrast-10"></div>
953
- </div>
954
- `;
955
- })}
956
-
957
- <x-checkbox
958
- data-testclass="inputs"
959
- data-testid="options:dates"
960
- ?disabled=${isDisabled}
961
- ?readonly=${isReadonly}
962
- ?checked=${this.form.start_date || this.form.end_date}
963
- class="m-m"
964
- @change=${(evt) => {
965
- if (evt instanceof CheckboxChangeEvent) {
966
- let startDate = null;
967
- let endDate = null;
968
- if (evt.detail) {
969
- const today = Date.now();
970
- const oneMonthFromToday = new Date(today).setMonth(new Date().getMonth() + 1);
971
- startDate = serializeDate(new Date(today));
972
- endDate = serializeDate(new Date(oneMonthFromToday));
973
- }
974
- this.edit({ start_date: startDate, end_date: endDate });
975
- }
976
- }}
977
- >
978
- <div class="flex flex-col">
979
- <foxy-i18n lang=${this.lang} key="set_time_constraints" ns=${this.ns}></foxy-i18n>
980
- <foxy-i18n
981
- class="text-xs leading-s ${isDisabled ? 'text-disabled' : 'text-secondary'}"
982
- lang=${this.lang}
983
- key="set_time_constraints_explainer"
984
- ns=${this.ns}
985
- >
986
- </foxy-i18n>
987
- </div>
988
359
 
989
- ${this.form.start_date || this.form.end_date
990
- ? html `
991
- <div
992
- class="grid grid-cols-2 gap-m mt-m"
993
- slot="content"
994
- style="--lumo-border-radius: var(--lumo-border-radius-s)"
995
- >
996
- ${['start_date', 'end_date'].map(property => {
997
- const formValue = this.form[property];
998
- const pickerValue = formValue
999
- ? formValue.length > 10
1000
- ? serializeDate(new Date(formValue))
1001
- : formValue
1002
- : '';
1003
- return html `
1004
- <vaadin-date-picker
1005
- data-testclass="inputs"
1006
- data-testid="options:${property.replace('_', '-')}"
1007
- placeholder=${this.t('select')}
1008
- label=${this.t(property)}
1009
- clear-button-visible
1010
- ?disabled=${isDisabled}
1011
- ?readonly=${isReadonly}
1012
- .value=${live(pickerValue)}
1013
- @change=${(evt) => {
1014
- const field = evt.currentTarget;
1015
- this.edit({ [property]: field.value });
1016
- }}
1017
- >
1018
- </vaadin-date-picker>
1019
- `;
1020
- })}
1021
- </div>
1022
- `
1023
- : ''}
1024
- </x-checkbox>
1025
- </x-group>
360
+ <foxy-internal-number-control min="0" max="1" infer="inclusive-tax-rate">
361
+ </foxy-internal-number-control>
1026
362
 
1027
- ${this.renderTemplateOrSlot('options:after')}
1028
- </div>
1029
- `;
1030
- }
1031
- __renderTimestamps() {
1032
- return html `
1033
- <div>
1034
- ${this.renderTemplateOrSlot('timestamps:before')}
1035
-
1036
- <x-metadata
1037
- data-testid="timestamps"
1038
- .items=${['date_modified', 'date_created'].map(field => {
1039
- var _a;
1040
- return ({
1041
- name: this.t(field),
1042
- value: ((_a = this.data) === null || _a === void 0 ? void 0 : _a[field]) ? this.t('date', { value: new Date(this.data[field]) })
1043
- : '',
1044
- });
1045
- })}
1046
- >
1047
- </x-metadata>
363
+ <foxy-internal-checkbox-group-control
364
+ infer="options"
365
+ theme="vertical"
366
+ .getValue=${this.__optionsGetValue}
367
+ .setValue=${this.__optionsSetValue}
368
+ .options=${this.__optionsOptions}
369
+ >
370
+ </foxy-internal-checkbox-group-control>
1048
371
 
1049
- ${this.renderTemplateOrSlot('timestamps:after')}
1050
- </div>
1051
- `;
1052
- }
1053
- __renderCreate() {
1054
- const isCleanTemplateInvalid = this.in({ idle: { template: { clean: 'invalid' } } });
1055
- const isDirtyTemplateInvalid = this.in({ idle: { template: { dirty: 'invalid' } } });
1056
- const isCleanSnapshotInvalid = this.in({ idle: { snapshot: { clean: 'invalid' } } });
1057
- const isDirtySnapshotInvalid = this.in({ idle: { snapshot: { dirty: 'invalid' } } });
1058
- const isTemplateInvalid = isCleanTemplateInvalid || isDirtyTemplateInvalid;
1059
- const isSnaphotInvalid = isCleanSnapshotInvalid || isDirtySnapshotInvalid;
1060
- const isInvalid = isTemplateInvalid || isSnaphotInvalid;
1061
- const isIdle = this.in('idle');
1062
- return html `
1063
- <div>
1064
- ${this.renderTemplateOrSlot('create:before')}
372
+ <foxy-internal-editable-list-control
373
+ infer="customer-subscription-restrictions"
374
+ .getValue=${this.__customerSubscriptionRestrictionsGetValue}
375
+ .setValue=${this.__customerSubscriptionRestrictionsSetValue}
376
+ >
377
+ </foxy-internal-editable-list-control>
378
+
379
+ <foxy-internal-query-builder-control infer="customer-attribute-restrictions">
380
+ </foxy-internal-query-builder-control>
381
+
382
+ <foxy-internal-async-list-control
383
+ first=${ifDefined((_g = this.data) === null || _g === void 0 ? void 0 : _g._links['fx:attributes'].href)}
384
+ limit="5"
385
+ infer="attributes"
386
+ item="foxy-attribute-card"
387
+ form="foxy-attribute-form"
388
+ alert
389
+ >
390
+ </foxy-internal-async-list-control>
1065
391
 
1066
- <vaadin-button
1067
- data-testid="create"
1068
- class="w-full"
1069
- theme="primary success"
1070
- ?disabled=${!isIdle || isInvalid || this.disabledSelector.matches('create', true)}
1071
- @click=${this.submit}
1072
- >
1073
- <foxy-i18n ns=${this.ns} key="create" lang=${this.lang}></foxy-i18n>
1074
- </vaadin-button>
392
+ ${super.renderBody()}
1075
393
 
1076
- ${this.renderTemplateOrSlot('create:after')}
1077
- </div>
394
+ <foxy-nucleon
395
+ infer=""
396
+ class="hidden"
397
+ href=${ifDefined((_h = this.data) === null || _h === void 0 ? void 0 : _h._links['fx:store'].href)}
398
+ id=${this.__storeLoaderId}
399
+ @update=${() => this.requestUpdate()}
400
+ >
401
+ </foxy-nucleon>
1078
402
  `;
1079
403
  }
1080
- __renderDelete() {
1081
- return html `
1082
- <div>
1083
- <foxy-internal-confirm-dialog
1084
- data-testid="confirm"
1085
- message="delete_prompt"
1086
- confirm="delete"
1087
- cancel="cancel"
1088
- header="delete"
1089
- theme="primary error"
1090
- lang=${this.lang}
1091
- ns=${this.ns}
1092
- id="confirm"
1093
- @hide=${(evt) => !evt.detail.cancelled && this.delete()}
1094
- >
1095
- </foxy-internal-confirm-dialog>
1096
-
1097
- ${this.renderTemplateOrSlot('delete:before')}
1098
-
1099
- <vaadin-button
1100
- data-testid="delete"
1101
- theme="error"
1102
- class="w-full"
1103
- ?disabled=${!this.in('idle') || this.disabledSelector.matches('delete', true)}
1104
- @click=${(evt) => {
1105
- const confirm = this.renderRoot.querySelector('#confirm');
1106
- confirm.show(evt.currentTarget);
1107
- }}
1108
- >
1109
- <foxy-i18n ns=${this.ns} key="delete" lang=${this.lang}></foxy-i18n>
1110
- </vaadin-button>
1111
-
1112
- ${this.renderTemplateOrSlot('delete:after')}
1113
- </div>
1114
- `;
404
+ get __storeLoader() {
405
+ return this.renderRoot.querySelector(`#${this.__storeLoaderId}`);
1115
406
  }
1116
407
  }
1117
- CouponForm.__codesQueryOptions = [
1118
- { label: 'code', path: 'code', type: Type.String },
1119
- { label: 'used_codes', path: 'number_of_uses_to_date', type: Type.Number },
1120
- { label: 'date_created', path: 'date_created', type: Type.Date },
1121
- { label: 'date_modified', path: 'date_modified', type: Type.Date },
1122
- ];
1123
408
  //# sourceMappingURL=CouponForm.js.map