@ceed/ads 1.30.1 → 1.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/inputs/DatePicker.md +40 -20
- package/dist/components/inputs/DateRangePicker.md +36 -19
- package/dist/components/inputs/MonthPicker.md +49 -18
- package/dist/components/inputs/MonthRangePicker.md +34 -16
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +3 -3
- package/dist/index.cjs +105 -42
- package/dist/index.js +105 -42
- 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,
|
|
@@ -2908,7 +2916,8 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2908
2916
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
2909
2917
|
disableFuture,
|
|
2910
2918
|
disablePast,
|
|
2911
|
-
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0
|
|
2919
|
+
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0,
|
|
2920
|
+
locale
|
|
2912
2921
|
}
|
|
2913
2922
|
), !hideClearButton && /* @__PURE__ */ import_react20.default.createElement(
|
|
2914
2923
|
DialogActions_default,
|
|
@@ -4759,6 +4768,7 @@ var import_react_imask2 = require("react-imask");
|
|
|
4759
4768
|
var import_CalendarToday2 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
4760
4769
|
var import_joy36 = require("@mui/joy");
|
|
4761
4770
|
var import_base4 = require("@mui/base");
|
|
4771
|
+
var hasAlphabeticMonth2 = (format) => /MMMM|MMM/.test(format);
|
|
4762
4772
|
var CalendarButton2 = (0, import_joy36.styled)(IconButton_default, {
|
|
4763
4773
|
name: "DateRangePicker",
|
|
4764
4774
|
slot: "calendarButton"
|
|
@@ -4830,6 +4840,7 @@ var DateRangePickerRoot = (0, import_joy36.styled)("div", {
|
|
|
4830
4840
|
width: "100%"
|
|
4831
4841
|
});
|
|
4832
4842
|
var validValueFormat2 = (value, format) => {
|
|
4843
|
+
if (hasAlphabeticMonth2(format)) return true;
|
|
4833
4844
|
try {
|
|
4834
4845
|
const [date1Str, date2Str] = value.split(" - ");
|
|
4835
4846
|
if (!date1Str || !date2Str) {
|
|
@@ -4852,14 +4863,16 @@ var validValueFormat2 = (value, format) => {
|
|
|
4852
4863
|
return false;
|
|
4853
4864
|
}
|
|
4854
4865
|
};
|
|
4855
|
-
var formatValueString2 = ([date1, date2], format) => {
|
|
4866
|
+
var formatValueString2 = ([date1, date2], format, locale = "default") => {
|
|
4856
4867
|
const getStr = (date) => {
|
|
4857
4868
|
let day = `${date.getDate()}`;
|
|
4858
4869
|
let month = `${date.getMonth() + 1}`;
|
|
4859
4870
|
const year = date.getFullYear();
|
|
4860
4871
|
if (Number(day) < 10) day = "0" + day;
|
|
4861
4872
|
if (Number(month) < 10) month = "0" + month;
|
|
4862
|
-
|
|
4873
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
4874
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
4875
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
4863
4876
|
};
|
|
4864
4877
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
4865
4878
|
};
|
|
@@ -4947,6 +4960,7 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4947
4960
|
format = "YYYY/MM/DD",
|
|
4948
4961
|
displayFormat = "YYYY/MM/DD",
|
|
4949
4962
|
size,
|
|
4963
|
+
locale = "default",
|
|
4950
4964
|
inputReadOnly,
|
|
4951
4965
|
hideClearButton,
|
|
4952
4966
|
readOnly,
|
|
@@ -4960,8 +4974,9 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4960
4974
|
props.defaultValue || "",
|
|
4961
4975
|
(0, import_react29.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
4962
4976
|
);
|
|
4977
|
+
const isAlphabeticDisplay = hasAlphabeticMonth2(displayFormat);
|
|
4963
4978
|
const [displayValue, setDisplayValue] = (0, import_react29.useState)(
|
|
4964
|
-
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4979
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat, locale) : ""
|
|
4965
4980
|
);
|
|
4966
4981
|
const [anchorEl, setAnchorEl] = (0, import_react29.useState)(null);
|
|
4967
4982
|
const open = Boolean(anchorEl);
|
|
@@ -4973,14 +4988,14 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4973
4988
|
if (value) {
|
|
4974
4989
|
try {
|
|
4975
4990
|
const dates = parseDates(value, format);
|
|
4976
|
-
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4991
|
+
const newDisplayValue = formatValueString2(dates, displayFormat, locale);
|
|
4977
4992
|
setDisplayValue(newDisplayValue);
|
|
4978
4993
|
} catch (error2) {
|
|
4979
4994
|
}
|
|
4980
4995
|
} else {
|
|
4981
4996
|
setDisplayValue("");
|
|
4982
4997
|
}
|
|
4983
|
-
}, [displayFormat, value, format]);
|
|
4998
|
+
}, [displayFormat, locale, value, format]);
|
|
4984
4999
|
(0, import_react29.useEffect)(() => {
|
|
4985
5000
|
if (!anchorEl) {
|
|
4986
5001
|
innerRef.current?.blur();
|
|
@@ -4990,10 +5005,10 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4990
5005
|
const handleChange = (0, import_react29.useCallback)(
|
|
4991
5006
|
(event) => {
|
|
4992
5007
|
const value2 = event.target.value;
|
|
4993
|
-
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2);
|
|
5008
|
+
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat, locale) : value2);
|
|
4994
5009
|
setValue(value2);
|
|
4995
5010
|
},
|
|
4996
|
-
[displayFormat, format, setValue]
|
|
5011
|
+
[displayFormat, format, locale, setValue]
|
|
4997
5012
|
);
|
|
4998
5013
|
const handleDisplayInputChange = (0, import_react29.useCallback)(
|
|
4999
5014
|
(event) => {
|
|
@@ -5034,21 +5049,21 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5034
5049
|
if (props.value !== void 0) {
|
|
5035
5050
|
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
5036
5051
|
} else {
|
|
5037
|
-
setDisplayValue(formatValueString2([date1, date2], displayFormat));
|
|
5052
|
+
setDisplayValue(formatValueString2([date1, date2], displayFormat, locale));
|
|
5038
5053
|
setValue(formattedValue);
|
|
5039
5054
|
}
|
|
5040
5055
|
setAnchorEl(null);
|
|
5041
5056
|
},
|
|
5042
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
5057
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
5043
5058
|
);
|
|
5044
5059
|
const handleInputMouseDown = (0, import_react29.useCallback)(
|
|
5045
5060
|
(event) => {
|
|
5046
|
-
if (inputReadOnly) {
|
|
5061
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
5047
5062
|
event.preventDefault();
|
|
5048
5063
|
buttonRef.current?.focus();
|
|
5049
5064
|
}
|
|
5050
5065
|
},
|
|
5051
|
-
[inputReadOnly, buttonRef]
|
|
5066
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
5052
5067
|
);
|
|
5053
5068
|
const handlePresetClick = (0, import_react29.useCallback)(
|
|
5054
5069
|
(presetValue) => {
|
|
@@ -5056,12 +5071,12 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5056
5071
|
onChange?.({ target: { name: props.name, value: presetValue } });
|
|
5057
5072
|
} else {
|
|
5058
5073
|
const dates = parseDates(presetValue, format);
|
|
5059
|
-
setDisplayValue(formatValueString2(dates, displayFormat));
|
|
5074
|
+
setDisplayValue(formatValueString2(dates, displayFormat, locale));
|
|
5060
5075
|
setValue(presetValue);
|
|
5061
5076
|
}
|
|
5062
5077
|
setAnchorEl(null);
|
|
5063
5078
|
},
|
|
5064
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
5079
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
5065
5080
|
);
|
|
5066
5081
|
const isPresetDisabled = (0, import_react29.useCallback)(
|
|
5067
5082
|
(presetValue) => {
|
|
@@ -5096,12 +5111,11 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5096
5111
|
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
5097
5112
|
slotProps: {
|
|
5098
5113
|
input: {
|
|
5099
|
-
component: TextMaskAdapter5,
|
|
5114
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter5, format: displayFormat },
|
|
5100
5115
|
ref: innerRef,
|
|
5101
|
-
format: displayFormat,
|
|
5102
5116
|
sx: {
|
|
5103
5117
|
"&:hover": {
|
|
5104
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
5118
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
5105
5119
|
}
|
|
5106
5120
|
},
|
|
5107
5121
|
onMouseDown: handleInputMouseDown
|
|
@@ -5126,7 +5140,7 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5126
5140
|
),
|
|
5127
5141
|
label,
|
|
5128
5142
|
helperText,
|
|
5129
|
-
readOnly: readOnly || inputReadOnly
|
|
5143
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
5130
5144
|
}
|
|
5131
5145
|
), open && /* @__PURE__ */ import_react29.default.createElement(import_base4.ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ import_react29.default.createElement(
|
|
5132
5146
|
StyledPopper2,
|
|
@@ -5156,7 +5170,8 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5156
5170
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
5157
5171
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
5158
5172
|
disableFuture,
|
|
5159
|
-
disablePast
|
|
5173
|
+
disablePast,
|
|
5174
|
+
locale
|
|
5160
5175
|
}
|
|
5161
5176
|
), !hideClearButton && /* @__PURE__ */ import_react29.default.createElement(
|
|
5162
5177
|
DialogActions_default,
|
|
@@ -6809,8 +6824,9 @@ var formatValueString3 = (date, format, locale = "default") => {
|
|
|
6809
6824
|
const year = date.getFullYear().toString();
|
|
6810
6825
|
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
6811
6826
|
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
6827
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
6812
6828
|
const day = "01";
|
|
6813
|
-
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6829
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6814
6830
|
};
|
|
6815
6831
|
function parseDate3(dateString, format) {
|
|
6816
6832
|
const dateParts = dateString.split(/[-./\s]/);
|
|
@@ -7037,6 +7053,7 @@ var import_react_imask3 = require("react-imask");
|
|
|
7037
7053
|
var import_CalendarToday4 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
7038
7054
|
var import_joy62 = require("@mui/joy");
|
|
7039
7055
|
var import_base6 = require("@mui/base");
|
|
7056
|
+
var hasAlphabeticMonth3 = (format) => /MMMM|MMM/.test(format);
|
|
7040
7057
|
var StyledPopper4 = (0, import_joy62.styled)(import_base6.Popper, {
|
|
7041
7058
|
name: "MonthRangePicker",
|
|
7042
7059
|
slot: "popper"
|
|
@@ -7060,12 +7077,14 @@ var MonthRangePickerRoot = (0, import_joy62.styled)("div", {
|
|
|
7060
7077
|
})({
|
|
7061
7078
|
width: "100%"
|
|
7062
7079
|
});
|
|
7063
|
-
var formatValueString4 = ([date1, date2], format) => {
|
|
7080
|
+
var formatValueString4 = ([date1, date2], format, locale = "default") => {
|
|
7064
7081
|
const getStr = (date) => {
|
|
7065
7082
|
let month = `${date.getMonth() + 1}`;
|
|
7066
7083
|
const year = date.getFullYear();
|
|
7067
7084
|
if (Number(month) < 10) month = "0" + month;
|
|
7068
|
-
|
|
7085
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
7086
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
7087
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/YYYY/g, year.toString());
|
|
7069
7088
|
};
|
|
7070
7089
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
7071
7090
|
};
|
|
@@ -7137,18 +7156,38 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7137
7156
|
sx,
|
|
7138
7157
|
className,
|
|
7139
7158
|
format = "YYYY/MM",
|
|
7159
|
+
displayFormat: displayFormatProp,
|
|
7140
7160
|
size,
|
|
7161
|
+
locale = "default",
|
|
7141
7162
|
...innerProps
|
|
7142
7163
|
} = props;
|
|
7164
|
+
const displayFormat = displayFormatProp ?? format;
|
|
7165
|
+
const isAlphabeticDisplay = hasAlphabeticMonth3(displayFormat);
|
|
7143
7166
|
const innerRef = (0, import_react50.useRef)(null);
|
|
7167
|
+
const buttonRef = (0, import_react50.useRef)(null);
|
|
7144
7168
|
const [value, setValue] = useControlledState(
|
|
7145
7169
|
props.value,
|
|
7146
7170
|
props.defaultValue || "",
|
|
7147
7171
|
(0, import_react50.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
7148
7172
|
);
|
|
7173
|
+
const [displayValue, setDisplayValue] = (0, import_react50.useState)(
|
|
7174
|
+
() => value ? formatValueString4(parseDates2(value), displayFormat, locale) : ""
|
|
7175
|
+
);
|
|
7149
7176
|
const [anchorEl, setAnchorEl] = (0, import_react50.useState)(null);
|
|
7150
7177
|
const open = Boolean(anchorEl);
|
|
7151
7178
|
const calendarValue = (0, import_react50.useMemo)(() => value ? parseDates2(value) : void 0, [value]);
|
|
7179
|
+
(0, import_react50.useEffect)(() => {
|
|
7180
|
+
if (value) {
|
|
7181
|
+
try {
|
|
7182
|
+
const dates = parseDates2(value);
|
|
7183
|
+
const newDisplayValue = formatValueString4(dates, displayFormat, locale);
|
|
7184
|
+
setDisplayValue(newDisplayValue);
|
|
7185
|
+
} catch {
|
|
7186
|
+
}
|
|
7187
|
+
} else {
|
|
7188
|
+
setDisplayValue("");
|
|
7189
|
+
}
|
|
7190
|
+
}, [displayFormat, locale, value]);
|
|
7152
7191
|
(0, import_react50.useEffect)(() => {
|
|
7153
7192
|
if (!anchorEl) {
|
|
7154
7193
|
innerRef.current?.blur();
|
|
@@ -7157,9 +7196,21 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7157
7196
|
(0, import_react50.useImperativeHandle)(ref, () => innerRef.current, [innerRef]);
|
|
7158
7197
|
const handleChange = (0, import_react50.useCallback)(
|
|
7159
7198
|
(event) => {
|
|
7199
|
+
setDisplayValue(
|
|
7200
|
+
event.target.value ? formatValueString4(parseDates2(event.target.value), displayFormat, locale) : ""
|
|
7201
|
+
);
|
|
7160
7202
|
setValue(event.target.value);
|
|
7161
7203
|
},
|
|
7162
|
-
[setValue]
|
|
7204
|
+
[displayFormat, locale, setValue]
|
|
7205
|
+
);
|
|
7206
|
+
const handleInputMouseDown = (0, import_react50.useCallback)(
|
|
7207
|
+
(event) => {
|
|
7208
|
+
if (isAlphabeticDisplay) {
|
|
7209
|
+
event.preventDefault();
|
|
7210
|
+
buttonRef.current?.focus();
|
|
7211
|
+
}
|
|
7212
|
+
},
|
|
7213
|
+
[isAlphabeticDisplay, buttonRef]
|
|
7163
7214
|
);
|
|
7164
7215
|
const handleCalendarToggle = (0, import_react50.useCallback)(
|
|
7165
7216
|
(event) => {
|
|
@@ -7171,10 +7222,12 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7171
7222
|
const handleCalendarChange = (0, import_react50.useCallback)(
|
|
7172
7223
|
([date1, date2]) => {
|
|
7173
7224
|
if (!date1 || !date2) return;
|
|
7174
|
-
|
|
7225
|
+
const formattedValue = formatValueString4([date1, date2], format);
|
|
7226
|
+
setDisplayValue(formatValueString4([date1, date2], displayFormat, locale));
|
|
7227
|
+
setValue(formattedValue);
|
|
7175
7228
|
setAnchorEl(null);
|
|
7176
7229
|
},
|
|
7177
|
-
[setValue, setAnchorEl, format]
|
|
7230
|
+
[setValue, setAnchorEl, format, displayFormat, locale]
|
|
7178
7231
|
);
|
|
7179
7232
|
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
7233
|
Input_default,
|
|
@@ -7183,14 +7236,22 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7183
7236
|
color: error ? "danger" : innerProps.color,
|
|
7184
7237
|
ref,
|
|
7185
7238
|
size,
|
|
7186
|
-
value,
|
|
7239
|
+
value: isAlphabeticDisplay ? displayValue : value,
|
|
7187
7240
|
onChange: handleChange,
|
|
7188
7241
|
disabled,
|
|
7189
7242
|
required,
|
|
7190
|
-
placeholder: `${
|
|
7243
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
7191
7244
|
slotProps: {
|
|
7192
|
-
input: {
|
|
7245
|
+
input: {
|
|
7246
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter9, format },
|
|
7247
|
+
ref: innerRef,
|
|
7248
|
+
...isAlphabeticDisplay ? {
|
|
7249
|
+
sx: { "&:hover": { cursor: "default" } },
|
|
7250
|
+
onMouseDown: handleInputMouseDown
|
|
7251
|
+
} : {}
|
|
7252
|
+
}
|
|
7193
7253
|
},
|
|
7254
|
+
readOnly: isAlphabeticDisplay || void 0,
|
|
7194
7255
|
error,
|
|
7195
7256
|
className,
|
|
7196
7257
|
sx: {
|
|
@@ -7201,6 +7262,7 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7201
7262
|
endDecorator: /* @__PURE__ */ import_react50.default.createElement(
|
|
7202
7263
|
IconButton_default,
|
|
7203
7264
|
{
|
|
7265
|
+
ref: buttonRef,
|
|
7204
7266
|
variant: "plain",
|
|
7205
7267
|
onClick: handleCalendarToggle,
|
|
7206
7268
|
"aria-label": "Toggle Calendar",
|
|
@@ -7243,7 +7305,8 @@ var MonthRangePicker = (0, import_react50.forwardRef)((inProps, ref) => {
|
|
|
7243
7305
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
7244
7306
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
7245
7307
|
disableFuture,
|
|
7246
|
-
disablePast
|
|
7308
|
+
disablePast,
|
|
7309
|
+
locale
|
|
7247
7310
|
}
|
|
7248
7311
|
), /* @__PURE__ */ import_react50.default.createElement(
|
|
7249
7312
|
DialogActions_default,
|