@woobee/ui 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +130 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -15,8 +15,9 @@ interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'typ
|
|
|
15
15
|
leftIcon?: ReactNode;
|
|
16
16
|
rightIcon?: ReactNode;
|
|
17
17
|
compact?: boolean;
|
|
18
|
+
darkMode?: boolean;
|
|
18
19
|
}
|
|
19
|
-
declare function Button({ children, onClick, placeholder, variant, size, className, type, loading, disabled, leftIcon, rightIcon, compact, ...props }: ButtonProps): React.JSX.Element;
|
|
20
|
+
declare function Button({ children, onClick, placeholder, variant, size, className, type, loading, disabled, leftIcon, rightIcon, compact, darkMode, ...props }: ButtonProps): React.JSX.Element;
|
|
20
21
|
|
|
21
22
|
type TagSize = 'small' | 'medium';
|
|
22
23
|
interface TagProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'typ
|
|
|
15
15
|
leftIcon?: ReactNode;
|
|
16
16
|
rightIcon?: ReactNode;
|
|
17
17
|
compact?: boolean;
|
|
18
|
+
darkMode?: boolean;
|
|
18
19
|
}
|
|
19
|
-
declare function Button({ children, onClick, placeholder, variant, size, className, type, loading, disabled, leftIcon, rightIcon, compact, ...props }: ButtonProps): React.JSX.Element;
|
|
20
|
+
declare function Button({ children, onClick, placeholder, variant, size, className, type, loading, disabled, leftIcon, rightIcon, compact, darkMode, ...props }: ButtonProps): React.JSX.Element;
|
|
20
21
|
|
|
21
22
|
type TagSize = 'small' | 'medium';
|
|
22
23
|
interface TagProps {
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var React16 = require('react');
|
|
5
5
|
var reactDom = require('react-dom');
|
|
6
6
|
var reactTransitionGroup = require('react-transition-group');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var React16__default = /*#__PURE__*/_interopDefault(React16);
|
|
11
11
|
|
|
12
12
|
// src/utils/classNames.ts
|
|
13
13
|
function classNames(classNameHash) {
|
|
@@ -35,6 +35,7 @@ function Button({
|
|
|
35
35
|
leftIcon = null,
|
|
36
36
|
rightIcon = null,
|
|
37
37
|
compact = false,
|
|
38
|
+
darkMode = false,
|
|
38
39
|
...props
|
|
39
40
|
}) {
|
|
40
41
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -51,11 +52,20 @@ function Button({
|
|
|
51
52
|
"px-5 py-3 text-base": size === "big",
|
|
52
53
|
"px-5 py-3 text-lg font-medium": size === "huge",
|
|
53
54
|
"!px-1 !py-0.5": compact,
|
|
54
|
-
"border bg-brown-500
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
55
|
+
"border bg-brown-500 border-transparent text-white": variant === "primary" && !darkMode,
|
|
56
|
+
"dark:bg-primary-500 dark:hover:bg-primary-600 dark:text-black": variant === "primary" && !darkMode,
|
|
57
|
+
"border bg-primary-500 hover:bg-primary-600 border-transparent text-black": variant === "primary" && !!darkMode,
|
|
58
|
+
"text-gray-700 bg-white border border-gray-300 hover:text-gray-500": variant === "secondary" && !darkMode,
|
|
59
|
+
"text-charcoal-100 bg-charcoal-800 hover:bg-charcoal-700 border border-charcoal-700": variant === "secondary" && !!darkMode,
|
|
60
|
+
"!rounded-md text-left w-full text-gray-700 bg-white border border-gray-200 hover:bg-gray-50 hover:text-gray-500": variant === "form-input" && !darkMode,
|
|
61
|
+
"!rounded-md text-left w-full text-charcoal-100 bg-charcoal-800 hover:bg-charcoal-700 border border-charcoal-700": variant === "form-input" && !!darkMode,
|
|
62
|
+
"dark:bg-charcoal-800 dark:hover:bg-charcoal-700 dark:text-charcoal-100 dark:border-charcoal-700": (variant === "secondary" || variant === "form-input") && !darkMode,
|
|
63
|
+
"hover:text-brown-500 !shadow-none": variant === "flat" && !darkMode,
|
|
64
|
+
"dark:text-charcoal-100 dark:hover:text-primary-500": variant === "flat" && !darkMode,
|
|
65
|
+
"text-charcoal-100 hover:text-primary-500 !shadow-none": variant === "flat" && !!darkMode,
|
|
66
|
+
"!text-gray-300 hover:!text-gray-400": !children && !darkMode,
|
|
67
|
+
"dark:!text-charcoal-400": !children && !darkMode,
|
|
68
|
+
"!text-charcoal-400": !children && !!darkMode,
|
|
59
69
|
...classNameObject(className)
|
|
60
70
|
}),
|
|
61
71
|
...props,
|
|
@@ -172,11 +182,11 @@ function Tabs({
|
|
|
172
182
|
}
|
|
173
183
|
);
|
|
174
184
|
}
|
|
175
|
-
var Toggle =
|
|
185
|
+
var Toggle = React16.forwardRef(
|
|
176
186
|
({ listening, size, name, value, onChange, className }, ref) => {
|
|
177
|
-
const internalRef =
|
|
187
|
+
const internalRef = React16.useRef(null);
|
|
178
188
|
const spanRef = ref || internalRef;
|
|
179
|
-
|
|
189
|
+
React16.useEffect(() => {
|
|
180
190
|
if (listening && spanRef && "current" in spanRef && spanRef.current && value !== null) {
|
|
181
191
|
spanRef.current.value = value;
|
|
182
192
|
}
|
|
@@ -261,6 +271,10 @@ function CheckboxList({
|
|
|
261
271
|
loading = false,
|
|
262
272
|
placeholder = "No items found."
|
|
263
273
|
}) {
|
|
274
|
+
const hasLoadedRef = React16.useRef(false);
|
|
275
|
+
if (!loading) {
|
|
276
|
+
hasLoadedRef.current = true;
|
|
277
|
+
}
|
|
264
278
|
const getFinalKey = (item, index) => {
|
|
265
279
|
const key = typeof itemKey === "function" ? itemKey(item) : item[itemKey];
|
|
266
280
|
return key !== void 0 && key !== null ? key : index;
|
|
@@ -271,7 +285,7 @@ function CheckboxList({
|
|
|
271
285
|
}
|
|
272
286
|
return placeholder;
|
|
273
287
|
};
|
|
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 &&
|
|
288
|
+
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 && !hasLoadedRef.current ? /* @__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
289
|
const finalKey = getFinalKey(item, index);
|
|
276
290
|
const label = typeof itemLabel === "function" ? itemLabel(item) : item[itemLabel];
|
|
277
291
|
const checked = typeof isChecked === "function" ? isChecked(item, selected) : selected.some(
|
|
@@ -315,7 +329,7 @@ function CheckboxList({
|
|
|
315
329
|
);
|
|
316
330
|
}) : renderPlaceholder() }) }) });
|
|
317
331
|
}
|
|
318
|
-
var ModalContext =
|
|
332
|
+
var ModalContext = React16.createContext({
|
|
319
333
|
modalShowing: false,
|
|
320
334
|
drawerShowing: false,
|
|
321
335
|
setModalShowing: () => {
|
|
@@ -324,10 +338,10 @@ var ModalContext = React15.createContext({
|
|
|
324
338
|
}
|
|
325
339
|
});
|
|
326
340
|
function useModalContext() {
|
|
327
|
-
return
|
|
341
|
+
return React16.useContext(ModalContext);
|
|
328
342
|
}
|
|
329
343
|
function ModalProvider({ children }) {
|
|
330
|
-
const [currentState, setCurrentState] =
|
|
344
|
+
const [currentState, setCurrentState] = React16.useState(0);
|
|
331
345
|
function reducer(state, action) {
|
|
332
346
|
const updatedValues = { ...state };
|
|
333
347
|
if ("modalShowing" in action) {
|
|
@@ -341,12 +355,12 @@ function ModalProvider({ children }) {
|
|
|
341
355
|
}
|
|
342
356
|
return updatedValues;
|
|
343
357
|
}
|
|
344
|
-
const [values, dispatch] =
|
|
358
|
+
const [values, dispatch] = React16.useReducer(reducer, {
|
|
345
359
|
modalShowing: false,
|
|
346
360
|
drawerShowing: false
|
|
347
361
|
});
|
|
348
362
|
const { modalShowing, drawerShowing } = values;
|
|
349
|
-
|
|
363
|
+
React16.useEffect(() => {
|
|
350
364
|
if (typeof document === "undefined") return;
|
|
351
365
|
const bodyEl = document.getElementsByTagName("BODY")[0];
|
|
352
366
|
if (!bodyEl) return;
|
|
@@ -369,12 +383,12 @@ function ModalProvider({ children }) {
|
|
|
369
383
|
}
|
|
370
384
|
);
|
|
371
385
|
}
|
|
372
|
-
var TransitionContext =
|
|
386
|
+
var TransitionContext = React16.createContext({
|
|
373
387
|
parent: {}
|
|
374
388
|
});
|
|
375
389
|
function useIsInitialRender() {
|
|
376
|
-
const isInitialRender =
|
|
377
|
-
|
|
390
|
+
const isInitialRender = React16.useRef(true);
|
|
391
|
+
React16.useEffect(() => {
|
|
378
392
|
isInitialRender.current = false;
|
|
379
393
|
}, []);
|
|
380
394
|
return isInitialRender.current;
|
|
@@ -408,7 +422,7 @@ function CSSTransitionComponent({
|
|
|
408
422
|
const leaveClasses = leave.split(" ").filter((s) => s.length);
|
|
409
423
|
const leaveFromClasses = leaveFrom.split(" ").filter((s) => s.length);
|
|
410
424
|
const leaveToClasses = leaveTo.split(" ").filter((s) => s.length);
|
|
411
|
-
const nodeRef =
|
|
425
|
+
const nodeRef = React16.useRef(null);
|
|
412
426
|
function addClasses(node, classes) {
|
|
413
427
|
classes.length && node.classList.add(...classes);
|
|
414
428
|
}
|
|
@@ -458,7 +472,7 @@ function CSSTransitionComponent({
|
|
|
458
472
|
removeClasses(nodeRef.current, [...leaveToClasses, ...leaveClasses]);
|
|
459
473
|
onExited(nodeRef.current);
|
|
460
474
|
},
|
|
461
|
-
children:
|
|
475
|
+
children: React16__default.default.cloneElement(children, {
|
|
462
476
|
ref: (node) => {
|
|
463
477
|
nodeRef.current = node;
|
|
464
478
|
const childRef = children.ref;
|
|
@@ -473,7 +487,7 @@ function CSSTransitionComponent({
|
|
|
473
487
|
);
|
|
474
488
|
}
|
|
475
489
|
function Transition({ show, appear, ...rest }) {
|
|
476
|
-
const { parent } =
|
|
490
|
+
const { parent } = React16.useContext(TransitionContext);
|
|
477
491
|
const isInitialRender = useIsInitialRender();
|
|
478
492
|
const isChild = show === void 0;
|
|
479
493
|
if (isChild) {
|
|
@@ -588,15 +602,15 @@ function Modal({
|
|
|
588
602
|
fullscreen,
|
|
589
603
|
opts
|
|
590
604
|
}) {
|
|
591
|
-
const { setModalShowing } =
|
|
605
|
+
const { setModalShowing } = React16.useContext(ModalContext);
|
|
592
606
|
const { darkMode, sidebarPosition = "right", mobileSidebarPosition = "bottom" } = opts || {};
|
|
593
607
|
const isMobileSidebarTop = mobileSidebarPosition === "top" || mobileSidebarPosition === "above";
|
|
594
|
-
const [mounted, setMounted] =
|
|
595
|
-
|
|
608
|
+
const [mounted, setMounted] = React16.useState(false);
|
|
609
|
+
React16.useEffect(() => {
|
|
596
610
|
setMounted(true);
|
|
597
611
|
return () => setMounted(false);
|
|
598
612
|
}, []);
|
|
599
|
-
|
|
613
|
+
React16.useEffect(() => {
|
|
600
614
|
if (typeof document === "undefined") return;
|
|
601
615
|
const bodyEl = document.getElementsByTagName("BODY")[0];
|
|
602
616
|
if (open) {
|
|
@@ -821,8 +835,8 @@ function Drawer({
|
|
|
821
835
|
wrapperClassName,
|
|
822
836
|
sectionClassName = ""
|
|
823
837
|
}) {
|
|
824
|
-
const { setDrawerShowing } =
|
|
825
|
-
|
|
838
|
+
const { setDrawerShowing } = React16.useContext(ModalContext);
|
|
839
|
+
React16.useEffect(() => {
|
|
826
840
|
setDrawerShowing(open);
|
|
827
841
|
}, [open]);
|
|
828
842
|
function handleClose() {
|
|
@@ -943,9 +957,9 @@ function InlinePrompt({
|
|
|
943
957
|
cancelText,
|
|
944
958
|
opts
|
|
945
959
|
}) {
|
|
946
|
-
const [isOpen, setIsOpen] =
|
|
947
|
-
const nodeTarget =
|
|
948
|
-
const nodeWindow =
|
|
960
|
+
const [isOpen, setIsOpen] = React16.useState(false);
|
|
961
|
+
const nodeTarget = React16.useRef(null);
|
|
962
|
+
const nodeWindow = React16.useRef(null);
|
|
949
963
|
const { condensed, blocked } = opts || {};
|
|
950
964
|
function handleClickOutside(e) {
|
|
951
965
|
if (nodeTarget.current?.contains(e.target) || nodeWindow.current?.contains(e.target)) {
|
|
@@ -965,7 +979,7 @@ function InlinePrompt({
|
|
|
965
979
|
onConfirm();
|
|
966
980
|
setIsOpen(false);
|
|
967
981
|
}
|
|
968
|
-
|
|
982
|
+
React16.useEffect(() => {
|
|
969
983
|
if (isOpen) {
|
|
970
984
|
document.addEventListener("mousedown", handleClickOutside);
|
|
971
985
|
} else {
|
|
@@ -1185,7 +1199,7 @@ function Td({ className, align, colSpan, condensed, narrow, children }) {
|
|
|
1185
1199
|
}
|
|
1186
1200
|
);
|
|
1187
1201
|
}
|
|
1188
|
-
var Input =
|
|
1202
|
+
var Input = React16.forwardRef((props, ref) => {
|
|
1189
1203
|
const {
|
|
1190
1204
|
id,
|
|
1191
1205
|
theme,
|
|
@@ -1221,11 +1235,11 @@ var Input = React15.forwardRef((props, ref) => {
|
|
|
1221
1235
|
hideIndicator,
|
|
1222
1236
|
darkMode
|
|
1223
1237
|
} = props;
|
|
1224
|
-
const [focused, setFocused] =
|
|
1225
|
-
const inputRef =
|
|
1238
|
+
const [focused, setFocused] = React16.useState(false);
|
|
1239
|
+
const inputRef = React16.useRef(null);
|
|
1226
1240
|
const hasPrefix = !!prefix && prefix.length > 0;
|
|
1227
|
-
|
|
1228
|
-
|
|
1241
|
+
React16.useImperativeHandle(ref, () => inputRef.current);
|
|
1242
|
+
React16.useEffect(() => {
|
|
1229
1243
|
if (listening && inputRef.current && defaultValue !== null && defaultValue !== void 0) {
|
|
1230
1244
|
if (hasPrefix) {
|
|
1231
1245
|
inputRef.current.value = prefix + String(defaultValue);
|
|
@@ -1403,7 +1417,7 @@ function Label({
|
|
|
1403
1417
|
)
|
|
1404
1418
|
] });
|
|
1405
1419
|
}
|
|
1406
|
-
var Select =
|
|
1420
|
+
var Select = React16.forwardRef((props, ref) => {
|
|
1407
1421
|
const {
|
|
1408
1422
|
id,
|
|
1409
1423
|
loading = false,
|
|
@@ -1443,7 +1457,7 @@ var Select = React15.forwardRef((props, ref) => {
|
|
|
1443
1457
|
});
|
|
1444
1458
|
Select.displayName = "Select";
|
|
1445
1459
|
var Select_default = Select;
|
|
1446
|
-
var SelectInput =
|
|
1460
|
+
var SelectInput = React16.forwardRef((props, ref) => {
|
|
1447
1461
|
const {
|
|
1448
1462
|
className,
|
|
1449
1463
|
placeholder = "Select an option",
|
|
@@ -1480,7 +1494,7 @@ var SelectInput = React15.forwardRef((props, ref) => {
|
|
|
1480
1494
|
});
|
|
1481
1495
|
SelectInput.displayName = "SelectInput";
|
|
1482
1496
|
var SelectInput_default = SelectInput;
|
|
1483
|
-
var Textarea =
|
|
1497
|
+
var Textarea = React16.forwardRef((props, ref) => {
|
|
1484
1498
|
const {
|
|
1485
1499
|
id,
|
|
1486
1500
|
className,
|
|
@@ -1545,8 +1559,8 @@ function TagInput({
|
|
|
1545
1559
|
onChange,
|
|
1546
1560
|
placeholder
|
|
1547
1561
|
}) {
|
|
1548
|
-
const [currentState, setCurrentState] =
|
|
1549
|
-
const tagInputRef =
|
|
1562
|
+
const [currentState, setCurrentState] = React16.useState(0);
|
|
1563
|
+
const tagInputRef = React16.useRef(null);
|
|
1550
1564
|
function reducer(state, action) {
|
|
1551
1565
|
const updatedValues = { ...state };
|
|
1552
1566
|
if ("tags" in action) {
|
|
@@ -1560,11 +1574,11 @@ function TagInput({
|
|
|
1560
1574
|
}
|
|
1561
1575
|
return updatedValues;
|
|
1562
1576
|
}
|
|
1563
|
-
const [values, dispatch] =
|
|
1577
|
+
const [values, dispatch] = React16.useReducer(reducer, {
|
|
1564
1578
|
tags: []
|
|
1565
1579
|
});
|
|
1566
1580
|
const { tags } = values;
|
|
1567
|
-
|
|
1581
|
+
React16.useEffect(() => {
|
|
1568
1582
|
if (defaultValue) {
|
|
1569
1583
|
dispatch({ tags: defaultValue, render: true });
|
|
1570
1584
|
} else {
|
|
@@ -1651,35 +1665,41 @@ function NoData({ className }) {
|
|
|
1651
1665
|
] })
|
|
1652
1666
|
] });
|
|
1653
1667
|
}
|
|
1654
|
-
var ThemeContext =
|
|
1668
|
+
var ThemeContext = React16.createContext(void 0);
|
|
1655
1669
|
function ThemeProvider({ children, defaultTheme = "system" }) {
|
|
1656
|
-
const [mode, setMode] =
|
|
1657
|
-
const [isDark, setIsDark] =
|
|
1658
|
-
const
|
|
1659
|
-
|
|
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(() => {
|
|
1670
|
+
const [mode, setMode] = React16.useState(defaultTheme);
|
|
1671
|
+
const [isDark, setIsDark] = React16.useState(false);
|
|
1672
|
+
const [mounted, setMounted] = React16.useState(false);
|
|
1673
|
+
React16.useEffect(() => {
|
|
1667
1674
|
const saved = localStorage.getItem("theme") || defaultTheme;
|
|
1668
1675
|
setMode(saved);
|
|
1676
|
+
setMounted(true);
|
|
1669
1677
|
}, [defaultTheme]);
|
|
1670
|
-
|
|
1678
|
+
React16.useEffect(() => {
|
|
1679
|
+
if (!mounted) return;
|
|
1671
1680
|
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1672
|
-
const
|
|
1673
|
-
const
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1681
|
+
const updateTheme = () => {
|
|
1682
|
+
const prefersDark = media.matches;
|
|
1683
|
+
const currentIsDark = mode === "dark" || mode === "system" && prefersDark;
|
|
1684
|
+
if (currentIsDark) {
|
|
1685
|
+
document.documentElement.classList.add("dark");
|
|
1686
|
+
document.documentElement.classList.remove("light");
|
|
1687
|
+
} else {
|
|
1688
|
+
document.documentElement.classList.remove("dark");
|
|
1689
|
+
document.documentElement.classList.add("light");
|
|
1678
1690
|
}
|
|
1691
|
+
setIsDark(currentIsDark);
|
|
1679
1692
|
};
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1693
|
+
const timeoutId = setTimeout(updateTheme, 0);
|
|
1694
|
+
const handleMediaChange = () => {
|
|
1695
|
+
updateTheme();
|
|
1696
|
+
};
|
|
1697
|
+
media.addEventListener("change", handleMediaChange);
|
|
1698
|
+
return () => {
|
|
1699
|
+
clearTimeout(timeoutId);
|
|
1700
|
+
media.removeEventListener("change", handleMediaChange);
|
|
1701
|
+
};
|
|
1702
|
+
}, [mode, mounted]);
|
|
1683
1703
|
function handleToggleTheme(triggerMode) {
|
|
1684
1704
|
const triggeredMode = triggerMode === mode ? "system" : triggerMode;
|
|
1685
1705
|
setMode(triggeredMode);
|
|
@@ -1702,7 +1722,7 @@ function ThemeProvider({ children, defaultTheme = "system" }) {
|
|
|
1702
1722
|
);
|
|
1703
1723
|
}
|
|
1704
1724
|
function useThemeContext() {
|
|
1705
|
-
const context =
|
|
1725
|
+
const context = React16.useContext(ThemeContext);
|
|
1706
1726
|
if (!context) {
|
|
1707
1727
|
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
1708
1728
|
}
|
|
@@ -1749,13 +1769,13 @@ function debounce(fn, delay) {
|
|
|
1749
1769
|
|
|
1750
1770
|
// src/hooks/useDebounce.ts
|
|
1751
1771
|
function useDebounce(callback, delay, deps = []) {
|
|
1752
|
-
const callbackFn =
|
|
1772
|
+
const callbackFn = React16.useCallback(debounce(callback, delay), deps);
|
|
1753
1773
|
return [callbackFn];
|
|
1754
1774
|
}
|
|
1755
1775
|
|
|
1756
1776
|
// src/hooks/useResizeListener.ts
|
|
1757
1777
|
function useResizeListener(props = {}) {
|
|
1758
|
-
const [values, setValues] =
|
|
1778
|
+
const [values, setValues] = React16.useState(
|
|
1759
1779
|
[
|
|
1760
1780
|
typeof window === "undefined" ? props.mobileAgent ? 375 : 1080 : window.innerWidth,
|
|
1761
1781
|
typeof window === "undefined" ? props.mobileAgent ? 812 : 750 : window.innerHeight,
|
|
@@ -1777,7 +1797,7 @@ function useResizeListener(props = {}) {
|
|
|
1777
1797
|
]);
|
|
1778
1798
|
}
|
|
1779
1799
|
const [debouncedSetValue] = useDebounce(handleChangeViewport, 300);
|
|
1780
|
-
|
|
1800
|
+
React16.useEffect(() => {
|
|
1781
1801
|
window.addEventListener("resize", debouncedSetValue);
|
|
1782
1802
|
return () => {
|
|
1783
1803
|
window.removeEventListener("resize", debouncedSetValue);
|
|
@@ -1785,7 +1805,7 @@ function useResizeListener(props = {}) {
|
|
|
1785
1805
|
}, [debouncedSetValue]);
|
|
1786
1806
|
return { screenWidth, screenHeight, viewport, viewMode, mobileView, tabletView };
|
|
1787
1807
|
}
|
|
1788
|
-
var PopoverContext =
|
|
1808
|
+
var PopoverContext = React16.createContext(void 0);
|
|
1789
1809
|
function PopoverCard({
|
|
1790
1810
|
show,
|
|
1791
1811
|
style,
|
|
@@ -1934,8 +1954,8 @@ var resetValues = {
|
|
|
1934
1954
|
actions: null
|
|
1935
1955
|
};
|
|
1936
1956
|
function PopoverProvider({ children }) {
|
|
1937
|
-
const [currentState, setCurrentState] =
|
|
1938
|
-
const [values, dispatch] =
|
|
1957
|
+
const [currentState, setCurrentState] = React16.useState(0);
|
|
1958
|
+
const [values, dispatch] = React16.useReducer(reducer, resetValues);
|
|
1939
1959
|
const { show, style, tooltipStyle, position, description, actions } = values;
|
|
1940
1960
|
function reducer(state, action) {
|
|
1941
1961
|
const updatedValues = { ...state };
|
|
@@ -2000,7 +2020,7 @@ function PopoverProvider({ children }) {
|
|
|
2000
2020
|
);
|
|
2001
2021
|
}
|
|
2002
2022
|
function usePopoverContext() {
|
|
2003
|
-
const context =
|
|
2023
|
+
const context = React16.useContext(PopoverContext);
|
|
2004
2024
|
if (!context) {
|
|
2005
2025
|
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
2006
2026
|
}
|
|
@@ -2010,10 +2030,10 @@ function Popover({ className, description, actions, children, opts }) {
|
|
|
2010
2030
|
const { activated } = opts || {};
|
|
2011
2031
|
const { showPopover, setPopover } = usePopoverContext();
|
|
2012
2032
|
const { screenWidth, screenHeight } = useResizeListener();
|
|
2013
|
-
const [menuData, setMenuData] =
|
|
2014
|
-
const parentRef =
|
|
2033
|
+
const [menuData, setMenuData] = React16.useState({ showMenu: false, x: 0, y: 0, left: 0, right: 0, top: 0, bottom: 0 });
|
|
2034
|
+
const parentRef = React16.useRef(null);
|
|
2015
2035
|
(actions || []).some((action) => (action.items || []).length > 0);
|
|
2016
|
-
|
|
2036
|
+
React16.useEffect(() => {
|
|
2017
2037
|
const stickyTop = menuData.showMenu && screenHeight - (menuData.y + 14) < 300;
|
|
2018
2038
|
setPopover({
|
|
2019
2039
|
show: menuData.showMenu,
|
|
@@ -2036,7 +2056,7 @@ function Popover({ className, description, actions, children, opts }) {
|
|
|
2036
2056
|
actions
|
|
2037
2057
|
});
|
|
2038
2058
|
}, [menuData, screenWidth, screenHeight, description, actions, setPopover]);
|
|
2039
|
-
|
|
2059
|
+
React16.useEffect(() => {
|
|
2040
2060
|
if (!showPopover && !!menuData.showMenu) {
|
|
2041
2061
|
setMenuData((prev) => ({
|
|
2042
2062
|
...prev,
|
|
@@ -2165,8 +2185,8 @@ function Dragger({
|
|
|
2165
2185
|
children,
|
|
2166
2186
|
onChange
|
|
2167
2187
|
}) {
|
|
2168
|
-
const [, setCurrentState] =
|
|
2169
|
-
const [values, dispatch] =
|
|
2188
|
+
const [, setCurrentState] = React16.useState(0);
|
|
2189
|
+
const [values, dispatch] = React16.useReducer(reducer, {
|
|
2170
2190
|
items: null,
|
|
2171
2191
|
displayItems: null,
|
|
2172
2192
|
dragging: false,
|
|
@@ -2179,14 +2199,14 @@ function Dragger({
|
|
|
2179
2199
|
const { items, displayItems, dragging, dragItem, dragFrom, dragTo, updated } = values || {};
|
|
2180
2200
|
const grandChildren = children && children.props.children;
|
|
2181
2201
|
const isValid = !disabled && !!records && !!children && !!grandChildren && grandChildren.length > 0;
|
|
2182
|
-
|
|
2202
|
+
React16.useEffect(() => {
|
|
2183
2203
|
dispatch({
|
|
2184
2204
|
items: grandChildren,
|
|
2185
2205
|
updated: false,
|
|
2186
2206
|
render: true
|
|
2187
2207
|
});
|
|
2188
2208
|
}, [timestamp, grandChildren]);
|
|
2189
|
-
|
|
2209
|
+
React16.useEffect(() => {
|
|
2190
2210
|
if (!updated) {
|
|
2191
2211
|
if (grandChildren && grandChildren.length > 0) {
|
|
2192
2212
|
dispatch({
|
|
@@ -2426,9 +2446,9 @@ function Dragger({
|
|
|
2426
2446
|
}
|
|
2427
2447
|
dispatch({ dragging: false });
|
|
2428
2448
|
}
|
|
2429
|
-
const derivedItems = !!items &&
|
|
2449
|
+
const derivedItems = !!items && React16__default.default.cloneElement(children, {
|
|
2430
2450
|
children: items.map((grandChild, index) => {
|
|
2431
|
-
return
|
|
2451
|
+
return React16__default.default.cloneElement(grandChild, {
|
|
2432
2452
|
id: (records[index] || {}).id,
|
|
2433
2453
|
draggable: true,
|
|
2434
2454
|
className: classNames({
|
|
@@ -2445,9 +2465,9 @@ function Dragger({
|
|
|
2445
2465
|
});
|
|
2446
2466
|
})
|
|
2447
2467
|
});
|
|
2448
|
-
const derivedDisplayItems = !!displayItems &&
|
|
2468
|
+
const derivedDisplayItems = !!displayItems && React16__default.default.cloneElement(children, {
|
|
2449
2469
|
children: displayItems.map((grandChild, index) => {
|
|
2450
|
-
return
|
|
2470
|
+
return React16__default.default.cloneElement(grandChild, {
|
|
2451
2471
|
draggable: true,
|
|
2452
2472
|
className: classNames({
|
|
2453
2473
|
...classNameObject(grandChild.props.className),
|
|
@@ -2505,8 +2525,8 @@ function ExcelTable({
|
|
|
2505
2525
|
isAddRowVisible = true,
|
|
2506
2526
|
addRowLabel = "+ Add Option"
|
|
2507
2527
|
}) {
|
|
2508
|
-
const [editingCell, setEditingCell] =
|
|
2509
|
-
|
|
2528
|
+
const [editingCell, setEditingCell] = React16.useState(null);
|
|
2529
|
+
React16.useEffect(() => {
|
|
2510
2530
|
setTimeout(() => {
|
|
2511
2531
|
const textareas = document.querySelectorAll(".excel-table-textarea");
|
|
2512
2532
|
textareas.forEach((ta) => {
|
|
@@ -2730,21 +2750,21 @@ function ExcelTable({
|
|
|
2730
2750
|
] }) });
|
|
2731
2751
|
}
|
|
2732
2752
|
function Coverflow({ images = [], onClose }) {
|
|
2733
|
-
const scrollContainerRef =
|
|
2734
|
-
const thumbnailContainerRef =
|
|
2735
|
-
const [visualIndex, setVisualIndex] =
|
|
2736
|
-
const isJumpingRef =
|
|
2737
|
-
const wheelLockRef =
|
|
2738
|
-
const wheelTimeoutRef =
|
|
2739
|
-
const [isReady, setIsReady] =
|
|
2740
|
-
const [isMounted, setIsMounted] =
|
|
2741
|
-
|
|
2753
|
+
const scrollContainerRef = React16.useRef(null);
|
|
2754
|
+
const thumbnailContainerRef = React16.useRef(null);
|
|
2755
|
+
const [visualIndex, setVisualIndex] = React16.useState(0);
|
|
2756
|
+
const isJumpingRef = React16.useRef(false);
|
|
2757
|
+
const wheelLockRef = React16.useRef(false);
|
|
2758
|
+
const wheelTimeoutRef = React16.useRef(null);
|
|
2759
|
+
const [isReady, setIsReady] = React16.useState(false);
|
|
2760
|
+
const [isMounted, setIsMounted] = React16.useState(false);
|
|
2761
|
+
React16.useEffect(() => {
|
|
2742
2762
|
setIsMounted(true);
|
|
2743
2763
|
}, []);
|
|
2744
2764
|
const count = images.length;
|
|
2745
2765
|
const hasMultiple = count > 1;
|
|
2746
2766
|
const extendedImages = hasMultiple ? [images[count - 1], ...images, images[0]] : images;
|
|
2747
|
-
|
|
2767
|
+
React16.useEffect(() => {
|
|
2748
2768
|
if (hasMultiple && scrollContainerRef.current) {
|
|
2749
2769
|
const container = scrollContainerRef.current;
|
|
2750
2770
|
const width = container.offsetWidth;
|
|
@@ -2755,7 +2775,7 @@ function Coverflow({ images = [], onClose }) {
|
|
|
2755
2775
|
setIsReady(true);
|
|
2756
2776
|
}
|
|
2757
2777
|
}, [hasMultiple]);
|
|
2758
|
-
|
|
2778
|
+
React16.useEffect(() => {
|
|
2759
2779
|
if (hasMultiple && thumbnailContainerRef.current) {
|
|
2760
2780
|
const thumbContainer = thumbnailContainerRef.current;
|
|
2761
2781
|
const thumbNode = thumbContainer.children[visualIndex];
|
|
@@ -2768,7 +2788,7 @@ function Coverflow({ images = [], onClose }) {
|
|
|
2768
2788
|
}
|
|
2769
2789
|
}
|
|
2770
2790
|
}, [visualIndex, hasMultiple]);
|
|
2771
|
-
|
|
2791
|
+
React16.useEffect(() => {
|
|
2772
2792
|
const container = scrollContainerRef.current;
|
|
2773
2793
|
if (!container || !hasMultiple) return;
|
|
2774
2794
|
const handleWheel = (e) => {
|
|
@@ -2872,7 +2892,7 @@ function Coverflow({ images = [], onClose }) {
|
|
|
2872
2892
|
behavior: "smooth"
|
|
2873
2893
|
});
|
|
2874
2894
|
};
|
|
2875
|
-
|
|
2895
|
+
React16.useEffect(() => {
|
|
2876
2896
|
const handleKeyDown = (e) => {
|
|
2877
2897
|
if (e.key === "Escape") onClose && onClose();
|
|
2878
2898
|
if (e.key === "ArrowLeft") prevSlide();
|
|
@@ -3046,7 +3066,7 @@ function DataTableRow({ index, selected, label, description, additionalDescripti
|
|
|
3046
3066
|
"!text-left": dataItem.align === "left",
|
|
3047
3067
|
"align-middle": vertical === "middle"
|
|
3048
3068
|
}),
|
|
3049
|
-
children: typeof dataItem.data[index] === "string" ||
|
|
3069
|
+
children: typeof dataItem.data[index] === "string" || React16__default.default.isValidElement(dataItem.data[index]) ? dataItem.data[index] : numberFormatter(dataItem.data[index], dataItem.decimal != null ? dataItem.decimal : 1)
|
|
3050
3070
|
},
|
|
3051
3071
|
`${dataIndex}-${index}`
|
|
3052
3072
|
))
|
|
@@ -3067,8 +3087,8 @@ function DataTable({
|
|
|
3067
3087
|
}) {
|
|
3068
3088
|
const { mobileView } = useResizeListener();
|
|
3069
3089
|
const { ignoreTotal, showCurrency, labelTitle, labelCentered, vertical, darkMode } = opts || {};
|
|
3070
|
-
const [displayHeaders, setDisplayHeaders] =
|
|
3071
|
-
|
|
3090
|
+
const [displayHeaders, setDisplayHeaders] = React16.useState([]);
|
|
3091
|
+
React16.useEffect(() => {
|
|
3072
3092
|
setDisplayHeaders(headers);
|
|
3073
3093
|
}, [headers]);
|
|
3074
3094
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3183,7 +3203,7 @@ function DataTable({
|
|
|
3183
3203
|
backgroundColor: `${colors[dataIndex]}`,
|
|
3184
3204
|
color: bestTextColorForBg(colors[dataIndex])
|
|
3185
3205
|
} : void 0,
|
|
3186
|
-
children: typeof total[dataIndex] === "string" ||
|
|
3206
|
+
children: typeof total[dataIndex] === "string" || React16__default.default.isValidElement(total[dataIndex]) ? total[dataIndex] : showCurrency ? /* @__PURE__ */ jsxRuntime.jsx(CurrencyDisplay, { amount: total[dataIndex] }) : numberFormatter(total[dataIndex], 1)
|
|
3187
3207
|
},
|
|
3188
3208
|
`${dataIndex}-total`
|
|
3189
3209
|
))
|
|
@@ -3365,8 +3385,8 @@ function DataGridHeader({ sort, onClick, opts, children }) {
|
|
|
3365
3385
|
);
|
|
3366
3386
|
}
|
|
3367
3387
|
function DataGridElement({ processing: defaultProcessing, type, value, error, menu, params, opts, onSelect }) {
|
|
3368
|
-
const [processing, setProcessing] =
|
|
3369
|
-
|
|
3388
|
+
const [processing, setProcessing] = React16.useState(defaultProcessing);
|
|
3389
|
+
React16.useEffect(() => {
|
|
3370
3390
|
setProcessing(defaultProcessing);
|
|
3371
3391
|
}, [defaultProcessing]);
|
|
3372
3392
|
const { align } = opts || {};
|
|
@@ -3458,8 +3478,8 @@ function DataGridContent({ loading, error, type, value, opts, onClick }) {
|
|
|
3458
3478
|
);
|
|
3459
3479
|
}
|
|
3460
3480
|
function DataGrid({ headers, data, selectedId, footers, opts, onSelect }) {
|
|
3461
|
-
const [displayedData, setDisplayedData] =
|
|
3462
|
-
const [orderByState, setOrderByState] =
|
|
3481
|
+
const [displayedData, setDisplayedData] = React16.useState([]);
|
|
3482
|
+
const [orderByState, setOrderByState] = React16.useState({
|
|
3463
3483
|
category: headers[0]?.id || "",
|
|
3464
3484
|
direction: "asc"
|
|
3465
3485
|
});
|
|
@@ -3471,7 +3491,7 @@ function DataGrid({ headers, data, selectedId, footers, opts, onSelect }) {
|
|
|
3471
3491
|
setOrderByState({ category, direction: orderByState.direction === "asc" ? "desc" : "asc" });
|
|
3472
3492
|
}
|
|
3473
3493
|
}
|
|
3474
|
-
|
|
3494
|
+
React16.useEffect(() => {
|
|
3475
3495
|
if ((data || []).length > 0) {
|
|
3476
3496
|
const availableKeys = (headers || []).map((header) => header.id);
|
|
3477
3497
|
const { category, direction } = orderByState;
|