@blenx-dev/core 0.1.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/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/package.json +49 -0
- package/src/DataTable/data-table-column-toggle.tsx +73 -0
- package/src/DataTable/data-table-empty.tsx +27 -0
- package/src/DataTable/data-table-error.tsx +25 -0
- package/src/DataTable/data-table-infinite-loader.tsx +73 -0
- package/src/DataTable/data-table-loading.tsx +67 -0
- package/src/DataTable/data-table-pagination.tsx +80 -0
- package/src/DataTable/data-table-toolbar.tsx +62 -0
- package/src/DataTable/data-table.css.ts +420 -0
- package/src/DataTable/data-table.tsx +507 -0
- package/src/DataTable/index.ts +24 -0
- package/src/DataTable/types.ts +169 -0
- package/src/DataTable/use-infinite-scroll.ts +67 -0
- package/src/components/Accordion/accordion.css.ts +84 -0
- package/src/components/Accordion/accordion.tsx +87 -0
- package/src/components/Accordion/index.ts +8 -0
- package/src/components/Alert/alert.css.ts +29 -0
- package/src/components/Alert/alert.tsx +40 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/AlertDialog/alert-dialog.css.ts +62 -0
- package/src/components/AlertDialog/alert-dialog.tsx +199 -0
- package/src/components/AlertDialog/index.ts +1 -0
- package/src/components/AspectRatio/aspect-ratio.css.ts +7 -0
- package/src/components/AspectRatio/aspect-ratio.tsx +20 -0
- package/src/components/AspectRatio/index.ts +1 -0
- package/src/components/Autocomplete/autocomplete.css.ts +167 -0
- package/src/components/Autocomplete/autocomplete.tsx +226 -0
- package/src/components/Autocomplete/index.ts +1 -0
- package/src/components/Avatar/avatar.css.ts +65 -0
- package/src/components/Avatar/avatar.tsx +44 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Badge/badge.css.ts +180 -0
- package/src/components/Badge/badge.tsx +47 -0
- package/src/components/Badge/index.ts +1 -0
- package/src/components/Box/box.css.ts +5 -0
- package/src/components/Box/box.tsx +21 -0
- package/src/components/Box/index.ts +1 -0
- package/src/components/Breadcrumbs/breadcrumbs.css.ts +72 -0
- package/src/components/Breadcrumbs/breadcrumbs.tsx +79 -0
- package/src/components/Breadcrumbs/index.ts +9 -0
- package/src/components/Button/button.css.ts +200 -0
- package/src/components/Button/button.tsx +55 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Calendar/calendar.css.ts +187 -0
- package/src/components/Calendar/calendar.tsx +143 -0
- package/src/components/Calendar/index.ts +1 -0
- package/src/components/Card/card.tsx +32 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Checkbox/checkbox.css.ts +76 -0
- package/src/components/Checkbox/checkbox.tsx +94 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/CloseButton/close-button.css.ts +11 -0
- package/src/components/CloseButton/close-button.tsx +15 -0
- package/src/components/CloseButton/index.ts +2 -0
- package/src/components/ColorPicker/color-picker.tsx +123 -0
- package/src/components/ColorPicker/index.ts +1 -0
- package/src/components/ColorSwatch/color-swatch.tsx +21 -0
- package/src/components/ColorSwatch/index.ts +1 -0
- package/src/components/Combobox/combobox.css.ts +333 -0
- package/src/components/Combobox/combobox.tsx +350 -0
- package/src/components/Combobox/index.ts +1 -0
- package/src/components/Command/command.css.ts +130 -0
- package/src/components/Command/command.tsx +413 -0
- package/src/components/Command/index.ts +7 -0
- package/src/components/Container/container.css.ts +41 -0
- package/src/components/Container/container.tsx +25 -0
- package/src/components/Container/index.ts +1 -0
- package/src/components/CopyButton/copy-button.css.ts +11 -0
- package/src/components/CopyButton/copy-button.tsx +45 -0
- package/src/components/CopyButton/index.ts +2 -0
- package/src/components/DatePicker/date-picker.tsx +75 -0
- package/src/components/DatePicker/index.ts +1 -0
- package/src/components/Dialog/dialog.css.ts +57 -0
- package/src/components/Dialog/dialog.tsx +181 -0
- package/src/components/Dialog/index.ts +1 -0
- package/src/components/Drawer/drawer.css.ts +404 -0
- package/src/components/Drawer/drawer.tsx +573 -0
- package/src/components/Drawer/index.ts +1 -0
- package/src/components/Field/field.css.ts +35 -0
- package/src/components/Field/field.tsx +101 -0
- package/src/components/Field/index.ts +1 -0
- package/src/components/Grid/grid.css.ts +12 -0
- package/src/components/Grid/grid.tsx +32 -0
- package/src/components/Grid/index.ts +1 -0
- package/src/components/Icon/icon.css.ts +10 -0
- package/src/components/Icon/icon.tsx +15 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/IconButton/icon-button.css.ts +6 -0
- package/src/components/IconButton/icon-button.tsx +11 -0
- package/src/components/IconButton/index.ts +2 -0
- package/src/components/Input/index.ts +1 -0
- package/src/components/Input/input.css.ts +72 -0
- package/src/components/Input/input.tsx +50 -0
- package/src/components/InputGroup/index.ts +1 -0
- package/src/components/InputGroup/input-group.css.ts +156 -0
- package/src/components/InputGroup/input-group.tsx +133 -0
- package/src/components/Menu/index.ts +1 -0
- package/src/components/Menu/menu.css.ts +121 -0
- package/src/components/Menu/menu.tsx +115 -0
- package/src/components/OTPField/index.ts +1 -0
- package/src/components/OTPField/otp-field.css.ts +54 -0
- package/src/components/OTPField/otp-field.tsx +46 -0
- package/src/components/Popover/index.ts +1 -0
- package/src/components/Popover/popover.css.ts +81 -0
- package/src/components/Popover/popover.tsx +113 -0
- package/src/components/Progress/index.ts +7 -0
- package/src/components/Progress/progress.css.ts +37 -0
- package/src/components/Progress/progress.tsx +62 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/Radio/radio.css.ts +72 -0
- package/src/components/Radio/radio.tsx +49 -0
- package/src/components/ScrollArea/index.ts +1 -0
- package/src/components/ScrollArea/scroll-area.css.ts +79 -0
- package/src/components/ScrollArea/scroll-area.tsx +96 -0
- package/src/components/SegmentedControl/index.ts +1 -0
- package/src/components/SegmentedControl/segmented-control.tsx +42 -0
- package/src/components/Select/index.ts +1 -0
- package/src/components/Select/select.css.ts +182 -0
- package/src/components/Select/select.tsx +165 -0
- package/src/components/Separator/index.ts +1 -0
- package/src/components/Separator/separator.css.ts +59 -0
- package/src/components/Separator/separator.tsx +34 -0
- package/src/components/Sheet/index.ts +1 -0
- package/src/components/Sheet/sheet.css.ts +184 -0
- package/src/components/Sheet/sheet.tsx +215 -0
- package/src/components/Slider/index.ts +1 -0
- package/src/components/Slider/slider.css.ts +81 -0
- package/src/components/Slider/slider.tsx +100 -0
- package/src/components/Spinner/index.ts +1 -0
- package/src/components/Spinner/spinner.css.ts +17 -0
- package/src/components/Spinner/spinner.tsx +15 -0
- package/src/components/Splitter/index.ts +1 -0
- package/src/components/Splitter/splitter.css.ts +69 -0
- package/src/components/Splitter/splitter.tsx +521 -0
- package/src/components/Stack/index.ts +1 -0
- package/src/components/Stack/stack.css.ts +42 -0
- package/src/components/Stack/stack.tsx +32 -0
- package/src/components/Surface/index.ts +1 -0
- package/src/components/Surface/surface.css.ts +40 -0
- package/src/components/Surface/surface.tsx +19 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Switch/switch.css.ts +46 -0
- package/src/components/Switch/switch.tsx +25 -0
- package/src/components/Table/index.ts +2 -0
- package/src/components/Table/table.css.ts +71 -0
- package/src/components/Table/table.tsx +117 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/Tabs/tabs.css.ts +250 -0
- package/src/components/Tabs/tabs.tsx +119 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/Text/text.css.ts +118 -0
- package/src/components/Text/text.tsx +66 -0
- package/src/components/Textarea/index.ts +1 -0
- package/src/components/Textarea/textarea.css.ts +66 -0
- package/src/components/Textarea/textarea.tsx +48 -0
- package/src/components/Toggle/index.ts +1 -0
- package/src/components/Toggle/toggle.css.ts +91 -0
- package/src/components/Toggle/toggle.tsx +44 -0
- package/src/components/ToggleGroup/index.ts +1 -0
- package/src/components/ToggleGroup/toggle-group.css.ts +77 -0
- package/src/components/ToggleGroup/toggle-group.tsx +131 -0
- package/src/components/index.ts +54 -0
- package/src/index.ts +3 -0
- package/src/utils/drawer-styles.css.ts +85 -0
- package/src/utils/heights.ts +16 -0
- package/src/utils/sprinkles.css.ts +197 -0
- package/src/utils/sprinkles.tokens.ts +74 -0
- package/src/utils/types.ts +10 -0
- package/src/utils/ve-style.utils.ts +51 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { style } from "@vanilla-extract/css";
|
|
2
|
+
import { semanticVars, tokenVars } from "@blenx-dev/theme/contract";
|
|
3
|
+
|
|
4
|
+
export const inputGroup = style({
|
|
5
|
+
position: "relative",
|
|
6
|
+
width: "100%",
|
|
7
|
+
minWidth: 0,
|
|
8
|
+
color: semanticVars.text.primary,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const inputSm = style({
|
|
12
|
+
paddingInlineStart: "30px",
|
|
13
|
+
paddingInlineEnd: "26px",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const inputDefault = style({
|
|
17
|
+
paddingInlineStart: "32px",
|
|
18
|
+
paddingInlineEnd: "28px",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const inputLg = style({
|
|
22
|
+
paddingInlineStart: "34px",
|
|
23
|
+
paddingInlineEnd: "30px",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const startAddon = style({
|
|
27
|
+
pointerEvents: "none",
|
|
28
|
+
position: "absolute",
|
|
29
|
+
insetBlock: 0,
|
|
30
|
+
insetInlineStart: tokenVars.borderWidth.thin,
|
|
31
|
+
display: "flex",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
opacity: 0.8,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const startAddonSm = style({
|
|
37
|
+
paddingInlineStart: "9px",
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const startAddonDefault = style({
|
|
41
|
+
paddingInlineStart: "11px",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const adornment = style({
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: "50%",
|
|
47
|
+
display: "inline-flex",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
justifyContent: "center",
|
|
50
|
+
flexShrink: 0,
|
|
51
|
+
transform: "translateY(-50%)",
|
|
52
|
+
borderRadius: tokenVars.borderRadius.md,
|
|
53
|
+
borderWidth: tokenVars.borderWidth.thin,
|
|
54
|
+
borderStyle: "solid",
|
|
55
|
+
borderColor: "transparent",
|
|
56
|
+
opacity: 0.8,
|
|
57
|
+
outline: "none",
|
|
58
|
+
transitionProperty: "color, background-color, box-shadow, opacity",
|
|
59
|
+
transitionDuration: "150ms",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const adornmentSm = style({
|
|
63
|
+
width: "28px",
|
|
64
|
+
height: "28px",
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const adornmentDefault = style({
|
|
68
|
+
width: "32px",
|
|
69
|
+
height: "32px",
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const adornmentEndSm = style({
|
|
73
|
+
insetInlineEnd: tokenVars.spacing["0"],
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export const adornmentEndDefault = style({
|
|
77
|
+
insetInlineEnd: tokenVars.spacing["0.5"],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const positioner = style({
|
|
81
|
+
outline: "none",
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const popupShell = style({
|
|
85
|
+
position: "relative",
|
|
86
|
+
display: "flex",
|
|
87
|
+
maxHeight: "100%",
|
|
88
|
+
minWidth: "var(--anchor-width)",
|
|
89
|
+
maxWidth: "var(--available-width)",
|
|
90
|
+
borderWidth: tokenVars.borderWidth.thin,
|
|
91
|
+
borderStyle: "solid",
|
|
92
|
+
borderColor: semanticVars.border.default,
|
|
93
|
+
borderRadius: tokenVars.borderRadius.lg,
|
|
94
|
+
backgroundColor: semanticVars.surface.default,
|
|
95
|
+
boxShadow: tokenVars.shadow.lg,
|
|
96
|
+
transformOrigin: "var(--transform-origin)",
|
|
97
|
+
transitionProperty: "transform, opacity",
|
|
98
|
+
transitionDuration: "150ms",
|
|
99
|
+
"::before": {
|
|
100
|
+
content: '""',
|
|
101
|
+
pointerEvents: "none",
|
|
102
|
+
position: "absolute",
|
|
103
|
+
inset: 0,
|
|
104
|
+
borderRadius: "inherit",
|
|
105
|
+
boxShadow: "0 1px 0 rgba(0, 0, 0, 0.04), inset 0 0 0 1px rgba(255, 255, 255, 0.02)",
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export const popup = style({
|
|
110
|
+
display: "flex",
|
|
111
|
+
flex: 1,
|
|
112
|
+
flexDirection: "column",
|
|
113
|
+
maxHeight: "min(var(--available-height), 23rem)",
|
|
114
|
+
color: semanticVars.text.primary,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const separator = style({
|
|
118
|
+
height: "1px",
|
|
119
|
+
marginBlock: tokenVars.spacing.xs,
|
|
120
|
+
marginInline: tokenVars.spacing.sm,
|
|
121
|
+
backgroundColor: semanticVars.border.default,
|
|
122
|
+
selectors: {
|
|
123
|
+
"&:last-child": {
|
|
124
|
+
display: "none",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export const group = style({
|
|
130
|
+
display: "flex",
|
|
131
|
+
flexDirection: "column",
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export const groupLabel = style({
|
|
135
|
+
paddingBlock: "6px",
|
|
136
|
+
paddingInline: tokenVars.spacing.sm,
|
|
137
|
+
fontSize: tokenVars.fontSize.xs,
|
|
138
|
+
fontWeight: tokenVars.fontWeight.medium,
|
|
139
|
+
color: semanticVars.text.secondary,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export const empty = style({
|
|
143
|
+
padding: tokenVars.spacing.sm,
|
|
144
|
+
textAlign: "center",
|
|
145
|
+
fontSize: tokenVars.fontSize.md,
|
|
146
|
+
color: semanticVars.text.secondary,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export const row = style({
|
|
150
|
+
display: "flex",
|
|
151
|
+
flexDirection: "column",
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export const value = style({
|
|
155
|
+
display: "block",
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export const list = style({
|
|
159
|
+
padding: tokenVars.spacing.xs,
|
|
160
|
+
selectors: {
|
|
161
|
+
"&:not(:empty)": {
|
|
162
|
+
scrollPaddingBlock: tokenVars.spacing.xs,
|
|
163
|
+
},
|
|
164
|
+
"&:has([data-slot='combobox-item'])": {
|
|
165
|
+
paddingInlineEnd: tokenVars.spacing.sm,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
export const status = style({
|
|
171
|
+
paddingInline: tokenVars.spacing.md,
|
|
172
|
+
paddingBlock: tokenVars.spacing.sm,
|
|
173
|
+
fontSize: tokenVars.fontSize.xs,
|
|
174
|
+
fontWeight: tokenVars.fontWeight.medium,
|
|
175
|
+
color: semanticVars.text.secondary,
|
|
176
|
+
selectors: {
|
|
177
|
+
"&:empty": {
|
|
178
|
+
margin: 0,
|
|
179
|
+
padding: 0,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export const item = style({
|
|
185
|
+
display: "grid",
|
|
186
|
+
gridTemplateColumns: "1rem 1fr",
|
|
187
|
+
alignItems: "center",
|
|
188
|
+
columnGap: tokenVars.spacing.sm,
|
|
189
|
+
minHeight: "32px",
|
|
190
|
+
paddingInlineStart: tokenVars.spacing.sm,
|
|
191
|
+
paddingInlineEnd: tokenVars.spacing.md,
|
|
192
|
+
paddingBlock: tokenVars.spacing["1"],
|
|
193
|
+
borderRadius: tokenVars.borderRadius.sm,
|
|
194
|
+
cursor: "default",
|
|
195
|
+
userSelect: "none",
|
|
196
|
+
outline: "none",
|
|
197
|
+
fontSize: tokenVars.fontSize.md,
|
|
198
|
+
selectors: {
|
|
199
|
+
"&:hover": {
|
|
200
|
+
backgroundColor: semanticVars.background.subtle,
|
|
201
|
+
},
|
|
202
|
+
"&[data-disabled]": {
|
|
203
|
+
pointerEvents: "none",
|
|
204
|
+
opacity: 0.64,
|
|
205
|
+
},
|
|
206
|
+
"&[data-highlighted]": {
|
|
207
|
+
backgroundColor: semanticVars.background.subtle,
|
|
208
|
+
color: semanticVars.text.primary,
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
export const itemIndicator = style({
|
|
214
|
+
gridColumn: "1",
|
|
215
|
+
display: "flex",
|
|
216
|
+
alignItems: "center",
|
|
217
|
+
justifyContent: "center",
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
export const itemContent = style({
|
|
221
|
+
gridColumn: "2",
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
export const chips = style({
|
|
225
|
+
position: "relative",
|
|
226
|
+
display: "inline-flex",
|
|
227
|
+
width: "100%",
|
|
228
|
+
minWidth: 0,
|
|
229
|
+
flexWrap: "wrap",
|
|
230
|
+
alignItems: "center",
|
|
231
|
+
gap: tokenVars.spacing.xxs,
|
|
232
|
+
minHeight: "36px",
|
|
233
|
+
padding: "calc(4px - 1px)",
|
|
234
|
+
borderWidth: tokenVars.borderWidth.thin,
|
|
235
|
+
borderStyle: "solid",
|
|
236
|
+
borderColor: semanticVars.border.default,
|
|
237
|
+
borderRadius: tokenVars.borderRadius.lg,
|
|
238
|
+
backgroundColor: semanticVars.background.default,
|
|
239
|
+
color: semanticVars.text.primary,
|
|
240
|
+
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.04)",
|
|
241
|
+
outline: "none",
|
|
242
|
+
transitionProperty: "border-color, box-shadow",
|
|
243
|
+
transitionDuration: "150ms",
|
|
244
|
+
selectors: {
|
|
245
|
+
"&:focus-within": {
|
|
246
|
+
borderColor: semanticVars.border.strong,
|
|
247
|
+
boxShadow: `0 0 0 2px ${semanticVars.border.strong}`,
|
|
248
|
+
},
|
|
249
|
+
"&:has([aria-invalid='true'])": {
|
|
250
|
+
borderColor: semanticVars.status.danger.default,
|
|
251
|
+
},
|
|
252
|
+
"&:has([aria-invalid='true']:focus-visible)": {
|
|
253
|
+
borderColor: semanticVars.status.danger.default,
|
|
254
|
+
boxShadow: `0 0 0 2px ${semanticVars.status.danger}`,
|
|
255
|
+
},
|
|
256
|
+
"&:has(:disabled)": {
|
|
257
|
+
opacity: 0.64,
|
|
258
|
+
cursor: "not-allowed",
|
|
259
|
+
},
|
|
260
|
+
"&:has([data-size='sm'])": {
|
|
261
|
+
minHeight: "32px",
|
|
262
|
+
},
|
|
263
|
+
"&:has([data-size='lg'])": {
|
|
264
|
+
minHeight: "40px",
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
export const chipsStartAddon = style({
|
|
270
|
+
display: "flex",
|
|
271
|
+
flexShrink: 0,
|
|
272
|
+
alignItems: "center",
|
|
273
|
+
opacity: 0.8,
|
|
274
|
+
paddingInlineStart: tokenVars.spacing.sm,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
export const chipsStartAddonSm = style({
|
|
278
|
+
paddingInlineStart: "6px",
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
export const chipsInput = style({
|
|
282
|
+
flex: "1 1 0%",
|
|
283
|
+
minWidth: "3rem",
|
|
284
|
+
borderWidth: 0,
|
|
285
|
+
outline: "none",
|
|
286
|
+
backgroundColor: "transparent",
|
|
287
|
+
paddingBlock: "6px",
|
|
288
|
+
paddingInlineStart: tokenVars.spacing.xs,
|
|
289
|
+
paddingInlineEnd: tokenVars.spacing.xs,
|
|
290
|
+
fontSize: tokenVars.fontSize.md,
|
|
291
|
+
lineHeight: 1.5,
|
|
292
|
+
color: semanticVars.text.primary,
|
|
293
|
+
selectors: {
|
|
294
|
+
"&::placeholder": {
|
|
295
|
+
color: semanticVars.text.disabled,
|
|
296
|
+
},
|
|
297
|
+
"&:disabled": {
|
|
298
|
+
opacity: 0.5,
|
|
299
|
+
cursor: "not-allowed",
|
|
300
|
+
},
|
|
301
|
+
"&:has(+ [data-slot='combobox-chip'])": {
|
|
302
|
+
paddingInlineStart: tokenVars.spacing.xxs,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
export const chip = style({
|
|
308
|
+
display: "inline-flex",
|
|
309
|
+
alignItems: "center",
|
|
310
|
+
borderRadius: tokenVars.borderRadius.md,
|
|
311
|
+
backgroundColor: semanticVars.background.subtle,
|
|
312
|
+
color: semanticVars.text.primary,
|
|
313
|
+
paddingInlineStart: tokenVars.spacing.sm,
|
|
314
|
+
fontSize: tokenVars.fontSize.sm,
|
|
315
|
+
fontWeight: tokenVars.fontWeight.medium,
|
|
316
|
+
lineHeight: 1.2,
|
|
317
|
+
outline: "none",
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
export const chipRemove = style({
|
|
321
|
+
display: "inline-flex",
|
|
322
|
+
height: "100%",
|
|
323
|
+
alignItems: "center",
|
|
324
|
+
flexShrink: 0,
|
|
325
|
+
cursor: "pointer",
|
|
326
|
+
paddingInline: tokenVars.spacing.xs,
|
|
327
|
+
opacity: 0.8,
|
|
328
|
+
selectors: {
|
|
329
|
+
"&:hover": {
|
|
330
|
+
opacity: 1,
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
});
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react/combobox";
|
|
2
|
+
import { CaretUpDownIcon, CheckIcon, XIcon } from "@phosphor-icons/react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { Input } from "../Input/input";
|
|
6
|
+
import { ScrollArea } from "../ScrollArea/scroll-area";
|
|
7
|
+
import {
|
|
8
|
+
inputGroup,
|
|
9
|
+
inputSm,
|
|
10
|
+
inputDefault,
|
|
11
|
+
inputLg,
|
|
12
|
+
startAddon,
|
|
13
|
+
startAddonSm,
|
|
14
|
+
startAddonDefault,
|
|
15
|
+
adornment,
|
|
16
|
+
adornmentSm,
|
|
17
|
+
adornmentDefault,
|
|
18
|
+
adornmentEndSm,
|
|
19
|
+
adornmentEndDefault,
|
|
20
|
+
positioner,
|
|
21
|
+
popupShell,
|
|
22
|
+
popup,
|
|
23
|
+
separator,
|
|
24
|
+
group,
|
|
25
|
+
groupLabel,
|
|
26
|
+
empty,
|
|
27
|
+
row,
|
|
28
|
+
list,
|
|
29
|
+
status,
|
|
30
|
+
item,
|
|
31
|
+
itemIndicator,
|
|
32
|
+
itemContent,
|
|
33
|
+
chips,
|
|
34
|
+
chipsStartAddon,
|
|
35
|
+
chipsInput,
|
|
36
|
+
chip,
|
|
37
|
+
chipRemove,
|
|
38
|
+
} from "./combobox.css";
|
|
39
|
+
import { CloseButton } from "../CloseButton";
|
|
40
|
+
|
|
41
|
+
type InputSize = "sm" | "default" | "lg" | number;
|
|
42
|
+
|
|
43
|
+
export const ComboboxContext: React.Context<{
|
|
44
|
+
chipsRef: React.RefObject<Element | null> | null;
|
|
45
|
+
multiple: boolean;
|
|
46
|
+
}> = React.createContext<{
|
|
47
|
+
chipsRef: React.RefObject<Element | null> | null;
|
|
48
|
+
multiple: boolean;
|
|
49
|
+
}>({
|
|
50
|
+
chipsRef: null,
|
|
51
|
+
multiple: false,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export function Combobox<Value, Multiple extends boolean | undefined = false>(
|
|
55
|
+
props: ComboboxPrimitive.Root.Props<Value, Multiple>,
|
|
56
|
+
): React.ReactElement {
|
|
57
|
+
const chipsRef = React.useRef<Element | null>(null);
|
|
58
|
+
const contextValue = React.useMemo(
|
|
59
|
+
() => ({ chipsRef, multiple: Boolean(props.multiple) }),
|
|
60
|
+
[props.multiple],
|
|
61
|
+
);
|
|
62
|
+
return (
|
|
63
|
+
<ComboboxContext.Provider value={contextValue}>
|
|
64
|
+
<ComboboxPrimitive.Root {...props} />
|
|
65
|
+
</ComboboxContext.Provider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function ComboboxChipsInput({
|
|
70
|
+
size,
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: ComboboxPrimitive.Input.Props & {
|
|
74
|
+
size?: InputSize;
|
|
75
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
76
|
+
}): React.ReactElement {
|
|
77
|
+
const resolvedSize = size ?? "default";
|
|
78
|
+
return (
|
|
79
|
+
<ComboboxPrimitive.Input
|
|
80
|
+
className={clsx(chipsInput, className)}
|
|
81
|
+
data-size={typeof resolvedSize === "string" ? resolvedSize : undefined}
|
|
82
|
+
data-slot="combobox-chips-input"
|
|
83
|
+
size={typeof resolvedSize === "number" ? resolvedSize : undefined}
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type ComboboxTriggerProps = ComboboxPrimitive.Trigger.Props;
|
|
90
|
+
export function ComboboxTrigger({ className, ...props }: ComboboxTriggerProps): React.ReactElement {
|
|
91
|
+
return (
|
|
92
|
+
<ComboboxPrimitive.Trigger className={className} data-slot="combobox-trigger" {...props} />
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
type ComboboxClearProps = ComboboxPrimitive.Clear.Props;
|
|
97
|
+
export function ComboboxClear({
|
|
98
|
+
className,
|
|
99
|
+
children,
|
|
100
|
+
...props
|
|
101
|
+
}: ComboboxClearProps): React.ReactElement {
|
|
102
|
+
return (
|
|
103
|
+
<ComboboxPrimitive.Clear
|
|
104
|
+
className={clsx(adornment, className)}
|
|
105
|
+
data-slot="combobox-clear"
|
|
106
|
+
{...props}
|
|
107
|
+
>
|
|
108
|
+
{children ?? <XIcon size={18} weight="regular" />}
|
|
109
|
+
</ComboboxPrimitive.Clear>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function ComboboxInput({
|
|
114
|
+
showTrigger = true,
|
|
115
|
+
showClear = false,
|
|
116
|
+
startAddon: startAddonNode,
|
|
117
|
+
size,
|
|
118
|
+
triggerProps,
|
|
119
|
+
clearProps,
|
|
120
|
+
render: renderProp,
|
|
121
|
+
className,
|
|
122
|
+
...props
|
|
123
|
+
}: Omit<ComboboxPrimitive.Input.Props, "size"> & {
|
|
124
|
+
showTrigger?: boolean;
|
|
125
|
+
showClear?: boolean;
|
|
126
|
+
startAddon?: React.ReactNode;
|
|
127
|
+
size?: InputSize;
|
|
128
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
129
|
+
triggerProps?: ComboboxPrimitive.Trigger.Props;
|
|
130
|
+
clearProps?: ComboboxPrimitive.Clear.Props;
|
|
131
|
+
}): React.ReactElement {
|
|
132
|
+
const resolvedSize = size ?? "default";
|
|
133
|
+
const renderSize = resolvedSize === "sm" || resolvedSize === "lg" ? resolvedSize : "default";
|
|
134
|
+
const inputCls = clsx(
|
|
135
|
+
resolvedSize === "sm" ? inputSm : resolvedSize === "lg" ? inputLg : inputDefault,
|
|
136
|
+
className,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<ComboboxPrimitive.InputGroup className={inputGroup} data-slot="combobox-input-group">
|
|
141
|
+
{startAddonNode && (
|
|
142
|
+
<div
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
className={clsx(startAddon, resolvedSize === "sm" ? startAddonSm : startAddonDefault)}
|
|
145
|
+
data-slot="combobox-start-addon"
|
|
146
|
+
>
|
|
147
|
+
{startAddonNode}
|
|
148
|
+
</div>
|
|
149
|
+
)}
|
|
150
|
+
<ComboboxPrimitive.Input
|
|
151
|
+
data-slot="combobox-input"
|
|
152
|
+
render={renderProp ?? <Input size={renderSize} />}
|
|
153
|
+
className={inputCls}
|
|
154
|
+
{...props}
|
|
155
|
+
/>
|
|
156
|
+
{showTrigger && (
|
|
157
|
+
<ComboboxPrimitive.Trigger
|
|
158
|
+
className={clsx(
|
|
159
|
+
adornment,
|
|
160
|
+
resolvedSize === "sm" ? adornmentSm : adornmentDefault,
|
|
161
|
+
resolvedSize === "sm" ? adornmentEndSm : adornmentEndDefault,
|
|
162
|
+
)}
|
|
163
|
+
data-slot="combobox-trigger"
|
|
164
|
+
{...triggerProps}
|
|
165
|
+
>
|
|
166
|
+
<CaretUpDownIcon size={resolvedSize === "sm" ? 16 : 18} weight="regular" />
|
|
167
|
+
</ComboboxPrimitive.Trigger>
|
|
168
|
+
)}
|
|
169
|
+
{showClear && (
|
|
170
|
+
<ComboboxClear
|
|
171
|
+
className={clsx(
|
|
172
|
+
adornment,
|
|
173
|
+
resolvedSize === "sm" ? adornmentSm : adornmentDefault,
|
|
174
|
+
resolvedSize === "sm" ? adornmentEndSm : adornmentEndDefault,
|
|
175
|
+
)}
|
|
176
|
+
render={<CloseButton />}
|
|
177
|
+
{...clearProps}
|
|
178
|
+
/>
|
|
179
|
+
)}
|
|
180
|
+
</ComboboxPrimitive.InputGroup>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function ComboboxPopup({
|
|
185
|
+
children,
|
|
186
|
+
side = "bottom",
|
|
187
|
+
sideOffset = 4,
|
|
188
|
+
alignOffset,
|
|
189
|
+
align = "start",
|
|
190
|
+
anchor: anchorProp,
|
|
191
|
+
portalProps,
|
|
192
|
+
className,
|
|
193
|
+
...props
|
|
194
|
+
}: ComboboxPrimitive.Popup.Props & {
|
|
195
|
+
align?: ComboboxPrimitive.Positioner.Props["align"];
|
|
196
|
+
sideOffset?: ComboboxPrimitive.Positioner.Props["sideOffset"];
|
|
197
|
+
alignOffset?: ComboboxPrimitive.Positioner.Props["alignOffset"];
|
|
198
|
+
side?: ComboboxPrimitive.Positioner.Props["side"];
|
|
199
|
+
anchor?: ComboboxPrimitive.Positioner.Props["anchor"];
|
|
200
|
+
portalProps?: ComboboxPrimitive.Portal.Props;
|
|
201
|
+
}): React.ReactElement {
|
|
202
|
+
const { chipsRef } = React.useContext(ComboboxContext);
|
|
203
|
+
const anchor = anchorProp ?? chipsRef;
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<ComboboxPrimitive.Portal {...portalProps}>
|
|
207
|
+
<ComboboxPrimitive.Positioner
|
|
208
|
+
align={align}
|
|
209
|
+
alignOffset={alignOffset}
|
|
210
|
+
anchor={anchor}
|
|
211
|
+
className={positioner}
|
|
212
|
+
data-slot="combobox-positioner"
|
|
213
|
+
side={side}
|
|
214
|
+
sideOffset={sideOffset}
|
|
215
|
+
>
|
|
216
|
+
<span className={clsx(popupShell, className)}>
|
|
217
|
+
<ComboboxPrimitive.Popup className={popup} data-slot="combobox-popup" {...props}>
|
|
218
|
+
{children}
|
|
219
|
+
</ComboboxPrimitive.Popup>
|
|
220
|
+
</span>
|
|
221
|
+
</ComboboxPrimitive.Positioner>
|
|
222
|
+
</ComboboxPrimitive.Portal>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function ComboboxItem({
|
|
227
|
+
children,
|
|
228
|
+
className,
|
|
229
|
+
...props
|
|
230
|
+
}: ComboboxPrimitive.Item.Props): React.ReactElement {
|
|
231
|
+
return (
|
|
232
|
+
<ComboboxPrimitive.Item className={clsx(item, className)} data-slot="combobox-item" {...props}>
|
|
233
|
+
<ComboboxPrimitive.ItemIndicator className={itemIndicator}>
|
|
234
|
+
<CheckIcon size={16} weight="bold" />
|
|
235
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
236
|
+
<div className={itemContent}>{children}</div>
|
|
237
|
+
</ComboboxPrimitive.Item>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function ComboboxSeparator(props: ComboboxPrimitive.Separator.Props): React.ReactElement {
|
|
242
|
+
return (
|
|
243
|
+
<ComboboxPrimitive.Separator className={separator} data-slot="combobox-separator" {...props} />
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function ComboboxGroup(props: ComboboxPrimitive.Group.Props): React.ReactElement {
|
|
248
|
+
return <ComboboxPrimitive.Group className={group} data-slot="combobox-group" {...props} />;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function ComboboxGroupLabel(props: ComboboxPrimitive.GroupLabel.Props): React.ReactElement {
|
|
252
|
+
return (
|
|
253
|
+
<ComboboxPrimitive.GroupLabel
|
|
254
|
+
className={groupLabel}
|
|
255
|
+
data-slot="combobox-group-label"
|
|
256
|
+
{...props}
|
|
257
|
+
/>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function ComboboxEmpty(props: ComboboxPrimitive.Empty.Props): React.ReactElement {
|
|
262
|
+
return <ComboboxPrimitive.Empty className={empty} data-slot="combobox-empty" {...props} />;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function ComboboxRow(props: ComboboxPrimitive.Row.Props): React.ReactElement {
|
|
266
|
+
return <ComboboxPrimitive.Row className={row} data-slot="combobox-row" {...props} />;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function ComboboxValue(props: ComboboxPrimitive.Value.Props): React.ReactElement {
|
|
270
|
+
return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function ComboboxList(props: ComboboxPrimitive.List.Props): React.ReactElement {
|
|
274
|
+
return (
|
|
275
|
+
<ScrollArea scrollbarGutter scrollFade>
|
|
276
|
+
<ComboboxPrimitive.List className={list} data-slot="combobox-list" {...props} />
|
|
277
|
+
</ScrollArea>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export function ComboboxStatus(props: ComboboxPrimitive.Status.Props): React.ReactElement {
|
|
282
|
+
return <ComboboxPrimitive.Status className={status} data-slot="combobox-status" {...props} />;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function ComboboxCollection(props: ComboboxPrimitive.Collection.Props): React.ReactElement {
|
|
286
|
+
return <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function ComboboxChips({
|
|
290
|
+
children,
|
|
291
|
+
startAddon: startAddonNode,
|
|
292
|
+
className,
|
|
293
|
+
...props
|
|
294
|
+
}: ComboboxPrimitive.Chips.Props & {
|
|
295
|
+
startAddon?: React.ReactNode;
|
|
296
|
+
}): React.ReactElement {
|
|
297
|
+
const { chipsRef } = React.useContext(ComboboxContext);
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<ComboboxPrimitive.Chips
|
|
301
|
+
data-slot="combobox-chips"
|
|
302
|
+
ref={chipsRef as React.Ref<HTMLDivElement> | null}
|
|
303
|
+
className={clsx(chips, className)}
|
|
304
|
+
{...props}
|
|
305
|
+
>
|
|
306
|
+
{startAddonNode && (
|
|
307
|
+
<div aria-hidden="true" data-slot="combobox-start-addon" className={chipsStartAddon}>
|
|
308
|
+
{startAddonNode}
|
|
309
|
+
</div>
|
|
310
|
+
)}
|
|
311
|
+
{children}
|
|
312
|
+
</ComboboxPrimitive.Chips>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function ComboboxChip({
|
|
317
|
+
children,
|
|
318
|
+
removeProps,
|
|
319
|
+
className,
|
|
320
|
+
...props
|
|
321
|
+
}: ComboboxPrimitive.Chip.Props & {
|
|
322
|
+
removeProps?: ComboboxPrimitive.ChipRemove.Props;
|
|
323
|
+
}): React.ReactElement {
|
|
324
|
+
return (
|
|
325
|
+
<ComboboxPrimitive.Chip className={clsx(chip, className)} data-slot="combobox-chip" {...props}>
|
|
326
|
+
{children}
|
|
327
|
+
<ComboboxChipRemove {...removeProps} />
|
|
328
|
+
</ComboboxPrimitive.Chip>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function ComboboxChipRemove({
|
|
333
|
+
className,
|
|
334
|
+
...props
|
|
335
|
+
}: ComboboxPrimitive.ChipRemove.Props): React.ReactElement {
|
|
336
|
+
return (
|
|
337
|
+
<ComboboxPrimitive.ChipRemove
|
|
338
|
+
aria-label="Remove"
|
|
339
|
+
className={clsx(chipRemove, className)}
|
|
340
|
+
data-slot="combobox-chip-remove"
|
|
341
|
+
{...props}
|
|
342
|
+
>
|
|
343
|
+
<XIcon size={16} weight="regular" />
|
|
344
|
+
</ComboboxPrimitive.ChipRemove>
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export const useComboboxFilter: typeof ComboboxPrimitive.useFilter = ComboboxPrimitive.useFilter;
|
|
349
|
+
|
|
350
|
+
export { ComboboxChipRemove };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./combobox";
|