@parrot-co/parrot-ui 0.1.28 → 1.0.0-beta.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/dist/colors.css +571 -0
- package/dist/dark.css +606 -0
- package/dist/index.d.mts +773 -0
- package/dist/index.d.ts +773 -0
- package/dist/index.js +3936 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3850 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2865 -0
- package/dist/theme.css +67 -0
- package/package.json +69 -59
- package/src/theme.css +67 -0
- package/dist/main.js +0 -4586
- package/dist/main.js.map +0 -1
- package/dist/module.js +0 -4517
- package/dist/module.js.map +0 -1
- package/dist/types.d.ts +0 -604
- package/dist/types.d.ts.map +0 -1
- package/styles.css +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3850 @@
|
|
|
1
|
+
import * as React36 from 'react';
|
|
2
|
+
import React36__default from 'react';
|
|
3
|
+
import { TextField, Input as Input$1, Button as Button$1, ToggleButton as ToggleButton$1, NumberField, Group, TextArea, CheckboxGroup as CheckboxGroup$1, CheckboxField, CheckboxButton, MenuTrigger as MenuTrigger$1, Pressable, Popover as Popover$1, Menu as Menu$1, MenuItem as MenuItem$1, MenuSection as MenuSection$1, Header, ListBox as ListBox$1, ListBoxItem as ListBoxItem$1, composeRenderProps, ListBoxSection as ListBoxSection$1, useAsyncList, useFilter, ComboBox as ComboBox$1, RadioField, RadioButton, RadioGroup as RadioGroup$1, Select as Select$1, SelectValue, Calendar as Calendar$1, RangeCalendar as RangeCalendar$1, DateField as DateField$1, TimeField as TimeField$1, DatePicker as DatePicker$1, DateRangePicker as DateRangePicker$1, DropZone, FileTrigger, ProgressBar, SwitchField, SwitchButton, Slider as Slider$1, SliderTrack, SliderThumb, Tabs as Tabs$1, TabList, Tab as Tab$1, TabPanel, Table as Table$1, TableHeader, Column, TableBody, Row, Cell, ModalOverlay, Modal as Modal$1, Dialog, TagGroup as TagGroup$1, TagList, Tag as Tag$1, parseColor, ColorArea as ColorArea$1, ColorThumb, ColorField as ColorField$1, ColorSwatchPicker as ColorSwatchPicker$1, ColorSwatchPickerItem, ColorSwatch, ColorSlider as ColorSlider$1, ToggleButtonGroup, Collection, useContextProps, GroupContext, FieldError, LabelContext, CalendarMonthPicker, CalendarYearPicker, Heading, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, CalendarCell, DateInput, DateSegment, TextContext } from 'react-aria-components';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { parseDate, parseTime } from '@internationalized/date';
|
|
6
|
+
import { useOverlayTriggerState } from 'react-stately';
|
|
7
|
+
|
|
8
|
+
// src/components/input/input.tsx
|
|
9
|
+
|
|
10
|
+
// src/utils/assertions.ts
|
|
11
|
+
function isArray(value) {
|
|
12
|
+
return value !== null && Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function isEmptyArray(value) {
|
|
15
|
+
return isArray(value) && value.length === 0;
|
|
16
|
+
}
|
|
17
|
+
function isObject(value) {
|
|
18
|
+
return (typeof value === "object" || typeof value === "function") && !Array.isArray(value) && value !== null;
|
|
19
|
+
}
|
|
20
|
+
function isUndefinedOrNull(value) {
|
|
21
|
+
return value == null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/utils/dom.ts
|
|
25
|
+
function processClassValue(value) {
|
|
26
|
+
if (!value) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (typeof value === "function") {
|
|
30
|
+
return processClassValue(value?.());
|
|
31
|
+
}
|
|
32
|
+
if (isArray(value)) {
|
|
33
|
+
let i = 0;
|
|
34
|
+
let temp = "";
|
|
35
|
+
while (i < value.length) {
|
|
36
|
+
const result = processClassValue(value[i++]);
|
|
37
|
+
if (result) {
|
|
38
|
+
temp && (temp += " ");
|
|
39
|
+
temp += `${result}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return temp;
|
|
43
|
+
}
|
|
44
|
+
if (isObject(value)) {
|
|
45
|
+
let str = "";
|
|
46
|
+
for (const key in value) {
|
|
47
|
+
if (value[key]) {
|
|
48
|
+
str && (str += " ");
|
|
49
|
+
str += `${key}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return str;
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
function cx(...args) {
|
|
57
|
+
let i = 0;
|
|
58
|
+
let classStr = "";
|
|
59
|
+
while (i < args.length) {
|
|
60
|
+
const result = processClassValue(args[i++]);
|
|
61
|
+
if (result) {
|
|
62
|
+
classStr && (classStr += " ");
|
|
63
|
+
classStr += result;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return classStr;
|
|
67
|
+
}
|
|
68
|
+
function cn(...args) {
|
|
69
|
+
return twMerge(cx(...args));
|
|
70
|
+
}
|
|
71
|
+
var validDOMProperties = /* @__PURE__ */ new Set([
|
|
72
|
+
// Common HTML attributes
|
|
73
|
+
"accept",
|
|
74
|
+
"acceptCharset",
|
|
75
|
+
"accessKey",
|
|
76
|
+
"action",
|
|
77
|
+
"allowFullScreen",
|
|
78
|
+
"allowTransparency",
|
|
79
|
+
"alt",
|
|
80
|
+
"async",
|
|
81
|
+
"autoComplete",
|
|
82
|
+
"autoFocus",
|
|
83
|
+
"autoPlay",
|
|
84
|
+
"capture",
|
|
85
|
+
"cellPadding",
|
|
86
|
+
"cellSpacing",
|
|
87
|
+
"challenge",
|
|
88
|
+
"charSet",
|
|
89
|
+
"checked",
|
|
90
|
+
"cite",
|
|
91
|
+
"classID",
|
|
92
|
+
"className",
|
|
93
|
+
"colSpan",
|
|
94
|
+
"cols",
|
|
95
|
+
"content",
|
|
96
|
+
"contentEditable",
|
|
97
|
+
"contextMenu",
|
|
98
|
+
"controls",
|
|
99
|
+
"coords",
|
|
100
|
+
"crossOrigin",
|
|
101
|
+
"data",
|
|
102
|
+
"dateTime",
|
|
103
|
+
"default",
|
|
104
|
+
"defer",
|
|
105
|
+
"dir",
|
|
106
|
+
"disabled",
|
|
107
|
+
"download",
|
|
108
|
+
"draggable",
|
|
109
|
+
"encType",
|
|
110
|
+
"form",
|
|
111
|
+
"formAction",
|
|
112
|
+
"formEncType",
|
|
113
|
+
"formMethod",
|
|
114
|
+
"formNoValidate",
|
|
115
|
+
"formTarget",
|
|
116
|
+
"frameBorder",
|
|
117
|
+
"headers",
|
|
118
|
+
"height",
|
|
119
|
+
"hidden",
|
|
120
|
+
"high",
|
|
121
|
+
"href",
|
|
122
|
+
"hrefLang",
|
|
123
|
+
"htmlFor",
|
|
124
|
+
"httpEquiv",
|
|
125
|
+
"icon",
|
|
126
|
+
"id",
|
|
127
|
+
"inputMode",
|
|
128
|
+
"integrity",
|
|
129
|
+
"is",
|
|
130
|
+
"keyParams",
|
|
131
|
+
"keyType",
|
|
132
|
+
"kind",
|
|
133
|
+
"label",
|
|
134
|
+
"lang",
|
|
135
|
+
"list",
|
|
136
|
+
"loop",
|
|
137
|
+
"low",
|
|
138
|
+
"manifest",
|
|
139
|
+
"marginHeight",
|
|
140
|
+
"marginWidth",
|
|
141
|
+
"max",
|
|
142
|
+
"maxLength",
|
|
143
|
+
"media",
|
|
144
|
+
"mediaGroup",
|
|
145
|
+
"method",
|
|
146
|
+
"min",
|
|
147
|
+
"minLength",
|
|
148
|
+
"multiple",
|
|
149
|
+
"muted",
|
|
150
|
+
"name",
|
|
151
|
+
"noValidate",
|
|
152
|
+
"nonce",
|
|
153
|
+
"open",
|
|
154
|
+
"optimum",
|
|
155
|
+
"pattern",
|
|
156
|
+
"placeholder",
|
|
157
|
+
"poster",
|
|
158
|
+
"preload",
|
|
159
|
+
"profile",
|
|
160
|
+
"radioGroup",
|
|
161
|
+
"readOnly",
|
|
162
|
+
"referrerPolicy",
|
|
163
|
+
"rel",
|
|
164
|
+
"required",
|
|
165
|
+
"reversed",
|
|
166
|
+
"role",
|
|
167
|
+
"rowSpan",
|
|
168
|
+
"rows",
|
|
169
|
+
"sandbox",
|
|
170
|
+
"scope",
|
|
171
|
+
"scoped",
|
|
172
|
+
"scrolling",
|
|
173
|
+
"seamless",
|
|
174
|
+
"selected",
|
|
175
|
+
"shape",
|
|
176
|
+
"size",
|
|
177
|
+
"sizes",
|
|
178
|
+
"span",
|
|
179
|
+
"spellCheck",
|
|
180
|
+
"src",
|
|
181
|
+
"srcDoc",
|
|
182
|
+
"srcLang",
|
|
183
|
+
"srcSet",
|
|
184
|
+
"start",
|
|
185
|
+
"step",
|
|
186
|
+
"style",
|
|
187
|
+
"summary",
|
|
188
|
+
"tabIndex",
|
|
189
|
+
"target",
|
|
190
|
+
"title",
|
|
191
|
+
"type",
|
|
192
|
+
"useMap",
|
|
193
|
+
"value",
|
|
194
|
+
"width",
|
|
195
|
+
"wmode",
|
|
196
|
+
"wrap",
|
|
197
|
+
// Event handlers
|
|
198
|
+
"onCopy",
|
|
199
|
+
"onCut",
|
|
200
|
+
"onPaste",
|
|
201
|
+
"onCompositionEnd",
|
|
202
|
+
"onCompositionStart",
|
|
203
|
+
"onCompositionUpdate",
|
|
204
|
+
"onKeyDown",
|
|
205
|
+
"onKeyPress",
|
|
206
|
+
"onKeyUp",
|
|
207
|
+
"onFocus",
|
|
208
|
+
"onBlur",
|
|
209
|
+
"onChange",
|
|
210
|
+
"onInput",
|
|
211
|
+
"onInvalid",
|
|
212
|
+
"onSubmit",
|
|
213
|
+
"onClick",
|
|
214
|
+
"onContextMenu",
|
|
215
|
+
"onDoubleClick",
|
|
216
|
+
"onDrag",
|
|
217
|
+
"onDragEnd",
|
|
218
|
+
"onDragEnter",
|
|
219
|
+
"onDragExit",
|
|
220
|
+
"onDragLeave",
|
|
221
|
+
"onDragOver",
|
|
222
|
+
"onDragStart",
|
|
223
|
+
"onDrop",
|
|
224
|
+
"onMouseDown",
|
|
225
|
+
"onMouseEnter",
|
|
226
|
+
"onMouseLeave",
|
|
227
|
+
"onMouseMove",
|
|
228
|
+
"onMouseOut",
|
|
229
|
+
"onMouseOver",
|
|
230
|
+
"onMouseUp",
|
|
231
|
+
"onSelect",
|
|
232
|
+
"onTouchCancel",
|
|
233
|
+
"onTouchEnd",
|
|
234
|
+
"onTouchMove",
|
|
235
|
+
"onTouchStart",
|
|
236
|
+
"onScroll",
|
|
237
|
+
"onWheel",
|
|
238
|
+
"onAbort",
|
|
239
|
+
"onCanPlay",
|
|
240
|
+
"onCanPlayThrough",
|
|
241
|
+
"onDurationChange",
|
|
242
|
+
"onEmptied",
|
|
243
|
+
"onEncrypted",
|
|
244
|
+
"onEnded",
|
|
245
|
+
"onError",
|
|
246
|
+
"onLoadedData",
|
|
247
|
+
"onLoadedMetadata",
|
|
248
|
+
"onLoadStart",
|
|
249
|
+
"onPause",
|
|
250
|
+
"onPlay",
|
|
251
|
+
"onPlaying",
|
|
252
|
+
"onProgress",
|
|
253
|
+
"onRateChange",
|
|
254
|
+
"onSeeked",
|
|
255
|
+
"onSeeking",
|
|
256
|
+
"onStalled",
|
|
257
|
+
"onSuspend",
|
|
258
|
+
"onTimeUpdate",
|
|
259
|
+
"onVolumeChange",
|
|
260
|
+
"onWaiting",
|
|
261
|
+
"onLoad",
|
|
262
|
+
"onAnimationStart",
|
|
263
|
+
"onAnimationEnd",
|
|
264
|
+
"onAnimationIteration",
|
|
265
|
+
"onTransitionEnd",
|
|
266
|
+
"onToggle"
|
|
267
|
+
]);
|
|
268
|
+
function filterDOMProps(props) {
|
|
269
|
+
const newProps = {};
|
|
270
|
+
for (const key in props) {
|
|
271
|
+
if (!key.startsWith("data-") && !validDOMProperties.has(key)) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
newProps[key] = props[key];
|
|
275
|
+
}
|
|
276
|
+
return newProps;
|
|
277
|
+
}
|
|
278
|
+
function InputLabel({
|
|
279
|
+
ref,
|
|
280
|
+
color,
|
|
281
|
+
className,
|
|
282
|
+
children,
|
|
283
|
+
...props
|
|
284
|
+
}) {
|
|
285
|
+
const [merged, mergedRef] = useContextProps(
|
|
286
|
+
props,
|
|
287
|
+
ref ?? null,
|
|
288
|
+
LabelContext
|
|
289
|
+
);
|
|
290
|
+
const { elementType: ElementType = "label", ...labelProps } = merged;
|
|
291
|
+
return /* @__PURE__ */ React36.createElement(
|
|
292
|
+
ElementType,
|
|
293
|
+
{
|
|
294
|
+
...labelProps,
|
|
295
|
+
ref: mergedRef,
|
|
296
|
+
"data-color": color,
|
|
297
|
+
className: cn("prt-input-label", className)
|
|
298
|
+
},
|
|
299
|
+
children
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
function InputError({
|
|
303
|
+
children,
|
|
304
|
+
validationStatus = "error",
|
|
305
|
+
className,
|
|
306
|
+
...props
|
|
307
|
+
}) {
|
|
308
|
+
return /* @__PURE__ */ React36.createElement(
|
|
309
|
+
FieldError,
|
|
310
|
+
{
|
|
311
|
+
...props,
|
|
312
|
+
elementType: "div",
|
|
313
|
+
className: cn("prt-input-error", className),
|
|
314
|
+
"data-validation-status": validationStatus
|
|
315
|
+
},
|
|
316
|
+
children
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
var SpaceContext = React36.createContext({ classNames: {}, compactItemWrapperAdjust: "" });
|
|
320
|
+
var GAP_CLASS = {
|
|
321
|
+
none: "gap-0",
|
|
322
|
+
"4xs": "gap-0.5",
|
|
323
|
+
"3xs": "gap-1",
|
|
324
|
+
"2xs": "gap-2",
|
|
325
|
+
xs: "gap-2.5",
|
|
326
|
+
sm: "gap-3",
|
|
327
|
+
md: "gap-3.5",
|
|
328
|
+
lg: "gap-4",
|
|
329
|
+
xl: "gap-6",
|
|
330
|
+
"2xl": "gap-8",
|
|
331
|
+
"3xl": "gap-10",
|
|
332
|
+
"4xl": "gap-12"
|
|
333
|
+
};
|
|
334
|
+
function Space({
|
|
335
|
+
children,
|
|
336
|
+
compact,
|
|
337
|
+
gap = "none",
|
|
338
|
+
stack,
|
|
339
|
+
className,
|
|
340
|
+
classNames,
|
|
341
|
+
style,
|
|
342
|
+
styles
|
|
343
|
+
}) {
|
|
344
|
+
const childrenCount = React36.Children.count(children);
|
|
345
|
+
const nodes = React36.useMemo(() => {
|
|
346
|
+
return React36.Children.map(children, (child, index) => {
|
|
347
|
+
const isFirstChild = index == 0;
|
|
348
|
+
const isLastChild = index == childrenCount - 1;
|
|
349
|
+
if (!React36.isValidElement(child)) return null;
|
|
350
|
+
return /* @__PURE__ */ React36.createElement(
|
|
351
|
+
SpaceContext.Provider,
|
|
352
|
+
{
|
|
353
|
+
value: {
|
|
354
|
+
classNames: {
|
|
355
|
+
"space-item-first": isFirstChild,
|
|
356
|
+
"space-item-last": isLastChild,
|
|
357
|
+
"space-item": true
|
|
358
|
+
},
|
|
359
|
+
compactItemWrapperAdjust: isLastChild ? "" : "compact-item-wrapper-adjust"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
child
|
|
363
|
+
);
|
|
364
|
+
});
|
|
365
|
+
}, [children]);
|
|
366
|
+
return /* @__PURE__ */ React36.createElement(
|
|
367
|
+
"div",
|
|
368
|
+
{
|
|
369
|
+
"data-compact": compact,
|
|
370
|
+
style: { ...style, ...styles?.wrapper },
|
|
371
|
+
className: cn(
|
|
372
|
+
"prt-space flex",
|
|
373
|
+
stack ? "flex-col" : "flex-row",
|
|
374
|
+
GAP_CLASS[gap],
|
|
375
|
+
className,
|
|
376
|
+
classNames?.wrapper
|
|
377
|
+
)
|
|
378
|
+
},
|
|
379
|
+
nodes
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
function useSpace() {
|
|
383
|
+
return React36.useContext(SpaceContext);
|
|
384
|
+
}
|
|
385
|
+
var ThemeContext = React36.createContext(null);
|
|
386
|
+
function ThemeProvider(props) {
|
|
387
|
+
const { children, className, ...themeProps } = props;
|
|
388
|
+
return /* @__PURE__ */ React36.createElement(ThemeContext.Provider, { value: themeProps }, /* @__PURE__ */ React36.createElement(
|
|
389
|
+
"div",
|
|
390
|
+
{
|
|
391
|
+
"data-theme": themeProps.appearance,
|
|
392
|
+
"data-radius": themeProps.radius,
|
|
393
|
+
"data-color": themeProps.color,
|
|
394
|
+
className: cn("parrot-theme", className)
|
|
395
|
+
},
|
|
396
|
+
children
|
|
397
|
+
));
|
|
398
|
+
}
|
|
399
|
+
function useTheme(options) {
|
|
400
|
+
const theme = React36.useContext(ThemeContext);
|
|
401
|
+
if (!theme && options?.requireThemeProvider)
|
|
402
|
+
throw new Error("No theme found");
|
|
403
|
+
return theme;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/components/form/field.tsx
|
|
407
|
+
function Field({
|
|
408
|
+
label,
|
|
409
|
+
description,
|
|
410
|
+
error,
|
|
411
|
+
color = "gray",
|
|
412
|
+
radius,
|
|
413
|
+
size = "md",
|
|
414
|
+
className,
|
|
415
|
+
classNames,
|
|
416
|
+
style,
|
|
417
|
+
styles,
|
|
418
|
+
prepend,
|
|
419
|
+
append,
|
|
420
|
+
appearance = "outline",
|
|
421
|
+
validationStatus,
|
|
422
|
+
children,
|
|
423
|
+
replaceDefaultControlWrapper,
|
|
424
|
+
isDisabled,
|
|
425
|
+
wrapperRef,
|
|
426
|
+
...props
|
|
427
|
+
}) {
|
|
428
|
+
const space = useSpace();
|
|
429
|
+
const theme = useTheme();
|
|
430
|
+
const controlRef = React36__default.useRef(null);
|
|
431
|
+
const [, groupRef] = useContextProps({}, controlRef, GroupContext);
|
|
432
|
+
return /* @__PURE__ */ React36__default.createElement(
|
|
433
|
+
"div",
|
|
434
|
+
{
|
|
435
|
+
ref: wrapperRef,
|
|
436
|
+
...filterDOMProps(props),
|
|
437
|
+
"data-color": color,
|
|
438
|
+
"data-radius": radius ?? theme?.radius ?? "lg",
|
|
439
|
+
"data-size": size,
|
|
440
|
+
className: cn(
|
|
441
|
+
"prt-input-group flex flex-col gap-1",
|
|
442
|
+
space.compactItemWrapperAdjust,
|
|
443
|
+
className,
|
|
444
|
+
classNames?.wrapper
|
|
445
|
+
),
|
|
446
|
+
style: { ...style, ...styles?.wrapper }
|
|
447
|
+
},
|
|
448
|
+
label && /* @__PURE__ */ React36__default.createElement(
|
|
449
|
+
InputLabel,
|
|
450
|
+
{
|
|
451
|
+
style: styles?.label,
|
|
452
|
+
className: classNames?.label,
|
|
453
|
+
color
|
|
454
|
+
},
|
|
455
|
+
label
|
|
456
|
+
),
|
|
457
|
+
!replaceDefaultControlWrapper && /* @__PURE__ */ React36__default.createElement(
|
|
458
|
+
"div",
|
|
459
|
+
{
|
|
460
|
+
ref: groupRef,
|
|
461
|
+
className: cn(
|
|
462
|
+
"prt-input-control relative inline-flex w-full items-center",
|
|
463
|
+
space.classNames
|
|
464
|
+
),
|
|
465
|
+
"data-has-error": !!error,
|
|
466
|
+
"data-appearance": appearance,
|
|
467
|
+
"data-disabled": isDisabled
|
|
468
|
+
},
|
|
469
|
+
prepend && /* @__PURE__ */ React36__default.createElement("div", { className: "add-on add-on-left flex items-center" }, prepend),
|
|
470
|
+
children,
|
|
471
|
+
append && /* @__PURE__ */ React36__default.createElement("div", { className: "add-on add-on-right flex items-center" }, append)
|
|
472
|
+
),
|
|
473
|
+
replaceDefaultControlWrapper && children,
|
|
474
|
+
error && /* @__PURE__ */ React36__default.createElement(InputError, { validationStatus }, error),
|
|
475
|
+
description && /* @__PURE__ */ React36__default.createElement(
|
|
476
|
+
FieldDescription,
|
|
477
|
+
{
|
|
478
|
+
style: styles?.description,
|
|
479
|
+
className: classNames?.description
|
|
480
|
+
},
|
|
481
|
+
description
|
|
482
|
+
)
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
Field.displayName = "Field";
|
|
486
|
+
function FieldDescription({
|
|
487
|
+
children,
|
|
488
|
+
className,
|
|
489
|
+
style
|
|
490
|
+
}) {
|
|
491
|
+
const [merged, ref] = useContextProps(
|
|
492
|
+
{ slot: "description" },
|
|
493
|
+
null,
|
|
494
|
+
TextContext
|
|
495
|
+
);
|
|
496
|
+
return /* @__PURE__ */ React36__default.createElement(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
...merged,
|
|
500
|
+
ref,
|
|
501
|
+
className: cn("prt-input-description", className),
|
|
502
|
+
style
|
|
503
|
+
},
|
|
504
|
+
children
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/components/input/input.tsx
|
|
509
|
+
function Input({
|
|
510
|
+
className,
|
|
511
|
+
classNames,
|
|
512
|
+
style,
|
|
513
|
+
styles,
|
|
514
|
+
onChange,
|
|
515
|
+
inputRef,
|
|
516
|
+
wrapperRef,
|
|
517
|
+
prepend,
|
|
518
|
+
append,
|
|
519
|
+
label,
|
|
520
|
+
description,
|
|
521
|
+
error,
|
|
522
|
+
color,
|
|
523
|
+
size,
|
|
524
|
+
radius,
|
|
525
|
+
appearance,
|
|
526
|
+
validationStatus,
|
|
527
|
+
shape,
|
|
528
|
+
placeholder,
|
|
529
|
+
...textFieldProps
|
|
530
|
+
}) {
|
|
531
|
+
return /* @__PURE__ */ React36.createElement(TextField, { ...textFieldProps, onChange, isInvalid: !!error }, /* @__PURE__ */ React36.createElement(
|
|
532
|
+
Field,
|
|
533
|
+
{
|
|
534
|
+
className,
|
|
535
|
+
classNames,
|
|
536
|
+
styles,
|
|
537
|
+
style,
|
|
538
|
+
wrapperRef,
|
|
539
|
+
prepend,
|
|
540
|
+
append,
|
|
541
|
+
label,
|
|
542
|
+
description,
|
|
543
|
+
error,
|
|
544
|
+
color,
|
|
545
|
+
size,
|
|
546
|
+
radius,
|
|
547
|
+
appearance,
|
|
548
|
+
validationStatus
|
|
549
|
+
},
|
|
550
|
+
/* @__PURE__ */ React36.createElement(
|
|
551
|
+
Input$1,
|
|
552
|
+
{
|
|
553
|
+
ref: inputRef,
|
|
554
|
+
placeholder,
|
|
555
|
+
"data-has-left-addon": !!prepend,
|
|
556
|
+
"data-has-right-addon": !!append,
|
|
557
|
+
style: styles?.input,
|
|
558
|
+
className: cn("prt-text-input-el", classNames?.input)
|
|
559
|
+
}
|
|
560
|
+
)
|
|
561
|
+
));
|
|
562
|
+
}
|
|
563
|
+
function Loader({
|
|
564
|
+
color,
|
|
565
|
+
className,
|
|
566
|
+
classNames,
|
|
567
|
+
style,
|
|
568
|
+
styles,
|
|
569
|
+
size = "sm",
|
|
570
|
+
label = "Loading",
|
|
571
|
+
ref,
|
|
572
|
+
...props
|
|
573
|
+
}) {
|
|
574
|
+
const theme = useTheme();
|
|
575
|
+
const resolvedColor = color ?? theme?.color;
|
|
576
|
+
const id2 = React36.useId();
|
|
577
|
+
return /* @__PURE__ */ React36.createElement(
|
|
578
|
+
"div",
|
|
579
|
+
{
|
|
580
|
+
"data-color": resolvedColor,
|
|
581
|
+
className: cn("prt-loader", className, classNames?.wrapper),
|
|
582
|
+
style: { ...style, ...styles?.wrapper },
|
|
583
|
+
role: "status",
|
|
584
|
+
"aria-label": label,
|
|
585
|
+
ref,
|
|
586
|
+
...props
|
|
587
|
+
},
|
|
588
|
+
/* @__PURE__ */ React36.createElement(
|
|
589
|
+
"svg",
|
|
590
|
+
{
|
|
591
|
+
className: cn("prt-loader-icon", classNames?.icon),
|
|
592
|
+
style: styles?.icon,
|
|
593
|
+
"data-size": size,
|
|
594
|
+
viewBox: "0 0 24 24",
|
|
595
|
+
"aria-hidden": "true"
|
|
596
|
+
},
|
|
597
|
+
/* @__PURE__ */ React36.createElement("defs", null, /* @__PURE__ */ React36.createElement(
|
|
598
|
+
"linearGradient",
|
|
599
|
+
{
|
|
600
|
+
id: `${id2}-a`,
|
|
601
|
+
x1: "50%",
|
|
602
|
+
x2: "50%",
|
|
603
|
+
y1: "5.271%",
|
|
604
|
+
y2: "91.793%"
|
|
605
|
+
},
|
|
606
|
+
/* @__PURE__ */ React36.createElement("stop", { offset: "0%", stopColor: "currentColor" }),
|
|
607
|
+
/* @__PURE__ */ React36.createElement("stop", { offset: "100%", stopColor: "currentColor", stopOpacity: "0.55" })
|
|
608
|
+
), /* @__PURE__ */ React36.createElement(
|
|
609
|
+
"linearGradient",
|
|
610
|
+
{
|
|
611
|
+
id: `${id2}-b`,
|
|
612
|
+
x1: "50%",
|
|
613
|
+
x2: "50%",
|
|
614
|
+
y1: "15.24%",
|
|
615
|
+
y2: "87.15%"
|
|
616
|
+
},
|
|
617
|
+
/* @__PURE__ */ React36.createElement("stop", { offset: "0%", stopColor: "currentColor", stopOpacity: "0" }),
|
|
618
|
+
/* @__PURE__ */ React36.createElement("stop", { offset: "100%", stopColor: "currentColor", stopOpacity: "0.55" })
|
|
619
|
+
)),
|
|
620
|
+
/* @__PURE__ */ React36.createElement("g", { fill: "none" }, /* @__PURE__ */ React36.createElement(
|
|
621
|
+
"path",
|
|
622
|
+
{
|
|
623
|
+
d: "M8.749.021a1.5 1.5 0 0 1 .497 2.958A7.5 7.5 0 0 0 3 10.375a7.5 7.5 0 0 0 7.5 7.5v3c-5.799 0-10.5-4.7-10.5-10.5C0 5.23 3.726.865 8.749.021",
|
|
624
|
+
fill: `url(#${id2}-a)`,
|
|
625
|
+
transform: "translate(1.5 1.625)"
|
|
626
|
+
}
|
|
627
|
+
), /* @__PURE__ */ React36.createElement(
|
|
628
|
+
"path",
|
|
629
|
+
{
|
|
630
|
+
d: "M15.392 2.673a1.5 1.5 0 0 1 2.119-.115A10.48 10.48 0 0 1 21 10.375c0 5.8-4.701 10.5-10.5 10.5v-3a7.5 7.5 0 0 0 5.007-13.084a1.5 1.5 0 0 1-.115-2.118",
|
|
631
|
+
fill: `url(#${id2}-b)`,
|
|
632
|
+
transform: "translate(1.5 1.625)"
|
|
633
|
+
}
|
|
634
|
+
))
|
|
635
|
+
)
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/utils/object.ts
|
|
640
|
+
function omitNullOrUndefined(object) {
|
|
641
|
+
return Object.keys(object).reduce((obj, key) => {
|
|
642
|
+
if (object[key] == null) {
|
|
643
|
+
return { ...obj };
|
|
644
|
+
}
|
|
645
|
+
return {
|
|
646
|
+
...obj,
|
|
647
|
+
[key]: object[key]
|
|
648
|
+
};
|
|
649
|
+
}, {});
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// src/components/button/button-group.tsx
|
|
653
|
+
var ButtonGroupContext = React36.createContext({});
|
|
654
|
+
function ButtonGroup({
|
|
655
|
+
color,
|
|
656
|
+
variant,
|
|
657
|
+
size,
|
|
658
|
+
compact,
|
|
659
|
+
radius,
|
|
660
|
+
gap,
|
|
661
|
+
children,
|
|
662
|
+
className,
|
|
663
|
+
classNames,
|
|
664
|
+
style,
|
|
665
|
+
styles
|
|
666
|
+
}) {
|
|
667
|
+
const cleanProps = omitNullOrUndefined({
|
|
668
|
+
color,
|
|
669
|
+
variant,
|
|
670
|
+
size,
|
|
671
|
+
radius
|
|
672
|
+
});
|
|
673
|
+
return /* @__PURE__ */ React36.createElement(ButtonGroupContext.Provider, { value: cleanProps }, /* @__PURE__ */ React36.createElement(
|
|
674
|
+
Space,
|
|
675
|
+
{
|
|
676
|
+
className,
|
|
677
|
+
classNames,
|
|
678
|
+
style,
|
|
679
|
+
styles,
|
|
680
|
+
gap,
|
|
681
|
+
compact
|
|
682
|
+
},
|
|
683
|
+
children
|
|
684
|
+
));
|
|
685
|
+
}
|
|
686
|
+
function useButtonGroup() {
|
|
687
|
+
return React36.useContext(ButtonGroupContext);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// src/components/button/button.tsx
|
|
691
|
+
function Button(props) {
|
|
692
|
+
const space = useSpace();
|
|
693
|
+
const buttonGroupProps = useButtonGroup();
|
|
694
|
+
const theme = useTheme();
|
|
695
|
+
const {
|
|
696
|
+
color = theme?.color ?? "primary",
|
|
697
|
+
variant = "solid",
|
|
698
|
+
append,
|
|
699
|
+
prepend,
|
|
700
|
+
size = "md",
|
|
701
|
+
children,
|
|
702
|
+
className,
|
|
703
|
+
isLoading,
|
|
704
|
+
radius = "full",
|
|
705
|
+
isIconButton,
|
|
706
|
+
style,
|
|
707
|
+
classNames,
|
|
708
|
+
styles,
|
|
709
|
+
...otherProps
|
|
710
|
+
} = { ...buttonGroupProps, ...props };
|
|
711
|
+
return /* @__PURE__ */ React36.createElement(
|
|
712
|
+
Button$1,
|
|
713
|
+
{
|
|
714
|
+
style: { ...style, ...styles?.wrapper },
|
|
715
|
+
"data-size": size,
|
|
716
|
+
"data-radius": radius,
|
|
717
|
+
"data-icon-button": isIconButton,
|
|
718
|
+
"data-loading": isLoading,
|
|
719
|
+
"aria-busy": isLoading,
|
|
720
|
+
"data-color": color,
|
|
721
|
+
"data-variant": variant,
|
|
722
|
+
className: cn(
|
|
723
|
+
"prt-button prt-size",
|
|
724
|
+
space.classNames,
|
|
725
|
+
className,
|
|
726
|
+
classNames?.wrapper
|
|
727
|
+
),
|
|
728
|
+
...otherProps
|
|
729
|
+
},
|
|
730
|
+
prepend,
|
|
731
|
+
isIconButton && isLoading ? null : children,
|
|
732
|
+
isLoading ? /* @__PURE__ */ React36.createElement(
|
|
733
|
+
Loader,
|
|
734
|
+
{
|
|
735
|
+
color,
|
|
736
|
+
className: cn("prt-button-loader", classNames?.loader),
|
|
737
|
+
style: styles?.loader,
|
|
738
|
+
size: "xs"
|
|
739
|
+
}
|
|
740
|
+
) : append
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
function IconButton({ children, ...props }) {
|
|
744
|
+
return /* @__PURE__ */ React36__default.createElement(Button, { isIconButton: true, ...props }, children);
|
|
745
|
+
}
|
|
746
|
+
var ToggleButtonGroupContext = React36.createContext({});
|
|
747
|
+
function ToggleButton({
|
|
748
|
+
idleColor,
|
|
749
|
+
idleVariant,
|
|
750
|
+
activeColor,
|
|
751
|
+
activeVariant,
|
|
752
|
+
append,
|
|
753
|
+
prepend,
|
|
754
|
+
size,
|
|
755
|
+
radius,
|
|
756
|
+
isIconButton,
|
|
757
|
+
className,
|
|
758
|
+
classNames,
|
|
759
|
+
style,
|
|
760
|
+
styles,
|
|
761
|
+
children,
|
|
762
|
+
...props
|
|
763
|
+
}) {
|
|
764
|
+
const space = useSpace();
|
|
765
|
+
const theme = useTheme();
|
|
766
|
+
const group = React36.useContext(ToggleButtonGroupContext);
|
|
767
|
+
const _idleColor = idleColor ?? group.idleColor ?? "gray";
|
|
768
|
+
const _idleVariant = idleVariant ?? group.idleVariant ?? "outline";
|
|
769
|
+
const _activeColor = activeColor ?? group.activeColor ?? theme?.color ?? "primary";
|
|
770
|
+
const _activeVariant = activeVariant ?? group.activeVariant ?? "solid";
|
|
771
|
+
const _size = size ?? group.size ?? "md";
|
|
772
|
+
const _radius = radius ?? group.radius ?? "full";
|
|
773
|
+
const _isIconButton = isIconButton ?? group.isIconButton;
|
|
774
|
+
return /* @__PURE__ */ React36.createElement(
|
|
775
|
+
ToggleButton$1,
|
|
776
|
+
{
|
|
777
|
+
...props,
|
|
778
|
+
className: cn(
|
|
779
|
+
"prt-button prt-size",
|
|
780
|
+
space.classNames,
|
|
781
|
+
className,
|
|
782
|
+
classNames?.wrapper
|
|
783
|
+
),
|
|
784
|
+
style: { ...style, ...styles?.wrapper },
|
|
785
|
+
render: (domProps, { isSelected }) => /* @__PURE__ */ React36.createElement(
|
|
786
|
+
"button",
|
|
787
|
+
{
|
|
788
|
+
...domProps,
|
|
789
|
+
"data-is-toggle": "true",
|
|
790
|
+
"data-size": _size,
|
|
791
|
+
"data-radius": _radius,
|
|
792
|
+
"data-icon-button": _isIconButton,
|
|
793
|
+
"data-color": isSelected ? _activeColor : _idleColor,
|
|
794
|
+
"data-variant": isSelected ? _activeVariant : _idleVariant
|
|
795
|
+
},
|
|
796
|
+
prepend,
|
|
797
|
+
children,
|
|
798
|
+
append
|
|
799
|
+
)
|
|
800
|
+
}
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// src/components/input/number-input.tsx
|
|
805
|
+
function NumberInput({
|
|
806
|
+
appearance = "outline",
|
|
807
|
+
size = "md",
|
|
808
|
+
color = "gray",
|
|
809
|
+
classNames,
|
|
810
|
+
styles,
|
|
811
|
+
append,
|
|
812
|
+
prepend,
|
|
813
|
+
placeholder,
|
|
814
|
+
showSteppers = false,
|
|
815
|
+
error,
|
|
816
|
+
label,
|
|
817
|
+
description,
|
|
818
|
+
incrementIcon,
|
|
819
|
+
decrementIcon,
|
|
820
|
+
inputRef,
|
|
821
|
+
wrapperRef,
|
|
822
|
+
validationStatus,
|
|
823
|
+
shape,
|
|
824
|
+
radius,
|
|
825
|
+
...props
|
|
826
|
+
}) {
|
|
827
|
+
const space = useSpace();
|
|
828
|
+
return /* @__PURE__ */ React36.createElement(
|
|
829
|
+
NumberField,
|
|
830
|
+
{
|
|
831
|
+
...props,
|
|
832
|
+
isInvalid: !!error,
|
|
833
|
+
"aria-label": props["aria-label"] ?? "number input"
|
|
834
|
+
},
|
|
835
|
+
/* @__PURE__ */ React36.createElement(
|
|
836
|
+
Field,
|
|
837
|
+
{
|
|
838
|
+
classNames,
|
|
839
|
+
color,
|
|
840
|
+
size,
|
|
841
|
+
radius,
|
|
842
|
+
error,
|
|
843
|
+
label,
|
|
844
|
+
description,
|
|
845
|
+
validationStatus,
|
|
846
|
+
replaceDefaultControlWrapper: true
|
|
847
|
+
},
|
|
848
|
+
/* @__PURE__ */ React36.createElement(Group, { className: "prt-input-container", style: { display: "flex", gap: 4 } }, showSteppers && /* @__PURE__ */ React36.createElement(
|
|
849
|
+
IconButton,
|
|
850
|
+
{
|
|
851
|
+
slot: "decrement",
|
|
852
|
+
radius: "md",
|
|
853
|
+
color,
|
|
854
|
+
variant: "outline",
|
|
855
|
+
size,
|
|
856
|
+
className: classNames?.decrement,
|
|
857
|
+
style: styles?.decrement
|
|
858
|
+
},
|
|
859
|
+
decrementIcon
|
|
860
|
+
), /* @__PURE__ */ React36.createElement(
|
|
861
|
+
Input$1,
|
|
862
|
+
{
|
|
863
|
+
style: styles?.input,
|
|
864
|
+
ref: inputRef,
|
|
865
|
+
placeholder,
|
|
866
|
+
className: cn(
|
|
867
|
+
classNames?.input,
|
|
868
|
+
"prt-input-control",
|
|
869
|
+
"space-item",
|
|
870
|
+
space.classNames
|
|
871
|
+
),
|
|
872
|
+
"data-appearance": appearance,
|
|
873
|
+
"data-has-left-addon": !!prepend,
|
|
874
|
+
"data-has-right-addon": !!append
|
|
875
|
+
}
|
|
876
|
+
), showSteppers && /* @__PURE__ */ React36.createElement(
|
|
877
|
+
IconButton,
|
|
878
|
+
{
|
|
879
|
+
slot: "increment",
|
|
880
|
+
radius: "md",
|
|
881
|
+
color,
|
|
882
|
+
variant: "outline",
|
|
883
|
+
size,
|
|
884
|
+
className: classNames?.increment,
|
|
885
|
+
style: styles?.increment
|
|
886
|
+
},
|
|
887
|
+
incrementIcon
|
|
888
|
+
))
|
|
889
|
+
)
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
function HiCheck({ size = "1em", ...props }) {
|
|
893
|
+
return /* @__PURE__ */ React36.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }));
|
|
894
|
+
}
|
|
895
|
+
function HiChevronDown({ size = "1em", ...props }) {
|
|
896
|
+
return /* @__PURE__ */ React36.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { fillRule: "evenodd", d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z", clipRule: "evenodd" }));
|
|
897
|
+
}
|
|
898
|
+
function HiChevronLeft({ size = "1em", ...props }) {
|
|
899
|
+
return /* @__PURE__ */ React36.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { fillRule: "evenodd", d: "M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z", clipRule: "evenodd" }));
|
|
900
|
+
}
|
|
901
|
+
function HiChevronRight({ size = "1em", ...props }) {
|
|
902
|
+
return /* @__PURE__ */ React36.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { fillRule: "evenodd", d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", clipRule: "evenodd" }));
|
|
903
|
+
}
|
|
904
|
+
function HiChevronUp({ size = "1em", ...props }) {
|
|
905
|
+
return /* @__PURE__ */ React36.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { fillRule: "evenodd", d: "M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z", clipRule: "evenodd" }));
|
|
906
|
+
}
|
|
907
|
+
function HiOutlineCalendar({ size = "1em", ...props }) {
|
|
908
|
+
return /* @__PURE__ */ React36.createElement("svg", { fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }));
|
|
909
|
+
}
|
|
910
|
+
function HiOutlineCheckCircle({ size = "1em", ...props }) {
|
|
911
|
+
return /* @__PURE__ */ React36.createElement("svg", { fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }));
|
|
912
|
+
}
|
|
913
|
+
function HiOutlineDocumentAdd({ size = "1em", ...props }) {
|
|
914
|
+
return /* @__PURE__ */ React36.createElement("svg", { fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }));
|
|
915
|
+
}
|
|
916
|
+
function HiOutlineExclamationCircle({ size = "1em", ...props }) {
|
|
917
|
+
return /* @__PURE__ */ React36.createElement("svg", { fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }));
|
|
918
|
+
}
|
|
919
|
+
function HiOutlinePaperClip({ size = "1em", ...props }) {
|
|
920
|
+
return /* @__PURE__ */ React36.createElement("svg", { fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" }));
|
|
921
|
+
}
|
|
922
|
+
function HiOutlineRefresh({ size = "1em", ...props }) {
|
|
923
|
+
return /* @__PURE__ */ React36.createElement("svg", { fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }));
|
|
924
|
+
}
|
|
925
|
+
function HiOutlineTrash({ size = "1em", ...props }) {
|
|
926
|
+
return /* @__PURE__ */ React36.createElement("svg", { fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" }));
|
|
927
|
+
}
|
|
928
|
+
function HiSelector({ size = "1em", ...props }) {
|
|
929
|
+
return /* @__PURE__ */ React36.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { fillRule: "evenodd", d: "M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z", clipRule: "evenodd" }));
|
|
930
|
+
}
|
|
931
|
+
function HiX({ size = "1em", ...props }) {
|
|
932
|
+
return /* @__PURE__ */ React36.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", width: size, height: size, ...props }, /* @__PURE__ */ React36.createElement("path", { fillRule: "evenodd", d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z", clipRule: "evenodd" }));
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// src/utils/theme.ts
|
|
936
|
+
var supportedColors = [
|
|
937
|
+
"red",
|
|
938
|
+
"orange",
|
|
939
|
+
"amber",
|
|
940
|
+
"yellow",
|
|
941
|
+
"lime",
|
|
942
|
+
"green",
|
|
943
|
+
"emerald",
|
|
944
|
+
"teal",
|
|
945
|
+
"cyan",
|
|
946
|
+
"sky",
|
|
947
|
+
"blue",
|
|
948
|
+
"indigo",
|
|
949
|
+
"violet",
|
|
950
|
+
"purple",
|
|
951
|
+
"fuchsia",
|
|
952
|
+
"pink",
|
|
953
|
+
"rose",
|
|
954
|
+
"slate",
|
|
955
|
+
"gray",
|
|
956
|
+
"zinc",
|
|
957
|
+
"neutral",
|
|
958
|
+
"stone"
|
|
959
|
+
];
|
|
960
|
+
|
|
961
|
+
// src/utils/helpers.ts
|
|
962
|
+
function warnDeprecation(deprecatedProp, newProp, value) {
|
|
963
|
+
if (!isUndefinedOrNull(value)) {
|
|
964
|
+
console.warn(
|
|
965
|
+
`${deprecatedProp} is deprecated and will be removed in a future release. ${`Please use ${newProp} instead.` }`
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function hashCode(text) {
|
|
970
|
+
const str = String(text);
|
|
971
|
+
let hash = 0;
|
|
972
|
+
let char;
|
|
973
|
+
if (str.trim().length === 0) return hash;
|
|
974
|
+
for (let i = 0; i < str.length; i++) {
|
|
975
|
+
char = str.charCodeAt(i);
|
|
976
|
+
hash = (hash << 5) - hash + char;
|
|
977
|
+
hash &= hash;
|
|
978
|
+
}
|
|
979
|
+
return Math.abs(hash);
|
|
980
|
+
}
|
|
981
|
+
function id() {
|
|
982
|
+
return Math.random().toString(36);
|
|
983
|
+
}
|
|
984
|
+
function getRandomColor(string) {
|
|
985
|
+
const hash = hashCode(string);
|
|
986
|
+
return supportedColors[hash % supportedColors.length];
|
|
987
|
+
}
|
|
988
|
+
function breakpointClassNames(prefix, value) {
|
|
989
|
+
if (!value) return "";
|
|
990
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
991
|
+
return `${prefix}-${value}`;
|
|
992
|
+
}
|
|
993
|
+
let classNames = "";
|
|
994
|
+
for (const key of Object.keys(value)) {
|
|
995
|
+
const breakpoint = key;
|
|
996
|
+
const breakpointValue = value[breakpoint];
|
|
997
|
+
if (breakpointValue) {
|
|
998
|
+
classNames && (classNames += " ");
|
|
999
|
+
classNames += breakpoint === "base" ? `${prefix}-${breakpointValue}` : `${breakpoint}:${prefix}-${breakpointValue}`;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return classNames;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
// src/components/text/text.tsx
|
|
1006
|
+
function Text({
|
|
1007
|
+
textCase,
|
|
1008
|
+
size = "sm",
|
|
1009
|
+
weight,
|
|
1010
|
+
color = "gray",
|
|
1011
|
+
variant = "default",
|
|
1012
|
+
highlight,
|
|
1013
|
+
align,
|
|
1014
|
+
lineHeight,
|
|
1015
|
+
underline,
|
|
1016
|
+
italic,
|
|
1017
|
+
as: Comp = "span",
|
|
1018
|
+
className,
|
|
1019
|
+
...rest
|
|
1020
|
+
}) {
|
|
1021
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1022
|
+
Comp,
|
|
1023
|
+
{
|
|
1024
|
+
className: cn(
|
|
1025
|
+
"prt-text",
|
|
1026
|
+
className,
|
|
1027
|
+
{
|
|
1028
|
+
[`text-highlight`]: !!highlight,
|
|
1029
|
+
[`text-weight-${weight}`]: !!weight,
|
|
1030
|
+
[`text-align-${align}`]: !!align,
|
|
1031
|
+
[`text-line-height-${lineHeight}`]: !!lineHeight,
|
|
1032
|
+
[`text-transform-${textCase}`]: !!textCase
|
|
1033
|
+
},
|
|
1034
|
+
breakpointClassNames("text-size", size)
|
|
1035
|
+
),
|
|
1036
|
+
"data-underline": underline,
|
|
1037
|
+
"data-italic": italic,
|
|
1038
|
+
"data-color": color,
|
|
1039
|
+
"data-color-variant": variant,
|
|
1040
|
+
...rest
|
|
1041
|
+
}
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
function Textarea({
|
|
1045
|
+
appearance = "outline",
|
|
1046
|
+
resize,
|
|
1047
|
+
label,
|
|
1048
|
+
description,
|
|
1049
|
+
error,
|
|
1050
|
+
color = "gray",
|
|
1051
|
+
radius,
|
|
1052
|
+
size,
|
|
1053
|
+
className,
|
|
1054
|
+
classNames,
|
|
1055
|
+
styles,
|
|
1056
|
+
style,
|
|
1057
|
+
prepend,
|
|
1058
|
+
append,
|
|
1059
|
+
validationStatus,
|
|
1060
|
+
shape,
|
|
1061
|
+
inputRef,
|
|
1062
|
+
wrapperRef,
|
|
1063
|
+
placeholder,
|
|
1064
|
+
rows,
|
|
1065
|
+
isDisabled,
|
|
1066
|
+
...textFieldProps
|
|
1067
|
+
}) {
|
|
1068
|
+
const theme = useTheme();
|
|
1069
|
+
return /* @__PURE__ */ React36.createElement(TextField, { ...textFieldProps, isDisabled, isInvalid: !!error }, /* @__PURE__ */ React36.createElement(
|
|
1070
|
+
Field,
|
|
1071
|
+
{
|
|
1072
|
+
label,
|
|
1073
|
+
description,
|
|
1074
|
+
error,
|
|
1075
|
+
color,
|
|
1076
|
+
size,
|
|
1077
|
+
radius: radius ?? theme?.radius ?? "lg",
|
|
1078
|
+
validationStatus,
|
|
1079
|
+
style,
|
|
1080
|
+
styles,
|
|
1081
|
+
classNames,
|
|
1082
|
+
replaceDefaultControlWrapper: true
|
|
1083
|
+
},
|
|
1084
|
+
/* @__PURE__ */ React36.createElement(
|
|
1085
|
+
TextArea,
|
|
1086
|
+
{
|
|
1087
|
+
placeholder,
|
|
1088
|
+
rows,
|
|
1089
|
+
disabled: isDisabled,
|
|
1090
|
+
className: cn("prt-input-control", "prt-text-area", className),
|
|
1091
|
+
"data-has-error": !!error,
|
|
1092
|
+
"data-resize": resize,
|
|
1093
|
+
"data-appearance": appearance,
|
|
1094
|
+
style: styles?.input
|
|
1095
|
+
}
|
|
1096
|
+
)
|
|
1097
|
+
));
|
|
1098
|
+
}
|
|
1099
|
+
var CheckboxGroupVariantContext = React36.createContext(null);
|
|
1100
|
+
function CheckboxGroup({
|
|
1101
|
+
children,
|
|
1102
|
+
label,
|
|
1103
|
+
description,
|
|
1104
|
+
errorMessage,
|
|
1105
|
+
size,
|
|
1106
|
+
appearance,
|
|
1107
|
+
color,
|
|
1108
|
+
radius,
|
|
1109
|
+
shape,
|
|
1110
|
+
...props
|
|
1111
|
+
}) {
|
|
1112
|
+
const variants = React36.useMemo(
|
|
1113
|
+
() => ({ size, appearance, color, radius, shape }),
|
|
1114
|
+
[size, appearance, color, radius, shape]
|
|
1115
|
+
);
|
|
1116
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1117
|
+
CheckboxGroup$1,
|
|
1118
|
+
{
|
|
1119
|
+
...props,
|
|
1120
|
+
"aria-label": typeof label === "string" ? label : void 0
|
|
1121
|
+
},
|
|
1122
|
+
/* @__PURE__ */ React36.createElement("div", { className: "flex flex-col gap-2" }, label && /* @__PURE__ */ React36.createElement("span", { className: "text-sm font-medium text-gray-700" }, label), /* @__PURE__ */ React36.createElement(CheckboxGroupVariantContext.Provider, { value: variants }, children), description && /* @__PURE__ */ React36.createElement("span", { className: "text-xs leading-normal text-gray-400" }, description), errorMessage && /* @__PURE__ */ React36.createElement(InputError, null, errorMessage))
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
// src/components/checkbox/checkbox.tsx
|
|
1127
|
+
function getRadius(shape) {
|
|
1128
|
+
if (shape === "sharp") return "none";
|
|
1129
|
+
if (shape === "round") return "md";
|
|
1130
|
+
return void 0;
|
|
1131
|
+
}
|
|
1132
|
+
function Checkbox({
|
|
1133
|
+
appearance,
|
|
1134
|
+
size,
|
|
1135
|
+
shape,
|
|
1136
|
+
radius,
|
|
1137
|
+
color,
|
|
1138
|
+
className,
|
|
1139
|
+
classNames,
|
|
1140
|
+
styles,
|
|
1141
|
+
style,
|
|
1142
|
+
children,
|
|
1143
|
+
...props
|
|
1144
|
+
}) {
|
|
1145
|
+
const group = React36.useContext(CheckboxGroupVariantContext);
|
|
1146
|
+
const resolvedColor = color ?? group?.color ?? "primary";
|
|
1147
|
+
const resolvedAppearance = appearance ?? group?.appearance ?? "outline";
|
|
1148
|
+
const resolvedSize = size ?? group?.size ?? "md";
|
|
1149
|
+
const resolvedRadius = radius ?? group?.radius ?? getRadius(shape ?? group?.shape) ?? "md";
|
|
1150
|
+
return /* @__PURE__ */ React36.createElement(CheckboxField, { ...props }, /* @__PURE__ */ React36.createElement(
|
|
1151
|
+
CheckboxButton,
|
|
1152
|
+
{
|
|
1153
|
+
style: { ...style, ...styles?.wrapper },
|
|
1154
|
+
className: cn(className, "prt-checkbox", classNames?.wrapper)
|
|
1155
|
+
},
|
|
1156
|
+
({ isSelected, isIndeterminate, isFocusVisible }) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
1157
|
+
"div",
|
|
1158
|
+
{
|
|
1159
|
+
style: styles?.checkbox,
|
|
1160
|
+
"data-color": resolvedColor,
|
|
1161
|
+
"data-variant": isSelected || isIndeterminate ? "solid" : void 0,
|
|
1162
|
+
"data-radius": resolvedRadius,
|
|
1163
|
+
className: cn(["prt-fake-checkbox", classNames?.checkbox]),
|
|
1164
|
+
"data-focused": isFocusVisible,
|
|
1165
|
+
"data-checked": isSelected && !isIndeterminate,
|
|
1166
|
+
"data-indeterminate": isIndeterminate,
|
|
1167
|
+
"data-size": resolvedSize,
|
|
1168
|
+
"data-appearance": isSelected || isIndeterminate ? void 0 : resolvedAppearance,
|
|
1169
|
+
"aria-hidden": "true"
|
|
1170
|
+
},
|
|
1171
|
+
isSelected && !isIndeterminate && /* @__PURE__ */ React36.createElement(
|
|
1172
|
+
"svg",
|
|
1173
|
+
{
|
|
1174
|
+
className: cn("prt-checkbox-icon", classNames?.icon),
|
|
1175
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1176
|
+
viewBox: "6 7 12 10",
|
|
1177
|
+
fill: "none",
|
|
1178
|
+
stroke: "currentColor",
|
|
1179
|
+
strokeWidth: "2",
|
|
1180
|
+
strokeLinecap: "round",
|
|
1181
|
+
strokeLinejoin: "round"
|
|
1182
|
+
},
|
|
1183
|
+
/* @__PURE__ */ React36.createElement("path", { d: "M9 12l2 2l4 -4" })
|
|
1184
|
+
),
|
|
1185
|
+
isIndeterminate && /* @__PURE__ */ React36.createElement(
|
|
1186
|
+
"div",
|
|
1187
|
+
{
|
|
1188
|
+
className: cn(["prt-checkbox-icon", classNames?.icon]),
|
|
1189
|
+
style: {
|
|
1190
|
+
background: "currentColor",
|
|
1191
|
+
width: "70%",
|
|
1192
|
+
height: 2,
|
|
1193
|
+
borderRadius: 4
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
)
|
|
1197
|
+
), children)
|
|
1198
|
+
));
|
|
1199
|
+
}
|
|
1200
|
+
function CheckboxItem({
|
|
1201
|
+
className,
|
|
1202
|
+
classNames,
|
|
1203
|
+
styles,
|
|
1204
|
+
style,
|
|
1205
|
+
children,
|
|
1206
|
+
...props
|
|
1207
|
+
}) {
|
|
1208
|
+
return /* @__PURE__ */ React36.createElement(CheckboxField, { ...props }, /* @__PURE__ */ React36.createElement(
|
|
1209
|
+
CheckboxButton,
|
|
1210
|
+
{
|
|
1211
|
+
style: { ...style, ...styles?.wrapper },
|
|
1212
|
+
className: cn(className, "prt-checkbox-item", classNames?.wrapper)
|
|
1213
|
+
},
|
|
1214
|
+
children
|
|
1215
|
+
));
|
|
1216
|
+
}
|
|
1217
|
+
function Menu({ children, ...props }) {
|
|
1218
|
+
return /* @__PURE__ */ React36.createElement(MenuTrigger$1, { ...props }, children);
|
|
1219
|
+
}
|
|
1220
|
+
function MenuTrigger({ asChild, children }) {
|
|
1221
|
+
if (asChild) {
|
|
1222
|
+
return /* @__PURE__ */ React36.createElement(Pressable, null, children);
|
|
1223
|
+
}
|
|
1224
|
+
return /* @__PURE__ */ React36.createElement(Button, null, children);
|
|
1225
|
+
}
|
|
1226
|
+
function px(value) {
|
|
1227
|
+
if (value == null) return void 0;
|
|
1228
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
1229
|
+
}
|
|
1230
|
+
function MenuContent({
|
|
1231
|
+
children,
|
|
1232
|
+
menuHeader,
|
|
1233
|
+
menuFooter,
|
|
1234
|
+
minWidth = 200,
|
|
1235
|
+
maxHeight = 300,
|
|
1236
|
+
maxWidth,
|
|
1237
|
+
placement = "bottom start",
|
|
1238
|
+
offset = 8,
|
|
1239
|
+
color,
|
|
1240
|
+
classNames,
|
|
1241
|
+
styles,
|
|
1242
|
+
className,
|
|
1243
|
+
style,
|
|
1244
|
+
...props
|
|
1245
|
+
}) {
|
|
1246
|
+
const theme = useTheme();
|
|
1247
|
+
const dataColor = color ?? theme?.color ?? "violet";
|
|
1248
|
+
const dataRadius = theme?.radius ?? "lg";
|
|
1249
|
+
const header = typeof menuHeader === "function" ? menuHeader() : menuHeader;
|
|
1250
|
+
const footer = typeof menuFooter === "function" ? menuFooter() : menuFooter;
|
|
1251
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1252
|
+
Popover$1,
|
|
1253
|
+
{
|
|
1254
|
+
placement,
|
|
1255
|
+
offset,
|
|
1256
|
+
"data-color": dataColor,
|
|
1257
|
+
"data-radius": dataRadius,
|
|
1258
|
+
className: cn("prt-popover", classNames?.popover),
|
|
1259
|
+
style: { ...styles?.popover }
|
|
1260
|
+
},
|
|
1261
|
+
/* @__PURE__ */ React36.createElement(
|
|
1262
|
+
"div",
|
|
1263
|
+
{
|
|
1264
|
+
"data-color": dataColor,
|
|
1265
|
+
"data-radius": dataRadius,
|
|
1266
|
+
className: cn("prt-list-box-wrapper", classNames?.wrapper, className),
|
|
1267
|
+
style: {
|
|
1268
|
+
minWidth: typeof minWidth === "number" ? `max(200px, ${minWidth}px)` : minWidth,
|
|
1269
|
+
maxWidth: px(maxWidth),
|
|
1270
|
+
maxHeight: px(maxHeight),
|
|
1271
|
+
...styles?.wrapper,
|
|
1272
|
+
...style
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1275
|
+
header,
|
|
1276
|
+
/* @__PURE__ */ React36.createElement(
|
|
1277
|
+
Menu$1,
|
|
1278
|
+
{
|
|
1279
|
+
...props,
|
|
1280
|
+
className: cn("prt-menu-list", classNames?.list),
|
|
1281
|
+
style: { ...styles?.list }
|
|
1282
|
+
},
|
|
1283
|
+
children
|
|
1284
|
+
),
|
|
1285
|
+
footer
|
|
1286
|
+
)
|
|
1287
|
+
);
|
|
1288
|
+
}
|
|
1289
|
+
function MenuItem({
|
|
1290
|
+
children,
|
|
1291
|
+
icon,
|
|
1292
|
+
label,
|
|
1293
|
+
description,
|
|
1294
|
+
color,
|
|
1295
|
+
isReadOnly,
|
|
1296
|
+
className,
|
|
1297
|
+
style,
|
|
1298
|
+
textValue,
|
|
1299
|
+
...props
|
|
1300
|
+
}) {
|
|
1301
|
+
const resolvedTextValue = textValue ?? (typeof label === "string" ? label : void 0) ?? (typeof children === "string" ? children : void 0);
|
|
1302
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1303
|
+
MenuItem$1,
|
|
1304
|
+
{
|
|
1305
|
+
...props,
|
|
1306
|
+
textValue: resolvedTextValue,
|
|
1307
|
+
"data-color": color,
|
|
1308
|
+
"data-readonly": isReadOnly || void 0,
|
|
1309
|
+
style,
|
|
1310
|
+
className: cn(className, "prt-list-option prt-menu-item")
|
|
1311
|
+
},
|
|
1312
|
+
({ isSelected }) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement("div", { className: "flex items-center gap-3" }, icon && /* @__PURE__ */ React36.createElement("div", { className: "flex gap-3 prt-list-option-icon-wrapper" }, React36.isValidElement(icon) && React36.cloneElement(icon, {
|
|
1313
|
+
className: "prt-list-option-icon",
|
|
1314
|
+
size: 18,
|
|
1315
|
+
...icon.props
|
|
1316
|
+
})), /* @__PURE__ */ React36.createElement("div", { className: "flex flex-col gap-1" }, /* @__PURE__ */ React36.createElement("div", { slot: "label", className: "text-sm text-black" }, label ?? children), description && /* @__PURE__ */ React36.createElement(
|
|
1317
|
+
"div",
|
|
1318
|
+
{
|
|
1319
|
+
slot: "description",
|
|
1320
|
+
className: "text-sm leading-normal text-gray-500"
|
|
1321
|
+
},
|
|
1322
|
+
description
|
|
1323
|
+
))), isSelected && /* @__PURE__ */ React36.createElement(HiCheck, { className: "selected-marker" }))
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
function MenuSection({
|
|
1327
|
+
title,
|
|
1328
|
+
children,
|
|
1329
|
+
className,
|
|
1330
|
+
...props
|
|
1331
|
+
}) {
|
|
1332
|
+
return /* @__PURE__ */ React36.createElement(MenuSection$1, { ...props, className: cn(className, "prt-list-section") }, title && /* @__PURE__ */ React36.createElement(Header, { className: "prt-list-section-header" }, title), children);
|
|
1333
|
+
}
|
|
1334
|
+
var ListBoxConfigContext = React36.createContext({
|
|
1335
|
+
showSelectionIndicator: true
|
|
1336
|
+
});
|
|
1337
|
+
function ListBox({
|
|
1338
|
+
items,
|
|
1339
|
+
children,
|
|
1340
|
+
labelKey = "label",
|
|
1341
|
+
valueKey = "id",
|
|
1342
|
+
sectionKey,
|
|
1343
|
+
color = "gray",
|
|
1344
|
+
width,
|
|
1345
|
+
showSectionSeparator = true,
|
|
1346
|
+
showSelectionIndicator = true,
|
|
1347
|
+
renderOption,
|
|
1348
|
+
renderSelectionIndicator,
|
|
1349
|
+
renderSectionLabel,
|
|
1350
|
+
renderEmpty,
|
|
1351
|
+
className,
|
|
1352
|
+
classNames,
|
|
1353
|
+
style,
|
|
1354
|
+
styles,
|
|
1355
|
+
listBoxRef,
|
|
1356
|
+
...props
|
|
1357
|
+
}) {
|
|
1358
|
+
const theme = useTheme();
|
|
1359
|
+
const config = React36.useMemo(
|
|
1360
|
+
() => ({
|
|
1361
|
+
showSelectionIndicator,
|
|
1362
|
+
renderSelectionIndicator
|
|
1363
|
+
}),
|
|
1364
|
+
[showSelectionIndicator, renderSelectionIndicator]
|
|
1365
|
+
);
|
|
1366
|
+
function renderItem(item) {
|
|
1367
|
+
const record = item;
|
|
1368
|
+
const id2 = record[valueKey];
|
|
1369
|
+
const label = record[labelKey];
|
|
1370
|
+
if (sectionKey && record[sectionKey]) {
|
|
1371
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1372
|
+
ListBoxSection,
|
|
1373
|
+
{
|
|
1374
|
+
id: id2,
|
|
1375
|
+
title: renderSectionLabel?.(item) ?? label
|
|
1376
|
+
},
|
|
1377
|
+
/* @__PURE__ */ React36.createElement(Collection, { items: record[sectionKey] }, (child) => {
|
|
1378
|
+
const childRecord = child;
|
|
1379
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1380
|
+
ListBoxItem,
|
|
1381
|
+
{
|
|
1382
|
+
id: childRecord[valueKey],
|
|
1383
|
+
textValue: childRecord[labelKey]
|
|
1384
|
+
},
|
|
1385
|
+
renderOption?.(child) ?? childRecord[labelKey]
|
|
1386
|
+
);
|
|
1387
|
+
})
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
return /* @__PURE__ */ React36.createElement(ListBoxItem, { id: id2, textValue: label }, renderOption?.(item) ?? label);
|
|
1391
|
+
}
|
|
1392
|
+
const listBoxChildren = children ?? renderItem;
|
|
1393
|
+
return /* @__PURE__ */ React36.createElement(ListBoxConfigContext.Provider, { value: config }, /* @__PURE__ */ React36.createElement(
|
|
1394
|
+
ListBox$1,
|
|
1395
|
+
{
|
|
1396
|
+
...props,
|
|
1397
|
+
ref: listBoxRef,
|
|
1398
|
+
items,
|
|
1399
|
+
className: cn("prt-list-box-wrapper", classNames?.wrapper, className),
|
|
1400
|
+
"data-radius": theme?.radius ?? "lg",
|
|
1401
|
+
"data-color": color,
|
|
1402
|
+
"data-section-separator": showSectionSeparator,
|
|
1403
|
+
style: { width, ...style, ...styles?.wrapper },
|
|
1404
|
+
renderEmptyState: () => /* @__PURE__ */ React36.createElement(
|
|
1405
|
+
"div",
|
|
1406
|
+
{
|
|
1407
|
+
className: "flex items-center justify-center gap-3",
|
|
1408
|
+
style: { height: 50 }
|
|
1409
|
+
},
|
|
1410
|
+
renderEmpty?.() ?? /* @__PURE__ */ React36.createElement("span", { className: "text-sm text-gray-400" }, "No options")
|
|
1411
|
+
)
|
|
1412
|
+
},
|
|
1413
|
+
listBoxChildren
|
|
1414
|
+
));
|
|
1415
|
+
}
|
|
1416
|
+
function ListBoxItem({
|
|
1417
|
+
color,
|
|
1418
|
+
variant,
|
|
1419
|
+
className,
|
|
1420
|
+
showSelectionIndicator,
|
|
1421
|
+
children,
|
|
1422
|
+
textValue,
|
|
1423
|
+
...props
|
|
1424
|
+
}) {
|
|
1425
|
+
const config = React36.useContext(ListBoxConfigContext);
|
|
1426
|
+
const showIndicator = showSelectionIndicator ?? config.showSelectionIndicator;
|
|
1427
|
+
const resolvedTextValue = textValue ?? (typeof children === "string" ? children : void 0);
|
|
1428
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1429
|
+
ListBoxItem$1,
|
|
1430
|
+
{
|
|
1431
|
+
...props,
|
|
1432
|
+
textValue: resolvedTextValue,
|
|
1433
|
+
className: cn("prt-list-option", className),
|
|
1434
|
+
"data-color": color,
|
|
1435
|
+
"data-variant": variant
|
|
1436
|
+
},
|
|
1437
|
+
composeRenderProps(
|
|
1438
|
+
children,
|
|
1439
|
+
(rendered, renderProps) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, rendered, renderProps.isSelected && showIndicator && /* @__PURE__ */ React36.createElement("span", { className: "selection-indicator" }, config.renderSelectionIndicator?.(
|
|
1440
|
+
props.value ?? props
|
|
1441
|
+
) ?? /* @__PURE__ */ React36.createElement(HiCheck, { size: 16 })))
|
|
1442
|
+
)
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
function ListBoxSection({
|
|
1446
|
+
title,
|
|
1447
|
+
className,
|
|
1448
|
+
children,
|
|
1449
|
+
...props
|
|
1450
|
+
}) {
|
|
1451
|
+
return /* @__PURE__ */ React36.createElement(ListBoxSection$1, { ...props, className: cn("prt-list-section", className) }, title && /* @__PURE__ */ React36.createElement(Header, { className: "prt-list-section-header" }, title), children);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
// src/components/combo-box/combo-box.tsx
|
|
1455
|
+
function ComboBox({
|
|
1456
|
+
description,
|
|
1457
|
+
error,
|
|
1458
|
+
label,
|
|
1459
|
+
selectorIcon = /* @__PURE__ */ React36.createElement(HiSelector, { size: 18 }),
|
|
1460
|
+
selectorSize = "sm",
|
|
1461
|
+
style,
|
|
1462
|
+
styles,
|
|
1463
|
+
className,
|
|
1464
|
+
classNames,
|
|
1465
|
+
isLoading,
|
|
1466
|
+
loadData,
|
|
1467
|
+
loadingIndicator = /* @__PURE__ */ React36.createElement(Loader, { size: "xs" }),
|
|
1468
|
+
items,
|
|
1469
|
+
defaultItems,
|
|
1470
|
+
inputValue,
|
|
1471
|
+
onInputChange,
|
|
1472
|
+
placeholder,
|
|
1473
|
+
prepend,
|
|
1474
|
+
append,
|
|
1475
|
+
color,
|
|
1476
|
+
size,
|
|
1477
|
+
radius,
|
|
1478
|
+
appearance,
|
|
1479
|
+
labelKey,
|
|
1480
|
+
valueKey,
|
|
1481
|
+
sectionKey,
|
|
1482
|
+
renderOption,
|
|
1483
|
+
renderSectionLabel,
|
|
1484
|
+
children,
|
|
1485
|
+
...props
|
|
1486
|
+
}) {
|
|
1487
|
+
const list = useAsyncList({
|
|
1488
|
+
async load({ filterText, signal }) {
|
|
1489
|
+
if (loadData) {
|
|
1490
|
+
return { items: await loadData(filterText, signal) };
|
|
1491
|
+
}
|
|
1492
|
+
return { items: [] };
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
1496
|
+
const usingAsync = !!loadData;
|
|
1497
|
+
const comboItems = usingAsync ? list.items : items;
|
|
1498
|
+
const comboInputValue = usingAsync ? list.filterText : inputValue;
|
|
1499
|
+
const loading = usingAsync ? list.isLoading : isLoading;
|
|
1500
|
+
function handleInputChange(value) {
|
|
1501
|
+
if (usingAsync) list.setFilterText(value);
|
|
1502
|
+
onInputChange?.(value);
|
|
1503
|
+
}
|
|
1504
|
+
const comboBoxProps = {
|
|
1505
|
+
...props,
|
|
1506
|
+
items: comboItems,
|
|
1507
|
+
defaultItems,
|
|
1508
|
+
inputValue: comboInputValue,
|
|
1509
|
+
onInputChange: handleInputChange,
|
|
1510
|
+
isInvalid: !!error,
|
|
1511
|
+
defaultFilter: contains
|
|
1512
|
+
};
|
|
1513
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1514
|
+
ComboBox$1,
|
|
1515
|
+
{
|
|
1516
|
+
...comboBoxProps,
|
|
1517
|
+
className: cn("prt-combo-box", className, classNames?.wrapper)
|
|
1518
|
+
},
|
|
1519
|
+
/* @__PURE__ */ React36.createElement(
|
|
1520
|
+
Field,
|
|
1521
|
+
{
|
|
1522
|
+
styles,
|
|
1523
|
+
classNames,
|
|
1524
|
+
style,
|
|
1525
|
+
label,
|
|
1526
|
+
description,
|
|
1527
|
+
error,
|
|
1528
|
+
color,
|
|
1529
|
+
size,
|
|
1530
|
+
radius,
|
|
1531
|
+
appearance,
|
|
1532
|
+
prepend,
|
|
1533
|
+
append
|
|
1534
|
+
},
|
|
1535
|
+
/* @__PURE__ */ React36.createElement(
|
|
1536
|
+
Input$1,
|
|
1537
|
+
{
|
|
1538
|
+
placeholder,
|
|
1539
|
+
style: styles?.input,
|
|
1540
|
+
className: cn(
|
|
1541
|
+
"prt-text-input-el",
|
|
1542
|
+
"prt-combo-box-input",
|
|
1543
|
+
classNames?.input
|
|
1544
|
+
)
|
|
1545
|
+
}
|
|
1546
|
+
),
|
|
1547
|
+
/* @__PURE__ */ React36.createElement(
|
|
1548
|
+
IconButton,
|
|
1549
|
+
{
|
|
1550
|
+
className: cn("prt-combo-box-button", classNames?.button),
|
|
1551
|
+
style: styles?.button,
|
|
1552
|
+
variant: "ghost",
|
|
1553
|
+
color: "gray",
|
|
1554
|
+
size: selectorSize
|
|
1555
|
+
},
|
|
1556
|
+
loading ? loadingIndicator : selectorIcon
|
|
1557
|
+
)
|
|
1558
|
+
),
|
|
1559
|
+
/* @__PURE__ */ React36.createElement(
|
|
1560
|
+
Popover$1,
|
|
1561
|
+
{
|
|
1562
|
+
offset: 6,
|
|
1563
|
+
className: cn(
|
|
1564
|
+
"prt-popover",
|
|
1565
|
+
"prt-combo-box-popover",
|
|
1566
|
+
classNames?.popover
|
|
1567
|
+
),
|
|
1568
|
+
style: styles?.popover
|
|
1569
|
+
},
|
|
1570
|
+
/* @__PURE__ */ React36.createElement(
|
|
1571
|
+
ListBox,
|
|
1572
|
+
{
|
|
1573
|
+
items: comboItems,
|
|
1574
|
+
labelKey,
|
|
1575
|
+
valueKey,
|
|
1576
|
+
sectionKey,
|
|
1577
|
+
renderOption,
|
|
1578
|
+
renderSectionLabel,
|
|
1579
|
+
width: "var(--trigger-width)"
|
|
1580
|
+
},
|
|
1581
|
+
children
|
|
1582
|
+
)
|
|
1583
|
+
)
|
|
1584
|
+
);
|
|
1585
|
+
}
|
|
1586
|
+
function Radio({
|
|
1587
|
+
size = "sm",
|
|
1588
|
+
className,
|
|
1589
|
+
style,
|
|
1590
|
+
appearance,
|
|
1591
|
+
color,
|
|
1592
|
+
children,
|
|
1593
|
+
...props
|
|
1594
|
+
}) {
|
|
1595
|
+
return /* @__PURE__ */ React36.createElement(RadioField, { ...props }, /* @__PURE__ */ React36.createElement(RadioButton, { style, className: cn("prt-radio", className) }, ({ isSelected }) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
1596
|
+
"div",
|
|
1597
|
+
{
|
|
1598
|
+
"data-color": color,
|
|
1599
|
+
className: "prt-fake-radio",
|
|
1600
|
+
"data-appearance": appearance,
|
|
1601
|
+
"data-checked": isSelected,
|
|
1602
|
+
"data-size": size
|
|
1603
|
+
}
|
|
1604
|
+
), children)));
|
|
1605
|
+
}
|
|
1606
|
+
function RadioGroup({
|
|
1607
|
+
className,
|
|
1608
|
+
classNames,
|
|
1609
|
+
style,
|
|
1610
|
+
styles,
|
|
1611
|
+
label,
|
|
1612
|
+
description,
|
|
1613
|
+
errorMessage,
|
|
1614
|
+
children,
|
|
1615
|
+
...props
|
|
1616
|
+
}) {
|
|
1617
|
+
const isHorizontal = props.orientation === "horizontal";
|
|
1618
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1619
|
+
RadioGroup$1,
|
|
1620
|
+
{
|
|
1621
|
+
...props,
|
|
1622
|
+
"aria-label": typeof label === "string" ? label : void 0
|
|
1623
|
+
},
|
|
1624
|
+
/* @__PURE__ */ React36.createElement(
|
|
1625
|
+
"div",
|
|
1626
|
+
{
|
|
1627
|
+
style: { ...style, ...styles?.wrapper },
|
|
1628
|
+
className: cn(
|
|
1629
|
+
"prt-radio-group flex flex-col gap-2",
|
|
1630
|
+
className,
|
|
1631
|
+
classNames?.wrapper
|
|
1632
|
+
)
|
|
1633
|
+
},
|
|
1634
|
+
label && /* @__PURE__ */ React36.createElement(InputLabel, null, label),
|
|
1635
|
+
description && /* @__PURE__ */ React36.createElement("span", { className: "text-sm text-gray-600" }, description),
|
|
1636
|
+
/* @__PURE__ */ React36.createElement("div", { className: cn("flex gap-2", isHorizontal ? "flex-row" : "flex-col") }, children),
|
|
1637
|
+
errorMessage && /* @__PURE__ */ React36.createElement(InputError, null, errorMessage)
|
|
1638
|
+
)
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
function RadioCard({
|
|
1642
|
+
title,
|
|
1643
|
+
description,
|
|
1644
|
+
children,
|
|
1645
|
+
appearance,
|
|
1646
|
+
showIndicator = true,
|
|
1647
|
+
color,
|
|
1648
|
+
className,
|
|
1649
|
+
style,
|
|
1650
|
+
classNames,
|
|
1651
|
+
styles,
|
|
1652
|
+
...props
|
|
1653
|
+
}) {
|
|
1654
|
+
return /* @__PURE__ */ React36.createElement(RadioField, { ...props }, /* @__PURE__ */ React36.createElement(
|
|
1655
|
+
RadioButton,
|
|
1656
|
+
{
|
|
1657
|
+
"data-radius": "lg",
|
|
1658
|
+
className: cn(className, "prt-radio-card", classNames?.wrapper),
|
|
1659
|
+
"data-color": color,
|
|
1660
|
+
"data-appearance": appearance,
|
|
1661
|
+
style: { ...style, ...styles?.wrapper }
|
|
1662
|
+
},
|
|
1663
|
+
({ isSelected }) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, showIndicator && /* @__PURE__ */ React36.createElement(
|
|
1664
|
+
"div",
|
|
1665
|
+
{
|
|
1666
|
+
className: "prt-radio-card-indicator prt-fake-radio",
|
|
1667
|
+
"data-size": "sm",
|
|
1668
|
+
"data-checked": isSelected
|
|
1669
|
+
}
|
|
1670
|
+
), /* @__PURE__ */ React36.createElement(
|
|
1671
|
+
"div",
|
|
1672
|
+
{
|
|
1673
|
+
className: cn(
|
|
1674
|
+
"flex w-full flex-col gap-2.5 prt-radio-card-content",
|
|
1675
|
+
classNames?.content
|
|
1676
|
+
),
|
|
1677
|
+
style: { ...styles?.content }
|
|
1678
|
+
},
|
|
1679
|
+
(title || description) && /* @__PURE__ */ React36.createElement("div", { className: "flex flex-col gap-0.5" }, title && /* @__PURE__ */ React36.createElement(
|
|
1680
|
+
"div",
|
|
1681
|
+
{
|
|
1682
|
+
className: cn("text-sm", classNames?.title),
|
|
1683
|
+
style: { ...styles?.title }
|
|
1684
|
+
},
|
|
1685
|
+
title
|
|
1686
|
+
), description && /* @__PURE__ */ React36.createElement(
|
|
1687
|
+
"div",
|
|
1688
|
+
{
|
|
1689
|
+
className: cn(
|
|
1690
|
+
"text-xs leading-relaxed text-gray-400",
|
|
1691
|
+
classNames?.description
|
|
1692
|
+
),
|
|
1693
|
+
style: { ...styles?.description }
|
|
1694
|
+
},
|
|
1695
|
+
description
|
|
1696
|
+
)),
|
|
1697
|
+
children
|
|
1698
|
+
))
|
|
1699
|
+
));
|
|
1700
|
+
}
|
|
1701
|
+
function RadioItem({
|
|
1702
|
+
className,
|
|
1703
|
+
style,
|
|
1704
|
+
classNames,
|
|
1705
|
+
styles,
|
|
1706
|
+
children,
|
|
1707
|
+
...props
|
|
1708
|
+
}) {
|
|
1709
|
+
return /* @__PURE__ */ React36.createElement(RadioField, { ...props }, /* @__PURE__ */ React36.createElement(
|
|
1710
|
+
RadioButton,
|
|
1711
|
+
{
|
|
1712
|
+
style: { ...style, ...styles?.wrapper },
|
|
1713
|
+
className: cn(className, classNames?.wrapper, "prt-radio-item")
|
|
1714
|
+
},
|
|
1715
|
+
children
|
|
1716
|
+
));
|
|
1717
|
+
}
|
|
1718
|
+
function Tag({
|
|
1719
|
+
prepend,
|
|
1720
|
+
append,
|
|
1721
|
+
children,
|
|
1722
|
+
hashValue,
|
|
1723
|
+
color,
|
|
1724
|
+
size = "sm",
|
|
1725
|
+
shape,
|
|
1726
|
+
variant = "light",
|
|
1727
|
+
className,
|
|
1728
|
+
style,
|
|
1729
|
+
classNames,
|
|
1730
|
+
styles,
|
|
1731
|
+
radius = "full",
|
|
1732
|
+
ref,
|
|
1733
|
+
...props
|
|
1734
|
+
}) {
|
|
1735
|
+
warnDeprecation("shape", "radius", shape);
|
|
1736
|
+
const randomColor = React36__default.useMemo(() => {
|
|
1737
|
+
if (hashValue) {
|
|
1738
|
+
return getRandomColor(hashValue);
|
|
1739
|
+
}
|
|
1740
|
+
return "gray";
|
|
1741
|
+
}, [hashValue]);
|
|
1742
|
+
return /* @__PURE__ */ React36__default.createElement(
|
|
1743
|
+
"span",
|
|
1744
|
+
{
|
|
1745
|
+
className: cn(className, "prt-tag", classNames?.wrapper),
|
|
1746
|
+
style: { ...style, ...styles?.wrapper },
|
|
1747
|
+
"data-radius": radius,
|
|
1748
|
+
"data-size": size,
|
|
1749
|
+
"data-color": color ?? randomColor,
|
|
1750
|
+
"data-variant": variant,
|
|
1751
|
+
ref,
|
|
1752
|
+
...props
|
|
1753
|
+
},
|
|
1754
|
+
prepend,
|
|
1755
|
+
children,
|
|
1756
|
+
append
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
// src/components/select/select.tsx
|
|
1761
|
+
function Select({
|
|
1762
|
+
label,
|
|
1763
|
+
description,
|
|
1764
|
+
error,
|
|
1765
|
+
placeholder,
|
|
1766
|
+
selectionMode = "single",
|
|
1767
|
+
appearance = "outline",
|
|
1768
|
+
renderValue,
|
|
1769
|
+
color = "gray",
|
|
1770
|
+
size = "sm",
|
|
1771
|
+
radius,
|
|
1772
|
+
listBoxColor,
|
|
1773
|
+
name,
|
|
1774
|
+
value,
|
|
1775
|
+
defaultValue,
|
|
1776
|
+
isDisabled,
|
|
1777
|
+
isRequired,
|
|
1778
|
+
disabledKeys,
|
|
1779
|
+
onChange,
|
|
1780
|
+
onSelectionChange,
|
|
1781
|
+
showSectionSeparator = true,
|
|
1782
|
+
showSelectionIndicator = true,
|
|
1783
|
+
items,
|
|
1784
|
+
children,
|
|
1785
|
+
labelKey = "label",
|
|
1786
|
+
valueKey = "id",
|
|
1787
|
+
sectionKey,
|
|
1788
|
+
renderOption,
|
|
1789
|
+
renderSectionLabel,
|
|
1790
|
+
className,
|
|
1791
|
+
classNames,
|
|
1792
|
+
style,
|
|
1793
|
+
styles
|
|
1794
|
+
}) {
|
|
1795
|
+
const theme = useTheme();
|
|
1796
|
+
const isMultiple = selectionMode === "multiple";
|
|
1797
|
+
color = color ?? theme?.color;
|
|
1798
|
+
function handleChange(v) {
|
|
1799
|
+
onChange?.({ target: { value: v, name } });
|
|
1800
|
+
onSelectionChange?.(v == null ? [] : Array.isArray(v) ? v : [v]);
|
|
1801
|
+
}
|
|
1802
|
+
function labelOf(item) {
|
|
1803
|
+
if (item == null) return null;
|
|
1804
|
+
return item[labelKey];
|
|
1805
|
+
}
|
|
1806
|
+
const racSelectProps = {
|
|
1807
|
+
selectionMode,
|
|
1808
|
+
isDisabled,
|
|
1809
|
+
isRequired,
|
|
1810
|
+
placeholder,
|
|
1811
|
+
disabledKeys,
|
|
1812
|
+
value,
|
|
1813
|
+
defaultValue,
|
|
1814
|
+
isInvalid: !!error,
|
|
1815
|
+
onChange: handleChange
|
|
1816
|
+
};
|
|
1817
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1818
|
+
Select$1,
|
|
1819
|
+
{
|
|
1820
|
+
...racSelectProps,
|
|
1821
|
+
"aria-label": label == null ? placeholder ?? "Select" : void 0,
|
|
1822
|
+
className: cn("prt-select", className, classNames?.wrapper),
|
|
1823
|
+
style: { ...style, ...styles?.wrapper }
|
|
1824
|
+
},
|
|
1825
|
+
/* @__PURE__ */ React36.createElement(
|
|
1826
|
+
Field,
|
|
1827
|
+
{
|
|
1828
|
+
replaceDefaultControlWrapper: true,
|
|
1829
|
+
label,
|
|
1830
|
+
error,
|
|
1831
|
+
description,
|
|
1832
|
+
color,
|
|
1833
|
+
size,
|
|
1834
|
+
radius,
|
|
1835
|
+
classNames,
|
|
1836
|
+
styles
|
|
1837
|
+
},
|
|
1838
|
+
/* @__PURE__ */ React36.createElement(
|
|
1839
|
+
Button$1,
|
|
1840
|
+
{
|
|
1841
|
+
"data-selection-mode": selectionMode,
|
|
1842
|
+
"data-appearance": appearance,
|
|
1843
|
+
style: styles?.trigger,
|
|
1844
|
+
className: cn("prt-input-control", "prt-select-trigger", classNames?.trigger)
|
|
1845
|
+
},
|
|
1846
|
+
/* @__PURE__ */ React36.createElement(SelectValue, { className: cn("single-value", classNames?.value) }, ({ isPlaceholder, selectedItems, selectedText }) => {
|
|
1847
|
+
if (isPlaceholder) {
|
|
1848
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1849
|
+
"span",
|
|
1850
|
+
{
|
|
1851
|
+
style: styles?.placeholder,
|
|
1852
|
+
className: cn("text-gray-400", classNames?.placeholder)
|
|
1853
|
+
},
|
|
1854
|
+
placeholder
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
if (isMultiple) {
|
|
1858
|
+
return /* @__PURE__ */ React36.createElement("div", { className: "flex flex-wrap gap-1" }, selectedItems.map(
|
|
1859
|
+
(item, index) => item == null ? null : renderValue?.(item) ?? /* @__PURE__ */ React36.createElement(
|
|
1860
|
+
Tag,
|
|
1861
|
+
{
|
|
1862
|
+
size: "md",
|
|
1863
|
+
variant: "pastel",
|
|
1864
|
+
color,
|
|
1865
|
+
key: index
|
|
1866
|
+
},
|
|
1867
|
+
labelOf(item)
|
|
1868
|
+
)
|
|
1869
|
+
));
|
|
1870
|
+
}
|
|
1871
|
+
const selectedItem = selectedItems[0] ?? null;
|
|
1872
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1873
|
+
"div",
|
|
1874
|
+
{
|
|
1875
|
+
className: cn("single-value", classNames?.value),
|
|
1876
|
+
style: styles?.value
|
|
1877
|
+
},
|
|
1878
|
+
(selectedItem && renderValue?.(selectedItem)) ?? labelOf(selectedItem) ?? selectedText
|
|
1879
|
+
);
|
|
1880
|
+
}),
|
|
1881
|
+
/* @__PURE__ */ React36.createElement(HiSelector, { className: "selector", size: 18 })
|
|
1882
|
+
)
|
|
1883
|
+
),
|
|
1884
|
+
/* @__PURE__ */ React36.createElement(
|
|
1885
|
+
Popover$1,
|
|
1886
|
+
{
|
|
1887
|
+
offset: 4,
|
|
1888
|
+
className: cn("prt-popover", "prt-select-popover", classNames?.popover),
|
|
1889
|
+
style: styles?.popover
|
|
1890
|
+
},
|
|
1891
|
+
/* @__PURE__ */ React36.createElement(
|
|
1892
|
+
ListBox,
|
|
1893
|
+
{
|
|
1894
|
+
items,
|
|
1895
|
+
labelKey,
|
|
1896
|
+
valueKey,
|
|
1897
|
+
sectionKey,
|
|
1898
|
+
renderOption,
|
|
1899
|
+
renderSectionLabel,
|
|
1900
|
+
showSectionSeparator,
|
|
1901
|
+
showSelectionIndicator,
|
|
1902
|
+
color: listBoxColor ?? "gray",
|
|
1903
|
+
width: "var(--trigger-width)"
|
|
1904
|
+
},
|
|
1905
|
+
children
|
|
1906
|
+
)
|
|
1907
|
+
)
|
|
1908
|
+
);
|
|
1909
|
+
}
|
|
1910
|
+
function CalendarBody({
|
|
1911
|
+
numberOfMonths = 1,
|
|
1912
|
+
showMonthAndYearPickers = false
|
|
1913
|
+
}) {
|
|
1914
|
+
return /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement("header", { className: "prt-calendar-header" }, /* @__PURE__ */ React36.createElement(
|
|
1915
|
+
IconButton,
|
|
1916
|
+
{
|
|
1917
|
+
slot: "previous",
|
|
1918
|
+
variant: "outline",
|
|
1919
|
+
radius: "full",
|
|
1920
|
+
size: "sm",
|
|
1921
|
+
color: "gray"
|
|
1922
|
+
},
|
|
1923
|
+
/* @__PURE__ */ React36.createElement(HiChevronLeft, { size: 20 })
|
|
1924
|
+
), showMonthAndYearPickers ? /* @__PURE__ */ React36.createElement("div", { className: "flex items-center gap-2 prt-calendar-selects" }, /* @__PURE__ */ React36.createElement(CalendarMonthPicker, null, ({ "aria-label": ariaLabel, value, onChange, items }) => /* @__PURE__ */ React36.createElement(
|
|
1925
|
+
Select,
|
|
1926
|
+
{
|
|
1927
|
+
"aria-label": ariaLabel,
|
|
1928
|
+
size: "sm",
|
|
1929
|
+
appearance: "filled",
|
|
1930
|
+
valueKey: "id",
|
|
1931
|
+
labelKey: "formatted",
|
|
1932
|
+
value,
|
|
1933
|
+
onChange: (e) => onChange(e.target.value),
|
|
1934
|
+
items
|
|
1935
|
+
}
|
|
1936
|
+
)), /* @__PURE__ */ React36.createElement(CalendarYearPicker, null, ({ "aria-label": ariaLabel, value, onChange, items }) => /* @__PURE__ */ React36.createElement(
|
|
1937
|
+
Select,
|
|
1938
|
+
{
|
|
1939
|
+
"aria-label": ariaLabel,
|
|
1940
|
+
size: "sm",
|
|
1941
|
+
appearance: "filled",
|
|
1942
|
+
valueKey: "id",
|
|
1943
|
+
labelKey: "formatted",
|
|
1944
|
+
value,
|
|
1945
|
+
onChange: (e) => onChange(e.target.value),
|
|
1946
|
+
items
|
|
1947
|
+
}
|
|
1948
|
+
))) : /* @__PURE__ */ React36.createElement(Heading, { className: "prt-calendar-heading" }), /* @__PURE__ */ React36.createElement(
|
|
1949
|
+
IconButton,
|
|
1950
|
+
{
|
|
1951
|
+
slot: "next",
|
|
1952
|
+
variant: "outline",
|
|
1953
|
+
radius: "full",
|
|
1954
|
+
size: "sm",
|
|
1955
|
+
color: "gray"
|
|
1956
|
+
},
|
|
1957
|
+
/* @__PURE__ */ React36.createElement(HiChevronRight, { size: 20 })
|
|
1958
|
+
)), /* @__PURE__ */ React36.createElement("div", { className: "prt-calendar-months" }, Array.from({ length: numberOfMonths }, (_, i) => /* @__PURE__ */ React36.createElement(
|
|
1959
|
+
CalendarGrid,
|
|
1960
|
+
{
|
|
1961
|
+
key: i,
|
|
1962
|
+
offset: { months: i },
|
|
1963
|
+
className: "prt-calendar-grid"
|
|
1964
|
+
},
|
|
1965
|
+
/* @__PURE__ */ React36.createElement(CalendarGridHeader, null, (day) => /* @__PURE__ */ React36.createElement(CalendarHeaderCell, { className: "prt-date-weekday" }, day)),
|
|
1966
|
+
/* @__PURE__ */ React36.createElement(CalendarGridBody, null, (date) => /* @__PURE__ */ React36.createElement(CalendarCell, { date, className: "prt-date-cell" }))
|
|
1967
|
+
))));
|
|
1968
|
+
}
|
|
1969
|
+
function Calendar({
|
|
1970
|
+
numberOfMonths = 1,
|
|
1971
|
+
showMonthAndYearPickers,
|
|
1972
|
+
color,
|
|
1973
|
+
radius,
|
|
1974
|
+
ref,
|
|
1975
|
+
...props
|
|
1976
|
+
}) {
|
|
1977
|
+
const theme = useTheme();
|
|
1978
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1979
|
+
Calendar$1,
|
|
1980
|
+
{
|
|
1981
|
+
...props,
|
|
1982
|
+
ref,
|
|
1983
|
+
visibleDuration: { months: numberOfMonths },
|
|
1984
|
+
"data-color": color ?? theme?.color ?? "primary",
|
|
1985
|
+
"data-radius": radius ?? theme?.radius ?? "lg",
|
|
1986
|
+
className: "prt-calendar-wrapper"
|
|
1987
|
+
},
|
|
1988
|
+
/* @__PURE__ */ React36.createElement(
|
|
1989
|
+
CalendarBody,
|
|
1990
|
+
{
|
|
1991
|
+
numberOfMonths,
|
|
1992
|
+
showMonthAndYearPickers
|
|
1993
|
+
}
|
|
1994
|
+
)
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
function RangeCalendar({
|
|
1998
|
+
numberOfMonths = 1,
|
|
1999
|
+
showMonthAndYearPickers,
|
|
2000
|
+
color,
|
|
2001
|
+
radius,
|
|
2002
|
+
ref,
|
|
2003
|
+
...props
|
|
2004
|
+
}) {
|
|
2005
|
+
const theme = useTheme();
|
|
2006
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2007
|
+
RangeCalendar$1,
|
|
2008
|
+
{
|
|
2009
|
+
...props,
|
|
2010
|
+
ref,
|
|
2011
|
+
visibleDuration: { months: numberOfMonths },
|
|
2012
|
+
"data-color": color ?? theme?.color ?? "primary",
|
|
2013
|
+
"data-radius": radius ?? theme?.radius ?? "lg",
|
|
2014
|
+
"data-range": "true",
|
|
2015
|
+
className: "prt-calendar-wrapper"
|
|
2016
|
+
},
|
|
2017
|
+
/* @__PURE__ */ React36.createElement(
|
|
2018
|
+
CalendarBody,
|
|
2019
|
+
{
|
|
2020
|
+
numberOfMonths,
|
|
2021
|
+
showMonthAndYearPickers
|
|
2022
|
+
}
|
|
2023
|
+
)
|
|
2024
|
+
);
|
|
2025
|
+
}
|
|
2026
|
+
function DateSegments({ slot, className }) {
|
|
2027
|
+
return /* @__PURE__ */ React36.createElement(DateInput, { slot, className: cn("prt-date-field", className) }, (segment) => /* @__PURE__ */ React36.createElement(DateSegment, { segment, className: "prt-date-input-segment" }));
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
// src/components/date/date-field.tsx
|
|
2031
|
+
function DateField({
|
|
2032
|
+
appearance = "outline",
|
|
2033
|
+
size = "md",
|
|
2034
|
+
color,
|
|
2035
|
+
radius,
|
|
2036
|
+
value,
|
|
2037
|
+
defaultValue,
|
|
2038
|
+
onChange,
|
|
2039
|
+
label,
|
|
2040
|
+
description,
|
|
2041
|
+
error,
|
|
2042
|
+
validationStatus,
|
|
2043
|
+
prepend,
|
|
2044
|
+
append,
|
|
2045
|
+
className,
|
|
2046
|
+
classNames,
|
|
2047
|
+
style,
|
|
2048
|
+
styles,
|
|
2049
|
+
ref,
|
|
2050
|
+
...props
|
|
2051
|
+
}) {
|
|
2052
|
+
function handleChange(date) {
|
|
2053
|
+
onChange?.(date?.toString() ?? null, date);
|
|
2054
|
+
}
|
|
2055
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2056
|
+
DateField$1,
|
|
2057
|
+
{
|
|
2058
|
+
...props,
|
|
2059
|
+
value: value != null ? parseDate(value) : void 0,
|
|
2060
|
+
defaultValue: defaultValue != null ? parseDate(defaultValue) : void 0,
|
|
2061
|
+
onChange: handleChange,
|
|
2062
|
+
isInvalid: !!error
|
|
2063
|
+
},
|
|
2064
|
+
/* @__PURE__ */ React36.createElement(
|
|
2065
|
+
Field,
|
|
2066
|
+
{
|
|
2067
|
+
replaceDefaultControlWrapper: true,
|
|
2068
|
+
label,
|
|
2069
|
+
error,
|
|
2070
|
+
description,
|
|
2071
|
+
color,
|
|
2072
|
+
size,
|
|
2073
|
+
radius,
|
|
2074
|
+
appearance,
|
|
2075
|
+
validationStatus,
|
|
2076
|
+
className,
|
|
2077
|
+
classNames,
|
|
2078
|
+
style,
|
|
2079
|
+
styles
|
|
2080
|
+
},
|
|
2081
|
+
/* @__PURE__ */ React36.createElement(
|
|
2082
|
+
Group,
|
|
2083
|
+
{
|
|
2084
|
+
ref,
|
|
2085
|
+
"data-appearance": appearance,
|
|
2086
|
+
"data-color": color,
|
|
2087
|
+
className: cn("prt-input-control", "date-field-control")
|
|
2088
|
+
},
|
|
2089
|
+
prepend && /* @__PURE__ */ React36.createElement("div", { className: "add-on add-on-left flex items-center" }, prepend),
|
|
2090
|
+
/* @__PURE__ */ React36.createElement(DateSegments, null),
|
|
2091
|
+
append && /* @__PURE__ */ React36.createElement("div", { className: "add-on add-on-right flex items-center" }, append)
|
|
2092
|
+
)
|
|
2093
|
+
)
|
|
2094
|
+
);
|
|
2095
|
+
}
|
|
2096
|
+
function TimeField({
|
|
2097
|
+
appearance = "outline",
|
|
2098
|
+
size = "md",
|
|
2099
|
+
color,
|
|
2100
|
+
radius,
|
|
2101
|
+
value,
|
|
2102
|
+
defaultValue,
|
|
2103
|
+
onChange,
|
|
2104
|
+
label,
|
|
2105
|
+
description,
|
|
2106
|
+
error,
|
|
2107
|
+
validationStatus,
|
|
2108
|
+
prepend,
|
|
2109
|
+
append,
|
|
2110
|
+
className,
|
|
2111
|
+
classNames,
|
|
2112
|
+
style,
|
|
2113
|
+
styles,
|
|
2114
|
+
ref,
|
|
2115
|
+
...props
|
|
2116
|
+
}) {
|
|
2117
|
+
function handleChange(time) {
|
|
2118
|
+
onChange?.(time?.toString() ?? null, time);
|
|
2119
|
+
}
|
|
2120
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2121
|
+
TimeField$1,
|
|
2122
|
+
{
|
|
2123
|
+
...props,
|
|
2124
|
+
value: value != null ? parseTime(value) : void 0,
|
|
2125
|
+
defaultValue: defaultValue != null ? parseTime(defaultValue) : void 0,
|
|
2126
|
+
onChange: handleChange,
|
|
2127
|
+
isInvalid: !!error
|
|
2128
|
+
},
|
|
2129
|
+
/* @__PURE__ */ React36.createElement(
|
|
2130
|
+
Field,
|
|
2131
|
+
{
|
|
2132
|
+
replaceDefaultControlWrapper: true,
|
|
2133
|
+
label,
|
|
2134
|
+
error,
|
|
2135
|
+
description,
|
|
2136
|
+
color,
|
|
2137
|
+
size,
|
|
2138
|
+
radius,
|
|
2139
|
+
appearance,
|
|
2140
|
+
validationStatus,
|
|
2141
|
+
className,
|
|
2142
|
+
classNames,
|
|
2143
|
+
style,
|
|
2144
|
+
styles
|
|
2145
|
+
},
|
|
2146
|
+
/* @__PURE__ */ React36.createElement(
|
|
2147
|
+
Group,
|
|
2148
|
+
{
|
|
2149
|
+
ref,
|
|
2150
|
+
"data-appearance": appearance,
|
|
2151
|
+
"data-color": color,
|
|
2152
|
+
className: cn("prt-input-control", "date-field-control")
|
|
2153
|
+
},
|
|
2154
|
+
prepend && /* @__PURE__ */ React36.createElement("div", { className: "add-on add-on-left flex items-center" }, prepend),
|
|
2155
|
+
/* @__PURE__ */ React36.createElement(DateSegments, null),
|
|
2156
|
+
append && /* @__PURE__ */ React36.createElement("div", { className: "add-on add-on-right flex items-center" }, append)
|
|
2157
|
+
)
|
|
2158
|
+
)
|
|
2159
|
+
);
|
|
2160
|
+
}
|
|
2161
|
+
function DatePicker({
|
|
2162
|
+
appearance = "outline",
|
|
2163
|
+
size = "md",
|
|
2164
|
+
color,
|
|
2165
|
+
numberOfMonths,
|
|
2166
|
+
showMonthAndYearPickers,
|
|
2167
|
+
radius,
|
|
2168
|
+
selectorIcon = /* @__PURE__ */ React36.createElement(HiOutlineCalendar, { size: 16 }),
|
|
2169
|
+
value,
|
|
2170
|
+
defaultValue,
|
|
2171
|
+
onChange,
|
|
2172
|
+
label,
|
|
2173
|
+
description,
|
|
2174
|
+
error,
|
|
2175
|
+
validationStatus,
|
|
2176
|
+
className,
|
|
2177
|
+
classNames,
|
|
2178
|
+
style,
|
|
2179
|
+
styles,
|
|
2180
|
+
ref,
|
|
2181
|
+
...props
|
|
2182
|
+
}) {
|
|
2183
|
+
function handleChange(date) {
|
|
2184
|
+
onChange?.(date?.toString() ?? null, date);
|
|
2185
|
+
}
|
|
2186
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2187
|
+
DatePicker$1,
|
|
2188
|
+
{
|
|
2189
|
+
...props,
|
|
2190
|
+
value: value != null ? parseDate(value) : void 0,
|
|
2191
|
+
defaultValue: defaultValue != null ? parseDate(defaultValue) : void 0,
|
|
2192
|
+
onChange: handleChange,
|
|
2193
|
+
isInvalid: !!error
|
|
2194
|
+
},
|
|
2195
|
+
/* @__PURE__ */ React36.createElement(
|
|
2196
|
+
Field,
|
|
2197
|
+
{
|
|
2198
|
+
replaceDefaultControlWrapper: true,
|
|
2199
|
+
label,
|
|
2200
|
+
error,
|
|
2201
|
+
description,
|
|
2202
|
+
color,
|
|
2203
|
+
size,
|
|
2204
|
+
radius,
|
|
2205
|
+
appearance,
|
|
2206
|
+
validationStatus,
|
|
2207
|
+
className,
|
|
2208
|
+
classNames,
|
|
2209
|
+
style,
|
|
2210
|
+
styles
|
|
2211
|
+
},
|
|
2212
|
+
/* @__PURE__ */ React36.createElement(
|
|
2213
|
+
Group,
|
|
2214
|
+
{
|
|
2215
|
+
ref,
|
|
2216
|
+
"data-appearance": appearance,
|
|
2217
|
+
"data-color": color,
|
|
2218
|
+
className: cn("prt-input-control", "prt-date-picker-trigger")
|
|
2219
|
+
},
|
|
2220
|
+
/* @__PURE__ */ React36.createElement(DateSegments, null),
|
|
2221
|
+
/* @__PURE__ */ React36.createElement(IconButton, { size: "sm", variant: "light", color }, selectorIcon)
|
|
2222
|
+
)
|
|
2223
|
+
),
|
|
2224
|
+
/* @__PURE__ */ React36.createElement(
|
|
2225
|
+
Popover$1,
|
|
2226
|
+
{
|
|
2227
|
+
offset: 8,
|
|
2228
|
+
placement: "bottom start",
|
|
2229
|
+
className: cn("prt-popover", "prt-date-popover")
|
|
2230
|
+
},
|
|
2231
|
+
/* @__PURE__ */ React36.createElement(
|
|
2232
|
+
Calendar,
|
|
2233
|
+
{
|
|
2234
|
+
color,
|
|
2235
|
+
radius,
|
|
2236
|
+
numberOfMonths,
|
|
2237
|
+
showMonthAndYearPickers
|
|
2238
|
+
}
|
|
2239
|
+
)
|
|
2240
|
+
)
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
function toRange(value) {
|
|
2244
|
+
return value != null ? { start: parseDate(value.start), end: parseDate(value.end) } : void 0;
|
|
2245
|
+
}
|
|
2246
|
+
function DateRangePicker({
|
|
2247
|
+
appearance = "outline",
|
|
2248
|
+
size = "md",
|
|
2249
|
+
color,
|
|
2250
|
+
numberOfMonths = 2,
|
|
2251
|
+
showMonthAndYearPickers,
|
|
2252
|
+
radius,
|
|
2253
|
+
dropdownIcon = /* @__PURE__ */ React36.createElement(HiOutlineCalendar, { size: 16 }),
|
|
2254
|
+
value,
|
|
2255
|
+
defaultValue,
|
|
2256
|
+
onChange,
|
|
2257
|
+
label,
|
|
2258
|
+
description,
|
|
2259
|
+
error,
|
|
2260
|
+
validationStatus,
|
|
2261
|
+
className,
|
|
2262
|
+
classNames,
|
|
2263
|
+
style,
|
|
2264
|
+
styles,
|
|
2265
|
+
ref,
|
|
2266
|
+
...props
|
|
2267
|
+
}) {
|
|
2268
|
+
function handleChange(range) {
|
|
2269
|
+
onChange?.(
|
|
2270
|
+
range ? { start: range.start.toString(), end: range.end.toString() } : null,
|
|
2271
|
+
range
|
|
2272
|
+
);
|
|
2273
|
+
}
|
|
2274
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2275
|
+
DateRangePicker$1,
|
|
2276
|
+
{
|
|
2277
|
+
...props,
|
|
2278
|
+
value: toRange(value),
|
|
2279
|
+
defaultValue: toRange(defaultValue),
|
|
2280
|
+
onChange: handleChange,
|
|
2281
|
+
isInvalid: !!error
|
|
2282
|
+
},
|
|
2283
|
+
/* @__PURE__ */ React36.createElement(
|
|
2284
|
+
Field,
|
|
2285
|
+
{
|
|
2286
|
+
replaceDefaultControlWrapper: true,
|
|
2287
|
+
label,
|
|
2288
|
+
error,
|
|
2289
|
+
description,
|
|
2290
|
+
color,
|
|
2291
|
+
size,
|
|
2292
|
+
radius,
|
|
2293
|
+
appearance,
|
|
2294
|
+
validationStatus,
|
|
2295
|
+
className,
|
|
2296
|
+
classNames,
|
|
2297
|
+
style,
|
|
2298
|
+
styles
|
|
2299
|
+
},
|
|
2300
|
+
/* @__PURE__ */ React36.createElement(
|
|
2301
|
+
Group,
|
|
2302
|
+
{
|
|
2303
|
+
ref,
|
|
2304
|
+
"data-appearance": appearance,
|
|
2305
|
+
"data-color": color,
|
|
2306
|
+
className: cn("prt-input-control", "prt-date-picker-trigger")
|
|
2307
|
+
},
|
|
2308
|
+
/* @__PURE__ */ React36.createElement("div", { className: "prt-date-range-fields" }, /* @__PURE__ */ React36.createElement(DateSegments, { slot: "start" }), /* @__PURE__ */ React36.createElement("span", { "aria-hidden": "true", className: "prt-date-range-sep" }, "\u2013"), /* @__PURE__ */ React36.createElement(DateSegments, { slot: "end" })),
|
|
2309
|
+
/* @__PURE__ */ React36.createElement(IconButton, { size: "sm", variant: "light", color }, dropdownIcon)
|
|
2310
|
+
)
|
|
2311
|
+
),
|
|
2312
|
+
/* @__PURE__ */ React36.createElement(
|
|
2313
|
+
Popover$1,
|
|
2314
|
+
{
|
|
2315
|
+
offset: 8,
|
|
2316
|
+
placement: "bottom start",
|
|
2317
|
+
className: cn("prt-popover", "prt-date-popover")
|
|
2318
|
+
},
|
|
2319
|
+
/* @__PURE__ */ React36.createElement(
|
|
2320
|
+
RangeCalendar,
|
|
2321
|
+
{
|
|
2322
|
+
color,
|
|
2323
|
+
radius,
|
|
2324
|
+
numberOfMonths,
|
|
2325
|
+
showMonthAndYearPickers
|
|
2326
|
+
}
|
|
2327
|
+
)
|
|
2328
|
+
)
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2331
|
+
var AvatarGroupContext = React36.createContext(null);
|
|
2332
|
+
function defaultGetInitials(name) {
|
|
2333
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
2334
|
+
if (parts.length === 0) return "";
|
|
2335
|
+
if (parts.length === 1) return parts[0].slice(0, 2);
|
|
2336
|
+
return parts[0][0] + parts[parts.length - 1][0];
|
|
2337
|
+
}
|
|
2338
|
+
function Avatar({
|
|
2339
|
+
src,
|
|
2340
|
+
alt,
|
|
2341
|
+
name,
|
|
2342
|
+
color,
|
|
2343
|
+
variant,
|
|
2344
|
+
fallback,
|
|
2345
|
+
children,
|
|
2346
|
+
size,
|
|
2347
|
+
className,
|
|
2348
|
+
radius,
|
|
2349
|
+
classNames,
|
|
2350
|
+
styles,
|
|
2351
|
+
style,
|
|
2352
|
+
getInitials = defaultGetInitials,
|
|
2353
|
+
ref,
|
|
2354
|
+
...props
|
|
2355
|
+
}) {
|
|
2356
|
+
const [erroredSrc, setErroredSrc] = React36.useState();
|
|
2357
|
+
const theme = useTheme();
|
|
2358
|
+
const group = React36.useContext(AvatarGroupContext);
|
|
2359
|
+
const defaultColor = React36.useMemo(() => {
|
|
2360
|
+
return supportedColors[hashCode(name || "") % supportedColors.length];
|
|
2361
|
+
}, [name]);
|
|
2362
|
+
const resolvedSize = size ?? group?.size ?? "md";
|
|
2363
|
+
const resolvedVariant = variant ?? group?.variant ?? "light";
|
|
2364
|
+
const resolvedColor = color ?? group?.color ?? defaultColor;
|
|
2365
|
+
function renderContent() {
|
|
2366
|
+
if (src && erroredSrc !== src) {
|
|
2367
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2368
|
+
"img",
|
|
2369
|
+
{
|
|
2370
|
+
className: cn("prt-avatar-img", classNames?.img),
|
|
2371
|
+
style: styles?.img,
|
|
2372
|
+
onError: () => setErroredSrc(src),
|
|
2373
|
+
src,
|
|
2374
|
+
alt: alt ?? name
|
|
2375
|
+
}
|
|
2376
|
+
);
|
|
2377
|
+
}
|
|
2378
|
+
if (children) return children;
|
|
2379
|
+
if (name) {
|
|
2380
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2381
|
+
"span",
|
|
2382
|
+
{
|
|
2383
|
+
className: cn("prt-avatar-fallback", classNames?.fallback),
|
|
2384
|
+
style: styles?.fallback
|
|
2385
|
+
},
|
|
2386
|
+
getInitials(name)
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2389
|
+
return fallback ?? null;
|
|
2390
|
+
}
|
|
2391
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2392
|
+
"div",
|
|
2393
|
+
{
|
|
2394
|
+
style: { ...style, ...styles?.base },
|
|
2395
|
+
className: cn("prt-avatar prt-size", className, classNames?.base),
|
|
2396
|
+
"data-radius": radius ?? theme?.avatarRadiusSize ?? "full",
|
|
2397
|
+
"data-color": resolvedColor,
|
|
2398
|
+
"data-variant": resolvedVariant,
|
|
2399
|
+
"data-interactive": false,
|
|
2400
|
+
"data-size": resolvedSize,
|
|
2401
|
+
role: "img",
|
|
2402
|
+
"aria-label": alt ?? name,
|
|
2403
|
+
ref,
|
|
2404
|
+
...props
|
|
2405
|
+
},
|
|
2406
|
+
renderContent()
|
|
2407
|
+
);
|
|
2408
|
+
}
|
|
2409
|
+
function AvatarGroup({
|
|
2410
|
+
max,
|
|
2411
|
+
size,
|
|
2412
|
+
color,
|
|
2413
|
+
variant,
|
|
2414
|
+
children,
|
|
2415
|
+
className,
|
|
2416
|
+
style,
|
|
2417
|
+
classNames,
|
|
2418
|
+
styles
|
|
2419
|
+
}) {
|
|
2420
|
+
const value = React36.useMemo(
|
|
2421
|
+
() => ({ size, color, variant }),
|
|
2422
|
+
[size, color, variant]
|
|
2423
|
+
);
|
|
2424
|
+
const items = React36.Children.toArray(children);
|
|
2425
|
+
const visible = max != null ? items.slice(0, max) : items;
|
|
2426
|
+
const overflow = max != null ? Math.max(0, items.length - max) : 0;
|
|
2427
|
+
return /* @__PURE__ */ React36.createElement(AvatarGroupContext.Provider, { value }, /* @__PURE__ */ React36.createElement(
|
|
2428
|
+
"div",
|
|
2429
|
+
{
|
|
2430
|
+
className: cn("prt-avatar-group", className, classNames?.wrapper),
|
|
2431
|
+
style: { ...style, ...styles?.wrapper }
|
|
2432
|
+
},
|
|
2433
|
+
visible,
|
|
2434
|
+
overflow > 0 && /* @__PURE__ */ React36.createElement(
|
|
2435
|
+
"div",
|
|
2436
|
+
{
|
|
2437
|
+
className: cn("prt-avatar prt-size", classNames?.overflow),
|
|
2438
|
+
style: styles?.overflow,
|
|
2439
|
+
"data-size": size ?? "md",
|
|
2440
|
+
"data-color": color ?? "gray",
|
|
2441
|
+
"data-variant": variant ?? "light",
|
|
2442
|
+
"data-radius": "full",
|
|
2443
|
+
"data-interactive": false
|
|
2444
|
+
},
|
|
2445
|
+
"+",
|
|
2446
|
+
overflow
|
|
2447
|
+
)
|
|
2448
|
+
));
|
|
2449
|
+
}
|
|
2450
|
+
function convertFileToUpload(file) {
|
|
2451
|
+
return {
|
|
2452
|
+
name: file.name,
|
|
2453
|
+
id: id(),
|
|
2454
|
+
url: URL.createObjectURL(file),
|
|
2455
|
+
status: "success",
|
|
2456
|
+
file
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
function FileUploader({
|
|
2460
|
+
onFileUpload,
|
|
2461
|
+
onRemoveFile,
|
|
2462
|
+
error,
|
|
2463
|
+
label,
|
|
2464
|
+
allowMultiple,
|
|
2465
|
+
uploads: controlledUploads,
|
|
2466
|
+
hideFileList,
|
|
2467
|
+
color = "gray",
|
|
2468
|
+
ref,
|
|
2469
|
+
classNames,
|
|
2470
|
+
styles,
|
|
2471
|
+
className,
|
|
2472
|
+
style
|
|
2473
|
+
}) {
|
|
2474
|
+
const [_uploads, setUploads] = React36.useState([]);
|
|
2475
|
+
const uploads = controlledUploads ?? _uploads;
|
|
2476
|
+
function onUpload(next) {
|
|
2477
|
+
if (isEmptyArray(next)) return;
|
|
2478
|
+
setUploads(next);
|
|
2479
|
+
onFileUpload?.(next);
|
|
2480
|
+
}
|
|
2481
|
+
function handleSelect(files) {
|
|
2482
|
+
if (!files?.length) return;
|
|
2483
|
+
onUpload(Array.from(files).map(convertFileToUpload));
|
|
2484
|
+
}
|
|
2485
|
+
function handleRemoveFile() {
|
|
2486
|
+
setUploads([]);
|
|
2487
|
+
onRemoveFile?.();
|
|
2488
|
+
}
|
|
2489
|
+
function handleRetry() {
|
|
2490
|
+
console.log("retry");
|
|
2491
|
+
}
|
|
2492
|
+
const isIdle = allowMultiple || !allowMultiple && uploads[0]?.status === "idle" || !uploads.length;
|
|
2493
|
+
const isUploading = !allowMultiple && uploads[0]?.status === "loading";
|
|
2494
|
+
const isUploaded = !allowMultiple && uploads[0]?.status === "success";
|
|
2495
|
+
const isFailed = !allowMultiple && uploads[0]?.status === "error";
|
|
2496
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2497
|
+
"div",
|
|
2498
|
+
{
|
|
2499
|
+
ref,
|
|
2500
|
+
className: cn("flex flex-col gap-2.5", classNames?.wrapper, className),
|
|
2501
|
+
style: { ...styles?.wrapper, ...style }
|
|
2502
|
+
},
|
|
2503
|
+
label && /* @__PURE__ */ React36.createElement(InputLabel, null, label),
|
|
2504
|
+
/* @__PURE__ */ React36.createElement(
|
|
2505
|
+
DropZone,
|
|
2506
|
+
{
|
|
2507
|
+
"aria-label": typeof label === "string" ? label : "File upload",
|
|
2508
|
+
onDrop: async (e) => {
|
|
2509
|
+
const fileItems = e.items.filter(
|
|
2510
|
+
(item) => item.kind === "file"
|
|
2511
|
+
);
|
|
2512
|
+
const files = await Promise.all(
|
|
2513
|
+
fileItems.map((item) => item.getFile())
|
|
2514
|
+
);
|
|
2515
|
+
onUpload(files.map(convertFileToUpload));
|
|
2516
|
+
},
|
|
2517
|
+
"data-radius": "lg",
|
|
2518
|
+
"data-color": color,
|
|
2519
|
+
className: cn("prt-file-uploader", classNames?.dropzone),
|
|
2520
|
+
style: { ...styles?.dropzone },
|
|
2521
|
+
"data-state": allowMultiple || !uploads.length ? "idle" : uploads[0]?.status
|
|
2522
|
+
},
|
|
2523
|
+
isIdle && /* @__PURE__ */ React36.createElement(FileTrigger, { allowsMultiple: allowMultiple, onSelect: handleSelect }, /* @__PURE__ */ React36.createElement(Button$1, { className: "prt-file-uploader-trigger" }, /* @__PURE__ */ React36.createElement("div", { className: "flex items-center gap-2.5" }, /* @__PURE__ */ React36.createElement(HiOutlineDocumentAdd, { className: "state-icon", size: 20 }), /* @__PURE__ */ React36.createElement("span", { className: "text-sm text-inherit" }, "Click or drag files here to upload")))),
|
|
2524
|
+
isUploading && /* @__PURE__ */ React36.createElement("div", { className: "flex items-center gap-2.5" }, /* @__PURE__ */ React36.createElement(Loader, { size: "xs" }), /* @__PURE__ */ React36.createElement("span", { className: "text-sm text-inherit" }, "Name_of_file.ext / Uploading...")),
|
|
2525
|
+
isUploaded && /* @__PURE__ */ React36.createElement("div", { className: "flex w-full items-center justify-between" }, /* @__PURE__ */ React36.createElement("div", { className: "flex items-center gap-2.5" }, /* @__PURE__ */ React36.createElement(HiOutlineCheckCircle, { size: 16 }), /* @__PURE__ */ React36.createElement("span", { className: "text-sm text-green-600" }, "File successfully uploaded")), /* @__PURE__ */ React36.createElement(
|
|
2526
|
+
IconButton,
|
|
2527
|
+
{
|
|
2528
|
+
onPress: handleRemoveFile,
|
|
2529
|
+
variant: "outline",
|
|
2530
|
+
color: "green",
|
|
2531
|
+
size: "xs"
|
|
2532
|
+
},
|
|
2533
|
+
/* @__PURE__ */ React36.createElement(HiOutlineTrash, { size: 16 })
|
|
2534
|
+
)),
|
|
2535
|
+
isFailed && /* @__PURE__ */ React36.createElement("div", { className: "flex w-full justify-between" }, /* @__PURE__ */ React36.createElement("div", { className: "flex items-center gap-2.5" }, /* @__PURE__ */ React36.createElement(HiOutlineExclamationCircle, { className: "state-icon" }), /* @__PURE__ */ React36.createElement("span", { className: "text-sm text-red-600" }, "Failed to upload file")), /* @__PURE__ */ React36.createElement(
|
|
2536
|
+
IconButton,
|
|
2537
|
+
{
|
|
2538
|
+
onPress: handleRetry,
|
|
2539
|
+
variant: "outline",
|
|
2540
|
+
color: "tomato",
|
|
2541
|
+
size: "xs"
|
|
2542
|
+
},
|
|
2543
|
+
/* @__PURE__ */ React36.createElement(HiOutlineRefresh, { size: 16 })
|
|
2544
|
+
))
|
|
2545
|
+
),
|
|
2546
|
+
uploads.length > 1 && !hideFileList && /* @__PURE__ */ React36.createElement(
|
|
2547
|
+
"div",
|
|
2548
|
+
{
|
|
2549
|
+
style: { marginTop: 10, ...styles?.list },
|
|
2550
|
+
className: cn("flex flex-col gap-3 upload-list", classNames?.list)
|
|
2551
|
+
},
|
|
2552
|
+
uploads.map((upload) => /* @__PURE__ */ React36.createElement("div", { className: "flex items-center gap-2.5", key: upload.id }, upload.status === "loading" && /* @__PURE__ */ React36.createElement(Loader, null), upload.status === "success" && /* @__PURE__ */ React36.createElement(HiOutlinePaperClip, null), /* @__PURE__ */ React36.createElement("span", { className: "text-sm text-gray-700" }, upload.name)))
|
|
2553
|
+
),
|
|
2554
|
+
error && /* @__PURE__ */ React36.createElement(InputError, null, error)
|
|
2555
|
+
);
|
|
2556
|
+
}
|
|
2557
|
+
function Separator({
|
|
2558
|
+
orientation,
|
|
2559
|
+
className,
|
|
2560
|
+
color,
|
|
2561
|
+
opacity,
|
|
2562
|
+
ref,
|
|
2563
|
+
...props
|
|
2564
|
+
}) {
|
|
2565
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2566
|
+
"div",
|
|
2567
|
+
{
|
|
2568
|
+
"data-opacity": opacity,
|
|
2569
|
+
"data-color": color,
|
|
2570
|
+
"data-orientation": orientation,
|
|
2571
|
+
className: cn(["prt-separator", className]),
|
|
2572
|
+
ref,
|
|
2573
|
+
...props
|
|
2574
|
+
}
|
|
2575
|
+
);
|
|
2576
|
+
}
|
|
2577
|
+
function Progress({
|
|
2578
|
+
height = 2,
|
|
2579
|
+
className,
|
|
2580
|
+
style,
|
|
2581
|
+
classNames,
|
|
2582
|
+
styles,
|
|
2583
|
+
color = "gray",
|
|
2584
|
+
label,
|
|
2585
|
+
ref,
|
|
2586
|
+
...props
|
|
2587
|
+
}) {
|
|
2588
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2589
|
+
ProgressBar,
|
|
2590
|
+
{
|
|
2591
|
+
...props,
|
|
2592
|
+
...typeof label === "string" ? { "aria-label": label } : {},
|
|
2593
|
+
"data-color": color,
|
|
2594
|
+
className: cn("progress-bar", className, classNames?.wrapper),
|
|
2595
|
+
style: { ...style, ...styles?.wrapper }
|
|
2596
|
+
},
|
|
2597
|
+
({ percentage }) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, label && /* @__PURE__ */ React36.createElement(
|
|
2598
|
+
"span",
|
|
2599
|
+
{
|
|
2600
|
+
className: cn("text-sm text-gray-700", classNames?.label),
|
|
2601
|
+
style: { ...styles?.label }
|
|
2602
|
+
},
|
|
2603
|
+
label
|
|
2604
|
+
), /* @__PURE__ */ React36.createElement(
|
|
2605
|
+
"div",
|
|
2606
|
+
{
|
|
2607
|
+
className: cn("progress-wrapper", classNames?.track),
|
|
2608
|
+
style: {
|
|
2609
|
+
height,
|
|
2610
|
+
background: "var(--color-gray-200)",
|
|
2611
|
+
position: "relative",
|
|
2612
|
+
borderRadius: 60,
|
|
2613
|
+
overflow: "hidden",
|
|
2614
|
+
...styles?.track
|
|
2615
|
+
},
|
|
2616
|
+
ref
|
|
2617
|
+
},
|
|
2618
|
+
/* @__PURE__ */ React36.createElement(
|
|
2619
|
+
"div",
|
|
2620
|
+
{
|
|
2621
|
+
className: cn("progress absolute", classNames?.bar),
|
|
2622
|
+
style: {
|
|
2623
|
+
left: 0,
|
|
2624
|
+
top: 0,
|
|
2625
|
+
height: "100%",
|
|
2626
|
+
width: `${percentage ?? 0}%`,
|
|
2627
|
+
background: "var(--c-solid)",
|
|
2628
|
+
transition: "all 0.3s ease",
|
|
2629
|
+
...styles?.bar
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
)
|
|
2633
|
+
))
|
|
2634
|
+
);
|
|
2635
|
+
}
|
|
2636
|
+
function Switch({
|
|
2637
|
+
color = "violet",
|
|
2638
|
+
size = "sm",
|
|
2639
|
+
children,
|
|
2640
|
+
className,
|
|
2641
|
+
style,
|
|
2642
|
+
classNames,
|
|
2643
|
+
styles,
|
|
2644
|
+
...props
|
|
2645
|
+
}) {
|
|
2646
|
+
return /* @__PURE__ */ React36.createElement(SwitchField, { ...props }, /* @__PURE__ */ React36.createElement(
|
|
2647
|
+
SwitchButton,
|
|
2648
|
+
{
|
|
2649
|
+
className: cn(className, "prt-switch-group", classNames?.wrapper),
|
|
2650
|
+
style: { ...style, ...styles?.wrapper }
|
|
2651
|
+
},
|
|
2652
|
+
/* @__PURE__ */ React36.createElement("span", { "data-color": color, "data-size": size, className: "prt-switch track" }, /* @__PURE__ */ React36.createElement(
|
|
2653
|
+
"span",
|
|
2654
|
+
{
|
|
2655
|
+
className: cn("prt-switch-thumb", classNames?.thumb),
|
|
2656
|
+
style: { ...styles?.thumb }
|
|
2657
|
+
}
|
|
2658
|
+
)),
|
|
2659
|
+
children
|
|
2660
|
+
));
|
|
2661
|
+
}
|
|
2662
|
+
function Slider({
|
|
2663
|
+
className,
|
|
2664
|
+
classNames,
|
|
2665
|
+
style,
|
|
2666
|
+
styles,
|
|
2667
|
+
name,
|
|
2668
|
+
size = "sm",
|
|
2669
|
+
color,
|
|
2670
|
+
label,
|
|
2671
|
+
orientation = "horizontal",
|
|
2672
|
+
...props
|
|
2673
|
+
}) {
|
|
2674
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2675
|
+
Slider$1,
|
|
2676
|
+
{
|
|
2677
|
+
...props,
|
|
2678
|
+
orientation,
|
|
2679
|
+
"aria-label": typeof label === "string" ? label : props["aria-label"] ?? "slider",
|
|
2680
|
+
"data-color": color,
|
|
2681
|
+
"data-size": size,
|
|
2682
|
+
style: { ...style, ...styles?.wrapper },
|
|
2683
|
+
className: cn("prt-slider", orientation, className, classNames?.wrapper)
|
|
2684
|
+
},
|
|
2685
|
+
label && /* @__PURE__ */ React36.createElement(InputLabel, { style: styles?.label, className: classNames?.label }, label),
|
|
2686
|
+
/* @__PURE__ */ React36.createElement(
|
|
2687
|
+
SliderTrack,
|
|
2688
|
+
{
|
|
2689
|
+
className: cn("prt-slider-track", classNames?.track),
|
|
2690
|
+
style: styles?.track
|
|
2691
|
+
},
|
|
2692
|
+
({ state }) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
2693
|
+
"div",
|
|
2694
|
+
{
|
|
2695
|
+
style: {
|
|
2696
|
+
...styles?.fill,
|
|
2697
|
+
width: `${state.getThumbPercent(0) * 100}%`
|
|
2698
|
+
},
|
|
2699
|
+
className: cn("prt-slider-track-fill", classNames?.fill)
|
|
2700
|
+
}
|
|
2701
|
+
), /* @__PURE__ */ React36.createElement(
|
|
2702
|
+
SliderThumb,
|
|
2703
|
+
{
|
|
2704
|
+
index: 0,
|
|
2705
|
+
name,
|
|
2706
|
+
className: cn("prt-slider-thumb", classNames?.thumb),
|
|
2707
|
+
style: styles?.thumb
|
|
2708
|
+
},
|
|
2709
|
+
/* @__PURE__ */ React36.createElement(
|
|
2710
|
+
"div",
|
|
2711
|
+
{
|
|
2712
|
+
style: styles?.innerThumb,
|
|
2713
|
+
className: cn("prt-slider-thumb-inner", classNames?.innerThumb)
|
|
2714
|
+
}
|
|
2715
|
+
)
|
|
2716
|
+
))
|
|
2717
|
+
)
|
|
2718
|
+
);
|
|
2719
|
+
}
|
|
2720
|
+
function Sticker({
|
|
2721
|
+
variant = "outline",
|
|
2722
|
+
color = "violet",
|
|
2723
|
+
padded = true,
|
|
2724
|
+
radius,
|
|
2725
|
+
children,
|
|
2726
|
+
ref,
|
|
2727
|
+
className,
|
|
2728
|
+
style,
|
|
2729
|
+
...props
|
|
2730
|
+
}) {
|
|
2731
|
+
const theme = useTheme();
|
|
2732
|
+
return /* @__PURE__ */ React36__default.createElement(
|
|
2733
|
+
"div",
|
|
2734
|
+
{
|
|
2735
|
+
ref,
|
|
2736
|
+
"data-radius": radius ?? theme?.radius ?? "lg",
|
|
2737
|
+
"data-variant": variant,
|
|
2738
|
+
"data-color": color,
|
|
2739
|
+
style,
|
|
2740
|
+
className: cn("inline-flex items-center gap-3", padded && "p-4", className),
|
|
2741
|
+
...props
|
|
2742
|
+
},
|
|
2743
|
+
children
|
|
2744
|
+
);
|
|
2745
|
+
}
|
|
2746
|
+
function Tab(_props) {
|
|
2747
|
+
return null;
|
|
2748
|
+
}
|
|
2749
|
+
function Tabs({
|
|
2750
|
+
className,
|
|
2751
|
+
style,
|
|
2752
|
+
classNames,
|
|
2753
|
+
styles,
|
|
2754
|
+
children,
|
|
2755
|
+
onSelectionChange,
|
|
2756
|
+
...props
|
|
2757
|
+
}) {
|
|
2758
|
+
const theme = useTheme();
|
|
2759
|
+
const tabListRef = React36.useRef(null);
|
|
2760
|
+
const [indicator, setIndicator] = React36.useState({ width: 0, left: 0 });
|
|
2761
|
+
const tabs = [];
|
|
2762
|
+
React36.Children.forEach(children, (child, index) => {
|
|
2763
|
+
if (React36.isValidElement(child)) {
|
|
2764
|
+
tabs.push({
|
|
2765
|
+
id: child.props.id ?? child.key ?? index,
|
|
2766
|
+
title: child.props.title,
|
|
2767
|
+
children: child.props.children,
|
|
2768
|
+
isDisabled: child.props.isDisabled
|
|
2769
|
+
});
|
|
2770
|
+
}
|
|
2771
|
+
});
|
|
2772
|
+
const [activeKey, setActiveKey] = React36.useState(
|
|
2773
|
+
props.selectedKey ?? props.defaultSelectedKey ?? tabs[0]?.id
|
|
2774
|
+
);
|
|
2775
|
+
React36.useEffect(() => {
|
|
2776
|
+
if (props.selectedKey != null) setActiveKey(props.selectedKey);
|
|
2777
|
+
}, [props.selectedKey]);
|
|
2778
|
+
React36.useEffect(() => {
|
|
2779
|
+
const list = tabListRef.current;
|
|
2780
|
+
const selected = list?.querySelector(
|
|
2781
|
+
".prt-tab[data-selected]"
|
|
2782
|
+
);
|
|
2783
|
+
if (list && selected) {
|
|
2784
|
+
const lb = list.getBoundingClientRect();
|
|
2785
|
+
const sb = selected.getBoundingClientRect();
|
|
2786
|
+
setIndicator({ width: sb.width, left: sb.left - lb.left });
|
|
2787
|
+
}
|
|
2788
|
+
}, [activeKey, tabs.length]);
|
|
2789
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2790
|
+
Tabs$1,
|
|
2791
|
+
{
|
|
2792
|
+
...props,
|
|
2793
|
+
onSelectionChange: (key) => {
|
|
2794
|
+
setActiveKey(key);
|
|
2795
|
+
onSelectionChange?.(key);
|
|
2796
|
+
},
|
|
2797
|
+
"data-color": theme?.color ?? "violet",
|
|
2798
|
+
className: cn("prt-tabs", className, classNames?.wrapper),
|
|
2799
|
+
style: { position: "relative", ...style, ...styles?.wrapper }
|
|
2800
|
+
},
|
|
2801
|
+
/* @__PURE__ */ React36.createElement("div", { style: { position: "relative" } }, /* @__PURE__ */ React36.createElement(
|
|
2802
|
+
TabList,
|
|
2803
|
+
{
|
|
2804
|
+
ref: tabListRef,
|
|
2805
|
+
className: cn("prt-tab-list", classNames?.list),
|
|
2806
|
+
style: { ...styles?.list },
|
|
2807
|
+
items: tabs
|
|
2808
|
+
},
|
|
2809
|
+
(tab) => /* @__PURE__ */ React36.createElement(
|
|
2810
|
+
Tab$1,
|
|
2811
|
+
{
|
|
2812
|
+
id: tab.id,
|
|
2813
|
+
className: cn("prt-tab", classNames?.tab),
|
|
2814
|
+
style: { ...styles?.tab },
|
|
2815
|
+
isDisabled: tab.isDisabled
|
|
2816
|
+
},
|
|
2817
|
+
tab.title
|
|
2818
|
+
)
|
|
2819
|
+
), /* @__PURE__ */ React36.createElement(
|
|
2820
|
+
"div",
|
|
2821
|
+
{
|
|
2822
|
+
className: cn("indicator", classNames?.indicator),
|
|
2823
|
+
style: {
|
|
2824
|
+
position: "absolute",
|
|
2825
|
+
left: indicator.left,
|
|
2826
|
+
bottom: 0,
|
|
2827
|
+
background: "var(--color-10)",
|
|
2828
|
+
height: 2,
|
|
2829
|
+
marginBottom: -1,
|
|
2830
|
+
width: indicator.width,
|
|
2831
|
+
transition: "all 0.2s ease",
|
|
2832
|
+
...styles?.indicator
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
)),
|
|
2836
|
+
tabs.map((tab) => /* @__PURE__ */ React36.createElement(
|
|
2837
|
+
TabPanel,
|
|
2838
|
+
{
|
|
2839
|
+
key: String(tab.id),
|
|
2840
|
+
id: tab.id,
|
|
2841
|
+
className: cn(classNames?.panel),
|
|
2842
|
+
style: { ...styles?.panel }
|
|
2843
|
+
},
|
|
2844
|
+
tab.children
|
|
2845
|
+
))
|
|
2846
|
+
);
|
|
2847
|
+
}
|
|
2848
|
+
function defaultRowId(item) {
|
|
2849
|
+
const record = item;
|
|
2850
|
+
return record.id ?? record.key;
|
|
2851
|
+
}
|
|
2852
|
+
function Table({
|
|
2853
|
+
columns,
|
|
2854
|
+
data,
|
|
2855
|
+
getRowId = defaultRowId,
|
|
2856
|
+
selectionMode = "none",
|
|
2857
|
+
selectedKeys,
|
|
2858
|
+
onSelectionChange,
|
|
2859
|
+
sortDescriptor,
|
|
2860
|
+
onSortChange,
|
|
2861
|
+
renderEmptyState,
|
|
2862
|
+
radius,
|
|
2863
|
+
className,
|
|
2864
|
+
classNames,
|
|
2865
|
+
style,
|
|
2866
|
+
styles,
|
|
2867
|
+
...props
|
|
2868
|
+
}) {
|
|
2869
|
+
const racColumns = React36.useMemo(
|
|
2870
|
+
() => columns.map((column) => ({ ...column, id: column.key })),
|
|
2871
|
+
[columns]
|
|
2872
|
+
);
|
|
2873
|
+
const firstColumnKey = columns[0]?.key;
|
|
2874
|
+
const [internalSort, setInternalSort] = React36.useState();
|
|
2875
|
+
const activeSort = onSortChange ? sortDescriptor : internalSort;
|
|
2876
|
+
const rows = React36.useMemo(() => {
|
|
2877
|
+
if (onSortChange || !activeSort) return data;
|
|
2878
|
+
const column = columns.find((c) => c.key === activeSort.column);
|
|
2879
|
+
if (!column) return data;
|
|
2880
|
+
return [...data].sort((a, b) => {
|
|
2881
|
+
const av = a[column.dataIndex];
|
|
2882
|
+
const bv = b[column.dataIndex];
|
|
2883
|
+
const cmp = av < bv ? -1 : av > bv ? 1 : 0;
|
|
2884
|
+
return activeSort.direction === "descending" ? -cmp : cmp;
|
|
2885
|
+
});
|
|
2886
|
+
}, [data, columns, activeSort, onSortChange]);
|
|
2887
|
+
return /* @__PURE__ */ React36.createElement(
|
|
2888
|
+
Table$1,
|
|
2889
|
+
{
|
|
2890
|
+
...props,
|
|
2891
|
+
selectionMode,
|
|
2892
|
+
selectedKeys,
|
|
2893
|
+
onSelectionChange,
|
|
2894
|
+
sortDescriptor: activeSort,
|
|
2895
|
+
onSortChange: onSortChange ?? setInternalSort,
|
|
2896
|
+
"data-radius": radius,
|
|
2897
|
+
className: cn("prt-table", className, classNames?.wrapper),
|
|
2898
|
+
style: { ...style, ...styles?.wrapper }
|
|
2899
|
+
},
|
|
2900
|
+
/* @__PURE__ */ React36.createElement(
|
|
2901
|
+
TableHeader,
|
|
2902
|
+
{
|
|
2903
|
+
columns: racColumns,
|
|
2904
|
+
className: cn("prt-table-header", classNames?.header)
|
|
2905
|
+
},
|
|
2906
|
+
(column) => /* @__PURE__ */ React36.createElement(
|
|
2907
|
+
Column,
|
|
2908
|
+
{
|
|
2909
|
+
isRowHeader: column.key === firstColumnKey,
|
|
2910
|
+
allowsSorting: column.allowSorting,
|
|
2911
|
+
className: cn("prt-table-column", classNames?.column),
|
|
2912
|
+
style: styles?.column
|
|
2913
|
+
},
|
|
2914
|
+
({ allowsSorting, sortDirection }) => /* @__PURE__ */ React36.createElement("div", { className: "prt-table-column-header" }, /* @__PURE__ */ React36.createElement("span", null, column.title), allowsSorting && sortDirection && /* @__PURE__ */ React36.createElement("span", { "aria-hidden": "true", className: "prt-table-sort-indicator" }, sortDirection === "ascending" ? /* @__PURE__ */ React36.createElement(HiChevronUp, { size: 14 }) : /* @__PURE__ */ React36.createElement(HiChevronDown, { size: 14 })))
|
|
2915
|
+
)
|
|
2916
|
+
),
|
|
2917
|
+
/* @__PURE__ */ React36.createElement(
|
|
2918
|
+
TableBody,
|
|
2919
|
+
{
|
|
2920
|
+
items: rows,
|
|
2921
|
+
dependencies: [columns],
|
|
2922
|
+
renderEmptyState: renderEmptyState ? () => /* @__PURE__ */ React36.createElement(React36.Fragment, null, renderEmptyState()) : void 0
|
|
2923
|
+
},
|
|
2924
|
+
(item) => /* @__PURE__ */ React36.createElement(
|
|
2925
|
+
Row,
|
|
2926
|
+
{
|
|
2927
|
+
id: getRowId(item),
|
|
2928
|
+
columns: racColumns,
|
|
2929
|
+
className: cn("prt-table-row", classNames?.row),
|
|
2930
|
+
style: styles?.row
|
|
2931
|
+
},
|
|
2932
|
+
(column) => /* @__PURE__ */ React36.createElement(
|
|
2933
|
+
Cell,
|
|
2934
|
+
{
|
|
2935
|
+
className: cn("prt-table-cell", classNames?.cell),
|
|
2936
|
+
style: styles?.cell
|
|
2937
|
+
},
|
|
2938
|
+
column.render ? column.render(item[column.dataIndex], item) : item[column.dataIndex]
|
|
2939
|
+
)
|
|
2940
|
+
)
|
|
2941
|
+
)
|
|
2942
|
+
);
|
|
2943
|
+
}
|
|
2944
|
+
function Timeline({
|
|
2945
|
+
items,
|
|
2946
|
+
render,
|
|
2947
|
+
labelKey,
|
|
2948
|
+
getIndicator,
|
|
2949
|
+
hideLastItemTail = true,
|
|
2950
|
+
classNames,
|
|
2951
|
+
styles,
|
|
2952
|
+
className,
|
|
2953
|
+
style
|
|
2954
|
+
}) {
|
|
2955
|
+
return /* @__PURE__ */ React36__default.createElement(
|
|
2956
|
+
"div",
|
|
2957
|
+
{
|
|
2958
|
+
className: cn(classNames?.wrapper, className),
|
|
2959
|
+
style: { ...styles?.wrapper, ...style }
|
|
2960
|
+
},
|
|
2961
|
+
items.map((item, index) => {
|
|
2962
|
+
const indicator = getIndicator?.(item) ?? /* @__PURE__ */ React36__default.createElement("div", { className: "prt-timeline-indicator", "data-variant": "outline" });
|
|
2963
|
+
const content = render?.(item) ?? item[labelKey];
|
|
2964
|
+
const isLast = index === items.length - 1;
|
|
2965
|
+
return /* @__PURE__ */ React36__default.createElement(
|
|
2966
|
+
"div",
|
|
2967
|
+
{
|
|
2968
|
+
className: cn("flex gap-3 prt-timeline-item", classNames?.item),
|
|
2969
|
+
style: { ...styles?.item },
|
|
2970
|
+
key: index
|
|
2971
|
+
},
|
|
2972
|
+
/* @__PURE__ */ React36__default.createElement("div", { className: "flex flex-col items-center gap-3" }, /* @__PURE__ */ React36__default.createElement("div", { className: "flex gap-3 prt-timeline-indicator-container" }, indicator), isLast && hideLastItemTail ? null : /* @__PURE__ */ React36__default.createElement("div", { className: "prt-timeline-item-tail" })),
|
|
2973
|
+
/* @__PURE__ */ React36__default.createElement(
|
|
2974
|
+
"div",
|
|
2975
|
+
{
|
|
2976
|
+
className: cn(
|
|
2977
|
+
"flex w-full gap-3 prt-timeline-item-content",
|
|
2978
|
+
classNames?.content
|
|
2979
|
+
),
|
|
2980
|
+
style: { ...styles?.content }
|
|
2981
|
+
},
|
|
2982
|
+
content
|
|
2983
|
+
)
|
|
2984
|
+
);
|
|
2985
|
+
})
|
|
2986
|
+
);
|
|
2987
|
+
}
|
|
2988
|
+
function Modal({
|
|
2989
|
+
variant = "modal",
|
|
2990
|
+
radius,
|
|
2991
|
+
isDismissable = true,
|
|
2992
|
+
width = 400,
|
|
2993
|
+
title,
|
|
2994
|
+
description,
|
|
2995
|
+
onConfirm,
|
|
2996
|
+
onCancel,
|
|
2997
|
+
confirmLabel = "Confirm",
|
|
2998
|
+
cancelLabel = "Cancel",
|
|
2999
|
+
confirmButtonProps,
|
|
3000
|
+
cancelButtonProps,
|
|
3001
|
+
showCloseButton = true,
|
|
3002
|
+
hideTitle,
|
|
3003
|
+
onClose,
|
|
3004
|
+
children,
|
|
3005
|
+
className,
|
|
3006
|
+
style,
|
|
3007
|
+
classNames,
|
|
3008
|
+
styles,
|
|
3009
|
+
...props
|
|
3010
|
+
}) {
|
|
3011
|
+
const theme = useTheme();
|
|
3012
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3013
|
+
ModalOverlay,
|
|
3014
|
+
{
|
|
3015
|
+
...props,
|
|
3016
|
+
isDismissable,
|
|
3017
|
+
style: styles?.underlay,
|
|
3018
|
+
className: cn("prt-modal-underlay", classNames?.underlay)
|
|
3019
|
+
},
|
|
3020
|
+
/* @__PURE__ */ React36.createElement(
|
|
3021
|
+
Modal$1,
|
|
3022
|
+
{
|
|
3023
|
+
"data-variant": variant,
|
|
3024
|
+
style: styles?.wrapper,
|
|
3025
|
+
className: cn("prt-modal-container", classNames?.wrapper)
|
|
3026
|
+
},
|
|
3027
|
+
/* @__PURE__ */ React36.createElement(
|
|
3028
|
+
Dialog,
|
|
3029
|
+
{
|
|
3030
|
+
"aria-label": typeof title === "string" ? title : void 0,
|
|
3031
|
+
"data-radius": radius ?? theme?.radius ?? "md",
|
|
3032
|
+
className: cn("prt-modal-content", className, classNames?.content),
|
|
3033
|
+
style: { width, ...style, ...styles?.content }
|
|
3034
|
+
},
|
|
3035
|
+
({ close }) => /* @__PURE__ */ React36.createElement(React36.Fragment, null, !hideTitle && /* @__PURE__ */ React36.createElement(
|
|
3036
|
+
"header",
|
|
3037
|
+
{
|
|
3038
|
+
style: styles?.header,
|
|
3039
|
+
className: cn(
|
|
3040
|
+
"prt-modal-head flex items-center justify-between gap-8",
|
|
3041
|
+
classNames?.header
|
|
3042
|
+
)
|
|
3043
|
+
},
|
|
3044
|
+
/* @__PURE__ */ React36.createElement("div", { className: "flex flex-col gap-1" }, title && /* @__PURE__ */ React36.createElement(
|
|
3045
|
+
"div",
|
|
3046
|
+
{
|
|
3047
|
+
style: styles?.title,
|
|
3048
|
+
className: cn(
|
|
3049
|
+
"prt-modal-title font-medium text-base text-black",
|
|
3050
|
+
classNames?.title
|
|
3051
|
+
)
|
|
3052
|
+
},
|
|
3053
|
+
title
|
|
3054
|
+
), description && /* @__PURE__ */ React36.createElement("div", { className: "text-xs leading-normal text-gray-500" }, description)),
|
|
3055
|
+
showCloseButton && /* @__PURE__ */ React36.createElement(
|
|
3056
|
+
IconButton,
|
|
3057
|
+
{
|
|
3058
|
+
variant: "ghost",
|
|
3059
|
+
color: "gray",
|
|
3060
|
+
size: "sm",
|
|
3061
|
+
onPress: () => {
|
|
3062
|
+
onClose?.();
|
|
3063
|
+
close();
|
|
3064
|
+
}
|
|
3065
|
+
},
|
|
3066
|
+
/* @__PURE__ */ React36.createElement(HiX, { size: 18 })
|
|
3067
|
+
)
|
|
3068
|
+
), /* @__PURE__ */ React36.createElement(
|
|
3069
|
+
"div",
|
|
3070
|
+
{
|
|
3071
|
+
className: cn(
|
|
3072
|
+
"prt-modal-body flex flex-col gap-3",
|
|
3073
|
+
classNames?.body
|
|
3074
|
+
),
|
|
3075
|
+
style: styles?.body
|
|
3076
|
+
},
|
|
3077
|
+
children
|
|
3078
|
+
), (onConfirm || onCancel) && /* @__PURE__ */ React36.createElement(
|
|
3079
|
+
"footer",
|
|
3080
|
+
{
|
|
3081
|
+
style: styles?.footer,
|
|
3082
|
+
className: cn(
|
|
3083
|
+
"prt-modal-footer flex w-full justify-end gap-2.5",
|
|
3084
|
+
classNames?.footer
|
|
3085
|
+
)
|
|
3086
|
+
},
|
|
3087
|
+
onCancel && /* @__PURE__ */ React36.createElement(
|
|
3088
|
+
Button,
|
|
3089
|
+
{
|
|
3090
|
+
onPress: () => {
|
|
3091
|
+
onCancel();
|
|
3092
|
+
close();
|
|
3093
|
+
},
|
|
3094
|
+
variant: "outline",
|
|
3095
|
+
color: "gray",
|
|
3096
|
+
...cancelButtonProps
|
|
3097
|
+
},
|
|
3098
|
+
cancelLabel
|
|
3099
|
+
),
|
|
3100
|
+
onConfirm && /* @__PURE__ */ React36.createElement(Button, { onPress: onConfirm, ...confirmButtonProps }, confirmLabel)
|
|
3101
|
+
))
|
|
3102
|
+
)
|
|
3103
|
+
)
|
|
3104
|
+
);
|
|
3105
|
+
}
|
|
3106
|
+
function useModal(props = {}) {
|
|
3107
|
+
return useOverlayTriggerState(props);
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
// src/utils/regex.ts
|
|
3111
|
+
var EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
3112
|
+
function useControlledState(value, defaultValue, onChange) {
|
|
3113
|
+
const [state, setState] = React36.useState(value || defaultValue);
|
|
3114
|
+
const isControlled = !isUndefinedOrNull(value);
|
|
3115
|
+
const controlledValue = isControlled ? value : state;
|
|
3116
|
+
const setValue = React36.useCallback(
|
|
3117
|
+
(value2) => {
|
|
3118
|
+
if (!isControlled) {
|
|
3119
|
+
setState(value2);
|
|
3120
|
+
}
|
|
3121
|
+
if (!Object.is(controlledValue, value2)) {
|
|
3122
|
+
onChange?.(value2);
|
|
3123
|
+
}
|
|
3124
|
+
},
|
|
3125
|
+
[isControlled, controlledValue]
|
|
3126
|
+
);
|
|
3127
|
+
return [controlledValue, setValue];
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
// src/components/tag-input/tag-input.tsx
|
|
3131
|
+
function isValidUrl(value) {
|
|
3132
|
+
const candidate = /^https?:\/\//.test(value) ? value : `https://${value}`;
|
|
3133
|
+
try {
|
|
3134
|
+
new URL(candidate);
|
|
3135
|
+
return /\./.test(value);
|
|
3136
|
+
} catch {
|
|
3137
|
+
return false;
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
var FORMAT_VALIDATORS = {
|
|
3141
|
+
text: (value) => value.trim().length > 0,
|
|
3142
|
+
email: (value) => EMAIL_REGEX.test(value),
|
|
3143
|
+
url: isValidUrl,
|
|
3144
|
+
number: (value) => value.trim() !== "" && !Number.isNaN(Number(value))
|
|
3145
|
+
};
|
|
3146
|
+
var SHAPE_RADIUS = {
|
|
3147
|
+
pill: "full",
|
|
3148
|
+
rounded: "md",
|
|
3149
|
+
sharp: "none"
|
|
3150
|
+
};
|
|
3151
|
+
function dedupe(values) {
|
|
3152
|
+
if (!values) return void 0;
|
|
3153
|
+
return Array.from(new Set(values));
|
|
3154
|
+
}
|
|
3155
|
+
function escapeRegExp(value) {
|
|
3156
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3157
|
+
}
|
|
3158
|
+
function TagInput({
|
|
3159
|
+
appearance = "outline",
|
|
3160
|
+
size = "md",
|
|
3161
|
+
label,
|
|
3162
|
+
error,
|
|
3163
|
+
description,
|
|
3164
|
+
placeholder,
|
|
3165
|
+
tags,
|
|
3166
|
+
defaultTags,
|
|
3167
|
+
format = "text",
|
|
3168
|
+
validate,
|
|
3169
|
+
delimiters = [","],
|
|
3170
|
+
isRequired,
|
|
3171
|
+
tagColor = "gray",
|
|
3172
|
+
tagVariant = "light",
|
|
3173
|
+
tagShape = "rounded",
|
|
3174
|
+
tagSize = "md",
|
|
3175
|
+
color = "gray",
|
|
3176
|
+
radius,
|
|
3177
|
+
validationStatus,
|
|
3178
|
+
className,
|
|
3179
|
+
classNames,
|
|
3180
|
+
style,
|
|
3181
|
+
styles,
|
|
3182
|
+
onChange,
|
|
3183
|
+
onInputValueChange,
|
|
3184
|
+
renderTag,
|
|
3185
|
+
ref
|
|
3186
|
+
}) {
|
|
3187
|
+
const [inputValue, setInputValue] = React36.useState("");
|
|
3188
|
+
const [values, setValues] = useControlledState(
|
|
3189
|
+
dedupe(tags),
|
|
3190
|
+
dedupe(defaultTags) ?? [],
|
|
3191
|
+
onChange
|
|
3192
|
+
);
|
|
3193
|
+
const inputRef = React36.useRef(null);
|
|
3194
|
+
const isValid = validate ?? FORMAT_VALIDATORS[format];
|
|
3195
|
+
const splitPattern = React36.useMemo(
|
|
3196
|
+
() => new RegExp(`[${delimiters.map(escapeRegExp).join("")}\\n]`),
|
|
3197
|
+
[delimiters]
|
|
3198
|
+
);
|
|
3199
|
+
function commit(raw) {
|
|
3200
|
+
const candidates = raw.split(splitPattern).map((v) => v.trim()).filter(Boolean).filter(isValid);
|
|
3201
|
+
if (!candidates.length) return;
|
|
3202
|
+
setValues(Array.from(/* @__PURE__ */ new Set([...values, ...candidates])));
|
|
3203
|
+
setInputValue("");
|
|
3204
|
+
}
|
|
3205
|
+
function removeValue(value) {
|
|
3206
|
+
setValues(values.filter((v) => v !== value));
|
|
3207
|
+
}
|
|
3208
|
+
function handleInputChange(value) {
|
|
3209
|
+
if (delimiters.some((d) => value.includes(d))) {
|
|
3210
|
+
const parts = value.split(splitPattern);
|
|
3211
|
+
const trailing = parts.pop() ?? "";
|
|
3212
|
+
commit(parts.join(","));
|
|
3213
|
+
setInputValue(trailing);
|
|
3214
|
+
onInputValueChange?.(trailing);
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
setInputValue(value);
|
|
3218
|
+
onInputValueChange?.(value);
|
|
3219
|
+
}
|
|
3220
|
+
function onKeyDown(e) {
|
|
3221
|
+
if (e.key === "Enter") {
|
|
3222
|
+
e.preventDefault();
|
|
3223
|
+
commit(inputValue);
|
|
3224
|
+
return;
|
|
3225
|
+
}
|
|
3226
|
+
if (e.key === "Backspace" && !inputValue && values.length) {
|
|
3227
|
+
removeValue(values[values.length - 1]);
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
function captureFocus() {
|
|
3231
|
+
inputRef.current?.focus();
|
|
3232
|
+
}
|
|
3233
|
+
const groupLabel = typeof label === "string" ? label : "tags";
|
|
3234
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3235
|
+
TextField,
|
|
3236
|
+
{
|
|
3237
|
+
value: inputValue,
|
|
3238
|
+
onChange: handleInputChange,
|
|
3239
|
+
isRequired,
|
|
3240
|
+
isInvalid: !!error
|
|
3241
|
+
},
|
|
3242
|
+
/* @__PURE__ */ React36.createElement(
|
|
3243
|
+
Field,
|
|
3244
|
+
{
|
|
3245
|
+
replaceDefaultControlWrapper: true,
|
|
3246
|
+
label,
|
|
3247
|
+
error,
|
|
3248
|
+
description,
|
|
3249
|
+
color,
|
|
3250
|
+
size,
|
|
3251
|
+
radius,
|
|
3252
|
+
appearance,
|
|
3253
|
+
validationStatus,
|
|
3254
|
+
className,
|
|
3255
|
+
classNames,
|
|
3256
|
+
style,
|
|
3257
|
+
styles
|
|
3258
|
+
},
|
|
3259
|
+
/* @__PURE__ */ React36.createElement(
|
|
3260
|
+
"div",
|
|
3261
|
+
{
|
|
3262
|
+
ref,
|
|
3263
|
+
className: cn("prt-input-control", "prt-tag-field"),
|
|
3264
|
+
"data-appearance": appearance,
|
|
3265
|
+
onClick: captureFocus
|
|
3266
|
+
},
|
|
3267
|
+
/* @__PURE__ */ React36.createElement(
|
|
3268
|
+
TagGroup$1,
|
|
3269
|
+
{
|
|
3270
|
+
"aria-label": groupLabel,
|
|
3271
|
+
className: "prt-tag-field-group",
|
|
3272
|
+
onRemove: (keys) => setValues(values.filter((v) => !keys.has(v)))
|
|
3273
|
+
},
|
|
3274
|
+
/* @__PURE__ */ React36.createElement(TagList, { className: "prt-tag-field-list" }, values.map((value) => /* @__PURE__ */ React36.createElement(
|
|
3275
|
+
Tag$1,
|
|
3276
|
+
{
|
|
3277
|
+
key: value,
|
|
3278
|
+
id: value,
|
|
3279
|
+
textValue: value,
|
|
3280
|
+
className: "prt-tag-field-tag"
|
|
3281
|
+
},
|
|
3282
|
+
renderTag ? renderTag(value, removeValue) : /* @__PURE__ */ React36.createElement(
|
|
3283
|
+
Tag,
|
|
3284
|
+
{
|
|
3285
|
+
variant: tagVariant,
|
|
3286
|
+
color: tagColor,
|
|
3287
|
+
radius: tagShape ? SHAPE_RADIUS[tagShape] : "full",
|
|
3288
|
+
size: tagSize,
|
|
3289
|
+
append: /* @__PURE__ */ React36.createElement(
|
|
3290
|
+
Button$1,
|
|
3291
|
+
{
|
|
3292
|
+
slot: "remove",
|
|
3293
|
+
className: "prt-tag-field-remove",
|
|
3294
|
+
"aria-label": `Remove ${value}`
|
|
3295
|
+
},
|
|
3296
|
+
/* @__PURE__ */ React36.createElement(HiX, { size: 14 })
|
|
3297
|
+
)
|
|
3298
|
+
},
|
|
3299
|
+
value
|
|
3300
|
+
)
|
|
3301
|
+
)))
|
|
3302
|
+
),
|
|
3303
|
+
/* @__PURE__ */ React36.createElement(
|
|
3304
|
+
Input$1,
|
|
3305
|
+
{
|
|
3306
|
+
ref: inputRef,
|
|
3307
|
+
placeholder,
|
|
3308
|
+
onKeyDown,
|
|
3309
|
+
className: "prt-tag-field-input"
|
|
3310
|
+
}
|
|
3311
|
+
)
|
|
3312
|
+
)
|
|
3313
|
+
)
|
|
3314
|
+
);
|
|
3315
|
+
}
|
|
3316
|
+
var PopoverContext = React36.createContext(null);
|
|
3317
|
+
function usePopoverContext(component) {
|
|
3318
|
+
const ctx = React36.useContext(PopoverContext);
|
|
3319
|
+
if (!ctx) {
|
|
3320
|
+
throw new Error(`${component} must be used within a Popover`);
|
|
3321
|
+
}
|
|
3322
|
+
return ctx;
|
|
3323
|
+
}
|
|
3324
|
+
function Popover({ children, ...props }) {
|
|
3325
|
+
const triggerRef = React36.useRef(null);
|
|
3326
|
+
const state = useOverlayTriggerState(props);
|
|
3327
|
+
return /* @__PURE__ */ React36.createElement(PopoverContext.Provider, { value: { triggerRef, state } }, children);
|
|
3328
|
+
}
|
|
3329
|
+
function PopoverTrigger({ children }) {
|
|
3330
|
+
const ctx = usePopoverContext("PopoverTrigger");
|
|
3331
|
+
return React36.cloneElement(children, {
|
|
3332
|
+
ref: ctx.triggerRef,
|
|
3333
|
+
onPress: () => ctx.state.toggle()
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
function PopoverContent({
|
|
3337
|
+
children,
|
|
3338
|
+
offset = 12,
|
|
3339
|
+
placement,
|
|
3340
|
+
style,
|
|
3341
|
+
className,
|
|
3342
|
+
classNames,
|
|
3343
|
+
styles,
|
|
3344
|
+
width,
|
|
3345
|
+
...props
|
|
3346
|
+
}) {
|
|
3347
|
+
const ctx = usePopoverContext("PopoverContent");
|
|
3348
|
+
const theme = useTheme();
|
|
3349
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3350
|
+
Popover$1,
|
|
3351
|
+
{
|
|
3352
|
+
...props,
|
|
3353
|
+
triggerRef: ctx.triggerRef,
|
|
3354
|
+
isOpen: ctx.state.isOpen,
|
|
3355
|
+
onOpenChange: ctx.state.setOpen,
|
|
3356
|
+
offset,
|
|
3357
|
+
placement,
|
|
3358
|
+
"data-color": theme?.color,
|
|
3359
|
+
"data-radius": theme?.radius,
|
|
3360
|
+
className: cn("prt-popover", classNames?.popover),
|
|
3361
|
+
style: { ...width != null ? { width } : null, ...styles?.popover }
|
|
3362
|
+
},
|
|
3363
|
+
/* @__PURE__ */ React36.createElement(
|
|
3364
|
+
"div",
|
|
3365
|
+
{
|
|
3366
|
+
"data-radius": "md",
|
|
3367
|
+
className: cn("prt-popover-content", className, classNames?.content),
|
|
3368
|
+
style: { ...style, ...styles?.content }
|
|
3369
|
+
},
|
|
3370
|
+
children
|
|
3371
|
+
)
|
|
3372
|
+
);
|
|
3373
|
+
}
|
|
3374
|
+
var TagGroupVariantContext = React36.createContext({});
|
|
3375
|
+
function TagGroup({
|
|
3376
|
+
label,
|
|
3377
|
+
description,
|
|
3378
|
+
errorMessage,
|
|
3379
|
+
items,
|
|
3380
|
+
children,
|
|
3381
|
+
renderEmptyState,
|
|
3382
|
+
activeColor,
|
|
3383
|
+
activeVariant,
|
|
3384
|
+
idleColor,
|
|
3385
|
+
idleVariant,
|
|
3386
|
+
autoColor,
|
|
3387
|
+
classNames,
|
|
3388
|
+
styles,
|
|
3389
|
+
className,
|
|
3390
|
+
style,
|
|
3391
|
+
...props
|
|
3392
|
+
}) {
|
|
3393
|
+
const variants = React36.useMemo(
|
|
3394
|
+
() => ({ activeColor, activeVariant, idleColor, idleVariant, autoColor }),
|
|
3395
|
+
[activeColor, activeVariant, idleColor, idleVariant, autoColor]
|
|
3396
|
+
);
|
|
3397
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3398
|
+
TagGroup$1,
|
|
3399
|
+
{
|
|
3400
|
+
...props,
|
|
3401
|
+
"aria-label": typeof label === "string" ? label : void 0
|
|
3402
|
+
},
|
|
3403
|
+
/* @__PURE__ */ React36.createElement(
|
|
3404
|
+
"div",
|
|
3405
|
+
{
|
|
3406
|
+
className: cn("flex flex-col gap-3 tag-group", classNames?.wrapper, className),
|
|
3407
|
+
style: { ...styles?.wrapper, ...style }
|
|
3408
|
+
},
|
|
3409
|
+
label && /* @__PURE__ */ React36.createElement(InputLabel, null, label),
|
|
3410
|
+
/* @__PURE__ */ React36.createElement(TagGroupVariantContext.Provider, { value: variants }, /* @__PURE__ */ React36.createElement(
|
|
3411
|
+
TagList,
|
|
3412
|
+
{
|
|
3413
|
+
items,
|
|
3414
|
+
renderEmptyState,
|
|
3415
|
+
className: cn("prt-tag-list", classNames?.list),
|
|
3416
|
+
style: { display: "flex", flexWrap: "wrap", gap: 6, ...styles?.list }
|
|
3417
|
+
},
|
|
3418
|
+
children
|
|
3419
|
+
)),
|
|
3420
|
+
errorMessage && /* @__PURE__ */ React36.createElement(InputError, null, errorMessage),
|
|
3421
|
+
description && /* @__PURE__ */ React36.createElement("div", { className: "text-sm text-gray-700" }, description)
|
|
3422
|
+
)
|
|
3423
|
+
);
|
|
3424
|
+
}
|
|
3425
|
+
function TagGroupItem({
|
|
3426
|
+
children,
|
|
3427
|
+
textValue,
|
|
3428
|
+
...props
|
|
3429
|
+
}) {
|
|
3430
|
+
const theme = useTheme();
|
|
3431
|
+
const {
|
|
3432
|
+
activeColor,
|
|
3433
|
+
activeVariant = "solid",
|
|
3434
|
+
idleColor = "gray",
|
|
3435
|
+
idleVariant = "outline",
|
|
3436
|
+
autoColor
|
|
3437
|
+
} = React36.useContext(TagGroupVariantContext);
|
|
3438
|
+
const resolvedActive = activeColor ?? theme?.color ?? "gray";
|
|
3439
|
+
const tv = textValue ?? (typeof children === "string" ? children : void 0);
|
|
3440
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3441
|
+
Tag$1,
|
|
3442
|
+
{
|
|
3443
|
+
...props,
|
|
3444
|
+
textValue: tv,
|
|
3445
|
+
render: (domProps, { isSelected }) => {
|
|
3446
|
+
const color = autoColor ? getRandomColor(String(tv ?? "")) : isSelected ? resolvedActive : idleColor;
|
|
3447
|
+
const variant = isSelected ? activeVariant : idleVariant;
|
|
3448
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3449
|
+
"div",
|
|
3450
|
+
{
|
|
3451
|
+
...domProps,
|
|
3452
|
+
"data-is-toggle": "true",
|
|
3453
|
+
"data-radius": "full",
|
|
3454
|
+
"data-size": "sm",
|
|
3455
|
+
"data-color": color,
|
|
3456
|
+
"data-variant": variant,
|
|
3457
|
+
className: "prt-button prt-size"
|
|
3458
|
+
},
|
|
3459
|
+
children
|
|
3460
|
+
);
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
);
|
|
3464
|
+
}
|
|
3465
|
+
function ColorPicker({
|
|
3466
|
+
onChange,
|
|
3467
|
+
color: colorProp,
|
|
3468
|
+
styles,
|
|
3469
|
+
classNames,
|
|
3470
|
+
className,
|
|
3471
|
+
style
|
|
3472
|
+
}) {
|
|
3473
|
+
const [colorSpace, setColorSpace] = React36.useState("hex");
|
|
3474
|
+
const [color, setColor] = useControlledState(
|
|
3475
|
+
colorProp,
|
|
3476
|
+
parseColor("#BB66CC").toFormat("hsla"),
|
|
3477
|
+
onChange
|
|
3478
|
+
);
|
|
3479
|
+
function handleChange(color2) {
|
|
3480
|
+
setColor(color2);
|
|
3481
|
+
onChange?.(color2);
|
|
3482
|
+
}
|
|
3483
|
+
function setAlpha(alpha) {
|
|
3484
|
+
if (isNaN(alpha)) {
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
const newColor = color.withChannelValue("alpha", alpha);
|
|
3488
|
+
setColor(newColor);
|
|
3489
|
+
}
|
|
3490
|
+
const [h, s, l] = color.getColorChannels();
|
|
3491
|
+
const rgbaColor = color.toFormat("rgba");
|
|
3492
|
+
const [r, g, b] = rgbaColor.getColorChannels();
|
|
3493
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3494
|
+
"div",
|
|
3495
|
+
{
|
|
3496
|
+
className: cn("flex flex-col gap-3", className, classNames?.wrapper),
|
|
3497
|
+
style: { width: 240, ...style, ...styles?.wrapper }
|
|
3498
|
+
},
|
|
3499
|
+
/* @__PURE__ */ React36.createElement(
|
|
3500
|
+
ColorArea,
|
|
3501
|
+
{
|
|
3502
|
+
onChange: handleChange,
|
|
3503
|
+
onChangeEnd: handleChange,
|
|
3504
|
+
xChannel: s,
|
|
3505
|
+
yChannel: l,
|
|
3506
|
+
value: color ?? parseColor("hsl(219, 79%, 66%)"),
|
|
3507
|
+
style: { width: "100%", height: 140 }
|
|
3508
|
+
}
|
|
3509
|
+
),
|
|
3510
|
+
/* @__PURE__ */ React36.createElement("div", { className: "flex flex-col gap-3", style: { padding: 8 } }, /* @__PURE__ */ React36.createElement("div", { className: "flex flex-col gap-2" }, /* @__PURE__ */ React36.createElement(
|
|
3511
|
+
ColorSlider,
|
|
3512
|
+
{
|
|
3513
|
+
value: color,
|
|
3514
|
+
onChange: handleChange,
|
|
3515
|
+
onChangeEnd: handleChange,
|
|
3516
|
+
channel: h
|
|
3517
|
+
}
|
|
3518
|
+
), /* @__PURE__ */ React36.createElement(
|
|
3519
|
+
ColorSlider,
|
|
3520
|
+
{
|
|
3521
|
+
value: color,
|
|
3522
|
+
onChange: handleChange,
|
|
3523
|
+
onChangeEnd: handleChange,
|
|
3524
|
+
channel: "alpha"
|
|
3525
|
+
}
|
|
3526
|
+
)), /* @__PURE__ */ React36.createElement("div", { className: "flex flex-col gap-3" }, /* @__PURE__ */ React36.createElement("div", { className: "flex gap-1", style: { width: "100%" } }, colorSpace === "hex" && /* @__PURE__ */ React36.createElement(Space, { style: { gap: 3 }, compact: true }, /* @__PURE__ */ React36.createElement(
|
|
3527
|
+
ColorField,
|
|
3528
|
+
{
|
|
3529
|
+
value: color,
|
|
3530
|
+
onChange: (c) => c && handleChange(c),
|
|
3531
|
+
size: "sm",
|
|
3532
|
+
style: { width: "60%" },
|
|
3533
|
+
appearance: "filled",
|
|
3534
|
+
placeholder: "Add a color"
|
|
3535
|
+
}
|
|
3536
|
+
), /* @__PURE__ */ React36.createElement(
|
|
3537
|
+
NumberInput,
|
|
3538
|
+
{
|
|
3539
|
+
onChange: (n) => setAlpha(n),
|
|
3540
|
+
maxValue: 1,
|
|
3541
|
+
formatOptions: {
|
|
3542
|
+
style: "percent",
|
|
3543
|
+
maximumFractionDigits: 0
|
|
3544
|
+
},
|
|
3545
|
+
size: "sm",
|
|
3546
|
+
value: color.getChannelValue("alpha"),
|
|
3547
|
+
style: { width: "40%" },
|
|
3548
|
+
appearance: "filled"
|
|
3549
|
+
}
|
|
3550
|
+
)), ["rgb", "hsl"].includes(colorSpace) && /* @__PURE__ */ React36.createElement(Space, { style: { gap: 3 }, compact: true }, /* @__PURE__ */ React36.createElement(
|
|
3551
|
+
NumberInput,
|
|
3552
|
+
{
|
|
3553
|
+
value: colorSpace === "rgb" ? rgbaColor.getChannelValue(r) : color.getChannelValue(h),
|
|
3554
|
+
appearance: "filled",
|
|
3555
|
+
size: "sm"
|
|
3556
|
+
}
|
|
3557
|
+
), /* @__PURE__ */ React36.createElement(
|
|
3558
|
+
NumberInput,
|
|
3559
|
+
{
|
|
3560
|
+
value: colorSpace === "rgb" ? rgbaColor.getChannelValue(g) : color.getChannelValue(s),
|
|
3561
|
+
appearance: "filled",
|
|
3562
|
+
size: "sm"
|
|
3563
|
+
}
|
|
3564
|
+
), /* @__PURE__ */ React36.createElement(
|
|
3565
|
+
NumberInput,
|
|
3566
|
+
{
|
|
3567
|
+
value: colorSpace === "rgb" ? rgbaColor.getChannelValue(b) : color.getChannelValue(l),
|
|
3568
|
+
appearance: "filled",
|
|
3569
|
+
size: "sm"
|
|
3570
|
+
}
|
|
3571
|
+
), /* @__PURE__ */ React36.createElement(
|
|
3572
|
+
NumberInput,
|
|
3573
|
+
{
|
|
3574
|
+
formatOptions: {
|
|
3575
|
+
style: "percent",
|
|
3576
|
+
maximumFractionDigits: 0
|
|
3577
|
+
},
|
|
3578
|
+
value: colorSpace === "rgb" ? rgbaColor.getChannelValue("alpha") : color.getChannelValue("alpha"),
|
|
3579
|
+
appearance: "filled",
|
|
3580
|
+
size: "sm"
|
|
3581
|
+
}
|
|
3582
|
+
)), /* @__PURE__ */ React36.createElement(
|
|
3583
|
+
Select,
|
|
3584
|
+
{
|
|
3585
|
+
style: { width: "60%" },
|
|
3586
|
+
valueKey: "id",
|
|
3587
|
+
onChange: (v) => setColorSpace(v.target.value ?? colorSpace),
|
|
3588
|
+
showSelectionIndicator: false,
|
|
3589
|
+
value: colorSpace,
|
|
3590
|
+
size: "sm",
|
|
3591
|
+
appearance: "filled",
|
|
3592
|
+
items: ["hex", "rgb", "hsl"].map((o) => ({
|
|
3593
|
+
label: o.toUpperCase(),
|
|
3594
|
+
id: o
|
|
3595
|
+
}))
|
|
3596
|
+
}
|
|
3597
|
+
)), /* @__PURE__ */ React36.createElement(Separator, { color: "gray" }), /* @__PURE__ */ React36.createElement("div", { className: "flex gap-3" }, /* @__PURE__ */ React36.createElement(
|
|
3598
|
+
ColorSwatchPicker,
|
|
3599
|
+
{
|
|
3600
|
+
styles: {
|
|
3601
|
+
wrapper: { gap: 6 },
|
|
3602
|
+
swatch: {
|
|
3603
|
+
borderRadius: 5
|
|
3604
|
+
}
|
|
3605
|
+
},
|
|
3606
|
+
onChange: handleChange,
|
|
3607
|
+
colors: [
|
|
3608
|
+
"#000000",
|
|
3609
|
+
"#333333",
|
|
3610
|
+
"#555555",
|
|
3611
|
+
"#777777",
|
|
3612
|
+
"#999999",
|
|
3613
|
+
"#bbbbbb",
|
|
3614
|
+
"#dddddd",
|
|
3615
|
+
"#ffffff",
|
|
3616
|
+
"#4455BB",
|
|
3617
|
+
"#1199EE",
|
|
3618
|
+
"#55CCFF",
|
|
3619
|
+
"#22CCDD",
|
|
3620
|
+
"#22AA99",
|
|
3621
|
+
"#66BB66",
|
|
3622
|
+
"#99CC66",
|
|
3623
|
+
"#CCDD33",
|
|
3624
|
+
"#7755CC",
|
|
3625
|
+
"#BB66CC",
|
|
3626
|
+
"#FF88AA",
|
|
3627
|
+
"#EE4444",
|
|
3628
|
+
"#FF7744",
|
|
3629
|
+
"#FFAA22",
|
|
3630
|
+
"#FFCC66",
|
|
3631
|
+
"#FFEE66"
|
|
3632
|
+
].map((color2) => ({
|
|
3633
|
+
label: color2,
|
|
3634
|
+
color: parseColor(color2).toString("hsl"),
|
|
3635
|
+
key: color2
|
|
3636
|
+
}))
|
|
3637
|
+
}
|
|
3638
|
+
))))
|
|
3639
|
+
);
|
|
3640
|
+
}
|
|
3641
|
+
function ColorArea({
|
|
3642
|
+
className,
|
|
3643
|
+
classNames,
|
|
3644
|
+
style,
|
|
3645
|
+
styles,
|
|
3646
|
+
radius,
|
|
3647
|
+
...props
|
|
3648
|
+
}) {
|
|
3649
|
+
const theme = useTheme();
|
|
3650
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3651
|
+
ColorArea$1,
|
|
3652
|
+
{
|
|
3653
|
+
...props,
|
|
3654
|
+
className: cn("prt-color-area", className, classNames?.wrapper),
|
|
3655
|
+
"data-radius": radius ?? theme?.radius ?? "lg",
|
|
3656
|
+
style: ({ defaultStyle }) => ({
|
|
3657
|
+
...defaultStyle,
|
|
3658
|
+
...styles?.wrapper,
|
|
3659
|
+
...style
|
|
3660
|
+
})
|
|
3661
|
+
},
|
|
3662
|
+
/* @__PURE__ */ React36.createElement(
|
|
3663
|
+
ColorThumb,
|
|
3664
|
+
{
|
|
3665
|
+
className: cn("prt-color-area-thumb", classNames?.thumb),
|
|
3666
|
+
style: ({ defaultStyle }) => ({ ...defaultStyle, ...styles?.thumb })
|
|
3667
|
+
}
|
|
3668
|
+
)
|
|
3669
|
+
);
|
|
3670
|
+
}
|
|
3671
|
+
function ColorField({
|
|
3672
|
+
className,
|
|
3673
|
+
classNames,
|
|
3674
|
+
style,
|
|
3675
|
+
styles,
|
|
3676
|
+
inputRef,
|
|
3677
|
+
wrapperRef,
|
|
3678
|
+
prepend,
|
|
3679
|
+
append,
|
|
3680
|
+
label,
|
|
3681
|
+
description,
|
|
3682
|
+
error,
|
|
3683
|
+
color,
|
|
3684
|
+
size,
|
|
3685
|
+
radius,
|
|
3686
|
+
appearance,
|
|
3687
|
+
validationStatus,
|
|
3688
|
+
shape,
|
|
3689
|
+
placeholder,
|
|
3690
|
+
...colorFieldProps
|
|
3691
|
+
}) {
|
|
3692
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3693
|
+
ColorField$1,
|
|
3694
|
+
{
|
|
3695
|
+
...colorFieldProps,
|
|
3696
|
+
isInvalid: !!error,
|
|
3697
|
+
"aria-label": colorFieldProps["aria-label"] ?? "color-field"
|
|
3698
|
+
},
|
|
3699
|
+
/* @__PURE__ */ React36.createElement(
|
|
3700
|
+
Field,
|
|
3701
|
+
{
|
|
3702
|
+
className,
|
|
3703
|
+
classNames,
|
|
3704
|
+
styles,
|
|
3705
|
+
style,
|
|
3706
|
+
wrapperRef,
|
|
3707
|
+
prepend,
|
|
3708
|
+
append,
|
|
3709
|
+
label,
|
|
3710
|
+
description,
|
|
3711
|
+
error,
|
|
3712
|
+
color,
|
|
3713
|
+
size,
|
|
3714
|
+
radius,
|
|
3715
|
+
appearance,
|
|
3716
|
+
validationStatus
|
|
3717
|
+
},
|
|
3718
|
+
/* @__PURE__ */ React36.createElement(
|
|
3719
|
+
Input$1,
|
|
3720
|
+
{
|
|
3721
|
+
ref: inputRef,
|
|
3722
|
+
placeholder,
|
|
3723
|
+
"data-has-left-addon": !!prepend,
|
|
3724
|
+
"data-has-right-addon": !!append,
|
|
3725
|
+
style: styles?.input,
|
|
3726
|
+
className: cn("prt-text-input-el", classNames?.input)
|
|
3727
|
+
}
|
|
3728
|
+
)
|
|
3729
|
+
)
|
|
3730
|
+
);
|
|
3731
|
+
}
|
|
3732
|
+
function ColorSwatchPicker({
|
|
3733
|
+
colors,
|
|
3734
|
+
size,
|
|
3735
|
+
radius,
|
|
3736
|
+
onChange,
|
|
3737
|
+
className,
|
|
3738
|
+
classNames,
|
|
3739
|
+
style,
|
|
3740
|
+
styles,
|
|
3741
|
+
...props
|
|
3742
|
+
}) {
|
|
3743
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3744
|
+
ColorSwatchPicker$1,
|
|
3745
|
+
{
|
|
3746
|
+
...props,
|
|
3747
|
+
onChange,
|
|
3748
|
+
"aria-label": props["aria-label"] ?? "color swatch picker",
|
|
3749
|
+
className: cn("prt-color-swatch-picker", className, classNames?.wrapper),
|
|
3750
|
+
style: { ...style, ...styles?.wrapper }
|
|
3751
|
+
},
|
|
3752
|
+
colors.map((option) => /* @__PURE__ */ React36.createElement(
|
|
3753
|
+
ColorSwatchPickerItem,
|
|
3754
|
+
{
|
|
3755
|
+
key: option.key ?? option.color,
|
|
3756
|
+
color: option.color,
|
|
3757
|
+
className: cn("prt-color-swatch-item", classNames?.swatch),
|
|
3758
|
+
style: styles?.swatch
|
|
3759
|
+
},
|
|
3760
|
+
/* @__PURE__ */ React36.createElement(ColorSwatch, { className: "prt-color-swatch" })
|
|
3761
|
+
))
|
|
3762
|
+
);
|
|
3763
|
+
}
|
|
3764
|
+
function ColorSlider({ label, ...props }) {
|
|
3765
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3766
|
+
ColorSlider$1,
|
|
3767
|
+
{
|
|
3768
|
+
...props,
|
|
3769
|
+
"aria-label": props["aria-label"] ?? "color-slider"
|
|
3770
|
+
},
|
|
3771
|
+
/* @__PURE__ */ React36.createElement(Field, { label, className: "prt-color-slider", replaceDefaultControlWrapper: true }, /* @__PURE__ */ React36.createElement(SliderTrack, { className: "prt-color-slider-track" }, /* @__PURE__ */ React36.createElement("div", { className: "prt-color-slider-checkers" }), /* @__PURE__ */ React36.createElement(
|
|
3772
|
+
ColorThumb,
|
|
3773
|
+
{
|
|
3774
|
+
className: "prt-color-slider-thumb",
|
|
3775
|
+
style: ({ defaultStyle }) => ({ ...defaultStyle })
|
|
3776
|
+
}
|
|
3777
|
+
)))
|
|
3778
|
+
);
|
|
3779
|
+
}
|
|
3780
|
+
function parseColor2(color) {
|
|
3781
|
+
return parseColor(color);
|
|
3782
|
+
}
|
|
3783
|
+
function toKeys(value) {
|
|
3784
|
+
if (value == null) return void 0;
|
|
3785
|
+
return new Set(Array.isArray(value) ? value : [value]);
|
|
3786
|
+
}
|
|
3787
|
+
function ToggleGroup({
|
|
3788
|
+
selectionMode = "single",
|
|
3789
|
+
value,
|
|
3790
|
+
defaultValue,
|
|
3791
|
+
onChange,
|
|
3792
|
+
label,
|
|
3793
|
+
size,
|
|
3794
|
+
radius,
|
|
3795
|
+
idleColor,
|
|
3796
|
+
idleVariant,
|
|
3797
|
+
activeColor,
|
|
3798
|
+
activeVariant,
|
|
3799
|
+
disallowEmptySelection,
|
|
3800
|
+
orientation,
|
|
3801
|
+
compact,
|
|
3802
|
+
gap,
|
|
3803
|
+
className,
|
|
3804
|
+
classNames,
|
|
3805
|
+
style,
|
|
3806
|
+
styles,
|
|
3807
|
+
children
|
|
3808
|
+
}) {
|
|
3809
|
+
const groupDefaults = React36.useMemo(
|
|
3810
|
+
() => ({ idleColor, idleVariant, activeColor, activeVariant, size, radius }),
|
|
3811
|
+
[idleColor, idleVariant, activeColor, activeVariant, size, radius]
|
|
3812
|
+
);
|
|
3813
|
+
function handleSelectionChange(keys) {
|
|
3814
|
+
const arr = [...keys].map(String);
|
|
3815
|
+
onChange?.(
|
|
3816
|
+
selectionMode === "multiple" ? arr : arr[0] ?? ""
|
|
3817
|
+
);
|
|
3818
|
+
}
|
|
3819
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3820
|
+
ToggleButtonGroup,
|
|
3821
|
+
{
|
|
3822
|
+
"aria-label": label,
|
|
3823
|
+
selectionMode,
|
|
3824
|
+
selectedKeys: toKeys(value),
|
|
3825
|
+
defaultSelectedKeys: toKeys(defaultValue),
|
|
3826
|
+
onSelectionChange: handleSelectionChange,
|
|
3827
|
+
disallowEmptySelection: disallowEmptySelection ?? selectionMode === "single",
|
|
3828
|
+
orientation
|
|
3829
|
+
},
|
|
3830
|
+
/* @__PURE__ */ React36.createElement(ToggleButtonGroupContext.Provider, { value: groupDefaults }, /* @__PURE__ */ React36.createElement(
|
|
3831
|
+
Space,
|
|
3832
|
+
{
|
|
3833
|
+
compact,
|
|
3834
|
+
gap,
|
|
3835
|
+
className,
|
|
3836
|
+
classNames,
|
|
3837
|
+
style,
|
|
3838
|
+
styles
|
|
3839
|
+
},
|
|
3840
|
+
children
|
|
3841
|
+
))
|
|
3842
|
+
);
|
|
3843
|
+
}
|
|
3844
|
+
function Toggle({ value, ...props }) {
|
|
3845
|
+
return /* @__PURE__ */ React36.createElement(ToggleButton, { id: value, ...props });
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
export { Avatar, AvatarGroup, Button, ButtonGroup, Calendar, Checkbox, CheckboxGroup, CheckboxItem, ColorArea, ColorField, ColorPicker, ColorSlider, ColorSwatchPicker, ComboBox, DateField, DatePicker, DateRangePicker, FileUploader, IconButton, Input, ListBox, ListBoxItem, ListBoxSection, Loader, Menu, MenuContent, MenuItem, MenuSection, MenuTrigger, Modal, NumberInput, ListBoxItem as Option, Popover, PopoverContent, PopoverTrigger, Progress, Radio, RadioCard, RadioGroup, RadioItem, RangeCalendar, ListBoxSection as Section, Select, Separator, Slider, Space, Sticker, Switch, Tab, Table, Tabs, Tag, TagGroup, TagGroupItem, TagInput, Text, Textarea, ThemeProvider, TimeField, Timeline, Toggle, ToggleButton, ToggleGroup, parseColor2 as parseColor, useModal, useTheme };
|
|
3849
|
+
//# sourceMappingURL=index.mjs.map
|
|
3850
|
+
//# sourceMappingURL=index.mjs.map
|