@woobee/ui 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -0
- package/SKIPPED.md +58 -0
- package/dist/index.d.mts +578 -0
- package/dist/index.d.ts +578 -0
- package/dist/index.js +3653 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3594 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +55 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3653 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React15 = require('react');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
|
+
var reactTransitionGroup = require('react-transition-group');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var React15__default = /*#__PURE__*/_interopDefault(React15);
|
|
11
|
+
|
|
12
|
+
// src/utils/classNames.ts
|
|
13
|
+
function classNames(classNameHash) {
|
|
14
|
+
return Object.entries(classNameHash).filter(([, value]) => !!value).map(([key]) => key).join(" ");
|
|
15
|
+
}
|
|
16
|
+
function classNameObject(classNameString) {
|
|
17
|
+
if (!classNameString) return {};
|
|
18
|
+
return classNameString.split(" ").reduce((prev, className) => {
|
|
19
|
+
if (className) {
|
|
20
|
+
prev[className] = true;
|
|
21
|
+
}
|
|
22
|
+
return prev;
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
function Button({
|
|
26
|
+
children,
|
|
27
|
+
onClick,
|
|
28
|
+
placeholder = null,
|
|
29
|
+
variant = "primary",
|
|
30
|
+
size = "medium",
|
|
31
|
+
className = "",
|
|
32
|
+
type = "button",
|
|
33
|
+
loading = false,
|
|
34
|
+
disabled = false,
|
|
35
|
+
leftIcon = null,
|
|
36
|
+
rightIcon = null,
|
|
37
|
+
compact = false,
|
|
38
|
+
...props
|
|
39
|
+
}) {
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
type,
|
|
44
|
+
onClick,
|
|
45
|
+
disabled: disabled || loading,
|
|
46
|
+
className: classNames({
|
|
47
|
+
"items-center justify-center rounded-lg focus:outline-none focus:ring-0 disabled:opacity-50 disabled:pointer-events-none disabled:cursor-not-allowed shadow-sm": true,
|
|
48
|
+
"relative": !!leftIcon || !!rightIcon,
|
|
49
|
+
"px-2.5 py-1.5 text-xs": size === "small",
|
|
50
|
+
"px-4 py-2 text-sm": size === "medium",
|
|
51
|
+
"px-5 py-3 text-base": size === "big",
|
|
52
|
+
"px-5 py-3 text-lg font-medium": size === "huge",
|
|
53
|
+
"!px-1 !py-0.5": compact,
|
|
54
|
+
"border bg-brown-500 dark:bg-primary-500 dark:hover:bg-primary-600 border-transparent text-white dark:text-black": variant === "primary",
|
|
55
|
+
"text-gray-700 bg-white dark:bg-charcoal-800 dark:hover:bg-charcoal-700 dark:text-charcoal-100 border border-gray-300 dark:border-charcoal-700 hover:text-gray-500": variant === "secondary",
|
|
56
|
+
"!rounded-md text-left w-full text-gray-700 bg-white dark:bg-charcoal-800 dark:hover:bg-charcoal-700 dark:text-charcoal-100 border border-gray-200 dark:border-charcoal-700 hover:bg-gray-50 hover:text-gray-500": variant === "form-input",
|
|
57
|
+
"hover:text-brown-500 dark:text-charcoal-100 dark:hover:text-primary-500 !shadow-none": variant === "flat",
|
|
58
|
+
"!text-gray-300 hover:!text-gray-400 dark:!text-charcoal-400": !children,
|
|
59
|
+
...classNameObject(className)
|
|
60
|
+
}),
|
|
61
|
+
...props,
|
|
62
|
+
children: [
|
|
63
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-3", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "w-4 h-4 animate-spin", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { className: "opacity-75", fill: "currentColor", 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" })
|
|
66
|
+
] }) }),
|
|
67
|
+
!loading && leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-y-0 left-0 flex items-center pl-3", children: leftIcon }),
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: children || placeholder }),
|
|
69
|
+
!loading && rightIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-y-0 right-0 flex items-center pr-3", children: rightIcon })
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function Tag({
|
|
75
|
+
children,
|
|
76
|
+
className = "",
|
|
77
|
+
onRemove,
|
|
78
|
+
color,
|
|
79
|
+
style,
|
|
80
|
+
size = "medium"
|
|
81
|
+
}) {
|
|
82
|
+
const customStyle = color ? { backgroundColor: color, ...style } : style;
|
|
83
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
84
|
+
"span",
|
|
85
|
+
{
|
|
86
|
+
className: classNames({
|
|
87
|
+
"inline-flex items-center rounded font-medium whitespace-nowrap": true,
|
|
88
|
+
"bg-cream-200 dark:bg-charcoal-700 text-gray-800 dark:text-gray-200": !color,
|
|
89
|
+
"text-white": !!color,
|
|
90
|
+
// medium size
|
|
91
|
+
"text-sm": size === "medium",
|
|
92
|
+
"pl-2.5 pr-1 py-0.5 space-x-1": size === "medium" && !!onRemove,
|
|
93
|
+
"px-2 py-0.5": size === "medium" && !onRemove,
|
|
94
|
+
// small size
|
|
95
|
+
"text-xs": size === "small",
|
|
96
|
+
"pl-2 pr-0.5 py-0.5 space-x-0.5": size === "small" && !!onRemove,
|
|
97
|
+
"px-1.5 py-0.5": size === "small" && !onRemove,
|
|
98
|
+
...classNameObject(className)
|
|
99
|
+
}),
|
|
100
|
+
style: customStyle,
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children }),
|
|
103
|
+
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
104
|
+
Button,
|
|
105
|
+
{
|
|
106
|
+
variant: "flat",
|
|
107
|
+
compact: true,
|
|
108
|
+
size: size === "small" ? "small" : "medium",
|
|
109
|
+
className: "!text-red-500 hover:text-red-700 !px-0.5",
|
|
110
|
+
onClick: onRemove,
|
|
111
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xD7" })
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
function TagGroup({
|
|
119
|
+
tags = [],
|
|
120
|
+
onRemove,
|
|
121
|
+
placeholder = "No tags selected",
|
|
122
|
+
className = ""
|
|
123
|
+
}) {
|
|
124
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: classNames({
|
|
128
|
+
"flex flex-wrap h-11 gap-1.5 items-center": true,
|
|
129
|
+
...classNameObject(className)
|
|
130
|
+
}),
|
|
131
|
+
children: tags.length > 0 ? tags.map((tag) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
132
|
+
Tag,
|
|
133
|
+
{
|
|
134
|
+
color: tag.color,
|
|
135
|
+
onRemove: onRemove ? () => onRemove(tag) : void 0,
|
|
136
|
+
children: tag.name
|
|
137
|
+
},
|
|
138
|
+
tag.id || tag.name
|
|
139
|
+
)) : placeholder && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-300 dark:text-charcoal-400 text-sm flex items-center", children: placeholder })
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
function Tabs({
|
|
144
|
+
value,
|
|
145
|
+
onChange,
|
|
146
|
+
options = [
|
|
147
|
+
{ id: "point", label: "Point" },
|
|
148
|
+
{ id: "percentage", label: "Percentage" }
|
|
149
|
+
],
|
|
150
|
+
className = ""
|
|
151
|
+
}) {
|
|
152
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
className: classNames({
|
|
156
|
+
"inline-flex rounded-lg bg-cream-50 dark:bg-charcoal-800/90 dark:backdrop-filter dark:backdrop-blur-sm overflow-hidden text-xs p-1 space-x-0.5 rounded-xl": true,
|
|
157
|
+
...classNameObject(className)
|
|
158
|
+
}),
|
|
159
|
+
children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
160
|
+
"button",
|
|
161
|
+
{
|
|
162
|
+
className: classNames({
|
|
163
|
+
"px-3 py-2 transition-colors rounded-lg": true,
|
|
164
|
+
"bg-white text-brown-500 dark:text-primary-500 dark:bg-charcoal-600": value === option.id,
|
|
165
|
+
"hover:text-brown-500 dark:text-charcoal-300 dark:hover:text-primary-500": value !== option.id
|
|
166
|
+
}),
|
|
167
|
+
onClick: () => onChange(option.id),
|
|
168
|
+
children: option.label
|
|
169
|
+
},
|
|
170
|
+
option.id
|
|
171
|
+
))
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
var Toggle = React15.forwardRef(
|
|
176
|
+
({ listening, size, name, value, onChange, className }, ref) => {
|
|
177
|
+
const internalRef = React15.useRef(null);
|
|
178
|
+
const spanRef = ref || internalRef;
|
|
179
|
+
React15.useEffect(() => {
|
|
180
|
+
if (listening && spanRef && "current" in spanRef && spanRef.current && value !== null) {
|
|
181
|
+
spanRef.current.value = value;
|
|
182
|
+
}
|
|
183
|
+
}, [value, listening, spanRef]);
|
|
184
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
185
|
+
"span",
|
|
186
|
+
{
|
|
187
|
+
ref: spanRef,
|
|
188
|
+
role: "checkbox",
|
|
189
|
+
"aria-checked": value,
|
|
190
|
+
tabIndex: 0,
|
|
191
|
+
onClick: () => onChange(!value),
|
|
192
|
+
className: classNames({
|
|
193
|
+
"relative inline-block flex-shrink-0 border-2 border-transparent rounded-full transition-colors ease-in-out duration-200 focus:outline-none focus:shadow-outline": true,
|
|
194
|
+
"h-6 w-11": !size || size === "medium",
|
|
195
|
+
"h-4 w-7": size === "small",
|
|
196
|
+
"bg-brown-500 dark:bg-primary-500": value,
|
|
197
|
+
"bg-gray-200 dark:bg-charcoal-300": !value,
|
|
198
|
+
"cursor-pointer": !(className || "").includes("cursor-"),
|
|
199
|
+
...classNameObject(className)
|
|
200
|
+
}),
|
|
201
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
202
|
+
"span",
|
|
203
|
+
{
|
|
204
|
+
"aria-hidden": "true",
|
|
205
|
+
className: classNames({
|
|
206
|
+
"rounded-full bg-white shadow transform transition ease-in-out duration-200": true,
|
|
207
|
+
"inline-block h-5 w-5": !size || size === "medium",
|
|
208
|
+
"block h-3 w-3": size === "small",
|
|
209
|
+
"translate-x-5": value && (!size || size === "medium"),
|
|
210
|
+
"translate-x-0": !value,
|
|
211
|
+
"translate-x-3": value && size === "small"
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
Toggle.displayName = "Toggle";
|
|
220
|
+
var Toggle_default = Toggle;
|
|
221
|
+
function Loading({
|
|
222
|
+
title,
|
|
223
|
+
layout,
|
|
224
|
+
className = "",
|
|
225
|
+
spinClassName = "",
|
|
226
|
+
spinSizeClassName = "w-24 h-24"
|
|
227
|
+
}) {
|
|
228
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
className: classNames({
|
|
232
|
+
"space-y-3": true,
|
|
233
|
+
"flex flex-col items-center justify-center fixed inset-0": layout === "fixed",
|
|
234
|
+
"w-full": layout === "fill",
|
|
235
|
+
[className]: true
|
|
236
|
+
}),
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
239
|
+
"div",
|
|
240
|
+
{
|
|
241
|
+
className: classNames({
|
|
242
|
+
[spinClassName]: true,
|
|
243
|
+
[spinSizeClassName]: true,
|
|
244
|
+
"relative border-8 border-gray-500 rounded-full animate-spin": true
|
|
245
|
+
}),
|
|
246
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute -left-4 -top-4 right-2/4 bottom-2/4 bg-white/50 bg-opacity-75 rounded-full rounded-b-none rounded-r-none" })
|
|
247
|
+
}
|
|
248
|
+
),
|
|
249
|
+
!!title && title.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { children: title })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
function CheckboxList({
|
|
255
|
+
items = [],
|
|
256
|
+
selected = [],
|
|
257
|
+
onToggle,
|
|
258
|
+
itemKey = "id",
|
|
259
|
+
itemLabel = (item) => item.name || item.label || item.fullName,
|
|
260
|
+
isChecked,
|
|
261
|
+
loading = false,
|
|
262
|
+
placeholder = "No items found."
|
|
263
|
+
}) {
|
|
264
|
+
const getFinalKey = (item, index) => {
|
|
265
|
+
const key = typeof itemKey === "function" ? itemKey(item) : item[itemKey];
|
|
266
|
+
return key !== void 0 && key !== null ? key : index;
|
|
267
|
+
};
|
|
268
|
+
const renderPlaceholder = () => {
|
|
269
|
+
if (typeof placeholder === "string") {
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-sm text-gray-500 dark:text-charcoal-400", children: placeholder });
|
|
271
|
+
}
|
|
272
|
+
return placeholder;
|
|
273
|
+
};
|
|
274
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full border border-gray-300 dark:border-charcoal-700 rounded-lg shadow-sm bg-white dark:bg-charcoal-800 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-60 overflow-y-auto divide-y divide-gray-100 dark:divide-charcoal-700", children: loading && items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 flex items-center justify-center min-h-36", children: /* @__PURE__ */ jsxRuntime.jsx(Loading, { spinSizeClassName: "w-6 h-6", className: "inline-block" }) }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: items.length > 0 ? items.map((item, index) => {
|
|
275
|
+
const finalKey = getFinalKey(item, index);
|
|
276
|
+
const label = typeof itemLabel === "function" ? itemLabel(item) : item[itemLabel];
|
|
277
|
+
const checked = typeof isChecked === "function" ? isChecked(item, selected) : selected.some(
|
|
278
|
+
(s) => (s && typeof s === "object" ? s.id : s) === finalKey
|
|
279
|
+
);
|
|
280
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
281
|
+
"div",
|
|
282
|
+
{
|
|
283
|
+
className: classNames({
|
|
284
|
+
"px-2 py-2 cursor-pointer flex items-center justify-between transition-colors": true,
|
|
285
|
+
"hover:bg-gray-50 dark:hover:bg-charcoal-700": !checked,
|
|
286
|
+
"bg-gray-50 dark:bg-primary-900/20": checked
|
|
287
|
+
}),
|
|
288
|
+
onClick: () => onToggle && onToggle(item),
|
|
289
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-3", children: [
|
|
290
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
291
|
+
"div",
|
|
292
|
+
{
|
|
293
|
+
className: classNames({
|
|
294
|
+
"w-5 h-5 rounded border flex items-center justify-center transition-colors cursor-pointer": true,
|
|
295
|
+
"border-gray-300 bg-white dark:border-charcoal-700 dark:bg-charcoal-700": !checked,
|
|
296
|
+
"border-brown-500 bg-brown-500 dark:bg-primary-500 dark:border-primary-500 dark:text-black text-white": checked
|
|
297
|
+
}),
|
|
298
|
+
children: checked && /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z" }) })
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
302
|
+
"span",
|
|
303
|
+
{
|
|
304
|
+
className: classNames({
|
|
305
|
+
"text-sm": true,
|
|
306
|
+
"text-gray-900 dark:text-gray-100": !checked,
|
|
307
|
+
"dark:text-primary-400": checked
|
|
308
|
+
}),
|
|
309
|
+
children: label
|
|
310
|
+
}
|
|
311
|
+
)
|
|
312
|
+
] })
|
|
313
|
+
},
|
|
314
|
+
finalKey
|
|
315
|
+
);
|
|
316
|
+
}) : renderPlaceholder() }) }) });
|
|
317
|
+
}
|
|
318
|
+
var ModalContext = React15.createContext({
|
|
319
|
+
modalShowing: false,
|
|
320
|
+
drawerShowing: false,
|
|
321
|
+
setModalShowing: () => {
|
|
322
|
+
},
|
|
323
|
+
setDrawerShowing: () => {
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
function useModalContext() {
|
|
327
|
+
return React15.useContext(ModalContext);
|
|
328
|
+
}
|
|
329
|
+
function ModalProvider({ children }) {
|
|
330
|
+
const [currentState, setCurrentState] = React15.useState(0);
|
|
331
|
+
function reducer(state, action) {
|
|
332
|
+
const updatedValues = { ...state };
|
|
333
|
+
if ("modalShowing" in action) {
|
|
334
|
+
updatedValues.modalShowing = action.modalShowing;
|
|
335
|
+
}
|
|
336
|
+
if ("drawerShowing" in action) {
|
|
337
|
+
updatedValues.drawerShowing = action.drawerShowing;
|
|
338
|
+
}
|
|
339
|
+
if ("render" in action && !!action.render) {
|
|
340
|
+
setCurrentState(1 - currentState);
|
|
341
|
+
}
|
|
342
|
+
return updatedValues;
|
|
343
|
+
}
|
|
344
|
+
const [values, dispatch] = React15.useReducer(reducer, {
|
|
345
|
+
modalShowing: false,
|
|
346
|
+
drawerShowing: false
|
|
347
|
+
});
|
|
348
|
+
const { modalShowing, drawerShowing } = values;
|
|
349
|
+
React15.useEffect(() => {
|
|
350
|
+
if (typeof document === "undefined") return;
|
|
351
|
+
const bodyEl = document.getElementsByTagName("BODY")[0];
|
|
352
|
+
if (!bodyEl) return;
|
|
353
|
+
if (modalShowing) {
|
|
354
|
+
bodyEl.classList.add("overflow-hidden");
|
|
355
|
+
} else {
|
|
356
|
+
bodyEl.classList.remove("overflow-hidden");
|
|
357
|
+
}
|
|
358
|
+
}, [modalShowing]);
|
|
359
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
360
|
+
ModalContext.Provider,
|
|
361
|
+
{
|
|
362
|
+
value: {
|
|
363
|
+
modalShowing,
|
|
364
|
+
drawerShowing,
|
|
365
|
+
setModalShowing: (value) => dispatch({ modalShowing: value, render: modalShowing !== value }),
|
|
366
|
+
setDrawerShowing: (value) => dispatch({ drawerShowing: value, render: drawerShowing !== value })
|
|
367
|
+
},
|
|
368
|
+
children
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
var TransitionContext = React15.createContext({
|
|
373
|
+
parent: {}
|
|
374
|
+
});
|
|
375
|
+
function useIsInitialRender() {
|
|
376
|
+
const isInitialRender = React15.useRef(true);
|
|
377
|
+
React15.useEffect(() => {
|
|
378
|
+
isInitialRender.current = false;
|
|
379
|
+
}, []);
|
|
380
|
+
return isInitialRender.current;
|
|
381
|
+
}
|
|
382
|
+
function CSSTransitionComponent({
|
|
383
|
+
show,
|
|
384
|
+
enter = "",
|
|
385
|
+
enterFrom = "",
|
|
386
|
+
enterTo = "",
|
|
387
|
+
leave = "",
|
|
388
|
+
leaveFrom = "",
|
|
389
|
+
leaveTo = "",
|
|
390
|
+
appear,
|
|
391
|
+
children,
|
|
392
|
+
onEnter = () => {
|
|
393
|
+
},
|
|
394
|
+
onEntering = () => {
|
|
395
|
+
},
|
|
396
|
+
onEntered = () => {
|
|
397
|
+
},
|
|
398
|
+
onExit = () => {
|
|
399
|
+
},
|
|
400
|
+
onExiting = () => {
|
|
401
|
+
},
|
|
402
|
+
onExited = () => {
|
|
403
|
+
}
|
|
404
|
+
}) {
|
|
405
|
+
const enterClasses = enter.split(" ").filter((s) => s.length);
|
|
406
|
+
const enterFromClasses = enterFrom.split(" ").filter((s) => s.length);
|
|
407
|
+
const enterToClasses = enterTo.split(" ").filter((s) => s.length);
|
|
408
|
+
const leaveClasses = leave.split(" ").filter((s) => s.length);
|
|
409
|
+
const leaveFromClasses = leaveFrom.split(" ").filter((s) => s.length);
|
|
410
|
+
const leaveToClasses = leaveTo.split(" ").filter((s) => s.length);
|
|
411
|
+
const nodeRef = React15.useRef(null);
|
|
412
|
+
function addClasses(node, classes) {
|
|
413
|
+
classes.length && node.classList.add(...classes);
|
|
414
|
+
}
|
|
415
|
+
function removeClasses(node, classes) {
|
|
416
|
+
classes.length && node.classList.remove(...classes);
|
|
417
|
+
}
|
|
418
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
419
|
+
reactTransitionGroup.CSSTransition,
|
|
420
|
+
{
|
|
421
|
+
nodeRef,
|
|
422
|
+
appear,
|
|
423
|
+
unmountOnExit: true,
|
|
424
|
+
in: show,
|
|
425
|
+
addEndListener: (done) => {
|
|
426
|
+
if (!nodeRef.current) return done();
|
|
427
|
+
nodeRef.current.addEventListener("transitionend", done, false);
|
|
428
|
+
},
|
|
429
|
+
onEnter: () => {
|
|
430
|
+
if (!nodeRef.current) return;
|
|
431
|
+
addClasses(nodeRef.current, [...enterClasses, ...enterFromClasses]);
|
|
432
|
+
onEnter(nodeRef.current);
|
|
433
|
+
},
|
|
434
|
+
onEntering: () => {
|
|
435
|
+
if (!nodeRef.current) return;
|
|
436
|
+
removeClasses(nodeRef.current, enterFromClasses);
|
|
437
|
+
addClasses(nodeRef.current, enterToClasses);
|
|
438
|
+
onEntering(nodeRef.current);
|
|
439
|
+
},
|
|
440
|
+
onEntered: () => {
|
|
441
|
+
if (!nodeRef.current) return;
|
|
442
|
+
removeClasses(nodeRef.current, [...enterToClasses, ...enterClasses]);
|
|
443
|
+
onEntered(nodeRef.current);
|
|
444
|
+
},
|
|
445
|
+
onExit: () => {
|
|
446
|
+
if (!nodeRef.current) return;
|
|
447
|
+
addClasses(nodeRef.current, [...leaveClasses, ...leaveFromClasses]);
|
|
448
|
+
onExit(nodeRef.current);
|
|
449
|
+
},
|
|
450
|
+
onExiting: () => {
|
|
451
|
+
if (!nodeRef.current) return;
|
|
452
|
+
removeClasses(nodeRef.current, leaveFromClasses);
|
|
453
|
+
addClasses(nodeRef.current, leaveToClasses);
|
|
454
|
+
onExiting(nodeRef.current);
|
|
455
|
+
},
|
|
456
|
+
onExited: () => {
|
|
457
|
+
if (!nodeRef.current) return;
|
|
458
|
+
removeClasses(nodeRef.current, [...leaveToClasses, ...leaveClasses]);
|
|
459
|
+
onExited(nodeRef.current);
|
|
460
|
+
},
|
|
461
|
+
children: React15__default.default.cloneElement(children, {
|
|
462
|
+
ref: (node) => {
|
|
463
|
+
nodeRef.current = node;
|
|
464
|
+
const childRef = children.ref;
|
|
465
|
+
if (typeof childRef === "function") {
|
|
466
|
+
childRef(node);
|
|
467
|
+
} else if (childRef && typeof childRef === "object") {
|
|
468
|
+
childRef.current = node;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
})
|
|
472
|
+
}
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
function Transition({ show, appear, ...rest }) {
|
|
476
|
+
const { parent } = React15.useContext(TransitionContext);
|
|
477
|
+
const isInitialRender = useIsInitialRender();
|
|
478
|
+
const isChild = show === void 0;
|
|
479
|
+
if (isChild) {
|
|
480
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
481
|
+
CSSTransitionComponent,
|
|
482
|
+
{
|
|
483
|
+
appear: parent.appear || !parent.isInitialRender,
|
|
484
|
+
show: parent.show,
|
|
485
|
+
...rest
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
490
|
+
TransitionContext.Provider,
|
|
491
|
+
{
|
|
492
|
+
value: {
|
|
493
|
+
parent: {
|
|
494
|
+
show,
|
|
495
|
+
isInitialRender,
|
|
496
|
+
appear
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CSSTransitionComponent, { appear, show, ...rest })
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
function ModalFooter({
|
|
504
|
+
footer,
|
|
505
|
+
disabled,
|
|
506
|
+
onCancel,
|
|
507
|
+
onSubmit,
|
|
508
|
+
onChange,
|
|
509
|
+
closeText,
|
|
510
|
+
submitText,
|
|
511
|
+
submitColor,
|
|
512
|
+
changeText,
|
|
513
|
+
darkMode
|
|
514
|
+
}) {
|
|
515
|
+
if (footer) {
|
|
516
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
517
|
+
"div",
|
|
518
|
+
{
|
|
519
|
+
className: classNames({
|
|
520
|
+
"px-3 pt-5 pb-4 bg-gray-100 border-t border-gray-300 dark:border-charcoal-700 sm:px-6 sm:pt-3 sm:pb-3 dark:bg-black/40": true,
|
|
521
|
+
"!bg-charcoal-700 !border-t-charcoal-600": !!darkMode
|
|
522
|
+
}),
|
|
523
|
+
children: footer
|
|
524
|
+
}
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
const hasSubmit = typeof onSubmit === "function";
|
|
528
|
+
const hasCancel = typeof onCancel === "function";
|
|
529
|
+
const hasChange = typeof onChange === "function";
|
|
530
|
+
function handleSubmit(e) {
|
|
531
|
+
if (typeof onSubmit === "function" && !disabled) {
|
|
532
|
+
onSubmit(e);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
let submitVariant = "primary";
|
|
536
|
+
let submitBtnClassName = "w-full";
|
|
537
|
+
if (submitColor) {
|
|
538
|
+
if (submitColor === "red") {
|
|
539
|
+
submitVariant = void 0;
|
|
540
|
+
submitBtnClassName = "w-full bg-red-600 hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600 border-transparent text-white";
|
|
541
|
+
} else if (submitColor === "primary") {
|
|
542
|
+
submitVariant = "primary";
|
|
543
|
+
} else {
|
|
544
|
+
submitVariant = void 0;
|
|
545
|
+
submitBtnClassName = classNames({ "w-full": true, [submitColor]: true });
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return hasSubmit || hasCancel || hasChange ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between px-3 py-3 space-x-2 bg-transparent sm:px-6 sm:pt-3 sm:pb-3", children: [
|
|
549
|
+
hasChange && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex space-x-2", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-2xl", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "secondary", onClick: onChange, children: changeText || "Change" }) }) }),
|
|
550
|
+
(hasSubmit || hasCancel) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end flex-grow space-x-2", children: [
|
|
551
|
+
hasCancel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex shadow-sm rounded-2xl", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { className: "w-full", variant: "secondary", onClick: onCancel, children: closeText || "Cancel" }) }),
|
|
552
|
+
hasSubmit && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex w-full shadow-sm rounded-2xl sm:w-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
553
|
+
Button,
|
|
554
|
+
{
|
|
555
|
+
className: submitBtnClassName,
|
|
556
|
+
variant: submitVariant,
|
|
557
|
+
disabled,
|
|
558
|
+
onClick: () => handleSubmit({}),
|
|
559
|
+
children: submitText || "Submit"
|
|
560
|
+
}
|
|
561
|
+
) })
|
|
562
|
+
] })
|
|
563
|
+
] }) : null;
|
|
564
|
+
}
|
|
565
|
+
var MODAL_OPEN_COUNT = 0;
|
|
566
|
+
function Modal({
|
|
567
|
+
wrapperClassName,
|
|
568
|
+
open,
|
|
569
|
+
size,
|
|
570
|
+
title,
|
|
571
|
+
description,
|
|
572
|
+
transparent,
|
|
573
|
+
header,
|
|
574
|
+
sidebar,
|
|
575
|
+
footer,
|
|
576
|
+
children,
|
|
577
|
+
disabled,
|
|
578
|
+
onClose,
|
|
579
|
+
onExited = () => {
|
|
580
|
+
},
|
|
581
|
+
onCancel,
|
|
582
|
+
onSubmit,
|
|
583
|
+
onChange,
|
|
584
|
+
closeText,
|
|
585
|
+
submitText,
|
|
586
|
+
submitColor,
|
|
587
|
+
changeText,
|
|
588
|
+
fullscreen,
|
|
589
|
+
opts
|
|
590
|
+
}) {
|
|
591
|
+
const { setModalShowing } = React15.useContext(ModalContext);
|
|
592
|
+
const { darkMode, sidebarPosition = "right", mobileSidebarPosition = "bottom" } = opts || {};
|
|
593
|
+
const isMobileSidebarTop = mobileSidebarPosition === "top" || mobileSidebarPosition === "above";
|
|
594
|
+
const [mounted, setMounted] = React15.useState(false);
|
|
595
|
+
React15.useEffect(() => {
|
|
596
|
+
setMounted(true);
|
|
597
|
+
return () => setMounted(false);
|
|
598
|
+
}, []);
|
|
599
|
+
React15.useEffect(() => {
|
|
600
|
+
if (typeof document === "undefined") return;
|
|
601
|
+
const bodyEl = document.getElementsByTagName("BODY")[0];
|
|
602
|
+
if (open) {
|
|
603
|
+
setModalShowing(true);
|
|
604
|
+
if (MODAL_OPEN_COUNT === 0) {
|
|
605
|
+
bodyEl?.classList?.add("overflow-hidden");
|
|
606
|
+
}
|
|
607
|
+
MODAL_OPEN_COUNT++;
|
|
608
|
+
} else {
|
|
609
|
+
setModalShowing(false);
|
|
610
|
+
}
|
|
611
|
+
return () => {
|
|
612
|
+
if (open) {
|
|
613
|
+
MODAL_OPEN_COUNT--;
|
|
614
|
+
if (MODAL_OPEN_COUNT === 0) {
|
|
615
|
+
bodyEl?.classList?.remove("overflow-hidden");
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}, [open]);
|
|
620
|
+
function handleClose() {
|
|
621
|
+
if (typeof onClose === "function") {
|
|
622
|
+
onClose();
|
|
623
|
+
}
|
|
624
|
+
setModalShowing(false);
|
|
625
|
+
}
|
|
626
|
+
if (!mounted) return null;
|
|
627
|
+
return reactDom.createPortal(
|
|
628
|
+
/* @__PURE__ */ jsxRuntime.jsx(Transition, { show: open, onExited, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-x-0 text-sm bottom-0 z-[1300] px-0 bg-opacity-30 lg:px-6 lg:inset-0 lg:flex lg:items-center lg:justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
629
|
+
"div",
|
|
630
|
+
{
|
|
631
|
+
className: classNames({
|
|
632
|
+
"max-h-[100dvh] overflow-y-auto sm:w-full": true,
|
|
633
|
+
"lg:max-w-2xl": !size,
|
|
634
|
+
"lg:max-w-md": size === "small",
|
|
635
|
+
"lg:max-w-3xl": size === "medium",
|
|
636
|
+
"lg:max-w-6xl": size === "large",
|
|
637
|
+
"h-[100dvh] lg:h-auto lg:max-w-3xl": size === "full"
|
|
638
|
+
}),
|
|
639
|
+
children: [
|
|
640
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
641
|
+
Transition,
|
|
642
|
+
{
|
|
643
|
+
enter: "ease-out duration-300",
|
|
644
|
+
enterFrom: "opacity-0",
|
|
645
|
+
enterTo: "opacity-100",
|
|
646
|
+
leave: "ease-in duration-200",
|
|
647
|
+
leaveFrom: "opacity-100",
|
|
648
|
+
leaveTo: "opacity-0",
|
|
649
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 transition-opacity", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 bg-gray-500 dark:bg-charcoal-800 opacity-75" }) })
|
|
650
|
+
}
|
|
651
|
+
),
|
|
652
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
653
|
+
Transition,
|
|
654
|
+
{
|
|
655
|
+
enter: "ease-out duration-300",
|
|
656
|
+
enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
|
657
|
+
enterTo: "opacity-100 translate-y-0 sm:scale-100",
|
|
658
|
+
leave: "ease-in duration-200",
|
|
659
|
+
leaveFrom: "opacity-100 translate-y-0 sm:scale-100",
|
|
660
|
+
leaveTo: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
|
661
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
662
|
+
"div",
|
|
663
|
+
{
|
|
664
|
+
className: classNames({
|
|
665
|
+
"relative flex flex-col z-40 max-h-[100dvh] sm:max-h-9/10 sm:rounded-xl overflow-hidden transform transition-all sm:w-full": true,
|
|
666
|
+
"sm:max-w-2xl": !size,
|
|
667
|
+
"sm:max-w-md": size === "small",
|
|
668
|
+
"sm:max-w-4xl": size === "medium",
|
|
669
|
+
"sm:max-w-6xl": size === "large",
|
|
670
|
+
"sm:max-w-full sm:!max-h-full": size === "full",
|
|
671
|
+
"shadow-xl": !transparent,
|
|
672
|
+
"bg-white dark:bg-black": !transparent && !wrapperClassName,
|
|
673
|
+
"bg-transparent ": !!transparent && !wrapperClassName,
|
|
674
|
+
...classNameObject(wrapperClassName)
|
|
675
|
+
}),
|
|
676
|
+
role: "dialog",
|
|
677
|
+
"aria-modal": "true",
|
|
678
|
+
"aria-labelledby": "modal-headline",
|
|
679
|
+
children: [
|
|
680
|
+
!header && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
681
|
+
"div",
|
|
682
|
+
{
|
|
683
|
+
className: classNames({
|
|
684
|
+
"flex items-center justify-between px-3 pt-3 pb-2 space-x-2 sm:px-6 sm:pt-6 sm:pb-3": true,
|
|
685
|
+
"sm:border-b sm:border-gray-200 dark:sm:border-charcoal-700 sm:shadow-sm": !!sidebar
|
|
686
|
+
}),
|
|
687
|
+
children: [
|
|
688
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
689
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "my-0 text-base font-semibold leading-tight text-gray-900 dark:text-white", children: title }),
|
|
690
|
+
!!description && description.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-primary-700", children: description })
|
|
691
|
+
] }),
|
|
692
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "flat", compact: true, onClick: handleClose, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-6 h-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M6 18L18 6M6 6l12 12" }) }) })
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
),
|
|
696
|
+
!!header && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: header }),
|
|
697
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
698
|
+
"div",
|
|
699
|
+
{
|
|
700
|
+
className: classNames({
|
|
701
|
+
"pb-3 max-h-full overflow-y-auto": true,
|
|
702
|
+
"h-[100dvh] lg:h-auto": fullscreen || size === "full",
|
|
703
|
+
"sm:pt-4 sm:relative border-b border-gray-200 dark:border-charcoal-700": !!sidebar,
|
|
704
|
+
"sm:pr-80": !!sidebar && sidebarPosition === "right",
|
|
705
|
+
"sm:pl-80": !!sidebar && sidebarPosition === "left"
|
|
706
|
+
}),
|
|
707
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow px-3 sm:px-6", children: [
|
|
708
|
+
!!sidebar && isMobileSidebarTop && /* @__PURE__ */ jsxRuntime.jsx(
|
|
709
|
+
"div",
|
|
710
|
+
{
|
|
711
|
+
className: classNames({
|
|
712
|
+
"sm:absolute sm:top-0 sm:bottom-0 sm:w-80 sm:max-h-full sm:overflow-y-scroll sm:px-5 sm:py-4": true,
|
|
713
|
+
"sm:right-0 sm:border-l sm:border-gray-200 dark:sm:border-charcoal-700": sidebarPosition === "right",
|
|
714
|
+
"sm:left-0 sm:border-r sm:border-gray-200 dark:sm:border-charcoal-700": sidebarPosition === "left",
|
|
715
|
+
"pb-6 mb-6 border-b border-gray-200 dark:border-charcoal-700 sm:border-b-0 sm:pb-0 sm:mb-0": true
|
|
716
|
+
}),
|
|
717
|
+
children: sidebar
|
|
718
|
+
}
|
|
719
|
+
),
|
|
720
|
+
children,
|
|
721
|
+
!!sidebar && !isMobileSidebarTop && /* @__PURE__ */ jsxRuntime.jsx(
|
|
722
|
+
"div",
|
|
723
|
+
{
|
|
724
|
+
className: classNames({
|
|
725
|
+
"sm:absolute sm:top-0 sm:bottom-0 sm:w-80 sm:max-h-full sm:overflow-y-scroll sm:px-5 sm:py-4": true,
|
|
726
|
+
"sm:right-0 sm:border-l sm:border-gray-200 dark:sm:border-charcoal-700": sidebarPosition === "right",
|
|
727
|
+
"sm:left-0 sm:border-r sm:border-gray-200 dark:sm:border-charcoal-700": sidebarPosition === "left",
|
|
728
|
+
"pt-6 mt-6 border-t border-gray-200 dark:border-charcoal-700 sm:border-t-0 sm:mt-0": true
|
|
729
|
+
}),
|
|
730
|
+
children: sidebar
|
|
731
|
+
}
|
|
732
|
+
)
|
|
733
|
+
] })
|
|
734
|
+
}
|
|
735
|
+
),
|
|
736
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
737
|
+
ModalFooter,
|
|
738
|
+
{
|
|
739
|
+
footer,
|
|
740
|
+
disabled,
|
|
741
|
+
onCancel,
|
|
742
|
+
onSubmit,
|
|
743
|
+
onChange,
|
|
744
|
+
closeText,
|
|
745
|
+
submitText,
|
|
746
|
+
submitColor,
|
|
747
|
+
changeText,
|
|
748
|
+
darkMode
|
|
749
|
+
}
|
|
750
|
+
)
|
|
751
|
+
]
|
|
752
|
+
}
|
|
753
|
+
)
|
|
754
|
+
}
|
|
755
|
+
)
|
|
756
|
+
]
|
|
757
|
+
}
|
|
758
|
+
) }) }),
|
|
759
|
+
document.body
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
function ConfirmationBox({
|
|
763
|
+
open,
|
|
764
|
+
title = "Confirm Action",
|
|
765
|
+
description = "Are you sure you want to perform this action?",
|
|
766
|
+
cancelText = "Cancel",
|
|
767
|
+
confirmText = "Confirm",
|
|
768
|
+
confirmColor,
|
|
769
|
+
type = "danger",
|
|
770
|
+
disabled = false,
|
|
771
|
+
onClose,
|
|
772
|
+
onConfirm
|
|
773
|
+
}) {
|
|
774
|
+
let iconContainerClass = "";
|
|
775
|
+
let iconSvg = null;
|
|
776
|
+
let defaultConfirmColor = "primary";
|
|
777
|
+
if (type === "danger") {
|
|
778
|
+
iconContainerClass = "bg-red-50 dark:bg-red-950/30 text-red-600 dark:text-red-400";
|
|
779
|
+
defaultConfirmColor = "red";
|
|
780
|
+
iconSvg = /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) });
|
|
781
|
+
} else if (type === "warning") {
|
|
782
|
+
iconContainerClass = "bg-yellow-50 dark:bg-yellow-950/30 text-yellow-600 dark:text-yellow-400";
|
|
783
|
+
defaultConfirmColor = "primary";
|
|
784
|
+
iconSvg = /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) });
|
|
785
|
+
} else {
|
|
786
|
+
iconContainerClass = "bg-blue-50 dark:bg-blue-950/30 text-blue-600 dark:text-blue-400";
|
|
787
|
+
defaultConfirmColor = "primary";
|
|
788
|
+
iconSvg = /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) });
|
|
789
|
+
}
|
|
790
|
+
const resolvedConfirmColor = confirmColor || defaultConfirmColor;
|
|
791
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
792
|
+
Modal,
|
|
793
|
+
{
|
|
794
|
+
open,
|
|
795
|
+
size: "small",
|
|
796
|
+
title,
|
|
797
|
+
onClose,
|
|
798
|
+
onCancel: onClose,
|
|
799
|
+
onSubmit: onConfirm,
|
|
800
|
+
closeText: cancelText,
|
|
801
|
+
submitText: confirmText,
|
|
802
|
+
submitColor: resolvedConfirmColor,
|
|
803
|
+
disabled,
|
|
804
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start space-x-4", children: [
|
|
805
|
+
iconSvg && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full ${iconContainerClass}`, children: iconSvg }),
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 pt-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 font-medium", children: description }) })
|
|
807
|
+
] })
|
|
808
|
+
}
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
function Drawer({
|
|
812
|
+
theme,
|
|
813
|
+
open,
|
|
814
|
+
onClose,
|
|
815
|
+
title,
|
|
816
|
+
level,
|
|
817
|
+
description,
|
|
818
|
+
children,
|
|
819
|
+
footer,
|
|
820
|
+
animation = {},
|
|
821
|
+
wrapperClassName,
|
|
822
|
+
sectionClassName = ""
|
|
823
|
+
}) {
|
|
824
|
+
const { setDrawerShowing } = React15.useContext(ModalContext);
|
|
825
|
+
React15.useEffect(() => {
|
|
826
|
+
setDrawerShowing(open);
|
|
827
|
+
}, [open]);
|
|
828
|
+
function handleClose() {
|
|
829
|
+
if (typeof onClose === "function") {
|
|
830
|
+
onClose();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
834
|
+
Transition,
|
|
835
|
+
{
|
|
836
|
+
show: open,
|
|
837
|
+
enter: "transform transition ease-in-out duration-500 sm:duration-700",
|
|
838
|
+
enterFrom: "translate-x-full",
|
|
839
|
+
enterTo: "translate-x-0",
|
|
840
|
+
leave: "transform transition ease-in-out duration-500 sm:duration-700",
|
|
841
|
+
leaveFrom: "translate-x-0",
|
|
842
|
+
leaveTo: "translate-x-full",
|
|
843
|
+
...animation,
|
|
844
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
845
|
+
"section",
|
|
846
|
+
{
|
|
847
|
+
className: classNames({
|
|
848
|
+
"fixed inset-y-0 max-w-full right-0 flex": true,
|
|
849
|
+
"z-20": !level || level === "base" || level === "extra-wide" || level === "full",
|
|
850
|
+
"z-30": level === "middle",
|
|
851
|
+
"z-40": level === "top",
|
|
852
|
+
"z-50": level === "ceil",
|
|
853
|
+
[sectionClassName]: true
|
|
854
|
+
}),
|
|
855
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
856
|
+
"div",
|
|
857
|
+
{
|
|
858
|
+
className: classNames({
|
|
859
|
+
"w-screen": true,
|
|
860
|
+
"sm:max-w-7xl": level === "extra-wide",
|
|
861
|
+
"sm:max-w-full": level === "full",
|
|
862
|
+
"sm:max-w-4xl": !level || level === "base",
|
|
863
|
+
"sm:max-w-2xl": level === "middle",
|
|
864
|
+
"sm:max-w-md": level === "top",
|
|
865
|
+
"sm:max-w-sm": level === "ceil"
|
|
866
|
+
}),
|
|
867
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
868
|
+
"div",
|
|
869
|
+
{
|
|
870
|
+
className: classNames({
|
|
871
|
+
"h-full flex flex-col shadow-xl": true,
|
|
872
|
+
"bg-white dark:bg-primary-800": !wrapperClassName,
|
|
873
|
+
...classNameObject(wrapperClassName)
|
|
874
|
+
}),
|
|
875
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [
|
|
876
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
877
|
+
"header",
|
|
878
|
+
{
|
|
879
|
+
className: classNames({
|
|
880
|
+
"h-auto py-2.5 sm:py-3 px-4 sm:px-6": true,
|
|
881
|
+
"bg-primary-100 dark:bg-primary-900": !theme && (!level || level === "base" || level === "extra-wide" || level === "full"),
|
|
882
|
+
"bg-primary-200 dark:bg-primary-900": !theme && level === "middle",
|
|
883
|
+
"bg-primary-300 dark:bg-primary-900": !theme && level === "top",
|
|
884
|
+
"bg-primary-50 dark:bg-primary-900 border-b border-primary-100": !theme && level === "ceil",
|
|
885
|
+
"bg-white": theme === "WHITE",
|
|
886
|
+
"bg-black": theme === "BLACK",
|
|
887
|
+
"bg-red-500": theme === "RED",
|
|
888
|
+
"bg-orange-500": theme === "ORANGE",
|
|
889
|
+
"bg-yellow-500": theme === "YELLOW",
|
|
890
|
+
"bg-lime-500": theme === "LIME",
|
|
891
|
+
"bg-green-500": theme === "GREEN",
|
|
892
|
+
"bg-brown-500": theme === "BROWN",
|
|
893
|
+
"bg-blue-500": theme === "BLUE",
|
|
894
|
+
"bg-dark-blue-500": theme === "DARK_BLUE",
|
|
895
|
+
"bg-purple-500": theme === "PURPLE",
|
|
896
|
+
"bg-flamingo-500": theme === "FLAMINGO",
|
|
897
|
+
"bg-pink-500": theme === "PINK"
|
|
898
|
+
}),
|
|
899
|
+
children: [
|
|
900
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between space-x-3", children: [
|
|
901
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-base sm:text-lg leading-7 font-medium", children: title }),
|
|
902
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-7 flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
903
|
+
"div",
|
|
904
|
+
{
|
|
905
|
+
"aria-label": "Close",
|
|
906
|
+
className: "-mr-3 text-primary-700 dark:text-white hover:text-primary-500 p-1.5 rounded-lg hover:bg-primary-100 transition ease-in-out duration-150",
|
|
907
|
+
onClick: handleClose,
|
|
908
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M6 18L18 6M6 6l12 12" }) })
|
|
909
|
+
}
|
|
910
|
+
) })
|
|
911
|
+
] }),
|
|
912
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm leading-5 text-primary-300", children: description }) })
|
|
913
|
+
]
|
|
914
|
+
}
|
|
915
|
+
),
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-3 flex-1 flex flex-col justify-between overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 sm:px-6", children }) }),
|
|
917
|
+
!!footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:border-t sm:border-cool-gray-200 sm:dark:border-gray-700 py-2.5 sm:py-4 px-4 sm:px-6", children: footer })
|
|
918
|
+
] })
|
|
919
|
+
}
|
|
920
|
+
)
|
|
921
|
+
}
|
|
922
|
+
)
|
|
923
|
+
}
|
|
924
|
+
)
|
|
925
|
+
}
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
function SortIcon({ direction }) {
|
|
929
|
+
if (direction === "DESC") {
|
|
930
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-sm", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4" }) }) });
|
|
931
|
+
}
|
|
932
|
+
if (direction === "ASC") {
|
|
933
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-sm", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12" }) }) });
|
|
934
|
+
}
|
|
935
|
+
return null;
|
|
936
|
+
}
|
|
937
|
+
function InlinePrompt({
|
|
938
|
+
title,
|
|
939
|
+
onConfirm,
|
|
940
|
+
className = "",
|
|
941
|
+
withText,
|
|
942
|
+
confirmText,
|
|
943
|
+
cancelText,
|
|
944
|
+
opts
|
|
945
|
+
}) {
|
|
946
|
+
const [isOpen, setIsOpen] = React15.useState(false);
|
|
947
|
+
const nodeTarget = React15.useRef(null);
|
|
948
|
+
const nodeWindow = React15.useRef(null);
|
|
949
|
+
const { condensed, blocked } = opts || {};
|
|
950
|
+
function handleClickOutside(e) {
|
|
951
|
+
if (nodeTarget.current?.contains(e.target) || nodeWindow.current?.contains(e.target)) {
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
setIsOpen(false);
|
|
955
|
+
}
|
|
956
|
+
function handleOpenConfirmation() {
|
|
957
|
+
if (!blocked) {
|
|
958
|
+
setIsOpen(true);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function handleCloseConfirmation() {
|
|
962
|
+
setIsOpen(false);
|
|
963
|
+
}
|
|
964
|
+
function handleConfirm() {
|
|
965
|
+
onConfirm();
|
|
966
|
+
setIsOpen(false);
|
|
967
|
+
}
|
|
968
|
+
React15.useEffect(() => {
|
|
969
|
+
if (isOpen) {
|
|
970
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
971
|
+
} else {
|
|
972
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
973
|
+
}
|
|
974
|
+
return () => {
|
|
975
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
976
|
+
};
|
|
977
|
+
}, [isOpen]);
|
|
978
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-block text-left", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md w-full relative", children: [
|
|
979
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
980
|
+
"a",
|
|
981
|
+
{
|
|
982
|
+
ref: nodeTarget,
|
|
983
|
+
onClick: handleOpenConfirmation,
|
|
984
|
+
className: classNames({
|
|
985
|
+
"inline-flex justify-center w-full rounded-md bg-transparent font-medium focus:outline-none focus:border-blue-300 focus:shadow-outline-blue active:bg-gray-50 transition ease-in-out duration-150 cursor-pointer": true,
|
|
986
|
+
"leading-5 px-4 py-2": !condensed,
|
|
987
|
+
"text-gray-700 hover:text-gray-500 active:text-gray-800 text-md": !className.includes("text-"),
|
|
988
|
+
...classNameObject(className)
|
|
989
|
+
}),
|
|
990
|
+
"aria-haspopup": "true",
|
|
991
|
+
"aria-expanded": "true",
|
|
992
|
+
children: title
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
996
|
+
Transition,
|
|
997
|
+
{
|
|
998
|
+
show: isOpen,
|
|
999
|
+
enter: "transition ease-out duration-100",
|
|
1000
|
+
enterFrom: "opacity-0 scale-95",
|
|
1001
|
+
enterTo: "opacity-100 scale-100",
|
|
1002
|
+
leave: "transition ease-in duration-75",
|
|
1003
|
+
leaveFrom: "opacity-100 scale-100",
|
|
1004
|
+
leaveTo: "opacity-0 scale-95",
|
|
1005
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1006
|
+
"div",
|
|
1007
|
+
{
|
|
1008
|
+
ref: nodeWindow,
|
|
1009
|
+
className: "absolute top-0 left-0 min-w-full border border-gray-200 rounded-md bg-gray-50 flex justify-center z-20",
|
|
1010
|
+
children: [
|
|
1011
|
+
/* @__PURE__ */ jsxRuntime.jsxs("a", { onClick: handleConfirm, className: "inline-flex items-center cursor-pointer m-1 text-sm text-green-500", children: [
|
|
1012
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", className: "text-green-500 w-6 h-6", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1013
|
+
"path",
|
|
1014
|
+
{
|
|
1015
|
+
fillRule: "evenodd",
|
|
1016
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
1017
|
+
clipRule: "evenodd"
|
|
1018
|
+
}
|
|
1019
|
+
) }),
|
|
1020
|
+
withText && confirmText
|
|
1021
|
+
] }),
|
|
1022
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1023
|
+
"a",
|
|
1024
|
+
{
|
|
1025
|
+
className: "inline-flex items-center cursor-pointer m-1 text-sm text-red-500",
|
|
1026
|
+
onClick: handleCloseConfirmation,
|
|
1027
|
+
children: [
|
|
1028
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", className: "text-red-500 w-6 h-6", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1029
|
+
"path",
|
|
1030
|
+
{
|
|
1031
|
+
fillRule: "evenodd",
|
|
1032
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",
|
|
1033
|
+
clipRule: "evenodd"
|
|
1034
|
+
}
|
|
1035
|
+
) }),
|
|
1036
|
+
withText && cancelText
|
|
1037
|
+
]
|
|
1038
|
+
}
|
|
1039
|
+
)
|
|
1040
|
+
]
|
|
1041
|
+
}
|
|
1042
|
+
)
|
|
1043
|
+
}
|
|
1044
|
+
)
|
|
1045
|
+
] }) });
|
|
1046
|
+
}
|
|
1047
|
+
function H1({ className, children }) {
|
|
1048
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1049
|
+
"h1",
|
|
1050
|
+
{
|
|
1051
|
+
className: classNames({
|
|
1052
|
+
"text-lg sm:text-xl font-title text-primary-500 font-semibold": true,
|
|
1053
|
+
...classNameObject(className)
|
|
1054
|
+
}),
|
|
1055
|
+
children
|
|
1056
|
+
}
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
function H2({ className, children }) {
|
|
1060
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1061
|
+
"h2",
|
|
1062
|
+
{
|
|
1063
|
+
className: classNames({
|
|
1064
|
+
"text-2xl font-semibold": true,
|
|
1065
|
+
...classNameObject(className)
|
|
1066
|
+
}),
|
|
1067
|
+
children
|
|
1068
|
+
}
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
function H3({ id, className, children }) {
|
|
1072
|
+
if (id) {
|
|
1073
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1074
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id, className: "-mt-24" }),
|
|
1075
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1076
|
+
"h3",
|
|
1077
|
+
{
|
|
1078
|
+
className: classNames({
|
|
1079
|
+
"pt-20 mb-0 text-lg font-semibold": true,
|
|
1080
|
+
...classNameObject(className)
|
|
1081
|
+
}),
|
|
1082
|
+
children
|
|
1083
|
+
}
|
|
1084
|
+
)
|
|
1085
|
+
] });
|
|
1086
|
+
}
|
|
1087
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1088
|
+
"h3",
|
|
1089
|
+
{
|
|
1090
|
+
className: classNames({
|
|
1091
|
+
"text-lg mb-0 font-semibold": true,
|
|
1092
|
+
...classNameObject(className)
|
|
1093
|
+
}),
|
|
1094
|
+
children
|
|
1095
|
+
}
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
function H4({ id, className, children }) {
|
|
1099
|
+
if (id) {
|
|
1100
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1101
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id, className: "-mt-24" }),
|
|
1102
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1103
|
+
"h4",
|
|
1104
|
+
{
|
|
1105
|
+
className: classNames({
|
|
1106
|
+
"pt-20 mb-0 text-base font-semibold": true,
|
|
1107
|
+
...classNameObject(className)
|
|
1108
|
+
}),
|
|
1109
|
+
children
|
|
1110
|
+
}
|
|
1111
|
+
)
|
|
1112
|
+
] });
|
|
1113
|
+
}
|
|
1114
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1115
|
+
"h4",
|
|
1116
|
+
{
|
|
1117
|
+
className: classNames({
|
|
1118
|
+
"text-base mb-0 font-semibold": true,
|
|
1119
|
+
...classNameObject(className)
|
|
1120
|
+
}),
|
|
1121
|
+
children
|
|
1122
|
+
}
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
function B({ children }) {
|
|
1126
|
+
return /* @__PURE__ */ jsxRuntime.jsx("b", { className: "font-semibold", children });
|
|
1127
|
+
}
|
|
1128
|
+
function Table({ children, className }) {
|
|
1129
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1130
|
+
"div",
|
|
1131
|
+
{
|
|
1132
|
+
className: classNames({
|
|
1133
|
+
...classNameObject(className),
|
|
1134
|
+
"flex flex-col relative": true,
|
|
1135
|
+
"sm:px-0 lg:px-8": !className || !className.includes("px-")
|
|
1136
|
+
}),
|
|
1137
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 py-2 px-0.5 sm:px-0 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "align-middle inline-block min-w-full shadow overflow-hidden rounded-lg border-b border-t border-gray-200", children: /* @__PURE__ */ jsxRuntime.jsx("table", { className: "min-w-full", children }) }) })
|
|
1138
|
+
}
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
function Thead({ children }) {
|
|
1142
|
+
return /* @__PURE__ */ jsxRuntime.jsx("thead", { children });
|
|
1143
|
+
}
|
|
1144
|
+
function Tr({ children }) {
|
|
1145
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tr", { children });
|
|
1146
|
+
}
|
|
1147
|
+
function Th({ condensed, className, children, sticky, ...opts }) {
|
|
1148
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1149
|
+
"th",
|
|
1150
|
+
{
|
|
1151
|
+
className: classNames({
|
|
1152
|
+
...classNameObject(className),
|
|
1153
|
+
"sticky z-10 top-0": !!sticky,
|
|
1154
|
+
"border-b border-gray-200 bg-gray-50 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider": true,
|
|
1155
|
+
"px-6": !condensed,
|
|
1156
|
+
"py-4": !condensed && (!className || !className.includes("py-")),
|
|
1157
|
+
"px-2.5": !!condensed,
|
|
1158
|
+
"py-2": !!condensed && (!className || !className.includes("py-"))
|
|
1159
|
+
}),
|
|
1160
|
+
...opts,
|
|
1161
|
+
children
|
|
1162
|
+
}
|
|
1163
|
+
);
|
|
1164
|
+
}
|
|
1165
|
+
function Tbody({ children }) {
|
|
1166
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "bg-white", children });
|
|
1167
|
+
}
|
|
1168
|
+
function Td({ className, align, colSpan, condensed, narrow, children }) {
|
|
1169
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1170
|
+
"td",
|
|
1171
|
+
{
|
|
1172
|
+
align,
|
|
1173
|
+
colSpan,
|
|
1174
|
+
className: classNames({
|
|
1175
|
+
...classNameObject(className),
|
|
1176
|
+
"whitespace-no-wrap border-b border-gray-200": true,
|
|
1177
|
+
"px-6": !condensed && !narrow,
|
|
1178
|
+
"py-4": !condensed && !narrow && (!className || !className.includes("py-")),
|
|
1179
|
+
"px-2": !!condensed,
|
|
1180
|
+
"py-2": !!condensed && (!className || !className.includes("py-")),
|
|
1181
|
+
"px-0": !!narrow,
|
|
1182
|
+
"py-0": !!narrow && (!className || !className.includes("py-"))
|
|
1183
|
+
}),
|
|
1184
|
+
children
|
|
1185
|
+
}
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
var Input = React15.forwardRef((props, ref) => {
|
|
1189
|
+
const {
|
|
1190
|
+
id,
|
|
1191
|
+
theme,
|
|
1192
|
+
className,
|
|
1193
|
+
label,
|
|
1194
|
+
placeholder,
|
|
1195
|
+
active,
|
|
1196
|
+
pattern,
|
|
1197
|
+
maxLength,
|
|
1198
|
+
inputMode,
|
|
1199
|
+
prefix,
|
|
1200
|
+
type = "text",
|
|
1201
|
+
info,
|
|
1202
|
+
defaultValue,
|
|
1203
|
+
checked,
|
|
1204
|
+
min,
|
|
1205
|
+
max,
|
|
1206
|
+
error = false,
|
|
1207
|
+
errorMessage,
|
|
1208
|
+
readOnly = false,
|
|
1209
|
+
name,
|
|
1210
|
+
autoComplete = "off",
|
|
1211
|
+
autoFocus,
|
|
1212
|
+
spellCheck,
|
|
1213
|
+
noBorder,
|
|
1214
|
+
listening,
|
|
1215
|
+
onChange,
|
|
1216
|
+
onFocus,
|
|
1217
|
+
onBlur,
|
|
1218
|
+
onClick,
|
|
1219
|
+
onKeyUp,
|
|
1220
|
+
onKeyDown,
|
|
1221
|
+
hideIndicator,
|
|
1222
|
+
darkMode
|
|
1223
|
+
} = props;
|
|
1224
|
+
const [focused, setFocused] = React15.useState(false);
|
|
1225
|
+
const inputRef = React15.useRef(null);
|
|
1226
|
+
const hasPrefix = !!prefix && prefix.length > 0;
|
|
1227
|
+
React15.useImperativeHandle(ref, () => inputRef.current);
|
|
1228
|
+
React15.useEffect(() => {
|
|
1229
|
+
if (listening && inputRef.current && defaultValue !== null && defaultValue !== void 0) {
|
|
1230
|
+
if (hasPrefix) {
|
|
1231
|
+
inputRef.current.value = prefix + String(defaultValue);
|
|
1232
|
+
} else {
|
|
1233
|
+
inputRef.current.value = String(defaultValue);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}, [defaultValue]);
|
|
1237
|
+
function handleChange(e) {
|
|
1238
|
+
const value = e.target.value;
|
|
1239
|
+
if (hasPrefix && inputRef.current) {
|
|
1240
|
+
const plainValue = hasPrefix ? value.length < prefix.length ? value.length === 1 ? value : "" : value.replace(prefix, "") : value;
|
|
1241
|
+
inputRef.current.value = prefix + plainValue;
|
|
1242
|
+
if (typeof onChange === "function") {
|
|
1243
|
+
if (type === "checkbox") {
|
|
1244
|
+
onChange(e.target.checked);
|
|
1245
|
+
} else {
|
|
1246
|
+
onChange(plainValue);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
} else {
|
|
1250
|
+
if (typeof onChange === "function") {
|
|
1251
|
+
if (type === "checkbox") {
|
|
1252
|
+
onChange(e.target.checked);
|
|
1253
|
+
} else {
|
|
1254
|
+
onChange(value);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
function handleFocus(e) {
|
|
1260
|
+
if (type === "search") {
|
|
1261
|
+
setFocused(true);
|
|
1262
|
+
}
|
|
1263
|
+
if (typeof onFocus === "function") {
|
|
1264
|
+
onFocus(e);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
function handleBlur(e) {
|
|
1268
|
+
if (type === "search") {
|
|
1269
|
+
setFocused(false);
|
|
1270
|
+
}
|
|
1271
|
+
if (typeof onBlur === "function") {
|
|
1272
|
+
onBlur(e);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1276
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
|
|
1277
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1278
|
+
"input",
|
|
1279
|
+
{
|
|
1280
|
+
id,
|
|
1281
|
+
className: classNames({
|
|
1282
|
+
...classNameObject(className),
|
|
1283
|
+
"px-3 group form-input placeholder-gray-300 dark:placeholder-charcoal-400 focus:outline-none block transition ease-in-out duration-150 text-black dark:text-charcoal-100 dark:bg-charcoal-800 shadow-sm focus:dark:text-primary-500 focus:dark:border-primary-500 focus:dark:ring-primary-500": true,
|
|
1284
|
+
"!text-white !border-charcoal-400 !placeholder-charcoal-400 focus:!text-primary-500 focus:!border-primary-500 focus:!ring-primary-500": !!darkMode,
|
|
1285
|
+
"h-11": !className || !className.includes("h-"),
|
|
1286
|
+
"text-sm": type !== "tel",
|
|
1287
|
+
"text-lg": type === "tel",
|
|
1288
|
+
"rounded-lg": type !== "radio",
|
|
1289
|
+
"rounded-full": type === "radio",
|
|
1290
|
+
"border border-gray-200 dark:border-charcoal-700 shadow-sm text-black": !noBorder && !readOnly && type !== "radio",
|
|
1291
|
+
"border border-opacity-20 bg-gray-100 cursor-not-allowed": readOnly,
|
|
1292
|
+
"border-transparent": !!noBorder,
|
|
1293
|
+
"border-red-300 text-red-900 placeholder-red-100 focus:placeholder-red-100 focus:border-red-500 focus:ring-red-300": error,
|
|
1294
|
+
"focus:ring-primary-500": !error && type !== "radio",
|
|
1295
|
+
"focus:ring-transparent": type === "radio",
|
|
1296
|
+
"w-full": type !== "radio" && (!className || className.includes("w-full") || !className.includes("w-")),
|
|
1297
|
+
"sm:leading-normal": !className || !className.includes("leading-"),
|
|
1298
|
+
"cursor-pointer": type === "checkbox" || type === "button",
|
|
1299
|
+
"text-black h-4 w-4": type === "radio",
|
|
1300
|
+
"pr-10": type === "search"
|
|
1301
|
+
}),
|
|
1302
|
+
...type === "button" ? { value: label } : {},
|
|
1303
|
+
inputMode,
|
|
1304
|
+
pattern,
|
|
1305
|
+
name,
|
|
1306
|
+
min,
|
|
1307
|
+
max,
|
|
1308
|
+
ref: inputRef,
|
|
1309
|
+
type,
|
|
1310
|
+
maxLength,
|
|
1311
|
+
defaultValue,
|
|
1312
|
+
placeholder,
|
|
1313
|
+
readOnly,
|
|
1314
|
+
autoComplete,
|
|
1315
|
+
autoFocus,
|
|
1316
|
+
spellCheck,
|
|
1317
|
+
onClick,
|
|
1318
|
+
onChange: handleChange,
|
|
1319
|
+
onFocus: handleFocus,
|
|
1320
|
+
onBlur: handleBlur,
|
|
1321
|
+
onKeyUp,
|
|
1322
|
+
onKeyDown
|
|
1323
|
+
}
|
|
1324
|
+
),
|
|
1325
|
+
error && !hideIndicator && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1326
|
+
"div",
|
|
1327
|
+
{
|
|
1328
|
+
className: classNames({
|
|
1329
|
+
"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none": true,
|
|
1330
|
+
"!text-white focus:!text-primary-500": !!darkMode
|
|
1331
|
+
}),
|
|
1332
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-5 h-5 text-red-500", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1333
|
+
"path",
|
|
1334
|
+
{
|
|
1335
|
+
fillRule: "evenodd",
|
|
1336
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",
|
|
1337
|
+
clipRule: "evenodd"
|
|
1338
|
+
}
|
|
1339
|
+
) })
|
|
1340
|
+
}
|
|
1341
|
+
),
|
|
1342
|
+
type === "search" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1343
|
+
"div",
|
|
1344
|
+
{
|
|
1345
|
+
className: classNames({
|
|
1346
|
+
"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none focus:outline-none active:outline-none": true,
|
|
1347
|
+
"!text-white": !!darkMode,
|
|
1348
|
+
"text-gray-600": !focused,
|
|
1349
|
+
"!text-primary-500": focused
|
|
1350
|
+
}),
|
|
1351
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1352
|
+
"path",
|
|
1353
|
+
{
|
|
1354
|
+
fillRule: "evenodd",
|
|
1355
|
+
d: "M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z",
|
|
1356
|
+
clipRule: "evenodd"
|
|
1357
|
+
}
|
|
1358
|
+
) })
|
|
1359
|
+
}
|
|
1360
|
+
)
|
|
1361
|
+
] }),
|
|
1362
|
+
error && errorMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-sm text-red-600", children: errorMessage }),
|
|
1363
|
+
info != null && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-sm text-gray-500", children: info })
|
|
1364
|
+
] });
|
|
1365
|
+
});
|
|
1366
|
+
Input.displayName = "Input";
|
|
1367
|
+
var Input_default = Input;
|
|
1368
|
+
function Label({
|
|
1369
|
+
className,
|
|
1370
|
+
error = false,
|
|
1371
|
+
htmlFor,
|
|
1372
|
+
info,
|
|
1373
|
+
mandatory,
|
|
1374
|
+
opts,
|
|
1375
|
+
children
|
|
1376
|
+
}) {
|
|
1377
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1378
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1379
|
+
"label",
|
|
1380
|
+
{
|
|
1381
|
+
htmlFor,
|
|
1382
|
+
className: classNames({
|
|
1383
|
+
"block text-sm font-medium mb-1.5 text-black dark:text-white": true,
|
|
1384
|
+
"text-black dark:text-white/80": !error,
|
|
1385
|
+
"text-red-600": error,
|
|
1386
|
+
...classNameObject(className)
|
|
1387
|
+
}),
|
|
1388
|
+
children: [
|
|
1389
|
+
children,
|
|
1390
|
+
mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-1", children: "*" })
|
|
1391
|
+
]
|
|
1392
|
+
}
|
|
1393
|
+
),
|
|
1394
|
+
info && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1395
|
+
"span",
|
|
1396
|
+
{
|
|
1397
|
+
className: classNames({
|
|
1398
|
+
"text-sm leading-5 text-black mb-1.5": true,
|
|
1399
|
+
"text-red-600": error
|
|
1400
|
+
}),
|
|
1401
|
+
children: info
|
|
1402
|
+
}
|
|
1403
|
+
)
|
|
1404
|
+
] });
|
|
1405
|
+
}
|
|
1406
|
+
var Select = React15.forwardRef((props, ref) => {
|
|
1407
|
+
const {
|
|
1408
|
+
id,
|
|
1409
|
+
loading = false,
|
|
1410
|
+
className,
|
|
1411
|
+
onChange,
|
|
1412
|
+
error = false,
|
|
1413
|
+
errorMessage,
|
|
1414
|
+
info,
|
|
1415
|
+
readOnly = false,
|
|
1416
|
+
name,
|
|
1417
|
+
children,
|
|
1418
|
+
value
|
|
1419
|
+
} = props;
|
|
1420
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1421
|
+
!loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md shadow-sm border border-gray-200", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1422
|
+
"select",
|
|
1423
|
+
{
|
|
1424
|
+
id,
|
|
1425
|
+
value,
|
|
1426
|
+
className: classNames({
|
|
1427
|
+
...classNameObject(className),
|
|
1428
|
+
...classNameObject(
|
|
1429
|
+
`form-select block w-full transition duration-150 ease-in-out ${error ? "border-red-300 text-red-900 placeholder-red-300 focus:border-red-300 focus:shadow-outline-red" : ""}`
|
|
1430
|
+
)
|
|
1431
|
+
}),
|
|
1432
|
+
ref,
|
|
1433
|
+
name,
|
|
1434
|
+
disabled: readOnly,
|
|
1435
|
+
onChange,
|
|
1436
|
+
children
|
|
1437
|
+
}
|
|
1438
|
+
) }),
|
|
1439
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex relative w-6 loading" }),
|
|
1440
|
+
error && errorMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-sm text-red-600", children: errorMessage }),
|
|
1441
|
+
info != null && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-sm text-gray-500", children: info })
|
|
1442
|
+
] });
|
|
1443
|
+
});
|
|
1444
|
+
Select.displayName = "Select";
|
|
1445
|
+
var Select_default = Select;
|
|
1446
|
+
var SelectInput = React15.forwardRef((props, ref) => {
|
|
1447
|
+
const {
|
|
1448
|
+
className,
|
|
1449
|
+
placeholder = "Select an option",
|
|
1450
|
+
items = [],
|
|
1451
|
+
selectedValue = "",
|
|
1452
|
+
readOnly = false,
|
|
1453
|
+
error = false,
|
|
1454
|
+
onChange = () => {
|
|
1455
|
+
}
|
|
1456
|
+
} = props;
|
|
1457
|
+
function handleOnChange(event) {
|
|
1458
|
+
const value = event.target.value;
|
|
1459
|
+
if (typeof onChange === "function") {
|
|
1460
|
+
onChange(value);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1464
|
+
"select",
|
|
1465
|
+
{
|
|
1466
|
+
onChange: handleOnChange,
|
|
1467
|
+
value: selectedValue || "",
|
|
1468
|
+
disabled: readOnly,
|
|
1469
|
+
className: classNames({
|
|
1470
|
+
"form-select block w-full transition duration-150 ease-in-out border border-gray-200 rounded-md shadow-sm text-sm px-3 h-11 text-black": true,
|
|
1471
|
+
"cursor-not-allowed border bg-gray-100": readOnly,
|
|
1472
|
+
"border-red-300 text-red-900 placeholder-red-100 focus:placeholder-red-100 focus:border-red-500 focus:ring-red-300": error
|
|
1473
|
+
}),
|
|
1474
|
+
children: [
|
|
1475
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: placeholder }, ""),
|
|
1476
|
+
items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: item.id, children: item.name }, index))
|
|
1477
|
+
]
|
|
1478
|
+
}
|
|
1479
|
+
);
|
|
1480
|
+
});
|
|
1481
|
+
SelectInput.displayName = "SelectInput";
|
|
1482
|
+
var SelectInput_default = SelectInput;
|
|
1483
|
+
var Textarea = React15.forwardRef((props, ref) => {
|
|
1484
|
+
const {
|
|
1485
|
+
id,
|
|
1486
|
+
className,
|
|
1487
|
+
onChange,
|
|
1488
|
+
onFocus,
|
|
1489
|
+
onMouseDown,
|
|
1490
|
+
placeholder,
|
|
1491
|
+
error = false,
|
|
1492
|
+
errorMessage,
|
|
1493
|
+
info,
|
|
1494
|
+
readOnly = false,
|
|
1495
|
+
name,
|
|
1496
|
+
defaultValue,
|
|
1497
|
+
rows,
|
|
1498
|
+
opts,
|
|
1499
|
+
autoFocus
|
|
1500
|
+
} = props;
|
|
1501
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1502
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative rounded-xl shadow-sm", "data-plate-focus": opts?.plateFocus, children: [
|
|
1503
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1504
|
+
"textarea",
|
|
1505
|
+
{
|
|
1506
|
+
"data-plate-focus": opts?.plateFocus,
|
|
1507
|
+
autoFocus,
|
|
1508
|
+
id,
|
|
1509
|
+
rows,
|
|
1510
|
+
placeholder,
|
|
1511
|
+
className: classNames({
|
|
1512
|
+
...classNameObject(className),
|
|
1513
|
+
"form-input border block w-full placeholder-gray-300 dark:placeholder-white/50 dark:focus:placeholder-charcoal-400 text-sm transition ease-in-out duration-150 px-3 py-2 border-gray-200 dark:border-charcoal-700 text-black dark:text-charcoal-100 dark:bg-charcoal-800 rounded-lg": true,
|
|
1514
|
+
"focus:ring-white dark:focus:ring-1 dark:focus:border-primary-600 dark:focus:ring-primary-500": !error,
|
|
1515
|
+
"focus:outline-none focus:ring-0 focus:ring-offset-0 dark:focus:border-primary-500": true,
|
|
1516
|
+
"border-red-300 text-red-900 placeholder-red-300 dark:placeholder-red-600 focus:border-red-300 focus:shadow-outline-red": error
|
|
1517
|
+
}),
|
|
1518
|
+
name,
|
|
1519
|
+
ref,
|
|
1520
|
+
defaultValue,
|
|
1521
|
+
onFocus,
|
|
1522
|
+
onMouseDown,
|
|
1523
|
+
onChange,
|
|
1524
|
+
readOnly
|
|
1525
|
+
}
|
|
1526
|
+
),
|
|
1527
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-2 right-0 pr-3 flex pointer-events-none", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-5 w-5 text-red-500", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1528
|
+
"path",
|
|
1529
|
+
{
|
|
1530
|
+
fillRule: "evenodd",
|
|
1531
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",
|
|
1532
|
+
clipRule: "evenodd"
|
|
1533
|
+
}
|
|
1534
|
+
) }) })
|
|
1535
|
+
] }),
|
|
1536
|
+
error && errorMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-sm text-red-600", children: errorMessage }),
|
|
1537
|
+
info != null && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-sm text-gray-500", children: info })
|
|
1538
|
+
] });
|
|
1539
|
+
});
|
|
1540
|
+
Textarea.displayName = "Textarea";
|
|
1541
|
+
var Textarea_default = Textarea;
|
|
1542
|
+
function TagInput({
|
|
1543
|
+
name,
|
|
1544
|
+
defaultValue,
|
|
1545
|
+
onChange,
|
|
1546
|
+
placeholder
|
|
1547
|
+
}) {
|
|
1548
|
+
const [currentState, setCurrentState] = React15.useState(0);
|
|
1549
|
+
const tagInputRef = React15.useRef(null);
|
|
1550
|
+
function reducer(state, action) {
|
|
1551
|
+
const updatedValues = { ...state };
|
|
1552
|
+
if ("tags" in action) {
|
|
1553
|
+
updatedValues.tags = Array.from(new Set(action.tags));
|
|
1554
|
+
}
|
|
1555
|
+
if ("reset" in action && action.reset) {
|
|
1556
|
+
updatedValues.tags = [];
|
|
1557
|
+
}
|
|
1558
|
+
if ("render" in action && action.render) {
|
|
1559
|
+
setCurrentState(1 - currentState);
|
|
1560
|
+
}
|
|
1561
|
+
return updatedValues;
|
|
1562
|
+
}
|
|
1563
|
+
const [values, dispatch] = React15.useReducer(reducer, {
|
|
1564
|
+
tags: []
|
|
1565
|
+
});
|
|
1566
|
+
const { tags } = values;
|
|
1567
|
+
React15.useEffect(() => {
|
|
1568
|
+
if (defaultValue) {
|
|
1569
|
+
dispatch({ tags: defaultValue, render: true });
|
|
1570
|
+
} else {
|
|
1571
|
+
dispatch({ reset: true, render: true });
|
|
1572
|
+
}
|
|
1573
|
+
}, [defaultValue]);
|
|
1574
|
+
function handleAddTag(event) {
|
|
1575
|
+
if (event.key === "Enter") {
|
|
1576
|
+
const value = event.target.value;
|
|
1577
|
+
if (!value) return false;
|
|
1578
|
+
const newTags = Array.from(/* @__PURE__ */ new Set([...tags, value]));
|
|
1579
|
+
dispatch({ tags: newTags, render: true });
|
|
1580
|
+
if (typeof onChange === "function") {
|
|
1581
|
+
onChange(newTags);
|
|
1582
|
+
}
|
|
1583
|
+
if (tagInputRef.current) {
|
|
1584
|
+
tagInputRef.current.value = "";
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function handleRemoveTag(tag) {
|
|
1589
|
+
if (!tag) return false;
|
|
1590
|
+
const newTags = tags.filter((i) => i !== tag);
|
|
1591
|
+
dispatch({ tags: newTags, render: true });
|
|
1592
|
+
if (typeof onChange === "function") {
|
|
1593
|
+
onChange(newTags);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center w-full flex-wrap px-2 pt-2 pb-1 border border-gray-300 rounded-md", children: [
|
|
1597
|
+
tags.map((tag, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1598
|
+
"span",
|
|
1599
|
+
{
|
|
1600
|
+
className: "inline-flex bg-primary-200 text-primary-800 text-sm rounded-full h-6 px-3 justify-center items-center mr-1 mb-1",
|
|
1601
|
+
children: [
|
|
1602
|
+
tag,
|
|
1603
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1604
|
+
"svg",
|
|
1605
|
+
{
|
|
1606
|
+
className: "w-4 h-4 ml-1 cursor-pointer",
|
|
1607
|
+
fill: "currentColor",
|
|
1608
|
+
viewBox: "0 0 20 20",
|
|
1609
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1610
|
+
onClick: () => handleRemoveTag(tag),
|
|
1611
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1612
|
+
"path",
|
|
1613
|
+
{
|
|
1614
|
+
fillRule: "evenodd",
|
|
1615
|
+
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",
|
|
1616
|
+
clipRule: "evenodd"
|
|
1617
|
+
}
|
|
1618
|
+
)
|
|
1619
|
+
}
|
|
1620
|
+
)
|
|
1621
|
+
]
|
|
1622
|
+
},
|
|
1623
|
+
index
|
|
1624
|
+
)),
|
|
1625
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1626
|
+
"input",
|
|
1627
|
+
{
|
|
1628
|
+
ref: tagInputRef,
|
|
1629
|
+
className: "ml-2 text-sm focus:border-transparent focus:outline-none mb-1",
|
|
1630
|
+
placeholder: tags && tags.length > 0 ? "" : placeholder,
|
|
1631
|
+
onKeyDown: handleAddTag
|
|
1632
|
+
}
|
|
1633
|
+
)
|
|
1634
|
+
] });
|
|
1635
|
+
}
|
|
1636
|
+
function NoData({ className }) {
|
|
1637
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-col items-center text-center my-8 ${className || ""}`, children: [
|
|
1638
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1639
|
+
"img",
|
|
1640
|
+
{
|
|
1641
|
+
src: "/img/no-data.png",
|
|
1642
|
+
width: 420,
|
|
1643
|
+
height: 307,
|
|
1644
|
+
className: "max-w-[90%]",
|
|
1645
|
+
alt: "no data found"
|
|
1646
|
+
}
|
|
1647
|
+
),
|
|
1648
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-[90%] flex flex-col text-center", children: [
|
|
1649
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-6 font-medium text-gray-900 mt-3 dark:text-white/50", children: "It's empty." }),
|
|
1650
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-4 text-gray-700 dark:text-white/60", children: "Nothing to do for now." })
|
|
1651
|
+
] })
|
|
1652
|
+
] });
|
|
1653
|
+
}
|
|
1654
|
+
var ThemeContext = React15.createContext(void 0);
|
|
1655
|
+
function ThemeProvider({ children, defaultTheme = "system" }) {
|
|
1656
|
+
const [mode, setMode] = React15.useState(defaultTheme);
|
|
1657
|
+
const [isDark, setIsDark] = React15.useState(false);
|
|
1658
|
+
const stateRef = React15.useRef(mode);
|
|
1659
|
+
React15.useEffect(() => {
|
|
1660
|
+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
1661
|
+
const isDark2 = mode === "dark" || mode === "system" && prefersDark;
|
|
1662
|
+
document.documentElement.classList.toggle("dark", isDark2);
|
|
1663
|
+
stateRef.current = mode;
|
|
1664
|
+
setIsDark(isDark2);
|
|
1665
|
+
}, [mode]);
|
|
1666
|
+
React15.useEffect(() => {
|
|
1667
|
+
const saved = localStorage.getItem("theme") || defaultTheme;
|
|
1668
|
+
setMode(saved);
|
|
1669
|
+
}, [defaultTheme]);
|
|
1670
|
+
React15.useEffect(() => {
|
|
1671
|
+
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1672
|
+
const listener = () => {
|
|
1673
|
+
const prevMode = stateRef.current;
|
|
1674
|
+
if (prevMode !== "system") {
|
|
1675
|
+
setTimeout(() => {
|
|
1676
|
+
document.documentElement.classList.toggle("dark", prevMode === "dark");
|
|
1677
|
+
}, 100);
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
media.addEventListener("change", listener);
|
|
1681
|
+
return () => media.removeEventListener("change", listener);
|
|
1682
|
+
}, []);
|
|
1683
|
+
function handleToggleTheme(triggerMode) {
|
|
1684
|
+
const triggeredMode = triggerMode === mode ? "system" : triggerMode;
|
|
1685
|
+
setMode(triggeredMode);
|
|
1686
|
+
if (!triggeredMode || triggeredMode === "system") {
|
|
1687
|
+
localStorage.removeItem("theme");
|
|
1688
|
+
} else {
|
|
1689
|
+
localStorage.setItem("theme", triggeredMode);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1693
|
+
ThemeContext.Provider,
|
|
1694
|
+
{
|
|
1695
|
+
value: {
|
|
1696
|
+
theme: mode,
|
|
1697
|
+
darkMode: isDark,
|
|
1698
|
+
handleToggleTheme
|
|
1699
|
+
},
|
|
1700
|
+
children
|
|
1701
|
+
}
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
function useThemeContext() {
|
|
1705
|
+
const context = React15.useContext(ThemeContext);
|
|
1706
|
+
if (!context) {
|
|
1707
|
+
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
1708
|
+
}
|
|
1709
|
+
return context;
|
|
1710
|
+
}
|
|
1711
|
+
function ThemeToggle() {
|
|
1712
|
+
const { theme, handleToggleTheme } = useThemeContext();
|
|
1713
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-charcoal-700 dark:text-white z-30 flex space-x-1.5 items-center", children: [
|
|
1714
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1715
|
+
"div",
|
|
1716
|
+
{
|
|
1717
|
+
className: classNames({
|
|
1718
|
+
"opacity-20 cursor-pointer": true,
|
|
1719
|
+
"!opacity-100": theme === "light"
|
|
1720
|
+
}),
|
|
1721
|
+
onClick: () => handleToggleTheme("light"),
|
|
1722
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-6 h-6", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" }) })
|
|
1723
|
+
}
|
|
1724
|
+
),
|
|
1725
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1726
|
+
"div",
|
|
1727
|
+
{
|
|
1728
|
+
className: classNames({
|
|
1729
|
+
"opacity-20 cursor-pointer": true,
|
|
1730
|
+
"!opacity-100": theme === "dark"
|
|
1731
|
+
}),
|
|
1732
|
+
onClick: () => handleToggleTheme("dark"),
|
|
1733
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-5 h-5", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z" }) })
|
|
1734
|
+
}
|
|
1735
|
+
)
|
|
1736
|
+
] });
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
// src/utils/debounce.ts
|
|
1740
|
+
function debounce(fn, delay) {
|
|
1741
|
+
let timeoutId;
|
|
1742
|
+
return function(...args) {
|
|
1743
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
1744
|
+
timeoutId = setTimeout(() => {
|
|
1745
|
+
fn.apply(this, args);
|
|
1746
|
+
}, delay);
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
// src/hooks/useDebounce.ts
|
|
1751
|
+
function useDebounce(callback, delay, deps = []) {
|
|
1752
|
+
const callbackFn = React15.useCallback(debounce(callback, delay), deps);
|
|
1753
|
+
return [callbackFn];
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
// src/hooks/useResizeListener.ts
|
|
1757
|
+
function useResizeListener(props = {}) {
|
|
1758
|
+
const [values, setValues] = React15.useState(
|
|
1759
|
+
[
|
|
1760
|
+
typeof window === "undefined" ? props.mobileAgent ? 375 : 1080 : window.innerWidth,
|
|
1761
|
+
typeof window === "undefined" ? props.mobileAgent ? 812 : 750 : window.innerHeight,
|
|
1762
|
+
typeof window === "undefined" ? null : window.innerWidth < 576 ? "mobile" : "desktop",
|
|
1763
|
+
typeof window === "undefined" ? null : window.innerWidth < 576 ? "portrait-view" : "landscape-view",
|
|
1764
|
+
typeof window === "undefined" ? props.mobileAgent || null : window.innerWidth < 576 ? true : false,
|
|
1765
|
+
typeof window === "undefined" ? props.mobileAgent || null : window.innerWidth >= 576 && window.innerWidth < 992 ? true : false
|
|
1766
|
+
]
|
|
1767
|
+
);
|
|
1768
|
+
const [screenWidth, screenHeight, viewport, viewMode, mobileView, tabletView] = values || [];
|
|
1769
|
+
function handleChangeViewport() {
|
|
1770
|
+
setValues([
|
|
1771
|
+
window.innerWidth,
|
|
1772
|
+
window.innerHeight,
|
|
1773
|
+
window.innerWidth < 576 ? "mobile" : "desktop",
|
|
1774
|
+
window.innerWidth < 576 ? "portrait-view" : "landscape-view",
|
|
1775
|
+
window.innerWidth < 576 ? true : false,
|
|
1776
|
+
window.innerWidth >= 576 && window.innerWidth < 992 ? true : false
|
|
1777
|
+
]);
|
|
1778
|
+
}
|
|
1779
|
+
const [debouncedSetValue] = useDebounce(handleChangeViewport, 300);
|
|
1780
|
+
React15.useEffect(() => {
|
|
1781
|
+
window.addEventListener("resize", debouncedSetValue);
|
|
1782
|
+
return () => {
|
|
1783
|
+
window.removeEventListener("resize", debouncedSetValue);
|
|
1784
|
+
};
|
|
1785
|
+
}, [debouncedSetValue]);
|
|
1786
|
+
return { screenWidth, screenHeight, viewport, viewMode, mobileView, tabletView };
|
|
1787
|
+
}
|
|
1788
|
+
var PopoverContext = React15.createContext(void 0);
|
|
1789
|
+
function PopoverCard({
|
|
1790
|
+
show,
|
|
1791
|
+
style,
|
|
1792
|
+
tooltipStyle,
|
|
1793
|
+
position,
|
|
1794
|
+
description,
|
|
1795
|
+
actions,
|
|
1796
|
+
onClose
|
|
1797
|
+
}) {
|
|
1798
|
+
function handleMenuClick(action) {
|
|
1799
|
+
if (typeof action === "function") {
|
|
1800
|
+
action();
|
|
1801
|
+
}
|
|
1802
|
+
if (typeof onClose === "function") {
|
|
1803
|
+
onClose();
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
function handleCloseMenu() {
|
|
1807
|
+
if (typeof onClose === "function") {
|
|
1808
|
+
onClose();
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
const stickyTop = position === "top";
|
|
1812
|
+
if (typeof document === "undefined") return null;
|
|
1813
|
+
return reactDom.createPortal(
|
|
1814
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1815
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1816
|
+
"div",
|
|
1817
|
+
{
|
|
1818
|
+
className: classNames({
|
|
1819
|
+
"hidden sm:block fixed text-sm z-[9999] w-52 max-h-64 overflow-y-auto border border-gray-100 bg-white dark:bg-charcoal-800 dark:border-charcoal-700 shadow-md rounded-md pt-3 pb-2": true,
|
|
1820
|
+
"pointer-events-none opacity-0": !show,
|
|
1821
|
+
"opacity-100": show
|
|
1822
|
+
}),
|
|
1823
|
+
style: style || void 0,
|
|
1824
|
+
children: [
|
|
1825
|
+
!!description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pb-1 opacity-70", children: description }),
|
|
1826
|
+
actions && actions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1.5 w-full", children: actions.filter((action) => (action.items || []).length > 0).map((action, actionIndex) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1827
|
+
actionIndex > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-px bg-gray-100 dark:bg-charcoal-800 mb-3" }),
|
|
1828
|
+
action.section && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 text-xxs sm:text-xs uppercase text-gray-500 dark:text-white dark:hover", children: action.section }),
|
|
1829
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1830
|
+
"div",
|
|
1831
|
+
{
|
|
1832
|
+
className: classNames({
|
|
1833
|
+
"mt-1": !!action.section
|
|
1834
|
+
}),
|
|
1835
|
+
children: (action.items || []).map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1836
|
+
"div",
|
|
1837
|
+
{
|
|
1838
|
+
className: "text-sm sm:text-base px-3 py-1.5 text-charcoal-700 dark:text-charcoal-300 hover:text-gray-900 hover:bg-gray-200 hover:dark:text-charcoal-200 hover:dark:bg-charcoal-700 cursor-pointer whitespace-normal",
|
|
1839
|
+
onClick: () => handleMenuClick(item.action || item.onClick),
|
|
1840
|
+
children: item.label
|
|
1841
|
+
},
|
|
1842
|
+
item.id
|
|
1843
|
+
))
|
|
1844
|
+
}
|
|
1845
|
+
)
|
|
1846
|
+
] }, action.id)) })
|
|
1847
|
+
]
|
|
1848
|
+
}
|
|
1849
|
+
),
|
|
1850
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1851
|
+
"div",
|
|
1852
|
+
{
|
|
1853
|
+
className: classNames({
|
|
1854
|
+
"hidden sm:block fixed z-[9999] rotate-45 w-4 h-4 overflow-y-auto border-gray-100 bg-white dark:bg-charcoal-700 dark:border-charcoal-800": true,
|
|
1855
|
+
"border-t border-l": !stickyTop,
|
|
1856
|
+
"border-b border-r": stickyTop,
|
|
1857
|
+
"pointer-events-none opacity-0": !show,
|
|
1858
|
+
"opacity-100": show
|
|
1859
|
+
}),
|
|
1860
|
+
style: tooltipStyle || void 0
|
|
1861
|
+
}
|
|
1862
|
+
),
|
|
1863
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames({
|
|
1864
|
+
"block sm:hidden fixed inset-0 z-[9999] pointer-events-none": true
|
|
1865
|
+
}), children: [
|
|
1866
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1867
|
+
"div",
|
|
1868
|
+
{
|
|
1869
|
+
className: classNames({
|
|
1870
|
+
"absolute inset-0 bg-black/50 transition-opacity duration-300": true,
|
|
1871
|
+
"opacity-0": !show,
|
|
1872
|
+
"opacity-100 pointer-events-auto": show
|
|
1873
|
+
}),
|
|
1874
|
+
onClick: handleCloseMenu
|
|
1875
|
+
}
|
|
1876
|
+
),
|
|
1877
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1878
|
+
"div",
|
|
1879
|
+
{
|
|
1880
|
+
className: classNames({
|
|
1881
|
+
"absolute bottom-0 left-0 right-0 bg-white dark:bg-charcoal-800 overflow-hidden transition-transform duration-300 transform": true,
|
|
1882
|
+
"translate-y-full": !show,
|
|
1883
|
+
"translate-y-0 pointer-events-auto": show
|
|
1884
|
+
}),
|
|
1885
|
+
children: [
|
|
1886
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-3", children: [
|
|
1887
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-gray-900 dark:text-white", children: "Menu" }),
|
|
1888
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1889
|
+
"div",
|
|
1890
|
+
{
|
|
1891
|
+
onClick: handleCloseMenu,
|
|
1892
|
+
className: "p-1 -mr-1 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-charcoal-700 rounded-full",
|
|
1893
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
1894
|
+
}
|
|
1895
|
+
)
|
|
1896
|
+
] }),
|
|
1897
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 pb-6 max-h-[70vh] overflow-y-auto", children: [
|
|
1898
|
+
!!description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-4 text-sm text-gray-500 dark:text-gray-400", children: description }),
|
|
1899
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: actions && actions.filter((action) => (action.items || []).length > 0).map((action, actionIndex) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1900
|
+
action.section && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium uppercase text-gray-500 dark:text-gray-400 mb-2", children: action.section }),
|
|
1901
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: (action.items || []).map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1902
|
+
"div",
|
|
1903
|
+
{
|
|
1904
|
+
className: "py-1.5 px-2 -mx-2 flex items-center text-base text-gray-900 dark:text-gray-200 active:bg-gray-50 dark:active:bg-charcoal-700 rounded-lg cursor-pointer",
|
|
1905
|
+
onClick: () => handleMenuClick(item.action || item.onClick),
|
|
1906
|
+
children: item.label
|
|
1907
|
+
},
|
|
1908
|
+
item.id
|
|
1909
|
+
)) }),
|
|
1910
|
+
actionIndex < actions.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "mt-2 border-transparent" })
|
|
1911
|
+
] }, action.id)) })
|
|
1912
|
+
] })
|
|
1913
|
+
]
|
|
1914
|
+
}
|
|
1915
|
+
)
|
|
1916
|
+
] }),
|
|
1917
|
+
show && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1918
|
+
"div",
|
|
1919
|
+
{
|
|
1920
|
+
className: "hidden sm:block fixed inset-0",
|
|
1921
|
+
onClick: handleCloseMenu
|
|
1922
|
+
}
|
|
1923
|
+
)
|
|
1924
|
+
] }),
|
|
1925
|
+
document.body
|
|
1926
|
+
);
|
|
1927
|
+
}
|
|
1928
|
+
var resetValues = {
|
|
1929
|
+
show: false,
|
|
1930
|
+
style: null,
|
|
1931
|
+
tooltipStyle: null,
|
|
1932
|
+
position: null,
|
|
1933
|
+
description: null,
|
|
1934
|
+
actions: null
|
|
1935
|
+
};
|
|
1936
|
+
function PopoverProvider({ children }) {
|
|
1937
|
+
const [currentState, setCurrentState] = React15.useState(0);
|
|
1938
|
+
const [values, dispatch] = React15.useReducer(reducer, resetValues);
|
|
1939
|
+
const { show, style, tooltipStyle, position, description, actions } = values;
|
|
1940
|
+
function reducer(state, action) {
|
|
1941
|
+
const updatedValues = { ...state };
|
|
1942
|
+
if ("show" in action) {
|
|
1943
|
+
updatedValues.show = action.show;
|
|
1944
|
+
}
|
|
1945
|
+
if ("style" in action) {
|
|
1946
|
+
updatedValues.style = action.style;
|
|
1947
|
+
}
|
|
1948
|
+
if ("tooltipStyle" in action) {
|
|
1949
|
+
updatedValues.tooltipStyle = action.tooltipStyle;
|
|
1950
|
+
}
|
|
1951
|
+
if ("position" in action) {
|
|
1952
|
+
updatedValues.position = action.position;
|
|
1953
|
+
}
|
|
1954
|
+
if ("description" in action) {
|
|
1955
|
+
updatedValues.description = action.description;
|
|
1956
|
+
}
|
|
1957
|
+
if ("actions" in action) {
|
|
1958
|
+
updatedValues.actions = action.actions;
|
|
1959
|
+
}
|
|
1960
|
+
if ("render" in action && !!action.render) {
|
|
1961
|
+
setCurrentState((prev) => 1 - prev);
|
|
1962
|
+
}
|
|
1963
|
+
return updatedValues;
|
|
1964
|
+
}
|
|
1965
|
+
function handleShowPopover(params) {
|
|
1966
|
+
dispatch({
|
|
1967
|
+
...params,
|
|
1968
|
+
render: true
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
function handleClosePopover() {
|
|
1972
|
+
dispatch({
|
|
1973
|
+
...resetValues,
|
|
1974
|
+
render: true
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1978
|
+
PopoverContext.Provider,
|
|
1979
|
+
{
|
|
1980
|
+
value: {
|
|
1981
|
+
showPopover: show,
|
|
1982
|
+
setPopover: handleShowPopover
|
|
1983
|
+
},
|
|
1984
|
+
children: [
|
|
1985
|
+
children,
|
|
1986
|
+
!!show && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1987
|
+
PopoverCard,
|
|
1988
|
+
{
|
|
1989
|
+
show,
|
|
1990
|
+
style,
|
|
1991
|
+
tooltipStyle,
|
|
1992
|
+
position,
|
|
1993
|
+
description,
|
|
1994
|
+
actions,
|
|
1995
|
+
onClose: handleClosePopover
|
|
1996
|
+
}
|
|
1997
|
+
)
|
|
1998
|
+
]
|
|
1999
|
+
}
|
|
2000
|
+
);
|
|
2001
|
+
}
|
|
2002
|
+
function usePopoverContext() {
|
|
2003
|
+
const context = React15.useContext(PopoverContext);
|
|
2004
|
+
if (!context) {
|
|
2005
|
+
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
2006
|
+
}
|
|
2007
|
+
return context;
|
|
2008
|
+
}
|
|
2009
|
+
function Popover({ className, description, actions, children, opts }) {
|
|
2010
|
+
const { activated } = opts || {};
|
|
2011
|
+
const { showPopover, setPopover } = usePopoverContext();
|
|
2012
|
+
const { screenWidth, screenHeight } = useResizeListener();
|
|
2013
|
+
const [menuData, setMenuData] = React15.useState({ showMenu: false, x: 0, y: 0, left: 0, right: 0, top: 0, bottom: 0 });
|
|
2014
|
+
const parentRef = React15.useRef(null);
|
|
2015
|
+
(actions || []).some((action) => (action.items || []).length > 0);
|
|
2016
|
+
React15.useEffect(() => {
|
|
2017
|
+
const stickyTop = menuData.showMenu && screenHeight - (menuData.y + 14) < 300;
|
|
2018
|
+
setPopover({
|
|
2019
|
+
show: menuData.showMenu,
|
|
2020
|
+
style: !stickyTop ? {
|
|
2021
|
+
top: menuData.bottom + 14,
|
|
2022
|
+
right: screenWidth - menuData.right - 6
|
|
2023
|
+
} : {
|
|
2024
|
+
bottom: screenHeight - menuData.top + 12,
|
|
2025
|
+
right: screenWidth - menuData.right - 6
|
|
2026
|
+
},
|
|
2027
|
+
tooltipStyle: !stickyTop ? {
|
|
2028
|
+
top: menuData.bottom + 6,
|
|
2029
|
+
right: screenWidth - menuData.right + 6
|
|
2030
|
+
} : {
|
|
2031
|
+
bottom: screenHeight - menuData.top + 4,
|
|
2032
|
+
right: screenWidth - menuData.right + 6
|
|
2033
|
+
},
|
|
2034
|
+
position: stickyTop ? "top" : "bottom",
|
|
2035
|
+
description,
|
|
2036
|
+
actions
|
|
2037
|
+
});
|
|
2038
|
+
}, [menuData, screenWidth, screenHeight, description, actions, setPopover]);
|
|
2039
|
+
React15.useEffect(() => {
|
|
2040
|
+
if (!showPopover && !!menuData.showMenu) {
|
|
2041
|
+
setMenuData((prev) => ({
|
|
2042
|
+
...prev,
|
|
2043
|
+
showMenu: false
|
|
2044
|
+
}));
|
|
2045
|
+
}
|
|
2046
|
+
}, [showPopover, menuData.showMenu]);
|
|
2047
|
+
function handleToggleMenu(e) {
|
|
2048
|
+
e.stopPropagation();
|
|
2049
|
+
if (menuData.showMenu) {
|
|
2050
|
+
handleCloseMenu();
|
|
2051
|
+
} else {
|
|
2052
|
+
handleOpenMenu();
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
function handleOpenMenu() {
|
|
2056
|
+
if (parentRef && parentRef.current) {
|
|
2057
|
+
const coords = parentRef.current.getBoundingClientRect();
|
|
2058
|
+
setMenuData({
|
|
2059
|
+
showMenu: true,
|
|
2060
|
+
left: coords.left,
|
|
2061
|
+
right: coords.right,
|
|
2062
|
+
top: coords.top,
|
|
2063
|
+
bottom: coords.bottom,
|
|
2064
|
+
x: screenWidth - coords.right,
|
|
2065
|
+
y: coords.bottom
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
function handleCloseMenu() {
|
|
2070
|
+
setMenuData({
|
|
2071
|
+
showMenu: false,
|
|
2072
|
+
x: 0,
|
|
2073
|
+
y: 0,
|
|
2074
|
+
left: 0,
|
|
2075
|
+
right: 0,
|
|
2076
|
+
top: 0,
|
|
2077
|
+
bottom: 0
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "block h-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2081
|
+
"div",
|
|
2082
|
+
{
|
|
2083
|
+
ref: parentRef,
|
|
2084
|
+
className: classNames({
|
|
2085
|
+
"cursor-pointer py-0.5 px-2 h-full flex items-center justify-center hover:bg-gray-300/50 hover:dark:bg-charcoal-700 rounded-xl": true,
|
|
2086
|
+
"bg-gray-300/50 dark:bg-charcoal-700": menuData.showMenu && !activated,
|
|
2087
|
+
...classNameObject(className)
|
|
2088
|
+
}),
|
|
2089
|
+
onClick: handleToggleMenu,
|
|
2090
|
+
children
|
|
2091
|
+
}
|
|
2092
|
+
) });
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
// src/utils/format.ts
|
|
2096
|
+
var srgbToLinear = (c) => {
|
|
2097
|
+
c /= 255;
|
|
2098
|
+
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
2099
|
+
};
|
|
2100
|
+
var luminance = (r, g, b) => {
|
|
2101
|
+
const R = srgbToLinear(r);
|
|
2102
|
+
const G = srgbToLinear(g);
|
|
2103
|
+
const B2 = srgbToLinear(b);
|
|
2104
|
+
return 0.2126 * R + 0.7152 * G + 0.0722 * B2;
|
|
2105
|
+
};
|
|
2106
|
+
var contrastRatio = (L1, L2) => {
|
|
2107
|
+
const [light, dark] = L1 > L2 ? [L1, L2] : [L2, L1];
|
|
2108
|
+
return (light + 0.05) / (dark + 0.05);
|
|
2109
|
+
};
|
|
2110
|
+
var hexToRgb = (hex) => {
|
|
2111
|
+
hex = hex.replace(/^#/, "");
|
|
2112
|
+
if (hex.length === 3) {
|
|
2113
|
+
hex = hex.split("").map((x) => x + x).join("");
|
|
2114
|
+
}
|
|
2115
|
+
const num = parseInt(hex, 16);
|
|
2116
|
+
return {
|
|
2117
|
+
r: num >> 16 & 255,
|
|
2118
|
+
g: num >> 8 & 255,
|
|
2119
|
+
b: num & 255
|
|
2120
|
+
};
|
|
2121
|
+
};
|
|
2122
|
+
function bestTextColorForBg(hex) {
|
|
2123
|
+
const { r, g, b } = hexToRgb(hex || "#FFFFFF");
|
|
2124
|
+
const Lbg = luminance(r, g, b);
|
|
2125
|
+
const contrastWithWhite = contrastRatio(Lbg, 1);
|
|
2126
|
+
const contrastWithBlack = contrastRatio(Lbg, 0);
|
|
2127
|
+
return contrastWithWhite >= contrastWithBlack ? "white" : "black";
|
|
2128
|
+
}
|
|
2129
|
+
var numberFormatter = (x, decimal, opts) => {
|
|
2130
|
+
const { decimalSign, thousandSign } = opts || {};
|
|
2131
|
+
if (x === null || x === void 0 || x === "") return "";
|
|
2132
|
+
const parsedX = typeof x === "string" ? parseFloat(x) : x;
|
|
2133
|
+
if (isNaN(parsedX)) return "";
|
|
2134
|
+
const value = Math.round(parsedX * 100) / 100;
|
|
2135
|
+
if (typeof decimal == "number") {
|
|
2136
|
+
if (Math.floor(value) == value) {
|
|
2137
|
+
return value.toFixed(decimal || 0).toString().replace(/\B(?=(\d{3})+(?!\d))/g, thousandSign || ",");
|
|
2138
|
+
}
|
|
2139
|
+
return value.toFixed(decimal).toString().replace(".", decimalSign || ".").replace(/\B(?=(\d{3})+(?!\d))/g, thousandSign || ",");
|
|
2140
|
+
}
|
|
2141
|
+
return parsedX.toString().replace(/\B(?=(\d{3})+(?!\d))/g, thousandSign || ",");
|
|
2142
|
+
};
|
|
2143
|
+
function moveItem(items, movedItem, fromIndex, toIndex) {
|
|
2144
|
+
return items.reduce((prev, item, itemIndex) => {
|
|
2145
|
+
if (itemIndex === fromIndex) {
|
|
2146
|
+
return prev;
|
|
2147
|
+
}
|
|
2148
|
+
if (itemIndex === toIndex) {
|
|
2149
|
+
if (fromIndex < toIndex) {
|
|
2150
|
+
return [...prev, item, movedItem];
|
|
2151
|
+
} else {
|
|
2152
|
+
return [...prev, movedItem, item];
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
return [...prev, item];
|
|
2156
|
+
}, []);
|
|
2157
|
+
}
|
|
2158
|
+
function Dragger({
|
|
2159
|
+
type,
|
|
2160
|
+
parentClassName,
|
|
2161
|
+
header,
|
|
2162
|
+
records,
|
|
2163
|
+
timestamp,
|
|
2164
|
+
disabled,
|
|
2165
|
+
children,
|
|
2166
|
+
onChange
|
|
2167
|
+
}) {
|
|
2168
|
+
const [, setCurrentState] = React15.useState(0);
|
|
2169
|
+
const [values, dispatch] = React15.useReducer(reducer, {
|
|
2170
|
+
items: null,
|
|
2171
|
+
displayItems: null,
|
|
2172
|
+
dragging: false,
|
|
2173
|
+
dragItem: null,
|
|
2174
|
+
dragFrom: null,
|
|
2175
|
+
dragTo: null,
|
|
2176
|
+
updated: false,
|
|
2177
|
+
timer: null
|
|
2178
|
+
});
|
|
2179
|
+
const { items, displayItems, dragging, dragItem, dragFrom, dragTo, updated } = values || {};
|
|
2180
|
+
const grandChildren = children && children.props.children;
|
|
2181
|
+
const isValid = !disabled && !!records && !!children && !!grandChildren && grandChildren.length > 0;
|
|
2182
|
+
React15.useEffect(() => {
|
|
2183
|
+
dispatch({
|
|
2184
|
+
items: grandChildren,
|
|
2185
|
+
updated: false,
|
|
2186
|
+
render: true
|
|
2187
|
+
});
|
|
2188
|
+
}, [timestamp, grandChildren]);
|
|
2189
|
+
React15.useEffect(() => {
|
|
2190
|
+
if (!updated) {
|
|
2191
|
+
if (grandChildren && grandChildren.length > 0) {
|
|
2192
|
+
dispatch({
|
|
2193
|
+
items: grandChildren,
|
|
2194
|
+
displayItems: grandChildren,
|
|
2195
|
+
updated: false,
|
|
2196
|
+
render: true
|
|
2197
|
+
});
|
|
2198
|
+
} else {
|
|
2199
|
+
dispatch({
|
|
2200
|
+
items: [],
|
|
2201
|
+
displayItems: [],
|
|
2202
|
+
updated: false,
|
|
2203
|
+
render: true
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
}, [grandChildren, updated]);
|
|
2208
|
+
function reducer(state, action) {
|
|
2209
|
+
const updatedValues = { ...state };
|
|
2210
|
+
if ("items" in action) {
|
|
2211
|
+
updatedValues.items = action.items;
|
|
2212
|
+
}
|
|
2213
|
+
if ("displayItems" in action) {
|
|
2214
|
+
updatedValues.displayItems = action.displayItems;
|
|
2215
|
+
}
|
|
2216
|
+
if ("dragging" in action) {
|
|
2217
|
+
updatedValues.dragging = action.dragging;
|
|
2218
|
+
}
|
|
2219
|
+
if ("dragItem" in action) {
|
|
2220
|
+
updatedValues.dragItem = action.dragItem;
|
|
2221
|
+
}
|
|
2222
|
+
if ("dragFrom" in action) {
|
|
2223
|
+
updatedValues.dragFrom = action.dragFrom;
|
|
2224
|
+
}
|
|
2225
|
+
if ("dragTo" in action) {
|
|
2226
|
+
updatedValues.dragTo = action.dragTo;
|
|
2227
|
+
}
|
|
2228
|
+
if ("updated" in action) {
|
|
2229
|
+
updatedValues.updated = action.updated;
|
|
2230
|
+
}
|
|
2231
|
+
if ("timer" in action) {
|
|
2232
|
+
updatedValues.timer = action.timer;
|
|
2233
|
+
}
|
|
2234
|
+
if ("cursorX" in action) {
|
|
2235
|
+
updatedValues.cursorX = action.cursorX;
|
|
2236
|
+
}
|
|
2237
|
+
if ("cursorY" in action) {
|
|
2238
|
+
updatedValues.cursorY = action.cursorY;
|
|
2239
|
+
}
|
|
2240
|
+
if (action.render) {
|
|
2241
|
+
setCurrentState((prev) => 1 - prev);
|
|
2242
|
+
}
|
|
2243
|
+
return updatedValues;
|
|
2244
|
+
}
|
|
2245
|
+
if (!isValid) {
|
|
2246
|
+
if (type === "table") {
|
|
2247
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: parentClassName, children: [
|
|
2248
|
+
header,
|
|
2249
|
+
children
|
|
2250
|
+
] });
|
|
2251
|
+
}
|
|
2252
|
+
return children;
|
|
2253
|
+
}
|
|
2254
|
+
function handleDragStart(e, item, index) {
|
|
2255
|
+
e.stopPropagation();
|
|
2256
|
+
dispatch({
|
|
2257
|
+
dragging: true,
|
|
2258
|
+
dragItem: item,
|
|
2259
|
+
dragFrom: index,
|
|
2260
|
+
render: true
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
function handleDragEnd() {
|
|
2264
|
+
if (dragFrom !== dragTo) {
|
|
2265
|
+
const updatedItems = moveItem(items || [], dragItem, dragFrom, dragTo);
|
|
2266
|
+
dispatch({
|
|
2267
|
+
items: updatedItems,
|
|
2268
|
+
displayItems: updatedItems,
|
|
2269
|
+
dragging: false,
|
|
2270
|
+
dragItem: null,
|
|
2271
|
+
dragFrom: null,
|
|
2272
|
+
dragTo: null,
|
|
2273
|
+
updated: true,
|
|
2274
|
+
render: true
|
|
2275
|
+
});
|
|
2276
|
+
if (typeof onChange === "function") {
|
|
2277
|
+
const updated2 = !!updatedItems && updatedItems.map((updatedItem) => records.find((record) => record.id === updatedItem.key));
|
|
2278
|
+
onChange(updated2);
|
|
2279
|
+
}
|
|
2280
|
+
} else {
|
|
2281
|
+
dispatch({
|
|
2282
|
+
items,
|
|
2283
|
+
displayItems,
|
|
2284
|
+
dragging: false,
|
|
2285
|
+
dragItem: null,
|
|
2286
|
+
dragFrom: null,
|
|
2287
|
+
dragTo: null,
|
|
2288
|
+
render: true
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
function handleDragOver(ev, index) {
|
|
2293
|
+
ev.preventDefault();
|
|
2294
|
+
if (dragging && dragTo !== index) {
|
|
2295
|
+
if (dragFrom !== index) {
|
|
2296
|
+
const updatedItems = moveItem(items || [], dragItem, dragFrom, index);
|
|
2297
|
+
dispatch({
|
|
2298
|
+
displayItems: updatedItems,
|
|
2299
|
+
dragTo: index,
|
|
2300
|
+
render: dragTo !== index
|
|
2301
|
+
});
|
|
2302
|
+
} else {
|
|
2303
|
+
dispatch({
|
|
2304
|
+
displayItems: items,
|
|
2305
|
+
dragTo: index,
|
|
2306
|
+
render: dragTo !== index
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
function handleContextMenu(e) {
|
|
2312
|
+
e.preventDefault();
|
|
2313
|
+
}
|
|
2314
|
+
function handleTouchStart(e) {
|
|
2315
|
+
const touch = e.touches[0] || e.changedTouches[0];
|
|
2316
|
+
const { clientX, clientY } = touch;
|
|
2317
|
+
const timer = setTimeout(() => handleLongTouchStart({ clientX, clientY }), 500);
|
|
2318
|
+
dispatch({
|
|
2319
|
+
timer,
|
|
2320
|
+
cursorX: clientX,
|
|
2321
|
+
cursorY: clientY,
|
|
2322
|
+
dragging: false
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
function handleLongTouchStart({ clientX, clientY }) {
|
|
2326
|
+
const difference = Math.abs(clientY - (values.cursorY || 0));
|
|
2327
|
+
if (difference > 40) {
|
|
2328
|
+
return false;
|
|
2329
|
+
}
|
|
2330
|
+
dispatch({ dragging: true });
|
|
2331
|
+
const cards = records;
|
|
2332
|
+
let elementInBoundary = null;
|
|
2333
|
+
let elementIndex = null;
|
|
2334
|
+
for (let i = 0; i < cards.length; i++) {
|
|
2335
|
+
const cardItem = cards[i];
|
|
2336
|
+
if (!!cardItem) {
|
|
2337
|
+
const element = document.getElementById(cardItem.id);
|
|
2338
|
+
if (element) {
|
|
2339
|
+
const { top, right, bottom, left } = element.getBoundingClientRect();
|
|
2340
|
+
if (left <= clientX && clientX <= right && top <= clientY && clientY <= bottom) {
|
|
2341
|
+
elementInBoundary = element;
|
|
2342
|
+
elementIndex = i;
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
if (elementInBoundary && elementIndex !== null && items) {
|
|
2349
|
+
dispatch({
|
|
2350
|
+
dragging: true,
|
|
2351
|
+
dragItem: items[elementIndex],
|
|
2352
|
+
dragFrom: elementIndex,
|
|
2353
|
+
render: true
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
function handleTouchMove(e) {
|
|
2358
|
+
const touch = e.touches[0] || e.changedTouches[0];
|
|
2359
|
+
const { clientX, clientY } = touch;
|
|
2360
|
+
dispatch({
|
|
2361
|
+
cursorX: clientX,
|
|
2362
|
+
cursorY: clientY
|
|
2363
|
+
});
|
|
2364
|
+
if (values.dragging && items) {
|
|
2365
|
+
const cards = records;
|
|
2366
|
+
let targetIndex = null;
|
|
2367
|
+
for (let i = 0; i < cards.length; i++) {
|
|
2368
|
+
const cardItem = cards[i];
|
|
2369
|
+
if (!!cardItem) {
|
|
2370
|
+
const element = document.getElementById(cardItem.id);
|
|
2371
|
+
if (element) {
|
|
2372
|
+
const { top, right, bottom, left } = element.getBoundingClientRect();
|
|
2373
|
+
if (left <= clientX && clientX <= right && top <= clientY && clientY <= bottom) {
|
|
2374
|
+
targetIndex = i;
|
|
2375
|
+
break;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
if (targetIndex !== null && values.dragFrom !== targetIndex) {
|
|
2381
|
+
const updatedItems = moveItem(items, values.dragItem, values.dragFrom, targetIndex);
|
|
2382
|
+
dispatch({
|
|
2383
|
+
displayItems: updatedItems,
|
|
2384
|
+
dragTo: targetIndex,
|
|
2385
|
+
render: dragTo !== targetIndex
|
|
2386
|
+
});
|
|
2387
|
+
} else {
|
|
2388
|
+
dispatch({
|
|
2389
|
+
displayItems: items,
|
|
2390
|
+
dragTo: values.dragFrom,
|
|
2391
|
+
render: dragTo !== values.dragFrom
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
function handleTouchEnd() {
|
|
2397
|
+
if (dragFrom !== dragTo) {
|
|
2398
|
+
const updatedItems = moveItem(values.items || [], values.dragItem, values.dragFrom, values.dragTo);
|
|
2399
|
+
dispatch({
|
|
2400
|
+
items: updatedItems,
|
|
2401
|
+
displayItems: updatedItems,
|
|
2402
|
+
dragging: false,
|
|
2403
|
+
dragItem: null,
|
|
2404
|
+
dragFrom: null,
|
|
2405
|
+
dragTo: null,
|
|
2406
|
+
updated: true,
|
|
2407
|
+
render: true
|
|
2408
|
+
});
|
|
2409
|
+
if (typeof onChange === "function") {
|
|
2410
|
+
const updated2 = !!updatedItems && updatedItems.map((updatedItem) => records.find((record) => record.id === updatedItem.key));
|
|
2411
|
+
onChange(updated2);
|
|
2412
|
+
}
|
|
2413
|
+
} else {
|
|
2414
|
+
dispatch({
|
|
2415
|
+
items,
|
|
2416
|
+
displayItems,
|
|
2417
|
+
dragging: false,
|
|
2418
|
+
dragItem: null,
|
|
2419
|
+
dragFrom: null,
|
|
2420
|
+
dragTo: null,
|
|
2421
|
+
render: true
|
|
2422
|
+
});
|
|
2423
|
+
}
|
|
2424
|
+
if (values.timer) {
|
|
2425
|
+
clearTimeout(values.timer);
|
|
2426
|
+
}
|
|
2427
|
+
dispatch({ dragging: false });
|
|
2428
|
+
}
|
|
2429
|
+
const derivedItems = !!items && React15__default.default.cloneElement(children, {
|
|
2430
|
+
children: items.map((grandChild, index) => {
|
|
2431
|
+
return React15__default.default.cloneElement(grandChild, {
|
|
2432
|
+
id: (records[index] || {}).id,
|
|
2433
|
+
draggable: true,
|
|
2434
|
+
className: classNames({
|
|
2435
|
+
...classNameObject(grandChild.props.className),
|
|
2436
|
+
"opacity-0": !!dragging && dragTo === index
|
|
2437
|
+
}),
|
|
2438
|
+
onDragStart: (e) => handleDragStart(e, grandChild, index),
|
|
2439
|
+
onDragEnd: () => handleDragEnd(),
|
|
2440
|
+
onDragOver: (ev) => handleDragOver(ev, index),
|
|
2441
|
+
onTouchStart: (e) => handleTouchStart(e),
|
|
2442
|
+
onTouchMove: (e) => handleTouchMove(e),
|
|
2443
|
+
onTouchEnd: () => handleTouchEnd(),
|
|
2444
|
+
onContextMenu: (e) => handleContextMenu(e)
|
|
2445
|
+
});
|
|
2446
|
+
})
|
|
2447
|
+
});
|
|
2448
|
+
const derivedDisplayItems = !!displayItems && React15__default.default.cloneElement(children, {
|
|
2449
|
+
children: displayItems.map((grandChild, index) => {
|
|
2450
|
+
return React15__default.default.cloneElement(grandChild, {
|
|
2451
|
+
draggable: true,
|
|
2452
|
+
className: classNames({
|
|
2453
|
+
...classNameObject(grandChild.props.className),
|
|
2454
|
+
"opacity-25 sm:opacity-0": !!dragging && dragTo === index
|
|
2455
|
+
})
|
|
2456
|
+
});
|
|
2457
|
+
})
|
|
2458
|
+
});
|
|
2459
|
+
if (type === "table") {
|
|
2460
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2461
|
+
"table",
|
|
2462
|
+
{
|
|
2463
|
+
className: classNames({
|
|
2464
|
+
"relative": true,
|
|
2465
|
+
...classNameObject(parentClassName)
|
|
2466
|
+
}),
|
|
2467
|
+
children: [
|
|
2468
|
+
header,
|
|
2469
|
+
derivedItems,
|
|
2470
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2471
|
+
"tbody",
|
|
2472
|
+
{
|
|
2473
|
+
className: classNames({
|
|
2474
|
+
"absolute top-10 left-0 right-0 z-20 pointer-events-none": true,
|
|
2475
|
+
"hidden": !dragging
|
|
2476
|
+
}),
|
|
2477
|
+
children: derivedDisplayItems
|
|
2478
|
+
}
|
|
2479
|
+
)
|
|
2480
|
+
]
|
|
2481
|
+
}
|
|
2482
|
+
);
|
|
2483
|
+
}
|
|
2484
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
2485
|
+
derivedItems,
|
|
2486
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2487
|
+
"div",
|
|
2488
|
+
{
|
|
2489
|
+
className: classNames({
|
|
2490
|
+
"absolute top-0 left-0 right-0 z-20 pointer-events-none bg-white dark:bg-gray-900": true,
|
|
2491
|
+
"hidden": !dragging
|
|
2492
|
+
}),
|
|
2493
|
+
children: derivedDisplayItems
|
|
2494
|
+
}
|
|
2495
|
+
)
|
|
2496
|
+
] });
|
|
2497
|
+
}
|
|
2498
|
+
function ExcelTable({
|
|
2499
|
+
columns = [],
|
|
2500
|
+
data = [],
|
|
2501
|
+
onChange,
|
|
2502
|
+
onRowAdd,
|
|
2503
|
+
onRowDelete,
|
|
2504
|
+
placeholder,
|
|
2505
|
+
isAddRowVisible = true,
|
|
2506
|
+
addRowLabel = "+ Add Option"
|
|
2507
|
+
}) {
|
|
2508
|
+
const [editingCell, setEditingCell] = React15.useState(null);
|
|
2509
|
+
React15.useEffect(() => {
|
|
2510
|
+
setTimeout(() => {
|
|
2511
|
+
const textareas = document.querySelectorAll(".excel-table-textarea");
|
|
2512
|
+
textareas.forEach((ta) => {
|
|
2513
|
+
ta.style.height = "auto";
|
|
2514
|
+
ta.style.height = ta.scrollHeight + "px";
|
|
2515
|
+
});
|
|
2516
|
+
}, 0);
|
|
2517
|
+
}, [data]);
|
|
2518
|
+
const handleCellNavigation = (e, currentRow, currentCol) => {
|
|
2519
|
+
const isEditing = editingCell?.row === currentRow && editingCell?.col === currentCol;
|
|
2520
|
+
const totalRows = data.length;
|
|
2521
|
+
const totalCols = columns.length + 1;
|
|
2522
|
+
const addRowIndex = totalRows;
|
|
2523
|
+
let nextRow = currentRow;
|
|
2524
|
+
let nextCol = currentCol;
|
|
2525
|
+
const isAddRow = currentRow === addRowIndex;
|
|
2526
|
+
if (isEditing) {
|
|
2527
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
2528
|
+
setEditingCell(null);
|
|
2529
|
+
if (currentRow < totalRows - 1) nextRow = currentRow + 1;
|
|
2530
|
+
else if (currentRow === totalRows - 1) nextRow = addRowIndex;
|
|
2531
|
+
} else {
|
|
2532
|
+
return;
|
|
2533
|
+
}
|
|
2534
|
+
} else {
|
|
2535
|
+
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
2536
|
+
e.preventDefault();
|
|
2537
|
+
if (e.key === "ArrowUp") {
|
|
2538
|
+
if (isAddRow) nextRow = totalRows - 1;
|
|
2539
|
+
else nextRow = Math.max(0, currentRow - 1);
|
|
2540
|
+
}
|
|
2541
|
+
if (e.key === "ArrowDown") {
|
|
2542
|
+
if (currentRow < totalRows - 1) nextRow = currentRow + 1;
|
|
2543
|
+
else if (currentRow === totalRows - 1) nextRow = addRowIndex;
|
|
2544
|
+
}
|
|
2545
|
+
if (e.key === "ArrowLeft") nextCol = Math.max(0, currentCol - 1);
|
|
2546
|
+
if (e.key === "ArrowRight") nextCol = Math.min(totalCols - 1, currentCol + 1);
|
|
2547
|
+
} else if (e.key === "Enter") {
|
|
2548
|
+
e.preventDefault();
|
|
2549
|
+
if (isAddRow) {
|
|
2550
|
+
onRowAdd && onRowAdd();
|
|
2551
|
+
setTimeout(() => {
|
|
2552
|
+
const target = document.querySelector(`[data-row="${totalRows}"][data-col="0"]`);
|
|
2553
|
+
if (target) {
|
|
2554
|
+
target.focus();
|
|
2555
|
+
target.click();
|
|
2556
|
+
}
|
|
2557
|
+
}, 0);
|
|
2558
|
+
return;
|
|
2559
|
+
} else if (currentCol < columns.length) {
|
|
2560
|
+
setEditingCell({ row: currentRow, col: currentCol });
|
|
2561
|
+
} else {
|
|
2562
|
+
onRowDelete && onRowDelete(currentRow);
|
|
2563
|
+
setTimeout(() => {
|
|
2564
|
+
const targetRow = currentRow < data.length - 1 ? currentRow : Math.max(0, currentRow - 1);
|
|
2565
|
+
const target = document.querySelector(`[data-row="${targetRow}"][data-col="${columns.length}"]`);
|
|
2566
|
+
if (target) target.focus();
|
|
2567
|
+
else {
|
|
2568
|
+
const addBtn = document.getElementById("add-option-btn");
|
|
2569
|
+
if (addBtn) addBtn.focus();
|
|
2570
|
+
}
|
|
2571
|
+
}, 0);
|
|
2572
|
+
return;
|
|
2573
|
+
}
|
|
2574
|
+
} else if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && !isAddRow && currentCol < columns.length) {
|
|
2575
|
+
setEditingCell({ row: currentRow, col: currentCol });
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
if (nextRow !== currentRow || nextCol !== currentCol) {
|
|
2580
|
+
if (nextRow === addRowIndex) {
|
|
2581
|
+
const target = document.getElementById("add-option-btn");
|
|
2582
|
+
if (target) target.focus();
|
|
2583
|
+
} else {
|
|
2584
|
+
const target = document.querySelector(`[data-row="${nextRow}"][data-col="${nextCol}"]`);
|
|
2585
|
+
if (target) {
|
|
2586
|
+
target.focus();
|
|
2587
|
+
if (target.tagName === "INPUT" && target.type !== "checkbox" || target.tagName === "TEXTAREA") {
|
|
2588
|
+
target.select();
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2594
|
+
const handleFocus = (e, row, col) => {
|
|
2595
|
+
if (editingCell?.row !== row || editingCell?.col !== col) {
|
|
2596
|
+
setEditingCell(null);
|
|
2597
|
+
e.target.select();
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
const handleChange = (rowIdx, colId, val) => {
|
|
2601
|
+
const newData = [...data];
|
|
2602
|
+
newData[rowIdx] = { ...newData[rowIdx], [colId]: val };
|
|
2603
|
+
onChange && onChange(newData);
|
|
2604
|
+
};
|
|
2605
|
+
const handlePaste = (e, startRow, startCol) => {
|
|
2606
|
+
e.preventDefault();
|
|
2607
|
+
const clipboardData = e.clipboardData.getData("text/plain");
|
|
2608
|
+
const rows = clipboardData.split(/\r\n|\n|\r/).filter((row) => row.trim() !== "");
|
|
2609
|
+
let newData = [...data];
|
|
2610
|
+
rows.forEach((row, rIdx) => {
|
|
2611
|
+
const targetRowIdx = startRow + rIdx;
|
|
2612
|
+
const cells = row.split(" ");
|
|
2613
|
+
if (!newData[targetRowIdx]) {
|
|
2614
|
+
newData[targetRowIdx] = {};
|
|
2615
|
+
}
|
|
2616
|
+
columns.forEach((col, cIdx) => {
|
|
2617
|
+
const colIndexInPaste = cIdx - startCol;
|
|
2618
|
+
if (colIndexInPaste >= 0 && cells[colIndexInPaste] !== void 0) {
|
|
2619
|
+
const val = cells[colIndexInPaste];
|
|
2620
|
+
newData[targetRowIdx] = { ...newData[targetRowIdx], [col.id]: val };
|
|
2621
|
+
}
|
|
2622
|
+
});
|
|
2623
|
+
});
|
|
2624
|
+
onChange && onChange(newData);
|
|
2625
|
+
};
|
|
2626
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border border-gray-200 dark:border-charcoal-600 rounded-sm overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full border-collapse bg-white dark:bg-charcoal-900", children: [
|
|
2627
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2628
|
+
columns.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2629
|
+
"th",
|
|
2630
|
+
{
|
|
2631
|
+
className: classNames({
|
|
2632
|
+
"border-b border-r border-gray-200 dark:border-charcoal-600 bg-gray-50 dark:bg-charcoal-800 px-3 py-2 text-xs font-semibold text-gray-500": true,
|
|
2633
|
+
"w-auto": !col.width,
|
|
2634
|
+
[col.width || ""]: !!col.width,
|
|
2635
|
+
"text-left": !col.align,
|
|
2636
|
+
"text-center": col.align === "center",
|
|
2637
|
+
"text-right": col.align === "right"
|
|
2638
|
+
}),
|
|
2639
|
+
children: col.label
|
|
2640
|
+
},
|
|
2641
|
+
col.id || idx
|
|
2642
|
+
)),
|
|
2643
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "border-b border-gray-200 dark:border-charcoal-600 bg-gray-50 dark:bg-charcoal-800 w-8" })
|
|
2644
|
+
] }) }),
|
|
2645
|
+
/* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
|
|
2646
|
+
data.map((row, rowIdx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "group", children: [
|
|
2647
|
+
columns.map((col, colIdx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2648
|
+
"td",
|
|
2649
|
+
{
|
|
2650
|
+
className: "border-b border-r border-gray-200 dark:border-charcoal-600 p-0 relative align-top h-auto",
|
|
2651
|
+
children: col.type === "textarea" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2652
|
+
"textarea",
|
|
2653
|
+
{
|
|
2654
|
+
rows: 1,
|
|
2655
|
+
value: row[col.id] || "",
|
|
2656
|
+
onChange: (e) => {
|
|
2657
|
+
handleChange(rowIdx, col.id, e.target.value);
|
|
2658
|
+
e.target.style.height = "auto";
|
|
2659
|
+
e.target.style.height = e.target.scrollHeight + "px";
|
|
2660
|
+
},
|
|
2661
|
+
onFocus: (e) => handleFocus(e, rowIdx, colIdx),
|
|
2662
|
+
onKeyDown: (e) => handleCellNavigation(e, rowIdx, colIdx),
|
|
2663
|
+
onPaste: (e) => handlePaste(e, rowIdx, colIdx),
|
|
2664
|
+
"data-row": rowIdx,
|
|
2665
|
+
"data-col": colIdx,
|
|
2666
|
+
placeholder: typeof placeholder === "function" ? placeholder(rowIdx) : placeholder,
|
|
2667
|
+
className: "excel-table-textarea w-full min-h-[38px] px-3 py-2 border-none focus:ring-2 focus:ring-primary-500 focus:ring-inset bg-transparent outline-none text-sm text-gray-900 dark:text-white placeholder-gray-400 resize-none overflow-hidden leading-normal block",
|
|
2668
|
+
style: { height: "auto" }
|
|
2669
|
+
}
|
|
2670
|
+
) : col.type === "checkbox" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-[38px]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2671
|
+
"input",
|
|
2672
|
+
{
|
|
2673
|
+
type: "checkbox",
|
|
2674
|
+
checked: !!row[col.id],
|
|
2675
|
+
onChange: (e) => handleChange(rowIdx, col.id, e.target.checked),
|
|
2676
|
+
onKeyDown: (e) => handleCellNavigation(e, rowIdx, colIdx),
|
|
2677
|
+
"data-row": rowIdx,
|
|
2678
|
+
"data-col": colIdx,
|
|
2679
|
+
className: "w-5 h-5 cursor-pointer accent-primary-500"
|
|
2680
|
+
}
|
|
2681
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2682
|
+
"input",
|
|
2683
|
+
{
|
|
2684
|
+
type: col.type === "number" ? "number" : "text",
|
|
2685
|
+
value: row[col.id] || "",
|
|
2686
|
+
onChange: (e) => handleChange(rowIdx, col.id, e.target.value),
|
|
2687
|
+
onFocus: (e) => handleFocus(e, rowIdx, colIdx),
|
|
2688
|
+
onKeyDown: (e) => handleCellNavigation(e, rowIdx, colIdx),
|
|
2689
|
+
onPaste: (e) => handlePaste(e, rowIdx, colIdx),
|
|
2690
|
+
"data-row": rowIdx,
|
|
2691
|
+
"data-col": colIdx,
|
|
2692
|
+
className: classNames({
|
|
2693
|
+
"w-full h-full min-h-[38px] px-3 py-1 border-none focus:ring-2 focus:ring-primary-500 focus:ring-inset bg-transparent outline-none text-sm text-gray-900 dark:text-white": true,
|
|
2694
|
+
"text-left": col.align !== "center" && col.align !== "right",
|
|
2695
|
+
"text-center": col.align === "center",
|
|
2696
|
+
"text-right": col.align === "right"
|
|
2697
|
+
}),
|
|
2698
|
+
placeholder: col.type === "number" ? "0" : ""
|
|
2699
|
+
}
|
|
2700
|
+
)
|
|
2701
|
+
},
|
|
2702
|
+
col.id || colIdx
|
|
2703
|
+
)),
|
|
2704
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "border-b border-gray-200 dark:border-charcoal-600 p-0 text-center align-top h-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2705
|
+
"div",
|
|
2706
|
+
{
|
|
2707
|
+
onClick: () => onRowDelete && onRowDelete(rowIdx),
|
|
2708
|
+
onFocus: () => setEditingCell(null),
|
|
2709
|
+
onKeyDown: (e) => handleCellNavigation(e, rowIdx, columns.length),
|
|
2710
|
+
"data-row": rowIdx,
|
|
2711
|
+
"data-col": columns.length,
|
|
2712
|
+
tabIndex: 0,
|
|
2713
|
+
className: "cursor-pointer text-gray-300 hover:text-red-500 w-full h-[38px] flex items-center justify-center transition-colors focus:ring-2 focus:ring-inset focus:ring-primary-500 outline-none",
|
|
2714
|
+
children: "\xD7"
|
|
2715
|
+
}
|
|
2716
|
+
) })
|
|
2717
|
+
] }, rowIdx)),
|
|
2718
|
+
isAddRowVisible && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: columns.length + 1, className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2719
|
+
"div",
|
|
2720
|
+
{
|
|
2721
|
+
id: "add-option-btn",
|
|
2722
|
+
onClick: onRowAdd,
|
|
2723
|
+
onKeyDown: (e) => handleCellNavigation(e, data.length, 0),
|
|
2724
|
+
tabIndex: 0,
|
|
2725
|
+
className: "w-full cursor-pointer text-left px-3 py-2 text-gray-400 text-xs font-medium hover:text-primary-500 hover:bg-gray-50 dark:hover:bg-charcoal-800 transition-colors focus:ring-2 focus:ring-inset focus:ring-primary-500 outline-none",
|
|
2726
|
+
children: addRowLabel
|
|
2727
|
+
}
|
|
2728
|
+
) }) })
|
|
2729
|
+
] })
|
|
2730
|
+
] }) });
|
|
2731
|
+
}
|
|
2732
|
+
function Coverflow({ images = [], onClose }) {
|
|
2733
|
+
const scrollContainerRef = React15.useRef(null);
|
|
2734
|
+
const thumbnailContainerRef = React15.useRef(null);
|
|
2735
|
+
const [visualIndex, setVisualIndex] = React15.useState(0);
|
|
2736
|
+
const isJumpingRef = React15.useRef(false);
|
|
2737
|
+
const wheelLockRef = React15.useRef(false);
|
|
2738
|
+
const wheelTimeoutRef = React15.useRef(null);
|
|
2739
|
+
const [isReady, setIsReady] = React15.useState(false);
|
|
2740
|
+
const [isMounted, setIsMounted] = React15.useState(false);
|
|
2741
|
+
React15.useEffect(() => {
|
|
2742
|
+
setIsMounted(true);
|
|
2743
|
+
}, []);
|
|
2744
|
+
const count = images.length;
|
|
2745
|
+
const hasMultiple = count > 1;
|
|
2746
|
+
const extendedImages = hasMultiple ? [images[count - 1], ...images, images[0]] : images;
|
|
2747
|
+
React15.useEffect(() => {
|
|
2748
|
+
if (hasMultiple && scrollContainerRef.current) {
|
|
2749
|
+
const container = scrollContainerRef.current;
|
|
2750
|
+
const width = container.offsetWidth;
|
|
2751
|
+
container.scrollLeft = width;
|
|
2752
|
+
setVisualIndex(1);
|
|
2753
|
+
requestAnimationFrame(() => setIsReady(true));
|
|
2754
|
+
} else {
|
|
2755
|
+
setIsReady(true);
|
|
2756
|
+
}
|
|
2757
|
+
}, [hasMultiple]);
|
|
2758
|
+
React15.useEffect(() => {
|
|
2759
|
+
if (hasMultiple && thumbnailContainerRef.current) {
|
|
2760
|
+
const thumbContainer = thumbnailContainerRef.current;
|
|
2761
|
+
const thumbNode = thumbContainer.children[visualIndex];
|
|
2762
|
+
if (thumbNode) {
|
|
2763
|
+
thumbNode.scrollIntoView({
|
|
2764
|
+
behavior: isJumpingRef.current ? "auto" : "smooth",
|
|
2765
|
+
block: "nearest",
|
|
2766
|
+
inline: "center"
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
}, [visualIndex, hasMultiple]);
|
|
2771
|
+
React15.useEffect(() => {
|
|
2772
|
+
const container = scrollContainerRef.current;
|
|
2773
|
+
if (!container || !hasMultiple) return;
|
|
2774
|
+
const handleWheel = (e) => {
|
|
2775
|
+
if (e.ctrlKey) return;
|
|
2776
|
+
e.preventDefault();
|
|
2777
|
+
if (!wheelLockRef.current) {
|
|
2778
|
+
const threshold = 10;
|
|
2779
|
+
if (Math.abs(e.deltaX) > threshold || Math.abs(e.deltaY) > threshold) {
|
|
2780
|
+
const width = container.offsetWidth;
|
|
2781
|
+
const currentIndex = Math.round(container.scrollLeft / width);
|
|
2782
|
+
let targetIndex = currentIndex;
|
|
2783
|
+
if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) {
|
|
2784
|
+
targetIndex = e.deltaX > 0 ? currentIndex + 1 : currentIndex - 1;
|
|
2785
|
+
} else {
|
|
2786
|
+
targetIndex = e.deltaY > 0 ? currentIndex + 1 : currentIndex - 1;
|
|
2787
|
+
}
|
|
2788
|
+
container.scrollTo({
|
|
2789
|
+
left: targetIndex * width,
|
|
2790
|
+
behavior: "smooth"
|
|
2791
|
+
});
|
|
2792
|
+
wheelLockRef.current = true;
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
if (wheelTimeoutRef.current) clearTimeout(wheelTimeoutRef.current);
|
|
2796
|
+
wheelTimeoutRef.current = setTimeout(() => {
|
|
2797
|
+
wheelLockRef.current = false;
|
|
2798
|
+
}, 200);
|
|
2799
|
+
};
|
|
2800
|
+
container.addEventListener("wheel", handleWheel, { passive: false });
|
|
2801
|
+
return () => {
|
|
2802
|
+
container.removeEventListener("wheel", handleWheel);
|
|
2803
|
+
if (wheelTimeoutRef.current) clearTimeout(wheelTimeoutRef.current);
|
|
2804
|
+
};
|
|
2805
|
+
}, [hasMultiple]);
|
|
2806
|
+
const handleScroll = () => {
|
|
2807
|
+
if (!scrollContainerRef.current) return;
|
|
2808
|
+
const container = scrollContainerRef.current;
|
|
2809
|
+
const { scrollLeft, offsetWidth } = container;
|
|
2810
|
+
const scrollIndex = scrollLeft / offsetWidth;
|
|
2811
|
+
const roundedIndex = Math.round(scrollIndex);
|
|
2812
|
+
if (roundedIndex !== visualIndex) {
|
|
2813
|
+
setVisualIndex(roundedIndex);
|
|
2814
|
+
}
|
|
2815
|
+
if (isJumpingRef.current) return;
|
|
2816
|
+
if (scrollLeft <= 0) {
|
|
2817
|
+
performJump(count * offsetWidth);
|
|
2818
|
+
} else if (Math.abs(scrollLeft - (count + 1) * offsetWidth) < 2) {
|
|
2819
|
+
performJump(offsetWidth);
|
|
2820
|
+
}
|
|
2821
|
+
};
|
|
2822
|
+
const performJump = (targetLeft) => {
|
|
2823
|
+
if (!scrollContainerRef.current) return;
|
|
2824
|
+
isJumpingRef.current = true;
|
|
2825
|
+
const container = scrollContainerRef.current;
|
|
2826
|
+
container.style.scrollBehavior = "auto";
|
|
2827
|
+
container.scrollLeft = targetLeft;
|
|
2828
|
+
container.style.scrollBehavior = "";
|
|
2829
|
+
const newIndex = Math.round(targetLeft / container.offsetWidth);
|
|
2830
|
+
setVisualIndex(newIndex);
|
|
2831
|
+
if (thumbnailContainerRef.current) {
|
|
2832
|
+
const thumbContainer = thumbnailContainerRef.current;
|
|
2833
|
+
const thumbNode = thumbContainer.children[newIndex];
|
|
2834
|
+
if (thumbNode) {
|
|
2835
|
+
thumbNode.scrollIntoView({
|
|
2836
|
+
behavior: "auto",
|
|
2837
|
+
block: "nearest",
|
|
2838
|
+
inline: "center"
|
|
2839
|
+
});
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
setTimeout(() => {
|
|
2843
|
+
isJumpingRef.current = false;
|
|
2844
|
+
}, 50);
|
|
2845
|
+
};
|
|
2846
|
+
const scrollToIndex = (targetVisualIndex) => {
|
|
2847
|
+
if (!scrollContainerRef.current) return;
|
|
2848
|
+
const container = scrollContainerRef.current;
|
|
2849
|
+
const width = container.offsetWidth;
|
|
2850
|
+
container.scrollTo({
|
|
2851
|
+
left: width * targetVisualIndex,
|
|
2852
|
+
behavior: "smooth"
|
|
2853
|
+
});
|
|
2854
|
+
};
|
|
2855
|
+
const nextSlide = (e) => {
|
|
2856
|
+
if (!scrollContainerRef.current) return;
|
|
2857
|
+
const container = scrollContainerRef.current;
|
|
2858
|
+
const width = container.offsetWidth;
|
|
2859
|
+
const nextIndex = Math.round(container.scrollLeft / width) + 1;
|
|
2860
|
+
container.scrollTo({
|
|
2861
|
+
left: nextIndex * width,
|
|
2862
|
+
behavior: "smooth"
|
|
2863
|
+
});
|
|
2864
|
+
};
|
|
2865
|
+
const prevSlide = (e) => {
|
|
2866
|
+
if (!scrollContainerRef.current) return;
|
|
2867
|
+
const container = scrollContainerRef.current;
|
|
2868
|
+
const width = container.offsetWidth;
|
|
2869
|
+
const prevIndex = Math.round(container.scrollLeft / width) - 1;
|
|
2870
|
+
container.scrollTo({
|
|
2871
|
+
left: prevIndex * width,
|
|
2872
|
+
behavior: "smooth"
|
|
2873
|
+
});
|
|
2874
|
+
};
|
|
2875
|
+
React15.useEffect(() => {
|
|
2876
|
+
const handleKeyDown = (e) => {
|
|
2877
|
+
if (e.key === "Escape") onClose && onClose();
|
|
2878
|
+
if (e.key === "ArrowLeft") prevSlide();
|
|
2879
|
+
if (e.key === "ArrowRight") nextSlide();
|
|
2880
|
+
};
|
|
2881
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
2882
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
2883
|
+
}, [onClose]);
|
|
2884
|
+
if (!isMounted || !images || images.length === 0) return null;
|
|
2885
|
+
return reactDom.createPortal(
|
|
2886
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed inset-0 z-[1400] bg-black/95 flex flex-col justify-between animate-fadeIn transition-opacity duration-300", children: [
|
|
2887
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2888
|
+
"div",
|
|
2889
|
+
{
|
|
2890
|
+
onClick: onClose,
|
|
2891
|
+
className: "absolute top-4 right-4 z-[110] p-2 bg-black/20 hover:bg-white/20 rounded-full text-white transition-colors cursor-pointer",
|
|
2892
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-6 h-6", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
|
|
2893
|
+
}
|
|
2894
|
+
),
|
|
2895
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 relative flex items-center justify-center overflow-hidden w-full h-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2896
|
+
"div",
|
|
2897
|
+
{
|
|
2898
|
+
ref: scrollContainerRef,
|
|
2899
|
+
onScroll: handleScroll,
|
|
2900
|
+
className: classNames({
|
|
2901
|
+
"w-full h-full flex overflow-x-auto snap-x snap-mandatory scrollbar-none": true,
|
|
2902
|
+
"opacity-0": hasMultiple && !isReady,
|
|
2903
|
+
"opacity-100": !hasMultiple || isReady
|
|
2904
|
+
}),
|
|
2905
|
+
children: extendedImages.map((img, index) => {
|
|
2906
|
+
const key = `${img.id || index}-${index}`;
|
|
2907
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2908
|
+
"div",
|
|
2909
|
+
{
|
|
2910
|
+
className: "w-full h-full flex-shrink-0 flex items-center justify-center snap-center relative p-4",
|
|
2911
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full h-full max-w-4xl max-h-[75vh] flex items-center justify-center", children: [
|
|
2912
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2913
|
+
"img",
|
|
2914
|
+
{
|
|
2915
|
+
src: img.imageUrl,
|
|
2916
|
+
alt: img.imageTitle || "Gallery Image",
|
|
2917
|
+
className: "max-w-full max-h-full object-contain drop-shadow-2xl"
|
|
2918
|
+
}
|
|
2919
|
+
),
|
|
2920
|
+
(img.imageTitle || img.imageDescription) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-black/90 via-black/50 to-transparent text-white text-center pointer-events-none", children: [
|
|
2921
|
+
img.imageTitle && /* @__PURE__ */ jsxRuntime.jsx(H3, { className: "!text-base mb-1", children: img.imageTitle }),
|
|
2922
|
+
img.imageDescription && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-charcoal-200 max-w-2xl mx-auto", children: img.imageDescription })
|
|
2923
|
+
] })
|
|
2924
|
+
] })
|
|
2925
|
+
},
|
|
2926
|
+
key
|
|
2927
|
+
);
|
|
2928
|
+
})
|
|
2929
|
+
}
|
|
2930
|
+
) }),
|
|
2931
|
+
hasMultiple && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full p-4 pb-8 bg-gradient-to-t from-black to-transparent flex items-center justify-center gap-4 z-50", children: [
|
|
2932
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2933
|
+
"div",
|
|
2934
|
+
{
|
|
2935
|
+
onClick: () => prevSlide(),
|
|
2936
|
+
className: "p-2 rounded-full hover:bg-white/10 text-white transition-colors flex-shrink-0 cursor-pointer",
|
|
2937
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-8 h-8", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.75 19.5L8.25 12l7.5-7.5" }) })
|
|
2938
|
+
}
|
|
2939
|
+
),
|
|
2940
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2941
|
+
"div",
|
|
2942
|
+
{
|
|
2943
|
+
ref: thumbnailContainerRef,
|
|
2944
|
+
className: "flex gap-2 overflow-x-auto no-scrollbar max-w-xl px-2 snap-x",
|
|
2945
|
+
children: extendedImages.map((img, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2946
|
+
"div",
|
|
2947
|
+
{
|
|
2948
|
+
onClick: () => scrollToIndex(idx),
|
|
2949
|
+
className: classNames({
|
|
2950
|
+
"relative w-14 h-14 flex-shrink-0 rounded-md overflow-hidden border transition-all duration-300 snap-center cursor-pointer": true,
|
|
2951
|
+
"border-primary-500 opacity-100": visualIndex === idx,
|
|
2952
|
+
"border-transparent opacity-40 hover:opacity-80": visualIndex !== idx
|
|
2953
|
+
}),
|
|
2954
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2955
|
+
"img",
|
|
2956
|
+
{
|
|
2957
|
+
src: img.imageUrl,
|
|
2958
|
+
alt: "Thumbnail",
|
|
2959
|
+
className: "w-full h-full object-cover transition-transform duration-300"
|
|
2960
|
+
}
|
|
2961
|
+
)
|
|
2962
|
+
},
|
|
2963
|
+
`${img.id || idx}-${idx}`
|
|
2964
|
+
))
|
|
2965
|
+
}
|
|
2966
|
+
),
|
|
2967
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2968
|
+
"div",
|
|
2969
|
+
{
|
|
2970
|
+
onClick: () => nextSlide(),
|
|
2971
|
+
className: "p-2 rounded-full hover:bg-white/10 text-white transition-colors flex-shrink-0 cursor-pointer",
|
|
2972
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-8 h-8", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) })
|
|
2973
|
+
}
|
|
2974
|
+
)
|
|
2975
|
+
] })
|
|
2976
|
+
] }),
|
|
2977
|
+
document.body
|
|
2978
|
+
);
|
|
2979
|
+
}
|
|
2980
|
+
function CurrencyDisplay({ loading, error, currency, amount, decimal = 2, opts }) {
|
|
2981
|
+
const { contentFull } = opts || {};
|
|
2982
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2983
|
+
"div",
|
|
2984
|
+
{
|
|
2985
|
+
className: classNames({
|
|
2986
|
+
"flex space-x-2 justify-between items-center group": true,
|
|
2987
|
+
"w-full": !!contentFull,
|
|
2988
|
+
"-ml-1.5 text-red-500": amount < 0,
|
|
2989
|
+
"text-red-500": !!error,
|
|
2990
|
+
"animate-pulse bg-gray-100 text-transparent rounded-md": !!loading
|
|
2991
|
+
}),
|
|
2992
|
+
children: [
|
|
2993
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2994
|
+
"span",
|
|
2995
|
+
{
|
|
2996
|
+
className: classNames({
|
|
2997
|
+
"group-hover:text-inherit": true,
|
|
2998
|
+
"!text-transparent": !!loading,
|
|
2999
|
+
"text-red-200": amount < 0 || !!error,
|
|
3000
|
+
"text-gray-200": (!amount || amount >= 0) && !error
|
|
3001
|
+
}),
|
|
3002
|
+
children: [
|
|
3003
|
+
amount < 0 && "-",
|
|
3004
|
+
currency || "$"
|
|
3005
|
+
]
|
|
3006
|
+
}
|
|
3007
|
+
),
|
|
3008
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: amount ? numberFormatter(Math.abs(amount), decimal) : "-" })
|
|
3009
|
+
]
|
|
3010
|
+
}
|
|
3011
|
+
);
|
|
3012
|
+
}
|
|
3013
|
+
function DataTableRow({ index, selected, label, description, additionalDescription, data, opts }) {
|
|
3014
|
+
const { labelCenter, vertical, darkMode } = opts || {};
|
|
3015
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3016
|
+
"tr",
|
|
3017
|
+
{
|
|
3018
|
+
className: classNames({
|
|
3019
|
+
"align-top group dark:even:bg-charcoal-800 dark:odd:bg-charcoal-700": true,
|
|
3020
|
+
"!bg-primary-500/30 dark:!bg-primary-500/10 !text-black dark:!text-primary-400": selected,
|
|
3021
|
+
"even:bg-cream-50 odd:bg-white": !darkMode,
|
|
3022
|
+
"even:bg-charcoal-800 odd:bg-charcoal-700": !!darkMode
|
|
3023
|
+
}),
|
|
3024
|
+
children: [
|
|
3025
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3026
|
+
"td",
|
|
3027
|
+
{
|
|
3028
|
+
className: classNames({
|
|
3029
|
+
"py-1.5 px-2 sm:px-3 cursor-default whitespace-nowrap first:rounded-l-lg last:rounded-r-lg cursor-pointer": true,
|
|
3030
|
+
"text-center": !!labelCenter,
|
|
3031
|
+
"align-middle": vertical === "middle"
|
|
3032
|
+
}),
|
|
3033
|
+
children: label
|
|
3034
|
+
}
|
|
3035
|
+
),
|
|
3036
|
+
description && /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-2 py-1.5 sm:px-3 min-w-64 cursor-default first:rounded-l-lg last:rounded-r-lg cursor-pointer", children: [
|
|
3037
|
+
description,
|
|
3038
|
+
additionalDescription && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "uppercase opacity-50", children: additionalDescription })
|
|
3039
|
+
] }),
|
|
3040
|
+
data.map((dataItem, dataIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3041
|
+
"td",
|
|
3042
|
+
{
|
|
3043
|
+
className: classNames({
|
|
3044
|
+
"text-center py-1.5 px-2 sm:px-3 cursor-default first:rounded-l-lg last:rounded-r-lg cursor-pointer": true,
|
|
3045
|
+
"!bg-primary-100 !text-primary-500 font-semibold": !!dataItem.threshold && dataItem.data[index] > dataItem.threshold,
|
|
3046
|
+
"!text-left": dataItem.align === "left",
|
|
3047
|
+
"align-middle": vertical === "middle"
|
|
3048
|
+
}),
|
|
3049
|
+
children: typeof dataItem.data[index] === "string" || React15__default.default.isValidElement(dataItem.data[index]) ? dataItem.data[index] : numberFormatter(dataItem.data[index], dataItem.decimal != null ? dataItem.decimal : 1)
|
|
3050
|
+
},
|
|
3051
|
+
`${dataIndex}-${index}`
|
|
3052
|
+
))
|
|
3053
|
+
]
|
|
3054
|
+
}
|
|
3055
|
+
);
|
|
3056
|
+
}
|
|
3057
|
+
function DataTable({
|
|
3058
|
+
headers,
|
|
3059
|
+
labels,
|
|
3060
|
+
selectedId,
|
|
3061
|
+
descriptions,
|
|
3062
|
+
additionalDescriptions,
|
|
3063
|
+
colors,
|
|
3064
|
+
data,
|
|
3065
|
+
total,
|
|
3066
|
+
opts
|
|
3067
|
+
}) {
|
|
3068
|
+
const { mobileView } = useResizeListener();
|
|
3069
|
+
const { ignoreTotal, showCurrency, labelTitle, labelCentered, vertical, darkMode } = opts || {};
|
|
3070
|
+
const [displayHeaders, setDisplayHeaders] = React15.useState([]);
|
|
3071
|
+
React15.useEffect(() => {
|
|
3072
|
+
setDisplayHeaders(headers);
|
|
3073
|
+
}, [headers]);
|
|
3074
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3075
|
+
"table",
|
|
3076
|
+
{
|
|
3077
|
+
className: classNames({
|
|
3078
|
+
"w-full text-sm dark:text-charcoal-100 rounded-xl border-separate border-spacing-0": true,
|
|
3079
|
+
"text-charcoal-100": !!darkMode,
|
|
3080
|
+
"text-charcoal-500": !darkMode
|
|
3081
|
+
}),
|
|
3082
|
+
children: [
|
|
3083
|
+
/* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
|
|
3084
|
+
!displayHeaders && /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "font-semibold uppercase", children: [
|
|
3085
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3086
|
+
"td",
|
|
3087
|
+
{
|
|
3088
|
+
className: classNames({
|
|
3089
|
+
"px-2 py-2.5 px-2 sm:px-3 whitespace-nowrap w-4": true,
|
|
3090
|
+
"text-center": !!labelCentered
|
|
3091
|
+
}),
|
|
3092
|
+
children: mobileView ? "#" : labelTitle || "Code"
|
|
3093
|
+
}
|
|
3094
|
+
),
|
|
3095
|
+
(descriptions || []).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-2.5 px-2 sm:px-3 bg-gray-50", children: "Description" }),
|
|
3096
|
+
data.map((dataItem, dataIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3097
|
+
"td",
|
|
3098
|
+
{
|
|
3099
|
+
className: classNames({
|
|
3100
|
+
"w-4 py-2.5 px-2 sm:px-3 whitespace-nowrap text-center": true,
|
|
3101
|
+
"bg-gray-50": !colors,
|
|
3102
|
+
"!text-left": dataItem.align === "left"
|
|
3103
|
+
}),
|
|
3104
|
+
style: colors && colors[dataIndex] ? {
|
|
3105
|
+
backgroundColor: `${colors[dataIndex]}`,
|
|
3106
|
+
color: bestTextColorForBg(colors[dataIndex])
|
|
3107
|
+
} : void 0,
|
|
3108
|
+
children: dataItem.label
|
|
3109
|
+
},
|
|
3110
|
+
dataItem.key || dataItem.label
|
|
3111
|
+
))
|
|
3112
|
+
] }),
|
|
3113
|
+
displayHeaders && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "text-xs font-semibold uppercase", children: displayHeaders })
|
|
3114
|
+
] }),
|
|
3115
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: (labels || []).map((label, index) => {
|
|
3116
|
+
const keyData = data[0]?.data || [];
|
|
3117
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3118
|
+
DataTableRow,
|
|
3119
|
+
{
|
|
3120
|
+
index,
|
|
3121
|
+
label,
|
|
3122
|
+
selected: selectedId === keyData[index]?.props?.recordId,
|
|
3123
|
+
description: descriptions && descriptions[index],
|
|
3124
|
+
additionalDescription: additionalDescriptions && additionalDescriptions[index],
|
|
3125
|
+
data,
|
|
3126
|
+
opts: {
|
|
3127
|
+
labelCenter: labelCentered,
|
|
3128
|
+
vertical,
|
|
3129
|
+
darkMode
|
|
3130
|
+
}
|
|
3131
|
+
},
|
|
3132
|
+
(keyData[index] || {}).key || index
|
|
3133
|
+
);
|
|
3134
|
+
}) }),
|
|
3135
|
+
!ignoreTotal && /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "group", children: [
|
|
3136
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3137
|
+
"td",
|
|
3138
|
+
{
|
|
3139
|
+
colSpan: (descriptions || []).length === 0 ? 1 : 2,
|
|
3140
|
+
className: classNames({
|
|
3141
|
+
"border-t dark:border-charcoal-500 py-2.5 px-2 sm:px-3 font-semibold uppercase": true,
|
|
3142
|
+
"border-charcoal-500": !!darkMode,
|
|
3143
|
+
"border-gray-100 bg-gray-50": !darkMode
|
|
3144
|
+
}),
|
|
3145
|
+
children: "Total"
|
|
3146
|
+
}
|
|
3147
|
+
),
|
|
3148
|
+
!total && data.map((dataItem, dataIndex) => {
|
|
3149
|
+
const sumVal = dataItem.data ? dataItem.data.reduce((a, b) => a + (Number(b) || 0), 0) : 0;
|
|
3150
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3151
|
+
"td",
|
|
3152
|
+
{
|
|
3153
|
+
className: classNames({
|
|
3154
|
+
"border-t dark:border-charcoal-500 py-2.5 px-2 sm:px-3 text-center font-semibold": true,
|
|
3155
|
+
"bg-gray-50": !colors && !darkMode,
|
|
3156
|
+
"border-gray-100": !darkMode,
|
|
3157
|
+
"border-charcoal-500": !!darkMode
|
|
3158
|
+
}),
|
|
3159
|
+
style: colors && colors[dataIndex] ? {
|
|
3160
|
+
backgroundColor: `${colors[dataIndex]}`,
|
|
3161
|
+
color: bestTextColorForBg(colors[dataIndex])
|
|
3162
|
+
} : void 0,
|
|
3163
|
+
children: typeof dataItem.total === "string" ? dataItem.total != null ? dataItem.total : sumVal : showCurrency ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3164
|
+
CurrencyDisplay,
|
|
3165
|
+
{
|
|
3166
|
+
amount: dataItem.total
|
|
3167
|
+
}
|
|
3168
|
+
) : numberFormatter(dataItem.total != null ? dataItem.total : sumVal, 1)
|
|
3169
|
+
},
|
|
3170
|
+
`${dataIndex}-total`
|
|
3171
|
+
);
|
|
3172
|
+
}),
|
|
3173
|
+
!!total && total.map((dataItem, dataIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3174
|
+
"td",
|
|
3175
|
+
{
|
|
3176
|
+
className: classNames({
|
|
3177
|
+
"border-t dark:border-charcoal-500 py-2.5 px-2 sm:px-3 text-center font-semibold": true,
|
|
3178
|
+
"bg-gray-50": !colors && !darkMode,
|
|
3179
|
+
"border-gray-100": !darkMode,
|
|
3180
|
+
"border-charcoal-500": !!darkMode
|
|
3181
|
+
}),
|
|
3182
|
+
style: colors && colors[dataIndex] ? {
|
|
3183
|
+
backgroundColor: `${colors[dataIndex]}`,
|
|
3184
|
+
color: bestTextColorForBg(colors[dataIndex])
|
|
3185
|
+
} : void 0,
|
|
3186
|
+
children: typeof total[dataIndex] === "string" || React15__default.default.isValidElement(total[dataIndex]) ? total[dataIndex] : showCurrency ? /* @__PURE__ */ jsxRuntime.jsx(CurrencyDisplay, { amount: total[dataIndex] }) : numberFormatter(total[dataIndex], 1)
|
|
3187
|
+
},
|
|
3188
|
+
`${dataIndex}-total`
|
|
3189
|
+
))
|
|
3190
|
+
] }) })
|
|
3191
|
+
]
|
|
3192
|
+
}
|
|
3193
|
+
);
|
|
3194
|
+
}
|
|
3195
|
+
function NumberDisplay({ loading, amount, error, decimal = 0 }) {
|
|
3196
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3197
|
+
"div",
|
|
3198
|
+
{
|
|
3199
|
+
className: classNames({
|
|
3200
|
+
"flex space-x-2 items-center justify-between group w-full": true,
|
|
3201
|
+
"text-red-500": amount < 0 || !!error,
|
|
3202
|
+
"animate-pulse bg-gray-100 text-transparent rounded-md": !!loading
|
|
3203
|
+
}),
|
|
3204
|
+
children: [
|
|
3205
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3206
|
+
"span",
|
|
3207
|
+
{
|
|
3208
|
+
className: classNames({
|
|
3209
|
+
"group-hover:text-inherit": true,
|
|
3210
|
+
"!text-transparent": !!loading,
|
|
3211
|
+
"text-red-200": amount < 0 || !!error,
|
|
3212
|
+
"text-gray-200": amount >= 0 && !error
|
|
3213
|
+
}),
|
|
3214
|
+
children: amount < 0 && "-"
|
|
3215
|
+
}
|
|
3216
|
+
),
|
|
3217
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-right", children: amount ? numberFormatter(Math.abs(amount), decimal) : "" })
|
|
3218
|
+
]
|
|
3219
|
+
}
|
|
3220
|
+
);
|
|
3221
|
+
}
|
|
3222
|
+
function ChangeDisplay({ postfix = "%", data = [], decimal = 0 }) {
|
|
3223
|
+
const [current, prev] = data;
|
|
3224
|
+
function calculateGrowthPercentage(curr, previous) {
|
|
3225
|
+
if (!previous && !curr) {
|
|
3226
|
+
return 0;
|
|
3227
|
+
}
|
|
3228
|
+
if (!previous) {
|
|
3229
|
+
return Infinity;
|
|
3230
|
+
}
|
|
3231
|
+
return (curr - previous) * 100 / previous;
|
|
3232
|
+
}
|
|
3233
|
+
const CAPPED = 1e4;
|
|
3234
|
+
const growth = calculateGrowthPercentage(current, prev);
|
|
3235
|
+
const displayGrowth = Math.max(Math.min(growth, CAPPED), -CAPPED);
|
|
3236
|
+
if (prev > 0 && current === 0) {
|
|
3237
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center space-x-2 text-red-600 w-full", children: [
|
|
3238
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 text-right", children: "Lost" }),
|
|
3239
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "opacity-30 group-hover:opacity-100", children: "\u25BC" })
|
|
3240
|
+
] });
|
|
3241
|
+
}
|
|
3242
|
+
if (growth === Infinity) {
|
|
3243
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center space-x-2 text-green-600 w-full", children: [
|
|
3244
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 text-right", children: "New" }),
|
|
3245
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "opacity-30 group-hover:opacity-100", children: "\u25B2" })
|
|
3246
|
+
] });
|
|
3247
|
+
}
|
|
3248
|
+
if (growth === 0) {
|
|
3249
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center space-x-2 w-full", children: [
|
|
3250
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 text-right", children: "-" }),
|
|
3251
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: "\xA0" })
|
|
3252
|
+
] });
|
|
3253
|
+
}
|
|
3254
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3255
|
+
"div",
|
|
3256
|
+
{
|
|
3257
|
+
className: classNames({
|
|
3258
|
+
"flex justify-between items-center space-x-2 whitespace-nowrap w-full": true,
|
|
3259
|
+
"text-red-600": growth < 0,
|
|
3260
|
+
"text-green-600": growth > 0
|
|
3261
|
+
}),
|
|
3262
|
+
children: [
|
|
3263
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 text-right", children: [
|
|
3264
|
+
Math.abs(growth) <= CAPPED && (growth >= 0 ? "+" : "-"),
|
|
3265
|
+
growth > CAPPED && " >",
|
|
3266
|
+
growth < -CAPPED && " <",
|
|
3267
|
+
numberFormatter(Math.abs(displayGrowth), decimal),
|
|
3268
|
+
postfix
|
|
3269
|
+
] }),
|
|
3270
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "opacity-30 group-hover:opacity-100", children: growth > 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u25B2" }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u25BC" }) })
|
|
3271
|
+
]
|
|
3272
|
+
}
|
|
3273
|
+
);
|
|
3274
|
+
}
|
|
3275
|
+
function DateTimeDisplay({ loading, value }) {
|
|
3276
|
+
let formatted = "-";
|
|
3277
|
+
try {
|
|
3278
|
+
if (value) {
|
|
3279
|
+
formatted = new Intl.DateTimeFormat("en-GB", {
|
|
3280
|
+
weekday: "short",
|
|
3281
|
+
day: "numeric",
|
|
3282
|
+
month: "short",
|
|
3283
|
+
year: "numeric"
|
|
3284
|
+
}).format(new Date(value));
|
|
3285
|
+
}
|
|
3286
|
+
} catch (e) {
|
|
3287
|
+
formatted = String(value);
|
|
3288
|
+
}
|
|
3289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3290
|
+
"div",
|
|
3291
|
+
{
|
|
3292
|
+
className: classNames({
|
|
3293
|
+
"w-full whitespace-nowrap": true,
|
|
3294
|
+
"animate-pulse bg-gray-100 text-transparent rounded-md": !!loading
|
|
3295
|
+
}),
|
|
3296
|
+
children: formatted
|
|
3297
|
+
}
|
|
3298
|
+
);
|
|
3299
|
+
}
|
|
3300
|
+
function ThumbnailDisplay({ loading, value }) {
|
|
3301
|
+
const image = Array.isArray(value) ? value.length > 0 ? value[0] : null : value;
|
|
3302
|
+
const { imageUrl, imageDescription } = image || {};
|
|
3303
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3304
|
+
"div",
|
|
3305
|
+
{
|
|
3306
|
+
className: classNames({
|
|
3307
|
+
"w-full whitespace-nowrap": true,
|
|
3308
|
+
"animate-pulse bg-gray-100 text-transparent rounded-md": !!loading
|
|
3309
|
+
}),
|
|
3310
|
+
children: [
|
|
3311
|
+
image && imageUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3312
|
+
"img",
|
|
3313
|
+
{
|
|
3314
|
+
src: imageUrl,
|
|
3315
|
+
alt: imageDescription || "",
|
|
3316
|
+
className: "w-8 min-w-8 h-8 object-cover rounded-md"
|
|
3317
|
+
}
|
|
3318
|
+
),
|
|
3319
|
+
!image && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 min-w-8 h-8 bg-gray-100 dark:bg-charcoal-800 rounded-md" })
|
|
3320
|
+
]
|
|
3321
|
+
}
|
|
3322
|
+
);
|
|
3323
|
+
}
|
|
3324
|
+
function DataGridHeader({ sort, onClick, opts, children }) {
|
|
3325
|
+
const { align, grow, noWrap, isSorted, stickyHeader, darkMode } = opts || {};
|
|
3326
|
+
if (sort) {
|
|
3327
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3328
|
+
"th",
|
|
3329
|
+
{
|
|
3330
|
+
className: classNames({
|
|
3331
|
+
"py-2.5 px-2 sm:px-3 whitespace-nowrap text-center cursor-pointer font-semibold": true,
|
|
3332
|
+
"w-4": !grow,
|
|
3333
|
+
"!text-left": align === "left",
|
|
3334
|
+
"!text-right": align === "right",
|
|
3335
|
+
"whitespace-nowrap": !!noWrap,
|
|
3336
|
+
"sticky top-0 z-10 dark:bg-charcoal-800": !!stickyHeader,
|
|
3337
|
+
"bg-cream-50": !darkMode,
|
|
3338
|
+
"bg-charcoal-800": !!darkMode
|
|
3339
|
+
}),
|
|
3340
|
+
onClick,
|
|
3341
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative", children: [
|
|
3342
|
+
children,
|
|
3343
|
+
isSorted && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute top-0 bottom-0 -right-3.5 flex items-center", children: [
|
|
3344
|
+
isSorted === "asc" && /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-3 h-3", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 6.75 12 3m0 0 3.75 3.75M12 3v18" }) }),
|
|
3345
|
+
isSorted === "desc" && /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-3 h-3", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.75 17.25 12 21m0 0-3.75-3.75M12 21V3" }) })
|
|
3346
|
+
] })
|
|
3347
|
+
] })
|
|
3348
|
+
}
|
|
3349
|
+
);
|
|
3350
|
+
}
|
|
3351
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3352
|
+
"th",
|
|
3353
|
+
{
|
|
3354
|
+
className: classNames({
|
|
3355
|
+
"py-2.5 px-2 sm:px-3 text-center font-semibold": true,
|
|
3356
|
+
"w-4": !grow,
|
|
3357
|
+
"!text-left": align === "left",
|
|
3358
|
+
"whitespace-nowrap": !!noWrap,
|
|
3359
|
+
"sticky top-0 z-10 dark:bg-charcoal-800": !!stickyHeader,
|
|
3360
|
+
"bg-cream-50": !darkMode,
|
|
3361
|
+
"bg-charcoal-800": !!darkMode
|
|
3362
|
+
}),
|
|
3363
|
+
children
|
|
3364
|
+
}
|
|
3365
|
+
);
|
|
3366
|
+
}
|
|
3367
|
+
function DataGridElement({ processing: defaultProcessing, type, value, error, menu, params, opts, onSelect }) {
|
|
3368
|
+
const [processing, setProcessing] = React15.useState(defaultProcessing);
|
|
3369
|
+
React15.useEffect(() => {
|
|
3370
|
+
setProcessing(defaultProcessing);
|
|
3371
|
+
}, [defaultProcessing]);
|
|
3372
|
+
const { align } = opts || {};
|
|
3373
|
+
if (!processing && menu) {
|
|
3374
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3375
|
+
Popover,
|
|
3376
|
+
{
|
|
3377
|
+
actions: [
|
|
3378
|
+
{
|
|
3379
|
+
id: "edit-section",
|
|
3380
|
+
section: "Action",
|
|
3381
|
+
items: menu.map((menuItem) => {
|
|
3382
|
+
return {
|
|
3383
|
+
id: menuItem.id,
|
|
3384
|
+
label: menuItem.label,
|
|
3385
|
+
action: async () => {
|
|
3386
|
+
setProcessing(true);
|
|
3387
|
+
await menuItem.onClick(params);
|
|
3388
|
+
setProcessing(false);
|
|
3389
|
+
}
|
|
3390
|
+
};
|
|
3391
|
+
})
|
|
3392
|
+
}
|
|
3393
|
+
],
|
|
3394
|
+
opts: { compact: true, asBlock: true, align },
|
|
3395
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3396
|
+
DataGridContent,
|
|
3397
|
+
{
|
|
3398
|
+
loading: processing,
|
|
3399
|
+
error,
|
|
3400
|
+
type,
|
|
3401
|
+
value,
|
|
3402
|
+
opts: {
|
|
3403
|
+
...opts,
|
|
3404
|
+
contentFull: true
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
)
|
|
3408
|
+
}
|
|
3409
|
+
);
|
|
3410
|
+
}
|
|
3411
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3412
|
+
DataGridContent,
|
|
3413
|
+
{
|
|
3414
|
+
loading: processing,
|
|
3415
|
+
error,
|
|
3416
|
+
type,
|
|
3417
|
+
value,
|
|
3418
|
+
opts,
|
|
3419
|
+
onClick: () => {
|
|
3420
|
+
if (typeof onSelect === "function") {
|
|
3421
|
+
onSelect(params?.row);
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
);
|
|
3426
|
+
}
|
|
3427
|
+
function DataGridContent({ loading, error, type, value, opts, onClick }) {
|
|
3428
|
+
if (type === "currency") {
|
|
3429
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CurrencyDisplay, { loading, error, amount: value, opts });
|
|
3430
|
+
}
|
|
3431
|
+
if (type === "number") {
|
|
3432
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NumberDisplay, { loading, error, amount: value });
|
|
3433
|
+
}
|
|
3434
|
+
if (type === "change") {
|
|
3435
|
+
const [current, previous] = value || [];
|
|
3436
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChangeDisplay, { data: [current, previous], decimal: 0 });
|
|
3437
|
+
}
|
|
3438
|
+
if (type === "datetime") {
|
|
3439
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DateTimeDisplay, { value });
|
|
3440
|
+
}
|
|
3441
|
+
if (type === "thumbnail") {
|
|
3442
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThumbnailDisplay, { value });
|
|
3443
|
+
}
|
|
3444
|
+
const { noWrap, lineClamp } = opts || {};
|
|
3445
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3446
|
+
"div",
|
|
3447
|
+
{
|
|
3448
|
+
className: classNames({
|
|
3449
|
+
"whitespace-nowrap": !!noWrap,
|
|
3450
|
+
"line-clamp-1": lineClamp === 1,
|
|
3451
|
+
"line-clamp-2": lineClamp === 2,
|
|
3452
|
+
"line-clamp-3": lineClamp === 3,
|
|
3453
|
+
"animate-pulse bg-gray-100 text-transparent pointer-events-none": !!loading
|
|
3454
|
+
}),
|
|
3455
|
+
onClick,
|
|
3456
|
+
children: value
|
|
3457
|
+
}
|
|
3458
|
+
);
|
|
3459
|
+
}
|
|
3460
|
+
function DataGrid({ headers, data, selectedId, footers, opts, onSelect }) {
|
|
3461
|
+
const [displayedData, setDisplayedData] = React15.useState([]);
|
|
3462
|
+
const [orderByState, setOrderByState] = React15.useState({
|
|
3463
|
+
category: headers[0]?.id || "",
|
|
3464
|
+
direction: "asc"
|
|
3465
|
+
});
|
|
3466
|
+
const displayedHeaders = (headers || []).filter((header) => !header.hidden);
|
|
3467
|
+
function handleSort(category) {
|
|
3468
|
+
if (orderByState.category !== category) {
|
|
3469
|
+
setOrderByState({ category, direction: "asc" });
|
|
3470
|
+
} else {
|
|
3471
|
+
setOrderByState({ category, direction: orderByState.direction === "asc" ? "desc" : "asc" });
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
React15.useEffect(() => {
|
|
3475
|
+
if ((data || []).length > 0) {
|
|
3476
|
+
const availableKeys = (headers || []).map((header) => header.id);
|
|
3477
|
+
const { category, direction } = orderByState;
|
|
3478
|
+
const sortCategory = availableKeys.includes(category) ? category : headers[0]?.id;
|
|
3479
|
+
const sortDirection = ["asc", "desc"].includes(direction) ? direction : "asc";
|
|
3480
|
+
const targetHeader = headers.find((header) => header.id === sortCategory);
|
|
3481
|
+
const headerType = targetHeader?.type;
|
|
3482
|
+
let sortedData = [...data];
|
|
3483
|
+
if (headerType === "change") {
|
|
3484
|
+
sortedData = sortedData.sort((a, b) => {
|
|
3485
|
+
const x = a[sortCategory] || [0, 0];
|
|
3486
|
+
const y = b[sortCategory] || [0, 0];
|
|
3487
|
+
const left = x[1] ? (x[0] - x[1]) / x[1] : Infinity;
|
|
3488
|
+
const right = y[1] ? (y[0] - y[1]) / y[1] : Infinity;
|
|
3489
|
+
const multiplier = sortDirection === "asc" ? 1 : -1;
|
|
3490
|
+
if (left < right) {
|
|
3491
|
+
return multiplier * -1;
|
|
3492
|
+
}
|
|
3493
|
+
if (left > right) {
|
|
3494
|
+
return multiplier * 1;
|
|
3495
|
+
}
|
|
3496
|
+
if (x[0] - x[1] < y[0] - y[1]) {
|
|
3497
|
+
return multiplier * -1;
|
|
3498
|
+
}
|
|
3499
|
+
if (x[0] - x[1] > y[0] - y[1]) {
|
|
3500
|
+
return multiplier * 1;
|
|
3501
|
+
}
|
|
3502
|
+
return 0;
|
|
3503
|
+
});
|
|
3504
|
+
} else {
|
|
3505
|
+
sortedData.sort((a, b) => {
|
|
3506
|
+
let aVal = a[sortCategory];
|
|
3507
|
+
let bVal = b[sortCategory];
|
|
3508
|
+
if (aVal === bVal) return 0;
|
|
3509
|
+
if (aVal === null || aVal === void 0) return 1;
|
|
3510
|
+
if (bVal === null || bVal === void 0) return -1;
|
|
3511
|
+
if (typeof aVal === "string") {
|
|
3512
|
+
aVal = aVal.toLowerCase();
|
|
3513
|
+
}
|
|
3514
|
+
if (typeof bVal === "string") {
|
|
3515
|
+
bVal = bVal.toLowerCase();
|
|
3516
|
+
}
|
|
3517
|
+
const comparison = aVal < bVal ? -1 : 1;
|
|
3518
|
+
return sortDirection === "asc" ? comparison : -comparison;
|
|
3519
|
+
});
|
|
3520
|
+
}
|
|
3521
|
+
const updatedData = (displayedHeaders || []).map((header) => {
|
|
3522
|
+
return {
|
|
3523
|
+
key: header.id,
|
|
3524
|
+
label: header.label,
|
|
3525
|
+
align: header.align,
|
|
3526
|
+
data: (sortedData || []).map((row, rowIndex) => {
|
|
3527
|
+
const isError = header.error && Function("value", `return ${header.error}`)(row[header.id]);
|
|
3528
|
+
const [timestamp] = (header.id || "").split(" - ");
|
|
3529
|
+
const isProcessing = row[`${timestamp} - processing`];
|
|
3530
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3531
|
+
DataGridElement,
|
|
3532
|
+
{
|
|
3533
|
+
processing: isProcessing,
|
|
3534
|
+
type: header.type,
|
|
3535
|
+
value: row[header.id],
|
|
3536
|
+
menu: header.menu,
|
|
3537
|
+
opts: {
|
|
3538
|
+
align: header.align,
|
|
3539
|
+
noWrap: header.noWrap,
|
|
3540
|
+
vAlign: header.vertical,
|
|
3541
|
+
lineClamp: header.lineClamp
|
|
3542
|
+
},
|
|
3543
|
+
params: {
|
|
3544
|
+
id: row.id,
|
|
3545
|
+
data: sortedData,
|
|
3546
|
+
row,
|
|
3547
|
+
headerId: header.id,
|
|
3548
|
+
params: header.params
|
|
3549
|
+
},
|
|
3550
|
+
error: isError,
|
|
3551
|
+
onSelect
|
|
3552
|
+
},
|
|
3553
|
+
`${header.id}-${row.id}`
|
|
3554
|
+
);
|
|
3555
|
+
})
|
|
3556
|
+
};
|
|
3557
|
+
});
|
|
3558
|
+
setDisplayedData(updatedData);
|
|
3559
|
+
} else {
|
|
3560
|
+
setDisplayedData([]);
|
|
3561
|
+
}
|
|
3562
|
+
}, [data, orderByState, headers]);
|
|
3563
|
+
const displayedLabels = (displayedData || [])[0]?.data;
|
|
3564
|
+
const renderedData = (displayedData || []).filter((_, index) => index > 0);
|
|
3565
|
+
const renderedHeaders = (displayedHeaders || []).map((header) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3566
|
+
DataGridHeader,
|
|
3567
|
+
{
|
|
3568
|
+
sort: header.sort,
|
|
3569
|
+
opts: {
|
|
3570
|
+
align: header.align,
|
|
3571
|
+
noWrap: header.noWrap,
|
|
3572
|
+
grow: header.grow,
|
|
3573
|
+
isSorted: header.id === orderByState.category ? orderByState.direction : null,
|
|
3574
|
+
stickyHeader: opts?.stickyHeader,
|
|
3575
|
+
darkMode: opts?.darkMode
|
|
3576
|
+
},
|
|
3577
|
+
onClick: () => handleSort(header.id),
|
|
3578
|
+
children: header.label
|
|
3579
|
+
},
|
|
3580
|
+
header.id
|
|
3581
|
+
));
|
|
3582
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3583
|
+
DataTable,
|
|
3584
|
+
{
|
|
3585
|
+
headers: renderedHeaders,
|
|
3586
|
+
labels: displayedLabels,
|
|
3587
|
+
data: renderedData,
|
|
3588
|
+
selectedId,
|
|
3589
|
+
total: footers,
|
|
3590
|
+
opts: {
|
|
3591
|
+
...opts,
|
|
3592
|
+
ignoreTotal: !footers
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
);
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
exports.B = B;
|
|
3599
|
+
exports.Button = Button;
|
|
3600
|
+
exports.CheckboxList = CheckboxList;
|
|
3601
|
+
exports.ConfirmationBox = ConfirmationBox;
|
|
3602
|
+
exports.Coverflow = Coverflow;
|
|
3603
|
+
exports.DataGrid = DataGrid;
|
|
3604
|
+
exports.Dragger = Dragger;
|
|
3605
|
+
exports.Drawer = Drawer;
|
|
3606
|
+
exports.ExcelTable = ExcelTable;
|
|
3607
|
+
exports.H1 = H1;
|
|
3608
|
+
exports.H2 = H2;
|
|
3609
|
+
exports.H3 = H3;
|
|
3610
|
+
exports.H4 = H4;
|
|
3611
|
+
exports.InlinePrompt = InlinePrompt;
|
|
3612
|
+
exports.Input = Input_default;
|
|
3613
|
+
exports.Label = Label;
|
|
3614
|
+
exports.Loading = Loading;
|
|
3615
|
+
exports.Modal = Modal;
|
|
3616
|
+
exports.ModalContext = ModalContext;
|
|
3617
|
+
exports.ModalProvider = ModalProvider;
|
|
3618
|
+
exports.NoData = NoData;
|
|
3619
|
+
exports.Popover = Popover;
|
|
3620
|
+
exports.PopoverContext = PopoverContext;
|
|
3621
|
+
exports.PopoverProvider = PopoverProvider;
|
|
3622
|
+
exports.Select = Select_default;
|
|
3623
|
+
exports.SelectInput = SelectInput_default;
|
|
3624
|
+
exports.SortIcon = SortIcon;
|
|
3625
|
+
exports.Table = Table;
|
|
3626
|
+
exports.Tabs = Tabs;
|
|
3627
|
+
exports.Tag = Tag;
|
|
3628
|
+
exports.TagGroup = TagGroup;
|
|
3629
|
+
exports.TagInput = TagInput;
|
|
3630
|
+
exports.Tbody = Tbody;
|
|
3631
|
+
exports.Td = Td;
|
|
3632
|
+
exports.Textarea = Textarea_default;
|
|
3633
|
+
exports.Th = Th;
|
|
3634
|
+
exports.Thead = Thead;
|
|
3635
|
+
exports.ThemeContext = ThemeContext;
|
|
3636
|
+
exports.ThemeProvider = ThemeProvider;
|
|
3637
|
+
exports.ThemeToggle = ThemeToggle;
|
|
3638
|
+
exports.Toggle = Toggle_default;
|
|
3639
|
+
exports.Tr = Tr;
|
|
3640
|
+
exports.Transition = Transition;
|
|
3641
|
+
exports.bestTextColorForBg = bestTextColorForBg;
|
|
3642
|
+
exports.classNameObject = classNameObject;
|
|
3643
|
+
exports.classNames = classNames;
|
|
3644
|
+
exports.debounce = debounce;
|
|
3645
|
+
exports.moveItem = moveItem;
|
|
3646
|
+
exports.numberFormatter = numberFormatter;
|
|
3647
|
+
exports.useDebounce = useDebounce;
|
|
3648
|
+
exports.useModalContext = useModalContext;
|
|
3649
|
+
exports.usePopoverContext = usePopoverContext;
|
|
3650
|
+
exports.useResizeListener = useResizeListener;
|
|
3651
|
+
exports.useThemeContext = useThemeContext;
|
|
3652
|
+
//# sourceMappingURL=index.js.map
|
|
3653
|
+
//# sourceMappingURL=index.js.map
|