@stokelp/ui 3.0.0 → 3.0.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.
Files changed (74) hide show
  1. package/README.md +4 -4
  2. package/dist/components/app/mobile-card/MobileCardNotificationBadge.cjs +1 -1
  3. package/dist/components/app/mobile-card/MobileCardNotificationBadge.cjs.map +1 -1
  4. package/dist/components/app/mobile-card/MobileCardNotificationBadge.js +1 -1
  5. package/dist/components/app/mobile-navigation/MobileNavigation.d.ts +2 -1
  6. package/dist/components/app/navigation/AppNavigation.cjs +1 -1
  7. package/dist/components/app/navigation/AppNavigation.cjs.map +1 -1
  8. package/dist/components/app/navigation/AppNavigation.d.ts +2 -2
  9. package/dist/components/app/navigation/AppNavigation.js +1 -1
  10. package/dist/components/avatar/styled.d.ts +4 -5
  11. package/dist/components/button-filter/ButtonFilter.d.ts +3 -3
  12. package/dist/components/chat/Chat.d.ts +4 -4
  13. package/dist/components/chat/ChatDocumentMessage.cjs +1 -1
  14. package/dist/components/chat/ChatDocumentMessage.cjs.map +1 -1
  15. package/dist/components/chat/ChatDocumentMessage.js +2 -2
  16. package/dist/components/chat/ChatMessage.d.ts +3 -3
  17. package/dist/components/chip/Chip.d.ts +1 -1
  18. package/dist/components/combobox/Combobox.cjs +1 -1
  19. package/dist/components/combobox/Combobox.cjs.map +1 -1
  20. package/dist/components/combobox/Combobox.d.ts +4 -3
  21. package/dist/components/combobox/Combobox.js +64 -63
  22. package/dist/components/combobox/Combobox.js.map +1 -1
  23. package/dist/components/flag/styled.d.ts +4 -4
  24. package/dist/components/input/HighlightedInput.d.ts +3 -3
  25. package/dist/components/input/InputAddon.d.ts +3 -3
  26. package/dist/components/pagination/Pagination.d.ts +1 -1
  27. package/dist/components/radio-card-group/RadioCardGroup.d.ts +2 -2
  28. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs +1 -1
  29. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs.map +1 -1
  30. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js +2 -2
  31. package/dist/components/switch-card/SwitchCard.d.ts +2 -2
  32. package/dist/components/tabs/Tabs.d.ts +3 -4
  33. package/dist/components/textarea/Textarea.d.ts +3 -3
  34. package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowDownTrayIcon.cjs +2 -0
  35. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ArrowDownTrayIcon.cjs.map +1 -1
  36. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ArrowDownTrayIcon.js +1 -1
  37. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ArrowDownTrayIcon.js.map +1 -1
  38. package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowLeftCircleIcon.cjs +2 -0
  39. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ArrowLeftCircleIcon.cjs.map +1 -1
  40. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ArrowLeftCircleIcon.js +1 -1
  41. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ArrowLeftCircleIcon.js.map +1 -1
  42. package/dist/node_modules/@heroicons/react/24/outline/esm/ChatBubbleLeftRightIcon.cjs +2 -0
  43. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ChatBubbleLeftRightIcon.cjs.map +1 -1
  44. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ChatBubbleLeftRightIcon.js +1 -1
  45. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/ChatBubbleLeftRightIcon.js.map +1 -1
  46. package/dist/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs +2 -0
  47. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/CheckCircleIcon.cjs.map +1 -1
  48. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/CheckCircleIcon.js +1 -1
  49. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/CheckCircleIcon.js.map +1 -1
  50. package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentTextIcon.cjs +2 -0
  51. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/DocumentTextIcon.cjs.map +1 -1
  52. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/DocumentTextIcon.js +1 -1
  53. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/DocumentTextIcon.js.map +1 -1
  54. package/dist/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs +2 -0
  55. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/XCircleIcon.cjs.map +1 -1
  56. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/XCircleIcon.js +1 -1
  57. package/dist/node_modules/{.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons → @heroicons}/react/24/outline/esm/XCircleIcon.js.map +1 -1
  58. package/dist/node_modules/deepmerge/dist/cjs.cjs +2 -0
  59. package/dist/node_modules/deepmerge/dist/cjs.cjs.map +1 -0
  60. package/dist/node_modules/{.pnpm/deepmerge@4.3.1/node_modules/deepmerge → deepmerge}/dist/cjs.js +2 -2
  61. package/dist/node_modules/deepmerge/dist/cjs.js.map +1 -0
  62. package/dist/theme/recipes/icon-button.cjs +1 -1
  63. package/dist/theme/recipes/icon-button.cjs.map +1 -1
  64. package/dist/theme/recipes/icon-button.js +1 -1
  65. package/package.json +7 -8
  66. package/dist/node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/ArrowDownTrayIcon.cjs +0 -2
  67. package/dist/node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/ArrowLeftCircleIcon.cjs +0 -2
  68. package/dist/node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/ChatBubbleLeftRightIcon.cjs +0 -2
  69. package/dist/node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs +0 -2
  70. package/dist/node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/DocumentTextIcon.cjs +0 -2
  71. package/dist/node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs +0 -2
  72. package/dist/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.cjs +0 -2
  73. package/dist/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.cjs.map +0 -1
  74. package/dist/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js.map +0 -1
@@ -5,17 +5,17 @@ import { Text as n } from "../text/Text.js";
5
5
  import { ConditionalWrapper as r } from "../../shared/ConditionalWrapper.js";
6
6
  import { useUiLabels as i } from "../ui-labels/UiLabelsProvider.js";
7
7
  import { Input as a } from "../input/Input.js";
8
- import { Chip as o, ChipClearTrigger as ee, ChipLabel as te } from "../chip/Chip.js";
9
- import { Combobox as s, Portal as c, createListCollection as l, useComboboxItemContext as u } from "@ark-ui/react";
10
- import { styled as d } from "@stokelp/styled-system/jsx";
11
- import { combobox as f } from "@stokelp/styled-system/recipes";
12
- import { useCallback as ne, useEffect as re, useMemo as p, useState as m } from "react";
8
+ import { Chip as ee, ChipClearTrigger as o, ChipLabel as s } from "../chip/Chip.js";
9
+ import { Combobox as c, Portal as te, createListCollection as ne, useComboboxItemContext as l } from "@ark-ui/react";
10
+ import { styled as u } from "@stokelp/styled-system/jsx";
11
+ import { combobox as d } from "@stokelp/styled-system/recipes";
12
+ import { useCallback as f, useEffect as re, useMemo as p, useState as m } from "react";
13
13
  import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
14
14
  import { css as v } from "@stokelp/styled-system/css";
15
15
  import { FixedSizeList as ie } from "react-window";
16
- import { debounce as ae } from "lodash";
16
+ import { debounce as y } from "@zag-js/utils";
17
17
  // src/components/combobox/Combobox.tsx
