@stokelp/ui 3.0.0 → 4.0.0
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/README.md +4 -4
- package/dist/components/app/mobile-card/MobileCardNotificationBadge.cjs +1 -1
- package/dist/components/app/mobile-card/MobileCardNotificationBadge.cjs.map +1 -1
- package/dist/components/app/mobile-card/MobileCardNotificationBadge.js +1 -1
- package/dist/components/app/mobile-navigation/MobileNavigation.d.ts +2 -1
- package/dist/components/app/navigation/AppNavigation.cjs +1 -1
- package/dist/components/app/navigation/AppNavigation.cjs.map +1 -1
- package/dist/components/app/navigation/AppNavigation.d.ts +2 -2
- package/dist/components/app/navigation/AppNavigation.js +1 -1
- package/dist/components/avatar/styled.d.ts +4 -5
- package/dist/components/button-filter/ButtonFilter.d.ts +3 -3
- package/dist/components/chat/Chat.d.ts +4 -4
- package/dist/components/chat/ChatDocumentMessage.cjs +1 -1
- package/dist/components/chat/ChatDocumentMessage.cjs.map +1 -1
- package/dist/components/chat/ChatDocumentMessage.js +2 -2
- package/dist/components/chat/ChatMessage.d.ts +3 -3
- package/dist/components/chip/Chip.d.ts +1 -1
- package/dist/components/combobox/Combobox.cjs +1 -1
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +4 -3
- package/dist/components/combobox/Combobox.js +118 -106
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/flag/styled.d.ts +4 -4
- package/dist/components/input/HighlightedInput.d.ts +3 -3
- package/dist/components/input/InputAddon.d.ts +3 -3
- package/dist/components/pagination/Pagination.d.ts +1 -1
- package/dist/components/radio-card-group/RadioCardGroup.d.ts +2 -2
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.cjs.map +1 -1
- package/dist/components/select/Select.js +46 -36
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js +2 -2
- package/dist/components/switch-card/SwitchCard.d.ts +2 -2
- package/dist/components/tabs/Tabs.d.ts +3 -4
- package/dist/components/textarea/Textarea.d.ts +3 -3
- package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowDownTrayIcon.cjs +2 -0
- 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
- 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
- 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
- package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowLeftCircleIcon.cjs +2 -0
- 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
- 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
- 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
- package/dist/node_modules/@heroicons/react/24/outline/esm/ChatBubbleLeftRightIcon.cjs +2 -0
- 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
- 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
- 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
- package/dist/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs +2 -0
- 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
- 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
- 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
- package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentTextIcon.cjs +2 -0
- 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
- 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
- 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
- package/dist/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs +2 -0
- 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
- 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
- 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
- package/dist/node_modules/deepmerge/dist/cjs.cjs +2 -0
- package/dist/node_modules/deepmerge/dist/cjs.cjs.map +1 -0
- package/dist/node_modules/{.pnpm/deepmerge@4.3.1/node_modules/deepmerge → deepmerge}/dist/cjs.js +2 -2
- package/dist/node_modules/deepmerge/dist/cjs.js.map +1 -0
- package/dist/theme/recipes/icon-button.cjs +1 -1
- package/dist/theme/recipes/icon-button.cjs.map +1 -1
- package/dist/theme/recipes/icon-button.js +1 -1
- package/package.json +8 -10
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.cjs +0 -2
- package/dist/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.cjs.map +0 -1
- package/dist/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js.map +0 -1
|
@@ -5,147 +5,169 @@ 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
|
|
9
|
-
import { Combobox as
|
|
10
|
-
import { styled as
|
|
11
|
-
import { combobox as
|
|
12
|
-
import { useCallback as
|
|
13
|
-
import { Fragment as
|
|
14
|
-
import { css as
|
|
15
|
-
import {
|
|
16
|
-
import { debounce as
|
|
8
|
+
import { Chip as o, ChipClearTrigger as s, ChipLabel as c } from "../chip/Chip.js";
|
|
9
|
+
import { Combobox as l, Portal as ee, createListCollection as u, useComboboxItemContext as d } from "@ark-ui/react";
|
|
10
|
+
import { styled as f } from "@stokelp/styled-system/jsx";
|
|
11
|
+
import { combobox as p } from "@stokelp/styled-system/recipes";
|
|
12
|
+
import { useCallback as te, useEffect as ne, useMemo as m, useState as h } from "react";
|
|
13
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
14
|
+
import { css as y } from "@stokelp/styled-system/css";
|
|
15
|
+
import { List as re } from "react-window";
|
|
16
|
+
import { debounce as b } from "@zag-js/utils";
|
|
17
17
|
// src/components/combobox/Combobox.tsx
|
|
18
|
-
var { withProvider:
|
|
18
|
+
var { withProvider: x, withContext: S } = e(p), C = x(f(l.Root), "root", { defaultProps: { loopFocus: !0 } }), w = S(f(l.ClearTrigger), "clearTrigger"), T = S(f(l.Content), "content"), E = S(f(l.Input), "input"), D = S(f(l.Control), "control"), O = S(f(l.Item), "item"), k = S(f(l.ItemText), "itemText"), A = S(f(l.Positioner), "positioner"), j = S(f(l.Trigger), "trigger"), M = () => /* @__PURE__ */ v("svg", {
|
|
19
19
|
width: "16",
|
|
20
20
|
height: "17",
|
|
21
21
|
viewBox: "0 0 16 17",
|
|
22
22
|
fill: "none",
|
|
23
23
|
xmlns: "http://www.w3.org/2000/svg",
|
|
24
|
-
children: [/* @__PURE__ */
|
|
24
|
+
children: [/* @__PURE__ */ _("rect", {
|
|
25
25
|
x: "0.5",
|
|
26
26
|
y: "1",
|
|
27
27
|
width: "15",
|
|
28
28
|
height: "15",
|
|
29
29
|
rx: "3.5",
|
|
30
30
|
fill: "white"
|
|
31
|
-
}), /* @__PURE__ */
|
|
31
|
+
}), /* @__PURE__ */ _("rect", {
|
|
32
32
|
x: "0.5",
|
|
33
33
|
y: "1",
|
|
34
34
|
width: "15",
|
|
35
35
|
height: "15",
|
|
36
36
|
rx: "3.5",
|
|
37
|
-
className:
|
|
37
|
+
className: y({ stroke: "grey.100" })
|
|
38
38
|
})]
|
|
39
|
-
}),
|
|
39
|
+
}), N = () => /* @__PURE__ */ v("svg", {
|
|
40
40
|
width: "16",
|
|
41
41
|
height: "17",
|
|
42
42
|
viewBox: "0 0 16 17",
|
|
43
43
|
fill: "none",
|
|
44
44
|
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
-
children: [/* @__PURE__ */
|
|
45
|
+
children: [/* @__PURE__ */ _("rect", {
|
|
46
46
|
y: "0.5",
|
|
47
47
|
width: "16",
|
|
48
48
|
height: "16",
|
|
49
49
|
rx: "4",
|
|
50
|
-
className:
|
|
51
|
-
}), /* @__PURE__ */
|
|
50
|
+
className: y({ fill: "primary.500" })
|
|
51
|
+
}), /* @__PURE__ */ _("path", {
|
|
52
52
|
fillRule: "evenodd",
|
|
53
53
|
clipRule: "evenodd",
|
|
54
54
|
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",
|
|
55
55
|
fill: "white"
|
|
56
56
|
})]
|
|
57
57
|
});
|
|
58
|
-
function
|
|
59
|
-
let r =
|
|
60
|
-
return /* @__PURE__ */
|
|
58
|
+
function P({ item: e, isMultiple: t, renderItem: n }) {
|
|
59
|
+
let r = d();
|
|
60
|
+
return /* @__PURE__ */ v(g, { children: [t ? r.selected ? /* @__PURE__ */ _(N, {}) : /* @__PURE__ */ _(M, {}) : null, n ? n(e) : /* @__PURE__ */ _(k, {
|
|
61
61
|
truncate: !0,
|
|
62
62
|
children: e.label
|
|
63
63
|
})] });
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
let
|
|
65
|
+
function F({ index: e, style: n, ariaAttributes: i, items: a, isMultiple: o, renderItem: s }) {
|
|
66
|
+
let c = a[e];
|
|
67
|
+
return /* @__PURE__ */ _(r, {
|
|
68
|
+
when: !!c.tooltip,
|
|
69
|
+
wrapper: (e) => /* @__PURE__ */ _(t, {
|
|
70
|
+
label: c.tooltip,
|
|
71
|
+
children: e
|
|
72
|
+
}),
|
|
73
|
+
children: /* @__PURE__ */ _(O, {
|
|
74
|
+
item: c,
|
|
75
|
+
style: n,
|
|
76
|
+
"aria-posinset": i["aria-posinset"],
|
|
77
|
+
"aria-setsize": i["aria-setsize"],
|
|
78
|
+
children: /* @__PURE__ */ _(P, {
|
|
79
|
+
renderItem: s,
|
|
80
|
+
item: c,
|
|
81
|
+
isMultiple: o
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
var I = ({ items: e = [], initialItems: d, debounceMs: f = 0, placeholder: p, emptyLabel: y, loadingLabel: x, usePortal: S = !0, withAutoFilter: k = !0, positioning: M, loadItems: N, renderItem: I, renderValue: L, onResetInitialItems: R, isLoading: ie, value: ae, defaultValue: oe, openDropdownOnFocus: z = !0, clearValueWhenEmpty: B = !0, virtualized: V, rowHeight: H = 34, returnItemsOnEmpty: U, multiple: W = !1, ...G }) => {
|
|
87
|
+
let K = i(), [se, q] = h(() => e), [ce, J] = h(!1), [le, ue] = h(!1), Y = typeof N == "function", X = m(() => N ? b(async (e) => {
|
|
67
88
|
try {
|
|
68
|
-
|
|
69
|
-
let t = await
|
|
70
|
-
|
|
89
|
+
ue(!0), J(!0);
|
|
90
|
+
let t = await N(e);
|
|
91
|
+
q(t);
|
|
71
92
|
} catch (e) {
|
|
72
|
-
console.error(e),
|
|
93
|
+
console.error(e), q([]);
|
|
73
94
|
} finally {
|
|
74
|
-
|
|
95
|
+
J(!1);
|
|
75
96
|
}
|
|
76
|
-
},
|
|
77
|
-
|
|
97
|
+
}, f) : null, [N, f]), Z = [...!Y && !k ? e : se, ...d ?? []], de = te(async (t) => {
|
|
98
|
+
d && d.length > 0 && !d.find((e) => e.label === t.inputValue) && R?.();
|
|
78
99
|
let { inputValue: n } = t;
|
|
79
|
-
if (
|
|
100
|
+
if (X) X(n);
|
|
80
101
|
else {
|
|
81
|
-
let t =
|
|
82
|
-
if (t.length === 0 &&
|
|
83
|
-
|
|
102
|
+
let t = k && n !== "" ? e.filter((e) => e.label.toLowerCase().includes(n.toLowerCase())) : e;
|
|
103
|
+
if (t.length === 0 && U) return q(e);
|
|
104
|
+
q(t);
|
|
84
105
|
}
|
|
85
106
|
}, [
|
|
86
|
-
|
|
107
|
+
X,
|
|
87
108
|
e,
|
|
88
|
-
|
|
109
|
+
k
|
|
89
110
|
]);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, [e,
|
|
93
|
-
let
|
|
111
|
+
ne(() => {
|
|
112
|
+
X || q(e);
|
|
113
|
+
}, [e, X]);
|
|
114
|
+
let fe = m(() => u({ items: Z }), [Z]), pe = ie ?? ce, Q = x ?? /* @__PURE__ */ _(n, {
|
|
94
115
|
p: "space-8",
|
|
95
116
|
textAlign: "center",
|
|
96
|
-
children:
|
|
97
|
-
}), $ =
|
|
117
|
+
children: K.loading
|
|
118
|
+
}), $ = y ?? /* @__PURE__ */ _(n, {
|
|
98
119
|
p: "space-8",
|
|
99
120
|
textAlign: "center",
|
|
100
|
-
children:
|
|
121
|
+
children: K.noResults
|
|
101
122
|
});
|
|
102
|
-
return /* @__PURE__ */
|
|
123
|
+
return /* @__PURE__ */ v(C, {
|
|
103
124
|
lazyMount: !0,
|
|
104
125
|
unmountOnExit: !0,
|
|
105
|
-
collection:
|
|
126
|
+
collection: fe,
|
|
106
127
|
positioning: {
|
|
107
128
|
sameWidth: !0,
|
|
108
129
|
gutter: 0,
|
|
109
|
-
...
|
|
130
|
+
...M
|
|
110
131
|
},
|
|
111
132
|
"data-recipe": "combobox",
|
|
112
|
-
onInputValueChange:
|
|
113
|
-
value:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
133
|
+
onInputValueChange: de,
|
|
134
|
+
value: ae,
|
|
135
|
+
defaultValue: oe,
|
|
136
|
+
...G,
|
|
137
|
+
multiple: W,
|
|
138
|
+
children: [W ? /* @__PURE__ */ _(l.Context, { children: (t) => /* @__PURE__ */ v(D, {
|
|
117
139
|
"data-multiple": "true",
|
|
118
140
|
"data-open": t.open || void 0,
|
|
119
141
|
children: [
|
|
120
142
|
t.value.map((n) => {
|
|
121
143
|
let r = e.find((e) => String(e.value) === String(n));
|
|
122
|
-
return r ? /* @__PURE__ */
|
|
144
|
+
return r ? /* @__PURE__ */ v(o, {
|
|
123
145
|
size: "sm",
|
|
124
|
-
children: [
|
|
146
|
+
children: [L ? L(r) : /* @__PURE__ */ _(c, { children: r.label }), !G.readOnly && !G.disabled && /* @__PURE__ */ _(s, {
|
|
125
147
|
"aria-label": `Retirer ${r.label}`,
|
|
126
148
|
onClick: () => t.setValue(t.value.filter((e) => String(e) !== String(n)))
|
|
127
149
|
})]
|
|
128
150
|
}, n) : null;
|
|
129
151
|
}),
|
|
130
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ _(E, {
|
|
131
153
|
asChild: !0,
|
|
132
154
|
"data-multiple": "true",
|
|
133
|
-
placeholder: t.hasSelectedItems ? void 0 :
|
|
155
|
+
placeholder: t.hasSelectedItems ? void 0 : p,
|
|
134
156
|
onFocus: () => {
|
|
135
|
-
|
|
157
|
+
z && !Y && t.setOpen(!0);
|
|
136
158
|
},
|
|
137
|
-
children: /* @__PURE__ */
|
|
159
|
+
children: /* @__PURE__ */ _(a, {})
|
|
138
160
|
}),
|
|
139
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ _(j, {
|
|
140
162
|
asChild: !0,
|
|
141
|
-
hidden:
|
|
142
|
-
children: /* @__PURE__ */
|
|
163
|
+
hidden: Y && (!d || d.length === 0),
|
|
164
|
+
children: /* @__PURE__ */ _("svg", {
|
|
143
165
|
width: "24",
|
|
144
166
|
height: "24",
|
|
145
167
|
viewBox: "0 0 24 24",
|
|
146
168
|
fill: "none",
|
|
147
169
|
xmlns: "http://www.w3.org/2000/svg",
|
|
148
|
-
children: /* @__PURE__ */
|
|
170
|
+
children: /* @__PURE__ */ _("path", {
|
|
149
171
|
fillRule: "evenodd",
|
|
150
172
|
clipRule: "evenodd",
|
|
151
173
|
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",
|
|
@@ -154,29 +176,29 @@ var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, em
|
|
|
154
176
|
})
|
|
155
177
|
})
|
|
156
178
|
]
|
|
157
|
-
}) }) : /* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */
|
|
179
|
+
}) }) : /* @__PURE__ */ v(D, { children: [
|
|
180
|
+
/* @__PURE__ */ _(l.Context, { children: (e) => /* @__PURE__ */ _(E, {
|
|
159
181
|
asChild: !0,
|
|
160
|
-
placeholder:
|
|
182
|
+
placeholder: p,
|
|
161
183
|
onInput: (t) => {
|
|
162
184
|
let n = t.currentTarget.value;
|
|
163
|
-
|
|
185
|
+
B && n === "" && e.clearValue();
|
|
164
186
|
},
|
|
165
187
|
onFocus: () => {
|
|
166
|
-
|
|
188
|
+
z && !Y && e.setOpen(!0);
|
|
167
189
|
},
|
|
168
|
-
children: /* @__PURE__ */
|
|
190
|
+
children: /* @__PURE__ */ _(a, {})
|
|
169
191
|
}) }),
|
|
170
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ _(j, {
|
|
171
193
|
asChild: !0,
|
|
172
|
-
hidden:
|
|
173
|
-
children: /* @__PURE__ */
|
|
194
|
+
hidden: Y && (!d || d.length === 0),
|
|
195
|
+
children: /* @__PURE__ */ _("svg", {
|
|
174
196
|
width: "24",
|
|
175
197
|
height: "24",
|
|
176
198
|
viewBox: "0 0 24 24",
|
|
177
199
|
fill: "none",
|
|
178
200
|
xmlns: "http://www.w3.org/2000/svg",
|
|
179
|
-
children: /* @__PURE__ */
|
|
201
|
+
children: /* @__PURE__ */ _("path", {
|
|
180
202
|
fillRule: "evenodd",
|
|
181
203
|
clipRule: "evenodd",
|
|
182
204
|
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",
|
|
@@ -184,17 +206,17 @@ var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, em
|
|
|
184
206
|
})
|
|
185
207
|
})
|
|
186
208
|
}),
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
disabled:
|
|
189
|
-
onClick:
|
|
209
|
+
/* @__PURE__ */ _(w, {
|
|
210
|
+
disabled: G.readOnly,
|
|
211
|
+
onClick: R,
|
|
190
212
|
asChild: !0,
|
|
191
|
-
children: /* @__PURE__ */
|
|
213
|
+
children: /* @__PURE__ */ _("button", { children: /* @__PURE__ */ _("svg", {
|
|
192
214
|
width: "20",
|
|
193
215
|
height: "20",
|
|
194
216
|
viewBox: "0 0 20 20",
|
|
195
217
|
fill: "none",
|
|
196
218
|
xmlns: "http://www.w3.org/2000/svg",
|
|
197
|
-
children: /* @__PURE__ */
|
|
219
|
+
children: /* @__PURE__ */ _("path", {
|
|
198
220
|
fillRule: "evenodd",
|
|
199
221
|
clipRule: "evenodd",
|
|
200
222
|
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",
|
|
@@ -202,48 +224,38 @@ var M = ({ items: e = [], initialItems: u, debounceMs: d = 0, placeholder: f, em
|
|
|
202
224
|
})
|
|
203
225
|
}) })
|
|
204
226
|
})
|
|
205
|
-
] }), /* @__PURE__ */
|
|
206
|
-
when:
|
|
207
|
-
wrapper: (e) => /* @__PURE__ */
|
|
208
|
-
children: /* @__PURE__ */
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
item: X[e],
|
|
221
|
-
style: n,
|
|
222
|
-
children: /* @__PURE__ */ g(j, {
|
|
223
|
-
renderItem: M,
|
|
224
|
-
item: X[e],
|
|
225
|
-
isMultiple: H
|
|
226
|
-
})
|
|
227
|
-
}, X[e].value)
|
|
228
|
-
}, X[e].value)
|
|
229
|
-
}) }) : X.map((e) => /* @__PURE__ */ g(r, {
|
|
227
|
+
] }), /* @__PURE__ */ _(r, {
|
|
228
|
+
when: S,
|
|
229
|
+
wrapper: (e) => /* @__PURE__ */ _(ee, { children: e }),
|
|
230
|
+
children: /* @__PURE__ */ _(A, { children: /* @__PURE__ */ _(T, { children: pe ? Q : Z.length === 0 ? /* @__PURE__ */ _(g, { children: Y ? le ? $ : Q : $ }) : V ? /* @__PURE__ */ _(re, {
|
|
231
|
+
role: "presentation",
|
|
232
|
+
rowComponent: F,
|
|
233
|
+
rowProps: {
|
|
234
|
+
items: Z,
|
|
235
|
+
isMultiple: W,
|
|
236
|
+
renderItem: I
|
|
237
|
+
},
|
|
238
|
+
rowCount: Z.length,
|
|
239
|
+
rowHeight: H,
|
|
240
|
+
style: { height: Math.min(H * Z.length, 180) }
|
|
241
|
+
}) : Z.map((e) => /* @__PURE__ */ _(r, {
|
|
230
242
|
when: !!e.tooltip,
|
|
231
|
-
wrapper: (n) => /* @__PURE__ */
|
|
243
|
+
wrapper: (n) => /* @__PURE__ */ _(t, {
|
|
232
244
|
label: e.tooltip,
|
|
233
245
|
children: n
|
|
234
246
|
}),
|
|
235
|
-
children: /* @__PURE__ */
|
|
247
|
+
children: /* @__PURE__ */ _(O, {
|
|
236
248
|
item: e,
|
|
237
|
-
children: /* @__PURE__ */
|
|
238
|
-
renderItem:
|
|
249
|
+
children: /* @__PURE__ */ _(P, {
|
|
250
|
+
renderItem: I,
|
|
239
251
|
item: e,
|
|
240
|
-
isMultiple:
|
|
252
|
+
isMultiple: W
|
|
241
253
|
})
|
|
242
254
|
}, e.value)
|
|
243
255
|
}, e.value)) }) })
|
|
244
256
|
})]
|
|
245
257
|
});
|
|
246
258
|
};
|
|
247
|
-
export {
|
|
259
|
+
export { I as Combobox };
|
|
248
260
|
|
|
249
261
|
//# sourceMappingURL=Combobox.js.map
|
|
@@ -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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vF,GAAA,EAAA,UACE,kBAACwF,IAAD;IACE,QAAQ,KAAK,IAAIC,IAAYpC,EAAS,QAAQ,GAAG;IACjD,WAAWA,EAAS;IACpB,UAAUoC;IACV,OAAM;IAEJ,WAAA,EAAE,UAAO,eACT,kBAACL,GAAD;KAEE,MAAM,CAAC,CAAC/B,EAASqC,EAAM,CAAC;KACxB,UAAS,MAAY,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","Tooltip","Combobox","UIInput","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","VirtualRow","items","index","ConditionalWrapper","ariaAttributes","Combobox$1","itemsFromUsers","controlledIsLoading","props","uiLabels","useUiLabels","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","usePortal","Portal","virtualized","List","rowHeight"],"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 { List, type RowComponentProps } 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\ninterface VirtualRowProps<Item extends ComboboxItem> {\n items: Item[]\n isMultiple: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\n// Declared at module level: react-window memoizes the row component by identity, so a\n// component created during render would remount every visible row on each render.\nfunction VirtualRow<Item extends ComboboxItem>({\n index,\n style,\n ariaAttributes,\n items,\n isMultiple,\n renderItem,\n}: RowComponentProps<VirtualRowProps<Item>>) {\n const item = items[index]\n\n return (\n <ConditionalWrapper when={!!item.tooltip} wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}>\n {/* Only the position attributes: the option keeps its role from Ark, not react-window's listitem. */}\n <Item\n item={item}\n style={style}\n aria-posinset={ariaAttributes['aria-posinset']}\n aria-setsize={ariaAttributes['aria-setsize']}\n >\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={isMultiple} />\n </Item>\n </ConditionalWrapper>\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 // role=\"presentation\" overrides the list's own role=\"list\": the options must stay\n // owned by the listbox.\n <List\n role=\"presentation\"\n rowComponent={VirtualRow<T>}\n rowProps={{ items: allItems, isMultiple: multiple, renderItem }}\n rowCount={allItems.length}\n rowHeight={rowHeight}\n style={{ height: Math.min(rowHeight * allItems.length, 180) }}\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,IAAaN,EAAYH,EAAOZ,EAAY,UAAU,GAAG,YAAY,GACrEsB,IAAUP,EAAYH,EAAOZ,EAAY,OAAO,GAAG,SAAS,GA0C5DuB,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,OAAM;CAAlE,UAAA,CACE,kBAAC,QAAD;EAAM,GAAE;E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,kBAAC,UAAD,EAAA,UACE,kBAAC,OAAD;KAAK,OAAM;KAAK,QAAO;KAAK,SAAQ;KAAY,MAAK;KAAO,OAAM;KAChE,UAAA,kBAAC,QAAD;MACE,UAAS;MACT,UAAS;MACT,GAAE;MACF,MAAK;KACN,CAAA;IACE,CAAA,EACC,CAAA;GACI,CAAA;EACP,EAAA,CAAA,GAEX,kBAAC7B,GAAD;GAAoB,MAAMsD;GAAW,UAAS,MAAY,kBAACC,IAAD,EAAS,YAAiB,CAAA;GAClF,UAAA,kBAACrE,GAAD,EAAA,UACE,kBAACL,GAAD,EAAA,UACGqD,KACCC,IACEZ,EAAS,WAAW,IACtB,kBAAAzD,GAAA,EAAA,UAAGgD,IAAaF,KAAsB0B,IAAeH,IAAkBG,EAAe,CAAA,IACpFkB,IAGF,kBAACC,IAAD;IACE,MAAK;IACL,cAAc5D;IACd,UAAU;KAAE,OAAO0B;KAAU,YAAYkB;KAAU;IAAW;IAC9D,UAAUlB,EAAS;IACR;IACX,OAAO,EAAE,QAAQ,KAAK,IAAImC,IAAYnC,EAAS,QAAQ,GAAG,EAAE;GAC7D,CAAA,IAEDA,EAAS,KAAI,MACX,kBAACvB,GAAD;IAEE,MAAM,CAAC,CAACJ,EAAK;IACb,UAAS,MAAY,kBAAC7B,GAAD;KAAS,OAAO6B,EAAK;KAAU;IAAkB,CAAA;IAEtE,UAAA,kBAACZ,GAAD;KAA6B;KAC3B,UAAA,kBAACO,GAAD;MAA6B;MAAkB;MAAM,YAAYkD;KAAW,CAAA;IACxE,GAFK7C,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 {
|
|
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<
|
|
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<
|
|
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<
|
|
5
|
+
export declare const Root: ComponentVariants<StyledComponent<"div", {}>, HighlightedInputRecipe>;
|
|
6
6
|
export declare const InputSlot: StyledComponent<"input", InputVariantProps>;
|
|
7
|
-
export declare const Renderer: StyledComponent<
|
|
8
|
-
export declare const Highlight: StyledComponent<
|
|
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 {
|
|
3
|
+
import { PolymorphicProps } from '@ark-ui/react';
|
|
4
4
|
import { InputAddonVariantProps } from '@stokelp/styled-system/recipes';
|
|
5
|
-
export declare const InputAddon: StyledComponent<
|
|
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<
|
|
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<
|
|
8
|
-
export declare const RadioCardGroupItemDescription: StyledComponent<
|
|
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("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../ui-labels/UiLabelsProvider.cjs");let a=require("@ark-ui/react"),o=require("@stokelp/styled-system/jsx"),s=require("@stokelp/styled-system/recipes"),c=require("react"),l=require("react/jsx-runtime"),u=require("@stokelp/styled-system/css"),d=require("react-window");var{withProvider:f,withContext:p}=e.createStyleContext(s.select),m=f((0,o.styled)(a.Select.Root),`root`,{defaultProps:{loopFocus:!0}}),h=p((0,o.styled)(a.Select.ClearTrigger),`clearTrigger`),g=p((0,o.styled)(a.Select.Content),`content`),_=p((0,o.styled)(a.Select.Control),`control`),v=p((0,o.styled)(a.Select.Indicator),`indicator`),y=p((0,o.styled)(a.Select.Item),`item`),b=p((0,o.styled)(a.Select.ItemGroup),`itemGroup`),x=p((0,o.styled)(a.Select.ItemGroupLabel),`itemGroupLabel`),S=p((0,o.styled)(a.Select.ItemText),`itemText`),C=p((0,o.styled)(a.Select.Positioner),`positioner`),w=p((0,o.styled)(a.Select.Trigger),`trigger`),T=p((0,o.styled)(a.Select.ValueText),`valueText`),E=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,u.css)({stroke:`grey.100`})})]}),D=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,u.css)({fill:`primary.500`})}),(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,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`,fill:`white`})]});function O({placeholder:e,allSelectedLabel:t}){let n=(0,a.useSelectContext)(),r=n.collection.items,i=n.selectedItems;return n.multiple&&i.filter(e=>!e.disabled).length>=r.filter(e=>!e.disabled).length&&t?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:t}):(0,l.jsx)(T,{truncate:!0,placeholder:e})}function k({renderTrigger:e,placeholder:t,allSelectedLabel:n}){let r=(0,a.useSelectContext)(),i=r.value&&r.value.length>0?r.collection.findMany(r.value):[];if(i.length===0)return(0,l.jsx)(T,{className:`custom`,truncate:!0,placeholder:t});let o=r.selectedItems;return r.multiple&&o.filter(e=>!e.disabled).length>=r.collection.items.filter(e=>!e.disabled).length&&n?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:n}):(0,l.jsx)(T,{className:`custom`,placeholder:t,children:i.map(t=>(0,l.jsx)(`span`,{children:e(t)},t.value))})}function A({item:e,isMultiple:t,renderItem:n}){let r=(0,a.useSelectItemContext)();return(0,l.jsxs)(l.Fragment,{children:[t?r.selected?(0,l.jsx)(D,{}):(0,l.jsx)(E,{}):null,n?n(e):(0,l.jsx)(S,{truncate:!0,children:e.label})]})}function j(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.label===n.groupLabel?e.items.push(n):t.push({label:n.groupLabel,items:[n]})}return t}function
|
|
1
|
+
"use client";const e=require("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../ui-labels/UiLabelsProvider.cjs");let a=require("@ark-ui/react"),o=require("@stokelp/styled-system/jsx"),s=require("@stokelp/styled-system/recipes"),c=require("react"),l=require("react/jsx-runtime"),u=require("@stokelp/styled-system/css"),d=require("react-window");var{withProvider:f,withContext:p}=e.createStyleContext(s.select),m=f((0,o.styled)(a.Select.Root),`root`,{defaultProps:{loopFocus:!0}}),h=p((0,o.styled)(a.Select.ClearTrigger),`clearTrigger`),g=p((0,o.styled)(a.Select.Content),`content`),_=p((0,o.styled)(a.Select.Control),`control`),v=p((0,o.styled)(a.Select.Indicator),`indicator`),y=p((0,o.styled)(a.Select.Item),`item`),b=p((0,o.styled)(a.Select.ItemGroup),`itemGroup`),x=p((0,o.styled)(a.Select.ItemGroupLabel),`itemGroupLabel`),S=p((0,o.styled)(a.Select.ItemText),`itemText`),C=p((0,o.styled)(a.Select.Positioner),`positioner`),w=p((0,o.styled)(a.Select.Trigger),`trigger`),T=p((0,o.styled)(a.Select.ValueText),`valueText`),E=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,u.css)({stroke:`grey.100`})})]}),D=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,u.css)({fill:`primary.500`})}),(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,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`,fill:`white`})]});function O({placeholder:e,allSelectedLabel:t}){let n=(0,a.useSelectContext)(),r=n.collection.items,i=n.selectedItems;return n.multiple&&i.filter(e=>!e.disabled).length>=r.filter(e=>!e.disabled).length&&t?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:t}):(0,l.jsx)(T,{truncate:!0,placeholder:e})}function k({renderTrigger:e,placeholder:t,allSelectedLabel:n}){let r=(0,a.useSelectContext)(),i=r.value&&r.value.length>0?r.collection.findMany(r.value):[];if(i.length===0)return(0,l.jsx)(T,{className:`custom`,truncate:!0,placeholder:t});let o=r.selectedItems;return r.multiple&&o.filter(e=>!e.disabled).length>=r.collection.items.filter(e=>!e.disabled).length&&n?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:n}):(0,l.jsx)(T,{className:`custom`,placeholder:t,children:i.map(t=>(0,l.jsx)(`span`,{children:e(t)},t.value))})}function A({item:e,isMultiple:t,renderItem:n}){let r=(0,a.useSelectItemContext)();return(0,l.jsxs)(l.Fragment,{children:[t?r.selected?(0,l.jsx)(D,{}):(0,l.jsx)(E,{}):null,n?n(e):(0,l.jsx)(S,{truncate:!0,children:e.label})]})}function j({index:e,style:n,ariaAttributes:i,items:a,renderItem:o}){let s=a[e];return(0,l.jsx)(r.ConditionalWrapper,{when:!!s.tooltip,wrapper:e=>(0,l.jsx)(t.Tooltip,{label:s.tooltip,children:e}),children:(0,l.jsx)(y,{item:s,style:n,"aria-posinset":i[`aria-posinset`],"aria-setsize":i[`aria-setsize`],children:(0,l.jsx)(A,{renderItem:o,item:s})})})}function M(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.label===n.groupLabel?e.items.push(n):t.push({label:n.groupLabel,items:[n]})}return t}function N({items:e,placeholder:o,emptyLabel:s,usePortal:f=!0,positioning:p,renderItem:S,renderTrigger:T,virtualized:E,rowHeight:D=34,...N}){let P=i.useUiLabels(),F=(0,a.createListCollection)({items:e}),I=(0,c.useRef)(null),L=e=>(0,l.jsxs)(c.Fragment,{children:[(0,l.jsx)(r.ConditionalWrapper,{when:!!e.tooltip,wrapper:n=>(0,l.jsx)(t.Tooltip,{label:e.tooltip,children:n}),children:(0,l.jsx)(y,{item:e,children:(0,l.jsx)(A,{renderItem:S,item:e,isMultiple:N.multiple})},e.value)},e.value),e.separatorAfter&&(0,l.jsx)(`div`,{role:`separator`,className:(0,u.css)({height:`1px`,flexShrink:0,backgroundColor:`grey.100`,marginY:`space-4`,marginX:`space-8`})})]},e.value);return(0,l.jsxs)(m,{lazyMount:!0,unmountOnExit:!0,collection:F,positioning:{sameWidth:!0,gutter:0,...p},"data-recipe":`select`,...N,ref:e=>{e&&(I.current=e.closest(`[role="dialog"]`))},children:[(0,l.jsxs)(_,{children:[(0,l.jsxs)(w,{children:[T?(0,l.jsx)(k,{renderTrigger:T,placeholder:o,allSelectedLabel:N.allSelectedLabel}):(0,l.jsx)(O,{placeholder:o,allSelectedLabel:N.allSelectedLabel}),(0,l.jsx)(v,{asChild:!0,children:(0,l.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,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`,fill:`currentColor`})})})]}),(0,l.jsx)(h,{disabled:N.readOnly,asChild:!0,children:(0,l.jsx)(`button`,{children:(0,l.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,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`,fill:`currentColor`})})})})]}),(0,l.jsx)(r.ConditionalWrapper,{when:f,wrapper:e=>(0,l.jsx)(a.Portal,{container:I,children:e}),children:(0,l.jsx)(C,{children:(0,l.jsx)(g,{children:e.length===0?(0,l.jsx)(n.Text,{px:`space-8`,textAlign:`center`,children:s??P.noResults}):E?(0,l.jsx)(d.List,{role:`presentation`,rowComponent:j,rowProps:{items:e,renderItem:S},rowCount:e.length,rowHeight:D,style:{height:Math.min(D*e.length,180)}}):M(e).map((e,t)=>e.label===void 0?(0,l.jsx)(c.Fragment,{children:e.items.map(L)},`group-${t}`):(0,l.jsxs)(b,{children:[(0,l.jsx)(x,{children:e.label}),e.items.map(L)]},`group-${t}`))})})}),(0,l.jsx)(a.Select.HiddenSelect,{})]})}exports.Select=N;
|
|
2
2
|
//# sourceMappingURL=Select.cjs.map
|