@unifiedsoftware/react-ui 1.0.4 → 1.0.5
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 +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +57 -60
- package/dist/index.mjs +95 -98
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -80,6 +80,13 @@ type MenuGroupProps = Omit<MenuItemProps$1, 'items'> & {
|
|
|
80
80
|
};
|
|
81
81
|
declare const MenuGroup: React.FC<MenuGroupProps>;
|
|
82
82
|
|
|
83
|
+
type MenuItemType = (MenuGroupProps & {
|
|
84
|
+
type?: 'group';
|
|
85
|
+
}) | (MenuSubmenuProps & {
|
|
86
|
+
type?: 'submenu';
|
|
87
|
+
}) | (MenuItemProps$1 & {
|
|
88
|
+
type?: 'item';
|
|
89
|
+
});
|
|
83
90
|
interface Props$8 {
|
|
84
91
|
value?: any | any[];
|
|
85
92
|
defaultValue?: any | any[];
|
|
@@ -88,15 +95,9 @@ interface Props$8 {
|
|
|
88
95
|
openMode?: 'manual' | 'automatic';
|
|
89
96
|
onChange?: (value: any | any[]) => void;
|
|
90
97
|
onOpen?: (values: any[]) => void;
|
|
98
|
+
onItemSelect?: (props: MenuItemProps$1) => void;
|
|
91
99
|
}
|
|
92
100
|
type NativeAttrs$2 = Omit<React.HTMLAttributes<HTMLDivElement>, keyof Props$8 | 'items'>;
|
|
93
|
-
type MenuItemType = (MenuGroupProps & {
|
|
94
|
-
type?: 'group';
|
|
95
|
-
}) | (MenuSubmenuProps & {
|
|
96
|
-
type?: 'submenu';
|
|
97
|
-
}) | (MenuItemProps$1 & {
|
|
98
|
-
type?: 'item';
|
|
99
|
-
});
|
|
100
101
|
type MenuProps = Props$8 & NativeAttrs$2 & {
|
|
101
102
|
items: MenuItemType[];
|
|
102
103
|
};
|
|
@@ -104,11 +105,13 @@ declare const Menu: React.FC<MenuProps>;
|
|
|
104
105
|
|
|
105
106
|
interface MenuContextValue {
|
|
106
107
|
value: any;
|
|
108
|
+
originalValue: any;
|
|
107
109
|
openValues: any[];
|
|
108
110
|
expandMode: 'single' | 'multiple';
|
|
109
111
|
openMode: 'manual' | 'automatic';
|
|
110
112
|
onChange: (value: any) => void;
|
|
111
113
|
onOpen: (values: any) => void;
|
|
114
|
+
onItemSelect: (props: MenuItemProps$1) => void;
|
|
112
115
|
}
|
|
113
116
|
declare const MenuContext: react.Context<MenuContextValue | null>;
|
|
114
117
|
declare const useMenu: () => MenuContextValue;
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,13 @@ type MenuGroupProps = Omit<MenuItemProps$1, 'items'> & {
|
|
|
80
80
|
};
|
|
81
81
|
declare const MenuGroup: React.FC<MenuGroupProps>;
|
|
82
82
|
|
|
83
|
+
type MenuItemType = (MenuGroupProps & {
|
|
84
|
+
type?: 'group';
|
|
85
|
+
}) | (MenuSubmenuProps & {
|
|
86
|
+
type?: 'submenu';
|
|
87
|
+
}) | (MenuItemProps$1 & {
|
|
88
|
+
type?: 'item';
|
|
89
|
+
});
|
|
83
90
|
interface Props$8 {
|
|
84
91
|
value?: any | any[];
|
|
85
92
|
defaultValue?: any | any[];
|
|
@@ -88,15 +95,9 @@ interface Props$8 {
|
|
|
88
95
|
openMode?: 'manual' | 'automatic';
|
|
89
96
|
onChange?: (value: any | any[]) => void;
|
|
90
97
|
onOpen?: (values: any[]) => void;
|
|
98
|
+
onItemSelect?: (props: MenuItemProps$1) => void;
|
|
91
99
|
}
|
|
92
100
|
type NativeAttrs$2 = Omit<React.HTMLAttributes<HTMLDivElement>, keyof Props$8 | 'items'>;
|
|
93
|
-
type MenuItemType = (MenuGroupProps & {
|
|
94
|
-
type?: 'group';
|
|
95
|
-
}) | (MenuSubmenuProps & {
|
|
96
|
-
type?: 'submenu';
|
|
97
|
-
}) | (MenuItemProps$1 & {
|
|
98
|
-
type?: 'item';
|
|
99
|
-
});
|
|
100
101
|
type MenuProps = Props$8 & NativeAttrs$2 & {
|
|
101
102
|
items: MenuItemType[];
|
|
102
103
|
};
|
|
@@ -104,11 +105,13 @@ declare const Menu: React.FC<MenuProps>;
|
|
|
104
105
|
|
|
105
106
|
interface MenuContextValue {
|
|
106
107
|
value: any;
|
|
108
|
+
originalValue: any;
|
|
107
109
|
openValues: any[];
|
|
108
110
|
expandMode: 'single' | 'multiple';
|
|
109
111
|
openMode: 'manual' | 'automatic';
|
|
110
112
|
onChange: (value: any) => void;
|
|
111
113
|
onOpen: (values: any) => void;
|
|
114
|
+
onItemSelect: (props: MenuItemProps$1) => void;
|
|
112
115
|
}
|
|
113
116
|
declare const MenuContext: react.Context<MenuContextValue | null>;
|
|
114
117
|
declare const useMenu: () => MenuContextValue;
|
package/dist/index.js
CHANGED
|
@@ -315,52 +315,49 @@ var MenuValueContext_default = MenuValueContext;
|
|
|
315
315
|
|
|
316
316
|
// src/components/Menu/MenuItem.tsx
|
|
317
317
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
318
|
-
var MenuItem = (0, import_react8.forwardRef)(
|
|
319
|
-
(_a,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
(0
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
`${PREFIX_CLS}menu-item
|
|
344
|
-
{
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
children:
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
);
|
|
318
|
+
var MenuItem = (0, import_react8.forwardRef)((props, ref) => {
|
|
319
|
+
const _a = props, { as: Component = "div", className, style, value, title, icon, level = 1, disabled, onClick } = _a, rest = __objRest(_a, ["as", "className", "style", "value", "title", "icon", "level", "disabled", "onClick"]);
|
|
320
|
+
const { value: menuValue, originalValue, openMode, onChange, onOpen, onItemSelect } = useMenu();
|
|
321
|
+
const values = (0, import_react8.useContext)(MenuValueContext_default);
|
|
322
|
+
const mergedValues = [...values, value];
|
|
323
|
+
const handleClick = (event) => {
|
|
324
|
+
if (value !== void 0) {
|
|
325
|
+
onChange(mergedValues);
|
|
326
|
+
}
|
|
327
|
+
onClick == null ? void 0 : onClick(event);
|
|
328
|
+
onItemSelect == null ? void 0 : onItemSelect(props);
|
|
329
|
+
};
|
|
330
|
+
(0, import_react8.useEffect)(() => {
|
|
331
|
+
if (openMode === "automatic" && originalValue.length > 0 && originalValue[originalValue.length - 1] === value) {
|
|
332
|
+
onOpen(values);
|
|
333
|
+
onChange(mergedValues);
|
|
334
|
+
}
|
|
335
|
+
}, [value, originalValue, openMode]);
|
|
336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
337
|
+
Component,
|
|
338
|
+
__spreadProps(__spreadValues({
|
|
339
|
+
ref,
|
|
340
|
+
className: (0, import_clsx3.default)(
|
|
341
|
+
`${PREFIX_CLS}menu-item`,
|
|
342
|
+
{
|
|
343
|
+
[`${PREFIX_CLS}menu-item--selected`]: menuValue.includes(value),
|
|
344
|
+
[`${PREFIX_CLS}menu-item--disabled`]: disabled
|
|
345
|
+
},
|
|
346
|
+
className
|
|
347
|
+
),
|
|
348
|
+
style: __spreadValues({
|
|
349
|
+
paddingLeft: level <= 1 ? `var(--${PREFIX_CLS}menu-item-padding-x)` : `calc(${level} * var(--${PREFIX_CLS}menu-item-padding-level))`
|
|
350
|
+
}, style),
|
|
351
|
+
onClick: handleClick
|
|
352
|
+
}, rest), {
|
|
353
|
+
children: [
|
|
354
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${PREFIX_CLS}overlay`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${PREFIX_CLS}overlay__surface` }) }),
|
|
355
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${PREFIX_CLS}menu-item__icon`, children: icon }),
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${PREFIX_CLS}menu-item__content`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `${PREFIX_CLS}menu-item__title`, children: title }) })
|
|
357
|
+
]
|
|
358
|
+
})
|
|
359
|
+
);
|
|
360
|
+
});
|
|
364
361
|
MenuItem.displayName = "MenuItem";
|
|
365
362
|
var MenuItem_default = MenuItem;
|
|
366
363
|
|
|
@@ -416,11 +413,10 @@ var MenuSubmenu = (_a) => {
|
|
|
416
413
|
"items",
|
|
417
414
|
"onClick"
|
|
418
415
|
]);
|
|
419
|
-
const { value: menuValue, openValues, expandMode,
|
|
416
|
+
const { value: menuValue, openValues, expandMode, onOpen } = useMenu();
|
|
420
417
|
const values = (0, import_react9.useContext)(MenuValueContext_default);
|
|
421
418
|
const isOpen = openValues.includes(value);
|
|
422
419
|
const mergedValues = [...values, value];
|
|
423
|
-
const [openMounted, setOpenMounted] = (0, import_react9.useState)(false);
|
|
424
420
|
const content = (0, import_react9.useMemo)(() => {
|
|
425
421
|
return items == null ? void 0 : items.map((_a2, index) => {
|
|
426
422
|
var _b2 = _a2, { type } = _b2, item = __objRest(_b2, ["type"]);
|
|
@@ -442,12 +438,6 @@ var MenuSubmenu = (_a) => {
|
|
|
442
438
|
}
|
|
443
439
|
onClick == null ? void 0 : onClick(event);
|
|
444
440
|
};
|
|
445
|
-
(0, import_react9.useEffect)(() => {
|
|
446
|
-
if (openMode === "automatic" && menuValue.length > 0 && menuValue[menuValue.length - 1] === value && !openMounted) {
|
|
447
|
-
onOpen(values);
|
|
448
|
-
setOpenMounted(true);
|
|
449
|
-
}
|
|
450
|
-
}, [value, menuValue, openMode, openMounted]);
|
|
451
441
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MenuValueContext_default.Provider, { value: mergedValues, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: (0, import_clsx4.default)(`${PREFIX_CLS}menu-submenu`), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Collapse_default, { isOpen, children: [
|
|
452
442
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CollapseTrigger_default, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
453
443
|
"div",
|
|
@@ -536,14 +526,15 @@ var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
|
536
526
|
var Menu = (_a) => {
|
|
537
527
|
var _b = _a, {
|
|
538
528
|
children,
|
|
539
|
-
value: valueProp,
|
|
529
|
+
value: valueProp = [],
|
|
540
530
|
defaultValue,
|
|
541
531
|
openValues: openValuesProp,
|
|
542
532
|
expandMode = "multiple",
|
|
543
533
|
openMode = "manual",
|
|
544
534
|
items,
|
|
545
535
|
onChange,
|
|
546
|
-
onOpen
|
|
536
|
+
onOpen,
|
|
537
|
+
onItemSelect
|
|
547
538
|
} = _b, rest = __objRest(_b, [
|
|
548
539
|
"children",
|
|
549
540
|
"value",
|
|
@@ -553,7 +544,8 @@ var Menu = (_a) => {
|
|
|
553
544
|
"openMode",
|
|
554
545
|
"items",
|
|
555
546
|
"onChange",
|
|
556
|
-
"onOpen"
|
|
547
|
+
"onOpen",
|
|
548
|
+
"onItemSelect"
|
|
557
549
|
]);
|
|
558
550
|
var _a2;
|
|
559
551
|
const [selfValue, setSelfValue] = (0, import_react11.useState)((_a2 = valueProp != null ? valueProp : defaultValue) != null ? _a2 : []);
|
|
@@ -565,7 +557,7 @@ var Menu = (_a) => {
|
|
|
565
557
|
});
|
|
566
558
|
}, [items]);
|
|
567
559
|
const handleChange = (value) => {
|
|
568
|
-
if (valueProp !== void 0) {
|
|
560
|
+
if (valueProp !== void 0 && openMode !== "automatic") {
|
|
569
561
|
onChange == null ? void 0 : onChange(value);
|
|
570
562
|
} else {
|
|
571
563
|
setSelfValue(value);
|
|
@@ -578,8 +570,11 @@ var Menu = (_a) => {
|
|
|
578
570
|
setSelfOpenValues(values);
|
|
579
571
|
}
|
|
580
572
|
};
|
|
573
|
+
const handleItemSelect = (props) => {
|
|
574
|
+
onItemSelect == null ? void 0 : onItemSelect(props);
|
|
575
|
+
};
|
|
581
576
|
(0, import_react11.useEffect)(() => {
|
|
582
|
-
if (valueProp !== void 0) {
|
|
577
|
+
if (valueProp !== void 0 && openMode !== "automatic") {
|
|
583
578
|
setSelfValue(valueProp);
|
|
584
579
|
}
|
|
585
580
|
}, [valueProp]);
|
|
@@ -593,11 +588,13 @@ var Menu = (_a) => {
|
|
|
593
588
|
{
|
|
594
589
|
value: {
|
|
595
590
|
value: selfValue,
|
|
591
|
+
originalValue: valueProp,
|
|
596
592
|
openValues: selfOpenValues,
|
|
597
593
|
expandMode,
|
|
598
594
|
openMode,
|
|
599
595
|
onOpen: handleOpen,
|
|
600
|
-
onChange: handleChange
|
|
596
|
+
onChange: handleChange,
|
|
597
|
+
onItemSelect: handleItemSelect
|
|
601
598
|
},
|
|
602
599
|
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", __spreadProps(__spreadValues({ className: (0, import_clsx6.default)(`${PREFIX_CLS}menu`) }, rest), { children: content || children }))
|
|
603
600
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -200,7 +200,7 @@ var CollapseTrigger_default = CollapseTrigger;
|
|
|
200
200
|
|
|
201
201
|
// src/components/Menu/Menu.tsx
|
|
202
202
|
import clsx6 from "clsx";
|
|
203
|
-
import { useEffect as
|
|
203
|
+
import { useEffect as useEffect3, useMemo as useMemo3, useState as useState2 } from "react";
|
|
204
204
|
|
|
205
205
|
// src/components/Menu/MenuContext.tsx
|
|
206
206
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
@@ -220,7 +220,7 @@ import { useMemo as useMemo2 } from "react";
|
|
|
220
220
|
|
|
221
221
|
// src/components/Menu/MenuItem.tsx
|
|
222
222
|
import clsx3 from "clsx";
|
|
223
|
-
import { forwardRef as forwardRef4, useContext as useContext4, useEffect as useEffect2
|
|
223
|
+
import { forwardRef as forwardRef4, useContext as useContext4, useEffect as useEffect2 } from "react";
|
|
224
224
|
|
|
225
225
|
// src/components/Menu/MenuValueContext.tsx
|
|
226
226
|
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
@@ -236,58 +236,55 @@ var MenuValueContext_default = MenuValueContext;
|
|
|
236
236
|
|
|
237
237
|
// src/components/Menu/MenuItem.tsx
|
|
238
238
|
import { jsx as jsx2, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
239
|
-
var MenuItem = forwardRef4(
|
|
240
|
-
(_a,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
`${PREFIX_CLS}menu-item
|
|
265
|
-
{
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
children:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
);
|
|
239
|
+
var MenuItem = forwardRef4((props, ref) => {
|
|
240
|
+
const _a = props, { as: Component = "div", className, style, value, title, icon, level = 1, disabled, onClick } = _a, rest = __objRest(_a, ["as", "className", "style", "value", "title", "icon", "level", "disabled", "onClick"]);
|
|
241
|
+
const { value: menuValue, originalValue, openMode, onChange, onOpen, onItemSelect } = useMenu();
|
|
242
|
+
const values = useContext4(MenuValueContext_default);
|
|
243
|
+
const mergedValues = [...values, value];
|
|
244
|
+
const handleClick = (event) => {
|
|
245
|
+
if (value !== void 0) {
|
|
246
|
+
onChange(mergedValues);
|
|
247
|
+
}
|
|
248
|
+
onClick == null ? void 0 : onClick(event);
|
|
249
|
+
onItemSelect == null ? void 0 : onItemSelect(props);
|
|
250
|
+
};
|
|
251
|
+
useEffect2(() => {
|
|
252
|
+
if (openMode === "automatic" && originalValue.length > 0 && originalValue[originalValue.length - 1] === value) {
|
|
253
|
+
onOpen(values);
|
|
254
|
+
onChange(mergedValues);
|
|
255
|
+
}
|
|
256
|
+
}, [value, originalValue, openMode]);
|
|
257
|
+
return /* @__PURE__ */ jsxs3(
|
|
258
|
+
Component,
|
|
259
|
+
__spreadProps(__spreadValues({
|
|
260
|
+
ref,
|
|
261
|
+
className: clsx3(
|
|
262
|
+
`${PREFIX_CLS}menu-item`,
|
|
263
|
+
{
|
|
264
|
+
[`${PREFIX_CLS}menu-item--selected`]: menuValue.includes(value),
|
|
265
|
+
[`${PREFIX_CLS}menu-item--disabled`]: disabled
|
|
266
|
+
},
|
|
267
|
+
className
|
|
268
|
+
),
|
|
269
|
+
style: __spreadValues({
|
|
270
|
+
paddingLeft: level <= 1 ? `var(--${PREFIX_CLS}menu-item-padding-x)` : `calc(${level} * var(--${PREFIX_CLS}menu-item-padding-level))`
|
|
271
|
+
}, style),
|
|
272
|
+
onClick: handleClick
|
|
273
|
+
}, rest), {
|
|
274
|
+
children: [
|
|
275
|
+
/* @__PURE__ */ jsx2("div", { className: `${PREFIX_CLS}overlay`, children: /* @__PURE__ */ jsx2("div", { className: `${PREFIX_CLS}overlay__surface` }) }),
|
|
276
|
+
icon && /* @__PURE__ */ jsx2("div", { className: `${PREFIX_CLS}menu-item__icon`, children: icon }),
|
|
277
|
+
/* @__PURE__ */ jsx2("div", { className: `${PREFIX_CLS}menu-item__content`, children: /* @__PURE__ */ jsx2("span", { className: `${PREFIX_CLS}menu-item__title`, children: title }) })
|
|
278
|
+
]
|
|
279
|
+
})
|
|
280
|
+
);
|
|
281
|
+
});
|
|
285
282
|
MenuItem.displayName = "MenuItem";
|
|
286
283
|
var MenuItem_default = MenuItem;
|
|
287
284
|
|
|
288
285
|
// src/components/Menu/MenuSubmenu.tsx
|
|
289
286
|
import clsx4 from "clsx";
|
|
290
|
-
import { useContext as useContext5,
|
|
287
|
+
import { useContext as useContext5, useMemo } from "react";
|
|
291
288
|
import { MdKeyboardArrowDown, MdKeyboardArrowUp } from "react-icons/md";
|
|
292
289
|
|
|
293
290
|
// src/components/Menu/utils.ts
|
|
@@ -337,11 +334,10 @@ var MenuSubmenu = (_a) => {
|
|
|
337
334
|
"items",
|
|
338
335
|
"onClick"
|
|
339
336
|
]);
|
|
340
|
-
const { value: menuValue, openValues, expandMode,
|
|
337
|
+
const { value: menuValue, openValues, expandMode, onOpen } = useMenu();
|
|
341
338
|
const values = useContext5(MenuValueContext_default);
|
|
342
339
|
const isOpen = openValues.includes(value);
|
|
343
340
|
const mergedValues = [...values, value];
|
|
344
|
-
const [openMounted, setOpenMounted] = useState3(false);
|
|
345
341
|
const content = useMemo(() => {
|
|
346
342
|
return items == null ? void 0 : items.map((_a2, index) => {
|
|
347
343
|
var _b2 = _a2, { type } = _b2, item = __objRest(_b2, ["type"]);
|
|
@@ -363,12 +359,6 @@ var MenuSubmenu = (_a) => {
|
|
|
363
359
|
}
|
|
364
360
|
onClick == null ? void 0 : onClick(event);
|
|
365
361
|
};
|
|
366
|
-
useEffect3(() => {
|
|
367
|
-
if (openMode === "automatic" && menuValue.length > 0 && menuValue[menuValue.length - 1] === value && !openMounted) {
|
|
368
|
-
onOpen(values);
|
|
369
|
-
setOpenMounted(true);
|
|
370
|
-
}
|
|
371
|
-
}, [value, menuValue, openMode, openMounted]);
|
|
372
362
|
return /* @__PURE__ */ jsx3(MenuValueContext_default.Provider, { value: mergedValues, children: /* @__PURE__ */ jsx3("div", { className: clsx4(`${PREFIX_CLS}menu-submenu`), children: /* @__PURE__ */ jsxs4(Collapse_default, { isOpen, children: [
|
|
373
363
|
/* @__PURE__ */ jsx3(CollapseTrigger_default, { children: /* @__PURE__ */ jsxs4(
|
|
374
364
|
"div",
|
|
@@ -457,14 +447,15 @@ import { jsx as jsx5 } from "react/jsx-runtime";
|
|
|
457
447
|
var Menu = (_a) => {
|
|
458
448
|
var _b = _a, {
|
|
459
449
|
children,
|
|
460
|
-
value: valueProp,
|
|
450
|
+
value: valueProp = [],
|
|
461
451
|
defaultValue,
|
|
462
452
|
openValues: openValuesProp,
|
|
463
453
|
expandMode = "multiple",
|
|
464
454
|
openMode = "manual",
|
|
465
455
|
items,
|
|
466
456
|
onChange,
|
|
467
|
-
onOpen
|
|
457
|
+
onOpen,
|
|
458
|
+
onItemSelect
|
|
468
459
|
} = _b, rest = __objRest(_b, [
|
|
469
460
|
"children",
|
|
470
461
|
"value",
|
|
@@ -474,11 +465,12 @@ var Menu = (_a) => {
|
|
|
474
465
|
"openMode",
|
|
475
466
|
"items",
|
|
476
467
|
"onChange",
|
|
477
|
-
"onOpen"
|
|
468
|
+
"onOpen",
|
|
469
|
+
"onItemSelect"
|
|
478
470
|
]);
|
|
479
471
|
var _a2;
|
|
480
|
-
const [selfValue, setSelfValue] =
|
|
481
|
-
const [selfOpenValues, setSelfOpenValues] =
|
|
472
|
+
const [selfValue, setSelfValue] = useState2((_a2 = valueProp != null ? valueProp : defaultValue) != null ? _a2 : []);
|
|
473
|
+
const [selfOpenValues, setSelfOpenValues] = useState2(openValuesProp != null ? openValuesProp : []);
|
|
482
474
|
const content = useMemo3(() => {
|
|
483
475
|
return items == null ? void 0 : items.map((_a3, index) => {
|
|
484
476
|
var _b2 = _a3, { type } = _b2, item = __objRest(_b2, ["type"]);
|
|
@@ -486,7 +478,7 @@ var Menu = (_a) => {
|
|
|
486
478
|
});
|
|
487
479
|
}, [items]);
|
|
488
480
|
const handleChange = (value) => {
|
|
489
|
-
if (valueProp !== void 0) {
|
|
481
|
+
if (valueProp !== void 0 && openMode !== "automatic") {
|
|
490
482
|
onChange == null ? void 0 : onChange(value);
|
|
491
483
|
} else {
|
|
492
484
|
setSelfValue(value);
|
|
@@ -499,12 +491,15 @@ var Menu = (_a) => {
|
|
|
499
491
|
setSelfOpenValues(values);
|
|
500
492
|
}
|
|
501
493
|
};
|
|
502
|
-
|
|
503
|
-
|
|
494
|
+
const handleItemSelect = (props) => {
|
|
495
|
+
onItemSelect == null ? void 0 : onItemSelect(props);
|
|
496
|
+
};
|
|
497
|
+
useEffect3(() => {
|
|
498
|
+
if (valueProp !== void 0 && openMode !== "automatic") {
|
|
504
499
|
setSelfValue(valueProp);
|
|
505
500
|
}
|
|
506
501
|
}, [valueProp]);
|
|
507
|
-
|
|
502
|
+
useEffect3(() => {
|
|
508
503
|
if (openValuesProp !== void 0) {
|
|
509
504
|
setSelfOpenValues(openValuesProp);
|
|
510
505
|
}
|
|
@@ -514,11 +509,13 @@ var Menu = (_a) => {
|
|
|
514
509
|
{
|
|
515
510
|
value: {
|
|
516
511
|
value: selfValue,
|
|
512
|
+
originalValue: valueProp,
|
|
517
513
|
openValues: selfOpenValues,
|
|
518
514
|
expandMode,
|
|
519
515
|
openMode,
|
|
520
516
|
onOpen: handleOpen,
|
|
521
|
-
onChange: handleChange
|
|
517
|
+
onChange: handleChange,
|
|
518
|
+
onItemSelect: handleItemSelect
|
|
522
519
|
},
|
|
523
520
|
children: /* @__PURE__ */ jsx5("div", __spreadProps(__spreadValues({ className: clsx6(`${PREFIX_CLS}menu`) }, rest), { children: content || children }))
|
|
524
521
|
}
|
|
@@ -530,7 +527,7 @@ var Menu_default = Menu;
|
|
|
530
527
|
// src/components/Tabs/Tab.tsx
|
|
531
528
|
import clsx7 from "clsx";
|
|
532
529
|
import mergeRefs from "merge-refs";
|
|
533
|
-
import { forwardRef as forwardRef5, useEffect as
|
|
530
|
+
import { forwardRef as forwardRef5, useEffect as useEffect4, useRef as useRef2 } from "react";
|
|
534
531
|
|
|
535
532
|
// src/components/Tabs/TabsContext.ts
|
|
536
533
|
import { createContext as createContext4, useContext as useContext6 } from "react";
|
|
@@ -584,7 +581,7 @@ var Tab = forwardRef5(
|
|
|
584
581
|
tabs.onChange(value);
|
|
585
582
|
onClick == null ? void 0 : onClick(event);
|
|
586
583
|
};
|
|
587
|
-
|
|
584
|
+
useEffect4(() => {
|
|
588
585
|
if (value === tabs.value) {
|
|
589
586
|
tabs.previousTabRef.current = tabRef.current;
|
|
590
587
|
}
|
|
@@ -609,18 +606,18 @@ var Tab = forwardRef5(
|
|
|
609
606
|
|
|
610
607
|
// src/components/Tabs/Tabs.tsx
|
|
611
608
|
import clsx8 from "clsx";
|
|
612
|
-
import { useEffect as
|
|
609
|
+
import { useEffect as useEffect5, useRef as useRef3, useState as useState3 } from "react";
|
|
613
610
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
614
611
|
var prefixCls = "us-";
|
|
615
612
|
var Tabs = (_a) => {
|
|
616
613
|
var _b = _a, { children, className, value, defaultValue, onChange } = _b, rest = __objRest(_b, ["children", "className", "value", "defaultValue", "onChange"]);
|
|
617
614
|
const previousTabRef = useRef3(null);
|
|
618
|
-
const [selfValue, setSelfValue] =
|
|
615
|
+
const [selfValue, setSelfValue] = useState3(value != null ? value : defaultValue);
|
|
619
616
|
const handleChange = (value2) => {
|
|
620
617
|
setSelfValue(value2);
|
|
621
618
|
onChange == null ? void 0 : onChange(value2);
|
|
622
619
|
};
|
|
623
|
-
|
|
620
|
+
useEffect5(() => {
|
|
624
621
|
if (value !== void 0) {
|
|
625
622
|
setSelfValue(value);
|
|
626
623
|
}
|
|
@@ -633,7 +630,7 @@ var Tabs = (_a) => {
|
|
|
633
630
|
|
|
634
631
|
// src/components/DropdownEnumList.tsx
|
|
635
632
|
import { DropDownList } from "@progress/kendo-react-dropdowns";
|
|
636
|
-
import { useEffect as
|
|
633
|
+
import { useEffect as useEffect6, useState as useState4 } from "react";
|
|
637
634
|
import { Fragment as Fragment2, jsx as jsx8 } from "react/jsx-runtime";
|
|
638
635
|
function parsearDataForComboBox(array, key, text, itemAll = false) {
|
|
639
636
|
const dataForComboBox = [];
|
|
@@ -669,16 +666,16 @@ function EnumToArray(typeEnum, replaceGuionForSpace = true, description) {
|
|
|
669
666
|
return values;
|
|
670
667
|
}
|
|
671
668
|
var DropEnumList = ({ dataEnum, description, onChange, width, defaultValue }) => {
|
|
672
|
-
const [value, setValue] =
|
|
673
|
-
const [data, setData] =
|
|
674
|
-
|
|
669
|
+
const [value, setValue] = useState4("");
|
|
670
|
+
const [data, setData] = useState4([]);
|
|
671
|
+
useEffect6(() => {
|
|
675
672
|
setData(
|
|
676
673
|
parsearDataForComboBox(EnumToArray(dataEnum, true, description), "value", "label", false).sort(
|
|
677
674
|
(a, b) => Number(a.key) - Number(b.key)
|
|
678
675
|
)
|
|
679
676
|
);
|
|
680
677
|
}, []);
|
|
681
|
-
|
|
678
|
+
useEffect6(() => {
|
|
682
679
|
if (data.length > 0) {
|
|
683
680
|
setValue(data.filter((x) => x.key == defaultValue)[0]);
|
|
684
681
|
}
|
|
@@ -708,17 +705,17 @@ var DropEnumList = ({ dataEnum, description, onChange, width, defaultValue }) =>
|
|
|
708
705
|
};
|
|
709
706
|
|
|
710
707
|
// src/contexts/BreadCrumbContext.tsx
|
|
711
|
-
import { createContext as createContext5, useState as
|
|
708
|
+
import { createContext as createContext5, useState as useState6 } from "react";
|
|
712
709
|
|
|
713
710
|
// src/hooks/useLocalStorage.tsx
|
|
714
|
-
import { useCallback, useEffect as
|
|
711
|
+
import { useCallback, useEffect as useEffect8, useState as useState5 } from "react";
|
|
715
712
|
|
|
716
713
|
// src/hooks/useEventListener.tsx
|
|
717
714
|
import { useRef as useRef4 } from "react";
|
|
718
715
|
|
|
719
716
|
// src/hooks/useIsomorphicLayoutEffect.tsx
|
|
720
|
-
import { useEffect as
|
|
721
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect :
|
|
717
|
+
import { useEffect as useEffect7, useLayoutEffect } from "react";
|
|
718
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect7;
|
|
722
719
|
var useIsomorphicLayoutEffect_default = useIsomorphicLayoutEffect;
|
|
723
720
|
|
|
724
721
|
// src/hooks/useEventListener.tsx
|
|
@@ -744,7 +741,7 @@ function useLocalStorage(key, initialValue) {
|
|
|
744
741
|
return initialValue;
|
|
745
742
|
}
|
|
746
743
|
}, [initialValue, key]);
|
|
747
|
-
const [storedValue, setStoredValue] =
|
|
744
|
+
const [storedValue, setStoredValue] = useState5(readValue);
|
|
748
745
|
const setValue = useCallback(
|
|
749
746
|
(value) => {
|
|
750
747
|
if (typeof window == "undefined") {
|
|
@@ -761,7 +758,7 @@ function useLocalStorage(key, initialValue) {
|
|
|
761
758
|
},
|
|
762
759
|
[key, storedValue]
|
|
763
760
|
);
|
|
764
|
-
|
|
761
|
+
useEffect8(() => {
|
|
765
762
|
setStoredValue(readValue());
|
|
766
763
|
}, []);
|
|
767
764
|
const handleStorageChange = useCallback(() => {
|
|
@@ -788,7 +785,7 @@ var BreadCrumbContextProvider = ({ children }) => {
|
|
|
788
785
|
const [path, setPath] = useLocalStorage("@path", "/");
|
|
789
786
|
const [goBack, setGoBack] = useLocalStorage("@goBack", false);
|
|
790
787
|
const [pathChild, setPathChild] = useLocalStorage("@pathChild", "");
|
|
791
|
-
const [routes, setRoutes] =
|
|
788
|
+
const [routes, setRoutes] = useState6([]);
|
|
792
789
|
return /* @__PURE__ */ jsx9(
|
|
793
790
|
BreadCrumbContext.Provider,
|
|
794
791
|
{
|
|
@@ -810,11 +807,11 @@ var BreadCrumbContextProvider = ({ children }) => {
|
|
|
810
807
|
};
|
|
811
808
|
|
|
812
809
|
// src/contexts/DrawerContext.tsx
|
|
813
|
-
import { createContext as createContext6, useState as
|
|
810
|
+
import { createContext as createContext6, useState as useState7 } from "react";
|
|
814
811
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
815
812
|
var DrawerContext = createContext6({});
|
|
816
813
|
var DrawerContextProvider = ({ children }) => {
|
|
817
|
-
const [active, setActive] =
|
|
814
|
+
const [active, setActive] = useState7(false);
|
|
818
815
|
return /* @__PURE__ */ jsx10(DrawerContext.Provider, { value: { active, setActive }, children });
|
|
819
816
|
};
|
|
820
817
|
|
|
@@ -837,11 +834,11 @@ var HistoryContextProvider = ({ children }) => {
|
|
|
837
834
|
};
|
|
838
835
|
|
|
839
836
|
// src/contexts/SidebarMainContext.tsx
|
|
840
|
-
import { createContext as createContext8, useState as
|
|
837
|
+
import { createContext as createContext8, useState as useState8 } from "react";
|
|
841
838
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
842
839
|
var SidebarMainContext = createContext8({});
|
|
843
840
|
var SidebarMainContextProvider = ({ children }) => {
|
|
844
|
-
const [open2, setOpen] =
|
|
841
|
+
const [open2, setOpen] = useState8(true);
|
|
845
842
|
return /* @__PURE__ */ jsx12(SidebarMainContext.Provider, { value: { open: open2, setOpen }, children });
|
|
846
843
|
};
|
|
847
844
|
|
|
@@ -852,19 +849,19 @@ function GlobalProvider({ children }) {
|
|
|
852
849
|
}
|
|
853
850
|
|
|
854
851
|
// src/hooks/usePrevious.tsx
|
|
855
|
-
import { useEffect as
|
|
852
|
+
import { useEffect as useEffect9, useRef as useRef5 } from "react";
|
|
856
853
|
var usePrevious = (value) => {
|
|
857
854
|
const ref = useRef5();
|
|
858
|
-
|
|
855
|
+
useEffect9(() => {
|
|
859
856
|
ref.current = value;
|
|
860
857
|
});
|
|
861
858
|
return ref.current;
|
|
862
859
|
};
|
|
863
860
|
|
|
864
861
|
// src/hooks/useStep.tsx
|
|
865
|
-
import { useCallback as useCallback2, useMemo as useMemo4, useState as
|
|
862
|
+
import { useCallback as useCallback2, useMemo as useMemo4, useState as useState9 } from "react";
|
|
866
863
|
var useStep = (maxStep) => {
|
|
867
|
-
const [currentStep, setCurrentStep] =
|
|
864
|
+
const [currentStep, setCurrentStep] = useState9(1);
|
|
868
865
|
const canGoToNextStep = useMemo4(() => currentStep + 1 <= maxStep, [currentStep, maxStep]);
|
|
869
866
|
const canGoToPrevStep = useMemo4(() => currentStep - 1 >= 1, [currentStep]);
|
|
870
867
|
const setStep = useCallback2(
|
|
@@ -905,7 +902,7 @@ var useStep = (maxStep) => {
|
|
|
905
902
|
};
|
|
906
903
|
|
|
907
904
|
// src/layout/AppBreadcrumb.tsx
|
|
908
|
-
import { useContext as useContext7, useEffect as
|
|
905
|
+
import { useContext as useContext7, useEffect as useEffect10 } from "react";
|
|
909
906
|
import { MdClose } from "react-icons/md";
|
|
910
907
|
import { VscChevronRight } from "react-icons/vsc";
|
|
911
908
|
import { Link as Link3 } from "react-router-dom";
|
|
@@ -1333,7 +1330,7 @@ var CloseIcon = styled6.button`
|
|
|
1333
1330
|
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1334
1331
|
var AppBreadCrumb = ({ title, paths }) => {
|
|
1335
1332
|
const { setRoutes } = useContext7(BreadCrumbContext);
|
|
1336
|
-
|
|
1333
|
+
useEffect10(() => {
|
|
1337
1334
|
if (!(paths == null ? void 0 : paths.length))
|
|
1338
1335
|
return;
|
|
1339
1336
|
setRoutes(paths != null ? paths : []);
|
|
@@ -1346,10 +1343,10 @@ var AppBreadCrumbNav = ({
|
|
|
1346
1343
|
}) => {
|
|
1347
1344
|
const { active, path, routes, setRoutes } = useContext7(BreadCrumbContext);
|
|
1348
1345
|
const { updateList } = useContext7(HistoryContext);
|
|
1349
|
-
|
|
1346
|
+
useEffect10(() => {
|
|
1350
1347
|
updateList({ name: active, path });
|
|
1351
1348
|
}, [path, active]);
|
|
1352
|
-
|
|
1349
|
+
useEffect10(() => {
|
|
1353
1350
|
setRoutes(paths != null ? paths : []);
|
|
1354
1351
|
}, [paths]);
|
|
1355
1352
|
return /* @__PURE__ */ jsxs8(Breadcrumb, { children: [
|
|
@@ -1389,7 +1386,7 @@ var AppBreadCrumbNav = ({
|
|
|
1389
1386
|
};
|
|
1390
1387
|
|
|
1391
1388
|
// src/layout/AppLoader.tsx
|
|
1392
|
-
import { useEffect as
|
|
1389
|
+
import { useEffect as useEffect11 } from "react";
|
|
1393
1390
|
import ReactDOM from "react-dom";
|
|
1394
1391
|
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1395
1392
|
var LoaderGrid = () => {
|
|
@@ -1410,7 +1407,7 @@ var AppLoader = (props) => {
|
|
|
1410
1407
|
/* @__PURE__ */ jsx15("div", { className: "k-loading-image" }),
|
|
1411
1408
|
/* @__PURE__ */ jsx15("div", { className: "k-loading-color" })
|
|
1412
1409
|
] });
|
|
1413
|
-
|
|
1410
|
+
useEffect11(() => {
|
|
1414
1411
|
if (type === "button") {
|
|
1415
1412
|
const loadingEl = document.createElement("div");
|
|
1416
1413
|
loadingEl.className = "icon button-loading k-loading-mask";
|