18
- var { withProvider: y, withContext: b } = e(f), x = y(d(s.Root), "root", { defaultProps: { loopFocus: !0 } }), S = b(d(s.ClearTrigger), "clearTrigger"), C = b(d(s.Content), "content"), w = b(d(s.Input), "input"), T = b(d(s.Control), "control"), E = b(d(s.Item), "item"), D = b(d(s.ItemText), "itemText"), oe = b(d(s.Positioner), "positioner"), O = b(d(s.Trigger), "trigger"), k = () => /* @__PURE__ */ _("svg", {
18
+ var { withProvider: b, withContext: x } = e(d), ae = b(u(c.Root), "root", { defaultProps: { loopFocus: !0 } }), oe = x(u(c.ClearTrigger), "clearTrigger"), S = x(u(c.Content), "content"), C = x(u(c.Input), "input"), w = x(u(c.Control), "control"), T = x(u(c.Item), "item"), E = x(u(c.ItemText), "itemText"), D = x(u(c.Positioner), "positioner"), O = x(u(c.Trigger), "trigger"), k = () => /* @__PURE__ */ _("svg", {
19
19
  width: "16",
20
20
  height: "17",
21
21
  viewBox: "0 0 16 17",
@@ -56,50 +56,50 @@ var { withProvider: y, withContext: b } = e(f), x = y(d(s.Root), "root", { defau
56
56
  })]
57
57
  });
58
58
  function j({ item: e, isMultiple: t, renderItem: n }) {
59
- let r = u();
60
- return /* @__PURE__ */ _(h, { children: [t ? r.selected ? /* @__PURE__ */ g(A, {}) : /* @__PURE__ */ g(k, {}) : null, n ? n(e) : /* @__PURE__ */ g(D, {
59
+ let r = l();
60
+ return /* @__PURE__ */ _(h, { children: [t ? r.selected ? /* @__PURE__ */ g(A, {}) : /* @__PURE__ */ g(k, {}) : null, n ? n(e) : /* @__PURE__ */ g(E, {
61
61
  truncate: !0,
62
62
  children: e.label
63
63
  })] });
64
64
  }
65
- var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, emptyLabel: v, loadingLabel: y, usePortal: b = !0, withAutoFilter: D = !0, positioning: k, loadItems: A, renderItem: M, renderValue: N, onResetInitialItems: P, isLoading: F, value: I, openDropdownOnFocus: L = !0, clearValueWhenEmpty: R = !0, virtualized: z, rowHeight: B = 34, returnItemsOnEmpty: V, multiple: H = !1, ...U }) => {
66
- let W = i(), [G, K] = m(() => e), [se, q] = m(!1), [ce, le] = m(!1), J = typeof A == "function", Y = p(() => A ? ae(async (e) => {
65
+ var M = ({ items: e = [], initialItems: l, debounceMs: u = 0, placeholder: d, emptyLabel: v, loadingLabel: b, usePortal: x = !0, withAutoFilter: E = !0, positioning: k, loadItems: A, renderItem: M, renderValue: N, onResetInitialItems: P, isLoading: F, value: I, defaultValue: L, openDropdownOnFocus: R = !0, clearValueWhenEmpty: z = !0, virtualized: B, rowHeight: V = 34, returnItemsOnEmpty: H, multiple: U = !1, ...W }) => {
66
+ let G = i(), [K, q] = m(() => e), [se, J] = m(!1), [ce, le] = m(!1), Y = typeof A == "function", X = p(() => A ? y(async (e) => {
67
67
  try {
68
- le(!0), q(!0);
68
+ le(!0), J(!0);
69
69
  let t = await A(e);
70
- K(t);
70
+ q(t);
71
71
  } catch (e) {
72
- console.error(e), K([]);
72
+ console.error(e), q([]);
73
73
  } finally {
74
- q(!1);
74
+ J(!1);
75
75
  }
76
- }, d) : null, [A, d]), X = [...!J && !D ? e : G, ...u ?? []], ue = ne(async (t) => {
77
- u && u.length > 0 && !u.find((e) => e.label === t.inputValue) && P?.();
76
+ }, u) : null, [A, u]), Z = [...!Y && !E ? e : K, ...l ?? []], ue = f(async (t) => {
77
+ l && l.length > 0 && !l.find((e) => e.label === t.inputValue) && P?.();
78
78
  let { inputValue: n } = t;
79
- if (Y) Y(n);
79
+ if (X) X(n);
80
80
  else {
81
- let t = D && n !== "" ? e.filter((e) => e.label.toLowerCase().includes(n.toLowerCase())) : e;
82
- if (t.length === 0 && V) return K(e);
83
- K(t);
81
+ let t = E && n !== "" ? e.filter((e) => e.label.toLowerCase().includes(n.toLowerCase())) : e;
82
+ if (t.length === 0 && H) return q(e);
83
+ q(t);
84
84
  }
85
85
  }, [
86
- Y,
86
+ X,
87
87
  e,
88
- D
88
+ E
89
89
  ]);
90
90
  re(() => {
91
- Y || K(e);
92
- }, [e, Y]);
93
- let de = p(() => l({ items: X }), [X]), Z = F ?? se, Q = y ?? /* @__PURE__ */ g(n, {
91
+ X || q(e);
92
+ }, [e, X]);
93
+ let de = p(() => ne({ items: Z }), [Z]), fe = F ?? se, Q = b ?? /* @__PURE__ */ g(n, {
94
94
  p: "space-8",
95
95
  textAlign: "center",
96
- children: W.loading
96
+ children: G.loading
97
97
  }), $ = v ?? /* @__PURE__ */ g(n, {
98
98
  p: "space-8",
99
99
  textAlign: "center",
100
- children: W.noResults
100
+ children: G.noResults
101
101
  });
102
- return /* @__PURE__ */ _(x, {
102
+ return /* @__PURE__ */ _(ae, {
103
103
  lazyMount: !0,
104
104
  unmountOnExit: !0,
105
105
  collection: de,
@@ -111,34 +111,35 @@ var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, em
111
111
  "data-recipe": "combobox",
112
112
  onInputValueChange: ue,
113
113
  value: I,
114
- ...U,
115
- multiple: H,
116
- children: [H ? /* @__PURE__ */ g(s.Context, { children: (t) => /* @__PURE__ */ _(T, {
114
+ defaultValue: L,
115
+ ...W,
116
+ multiple: U,
117
+ children: [U ? /* @__PURE__ */ g(c.Context, { children: (t) => /* @__PURE__ */ _(w, {
117
118
  "data-multiple": "true",
118
119
  "data-open": t.open || void 0,
119
120
  children: [
120
121
  t.value.map((n) => {
121
122
  let r = e.find((e) => String(e.value) === String(n));
122
- return r ? /* @__PURE__ */ _(o, {
123
+ return r ? /* @__PURE__ */ _(ee, {
123
124
  size: "sm",
124
- children: [N ? N(r) : /* @__PURE__ */ g(te, { children: r.label }), !U.readOnly && !U.disabled && /* @__PURE__ */ g(ee, {
125
+ children: [N ? N(r) : /* @__PURE__ */ g(s, { children: r.label }), !W.readOnly && !W.disabled && /* @__PURE__ */ g(o, {
125
126
  "aria-label": `Retirer ${r.label}`,
126
127
  onClick: () => t.setValue(t.value.filter((e) => String(e) !== String(n)))
127
128
  })]
128
129
  }, n) : null;
129
130
  }),
130
- /* @__PURE__ */ g(w, {
131
+ /* @__PURE__ */ g(C, {
131
132
  asChild: !0,
132
133
  "data-multiple": "true",
133
- placeholder: t.hasSelectedItems ? void 0 : f,
134
+ placeholder: t.hasSelectedItems ? void 0 : d,
134
135
  onFocus: () => {
135
- L && !J && t.setOpen(!0);
136
+ R && !Y && t.setOpen(!0);
136
137
  },
137
138
  children: /* @__PURE__ */ g(a, {})
138
139
  }),
139
140
  /* @__PURE__ */ g(O, {
140
141
  asChild: !0,
141
- hidden: J && (!u || u.length === 0),
142
+ hidden: Y && (!l || l.length === 0),
142
143
  children: /* @__PURE__ */ g("svg", {
143
144
  width: "24",
144
145
  height: "24",
@@ -154,22 +155,22 @@ var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, em
154
155
  })
155
156
  })
156
157
  ]
157
- }) }) : /* @__PURE__ */ _(T, { children: [
158
- /* @__PURE__ */ g(s.Context, { children: (e) => /* @__PURE__ */ g(w, {
158
+ }) }) : /* @__PURE__ */ _(w, { children: [
159
+ /* @__PURE__ */ g(c.Context, { children: (e) => /* @__PURE__ */ g(C, {
159
160
  asChild: !0,
160
- placeholder: f,
161
+ placeholder: d,
161
162
  onInput: (t) => {
162
163
  let n = t.currentTarget.value;
163
- R && n === "" && e.clearValue();
164
+ z && n === "" && e.clearValue();
164
165
  },
165
166
  onFocus: () => {
166
- L && !J && e.setOpen(!0);
167
+ R && !Y && e.setOpen(!0);
167
168
  },
168
169
  children: /* @__PURE__ */ g(a, {})
169
170
  }) }),
170
171
  /* @__PURE__ */ g(O, {
171
172
  asChild: !0,
172
- hidden: J && (!u || u.length === 0),
173
+ hidden: Y && (!l || l.length === 0),
173
174
  children: /* @__PURE__ */ g("svg", {
174
175
  width: "24",
175
176
  height: "24",
@@ -184,8 +185,8 @@ var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, em
184
185
  })
185
186
  })
186
187
  }),
187
- /* @__PURE__ */ g(S, {
188
- disabled: U.readOnly,
188
+ /* @__PURE__ */ g(oe, {
189
+ disabled: W.readOnly,
189
190
  onClick: P,
190
191
  asChild: !0,
191
192
  children: /* @__PURE__ */ g("button", { children: /* @__PURE__ */ g("svg", {
@@ -203,41 +204,41 @@ var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, em
203
204
  }) })
204
205
  })
205
206
  ] }), /* @__PURE__ */ g(r, {
206
- when: b,
207
- wrapper: (e) => /* @__PURE__ */ g(c, { children: e }),
208
- children: /* @__PURE__ */ g(oe, { children: /* @__PURE__ */ g(C, { children: Z ? Q : X.length === 0 ? /* @__PURE__ */ g(h, { children: J ? ce ? $ : Q : $ }) : z ? /* @__PURE__ */ g(h, { children: /* @__PURE__ */ g(ie, {
209
- height: Math.min(B * X.length, 180),
210
- itemCount: X.length,
211
- itemSize: B,
207
+ when: x,
208
+ wrapper: (e) => /* @__PURE__ */ g(te, { children: e }),
209
+ children: /* @__PURE__ */ g(D, { children: /* @__PURE__ */ g(S, { children: fe ? Q : Z.length === 0 ? /* @__PURE__ */ g(h, { children: Y ? ce ? $ : Q : $ }) : B ? /* @__PURE__ */ g(h, { children: /* @__PURE__ */ g(ie, {
210
+ height: Math.min(V * Z.length, 180),
211
+ itemCount: Z.length,
212
+ itemSize: V,
212
213
  width: "100%",
213
214
  children: ({ index: e, style: n }) => /* @__PURE__ */ g(r, {
214
- when: !!X[e].tooltip,
215
+ when: !!Z[e].tooltip,
215
216
  wrapper: (n) => /* @__PURE__ */ g(t, {
216
- label: X[e].tooltip,
217
+ label: Z[e].tooltip,
217
218
  children: n
218
219
  }),
219
- children: /* @__PURE__ */ g(E, {
220
- item: X[e],
220
+ children: /* @__PURE__ */ g(T, {
221
+ item: Z[e],
221
222
  style: n,
222
223
  children: /* @__PURE__ */ g(j, {
223
224
  renderItem: M,
224
- item: X[e],
225
- isMultiple: H
225
+ item: Z[e],
226
+ isMultiple: U
226
227
  })
227
- }, X[e].value)
228
- }, X[e].value)
229
- }) }) : X.map((e) => /* @__PURE__ */ g(r, {
228
+ }, Z[e].value)
229
+ }, Z[e].value)
230
+ }) }) : Z.map((e) => /* @__PURE__ */ g(r, {
230
231
  when: !!e.tooltip,
231
232
  wrapper: (n) => /* @__PURE__ */ g(t, {
232
233
  label: e.tooltip,
233
234
  children: n
234
235
  }),
235
- children: /* @__PURE__ */ g(E, {
236
+ children: /* @__PURE__ */ g(T, {
236
237
  item: e,
237
238
  children: /* @__PURE__ */ g(j, {
238
239
  renderItem: M,
239
240
  item: e,
240
- isMultiple: H
241
+ isMultiple: U
241
242
  })
242
243
  }, e.value)
243
244
  }, e.value)) }) })
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","names":["ArkCombobox","_Fragment","Combobox","UIInput","Tooltip","Tooltip$1","Input$1","Fragment$1","createStyleContext","combobox","Root","withProvider","styled","Combobox","ClearTrigger","withContext","Content","Input","Control","Item","ItemText","Positioner","Trigger","MultipleUncheckedIndicator","css","MultipleCheckedIndicator","CustomInnerItem","context","useComboboxItemContext","isMultiple","renderItem","item","Combobox$1","itemsFromUsers","controlledIsLoading","props","uiLabels","useUiLabels","items","setItems","useState","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","asyncMode","loadItems","debouncedLoadItems","useMemo","debounce","newItems","value","error","debounceMs","allItems","withAutoFilter","initialItems","handleInputChange","useCallback","details","onResetInitialItems","inputValue","returnItemsOnEmpty","collection","createListCollection","effectiveIsLoading","loadingContent","loadingLabel","Text","emptyContent","emptyLabel","positioning","multiple","api","i","v","Chip","renderValue","ChipLabel","ChipClearTrigger","x","placeholder","openDropdownOnFocus","e","clearValueWhenEmpty","ConditionalWrapper","usePortal","Portal","virtualized","FixedSizeList","rowHeight","index"],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from 'lodash'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<ComboboxRootProps<T>, 'collection' | 'value'> & {\n value?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (the no-results label) until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.loading}\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.noResults}\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,IAAM,EAAE,iBAAc,mBAAgBQ,EAAmBC,CAAQ,GAG3DC,IAAOC,EAAaC,EAAOZ,EAAY,IAAS,GAAG,QAAQ,EAC/D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GAEKc,IAAeC,EAAYH,EAAOZ,EAAY,YAAY,GAAG,cAAc,GAC3EgB,IAAUD,EAAYH,EAAOZ,EAAY,OAAO,GAAG,SAAS,GAC5DiB,IAAQF,EAAYH,EAAOZ,EAAY,KAAK,GAAG,OAAO,GACtDkB,IAAUH,EAAYH,EAAOZ,EAAY,OAAO,GAAG,SAAS,GAC5DmB,IAAOJ,EAAYH,EAAOZ,EAAY,IAAI,GAAG,MAAM,GACnDoB,IAAWL,EAAYH,EAAOZ,EAAY,QAAQ,GAAG,UAAU,GAC/DqB,KAAaN,EAAYH,EAAOZ,EAAY,UAAU,GAAG,YAAY,GACrEsB,IAAUP,EAAYH,EAAOZ,EAAY,OAAO,GAAG,SAAS,GAqC5DuB,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,OAAM;CAAlE,UAAA,CACE,kBAAC,QAAD;EAAM,GAAE;EAAM,GAAE;EAAI,OAAM;EAAK,QAAO;EAAK,IAAG;EAAM,MAAK;CAAS,CAAA,GAClE,kBAAC,QAAD;EAAM,GAAE;EAAM,GAAE;EAAI,OAAM;EAAK,QAAO;EAAK,IAAG;EAAM,WAAWC,EAAI,EAAE,QAAQ,WAAW,CAAC;CAAI,CAAA,CAC1F;A,IAGDC,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,OAAM;CAAlE,UAAA,CACE,kBAAC,QAAD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kBAACvF,GAAD;MAAS,OAAOkD,EAASqC,EAAM,CAAC;MAAU;KAAkB,CAAA;KAEjF,UAAA,kBAACxE,GAAD;MAAkC,MAAMmC,EAASqC;MAAe;MAC9D,UAAA,kBAACjE,GAAD;OAA6B;OAAY,MAAM4B,EAASqC;OAAQ,YAAYnB;MAAW,CAAA;KACnF,GAFKlB,EAASqC,EAAM,CAAC,KAErB;IACY,GAPbrC,EAASqC,EAAM,CAAC,KAOH;GAET,CAAA,EACf,CAAA,IAEFrC,EAAS,KAAI,MACX,kBAAC+B,GAAD;IAEE,MAAM,CAAC,CAACtD,EAAK;IACb,UAAS,MAAY,kBAAC3B,GAAD;KAAS,OAAO2B,EAAK;KAAU;IAAkB,CAAA;IAEtE,UAAA,kBAACZ,GAAD;KAA6B;KAC3B,UAAA,kBAACO,GAAD;MAA6B;MAAkB;MAAM,YAAY8C;KAAW,CAAA;IACxE,GAFKzC,EAAK,KAEV;GACY,GAPbA,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
1
+ {"version":3,"file":"Combobox.js","names":["ArkCombobox","_Fragment","Combobox","UIInput","Tooltip","Tooltip$1","Input$1","Fragment$1","createStyleContext","combobox","Root","withProvider","styled","Combobox","ClearTrigger","withContext","Content","Input","Control","Item","ItemText","Positioner","Trigger","MultipleUncheckedIndicator","css","MultipleCheckedIndicator","CustomInnerItem","context","useComboboxItemContext","isMultiple","renderItem","item","Combobox$1","itemsFromUsers","controlledIsLoading","props","uiLabels","useUiLabels","items","setItems","useState","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","asyncMode","loadItems","debouncedLoadItems","useMemo","debounce","newItems","value","error","debounceMs","allItems","withAutoFilter","initialItems","handleInputChange","useCallback","details","onResetInitialItems","inputValue","returnItemsOnEmpty","collection","createListCollection","effectiveIsLoading","loadingContent","loadingLabel","Text","emptyContent","emptyLabel","positioning","multiple","api","i","v","Chip","renderValue","ChipLabel","ChipClearTrigger","x","placeholder","openDropdownOnFocus","e","clearValueWhenEmpty","ConditionalWrapper","usePortal","Portal","virtualized","FixedSizeList","rowHeight","index"],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from '@zag-js/utils'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<\n ComboboxRootProps<T>,\n 'collection' | 'value' | 'defaultValue'\n> & {\n // Item values may be numbers: the chips compare them as strings.\n value?: Array<string | number>\n defaultValue?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & Omit<HTMLStyledProps<'div'>, 'defaultValue'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n defaultValue,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (the no-results label) until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.loading}\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.noResults}\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n defaultValue={defaultValue as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,IAAM,EAAE,iBAAc,mBAAgBQ,EAAmBC,CAAQ,GAG3DC,KAAOC,EAAaC,EAAOZ,EAAY,IAAS,GAAG,QAAQ,EAC/D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GAEKc,KAAeC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C,EAAS,KAAI,MACX,kBAAC+B,GAAD;IAEE,MAAM,CAAC,CAACtD,EAAK;IACb,UAAS,MAAY,kBAAC3B,GAAD;KAAS,OAAO2B,EAAK;KAAU;IAAkB,CAAA;IAEtE,UAAA,kBAACZ,GAAD;KAA6B;KAC3B,UAAA,kBAACO,GAAD;MAA6B;MAAkB;MAAM,YAAY8C;KAAW,CAAA;IACxE,GAFKzC,EAAK,KAEV;GACY,GAPbA,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
@@ -1,6 +1,6 @@
1
- import { ComponentProps, ForwardRefExoticComponent } from 'react';
1
+ import { ComponentProps, ForwardRefExoticComponent, SVGProps, RefAttributes } from 'react';
2
2
  import { StyledComponent } from '@stokelp/styled-system/jsx';
3
- import { Assign, AnyProps } from '@stokelp/styled-system/types';
3
+ import { PolymorphicProps } from '@ark-ui/react';
4
4
  import { FlagVariantProps } from '@stokelp/styled-system/recipes';
5
5
  declare const flags: {
6
6
  af: import('react').JSX.Element;
@@ -210,11 +210,11 @@ declare const flags: {
210
210
  zw: import('react').JSX.Element;
211
211
  };
212
212
  export type FlagCountryCode = keyof typeof flags;
213
- declare const StyledFlag: StyledComponent<any, Assign<AnyProps, FlagVariantProps>>;
213
+ declare const StyledFlag: StyledComponent<ForwardRefExoticComponent< SVGProps<SVGSVGElement> & PolymorphicProps>, FlagVariantProps>;
214
214
  type StyledFlagProps = ComponentProps<typeof StyledFlag>;
215
215
  export type FlagProps = StyledFlagProps & {
216
216
  countryCode: FlagCountryCode;
217
217
  };
218
218
  export declare const FlagCountryCodes: FlagCountryCode[];
219
- export declare const Flag: ForwardRefExoticComponent<any>;
219
+ export declare const Flag: ForwardRefExoticComponent<Omit<FlagProps, "ref"> & RefAttributes<SVGSVGElement>>;
220
220
  export {};
@@ -2,10 +2,10 @@ import { ComponentProps, FC } from 'react';
2
2
  import { ComponentVariants } from '../../utils/slots';
3
3
  import { StyledComponent } from '@stokelp/styled-system/jsx';
4
4
  import { HighlightedInputRecipe, InputVariantProps } from '@stokelp/styled-system/recipes';
5
- export declare const Root: ComponentVariants<StyledComponent<string, {}>, HighlightedInputRecipe>;
5
+ export declare const Root: ComponentVariants<StyledComponent<"div", {}>, HighlightedInputRecipe>;
6
6
  export declare const InputSlot: StyledComponent<"input", InputVariantProps>;
7
- export declare const Renderer: StyledComponent<string, {}>;
8
- export declare const Highlight: StyledComponent<string, {}>;
7
+ export declare const Renderer: StyledComponent<"p", {}>;
8
+ export declare const Highlight: StyledComponent<"span", {}>;
9
9
  export type HighlightedInputRootProps = ComponentProps<typeof Root>;
10
10
  export type HighlightedInputInputProps = ComponentProps<typeof InputSlot>;
11
11
  export type HighlightedInputRendererProps = ComponentProps<typeof Renderer>;
@@ -1,7 +1,7 @@
1
- import { ComponentProps } from 'react';
1
+ import { ComponentProps, ForwardRefExoticComponent, ClassAttributes, HTMLAttributes } from 'react';
2
2
  import { StyledComponent } from '@stokelp/styled-system/jsx';
3
- import { Assign, AnyProps } from '@stokelp/styled-system/types';
3
+ import { PolymorphicProps } from '@ark-ui/react';
4
4
  import { InputAddonVariantProps } from '@stokelp/styled-system/recipes';
5
- export declare const InputAddon: StyledComponent<any, Assign<AnyProps, InputAddonVariantProps>>;
5
+ export declare const InputAddon: StyledComponent<ForwardRefExoticComponent< ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & PolymorphicProps>, InputAddonVariantProps>;
6
6
  export interface InputAddonProps extends ComponentProps<typeof InputAddon> {
7
7
  }
@@ -2,7 +2,7 @@ import { ComponentProps, FC } from 'react';
2
2
  import { ComponentVariants } from '../../utils/slots';
3
3
  import { StyledComponent } from '@stokelp/styled-system/jsx';
4
4
  import { PaginationRecipe } from '@stokelp/styled-system/recipes';
5
- declare const StyledPagination: ComponentVariants<StyledComponent<string, {}>, PaginationRecipe>;
5
+ declare const StyledPagination: ComponentVariants<StyledComponent<"div", {}>, PaginationRecipe>;
6
6
  type StyledPaginationProps = ComponentProps<typeof StyledPagination>;
7
7
  export interface PaginationProps extends Omit<StyledPaginationProps, 'children' | 'defaultValue' | 'onChange'> {
8
8
  total: number;
@@ -4,8 +4,8 @@ import { StyledComponent } from '@stokelp/styled-system/jsx';
4
4
  import { ComponentVariants } from '../../utils/slots';
5
5
  import { RadioCardGroupRecipe } from '@stokelp/styled-system/recipes';
6
6
  export declare const RadioCardGroupItemTitle: StyledComponent<ForwardRefExoticComponent<ArkRadioGroup.ItemTextProps & RefAttributes<HTMLSpanElement>>, {}>;
7
- export declare const RadioCardGroupItemContent: StyledComponent<string, {}>;
8
- export declare const RadioCardGroupItemDescription: StyledComponent<string, {}>;
7
+ export declare const RadioCardGroupItemContent: StyledComponent<"div", {}>;
8
+ export declare const RadioCardGroupItemDescription: StyledComponent<"p", {}>;
9
9
  export declare const RadioCardGroupItemImage: StyledComponent<ForwardRefExoticComponent< ClassAttributes<HTMLImageElement> & ImgHTMLAttributes<HTMLImageElement> & PolymorphicProps>, {}>;
10
10
  export declare const RadioCardGroup: ComponentVariants<StyledComponent<ForwardRefExoticComponent<ArkRadioGroup.RootProps & RefAttributes<HTMLDivElement>>, {}>, RadioCardGroupRecipe>;
11
11
  export declare const RadioCardGroupItem: StyledComponent<ForwardRefExoticComponent<Omit<Omit<ArkRadioGroup.ItemProps & RefAttributes<HTMLLabelElement>, "ref">, "value"> & {
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../text/Text.cjs"),t=require("./labels.cjs"),n=require("../ui-labels/UiLabelsProvider.cjs"),r=require("../icon/Icon.cjs"),i=require("../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs"),a=require("../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs");let o=require("@stokelp/styled-system/jsx"),s=require("react/jsx-runtime");var c=5,l=[`profile`,`location`,`contacts`,`legalBanking`,`sector`,`certificate`];function u(e,t=`fr-FR`){return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e)}function d(e,t,n=`fr-FR`){if(e<60)return`${Math.round(e)} ${t.minutes}`;let r=e/60;if(r<48)return`${Math.round(r)} ${t.hours}`;let i=r/24;return`${new Intl.NumberFormat(n,{maximumFractionDigits:1}).format(i)} ${t.days}`}function f(e){let t=e/5;return t>=.7?`#3B6D11`:t>=.4?`#854F0B`:`#A32D2D`}function p(e){return e>=70?`#639922`:e>=40?`#BA7517`:`#E24B4A`}var m=({rating:c,responseRate:m,labels:h})=>{let g=n.useUiLabels(),_=t.mergeSupplierRatingLabels(g.supplierRating,h),v=m!=null,y=c.responseDelayMinutes!=null,b=c.responseDelayScore==null?null:Math.round(c.responseDelayScore*100),x=Math.round(c.completionScore*100),S=[{key:`responseRate`,value:v?`${Math.round(m)} %`:_.notAvailable,barPercent:v?Math.round(m):null,color:v?p(Math.round(m)):void 0},{key:`responseDelay`,value:y?d(c.responseDelayMinutes,_.units,g.locale):_.notAvailable,barPercent:b,color:b==null?void 0:p(b)},{key:`completion`,value:`${x} %`,barPercent:x,color:p(x)}];return(0,s.jsxs)(o.Box,{bg:`white`,borderRadius:`radius-8`,p:`space-16`,minW:`240px`,maxW:`260px`,css:{"& *":{fontFamily:`inherit`}},children:[(0,s.jsxs)(o.HStack,{justify:`space-between`,alignItems:`baseline`,mb:`space-8`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.md`,fontWeight:`bold`,children:_.title}),c.insufficientData||c.overall==null?(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,color:`grey.400`,children:_.insufficientData}):(0,s.jsxs)(e.Text,{as:`span`,fontSize:`body.lg`,fontWeight:`medium`,style:{color:f(c.overall)},children:[u(c.overall,g.locale),` / `,5,` ★`]})]}),(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-8`,mb:`space-8`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:_.componentsTitle}),S.map(t=>(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-2`,children:[(0,s.jsxs)(o.HStack,{justify:`space-between`,alignItems:`baseline`,gap:`space-8`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:`grey.500`,children:_.components[t.key]}),(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,whiteSpace:`nowrap`,style:{color:t.color},color:t.color?void 0:`grey.300`,children:t.value})]}),(0,s.jsx)(o.Box,{h:`3px`,bg:`grey.100`,borderRadius:`full`,overflow:`hidden`,children:(0,s.jsx)(o.Box,{h:`100%`,borderRadius:`full`,style:{width:t.barPercent==null?`0%`:`${t.barPercent}%`,background:t.color??`transparent`}})})]},t.key))]}),(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-4`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:_.completionTitle}),l.map(t=>{let n=c.completion[t];return(0,s.jsxs)(o.HStack,{alignItems:`center`,gap:`space-8`,children:[(0,s.jsx)(r.Icon,{size:`sm`,color:n?`success.500`:`grey.300`,flexShrink:`0`,children:n?(0,s.jsx)(i.default,{}):(0,s.jsx)(a.default,{})}),(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:n?`grey.500`:`grey.400`,children:_.completion[t]})]},t)})]}),_.footer&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mt:`space-8`,mb:`space-8`}),(0,s.jsx)(e.Text,{as:`span`,fontSize:`9px`,color:`grey.300`,style:{lineHeight:1},children:_.footer})]})]})};exports.DEFAULT_SUPPLIER_RATING_LABELS=t.DEFAULT_SUPPLIER_RATING_LABELS,exports.SUPPLIER_RATING_MAX=c,exports.SupplierRatingBreakdown=m,exports.formatOverall=u,exports.formatResponseDelay=d,exports.getHeadlineColor=f,exports.mergeSupplierRatingLabels=t.mergeSupplierRatingLabels;
1
+ "use client";const e=require("../text/Text.cjs"),t=require("./labels.cjs"),n=require("../ui-labels/UiLabelsProvider.cjs"),r=require("../icon/Icon.cjs"),i=require("../../node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs"),a=require("../../node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs");let o=require("@stokelp/styled-system/jsx"),s=require("react/jsx-runtime");var c=5,l=[`profile`,`location`,`contacts`,`legalBanking`,`sector`,`certificate`];function u(e,t=`fr-FR`){return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e)}function d(e,t,n=`fr-FR`){if(e<60)return`${Math.round(e)} ${t.minutes}`;let r=e/60;if(r<48)return`${Math.round(r)} ${t.hours}`;let i=r/24;return`${new Intl.NumberFormat(n,{maximumFractionDigits:1}).format(i)} ${t.days}`}function f(e){let t=e/5;return t>=.7?`#3B6D11`:t>=.4?`#854F0B`:`#A32D2D`}function p(e){return e>=70?`#639922`:e>=40?`#BA7517`:`#E24B4A`}var m=({rating:c,responseRate:m,labels:h})=>{let g=n.useUiLabels(),_=t.mergeSupplierRatingLabels(g.supplierRating,h),v=m!=null,y=c.responseDelayMinutes!=null,b=c.responseDelayScore==null?null:Math.round(c.responseDelayScore*100),x=Math.round(c.completionScore*100),S=[{key:`responseRate`,value:v?`${Math.round(m)} %`:_.notAvailable,barPercent:v?Math.round(m):null,color:v?p(Math.round(m)):void 0},{key:`responseDelay`,value:y?d(c.responseDelayMinutes,_.units,g.locale):_.notAvailable,barPercent:b,color:b==null?void 0:p(b)},{key:`completion`,value:`${x} %`,barPercent:x,color:p(x)}];return(0,s.jsxs)(o.Box,{bg:`white`,borderRadius:`radius-8`,p:`space-16`,minW:`240px`,maxW:`260px`,css:{"& *":{fontFamily:`inherit`}},children:[(0,s.jsxs)(o.HStack,{justify:`space-between`,alignItems:`baseline`,mb:`space-8`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.md`,fontWeight:`bold`,children:_.title}),c.insufficientData||c.overall==null?(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,color:`grey.400`,children:_.insufficientData}):(0,s.jsxs)(e.Text,{as:`span`,fontSize:`body.lg`,fontWeight:`medium`,style:{color:f(c.overall)},children:[u(c.overall,g.locale),` / `,5,` ★`]})]}),(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-8`,mb:`space-8`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:_.componentsTitle}),S.map(t=>(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-2`,children:[(0,s.jsxs)(o.HStack,{justify:`space-between`,alignItems:`baseline`,gap:`space-8`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:`grey.500`,children:_.components[t.key]}),(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,whiteSpace:`nowrap`,style:{color:t.color},color:t.color?void 0:`grey.300`,children:t.value})]}),(0,s.jsx)(o.Box,{h:`3px`,bg:`grey.100`,borderRadius:`full`,overflow:`hidden`,children:(0,s.jsx)(o.Box,{h:`100%`,borderRadius:`full`,style:{width:t.barPercent==null?`0%`:`${t.barPercent}%`,background:t.color??`transparent`}})})]},t.key))]}),(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-4`,children:[(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:_.completionTitle}),l.map(t=>{let n=c.completion[t];return(0,s.jsxs)(o.HStack,{alignItems:`center`,gap:`space-8`,children:[(0,s.jsx)(r.Icon,{size:`sm`,color:n?`success.500`:`grey.300`,flexShrink:`0`,children:n?(0,s.jsx)(i.default,{}):(0,s.jsx)(a.default,{})}),(0,s.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:n?`grey.500`:`grey.400`,children:_.completion[t]})]},t)})]}),_.footer&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mt:`space-8`,mb:`space-8`}),(0,s.jsx)(e.Text,{as:`span`,fontSize:`9px`,color:`grey.300`,style:{lineHeight:1},children:_.footer})]})]})};exports.DEFAULT_SUPPLIER_RATING_LABELS=t.DEFAULT_SUPPLIER_RATING_LABELS,exports.SUPPLIER_RATING_MAX=c,exports.SupplierRatingBreakdown=m,exports.formatOverall=u,exports.formatResponseDelay=d,exports.getHeadlineColor=f,exports.mergeSupplierRatingLabels=t.mergeSupplierRatingLabels;
2
2
  //# sourceMappingURL=SupplierRatingBreakdown.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SupplierRatingBreakdown.cjs","names":["useUiLabels","mergeSupplierRatingLabels","Box","HStack","Text","VStack","Icon","CheckCircleIcon","XCircleIcon","_Fragment","require_Text","require_labels","require_UiLabelsProvider","require_Icon","require_CheckCircleIcon","require_XCircleIcon","_stokelp_styled_system_jsx","react_jsx_runtime","SUPPLIER_RATING_MAX","COMPLETION_ORDER","formatOverall","locale","overall","formatResponseDelay","minutes","units","hours","days","getHeadlineColor","ratio","getBarColor","ratioPercent","SupplierRatingBreakdown","labelsProp","uiLabels","labels","hasResponseRate","responseRate","hasDelay","rating","delayPercent","completionPercent","rows","row","done","key"],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon, Text } from '~/components'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport {\n mergeSupplierRatingLabels,\n type SupplierRatingCompletionKey,\n type SupplierRatingComponentKey,\n type SupplierRating,\n type SupplierRatingLabels,\n} from './labels'\n\nexport * from './labels'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\n/** Note with one decimal in the reader's number format (\"4,2\" in French, \"4.2\" in English). */\nexport function formatOverall(overall: number, locale = 'fr-FR'): string {\n return new Intl.NumberFormat(locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 }).format(overall)\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units'], locale = 'fr-FR'): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(days)} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const uiLabels = useUiLabels()\n const labels = mergeSupplierRatingLabels(uiLabels.supplierRating, labelsProp)\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay\n ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units, uiLabels.locale)\n : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall, uiLabels.locale)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\n )\n}\n"],"mappings":"A,qfAeA,IAAakB,EAAsB,EAE7BC,EAAkD,CACtD,UACA,WACA,WACA,eACA,SACA,aACF,EAGA,SAAgBC,EAAc,EAAiB,EA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,SAAS,UAAU,WAAW,OAAO,MAAM,WACxD,SAAA+B,EAAO,eACJ,CAAA,EACLhB,EAAiB,IAAI,GAAO,CAC3B,IAAMyB,EAAOL,EAAO,WAAWM,GAC/B,OACE,EAAA5B,EAAA,KAAA,CAACd,EAAAA,OAAD,CAAkB,WAAW,SAAS,IAAI,UAA1C,SAAA,EACE,EAAAc,EAAA,IAAA,CAACX,EAAAA,KAAD,CAAM,KAAK,KAAK,MAAOsC,EAAO,cAAgB,WAAY,WAAW,IAClE,SAAAA,GAAO,EAAA3B,EAAA,IAAA,CAACV,EAAAA,QAAD,CAAkB,CAAA,GAAI,EAAAU,EAAA,IAAA,CAACT,EAAAA,QAAD,CAAc,CAAA,CACxC,CAAA,GACN,EAAAS,EAAA,IAAA,CAACb,EAAAA,KAAD,CAAM,GAAG,OAAO,SAAS,UAAU,MAAOwC,EAAO,WAAa,WAC3D,SAAAT,EAAO,WAAWU,EACf,CAAA,CACA,CAPK,EAAAA,CAOL,CAEZ,CAAC,CACK,C,GAEPV,EAAO,SACN,EAAAlB,EAAA,KAAA,CAAAR,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAQ,EAAA,IAAA,CAACf,EAAAA,IAAD,CAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAW,CAAA,GACtD,EAAAe,EAAA,IAAA,CAACb,EAAAA,KAAD,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,EACpE,SAAA+B,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,C,EAET,E"}
1
+ {"version":3,"file":"SupplierRatingBreakdown.cjs","names":["useUiLabels","mergeSupplierRatingLabels","Box","HStack","Text","VStack","Icon","CheckCircleIcon","XCircleIcon","_Fragment","require_Text","require_labels","require_UiLabelsProvider","require_Icon","require_CheckCircleIcon","require_XCircleIcon","_stokelp_styled_system_jsx","react_jsx_runtime","SUPPLIER_RATING_MAX","COMPLETION_ORDER","formatOverall","locale","overall","formatResponseDelay","minutes","units","hours","days","getHeadlineColor","ratio","getBarColor","ratioPercent","SupplierRatingBreakdown","labelsProp","uiLabels","labels","hasResponseRate","responseRate","hasDelay","rating","delayPercent","completionPercent","rows","row","done","key"],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon, Text } from '~/components'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport {\n mergeSupplierRatingLabels,\n type SupplierRatingCompletionKey,\n type SupplierRatingComponentKey,\n type SupplierRating,\n type SupplierRatingLabels,\n} from './labels'\n\nexport * from './labels'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\n/** Note with one decimal in the reader's number format (\"4,2\" in French, \"4.2\" in English). */\nexport function formatOverall(overall: number, locale = 'fr-FR'): string {\n return new Intl.NumberFormat(locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 }).format(overall)\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units'], locale = 'fr-FR'): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(days)} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const uiLabels = useUiLabels()\n const labels = mergeSupplierRatingLabels(uiLabels.supplierRating, labelsProp)\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay\n ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units, uiLabels.locale)\n : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall, uiLabels.locale)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\n )\n}\n"],"mappings":"A,uYAeA,IAAakB,EAAsB,EAE7BC,EAAkD,CACtD,UACA,WACA,WACA,eACA,SACA,aACF,EAGA,SAAgBC,EAAc,EAAiB,EAAS,QAAiB,CACvE,OAAO,IAAI,KAAK,aAAaC,EAAQ,CAAE,sBAAuB,EAAG,sBAAuB,CAAE,CAAC,CAAC,CAAC,OAAOC,CAAO,CAC7G,CAGA,SAAgBC,EAAoB,EAAiB,EAAsC,EAAS,QAAiB,CACnH,GAAIC,EAAU,GAAI,MAAO,GAAG,KAAK,MAAMA,CAAO,EAAE,GAAGC,EAAM,UACzD,IAAMC,EAAQF,EAAU,GACxB,GAAIE,EAAQ,GAAI,MAAO,GAAG,KAAK,MAAMA,CAAK,EAAE,GAAGD,EAAM,QACrD,IAAME,EAAOD,EAAQ,GACrB,MAAO,GAAG,IAAI,KAAK,aAAaL,EAAQ,CAAE,sBAAuB,CAAE,CAAC,CAAC,CAAC,OAAOM,CAAI,EAAE,GAAGF,EAAM,MAC9F,CAEA,SAAgBG,EAAiB,EAAyB,CACxD,IAAMC,EAAQP,EAAA,EAGd,OAFIO,GAAS,GAAY,UACrBA,GAAS,GAAY,UAClB,SACT,CAEA,SAASC,EAAY,EAA8B,CAGjD,OAFIC,GAAgB,GAAW,UAC3BA,GAAgB,GAAW,UACxB,SACT,CAkBA,IAAaC,GAA2B,CAAE,SAAQ,eAAc,OAAQC,KAA+C,CACrH,IAAMC,EAAWlC,EAAAA,YAAY,EACvBmC,EAASlC,EAAAA,0BAA0BiC,EAAS,eAAgBD,CAAU,EAEtEG,EAAkBC,GAAgB,KAClCC,EAAWC,EAA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M,WAAW,MAAO,CAAE,WAAY,CAAE,EACpE,SAAA+B,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,C,EAET,E"}
@@ -3,8 +3,8 @@ import { Text as e } from "../text/Text.js";
3
3
  import { DEFAULT_SUPPLIER_RATING_LABELS as t, mergeSupplierRatingLabels as n } from "./labels.js";
4
4
  import { useUiLabels as r } from "../ui-labels/UiLabelsProvider.js";
5
5
  import { Icon as i } from "../icon/Icon.js";
6
- import a from "../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.js";
7
- import o from "../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.3.1/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.js";
6
+ import a from "../../node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.js";
7
+ import o from "../../node_modules/@heroicons/react/24/outline/esm/XCircleIcon.js";
8
8
  import { Box as s, HStack as c, VStack as l } from "@stokelp/styled-system/jsx";
9
9
  import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
10
10
  // src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx
@@ -6,8 +6,8 @@ import { StyledComponent } from '@stokelp/styled-system/jsx';
6
6
  export interface SwitchCardProps extends Assign<JsxStyleProps, SwitchRootProps>, SwitchCardVariantProps {
7
7
  }
8
8
  export declare const SwitchCardTitle: StyledComponent<ForwardRefExoticComponent<ArkSwitch.LabelProps & RefAttributes<HTMLSpanElement>>, {}>;
9
- export declare const SwitchCardContent: StyledComponent<string, {}>;
10
- export declare const SwitchCardDescription: StyledComponent<string, {}>;
9
+ export declare const SwitchCardContent: StyledComponent<"div", {}>;
10
+ export declare const SwitchCardDescription: StyledComponent<"p", {}>;
11
11
  export declare const SwitchCardImage: StyledComponent<ForwardRefExoticComponent< ClassAttributes<HTMLImageElement> & ImgHTMLAttributes<HTMLImageElement> & PolymorphicProps>, {}>;
12
12
  export type SwitchCardTitleProps = ComponentProps<typeof SwitchCardTitle>;
13
13
  export type SwitchCardContentProps = ComponentProps<typeof SwitchCardContent>;
@@ -1,13 +1,12 @@
1
- import { Tabs as ArkTab } from '@ark-ui/react';
2
- import { ComponentProps, ForwardRefExoticComponent, RefAttributes } from 'react';
1
+ import { Tabs as ArkTab, PolymorphicProps } from '@ark-ui/react';
2
+ import { ComponentProps, ForwardRefExoticComponent, RefAttributes, ClassAttributes, HTMLAttributes } from 'react';
3
3
  import { ComponentVariants } from '../../utils/slots.tsx';
4
4
  import { StyledComponent } from '@stokelp/styled-system/jsx';
5
5
  import { TabsRecipe, TabsChipVariantProps } from '@stokelp/styled-system/recipes';
6
- import { Assign, AnyProps } from '@stokelp/styled-system/types';
7
6
  export declare const Tabs: ComponentVariants<StyledComponent<ForwardRefExoticComponent<ArkTab.RootProps & RefAttributes<HTMLDivElement>>, {}>, TabsRecipe>;
8
7
  export declare const TabsContent: StyledComponent<ForwardRefExoticComponent<ArkTab.ContentProps & RefAttributes<HTMLDivElement>>, {}>;
9
8
  export declare const TabsTrigger: StyledComponent<ForwardRefExoticComponent<Omit<ArkTab.TriggerProps & RefAttributes<HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>>, {}>;
10
- export declare const TabsChip: StyledComponent<any, Assign<AnyProps, TabsChipVariantProps>>;
9
+ export declare const TabsChip: StyledComponent<ForwardRefExoticComponent< ClassAttributes<HTMLSpanElement> & HTMLAttributes<HTMLSpanElement> & PolymorphicProps>, TabsChipVariantProps>;
11
10
  declare const TabsIndicator: StyledComponent<ForwardRefExoticComponent<ArkTab.IndicatorProps & RefAttributes<HTMLDivElement>>, {}>;
12
11
  export declare const TabsList: StyledComponent<ForwardRefExoticComponent<Omit<ArkTab.ListProps & RefAttributes<HTMLDivElement>, "ref"> & RefAttributes<HTMLDivElement>>, {}>;
13
12
  export interface TabsProps extends ComponentProps<typeof Tabs> {
@@ -1,6 +1,6 @@
1
- import { ComponentProps } from 'react';
1
+ import { ComponentProps, ForwardRefExoticComponent, ClassAttributes, TextareaHTMLAttributes } from 'react';
2
2
  import { StyledComponent } from '@stokelp/styled-system/jsx';
3
- import { Assign, AnyProps } from '@stokelp/styled-system/types';
3
+ import { PolymorphicProps } from '@ark-ui/react';
4
4
  import { TextareaVariantProps } from '@stokelp/styled-system/recipes';
5
- export declare const Textarea: StyledComponent<any, Assign<AnyProps, TextareaVariantProps>>;
5
+ export declare const Textarea: StyledComponent<ForwardRefExoticComponent< ClassAttributes<HTMLTextAreaElement> & TextareaHTMLAttributes<HTMLTextAreaElement> & PolymorphicProps>, TextareaVariantProps>;
6
6
  export type TextareaProps = ComponentProps<typeof Textarea>;
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../../../../../_virtual/_rolldown/runtime.cjs");let t=require("react");t=e.__toESM(t);function n({title:e,titleId:n,...r},i){return t.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:i,"aria-labelledby":n},r),e?t.createElement(`title`,{id:n},e):null,t.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3`}))}var r=t.forwardRef(n);exports.default=r;
2
+ //# sourceMappingURL=ArrowDownTrayIcon.cjs.map