@sunggang/ui-lib 0.3.65 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/BaseCkeditor.cjs.js +66855 -0
  2. package/BaseCkeditor.esm.js +15 -18
  3. package/BigCalender.cjs.d.ts +1 -0
  4. package/BigCalender.cjs.default.js +1 -0
  5. package/BigCalender.cjs.js +20404 -0
  6. package/BigCalender.cjs.mjs +2 -0
  7. package/BigCalender.esm.d.ts +1 -0
  8. package/BigCalender.esm.js +20393 -0
  9. package/CkEditor.cjs.d.ts +1 -0
  10. package/CkEditor.cjs.default.js +1 -0
  11. package/CkEditor.cjs.js +31 -0
  12. package/CkEditor.cjs.mjs +2 -0
  13. package/CkEditor.esm.d.ts +1 -0
  14. package/CkEditor.esm.js +23 -0
  15. package/DataTable.cjs.d.ts +1 -0
  16. package/DataTable.cjs.default.js +1 -0
  17. package/DataTable.cjs.js +968 -0
  18. package/DataTable.cjs.mjs +2 -0
  19. package/DataTable.esm.d.ts +1 -0
  20. package/DataTable.esm.js +943 -0
  21. package/DropImage.cjs.d.ts +1 -0
  22. package/DropImage.cjs.default.js +1 -0
  23. package/DropImage.cjs.js +16845 -0
  24. package/DropImage.cjs.mjs +2 -0
  25. package/DropImage.esm.d.ts +1 -0
  26. package/DropImage.esm.js +16834 -0
  27. package/Form.cjs.d.ts +1 -0
  28. package/Form.cjs.default.js +1 -0
  29. package/Form.cjs.js +402 -0
  30. package/Form.cjs.mjs +2 -0
  31. package/Form.esm.d.ts +1 -0
  32. package/Form.esm.js +390 -0
  33. package/FormProvider.cjs.d.ts +1 -0
  34. package/FormProvider.cjs.default.js +1 -0
  35. package/FormProvider.cjs.js +81 -0
  36. package/FormProvider.cjs.mjs +2 -0
  37. package/FormProvider.esm.d.ts +1 -0
  38. package/FormProvider.esm.js +71 -0
  39. package/LiffProvider.cjs.d.ts +1 -0
  40. package/LiffProvider.cjs.default.js +1 -0
  41. package/LiffProvider.cjs.js +1120 -0
  42. package/LiffProvider.cjs.mjs +2 -0
  43. package/LiffProvider.esm.d.ts +1 -0
  44. package/LiffProvider.esm.js +1114 -0
  45. package/Modal.cjs.js +168 -0
  46. package/Modal.esm.js +164 -0
  47. package/Tabs.cjs.d.ts +1 -0
  48. package/Tabs.cjs.default.js +1 -0
  49. package/Tabs.cjs.js +62 -0
  50. package/Tabs.cjs.mjs +2 -0
  51. package/Tabs.esm.d.ts +1 -0
  52. package/Tabs.esm.js +58 -0
  53. package/_commonjsHelpers.cjs.js +30 -0
  54. package/_commonjsHelpers.esm.js +25 -0
  55. package/_tslib.cjs.js +232 -0
  56. package/_tslib.esm.js +224 -0
  57. package/baseSwitch.cjs.js +25830 -0
  58. package/baseSwitch.esm.js +25785 -0
  59. package/index.cjs.css +4832 -0
  60. package/index.cjs.d.ts +1 -0
  61. package/index.cjs.default.js +1 -0
  62. package/index.cjs.js +1962 -0
  63. package/index.cjs.mjs +2 -0
  64. package/index.cjs2.js +1064 -0
  65. package/index.cjs3.js +6424 -0
  66. package/index.esm.cjs.js +3406 -0
  67. package/index.esm.css +3624 -3632
  68. package/index.esm.esm.js +3375 -0
  69. package/index.esm.js +1902 -22
  70. package/index.esm2.js +131 -81165
  71. package/index.esm3.js +2 -25
  72. package/inheritsLoose.cjs.js +9 -0
  73. package/inheritsLoose.esm.js +7 -0
  74. package/input.cjs.js +244 -0
  75. package/input.esm.js +220 -0
  76. package/memoize-one.esm.cjs.js +204 -0
  77. package/memoize-one.esm.esm.js +189 -0
  78. package/package.json +57 -5
  79. package/setPrototypeOf.cjs.js +91 -0
  80. package/setPrototypeOf.esm.js +83 -0
  81. package/src/BigCalender.d.ts +2 -0
  82. package/src/CkEditor.d.ts +1 -0
  83. package/src/DataTable.d.ts +2 -0
  84. package/src/DropImage.d.ts +2 -0
  85. package/src/Form.d.ts +3 -0
  86. package/src/FormProvider.d.ts +1 -0
  87. package/src/LiffProvider.d.ts +1 -0
  88. package/src/Tabs.d.ts +1 -0
  89. package/src/index.d.ts +8 -21
  90. package/src/lib/Form/types.d.ts +1 -0
  91. package/styled-components.esm.cjs.js +1621 -0
  92. package/styled-components.esm.esm.js +1615 -0
  93. package/utils.cjs.js +13 -0
  94. package/utils.esm.js +11 -0
package/index.esm.js CHANGED
@@ -1,25 +1,1905 @@
1
- export { B as BaseSwitch, G as BaseTable, N as BigCalender, y as Button, k as CSRDropImage, n as City, C as Controller, P as CustomSelect, m as CustomUpload, q as CustomUploadField, E as DataTable, t as DateRangePicker, O as DnDCalendar, H as Drawer, l as DropDown, D as DropImage, F as FieldLabel, o as Fields, r as Form, Y as FormProvider, I as InputOTPs, V as LiffContext, W as LiffProvider, x as ReactDateRange, J as Regex, R as Row, w as SingleDatePicker, S as Spin, A as StackCards, s as Switch, Q as TabsPanel, T as Textarea, U as UiLibrary, z as buttonVariants, $ as useController, a0 as useFieldArray, Z as useForm, u as useFormContext, a1 as useFormState, X as useLiffContext, a2 as useWatch, v as validateMsg, L as verifyId, K as verifyTaiwanIdIntermediateString, M as verifyTaxId } from './index.esm2.js';
2
- import 'react/jsx-runtime';
3
- import 'react';
4
- import '@iconify/react';
5
- import 'react-dom';
6
- import '@emotion/react';
7
- import '@mui/material';
8
- import '@radix-ui/react-switch';
1
+ import { b as buttonVariants, B as Button } from './input.esm.js';
2
+ export { B as Button, I as Input, b as buttonVariants } from './input.esm.js';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import * as React from 'react';
5
+ import React__default, { useState, useRef, useEffect, useMemo, createContext, useContext, useCallback, forwardRef } from 'react';
6
+ import * as SwitchPrimitives from '@radix-ui/react-switch';
7
+ import { c as cn } from './utils.esm.js';
8
+ import { u as useForm, C as Controller } from './index.esm.esm.js';
9
+ export { B as BaseSwitch, S as Select, d as SelectContent, a as SelectGroup, f as SelectItem, e as SelectLabel, i as SelectScrollDownButton, h as SelectScrollUpButton, g as SelectSeparator, c as SelectTrigger, b as SelectValue } from './baseSwitch.esm.js';
10
+ import format from 'date-fns/format';
11
+ import { Calendar as Calendar$1 } from 'lucide-react';
12
+ import { Icon } from '@iconify/react';
13
+ import { DayPicker } from 'react-day-picker';
14
+ import zhTW from 'date-fns/locale/zh-TW';
15
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
16
+ import { Calendar as Calendar$2, DateRange } from 'react-date-range';
17
+ import * as locales from 'react-date-range/dist/locale/index.js';
18
+ import addDays from 'date-fns/addDays';
19
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
20
+ import { CheckIcon } from '@radix-ui/react-icons';
21
+ import { OTPInput, OTPInputContext } from 'input-otp';
22
+ import '@radix-ui/react-slot';
23
+ import 'class-variance-authority';
9
24
  import 'clsx';
10
25
  import 'tailwind-merge';
26
+ import 'next/dynamic';
27
+ import './setPrototypeOf.esm.js';
28
+ import './memoize-one.esm.esm.js';
29
+ import '@emotion/react';
30
+ import 'react-dom';
31
+ import '@mui/material';
32
+ import './styled-components.esm.esm.js';
33
+ import './_tslib.esm.js';
34
+ import './_commonjsHelpers.esm.js';
35
+ import './Modal.esm.js';
11
36
  import '@radix-ui/react-select';
