@ceed/ads 1.30.0 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Overview.md +5 -5
- package/dist/components/Calendar/utils/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +4 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +4 -0
- package/dist/components/MonthRangePicker/MonthRangePicker.d.ts +8 -0
- package/dist/components/data-display/Avatar.md +85 -74
- package/dist/components/data-display/Badge.md +23 -5
- package/dist/components/data-display/Chip.md +49 -35
- package/dist/components/data-display/DataTable.md +93 -0
- package/dist/components/data-display/InfoSign.md +15 -5
- package/dist/components/data-display/Markdown.md +22 -26
- package/dist/components/data-display/Table.md +63 -53
- package/dist/components/data-display/Tooltip.md +70 -58
- package/dist/components/data-display/Typography.md +28 -11
- package/dist/components/feedback/Alert.md +86 -74
- package/dist/components/feedback/CircularProgress.md +20 -5
- package/dist/components/feedback/Dialog.md +8 -12
- package/dist/components/feedback/Modal.md +12 -16
- package/dist/components/feedback/Skeleton.md +20 -5
- package/dist/components/inputs/Autocomplete.md +8 -10
- package/dist/components/inputs/Button.md +107 -87
- package/dist/components/inputs/ButtonGroup.md +20 -5
- package/dist/components/inputs/Calendar.md +25 -5
- package/dist/components/inputs/Checkbox.md +171 -450
- package/dist/components/inputs/CurrencyInput.md +25 -5
- package/dist/components/inputs/DatePicker.md +59 -5
- package/dist/components/inputs/DateRangePicker.md +46 -5
- package/dist/components/inputs/FilterMenu.md +85 -9
- package/dist/components/inputs/FilterableCheckboxGroup.md +23 -8
- package/dist/components/inputs/FormControl.md +34 -6
- package/dist/components/inputs/IconButton.md +21 -5
- package/dist/components/inputs/Input.md +254 -68
- package/dist/components/inputs/MonthPicker.md +59 -5
- package/dist/components/inputs/MonthRangePicker.md +44 -5
- package/dist/components/inputs/PercentageInput.md +28 -5
- package/dist/components/inputs/RadioButton.md +26 -5
- package/dist/components/inputs/RadioList.md +23 -6
- package/dist/components/inputs/RadioTileGroup.md +40 -8
- package/dist/components/inputs/Select.md +59 -5
- package/dist/components/inputs/Slider.md +26 -5
- package/dist/components/inputs/Switch.md +23 -5
- package/dist/components/inputs/Textarea.md +27 -5
- package/dist/components/inputs/Uploader/Uploader.md +24 -5
- package/dist/components/layout/Box.md +66 -58
- package/dist/components/layout/Container.md +9 -13
- package/dist/components/layout/Grid.md +91 -75
- package/dist/components/layout/Stack.md +85 -70
- package/dist/components/navigation/Breadcrumbs.md +23 -14
- package/dist/components/navigation/Dropdown.md +29 -20
- package/dist/components/navigation/IconMenuButton.md +24 -11
- package/dist/components/navigation/InsetDrawer.md +16 -5
- package/dist/components/navigation/Link.md +30 -14
- package/dist/components/navigation/Menu.md +33 -20
- package/dist/components/navigation/MenuButton.md +26 -12
- package/dist/components/navigation/NavigationGroup.md +7 -11
- package/dist/components/navigation/NavigationItem.md +8 -12
- package/dist/components/navigation/Navigator.md +5 -9
- package/dist/components/navigation/Pagination.md +21 -12
- package/dist/components/navigation/ProfileMenu.md +17 -5
- package/dist/components/navigation/Stepper.md +18 -5
- package/dist/components/navigation/Tabs.md +37 -14
- package/dist/components/surfaces/Accordions.md +12 -16
- package/dist/components/surfaces/Card.md +59 -47
- package/dist/components/surfaces/Divider.md +70 -61
- package/dist/components/surfaces/Sheet.md +18 -5
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +3 -3
- package/dist/index.cjs +99 -39
- package/dist/index.js +99 -39
- package/framer/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -745,6 +745,9 @@ var getMonthName = (date, locale, options) => {
|
|
|
745
745
|
...options?.hideYear ? {} : { year: "numeric" }
|
|
746
746
|
});
|
|
747
747
|
};
|
|
748
|
+
var getShortMonthName = (date, locale) => {
|
|
749
|
+
return date.toLocaleString(locale, { month: "short" });
|
|
750
|
+
};
|
|
748
751
|
var getMonthNameFromIndex = (index, locale) => {
|
|
749
752
|
return new Date(0, index).toLocaleString(locale, { month: "short" });
|
|
750
753
|
};
|
|
@@ -2411,6 +2414,7 @@ DialogActions.displayName = "DialogActions";
|
|
|
2411
2414
|
var DialogActions_default = DialogActions;
|
|
2412
2415
|
|
|
2413
2416
|
// src/components/DatePicker/DatePicker.tsx
|
|
2417
|
+
var hasAlphabeticMonth = (format) => /MMMM|MMM/.test(format);
|
|
2414
2418
|
var CalendarButton = styled10(IconButton_default, {
|
|
2415
2419
|
name: "DatePicker",
|
|
2416
2420
|
slot: "calendarButton"
|
|
@@ -2481,6 +2485,7 @@ var DatePickerRoot = styled10("div", {
|
|
|
2481
2485
|
width: "100%"
|
|
2482
2486
|
});
|
|
2483
2487
|
var validValueFormat = (value, format) => {
|
|
2488
|
+
if (hasAlphabeticMonth(format)) return true;
|
|
2484
2489
|
try {
|
|
2485
2490
|
const parsedValue = parseDate(value, format);
|
|
2486
2491
|
if (parsedValue.toString() === "Invalid Date") {
|
|
@@ -2495,13 +2500,15 @@ var validValueFormat = (value, format) => {
|
|
|
2495
2500
|
return false;
|
|
2496
2501
|
}
|
|
2497
2502
|
};
|
|
2498
|
-
var formatValueString = (date, format) => {
|
|
2503
|
+
var formatValueString = (date, format, locale = "default") => {
|
|
2499
2504
|
let day = `${date.getDate()}`;
|
|
2500
2505
|
let month = `${date.getMonth() + 1}`;
|
|
2501
2506
|
const year = date.getFullYear();
|
|
2502
2507
|
if (Number(day) < 10) day = "0" + day;
|
|
2503
2508
|
if (Number(month) < 10) month = "0" + month;
|
|
2504
|
-
|
|
2509
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
2510
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
2511
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
2505
2512
|
};
|
|
2506
2513
|
function parseDate(dateString, format) {
|
|
2507
2514
|
const formatParts = format.split(/[-./\s]/);
|
|
@@ -2586,6 +2593,7 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2586
2593
|
format = "YYYY/MM/DD",
|
|
2587
2594
|
displayFormat = "YYYY/MM/DD",
|
|
2588
2595
|
size,
|
|
2596
|
+
locale = "default",
|
|
2589
2597
|
inputReadOnly,
|
|
2590
2598
|
hideClearButton,
|
|
2591
2599
|
readOnly,
|
|
@@ -2600,8 +2608,9 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2600
2608
|
props.defaultValue || "",
|
|
2601
2609
|
useCallback8((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
2602
2610
|
);
|
|
2611
|
+
const isAlphabeticDisplay = hasAlphabeticMonth(displayFormat);
|
|
2603
2612
|
const [displayValue, setDisplayValue] = useState7(
|
|
2604
|
-
() => value ? formatValueString(parseDate(value, format), displayFormat) : ""
|
|
2613
|
+
() => value ? formatValueString(parseDate(value, format), displayFormat, locale) : ""
|
|
2605
2614
|
);
|
|
2606
2615
|
const [anchorEl, setAnchorEl] = useState7(null);
|
|
2607
2616
|
const open = Boolean(anchorEl);
|
|
@@ -2615,19 +2624,19 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2615
2624
|
setDisplayValue("");
|
|
2616
2625
|
return;
|
|
2617
2626
|
}
|
|
2618
|
-
const formattedValue = formatValueString(parseDate(value, format), displayFormat);
|
|
2627
|
+
const formattedValue = formatValueString(parseDate(value, format), displayFormat, locale);
|
|
2619
2628
|
if (validValueFormat(formattedValue, displayFormat) && formattedValue !== displayValue) {
|
|
2620
2629
|
setDisplayValue(formattedValue);
|
|
2621
2630
|
}
|
|
2622
|
-
}, [displayFormat, displayValue, format, value]);
|
|
2631
|
+
}, [displayFormat, displayValue, format, locale, value]);
|
|
2623
2632
|
useImperativeHandle(ref, () => innerRef.current, [innerRef]);
|
|
2624
2633
|
const handleChange = useCallback8(
|
|
2625
2634
|
(event) => {
|
|
2626
2635
|
const value2 = event.target.value;
|
|
2627
|
-
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2);
|
|
2636
|
+
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat, locale) : value2);
|
|
2628
2637
|
setValue(value2);
|
|
2629
2638
|
},
|
|
2630
|
-
[displayFormat, format, setValue]
|
|
2639
|
+
[displayFormat, format, locale, setValue]
|
|
2631
2640
|
);
|
|
2632
2641
|
const handleDisplayInputChange = useCallback8(
|
|
2633
2642
|
(event) => {
|
|
@@ -2665,12 +2674,12 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2665
2674
|
);
|
|
2666
2675
|
const handleInputMouseDown = useCallback8(
|
|
2667
2676
|
(event) => {
|
|
2668
|
-
if (inputReadOnly) {
|
|
2677
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
2669
2678
|
event.preventDefault();
|
|
2670
2679
|
buttonRef.current?.focus();
|
|
2671
2680
|
}
|
|
2672
2681
|
},
|
|
2673
|
-
[inputReadOnly, buttonRef]
|
|
2682
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
2674
2683
|
);
|
|
2675
2684
|
const handlePresetClick = useCallback8(
|
|
2676
2685
|
(presetValue) => {
|
|
@@ -2716,12 +2725,11 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2716
2725
|
error,
|
|
2717
2726
|
slotProps: {
|
|
2718
2727
|
input: {
|
|
2719
|
-
component: TextMaskAdapter3,
|
|
2728
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter3, format: displayFormat },
|
|
2720
2729
|
ref: innerRef,
|
|
2721
|
-
format: displayFormat,
|
|
2722
2730
|
sx: {
|
|
2723
2731
|
"&:hover": {
|
|
2724
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
2732
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
2725
2733
|
}
|
|
2726
2734
|
},
|
|
2727
2735
|
onMouseDown: handleInputMouseDown
|
|
@@ -2745,7 +2753,7 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2745
2753
|
),
|
|
2746
2754
|
label,
|
|
2747
2755
|
helperText,
|
|
2748
|
-
readOnly: readOnly || inputReadOnly
|
|
2756
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
2749
2757
|
}
|
|
2750
2758
|
), open && /* @__PURE__ */ React18.createElement(ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ React18.createElement(
|
|
2751
2759
|
StyledPopper,
|
|
@@ -4634,6 +4642,7 @@ import { IMaskInput as IMaskInput2, IMask as IMask2 } from "react-imask";
|
|
|
4634
4642
|
import CalendarTodayIcon2 from "@mui/icons-material/CalendarToday";
|
|
4635
4643
|
import { styled as styled14, useThemeProps as useThemeProps5 } from "@mui/joy";
|
|
4636
4644
|
import { FocusTrap as FocusTrap2, ClickAwayListener as ClickAwayListener2, Popper as Popper3 } from "@mui/base";
|
|
4645
|
+
var hasAlphabeticMonth2 = (format) => /MMMM|MMM/.test(format);
|
|
4637
4646
|
var CalendarButton2 = styled14(IconButton_default, {
|
|
4638
4647
|
name: "DateRangePicker",
|
|
4639
4648
|
slot: "calendarButton"
|
|
@@ -4705,6 +4714,7 @@ var DateRangePickerRoot = styled14("div", {
|
|
|
4705
4714
|
width: "100%"
|
|
4706
4715
|
});
|
|
4707
4716
|
var validValueFormat2 = (value, format) => {
|
|
4717
|
+
if (hasAlphabeticMonth2(format)) return true;
|
|
4708
4718
|
try {
|
|
4709
4719
|
const [date1Str, date2Str] = value.split(" - ");
|
|
4710
4720
|
if (!date1Str || !date2Str) {
|
|
@@ -4727,14 +4737,16 @@ var validValueFormat2 = (value, format) => {
|
|
|
4727
4737
|
return false;
|
|
4728
4738
|
}
|
|
4729
4739
|
};
|
|
4730
|
-
var formatValueString2 = ([date1, date2], format) => {
|
|
4740
|
+
var formatValueString2 = ([date1, date2], format, locale = "default") => {
|
|
4731
4741
|
const getStr = (date) => {
|
|
4732
4742
|
let day = `${date.getDate()}`;
|
|
4733
4743
|
let month = `${date.getMonth() + 1}`;
|
|
4734
4744
|
const year = date.getFullYear();
|
|
4735
4745
|
if (Number(day) < 10) day = "0" + day;
|
|
4736
4746
|
if (Number(month) < 10) month = "0" + month;
|
|
4737
|
-
|
|
4747
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
4748
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
4749
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
4738
4750
|
};
|
|
4739
4751
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
4740
4752
|
};
|
|
@@ -4822,6 +4834,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4822
4834
|
format = "YYYY/MM/DD",
|
|
4823
4835
|
displayFormat = "YYYY/MM/DD",
|
|
4824
4836
|
size,
|
|
4837
|
+
locale = "default",
|
|
4825
4838
|
inputReadOnly,
|
|
4826
4839
|
hideClearButton,
|
|
4827
4840
|
readOnly,
|
|
@@ -4835,8 +4848,9 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4835
4848
|
props.defaultValue || "",
|
|
4836
4849
|
useCallback13((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
4837
4850
|
);
|
|
4851
|
+
const isAlphabeticDisplay = hasAlphabeticMonth2(displayFormat);
|
|
4838
4852
|
const [displayValue, setDisplayValue] = useState10(
|
|
4839
|
-
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4853
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat, locale) : ""
|
|
4840
4854
|
);
|
|
4841
4855
|
const [anchorEl, setAnchorEl] = useState10(null);
|
|
4842
4856
|
const open = Boolean(anchorEl);
|
|
@@ -4848,14 +4862,14 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4848
4862
|
if (value) {
|
|
4849
4863
|
try {
|
|
4850
4864
|
const dates = parseDates(value, format);
|
|
4851
|
-
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4865
|
+
const newDisplayValue = formatValueString2(dates, displayFormat, locale);
|
|
4852
4866
|
setDisplayValue(newDisplayValue);
|
|
4853
4867
|
} catch (error2) {
|
|
4854
4868
|
}
|
|
4855
4869
|
} else {
|
|
4856
4870
|
setDisplayValue("");
|
|
4857
4871
|
}
|
|
4858
|
-
}, [displayFormat, value, format]);
|
|
4872
|
+
}, [displayFormat, locale, value, format]);
|
|
4859
4873
|
useEffect8(() => {
|
|
4860
4874
|
if (!anchorEl) {
|
|
4861
4875
|
innerRef.current?.blur();
|
|
@@ -4865,10 +4879,10 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4865
4879
|
const handleChange = useCallback13(
|
|
4866
4880
|
(event) => {
|
|
4867
4881
|
const value2 = event.target.value;
|
|
4868
|
-
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2);
|
|
4882
|
+
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat, locale) : value2);
|
|
4869
4883
|
setValue(value2);
|
|
4870
4884
|
},
|
|
4871
|
-
[displayFormat, format, setValue]
|
|
4885
|
+
[displayFormat, format, locale, setValue]
|
|
4872
4886
|
);
|
|
4873
4887
|
const handleDisplayInputChange = useCallback13(
|
|
4874
4888
|
(event) => {
|
|
@@ -4909,21 +4923,21 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4909
4923
|
if (props.value !== void 0) {
|
|
4910
4924
|
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
4911
4925
|
} else {
|
|
4912
|
-
setDisplayValue(formatValueString2([date1, date2], displayFormat));
|
|
4926
|
+
setDisplayValue(formatValueString2([date1, date2], displayFormat, locale));
|
|
4913
4927
|
setValue(formattedValue);
|
|
4914
4928
|
}
|
|
4915
4929
|
setAnchorEl(null);
|
|
4916
4930
|
},
|
|
4917
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4931
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4918
4932
|
);
|
|
4919
4933
|
const handleInputMouseDown = useCallback13(
|
|
4920
4934
|
(event) => {
|
|
4921
|
-
if (inputReadOnly) {
|
|
4935
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
4922
4936
|
event.preventDefault();
|
|
4923
4937
|
buttonRef.current?.focus();
|
|
4924
4938
|
}
|
|
4925
4939
|
},
|
|
4926
|
-
[inputReadOnly, buttonRef]
|
|
4940
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
4927
4941
|
);
|
|
4928
4942
|
const handlePresetClick = useCallback13(
|
|
4929
4943
|
(presetValue) => {
|
|
@@ -4931,12 +4945,12 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4931
4945
|
onChange?.({ target: { name: props.name, value: presetValue } });
|
|
4932
4946
|
} else {
|
|
4933
4947
|
const dates = parseDates(presetValue, format);
|
|
4934
|
-
setDisplayValue(formatValueString2(dates, displayFormat));
|
|
4948
|
+
setDisplayValue(formatValueString2(dates, displayFormat, locale));
|
|
4935
4949
|
setValue(presetValue);
|
|
4936
4950
|
}
|
|
4937
4951
|
setAnchorEl(null);
|
|
4938
4952
|
},
|
|
4939
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4953
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4940
4954
|
);
|
|
4941
4955
|
const isPresetDisabled = useCallback13(
|
|
4942
4956
|
(presetValue) => {
|
|
@@ -4971,12 +4985,11 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4971
4985
|
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
4972
4986
|
slotProps: {
|
|
4973
4987
|
input: {
|
|
4974
|
-
component: TextMaskAdapter5,
|
|
4988
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter5, format: displayFormat },
|
|
4975
4989
|
ref: innerRef,
|
|
4976
|
-
format: displayFormat,
|
|
4977
4990
|
sx: {
|
|
4978
4991
|
"&:hover": {
|
|
4979
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
4992
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
4980
4993
|
}
|
|
4981
4994
|
},
|
|
4982
4995
|
onMouseDown: handleInputMouseDown
|
|
@@ -5001,7 +5014,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
5001
5014
|
),
|
|
5002
5015
|
label,
|
|
5003
5016
|
helperText,
|
|
5004
|
-
readOnly: readOnly || inputReadOnly
|
|
5017
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
5005
5018
|
}
|
|
5006
5019
|
), open && /* @__PURE__ */ React26.createElement(ClickAwayListener2, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ React26.createElement(
|
|
5007
5020
|
StyledPopper2,
|
|
@@ -6690,8 +6703,9 @@ var formatValueString3 = (date, format, locale = "default") => {
|
|
|
6690
6703
|
const year = date.getFullYear().toString();
|
|
6691
6704
|
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
6692
6705
|
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
6706
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
6693
6707
|
const day = "01";
|
|
6694
|
-
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6708
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6695
6709
|
};
|
|
6696
6710
|
function parseDate3(dateString, format) {
|
|
6697
6711
|
const dateParts = dateString.split(/[-./\s]/);
|
|
@@ -6918,6 +6932,7 @@ import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
|
|
|
6918
6932
|
import CalendarTodayIcon4 from "@mui/icons-material/CalendarToday";
|
|
6919
6933
|
import { styled as styled23, useThemeProps as useThemeProps8 } from "@mui/joy";
|
|
6920
6934
|
import { FocusTrap as FocusTrap4, ClickAwayListener as ClickAwayListener4, Popper as Popper5 } from "@mui/base";
|
|
6935
|
+
var hasAlphabeticMonth3 = (format) => /MMMM|MMM/.test(format);
|
|
6921
6936
|
var StyledPopper4 = styled23(Popper5, {
|
|
6922
6937
|
name: "MonthRangePicker",
|
|
6923
6938
|
slot: "popper"
|
|
@@ -6941,12 +6956,14 @@ var MonthRangePickerRoot = styled23("div", {
|
|
|
6941
6956
|
})({
|
|
6942
6957
|
width: "100%"
|
|
6943
6958
|
});
|
|
6944
|
-
var formatValueString4 = ([date1, date2], format) => {
|
|
6959
|
+
var formatValueString4 = ([date1, date2], format, locale = "default") => {
|
|
6945
6960
|
const getStr = (date) => {
|
|
6946
6961
|
let month = `${date.getMonth() + 1}`;
|
|
6947
6962
|
const year = date.getFullYear();
|
|
6948
6963
|
if (Number(month) < 10) month = "0" + month;
|
|
6949
|
-
|
|
6964
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
6965
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
6966
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/YYYY/g, year.toString());
|
|
6950
6967
|
};
|
|
6951
6968
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
6952
6969
|
};
|
|
@@ -7018,18 +7035,38 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7018
7035
|
sx,
|
|
7019
7036
|
className,
|
|
7020
7037
|
format = "YYYY/MM",
|
|
7038
|
+
displayFormat: displayFormatProp,
|
|
7021
7039
|
size,
|
|
7040
|
+
locale = "default",
|
|
7022
7041
|
...innerProps
|
|
7023
7042
|
} = props;
|
|
7043
|
+
const displayFormat = displayFormatProp ?? format;
|
|
7044
|
+
const isAlphabeticDisplay = hasAlphabeticMonth3(displayFormat);
|
|
7024
7045
|
const innerRef = useRef12(null);
|
|
7046
|
+
const buttonRef = useRef12(null);
|
|
7025
7047
|
const [value, setValue] = useControlledState(
|
|
7026
7048
|
props.value,
|
|
7027
7049
|
props.defaultValue || "",
|
|
7028
7050
|
useCallback27((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
7029
7051
|
);
|
|
7052
|
+
const [displayValue, setDisplayValue] = useState17(
|
|
7053
|
+
() => value ? formatValueString4(parseDates2(value), displayFormat, locale) : ""
|
|
7054
|
+
);
|
|
7030
7055
|
const [anchorEl, setAnchorEl] = useState17(null);
|
|
7031
7056
|
const open = Boolean(anchorEl);
|
|
7032
7057
|
const calendarValue = useMemo16(() => value ? parseDates2(value) : void 0, [value]);
|
|
7058
|
+
useEffect14(() => {
|
|
7059
|
+
if (value) {
|
|
7060
|
+
try {
|
|
7061
|
+
const dates = parseDates2(value);
|
|
7062
|
+
const newDisplayValue = formatValueString4(dates, displayFormat, locale);
|
|
7063
|
+
setDisplayValue(newDisplayValue);
|
|
7064
|
+
} catch {
|
|
7065
|
+
}
|
|
7066
|
+
} else {
|
|
7067
|
+
setDisplayValue("");
|
|
7068
|
+
}
|
|
7069
|
+
}, [displayFormat, locale, value]);
|
|
7033
7070
|
useEffect14(() => {
|
|
7034
7071
|
if (!anchorEl) {
|
|
7035
7072
|
innerRef.current?.blur();
|
|
@@ -7038,9 +7075,21 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7038
7075
|
useImperativeHandle5(ref, () => innerRef.current, [innerRef]);
|
|
7039
7076
|
const handleChange = useCallback27(
|
|
7040
7077
|
(event) => {
|
|
7078
|
+
setDisplayValue(
|
|
7079
|
+
event.target.value ? formatValueString4(parseDates2(event.target.value), displayFormat, locale) : ""
|
|
7080
|
+
);
|
|
7041
7081
|
setValue(event.target.value);
|
|
7042
7082
|
},
|
|
7043
|
-
[setValue]
|
|
7083
|
+
[displayFormat, locale, setValue]
|
|
7084
|
+
);
|
|
7085
|
+
const handleInputMouseDown = useCallback27(
|
|
7086
|
+
(event) => {
|
|
7087
|
+
if (isAlphabeticDisplay) {
|
|
7088
|
+
event.preventDefault();
|
|
7089
|
+
buttonRef.current?.focus();
|
|
7090
|
+
}
|
|
7091
|
+
},
|
|
7092
|
+
[isAlphabeticDisplay, buttonRef]
|
|
7044
7093
|
);
|
|
7045
7094
|
const handleCalendarToggle = useCallback27(
|
|
7046
7095
|
(event) => {
|
|
@@ -7052,10 +7101,12 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7052
7101
|
const handleCalendarChange = useCallback27(
|
|
7053
7102
|
([date1, date2]) => {
|
|
7054
7103
|
if (!date1 || !date2) return;
|
|
7055
|
-
|
|
7104
|
+
const formattedValue = formatValueString4([date1, date2], format);
|
|
7105
|
+
setDisplayValue(formatValueString4([date1, date2], displayFormat, locale));
|
|
7106
|
+
setValue(formattedValue);
|
|
7056
7107
|
setAnchorEl(null);
|
|
7057
7108
|
},
|
|
7058
|
-
[setValue, setAnchorEl, format]
|
|
7109
|
+
[setValue, setAnchorEl, format, displayFormat, locale]
|
|
7059
7110
|
);
|
|
7060
7111
|
return /* @__PURE__ */ React47.createElement(MonthRangePickerRoot, null, /* @__PURE__ */ React47.createElement(FocusTrap4, { open: true }, /* @__PURE__ */ React47.createElement(React47.Fragment, null, /* @__PURE__ */ React47.createElement(
|
|
7061
7112
|
Input_default,
|
|
@@ -7064,14 +7115,22 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7064
7115
|
color: error ? "danger" : innerProps.color,
|
|
7065
7116
|
ref,
|
|
7066
7117
|
size,
|
|
7067
|
-
value,
|
|
7118
|
+
value: isAlphabeticDisplay ? displayValue : value,
|
|
7068
7119
|
onChange: handleChange,
|
|
7069
7120
|
disabled,
|
|
7070
7121
|
required,
|
|
7071
|
-
placeholder: `${
|
|
7122
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
7072
7123
|
slotProps: {
|
|
7073
|
-
input: {
|
|
7124
|
+
input: {
|
|
7125
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter9, format },
|
|
7126
|
+
ref: innerRef,
|
|
7127
|
+
...isAlphabeticDisplay ? {
|
|
7128
|
+
sx: { "&:hover": { cursor: "default" } },
|
|
7129
|
+
onMouseDown: handleInputMouseDown
|
|
7130
|
+
} : {}
|
|
7131
|
+
}
|
|
7074
7132
|
},
|
|
7133
|
+
readOnly: isAlphabeticDisplay || void 0,
|
|
7075
7134
|
error,
|
|
7076
7135
|
className,
|
|
7077
7136
|
sx: {
|
|
@@ -7082,6 +7141,7 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7082
7141
|
endDecorator: /* @__PURE__ */ React47.createElement(
|
|
7083
7142
|
IconButton_default,
|
|
7084
7143
|
{
|
|
7144
|
+
ref: buttonRef,
|
|
7085
7145
|
variant: "plain",
|
|
7086
7146
|
onClick: handleCalendarToggle,
|
|
7087
7147
|
"aria-label": "Toggle Calendar",
|