@repobit/dex-store-elements 1.4.3 → 1.4.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.4.5](https://github.com/bitdefender/dex-core/compare/@repobit/dex-store-elements@1.4.4...@repobit/dex-store-elements@1.4.5) (2026-03-19)
7
+
8
+ **Note:** Version bump only for package @repobit/dex-store-elements
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.4.4](https://github.com/bitdefender/dex-core/compare/@repobit/dex-store-elements@1.4.3...@repobit/dex-store-elements@1.4.4) (2026-03-19)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **DEX-26778:** fix no discount price ([f08d636](https://github.com/bitdefender/dex-core/commit/f08d63626a15f536bfdbd4f6f47bc4f3fcabab97))
20
+
21
+
22
+
6
23
  ## [1.4.3](https://github.com/bitdefender/dex-core/compare/@repobit/dex-store-elements@1.4.2...@repobit/dex-store-elements@1.4.3) (2026-03-03)
7
24
 
8
25
 
@@ -18,20 +18,20 @@ const OPTION_DISCOUNT_AVAILABLE = {
18
18
  'percentage-monthly': (option) => isPresent(option.getDiscount({ symbol: false, percentage: true, monthly: true }))
19
19
  };
20
20
  const OPTION_DISCOUNT_RENDER = {
21
- 'value': (option) => String(option.getDiscount({ percentage: false })),
22
- 'percentage': (option) => String(option.getDiscount({ percentage: true })),
23
- 'value-monthly': (option) => String(option.getDiscount({ percentage: false, monthly: true })),
24
- 'percentage-monthly': (option) => String(option.getDiscount({ percentage: true, monthly: true }))
21
+ 'value': (option) => option.getDiscount({ percentage: false }),
22
+ 'percentage': (option) => option.getDiscount({ percentage: true }),
23
+ 'value-monthly': (option) => option.getDiscount({ percentage: false, monthly: true }),
24
+ 'percentage-monthly': (option) => option.getDiscount({ percentage: true, monthly: true })
25
25
  };
26
26
  const STATE_DISCOUNT_AVAILABLE = {
27
- 'min-value': (state) => isPresent(state.discount.min.value),
28
- 'max-value': (state) => isPresent(state.discount.max.value),
29
- 'min-value-monthly': (state) => isPresent(state.discount.monthly.min.value),
30
- 'max-value-monthly': (state) => isPresent(state.discount.monthly.max.value),
31
- 'min-percentage': (state) => isPresent(state.discount.percentage.min.value),
32
- 'max-percentage': (state) => isPresent(state.discount.percentage.max.value),
33
- 'min-percentage-monthly': (state) => isPresent(state.discount.percentage.monthly.min.value),
34
- 'max-percentage-monthly': (state) => isPresent(state.discount.percentage.monthly.max.value)
27
+ 'min-value': (state) => Boolean(state.discount.min.fmt),
28
+ 'max-value': (state) => Boolean(state.discount.max.fmt),
29
+ 'min-value-monthly': (state) => Boolean(state.discount.monthly.min.fmt),
30
+ 'max-value-monthly': (state) => Boolean(state.discount.monthly.max.fmt),
31
+ 'min-percentage': (state) => Boolean(state.discount.percentage.min.fmt),
32
+ 'max-percentage': (state) => Boolean(state.discount.percentage.max.fmt),
33
+ 'min-percentage-monthly': (state) => Boolean(state.discount.percentage.monthly.min.fmt),
34
+ 'max-percentage-monthly': (state) => Boolean(state.discount.percentage.monthly.max.fmt)
35
35
  };
36
36
  const STATE_DISCOUNT_RENDER = {
37
37
  'min-value': (state) => state.discount.min.fmt,
@@ -1 +1 @@
1
- {"version":3,"file":"discount.js","sourceRoot":"","sources":["../../../../src/renders/attributes/discount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,CAAU,CAAC;AAIvG,MAAM,qBAAqB,GAAG;IAC5B,WAAW;IACX,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IACxB,wBAAwB;CA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ACjE,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,CAAC;YACX,EAAE,CAAC,WAAW,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;YACxD,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAExB,uBAAuB;IACvB,IAAI,oBAAoB,IAAI,KAAK,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAqB;YAC/C,IAAI,EAAS,oBAAoB;YACjC,OAAO,EAAM,qBAAqB;YAClC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;SAC/D,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,CAAC;YACX,EAAE,CAAC,WAAW,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Compiler } from '@/dsl/compilers';\nimport type { UnifiedContext } from '../context';\nimport { isPresent } from './utilty';\n\nconst OPTION_DISCOUNT_TOKENS = ['value', 'percentage', 'value-monthly', 'percentage-monthly'] as const;\ntype OptionDiscountToken = typeof OPTION_DISCOUNT_TOKENS[number];\ntype OptionCtx = NonNullable<UnifiedContext['option']>;\n\nconst STATE_DISCOUNT_TOKENS = [\n 'min-value',\n 'max-value',\n 'min-percentage',\n 'max-percentage',\n 'min-value-monthly',\n 'max-value-monthly',\n 'min-percentage-monthly',\n 'max-percentage-monthly'\n] as const;\ntype StateDiscountToken = typeof STATE_DISCOUNT_TOKENS[number];\ntype StateCtx = NonNullable<UnifiedContext['state']>;\n\nconst OPTION_DISCOUNT_AVAILABLE = {\n 'value' : (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: false })),\n 'percentage' : (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: true })),\n 'value-monthly' : (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: false, monthly: true })),\n 'percentage-monthly': (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: true, monthly: true }))\n} satisfies Record<OptionDiscountToken, (option: OptionCtx) => boolean>;\n\nconst OPTION_DISCOUNT_RENDER = {\n 'value' : (option: OptionCtx) => String(option.getDiscount({ percentage: false })),\n 'percentage' : (option: OptionCtx) => String(option.getDiscount({ percentage: true })),\n 'value-monthly' : (option: OptionCtx) => String(option.getDiscount({ percentage: false, monthly: true })),\n 'percentage-monthly': (option: OptionCtx) => String(option.getDiscount({ percentage: true, monthly: true }))\n} satisfies Record<OptionDiscountToken, (option: OptionCtx) => string>;\n\nconst STATE_DISCOUNT_AVAILABLE = {\n 'min-value' : (state: StateCtx) => isPresent(state.discount.min.value),\n 'max-value' : (state: StateCtx) => isPresent(state.discount.max.value),\n 'min-value-monthly' : (state: StateCtx) => isPresent(state.discount.monthly.min.value),\n 'max-value-monthly' : (state: StateCtx) => isPresent(state.discount.monthly.max.value),\n 'min-percentage' : (state: StateCtx) => isPresent(state.discount.percentage.min.value),\n 'max-percentage' : (state: StateCtx) => isPresent(state.discount.percentage.max.value),\n 'min-percentage-monthly': (state: StateCtx) => isPresent(state.discount.percentage.monthly.min.value),\n 'max-percentage-monthly': (state: StateCtx) => isPresent(state.discount.percentage.monthly.max.value)\n} satisfies Record<StateDiscountToken, (state: StateCtx) => boolean>;\n\nconst STATE_DISCOUNT_RENDER = {\n 'min-value' : (state: StateCtx) => state.discount.min.fmt,\n 'max-value' : (state: StateCtx) => state.discount.max.fmt,\n 'min-value-monthly' : (state: StateCtx) => state.discount.monthly.min.fmt,\n 'max-value-monthly' : (state: StateCtx) => state.discount.monthly.max.fmt,\n 'min-percentage' : (state: StateCtx) => state.discount.percentage.min.fmt,\n 'max-percentage' : (state: StateCtx) => state.discount.percentage.max.fmt,\n 'min-percentage-monthly': (state: StateCtx) => state.discount.percentage.monthly.min.fmt,\n 'max-percentage-monthly': (state: StateCtx) => state.discount.percentage.monthly.max.fmt\n} satisfies Record<StateDiscountToken, (state: StateCtx) => string>;\n\n// Handles both data-store-discount (option-level) and data-store-context-discount (state-level)\nexport const handleDiscount = (el: HTMLElement, ctx: UnifiedContext) => {\n const { storeDiscount, storeContextDiscount } = el.dataset;\n const option = ctx.option;\n\n // Option-level discount\n if (storeDiscount && option) {\n const chosen = Compiler.enum<OptionDiscountToken>({\n expr : storeDiscount,\n allowed : OPTION_DISCOUNT_TOKENS,\n isAvailable: (token) => OPTION_DISCOUNT_AVAILABLE[token](option)\n });\n\n if (chosen) {\n el.textContent = OPTION_DISCOUNT_RENDER[chosen](option);\n return;\n }\n }\n\n const state = ctx.state;\n\n // State-level discount\n if (storeContextDiscount && state) {\n const chosen = Compiler.enum<StateDiscountToken>({\n expr : storeContextDiscount,\n allowed : STATE_DISCOUNT_TOKENS,\n isAvailable: (token) => STATE_DISCOUNT_AVAILABLE[token](state)\n });\n\n if (chosen) {\n el.textContent = STATE_DISCOUNT_RENDER[chosen](state);\n }\n }\n};\n"]}
1
+ {"version":3,"file":"discount.js","sourceRoot":"","sources":["../../../../src/renders/attributes/discount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,CAAU,CAAC;AAIvG,MAAM,qBAAqB,GAAG;IAC5B,WAAW;IACX,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IACxB,wBAAwB;CAChB,CAAC;AAIX,MAAM,yBAAyB,GAAG;IAChC,OAAO,EAAe,CAAC,MAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EA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AoB,IAAI,KAAK,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAqB;YAC/C,IAAI,EAAS,oBAAoB;YACjC,OAAO,EAAM,qBAAqB;YAClC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;SAC/D,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,CAAC;YACX,EAAE,CAAC,WAAW,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Compiler } from '@/dsl/compilers';\nimport type { UnifiedContext } from '../context';\nimport { isPresent } from './utilty';\n\nconst OPTION_DISCOUNT_TOKENS = ['value', 'percentage', 'value-monthly', 'percentage-monthly'] as const;\ntype OptionDiscountToken = typeof OPTION_DISCOUNT_TOKENS[number];\ntype OptionCtx = NonNullable<UnifiedContext['option']>;\n\nconst STATE_DISCOUNT_TOKENS = [\n 'min-value',\n 'max-value',\n 'min-percentage',\n 'max-percentage',\n 'min-value-monthly',\n 'max-value-monthly',\n 'min-percentage-monthly',\n 'max-percentage-monthly'\n] as const;\ntype StateDiscountToken = typeof STATE_DISCOUNT_TOKENS[number];\ntype StateCtx = NonNullable<UnifiedContext['state']>;\n\nconst OPTION_DISCOUNT_AVAILABLE = {\n 'value' : (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: false })),\n 'percentage' : (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: true })),\n 'value-monthly' : (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: false, monthly: true })),\n 'percentage-monthly': (option: OptionCtx) => isPresent(option.getDiscount({ symbol: false, percentage: true, monthly: true }))\n} satisfies Record<OptionDiscountToken, (option: OptionCtx) => boolean>;\n\nconst OPTION_DISCOUNT_RENDER = {\n 'value' : (option: OptionCtx) => option.getDiscount({ percentage: false }),\n 'percentage' : (option: OptionCtx) => option.getDiscount({ percentage: true }),\n 'value-monthly' : (option: OptionCtx) => option.getDiscount({ percentage: false, monthly: true }),\n 'percentage-monthly': (option: OptionCtx) => option.getDiscount({ percentage: true, monthly: true })\n} satisfies Record<OptionDiscountToken, (option: OptionCtx) => string>;\n\nconst STATE_DISCOUNT_AVAILABLE = {\n 'min-value' : (state: StateCtx) => Boolean(state.discount.min.fmt),\n 'max-value' : (state: StateCtx) => Boolean(state.discount.max.fmt),\n 'min-value-monthly' : (state: StateCtx) => Boolean(state.discount.monthly.min.fmt),\n 'max-value-monthly' : (state: StateCtx) => Boolean(state.discount.monthly.max.fmt),\n 'min-percentage' : (state: StateCtx) => Boolean(state.discount.percentage.min.fmt),\n 'max-percentage' : (state: StateCtx) => Boolean(state.discount.percentage.max.fmt),\n 'min-percentage-monthly': (state: StateCtx) => Boolean(state.discount.percentage.monthly.min.fmt),\n 'max-percentage-monthly': (state: StateCtx) => Boolean(state.discount.percentage.monthly.max.fmt)\n} satisfies Record<StateDiscountToken, (state: StateCtx) => boolean>;\n\nconst STATE_DISCOUNT_RENDER = {\n 'min-value' : (state: StateCtx) => state.discount.min.fmt,\n 'max-value' : (state: StateCtx) => state.discount.max.fmt,\n 'min-value-monthly' : (state: StateCtx) => state.discount.monthly.min.fmt,\n 'max-value-monthly' : (state: StateCtx) => state.discount.monthly.max.fmt,\n 'min-percentage' : (state: StateCtx) => state.discount.percentage.min.fmt,\n 'max-percentage' : (state: StateCtx) => state.discount.percentage.max.fmt,\n 'min-percentage-monthly': (state: StateCtx) => state.discount.percentage.monthly.min.fmt,\n 'max-percentage-monthly': (state: StateCtx) => state.discount.percentage.monthly.max.fmt\n} satisfies Record<StateDiscountToken, (state: StateCtx) => string>;\n\n// Handles both data-store-discount (option-level) and data-store-context-discount (state-level)\nexport const handleDiscount = (el: HTMLElement, ctx: UnifiedContext) => {\n const { storeDiscount, storeContextDiscount } = el.dataset;\n const option = ctx.option;\n\n // Option-level discount\n if (storeDiscount && option) {\n const chosen = Compiler.enum<OptionDiscountToken>({\n expr : storeDiscount,\n allowed : OPTION_DISCOUNT_TOKENS,\n isAvailable: (token) => OPTION_DISCOUNT_AVAILABLE[token](option)\n });\n\n if (chosen) {\n el.textContent = OPTION_DISCOUNT_RENDER[chosen](option);\n return;\n }\n }\n\n const state = ctx.state;\n\n // State-level discount\n if (storeContextDiscount && state) {\n const chosen = Compiler.enum<StateDiscountToken>({\n expr : storeContextDiscount,\n allowed : STATE_DISCOUNT_TOKENS,\n isAvailable: (token) => STATE_DISCOUNT_AVAILABLE[token](state)\n });\n\n if (chosen) {\n el.textContent = STATE_DISCOUNT_RENDER[chosen](state);\n }\n }\n};\n"]}
@@ -24,14 +24,14 @@ const OPTION_PRICE_RENDER = {
24
24
  'discounted-monthly': (option) => option.getDiscountedPrice({ monthly: true })
25
25
  };
26
26
  const STATE_PRICE_AVAILABLE = {
27
- 'min-full': (state) => isPresent(state.price.min.value),
28
- 'max-full': (state) => isPresent(state.price.max.value),
29
- 'min-full-monthly': (state) => isPresent(state.price.monthly.min.value),
30
- 'max-full-monthly': (state) => isPresent(state.price.monthly.max.value),
31
- 'min-discounted': (state) => isPresent(state.discountedPrice.min.value),
32
- 'max-discounted': (state) => isPresent(state.discountedPrice.max.value),
33
- 'min-discounted-monthly': (state) => isPresent(state.discountedPrice.monthly.min.value),
34
- 'max-discounted-monthly': (state) => isPresent(state.discountedPrice.monthly.max.value)
27
+ 'min-full': (state) => Boolean(state.price.min.fmt),
28
+ 'max-full': (state) => Boolean(state.price.max.fmt),
29
+ 'min-full-monthly': (state) => Boolean(state.price.monthly.min.fmt),
30
+ 'max-full-monthly': (state) => Boolean(state.price.monthly.max.fmt),
31
+ 'min-discounted': (state) => Boolean(state.discountedPrice.min.fmt),
32
+ 'max-discounted': (state) => Boolean(state.discountedPrice.max.fmt),
33
+ 'min-discounted-monthly': (state) => Boolean(state.discountedPrice.monthly.min.fmt),
34
+ 'max-discounted-monthly': (state) => Boolean(state.discountedPrice.monthly.max.fmt)
35
35
  };
36
36
  const STATE_PRICE_RENDER = {
37
37
  'min-full': (state) => state.price.min.fmt,
@@ -1 +1 @@
1
- {"version":3,"file":"price.js","sourceRoot":"","sources":["../../../../src/renders/attributes/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAoB,CAAU,CAAC;AAIlG,MAAM,kBAAkB,GAAG;IACzB,UAAU;IACV,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;IAClB,wBAAwB;IACxB,wBAAwB;CAChB,CAAC;AAIX,MAAM,sBAAsB,GAAG;IAC7B,MAAM,EAAgB,CAAC,MAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5F,YAAY,EAAU,CAAC,MAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACtG,cAAc,EAAQ,CAAC,MAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3G,oBAAoB,EAAE,CAAC,MAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;CACnD,CAAC;AAErE,MAAM,mBAAmB,GAAG;IAC1B,MAAM,EAAgB,CAAC,MAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAA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AAS,UAAU;YACvB,OAAO,EAAM,mBAAmB;YAChC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;SAC9D,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,CAAC;YACX,EAAE,CAAC,WAAW,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAExB,oBAAoB;IACpB,IAAI,iBAAiB,IAAI,KAAK,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAkB;YAC5C,IAAI,EAAS,iBAAiB;YAC9B,OAAO,EAAM,kBAAkB;YAC/B,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;SAC5D,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,CAAC;YACX,EAAE,CAAC,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Compiler } from '@/dsl/compilers';\nimport type { UnifiedContext } from '../context';\nimport { isPresent } from './utilty';\n\nconst OPTION_PRICE_TOKENS = ['full', 'discounted', 'full-monthly', 'discounted-monthly'] as const;\ntype OptionPriceToken = typeof OPTION_PRICE_TOKENS[number];\ntype OptionCtx = NonNullable<UnifiedContext['option']>;\n\nconst STATE_PRICE_TOKENS = [\n 'min-full',\n 'max-full',\n 'min-discounted',\n 'max-discounted',\n 'min-full-monthly',\n 'max-full-monthly',\n 'min-discounted-monthly',\n 'max-discounted-monthly'\n] as const;\ntype StatePriceToken = typeof STATE_PRICE_TOKENS[number];\ntype StateCtx = NonNullable<UnifiedContext['state']>;\n\nconst OPTION_PRICE_AVAILABLE = {\n 'full' : (option: OptionCtx) => isPresent(option.getPrice({ currency: false })),\n 'discounted' : (option: OptionCtx) => isPresent(option.getDiscountedPrice({ currency: false })),\n 'full-monthly' : (option: OptionCtx) => isPresent(option.getPrice({ currency: false, monthly: true })),\n 'discounted-monthly': (option: OptionCtx) => isPresent(option.getDiscountedPrice({ currency: false, monthly: true }))\n} satisfies Record<OptionPriceToken, (option: OptionCtx) => boolean>;\n\nconst OPTION_PRICE_RENDER = {\n 'full' : (option: OptionCtx) => option.getPrice(),\n 'discounted' : (option: OptionCtx) => option.getDiscountedPrice(),\n 'full-monthly' : (option: OptionCtx) => option.getPrice({ monthly: true }),\n 'discounted-monthly': (option: OptionCtx) => option.getDiscountedPrice({ monthly: true })\n} satisfies Record<OptionPriceToken, (option: OptionCtx) => string>;\n\nconst STATE_PRICE_AVAILABLE = {\n 'min-full' : (state: StateCtx) => isPresent(state.price.min.value),\n 'max-full' : (state: StateCtx) => isPresent(state.price.max.value),\n 'min-full-monthly' : (state: StateCtx) => isPresent(state.price.monthly.min.value),\n 'max-full-monthly' : (state: StateCtx) => isPresent(state.price.monthly.max.value),\n 'min-discounted' : (state: StateCtx) => isPresent(state.discountedPrice.min.value),\n 'max-discounted' : (state: StateCtx) => isPresent(state.discountedPrice.max.value),\n 'min-discounted-monthly': (state: StateCtx) => isPresent(state.discountedPrice.monthly.min.value),\n 'max-discounted-monthly': (state: StateCtx) => isPresent(state.discountedPrice.monthly.max.value)\n} satisfies Record<StatePriceToken, (state: StateCtx) => boolean>;\n\nconst STATE_PRICE_RENDER = {\n 'min-full' : (state: StateCtx) => state.price.min.fmt,\n 'max-full' : (state: StateCtx) => state.price.max.fmt,\n 'min-full-monthly' : (state: StateCtx) => state.price.monthly.min.fmt,\n 'max-full-monthly' : (state: StateCtx) => state.price.monthly.max.fmt,\n 'min-discounted' : (state: StateCtx) => state.discountedPrice.min.fmt,\n 'max-discounted' : (state: StateCtx) => state.discountedPrice.max.fmt,\n 'min-discounted-monthly': (state: StateCtx) => state.discountedPrice.monthly.min.fmt,\n 'max-discounted-monthly': (state: StateCtx) => state.discountedPrice.monthly.max.fmt\n} satisfies Record<StatePriceToken, (state: StateCtx) => string>;\n\n// Handles both data-store-price (option-level) and data-store-context-price (state-level)\nexport const handlePrice = (el: HTMLElement, ctx: UnifiedContext) => {\n const { storePrice, storeContextPrice } = el.dataset;\n const option = ctx.option;\n\n // Option-level price\n if (storePrice && option) {\n const chosen = Compiler.enum<OptionPriceToken>({\n expr : storePrice,\n allowed : OPTION_PRICE_TOKENS,\n isAvailable: (token) => OPTION_PRICE_AVAILABLE[token](option)\n });\n\n if (chosen) {\n el.textContent = OPTION_PRICE_RENDER[chosen](option);\n return;\n }\n }\n\n const state = ctx.state;\n\n // State-level price\n if (storeContextPrice && state) {\n const chosen = Compiler.enum<StatePriceToken>({\n expr : storeContextPrice,\n allowed : STATE_PRICE_TOKENS,\n isAvailable: (token) => STATE_PRICE_AVAILABLE[token](state)\n });\n\n if (chosen) {\n el.textContent = STATE_PRICE_RENDER[chosen](state);\n }\n }\n};\n"]}
1
+ {"version":3,"file":"price.js","sourceRoot":"","sources":["../../../../src/renders/attributes/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAoB,CAAU,CAAC;AAIlG,MAAM,kBAAkB,GAAG;IACzB,UAAU;IACV,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;IAClB,wBAAwB;IACxB,wBAAwB;CAChB,CAAC;AAIX,MAAM,sBAAsB,GAAG;IAC7B,MAAM,EAAgB,CAAC,MAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5F,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kBAAkB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Compiler } from '@/dsl/compilers';\nimport type { UnifiedContext } from '../context';\nimport { isPresent } from './utilty';\n\nconst OPTION_PRICE_TOKENS = ['full', 'discounted', 'full-monthly', 'discounted-monthly'] as const;\ntype OptionPriceToken = typeof OPTION_PRICE_TOKENS[number];\ntype OptionCtx = NonNullable<UnifiedContext['option']>;\n\nconst STATE_PRICE_TOKENS = [\n 'min-full',\n 'max-full',\n 'min-discounted',\n 'max-discounted',\n 'min-full-monthly',\n 'max-full-monthly',\n 'min-discounted-monthly',\n 'max-discounted-monthly'\n] as const;\ntype StatePriceToken = typeof STATE_PRICE_TOKENS[number];\ntype StateCtx = NonNullable<UnifiedContext['state']>;\n\nconst OPTION_PRICE_AVAILABLE = {\n 'full' : (option: OptionCtx) => isPresent(option.getPrice({ currency: false })),\n 'discounted' : (option: OptionCtx) => isPresent(option.getDiscountedPrice({ currency: false })),\n 'full-monthly' : (option: OptionCtx) => isPresent(option.getPrice({ currency: false, monthly: true })),\n 'discounted-monthly': (option: OptionCtx) => isPresent(option.getDiscountedPrice({ currency: false, monthly: true }))\n} satisfies Record<OptionPriceToken, (option: OptionCtx) => boolean>;\n\nconst OPTION_PRICE_RENDER = {\n 'full' : (option: OptionCtx) => option.getPrice(),\n 'discounted' : (option: OptionCtx) => option.getDiscountedPrice(),\n 'full-monthly' : (option: OptionCtx) => option.getPrice({ monthly: true }),\n 'discounted-monthly': (option: OptionCtx) => option.getDiscountedPrice({ monthly: true })\n} satisfies Record<OptionPriceToken, (option: OptionCtx) => string>;\n\nconst STATE_PRICE_AVAILABLE = {\n 'min-full' : (state: StateCtx) => Boolean(state.price.min.fmt),\n 'max-full' : (state: StateCtx) => Boolean(state.price.max.fmt),\n 'min-full-monthly' : (state: StateCtx) => Boolean(state.price.monthly.min.fmt),\n 'max-full-monthly' : (state: StateCtx) => Boolean(state.price.monthly.max.fmt),\n 'min-discounted' : (state: StateCtx) => Boolean(state.discountedPrice.min.fmt),\n 'max-discounted' : (state: StateCtx) => Boolean(state.discountedPrice.max.fmt),\n 'min-discounted-monthly': (state: StateCtx) => Boolean(state.discountedPrice.monthly.min.fmt),\n 'max-discounted-monthly': (state: StateCtx) => Boolean(state.discountedPrice.monthly.max.fmt)\n} satisfies Record<StatePriceToken, (state: StateCtx) => boolean>;\n\nconst STATE_PRICE_RENDER = {\n 'min-full' : (state: StateCtx) => state.price.min.fmt,\n 'max-full' : (state: StateCtx) => state.price.max.fmt,\n 'min-full-monthly' : (state: StateCtx) => state.price.monthly.min.fmt,\n 'max-full-monthly' : (state: StateCtx) => state.price.monthly.max.fmt,\n 'min-discounted' : (state: StateCtx) => state.discountedPrice.min.fmt,\n 'max-discounted' : (state: StateCtx) => state.discountedPrice.max.fmt,\n 'min-discounted-monthly': (state: StateCtx) => state.discountedPrice.monthly.min.fmt,\n 'max-discounted-monthly': (state: StateCtx) => state.discountedPrice.monthly.max.fmt\n} satisfies Record<StatePriceToken, (state: StateCtx) => string>;\n\n// Handles both data-store-price (option-level) and data-store-context-price (state-level)\nexport const handlePrice = (el: HTMLElement, ctx: UnifiedContext) => {\n const { storePrice, storeContextPrice } = el.dataset;\n const option = ctx.option;\n\n // Option-level price\n if (storePrice && option) {\n const chosen = Compiler.enum<OptionPriceToken>({\n expr : storePrice,\n allowed : OPTION_PRICE_TOKENS,\n isAvailable: (token) => OPTION_PRICE_AVAILABLE[token](option)\n });\n\n if (chosen) {\n el.textContent = OPTION_PRICE_RENDER[chosen](option);\n return;\n }\n }\n\n const state = ctx.state;\n\n // State-level price\n if (storeContextPrice && state) {\n const chosen = Compiler.enum<StatePriceToken>({\n expr : storeContextPrice,\n allowed : STATE_PRICE_TOKENS,\n isAvailable: (token) => STATE_PRICE_AVAILABLE[token](state)\n });\n\n if (chosen) {\n el.textContent = STATE_PRICE_RENDER[chosen](state);\n }\n }\n};\n"]}
@@ -1,3 +1,5 @@
1
- export const isPresent = (value) => value !== null && value !== undefined;
1
+ export const isPresent = (value) => value !== null
2
+ && value !== undefined
3
+ && (typeof value !== 'number' || Number.isFinite(value));
2
4
  export const resolveAnchor = (el) => el instanceof HTMLAnchorElement ? el : el.querySelector('a');
3
5
  //# sourceMappingURL=utilty.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilty.js","sourceRoot":"","sources":["../../../../src/renders/attributes/utilty.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAW,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAE5F,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAe,EAA4B,EAAE,CACzE,EAAE,YAAY,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAoB,GAAG,CAAC,CAAC","sourcesContent":["export const isPresent = (value: unknown): boolean => value !== null && value !== undefined;\n\nexport const resolveAnchor = (el: HTMLElement): HTMLAnchorElement | null =>\n el instanceof HTMLAnchorElement ? el : el.querySelector<HTMLAnchorElement>('a');\n"]}
1
+ {"version":3,"file":"utilty.js","sourceRoot":"","sources":["../../../../src/renders/attributes/utilty.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAW,EAAE,CACnD,KAAK,KAAK,IAAI;OACX,KAAK,KAAK,SAAS;OACnB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAe,EAA4B,EAAE,CACzE,EAAE,YAAY,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAoB,GAAG,CAAC,CAAC","sourcesContent":["export const isPresent = (value: unknown): boolean =>\n value !== null\n && value !== undefined\n && (typeof value !== 'number' || Number.isFinite(value));\n\nexport const resolveAnchor = (el: HTMLElement): HTMLAnchorElement | null =>\n el instanceof HTMLAnchorElement ? el : el.querySelector<HTMLAnchorElement>('a');\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repobit/dex-store-elements",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "HTML elements layer for pricings",
5
5
  "author": "Buga Adrian Alexandru <abuga@bitdefender.com>",
6
6
  "homepage": "https://github.com/bitdefender/dex-core#readme",
@@ -40,20 +40,20 @@
40
40
  "url": "https://github.com/bitdefender/dex-core/issues"
41
41
  },
42
42
  "volta": {
43
- "node": "22.14.0"
43
+ "node": "24.14.0"
44
44
  },
45
45
  "devDependencies": {
46
- "lit": "^3.0.0"
46
+ "lit": "^3.3.2"
47
47
  },
48
48
  "peerDependencies": {
49
- "@repobit/dex-store": "*",
50
- "deepmerge": "^4.0.0",
49
+ "@repobit/dex-store": "^1.3.10",
50
+ "deepmerge": "^4.3.1",
51
51
  "lit": "^3.0.0"
52
52
  },
53
53
  "dependencies": {
54
- "@lit/context": "^1.1.5",
55
- "@lit/task": "^1.0.2",
56
- "eta": "^4.0.1",
54
+ "@lit/context": "^1.1.6",
55
+ "@lit/task": "^1.0.3",
56
+ "eta": "^4.5.1",
57
57
  "nanomorph": "^5.4.3"
58
58
  },
59
59
  "contributes": {
@@ -63,5 +63,5 @@
63
63
  ]
64
64
  }
65
65
  },
66
- "gitHead": "aa11037fa9edc1d2644624233dadbc557adf416f"
66
+ "gitHead": "9792ae8c968ed6411c532e76e18dd4c1e0029371"
67
67
  }