@candidhealth/react-vitals 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,4476 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/core/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ AlertModal: () => AlertModal,
34
+ AsyncMultiSelect: () => AsyncMultiSelect,
35
+ AsyncSelect: () => AsyncSelect,
36
+ Button: () => Button,
37
+ ButtonGroup: () => ButtonGroup,
38
+ CURRENCY_REGEX: () => CURRENCY_REGEX,
39
+ Callout: () => Callout,
40
+ Checkbox: () => Checkbox,
41
+ Collapsible: () => Collapsible,
42
+ CollapsibleSection: () => CollapsibleSection,
43
+ ComposableTabs: () => ComposableTabs,
44
+ ControlledField: () => ControlledField,
45
+ ControlledFieldProvider: () => ControlledFieldProvider,
46
+ Copyable: () => Copyable,
47
+ DEFAULT_NUM_VALUES_TO_SHOW: () => DEFAULT_NUM_VALUES_TO_SHOW,
48
+ DatePicker: () => DatePicker,
49
+ Divider: () => Divider,
50
+ DollarInput: () => DollarInput,
51
+ Drawer: () => Drawer,
52
+ DrawerHeader: () => DrawerHeader,
53
+ DrawerHeaderSkeleton: () => DrawerHeaderSkeleton,
54
+ DrawerStateContext: () => DrawerStateContext,
55
+ DropdownChevron: () => DropdownChevron,
56
+ EmptyState: () => EmptyState,
57
+ ErrorText: () => ErrorText,
58
+ FormCheckbox: () => FormCheckbox,
59
+ FormDatePicker: () => FormDatePicker,
60
+ FormDollarInput: () => FormDollarInput,
61
+ FormInput: () => FormInput,
62
+ FormMultiSelect: () => FormMultiSelect,
63
+ FormPercentInput: () => FormPercentInput,
64
+ FormProvider: () => import_react_hook_form3.FormProvider,
65
+ FormRadioButtonGroup: () => FormRadioButtonGroup,
66
+ FormSelect: () => FormSelect,
67
+ FormSwitch: () => FormSwitch,
68
+ FormTextArea: () => FormTextArea,
69
+ FullscreenModal: () => FullscreenModal,
70
+ HeaderTile: () => HeaderTile,
71
+ Icon: () => Icon,
72
+ IndeterminateCheckbox: () => IndeterminateCheckbox,
73
+ Input: () => Input,
74
+ InputBox: () => InputBox,
75
+ IsEditingProvider: () => IsEditingProvider,
76
+ IsVisibleProvider: () => IsVisibleProvider,
77
+ Label: () => Label,
78
+ LoadingBar: () => LoadingBar,
79
+ LoadingState: () => LoadingState,
80
+ Menu: () => Menu,
81
+ MenuRoot: () => MenuRoot,
82
+ MenuSeparator: () => MenuSeparator,
83
+ Modal: () => Modal,
84
+ MultiSelect: () => MultiSelect,
85
+ OverflowTooltip: () => OverflowTooltip,
86
+ PercentInput: () => PercentInput,
87
+ PhoneNumber: () => PhoneNumber,
88
+ Popover: () => Popover,
89
+ RING_COLOR_CLASSNAME: () => RING_COLOR_CLASSNAME,
90
+ RadioButtonGroup: () => RadioButtonGroup,
91
+ RadioButtonItem: () => RadioButtonItem,
92
+ ScrollTabsLayout: () => ScrollTabsLayout,
93
+ Select: () => Select,
94
+ SelectListItem: () => SelectListItem,
95
+ SelectWithUnselect: () => SelectWithUnselect,
96
+ Skeleton: () => Skeleton,
97
+ Spinner: () => Spinner,
98
+ Switch: () => Switch,
99
+ TabGroup: () => TabGroup,
100
+ Table: () => Table,
101
+ TableCheckboxSkeleton: () => TableCheckboxSkeleton,
102
+ TableSkeleton: () => TableSkeleton,
103
+ Tabs: () => Tabs,
104
+ TabsSkeleton: () => TabsSkeleton,
105
+ TabsTrigger: () => TabsTrigger,
106
+ Tag: () => Tag,
107
+ Text: () => Text,
108
+ TextArea: () => TextArea,
109
+ TextAreaComp: () => TextAreaComp,
110
+ Tooltip: () => Tooltip,
111
+ TooltipContent: () => TooltipContent,
112
+ UncontrolledField: () => UncontrolledField,
113
+ UncontrolledFieldProvider: () => UncontrolledFieldProvider,
114
+ asNullish: () => asNullish,
115
+ asNumericStr: () => asNumericStr,
116
+ asOptional: () => asOptional,
117
+ asRequiredCustom: () => asRequiredCustom,
118
+ buildZodIssue: () => buildZodIssue,
119
+ buttonStyles: () => buttonStyles,
120
+ copyToClipboard: () => copyToClipboard,
121
+ createContextHelper: () => createContextHelper,
122
+ createToggleContextHelper: () => createToggleContextHelper,
123
+ createTypedTabs: () => createTypedTabs,
124
+ doesSelectItemMatch: () => doesSelectItemMatch,
125
+ dollarsStrSchema: () => dollarsStrSchema,
126
+ formatPhoneNumber: () => formatPhoneNumber,
127
+ formatPhoneNumberForDisplay: () => formatPhoneNumberForDisplay,
128
+ getCountry: () => import_react_international_phone.getCountry,
129
+ getFieldError: () => getFieldError,
130
+ inputBoxStyles: () => inputBoxStyles,
131
+ inputStyles: () => inputStyles,
132
+ isValidPhoneNumber: () => isValidPhoneNumber,
133
+ linkStyles: () => linkStyles,
134
+ localStoragePersist: () => localStoragePersist,
135
+ npiSchema: () => npiSchema,
136
+ npiSchemaOptional: () => npiSchemaOptional,
137
+ requiredDollarsStrSchema: () => requiredDollarsStrSchema,
138
+ requiredDollarsStrSchemaWithCustomMessage: () => requiredDollarsStrSchemaWithCustomMessage,
139
+ requiredNonZeroDollarsStrSchema: () => requiredNonZeroDollarsStrSchema,
140
+ requiredPositiveDollarsStrSchema: () => requiredPositiveDollarsStrSchema,
141
+ requiredPositiveOrZeroDollarsStrSchema: () => requiredPositiveOrZeroDollarsStrSchema,
142
+ selectedAmountSchema: () => selectedAmountSchema,
143
+ taxIdSchema: () => taxIdSchema,
144
+ taxonomyCodeSchema: () => taxonomyCodeSchema,
145
+ useAsyncMultiSelect: () => useAsyncMultiSelect,
146
+ useAsyncSelect: () => useAsyncSelect,
147
+ useControlledField: () => useControlledField,
148
+ useControlledFormField: () => useControlledFormField,
149
+ useController: () => import_react_hook_form3.useController,
150
+ useCopyable: () => useCopyable,
151
+ useDebounce: () => useDebounce,
152
+ useDrawer: () => useDrawer,
153
+ useDrawerResize: () => useDrawerResize,
154
+ useFieldArray: () => import_react_hook_form3.useFieldArray,
155
+ useForm: () => useForm,
156
+ useFormContext: () => useFormContext,
157
+ useFormState: () => import_react_hook_form3.useFormState,
158
+ useIsEditing: () => useIsEditing,
159
+ useIsHovered: () => useIsHovered,
160
+ useIsVisible: () => useIsVisible,
161
+ useOverflowObserver: () => useOverflowObserver,
162
+ useSwitchId: () => useSwitchId,
163
+ useSyncState: () => useSyncState,
164
+ useTable: () => useTable,
165
+ useToggle: () => useToggle,
166
+ useUncontrolledField: () => useUncontrolledField,
167
+ useUncontrolledFormField: () => useUncontrolledFormField,
168
+ useWatch: () => import_react_hook_form3.useWatch
169
+ });
170
+ module.exports = __toCommonJS(index_exports);
171
+
172
+ // src/core/button/Button.tsx
173
+ var React = __toESM(require("react"), 1);
174
+ var import_tailwind_merge2 = require("tailwind-merge");
175
+
176
+ // src/core/button/buttonStyles.ts
177
+ var import_tailwind_merge = require("tailwind-merge");
178
+ var linkStyles = "text-indigo-600 hover:underline active:text-indigo-400 focus:outline-indigo-400 focus:outline-offset-2";
179
+ var roundedMdStyles = {
180
+ none: "",
181
+ right: "rounded-r-md",
182
+ left: "rounded-l-md",
183
+ both: "rounded-md"
184
+ };
185
+ var roundedLgStyles = {
186
+ none: "",
187
+ right: "rounded-r-lg",
188
+ left: "rounded-l-lg",
189
+ both: "rounded-lg"
190
+ };
191
+ var roundedXlStyles = {
192
+ none: "",
193
+ right: "rounded-r-xl",
194
+ left: "rounded-l-xl",
195
+ both: "rounded-xl"
196
+ };
197
+ var borderRadiusStyles = {
198
+ default: {
199
+ xs: roundedMdStyles,
200
+ sm: roundedMdStyles,
201
+ md: roundedMdStyles,
202
+ lg: roundedLgStyles
203
+ },
204
+ large: {
205
+ xs: roundedLgStyles,
206
+ sm: roundedLgStyles,
207
+ md: roundedLgStyles,
208
+ lg: roundedXlStyles
209
+ }
210
+ };
211
+ var sizeStyles = {
212
+ xs: "h-xs gap-1 px-2 text-sm",
213
+ sm: "h-sm gap-1 px-2 text-sm",
214
+ md: "h-md gap-1.5 px-3 text-base",
215
+ lg: "h-lg gap-2 px-4 text-lg"
216
+ };
217
+ var colorStyles = {
218
+ default: {
219
+ primary: "bg-indigo-600 hover:bg-indigo-700 data-[state='open']:bg-indigo-700 border border-indigo-700 text-white",
220
+ default: "bg-white hover:bg-gray-100 data-[state='open']:bg-gray-100 border border-gray-200 text-gray-700",
221
+ danger: "bg-red-600 hover:bg-red-700 data-[state='open']:bg-red-700 border border-red-700 text-white",
222
+ error: "bg-white hover:bg-red-50 data-[state='open']:bg-red-50 text-red-500 border border-red-300"
223
+ },
224
+ transparent: {
225
+ primary: "bg-indigo-900/0 hover:bg-indigo-900/10 data-[state='open']:bg-indigo-900/10 text-indigo-700",
226
+ default: "bg-gray-900/0 hover:bg-gray-900/10 data-[state='open']:bg-gray-900/10 text-gray-700",
227
+ danger: "bg-red-900/0 hover:bg-red-900/10 data-[state='open']:bg-red-900/10 text-red-700",
228
+ error: "bg-red-900/0 hover:bg-red-900/10 data-[state='open']:bg-red-900/10 text-red-500"
229
+ },
230
+ dark: {
231
+ primary: "bg-indigo-600 hover:bg-indigo-700 data-[state='open']:bg-indigo-700 border border-indigo-700 text-white",
232
+ default: "bg-gray-900 hover:bg-gray-600 data-[state='open']:bg-gray-600 text-white",
233
+ danger: "bg-red-600 hover:bg-red-700 data-[state='open']:bg-red-700 text-white",
234
+ error: "bg-white hover:bg-red-50 data-[state='open']:bg-red-50 text-red-500"
235
+ }
236
+ };
237
+ var buttonStyles = ({
238
+ fullWidth = false,
239
+ size = "md",
240
+ intent = "default",
241
+ variant = "default",
242
+ soften = "both",
243
+ loading,
244
+ roundedness = "default"
245
+ }) => {
246
+ if (variant === "link") {
247
+ return (0, import_tailwind_merge.twJoin)(fullWidth && "w-full", loading && "animate-loading-pulse", linkStyles);
248
+ }
249
+ return (0, import_tailwind_merge.twJoin)(
250
+ "flex items-center justify-center whitespace-nowrap focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-50",
251
+ fullWidth && "w-full",
252
+ borderRadiusStyles[roundedness][size][soften],
253
+ sizeStyles[size],
254
+ colorStyles[variant][intent],
255
+ loading && "animate-loading-pulse"
256
+ );
257
+ };
258
+
259
+ // src/core/button/Button.tsx
260
+ var import_jsx_runtime = require("react/jsx-runtime");
261
+ var ButtonImpl = ({
262
+ fullWidth,
263
+ size,
264
+ intent,
265
+ variant,
266
+ disabled,
267
+ loading,
268
+ soften,
269
+ roundedness,
270
+ className,
271
+ children,
272
+ ...rest
273
+ }, ref) => {
274
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
275
+ "button",
276
+ {
277
+ type: "button",
278
+ className: (0, import_tailwind_merge2.twMerge)(buttonStyles({ fullWidth, size, intent, variant, loading, soften, roundedness }), className),
279
+ ...rest,
280
+ ref,
281
+ disabled: disabled || loading,
282
+ children
283
+ }
284
+ );
285
+ };
286
+ var Button = React.forwardRef(ButtonImpl);
287
+
288
+ // src/core/button/ButtonGroup.tsx
289
+ var import_jsx_runtime2 = require("react/jsx-runtime");
290
+ var ButtonGroup = ({
291
+ size,
292
+ value,
293
+ onChange,
294
+ buttons
295
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex", children: buttons.map((button, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
296
+ Button,
297
+ {
298
+ size,
299
+ onClick: () => onChange(button.value),
300
+ soften: i === 0 ? "left" : i === buttons.length - 1 ? "right" : "none",
301
+ intent: value === button.value ? "primary" : void 0,
302
+ children: button.content
303
+ },
304
+ button.value
305
+ )) });
306
+
307
+ // src/core/callout/Callout.tsx
308
+ var import_free_solid_svg_icons = require("@fortawesome/free-solid-svg-icons");
309
+ var import_tailwind_merge3 = require("tailwind-merge");
310
+
311
+ // src/core/icon/Icon.tsx
312
+ var import_react_fontawesome = require("@fortawesome/react-fontawesome");
313
+ var import_jsx_runtime3 = require("react/jsx-runtime");
314
+ var Icon = ({ icon }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_fontawesome.FontAwesomeIcon, { icon });
315
+
316
+ // src/core/callout/Callout.tsx
317
+ var import_jsx_runtime4 = require("react/jsx-runtime");
318
+ var calloutBackgroundStyles = {
319
+ default: "bg-gray-100",
320
+ warning: "bg-yellow-50",
321
+ primary: "bg-indigo-50",
322
+ danger: "bg-red-50"
323
+ };
324
+ var calloutIconStyles = {
325
+ default: "text-gray-500",
326
+ warning: "text-yellow-700",
327
+ primary: "text-indigo-500",
328
+ danger: "text-red-800"
329
+ };
330
+ var calloutBorderStyles = {
331
+ default: "border-[1px] border-gray-200",
332
+ primary: "border-[1px] border-indigo-100",
333
+ warning: "border-[1px] border-yellow-200",
334
+ danger: "border-[1px] border-red-100"
335
+ };
336
+ var calloutIcons = {
337
+ default: import_free_solid_svg_icons.faCircleInfo,
338
+ warning: import_free_solid_svg_icons.faTriangleExclamation,
339
+ primary: import_free_solid_svg_icons.faDiamond,
340
+ danger: import_free_solid_svg_icons.faCircle
341
+ };
342
+ var Callout = ({
343
+ title,
344
+ intent = "default",
345
+ rightSlot,
346
+ children,
347
+ customIcon,
348
+ isAttachedAtBottom,
349
+ isCentered
350
+ }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
351
+ "div",
352
+ {
353
+ className: (0, import_tailwind_merge3.twJoin)(
354
+ "flex w-full justify-between rounded-lg p-2.5",
355
+ calloutBackgroundStyles[intent],
356
+ calloutBorderStyles[intent],
357
+ isAttachedAtBottom ? "rounded-b-none" : "rounded-b-lg",
358
+ isCentered ? "items-center" : "items-start"
359
+ ),
360
+ children: [
361
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex gap-2", children: [
362
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: (0, import_tailwind_merge3.twJoin)("text-sm", title ? "leading-6.5" : "leading-5", calloutIconStyles[intent]), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { icon: customIcon ?? calloutIcons[intent] }) }),
363
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-1 flex-col gap-1", children: [
364
+ title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "leading-6.5 font-medium whitespace-pre-line text-gray-700", children: title }),
365
+ children && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-sm leading-5 text-gray-500", children })
366
+ ] })
367
+ ] }),
368
+ rightSlot
369
+ ]
370
+ }
371
+ );
372
+
373
+ // src/core/checkbox/Checkbox.tsx
374
+ var import_react = require("react");
375
+ var import_tailwind_merge4 = require("tailwind-merge");
376
+ var import_jsx_runtime5 = require("react/jsx-runtime");
377
+ var Checkbox = (0, import_react.forwardRef)(({ className, hasError, ...rest }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
378
+ "input",
379
+ {
380
+ type: "checkbox",
381
+ className: (0, import_tailwind_merge4.twJoin)(
382
+ className,
383
+ "block rounded-sm text-indigo-600 checked:bg-indigo-600 indeterminate:bg-indigo-600 focus:ring-0 focus:ring-offset-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-400 disabled:cursor-not-allowed disabled:bg-gray-200 disabled:hover:bg-gray-200",
384
+ hasError ? "border-red-300 text-red-900 placeholder-red-300" : "border-gray-200 disabled:border-gray-200"
385
+ ),
386
+ ...rest,
387
+ ref
388
+ }
389
+ ));
390
+ var IndeterminateCheckbox = ({
391
+ indeterminate = false,
392
+ ...rest
393
+ }) => {
394
+ const ref = (0, import_react.useRef)(null);
395
+ (0, import_react.useEffect)(() => {
396
+ if (ref.current) {
397
+ ref.current.indeterminate = indeterminate;
398
+ }
399
+ }, [indeterminate]);
400
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Checkbox, { ref, ...rest });
401
+ };
402
+
403
+ // src/core/collapsible/Collapsible.tsx
404
+ var import_free_solid_svg_icons2 = require("@fortawesome/free-solid-svg-icons");
405
+ var import_react_collapsible = require("@radix-ui/react-collapsible");
406
+ var import_react2 = require("react");
407
+ var import_tailwind_merge5 = require("tailwind-merge");
408
+ var import_jsx_runtime6 = require("react/jsx-runtime");
409
+ var Collapsible = ({
410
+ title,
411
+ children,
412
+ defaultOpen = false,
413
+ iconPosition = "left",
414
+ hideIcon,
415
+ open: controlledOpen,
416
+ setOpen: controlledSetOpen,
417
+ triggerClassName
418
+ }) => {
419
+ const isControlled = controlledOpen !== void 0 && controlledSetOpen !== void 0;
420
+ const [uncontrolledOpen, setUncontrolledOpen] = (0, import_react2.useState)(defaultOpen);
421
+ const isOpen = isControlled ? controlledOpen : uncontrolledOpen;
422
+ const setIsOpen = isControlled ? controlledSetOpen : setUncontrolledOpen;
423
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_collapsible.Root, { className: "flex flex-col gap-2", open: isOpen, onOpenChange: setIsOpen, children: [
424
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
425
+ import_react_collapsible.Trigger,
426
+ {
427
+ asChild: true,
428
+ className: (0, import_tailwind_merge5.twMerge)("flex cursor-pointer items-center gap-2 font-medium text-gray-500", triggerClassName),
429
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
430
+ !hideIcon && iconPosition === "left" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "min-w-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
431
+ Icon,
432
+ {
433
+ icon: isOpen ? import_free_solid_svg_icons2.faChevronDown : import_free_solid_svg_icons2.faChevronRight
434
+ }
435
+ ) }),
436
+ title,
437
+ !hideIcon && iconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "min-w-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
438
+ Icon,
439
+ {
440
+ icon: isOpen ? import_free_solid_svg_icons2.faChevronDown : import_free_solid_svg_icons2.faChevronRight
441
+ }
442
+ ) })
443
+ ] })
444
+ }
445
+ ),
446
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_collapsible.Content, { className: "overflow-y-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex flex-col gap-2", children }) })
447
+ ] });
448
+ };
449
+
450
+ // src/core/collapsible-section/CollapsibleSection.tsx
451
+ var import_free_solid_svg_icons3 = require("@fortawesome/free-solid-svg-icons");
452
+ var import_react_slot = require("@radix-ui/react-slot");
453
+ var import_tailwind_merge6 = require("tailwind-merge");
454
+
455
+ // src/core/utils/useToggle.tsx
456
+ var React3 = __toESM(require("react"), 1);
457
+
458
+ // src/core/utils/create-context-helper.tsx
459
+ var React2 = __toESM(require("react"), 1);
460
+ var import_jsx_runtime7 = require("react/jsx-runtime");
461
+ var createContextHelper = (defaultContext) => {
462
+ const Context = React2.createContext(defaultContext);
463
+ const Provider3 = ({ children, ...rest }) => {
464
+ const value = React2.useMemo(() => rest, Object.values(rest));
465
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Context.Provider, { value, children });
466
+ };
467
+ const useContext7 = () => {
468
+ const context = React2.useContext(Context);
469
+ if (context) {
470
+ return context;
471
+ }
472
+ if (defaultContext !== void 0) {
473
+ return defaultContext;
474
+ }
475
+ throw new Error("Required context: useContext likely outside of a Provider");
476
+ };
477
+ return [Provider3, useContext7];
478
+ };
479
+
480
+ // src/core/utils/useToggle.tsx
481
+ var import_jsx_runtime8 = require("react/jsx-runtime");
482
+ var [ToggleProvider, useToggleHook] = createContextHelper({
483
+ state: false,
484
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
485
+ update: () => {
486
+ },
487
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
488
+ toggle: () => {
489
+ }
490
+ });
491
+ var createToggleContextHelper = (defaultState = false) => {
492
+ const Provider3 = ({ children, state: initState }) => {
493
+ const hook = useToggle(initState ?? defaultState);
494
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ToggleProvider, { ...hook, children });
495
+ };
496
+ Provider3.displayName = "ToggleProvider";
497
+ return [Provider3, useToggleHook];
498
+ };
499
+ var [IsVisibleProvider, useIsVisible] = createToggleContextHelper(true);
500
+ var [IsEditingProvider, useIsEditing] = createToggleContextHelper(false);
501
+ var useToggle = (initState) => {
502
+ const [state, update] = React3.useState(initState ?? false);
503
+ const toggle = React3.useCallback(() => update((state2) => !state2), []);
504
+ return { state, update, toggle };
505
+ };
506
+
507
+ // src/core/collapsible-section/CollapsibleSection.tsx
508
+ var import_jsx_runtime9 = require("react/jsx-runtime");
509
+ var ToggleButton = ({ children, ...rest }) => {
510
+ const { state: isVisible, toggle } = useIsVisible();
511
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_slot.Slot, { onClick: toggle, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Button, { variant: "transparent", size: "xs", ...rest, children: [
512
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: (0, import_tailwind_merge6.twJoin)("transition-transform", !isVisible && "-rotate-90"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { icon: import_free_solid_svg_icons3.faChevronDown }) }),
513
+ children
514
+ ] }) });
515
+ };
516
+ var Content2 = ({ children }) => {
517
+ const { state: isVisible } = useIsVisible();
518
+ if (isVisible) return children;
519
+ return null;
520
+ };
521
+ var CollapsibleSection = ({ children, defaultOpen }) => {
522
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(IsVisibleProvider, { state: defaultOpen, children });
523
+ };
524
+ CollapsibleSection.ToggleButton = ToggleButton;
525
+ CollapsibleSection.Content = Content2;
526
+
527
+ // src/core/copyable/Copyable.tsx
528
+ var import_free_solid_svg_icons4 = require("@fortawesome/free-solid-svg-icons");
529
+ var RadixTooltip2 = __toESM(require("@radix-ui/react-tooltip"), 1);
530
+ var import_tailwind_merge7 = require("tailwind-merge");
531
+
532
+ // src/core/tooltip/Tooltip.tsx
533
+ var RadixTooltip = __toESM(require("@radix-ui/react-tooltip"), 1);
534
+
535
+ // src/core/utils/useOverflowObserver.tsx
536
+ var React4 = __toESM(require("react"), 1);
537
+ var useOverflowObserver = () => {
538
+ const [hasOverflow, setHasOverflow] = React4.useState(false);
539
+ const elementRef = React4.useRef(null);
540
+ React4.useEffect(() => {
541
+ if (elementRef.current == null) return;
542
+ const resizeObserver = new ResizeObserver(([entry]) => {
543
+ window.requestAnimationFrame(() => {
544
+ const element = entry?.target;
545
+ const hasOverflowWidth = element.offsetWidth < element.scrollWidth;
546
+ const hasOverflowHeight = element.offsetHeight < element.scrollHeight;
547
+ const calcHasOverflow = hasOverflowWidth || hasOverflowHeight;
548
+ if (calcHasOverflow !== hasOverflow) {
549
+ setHasOverflow(calcHasOverflow);
550
+ }
551
+ });
552
+ });
553
+ resizeObserver.observe(elementRef.current);
554
+ return () => resizeObserver.disconnect();
555
+ }, [hasOverflow]);
556
+ return { elementRef, hasOverflow };
557
+ };
558
+
559
+ // src/core/tooltip/Tooltip.tsx
560
+ var import_jsx_runtime10 = require("react/jsx-runtime");
561
+ var TooltipContent = ({ children, variant = "dark", ...rest }) => {
562
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RadixTooltip.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
563
+ RadixTooltip.Content,
564
+ {
565
+ ...rest,
566
+ hideWhenDetached: true,
567
+ sideOffset: 6,
568
+ className: `z-9000000000 max-w-prose rounded-lg px-5 py-3 text-sm break-words shadow-lg ${variant === "dark" ? "bg-gray-900 text-white" : "bg-white text-gray-600"}`,
569
+ children: [
570
+ children,
571
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RadixTooltip.Arrow, { className: variant === "dark" ? "fill-gray-900" : "fill-white", offset: 8 })
572
+ ]
573
+ }
574
+ ) });
575
+ };
576
+ TooltipContent.displayName = RadixTooltip.Content.displayName;
577
+ var OverflowTrigger = ({
578
+ element,
579
+ ...rest
580
+ }) => {
581
+ const { elementRef, hasOverflow } = useOverflowObserver();
582
+ if (!hasOverflow) {
583
+ return element(elementRef);
584
+ }
585
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RadixTooltip.Trigger, { asChild: true, ...rest, children: element(elementRef) });
586
+ };
587
+ var TooltipTrigger = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RadixTooltip.Trigger, { asChild: true, ...props });
588
+ var TooltipProvider = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RadixTooltip.Provider, { disableHoverableContent: true, delayDuration: 0, ...props });
589
+ var TooltipRoot = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RadixTooltip.Root, { ...props });
590
+ var Tooltip = ({ trigger, content, variant, side, ...rest }) => {
591
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Tooltip.Root, { ...rest, children: [
592
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Tooltip.Trigger, { children: trigger }),
593
+ content && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Tooltip.Content, { side, variant, children: content })
594
+ ] });
595
+ };
596
+ Tooltip.Provider = TooltipProvider;
597
+ Tooltip.Root = TooltipRoot;
598
+ Tooltip.Trigger = TooltipTrigger;
599
+ Tooltip.OverflowTrigger = OverflowTrigger;
600
+ Tooltip.Content = TooltipContent;
601
+
602
+ // src/core/copyable/use-copyable.ts
603
+ var React5 = __toESM(require("react"), 1);
604
+ var waitMs = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
605
+ var oldSchoolCopy = (text) => {
606
+ const tempTextArea = document.createElement("textarea");
607
+ tempTextArea.value = text;
608
+ document.body.appendChild(tempTextArea);
609
+ tempTextArea.select();
610
+ document.execCommand("copy");
611
+ document.body.removeChild(tempTextArea);
612
+ };
613
+ var copyToClipboard = async (value) => {
614
+ try {
615
+ if (navigator?.clipboard?.writeText) {
616
+ await navigator.clipboard.writeText(value);
617
+ } else {
618
+ throw new Error("writeText not supported");
619
+ }
620
+ } catch {
621
+ oldSchoolCopy(value);
622
+ }
623
+ };
624
+ var useCopyable = () => {
625
+ const [state, setState] = React5.useState("idle");
626
+ const copy = React5.useCallback(async (value, onClick) => {
627
+ if (!value) {
628
+ return;
629
+ }
630
+ setState("copying");
631
+ await Promise.all([copyToClipboard(value), waitMs(350)]);
632
+ onClick?.();
633
+ setState("copied");
634
+ await waitMs(1750);
635
+ setState("idle");
636
+ }, []);
637
+ return { state, copy };
638
+ };
639
+
640
+ // src/core/copyable/Copyable.tsx
641
+ var import_jsx_runtime11 = require("react/jsx-runtime");
642
+ var Copyable = ({ children, value, tooltip, onClick, asChild }) => {
643
+ const { state, copy } = useCopyable();
644
+ const handleCopy = async (e) => {
645
+ e.stopPropagation();
646
+ await copy(value, onClick);
647
+ };
648
+ if (!value && tooltip) {
649
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { trigger: children, content: tooltip });
650
+ }
651
+ if (!value) {
652
+ return children;
653
+ }
654
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(RadixTooltip2.Root, { open: state === "copied" ? true : void 0, delayDuration: 150, children: [
655
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
656
+ RadixTooltip2.Trigger,
657
+ {
658
+ asChild: true,
659
+ onClick: handleCopy,
660
+ className: (0, import_tailwind_merge7.twJoin)(
661
+ "w-fit cursor-pointer rounded-xs",
662
+ state !== "copied" && "hover:bg-[#E8E8EB] hover:shadow-[0_0_0_2px_#E8E8EB] active:opacity-60",
663
+ state === "copying" && "opacity-60"
664
+ ),
665
+ children: asChild ? children : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children })
666
+ }
667
+ ),
668
+ tooltip && state === "idle" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipContent, { side: "bottom", children: tooltip }),
669
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RadixTooltip2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
670
+ RadixTooltip2.Content,
671
+ {
672
+ sideOffset: 6,
673
+ side: "right",
674
+ className: (0, import_tailwind_merge7.twJoin)(
675
+ "z-101 grid h-6 w-6 place-items-center rounded-sm bg-white shadow-lg",
676
+ state !== "copying" && "animate-fade-in"
677
+ ),
678
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: state === "copied" ? "text-green-500" : "text-gray-500", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
679
+ Icon,
680
+ {
681
+ icon: state === "copied" ? import_free_solid_svg_icons4.faCheck : import_free_solid_svg_icons4.faCopy
682
+ }
683
+ ) })
684
+ }
685
+ ) })
686
+ ] });
687
+ };
688
+
689
+ // src/core/date-picker/DatePickerRange.tsx
690
+ var import_react6 = require("react");
691
+ var import_react_datepicker = __toESM(require("react-datepicker"), 1);
692
+
693
+ // src/core/date-picker/DatePickerHeader.tsx
694
+ var import_free_solid_svg_icons5 = require("@fortawesome/free-solid-svg-icons");
695
+ var import_date_fns = require("date-fns");
696
+ var import_lodash_es = require("lodash-es");
697
+ var import_jsx_runtime12 = require("react/jsx-runtime");
698
+ var years = (0, import_lodash_es.range)(1920, (0, import_date_fns.getYear)(/* @__PURE__ */ new Date()) + 1, 1).sort((a, b) => b - a);
699
+ var months = [
700
+ "January",
701
+ "February",
702
+ "March",
703
+ "April",
704
+ "May",
705
+ "June",
706
+ "July",
707
+ "August",
708
+ "September",
709
+ "October",
710
+ "November",
711
+ "December"
712
+ ];
713
+ var DatePickerHeader = ({
714
+ date,
715
+ decreaseMonth,
716
+ increaseMonth,
717
+ changeMonth,
718
+ changeYear,
719
+ prevMonthButtonDisabled,
720
+ nextMonthButtonDisabled
721
+ }) => {
722
+ const datePickerContainer = document.querySelector(".react-datepicker") ?? void 0;
723
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "space-y-2 p-2", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
724
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { onClick: decreaseMonth, disabled: prevMonthButtonDisabled, variant: "transparent", size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { icon: import_free_solid_svg_icons5.faChevronLeft }) }),
725
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
726
+ Select,
727
+ {
728
+ size: "sm",
729
+ popover: {
730
+ container: datePickerContainer
731
+ },
732
+ value: months[(0, import_date_fns.getMonth)(date)],
733
+ onChange: (value) => changeMonth(months.indexOf(value)),
734
+ items: months.map((month) => ({ label: month, value: month }))
735
+ }
736
+ ),
737
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
738
+ Select,
739
+ {
740
+ size: "sm",
741
+ popover: {
742
+ container: datePickerContainer
743
+ },
744
+ value: (0, import_date_fns.getYear)(date).toString(),
745
+ onChange: (value) => changeYear(parseInt(value)),
746
+ items: years.map((year) => ({ label: year.toString(), value: year.toString() }))
747
+ }
748
+ ),
749
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { onClick: increaseMonth, disabled: nextMonthButtonDisabled, variant: "transparent", size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { icon: import_free_solid_svg_icons5.faChevronRight }) })
750
+ ] }) });
751
+ };
752
+
753
+ // src/core/date-picker/shared.tsx
754
+ var import_free_solid_svg_icons6 = require("@fortawesome/free-solid-svg-icons");
755
+
756
+ // src/core/date-picker/DatePickerInput.tsx
757
+ var import_react3 = require("react");
758
+ var import_tailwind_merge8 = require("tailwind-merge");
759
+
760
+ // src/core/types.ts
761
+ var RING_COLOR_CLASSNAME = "focus:ring-2 focus:ring-indigo-200";
762
+
763
+ // src/core/date-picker/DatePickerInput.tsx
764
+ var import_jsx_runtime13 = require("react/jsx-runtime");
765
+ var DatePickerInput = (0, import_react3.forwardRef)(
766
+ ({ inputProps, errorNode, hasError, rightAction, disabled, className, ...rest }, ref) => {
767
+ const ringClassName = disabled ? "focus:outline-hidden focus:ring-0" : hasError ? "focus:outline-hidden focus:ring-red-500 focus:border-red-500" : RING_COLOR_CLASSNAME;
768
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
769
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative block w-full rounded-md shadow-sm", children: [
770
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
771
+ "input",
772
+ {
773
+ type: "text",
774
+ className: (0, import_tailwind_merge8.twMerge)(
775
+ "block w-full rounded-md disabled:bg-gray-100",
776
+ rightAction && "pr-8",
777
+ hasError ? "border-red-300 text-red-900 placeholder-red-300" : "border-gray-200",
778
+ ringClassName,
779
+ className,
780
+ inputProps?.className
781
+ ),
782
+ ref,
783
+ disabled,
784
+ autoComplete: "off",
785
+ ...rest,
786
+ ...inputProps
787
+ }
788
+ ),
789
+ rightAction && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: (0, import_tailwind_merge8.twJoin)("absolute inset-y-0 right-0 flex items-center pr-3", disabled && "cursor-auto"), children: rightAction })
790
+ ] }),
791
+ hasError != null && errorNode != null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "mt-2 max-h-[100px] overflow-auto text-sm text-red-600", children: errorNode })
792
+ ] });
793
+ }
794
+ );
795
+
796
+ // src/core/date-picker/shared.tsx
797
+ var import_jsx_runtime14 = require("react/jsx-runtime");
798
+ var customInputFieldFactory = ({
799
+ inputProps,
800
+ errorNode,
801
+ hasError,
802
+ isEmpty,
803
+ disabled,
804
+ onClearInput
805
+ }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
806
+ DatePickerInput,
807
+ {
808
+ inputProps,
809
+ errorNode,
810
+ hasError,
811
+ rightAction: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-gray-300", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { icon: import_free_solid_svg_icons6.faCalendar }) }) : !disabled ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { size: "xs", onClick: onClearInput, variant: "transparent", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-gray-500", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { icon: import_free_solid_svg_icons6.faXmark }) }) }) : null
812
+ }
813
+ );
814
+
815
+ // src/core/date-picker/TimeInput.tsx
816
+ var import_react5 = require("react");
817
+
818
+ // src/core/input/InputBox.tsx
819
+ var React6 = __toESM(require("react"), 1);
820
+ var import_react4 = require("react");
821
+
822
+ // src/core/input/inputBoxStyles.ts
823
+ var import_tailwind_merge9 = require("tailwind-merge");
824
+ var sizeStyles2 = {
825
+ sm: "h-sm gap-1 px-2 text-sm [&>input]:text-sm",
826
+ md: "h-md gap-2 px-2.5 text-base [&>input]:text-base",
827
+ lg: "h-lg gap-2.5 px-3 text-lg [&>input]:text-lg"
828
+ };
829
+ var defaultVariantStyles = "rounded-md border bg-white focus-within:outline focus:outline focus-within:outline-offset-0 focus:outline-offset-0 focus-within:outline-2 focus:outline-2";
830
+ var transparentVariantStyles = "border-none bg-transparent focus-within:outline-hidden focus:outline-hidden";
831
+ var variantStyles = {
832
+ default: {
833
+ default: `${defaultVariantStyles} disabled:bg-gray-100 disabled:text-gray-400 border-gray-200 focus-within:border-indigo-400 focus-within:outline-indigo-200 focus:border-indigo-400 focus:outline-indigo-200`,
834
+ error: `${defaultVariantStyles} border-red-300 focus-within:border-red-300 focus-within:outline-red-200 focus:border-red-300 focus:outline-red-200`,
835
+ warning: `${defaultVariantStyles} border-yellow-300 focus-within:border-yellow-300 focus-within:outline-yellow-200 focus:border-yellow-300 focus:outline-yellow-200`
836
+ },
837
+ transparent: {
838
+ default: `${transparentVariantStyles} disabled:bg-gray-100 disabled:text-gray-400`,
839
+ error: transparentVariantStyles,
840
+ warning: transparentVariantStyles
841
+ }
842
+ };
843
+ var inputBoxStyles = ({ size = "md", variant = "default", hasError, hasWarning }) => (0, import_tailwind_merge9.twJoin)(
844
+ "flex w-full items-center focus-within:ring-0 focus:ring-0 has-disabled:bg-gray-100 has-disabled:text-gray-400",
845
+ sizeStyles2[size],
846
+ variantStyles[variant][hasError ? "error" : hasWarning ? "warning" : "default"]
847
+ );
848
+ var inputStyles = "w-full text-gray-800 placeholder:text-gray-400 disabled:text-gray-400";
849
+
850
+ // src/core/input/InputBox.tsx
851
+ var import_jsx_runtime15 = require("react/jsx-runtime");
852
+ var NestedInputImpl = (props, ref) => {
853
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
854
+ "input",
855
+ {
856
+ type: "text",
857
+ className: `${inputStyles} border-none bg-transparent p-0 focus:ring-0 focus:outline-hidden`,
858
+ autoComplete: "off",
859
+ ...props,
860
+ ref
861
+ }
862
+ );
863
+ };
864
+ var NestedInput = (0, import_react4.forwardRef)(NestedInputImpl);
865
+ var InputBoxImpl = ({ children, ...style }, ref) => (
866
+ // Styling text to propagate stateful text color inheritance for the children of InputBox
867
+ // (think Icons, other non-input elements). Avoids style collisions when Input is used solo.
868
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { ref, className: `${style.hasError ? "text-red-300" : "text-gray-400"} ${inputBoxStyles(style)}`, children })
869
+ );
870
+ var InputBox = React6.forwardRef(InputBoxImpl);
871
+ InputBox.Input = NestedInput;
872
+ var InputImpl = ({ size, variant, hasError, hasWarning, prefix, ...rest }, ref) => {
873
+ return prefix ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-row items-center", children: [
874
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { className: "p-1 text-gray-500", children: prefix }),
875
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
876
+ "input",
877
+ {
878
+ type: "text",
879
+ className: `${inputStyles} ${inputBoxStyles({ size, variant, hasError, hasWarning })}`,
880
+ autoComplete: "off",
881
+ ...rest,
882
+ ref
883
+ }
884
+ )
885
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
886
+ "input",
887
+ {
888
+ type: "text",
889
+ className: `${inputStyles} ${inputBoxStyles({ size, variant, hasError, hasWarning })}`,
890
+ autoComplete: "off",
891
+ ...rest,
892
+ ref
893
+ }
894
+ );
895
+ };
896
+ var Input = (0, import_react4.forwardRef)(InputImpl);
897
+
898
+ // src/core/date-picker/TimeInput.tsx
899
+ var import_jsx_runtime16 = require("react/jsx-runtime");
900
+ var TimeInput = ({
901
+ value: inputValue,
902
+ onChange
903
+ }) => {
904
+ const [value, setValue] = (0, import_react5.useState)(inputValue?.toString());
905
+ const handleUpdateTime = (0, import_react5.useCallback)(() => {
906
+ onChange?.(value);
907
+ }, [value, onChange]);
908
+ const handleKeyDown = (event) => {
909
+ if (event.key === "Enter") {
910
+ handleUpdateTime();
911
+ }
912
+ };
913
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
914
+ Input,
915
+ {
916
+ value,
917
+ onChange: (e) => setValue(e.target.value),
918
+ onBlur: handleUpdateTime,
919
+ onKeyDown: handleKeyDown,
920
+ type: "time",
921
+ required: true
922
+ }
923
+ );
924
+ };
925
+
926
+ // src/core/date-picker/DatePickerRange.tsx
927
+ var import_jsx_runtime17 = require("react/jsx-runtime");
928
+ var DatePickerRange = ({
929
+ value = [void 0, void 0],
930
+ errorNode,
931
+ hasError,
932
+ inputProps,
933
+ placeholder,
934
+ onChange,
935
+ position = "bottom-start",
936
+ ...props
937
+ }) => {
938
+ const handleChange = (0, import_react6.useCallback)(
939
+ (date) => onChange?.([date[0] || void 0, date[1] || void 0]),
940
+ [onChange]
941
+ );
942
+ const clearDatePicker = (0, import_react6.useCallback)(
943
+ (e) => {
944
+ e.preventDefault();
945
+ onChange?.([void 0, void 0]);
946
+ },
947
+ [onChange]
948
+ );
949
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
950
+ import_react_datepicker.default,
951
+ {
952
+ ...props,
953
+ className: "placeholder:text-gray-400",
954
+ selected: value[0],
955
+ onChange: handleChange,
956
+ startDate: value[0],
957
+ endDate: value[1],
958
+ dateFormat: props.showTimeInput ? "MM/dd/yyyy h:mm aa" : "MM/dd/yyyy",
959
+ selectsRange: true,
960
+ popperPlacement: position,
961
+ placeholderText: placeholder,
962
+ customInput: !props.inline ? customInputFieldFactory({
963
+ inputProps,
964
+ isEmpty: value[0] == null && value[1] == null,
965
+ disabled: props.disabled,
966
+ errorNode,
967
+ hasError,
968
+ onClearInput: clearDatePicker
969
+ }) : void 0,
970
+ customTimeInput: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TimeInput, {}),
971
+ renderCustomHeader: DatePickerHeader
972
+ }
973
+ );
974
+ };
975
+
976
+ // src/core/date-picker/DatePickerSingle.tsx
977
+ var import_react7 = require("react");
978
+ var import_react_datepicker2 = __toESM(require("react-datepicker"), 1);
979
+ var import_jsx_runtime18 = require("react/jsx-runtime");
980
+ var DatePickerSingle = ({
981
+ value,
982
+ errorNode,
983
+ hasError,
984
+ inputProps,
985
+ placeholder,
986
+ onChange,
987
+ position = "bottom-start",
988
+ preventOpenOnFocus = true,
989
+ ...props
990
+ }) => {
991
+ const handleChange = (0, import_react7.useCallback)((date) => onChange?.(date ?? void 0), [onChange]);
992
+ const clearDatePicker = (0, import_react7.useCallback)(
993
+ (e) => {
994
+ e.preventDefault();
995
+ onChange?.(void 0);
996
+ },
997
+ [onChange]
998
+ );
999
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1000
+ import_react_datepicker2.default,
1001
+ {
1002
+ ...props,
1003
+ className: "placeholder:text-gray-400",
1004
+ preventOpenOnFocus,
1005
+ selected: value,
1006
+ onChange: handleChange,
1007
+ timeInputLabel: "",
1008
+ dateFormat: props.showTimeInput ? "MM/dd/yyyy h:mm aa" : "MM/dd/yyyy",
1009
+ placeholderText: placeholder,
1010
+ customInput: !props.inline ? customInputFieldFactory({
1011
+ inputProps,
1012
+ isEmpty: value == null,
1013
+ disabled: props.disabled,
1014
+ errorNode,
1015
+ hasError,
1016
+ onClearInput: clearDatePicker
1017
+ }) : void 0,
1018
+ customTimeInput: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TimeInput, {}),
1019
+ renderCustomHeader: DatePickerHeader,
1020
+ popperPlacement: position
1021
+ }
1022
+ );
1023
+ };
1024
+
1025
+ // src/core/date-picker/DatePicker.tsx
1026
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1027
+ var DatePicker = (props) => props.range ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DatePickerRange, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DatePickerSingle, { ...props });
1028
+
1029
+ // src/core/divider/Divider.tsx
1030
+ var import_tailwind_merge10 = require("tailwind-merge");
1031
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1032
+ var Divider = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: (0, import_tailwind_merge10.twMerge)("h-[1px] w-full border-b border-gray-200", className) });
1033
+
1034
+ // src/core/error-text/ErrorText.tsx
1035
+ var import_react8 = require("react");
1036
+ var import_tailwind_merge11 = require("tailwind-merge");
1037
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1038
+ var ErrorTextImpl = ({ className, ...props }, ref) => {
1039
+ if (!props.children) {
1040
+ return null;
1041
+ }
1042
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { ...props, ref, className: (0, import_tailwind_merge11.twJoin)("text-red-600", className) });
1043
+ };
1044
+ var ErrorText = (0, import_react8.forwardRef)(ErrorTextImpl);
1045
+
1046
+ // src/core/form/index.ts
1047
+ var import_react_hook_form3 = require("react-hook-form");
1048
+
1049
+ // src/core/form/components/ControlledField.tsx
1050
+ var import_react9 = require("react");
1051
+
1052
+ // src/core/form/hooks.ts
1053
+ var import_zod = require("@hookform/resolvers/zod");
1054
+ var React8 = __toESM(require("react"), 1);
1055
+ var import_react_hook_form = require("react-hook-form");
1056
+ var useForm = (schema, options) => {
1057
+ const methods = (0, import_react_hook_form.useForm)(
1058
+ options != null ? { resolver: (0, import_zod.zodResolver)(schema), ...options } : { resolver: (0, import_zod.zodResolver)(schema) }
1059
+ );
1060
+ const { setError } = methods;
1061
+ const setRootError = React8.useCallback(
1062
+ (message) => {
1063
+ setError("root", { type: "root", message });
1064
+ },
1065
+ [setError]
1066
+ );
1067
+ return { ...methods, setRootError };
1068
+ };
1069
+ useForm.displayName = "useForm";
1070
+ var useFormContext = () => {
1071
+ const methods = (0, import_react_hook_form.useFormContext)();
1072
+ const { setError } = methods;
1073
+ const setRootError = React8.useCallback(
1074
+ (message) => {
1075
+ setError("root", { type: "root", message });
1076
+ },
1077
+ [setError]
1078
+ );
1079
+ return { ...methods, setRootError };
1080
+ };
1081
+ useFormContext.displayName = "useFormContext";
1082
+ var useControlledFormField = ({ name: fieldName }) => {
1083
+ const { field, fieldState } = (0, import_react_hook_form.useController)({ name: fieldName });
1084
+ const { error } = fieldState;
1085
+ return { ...field, error };
1086
+ };
1087
+ useControlledFormField.displayName = "useControlledFormField";
1088
+ var useUncontrolledFormField = ({ name: fieldName, ...changeHandlers }) => {
1089
+ const { register, getFieldState } = useFormContext();
1090
+ const formState = (0, import_react_hook_form.useFormState)();
1091
+ const memoizedRegister = React8.useCallback(() => {
1092
+ if (!changeHandlers) {
1093
+ return register(fieldName);
1094
+ }
1095
+ const { onChange, onBlur, ...restRegister } = register(fieldName);
1096
+ const handleOnChange = async (event) => {
1097
+ await onChange(event);
1098
+ changeHandlers?.onChange?.(event);
1099
+ };
1100
+ const handleOnBlur = async (event) => {
1101
+ await onBlur(event);
1102
+ changeHandlers?.onBlur?.(event);
1103
+ };
1104
+ return {
1105
+ // TODO: add id to register for easier linking with labels
1106
+ // id: register().name,
1107
+ ...restRegister,
1108
+ onChange: changeHandlers?.onChange ? handleOnChange : onChange,
1109
+ onBlur: changeHandlers?.onBlur ? handleOnBlur : onBlur
1110
+ };
1111
+ }, [changeHandlers, register, fieldName]);
1112
+ const { error } = getFieldState(fieldName, formState);
1113
+ return { register: memoizedRegister, error };
1114
+ };
1115
+ useUncontrolledFormField.displayName = "useUncontrolledFormField";
1116
+
1117
+ // src/core/form/components/ControlledField.tsx
1118
+ var import_jsx_runtime22 = require("react/jsx-runtime");
1119
+ var ControlledFieldContext = (0, import_react9.createContext)(void 0);
1120
+ var ControlledFieldProvider = ({ children, ...restField }) => {
1121
+ const field = useControlledFormField(restField);
1122
+ const value = (0, import_react9.useMemo)(() => field, [field]);
1123
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ControlledFieldContext.Provider, { value, children });
1124
+ };
1125
+ ControlledFieldProvider.displayName = "ControlledFieldProvider";
1126
+ var useControlledField = () => {
1127
+ const context = (0, import_react9.useContext)(ControlledFieldContext);
1128
+ if (context) {
1129
+ return context;
1130
+ }
1131
+ throw new Error("useControlledField must be used within ControlledFieldProvider");
1132
+ };
1133
+ useControlledField.displayName = "useControlledField";
1134
+ var ControlledField = ({ render, ...restField }) => {
1135
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: render(useControlledFormField(restField)) });
1136
+ };
1137
+ ControlledField.displayName = "ControlledField";
1138
+
1139
+ // src/core/form/components/UncontrolledField.tsx
1140
+ var import_react10 = require("react");
1141
+ var import_jsx_runtime23 = require("react/jsx-runtime");
1142
+ var UncontrolledFieldContext = (0, import_react10.createContext)(void 0);
1143
+ var UncontrolledFieldProvider = ({
1144
+ children,
1145
+ ...restField
1146
+ }) => {
1147
+ const field = useUncontrolledFormField(restField);
1148
+ const value = (0, import_react10.useMemo)(() => field, [field]);
1149
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UncontrolledFieldContext.Provider, { value, children });
1150
+ };
1151
+ UncontrolledFieldProvider.displayName = "UncontrolledFieldProvider";
1152
+ var useUncontrolledField = () => {
1153
+ const context = (0, import_react10.useContext)(UncontrolledFieldContext);
1154
+ if (context) {
1155
+ return context;
1156
+ }
1157
+ throw new Error("useUncontrolledField must be used within UncontrolledFieldProvider");
1158
+ };
1159
+ useUncontrolledField.displayName = "useUncontrolledField";
1160
+ var UncontrolledField = ({ render, ...restField }) => {
1161
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: render(useUncontrolledFormField(restField)) });
1162
+ };
1163
+ UncontrolledField.displayName = "UncontrolledField";
1164
+
1165
+ // src/core/form/utils.ts
1166
+ var import_react_hook_form2 = require("react-hook-form");
1167
+ var getFieldError = (errors, name) => {
1168
+ if (name == null || errors == null) {
1169
+ return void 0;
1170
+ }
1171
+ return (0, import_react_hook_form2.get)(errors, name);
1172
+ };
1173
+
1174
+ // src/core/form/components/form-item/index.tsx
1175
+ var import_react15 = require("react");
1176
+
1177
+ // src/core/form/components/form-item/InlineFormItem.tsx
1178
+ var import_react11 = require("react");
1179
+
1180
+ // src/core/form/components/form-item/FieldErrorTooltip.tsx
1181
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1182
+ var FieldErrorTooltip = ({ error, children }) => {
1183
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1184
+ Tooltip,
1185
+ {
1186
+ variant: "light",
1187
+ open: error?.message ? void 0 : false,
1188
+ trigger: children,
1189
+ content: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ErrorText, { children: error?.message })
1190
+ }
1191
+ );
1192
+ };
1193
+
1194
+ // src/core/form/components/form-item/InlineFormItem.tsx
1195
+ var import_jsx_runtime25 = require("react/jsx-runtime");
1196
+ var InlineFormItem = (0, import_react11.forwardRef)(({ error, render }, ref) => {
1197
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FieldErrorTooltip, { error, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { ref, children: render }) });
1198
+ });
1199
+
1200
+ // src/core/form/components/form-item/NoneFormItem.tsx
1201
+ var import_react12 = require("react");
1202
+
1203
+ // src/core/form/components/form-item/FieldDescription.tsx
1204
+ var import_tailwind_merge12 = require("tailwind-merge");
1205
+ var import_jsx_runtime26 = require("react/jsx-runtime");
1206
+ var FieldDescription = ({ styles, children }) => {
1207
+ if (children == null) {
1208
+ return null;
1209
+ }
1210
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: (0, import_tailwind_merge12.twJoin)("text-sm text-gray-500", styles), children });
1211
+ };
1212
+
1213
+ // src/core/form/components/form-item/FieldErrorMessage.tsx
1214
+ var import_free_solid_svg_icons7 = require("@fortawesome/free-solid-svg-icons");
1215
+
1216
+ // src/core/overflow-tooltip/OverflowTooltip.tsx
1217
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1218
+ var OverflowTooltip = ({ element, tooltip, side, variant, ...props }) => {
1219
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Tooltip.Root, { ...props, children: [
1220
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Tooltip.OverflowTrigger, { element }),
1221
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Tooltip.Content, { side, variant, children: tooltip })
1222
+ ] });
1223
+ };
1224
+
1225
+ // src/core/form/components/form-item/FieldErrorMessage.tsx
1226
+ var import_jsx_runtime28 = require("react/jsx-runtime");
1227
+ function handleErrorOrErrorArrayMessage(error) {
1228
+ if (!Array.isArray(error)) {
1229
+ return error.message;
1230
+ }
1231
+ if (error.length === 1) {
1232
+ return error[0].message;
1233
+ }
1234
+ return error.map((err, index) => `Item ${index + 1}: ${err.message}`).join(", ");
1235
+ }
1236
+ var FieldErrorMessage = ({ error }) => {
1237
+ if (error == null) {
1238
+ return null;
1239
+ }
1240
+ const message = handleErrorOrErrorArrayMessage(error);
1241
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex h-4.5 items-center gap-x-1 pt-0.5 text-sm", children: [
1242
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-red-400", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon, { icon: import_free_solid_svg_icons7.faCircleExclamation }) }),
1243
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1244
+ OverflowTooltip,
1245
+ {
1246
+ tooltip: message,
1247
+ element: (ref) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ErrorText, { ref, className: "line-clamp-1 cursor-default break-all", children: message })
1248
+ }
1249
+ )
1250
+ ] });
1251
+ };
1252
+
1253
+ // src/core/form/components/form-item/FieldLabelWithTooltip.tsx
1254
+ var import_free_solid_svg_icons8 = require("@fortawesome/free-solid-svg-icons");
1255
+ var import_tailwind_merge14 = require("tailwind-merge");
1256
+
1257
+ // src/core/form/components/form-item/FieldLabel.tsx
1258
+ var import_tailwind_merge13 = require("tailwind-merge");
1259
+ var import_jsx_runtime29 = require("react/jsx-runtime");
1260
+ var FieldLabel = ({ styles, htmlFor, children }) => {
1261
+ if (children == null) {
1262
+ return null;
1263
+ }
1264
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("label", { htmlFor, className: (0, import_tailwind_merge13.twJoin)("block text-sm font-normal text-gray-500", styles), children });
1265
+ };
1266
+
1267
+ // src/core/form/components/form-item/FieldLabelWithTooltip.tsx
1268
+ var import_jsx_runtime30 = require("react/jsx-runtime");
1269
+ var FieldLabelWithTooltip = ({ styles, label, options }) => {
1270
+ if (label == null) {
1271
+ return null;
1272
+ }
1273
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(FieldLabel, { styles: (0, import_tailwind_merge14.twJoin)("space-x-1", styles), children: [
1274
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: label }),
1275
+ options?.optionalLabel && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "text-gray-400", children: "(Optional)" }),
1276
+ options?.tooltip && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1277
+ Tooltip,
1278
+ {
1279
+ content: options?.tooltip,
1280
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("span", { className: "inline-flex items-baseline space-x-1", children: [
1281
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "leading-none", children: options.tooltipIcon ? options.tooltipIcon : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "text-gray-500", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Icon, { icon: import_free_solid_svg_icons8.faCircleQuestion }) }) }),
1282
+ options?.tooltipLabel && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "font-normal text-gray-500", children: options?.tooltipLabel })
1283
+ ] })
1284
+ }
1285
+ ),
1286
+ options?.inlineLabelEndSlot
1287
+ ] });
1288
+ };
1289
+
1290
+ // src/core/form/components/form-item/NoneFormItem.tsx
1291
+ var import_jsx_runtime31 = require("react/jsx-runtime");
1292
+ var NoneFormItemImpl = ({ label, options, render, error }, ref) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
1293
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { children: [
1294
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FieldLabelWithTooltip, { label, options }),
1295
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FieldDescription, { styles: "pt-0.5", children: options?.description })
1296
+ ] }),
1297
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { ref, children: [
1298
+ render,
1299
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FieldErrorMessage, { error }),
1300
+ options?.bottomSlot
1301
+ ] })
1302
+ ] });
1303
+ var NoneFormItem = (0, import_react12.forwardRef)(NoneFormItemImpl);
1304
+
1305
+ // src/core/form/components/form-item/SideBySideFormItem.tsx
1306
+ var import_react13 = require("react");
1307
+ var import_tailwind_merge15 = require("tailwind-merge");
1308
+ var import_jsx_runtime32 = require("react/jsx-runtime");
1309
+ var SideBySideFormItem = (0, import_react13.forwardRef)(
1310
+ ({ styles, label, options, render, error }, ref) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: (0, import_tailwind_merge15.twJoin)("grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] gap-x-1", styles), ref, children: [
1311
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "pt-2.5", children: [
1312
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FieldLabelWithTooltip, { label, options }),
1313
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FieldDescription, { styles: "pt-0.5", children: options?.description })
1314
+ ] }),
1315
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { children: [
1316
+ render,
1317
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FieldErrorMessage, { error }),
1318
+ options?.bottomSlot
1319
+ ] })
1320
+ ] })
1321
+ );
1322
+
1323
+ // src/core/form/components/form-item/StackedFormItem.tsx
1324
+ var import_react14 = require("react");
1325
+ var import_tailwind_merge16 = require("tailwind-merge");
1326
+ var import_jsx_runtime33 = require("react/jsx-runtime");
1327
+ var StackedFormItem = (0, import_react14.forwardRef)(
1328
+ ({ styles, label, options, render, error }, ref) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: styles || void 0, ref, children: [
1329
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1330
+ FieldLabelWithTooltip,
1331
+ {
1332
+ styles: (0, import_tailwind_merge16.twJoin)("flex items-baseline", options?.description == null && "pb-1"),
1333
+ label,
1334
+ options
1335
+ }
1336
+ ),
1337
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldDescription, { styles: "pb-1", children: options?.description }),
1338
+ render,
1339
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldErrorMessage, { error }),
1340
+ options?.bottomSlot
1341
+ ] })
1342
+ );
1343
+
1344
+ // src/core/form/components/form-item/index.tsx
1345
+ var import_jsx_runtime34 = require("react/jsx-runtime");
1346
+ var FormItem = (0, import_react15.forwardRef)(({ layout = "stacked", ...rest }, ref) => {
1347
+ switch (layout) {
1348
+ case "inline":
1349
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(InlineFormItem, { ...rest, ref });
1350
+ case "side-by-side":
1351
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SideBySideFormItem, { ...rest, ref });
1352
+ case "stacked":
1353
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(StackedFormItem, { ...rest, ref });
1354
+ case "none":
1355
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(NoneFormItem, { ...rest, ref });
1356
+ default:
1357
+ throw new Error(`Unknown form item layout: ${layout}`);
1358
+ }
1359
+ });
1360
+
1361
+ // src/core/form/components/FormInput.tsx
1362
+ var import_jsx_runtime35 = require("react/jsx-runtime");
1363
+ var FormInput = ({
1364
+ name,
1365
+ styles,
1366
+ layout,
1367
+ label,
1368
+ options,
1369
+ onChange,
1370
+ onBlur,
1371
+ disabled,
1372
+ ...rest
1373
+ }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1374
+ UncontrolledField,
1375
+ {
1376
+ name,
1377
+ onChange,
1378
+ onBlur,
1379
+ render: ({ error, register }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1380
+ FormItem,
1381
+ {
1382
+ layout,
1383
+ styles,
1384
+ label,
1385
+ options,
1386
+ render: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Input, { ...register(), ...rest, disabled, hasError: !disabled && (!!error || void 0) }),
1387
+ error
1388
+ }
1389
+ )
1390
+ }
1391
+ );
1392
+
1393
+ // src/core/form/components/FormDollarInput.tsx
1394
+ var import_free_solid_svg_icons9 = require("@fortawesome/free-solid-svg-icons");
1395
+ var import_react17 = require("react");
1396
+ var import_tailwind_merge17 = require("tailwind-merge");
1397
+
1398
+ // src/core/utils/useSyncState.ts
1399
+ var import_react16 = require("react");
1400
+ var useSyncState = (upstream) => {
1401
+ const [prevUpstream, setPrevUpstream] = (0, import_react16.useState)(upstream);
1402
+ const [state, setState] = (0, import_react16.useState)(upstream);
1403
+ if (prevUpstream !== upstream) {
1404
+ setState(upstream);
1405
+ setPrevUpstream(upstream);
1406
+ }
1407
+ return [state, setState];
1408
+ };
1409
+
1410
+ // src/core/form/components/FormDollarInput.tsx
1411
+ var import_jsx_runtime36 = require("react/jsx-runtime");
1412
+ var twoDecimalFormatter = Intl.NumberFormat("en-US", {
1413
+ minimumFractionDigits: 2,
1414
+ maximumFractionDigits: 2
1415
+ });
1416
+ var formatInput = (value) => {
1417
+ return value.replaceAll(/[^0-9.,-]/g, "");
1418
+ };
1419
+ var roundToTwoDecimalPlaces = (value) => {
1420
+ return Math.round((value + Number.EPSILON) * 100) / 100;
1421
+ };
1422
+ var DollarInput = (0, import_react17.forwardRef)(
1423
+ ({ value, onChange, disabled = false, hasError = false, hasWarning = false, message }, ref) => {
1424
+ const [strValue, setStrValue] = useSyncState(value == null ? "" : twoDecimalFormatter.format(value / 100));
1425
+ const handleChange = (event) => {
1426
+ const inputValue = formatInput(event.target.value);
1427
+ if (!inputValue) {
1428
+ setStrValue("");
1429
+ return;
1430
+ }
1431
+ if (inputValue === "-" || inputValue === ".") {
1432
+ setStrValue(inputValue);
1433
+ return;
1434
+ }
1435
+ if (inputValue.split(".")?.[1]?.length > 2) return;
1436
+ const parsedValue = parseFloat(inputValue);
1437
+ if (!isNaN(parsedValue)) {
1438
+ setStrValue(inputValue);
1439
+ }
1440
+ };
1441
+ const handlePaste = (event) => {
1442
+ event.preventDefault();
1443
+ const pastedData = formatInput(event.clipboardData.getData("text"));
1444
+ const parsedAmount = parseFloat(pastedData);
1445
+ if (!isNaN(parsedAmount)) {
1446
+ setStrValue(twoDecimalFormatter.format(parsedAmount));
1447
+ onChange?.(roundToTwoDecimalPlaces(parsedAmount * 100));
1448
+ }
1449
+ };
1450
+ const handleBlur = () => {
1451
+ const parsedValue = parseFloat(strValue.replaceAll(",", ""));
1452
+ if (isNaN(parsedValue)) {
1453
+ onChange?.(null);
1454
+ } else {
1455
+ onChange?.(roundToTwoDecimalPlaces(parsedValue * 100));
1456
+ }
1457
+ };
1458
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
1459
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
1460
+ "div",
1461
+ {
1462
+ className: (0, import_tailwind_merge17.twJoin)(
1463
+ "flex h-md w-full items-center rounded-sm py-2.5 text-base [&>input]:rounded-l-none! [&>input]:rounded-r-md!",
1464
+ disabled && "cursor-not-allowed [&>input]:cursor-not-allowed [&>input]:bg-gray-50! [&>input]:text-gray-500!"
1465
+ ),
1466
+ children: [
1467
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1468
+ "div",
1469
+ {
1470
+ className: (0, import_tailwind_merge17.twJoin)(
1471
+ "flex h-md w-9.5 items-center justify-center rounded-l-md border-y border-l px-2.5 text-sm text-gray-500",
1472
+ hasError ? "border-red-300 bg-red-200 text-red-700" : hasWarning ? "border-yellow-300 bg-yellow-100 text-yellow-700" : "border-gray-200 bg-gray-100"
1473
+ ),
1474
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Icon, { icon: import_free_solid_svg_icons9.faDollarSign })
1475
+ }
1476
+ ),
1477
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1478
+ Input,
1479
+ {
1480
+ ref,
1481
+ variant: "default",
1482
+ disabled,
1483
+ value: strValue,
1484
+ hasError,
1485
+ hasWarning,
1486
+ onChange: handleChange,
1487
+ onBlur: handleBlur,
1488
+ onPaste: handlePaste,
1489
+ placeholder: "0.00"
1490
+ }
1491
+ )
1492
+ ]
1493
+ }
1494
+ ),
1495
+ hasWarning && message && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center gap-1 text-sm font-normal text-yellow-700", children: [
1496
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Icon, { icon: import_free_solid_svg_icons9.faTriangleExclamation }),
1497
+ message
1498
+ ] }),
1499
+ hasError && message && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center gap-1 text-sm font-normal text-red-700", children: [
1500
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Icon, { icon: import_free_solid_svg_icons9.faCircleExclamation }),
1501
+ message
1502
+ ] })
1503
+ ] });
1504
+ }
1505
+ );
1506
+ var FormDollarInput = (0, import_react17.forwardRef)(
1507
+ ({ name, layout, label, onChange, disabled, hasWarning = false, message, options }, ref) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1508
+ ControlledField,
1509
+ {
1510
+ name,
1511
+ render: (field) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1512
+ FormItem,
1513
+ {
1514
+ label,
1515
+ layout,
1516
+ options,
1517
+ error: field.error,
1518
+ render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1519
+ DollarInput,
1520
+ {
1521
+ onChange: (cents) => {
1522
+ field.onChange(cents);
1523
+ onChange?.(cents);
1524
+ },
1525
+ value: field.value,
1526
+ disabled,
1527
+ hasError: !disabled && (!!field.error || void 0),
1528
+ hasWarning: !disabled && hasWarning,
1529
+ message,
1530
+ ref
1531
+ }
1532
+ )
1533
+ }
1534
+ )
1535
+ }
1536
+ )
1537
+ );
1538
+
1539
+ // src/core/form/components/FormPercentInput.tsx
1540
+ var import_free_solid_svg_icons10 = require("@fortawesome/free-solid-svg-icons");
1541
+ var import_react18 = require("react");
1542
+ var import_tailwind_merge18 = require("tailwind-merge");
1543
+ var import_jsx_runtime37 = require("react/jsx-runtime");
1544
+ var twoDecimalFormatter2 = Intl.NumberFormat("en-US", {
1545
+ minimumFractionDigits: 0,
1546
+ maximumFractionDigits: 2
1547
+ });
1548
+ var formatInput2 = (value) => {
1549
+ return value.replaceAll(/[^0-9.,]/g, "");
1550
+ };
1551
+ var roundToTwoDecimalPlaces2 = (value) => {
1552
+ return Math.round((value + Number.EPSILON) * 100) / 100;
1553
+ };
1554
+ var PercentInput = (0, import_react18.forwardRef)(
1555
+ ({ value, onChange, disabled = false, hasError = false, hasWarning = false, message }, ref) => {
1556
+ const [strValue, setStrValue] = useSyncState(value == null ? "" : twoDecimalFormatter2.format(value));
1557
+ const handleChange = (event) => {
1558
+ const inputValue = formatInput2(event.target.value);
1559
+ if (!inputValue) {
1560
+ setStrValue("");
1561
+ return;
1562
+ }
1563
+ if (inputValue === ".") {
1564
+ setStrValue(inputValue);
1565
+ return;
1566
+ }
1567
+ if (inputValue.split(".")?.[1]?.length > 2) return;
1568
+ const parsedValue = parseFloat(inputValue);
1569
+ if (!isNaN(parsedValue)) {
1570
+ setStrValue(inputValue);
1571
+ }
1572
+ };
1573
+ const handlePaste = (event) => {
1574
+ event.preventDefault();
1575
+ const pastedData = formatInput2(event.clipboardData.getData("text"));
1576
+ const parsedAmount = parseFloat(pastedData);
1577
+ if (!isNaN(parsedAmount)) {
1578
+ setStrValue(twoDecimalFormatter2.format(parsedAmount));
1579
+ onChange?.(roundToTwoDecimalPlaces2(parsedAmount));
1580
+ }
1581
+ };
1582
+ const handleBlur = () => {
1583
+ const parsedValue = parseFloat(strValue.replaceAll(",", ""));
1584
+ if (isNaN(parsedValue)) {
1585
+ onChange?.(null);
1586
+ } else {
1587
+ onChange?.(roundToTwoDecimalPlaces2(parsedValue));
1588
+ }
1589
+ };
1590
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
1591
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
1592
+ "div",
1593
+ {
1594
+ className: (0, import_tailwind_merge18.twJoin)(
1595
+ "flex h-md w-full items-center rounded-sm py-2.5 text-base [&>input]:rounded-l-none! [&>input]:rounded-r-md!",
1596
+ disabled && "cursor-not-allowed [&>input]:cursor-not-allowed [&>input]:bg-gray-50! [&>input]:text-gray-500!"
1597
+ ),
1598
+ children: [
1599
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1600
+ "div",
1601
+ {
1602
+ className: (0, import_tailwind_merge18.twJoin)(
1603
+ "flex h-md w-9.5 items-center justify-center rounded-l-md border-y border-l px-2.5 text-sm text-gray-500",
1604
+ hasError ? "border-red-300 bg-red-200 text-red-700" : hasWarning ? "border-yellow-300 bg-yellow-100 text-yellow-700" : "border-gray-200 bg-gray-100"
1605
+ ),
1606
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { icon: import_free_solid_svg_icons10.faPercent })
1607
+ }
1608
+ ),
1609
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1610
+ Input,
1611
+ {
1612
+ ref,
1613
+ variant: "default",
1614
+ disabled,
1615
+ value: strValue,
1616
+ hasError,
1617
+ hasWarning,
1618
+ onChange: handleChange,
1619
+ onBlur: handleBlur,
1620
+ onPaste: handlePaste,
1621
+ placeholder: "0"
1622
+ }
1623
+ )
1624
+ ]
1625
+ }
1626
+ ),
1627
+ hasWarning && message && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-1 text-sm font-normal text-yellow-700", children: [
1628
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { icon: import_free_solid_svg_icons10.faTriangleExclamation }),
1629
+ message
1630
+ ] }),
1631
+ hasError && message && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-1 text-sm font-normal text-red-700", children: [
1632
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { icon: import_free_solid_svg_icons10.faCircleExclamation }),
1633
+ message
1634
+ ] })
1635
+ ] });
1636
+ }
1637
+ );
1638
+ var FormPercentInput = (0, import_react18.forwardRef)(
1639
+ ({ name, layout, label, onChange, disabled, hasWarning = false, message, options }, ref) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1640
+ ControlledField,
1641
+ {
1642
+ name,
1643
+ render: (field) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1644
+ FormItem,
1645
+ {
1646
+ label,
1647
+ layout,
1648
+ options,
1649
+ error: field.error,
1650
+ render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1651
+ PercentInput,
1652
+ {
1653
+ onChange: (percent) => {
1654
+ field.onChange(percent);
1655
+ onChange?.(percent);
1656
+ },
1657
+ value: field.value,
1658
+ disabled,
1659
+ hasError: !disabled && (!!field.error || void 0),
1660
+ hasWarning: !disabled && hasWarning,
1661
+ message,
1662
+ ref
1663
+ }
1664
+ )
1665
+ }
1666
+ )
1667
+ }
1668
+ )
1669
+ );
1670
+
1671
+ // src/core/form/components/FormCheckbox.tsx
1672
+ var import_jsx_runtime38 = require("react/jsx-runtime");
1673
+ var FormCheckbox = ({ name, disabled, onChange: propsOnChange, children }) => {
1674
+ const {
1675
+ onChange,
1676
+ error,
1677
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1678
+ value,
1679
+ ...field
1680
+ } = useControlledFormField({ name });
1681
+ const handleChange = (e) => {
1682
+ const { checked } = e.target;
1683
+ onChange(checked);
1684
+ propsOnChange?.(checked);
1685
+ };
1686
+ if (children == null) {
1687
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
1688
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1689
+ Checkbox,
1690
+ {
1691
+ ...field,
1692
+ id: name,
1693
+ disabled,
1694
+ checked: !!value,
1695
+ onChange: handleChange,
1696
+ hasError: !!error
1697
+ }
1698
+ ),
1699
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FieldErrorMessage, { error })
1700
+ ] });
1701
+ }
1702
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(ControlledFieldProvider, { name, children: [
1703
+ children,
1704
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FieldErrorMessage, { error })
1705
+ ] });
1706
+ };
1707
+ function CheckboxImpl({ onChange: propsOnChange }) {
1708
+ const {
1709
+ name,
1710
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1711
+ value,
1712
+ onChange,
1713
+ error,
1714
+ ...field
1715
+ } = useControlledField();
1716
+ const handleChange = (e) => {
1717
+ const { checked } = e.target;
1718
+ onChange(checked);
1719
+ propsOnChange?.(checked);
1720
+ };
1721
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Checkbox, { ...field, id: name, checked: !!value, onChange: handleChange, hasError: !!error });
1722
+ }
1723
+ function LabelImpl({ children, className }) {
1724
+ const { name } = useControlledField();
1725
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FieldLabel, { htmlFor: name, styles: className, children });
1726
+ }
1727
+ FormCheckbox.Label = LabelImpl;
1728
+ FormCheckbox.Checkbox = CheckboxImpl;
1729
+
1730
+ // src/core/form/components/ControlledFormItem.tsx
1731
+ var import_jsx_runtime39 = require("react/jsx-runtime");
1732
+ var ControlledFormItem = ({
1733
+ name,
1734
+ styles,
1735
+ layout,
1736
+ label,
1737
+ options,
1738
+ render
1739
+ }) => {
1740
+ const field = useControlledFormField({ name });
1741
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
1742
+ FormItem,
1743
+ {
1744
+ layout,
1745
+ styles,
1746
+ label,
1747
+ options,
1748
+ render: render(field),
1749
+ error: field.error
1750
+ }
1751
+ );
1752
+ };
1753
+
1754
+ // src/core/select/props.ts
1755
+ var DEFAULT_NUM_VALUES_TO_SHOW = 2;
1756
+
1757
+ // src/core/select/selectItem.ts
1758
+ function doesSelectItemMatch(option, query) {
1759
+ if (!query) {
1760
+ return true;
1761
+ }
1762
+ if (option.isMatch) {
1763
+ return option.isMatch(query);
1764
+ }
1765
+ return option.label.toLowerCase().includes(query.toLowerCase());
1766
+ }
1767
+
1768
+ // src/core/select/useAsyncMultiSelect.ts
1769
+ var import_react_query = require("@tanstack/react-query");
1770
+ var import_react19 = require("react");
1771
+ function useDebounce(value, delay) {
1772
+ const [debouncedValue, setDebouncedValue] = (0, import_react19.useState)(value);
1773
+ (0, import_react19.useEffect)(() => {
1774
+ const handler = setTimeout(() => {
1775
+ setDebouncedValue(value);
1776
+ }, delay);
1777
+ return () => {
1778
+ clearTimeout(handler);
1779
+ };
1780
+ }, [value, delay]);
1781
+ return debouncedValue;
1782
+ }
1783
+ function useAsyncMultiSelect({
1784
+ value,
1785
+ fetchValues,
1786
+ fetchOptions,
1787
+ objToItem,
1788
+ customValueToItem,
1789
+ queryKeyPrefix
1790
+ }) {
1791
+ const [query, setQuery] = (0, import_react19.useState)("");
1792
+ const [page, setPage] = (0, import_react19.useState)(void 0);
1793
+ const debouncedSearchTerm = useDebounce(query, 500);
1794
+ const key = Array.isArray(queryKeyPrefix) ? queryKeyPrefix : [queryKeyPrefix];
1795
+ const { data: fetchedValues } = (0, import_react_query.useQuery)({
1796
+ queryKey: [...key, "values", value],
1797
+ queryFn: () => fetchValues(value),
1798
+ enabled: !!value
1799
+ });
1800
+ const {
1801
+ data: fetchedOptions,
1802
+ isLoading: isLoadingOptions,
1803
+ error: optionsError
1804
+ } = (0, import_react_query.useQuery)({
1805
+ queryKey: [...key, "options", debouncedSearchTerm, page],
1806
+ queryFn: () => fetchOptions(debouncedSearchTerm, page)
1807
+ });
1808
+ const selectItems = (0, import_react19.useMemo)(() => {
1809
+ const fetchedValueItems = fetchedValues?.error === false ? fetchedValues.value.map(objToItem) : [];
1810
+ const customItems = customValueToItem ? value.filter((v) => !fetchedValueItems.some((i) => i.value === v)).map((v) => customValueToItem(v)) : [];
1811
+ const fetchedOptionItems = fetchedOptions?.error === false ? fetchedOptions.value.results.map(objToItem) : [];
1812
+ return [...fetchedValueItems, ...customItems, ...fetchedOptionItems];
1813
+ }, [objToItem, value, fetchedValues, fetchedOptions, customValueToItem]);
1814
+ const loadProps = {
1815
+ isLoading: isLoadingOptions,
1816
+ isError: !!(optionsError || !fetchedOptions || fetchedOptions.error),
1817
+ canLoadMore: !fetchedOptions?.error ? !!fetchedOptions?.value?.nextPage : false,
1818
+ onLoadMore: () => {
1819
+ if (!fetchedOptions?.error) {
1820
+ setPage(fetchedOptions?.value?.nextPage);
1821
+ }
1822
+ }
1823
+ };
1824
+ return {
1825
+ setQuery,
1826
+ selectItems,
1827
+ loadProps,
1828
+ queriedObjects: [
1829
+ ...fetchedValues?.error === false ? fetchedValues.value : [],
1830
+ ...fetchedOptions?.error === false ? fetchedOptions.value.results : []
1831
+ ]
1832
+ };
1833
+ }
1834
+ var useAsyncSelect = ({
1835
+ value,
1836
+ fetchValue,
1837
+ ...rest
1838
+ }) => useAsyncMultiSelect({
1839
+ value: value ? [value] : [],
1840
+ fetchValues: async (values) => {
1841
+ if (!values[0]) {
1842
+ return {
1843
+ error: false,
1844
+ value: []
1845
+ };
1846
+ }
1847
+ const result = await fetchValue(values[0]);
1848
+ if (result.error) return result;
1849
+ return {
1850
+ error: false,
1851
+ value: result.value ? [result.value] : []
1852
+ };
1853
+ },
1854
+ ...rest
1855
+ });
1856
+
1857
+ // src/core/select/AsyncMultiSelect.tsx
1858
+ var import_core3 = require("@dnd-kit/core");
1859
+ var import_sortable2 = require("@dnd-kit/sortable");
1860
+ var import_free_solid_svg_icons13 = require("@fortawesome/free-solid-svg-icons");
1861
+ var import_react21 = require("react");
1862
+ var import_tailwind_merge22 = require("tailwind-merge");
1863
+
1864
+ // src/core/dropdown-chevron/DropdownChevron.tsx
1865
+ var import_free_solid_svg_icons11 = require("@fortawesome/free-solid-svg-icons");
1866
+ var import_tailwind_merge19 = require("tailwind-merge");
1867
+ var import_jsx_runtime40 = require("react/jsx-runtime");
1868
+ var DropdownChevron = () => {
1869
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: (0, import_tailwind_merge19.twJoin)("w-3 text-sm text-gray-500"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Icon, { icon: import_free_solid_svg_icons11.faChevronDown }) });
1870
+ };
1871
+
1872
+ // src/core/popover/Popover.tsx
1873
+ var RadixPopover = __toESM(require("@radix-ui/react-popover"), 1);
1874
+ var import_tailwind_merge20 = require("tailwind-merge");
1875
+ var import_jsx_runtime41 = require("react/jsx-runtime");
1876
+ var Popover = ({
1877
+ open,
1878
+ trigger,
1879
+ triggerClassName,
1880
+ children,
1881
+ arrowClassName,
1882
+ contentClassName,
1883
+ disabled,
1884
+ onOpenChange,
1885
+ alignContent,
1886
+ container,
1887
+ ...props
1888
+ }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(RadixPopover.Root, { open, onOpenChange, children: [
1889
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(RadixPopover.Trigger, { asChild: true, disabled, className: triggerClassName, children: trigger }),
1890
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
1891
+ PopoverBody,
1892
+ {
1893
+ align: alignContent,
1894
+ ...props,
1895
+ contentClassName,
1896
+ arrowClassName,
1897
+ container,
1898
+ children
1899
+ }
1900
+ )
1901
+ ] });
1902
+ var PopoverBody = ({ children, arrowClassName, contentClassName, container, ...props }) => {
1903
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(RadixPopover.Portal, { container, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
1904
+ RadixPopover.Content,
1905
+ {
1906
+ ...props,
1907
+ className: (0, import_tailwind_merge20.twMerge)("isolate z-50 rounded-lg bg-white shadow-lg focus:outline-hidden", contentClassName),
1908
+ children: [
1909
+ children,
1910
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(RadixPopover.Arrow, { className: (0, import_tailwind_merge20.twMerge)("fill-white", arrowClassName), offset: 8 })
1911
+ ]
1912
+ }
1913
+ ) });
1914
+ };
1915
+ Popover.Root = (props) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(RadixPopover.Root, { ...props });
1916
+ Popover.Trigger = (props) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(RadixPopover.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { ...props }) });
1917
+ Popover.Body = PopoverBody;
1918
+ Popover.Close = (props) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(RadixPopover.Close, { asChild: true, ...props });
1919
+
1920
+ // src/core/select/SelectListItem.tsx
1921
+ var import_sortable = require("@dnd-kit/sortable");
1922
+ var import_utilities = require("@dnd-kit/utilities");
1923
+ var import_free_solid_svg_icons12 = require("@fortawesome/free-solid-svg-icons");
1924
+ var import_react20 = require("react");
1925
+ var import_tailwind_merge21 = require("tailwind-merge");
1926
+ var import_jsx_runtime42 = require("react/jsx-runtime");
1927
+ var SelectListItem = ({
1928
+ sortableId,
1929
+ children,
1930
+ onClick,
1931
+ disabled = false,
1932
+ focused = false
1933
+ }) => {
1934
+ const { setNodeRef, listeners, attributes, transform, transition } = (0, import_sortable.useSortable)({ id: sortableId ?? "" });
1935
+ const containerRef = (0, import_react20.useRef)(null);
1936
+ (0, import_react20.useEffect)(() => {
1937
+ if (focused && containerRef.current) {
1938
+ containerRef.current.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
1939
+ }
1940
+ }, [focused]);
1941
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
1942
+ "li",
1943
+ {
1944
+ ref: (ref) => {
1945
+ setNodeRef(ref);
1946
+ containerRef.current = ref;
1947
+ },
1948
+ onClick: disabled ? void 0 : onClick,
1949
+ className: (0, import_tailwind_merge21.twJoin)(
1950
+ "flex w-full items-center gap-2 rounded-lg px-2 py-1.5",
1951
+ disabled ? "cursor-not-allowed text-gray-400" : "cursor-pointer transition-colors duration-150 hover:bg-gray-100",
1952
+ focused && "bg-gray-100"
1953
+ ),
1954
+ style: {
1955
+ transform: import_utilities.CSS.Transform.toString(transform),
1956
+ transition
1957
+ },
1958
+ ...attributes,
1959
+ children: [
1960
+ sortableId && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
1961
+ "div",
1962
+ {
1963
+ className: "cursor-grab font-medium active:cursor-grabbing",
1964
+ ...listeners,
1965
+ onClick: (e) => {
1966
+ e.stopPropagation();
1967
+ listeners?.onClick(e);
1968
+ },
1969
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { icon: import_free_solid_svg_icons12.faGripVertical })
1970
+ }
1971
+ ),
1972
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "flex w-full flex-1 items-center justify-between", children })
1973
+ ]
1974
+ }
1975
+ );
1976
+ };
1977
+
1978
+ // src/core/select/AsyncMultiSelect.tsx
1979
+ var import_jsx_runtime43 = require("react/jsx-runtime");
1980
+ var AsyncMultiSelect = ({
1981
+ value = [],
1982
+ onChange,
1983
+ disabled = false,
1984
+ ordered,
1985
+ variant,
1986
+ triggerPlaceholder,
1987
+ hideSearch = false,
1988
+ searchPlaceholder = "Search...",
1989
+ items,
1990
+ loadProps,
1991
+ onSearchChange,
1992
+ minSelection = 0,
1993
+ maxSelection = "unlimited",
1994
+ allowCustomValues,
1995
+ hasError,
1996
+ popover,
1997
+ isValidCustomValue = () => true,
1998
+ onSelectAll,
1999
+ numValuesToShow,
2000
+ emptyState,
2001
+ size,
2002
+ onOpen,
2003
+ onClose
2004
+ }) => {
2005
+ const [open, setOpen] = (0, import_react21.useState)(false);
2006
+ const [search, setSearch] = (0, import_react21.useState)("");
2007
+ const [focusIndex, setFocusIndex] = (0, import_react21.useState)(0);
2008
+ const inputRef = (0, import_react21.useRef)(null);
2009
+ const unselectedOptions = (0, import_react21.useMemo)(() => items.filter((item) => !value.includes(item.value)), [items, value]);
2010
+ const resetSearch = () => {
2011
+ setSearch("");
2012
+ onSearchChange?.("");
2013
+ };
2014
+ const handleClose = () => {
2015
+ setOpen(false);
2016
+ resetSearch();
2017
+ setFocusIndex(0);
2018
+ onClose?.();
2019
+ };
2020
+ const searchMatchesExistingOption = value.some((v) => v.toString().toLowerCase() === search.toLowerCase()) || unselectedOptions.find((opt) => opt.value?.toString().toLowerCase() === search.toLowerCase());
2021
+ const showCustomItem = allowCustomValues && !!search && !loadProps?.isLoading && !searchMatchesExistingOption && isValidCustomValue(search);
2022
+ const isCustomValueSelected = (0, import_react21.useMemo)(
2023
+ () => allowCustomValues && value.some((v) => !items.map((item) => item.value).includes(v)),
2024
+ [allowCustomValues, items, value]
2025
+ );
2026
+ const showCustomValue = isCustomValueSelected && !loadProps?.isLoading;
2027
+ const handleAddCustomItem = () => {
2028
+ if (maxSelection === 1) {
2029
+ setOpen(false);
2030
+ onChange?.([search]);
2031
+ } else {
2032
+ onChange?.([...value, search]);
2033
+ }
2034
+ resetSearch();
2035
+ };
2036
+ const handleOptionSelected = (val) => {
2037
+ if (maxSelection === 1) {
2038
+ onChange?.([val]);
2039
+ handleClose();
2040
+ } else {
2041
+ let items2 = ordered ? [...value, val] : [val, ...value];
2042
+ if (maxSelection !== "unlimited") {
2043
+ items2 = items2.slice(0, maxSelection);
2044
+ }
2045
+ onChange?.(items2);
2046
+ }
2047
+ if (inputRef.current) {
2048
+ inputRef.current.select();
2049
+ }
2050
+ };
2051
+ const totalNumItems = unselectedOptions.length + (showCustomItem ? 1 : 0);
2052
+ const handleKeyDown = (e) => {
2053
+ if (e.key === "ArrowDown") {
2054
+ e.preventDefault();
2055
+ setFocusIndex((prev) => (prev + 1) % totalNumItems);
2056
+ } else if (e.key === "ArrowUp") {
2057
+ e.preventDefault();
2058
+ setFocusIndex((prev) => Math.max(prev - 1, 0));
2059
+ } else if (e.key === "Enter") {
2060
+ e.preventDefault();
2061
+ if (focusIndex === 0 && showCustomItem) {
2062
+ handleAddCustomItem();
2063
+ } else if (totalNumItems > focusIndex) {
2064
+ const unselectedOptionsIndex = focusIndex - (showCustomItem ? 1 : 0);
2065
+ if (!unselectedOptions[unselectedOptionsIndex].disabled) {
2066
+ handleOptionSelected(unselectedOptions[unselectedOptionsIndex].value);
2067
+ }
2068
+ }
2069
+ } else if (e.key === "Tab") {
2070
+ e.preventDefault();
2071
+ setOpen(false);
2072
+ }
2073
+ };
2074
+ const handleSearchTermChange = (val) => {
2075
+ setSearch(val);
2076
+ setFocusIndex(0);
2077
+ onSearchChange?.(val);
2078
+ };
2079
+ const handleTriggerKeyDown = (e) => {
2080
+ if (!hideSearch && !e.ctrlKey && !e.metaKey && !e.altKey) {
2081
+ setOpen(true);
2082
+ onOpen?.();
2083
+ handleSearchTermChange(e.key);
2084
+ }
2085
+ };
2086
+ const valueToOptionMap = (0, import_react21.useMemo)(() => {
2087
+ const map = /* @__PURE__ */ new Map();
2088
+ items.forEach((item) => map.set(item.value, item));
2089
+ return map;
2090
+ }, [items]);
2091
+ const allValuesHaveOptions = (0, import_react21.useMemo)(
2092
+ () => value.every((val) => valueToOptionMap.has(val)) || showCustomValue,
2093
+ [value, valueToOptionMap, showCustomValue]
2094
+ );
2095
+ const triggerText = (0, import_react21.useMemo)(() => {
2096
+ if (value.length === 0) {
2097
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "truncate", children: triggerPlaceholder ?? `Select ${maxSelection === 1 ? "an item..." : "items..."}` });
2098
+ }
2099
+ if (!allValuesHaveOptions) {
2100
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "line-clamp-1", children: "Loading..." });
2101
+ }
2102
+ const optionMatchingFirstVal = valueToOptionMap.get(value[0]) || {
2103
+ label: value[0],
2104
+ icon: void 0
2105
+ };
2106
+ const firstValText = optionMatchingFirstVal ? optionMatchingFirstVal.label : value[0];
2107
+ const icon = value.length === 1 ? optionMatchingFirstVal?.icon : void 0;
2108
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
2109
+ icon && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "mr-1 inline-flex items-center", children: icon }),
2110
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "line-clamp-1 text-left", children: `${firstValText}${value.length > 1 ? "," : ""}` }),
2111
+ value.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "whitespace-nowrap", children: `+${value.length - 1} more` })
2112
+ ] });
2113
+ }, [maxSelection, valueToOptionMap, triggerPlaceholder, value, allValuesHaveOptions]);
2114
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2115
+ Popover,
2116
+ {
2117
+ open: open && !disabled,
2118
+ onOpenChange: (val) => {
2119
+ if (val) {
2120
+ setOpen(true);
2121
+ onOpen?.();
2122
+ } else {
2123
+ handleClose();
2124
+ }
2125
+ },
2126
+ alignContent: "start",
2127
+ disabled,
2128
+ triggerClassName: popover?.triggerClassName,
2129
+ contentClassName: popover?.contentClassName,
2130
+ container: popover?.container,
2131
+ trigger: popover?.customTrigger ?? (variant === "simple" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
2132
+ "div",
2133
+ {
2134
+ onKeyDown: handleTriggerKeyDown,
2135
+ className: (0, import_tailwind_merge22.twJoin)(
2136
+ "-mx-2 -my-1.5 flex cursor-pointer items-center justify-between gap-1.5 rounded-md px-2 py-1.5 transition-all duration-150",
2137
+ !disabled && "cursor-pointer hover:bg-gray-100"
2138
+ ),
2139
+ children: [
2140
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2141
+ "div",
2142
+ {
2143
+ className: (0, import_tailwind_merge22.twJoin)(
2144
+ "line-clamp-1 flex flex-1 items-center",
2145
+ value.length !== 0 ? "text-inherit" : "text-gray-500"
2146
+ ),
2147
+ children: triggerText
2148
+ }
2149
+ ),
2150
+ !disabled && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(DropdownChevron, {})
2151
+ ]
2152
+ }
2153
+ ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("button", { onKeyDown: handleTriggerKeyDown, className: (0, import_tailwind_merge22.twJoin)("w-full", inputBoxStyles({ hasError, size })), children: [
2154
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2155
+ "span",
2156
+ {
2157
+ className: `mr-auto line-clamp-1 flex items-center space-x-1 text-left text-base ${value.length === 0 ? "text-gray-400" : "text-gray-800"}`,
2158
+ children: triggerText
2159
+ }
2160
+ ),
2161
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(DropdownChevron, {})
2162
+ ] })),
2163
+ children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "w-72", children: [
2164
+ (!hideSearch || allowCustomValues) && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(InputBox, { variant: "transparent", children: [
2165
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "w-3 text-sm text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { icon: import_free_solid_svg_icons13.faMagnifyingGlass }) }),
2166
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2167
+ InputBox.Input,
2168
+ {
2169
+ ref: inputRef,
2170
+ value: search,
2171
+ onChange: (e) => handleSearchTermChange(e.target.value),
2172
+ placeholder: searchPlaceholder,
2173
+ onBlur: (e) => e.target.focus(),
2174
+ onKeyDown: handleKeyDown
2175
+ }
2176
+ )
2177
+ ] }) }),
2178
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("ul", { className: "max-h-72 space-y-1 overflow-y-auto p-1", children: [
2179
+ !allValuesHaveOptions ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectListItem, { disabled: true, children: "Loading..." }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2180
+ SelectedItems,
2181
+ {
2182
+ value,
2183
+ onChange,
2184
+ search,
2185
+ valueToOptionMap,
2186
+ onSelectAll,
2187
+ minSelection,
2188
+ ordered,
2189
+ numValuesToShow
2190
+ }
2191
+ ),
2192
+ showCustomItem && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectOption, { onClick: handleAddCustomItem, focused: showCustomItem && focusIndex === 0, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { children: `"${search}"` }) }),
2193
+ unselectedOptions.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2194
+ SelectOption,
2195
+ {
2196
+ onClick: () => handleOptionSelected(item.value),
2197
+ focused: focusIndex === (showCustomItem ? i + 1 : i),
2198
+ disabled: item.disabled,
2199
+ children: item.display ?? item.label
2200
+ },
2201
+ item.reactKey ?? item.value
2202
+ )),
2203
+ !loadProps ? (
2204
+ // no asynchronous loading
2205
+ unselectedOptions.length === 0 && (emptyState || /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectListItem, { disabled: true, children: "No results" }))
2206
+ ) : loadProps.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectListItem, { disabled: true, children: "Loading..." }) : loadProps.isError ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectListItem, { disabled: true, children: "An error occurred" }) : unselectedOptions.length === 0 ? emptyState || /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectListItem, { disabled: true, children: "No results" }) : loadProps.canLoadMore ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2207
+ "div",
2208
+ {
2209
+ className: "cursor-pointer px-2 py-1 text-sm font-medium text-indigo-600",
2210
+ onClick: loadProps.onLoadMore,
2211
+ children: "Load more..."
2212
+ }
2213
+ ) : null
2214
+ ] })
2215
+ ] })
2216
+ }
2217
+ );
2218
+ };
2219
+ var SelectOption = ({ children, focused, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(SelectListItem, { focused, ...rest, children: [
2220
+ children,
2221
+ focused && !rest.disabled && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "w-3 text-sm text-gray-500", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { icon: import_free_solid_svg_icons13.faArrowTurnDown }) })
2222
+ ] });
2223
+ var SelectedItems = ({
2224
+ value = [],
2225
+ onChange,
2226
+ onSelectAll,
2227
+ minSelection,
2228
+ search,
2229
+ valueToOptionMap,
2230
+ ordered,
2231
+ numValuesToShow = DEFAULT_NUM_VALUES_TO_SHOW
2232
+ }) => {
2233
+ const [showAllValues, setShowAllValues] = (0, import_react21.useState)(false);
2234
+ const filteredSelectedValues = (0, import_react21.useMemo)(() => {
2235
+ return value.filter((v) => {
2236
+ if (!search) {
2237
+ return true;
2238
+ }
2239
+ const option = valueToOptionMap.get(v);
2240
+ if (!option) {
2241
+ return false;
2242
+ }
2243
+ return doesSelectItemMatch(option, search);
2244
+ });
2245
+ }, [value, search, valueToOptionMap]);
2246
+ const sensors = (0, import_core3.useSensors)(
2247
+ (0, import_core3.useSensor)(import_core3.PointerSensor, {
2248
+ activationConstraint: {
2249
+ distance: 8
2250
+ }
2251
+ })
2252
+ );
2253
+ const onDragEnd = (event) => {
2254
+ const { active, over } = event;
2255
+ if (over && active.id !== over.id) {
2256
+ const newOrder = [...value];
2257
+ const activeIndex = newOrder.indexOf(active.id);
2258
+ const overIndex = newOrder.indexOf(over.id);
2259
+ newOrder.splice(activeIndex, 1);
2260
+ newOrder.splice(overIndex, 0, active.id);
2261
+ onChange?.(newOrder);
2262
+ }
2263
+ };
2264
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_core3.DndContext, { sensors, onDragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
2265
+ import_sortable2.SortableContext,
2266
+ {
2267
+ disabled: !ordered,
2268
+ items: filteredSelectedValues.map((v) => ({ id: v, value: v })),
2269
+ strategy: import_sortable2.verticalListSortingStrategy,
2270
+ children: [
2271
+ (filteredSelectedValues.length > numValuesToShow || onSelectAll) && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex justify-between px-2 pt-1.5 pb-px text-sm", children: [
2272
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "font-medium text-gray-500", children: [
2273
+ value.length,
2274
+ " selected",
2275
+ filteredSelectedValues.length < value.length ? ` (showing ${filteredSelectedValues.length})` : ""
2276
+ ] }),
2277
+ value.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "cursor-pointer text-red-600 hover:underline", onClick: () => onChange?.([]), children: "Clear" }) : onSelectAll ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "cursor-pointer text-indigo-700 hover:underline", onClick: onSelectAll, children: "Select all" }) : null
2278
+ ] }),
2279
+ filteredSelectedValues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
2280
+ filteredSelectedValues.slice(0, showAllValues ? value.length : numValuesToShow).map((val) => {
2281
+ const item = valueToOptionMap.get(val);
2282
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
2283
+ SelectListItem,
2284
+ {
2285
+ sortableId: ordered ? val : void 0,
2286
+ onClick: () => {
2287
+ const canRemove = minSelection === 0 || value.length !== 1;
2288
+ if (canRemove) {
2289
+ onChange?.(value.filter((v) => v !== val));
2290
+ }
2291
+ },
2292
+ children: [
2293
+ !item ? val : item.display ?? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex items-center gap-2", children: [
2294
+ item.icon,
2295
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { children: item.label })
2296
+ ] }),
2297
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "flex w-3 justify-center text-sm text-gray-500", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2298
+ Icon,
2299
+ {
2300
+ icon: minSelection === 1 ? import_free_solid_svg_icons13.faCheck : import_free_solid_svg_icons13.faXmark
2301
+ }
2302
+ ) })
2303
+ ]
2304
+ },
2305
+ val
2306
+ );
2307
+ }),
2308
+ filteredSelectedValues.length > numValuesToShow && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2309
+ "div",
2310
+ {
2311
+ className: "cursor-pointer px-2 py-1 text-sm font-medium text-indigo-600",
2312
+ onClick: () => setShowAllValues((prev) => !prev),
2313
+ children: showAllValues ? "Show less" : `Show ${filteredSelectedValues.length - numValuesToShow} more selected`
2314
+ }
2315
+ )
2316
+ ] }),
2317
+ (filteredSelectedValues.length > 0 || onSelectAll) && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("li", { className: "py-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("hr", { className: "h-px bg-gray-200" }) })
2318
+ ]
2319
+ }
2320
+ ) });
2321
+ };
2322
+
2323
+ // src/core/select/AsyncSelect.tsx
2324
+ var import_jsx_runtime44 = require("react/jsx-runtime");
2325
+ var AsyncSelect = ({
2326
+ value,
2327
+ onChange,
2328
+ allowUnselect = false,
2329
+ ...rest
2330
+ }) => {
2331
+ const multiValue = value ? [value] : [];
2332
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2333
+ AsyncMultiSelect,
2334
+ {
2335
+ minSelection: allowUnselect ? 0 : 1,
2336
+ maxSelection: 1,
2337
+ value: multiValue,
2338
+ onChange: (val) => onChange?.(val[0]),
2339
+ ...rest
2340
+ }
2341
+ );
2342
+ };
2343
+
2344
+ // src/core/select/MultiSelect.tsx
2345
+ var import_react22 = require("react");
2346
+ var import_jsx_runtime45 = require("react/jsx-runtime");
2347
+ var MultiSelect = ({
2348
+ value,
2349
+ items: options,
2350
+ onSearchChange,
2351
+ customValueToOption,
2352
+ ...rest
2353
+ }) => {
2354
+ const [query, setQuery] = (0, import_react22.useState)("");
2355
+ const optionsForValues = (0, import_react22.useMemo)(
2356
+ () => value?.map((val) => {
2357
+ const option = options.find((opt) => opt.value === val);
2358
+ if (option) return option;
2359
+ if (!customValueToOption) {
2360
+ return {
2361
+ value: val,
2362
+ label: val.toString()
2363
+ };
2364
+ }
2365
+ return customValueToOption(val);
2366
+ }) ?? [],
2367
+ [customValueToOption, options, value]
2368
+ );
2369
+ const optionsMatchingQuery = (0, import_react22.useMemo)(
2370
+ () => options.filter((option) => doesSelectItemMatch(option, query)),
2371
+ [query, options]
2372
+ );
2373
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
2374
+ AsyncMultiSelect,
2375
+ {
2376
+ value,
2377
+ items: [...optionsForValues, ...optionsMatchingQuery],
2378
+ onSearchChange: (q) => {
2379
+ setQuery(q);
2380
+ onSearchChange?.(q);
2381
+ },
2382
+ ...rest
2383
+ }
2384
+ );
2385
+ };
2386
+
2387
+ // src/core/select/Select.tsx
2388
+ var import_jsx_runtime46 = require("react/jsx-runtime");
2389
+ function Select({ value, onChange, allowUnselect, ...rest }) {
2390
+ const multivalue = value || value === 0 ? [value] : [];
2391
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
2392
+ MultiSelect,
2393
+ {
2394
+ value: multivalue,
2395
+ onChange: (val) => onChange?.(val[0]),
2396
+ minSelection: allowUnselect ? 0 : 1,
2397
+ maxSelection: 1,
2398
+ ...rest
2399
+ }
2400
+ );
2401
+ }
2402
+
2403
+ // src/core/select/SelectWtihUnselect.tsx
2404
+ var import_jsx_runtime47 = require("react/jsx-runtime");
2405
+ function SelectWithUnselect({
2406
+ value,
2407
+ onChange,
2408
+ ...rest
2409
+ }) {
2410
+ const multivalue = value || value === 0 ? [value] : [];
2411
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
2412
+ MultiSelect,
2413
+ {
2414
+ value: multivalue,
2415
+ onChange: (val) => onChange?.(val[0] ?? null),
2416
+ minSelection: 0,
2417
+ maxSelection: 1,
2418
+ ...rest
2419
+ }
2420
+ );
2421
+ }
2422
+
2423
+ // src/core/form/components/FormSelect.tsx
2424
+ var import_jsx_runtime48 = require("react/jsx-runtime");
2425
+ var FormSelect = ({
2426
+ name,
2427
+ styles,
2428
+ layout,
2429
+ label,
2430
+ options,
2431
+ onChange,
2432
+ ...rest
2433
+ }) => {
2434
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
2435
+ ControlledFormItem,
2436
+ {
2437
+ name,
2438
+ layout,
2439
+ styles,
2440
+ label,
2441
+ options,
2442
+ render: (field) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
2443
+ Select,
2444
+ {
2445
+ ...rest,
2446
+ value: field.value,
2447
+ onChange: (value) => {
2448
+ field.onChange(value);
2449
+ onChange?.(value);
2450
+ },
2451
+ hasError: !!field.error
2452
+ }
2453
+ )
2454
+ }
2455
+ );
2456
+ };
2457
+
2458
+ // src/core/form/components/FormMultiSelect.tsx
2459
+ var import_jsx_runtime49 = require("react/jsx-runtime");
2460
+ var FormMultiSelect = ({
2461
+ name,
2462
+ styles,
2463
+ layout,
2464
+ label,
2465
+ options,
2466
+ onChange,
2467
+ ...rest
2468
+ }) => {
2469
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
2470
+ ControlledFormItem,
2471
+ {
2472
+ name,
2473
+ layout,
2474
+ styles,
2475
+ label,
2476
+ options,
2477
+ render: (field) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
2478
+ MultiSelect,
2479
+ {
2480
+ ...rest,
2481
+ value: field.value,
2482
+ onChange: (value) => {
2483
+ field.onChange(value);
2484
+ onChange?.(value);
2485
+ },
2486
+ hasError: !!field.error
2487
+ }
2488
+ )
2489
+ }
2490
+ );
2491
+ };
2492
+
2493
+ // src/core/form/components/FormTextArea.tsx
2494
+ var import_lodash_es2 = require("lodash-es");
2495
+
2496
+ // src/core/textarea/TextArea.tsx
2497
+ var import_react23 = require("react");
2498
+ var import_tailwind_merge23 = require("tailwind-merge");
2499
+ var import_jsx_runtime50 = require("react/jsx-runtime");
2500
+ var TextAreaComp = (0, import_react23.forwardRef)(({ className, hasError, ...rest }, ref) => {
2501
+ const ringClassName = rest.disabled ? "focus:outline-hidden focus:ring-0" : hasError ? "focus:outline-hidden focus:ring-red-500 focus:border-red-500" : RING_COLOR_CLASSNAME;
2502
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
2503
+ "textarea",
2504
+ {
2505
+ ...rest,
2506
+ className: (0, import_tailwind_merge23.twMerge)(
2507
+ "block w-full resize-none rounded-md shadow-sm disabled:bg-gray-100",
2508
+ hasError ? "border-red-300 text-red-900 placeholder-red-300" : "border-gray-200 placeholder-gray-400 focus:border-indigo-400",
2509
+ ringClassName,
2510
+ className
2511
+ ),
2512
+ ref
2513
+ }
2514
+ );
2515
+ });
2516
+ var TextArea = (0, import_react23.forwardRef)(({ hasError, errorNode, ...rest }, ref) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
2517
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(TextAreaComp, { ...rest, hasError, ref }),
2518
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ErrorText, { className: "mt-2 text-sm", children: errorNode })
2519
+ ] }));
2520
+
2521
+ // src/core/form/components/FormTextArea.tsx
2522
+ var import_jsx_runtime51 = require("react/jsx-runtime");
2523
+ var FormTextArea = ({
2524
+ name,
2525
+ styles,
2526
+ layout,
2527
+ label,
2528
+ options,
2529
+ debounce: debounceInterval,
2530
+ ...rest
2531
+ }) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
2532
+ UncontrolledField,
2533
+ {
2534
+ name,
2535
+ render: ({ error, register }) => {
2536
+ const controlFields = register();
2537
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
2538
+ FormItem,
2539
+ {
2540
+ layout,
2541
+ styles,
2542
+ label,
2543
+ options,
2544
+ render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
2545
+ TextArea,
2546
+ {
2547
+ ...controlFields,
2548
+ hasError: !!error || void 0,
2549
+ ...rest,
2550
+ onChange: debounceInterval ? (0, import_lodash_es2.debounce)(controlFields.onChange, debounceInterval) : controlFields.onChange
2551
+ }
2552
+ ),
2553
+ error
2554
+ }
2555
+ );
2556
+ }
2557
+ }
2558
+ );
2559
+
2560
+ // src/core/form/components/FormSwitch.tsx
2561
+ var import_tailwind_merge24 = require("tailwind-merge");
2562
+
2563
+ // src/core/switch/Switch.tsx
2564
+ var RadixSwitch = __toESM(require("@radix-ui/react-switch"), 1);
2565
+ var React10 = __toESM(require("react"), 1);
2566
+ var import_jsx_runtime52 = require("react/jsx-runtime");
2567
+ var SwitchIdContext = React10.createContext(void 0);
2568
+ var useSwitchId = () => React10.useContext(SwitchIdContext);
2569
+ var SwitchControl = (props) => {
2570
+ const id = useSwitchId();
2571
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
2572
+ RadixSwitch.Root,
2573
+ {
2574
+ ...props,
2575
+ id,
2576
+ className: "flex h-5 w-9 shrink-0 items-center rounded-full bg-gray-200 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:bg-gray-100 data-[state=checked]:bg-indigo-700",
2577
+ children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(RadixSwitch.SwitchThumb, { className: "block h-4 w-4 translate-x-0.5 rounded-full bg-white duration-100 data-disabled:shadow-none data-[state=checked]:translate-x-[18px]" })
2578
+ }
2579
+ );
2580
+ };
2581
+ var SwitchLabel = (props) => {
2582
+ const id = useSwitchId();
2583
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("label", { ...props, htmlFor: id });
2584
+ };
2585
+ var Switch = ({ children, className, ...rest }) => {
2586
+ const autoId = React10.useId();
2587
+ if (children == null) {
2588
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(SwitchControl, { ...rest });
2589
+ }
2590
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(SwitchIdContext.Provider, { value: autoId, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className, children }) });
2591
+ };
2592
+ Switch.Control = SwitchControl;
2593
+ Switch.Label = SwitchLabel;
2594
+
2595
+ // src/core/form/components/FormSwitch.tsx
2596
+ var import_jsx_runtime53 = require("react/jsx-runtime");
2597
+ var FormSwitch = ({ name, styles, layout, label, options, onChange, ...props }) => {
2598
+ if (layout === "side-by-side") {
2599
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
2600
+ ControlledField,
2601
+ {
2602
+ name,
2603
+ render: (field) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: (0, import_tailwind_merge24.twJoin)("flex items-start gap-x-2", styles), children: [
2604
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
2605
+ Switch,
2606
+ {
2607
+ ...props,
2608
+ checked: (
2609
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2610
+ field.value
2611
+ ),
2612
+ onCheckedChange: (value) => {
2613
+ field.onChange(value);
2614
+ onChange?.(value);
2615
+ }
2616
+ }
2617
+ ) }),
2618
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "pt-1", children: [
2619
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(FieldLabelWithTooltip, { label, options }),
2620
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(FieldDescription, { styles: "pt-0.5", children: options?.description }),
2621
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(FieldErrorMessage, { error: field.error }),
2622
+ options?.bottomSlot
2623
+ ] })
2624
+ ] })
2625
+ }
2626
+ );
2627
+ }
2628
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
2629
+ ControlledFormItem,
2630
+ {
2631
+ name,
2632
+ layout,
2633
+ styles,
2634
+ label,
2635
+ options,
2636
+ render: (field) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Switch, { ...props, checked: field.value, onCheckedChange: field.onChange })
2637
+ }
2638
+ );
2639
+ };
2640
+
2641
+ // src/core/radio-button-group/RadioButtonItem.tsx
2642
+ var import_tailwind_merge25 = require("tailwind-merge");
2643
+ var import_jsx_runtime54 = require("react/jsx-runtime");
2644
+ var RadioButtonItem = ({
2645
+ value,
2646
+ displayValue,
2647
+ description,
2648
+ expandedContents,
2649
+ expandedContentsStyle,
2650
+ disabled,
2651
+ isChecked,
2652
+ onSelect,
2653
+ asCard = false
2654
+ }) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
2655
+ "div",
2656
+ {
2657
+ className: (0, import_tailwind_merge25.twJoin)(
2658
+ "flex flex-col gap-2",
2659
+ asCard && "rounded-md border px-3 py-2",
2660
+ asCard && !isChecked && "border-gray-200",
2661
+ asCard && isChecked && "border-indigo-500"
2662
+ ),
2663
+ children: [
2664
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
2665
+ "div",
2666
+ {
2667
+ className: (0, import_tailwind_merge25.twJoin)(
2668
+ "relative flex gap-2",
2669
+ disabled && "cursor-not-allowed opacity-30 *:cursor-not-allowed",
2670
+ expandedContentsStyle === "inline" ? "items-center" : "items-start"
2671
+ ),
2672
+ children: [
2673
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
2674
+ "input",
2675
+ {
2676
+ onChange: (evt) => onSelect?.(evt.target.value),
2677
+ id: value,
2678
+ value,
2679
+ checked: isChecked,
2680
+ disabled,
2681
+ type: "radio",
2682
+ className: "mt-px border-gray-200 p-2 text-indigo-700 ring-0 ring-indigo-700"
2683
+ }
2684
+ ),
2685
+ expandedContentsStyle === "inline" ? /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("label", { htmlFor: value, className: "flex w-full flex-row gap-2.5", children: [
2686
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex w-9/12 items-center gap-2", children: [
2687
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "font-medium", children: displayValue }),
2688
+ description && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { id: `${value}-description`, className: "text-gray-500", children: description })
2689
+ ] }),
2690
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "flex w-3/12 items-center", children: expandedContents?.(!isChecked || !!disabled) })
2691
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("label", { htmlFor: value, className: "flex flex-col gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "font-medium", children: displayValue }) })
2692
+ ]
2693
+ }
2694
+ ),
2695
+ expandedContentsStyle !== "inline" && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
2696
+ description && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { id: `${value}-description`, className: "text-gray-500", children: description }),
2697
+ expandedContents?.(!isChecked || !!disabled)
2698
+ ] })
2699
+ ]
2700
+ }
2701
+ );
2702
+
2703
+ // src/core/radio-button-group/RadioButtonGroup.tsx
2704
+ var import_jsx_runtime55 = require("react/jsx-runtime");
2705
+ var RadioButtonGroup = ({ className, items, onChange, value, asCards = false }) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("fieldset", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "space-y-3", children: items.map(
2706
+ ({ value: itemValue, displayValue, description, expandedContents, expandedContentsStyle, disabled }, index) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
2707
+ RadioButtonItem,
2708
+ {
2709
+ disabled,
2710
+ onSelect: onChange,
2711
+ isChecked: value === itemValue,
2712
+ value: itemValue,
2713
+ displayValue,
2714
+ description,
2715
+ expandedContents,
2716
+ expandedContentsStyle,
2717
+ asCard: asCards
2718
+ },
2719
+ index
2720
+ )
2721
+ ) }) });
2722
+
2723
+ // src/core/form/components/FormRadioButtonGroup.tsx
2724
+ var import_jsx_runtime56 = require("react/jsx-runtime");
2725
+ var FormRadioButtonGroup = ({
2726
+ name,
2727
+ items,
2728
+ onChange,
2729
+ asCards = false,
2730
+ className
2731
+ }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
2732
+ ControlledField,
2733
+ {
2734
+ name,
2735
+ render: (field) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [
2736
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
2737
+ RadioButtonGroup,
2738
+ {
2739
+ ...field,
2740
+ className,
2741
+ items,
2742
+ onChange: (newValue) => {
2743
+ field.onChange(newValue);
2744
+ onChange?.(newValue);
2745
+ },
2746
+ asCards
2747
+ }
2748
+ ),
2749
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(FieldErrorMessage, { error: field.error })
2750
+ ] })
2751
+ }
2752
+ );
2753
+
2754
+ // src/core/form/components/FormDatePicker.tsx
2755
+ var import_react24 = require("react");
2756
+ var import_tailwind_merge26 = require("tailwind-merge");
2757
+ var import_jsx_runtime57 = require("react/jsx-runtime");
2758
+ var FormDatePicker = ({
2759
+ name,
2760
+ styles,
2761
+ layout,
2762
+ label,
2763
+ onChange,
2764
+ options,
2765
+ containerRef,
2766
+ disabled,
2767
+ ...rest
2768
+ }) => {
2769
+ const {
2770
+ onChange: onChangeInternal,
2771
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2772
+ value,
2773
+ error
2774
+ } = useControlledFormField({ name });
2775
+ const handleChange = (0, import_react24.useCallback)(
2776
+ (newValue) => {
2777
+ onChange?.(newValue ?? null);
2778
+ onChangeInternal(newValue ?? null);
2779
+ },
2780
+ [onChangeInternal, onChange]
2781
+ );
2782
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
2783
+ FormItem,
2784
+ {
2785
+ layout,
2786
+ styles,
2787
+ label,
2788
+ options,
2789
+ ref: containerRef,
2790
+ render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: (0, import_tailwind_merge26.twJoin)(disabled && "text-gray-500"), children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
2791
+ DatePicker,
2792
+ {
2793
+ ...rest,
2794
+ disabled,
2795
+ value: (
2796
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2797
+ value
2798
+ ),
2799
+ onChange: handleChange,
2800
+ hasError: !!error
2801
+ }
2802
+ ) }),
2803
+ error
2804
+ }
2805
+ );
2806
+ };
2807
+
2808
+ // src/core/form/components/schemas/currency-schemas.ts
2809
+ var import_zod2 = require("zod");
2810
+ var CURRENCY_REGEX = /^-?(?:\d{1,3}(?:,\d{3})*|\d+|\.\d{1,2})(?:\.\d{1,2})?$/;
2811
+ var DOLLARS_STR_ERROR_MESSAGE = "Must use dollars and cents or whole numbers.";
2812
+ var dollarsStrSchema = import_zod2.z.string().regex(CURRENCY_REGEX, DOLLARS_STR_ERROR_MESSAGE);
2813
+ var requiredDollarsStrSchema = import_zod2.z.string().trim().nonempty("Required").regex(CURRENCY_REGEX, DOLLARS_STR_ERROR_MESSAGE);
2814
+ var requiredDollarsStrSchemaWithCustomMessage = (requiredError, invalidTypeError) => import_zod2.z.string().trim().nonempty(requiredError).regex(CURRENCY_REGEX, invalidTypeError);
2815
+ var requiredNonZeroDollarsStrSchema = requiredDollarsStrSchema.refine(
2816
+ (value) => parseFloat(value) !== 0,
2817
+ "Amount cannot be $0.00"
2818
+ );
2819
+ var requiredPositiveDollarsStrSchema = requiredDollarsStrSchema.refine(
2820
+ (value) => parseFloat(value) > 0,
2821
+ "Amount must be greater than $0.00"
2822
+ );
2823
+ var requiredPositiveOrZeroDollarsStrSchema = requiredDollarsStrSchema.refine(
2824
+ (value) => parseFloat(value) >= 0,
2825
+ "Amount must be greater than or equal to $0.00"
2826
+ );
2827
+
2828
+ // src/core/form/components/schemas/form-schemas.ts
2829
+ var import_zod4 = require("zod");
2830
+
2831
+ // src/core/form/components/schemas/helper-schemas.ts
2832
+ var import_zod3 = require("zod");
2833
+ var asOptional = (schema) => import_zod3.z.union([
2834
+ // order is important: the empty-like literals must precede actual schema
2835
+ import_zod3.z.literal(null).transform(() => void 0),
2836
+ import_zod3.z.literal("").transform(() => void 0),
2837
+ import_zod3.z.string().trim().transform((val) => val === "" ? void 0 : val).pipe(import_zod3.z.undefined()),
2838
+ schema.optional()
2839
+ ]);
2840
+ var asNullish = (schema) => import_zod3.z.union([
2841
+ // order is important: the empty-like literals must precede actual schema
2842
+ import_zod3.z.literal(null).transform(() => void 0),
2843
+ import_zod3.z.literal("").transform(() => void 0),
2844
+ import_zod3.z.string().trim().transform((val) => val === "" ? void 0 : val).pipe(import_zod3.z.undefined()),
2845
+ schema.nullish()
2846
+ ]);
2847
+ var asNumericStr = (schema, message = "Only numbers allowed") => schema.regex(/^\d+$/i, message);
2848
+ var asRequiredCustom = (message = "Required") => {
2849
+ return import_zod3.z.custom((value) => {
2850
+ if (value == null || typeof value !== "object") {
2851
+ return !!value;
2852
+ }
2853
+ if (Array.isArray(value)) {
2854
+ return value.length > 0;
2855
+ }
2856
+ return Object.keys(value).length > 0;
2857
+ }, message);
2858
+ };
2859
+
2860
+ // src/core/form/components/schemas/form-schemas.ts
2861
+ var npiSchema = asNumericStr(import_zod4.z.string().trim().nonempty("Required").length(10, "Must have 10 numbers"));
2862
+ var npiSchemaOptional = asOptional(asNumericStr(import_zod4.z.string().trim()).length(10, "Must have 10 numbers"));
2863
+ var taxonomyCodeSchema = import_zod4.z.string().trim().nonempty("Must contain characters, not just whitespace").length(10, "Must have 10 characters");
2864
+ var TAX_ID_REGEX = /^(([0-9]{9})|([0-9]{3}-[0-9]{2}-[0-9]{4})|([0-9]{2}-[0-9]{7}))$/i;
2865
+ var taxIdSchema = import_zod4.z.string().trim().nonempty("Required").regex(TAX_ID_REGEX, "Must have 9 numbers formatted: XXXXXXXXX or XXX-XX-XXXX or XX-XXXXXXX");
2866
+
2867
+ // src/core/form/components/schemas/selected-amount-schema.ts
2868
+ var import_zod5 = require("zod");
2869
+ var selectedAmountSchema = import_zod5.z.object({
2870
+ selected: asOptional(import_zod5.z.boolean()),
2871
+ amountStr: asOptional(dollarsStrSchema)
2872
+ });
2873
+
2874
+ // src/core/form/components/schemas/utils.ts
2875
+ var import_zod6 = require("zod");
2876
+ var buildZodIssue = (path, message) => ({
2877
+ path: Array.isArray(path) ? path : [path],
2878
+ message,
2879
+ code: import_zod6.z.ZodIssueCode.custom
2880
+ });
2881
+
2882
+ // src/core/drawer/Drawer.tsx
2883
+ var import_react27 = require("react");
2884
+ var import_tailwind_merge29 = require("tailwind-merge");
2885
+
2886
+ // src/core/loaders/Spinner.tsx
2887
+ var import_free_solid_svg_icons14 = require("@fortawesome/free-solid-svg-icons");
2888
+ var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
2889
+ var import_tailwind_merge27 = require("tailwind-merge");
2890
+ var import_jsx_runtime58 = require("react/jsx-runtime");
2891
+ var Spinner = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
2892
+ import_react_fontawesome2.FontAwesomeIcon,
2893
+ {
2894
+ ...props,
2895
+ className: (0, import_tailwind_merge27.twJoin)("animate-spin text-gray-400", className),
2896
+ icon: import_free_solid_svg_icons14.faSpinner
2897
+ }
2898
+ );
2899
+
2900
+ // src/core/loaders/LoadingState.tsx
2901
+ var import_jsx_runtime59 = require("react/jsx-runtime");
2902
+ var LoadingStateTemplate = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "inset-0 z-10 flex h-full items-center justify-center", children });
2903
+ var LoadingState = ({ size = "2x" }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(LoadingStateTemplate, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Spinner, { size }) });
2904
+
2905
+ // src/core/loaders/LoadingBar.tsx
2906
+ var import_tailwind_merge28 = require("tailwind-merge");
2907
+ var import_jsx_runtime60 = require("react/jsx-runtime");
2908
+ var LoadingBar = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: (0, import_tailwind_merge28.twMerge)("relative h-3 w-full overflow-hidden rounded-full bg-gray-100", className), children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
2909
+ "div",
2910
+ {
2911
+ className: "absolute inset-0 w-full animate-loading-slide bg-gradient-to-r from-transparent via-indigo-400/60 to-transparent",
2912
+ style: { width: "50%" }
2913
+ }
2914
+ ) });
2915
+
2916
+ // src/core/drawer/drawerState.ts
2917
+ var import_react25 = require("react");
2918
+ var DrawerStateContext = (0, import_react25.createContext)({
2919
+ isOpen: false,
2920
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2921
+ onClose: () => {
2922
+ }
2923
+ });
2924
+ var useDrawer = () => {
2925
+ const context = (0, import_react25.useContext)(DrawerStateContext);
2926
+ if (context === void 0) {
2927
+ throw new Error("useDrawer must be used within a DrawerStateContext");
2928
+ }
2929
+ return context;
2930
+ };
2931
+
2932
+ // src/core/drawer/useDrawerResize.ts
2933
+ var import_react26 = require("react");
2934
+ var MIN_LEFT_SPACE = 240;
2935
+ var MIN_WIDTH_PCT = 0.5;
2936
+ var MIN_WIDTH_PX = 500;
2937
+ var constraintPct = (val) => Math.min(1, Math.max(0, val));
2938
+ var localStoragePersist = (key) => ({
2939
+ load: () => {
2940
+ try {
2941
+ const val = localStorage.getItem(key);
2942
+ if (val && !Number.isNaN(Number(val))) {
2943
+ return constraintPct(Number(val));
2944
+ }
2945
+ return void 0;
2946
+ } catch {
2947
+ return void 0;
2948
+ }
2949
+ },
2950
+ save: (size) => {
2951
+ try {
2952
+ localStorage.setItem(key, constraintPct(size).toString());
2953
+ } catch {
2954
+ }
2955
+ }
2956
+ });
2957
+ var computeWidth = (pct) => window.innerWidth * pct;
2958
+ var computePct = (widthPx) => widthPx / window.innerWidth;
2959
+ var constrainedWidth = (width) => {
2960
+ const minWidth = Math.max(window.innerWidth * MIN_WIDTH_PCT, MIN_WIDTH_PX);
2961
+ const maxWidth = window.innerWidth - MIN_LEFT_SPACE;
2962
+ return Math.min(Math.max(width, minWidth), maxWidth);
2963
+ };
2964
+ var useDrawerResize = ({ slider, drawer, isOpen, defaultSizePct, persistWidth }) => {
2965
+ const widthPx = (0, import_react26.useRef)(computeWidth(defaultSizePct));
2966
+ const toggleOpen = (0, import_react26.useCallback)(
2967
+ (open) => {
2968
+ if (slider.current && drawer.current) {
2969
+ drawer.current.style.transition = `right 200ms ease-out, opacity 200ms`;
2970
+ slider.current.style.right = open ? `${widthPx.current}px` : "0";
2971
+ drawer.current.style.right = open ? "0" : `-200px`;
2972
+ drawer.current.style.opacity = open ? "1" : "0";
2973
+ drawer.current.style.pointerEvents = open ? "auto" : "none";
2974
+ }
2975
+ },
2976
+ [drawer, slider]
2977
+ );
2978
+ const setWidth = (0, import_react26.useCallback)(
2979
+ (width) => {
2980
+ widthPx.current = width;
2981
+ if (slider.current && drawer.current) {
2982
+ drawer.current.style.transition = "none";
2983
+ slider.current.style.right = `${width}px`;
2984
+ drawer.current.style.width = `${width}px`;
2985
+ }
2986
+ if (width !== 0) {
2987
+ persistWidth?.save?.(computePct(width));
2988
+ }
2989
+ },
2990
+ [drawer, persistWidth, slider]
2991
+ );
2992
+ (0, import_react26.useEffect)(() => {
2993
+ if (slider.current) {
2994
+ const onPointerDown = (e) => {
2995
+ document.body.style.userSelect = "none";
2996
+ const startX = e.clientX;
2997
+ const startWidth = widthPx.current;
2998
+ const onPointerMove = (evt) => {
2999
+ const newWidth = startWidth + (startX - evt.clientX);
3000
+ setWidth(constrainedWidth(newWidth));
3001
+ };
3002
+ const onPointerUp = () => {
3003
+ document.body.style.userSelect = "auto";
3004
+ window.removeEventListener("pointermove", onPointerMove);
3005
+ window.removeEventListener("pointerup", onPointerUp);
3006
+ };
3007
+ window.addEventListener("pointermove", onPointerMove);
3008
+ window.addEventListener("pointerup", onPointerUp);
3009
+ };
3010
+ const sliderNode = slider.current;
3011
+ sliderNode.addEventListener("pointerdown", onPointerDown);
3012
+ return () => {
3013
+ sliderNode.removeEventListener("pointerdown", onPointerDown);
3014
+ };
3015
+ }
3016
+ }, [setWidth, slider]);
3017
+ const loadWidth = (0, import_react26.useCallback)(() => {
3018
+ if (!isOpen) {
3019
+ toggleOpen(false);
3020
+ } else {
3021
+ const savedWidthPct = persistWidth?.load?.();
3022
+ const width = savedWidthPct ? constrainedWidth(computeWidth(savedWidthPct)) : computeWidth(defaultSizePct);
3023
+ setWidth(width);
3024
+ toggleOpen(true);
3025
+ }
3026
+ }, [defaultSizePct, isOpen, toggleOpen, persistWidth, setWidth]);
3027
+ (0, import_react26.useEffect)(() => {
3028
+ if (slider.current && drawer.current) {
3029
+ loadWidth();
3030
+ }
3031
+ }, [slider, drawer, loadWidth]);
3032
+ (0, import_react26.useEffect)(() => {
3033
+ window.addEventListener("resize", loadWidth);
3034
+ return () => window.removeEventListener("resize", loadWidth);
3035
+ }, [loadWidth]);
3036
+ };
3037
+
3038
+ // src/core/drawer/Drawer.tsx
3039
+ var import_jsx_runtime61 = require("react/jsx-runtime");
3040
+ var useKeypress = (key, action) => {
3041
+ (0, import_react27.useEffect)(() => {
3042
+ const onKeyup = (e) => {
3043
+ if (e.key === key) action();
3044
+ };
3045
+ document.addEventListener("keyup", onKeyup);
3046
+ return () => document.removeEventListener("keyup", onKeyup);
3047
+ }, [action, key]);
3048
+ };
3049
+ var drawerSizes = {
3050
+ sm: 1 / 2,
3051
+ md: 3 / 4,
3052
+ lg: 5 / 6
3053
+ };
3054
+ var Drawer = (0, import_react27.forwardRef)(
3055
+ ({ isOpen, onClose, onClickOutside, blurredOverlay, children, width = "md", persistWidth }, ref) => {
3056
+ const slider = (0, import_react27.useRef)(null);
3057
+ const drawer = (0, import_react27.useRef)(null);
3058
+ useDrawerResize({
3059
+ slider,
3060
+ drawer,
3061
+ isOpen,
3062
+ defaultSizePct: drawerSizes[width],
3063
+ persistWidth
3064
+ });
3065
+ useKeypress("Escape", () => {
3066
+ onClose?.();
3067
+ });
3068
+ return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
3069
+ DrawerStateContext.Provider,
3070
+ {
3071
+ value: {
3072
+ isOpen,
3073
+ onClose: () => onClose?.()
3074
+ },
3075
+ children: [
3076
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
3077
+ "div",
3078
+ {
3079
+ className: (0, import_tailwind_merge29.twJoin)(
3080
+ "absolute inset-0 z-30 transition-all",
3081
+ isOpen && blurredOverlay && "bg-gray-500/10 backdrop-blur-sm",
3082
+ // If the drawer is open, and the blurredOverlay prop is given, stop the user from clicking through the overlay
3083
+ isOpen && blurredOverlay ? "pointer-events-auto" : "pointer-events-none"
3084
+ ),
3085
+ onClick: onClickOutside
3086
+ }
3087
+ ),
3088
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
3089
+ "div",
3090
+ {
3091
+ ref: slider,
3092
+ className: (0, import_tailwind_merge29.twJoin)(
3093
+ "group absolute top-0 bottom-0 z-50 h-screen w-4 translate-x-1/2 cursor-col-resize",
3094
+ isOpen ? "block" : "hidden"
3095
+ ),
3096
+ children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "absolute top-0 right-1.5 bottom-0 left-1.5 bg-indigo-700 opacity-0 transition-opacity group-hover:opacity-100" })
3097
+ }
3098
+ ),
3099
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
3100
+ "div",
3101
+ {
3102
+ className: "absolute top-0 right-0 bottom-0 z-drawer flex flex-col overflow-y-hidden bg-gray-50 shadow",
3103
+ ref: drawer,
3104
+ children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
3105
+ "div",
3106
+ {
3107
+ ref,
3108
+ className: (0, import_tailwind_merge29.twJoin)(
3109
+ "relative flex w-full flex-1 flex-col overflow-hidden bg-white transition-all delay-100 duration-100 ease-in-out",
3110
+ isOpen ? "opacity-100" : "opacity-0"
3111
+ ),
3112
+ children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_react27.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(LoadingState, {}), children }) : void 0
3113
+ }
3114
+ )
3115
+ }
3116
+ )
3117
+ ]
3118
+ }
3119
+ );
3120
+ }
3121
+ );
3122
+
3123
+ // src/core/drawer/DrawerHeader.tsx
3124
+ var import_free_solid_svg_icons15 = require("@fortawesome/free-solid-svg-icons");
3125
+ var import_tailwind_merge35 = require("tailwind-merge");
3126
+
3127
+ // src/core/text/Text.tsx
3128
+ var import_tailwind_merge30 = require("tailwind-merge");
3129
+ var import_jsx_runtime62 = require("react/jsx-runtime");
3130
+ var VARIANT_STYLES = {
3131
+ "marketing-headline": "text-marketing-headline",
3132
+ "headline-1": "text-headline-1",
3133
+ "headline-2": "text-headline-2",
3134
+ "headline-3": "text-headline-3",
3135
+ "headline-4": "text-headline-4",
3136
+ "title-1": "text-title-1",
3137
+ "title-2": "text-title-2",
3138
+ "title-3": "text-title-3",
3139
+ "body-1": "text-body-1",
3140
+ "body-2": "text-body-2",
3141
+ label: "text-label",
3142
+ footnote: "text-footnote",
3143
+ smallcaps: "text-smallcaps"
3144
+ };
3145
+ var Text = ({ as, variant = "body-1", children, className, ...props }) => {
3146
+ const Tag2 = as ?? "p";
3147
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Tag2, { ...props, className: (0, import_tailwind_merge30.twJoin)(VARIANT_STYLES[variant], className), children });
3148
+ };
3149
+
3150
+ // src/core/skeleton/Skeleton.tsx
3151
+ var import_tailwind_merge31 = require("tailwind-merge");
3152
+ var import_jsx_runtime63 = require("react/jsx-runtime");
3153
+ var Skeleton = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: (0, import_tailwind_merge31.twMerge)("animate-skeleton-pulse rounded-lg bg-gray-200", className) });
3154
+
3155
+ // src/core/skeleton/TabsSkeleton/TabsSkeleton.tsx
3156
+ var import_tailwind_merge32 = require("tailwind-merge");
3157
+ var import_jsx_runtime64 = require("react/jsx-runtime");
3158
+ var TabsSkeleton = ({ numTabs = 3, className, tabClassName = "h-8 w-32" }) => {
3159
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: (0, import_tailwind_merge32.twMerge)("flex gap-4", className), children: Array.from({ length: numTabs }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Skeleton, { className: tabClassName }, index)) });
3160
+ };
3161
+
3162
+ // src/core/skeleton/TableSkeleton/TableSkeleton.tsx
3163
+ var import_tailwind_merge33 = require("tailwind-merge");
3164
+ var import_jsx_runtime65 = require("react/jsx-runtime");
3165
+ var TableSkeleton = ({
3166
+ numTableCols = 4,
3167
+ numTableRows = 3,
3168
+ className,
3169
+ rowHeight,
3170
+ hasBorder = false
3171
+ }) => {
3172
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("table", { className: (0, import_tailwind_merge33.twJoin)("flex w-full flex-col gap-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("tbody", { className: (0, import_tailwind_merge33.twJoin)("flex flex-col", rowHeight === void 0 && "gap-4"), children: Array.from({ length: numTableRows }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
3173
+ "tr",
3174
+ {
3175
+ className: (0, import_tailwind_merge33.twJoin)("flex gap-4", hasBorder && "px-2 not-last:border-b"),
3176
+ style: rowHeight ? { height: rowHeight } : void 0,
3177
+ children: Array.from({ length: numTableCols }).map((_2, index2) => {
3178
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("td", { className: "flex grow items-center px-1", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Skeleton, { className: (0, import_tailwind_merge33.twJoin)("w-full", rowHeight ? "h-3" : "h-6") }, index2) }, index2);
3179
+ })
3180
+ },
3181
+ index
3182
+ )) }) });
3183
+ };
3184
+
3185
+ // src/core/skeleton/TableSkeleton/TableCheckboxSkeleton.tsx
3186
+ var import_tailwind_merge34 = require("tailwind-merge");
3187
+ var import_jsx_runtime66 = require("react/jsx-runtime");
3188
+ var TableCheckboxSkeleton = ({
3189
+ numTableRows = 3,
3190
+ className,
3191
+ rowHeight,
3192
+ hasBorder = false
3193
+ }) => {
3194
+ return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("table", { className: (0, import_tailwind_merge34.twJoin)("flex w-full flex-col gap-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { className: (0, import_tailwind_merge34.twJoin)("flex flex-col", rowHeight === void 0 && "gap-4"), children: Array.from({ length: numTableRows }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
3195
+ "tr",
3196
+ {
3197
+ className: (0, import_tailwind_merge34.twJoin)("flex gap-4", hasBorder && "px-2 not-last:border-b"),
3198
+ style: rowHeight ? { height: rowHeight } : void 0,
3199
+ children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "flex grow items-center px-1", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Skeleton, { className: (0, import_tailwind_merge34.twJoin)("w-full, rounded-none", rowHeight ? "h-3" : "h-6") }, index) }, index)
3200
+ },
3201
+ index
3202
+ )) }) });
3203
+ };
3204
+
3205
+ // src/core/drawer/DrawerHeader.tsx
3206
+ var import_jsx_runtime67 = require("react/jsx-runtime");
3207
+ var DrawerHeader = ({
3208
+ resource,
3209
+ pagination,
3210
+ title,
3211
+ subtitle,
3212
+ actions,
3213
+ closeAction,
3214
+ label
3215
+ }) => {
3216
+ const { onClose } = useDrawer();
3217
+ return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "z-1 flex w-full flex-col items-stretch shadow", children: [
3218
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex justify-between px-8 py-1 shadow-sm", children: [
3219
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "flex items-center gap-1.5 text-base text-gray-500", children: resource && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
3220
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Icon, { icon: resource.icon || import_free_solid_svg_icons15.faBookmark }),
3221
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { children: resource.name })
3222
+ ] }) }),
3223
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-2", children: [
3224
+ pagination && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex gap-1", children: [
3225
+ pagination.extra,
3226
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Button, { size: "sm", onClick: pagination.onPrevious, disabled: !pagination.hasPrevious, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Icon, { icon: import_free_solid_svg_icons15.faChevronUp }) }),
3227
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Button, { size: "sm", onClick: pagination.onNext, disabled: !pagination.hasNext, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Icon, { icon: import_free_solid_svg_icons15.faChevronDown }) })
3228
+ ] }),
3229
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { "data-testid": "drawer-close", children: closeAction ? closeAction : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Button, { size: "xs", variant: "transparent", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "text-xl text-gray-500", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Icon, { icon: import_free_solid_svg_icons15.faXmark }) }) }) })
3230
+ ] })
3231
+ ] }),
3232
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-2 px-8 py-2", children: [
3233
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex min-w-0 shrink grow flex-col", children: [
3234
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Text, { variant: "title-1", className: (0, import_tailwind_merge35.twJoin)(typeof title === "string" && "truncate"), children: title }),
3235
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "text-base font-light", children: subtitle })
3236
+ ] }),
3237
+ label && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "flex items-center gap-2", children: label }),
3238
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "flex shrink-0 items-center gap-2", children: actions })
3239
+ ] })
3240
+ ] });
3241
+ };
3242
+ var DrawerHeaderSkeleton = () => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "space-y-2 px-8 py-2", children: [
3243
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex justify-between", children: [
3244
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Skeleton, { className: "h-6 w-36" }),
3245
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Skeleton, { className: "h-6 w-16" })
3246
+ ] }),
3247
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Skeleton, { className: "h-8 w-28" })
3248
+ ] });
3249
+
3250
+ // src/core/empty-state/EmptyState.tsx
3251
+ var import_free_solid_svg_icons16 = require("@fortawesome/free-solid-svg-icons");
3252
+ var import_react_fontawesome3 = require("@fortawesome/react-fontawesome");
3253
+ var import_react28 = require("react");
3254
+ var import_jsx_runtime68 = require("react/jsx-runtime");
3255
+ var EmptyState = (0, import_react28.forwardRef)(
3256
+ ({ icon = import_free_solid_svg_icons16.faCircle, title, description }, ref) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex flex-col items-center justify-center gap-3 p-4", ref, children: [
3257
+ /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_react_fontawesome3.FontAwesomeIcon, { className: "text-gray-500 ring-transparent", icon, size: "2x" }),
3258
+ /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex max-w-prose flex-col text-center", children: [
3259
+ title && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("h2", { className: "text-sm leading-6 font-medium text-gray-500", children: title }),
3260
+ description && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "text-xs leading-5 font-normal text-gray-500", children: description })
3261
+ ] })
3262
+ ] })
3263
+ );
3264
+
3265
+ // src/core/header-tile/HeaderTile.tsx
3266
+ var import_tailwind_merge36 = require("tailwind-merge");
3267
+ var import_jsx_runtime69 = require("react/jsx-runtime");
3268
+ var HeaderTileSimple = ({ title, content, className }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
3269
+ "div",
3270
+ {
3271
+ className: (0, import_tailwind_merge36.twJoin)(
3272
+ "flex min-h-18.5 flex-col items-start justify-between gap-2 rounded-md border border-gray-200 px-3 py-1.5",
3273
+ className
3274
+ ),
3275
+ children: [
3276
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { className: "max-w-35 text-base text-gray-900", children: title }),
3277
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Text, { children: content })
3278
+ ]
3279
+ }
3280
+ );
3281
+ var HeaderTileWithPopover = ({
3282
+ title,
3283
+ content,
3284
+ popover,
3285
+ className
3286
+ }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(Popover.Root, { children: [
3287
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Popover.Trigger, { className: (0, import_tailwind_merge36.twJoin)("flex h-auto! min-h-18.5 justify-start py-1.5", className), children: /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: "flex flex-col items-start justify-between gap-2", children: [
3288
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "text-base text-gray-900", children: title }),
3289
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { children: content })
3290
+ ] }) }),
3291
+ popover && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Popover.Body, { contentClassName: "max-w-150 min-w-60 p-3", children: popover })
3292
+ ] });
3293
+ var HeaderTile = (props) => {
3294
+ if (props.popover) {
3295
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(HeaderTileWithPopover, { ...props });
3296
+ }
3297
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(HeaderTileSimple, { ...props });
3298
+ };
3299
+
3300
+ // src/core/label/Label.tsx
3301
+ var React11 = __toESM(require("react"), 1);
3302
+
3303
+ // src/core/label/labelStyles.ts
3304
+ var import_tailwind_merge37 = require("tailwind-merge");
3305
+ var sizeStyles3 = {
3306
+ xs: "px-1 text-xs gap-0.5 h-4 rounded-md",
3307
+ sm: "h-5 gap-0.5 px-1 text-sm rounded-md",
3308
+ md: "h-6 gap-1 px-2 text-base rounded-lg",
3309
+ lg: "h-7 gap-1 px-2 text-lg rounded-lg"
3310
+ };
3311
+ var colorStyles2 = {
3312
+ default: {
3313
+ default: "bg-gray-100 text-gray-700 border border-gray-200",
3314
+ primary: "bg-indigo-100 text-indigo-700 border border-indigo-200",
3315
+ success: "bg-green-100 text-green-700 border border-green-200",
3316
+ warning: "bg-yellow-100 text-yellow-700 border border-yellow-200",
3317
+ danger: "bg-red-100 text-red-700 border border-red-200",
3318
+ disabled: "bg-gray-100 text-gray-400 border border-gray-200"
3319
+ },
3320
+ dark: {
3321
+ default: "bg-gray-700 text-gray-50 border border-gray-600",
3322
+ /**
3323
+ * Note(Stephen): We don't yet have tokens for all `intent` values for the dark variant.
3324
+ * Making them the same as default for now rather than wrestle with types as they are unused.
3325
+ */
3326
+ primary: "bg-gray-700 text-gray-50 border border-gray-600",
3327
+ success: "bg-gray-700 text-gray-50 border border-gray-600",
3328
+ warning: "bg-gray-700 text-gray-50 border border-gray-600",
3329
+ danger: "bg-gray-700 text-gray-50 border border-gray-600",
3330
+ disabled: "bg-gray-700 text-gray-50 border border-gray-600"
3331
+ }
3332
+ };
3333
+ var labelStyles = ({ intent = "default", size = "sm", variant = "default" }) => (0, import_tailwind_merge37.twJoin)(
3334
+ "inline-flex w-fit shrink-0 items-center justify-center truncate font-normal break-all",
3335
+ sizeStyles3[size],
3336
+ colorStyles2[variant][intent]
3337
+ );
3338
+
3339
+ // src/core/label/Label.tsx
3340
+ var import_jsx_runtime70 = require("react/jsx-runtime");
3341
+ var LabelImpl2 = ({ children, intent, size, variant, ...rest }, ref) => {
3342
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { ref, className: labelStyles({ intent, size, variant }), ...rest, children });
3343
+ };
3344
+ var Label = React11.forwardRef(LabelImpl2);
3345
+
3346
+ // src/core/menu/Menu.tsx
3347
+ var import_free_solid_svg_icons17 = require("@fortawesome/free-solid-svg-icons");
3348
+ var import_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
3349
+ var import_tailwind_merge38 = require("tailwind-merge");
3350
+ var import_jsx_runtime71 = require("react/jsx-runtime");
3351
+ var MenuTrigger = ({ children, ...rest }) => {
3352
+ if (children == null) {
3353
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_react_dropdown_menu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Button, { ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Icon, { icon: import_free_solid_svg_icons17.faEllipsis }) }) });
3354
+ }
3355
+ if (typeof children === "string") {
3356
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_react_dropdown_menu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Button, { ...rest, children: [
3357
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children }),
3358
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DropdownChevron, {})
3359
+ ] }) });
3360
+ }
3361
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_react_dropdown_menu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Button, { ...rest, children }) });
3362
+ };
3363
+ var MenuContent = ({ children, unrestrictedHeight = false, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_react_dropdown_menu.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
3364
+ import_react_dropdown_menu.Content,
3365
+ {
3366
+ collisionPadding: 8,
3367
+ sideOffset: 4,
3368
+ align: "end",
3369
+ className: "z-100 min-w-48 rounded-lg bg-white p-1.5 shadow-lg",
3370
+ ...props,
3371
+ children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: (0, import_tailwind_merge38.twJoin)("overflow-y-auto", !unrestrictedHeight && "max-h-[252px]"), children })
3372
+ }
3373
+ ) });
3374
+ var MenuItem = ({ loading, disabled, size = "default", ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
3375
+ import_react_dropdown_menu.Item,
3376
+ {
3377
+ "data-loading": loading || void 0,
3378
+ disabled: loading || disabled,
3379
+ className: (0, import_tailwind_merge38.twJoin)(
3380
+ "on-menu-item-active group flex w-full cursor-pointer items-center rounded-md p-2 text-gray-700 outline-hidden select-none data-disabled:cursor-not-allowed data-disabled:text-gray-400 data-highlighted:bg-gray-100 data-loading:bg-transparent data-loading:text-gray-400",
3381
+ size === "default" ? "gap-1.5 text-sm" : "gap-2 text-base"
3382
+ ),
3383
+ ...rest
3384
+ }
3385
+ );
3386
+ var MenuItemWithDisabledTooltip = ({ tooltip, onSelect, ...props }) => {
3387
+ if (!props.disabled || !tooltip) {
3388
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(MenuItem, { ...props, onSelect });
3389
+ }
3390
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
3391
+ Tooltip,
3392
+ {
3393
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(MenuItem, { ...props }) }),
3394
+ content: tooltip,
3395
+ side: "left"
3396
+ }
3397
+ );
3398
+ };
3399
+ var MenuRoot = (props) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_react_dropdown_menu.Root, { modal: false, ...props });
3400
+ var MenuSeparator = () => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_react_dropdown_menu.Separator, { className: "my-[5px] h-px bg-gray-200" });
3401
+ var Menu = ({ children, trigger, align, variant = "default", triggerSize, ...rest }) => {
3402
+ switch (variant) {
3403
+ case "minimal":
3404
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(MenuRoot, { ...rest, children: [
3405
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(MenuTrigger, { ...rest, size: triggerSize || "xs", variant: "transparent", children: trigger }),
3406
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(MenuContent, { align, children })
3407
+ ] });
3408
+ case "default":
3409
+ default:
3410
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(MenuRoot, { ...rest, children: [
3411
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(MenuTrigger, { size: triggerSize, ...rest, children: trigger }),
3412
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(MenuContent, { align, children })
3413
+ ] });
3414
+ }
3415
+ };
3416
+ Menu.Root = MenuRoot;
3417
+ Menu.Trigger = MenuTrigger;
3418
+ Menu.RawTrigger = import_react_dropdown_menu.Trigger;
3419
+ Menu.Content = MenuContent;
3420
+ Menu.Item = MenuItem;
3421
+ Menu.ItemWithDisabledToolTip = MenuItemWithDisabledTooltip;
3422
+ Menu.Separator = MenuSeparator;
3423
+
3424
+ // src/core/modal/components/ModalActions.tsx
3425
+ var import_jsx_runtime72 = require("react/jsx-runtime");
3426
+ var ModalActions = ({ children }) => {
3427
+ if (children == null) {
3428
+ return null;
3429
+ }
3430
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "sticky bottom-0 z-2 flex items-center justify-end gap-x-2 overflow-clip rounded-b-xl bg-white/80 px-8 pt-2 pb-6 backdrop-blur-sm", children });
3431
+ };
3432
+
3433
+ // src/core/modal/components/ModalBody.tsx
3434
+ var import_jsx_runtime73 = require("react/jsx-runtime");
3435
+ var ModalBody = ({ children }) => {
3436
+ if (children == null) {
3437
+ return null;
3438
+ }
3439
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "px-8 py-1.5", children });
3440
+ };
3441
+
3442
+ // src/core/modal/components/ModalCloseButton.tsx
3443
+ var import_react_dialog = require("@radix-ui/react-dialog");
3444
+ var import_jsx_runtime74 = require("react/jsx-runtime");
3445
+ var ModalCloseButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_react_dialog.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Button, { ...props }) });
3446
+
3447
+ // src/core/modal/components/ModalContent.tsx
3448
+ var import_react_dialog2 = require("@radix-ui/react-dialog");
3449
+ var import_tailwind_merge39 = require("tailwind-merge");
3450
+ var import_jsx_runtime75 = require("react/jsx-runtime");
3451
+ var preventDismiss = (e) => e.preventDefault();
3452
+ var handleDismiss = (dismissible) => {
3453
+ if (dismissible) {
3454
+ return;
3455
+ }
3456
+ return preventDismiss;
3457
+ };
3458
+ var ModalContent = ({
3459
+ children,
3460
+ maxWidthClassName = "max-w-prose",
3461
+ overflowYClassName = "overflow-y-auto",
3462
+ onDismiss,
3463
+ dismissible = true,
3464
+ fullscreen,
3465
+ ...rest
3466
+ }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_react_dialog2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
3467
+ import_react_dialog2.Overlay,
3468
+ {
3469
+ className: "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-fade-in-custom-easing",
3470
+ children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
3471
+ import_react_dialog2.Content,
3472
+ {
3473
+ ...rest,
3474
+ className: (0, import_tailwind_merge39.twJoin)(
3475
+ fullscreen ? "h-[calc(100vh-1rem)] w-[calc(100vw-1rem)]" : `max-h-[calc(100vh-2rem)] w-[clamp(100vw-2rem,100%,100vw-2rem)] ${maxWidthClassName}`,
3476
+ `fixed top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl bg-white shadow-lg focus:outline-hidden data-[state=open]:animate-fade-in-subtle-movement ${overflowYClassName}`
3477
+ ),
3478
+ onPointerDownOutside: fullscreen ? handleDismiss() : onDismiss ?? handleDismiss(dismissible),
3479
+ onEscapeKeyDown: fullscreen ? handleDismiss() : onDismiss ?? handleDismiss(dismissible),
3480
+ children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "relative flex h-full min-w-0 flex-1 flex-col", children })
3481
+ }
3482
+ )
3483
+ }
3484
+ ) });
3485
+
3486
+ // src/core/modal/components/ModalDescription.tsx
3487
+ var import_react_dialog3 = require("@radix-ui/react-dialog");
3488
+ var import_jsx_runtime76 = require("react/jsx-runtime");
3489
+ var ModalDescription = ({ children }) => {
3490
+ if (children == null) {
3491
+ return null;
3492
+ }
3493
+ return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_react_dialog3.Description, { className: "pb-3 text-base/6 font-normal text-gray-700", children });
3494
+ };
3495
+
3496
+ // src/core/modal/components/ModalErrorCallout.tsx
3497
+ var import_jsx_runtime77 = require("react/jsx-runtime");
3498
+ var ModalErrorCallout = ({ children }) => {
3499
+ if (!children) {
3500
+ return null;
3501
+ }
3502
+ return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "sticky top-14 z-10 px-5", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Callout, { intent: "danger", children }) });
3503
+ };
3504
+
3505
+ // src/core/modal/components/ModalRoot.tsx
3506
+ var import_react_dialog4 = require("@radix-ui/react-dialog");
3507
+ var import_jsx_runtime78 = require("react/jsx-runtime");
3508
+ var ModalRoot = (props) => {
3509
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_react_dialog4.Root, { ...props });
3510
+ };
3511
+
3512
+ // src/core/modal/components/ModalTitle.tsx
3513
+ var import_react_dialog6 = require("@radix-ui/react-dialog");
3514
+
3515
+ // src/core/modal/components/ModalCloseX.tsx
3516
+ var import_free_solid_svg_icons18 = require("@fortawesome/free-solid-svg-icons");
3517
+ var import_react_dialog5 = require("@radix-ui/react-dialog");
3518
+ var import_jsx_runtime79 = require("react/jsx-runtime");
3519
+ var ModalCloseX = () => /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "absolute top-2.5 right-2.5", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_react_dialog5.Close, { asChild: true, "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Button, { variant: "transparent", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "px-0.5 text-xl text-gray-500", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Icon, { icon: import_free_solid_svg_icons18.faXmark }) }) }) }) });
3520
+
3521
+ // src/core/modal/components/ModalTitle.tsx
3522
+ var import_jsx_runtime80 = require("react/jsx-runtime");
3523
+ var ModalTitle = ({ children, showX = true }) => {
3524
+ if (children == null) {
3525
+ return null;
3526
+ }
3527
+ return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "sticky top-0 z-2 overflow-clip rounded-t-xl bg-white/80 px-8 pt-8 pb-1.5 backdrop-blur-sm", children: [
3528
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_react_dialog6.Title, { className: "text-xl font-semibold text-gray-900", children }),
3529
+ showX && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ModalCloseX, {})
3530
+ ] });
3531
+ };
3532
+
3533
+ // src/core/modal/components/ModalTriggerButton.tsx
3534
+ var import_react_dialog7 = require("@radix-ui/react-dialog");
3535
+ var import_jsx_runtime81 = require("react/jsx-runtime");
3536
+ var ModalTriggerButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_react_dialog7.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Button, { ...props }) });
3537
+
3538
+ // src/core/modal/Modal.tsx
3539
+ var import_jsx_runtime82 = require("react/jsx-runtime");
3540
+ var ModalBodyImpl = ({
3541
+ children,
3542
+ title,
3543
+ error,
3544
+ description,
3545
+ actions,
3546
+ showX = true
3547
+ }) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_jsx_runtime82.Fragment, { children: [
3548
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ModalTitle, { showX, children: title }),
3549
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ModalErrorCallout, { children: error }),
3550
+ (description || children) && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(ModalBody, { children: [
3551
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ModalDescription, { children: description }),
3552
+ children
3553
+ ] }),
3554
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ModalActions, { children: actions })
3555
+ ] });
3556
+ var Modal = ({
3557
+ children,
3558
+ trigger,
3559
+ isOpen,
3560
+ onClose,
3561
+ onOpenChange,
3562
+ content,
3563
+ title,
3564
+ error,
3565
+ description,
3566
+ actions,
3567
+ ...rest
3568
+ }) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
3569
+ ModalRoot,
3570
+ {
3571
+ open: isOpen,
3572
+ onOpenChange: (open) => {
3573
+ if (trigger) {
3574
+ onOpenChange?.(open);
3575
+ } else if (open === false) {
3576
+ onClose?.();
3577
+ }
3578
+ },
3579
+ children: [
3580
+ trigger,
3581
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ModalContent, { "aria-describedby": description || void 0, ...rest, children: children !== void 0 ? children : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ModalBodyImpl, { title, error, description, actions, children: content }) })
3582
+ ]
3583
+ }
3584
+ );
3585
+ Modal.Body = ModalBodyImpl;
3586
+ Modal.TriggerButton = ModalTriggerButton;
3587
+ Modal.CloseButton = ModalCloseButton;
3588
+
3589
+ // src/core/modal/FullscreenModalHeader.tsx
3590
+ var import_react_dialog8 = require("@radix-ui/react-dialog");
3591
+ var import_tailwind_merge40 = require("tailwind-merge");
3592
+ var import_jsx_runtime83 = require("react/jsx-runtime");
3593
+ var FullscreenModalHeader = ({
3594
+ className,
3595
+ title,
3596
+ description,
3597
+ leftSlot,
3598
+ rightSlot
3599
+ }) => {
3600
+ return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: (0, import_tailwind_merge40.twJoin)("flex items-center justify-between gap-4", className), children: [
3601
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "flex flex-1 items-center gap-4", children: [
3602
+ leftSlot,
3603
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "flex flex-col gap-1", children: [
3604
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_react_dialog8.Title, { className: "text-2xl font-medium text-gray-700", children: title }),
3605
+ description && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "text-base/6 text-gray-500", children: description })
3606
+ ] })
3607
+ ] }),
3608
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "flex gap-2", children: rightSlot })
3609
+ ] });
3610
+ };
3611
+
3612
+ // src/core/modal/FullscreenModal.tsx
3613
+ var import_jsx_runtime84 = require("react/jsx-runtime");
3614
+ var FullscreenModal = ({
3615
+ children,
3616
+ trigger,
3617
+ isOpen,
3618
+ onClose,
3619
+ onOpenChange,
3620
+ fullscreen = true,
3621
+ showX = false,
3622
+ title,
3623
+ ...rest
3624
+ }) => /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
3625
+ ModalRoot,
3626
+ {
3627
+ open: isOpen,
3628
+ onOpenChange: (open) => {
3629
+ if (trigger) {
3630
+ onOpenChange?.(open);
3631
+ } else if (open === false) {
3632
+ onClose?.();
3633
+ }
3634
+ },
3635
+ children: [
3636
+ trigger,
3637
+ /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ModalContent, { fullscreen, ...rest, children: title ? /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Modal.Body, { title, showX, children }) : children })
3638
+ ]
3639
+ }
3640
+ );
3641
+ FullscreenModal.TriggerButton = ModalTriggerButton;
3642
+ FullscreenModal.CloseButton = ModalCloseButton;
3643
+ FullscreenModal.Header = FullscreenModalHeader;
3644
+
3645
+ // src/core/modal/AlertModal.tsx
3646
+ var import_jsx_runtime85 = require("react/jsx-runtime");
3647
+ var ModalBodyImpl2 = ({ children, title, error, description, actions }) => /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
3648
+ /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ModalTitle, { showX: false, children: title }),
3649
+ /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ModalErrorCallout, { children: error }),
3650
+ (description || children) && /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(ModalBody, { children: [
3651
+ /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ModalDescription, { children: description }),
3652
+ children
3653
+ ] }),
3654
+ /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ModalActions, { children: actions })
3655
+ ] });
3656
+ var AlertModal = ({
3657
+ children,
3658
+ trigger,
3659
+ isOpen,
3660
+ onOpenChange,
3661
+ onClose,
3662
+ content,
3663
+ title,
3664
+ error,
3665
+ description,
3666
+ actions,
3667
+ ...rest
3668
+ }) => /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
3669
+ ModalRoot,
3670
+ {
3671
+ open: isOpen,
3672
+ onOpenChange: (open) => {
3673
+ if (trigger) {
3674
+ onOpenChange?.(open);
3675
+ } else if (open === false) {
3676
+ onClose?.();
3677
+ }
3678
+ },
3679
+ children: [
3680
+ trigger,
3681
+ /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ModalContent, { ...rest, dismissible: false, children: children !== void 0 ? children : /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ModalBodyImpl2, { title, error, description, actions, children: content }) })
3682
+ ]
3683
+ }
3684
+ );
3685
+ AlertModal.Body = ModalBodyImpl2;
3686
+ AlertModal.TriggerButton = ModalTriggerButton;
3687
+ AlertModal.CloseButton = ModalCloseButton;
3688
+
3689
+ // src/core/phone-number/PhoneNumber.tsx
3690
+ var import_style = require("react-international-phone/style.css");
3691
+ var import_react_international_phone = require("react-international-phone");
3692
+ var import_tailwind_merge41 = require("tailwind-merge");
3693
+ var import_jsx_runtime86 = require("react/jsx-runtime");
3694
+ var PhoneNumber = ({
3695
+ hasError,
3696
+ onChange,
3697
+ ...props
3698
+ }) => {
3699
+ return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
3700
+ import_react_international_phone.PhoneInput,
3701
+ {
3702
+ defaultCountry: props.defaultCountry ?? "us",
3703
+ disableDialCodeAndPrefix: true,
3704
+ showDisabledDialCodeAndPrefix: true,
3705
+ inputClassName: (0, import_tailwind_merge41.twJoin)("flex-1 placeholder:text-gray-400", hasError ? "border-red-300!" : "border-gray-200!"),
3706
+ countrySelectorStyleProps: { className: "border-gray-200!" },
3707
+ onChange: (value, meta) => onChange(meta.inputValue ? value : void 0),
3708
+ ...props
3709
+ }
3710
+ );
3711
+ };
3712
+ var formatPhoneNumber = (input) => {
3713
+ if (!input) {
3714
+ return input;
3715
+ }
3716
+ const digitsOnly = input.replace(/\D/g, "");
3717
+ if (digitsOnly.length === 10) {
3718
+ return `+1${digitsOnly}`;
3719
+ }
3720
+ if (digitsOnly.length === 11 && digitsOnly.startsWith("1")) {
3721
+ return `+${digitsOnly}`;
3722
+ }
3723
+ return input;
3724
+ };
3725
+ var formatPhoneNumberForDisplay = (input) => {
3726
+ if (!input) {
3727
+ return input;
3728
+ }
3729
+ const digitsOnly = input.replace(/\D/g, "");
3730
+ if (digitsOnly.length === 11 && digitsOnly.startsWith("1")) {
3731
+ return `+1 (${digitsOnly.slice(1, 4)}) ${digitsOnly.slice(4, 7)}-${digitsOnly.slice(7)}`;
3732
+ }
3733
+ if (digitsOnly.length === 10) {
3734
+ return `(${digitsOnly.slice(0, 3)}) ${digitsOnly.slice(3, 6)}-${digitsOnly.slice(6)}`;
3735
+ }
3736
+ return input;
3737
+ };
3738
+ var isValidPhoneNumber = (input) => {
3739
+ if (!input) {
3740
+ return false;
3741
+ }
3742
+ if (input.startsWith("+1")) {
3743
+ return input.length === 12;
3744
+ }
3745
+ if (input.startsWith("1")) {
3746
+ return input.length === 11;
3747
+ }
3748
+ return true;
3749
+ };
3750
+
3751
+ // src/core/table/Table.tsx
3752
+ var import_tailwind_merge43 = require("tailwind-merge");
3753
+
3754
+ // src/core/table/TableBody.tsx
3755
+ var import_free_solid_svg_icons19 = require("@fortawesome/free-solid-svg-icons");
3756
+
3757
+ // src/core/table/TableRow.tsx
3758
+ var import_tailwind_merge42 = require("tailwind-merge");
3759
+
3760
+ // src/core/table/utils.ts
3761
+ var import_react_table = require("@tanstack/react-table");
3762
+ var isValidCell = (cell) => {
3763
+ if (!(cell.column.columnDef.cell instanceof Function)) {
3764
+ return null;
3765
+ }
3766
+ return cell.column.columnDef.cell(cell.getContext());
3767
+ };
3768
+ var renderHeader = (header) => {
3769
+ if (header.isPlaceholder) {
3770
+ return null;
3771
+ }
3772
+ return (0, import_react_table.flexRender)(header.column.columnDef.header, header.getContext());
3773
+ };
3774
+ var renderCell = (cell) => {
3775
+ if (isValidCell(cell) == null) {
3776
+ return null;
3777
+ }
3778
+ return (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext());
3779
+ };
3780
+ var sumOffset = (offset, { getSize }) => getSize() + offset;
3781
+ var getCols = (item) => {
3782
+ const cols = item.getContext().table.getAllColumns();
3783
+ const index = cols.findIndex(({ id }) => id === item.column.id);
3784
+ return { cols, index };
3785
+ };
3786
+ var getLeftStickyOffset = (item) => {
3787
+ const { cols, index } = getCols(item);
3788
+ if (index === 0) {
3789
+ return 0;
3790
+ }
3791
+ return cols.slice(0, index).reduce(sumOffset, 0);
3792
+ };
3793
+ var getRightStickyOffset = (item) => {
3794
+ const { cols, index } = getCols(item);
3795
+ if (index === cols.length - 1) {
3796
+ return 0;
3797
+ }
3798
+ return cols.slice(0, index).reduceRight(sumOffset, 0);
3799
+ };
3800
+ var handleStyle = (item, _style) => {
3801
+ const style = _style ? { ..._style } : {};
3802
+ if (item.column.columnDef.meta?.unPadded) {
3803
+ style.padding = 0;
3804
+ style.paddingTop = 0;
3805
+ style.paddingRight = 0;
3806
+ style.paddingBottom = 0;
3807
+ style.paddingLeft = 0;
3808
+ }
3809
+ const size = item.column.getSize();
3810
+ if (!size) {
3811
+ return style;
3812
+ }
3813
+ style.width = size;
3814
+ style.minWidth = size;
3815
+ if (item.column.columnDef.meta?.sticky === "left") {
3816
+ style.position = "sticky";
3817
+ style.left = getLeftStickyOffset(item);
3818
+ }
3819
+ if (item.column.columnDef.meta?.sticky === "right") {
3820
+ style.position = "sticky";
3821
+ style.right = getRightStickyOffset(item);
3822
+ }
3823
+ return style;
3824
+ };
3825
+ var handleHeaderStyle = handleStyle;
3826
+ var handleCellStyle = handleStyle;
3827
+
3828
+ // src/core/table/TableRow.tsx
3829
+ var import_jsx_runtime87 = require("react/jsx-runtime");
3830
+ var TableRow = ({ table, rowClassName, cellClassName, row }) => {
3831
+ const hasRowClick = !!table.options.meta?.onRowClick;
3832
+ const isStaticSubRow = !!table.options.meta?.staticSubRows;
3833
+ const onRowClick = (ev, row2) => {
3834
+ if (ev.target === ev.currentTarget) {
3835
+ table.options.meta?.onRowClick?.(row2);
3836
+ }
3837
+ };
3838
+ const cells = row.getVisibleCells();
3839
+ return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
3840
+ "tr",
3841
+ {
3842
+ "data-active": table.options.meta?.activeRowId === row.id ? "" : void 0,
3843
+ "data-clickable": !isStaticSubRow && (hasRowClick || row.getCanExpand()) ? "" : void 0,
3844
+ "data-depth": isStaticSubRow ? row.depth : void 0,
3845
+ onClick: !isStaticSubRow && row.getCanExpand() ? row.getToggleExpandedHandler() : void 0,
3846
+ className: (0, import_tailwind_merge42.twJoin)(
3847
+ "data-[active]:bg-indigo-100 data-[clickable]:hover:cursor-pointer data-[clickable]:hover:bg-indigo-50 data-[active]:data-[clickable]:hover:bg-indigo-200",
3848
+ rowClassName
3849
+ ),
3850
+ children: cells.map((cell) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
3851
+ "td",
3852
+ {
3853
+ onClickCapture: hasRowClick ? (ev) => onRowClick(ev, row) : void 0,
3854
+ className: cellClassName,
3855
+ style: handleCellStyle(cell),
3856
+ children: renderCell(cell)
3857
+ },
3858
+ cell.id
3859
+ ))
3860
+ }
3861
+ );
3862
+ };
3863
+
3864
+ // src/core/table/TableBody.tsx
3865
+ var import_jsx_runtime88 = require("react/jsx-runtime");
3866
+ var TableBody = ({ table, loading, rootClassName, ...props }) => {
3867
+ const { rows } = table.getRowModel();
3868
+ if (loading && rows.length === 0) {
3869
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("tbody", { className: rootClassName, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("td", { colSpan: table.getAllLeafColumns().length, className: "h-12 text-center align-middle text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Spinner, {}) }) }) });
3870
+ }
3871
+ if (rows.length === 0) {
3872
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("tbody", { className: rootClassName, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(EmptyRowsTd, { colSpan: table.getAllLeafColumns().length, emptyText: table.options.meta?.emptyText }) }) });
3873
+ }
3874
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("tbody", { className: rootClassName, children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TableRow, { ...props, table, row }, row.id)) });
3875
+ };
3876
+ var EmptyRowsTd = ({ emptyText = "No rows found", ...props }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("td", { ...props, className: "h-12 text-center align-middle text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("p", { className: "inline-flex items-center gap-2 text-2xl/none", children: [
3877
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Icon, { icon: import_free_solid_svg_icons19.faTable }) }),
3878
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { className: "text-base/none font-medium", children: emptyText })
3879
+ ] }) });
3880
+
3881
+ // src/core/table/TableHeader.tsx
3882
+ var import_free_solid_svg_icons20 = require("@fortawesome/free-solid-svg-icons");
3883
+ var import_jsx_runtime89 = require("react/jsx-runtime");
3884
+ var TableHeader = ({ table, rootClassName, rowClassName, cellClassName }) => {
3885
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("thead", { className: rootClassName, children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("tr", { className: rowClassName, children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
3886
+ Th,
3887
+ {
3888
+ scope: "col",
3889
+ colSpan: header.colSpan,
3890
+ className: cellClassName,
3891
+ style: handleHeaderStyle(header),
3892
+ header,
3893
+ children: renderHeader(header)
3894
+ },
3895
+ header.id
3896
+ )) }, headerGroup.id)) });
3897
+ };
3898
+ var Th = ({
3899
+ header,
3900
+ children,
3901
+ ...props
3902
+ }) => {
3903
+ if (header.column.getIsSorted()) {
3904
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("th", { ...props, "data-clickable": "ok", onClick: header.column.getToggleSortingHandler(), children: [
3905
+ children,
3906
+ /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { className: "ml-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(SortIcon, { dir: header.column.getIsSorted() }) })
3907
+ ] });
3908
+ }
3909
+ if (header.column.getCanSort()) {
3910
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("th", { ...props, "data-clickable": "ok", onClick: header.column.getToggleSortingHandler(), children: [
3911
+ children,
3912
+ /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { className: "invisible ml-1.5 group-hover:visible", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(SortIcon, { dir: header.column.getNextSortingOrder() }) })
3913
+ ] });
3914
+ }
3915
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("th", { ...props, children });
3916
+ };
3917
+ var SortIcon = ({ dir }) => {
3918
+ if (dir === "asc") {
3919
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Icon, { icon: import_free_solid_svg_icons20.faArrowUpWideShort });
3920
+ }
3921
+ if (dir === "desc") {
3922
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Icon, { icon: import_free_solid_svg_icons20.faArrowDownWideShort });
3923
+ }
3924
+ return null;
3925
+ };
3926
+
3927
+ // src/core/table/Table.tsx
3928
+ var import_jsx_runtime90 = require("react/jsx-runtime");
3929
+ var variants = {
3930
+ default: "default",
3931
+ seamless: "seamless",
3932
+ transparent: "transparent",
3933
+ subtable: "subtable"
3934
+ };
3935
+ var headerClassNames = (variant) => {
3936
+ switch (variant) {
3937
+ case variants.transparent:
3938
+ return {
3939
+ cellClassName: "text-left text-sm font-medium text-gray-500 whitespace-nowrap px-2.5 py-3"
3940
+ };
3941
+ case variants.subtable:
3942
+ return {
3943
+ rowClassName: "divide-x divide-gray-200",
3944
+ cellClassName: "text-left text-sm font-medium text-gray-500 whitespace-nowrap border-b bg-gray-100 px-2 py-1.5"
3945
+ };
3946
+ case variants.seamless:
3947
+ return {
3948
+ cellClassName: "text-left text-sm font-medium text-gray-500 whitespace-nowrap sticky top-0 z-1 border-b bg-gray-50 px-2 py-1.5 group data-[clickable]:cursor-pointer data-[clickable]:select-none data-[clickable]:hover:text-gray-800"
3949
+ };
3950
+ case variants.default:
3951
+ default:
3952
+ return {
3953
+ cellClassName: "text-left text-sm font-medium text-gray-500 whitespace-nowrap sticky top-0 z-1 border-b bg-gray-100 px-2 py-1.5 group data-[clickable]:cursor-pointer data-[clickable]:select-none data-[clickable]:hover:text-gray-800"
3954
+ };
3955
+ }
3956
+ };
3957
+ var bodyClassNames = (variant) => {
3958
+ switch (variant) {
3959
+ case variants.seamless:
3960
+ return {
3961
+ rowClassName: "[&:not(:last-child)_td]:border-gray-200",
3962
+ cellClassName: "text-sm text-gray-700 whitespace-nowrap h-fit"
3963
+ };
3964
+ case variants.transparent:
3965
+ return {
3966
+ rootClassName: "rounded-lg bg-white outline outline-1 outline-gray-200",
3967
+ rowClassName: "[&:not(:last-child)_td]:border-b [&:not(:last-child)_td]:border-gray-200 [&:first-child_td:first-child]:rounded-tl-lg [&:first-child_td:last-child]:rounded-tr-lg [&:last-child_td:first-child]:rounded-bl-lg [&:last-child_td:last-child]:rounded-br-lg",
3968
+ cellClassName: "text-sm text-gray-700 whitespace-nowrap p-2.5 py-1.5"
3969
+ };
3970
+ case variants.subtable:
3971
+ return {
3972
+ rowClassName: "[&:not(:last-child)_td]:border-b [&:not(:last-child)_td]:border-gray-200 divide-x divide-gray-200",
3973
+ cellClassName: "text-sm text-gray-700 whitespace-nowrap p-2"
3974
+ };
3975
+ case variants.default:
3976
+ default:
3977
+ return {
3978
+ rowClassName: "[&:not(:last-child)_td]:border-b [&:not(:last-child)_td]:border-gray-200 data-[depth='0']:bg-gray-50",
3979
+ cellClassName: "text-sm text-gray-700 whitespace-nowrap p-2"
3980
+ };
3981
+ }
3982
+ };
3983
+ var Table = ({ variant = "default", loading, fillHeight, ...props }) => {
3984
+ const uiLoading = loading ? "loading" : void 0;
3985
+ switch (variant) {
3986
+ case variants.transparent:
3987
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
3988
+ "table",
3989
+ {
3990
+ "data-ui": uiLoading,
3991
+ className: "mb-auto min-w-full border-separate border-spacing-0 data-[ui=loading]:pointer-events-none data-[ui=loading]:opacity-60 data-[ui=loading]:select-none",
3992
+ children: [
3993
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TableHeader, { ...props, ...headerClassNames(variant) }),
3994
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TableBody, { ...props, ...bodyClassNames(variant), loading })
3995
+ ]
3996
+ }
3997
+ );
3998
+ case variants.subtable:
3999
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "mb-auto min-w-full", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
4000
+ "table",
4001
+ {
4002
+ "data-ui": uiLoading,
4003
+ className: "min-w-full border-separate border-spacing-0 data-[ui=loading]:pointer-events-none data-[ui=loading]:opacity-60 data-[ui=loading]:select-none",
4004
+ children: [
4005
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TableHeader, { ...props, ...headerClassNames(variant) }),
4006
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TableBody, { ...props, ...bodyClassNames(variant), loading })
4007
+ ]
4008
+ }
4009
+ ) });
4010
+ case variants.seamless:
4011
+ case variants.default:
4012
+ default:
4013
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: (0, import_tailwind_merge43.twJoin)("mb-auto overflow-auto rounded-md border border-gray-200 bg-white", fillHeight && "h-full min-h-0"), children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "min-w-full", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
4014
+ "table",
4015
+ {
4016
+ "data-ui": uiLoading,
4017
+ className: "relative min-w-full border-separate border-spacing-0 data-[ui=loading]:pointer-events-none data-[ui=loading]:opacity-60 data-[ui=loading]:select-none",
4018
+ children: [
4019
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TableHeader, { ...props, ...headerClassNames(variant) }),
4020
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TableBody, { ...props, ...bodyClassNames(variant), loading })
4021
+ ]
4022
+ }
4023
+ ) }) });
4024
+ }
4025
+ };
4026
+
4027
+ // src/core/table/useTable.ts
4028
+ var import_react_table2 = require("@tanstack/react-table");
4029
+ var useTable = (options) => {
4030
+ const enableSorting = !!options.state?.sorting && !!options.onSortingChange;
4031
+ return (0, import_react_table2.useReactTable)({
4032
+ ...options,
4033
+ getCoreRowModel: (0, import_react_table2.getCoreRowModel)(),
4034
+ // This is a hack to allow the columns to flex by default,
4035
+ // and, then when size is overridden, they become fixed
4036
+ defaultColumn: {
4037
+ ...options.defaultColumn,
4038
+ minSize: 0,
4039
+ size: 0
4040
+ },
4041
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
4042
+ meta: {
4043
+ emptyText: options.emptyText,
4044
+ activeRowId: options.activeRowId,
4045
+ onRowClick: options.onRowClick,
4046
+ staticSubRows: options.staticSubRows
4047
+ },
4048
+ /* eslint-enable @typescript-eslint/no-unsafe-assignment */
4049
+ manualSorting: true,
4050
+ enableMultiSort: false,
4051
+ enableSorting
4052
+ });
4053
+ };
4054
+
4055
+ // src/core/tab-group/TabGroup.tsx
4056
+ var import_react_toggle_group = require("@radix-ui/react-toggle-group");
4057
+ var import_react29 = require("react");
4058
+ var import_tailwind_merge44 = require("tailwind-merge");
4059
+ var import_jsx_runtime91 = require("react/jsx-runtime");
4060
+ var TabGroup = ({ tabs, currentTab, setCurrentTab }) => {
4061
+ return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
4062
+ import_react_toggle_group.ToggleGroup,
4063
+ {
4064
+ type: "single",
4065
+ value: currentTab,
4066
+ onValueChange: (value) => {
4067
+ if (value) {
4068
+ setCurrentTab(value);
4069
+ }
4070
+ },
4071
+ className: "flex w-full justify-between gap-1 rounded-lg border border-gray-200 p-1",
4072
+ children: tabs.map(({ id, label, disabled }, index) => /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_react29.Fragment, { children: [
4073
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
4074
+ import_react_toggle_group.ToggleGroupItem,
4075
+ {
4076
+ value: id,
4077
+ disabled,
4078
+ className: (0, import_tailwind_merge44.twJoin)(
4079
+ "flex w-full items-center justify-center rounded-md border px-2 py-2 transition",
4080
+ disabled && "cursor-not-allowed opacity-50",
4081
+ !disabled && "hover:bg-indigo-50 focus-visible:border-indigo-700 focus-visible:outline-none",
4082
+ id !== currentTab && "border-transparent",
4083
+ id !== currentTab && !disabled && "hover:border-indigo-200",
4084
+ id === currentTab && !disabled && "border border-indigo-400 bg-white ring-2 ring-indigo-100"
4085
+ ),
4086
+ children: label
4087
+ }
4088
+ ),
4089
+ index !== tabs.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "my-1 flex w-[1px] bg-gray-300" })
4090
+ ] }, id))
4091
+ }
4092
+ );
4093
+ };
4094
+
4095
+ // src/core/tabs/Tabs.tsx
4096
+ var import_react_tabs2 = require("@radix-ui/react-tabs");
4097
+ var import_tailwind_merge46 = require("tailwind-merge");
4098
+
4099
+ // src/core/tabs/Trigger.tsx
4100
+ var import_react_tabs = require("@radix-ui/react-tabs");
4101
+ var import_tailwind_merge45 = require("tailwind-merge");
4102
+ var import_jsx_runtime92 = require("react/jsx-runtime");
4103
+ var TabsTrigger = ({
4104
+ id,
4105
+ label,
4106
+ disabled,
4107
+ dataTestId,
4108
+ fsId,
4109
+ extra,
4110
+ className
4111
+ }) => /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
4112
+ import_react_tabs.Trigger,
4113
+ {
4114
+ className: (0, import_tailwind_merge45.twMerge)(
4115
+ "h-full space-x-1 border-b-2 px-1 py-1 font-medium whitespace-nowrap transition-colors duration-150 data-[state='active']:border-indigo-500 data-[state='active']:text-indigo-700 data-[state='inactive']:border-transparent data-[state='inactive']:text-gray-500 data-[state='inactive']:hover:border-gray-200 data-[state='inactive']:hover:text-gray-700",
4116
+ className
4117
+ ),
4118
+ value: id,
4119
+ disabled,
4120
+ "data-testid": dataTestId,
4121
+ "fs-id": fsId,
4122
+ children: [
4123
+ label,
4124
+ extra && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: extra })
4125
+ ]
4126
+ }
4127
+ );
4128
+
4129
+ // src/core/tabs/Tabs.tsx
4130
+ var import_jsx_runtime93 = require("react/jsx-runtime");
4131
+ var [Provider2, useContext6] = createContextHelper();
4132
+ var Tabs = ({
4133
+ tabs,
4134
+ className,
4135
+ tabsListClassName,
4136
+ tabsListContainerClassName,
4137
+ tabsListTriggerClassName,
4138
+ currentTab,
4139
+ setCurrentTab,
4140
+ children,
4141
+ extraNode
4142
+ }) => {
4143
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Provider2, { currentTab, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_react_tabs2.Root, { className, value: currentTab, onValueChange: (id) => setCurrentTab(id), children: [
4144
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: (0, import_tailwind_merge46.twJoin)("flex gap-4", tabsListContainerClassName), children: [
4145
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_tabs2.List, { className: (0, import_tailwind_merge46.twJoin)("flex space-x-4 overflow-x-auto", tabsListClassName), children: tabs.map(({ id, label, disabled, fsId }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
4146
+ TabsTrigger,
4147
+ {
4148
+ id,
4149
+ label,
4150
+ disabled,
4151
+ className: tabsListTriggerClassName,
4152
+ fsId
4153
+ },
4154
+ id
4155
+ )) }),
4156
+ extraNode
4157
+ ] }),
4158
+ children
4159
+ ] }) });
4160
+ };
4161
+ var TabContent = ({ id, ...rest }) => {
4162
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_tabs2.Content, { value: id, ...rest });
4163
+ };
4164
+ var AlwaysMountedTabContent = ({
4165
+ id,
4166
+ visibleClassName,
4167
+ className,
4168
+ children
4169
+ }) => {
4170
+ const { currentTab } = useContext6();
4171
+ const visible = id === currentTab;
4172
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: (0, import_tailwind_merge46.twJoin)(visible ? visibleClassName : "hidden", className), children });
4173
+ };
4174
+ Tabs.TabContent = TabContent;
4175
+ Tabs.AlwaysMountedTabContent = AlwaysMountedTabContent;
4176
+ var createTypedTabs = () => ({
4177
+ Root: ({ currentTab, setCurrentTab, ...props }) => {
4178
+ const handleValueChange = setCurrentTab ? (value) => setCurrentTab(value) : void 0;
4179
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_tabs2.Root, { ...props, value: currentTab, onValueChange: handleValueChange });
4180
+ },
4181
+ List: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_tabs2.List, { ...props, className: (0, import_tailwind_merge46.twJoin)("flex space-x-4 overflow-x-auto", className) }),
4182
+ Trigger: TabsTrigger,
4183
+ Content: TabContent
4184
+ });
4185
+
4186
+ // src/core/tabs/ScrollTabsLayout.tsx
4187
+ var import_react30 = require("react");
4188
+ var import_tailwind_merge47 = require("tailwind-merge");
4189
+ var import_jsx_runtime94 = require("react/jsx-runtime");
4190
+ var ScrollTabsLayout = ({ tabs, onSelectTab, sectionClassName }) => {
4191
+ const [selectedTabName, setSelectedTabName] = (0, import_react30.useState)(tabs[0].tabName);
4192
+ const scrollContainerRef = (0, import_react30.useRef)(null);
4193
+ const tabRefs = (0, import_react30.useRef)({});
4194
+ const handleSelectTab = (0, import_react30.useCallback)(
4195
+ (tabId) => {
4196
+ scrollContainerRef.current?.scrollTo({
4197
+ top: tabRefs.current[tabId].offsetTop,
4198
+ behavior: "smooth"
4199
+ });
4200
+ setSelectedTabName(tabId);
4201
+ onSelectTab?.(tabId);
4202
+ },
4203
+ [onSelectTab]
4204
+ );
4205
+ (0, import_react30.useEffect)(() => {
4206
+ const scrollContainer = scrollContainerRef.current;
4207
+ const handleScroll = (e) => {
4208
+ Object.entries(tabRefs.current).forEach(([tabName, tabRef]) => {
4209
+ if (e.currentTarget?.scrollTop >= tabRef.offsetTop) {
4210
+ setSelectedTabName(tabName);
4211
+ onSelectTab?.(tabName);
4212
+ }
4213
+ });
4214
+ };
4215
+ scrollContainer?.addEventListener("scroll", handleScroll);
4216
+ return () => {
4217
+ scrollContainer?.removeEventListener("scroll", handleScroll);
4218
+ };
4219
+ });
4220
+ return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_jsx_runtime94.Fragment, { children: [
4221
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
4222
+ Tabs,
4223
+ {
4224
+ currentTab: selectedTabName,
4225
+ setCurrentTab: handleSelectTab,
4226
+ tabs: tabs.map((tab) => ({ id: tab.tabName, label: tab.tabName }))
4227
+ }
4228
+ ),
4229
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("hr", {}),
4230
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { ref: scrollContainerRef, className: "relative h-screen overflow-y-auto", children: [
4231
+ tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
4232
+ "div",
4233
+ {
4234
+ ref: (el) => el ? tabRefs.current[tab.tabName] = el : void 0,
4235
+ className: (0, import_tailwind_merge47.twJoin)("first:pt-4", sectionClassName),
4236
+ children: tab.content
4237
+ },
4238
+ tab.tabName
4239
+ )),
4240
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "h-screen" })
4241
+ ] })
4242
+ ] });
4243
+ };
4244
+
4245
+ // src/core/tabs/ComposableTabs.tsx
4246
+ var import_react_tabs3 = require("@radix-ui/react-tabs");
4247
+ var import_tailwind_merge48 = require("tailwind-merge");
4248
+ var import_jsx_runtime95 = require("react/jsx-runtime");
4249
+ var [TabsProvider, useTabsContext] = createContextHelper();
4250
+ var ComposableTabsList = ({ className, containerClassName, extraNode }) => {
4251
+ const { tabs } = useTabsContext();
4252
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: (0, import_tailwind_merge48.twJoin)("flex gap-4", containerClassName), children: [
4253
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_react_tabs3.List, { className: (0, import_tailwind_merge48.twJoin)("flex space-x-4 overflow-x-auto", className), children: tabs.map(({ id, label, disabled }) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(TabsTrigger, { id, label, disabled }, id)) }),
4254
+ extraNode
4255
+ ] });
4256
+ };
4257
+ var ComposableTabContent = ({ id, ...rest }) => {
4258
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_react_tabs3.Content, { value: id, ...rest });
4259
+ };
4260
+ var ComposableAlwaysMountedTabContent = ({
4261
+ id,
4262
+ visibleClassName,
4263
+ className,
4264
+ children
4265
+ }) => {
4266
+ const { currentTab } = useTabsContext();
4267
+ const visible = id === currentTab;
4268
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: (0, import_tailwind_merge48.twJoin)(visible ? visibleClassName : "hidden", className), children });
4269
+ };
4270
+ var ComposableTabsRoot = ({
4271
+ tabs,
4272
+ currentTab,
4273
+ setCurrentTab,
4274
+ className,
4275
+ children
4276
+ }) => {
4277
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(TabsProvider, { tabs, currentTab, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_react_tabs3.Root, { className, value: currentTab, onValueChange: (id) => setCurrentTab(id), children }) });
4278
+ };
4279
+ var ComposableTabs = {
4280
+ Root: ComposableTabsRoot,
4281
+ List: ComposableTabsList,
4282
+ TabContent: ComposableTabContent,
4283
+ AlwaysMountedTabContent: ComposableAlwaysMountedTabContent
4284
+ };
4285
+
4286
+ // src/core/tag/Tag.tsx
4287
+ var import_free_solid_svg_icons21 = require("@fortawesome/free-solid-svg-icons");
4288
+ var React12 = __toESM(require("react"), 1);
4289
+ var import_jsx_runtime96 = require("react/jsx-runtime");
4290
+ var TagLabel = ({ children, removable, onRemove, intent = "default", ...rest }, ref) => /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Label, { ...rest, ref, intent, children: [
4291
+ children,
4292
+ removable && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
4293
+ "button",
4294
+ {
4295
+ className: "ml-1 inline-flex h-xs items-center px-1 text-gray-500 hover:text-gray-700 focus:outline-hidden",
4296
+ onClick: onRemove,
4297
+ children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Icon, { icon: import_free_solid_svg_icons21.faXmark })
4298
+ }
4299
+ )
4300
+ ] });
4301
+ var TagImpl = React12.forwardRef(TagLabel);
4302
+ var Tag = ({ tooltip, ...rest }) => {
4303
+ if (!tooltip) {
4304
+ return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(TagImpl, { ...rest });
4305
+ }
4306
+ return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Tooltip, { trigger: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(TagImpl, { ...rest }), content: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("p", { className: "text-sm", children: tooltip }) });
4307
+ };
4308
+
4309
+ // src/core/utils/useIsHovered.ts
4310
+ var import_react31 = require("react");
4311
+ var useIsHovered = (ref) => {
4312
+ const [isHovered, setIsHovered] = (0, import_react31.useState)(false);
4313
+ (0, import_react31.useEffect)(() => {
4314
+ const handleMouseMove = () => {
4315
+ if (ref.current?.matches(":hover")) {
4316
+ setIsHovered(true);
4317
+ } else {
4318
+ setIsHovered(false);
4319
+ }
4320
+ };
4321
+ const handleScroll = () => {
4322
+ if (isHovered) {
4323
+ setIsHovered(false);
4324
+ }
4325
+ };
4326
+ window.addEventListener("mousemove", handleMouseMove);
4327
+ if (isHovered) {
4328
+ window.addEventListener("scroll", handleScroll, true);
4329
+ }
4330
+ return () => {
4331
+ window.removeEventListener("mousemove", handleMouseMove);
4332
+ window.removeEventListener("scroll", handleScroll, true);
4333
+ };
4334
+ }, [ref, isHovered]);
4335
+ return isHovered;
4336
+ };
4337
+ // Annotate the CommonJS export names for ESM import in node:
4338
+ 0 && (module.exports = {
4339
+ AlertModal,
4340
+ AsyncMultiSelect,
4341
+ AsyncSelect,
4342
+ Button,
4343
+ ButtonGroup,
4344
+ CURRENCY_REGEX,
4345
+ Callout,
4346
+ Checkbox,
4347
+ Collapsible,
4348
+ CollapsibleSection,
4349
+ ComposableTabs,
4350
+ ControlledField,
4351
+ ControlledFieldProvider,
4352
+ Copyable,
4353
+ DEFAULT_NUM_VALUES_TO_SHOW,
4354
+ DatePicker,
4355
+ Divider,
4356
+ DollarInput,
4357
+ Drawer,
4358
+ DrawerHeader,
4359
+ DrawerHeaderSkeleton,
4360
+ DrawerStateContext,
4361
+ DropdownChevron,
4362
+ EmptyState,
4363
+ ErrorText,
4364
+ FormCheckbox,
4365
+ FormDatePicker,
4366
+ FormDollarInput,
4367
+ FormInput,
4368
+ FormMultiSelect,
4369
+ FormPercentInput,
4370
+ FormProvider,
4371
+ FormRadioButtonGroup,
4372
+ FormSelect,
4373
+ FormSwitch,
4374
+ FormTextArea,
4375
+ FullscreenModal,
4376
+ HeaderTile,
4377
+ Icon,
4378
+ IndeterminateCheckbox,
4379
+ Input,
4380
+ InputBox,
4381
+ IsEditingProvider,
4382
+ IsVisibleProvider,
4383
+ Label,
4384
+ LoadingBar,
4385
+ LoadingState,
4386
+ Menu,
4387
+ MenuRoot,
4388
+ MenuSeparator,
4389
+ Modal,
4390
+ MultiSelect,
4391
+ OverflowTooltip,
4392
+ PercentInput,
4393
+ PhoneNumber,
4394
+ Popover,
4395
+ RING_COLOR_CLASSNAME,
4396
+ RadioButtonGroup,
4397
+ RadioButtonItem,
4398
+ ScrollTabsLayout,
4399
+ Select,
4400
+ SelectListItem,
4401
+ SelectWithUnselect,
4402
+ Skeleton,
4403
+ Spinner,
4404
+ Switch,
4405
+ TabGroup,
4406
+ Table,
4407
+ TableCheckboxSkeleton,
4408
+ TableSkeleton,
4409
+ Tabs,
4410
+ TabsSkeleton,
4411
+ TabsTrigger,
4412
+ Tag,
4413
+ Text,
4414
+ TextArea,
4415
+ TextAreaComp,
4416
+ Tooltip,
4417
+ TooltipContent,
4418
+ UncontrolledField,
4419
+ UncontrolledFieldProvider,
4420
+ asNullish,
4421
+ asNumericStr,
4422
+ asOptional,
4423
+ asRequiredCustom,
4424
+ buildZodIssue,
4425
+ buttonStyles,
4426
+ copyToClipboard,
4427
+ createContextHelper,
4428
+ createToggleContextHelper,
4429
+ createTypedTabs,
4430
+ doesSelectItemMatch,
4431
+ dollarsStrSchema,
4432
+ formatPhoneNumber,
4433
+ formatPhoneNumberForDisplay,
4434
+ getCountry,
4435
+ getFieldError,
4436
+ inputBoxStyles,
4437
+ inputStyles,
4438
+ isValidPhoneNumber,
4439
+ linkStyles,
4440
+ localStoragePersist,
4441
+ npiSchema,
4442
+ npiSchemaOptional,
4443
+ requiredDollarsStrSchema,
4444
+ requiredDollarsStrSchemaWithCustomMessage,
4445
+ requiredNonZeroDollarsStrSchema,
4446
+ requiredPositiveDollarsStrSchema,
4447
+ requiredPositiveOrZeroDollarsStrSchema,
4448
+ selectedAmountSchema,
4449
+ taxIdSchema,
4450
+ taxonomyCodeSchema,
4451
+ useAsyncMultiSelect,
4452
+ useAsyncSelect,
4453
+ useControlledField,
4454
+ useControlledFormField,
4455
+ useController,
4456
+ useCopyable,
4457
+ useDebounce,
4458
+ useDrawer,
4459
+ useDrawerResize,
4460
+ useFieldArray,
4461
+ useForm,
4462
+ useFormContext,
4463
+ useFormState,
4464
+ useIsEditing,
4465
+ useIsHovered,
4466
+ useIsVisible,
4467
+ useOverflowObserver,
4468
+ useSwitchId,
4469
+ useSyncState,
4470
+ useTable,
4471
+ useToggle,
4472
+ useUncontrolledField,
4473
+ useUncontrolledFormField,
4474
+ useWatch
4475
+ });
4476
+ //# sourceMappingURL=index.js.map