@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.cjs
CHANGED
|
@@ -893,6 +893,9 @@ var getMonthName = (date, locale, options) => {
|
|
|
893
893
|
...options?.hideYear ? {} : { year: "numeric" }
|
|
894
894
|
});
|
|
895
895
|
};
|
|
896
|
+
var getShortMonthName = (date, locale) => {
|
|
897
|
+
return date.toLocaleString(locale, { month: "short" });
|
|
898
|
+
};
|
|
896
899
|
var getMonthNameFromIndex = (index, locale) => {
|
|
897
900
|
return new Date(0, index).toLocaleString(locale, { month: "short" });
|
|
898
901
|
};
|
|
@@ -2536,6 +2539,7 @@ DialogActions.displayName = "DialogActions";
|
|
|
2536
2539
|
var DialogActions_default = DialogActions;
|
|
2537
2540
|
|
|
2538
2541
|
// src/components/DatePicker/DatePicker.tsx
|
|
2542
|
+
var hasAlphabeticMonth = (format) => /MMMM|MMM/.test(format);
|
|
2539
2543
|
var CalendarButton = (0, import_joy28.styled)(IconButton_default, {
|
|
2540
2544
|
name: "DatePicker",
|
|
2541
2545
|
slot: "calendarButton"
|
|
@@ -2606,6 +2610,7 @@ var DatePickerRoot = (0, import_joy28.styled)("div", {
|
|
|
2606
2610
|
width: "100%"
|
|
2607
2611
|
});
|
|
2608
2612
|
var validValueFormat = (value, format) => {
|
|
2613
|
+
if (hasAlphabeticMonth(format)) return true;
|
|
2609
2614
|
try {
|
|
2610
2615
|
const parsedValue = parseDate(value, format);
|
|
2611
2616
|
if (parsedValue.toString() === "Invalid Date") {
|
|
@@ -2620,13 +2625,15 @@ var validValueFormat = (value, format) => {
|
|
|
2620
2625
|
return false;
|
|
2621
2626
|
}
|
|
2622
2627
|
};
|
|
2623
|
-
var formatValueString = (date, format) => {
|
|
2628
|
+
var formatValueString = (date, format, locale = "default") => {
|
|
2624
2629
|
let day = `${date.getDate()}`;
|
|
2625
2630
|
let month = `${date.getMonth() + 1}`;
|
|
2626
2631
|
const year = date.getFullYear();
|
|
2627
2632
|
if (Number(day) < 10) day = "0" + day;
|
|
2628
2633
|
if (Number(month) < 10) month = "0" + month;
|
|
2629
|
-
|
|
2634
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
2635
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
2636
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
2630
2637
|
};
|
|
2631
2638
|
function parseDate(dateString, format) {
|
|
2632
2639
|
const formatParts = format.split(/[-./\s]/);
|
|
@@ -2711,6 +2718,7 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2711
2718
|
format = "YYYY/MM/DD",
|
|
2712
2719
|
displayFormat = "YYYY/MM/DD",
|
|
2713
2720
|
size,
|
|
2721
|
+
locale = "default",
|
|
2714
2722
|
inputReadOnly,
|
|
2715
2723
|
hideClearButton,
|
|
2716
2724
|
readOnly,
|
|
@@ -2725,8 +2733,9 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2725
2733
|
props.defaultValue || "",
|
|
2726
2734
|
(0, import_react20.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
2727
2735
|
);
|
|
2736
|
+
const isAlphabeticDisplay = hasAlphabeticMonth(displayFormat);
|
|
2728
2737
|
const [displayValue, setDisplayValue] = (0, import_react20.useState)(
|
|
2729
|
-
() => value ? formatValueString(parseDate(value, format), displayFormat) : ""
|
|
2738
|
+
() => value ? formatValueString(parseDate(value, format), displayFormat, locale) : ""
|
|
2730
2739
|
);
|
|
2731
2740
|
const [anchorEl, setAnchorEl] = (0, import_react20.useState)(null);
|
|
2732
2741
|
const open = Boolean(anchorEl);
|
|
@@ -2740,19 +2749,19 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2740
2749
|
setDisplayValue("");
|
|
2741
2750
|
return;
|
|
2742
2751
|
}
|
|
2743
|
-
const formattedValue = formatValueString(parseDate(value, format), displayFormat);
|
|
2752
|
+
const formattedValue = formatValueString(parseDate(value, format), displayFormat, locale);
|
|
2744
2753
|
if (validValueFormat(formattedValue, displayFormat) && formattedValue !== displayValue) {
|
|
2745
2754
|
setDisplayValue(formattedValue);
|
|
2746
2755
|
}
|
|
2747
|
-
}, [displayFormat, displayValue, format, value]);
|
|
2756
|
+
}, [displayFormat, displayValue, format, locale, value]);
|
|
2748
2757
|
(0, import_react20.useImperativeHandle)(ref, () => innerRef.current, [innerRef]);
|
|
2749
2758
|
const handleChange = (0, import_react20.useCallback)(
|
|
2750
2759
|
(event) => {
|
|
2751
2760
|
const value2 = event.target.value;
|
|
2752
|
-
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2);
|
|
2761
|
+
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat, locale) : value2);
|
|
2753
2762
|
setValue(value2);
|
|
2754
2763
|
},
|
|
2755
|
-
[displayFormat, format, setValue]
|
|
2764
|
+
[displayFormat, format, locale, setValue]
|
|
2756
2765
|
);
|
|
2757
2766
|
const handleDisplayInputChange = (0, import_react20.useCallback)(
|
|
2758
2767
|
(event) => {
|
|
@@ -2790,12 +2799,12 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2790
2799
|
);
|
|
2791
2800
|
const handleInputMouseDown = (0, import_react20.useCallback)(
|
|
2792
2801
|
(event) => {
|
|
2793
|
-
if (inputReadOnly) {
|
|
2802
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
2794
2803
|
event.preventDefault();
|
|
2795
2804
|
buttonRef.current?.focus();
|
|
2796
2805
|
}
|
|
2797
2806
|
},
|
|
2798
|
-
[inputReadOnly, buttonRef]
|
|
2807
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
2799
2808
|
);
|
|
2800
2809
|
const handlePresetClick = (0, import_react20.useCallback)(
|
|
2801
2810
|
(presetValue) => {
|
|
@@ -2841,12 +2850,11 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2841
2850
|
error,
|
|
2842
2851
|
slotProps: {
|
|
2843
2852
|
input: {
|
|
2844
|
-
component: TextMaskAdapter3,
|
|
2853
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter3, format: displayFormat },
|
|
2845
2854
|
ref: innerRef,
|
|
2846
|
-
format: displayFormat,
|
|
2847
2855
|
sx: {
|
|
2848
2856
|
"&:hover": {
|
|
2849
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
2857
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
2850
2858
|
}
|
|
2851
2859
|
},
|
|
2852
2860
|
onMouseDown: handleInputMouseDown
|
|
@@ -2870,7 +2878,7 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2870
2878
|
),
|
|
2871
2879
|
label,
|
|
2872
2880
|
helperText,
|
|
2873
|
-
readOnly: readOnly || inputReadOnly
|
|
2881
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
2874
2882
|
}
|
|
2875
2883
|
), open && /* @__PURE__ */ import_react20.default.createElement(import_base3.ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ import_react20.default.createElement(
|
|
2876
2884
|
StyledPopper,
|
|
@@ -4759,6 +4767,7 @@ var import_react_imask2 = require("react-imask");
|
|
|
4759
4767
|
var import_CalendarToday2 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
4760
4768
|
var import_joy36 = require("@mui/joy");
|
|
4761
4769
|
var import_base4 = require("@mui/base");
|
|
4770
|
+
var hasAlphabeticMonth2 = (format) => /MMMM|MMM/.test(format);
|
|
4762
4771
|
var CalendarButton2 = (0, import_joy36.styled)(IconButton_default, {
|
|
4763
4772
|
name: "DateRangePicker",
|
|
4764
4773
|
slot: "calendarButton"
|
|
@@ -4830,6 +4839,7 @@ var DateRangePickerRoot = (0, import_joy36.styled)("div", {
|
|
|
4830
4839
|
width: "100%"
|
|
4831
4840
|
});
|
|
4832
4841
|
var validValueFormat2 = (value, format) => {
|
|
4842
|
+
if (hasAlphabeticMonth2(format)) return true;
|
|
4833
4843
|
try {
|
|
4834
4844
|
const [date1Str, date2Str] = value.split(" - ");
|
|
4835
4845
|
if (!date1Str || !date2Str) {
|
|
@@ -4852,14 +4862,16 @@ var validValueFormat2 = (value, format) => {
|
|
|
4852
4862
|
return false;
|
|
4853
4863
|
}
|
|
4854
4864
|
};
|
|
4855
|
-
var formatValueString2 = ([date1, date2], format) => {
|
|
4865
|
+
var formatValueString2 = ([date1, date2], format, locale = "default") => {
|
|
4856
4866
|
const getStr = (date) => {
|
|
4857
4867
|
let day = `${date.getDate()}`;
|
|
4858
4868
|
let month = `${date.getMonth() + 1}`;
|
|
4859
4869
|
const year = date.getFullYear();
|
|
4860
4870
|
if (Number(day) < 10) day = "0" + day;
|
|
4861
4871
|
if (Number(month) < 10) month = "0" + month;
|
|
4862
|
-
|
|
4872
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
4873
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
4874
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
4863
4875
|
};
|
|
4864
4876
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
4865
4877
|
};
|
|
@@ -4947,6 +4959,7 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4947
4959
|
format = "YYYY/MM/DD",
|
|
4948
4960
|
displayFormat = "YYYY/MM/DD",
|
|
4949
4961
|
size,
|
|
4962
|
+
locale = "default",
|
|
4950
4963
|
inputReadOnly,
|
|
4951
4964
|
hideClearButton,
|
|
4952
4965
|
readOnly,
|
|
@@ -4960,8 +4973,9 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4960
4973
|
props.defaultValue || "",
|
|
4961
4974
|
(0, import_react29.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
4962
4975
|
);
|
|
4976
|
+
const isAlphabeticDisplay = hasAlphabeticMonth2(displayFormat);
|
|
4963
4977
|
const [displayValue, setDisplayValue] = (0, import_react29.useState)(
|
|
4964
|
-
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4978
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat, locale) : ""
|
|
4965
4979
|
);
|
|
4966
4980
|
const [anchorEl, setAnchorEl] = (0, import_react29.useState)(null);
|
|
4967
4981
|
const open = Boolean(anchorEl);
|
|
@@ -4973,14 +4987,14 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4973
4987
|
if (value) {
|
|
4974
4988
|
try {
|
|
4975
4989
|
const dates = parseDates(value, format);
|
|
4976
|
-
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4990
|
+
const newDisplayValue = formatValueString2(dates, displayFormat, locale);
|
|
4977
4991
|
setDisplayValue(newDisplayValue);
|
|
4978
4992
|
} catch (error2) {
|
|
4979
4993
|
}
|
|
4980
4994
|
} else {
|
|
4981
4995
|
setDisplayValue("");
|
|
4982
4996
|
}
|
|
4983
|
-
}, [displayFormat, value, format]);
|
|
4997
|
+
}, [displayFormat, locale, value, format]);
|
|
4984
4998
|
(0, import_react29.useEffect)(() => {
|
|
4985
4999
|
if (!anchorEl) {
|
|
4986
5000
|
innerRef.current?.blur();
|
|
@@ -4990,10 +5004,10 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4990
5004
|
const handleChange = (0, import_react29.useCallback)(
|
|
4991
5005
|
(event) => {
|
|
4992
5006
|
const value2 = event.target.value;
|
|
4993
|
-
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2);
|
|
5007
|
+
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat, locale) : value2);
|
|
4994
5008
|
setValue(value2);
|
|
4995
5009
|
},
|
|
4996
|
-
[displayFormat, format, setValue]
|
|
5010
|
+
[displayFormat, format, locale, setValue]
|
|
4997
5011
|
);
|
|
4998
5012
|
const handleDisplayInputChange = (0, import_react29.useCallback)(
|
|
4999
5013
|
(event) => {
|
|
@@ -5034,21 +5048,21 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5034
5048
|
if (props.value !== void 0) {
|
|
5035
5049
|
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
5036
5050
|
} else {
|
|
5037
|
-
setDisplayValue(formatValueString2([date1, date2], displayFormat));
|
|
5051
|
+
setDisplayValue(formatValueString2([date1, date2], displayFormat, locale));
|
|
5038
5052
|
setValue(formattedValue);
|
|
5039
5053
|
}
|
|
5040
5054
|
setAnchorEl(null);
|
|
5041
5055
|
},
|
|
5042
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
5056
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
5043
5057
|
);
|
|
5044
5058
|
const handleInputMouseDown = (0, import_react29.useCallback)(
|
|
5045
5059
|
(event) => {
|
|
5046
|
-
if (inputReadOnly) {
|
|
5060
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
5047
5061
|
event.preventDefault();
|
|
5048
5062
|
buttonRef.current?.focus();
|
|
5049
5063
|
}
|
|
5050
5064
|
},
|
|
5051
|
-
[inputReadOnly, buttonRef]
|
|
5065
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
5052
5066
|
);
|
|
5053
5067
|
const handlePresetClick = (0, import_react29.useCallback)(
|
|
5054
5068
|
(presetValue) => {
|
|
@@ -5056,12 +5070,12 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5056
5070
|
onChange?.({ target: { name: props.name, value: presetValue } });
|
|
5057
5071
|
} else {
|
|
5058
5072
|
const dates = parseDates(presetValue, format);
|
|
5059
|
-
setDisplayValue(formatValueString2(dates, displayFormat));
|
|
5073
|
+
setDisplayValue(formatValueString2(dates, displayFormat, locale));
|
|
5060
5074
|
setValue(presetValue);
|
|
5061
5075
|
}
|
|
5062
5076
|
setAnchorEl(null);
|
|
5063
5077
|
},
|
|
5064
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
5078
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
5065
5079
|
);
|
|
5066
5080
|
const isPresetDisabled = (0, import_react29.useCallback)(
|
|
5067
5081
|
(presetValue) => {
|
|
@@ -5096,12 +5110,11 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5096
5110
|
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
5097
5111
|
slotProps: {
|
|
5098
5112
|
input: {
|
|
5099
|
-
component: TextMaskAdapter5,
|
|
5113
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter5, format: displayFormat },
|
|
5100
5114
|
ref: innerRef,
|
|
5101
|
-
format: displayFormat,
|
|
5102
5115
|
sx: {
|
|
5103
5116
|
"&:hover": {
|
|
5104
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
5117
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
5105
5118
|
}
|
|
5106
5119
|
},
|
|
5107
5120
|
onMouseDown: handleInputMouseDown
|
|
@@ -5126,7 +5139,7 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5126
5139
|
),
|
|
5127
5140
|
label,
|
|
5128
5141
|
helperText,
|
|
5129
|
-
readOnly: readOnly || inputReadOnly
|
|
5142
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
5130
5143
|
}
|
|
5131
5144
|
), open && /* @__PURE__ */ import_react29.default.createElement(import_base4.ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ import_react29.default.createElement(
|
|
5132
5145
|
StyledPopper2,
|
|
@@ -6809,8 +6822,9 @@ var formatValueString3 = (date, format, locale = "default") => {
|
|
|
6809
6822
|
const year = date.getFullYear().toString();
|
|
6810
6823
|
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
6811
6824
|
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
6825
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
6812
6826
|
const day = "01";
|
|
6813
|
-
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6827
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6814
6828
|
};
|
|
6815
6829
|
function parseDate3(dateString, format) {
|
|
6816
6830
|
const dateParts = dateString.split(/[-./\s]/);
|
|
@@ -7037,6 +7051,7 @@ var import_react_imask3 = require("react-imask");
|
|
|
7037
7051
|
var import_CalendarToday4 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
7038
7052
|
var import_joy62 = require("@mui/joy");
|
|
7039
7053
|
var import_base6 = require("@mui/base");
|
|
7054
|
+
var hasAlphabeticMonth3 = (format) => /MMMM|MMM/.test(format);
|
|
7040
7055
|
var StyledPopper4 = (0, import_joy62.styled)(import_base6.Popper, {
|
|
7041
7056
|
name: "MonthRangePicker",
|
|
7042
7057
|
slot: "popper"
|
|
@@ -7060,12 +7075,14 @@ var MonthRangePickerRoot = (0, import_joy62.styled)("div", {
|
|
|
7060
7075
|
})({
|
|
7061
7076
|
width: "100%"
|
|
7062
7077
|
});
|
|
7063
|
-
var formatValueString4 = ([date1, date2], format) => {
|
|
7078
|
+
var formatValueString4 = ([date1, date2], format, locale = "default") => {
|
|
7064
7079
|
const getStr = (date) => {
|
|
7065
7080
|
let month = `${date.getMonth() + 1}`;
|
|
7066
7081
|
const year = date.getFullYear();
|
|
7067
7082
|
if (Number(month) < 10) month = "0" + month;
|
|
7068
|
-
|
|
7083
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
7084
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
7085
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/YYYY/g, year.toString());
|
|
7069
7086
|
};
|
|
7070
7087
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
7071
7088
|
};
|
|
@@ -7137,18 +7154,38 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7137
7154
|
sx,
|
|
7138
7155
|
className,
|
|
7139
7156
|
format = "YYYY/MM",
|
|
7157
|
+
displayFormat: displayFormatProp,
|
|
7140
7158
|
size,
|
|
7159
|
+
locale = "default",
|
|
7141
7160
|
...innerProps
|
|
7142
7161
|
} = props;
|
|
7162
|
+
const displayFormat = displayFormatProp ?? format;
|
|
7163
|
+
const isAlphabeticDisplay = hasAlphabeticMonth3(displayFormat);
|
|
7143
7164
|
const innerRef = (0, import_react50.useRef)(null);
|
|
7165
|
+
const buttonRef = (0, import_react50.useRef)(null);
|
|
7144
7166
|
const [value, setValue] = useControlledState(
|
|
7145
7167
|
props.value,
|
|
7146
7168
|
props.defaultValue || "",
|
|
7147
7169
|
(0, import_react50.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
7148
7170
|
);
|
|
7171
|
+
const [displayValue, setDisplayValue] = (0, import_react50.useState)(
|
|
7172
|
+
() => value ? formatValueString4(parseDates2(value), displayFormat, locale) : ""
|
|
7173
|
+
);
|
|
7149
7174
|
const [anchorEl, setAnchorEl] = (0, import_react50.useState)(null);
|
|
7150
7175
|
const open = Boolean(anchorEl);
|
|
7151
7176
|
const calendarValue = (0, import_react50.useMemo)(() => value ? parseDates2(value) : void 0, [value]);
|
|
7177
|
+
(0, import_react50.useEffect)(() => {
|
|
7178
|
+
if (value) {
|
|
7179
|
+
try {
|
|
7180
|
+
const dates = parseDates2(value);
|
|
7181
|
+
const newDisplayValue = formatValueString4(dates, displayFormat, locale);
|
|
7182
|
+
setDisplayValue(newDisplayValue);
|
|
7183
|
+
} catch {
|
|
7184
|
+
}
|
|
7185
|
+
} else {
|
|
7186
|
+
setDisplayValue("");
|
|
7187
|
+
}
|
|
7188
|
+
}, [displayFormat, locale, value]);
|
|
7152
7189
|
(0, import_react50.useEffect)(() => {
|
|
7153
7190
|
if (!anchorEl) {
|
|
7154
7191
|
innerRef.current?.blur();
|
|
@@ -7157,9 +7194,21 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7157
7194
|
(0, import_react50.useImperativeHandle)(ref, () => innerRef.current, [innerRef]);
|
|
7158
7195
|
const handleChange = (0, import_react50.useCallback)(
|
|
7159
7196
|
(event) => {
|
|
7197
|
+
setDisplayValue(
|
|
7198
|
+
event.target.value ? formatValueString4(parseDates2(event.target.value), displayFormat, locale) : ""
|
|
7199
|
+
);
|
|
7160
7200
|
setValue(event.target.value);
|
|
7161
7201
|
},
|
|
7162
|
-
[setValue]
|
|
7202
|
+
[displayFormat, locale, setValue]
|
|
7203
|
+
);
|
|
7204
|
+
const handleInputMouseDown = (0, import_react50.useCallback)(
|
|
7205
|
+
(event) => {
|
|
7206
|
+
if (isAlphabeticDisplay) {
|
|
7207
|
+
event.preventDefault();
|
|
7208
|
+
buttonRef.current?.focus();
|
|
7209
|
+
}
|
|
7210
|
+
},
|
|
7211
|
+
[isAlphabeticDisplay, buttonRef]
|
|
7163
7212
|
);
|
|
7164
7213
|
const handleCalendarToggle = (0, import_react50.useCallback)(
|
|
7165
7214
|
(event) => {
|
|
@@ -7171,10 +7220,12 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7171
7220
|
const handleCalendarChange = (0, import_react50.useCallback)(
|
|
7172
7221
|
([date1, date2]) => {
|
|
7173
7222
|
if (!date1 || !date2) return;
|
|
7174
|
-
|
|
7223
|
+
const formattedValue = formatValueString4([date1, date2], format);
|
|
7224
|
+
setDisplayValue(formatValueString4([date1, date2], displayFormat, locale));
|
|
7225
|
+
setValue(formattedValue);
|
|
7175
7226
|
setAnchorEl(null);
|
|
7176
7227
|
},
|
|
7177
|
-
[setValue, setAnchorEl, format]
|
|
7228
|
+
[setValue, setAnchorEl, format, displayFormat, locale]
|
|
7178
7229
|
);
|
|
7179
7230
|
return /* @__PURE__ */ import_react50.default.createElement(MonthRangePickerRoot, null, /* @__PURE__ */ import_react50.default.createElement(import_base6.FocusTrap, { open: true }, /* @__PURE__ */ import_react50.default.createElement(import_react50.default.Fragment, null, /* @__PURE__ */ import_react50.default.createElement(
|
|
7180
7231
|
Input_default,
|
|
@@ -7183,14 +7234,22 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7183
7234
|
color: error ? "danger" : innerProps.color,
|
|
7184
7235
|
ref,
|
|
7185
7236
|
size,
|
|
7186
|
-
value,
|
|
7237
|
+
value: isAlphabeticDisplay ? displayValue : value,
|
|
7187
7238
|
onChange: handleChange,
|
|
7188
7239
|
disabled,
|
|
7189
7240
|
required,
|
|
7190
|
-
placeholder: `${
|
|
7241
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
7191
7242
|
slotProps: {
|
|
7192
|
-
input: {
|
|
7243
|
+
input: {
|
|
7244
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter9, format },
|
|
7245
|
+
ref: innerRef,
|
|
7246
|
+
...isAlphabeticDisplay ? {
|
|
7247
|
+
sx: { "&:hover": { cursor: "default" } },
|
|
7248
|
+
onMouseDown: handleInputMouseDown
|
|
7249
|
+
} : {}
|
|
7250
|
+
}
|
|
7193
7251
|
},
|
|
7252
|
+
readOnly: isAlphabeticDisplay || void 0,
|
|
7194
7253
|
error,
|
|
7195
7254
|
className,
|
|
7196
7255
|
sx: {
|
|
@@ -7201,6 +7260,7 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7201
7260
|
endDecorator: /* @__PURE__ */ import_react50.default.createElement(
|
|
7202
7261
|
IconButton_default,
|
|
7203
7262
|
{
|
|
7263
|
+
ref: buttonRef,
|
|
7204
7264
|
variant: "plain",
|
|
7205
7265
|
onClick: handleCalendarToggle,
|
|
7206
7266
|
"aria-label": "Toggle Calendar",
|