12
- import '@radix-ui/react-icons';
13
- import 'date-fns/format';
14
- import 'lucide-react';
15
- import '@radix-ui/react-slot';
16
- import 'class-variance-authority';
17
- import 'react-day-picker';
18
- import 'date-fns/locale/zh-TW';
19
- import '@radix-ui/react-popover';
20
- import 'react-date-range';
21
- import 'react-date-range/dist/locale/index.js';
22
- import 'date-fns/addDays';
23
- import 'input-otp';
24
- import '@tanstack/react-table';
25
- import '@radix-ui/react-dropdown-menu';
37
+
38
+ function _define_property$6(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
51
+ function _object_spread$6(target) {
52
+ for(var i = 1; i < arguments.length; i++){
53
+ var source = arguments[i] != null ? arguments[i] : {};
54
+ var ownKeys = Object.keys(source);
55
+ if (typeof Object.getOwnPropertySymbols === "function") {
56
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
57
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
58
+ }));
59
+ }
60
+ ownKeys.forEach(function(key) {
61
+ _define_property$6(target, key, source[key]);
62
+ });
63
+ }
64
+ return target;
65
+ }
66
+ function ownKeys$5(object, enumerableOnly) {
67
+ var keys = Object.keys(object);
68
+ if (Object.getOwnPropertySymbols) {
69
+ var symbols = Object.getOwnPropertySymbols(object);
70
+ if (enumerableOnly) {
71
+ symbols = symbols.filter(function(sym) {
72
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
73
+ });
74
+ }
75
+ keys.push.apply(keys, symbols);
76
+ }
77
+ return keys;
78
+ }
79
+ function _object_spread_props$5(target, source) {
80
+ source = source != null ? source : {};
81
+ if (Object.getOwnPropertyDescriptors) {
82
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
83
+ } else {
84
+ ownKeys$5(Object(source)).forEach(function(key) {
85
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
86
+ });
87
+ }
88
+ return target;
89
+ }
90
+ function _object_without_properties$4(source, excluded) {
91
+ if (source == null) return {};
92
+ var target = _object_without_properties_loose$4(source, excluded);
93
+ var key, i;
94
+ if (Object.getOwnPropertySymbols) {
95
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
96
+ for(i = 0; i < sourceSymbolKeys.length; i++){
97
+ key = sourceSymbolKeys[i];
98
+ if (excluded.indexOf(key) >= 0) continue;
99
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
100
+ target[key] = source[key];
101
+ }
102
+ }
103
+ return target;
104
+ }
105
+ function _object_without_properties_loose$4(source, excluded) {
106
+ if (source == null) return {};
107
+ var target = {};
108
+ var sourceKeys = Object.keys(source);
109
+ var key, i;
110
+ for(i = 0; i < sourceKeys.length; i++){
111
+ key = sourceKeys[i];
112
+ if (excluded.indexOf(key) >= 0) continue;
113
+ target[key] = source[key];
114
+ }
115
+ return target;
116
+ }
117
+ var Switch = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
118
+ var _param_size = _param.size, size = _param_size === void 0 ? "large" : _param_size, color = _param.color, props = _object_without_properties$4(_param, [
119
+ "size",
120
+ "color"
121
+ ]);
122
+ var control = useForm().control;
123
+ var name = props.name, className = props.className;
124
+ var bgColor = color === "blue" ? "data-[state=checked]:bg-blue-500" : color === "red" ? "data-[state=checked]:bg-red-500" : color === "green" ? "data-[state=checked]:bg-green-500" : color === "yellow" ? "data-[state=checked]:bg-yellow-500" : "data-[state=checked]:bg-blue-500";
125
+ var sizeClass = {
126
+ small: {
127
+ root: "h-4 w-7",
128
+ thumb: "h-3 w-3 data-[state=checked]:translate-x-3"
129
+ },
130
+ medium: {
131
+ root: "h-5 w-9",
132
+ thumb: "h-4 w-4 data-[state=checked]:translate-x-4"
133
+ },
134
+ large: {
135
+ root: "h-6 w-11",
136
+ thumb: "h-5 w-5 data-[state=checked]:translate-x-5"
137
+ }
138
+ };
139
+ return /*#__PURE__*/ jsx("div", {
140
+ className: [
141
+ "h-24 w-full",
142
+ className
143
+ ].join(" "),
144
+ children: /*#__PURE__*/ jsx(Controller, {
145
+ name: name || "",
146
+ control: control,
147
+ render: function(param) {
148
+ param.field;
149
+ return /*#__PURE__*/ jsx(SwitchPrimitives.Root, _object_spread_props$5(_object_spread$6({
150
+ className: cn("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50", bgColor, sizeClass[size].root, "data-[state=unchecked]:bg-input")
151
+ }, props), {
152
+ ref: ref,
153
+ children: /*#__PURE__*/ jsx(SwitchPrimitives.Thumb, {
154
+ className: cn("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0", sizeClass[size].thumb)
155
+ })
156
+ }));
157
+ }
158
+ })
159
+ });
160
+ });
161
+
162
+ function _define_property$5(obj, key, value) {
163
+ if (key in obj) {
164
+ Object.defineProperty(obj, key, {
165
+ value: value,
166
+ enumerable: true,
167
+ configurable: true,
168
+ writable: true
169
+ });
170
+ } else {
171
+ obj[key] = value;
172
+ }
173
+ return obj;
174
+ }
175
+ function _extends$1() {
176
+ _extends$1 = Object.assign || function(target) {
177
+ for(var i = 1; i < arguments.length; i++){
178
+ var source = arguments[i];
179
+ for(var key in source){
180
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
181
+ target[key] = source[key];
182
+ }
183
+ }
184
+ }
185
+ return target;
186
+ };
187
+ return _extends$1.apply(this, arguments);
188
+ }
189
+ function _object_destructuring_empty$1(o) {
190
+ if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
191
+ return o;
192
+ }
193
+ function _object_spread$5(target) {
194
+ for(var i = 1; i < arguments.length; i++){
195
+ var source = arguments[i] != null ? arguments[i] : {};
196
+ var ownKeys = Object.keys(source);
197
+ if (typeof Object.getOwnPropertySymbols === "function") {
198
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
199
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
200
+ }));
201
+ }
202
+ ownKeys.forEach(function(key) {
203
+ _define_property$5(target, key, source[key]);
204
+ });
205
+ }
206
+ return target;
207
+ }
208
+ function ownKeys$4(object, enumerableOnly) {
209
+ var keys = Object.keys(object);
210
+ if (Object.getOwnPropertySymbols) {
211
+ var symbols = Object.getOwnPropertySymbols(object);
212
+ if (enumerableOnly) {
213
+ symbols = symbols.filter(function(sym) {
214
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
215
+ });
216
+ }
217
+ keys.push.apply(keys, symbols);
218
+ }
219
+ return keys;
220
+ }
221
+ function _object_spread_props$4(target, source) {
222
+ source = source != null ? source : {};
223
+ if (Object.getOwnPropertyDescriptors) {
224
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
225
+ } else {
226
+ ownKeys$4(Object(source)).forEach(function(key) {
227
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
228
+ });
229
+ }
230
+ return target;
231
+ }
232
+ function _object_without_properties$3(source, excluded) {
233
+ if (source == null) return {};
234
+ var target = _object_without_properties_loose$3(source, excluded);
235
+ var key, i;
236
+ if (Object.getOwnPropertySymbols) {
237
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
238
+ for(i = 0; i < sourceSymbolKeys.length; i++){
239
+ key = sourceSymbolKeys[i];
240
+ if (excluded.indexOf(key) >= 0) continue;
241
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
242
+ target[key] = source[key];
243
+ }
244
+ }
245
+ return target;
246
+ }
247
+ function _object_without_properties_loose$3(source, excluded) {
248
+ if (source == null) return {};
249
+ var target = {};
250
+ var sourceKeys = Object.keys(source);
251
+ var key, i;
252
+ for(i = 0; i < sourceKeys.length; i++){
253
+ key = sourceKeys[i];
254
+ if (excluded.indexOf(key) >= 0) continue;
255
+ target[key] = source[key];
256
+ }
257
+ return target;
258
+ }
259
+ function Calendar(_param) {
260
+ var className = _param.className, classNames = _param.classNames, _param_showOutsideDays = _param.showOutsideDays, showOutsideDays = _param_showOutsideDays === void 0 ? true : _param_showOutsideDays, props = _object_without_properties$3(_param, [
261
+ "className",
262
+ "classNames",
263
+ "showOutsideDays"
264
+ ]);
265
+ return /*#__PURE__*/ jsx(DayPicker, _object_spread_props$4(_object_spread$5({
266
+ showOutsideDays: showOutsideDays,
267
+ className: cn("p-3", className),
268
+ classNames: _object_spread$5({
269
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
270
+ month: "space-y-4",
271
+ caption: "flex justify-center pt-1 relative items-center",
272
+ caption_label: "text-sm font-medium",
273
+ nav: "space-x-1 flex items-center",
274
+ nav_button: cn(buttonVariants({
275
+ variant: "outline"
276
+ }), "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),
277
+ nav_button_previous: "absolute left-1",
278
+ nav_button_next: "absolute right-1",
279
+ table: "w-full border-collapse space-y-1",
280
+ head_row: "flex",
281
+ head_cell: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
282
+ row: "flex w-full mt-2",
283
+ cell: cn("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md", props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md"),
284
+ day: cn(buttonVariants({
285
+ variant: "ghost"
286
+ }), "h-8 w-8 p-0 font-normal aria-selected:opacity-100"),
287
+ day_range_start: "day-range-start",
288
+ day_range_end: "day-range-end",
289
+ day_selected: "bg-[#000] text-[#fff] hover:bg-[#000] hover:text-[#fff] focus:bg-[#000] focus:text-[#fff]",
290
+ day_today: "bg-accent text-accent-foreground",
291
+ day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
292
+ day_disabled: "text-muted-foreground opacity-50",
293
+ day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
294
+ day_hidden: "invisible"
295
+ }, classNames),
296
+ components: {
297
+ IconLeft: function(_param) {
298
+ _extends$1({}, _object_destructuring_empty$1(_param));
299
+ return /*#__PURE__*/ jsx(Icon, {
300
+ icon: "heroicons-solid:arrow-left",
301
+ width: "1rem",
302
+ height: "1rem"
303
+ });
304
+ },
305
+ IconRight: function(_param) {
306
+ _extends$1({}, _object_destructuring_empty$1(_param));
307
+ return /*#__PURE__*/ jsx(Icon, {
308
+ icon: "heroicons-solid:arrow-right",
309
+ width: "1rem",
310
+ height: "1rem"
311
+ });
312
+ }
313
+ }
314
+ }, props), {
315
+ locale: zhTW
316
+ }));
317
+ }
318
+ Calendar.displayName = "Calendar";
319
+
320
+ function _define_property$4(obj, key, value) {
321
+ if (key in obj) {
322
+ Object.defineProperty(obj, key, {
323
+ value: value,
324
+ enumerable: true,
325
+ configurable: true,
326
+ writable: true
327
+ });
328
+ } else {
329
+ obj[key] = value;
330
+ }
331
+ return obj;
332
+ }
333
+ function _object_spread$4(target) {
334
+ for(var i = 1; i < arguments.length; i++){
335
+ var source = arguments[i] != null ? arguments[i] : {};
336
+ var ownKeys = Object.keys(source);
337
+ if (typeof Object.getOwnPropertySymbols === "function") {
338
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
339
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
340
+ }));
341
+ }
342
+ ownKeys.forEach(function(key) {
343
+ _define_property$4(target, key, source[key]);
344
+ });
345
+ }
346
+ return target;
347
+ }
348
+ function _object_without_properties$2(source, excluded) {
349
+ if (source == null) return {};
350
+ var target = _object_without_properties_loose$2(source, excluded);
351
+ var key, i;
352
+ if (Object.getOwnPropertySymbols) {
353
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
354
+ for(i = 0; i < sourceSymbolKeys.length; i++){
355
+ key = sourceSymbolKeys[i];
356
+ if (excluded.indexOf(key) >= 0) continue;
357
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
358
+ target[key] = source[key];
359
+ }
360
+ }
361
+ return target;
362
+ }
363
+ function _object_without_properties_loose$2(source, excluded) {
364
+ if (source == null) return {};
365
+ var target = {};
366
+ var sourceKeys = Object.keys(source);
367
+ var key, i;
368
+ for(i = 0; i < sourceKeys.length; i++){
369
+ key = sourceKeys[i];
370
+ if (excluded.indexOf(key) >= 0) continue;
371
+ target[key] = source[key];
372
+ }
373
+ return target;
374
+ }
375
+ var Popover = PopoverPrimitive.Root;
376
+ var PopoverTrigger = PopoverPrimitive.Trigger;
377
+ var PopoverContent = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
378
+ var className = _param.className, _param_align = _param.align, align = _param_align === void 0 ? "center" : _param_align, _param_sideOffset = _param.sideOffset, sideOffset = _param_sideOffset === void 0 ? 4 : _param_sideOffset, props = _object_without_properties$2(_param, [
379
+ "className",
380
+ "align",
381
+ "sideOffset"
382
+ ]);
383
+ return /*#__PURE__*/ jsx(PopoverPrimitive.Portal, {
384
+ children: /*#__PURE__*/ jsx(PopoverPrimitive.Content, _object_spread$4({
385
+ ref: ref,
386
+ align: align,
387
+ sideOffset: sideOffset,
388
+ className: cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className)
389
+ }, props))
390
+ });
391
+ });
392
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
393
+
394
+ function DateRangePicker(param) {
395
+ var className = param.className, inputClassName = param.inputClassName, disable = param.disable, _param_isShowCleanBtn = param.isShowCleanBtn, isShowCleanBtn = _param_isShowCleanBtn === void 0 ? true : _param_isShowCleanBtn, onChange = param.onChange, dates = param.dates, setDates = param.setDates;
396
+ var handleDateChange = function(newDate) {
397
+ if (newDate) {
398
+ setDates(newDate);
399
+ if (onChange) onChange(newDate);
400
+ }
401
+ };
402
+ return /*#__PURE__*/ jsxs("div", {
403
+ className: "flex gap-2 items-center",
404
+ children: [
405
+ /*#__PURE__*/ jsx("div", {
406
+ className: cn("grid gap-2", className, disable ? "pointer-events-none opacity-55" : "pointer-events-auto opacity-100"),
407
+ children: /*#__PURE__*/ jsxs(Popover, {
408
+ children: [
409
+ /*#__PURE__*/ jsx(PopoverTrigger, {
410
+ asChild: true,
411
+ children: /*#__PURE__*/ jsxs(Button, {
412
+ id: "date",
413
+ variant: "outline",
414
+ className: cn("w-[300px] justify-start text-left font-normal", !dates && "text-muted-foreground", inputClassName),
415
+ children: [
416
+ /*#__PURE__*/ jsx(Calendar$1, {
417
+ className: "mr-2 h-4 w-4"
418
+ }),
419
+ (dates === null || dates === void 0 ? void 0 : dates.from) ? dates.to ? /*#__PURE__*/ jsxs(Fragment, {
420
+ children: [
421
+ format(dates.from, "yyyy-MM-dd"),
422
+ " -",
423
+ " ",
424
+ format(dates.to, "yyyy-MM-dd")
425
+ ]
426
+ }) : format(dates.from, "yyyy-MM-dd") : /*#__PURE__*/ jsx("span", {
427
+ children: "請選擇日期"
428
+ })
429
+ ]
430
+ })
431
+ }),
432
+ /*#__PURE__*/ jsx(PopoverContent, {
433
+ className: "w-auto p-0",
434
+ align: "start",
435
+ children: /*#__PURE__*/ jsx(Calendar, {
436
+ initialFocus: true,
437
+ mode: "range",
438
+ defaultMonth: dates === null || dates === void 0 ? void 0 : dates.from,
439
+ selected: dates,
440
+ onSelect: handleDateChange,
441
+ numberOfMonths: 2
442
+ })
443
+ })
444
+ ]
445
+ })
446
+ }),
447
+ isShowCleanBtn && /*#__PURE__*/ jsx(Button, {
448
+ variant: "ghost",
449
+ className: cn("justify-start text-left font-normal"),
450
+ onClick: function() {
451
+ return setDates(undefined);
452
+ },
453
+ children: "清除日期"
454
+ })
455
+ ]
456
+ });
457
+ }
458
+
459
+ function _array_like_to_array$2(arr, len) {
460
+ if (len == null || len > arr.length) len = arr.length;
461
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
462
+ return arr2;
463
+ }
464
+ function _array_with_holes$2(arr) {
465
+ if (Array.isArray(arr)) return arr;
466
+ }
467
+ function _iterable_to_array_limit$2(arr, i) {
468
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
469
+ if (_i == null) return;
470
+ var _arr = [];
471
+ var _n = true;
472
+ var _d = false;
473
+ var _s, _e;
474
+ try {
475
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
476
+ _arr.push(_s.value);
477
+ if (i && _arr.length === i) break;
478
+ }
479
+ } catch (err) {
480
+ _d = true;
481
+ _e = err;
482
+ } finally{
483
+ try {
484
+ if (!_n && _i["return"] != null) _i["return"]();
485
+ } finally{
486
+ if (_d) throw _e;
487
+ }
488
+ }
489
+ return _arr;
490
+ }
491
+ function _non_iterable_rest$2() {
492
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
493
+ }
494
+ function _sliced_to_array$2(arr, i) {
495
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
496
+ }
497
+ function _unsupported_iterable_to_array$2(o, minLen) {
498
+ if (!o) return;
499
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
500
+ var n = Object.prototype.toString.call(o).slice(8, -1);
501
+ if (n === "Object" && o.constructor) n = o.constructor.name;
502
+ if (n === "Map" || n === "Set") return Array.from(n);
503
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
504
+ }
505
+ var SingleDatePicker = function(param) {
506
+ var disable = param.disable, onChange = param.onChange;
507
+ var _useState = _sliced_to_array$2(useState(), 2), date = _useState[0], setDate = _useState[1];
508
+ var handleDate = function(newDate) {
509
+ if (newDate) {
510
+ setDate(newDate);
511
+ if (onChange) onChange(newDate);
512
+ }
513
+ };
514
+ return /*#__PURE__*/ jsx("div", {
515
+ className: cn(disable ? "pointer-events-none opacity-55" : "pointer-events-auto opacity-100"),
516
+ children: /*#__PURE__*/ jsxs(Popover, {
517
+ children: [
518
+ /*#__PURE__*/ jsx(PopoverTrigger, {
519
+ asChild: true,
520
+ children: /*#__PURE__*/ jsxs(Button, {
521
+ variant: "outline",
522
+ className: cn("w-[280px] justify-start text-left font-normal", !date && "text-muted-foreground"),
523
+ children: [
524
+ /*#__PURE__*/ jsx(Calendar$1, {
525
+ className: "mr-2 h-4 w-4"
526
+ }),
527
+ date ? format(date, "yyyy-MM-dd") : /*#__PURE__*/ jsx("span", {
528
+ children: "請選擇日期"
529
+ })
530
+ ]
531
+ })
532
+ }),
533
+ /*#__PURE__*/ jsx(PopoverContent, {
534
+ className: "w-auto p-0",
535
+ children: /*#__PURE__*/ jsx(Calendar, {
536
+ mode: "single",
537
+ selected: date,
538
+ onSelect: handleDate,
539
+ initialFocus: true
540
+ })
541
+ })
542
+ ]
543
+ })
544
+ });
545
+ };
546
+
547
+ function _array_like_to_array$1(arr, len) {
548
+ if (len == null || len > arr.length) len = arr.length;
549
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
550
+ return arr2;
551
+ }
552
+ function _array_with_holes$1(arr) {
553
+ if (Array.isArray(arr)) return arr;
554
+ }
555
+ function _iterable_to_array_limit$1(arr, i) {
556
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
557
+ if (_i == null) return;
558
+ var _arr = [];
559
+ var _n = true;
560
+ var _d = false;
561
+ var _s, _e;
562
+ try {
563
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
564
+ _arr.push(_s.value);
565
+ if (i && _arr.length === i) break;
566
+ }
567
+ } catch (err) {
568
+ _d = true;
569
+ _e = err;
570
+ } finally{
571
+ try {
572
+ if (!_n && _i["return"] != null) _i["return"]();
573
+ } finally{
574
+ if (_d) throw _e;
575
+ }
576
+ }
577
+ return _arr;
578
+ }
579
+ function _non_iterable_rest$1() {
580
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
581
+ }
582
+ function _sliced_to_array$1(arr, i) {
583
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
584
+ }
585
+ function _unsupported_iterable_to_array$1(o, minLen) {
586
+ if (!o) return;
587
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
588
+ var n = Object.prototype.toString.call(o).slice(8, -1);
589
+ if (n === "Object" && o.constructor) n = o.constructor.name;
590
+ if (n === "Map" || n === "Set") return Array.from(n);
591
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
592
+ }
593
+ var ReactDateRange = function(param) {
594
+ var className = param.className, item = param.item, onChange = param.onChange, dates = param.dates, date = param.date;
595
+ var _useState = _sliced_to_array$1(useState("zhTW"), 1), locale = _useState[0];
596
+ var _useState1 = _sliced_to_array$1(useState(""), 2), calendarData = _useState1[0], setCalendarData = _useState1[1];
597
+ var _useState2 = _sliced_to_array$1(useState({
598
+ startDate: new Date(),
599
+ endDate: addDays(new Date(), 7),
600
+ key: "selection"
601
+ }), 2), range = _useState2[0], setRange = _useState2[1];
602
+ var _useState3 = _sliced_to_array$1(useState(false), 2), open = _useState3[0], setOpen = _useState3[1];
603
+ var refOne = useRef(null);
604
+ var hideOnEscape = function(e) {
605
+ if (e.key === "Escape") {
606
+ setOpen(false);
607
+ }
608
+ };
609
+ var hideOnClickOutside = function(e) {
610
+ if (refOne.current && !refOne.current.contains(e.target)) {
611
+ setOpen(false);
612
+ }
613
+ };
614
+ useEffect(function() {
615
+ setCalendarData(date);
616
+ }, [
617
+ date
618
+ ]);
619
+ useEffect(function() {
620
+ if (!dates) return;
621
+ setRange(dates);
622
+ }, [
623
+ dates
624
+ ]);
625
+ useEffect(function() {
626
+ document.addEventListener("keydown", hideOnEscape, true);
627
+ document.addEventListener("click", hideOnClickOutside, true);
628
+ return function() {
629
+ document.removeEventListener("keydown", hideOnEscape, true);
630
+ document.removeEventListener("click", hideOnClickOutside, true);
631
+ };
632
+ }, []);
633
+ var formatDates = function() {
634
+ if (!range) return;
635
+ var startDate = range.startDate, endDate = range.endDate;
636
+ return "".concat(format(startDate, "yyyy-MM-dd"), " ~ ").concat(format(endDate, "yyyy-MM-dd"));
637
+ };
638
+ var formatDate = calendarData ? format(calendarData, (item === null || item === void 0 ? void 0 : item.dateDisplayFormat) || "yyyy-MM-dd") : "";
639
+ return /*#__PURE__*/ jsxs("div", {
640
+ className: [
641
+ className,
642
+ "relative"
643
+ ].join(" "),
644
+ children: [
645
+ (item === null || item === void 0 ? void 0 : item.label) && /*#__PURE__*/ jsx("div", {
646
+ className: "text-gray-700 font-medium mb-2 h-6",
647
+ children: item === null || item === void 0 ? void 0 : item.label
648
+ }),
649
+ /*#__PURE__*/ jsx("input", {
650
+ className: "border-solid border rounded p-2 h-10 w-full timePicker border-gray-300",
651
+ name: item === null || item === void 0 ? void 0 : item.name,
652
+ onClick: function() {
653
+ return setOpen(function(openState) {
654
+ return !openState;
655
+ });
656
+ },
657
+ placeholder: item === null || item === void 0 ? void 0 : item.placeholder,
658
+ value: (item === null || item === void 0 ? void 0 : item.type) === "date" ? formatDate : formatDates(),
659
+ autoComplete: "off"
660
+ }),
661
+ open && /*#__PURE__*/ jsxs("div", {
662
+ className: "absolute top-[72px] left-0 z-50 shadow-md",
663
+ ref: refOne,
664
+ children: [
665
+ open && (item === null || item === void 0 ? void 0 : item.type) === "date" && /*#__PURE__*/ jsx(Calendar$2, {
666
+ data: calendarData,
667
+ locale: locales[locale],
668
+ dateDisplayFormat: item === null || item === void 0 ? void 0 : item.dateDisplayFormat,
669
+ onChange: function(value) {
670
+ setCalendarData(value);
671
+ if (onChange) onChange(value);
672
+ setOpen(false);
673
+ }
674
+ }),
675
+ open && (item === null || item === void 0 ? void 0 : item.type) === "dateRange" && /*#__PURE__*/ jsx(DateRange, {
676
+ editableDateInputs: true,
677
+ onChange: function(value) {
678
+ setRange(value.selection);
679
+ if (onChange) onChange(value.selection);
680
+ },
681
+ ranges: [
682
+ range
683
+ ],
684
+ locale: locales[locale],
685
+ dateDisplayFormat: "yyyy.MM.dd"
686
+ })
687
+ ]
688
+ })
689
+ ]
690
+ });
691
+ };
692
+
693
+ function _define_property$3(obj, key, value) {
694
+ if (key in obj) {
695
+ Object.defineProperty(obj, key, {
696
+ value: value,
697
+ enumerable: true,
698
+ configurable: true,
699
+ writable: true
700
+ });
701
+ } else {
702
+ obj[key] = value;
703
+ }
704
+ return obj;
705
+ }
706
+ function _object_spread$3(target) {
707
+ for(var i = 1; i < arguments.length; i++){
708
+ var source = arguments[i] != null ? arguments[i] : {};
709
+ var ownKeys = Object.keys(source);
710
+ if (typeof Object.getOwnPropertySymbols === "function") {
711
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
712
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
713
+ }));
714
+ }
715
+ ownKeys.forEach(function(key) {
716
+ _define_property$3(target, key, source[key]);
717
+ });
718
+ }
719
+ return target;
720
+ }
721
+ function ownKeys$3(object, enumerableOnly) {
722
+ var keys = Object.keys(object);
723
+ if (Object.getOwnPropertySymbols) {
724
+ var symbols = Object.getOwnPropertySymbols(object);
725
+ if (enumerableOnly) {
726
+ symbols = symbols.filter(function(sym) {
727
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
728
+ });
729
+ }
730
+ keys.push.apply(keys, symbols);
731
+ }
732
+ return keys;
733
+ }
734
+ function _object_spread_props$3(target, source) {
735
+ source = source != null ? source : {};
736
+ if (Object.getOwnPropertyDescriptors) {
737
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
738
+ } else {
739
+ ownKeys$3(Object(source)).forEach(function(key) {
740
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
741
+ });
742
+ }
743
+ return target;
744
+ }
745
+ function _object_without_properties$1(source, excluded) {
746
+ if (source == null) return {};
747
+ var target = _object_without_properties_loose$1(source, excluded);
748
+ var key, i;
749
+ if (Object.getOwnPropertySymbols) {
750
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
751
+ for(i = 0; i < sourceSymbolKeys.length; i++){
752
+ key = sourceSymbolKeys[i];
753
+ if (excluded.indexOf(key) >= 0) continue;
754
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
755
+ target[key] = source[key];
756
+ }
757
+ }
758
+ return target;
759
+ }
760
+ function _object_without_properties_loose$1(source, excluded) {
761
+ if (source == null) return {};
762
+ var target = {};
763
+ var sourceKeys = Object.keys(source);
764
+ var key, i;
765
+ for(i = 0; i < sourceKeys.length; i++){
766
+ key = sourceKeys[i];
767
+ if (excluded.indexOf(key) >= 0) continue;
768
+ target[key] = source[key];
769
+ }
770
+ return target;
771
+ }
772
+ var Checkbox = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
773
+ var className = _param.className, props = _object_without_properties$1(_param, [
774
+ "className"
775
+ ]);
776
+ return /*#__PURE__*/ jsx(CheckboxPrimitive.Root, _object_spread_props$3(_object_spread$3({
777
+ ref: ref,
778
+ className: cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", className)
779
+ }, props), {
780
+ children: /*#__PURE__*/ jsx(CheckboxPrimitive.Indicator, {
781
+ className: cn("flex items-center justify-center text-current"),
782
+ children: /*#__PURE__*/ jsx(CheckIcon, {
783
+ className: "h-4 w-4"
784
+ })
785
+ })
786
+ }));
787
+ });
788
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
789
+
790
+ function _define_property$2(obj, key, value) {
791
+ if (key in obj) {
792
+ Object.defineProperty(obj, key, {
793
+ value: value,
794
+ enumerable: true,
795
+ configurable: true,
796
+ writable: true
797
+ });
798
+ } else {
799
+ obj[key] = value;
800
+ }
801
+ return obj;
802
+ }
803
+ function _extends() {
804
+ _extends = Object.assign || function(target) {
805
+ for(var i = 1; i < arguments.length; i++){
806
+ var source = arguments[i];
807
+ for(var key in source){
808
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
809
+ target[key] = source[key];
810
+ }
811
+ }
812
+ }
813
+ return target;
814
+ };
815
+ return _extends.apply(this, arguments);
816
+ }
817
+ function _object_destructuring_empty(o) {
818
+ if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
819
+ return o;
820
+ }
821
+ function _object_spread$2(target) {
822
+ for(var i = 1; i < arguments.length; i++){
823
+ var source = arguments[i] != null ? arguments[i] : {};
824
+ var ownKeys = Object.keys(source);
825
+ if (typeof Object.getOwnPropertySymbols === "function") {
826
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
827
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
828
+ }));
829
+ }
830
+ ownKeys.forEach(function(key) {
831
+ _define_property$2(target, key, source[key]);
832
+ });
833
+ }
834
+ return target;
835
+ }
836
+ function ownKeys$2(object, enumerableOnly) {
837
+ var keys = Object.keys(object);
838
+ if (Object.getOwnPropertySymbols) {
839
+ var symbols = Object.getOwnPropertySymbols(object);
840
+ if (enumerableOnly) {
841
+ symbols = symbols.filter(function(sym) {
842
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
843
+ });
844
+ }
845
+ keys.push.apply(keys, symbols);
846
+ }
847
+ return keys;
848
+ }
849
+ function _object_spread_props$2(target, source) {
850
+ source = source != null ? source : {};
851
+ if (Object.getOwnPropertyDescriptors) {
852
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
853
+ } else {
854
+ ownKeys$2(Object(source)).forEach(function(key) {
855
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
856
+ });
857
+ }
858
+ return target;
859
+ }
860
+ function _object_without_properties(source, excluded) {
861
+ if (source == null) return {};
862
+ var target = _object_without_properties_loose(source, excluded);
863
+ var key, i;
864
+ if (Object.getOwnPropertySymbols) {
865
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
866
+ for(i = 0; i < sourceSymbolKeys.length; i++){
867
+ key = sourceSymbolKeys[i];
868
+ if (excluded.indexOf(key) >= 0) continue;
869
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
870
+ target[key] = source[key];
871
+ }
872
+ }
873
+ return target;
874
+ }
875
+ function _object_without_properties_loose(source, excluded) {
876
+ if (source == null) return {};
877
+ var target = {};
878
+ var sourceKeys = Object.keys(source);
879
+ var key, i;
880
+ for(i = 0; i < sourceKeys.length; i++){
881
+ key = sourceKeys[i];
882
+ if (excluded.indexOf(key) >= 0) continue;
883
+ target[key] = source[key];
884
+ }
885
+ return target;
886
+ }
887
+ var InputOTP = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
888
+ var className = _param.className, containerClassName = _param.containerClassName, props = _object_without_properties(_param, [
889
+ "className",
890
+ "containerClassName"
891
+ ]);
892
+ return /*#__PURE__*/ jsx(OTPInput, _object_spread$2({
893
+ ref: ref,
894
+ containerClassName: cn("flex items-center gap-2 has-[:disabled]:opacity-50", containerClassName),
895
+ className: cn("disabled:cursor-not-allowed", className)
896
+ }, props));
897
+ });
898
+ var InputOTPGroup = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
899
+ var className = _param.className, props = _object_without_properties(_param, [
900
+ "className"
901
+ ]);
902
+ return /*#__PURE__*/ jsx("div", _object_spread$2({
903
+ ref: ref,
904
+ className: cn("flex items-center", className)
905
+ }, props));
906
+ });
907
+ var InputOTPSlot = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
908
+ var index = _param.index, className = _param.className, ringClassName = _param.ringClassName, props = _object_without_properties(_param, [
909
+ "index",
910
+ "className",
911
+ "ringClassName"
912
+ ]);
913
+ var inputOTPContext = React.useContext(OTPInputContext);
914
+ var _inputOTPContext_slots_index = inputOTPContext.slots[index], char = _inputOTPContext_slots_index.char, hasFakeCaret = _inputOTPContext_slots_index.hasFakeCaret, isActive = _inputOTPContext_slots_index.isActive;
915
+ return /*#__PURE__*/ jsxs("div", _object_spread_props$2(_object_spread$2({
916
+ ref: ref,
917
+ className: cn("relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md", isActive && "z-10 ring-1 ".concat(ringClassName), className)
918
+ }, props), {
919
+ children: [
920
+ char,
921
+ hasFakeCaret && /*#__PURE__*/ jsx("div", {
922
+ className: "pointer-events-none absolute inset-0 flex items-center justify-center",
923
+ children: /*#__PURE__*/ jsx("div", {
924
+ className: "h-4 w-px animate-caret-blink bg-foreground duration-1000"
925
+ })
926
+ })
927
+ ]
928
+ }));
929
+ });
930
+ var InputOTPSeparator = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
931
+ var props = _extends({}, _object_destructuring_empty(_param));
932
+ return /*#__PURE__*/ jsx("div", _object_spread_props$2(_object_spread$2({
933
+ ref: ref,
934
+ role: "separator"
935
+ }, props), {
936
+ children: /*#__PURE__*/ jsx(Icon, {
937
+ icon: "octicon:dash-16"
938
+ })
939
+ }));
940
+ });
941
+
942
+ function Spin(props) {
943
+ var show = props.show, _props_overlayBackground = props.overlayBackground, overlayBackground = _props_overlayBackground === void 0 ? "bg-[#00000055]" : _props_overlayBackground;
944
+ return show ? /*#__PURE__*/ jsx("div", {
945
+ className: [
946
+ "fixed flex justify-center items-center w-full h-full left-0 top-0 z-[9999] overflow-hidden",
947
+ overlayBackground
948
+ ].join(" "),
949
+ children: /*#__PURE__*/ jsx("div", {
950
+ className: "top-2/4 left-2/4",
951
+ children: /*#__PURE__*/ jsx("div", {
952
+ className: "w-10 h-10 rounded-full border-4 border-solid border-[#ffffff33] border-t-[#dbdbdb] animate-spin"
953
+ })
954
+ })
955
+ }) : null;
956
+ }
957
+
958
+ var COLORS = [
959
+ "blue",
960
+ "orange",
961
+ "yellow",
962
+ "red",
963
+ "purple",
964
+ "amber",
965
+ "lime",
966
+ "green",
967
+ "emerald",
968
+ "teal",
969
+ "cyan",
970
+ "sky",
971
+ "violet",
972
+ "indigo",
973
+ "purple",
974
+ "fuchsia",
975
+ "pink",
976
+ "rose"
977
+ ];
978
+ var DEFAULT_THEME = "blue";
979
+ var THEME_DATA = {
980
+ bg: {
981
+ blue: "bg-blue-500",
982
+ orange: "bg-orange-500",
983
+ yellow: "bg-yellow-500",
984
+ red: "bg-red-500",
985
+ purple: "bg-purple-500",
986
+ amber: "bg-amber-500",
987
+ lime: "bg-lime-500",
988
+ green: "bg-green-500",
989
+ emerald: "bg-emerald-500",
990
+ teal: "bg-teal-500",
991
+ cyan: "bg-cyan-500",
992
+ sky: "bg-sky-500",
993
+ indigo: "bg-indigo-500",
994
+ violet: "bg-violet-500",
995
+ fuchsia: "bg-fuchsia-500",
996
+ pink: "bg-pink-500",
997
+ rose: "bg-rose-500"
998
+ },
999
+ bgHover: {
1000
+ blue: "hover:bg-blue-100",
1001
+ orange: "hover:bg-orange-100",
1002
+ yellow: "hover:bg-yellow-100",
1003
+ red: "hover:bg-red-100",
1004
+ purple: "hover:bg-purple-100",
1005
+ amber: "hover:bg-amber-100",
1006
+ lime: "hover:bg-lime-100",
1007
+ green: "hover:bg-green-100",
1008
+ emerald: "hover:bg-emerald-100",
1009
+ teal: "hover:bg-teal-100",
1010
+ cyan: "hover:bg-cyan-100",
1011
+ sky: "hover:bg-sky-100",
1012
+ indigo: "hover:bg-indigo-100",
1013
+ violet: "hover:bg-violet-100",
1014
+ fuchsia: "hover:bg-fuchsia-100",
1015
+ pink: "hover:bg-pink-100",
1016
+ rose: "hover:bg-rose-100"
1017
+ },
1018
+ ring: {
1019
+ blue: "focus:ring-blue-500/20",
1020
+ orange: "focus:ring-orange-500/20",
1021
+ yellow: "focus:ring-yellow-500/20",
1022
+ red: "focus:ring-red-500/20",
1023
+ purple: "focus:ring-purple-500/20",
1024
+ amber: "focus:ring-amber-500/20",
1025
+ lime: "focus:ring-lime-500/20",
1026
+ green: "focus:ring-green-500/20",
1027
+ emerald: "focus:ring-emerald-500/20",
1028
+ teal: "focus:ring-teal-500/20",
1029
+ cyan: "focus:ring-cyan-500/20",
1030
+ sky: "focus:ring-sky-500/20",
1031
+ indigo: "focus:ring-indigo-500/20",
1032
+ violet: "focus:ring-violet-500/20",
1033
+ fuchsia: "focus:ring-fuchsia-500/20",
1034
+ pink: "focus:ring-pink-500/20",
1035
+ rose: "focus:ring-rose-500/20"
1036
+ },
1037
+ borderFocus: {
1038
+ blue: "focus:border-blue-500",
1039
+ orange: "focus:border-orange-500",
1040
+ yellow: "focus:border-yellow-500",
1041
+ red: "focus:border-red-500",
1042
+ purple: "focus:border-purple-500",
1043
+ amber: "focus:border-amber-500",
1044
+ lime: "focus:border-lime-500",
1045
+ green: "focus:border-green-500",
1046
+ emerald: "focus:border-emerald-500",
1047
+ teal: "focus:border-teal-500",
1048
+ cyan: "focus:border-cyan-500",
1049
+ sky: "focus:border-sky-500",
1050
+ indigo: "focus:border-indigo-500",
1051
+ violet: "focus:border-violet-500",
1052
+ fuchsia: "focus:border-fuchsia-500",
1053
+ pink: "focus:border-pink-500",
1054
+ rose: "focus:border-rose-500"
1055
+ },
1056
+ text: {
1057
+ blue: "text-blue-500",
1058
+ orange: "text-orange-500",
1059
+ yellow: "text-yellow-500",
1060
+ red: "text-red-500",
1061
+ purple: "text-purple-500",
1062
+ amber: "text-amber-500",
1063
+ lime: "text-lime-500",
1064
+ green: "text-green-500",
1065
+ emerald: "text-emerald-500",
1066
+ teal: "text-teal-500",
1067
+ cyan: "text-cyan-500",
1068
+ sky: "text-sky-500",
1069
+ indigo: "text-indigo-500",
1070
+ violet: "text-violet-500",
1071
+ fuchsia: "text-fuchsia-500",
1072
+ pink: "text-pink-500",
1073
+ rose: "text-rose-500"
1074
+ },
1075
+ textHover: {
1076
+ blue: "hover:text-blue-500",
1077
+ orange: "hover:text-orange-500",
1078
+ yellow: "hover:text-yellow-500",
1079
+ red: "hover:text-red-500",
1080
+ purple: "hover:text-purple-500",
1081
+ amber: "hover:text-amber-500",
1082
+ lime: "hover:text-lime-500",
1083
+ green: "hover:text-green-500",
1084
+ emerald: "hover:text-emerald-500",
1085
+ teal: "hover:text-teal-500",
1086
+ cyan: "hover:text-cyan-500",
1087
+ sky: "hover:text-sky-500",
1088
+ indigo: "hover:text-indigo-500",
1089
+ violet: "hover:text-violet-500",
1090
+ fuchsia: "hover:text-fuchsia-500",
1091
+ pink: "hover:text-pink-500",
1092
+ rose: "hover:text-rose-500"
1093
+ }
1094
+ };
1095
+
1096
+ function useOnClickOutside(ref, handler) {
1097
+ useEffect(function() {
1098
+ var listener = function(event) {
1099
+ if (!ref.current || ref.current.contains(event.target)) {
1100
+ return;
1101
+ }
1102
+ handler(event);
1103
+ };
1104
+ document.addEventListener("mousedown", listener);
1105
+ document.addEventListener("touchstart", listener);
1106
+ return function() {
1107
+ document.removeEventListener("mousedown", listener);
1108
+ document.removeEventListener("touchstart", listener);
1109
+ };
1110
+ }, [
1111
+ ref,
1112
+ handler
1113
+ ]);
1114
+ }
1115
+
1116
+ var CloseIcon = function(param) {
1117
+ var _param_className = param.className, className = _param_className === void 0 ? "" : _param_className;
1118
+ return /*#__PURE__*/ jsx("svg", {
1119
+ className: className,
1120
+ fill: "currentColor",
1121
+ viewBox: "0 0 20 20",
1122
+ xmlns: "http://www.w3.org/2000/svg",
1123
+ children: /*#__PURE__*/ jsx("path", {
1124
+ fillRule: "evenodd",
1125
+ d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
1126
+ clipRule: "evenodd"
1127
+ })
1128
+ });
1129
+ };
1130
+ var ChevronIcon = function(param) {
1131
+ var _param_className = param.className, className = _param_className === void 0 ? "" : _param_className;
1132
+ return /*#__PURE__*/ jsx("svg", {
1133
+ className: className,
1134
+ fill: "currentColor",
1135
+ viewBox: "0 0 20 20",
1136
+ xmlns: "http://www.w3.org/2000/svg",
1137
+ children: /*#__PURE__*/ jsx("path", {
1138
+ fillRule: "evenodd",
1139
+ d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",
1140
+ clipRule: "evenodd"
1141
+ })
1142
+ });
1143
+ };
1144
+ var SearchIcon = function(param) {
1145
+ var _param_className = param.className, className = _param_className === void 0 ? "" : _param_className;
1146
+ return /*#__PURE__*/ jsx("svg", {
1147
+ className: className,
1148
+ fill: "none",
1149
+ stroke: "currentColor",
1150
+ viewBox: "0 0 24 24",
1151
+ xmlns: "http://www.w3.org/2000/svg",
1152
+ children: /*#__PURE__*/ jsx("path", {
1153
+ strokeLinecap: "round",
1154
+ strokeLinejoin: "round",
1155
+ strokeWidth: 2,
1156
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
1157
+ })
1158
+ });
1159
+ };
1160
+
1161
+ var SelectContext = /*#__PURE__*/ createContext({
1162
+ value: null,
1163
+ handleValueChange: function(selected) {
1164
+ console.log("selected:", selected);
1165
+ },
1166
+ formatGroupLabel: null,
1167
+ formatOptionLabel: null,
1168
+ classNames: undefined
1169
+ });
1170
+ var useSelectContext = function() {
1171
+ return useContext(SelectContext);
1172
+ };
1173
+ var SelectProvider = function(param) {
1174
+ var value = param.value, handleValueChange = param.handleValueChange, otherData = param.otherData, children = param.children;
1175
+ var store = useMemo(function() {
1176
+ return {
1177
+ value: value,
1178
+ handleValueChange: handleValueChange,
1179
+ formatGroupLabel: otherData && typeof otherData.formatGroupLabel === "function" ? otherData.formatGroupLabel : null,
1180
+ formatOptionLabel: otherData && typeof otherData.formatOptionLabel === "function" ? otherData.formatOptionLabel : null,
1181
+ classNames: (otherData === null || otherData === void 0 ? void 0 : otherData.classNames) || undefined
1182
+ };
1183
+ }, [
1184
+ handleValueChange,
1185
+ otherData,
1186
+ value
1187
+ ]);
1188
+ return /*#__PURE__*/ jsx(SelectContext.Provider, {
1189
+ value: store,
1190
+ children: children
1191
+ });
1192
+ };
1193
+
1194
+ var DisabledItem = function(param) {
1195
+ var children = param.children;
1196
+ var classNames = useContext(SelectContext).classNames;
1197
+ return /*#__PURE__*/ jsx("div", {
1198
+ className: classNames && classNames.listDisabledItem ? classNames.listDisabledItem : "px-2 py-2 cursor-not-allowed truncate text-gray-400 select-none",
1199
+ children: children
1200
+ });
1201
+ };
1202
+
1203
+ function _define_property$1(obj, key, value) {
1204
+ if (key in obj) {
1205
+ Object.defineProperty(obj, key, {
1206
+ value: value,
1207
+ enumerable: true,
1208
+ configurable: true,
1209
+ writable: true
1210
+ });
1211
+ } else {
1212
+ obj[key] = value;
1213
+ }
1214
+ return obj;
1215
+ }
1216
+ function _object_spread$1(target) {
1217
+ for(var i = 1; i < arguments.length; i++){
1218
+ var source = arguments[i] != null ? arguments[i] : {};
1219
+ var ownKeys = Object.keys(source);
1220
+ if (typeof Object.getOwnPropertySymbols === "function") {
1221
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1222
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1223
+ }));
1224
+ }
1225
+ ownKeys.forEach(function(key) {
1226
+ _define_property$1(target, key, source[key]);
1227
+ });
1228
+ }
1229
+ return target;
1230
+ }
1231
+ function ownKeys$1(object, enumerableOnly) {
1232
+ var keys = Object.keys(object);
1233
+ if (Object.getOwnPropertySymbols) {
1234
+ var symbols = Object.getOwnPropertySymbols(object);
1235
+ if (enumerableOnly) {
1236
+ symbols = symbols.filter(function(sym) {
1237
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1238
+ });
1239
+ }
1240
+ keys.push.apply(keys, symbols);
1241
+ }
1242
+ return keys;
1243
+ }
1244
+ function _object_spread_props$1(target, source) {
1245
+ source = source != null ? source : {};
1246
+ if (Object.getOwnPropertyDescriptors) {
1247
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1248
+ } else {
1249
+ ownKeys$1(Object(source)).forEach(function(key) {
1250
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1251
+ });
1252
+ }
1253
+ return target;
1254
+ }
1255
+ var Item = function(param) {
1256
+ var item = param.item, primaryColor = param.primaryColor;
1257
+ var _useSelectContext = useSelectContext(), classNames = _useSelectContext.classNames, value = _useSelectContext.value, handleValueChange = _useSelectContext.handleValueChange, formatOptionLabel = _useSelectContext.formatOptionLabel;
1258
+ var isSelected = useMemo(function() {
1259
+ return value !== null && !Array.isArray(value) && value.value === item.value;
1260
+ }, [
1261
+ item.value,
1262
+ value
1263
+ ]);
1264
+ var textHoverColor = useMemo(function() {
1265
+ if (COLORS.includes(primaryColor)) {
1266
+ return THEME_DATA.textHover[primaryColor];
1267
+ }
1268
+ return THEME_DATA.textHover[DEFAULT_THEME];
1269
+ }, [
1270
+ primaryColor
1271
+ ]);
1272
+ var bgColor = useMemo(function() {
1273
+ if (COLORS.includes(primaryColor)) {
1274
+ return THEME_DATA.bg[primaryColor];
1275
+ }
1276
+ return THEME_DATA.bg[DEFAULT_THEME];
1277
+ }, [
1278
+ primaryColor
1279
+ ]);
1280
+ var bgHoverColor = useMemo(function() {
1281
+ if (COLORS.includes(primaryColor)) {
1282
+ return THEME_DATA.bgHover[primaryColor];
1283
+ }
1284
+ return THEME_DATA.bgHover[DEFAULT_THEME];
1285
+ }, [
1286
+ primaryColor
1287
+ ]);
1288
+ var getItemClass = useCallback(function() {
1289
+ var baseClass = "block transition duration-200 px-2 py-2 cursor-pointer select-none truncate rounded";
1290
+ var selectedClass = isSelected ? "text-white ".concat(bgColor) : "text-gray-500 ".concat(bgHoverColor, " ").concat(textHoverColor);
1291
+ return classNames && classNames.listItem ? classNames.listItem({
1292
+ isSelected: isSelected
1293
+ }) : "".concat(baseClass, " ").concat(selectedClass);
1294
+ }, [
1295
+ bgColor,
1296
+ bgHoverColor,
1297
+ classNames,
1298
+ isSelected,
1299
+ textHoverColor
1300
+ ]);
1301
+ return /*#__PURE__*/ jsx(Fragment, {
1302
+ children: formatOptionLabel ? /*#__PURE__*/ jsx("div", {
1303
+ onClick: function() {
1304
+ return handleValueChange(item);
1305
+ },
1306
+ children: formatOptionLabel(_object_spread_props$1(_object_spread$1({}, item), {
1307
+ isSelected: isSelected
1308
+ }))
1309
+ }) : /*#__PURE__*/ jsx(Fragment, {
1310
+ children: item.disabled ? /*#__PURE__*/ jsx(DisabledItem, {
1311
+ children: item.label
1312
+ }) : /*#__PURE__*/ jsx("li", {
1313
+ tabIndex: 0,
1314
+ onKeyDown: function(e) {
1315
+ if (e.key === " " || e.key === "Enter") {
1316
+ handleValueChange(item);
1317
+ }
1318
+ },
1319
+ "aria-selected": isSelected,
1320
+ role: "option",
1321
+ onClick: function() {
1322
+ return handleValueChange(item);
1323
+ },
1324
+ className: getItemClass(),
1325
+ children: item.label
1326
+ })
1327
+ })
1328
+ });
1329
+ };
1330
+
1331
+ var GroupItem = function(param) {
1332
+ var item = param.item, primaryColor = param.primaryColor;
1333
+ var _useSelectContext = useSelectContext(), classNames = _useSelectContext.classNames, formatGroupLabel = _useSelectContext.formatGroupLabel;
1334
+ return /*#__PURE__*/ jsx(Fragment, {
1335
+ children: item.options.length > 0 && /*#__PURE__*/ jsxs(Fragment, {
1336
+ children: [
1337
+ formatGroupLabel ? /*#__PURE__*/ jsx(Fragment, {
1338
+ children: formatGroupLabel(item)
1339
+ }) : /*#__PURE__*/ jsx("div", {
1340
+ className: (classNames === null || classNames === void 0 ? void 0 : classNames.listGroupLabel) ? classNames.listGroupLabel : "pr-2 py-2 cursor-default select-none truncate font-bold text-gray-700",
1341
+ children: item.label
1342
+ }),
1343
+ item.options.map(function(item, index) {
1344
+ return /*#__PURE__*/ jsx(Item, {
1345
+ primaryColor: primaryColor,
1346
+ item: item
1347
+ }, index);
1348
+ })
1349
+ ]
1350
+ })
1351
+ });
1352
+ };
1353
+
1354
+ var Options = function(param) {
1355
+ var list = param.list, noOptionsMessage = param.noOptionsMessage, text = param.text, isMultiple = param.isMultiple, value = param.value, _param_primaryColor = param.primaryColor, primaryColor = _param_primaryColor === void 0 ? DEFAULT_THEME : _param_primaryColor;
1356
+ var classNames = useContext(SelectContext).classNames;
1357
+ var filterByText = useCallback(function() {
1358
+ var filterItem = function(item) {
1359
+ return item.label.toLowerCase().indexOf(text.toLowerCase()) > -1;
1360
+ };
1361
+ var result = list.map(function(item) {
1362
+ if ("options" in item) {
1363
+ return {
1364
+ label: item.label,
1365
+ options: item.options.filter(filterItem)
1366
+ };
1367
+ }
1368
+ return item;
1369
+ });
1370
+ result = result.filter(function(item) {
1371
+ if ("options" in item) {
1372
+ return item.options.length > 0;
1373
+ }
1374
+ return filterItem(item);
1375
+ });
1376
+ return result;
1377
+ }, [
1378
+ text,
1379
+ list
1380
+ ]);
1381
+ var removeValues = useCallback(function(array) {
1382
+ if (!isMultiple) {
1383
+ return array;
1384
+ }
1385
+ if (Array.isArray(value)) {
1386
+ var valueId = value.map(function(item) {
1387
+ return item.value;
1388
+ });
1389
+ var filterItem = function(item) {
1390
+ return !valueId.includes(item.value);
1391
+ };
1392
+ var newArray = array.map(function(item) {
1393
+ if ("options" in item) {
1394
+ return {
1395
+ label: item.label,
1396
+ options: item.options.filter(filterItem)
1397
+ };
1398
+ }
1399
+ return item;
1400
+ });
1401
+ newArray = newArray.filter(function(item) {
1402
+ if ("options" in item) {
1403
+ return item.options.length > 0;
1404
+ } else {
1405
+ return filterItem(item);
1406
+ }
1407
+ });
1408
+ return newArray;
1409
+ }
1410
+ return array;
1411
+ }, [
1412
+ isMultiple,
1413
+ value
1414
+ ]);
1415
+ var filterResult = useMemo(function() {
1416
+ return removeValues(filterByText());
1417
+ }, [
1418
+ filterByText,
1419
+ removeValues
1420
+ ]);
1421
+ return /*#__PURE__*/ jsxs("div", {
1422
+ role: "options",
1423
+ className: classNames && classNames.list ? classNames.list : "max-h-72 overflow-y-auto",
1424
+ children: [
1425
+ filterResult.map(function(item, index) {
1426
+ return /*#__PURE__*/ jsx(React__default.Fragment, {
1427
+ children: "options" in item ? /*#__PURE__*/ jsxs(Fragment, {
1428
+ children: [
1429
+ /*#__PURE__*/ jsx("div", {
1430
+ className: "px-2.5",
1431
+ children: /*#__PURE__*/ jsx(GroupItem, {
1432
+ primaryColor: primaryColor || DEFAULT_THEME,
1433
+ item: item
1434
+ })
1435
+ }),
1436
+ index + 1 < filterResult.length && /*#__PURE__*/ jsx("hr", {
1437
+ className: "my-1"
1438
+ })
1439
+ ]
1440
+ }) : /*#__PURE__*/ jsx("div", {
1441
+ className: "px-2.5",
1442
+ children: /*#__PURE__*/ jsx(Item, {
1443
+ primaryColor: primaryColor || DEFAULT_THEME,
1444
+ item: item
1445
+ })
1446
+ })
1447
+ }, index);
1448
+ }),
1449
+ filterResult.length === 0 && /*#__PURE__*/ jsx(DisabledItem, {
1450
+ children: noOptionsMessage
1451
+ })
1452
+ ]
1453
+ });
1454
+ };
1455
+
1456
+ var SearchInput = /*#__PURE__*/ forwardRef(function SearchInput(param, ref) {
1457
+ var _param_placeholder = param.placeholder, placeholder = _param_placeholder === void 0 ? "" : _param_placeholder, _param_value = param.value, value = _param_value === void 0 ? "" : _param_value, onChange = param.onChange, _param_name = param.name, name = _param_name === void 0 ? "" : _param_name;
1458
+ var classNames = useContext(SelectContext).classNames;
1459
+ return /*#__PURE__*/ jsxs("div", {
1460
+ className: classNames && classNames.searchContainer ? classNames.searchContainer : "relative py-1 px-2.5",
1461
+ children: [
1462
+ /*#__PURE__*/ jsx(SearchIcon, {
1463
+ className: classNames && classNames.searchIcon ? classNames.searchIcon : "absolute w-5 h-5 mt-2.5 pb-0.5 ml-2 text-gray-500"
1464
+ }),
1465
+ /*#__PURE__*/ jsx("input", {
1466
+ ref: ref,
1467
+ className: classNames && classNames.searchBox ? classNames.searchBox : "w-full py-2 pl-8 text-sm text-gray-500 bg-gray-100 border border-gray-200 rounded focus:border-gray-200 focus:ring-0 focus:outline-none",
1468
+ type: "text",
1469
+ placeholder: placeholder,
1470
+ value: value,
1471
+ onChange: onChange,
1472
+ name: name
1473
+ })
1474
+ ]
1475
+ });
1476
+ });
1477
+
1478
+ var Spinner = function(param) {
1479
+ var _param_primaryColor = param.primaryColor, primaryColor = _param_primaryColor === void 0 ? DEFAULT_THEME : _param_primaryColor;
1480
+ var spinnerColor = useMemo(function() {
1481
+ if (COLORS.includes(primaryColor)) {
1482
+ return THEME_DATA.text[primaryColor];
1483
+ }
1484
+ return THEME_DATA.text[DEFAULT_THEME];
1485
+ }, [
1486
+ primaryColor
1487
+ ]);
1488
+ return /*#__PURE__*/ jsxs("svg", {
1489
+ className: "animate-spin mr-0.5 h-5 w-5 ".concat(spinnerColor),
1490
+ xmlns: "http://www.w3.org/2000/svg",
1491
+ fill: "none",
1492
+ viewBox: "0 0 24 24",
1493
+ children: [
1494
+ /*#__PURE__*/ jsx("circle", {
1495
+ className: "opacity-25",
1496
+ cx: "12",
1497
+ cy: "12",
1498
+ r: "10",
1499
+ stroke: "currentColor",
1500
+ strokeWidth: "4"
1501
+ }),
1502
+ /*#__PURE__*/ jsx("path", {
1503
+ className: "opacity-75",
1504
+ fill: "currentColor",
1505
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
1506
+ })
1507
+ ]
1508
+ });
1509
+ };
1510
+
1511
+ function _array_like_to_array(arr, len) {
1512
+ if (len == null || len > arr.length) len = arr.length;
1513
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1514
+ return arr2;
1515
+ }
1516
+ function _array_with_holes(arr) {
1517
+ if (Array.isArray(arr)) return arr;
1518
+ }
1519
+ function _array_without_holes(arr) {
1520
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
1521
+ }
1522
+ function _define_property(obj, key, value) {
1523
+ if (key in obj) {
1524
+ Object.defineProperty(obj, key, {
1525
+ value: value,
1526
+ enumerable: true,
1527
+ configurable: true,
1528
+ writable: true
1529
+ });
1530
+ } else {
1531
+ obj[key] = value;
1532
+ }
1533
+ return obj;
1534
+ }
1535
+ function _iterable_to_array(iter) {
1536
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1537
+ }
1538
+ function _iterable_to_array_limit(arr, i) {
1539
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1540
+ if (_i == null) return;
1541
+ var _arr = [];
1542
+ var _n = true;
1543
+ var _d = false;
1544
+ var _s, _e;
1545
+ try {
1546
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1547
+ _arr.push(_s.value);
1548
+ if (i && _arr.length === i) break;
1549
+ }
1550
+ } catch (err) {
1551
+ _d = true;
1552
+ _e = err;
1553
+ } finally{
1554
+ try {
1555
+ if (!_n && _i["return"] != null) _i["return"]();
1556
+ } finally{
1557
+ if (_d) throw _e;
1558
+ }
1559
+ }
1560
+ return _arr;
1561
+ }
1562
+ function _non_iterable_rest() {
1563
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1564
+ }
1565
+ function _non_iterable_spread() {
1566
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1567
+ }
1568
+ function _object_spread(target) {
1569
+ for(var i = 1; i < arguments.length; i++){
1570
+ var source = arguments[i] != null ? arguments[i] : {};
1571
+ var ownKeys = Object.keys(source);
1572
+ if (typeof Object.getOwnPropertySymbols === "function") {
1573
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1574
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1575
+ }));
1576
+ }
1577
+ ownKeys.forEach(function(key) {
1578
+ _define_property(target, key, source[key]);
1579
+ });
1580
+ }
1581
+ return target;
1582
+ }
1583
+ function ownKeys(object, enumerableOnly) {
1584
+ var keys = Object.keys(object);
1585
+ if (Object.getOwnPropertySymbols) {
1586
+ var symbols = Object.getOwnPropertySymbols(object);
1587
+ if (enumerableOnly) {
1588
+ symbols = symbols.filter(function(sym) {
1589
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1590
+ });
1591
+ }
1592
+ keys.push.apply(keys, symbols);
1593
+ }
1594
+ return keys;
1595
+ }
1596
+ function _object_spread_props(target, source) {
1597
+ source = source != null ? source : {};
1598
+ if (Object.getOwnPropertyDescriptors) {
1599
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1600
+ } else {
1601
+ ownKeys(Object(source)).forEach(function(key) {
1602
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1603
+ });
1604
+ }
1605
+ return target;
1606
+ }
1607
+ function _sliced_to_array(arr, i) {
1608
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
1609
+ }
1610
+ function _to_consumable_array(arr) {
1611
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
1612
+ }
1613
+ function _unsupported_iterable_to_array(o, minLen) {
1614
+ if (!o) return;
1615
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
1616
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1617
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1618
+ if (n === "Map" || n === "Set") return Array.from(n);
1619
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1620
+ }
1621
+ var DropDown = function(param) {
1622
+ var _param_options = param.options, options = _param_options === void 0 ? [] : _param_options, _param_value = param.value, value = _param_value === void 0 ? null : _param_value, onChange = param.onChange, onSearchInputChange = param.onSearchInputChange, _param_placeholder = param.placeholder, placeholder = _param_placeholder === void 0 ? "Select..." : _param_placeholder, _param_searchInputPlaceholder = param.searchInputPlaceholder, searchInputPlaceholder = _param_searchInputPlaceholder === void 0 ? "Search..." : _param_searchInputPlaceholder, _param_isMultiple = param.isMultiple, isMultiple = _param_isMultiple === void 0 ? false : _param_isMultiple, _param_isClearable = param.isClearable, isClearable = _param_isClearable === void 0 ? false : _param_isClearable, _param_isSearchable = param.isSearchable, isSearchable = _param_isSearchable === void 0 ? false : _param_isSearchable, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, _param_loading = param.loading, loading = _param_loading === void 0 ? false : _param_loading, _param_menuIsOpen = param.menuIsOpen, menuIsOpen = _param_menuIsOpen === void 0 ? false : _param_menuIsOpen, _param_noOptionsMessage = param.noOptionsMessage, noOptionsMessage = _param_noOptionsMessage === void 0 ? "No options found" : _param_noOptionsMessage, _param_primaryColor = param.primaryColor, primaryColor = _param_primaryColor === void 0 ? DEFAULT_THEME : _param_primaryColor, _param_formatGroupLabel = param.formatGroupLabel, formatGroupLabel = _param_formatGroupLabel === void 0 ? null : _param_formatGroupLabel, _param_formatOptionLabel = param.formatOptionLabel, formatOptionLabel = _param_formatOptionLabel === void 0 ? null : _param_formatOptionLabel, classNames = param.classNames;
1623
+ var _useState = _sliced_to_array(useState(menuIsOpen), 2), open = _useState[0], setOpen = _useState[1];
1624
+ var _useState1 = _sliced_to_array(useState(options), 2), list = _useState1[0], setList = _useState1[1];
1625
+ var _useState2 = _sliced_to_array(useState(""), 2), inputValue = _useState2[0], setInputValue = _useState2[1];
1626
+ var ref = useRef(null);
1627
+ var searchBoxRef = useRef(null);
1628
+ useEffect(function() {
1629
+ var formatItem = function(item) {
1630
+ if ("disabled" in item) return item;
1631
+ return _object_spread_props(_object_spread({}, item), {
1632
+ disabled: false
1633
+ });
1634
+ };
1635
+ setList(options.map(function(item) {
1636
+ if ("options" in item) {
1637
+ return {
1638
+ label: item.label,
1639
+ options: item.options.map(formatItem)
1640
+ };
1641
+ } else {
1642
+ return formatItem(item);
1643
+ }
1644
+ }));
1645
+ }, [
1646
+ options
1647
+ ]);
1648
+ useEffect(function() {
1649
+ if (isSearchable) {
1650
+ if (open) {
1651
+ var _searchBoxRef_current;
1652
+ (_searchBoxRef_current = searchBoxRef.current) === null || _searchBoxRef_current === void 0 ? void 0 : _searchBoxRef_current.select();
1653
+ } else {
1654
+ setInputValue("");
1655
+ }
1656
+ }
1657
+ }, [
1658
+ open,
1659
+ isSearchable
1660
+ ]);
1661
+ var toggle = useCallback(function() {
1662
+ if (!isDisabled) {
1663
+ setOpen(!open);
1664
+ }
1665
+ }, [
1666
+ isDisabled,
1667
+ open
1668
+ ]);
1669
+ var closeDropDown = useCallback(function() {
1670
+ if (open) setOpen(false);
1671
+ }, [
1672
+ open
1673
+ ]);
1674
+ useOnClickOutside(ref, function() {
1675
+ closeDropDown();
1676
+ });
1677
+ var onPressEnterOrSpace = useCallback(function(e) {
1678
+ e.preventDefault();
1679
+ if ((e.code === "Enter" || e.code === "Space") && !isDisabled) {
1680
+ toggle();
1681
+ }
1682
+ }, [
1683
+ isDisabled,
1684
+ toggle
1685
+ ]);
1686
+ var handleValueChange = useCallback(function(selected) {
1687
+ var update = function update() {
1688
+ if (!isMultiple && !Array.isArray(value)) {
1689
+ closeDropDown();
1690
+ onChange(selected);
1691
+ }
1692
+ if (isMultiple && (Array.isArray(value) || value === null)) {
1693
+ onChange(value === null ? [
1694
+ selected
1695
+ ] : _to_consumable_array(value).concat([
1696
+ selected
1697
+ ]));
1698
+ }
1699
+ };
1700
+ if (selected !== value) {
1701
+ update();
1702
+ }
1703
+ }, [
1704
+ closeDropDown,
1705
+ isMultiple,
1706
+ onChange,
1707
+ value
1708
+ ]);
1709
+ var clearValue = useCallback(function(e) {
1710
+ e.stopPropagation();
1711
+ onChange(null);
1712
+ }, [
1713
+ onChange
1714
+ ]);
1715
+ var removeItem = useCallback(function(e, item) {
1716
+ if (isMultiple && Array.isArray(value) && value.length) {
1717
+ e.stopPropagation();
1718
+ var result = value.filter(function(current) {
1719
+ return item.value !== current.value;
1720
+ });
1721
+ onChange(result.length ? result : null);
1722
+ }
1723
+ }, [
1724
+ isMultiple,
1725
+ onChange,
1726
+ value
1727
+ ]);
1728
+ var getSelectClass = useCallback(function() {
1729
+ var ringColor = THEME_DATA.ring[DEFAULT_THEME];
1730
+ if (COLORS.includes(primaryColor)) {
1731
+ ringColor = THEME_DATA.ring[primaryColor];
1732
+ }
1733
+ var borderFocus = THEME_DATA.borderFocus[DEFAULT_THEME];
1734
+ if (COLORS.includes(primaryColor)) {
1735
+ borderFocus = THEME_DATA.borderFocus[primaryColor];
1736
+ }
1737
+ var baseClass = "flex text-sm text-gray-500 border border-gray-300 rounded shadow-sm transition-all duration-300 focus:outline-none";
1738
+ var defaultClass = "".concat(baseClass, " ").concat(isDisabled ? "bg-gray-200" : "bg-white hover:border-gray-400 ".concat(borderFocus, " focus:ring ").concat(ringColor));
1739
+ return classNames && classNames.menuButton ? classNames.menuButton({
1740
+ isDisabled: isDisabled
1741
+ }) : defaultClass;
1742
+ }, [
1743
+ classNames,
1744
+ isDisabled,
1745
+ primaryColor
1746
+ ]);
1747
+ var getTagItemClass = useCallback(function(item) {
1748
+ var baseClasse = "bg-gray-200 border rounded-sm flex space-x-1";
1749
+ var disabledClass = isDisabled ? "border-gray-500 px-1" : "pl-1";
1750
+ return (classNames === null || classNames === void 0 ? void 0 : classNames.tagItem) ? classNames.tagItem({
1751
+ item: item,
1752
+ isDisabled: isDisabled
1753
+ }) : "".concat(baseClasse, " ").concat(disabledClass);
1754
+ }, [
1755
+ classNames,
1756
+ isDisabled
1757
+ ]);
1758
+ return /*#__PURE__*/ jsx(SelectProvider, {
1759
+ otherData: {
1760
+ formatGroupLabel: formatGroupLabel,
1761
+ formatOptionLabel: formatOptionLabel,
1762
+ classNames: classNames
1763
+ },
1764
+ value: value,
1765
+ handleValueChange: handleValueChange,
1766
+ children: /*#__PURE__*/ jsxs("div", {
1767
+ className: "relative w-full",
1768
+ ref: ref,
1769
+ children: [
1770
+ /*#__PURE__*/ jsxs("div", {
1771
+ "aria-expanded": open,
1772
+ onKeyDown: onPressEnterOrSpace,
1773
+ onClick: toggle,
1774
+ className: getSelectClass(),
1775
+ children: [
1776
+ /*#__PURE__*/ jsx("div", {
1777
+ className: "grow pl-2.5 py-2 pr-2 flex flex-wrap gap-1",
1778
+ children: !isMultiple ? /*#__PURE__*/ jsx("p", {
1779
+ className: "truncate cursor-default select-none",
1780
+ children: value && !Array.isArray(value) ? value.label : placeholder
1781
+ }) : /*#__PURE__*/ jsxs(Fragment, {
1782
+ children: [
1783
+ value === null && placeholder,
1784
+ Array.isArray(value) && value.map(function(item, index) {
1785
+ return /*#__PURE__*/ jsxs("div", {
1786
+ className: getTagItemClass(item),
1787
+ children: [
1788
+ /*#__PURE__*/ jsx("p", {
1789
+ className: (classNames === null || classNames === void 0 ? void 0 : classNames.tagItemText) ? classNames.tagItemText : "text-gray-600 truncate cursor-default select-none",
1790
+ children: item.label
1791
+ }),
1792
+ !isDisabled && /*#__PURE__*/ jsx("div", {
1793
+ role: "button",
1794
+ tabIndex: 0,
1795
+ onClick: function(e) {
1796
+ return removeItem(e, item);
1797
+ },
1798
+ className: (classNames === null || classNames === void 0 ? void 0 : classNames.tagItemIconContainer) ? classNames.tagItemIconContainer : "flex items-center px-1 cursor-pointer rounded-r-sm hover:bg-red-200 hover:text-red-600",
1799
+ children: /*#__PURE__*/ jsx(CloseIcon, {
1800
+ className: (classNames === null || classNames === void 0 ? void 0 : classNames.tagItemIcon) ? classNames.tagItemIcon : "w-3 h-3 mt-0.5"
1801
+ })
1802
+ })
1803
+ ]
1804
+ }, index);
1805
+ })
1806
+ ]
1807
+ })
1808
+ }),
1809
+ /*#__PURE__*/ jsxs("div", {
1810
+ className: "flex flex-none items-center py-1.5",
1811
+ children: [
1812
+ loading && /*#__PURE__*/ jsx("div", {
1813
+ className: "px-1.5",
1814
+ children: /*#__PURE__*/ jsx(Spinner, {
1815
+ primaryColor: primaryColor
1816
+ })
1817
+ }),
1818
+ isClearable && !isDisabled && value !== null && /*#__PURE__*/ jsx("div", {
1819
+ className: "px-1.5 cursor-pointer",
1820
+ onClick: clearValue,
1821
+ children: /*#__PURE__*/ jsx(CloseIcon, {
1822
+ className: (classNames === null || classNames === void 0 ? void 0 : classNames.closeIcon) ? classNames.closeIcon : "w-5 h-5 p-0.5"
1823
+ })
1824
+ }),
1825
+ /*#__PURE__*/ jsx("div", {
1826
+ className: "h-full",
1827
+ children: /*#__PURE__*/ jsx("span", {
1828
+ className: "w-px h-full inline-block text-white bg-gray-300 text-opacity-0"
1829
+ })
1830
+ }),
1831
+ /*#__PURE__*/ jsx("div", {
1832
+ className: "px-1.5",
1833
+ children: /*#__PURE__*/ jsx(ChevronIcon, {
1834
+ className: "transition duration-300 w-6 h-6 p-0.5".concat(open ? " transform rotate-90 text-gray-500" : " text-gray-300")
1835
+ })
1836
+ })
1837
+ ]
1838
+ })
1839
+ ]
1840
+ }),
1841
+ open && !isDisabled && /*#__PURE__*/ jsxs("div", {
1842
+ className: (classNames === null || classNames === void 0 ? void 0 : classNames.menu) ? classNames.menu : "absolute z-10 w-full bg-white shadow-lg border rounded py-1 mt-1.5 text-sm text-gray-700",
1843
+ children: [
1844
+ isSearchable && /*#__PURE__*/ jsx(SearchInput, {
1845
+ ref: searchBoxRef,
1846
+ value: inputValue,
1847
+ placeholder: searchInputPlaceholder,
1848
+ onChange: function(e) {
1849
+ if (onSearchInputChange && typeof onSearchInputChange === "function") onSearchInputChange(e);
1850
+ setInputValue(e.target.value);
1851
+ }
1852
+ }),
1853
+ /*#__PURE__*/ jsx(Options, {
1854
+ list: list,
1855
+ noOptionsMessage: noOptionsMessage,
1856
+ text: inputValue,
1857
+ isMultiple: isMultiple,
1858
+ value: value,
1859
+ primaryColor: primaryColor || DEFAULT_THEME
1860
+ })
1861
+ ]
1862
+ })
1863
+ ]
1864
+ })
1865
+ });
1866
+ };
1867
+
1868
+ var InputOTPs = function(param) {
1869
+ var noticeText = param.noticeText, _param_length = param.length, length = _param_length === void 0 ? 6 : _param_length, _param_textClassName = param.textClassName, textClassName = _param_textClassName === void 0 ? "text-sm" : _param_textClassName, _param_ringClassName = param.ringClassName, ringClassName = _param_ringClassName === void 0 ? "" : _param_ringClassName, value = param.value, setValue = param.setValue;
1870
+ var inputs = Array.from({
1871
+ length: length
1872
+ }, function(_, index) {
1873
+ return index + 1;
1874
+ });
1875
+ return /*#__PURE__*/ jsxs("div", {
1876
+ children: [
1877
+ /*#__PURE__*/ jsx(InputOTP, {
1878
+ maxLength: length,
1879
+ value: value,
1880
+ onChange: function(value) {
1881
+ return setValue(value);
1882
+ },
1883
+ children: /*#__PURE__*/ jsx(InputOTPGroup, {
1884
+ children: inputs.map(function(num, index) {
1885
+ return /*#__PURE__*/ jsx(InputOTPSlot, {
1886
+ index: index,
1887
+ ringClassName: ringClassName
1888
+ });
1889
+ })
1890
+ })
1891
+ }),
1892
+ /*#__PURE__*/ jsx("div", {
1893
+ className: [
1894
+ textClassName,
1895
+ "mt-2"
1896
+ ].join(" "),
1897
+ children: value === "" ? /*#__PURE__*/ jsx(Fragment, {
1898
+ children: noticeText
1899
+ }) : null
1900
+ })
1901
+ ]
1902
+ });
1903
+ };
1904
+
1905
+ export { Checkbox, DateRangePicker, DropDown, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, InputOTPs, ReactDateRange, SingleDatePicker, Spin, Switch };