@ceed/cds 1.40.3-next.1 → 1.40.3-next.3
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/components/Autocomplete/Autocomplete.d.ts +4 -4
- package/dist/components/Autocomplete/index.d.ts +2 -1
- package/dist/components/DataTable/components.d.ts +1 -1
- package/dist/components/DataTable/hooks.d.ts +6 -7
- package/dist/components/DataTable/types.d.ts +7 -0
- package/dist/components/DataTable/utils.d.ts +5 -0
- package/dist/components/IconMenuButton/IconMenuButton.d.ts +6 -5
- package/dist/components/IconMenuButton/index.d.ts +2 -1
- package/dist/components/Modal/Modal.d.ts +1 -4
- package/dist/components/Select/Select.d.ts +3 -4
- package/dist/components/Textarea/Textarea.d.ts +1 -4
- package/dist/components/Textarea/index.d.ts +2 -1
- package/dist/components/data-display/DataTable.md +4 -0
- package/dist/index.browser.js +6 -6
- package/dist/index.browser.js.map +4 -4
- package/dist/index.cjs +742 -649
- package/dist/index.js +255 -162
- package/dist/libs/slot-props.d.ts +22 -0
- package/framer/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -187,7 +187,7 @@ function Alert(inProps) {
|
|
|
187
187
|
Alert.displayName = "Alert";
|
|
188
188
|
|
|
189
189
|
// src/components/Autocomplete/Autocomplete.tsx
|
|
190
|
-
import React5, { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
|
|
190
|
+
import React5, { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
191
191
|
import {
|
|
192
192
|
Autocomplete as JoyAutocomplete,
|
|
193
193
|
AutocompleteOption as JoyAutocompleteOption,
|
|
@@ -294,6 +294,37 @@ function useControlledState(controlledValue, defaultValue, onChange) {
|
|
|
294
294
|
return [displayValue, handleChange, isControlled];
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
// src/libs/slot-props.ts
|
|
298
|
+
import { useMemo } from "react";
|
|
299
|
+
function assignRef(ref, value) {
|
|
300
|
+
if (typeof ref === "function") ref(value);
|
|
301
|
+
else if (ref) ref.current = value;
|
|
302
|
+
}
|
|
303
|
+
function mergeRefs(...refs) {
|
|
304
|
+
const live = refs.filter((r) => r != null);
|
|
305
|
+
if (live.length === 0) return void 0;
|
|
306
|
+
if (live.length === 1) return live[0];
|
|
307
|
+
return (value) => live.forEach((r) => assignRef(r, value));
|
|
308
|
+
}
|
|
309
|
+
function useMergedRef(a, b) {
|
|
310
|
+
return useMemo(() => mergeRefs(a, b), [a, b]);
|
|
311
|
+
}
|
|
312
|
+
function useSlotRef(slotProp, ref) {
|
|
313
|
+
const isFunctionForm = typeof slotProp === "function";
|
|
314
|
+
const slotRef = isFunctionForm ? void 0 : slotProp?.ref;
|
|
315
|
+
const mergedRef = useMergedRef(slotRef, ref);
|
|
316
|
+
return useMemo(() => {
|
|
317
|
+
if (isFunctionForm) {
|
|
318
|
+
return ((ownerState) => {
|
|
319
|
+
const resolved = slotProp(ownerState);
|
|
320
|
+
const merged = mergeRefs(resolved.ref, ref);
|
|
321
|
+
return merged ? { ...resolved, ref: merged } : { ...resolved };
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return mergedRef ? { ...slotProp, ref: mergedRef } : { ...slotProp };
|
|
325
|
+
}, [isFunctionForm, slotProp, mergedRef, ref]);
|
|
326
|
+
}
|
|
327
|
+
|
|
297
328
|
// src/components/Autocomplete/Autocomplete.tsx
|
|
298
329
|
var AutocompletePopper = styled3(Popper, {
|
|
299
330
|
name: "Autocomplete",
|
|
@@ -318,11 +349,11 @@ var AutocompleteListBox = React5.forwardRef((props, ref) => {
|
|
|
318
349
|
} = props;
|
|
319
350
|
const parentRef = useRef2(null);
|
|
320
351
|
const isGrouped = children[0].every((child) => child.hasOwnProperty("group"));
|
|
321
|
-
const itemHeight =
|
|
352
|
+
const itemHeight = useMemo2(() => {
|
|
322
353
|
const heights = itemHeightMap[fontSize ?? "md"];
|
|
323
354
|
return hasSecondaryText ? heights.secondary : heights.default;
|
|
324
355
|
}, [fontSize, hasSecondaryText]);
|
|
325
|
-
const renderTargets =
|
|
356
|
+
const renderTargets = useMemo2(() => {
|
|
326
357
|
if (loading) {
|
|
327
358
|
return [children[1]];
|
|
328
359
|
}
|
|
@@ -414,7 +445,7 @@ var autocompleteFilterOptions = createFilterOptions({
|
|
|
414
445
|
}
|
|
415
446
|
});
|
|
416
447
|
var getOptionLabel = (option) => `${option.label ?? ""}`;
|
|
417
|
-
function
|
|
448
|
+
function AutocompleteInner(props, ref) {
|
|
418
449
|
const {
|
|
419
450
|
label,
|
|
420
451
|
error,
|
|
@@ -444,7 +475,7 @@ function Autocomplete(props) {
|
|
|
444
475
|
)
|
|
445
476
|
);
|
|
446
477
|
const _value = rawValue ?? (props.multiple ? EMPTY_MULTIPLE_VALUE : "");
|
|
447
|
-
const options =
|
|
478
|
+
const options = useMemo2(
|
|
448
479
|
() => props.options.map((option) => {
|
|
449
480
|
if (typeof option !== "object") {
|
|
450
481
|
return {
|
|
@@ -456,14 +487,14 @@ function Autocomplete(props) {
|
|
|
456
487
|
}),
|
|
457
488
|
[props.options]
|
|
458
489
|
);
|
|
459
|
-
const optionMap =
|
|
490
|
+
const optionMap = useMemo2(() => {
|
|
460
491
|
const map = /* @__PURE__ */ new Map();
|
|
461
492
|
options.forEach((option) => {
|
|
462
493
|
map.set(option.value, option);
|
|
463
494
|
});
|
|
464
495
|
return map;
|
|
465
496
|
}, [options]);
|
|
466
|
-
const value =
|
|
497
|
+
const value = useMemo2(() => {
|
|
467
498
|
if (props.loading) {
|
|
468
499
|
return {
|
|
469
500
|
value: "",
|
|
@@ -482,23 +513,25 @@ function Autocomplete(props) {
|
|
|
482
513
|
},
|
|
483
514
|
[size, props.loading]
|
|
484
515
|
);
|
|
485
|
-
const startDecorator =
|
|
516
|
+
const startDecorator = useMemo2(
|
|
486
517
|
() => applySize(value?.startDecorator || props.startDecorator),
|
|
487
518
|
[value, applySize, props.startDecorator]
|
|
488
519
|
);
|
|
489
|
-
const endDecorator =
|
|
520
|
+
const endDecorator = useMemo2(
|
|
490
521
|
() => applySize(value?.endDecorator || props.endDecorator),
|
|
491
522
|
[value, applySize, props.endDecorator]
|
|
492
523
|
);
|
|
493
|
-
const
|
|
524
|
+
const inputSlotProps = useSlotRef(props.slotProps?.input, ref);
|
|
525
|
+
const slotProps = useMemo2(
|
|
494
526
|
() => ({
|
|
495
527
|
...props.slotProps,
|
|
496
528
|
listbox: {
|
|
497
529
|
...props.slotProps?.listbox,
|
|
498
530
|
hasSecondaryText: options.some((opt) => opt.secondaryText)
|
|
499
|
-
}
|
|
531
|
+
},
|
|
532
|
+
input: inputSlotProps
|
|
500
533
|
}),
|
|
501
|
-
[options, props.slotProps]
|
|
534
|
+
[options, props.slotProps, inputSlotProps]
|
|
502
535
|
);
|
|
503
536
|
const handleChange = useCallback2(
|
|
504
537
|
(event, value2) => {
|
|
@@ -532,9 +565,9 @@ function Autocomplete(props) {
|
|
|
532
565
|
endDecorator,
|
|
533
566
|
getOptionLabel,
|
|
534
567
|
renderTags: (tags, getTagProps) => tags.map((tag, index) => {
|
|
535
|
-
const { onClick, ...rest } = getTagProps({ index });
|
|
568
|
+
const { onClick, key, ...rest } = getTagProps({ index });
|
|
536
569
|
return applySize(
|
|
537
|
-
/* @__PURE__ */ React5.createElement(Chip_default, { color: "primary", ...rest }, /* @__PURE__ */ React5.createElement(Stack_default, { direction: "row", alignItems: "center", gap: 2, py: 0.5 }, tag.value, applySize(
|
|
570
|
+
/* @__PURE__ */ React5.createElement(Chip_default, { key, color: "primary", ...rest }, /* @__PURE__ */ React5.createElement(Stack_default, { direction: "row", alignItems: "center", gap: 2, py: 0.5 }, tag.value, applySize(
|
|
538
571
|
/* @__PURE__ */ React5.createElement(AutocompleteTagDelete, { color: "primary", variant: "soft", onClick }, /* @__PURE__ */ React5.createElement(CloseIcon, null))
|
|
539
572
|
)))
|
|
540
573
|
);
|
|
@@ -544,26 +577,29 @@ function Autocomplete(props) {
|
|
|
544
577
|
},
|
|
545
578
|
slotProps,
|
|
546
579
|
filterOptions: autocompleteFilterOptions,
|
|
547
|
-
renderOption: (props2, option) =>
|
|
548
|
-
|
|
549
|
-
{
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
applySize(option.label)
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
580
|
+
renderOption: (props2, option) => {
|
|
581
|
+
const { key, ...optionProps } = props2;
|
|
582
|
+
return /* @__PURE__ */ React5.createElement(JoyAutocompleteOption, { key, ...optionProps }, option.startDecorator && /* @__PURE__ */ React5.createElement(
|
|
583
|
+
ListItemDecorator,
|
|
584
|
+
{
|
|
585
|
+
sx: (theme) => ({
|
|
586
|
+
marginInlineEnd: `var(--Input-gap, ${theme.spacing(1)})`
|
|
587
|
+
})
|
|
588
|
+
},
|
|
589
|
+
applySize(option.startDecorator)
|
|
590
|
+
), option.secondaryText ? /* @__PURE__ */ React5.createElement(ListItemContent, { sx: { gap: 0.5 } }, /* @__PURE__ */ React5.createElement(Typography2, { level: "inherit" }, applySize(option.label)), /* @__PURE__ */ React5.createElement(Typography2, { level: secondaryTextLevelMap[size ?? "md"], textColor: "text.tertiary" }, option.secondaryText)) : (
|
|
591
|
+
// TODO: haulla에서 사용할 때, label을 ReactNode로 넘기면 에러가 발생함....
|
|
592
|
+
applySize(option.label)
|
|
593
|
+
), option.endDecorator && /* @__PURE__ */ React5.createElement(
|
|
594
|
+
ListItemDecorator,
|
|
595
|
+
{
|
|
596
|
+
sx: (theme) => ({
|
|
597
|
+
marginInlineStart: `var(--Input-gap, ${theme.spacing(1)})`
|
|
598
|
+
})
|
|
599
|
+
},
|
|
600
|
+
applySize(option.endDecorator)
|
|
601
|
+
));
|
|
602
|
+
},
|
|
567
603
|
renderGroup: (params) => params
|
|
568
604
|
}
|
|
569
605
|
);
|
|
@@ -583,13 +619,14 @@ function Autocomplete(props) {
|
|
|
583
619
|
helperText && /* @__PURE__ */ React5.createElement(FormHelperText_default, null, helperText)
|
|
584
620
|
);
|
|
585
621
|
}
|
|
622
|
+
var Autocomplete = React5.forwardRef(AutocompleteInner);
|
|
586
623
|
Autocomplete.displayName = "Autocomplete";
|
|
587
624
|
|
|
588
625
|
// src/components/Autocomplete/index.ts
|
|
589
626
|
var Autocomplete_default = Autocomplete;
|
|
590
627
|
|
|
591
628
|
// src/components/Avatar/Avatar.tsx
|
|
592
|
-
import React6, { forwardRef as forwardRef2, useMemo as
|
|
629
|
+
import React6, { forwardRef as forwardRef2, useMemo as useMemo3 } from "react";
|
|
593
630
|
import { Avatar as JoyAvatar, AvatarGroup, styled as styled4, useThemeProps as useThemeProps2 } from "@mui/joy";
|
|
594
631
|
var StyledAvatar = styled4(JoyAvatar, {
|
|
595
632
|
name: "Avatar",
|
|
@@ -617,7 +654,7 @@ var Avatar = forwardRef2(function Avatar2(inProps, ref) {
|
|
|
617
654
|
name: "Avatar"
|
|
618
655
|
});
|
|
619
656
|
const { children, getInitial = defaultGetInitial, ...inheritProps } = props;
|
|
620
|
-
const calcChildren =
|
|
657
|
+
const calcChildren = useMemo3(() => {
|
|
621
658
|
if (typeof children === "string") {
|
|
622
659
|
return getInitial?.(children) ?? "";
|
|
623
660
|
}
|
|
@@ -659,7 +696,7 @@ var MenuItem = JoyMenuItem;
|
|
|
659
696
|
var Menu_default = Menu;
|
|
660
697
|
|
|
661
698
|
// src/components/Dropdown/Dropdown.tsx
|
|
662
|
-
import React8, { createContext, useCallback as useCallback3, useMemo as
|
|
699
|
+
import React8, { createContext, useCallback as useCallback3, useMemo as useMemo4, useState as useState2 } from "react";
|
|
663
700
|
import { Dropdown as JoyDropdown } from "@mui/joy";
|
|
664
701
|
import { MenuButton } from "@mui/joy";
|
|
665
702
|
import { useMenuButton } from "@mui/base/useMenuButton";
|
|
@@ -667,7 +704,7 @@ var DropdownNestedRegistryContext = createContext(null);
|
|
|
667
704
|
function Dropdown({ open: openProp, defaultOpen = false, onOpenChange, ...rest }) {
|
|
668
705
|
const [nestedCount, setNestedCount] = useState2(0);
|
|
669
706
|
const [open, setOpen] = useControlledState(openProp, defaultOpen);
|
|
670
|
-
const registry =
|
|
707
|
+
const registry = useMemo4(
|
|
671
708
|
() => ({
|
|
672
709
|
register: () => setNestedCount((c) => c + 1),
|
|
673
710
|
unregister: () => setNestedCount((c) => Math.max(0, c - 1))
|
|
@@ -737,7 +774,7 @@ Button.displayName = "Button";
|
|
|
737
774
|
var Button_default = Button;
|
|
738
775
|
|
|
739
776
|
// src/components/Calendar/Calendar.tsx
|
|
740
|
-
import React13, { Fragment, forwardRef as forwardRef4, useCallback as useCallback6, useEffect as useEffect3, useMemo as
|
|
777
|
+
import React13, { Fragment, forwardRef as forwardRef4, useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo6, useRef as useRef3, useState as useState5 } from "react";
|
|
741
778
|
import { styled as styled5 } from "@mui/joy";
|
|
742
779
|
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
743
780
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
|
@@ -831,7 +868,7 @@ var isSameMonth = (date1, date2) => {
|
|
|
831
868
|
};
|
|
832
869
|
|
|
833
870
|
// src/components/Calendar/hooks/use-calendar-props.ts
|
|
834
|
-
import { useCallback as useCallback4, useMemo as
|
|
871
|
+
import { useCallback as useCallback4, useMemo as useMemo5, useState as useState3 } from "react";
|
|
835
872
|
import { useThemeProps as useThemeProps3 } from "@mui/joy";
|
|
836
873
|
var resolveView = (view, views) => {
|
|
837
874
|
return views.includes(view) ? view : views[0];
|
|
@@ -851,12 +888,12 @@ var useCalendarProps = (inProps) => {
|
|
|
851
888
|
});
|
|
852
889
|
const [[page, direction], setPage] = useState3([0, 0]);
|
|
853
890
|
const resolvedView = inProps.view ?? uncontrolledView;
|
|
854
|
-
const resolvedMinDate =
|
|
891
|
+
const resolvedMinDate = useMemo5(() => {
|
|
855
892
|
const minDate = inProps.minDate || /* @__PURE__ */ new Date(0);
|
|
856
893
|
minDate.setHours(0, 0, 0, 0);
|
|
857
894
|
return minDate;
|
|
858
895
|
}, [inProps.minDate]);
|
|
859
|
-
const resolvedMaxDate =
|
|
896
|
+
const resolvedMaxDate = useMemo5(() => {
|
|
860
897
|
const maxDate = inProps.maxDate || /* @__PURE__ */ new Date(864e13);
|
|
861
898
|
maxDate.setHours(0, 0, 0, 0);
|
|
862
899
|
return maxDate;
|
|
@@ -915,7 +952,7 @@ var useCalendarProps = (inProps) => {
|
|
|
915
952
|
},
|
|
916
953
|
name: "Calendar"
|
|
917
954
|
});
|
|
918
|
-
const ownerState =
|
|
955
|
+
const ownerState = useMemo5(() => ({ ...props, viewMonth, direction }), [props, viewMonth, direction]);
|
|
919
956
|
return [props, ownerState];
|
|
920
957
|
};
|
|
921
958
|
|
|
@@ -1347,8 +1384,8 @@ var swipePower = (offset, velocity) => {
|
|
|
1347
1384
|
var PickerDays = (props) => {
|
|
1348
1385
|
const { ownerState } = props;
|
|
1349
1386
|
const { getPickerDayProps, getDayCellProps } = useCalendar(ownerState);
|
|
1350
|
-
const calendarDates =
|
|
1351
|
-
const weekdayNames =
|
|
1387
|
+
const calendarDates = useMemo6(() => getCalendarDates(ownerState.viewMonth), [ownerState.viewMonth]);
|
|
1388
|
+
const weekdayNames = useMemo6(() => getWeekdayNames(ownerState.locale || "default"), [ownerState.locale]);
|
|
1352
1389
|
return /* @__PURE__ */ React13.createElement(CalendarViewContainer, { calendarType: "datePicker" }, /* @__PURE__ */ React13.createElement(AnimatePresence, { initial: false, custom: ownerState.direction }, /* @__PURE__ */ React13.createElement(
|
|
1353
1390
|
CalendarViewTable,
|
|
1354
1391
|
{
|
|
@@ -1432,8 +1469,8 @@ var PickerMonths = (props) => {
|
|
|
1432
1469
|
};
|
|
1433
1470
|
var PlainPickerDays = ({ ownerState }) => {
|
|
1434
1471
|
const { getPickerDayProps, getDayCellProps } = useCalendar(ownerState);
|
|
1435
|
-
const calendarDates =
|
|
1436
|
-
const weekdayNames =
|
|
1472
|
+
const calendarDates = useMemo6(() => getCalendarDates(ownerState.viewMonth), [ownerState.viewMonth]);
|
|
1473
|
+
const weekdayNames = useMemo6(() => getWeekdayNames(ownerState.locale || "default"), [ownerState.locale]);
|
|
1437
1474
|
return /* @__PURE__ */ React13.createElement(StaticCalendarViewTable, null, /* @__PURE__ */ React13.createElement(CalendarWeekHeaderContainer, null, /* @__PURE__ */ React13.createElement("tr", null, weekdayNames.map((name, i) => /* @__PURE__ */ React13.createElement(Fragment, { key: `${ownerState.viewMonth}_${name}_${i}` }, /* @__PURE__ */ React13.createElement("th", null, /* @__PURE__ */ React13.createElement(Typography_default, { level: "body-xs", textAlign: "center" }, name)), i < 6 && /* @__PURE__ */ React13.createElement("th", { style: { width: 4 }, "aria-hidden": "true", "aria-description": "cell-gap" }))))), /* @__PURE__ */ React13.createElement(CalendarDayPickerContainer, null, calendarDates.map((weekDates, rowIndex) => /* @__PURE__ */ React13.createElement(Fragment, { key: `${ownerState.viewMonth}_${rowIndex}` }, /* @__PURE__ */ React13.createElement("tr", null, weekDates.map(
|
|
1438
1475
|
(date, i) => date ? /* @__PURE__ */ React13.createElement(Fragment, { key: `${ownerState.viewMonth}_${date}_${i}` }, /* @__PURE__ */ React13.createElement(CalendarDayCell, { ...getDayCellProps(date) }, /* @__PURE__ */ React13.createElement(CalendarDay, { size: "sm", variant: "plain", color: "neutral", ...getPickerDayProps(date) }, date)), i < 6 && /* @__PURE__ */ React13.createElement("td", { "aria-hidden": "true", "aria-description": "cell-gap" })) : /* @__PURE__ */ React13.createElement(Fragment, { key: `${ownerState.viewMonth}_${i}` }, /* @__PURE__ */ React13.createElement("td", null), i < 6 && /* @__PURE__ */ React13.createElement("td", { "aria-hidden": "true", "aria-description": "cell-gap" }))
|
|
1439
1476
|
)), rowIndex < calendarDates.length - 1 && /* @__PURE__ */ React13.createElement("tr", { "aria-hidden": "true", "aria-description": "row-gap" }, /* @__PURE__ */ React13.createElement("td", { colSpan: 13, style: { height: 4 } }))))));
|
|
@@ -1812,7 +1849,7 @@ var Container = forwardRef5(function Container2(props, ref) {
|
|
|
1812
1849
|
Container.displayName = "Container";
|
|
1813
1850
|
|
|
1814
1851
|
// src/components/CurrencyInput/CurrencyInput.tsx
|
|
1815
|
-
import React17, { useCallback as useCallback8, useMemo as
|
|
1852
|
+
import React17, { useCallback as useCallback8, useMemo as useMemo7 } from "react";
|
|
1816
1853
|
import { NumericFormat } from "react-number-format";
|
|
1817
1854
|
|
|
1818
1855
|
// src/components/Input/Input.tsx
|
|
@@ -2146,19 +2183,19 @@ var CurrencyInput = React17.forwardRef(function CurrencyInput2(inProps, ref) {
|
|
|
2146
2183
|
props.defaultValue ?? null,
|
|
2147
2184
|
useCallback8((value2) => onChange?.({ target: { name, value: value2 } }), [onChange, name])
|
|
2148
2185
|
);
|
|
2149
|
-
const value =
|
|
2186
|
+
const value = useMemo7(() => {
|
|
2150
2187
|
if (_value && useMinorUnit) {
|
|
2151
2188
|
return _value / Math.pow(10, decimalScale);
|
|
2152
2189
|
}
|
|
2153
2190
|
return _value;
|
|
2154
2191
|
}, [_value, useMinorUnit, decimalScale]);
|
|
2155
|
-
const max =
|
|
2192
|
+
const max = useMemo7(() => {
|
|
2156
2193
|
if (props.max && useMinorUnit) {
|
|
2157
2194
|
return props.max / Math.pow(10, decimalScale);
|
|
2158
2195
|
}
|
|
2159
2196
|
return props.max;
|
|
2160
2197
|
}, [props.max, useMinorUnit, decimalScale]);
|
|
2161
|
-
const isOverLimit =
|
|
2198
|
+
const isOverLimit = useMemo7(() => max != null && value != null && value > max, [max, value]);
|
|
2162
2199
|
const handleChange = useCallback8(
|
|
2163
2200
|
(event) => {
|
|
2164
2201
|
if (event.target.value === "") {
|
|
@@ -2209,7 +2246,7 @@ var CurrencyInput_default = CurrencyInput;
|
|
|
2209
2246
|
// src/components/DataTable/DataTable.tsx
|
|
2210
2247
|
import React26, {
|
|
2211
2248
|
useCallback as useCallback13,
|
|
2212
|
-
useMemo as
|
|
2249
|
+
useMemo as useMemo12,
|
|
2213
2250
|
useRef as useRef7,
|
|
2214
2251
|
useId,
|
|
2215
2252
|
forwardRef as forwardRef7,
|
|
@@ -2443,6 +2480,9 @@ function computeAutoFitWidth(params) {
|
|
|
2443
2480
|
if (!isNaN(maxPx) && maxPx > 0) finalWidth = Math.min(finalWidth, maxPx);
|
|
2444
2481
|
return finalWidth;
|
|
2445
2482
|
}
|
|
2483
|
+
function getHeaderCellId(tableId, columnId) {
|
|
2484
|
+
return `${tableId}_header_${columnId}`.trim();
|
|
2485
|
+
}
|
|
2446
2486
|
|
|
2447
2487
|
// src/components/DataTable/styled.tsx
|
|
2448
2488
|
import React18 from "react";
|
|
@@ -2634,7 +2674,7 @@ import React23, {
|
|
|
2634
2674
|
useRef as useRef5,
|
|
2635
2675
|
useState as useState8,
|
|
2636
2676
|
useLayoutEffect,
|
|
2637
|
-
useMemo as
|
|
2677
|
+
useMemo as useMemo10,
|
|
2638
2678
|
useCallback as useCallback10,
|
|
2639
2679
|
useEffect as useEffect5,
|
|
2640
2680
|
memo,
|
|
@@ -3118,7 +3158,7 @@ import React20 from "react";
|
|
|
3118
3158
|
import { Textarea as JoyTextarea } from "@mui/joy";
|
|
3119
3159
|
import { motion as motion19 } from "framer-motion";
|
|
3120
3160
|
var MotionTextarea = motion19(JoyTextarea);
|
|
3121
|
-
var
|
|
3161
|
+
var TextareaBase = (props) => {
|
|
3122
3162
|
const {
|
|
3123
3163
|
label,
|
|
3124
3164
|
error,
|
|
@@ -3162,13 +3202,17 @@ var Textarea = (props) => {
|
|
|
3162
3202
|
helperText && /* @__PURE__ */ React20.createElement(FormHelperText_default, null, helperText)
|
|
3163
3203
|
);
|
|
3164
3204
|
};
|
|
3205
|
+
var Textarea = React20.forwardRef((props, ref) => {
|
|
3206
|
+
const textareaSlotProps = useSlotRef(props.slotProps?.textarea, ref);
|
|
3207
|
+
return /* @__PURE__ */ React20.createElement(TextareaBase, { ...props, slotProps: { ...props.slotProps, textarea: textareaSlotProps } });
|
|
3208
|
+
});
|
|
3165
3209
|
Textarea.displayName = "Textarea";
|
|
3166
3210
|
|
|
3167
3211
|
// src/components/Textarea/index.ts
|
|
3168
3212
|
var Textarea_default = Textarea;
|
|
3169
3213
|
|
|
3170
3214
|
// src/components/Select/Select.tsx
|
|
3171
|
-
import React21, { useMemo as
|
|
3215
|
+
import React21, { useMemo as useMemo9 } from "react";
|
|
3172
3216
|
import {
|
|
3173
3217
|
Select as JoySelect,
|
|
3174
3218
|
Option as JoyOption,
|
|
@@ -3184,7 +3228,7 @@ var secondaryTextLevelMap2 = {
|
|
|
3184
3228
|
lg: "body-md"
|
|
3185
3229
|
};
|
|
3186
3230
|
Option.displayName = "Option";
|
|
3187
|
-
function
|
|
3231
|
+
function SelectInner(props, ref) {
|
|
3188
3232
|
const {
|
|
3189
3233
|
label,
|
|
3190
3234
|
helperText,
|
|
@@ -3210,7 +3254,7 @@ function Select(props) {
|
|
|
3210
3254
|
formHelperText: formHelperTextProps,
|
|
3211
3255
|
...joySlotProps
|
|
3212
3256
|
} = slotProps ?? {};
|
|
3213
|
-
const options =
|
|
3257
|
+
const options = useMemo9(
|
|
3214
3258
|
() => props.options.map((option) => {
|
|
3215
3259
|
if (option.hasOwnProperty("value") && option.hasOwnProperty("label")) {
|
|
3216
3260
|
return option;
|
|
@@ -3235,13 +3279,14 @@ function Select(props) {
|
|
|
3235
3279
|
};
|
|
3236
3280
|
onChange?.(newEvent, newValue);
|
|
3237
3281
|
};
|
|
3238
|
-
const optionMap =
|
|
3282
|
+
const optionMap = useMemo9(() => {
|
|
3239
3283
|
const map = /* @__PURE__ */ new Map();
|
|
3240
3284
|
options.forEach((option) => {
|
|
3241
3285
|
map.set(option.value, option);
|
|
3242
3286
|
});
|
|
3243
3287
|
return map;
|
|
3244
3288
|
}, [options]);
|
|
3289
|
+
const buttonSlotProps = useSlotRef(joySlotProps.button, ref);
|
|
3245
3290
|
const select = /* @__PURE__ */ React21.createElement(
|
|
3246
3291
|
JoySelect,
|
|
3247
3292
|
{
|
|
@@ -3250,7 +3295,7 @@ function Select(props) {
|
|
|
3250
3295
|
disabled,
|
|
3251
3296
|
size,
|
|
3252
3297
|
color: error ? "danger" : color,
|
|
3253
|
-
slotProps: joySlotProps,
|
|
3298
|
+
slotProps: { ...joySlotProps, button: buttonSlotProps },
|
|
3254
3299
|
onChange: handleChange,
|
|
3255
3300
|
renderValue: (selected) => {
|
|
3256
3301
|
if (!selected) return null;
|
|
@@ -3280,6 +3325,7 @@ function Select(props) {
|
|
|
3280
3325
|
helperText && /* @__PURE__ */ React21.createElement(FormHelperText_default, { ...formHelperTextProps }, helperText)
|
|
3281
3326
|
);
|
|
3282
3327
|
}
|
|
3328
|
+
var Select = React21.forwardRef(SelectInner);
|
|
3283
3329
|
Select.displayName = "Select";
|
|
3284
3330
|
|
|
3285
3331
|
// src/components/Select/index.ts
|
|
@@ -3394,7 +3440,8 @@ var HeadCell = (props) => {
|
|
|
3394
3440
|
tableColRef,
|
|
3395
3441
|
headerClassName,
|
|
3396
3442
|
headerLineClamp,
|
|
3397
|
-
onAutoFit
|
|
3443
|
+
onAutoFit,
|
|
3444
|
+
columnId
|
|
3398
3445
|
} = props;
|
|
3399
3446
|
const theme = useTheme();
|
|
3400
3447
|
const ref = headerRef;
|
|
@@ -3405,23 +3452,20 @@ var HeadCell = (props) => {
|
|
|
3405
3452
|
}, [ref]);
|
|
3406
3453
|
const [isHovered, setIsHovered] = useState8(false);
|
|
3407
3454
|
const sortable = type === "actions" ? false : _sortable;
|
|
3408
|
-
const headId =
|
|
3409
|
-
() => `${tableId}_header_${headerName ?? field}`.trim(),
|
|
3410
|
-
[tableId, headerName, field]
|
|
3411
|
-
);
|
|
3455
|
+
const headId = useMemo10(() => getHeaderCellId(tableId, columnId ?? field), [tableId, columnId, field]);
|
|
3412
3456
|
const isResizingRef = useRef5(false);
|
|
3413
|
-
const resizer =
|
|
3457
|
+
const resizer = useMemo10(
|
|
3414
3458
|
() => resizable ?? true ? Resizer(
|
|
3415
3459
|
ref,
|
|
3416
3460
|
colRef,
|
|
3417
3461
|
(isResizing) => {
|
|
3418
3462
|
isResizingRef.current = isResizing;
|
|
3419
3463
|
},
|
|
3420
|
-
onAutoFit ? () => onAutoFit(field) : void 0
|
|
3464
|
+
onAutoFit ? () => onAutoFit(columnId ?? String(field)) : void 0
|
|
3421
3465
|
) : null,
|
|
3422
|
-
[resizable, ref, colRef, onAutoFit, field]
|
|
3466
|
+
[resizable, ref, colRef, onAutoFit, columnId, field]
|
|
3423
3467
|
);
|
|
3424
|
-
const style =
|
|
3468
|
+
const style = useMemo10(
|
|
3425
3469
|
() => ({
|
|
3426
3470
|
width,
|
|
3427
3471
|
minWidth: minWidth ?? "50px",
|
|
@@ -3439,7 +3483,7 @@ var HeadCell = (props) => {
|
|
|
3439
3483
|
);
|
|
3440
3484
|
const textAlign = getTextAlign(props);
|
|
3441
3485
|
const initialSort = sortOrder[0];
|
|
3442
|
-
const sortIcon =
|
|
3486
|
+
const sortIcon = useMemo10(() => {
|
|
3443
3487
|
const isSorted = !!sort;
|
|
3444
3488
|
const isVisible = sortable && (isSorted || isHovered);
|
|
3445
3489
|
return /* @__PURE__ */ React23.createElement(AnimatePresence2, { mode: "wait" }, isVisible && /* @__PURE__ */ React23.createElement(
|
|
@@ -3470,17 +3514,17 @@ var HeadCell = (props) => {
|
|
|
3470
3514
|
}
|
|
3471
3515
|
));
|
|
3472
3516
|
}, [headId, initialSort, sort, sortable, isHovered]);
|
|
3473
|
-
const infoSign =
|
|
3517
|
+
const infoSign = useMemo10(
|
|
3474
3518
|
() => description ? /* @__PURE__ */ React23.createElement(InfoSign_default, { message: description, placement: "bottom" }) : null,
|
|
3475
3519
|
[description]
|
|
3476
3520
|
);
|
|
3477
|
-
const params =
|
|
3521
|
+
const params = useMemo10(
|
|
3478
3522
|
() => ({
|
|
3479
3523
|
field
|
|
3480
3524
|
}),
|
|
3481
3525
|
[field]
|
|
3482
3526
|
);
|
|
3483
|
-
const computedHeaderClassName =
|
|
3527
|
+
const computedHeaderClassName = useMemo10(
|
|
3484
3528
|
() => (typeof headerClassName === "function" ? headerClassName(params) : headerClassName) || void 0,
|
|
3485
3529
|
[headerClassName, params]
|
|
3486
3530
|
);
|
|
@@ -3534,7 +3578,7 @@ var BodyCell = (props) => {
|
|
|
3534
3578
|
const theme = useTheme();
|
|
3535
3579
|
const [value, setValue] = useState8(row[field]);
|
|
3536
3580
|
const cellRef = useRef5(null);
|
|
3537
|
-
const params =
|
|
3581
|
+
const params = useMemo10(
|
|
3538
3582
|
() => ({
|
|
3539
3583
|
row,
|
|
3540
3584
|
value,
|
|
@@ -3543,20 +3587,20 @@ var BodyCell = (props) => {
|
|
|
3543
3587
|
}),
|
|
3544
3588
|
[row, rowId, value, field]
|
|
3545
3589
|
);
|
|
3546
|
-
const editMode =
|
|
3590
|
+
const editMode = useMemo10(
|
|
3547
3591
|
() => !!(props.editMode && (typeof isCellEditable === "function" ? isCellEditable(params) : isCellEditable ?? true)),
|
|
3548
3592
|
[props.editMode, isCellEditable, params]
|
|
3549
3593
|
);
|
|
3550
3594
|
const propsComponentProps = "componentProps" in props ? props.componentProps : null;
|
|
3551
3595
|
const hasComponentProps = "componentProps" in props;
|
|
3552
|
-
const componentProps =
|
|
3596
|
+
const componentProps = useMemo10(
|
|
3553
3597
|
() => ({
|
|
3554
3598
|
...hasComponentProps && (typeof propsComponentProps === "function" ? propsComponentProps(params) : propsComponentProps || {}),
|
|
3555
3599
|
size: "sm"
|
|
3556
3600
|
}),
|
|
3557
3601
|
[hasComponentProps, propsComponentProps, params]
|
|
3558
3602
|
);
|
|
3559
|
-
const editModeComponentProps =
|
|
3603
|
+
const editModeComponentProps = useMemo10(
|
|
3560
3604
|
() => ({
|
|
3561
3605
|
...componentProps,
|
|
3562
3606
|
onChange: (e) => {
|
|
@@ -3618,9 +3662,9 @@ var BodyCell = (props) => {
|
|
|
3618
3662
|
}),
|
|
3619
3663
|
[params, row, field, value, componentProps, type, onCellEditStop, onCellEditStart]
|
|
3620
3664
|
);
|
|
3621
|
-
const MemoizedRenderEditCell =
|
|
3622
|
-
const MemoizedRenderCell =
|
|
3623
|
-
const EditModeComponent =
|
|
3665
|
+
const MemoizedRenderEditCell = useMemo10(() => renderEditCell ? memo(renderEditCell) : null, [renderEditCell]);
|
|
3666
|
+
const MemoizedRenderCell = useMemo10(() => renderCell ? memo(renderCell) : null, [renderCell]);
|
|
3667
|
+
const EditModeComponent = useMemo10(() => {
|
|
3624
3668
|
if (MemoizedRenderEditCell) {
|
|
3625
3669
|
return createElement(MemoizedRenderEditCell, params);
|
|
3626
3670
|
}
|
|
@@ -3655,7 +3699,7 @@ var BodyCell = (props) => {
|
|
|
3655
3699
|
}[type || "text"];
|
|
3656
3700
|
}, [value, editModeComponentProps, type, MemoizedRenderEditCell, params]);
|
|
3657
3701
|
const linkComponentFromProps = props.component;
|
|
3658
|
-
const ReadModeComponent =
|
|
3702
|
+
const ReadModeComponent = useMemo10(() => {
|
|
3659
3703
|
if (MemoizedRenderCell) {
|
|
3660
3704
|
return createElement(MemoizedRenderCell, params);
|
|
3661
3705
|
}
|
|
@@ -3669,15 +3713,15 @@ var BodyCell = (props) => {
|
|
|
3669
3713
|
return typedComponent || innerText;
|
|
3670
3714
|
}, [value, MemoizedRenderCell, params, type, componentProps, linkComponentFromProps]);
|
|
3671
3715
|
const getActions = props.getActions;
|
|
3672
|
-
const CellComponent =
|
|
3716
|
+
const CellComponent = useMemo10(() => {
|
|
3673
3717
|
if (type === "actions") {
|
|
3674
3718
|
return /* @__PURE__ */ React23.createElement(Stack_default, { direction: "row", gap: 1, justifyContent: "center", alignItems: "center" }, getActions?.(params));
|
|
3675
3719
|
}
|
|
3676
3720
|
return editMode && EditModeComponent ? EditModeComponent : ReadModeComponent;
|
|
3677
3721
|
}, [type, getActions, params, editMode, EditModeComponent, ReadModeComponent]);
|
|
3678
|
-
const showTooltip =
|
|
3722
|
+
const showTooltip = useMemo10(() => noWrap && type === "longText", [noWrap, type]);
|
|
3679
3723
|
const isBoundary = props.isLastStartPinnedColumn || props.isLastEndPinnedColumn;
|
|
3680
|
-
const computedCellClassName =
|
|
3724
|
+
const computedCellClassName = useMemo10(
|
|
3681
3725
|
() => (typeof cellClassName === "function" ? cellClassName(params) : cellClassName) || "",
|
|
3682
3726
|
[cellClassName, params]
|
|
3683
3727
|
);
|
|
@@ -3689,7 +3733,7 @@ var BodyCell = (props) => {
|
|
|
3689
3733
|
{
|
|
3690
3734
|
ref: cellRef,
|
|
3691
3735
|
key: field,
|
|
3692
|
-
headers:
|
|
3736
|
+
headers: getHeaderCellId(tableId, props.columnId ?? field),
|
|
3693
3737
|
sx: {
|
|
3694
3738
|
textAlign: getTextAlign({ type }),
|
|
3695
3739
|
verticalAlign: editMode ? "top" : "middle",
|
|
@@ -3701,7 +3745,7 @@ var BodyCell = (props) => {
|
|
|
3701
3745
|
},
|
|
3702
3746
|
className: [isLastStartPinnedColumn && "is-last-left", isLastEndPinnedColumn && "is-last-right", computedCellClassName].filter(Boolean).join(" ") || ""
|
|
3703
3747
|
},
|
|
3704
|
-
|
|
3748
|
+
useMemo10(
|
|
3705
3749
|
() => showTooltip ? /* @__PURE__ */ React23.createElement(CellTextEllipsis, null, CellComponent) : CellComponent,
|
|
3706
3750
|
[CellComponent, showTooltip]
|
|
3707
3751
|
)
|
|
@@ -3754,36 +3798,46 @@ var VirtualizedTableRow = memo(StyledTableRow2, (prevProps, nextProps) => {
|
|
|
3754
3798
|
});
|
|
3755
3799
|
|
|
3756
3800
|
// src/components/DataTable/hooks.ts
|
|
3757
|
-
import { useState as useState9, useLayoutEffect as useLayoutEffect2, useRef as useRef6, useMemo as
|
|
3758
|
-
function useColumnWidths(
|
|
3801
|
+
import { useState as useState9, useLayoutEffect as useLayoutEffect2, useRef as useRef6, useMemo as useMemo11, useCallback as useCallback11, useEffect as useEffect6, createRef } from "react";
|
|
3802
|
+
function useColumnWidths(columnsById) {
|
|
3759
3803
|
const [widths, setWidths] = useState9({});
|
|
3760
3804
|
const roRef = useRef6();
|
|
3761
3805
|
useLayoutEffect2(() => {
|
|
3762
3806
|
if (roRef.current) roRef.current.disconnect();
|
|
3763
3807
|
roRef.current = new ResizeObserver((entries) => {
|
|
3764
|
-
let changed = false;
|
|
3765
3808
|
setWidths((prev) => {
|
|
3809
|
+
let changed = false;
|
|
3766
3810
|
const next = { ...prev };
|
|
3767
3811
|
entries.forEach((entry) => {
|
|
3768
|
-
const
|
|
3812
|
+
const columnId = entry.target.dataset.hdsColumnId;
|
|
3769
3813
|
const w = Math.round(entry.target.getBoundingClientRect().width);
|
|
3770
|
-
if (
|
|
3771
|
-
|
|
3814
|
+
if (w === 0) return;
|
|
3815
|
+
if (next[columnId] !== w) {
|
|
3816
|
+
next[columnId] = w;
|
|
3772
3817
|
changed = true;
|
|
3773
3818
|
}
|
|
3774
3819
|
});
|
|
3775
3820
|
return changed ? next : prev;
|
|
3776
3821
|
});
|
|
3777
3822
|
});
|
|
3778
|
-
|
|
3823
|
+
const measured = {};
|
|
3824
|
+
Object.entries(columnsById).forEach(([columnId, def]) => {
|
|
3779
3825
|
const el = def.headerRef.current;
|
|
3780
3826
|
if (el) {
|
|
3781
|
-
el.dataset.
|
|
3827
|
+
el.dataset.hdsColumnId = columnId;
|
|
3828
|
+
el.dataset.field = String(def.field);
|
|
3829
|
+
const w = Math.round(el.getBoundingClientRect().width);
|
|
3830
|
+
if (w > 0) measured[columnId] = w;
|
|
3782
3831
|
roRef.current.observe(el);
|
|
3783
3832
|
}
|
|
3784
3833
|
});
|
|
3834
|
+
setWidths((prev) => {
|
|
3835
|
+
const keys = Object.keys(measured);
|
|
3836
|
+
const same = keys.length === Object.keys(prev).length && keys.every((key) => prev[key] === measured[key]);
|
|
3837
|
+
return same ? prev : measured;
|
|
3838
|
+
});
|
|
3785
3839
|
return () => roRef.current?.disconnect();
|
|
3786
|
-
}, [
|
|
3840
|
+
}, [columnsById]);
|
|
3787
3841
|
return widths;
|
|
3788
3842
|
}
|
|
3789
3843
|
function useDataTableRenderer({
|
|
@@ -3832,16 +3886,16 @@ function useDataTableRenderer({
|
|
|
3832
3886
|
[onColumnVisibilityModelChange]
|
|
3833
3887
|
)
|
|
3834
3888
|
);
|
|
3835
|
-
const reorderedColumns =
|
|
3889
|
+
const reorderedColumns = useMemo11(() => {
|
|
3836
3890
|
if (!columnGroupingModel) return columnsProp;
|
|
3837
3891
|
return reorderColumnsByGroupingModel(columnsProp, columnGroupingModel);
|
|
3838
3892
|
}, [columnsProp, columnGroupingModel]);
|
|
3839
|
-
const visibleColumns =
|
|
3893
|
+
const visibleColumns = useMemo11(
|
|
3840
3894
|
() => reorderedColumns.filter((col) => visibilityModel[col.field] !== false),
|
|
3841
3895
|
[reorderedColumns, visibilityModel]
|
|
3842
3896
|
);
|
|
3843
|
-
const visibleFieldSet =
|
|
3844
|
-
const tableMinWidth =
|
|
3897
|
+
const visibleFieldSet = useMemo11(() => new Set(visibleColumns.map((c) => c.field)), [visibleColumns]);
|
|
3898
|
+
const tableMinWidth = useMemo11(() => {
|
|
3845
3899
|
const DEFAULT_MIN = 50;
|
|
3846
3900
|
let total = checkboxSelection ? 40 : 0;
|
|
3847
3901
|
for (const col of visibleColumns) {
|
|
@@ -3849,7 +3903,7 @@ function useDataTableRenderer({
|
|
|
3849
3903
|
}
|
|
3850
3904
|
return total;
|
|
3851
3905
|
}, [visibleColumns, checkboxSelection]);
|
|
3852
|
-
const allColumnsByField =
|
|
3906
|
+
const allColumnsByField = useMemo11(
|
|
3853
3907
|
() => reorderedColumns.reduce(
|
|
3854
3908
|
(acc, curr) => ({
|
|
3855
3909
|
...acc,
|
|
@@ -3859,19 +3913,40 @@ function useDataTableRenderer({
|
|
|
3859
3913
|
),
|
|
3860
3914
|
[reorderedColumns]
|
|
3861
3915
|
);
|
|
3862
|
-
const
|
|
3863
|
-
() =>
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3916
|
+
const columnIdByColumn = useMemo11(() => {
|
|
3917
|
+
const taken = new Set(reorderedColumns.map((column) => String(column.field)));
|
|
3918
|
+
const assigned = /* @__PURE__ */ new Set();
|
|
3919
|
+
const ids = /* @__PURE__ */ new Map();
|
|
3920
|
+
reorderedColumns.forEach((column) => {
|
|
3921
|
+
const field = String(column.field);
|
|
3922
|
+
if (!assigned.has(field)) {
|
|
3923
|
+
assigned.add(field);
|
|
3924
|
+
ids.set(column, field);
|
|
3925
|
+
return;
|
|
3926
|
+
}
|
|
3927
|
+
let n = 2;
|
|
3928
|
+
while (taken.has(`${field}__${n}`)) n += 1;
|
|
3929
|
+
taken.add(`${field}__${n}`);
|
|
3930
|
+
ids.set(column, `${field}__${n}`);
|
|
3931
|
+
});
|
|
3932
|
+
return ids;
|
|
3933
|
+
}, [reorderedColumns]);
|
|
3934
|
+
const columnIds = useMemo11(
|
|
3935
|
+
() => visibleColumns.map((column) => columnIdByColumn.get(column) ?? String(column.field)),
|
|
3936
|
+
[visibleColumns, columnIdByColumn]
|
|
3937
|
+
);
|
|
3938
|
+
const visibleColumnsById = useMemo11(
|
|
3939
|
+
() => Object.fromEntries(
|
|
3940
|
+
visibleColumns.map((column, index) => [
|
|
3941
|
+
columnIds[index],
|
|
3942
|
+
{
|
|
3943
|
+
...column,
|
|
3868
3944
|
headerRef: createRef(),
|
|
3869
3945
|
tableColRef: createRef()
|
|
3870
3946
|
}
|
|
3871
|
-
|
|
3872
|
-
{}
|
|
3947
|
+
])
|
|
3873
3948
|
),
|
|
3874
|
-
[visibleColumns]
|
|
3949
|
+
[visibleColumns, columnIds]
|
|
3875
3950
|
);
|
|
3876
3951
|
const sortComparator = useCallback11(
|
|
3877
3952
|
(rowA, rowB) => {
|
|
@@ -3902,11 +3977,11 @@ function useDataTableRenderer({
|
|
|
3902
3977
|
},
|
|
3903
3978
|
[sortModel, allColumnsByField]
|
|
3904
3979
|
);
|
|
3905
|
-
const rows =
|
|
3980
|
+
const rows = useMemo11(
|
|
3906
3981
|
() => sortModel.length ? [..._rows].sort(sortComparator) : _rows,
|
|
3907
3982
|
[_rows, sortModel, sortComparator]
|
|
3908
3983
|
);
|
|
3909
|
-
const sortOrder =
|
|
3984
|
+
const sortOrder = useMemo11(
|
|
3910
3985
|
() => Array.from(new Set(_sortOrder || ["asc", "desc", null])),
|
|
3911
3986
|
[_sortOrder]
|
|
3912
3987
|
);
|
|
@@ -3916,12 +3991,12 @@ function useDataTableRenderer({
|
|
|
3916
3991
|
(row, index) => _getId?.(row) ?? row.id ?? `${(index || 0) + (page - 1) * pageSize}`,
|
|
3917
3992
|
[_getId, page, pageSize]
|
|
3918
3993
|
);
|
|
3919
|
-
const selectedModelSet =
|
|
3920
|
-
const dataInPage =
|
|
3994
|
+
const selectedModelSet = useMemo11(() => new Set(selectionModel || []), [selectionModel]);
|
|
3995
|
+
const dataInPage = useMemo11(
|
|
3921
3996
|
() => !pagination || paginationMode === "server" ? rows : rows.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize),
|
|
3922
3997
|
[rows, page, pageSize, paginationMode, pagination]
|
|
3923
3998
|
);
|
|
3924
|
-
const selectableDataInPage =
|
|
3999
|
+
const selectableDataInPage = useMemo11(
|
|
3925
4000
|
() => dataInPage.filter((row, i) => {
|
|
3926
4001
|
if (!isRowSelectable) return true;
|
|
3927
4002
|
return isRowSelectable({ row, id: getId(row, i) });
|
|
@@ -3951,51 +4026,60 @@ function useDataTableRenderer({
|
|
|
3951
4026
|
},
|
|
3952
4027
|
[dataInPage, getId, isRowSelectable, selectionModel, onSelectionModelChange]
|
|
3953
4028
|
);
|
|
3954
|
-
const isAllSelected =
|
|
4029
|
+
const isAllSelected = useMemo11(
|
|
3955
4030
|
() => selectableDataInPage.length > 0 && selectableDataInPage.every((row, i) => selectedModelSet.has(getId(row, i))),
|
|
3956
4031
|
[selectableDataInPage, selectedModelSet, getId]
|
|
3957
4032
|
);
|
|
3958
4033
|
const rowCount = totalRowsProp || rows.length;
|
|
3959
|
-
const selectableRowCount =
|
|
4034
|
+
const selectableRowCount = useMemo11(() => {
|
|
3960
4035
|
if (!isRowSelectable) return rowCount;
|
|
3961
4036
|
return rows.filter((row, i) => isRowSelectable({ row, id: getId(row, i) })).length;
|
|
3962
4037
|
}, [rows, isRowSelectable, getId, rowCount]);
|
|
3963
|
-
const isTotalSelected =
|
|
4038
|
+
const isTotalSelected = useMemo11(
|
|
3964
4039
|
() => _isTotalSelected ?? (selectableRowCount > 0 && (selectionModel?.length || 0) === selectableRowCount),
|
|
3965
4040
|
[_isTotalSelected, selectionModel, selectableRowCount]
|
|
3966
4041
|
);
|
|
3967
|
-
const columnWidths = useColumnWidths(
|
|
4042
|
+
const columnWidths = useColumnWidths(visibleColumnsById);
|
|
4043
|
+
const measuredWidthByField = useMemo11(
|
|
4044
|
+
() => Object.fromEntries(
|
|
4045
|
+
Object.entries(visibleColumnsById).map(([columnId, column]) => [column.field, columnWidths[columnId]])
|
|
4046
|
+
),
|
|
4047
|
+
[visibleColumnsById, columnWidths]
|
|
4048
|
+
);
|
|
3968
4049
|
const getWidth = useCallback11(
|
|
3969
|
-
|
|
3970
|
-
allColumnsByField[f]?.
|
|
3971
|
-
[
|
|
4050
|
+
// 반환값은 pinned offset으로 더해지므로 반드시 숫자여야 한다. width/minWidth는 '500px' 같은 문자열.
|
|
4051
|
+
(f) => measuredWidthByField[f] ?? parsePxValue(allColumnsByField[f]?.width) ?? // Column prop 으로 지정된 width
|
|
4052
|
+
parsePxValue(allColumnsByField[f]?.minWidth) ?? 0,
|
|
4053
|
+
[measuredWidthByField, allColumnsByField]
|
|
3972
4054
|
);
|
|
3973
|
-
const processedColumnGroups =
|
|
4055
|
+
const processedColumnGroups = useMemo11(() => {
|
|
3974
4056
|
if (!columnGroupingModel) return null;
|
|
3975
4057
|
return calculateColumnGroups(columnGroupingModel, visibleColumns, visibleFieldSet);
|
|
3976
4058
|
}, [columnGroupingModel, visibleColumns, visibleFieldSet]);
|
|
3977
|
-
const effectivePinnedLeft =
|
|
4059
|
+
const effectivePinnedLeft = useMemo11(
|
|
3978
4060
|
() => pinnedColumns?.left?.filter((f) => visibleFieldSet.has(f)),
|
|
3979
4061
|
[pinnedColumns?.left, visibleFieldSet]
|
|
3980
4062
|
);
|
|
3981
|
-
const effectivePinnedRight =
|
|
4063
|
+
const effectivePinnedRight = useMemo11(
|
|
3982
4064
|
() => pinnedColumns?.right?.filter((f) => visibleFieldSet.has(f)),
|
|
3983
4065
|
[pinnedColumns?.right, visibleFieldSet]
|
|
3984
4066
|
);
|
|
3985
4067
|
const inferredFieldsKey = JSON.stringify(Object.keys(rows[0] || {}));
|
|
3986
|
-
const inferredFields =
|
|
3987
|
-
const columns =
|
|
4068
|
+
const inferredFields = useMemo11(() => JSON.parse(inferredFieldsKey), [inferredFieldsKey]);
|
|
4069
|
+
const columns = useMemo11(() => {
|
|
3988
4070
|
const baseColumns = visibleColumns.length > 0 ? visibleColumns : reorderedColumns.length > 0 ? [] : inferredFields.map((key) => ({
|
|
3989
4071
|
field: key
|
|
3990
4072
|
}));
|
|
3991
|
-
return baseColumns.map((column) => {
|
|
4073
|
+
return baseColumns.map((column, index) => {
|
|
4074
|
+
const columnId = columnIds[index] ?? String(column.field);
|
|
3992
4075
|
const isLeftPinned = effectivePinnedLeft?.includes(column.field);
|
|
3993
4076
|
const isRightPinned = effectivePinnedRight?.includes(column.field);
|
|
3994
4077
|
const isPinned = isLeftPinned || isRightPinned;
|
|
3995
4078
|
return {
|
|
3996
4079
|
...column,
|
|
3997
|
-
|
|
3998
|
-
|
|
4080
|
+
columnId,
|
|
4081
|
+
headerRef: visibleColumnsById[columnId]?.headerRef,
|
|
4082
|
+
tableColRef: visibleColumnsById[columnId]?.tableColRef,
|
|
3999
4083
|
isCellEditable: editMode && (typeof column.isCellEditable === "function" ? column.isCellEditable : column.isCellEditable ?? true),
|
|
4000
4084
|
sort: sortModel.find((sort) => sort.field === column.field)?.sort,
|
|
4001
4085
|
sortOrder: allColumnsByField[column.field]?.sortOrder || sortOrder,
|
|
@@ -4012,7 +4096,8 @@ function useDataTableRenderer({
|
|
|
4012
4096
|
inferredFields,
|
|
4013
4097
|
effectivePinnedLeft,
|
|
4014
4098
|
effectivePinnedRight,
|
|
4015
|
-
|
|
4099
|
+
columnIds,
|
|
4100
|
+
visibleColumnsById,
|
|
4016
4101
|
allColumnsByField,
|
|
4017
4102
|
editMode,
|
|
4018
4103
|
sortModel,
|
|
@@ -4072,15 +4157,14 @@ function useDataTableRenderer({
|
|
|
4072
4157
|
}
|
|
4073
4158
|
}, [_rows]);
|
|
4074
4159
|
const handleAutoFit = useCallback11(
|
|
4075
|
-
(
|
|
4076
|
-
const colDef =
|
|
4160
|
+
(columnId) => {
|
|
4161
|
+
const colDef = visibleColumnsById[columnId];
|
|
4077
4162
|
if (!colDef?.headerRef.current) return;
|
|
4078
|
-
const
|
|
4079
|
-
const columnType = column && "type" in column ? column.type : void 0;
|
|
4163
|
+
const columnType = "type" in colDef ? colDef.type : void 0;
|
|
4080
4164
|
if (columnType === "actions") return;
|
|
4081
4165
|
const optimalWidth = computeAutoFitWidth({
|
|
4082
4166
|
headerEl: colDef.headerRef.current,
|
|
4083
|
-
field,
|
|
4167
|
+
field: colDef.field,
|
|
4084
4168
|
dataInPage
|
|
4085
4169
|
});
|
|
4086
4170
|
if (optimalWidth == null) return;
|
|
@@ -4088,7 +4172,7 @@ function useDataTableRenderer({
|
|
|
4088
4172
|
colDef.headerRef.current.style.width = widthPx;
|
|
4089
4173
|
if (colDef.tableColRef.current) colDef.tableColRef.current.style.width = widthPx;
|
|
4090
4174
|
},
|
|
4091
|
-
[
|
|
4175
|
+
[visibleColumnsById, dataInPage]
|
|
4092
4176
|
);
|
|
4093
4177
|
return {
|
|
4094
4178
|
rowCount,
|
|
@@ -4563,9 +4647,9 @@ function Component(props, apiRef) {
|
|
|
4563
4647
|
measureElement: (element) => element.clientHeight,
|
|
4564
4648
|
overscan: 10
|
|
4565
4649
|
});
|
|
4566
|
-
const paginationModel =
|
|
4650
|
+
const paginationModel = useMemo12(() => ({ page, pageSize }), [page, pageSize]);
|
|
4567
4651
|
const columnsKey = getObjectVersion(columns);
|
|
4568
|
-
const headerCheckboxElement =
|
|
4652
|
+
const headerCheckboxElement = useMemo12(
|
|
4569
4653
|
() => /* @__PURE__ */ React26.createElement(
|
|
4570
4654
|
RenderCheckbox,
|
|
4571
4655
|
{
|
|
@@ -4775,7 +4859,7 @@ function Component(props, apiRef) {
|
|
|
4775
4859
|
"col",
|
|
4776
4860
|
{
|
|
4777
4861
|
ref: c.tableColRef,
|
|
4778
|
-
key:
|
|
4862
|
+
key: c.columnId,
|
|
4779
4863
|
style: {
|
|
4780
4864
|
width: c.width,
|
|
4781
4865
|
minWidth: c.minWidth ?? "50px"
|
|
@@ -4961,7 +5045,7 @@ var DataTable = forwardRef7(Component);
|
|
|
4961
5045
|
DataTable.displayName = "DataTable";
|
|
4962
5046
|
|
|
4963
5047
|
// src/components/DateRangePicker/DateRangePicker.tsx
|
|
4964
|
-
import React27, { forwardRef as forwardRef8, useCallback as useCallback14, useEffect as useEffect8, useImperativeHandle as useImperativeHandle3, useMemo as
|
|
5048
|
+
import React27, { forwardRef as forwardRef8, useCallback as useCallback14, useEffect as useEffect8, useImperativeHandle as useImperativeHandle3, useMemo as useMemo13, useRef as useRef8, useState as useState10 } from "react";
|
|
4965
5049
|
import { IMaskInput as IMaskInput2, IMask as IMask2 } from "react-imask";
|
|
4966
5050
|
import CalendarTodayIcon2 from "@mui/icons-material/CalendarToday";
|
|
4967
5051
|
import { styled as styled14, useThemeProps as useThemeProps7 } from "@mui/joy";
|
|
@@ -5183,7 +5267,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
5183
5267
|
);
|
|
5184
5268
|
const [anchorEl, setAnchorEl] = useState10(null);
|
|
5185
5269
|
const open = Boolean(anchorEl);
|
|
5186
|
-
const calendarValue =
|
|
5270
|
+
const calendarValue = useMemo13(
|
|
5187
5271
|
() => value ? parseDates(value, format) : void 0,
|
|
5188
5272
|
[value, format]
|
|
5189
5273
|
);
|
|
@@ -5500,10 +5584,10 @@ var ModalClose = JoyModalClose;
|
|
|
5500
5584
|
var MotionModalOverflow = motion24(JoyModalOverflow);
|
|
5501
5585
|
var ModalOverflow = MotionModalOverflow;
|
|
5502
5586
|
ModalOverflow.displayName = "ModalOverflow";
|
|
5503
|
-
|
|
5587
|
+
var ModalFrame = React29.forwardRef((props, ref) => {
|
|
5504
5588
|
const { title, children, titleStartDecorator, onClose, ...innerProps } = props;
|
|
5505
|
-
return /* @__PURE__ */ React29.createElement(StyledModalDialog, { ...innerProps }, /* @__PURE__ */ React29.createElement(ModalClose, { onClick: onClose }), /* @__PURE__ */ React29.createElement(DialogTitle_default, null, titleStartDecorator, title), /* @__PURE__ */ React29.createElement(DialogContent_default, null, children));
|
|
5506
|
-
}
|
|
5589
|
+
return /* @__PURE__ */ React29.createElement(StyledModalDialog, { ref, ...innerProps }, /* @__PURE__ */ React29.createElement(ModalClose, { onClick: onClose }), /* @__PURE__ */ React29.createElement(DialogTitle_default, null, titleStartDecorator, title), /* @__PURE__ */ React29.createElement(DialogContent_default, null, children));
|
|
5590
|
+
});
|
|
5507
5591
|
ModalFrame.displayName = "ModalFrame";
|
|
5508
5592
|
|
|
5509
5593
|
// src/components/DialogFrame/DialogFrame.tsx
|
|
@@ -5548,7 +5632,7 @@ var InsetDrawer = styled20(JoyDrawer2)(({ theme }) => ({
|
|
|
5548
5632
|
}));
|
|
5549
5633
|
|
|
5550
5634
|
// src/components/FilterableCheckboxGroup/FilterableCheckboxGroup.tsx
|
|
5551
|
-
import React32, { useCallback as useCallback15, useEffect as useEffect9, useMemo as
|
|
5635
|
+
import React32, { useCallback as useCallback15, useEffect as useEffect9, useMemo as useMemo14, useRef as useRef9, useState as useState11 } from "react";
|
|
5552
5636
|
import SearchIcon from "@mui/icons-material/Search";
|
|
5553
5637
|
import { useThemeProps as useThemeProps8 } from "@mui/joy";
|
|
5554
5638
|
import { useVirtualizer as useVirtualizer3 } from "@tanstack/react-virtual";
|
|
@@ -5609,11 +5693,11 @@ function FilterableCheckboxGroup(inProps) {
|
|
|
5609
5693
|
const parentRef = useRef9(null);
|
|
5610
5694
|
const isInitialSortRef = useRef9(false);
|
|
5611
5695
|
const prevOptionsRef = useRef9([...options]);
|
|
5612
|
-
const filteredOptions =
|
|
5696
|
+
const filteredOptions = useMemo14(() => {
|
|
5613
5697
|
if (!searchTerm) return sortedOptions;
|
|
5614
5698
|
return sortedOptions.filter((option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()));
|
|
5615
5699
|
}, [sortedOptions, searchTerm]);
|
|
5616
|
-
const itemSize =
|
|
5700
|
+
const itemSize = useMemo14(() => {
|
|
5617
5701
|
switch (size) {
|
|
5618
5702
|
case "sm":
|
|
5619
5703
|
return 28;
|
|
@@ -5687,7 +5771,7 @@ function FilterableCheckboxGroup(inProps) {
|
|
|
5687
5771
|
},
|
|
5688
5772
|
[filteredOptions, internalValue, setInternalValue]
|
|
5689
5773
|
);
|
|
5690
|
-
const enabledFilteredOptions =
|
|
5774
|
+
const enabledFilteredOptions = useMemo14(() => filteredOptions.filter((option) => !option.disabled), [filteredOptions]);
|
|
5691
5775
|
const isAllSelected = enabledFilteredOptions.length > 0 && enabledFilteredOptions.every((option) => internalValue.includes(option.value));
|
|
5692
5776
|
const isIndeterminate = !isAllSelected && enabledFilteredOptions.some((option) => internalValue.includes(option.value));
|
|
5693
5777
|
return /* @__PURE__ */ React32.createElement("div", { style: { width: "100%" } }, /* @__PURE__ */ React32.createElement(
|
|
@@ -5783,7 +5867,10 @@ import {
|
|
|
5783
5867
|
MenuButton as JoyMenuButton2,
|
|
5784
5868
|
IconButton as JoyIconButton2
|
|
5785
5869
|
} from "@mui/joy";
|
|
5786
|
-
function
|
|
5870
|
+
var MenuButtonRootSlot = React33.forwardRef(function MenuButtonRootSlot2({ as, ...rest }, ref) {
|
|
5871
|
+
return /* @__PURE__ */ React33.createElement(JoyIconButton2, { ...rest, component: as ?? "button", ref });
|
|
5872
|
+
});
|
|
5873
|
+
function IconMenuButtonInner(props, ref) {
|
|
5787
5874
|
const {
|
|
5788
5875
|
size,
|
|
5789
5876
|
icon,
|
|
@@ -5794,6 +5881,8 @@ function IconMenuButton(props) {
|
|
|
5794
5881
|
variant = "plain",
|
|
5795
5882
|
placement = "bottom"
|
|
5796
5883
|
} = props;
|
|
5884
|
+
const { ref: buttonComponentRef, ...buttonComponentProps } = props.buttonComponentProps ?? {};
|
|
5885
|
+
const mergedButtonRef = useMergedRef(buttonComponentRef, ref);
|
|
5797
5886
|
if (!items.length) {
|
|
5798
5887
|
return /* @__PURE__ */ React33.createElement(
|
|
5799
5888
|
JoyIconButton2,
|
|
@@ -5804,7 +5893,8 @@ function IconMenuButton(props) {
|
|
|
5804
5893
|
color,
|
|
5805
5894
|
disabled,
|
|
5806
5895
|
loading,
|
|
5807
|
-
...
|
|
5896
|
+
...buttonComponentProps,
|
|
5897
|
+
ref: mergedButtonRef
|
|
5808
5898
|
},
|
|
5809
5899
|
icon
|
|
5810
5900
|
);
|
|
@@ -5812,7 +5902,7 @@ function IconMenuButton(props) {
|
|
|
5812
5902
|
return /* @__PURE__ */ React33.createElement(Dropdown_default, null, /* @__PURE__ */ React33.createElement(
|
|
5813
5903
|
JoyMenuButton2,
|
|
5814
5904
|
{
|
|
5815
|
-
slots: { root:
|
|
5905
|
+
slots: { root: MenuButtonRootSlot },
|
|
5816
5906
|
slotProps: {
|
|
5817
5907
|
root: {
|
|
5818
5908
|
component: props.buttonComponent ?? "button",
|
|
@@ -5821,13 +5911,16 @@ function IconMenuButton(props) {
|
|
|
5821
5911
|
color,
|
|
5822
5912
|
disabled,
|
|
5823
5913
|
loading,
|
|
5824
|
-
...
|
|
5914
|
+
...buttonComponentProps,
|
|
5915
|
+
// Joy의 useSlot이 내부 ref와 이 ref를 합쳐준다. 위 no-items 분기와 같은 경로로 ref를 넘긴다.
|
|
5916
|
+
ref: mergedButtonRef
|
|
5825
5917
|
}
|
|
5826
5918
|
}
|
|
5827
5919
|
},
|
|
5828
5920
|
icon
|
|
5829
5921
|
), /* @__PURE__ */ React33.createElement(Menu, { placement, size }, items.map((i) => /* @__PURE__ */ React33.createElement(MenuItem, { key: i.text, component: i.component, ...i.componentProps ?? {} }, i.text))));
|
|
5830
5922
|
}
|
|
5923
|
+
var IconMenuButton = React33.forwardRef(IconMenuButtonInner);
|
|
5831
5924
|
IconMenuButton.displayName = "IconMenuButton";
|
|
5832
5925
|
|
|
5833
5926
|
// src/components/Markdown/Markdown.tsx
|
|
@@ -6277,7 +6370,7 @@ var MonthPicker = forwardRef9((inProps, ref) => {
|
|
|
6277
6370
|
});
|
|
6278
6371
|
|
|
6279
6372
|
// src/components/MonthRangePicker/MonthRangePicker.tsx
|
|
6280
|
-
import React37, { forwardRef as forwardRef10, useCallback as useCallback17, useEffect as useEffect12, useImperativeHandle as useImperativeHandle5, useMemo as
|
|
6373
|
+
import React37, { forwardRef as forwardRef10, useCallback as useCallback17, useEffect as useEffect12, useImperativeHandle as useImperativeHandle5, useMemo as useMemo15, useRef as useRef11, useState as useState14 } from "react";
|
|
6281
6374
|
import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
|
|
6282
6375
|
import CalendarTodayIcon4 from "@mui/icons-material/CalendarToday";
|
|
6283
6376
|
import { styled as styled22, useThemeProps as useThemeProps10 } from "@mui/joy";
|
|
@@ -6408,7 +6501,7 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6408
6501
|
);
|
|
6409
6502
|
const [anchorEl, setAnchorEl] = useState14(null);
|
|
6410
6503
|
const open = Boolean(anchorEl);
|
|
6411
|
-
const calendarValue =
|
|
6504
|
+
const calendarValue = useMemo15(() => value ? parseDates2(value) : void 0, [value]);
|
|
6412
6505
|
useEffect12(() => {
|
|
6413
6506
|
if (value) {
|
|
6414
6507
|
try {
|
|
@@ -6691,7 +6784,7 @@ function Navigator(props) {
|
|
|
6691
6784
|
Navigator.displayName = "Navigator";
|
|
6692
6785
|
|
|
6693
6786
|
// src/components/PercentageInput/PercentageInput.tsx
|
|
6694
|
-
import React41, { useCallback as useCallback18, useMemo as
|
|
6787
|
+
import React41, { useCallback as useCallback18, useMemo as useMemo16 } from "react";
|
|
6695
6788
|
import { NumericFormat as NumericFormat2 } from "react-number-format";
|
|
6696
6789
|
import { styled as styled25, useThemeProps as useThemeProps11 } from "@mui/joy";
|
|
6697
6790
|
var padDecimal = (value, decimalScale) => {
|
|
@@ -6750,13 +6843,13 @@ var PercentageInput = React41.forwardRef(
|
|
|
6750
6843
|
props.defaultValue ?? null,
|
|
6751
6844
|
useCallback18((value2) => onChange?.({ target: { name, value: value2 } }), [onChange, name])
|
|
6752
6845
|
);
|
|
6753
|
-
const value =
|
|
6846
|
+
const value = useMemo16(() => {
|
|
6754
6847
|
if (_value && useMinorUnit) {
|
|
6755
6848
|
return _value / Math.pow(10, maxDecimalScale);
|
|
6756
6849
|
}
|
|
6757
6850
|
return _value;
|
|
6758
6851
|
}, [_value, useMinorUnit, maxDecimalScale]);
|
|
6759
|
-
const internalError =
|
|
6852
|
+
const internalError = useMemo16(
|
|
6760
6853
|
() => value != null && (max != null && value > max || min != null && value < min),
|
|
6761
6854
|
[max, min, value]
|
|
6762
6855
|
);
|
|
@@ -7522,7 +7615,7 @@ function ThemeProvider(props) {
|
|
|
7522
7615
|
ThemeProvider.displayName = "ThemeProvider";
|
|
7523
7616
|
|
|
7524
7617
|
// src/components/Uploader/Uploader.tsx
|
|
7525
|
-
import React49, { useCallback as useCallback19, useEffect as useEffect13, useMemo as
|
|
7618
|
+
import React49, { useCallback as useCallback19, useEffect as useEffect13, useMemo as useMemo17, useRef as useRef12, useState as useState16 } from "react";
|
|
7526
7619
|
import { styled as styled31, Input as Input2 } from "@mui/joy";
|
|
7527
7620
|
import MuiFileUploadIcon from "@mui/icons-material/CloudUploadRounded";
|
|
7528
7621
|
import MuiUploadFileIcon from "@mui/icons-material/UploadFileRounded";
|
|
@@ -7662,8 +7755,8 @@ var Uploader = React49.memo((props) => {
|
|
|
7662
7755
|
const [files, setFiles] = useState16([]);
|
|
7663
7756
|
const [uploaded, setUploaded] = useState16(props.uploaded || []);
|
|
7664
7757
|
const [previewState, setPreviewState] = useState16("idle");
|
|
7665
|
-
const accepts =
|
|
7666
|
-
const parsedAccepts =
|
|
7758
|
+
const accepts = useMemo17(() => accept.split(",").map((accept2) => accept2.trim()), [accept]);
|
|
7759
|
+
const parsedAccepts = useMemo17(
|
|
7667
7760
|
() => accepts.flatMap((type) => {
|
|
7668
7761
|
if (["image/*", "video/*", "audio/*"].includes(type)) {
|
|
7669
7762
|
return ALL_EXTENSIONS_BY_TYPE[type];
|
|
@@ -7672,7 +7765,7 @@ var Uploader = React49.memo((props) => {
|
|
|
7672
7765
|
}),
|
|
7673
7766
|
[accepts]
|
|
7674
7767
|
);
|
|
7675
|
-
const helperText =
|
|
7768
|
+
const helperText = useMemo17(() => {
|
|
7676
7769
|
if (helperTextProp) {
|
|
7677
7770
|
return helperTextProp;
|
|
7678
7771
|
}
|
|
@@ -7702,8 +7795,8 @@ var Uploader = React49.memo((props) => {
|
|
|
7702
7795
|
}
|
|
7703
7796
|
return helperTexts.join(", ");
|
|
7704
7797
|
}, [accepts, maxFileTotalSize, maxCount, helperTextProp]);
|
|
7705
|
-
const error =
|
|
7706
|
-
const showDropZone =
|
|
7798
|
+
const error = useMemo17(() => !!errorText || errorProp, [errorProp, errorText]);
|
|
7799
|
+
const showDropZone = useMemo17(
|
|
7707
7800
|
() => !maxCount || maxCount && [...uploaded, ...files].length !== maxCount,
|
|
7708
7801
|
[files, maxCount, uploaded]
|
|
7709
7802
|
);
|