@voyantjs/pricing-ui 0.37.0 → 0.37.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"option-unit-price-rule-combobox.d.ts","sourceRoot":"","sources":["../../src/components/option-unit-price-rule-combobox.tsx"],"names":[],"mappings":"AAkBA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,2BAA2B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAmF5F"}
1
+ {"version":3,"file":"option-unit-price-rule-combobox.d.ts","sourceRoot":"","sources":["../../src/components/option-unit-price-rule-combobox.tsx"],"names":[],"mappings":"AAkBA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAUD,wBAAgB,2BAA2B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAmF5F"}
@@ -4,6 +4,9 @@ import { Combobox, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxI
4
4
  import * as React from "react";
5
5
  import { usePricingUiMessagesOrDefault } from "../i18n/provider.js";
6
6
  const PAGE_SIZE = 100;
7
+ function formatOptionUnitPriceRuleLabel(item) {
8
+ return `${item.optionId} / ${item.unitId}`; // i18n-literal-ok: joins stable identifiers.
9
+ }
7
10
  export function OptionUnitPriceRuleCombobox({ value, onChange, placeholder, disabled }) {
8
11
  const messages = usePricingUiMessagesOrDefault();
9
12
  const [search, setSearch] = React.useState("");
@@ -12,7 +15,7 @@ export function OptionUnitPriceRuleCombobox({ value, onChange, placeholder, disa
12
15
  const items = React.useMemo(() => {
13
16
  const map = new Map();
14
17
  for (const item of listQuery.data?.data ?? []) {
15
- const searchableText = `${item.optionId} / ${item.unitId}`;
18
+ const searchableText = formatOptionUnitPriceRuleLabel(item);
16
19
  if (!search || searchableText.toLowerCase().includes(search.toLowerCase())) {
17
20
  map.set(item.id, item);
18
21
  }
@@ -23,7 +26,7 @@ export function OptionUnitPriceRuleCombobox({ value, onChange, placeholder, disa
23
26
  }, [listQuery.data?.data, search, selectedQuery.data]);
24
27
  const itemMap = React.useMemo(() => new Map(items.map((item) => [item.id, item])), [items]);
25
28
  const selected = value ? itemMap.get(value) : undefined;
26
- const selectedLabel = selected ? `${selected.optionId} / ${selected.unitId}` : "";
29
+ const selectedLabel = selected ? formatOptionUnitPriceRuleLabel(selected) : "";
27
30
  const [inputValue, setInputValue] = React.useState(selectedLabel);
28
31
  React.useEffect(() => {
29
32
  if (selectedLabel)
@@ -31,7 +34,7 @@ export function OptionUnitPriceRuleCombobox({ value, onChange, placeholder, disa
31
34
  }, [selectedLabel]);
32
35
  return (_jsxs(Combobox, { items: items.map((item) => item.id), value: value ?? null, inputValue: inputValue, autoHighlight: true, disabled: disabled, itemToStringValue: (id) => {
33
36
  const item = itemMap.get(id);
34
- return item ? `${item.optionId} / ${item.unitId}` : "";
37
+ return item ? formatOptionUnitPriceRuleLabel(item) : "";
35
38
  }, onInputValueChange: (next) => {
36
39
  setInputValue(next);
37
40
  setSearch(next);
@@ -41,7 +44,7 @@ export function OptionUnitPriceRuleCombobox({ value, onChange, placeholder, disa
41
44
  const id = next ?? null;
42
45
  onChange(id);
43
46
  const item = id ? itemMap.get(id) : undefined;
44
- setInputValue(item ? `${item.optionId} / ${item.unitId}` : "");
47
+ setInputValue(item ? formatOptionUnitPriceRuleLabel(item) : "");
45
48
  }, children: [_jsx(ComboboxInput, { placeholder: placeholder ?? messages.comboboxes.optionUnitPriceRule.placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: listQuery.isPending || selectedQuery.isPending
46
49
  ? messages.common.loading
47
50
  : messages.comboboxes.optionUnitPriceRule.empty }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/pricing-ui",
3
- "version": "0.37.0",
3
+ "version": "0.37.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,13 +46,13 @@
46
46
  "react-dom": "^19.0.0",
47
47
  "react-hook-form": "^7.60.0",
48
48
  "zod": "^4.3.6",
49
- "@voyantjs/pricing-react": "0.37.0",
50
- "@voyantjs/products-react": "0.37.0",
51
- "@voyantjs/ui": "0.37.0",
52
- "@voyantjs/utils": "0.37.0"
49
+ "@voyantjs/pricing-react": "0.37.1",
50
+ "@voyantjs/products-react": "0.37.1",
51
+ "@voyantjs/ui": "0.37.1",
52
+ "@voyantjs/utils": "0.37.1"
53
53
  },
54
54
  "dependencies": {
55
- "@voyantjs/i18n": "0.37.0"
55
+ "@voyantjs/i18n": "0.37.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@tanstack/react-query": "^5.96.2",
@@ -66,12 +66,12 @@
66
66
  "typescript": "^6.0.2",
67
67
  "vitest": "^4.1.2",
68
68
  "zod": "^4.3.6",
69
- "@voyantjs/i18n": "0.37.0",
70
- "@voyantjs/pricing-react": "0.37.0",
71
- "@voyantjs/products-react": "0.37.0",
69
+ "@voyantjs/i18n": "0.37.1",
70
+ "@voyantjs/pricing-react": "0.37.1",
71
+ "@voyantjs/products-react": "0.37.1",
72
72
  "@voyantjs/voyant-typescript-config": "0.1.0",
73
- "@voyantjs/ui": "0.37.0",
74
- "@voyantjs/utils": "0.37.0"
73
+ "@voyantjs/ui": "0.37.1",
74
+ "@voyantjs/utils": "0.37.1"
75
75
  },
76
76
  "files": [
77
77
  "dist",