@ceed/cds 1.29.1 → 1.30.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/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 +43 -25
- package/dist/components/inputs/DateRangePicker.md +39 -24
- package/dist/components/inputs/MonthPicker.md +52 -23
- package/dist/components/inputs/MonthRangePicker.md +37 -21
- 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
|
@@ -895,6 +895,9 @@ var getMonthName = (date, locale, options) => {
|
|
|
895
895
|
...options?.hideYear ? {} : { year: "numeric" }
|
|
896
896
|
});
|
|
897
897
|
};
|
|
898
|
+
var getShortMonthName = (date, locale) => {
|
|
899
|
+
return date.toLocaleString(locale, { month: "short" });
|
|
900
|
+
};
|
|
898
901
|
var getMonthNameFromIndex = (index, locale) => {
|
|
899
902
|
return new Date(0, index).toLocaleString(locale, { month: "short" });
|
|
900
903
|
};
|
|
@@ -2538,6 +2541,7 @@ DialogActions.displayName = "DialogActions";
|
|
|
2538
2541
|
var DialogActions_default = DialogActions;
|
|
2539
2542
|
|
|
2540
2543
|
// src/components/DatePicker/DatePicker.tsx
|
|
2544
|
+
var hasAlphabeticMonth = (format) => /MMMM|MMM/.test(format);
|
|
2541
2545
|
var CalendarButton = (0, import_joy28.styled)(IconButton_default, {
|
|
2542
2546
|
name: "DatePicker",
|
|
2543
2547
|
slot: "calendarButton"
|
|
@@ -2608,6 +2612,7 @@ var DatePickerRoot = (0, import_joy28.styled)("div", {
|
|
|
2608
2612
|
width: "100%"
|
|
2609
2613
|
});
|
|
2610
2614
|
var validValueFormat = (value, format) => {
|
|
2615
|
+
if (hasAlphabeticMonth(format)) return true;
|
|
2611
2616
|
try {
|
|
2612
2617
|
const parsedValue = parseDate(value, format);
|
|
2613
2618
|
if (parsedValue.toString() === "Invalid Date") {
|
|
@@ -2622,13 +2627,15 @@ var validValueFormat = (value, format) => {
|
|
|
2622
2627
|
return false;
|
|
2623
2628
|
}
|
|
2624
2629
|
};
|
|
2625
|
-
var formatValueString = (date, format) => {
|
|
2630
|
+
var formatValueString = (date, format, locale = "default") => {
|
|
2626
2631
|
let day = `${date.getDate()}`;
|
|
2627
2632
|
let month = `${date.getMonth() + 1}`;
|
|
2628
2633
|
const year = date.getFullYear();
|
|
2629
2634
|
if (Number(day) < 10) day = "0" + day;
|
|
2630
2635
|
if (Number(month) < 10) month = "0" + month;
|
|
2631
|
-
|
|
2636
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
2637
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
2638
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
2632
2639
|
};
|
|
2633
2640
|
function parseDate(dateString, format) {
|
|
2634
2641
|
const formatParts = format.split(/[-./\s]/);
|
|
@@ -2713,6 +2720,7 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2713
2720
|
format = "YYYY/MM/DD",
|
|
2714
2721
|
displayFormat = "YYYY/MM/DD",
|
|
2715
2722
|
size,
|
|
2723
|
+
locale = "default",
|
|
2716
2724
|
inputReadOnly,
|
|
2717
2725
|
hideClearButton,
|
|
2718
2726
|
readOnly,
|
|
@@ -2727,8 +2735,9 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2727
2735
|
props.defaultValue || "",
|
|
2728
2736
|
(0, import_react20.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
2729
2737
|
);
|
|
2738
|
+
const isAlphabeticDisplay = hasAlphabeticMonth(displayFormat);
|
|
2730
2739
|
const [displayValue, setDisplayValue] = (0, import_react20.useState)(
|
|
2731
|
-
() => value ? formatValueString(parseDate(value, format), displayFormat) : ""
|
|
2740
|
+
() => value ? formatValueString(parseDate(value, format), displayFormat, locale) : ""
|
|
2732
2741
|
);
|
|
2733
2742
|
const [anchorEl, setAnchorEl] = (0, import_react20.useState)(null);
|
|
2734
2743
|
const open = Boolean(anchorEl);
|
|
@@ -2742,19 +2751,19 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2742
2751
|
setDisplayValue("");
|
|
2743
2752
|
return;
|
|
2744
2753
|
}
|
|
2745
|
-
const formattedValue = formatValueString(parseDate(value, format), displayFormat);
|
|
2754
|
+
const formattedValue = formatValueString(parseDate(value, format), displayFormat, locale);
|
|
2746
2755
|
if (validValueFormat(formattedValue, displayFormat) && formattedValue !== displayValue) {
|
|
2747
2756
|
setDisplayValue(formattedValue);
|
|
2748
2757
|
}
|
|
2749
|
-
}, [displayFormat, displayValue, format, value]);
|
|
2758
|
+
}, [displayFormat, displayValue, format, locale, value]);
|
|
2750
2759
|
(0, import_react20.useImperativeHandle)(ref, () => innerRef.current, [innerRef]);
|
|
2751
2760
|
const handleChange = (0, import_react20.useCallback)(
|
|
2752
2761
|
(event) => {
|
|
2753
2762
|
const value2 = event.target.value;
|
|
2754
|
-
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2);
|
|
2763
|
+
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat, locale) : value2);
|
|
2755
2764
|
setValue(value2);
|
|
2756
2765
|
},
|
|
2757
|
-
[displayFormat, format, setValue]
|
|
2766
|
+
[displayFormat, format, locale, setValue]
|
|
2758
2767
|
);
|
|
2759
2768
|
const handleDisplayInputChange = (0, import_react20.useCallback)(
|
|
2760
2769
|
(event) => {
|
|
@@ -2792,12 +2801,12 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2792
2801
|
);
|
|
2793
2802
|
const handleInputMouseDown = (0, import_react20.useCallback)(
|
|
2794
2803
|
(event) => {
|
|
2795
|
-
if (inputReadOnly) {
|
|
2804
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
2796
2805
|
event.preventDefault();
|
|
2797
2806
|
buttonRef.current?.focus();
|
|
2798
2807
|
}
|
|
2799
2808
|
},
|
|
2800
|
-
[inputReadOnly, buttonRef]
|
|
2809
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
2801
2810
|
);
|
|
2802
2811
|
const handlePresetClick = (0, import_react20.useCallback)(
|
|
2803
2812
|
(presetValue) => {
|
|
@@ -2843,12 +2852,11 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2843
2852
|
error,
|
|
2844
2853
|
slotProps: {
|
|
2845
2854
|
input: {
|
|
2846
|
-
component: TextMaskAdapter3,
|
|
2855
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter3, format: displayFormat },
|
|
2847
2856
|
ref: innerRef,
|
|
2848
|
-
format: displayFormat,
|
|
2849
2857
|
sx: {
|
|
2850
2858
|
"&:hover": {
|
|
2851
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
2859
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
2852
2860
|
}
|
|
2853
2861
|
},
|
|
2854
2862
|
onMouseDown: handleInputMouseDown
|
|
@@ -2872,7 +2880,7 @@ var DatePicker = (0, import_react20.forwardRef)((inProps, ref) => {
|
|
|
2872
2880
|
),
|
|
2873
2881
|
label,
|
|
2874
2882
|
helperText,
|
|
2875
|
-
readOnly: readOnly || inputReadOnly
|
|
2883
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
2876
2884
|
}
|
|
2877
2885
|
), open && /* @__PURE__ */ import_react20.default.createElement(import_base3.ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ import_react20.default.createElement(
|
|
2878
2886
|
StyledPopper,
|
|
@@ -4761,6 +4769,7 @@ var import_react_imask2 = require("react-imask");
|
|
|
4761
4769
|
var import_CalendarToday2 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
4762
4770
|
var import_joy36 = require("@mui/joy");
|
|
4763
4771
|
var import_base4 = require("@mui/base");
|
|
4772
|
+
var hasAlphabeticMonth2 = (format) => /MMMM|MMM/.test(format);
|
|
4764
4773
|
var CalendarButton2 = (0, import_joy36.styled)(IconButton_default, {
|
|
4765
4774
|
name: "DateRangePicker",
|
|
4766
4775
|
slot: "calendarButton"
|
|
@@ -4832,6 +4841,7 @@ var DateRangePickerRoot = (0, import_joy36.styled)("div", {
|
|
|
4832
4841
|
width: "100%"
|
|
4833
4842
|
});
|
|
4834
4843
|
var validValueFormat2 = (value, format) => {
|
|
4844
|
+
if (hasAlphabeticMonth2(format)) return true;
|
|
4835
4845
|
try {
|
|
4836
4846
|
const [date1Str, date2Str] = value.split(" - ");
|
|
4837
4847
|
if (!date1Str || !date2Str) {
|
|
@@ -4854,14 +4864,16 @@ var validValueFormat2 = (value, format) => {
|
|
|
4854
4864
|
return false;
|
|
4855
4865
|
}
|
|
4856
4866
|
};
|
|
4857
|
-
var formatValueString2 = ([date1, date2], format) => {
|
|
4867
|
+
var formatValueString2 = ([date1, date2], format, locale = "default") => {
|
|
4858
4868
|
const getStr = (date) => {
|
|
4859
4869
|
let day = `${date.getDate()}`;
|
|
4860
4870
|
let month = `${date.getMonth() + 1}`;
|
|
4861
4871
|
const year = date.getFullYear();
|
|
4862
4872
|
if (Number(day) < 10) day = "0" + day;
|
|
4863
4873
|
if (Number(month) < 10) month = "0" + month;
|
|
4864
|
-
|
|
4874
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
4875
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
4876
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
4865
4877
|
};
|
|
4866
4878
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
4867
4879
|
};
|
|
@@ -4949,6 +4961,7 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4949
4961
|
format = "YYYY/MM/DD",
|
|
4950
4962
|
displayFormat = "YYYY/MM/DD",
|
|
4951
4963
|
size,
|
|
4964
|
+
locale = "default",
|
|
4952
4965
|
inputReadOnly,
|
|
4953
4966
|
hideClearButton,
|
|
4954
4967
|
readOnly,
|
|
@@ -4962,8 +4975,9 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4962
4975
|
props.defaultValue || "",
|
|
4963
4976
|
(0, import_react29.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
4964
4977
|
);
|
|
4978
|
+
const isAlphabeticDisplay = hasAlphabeticMonth2(displayFormat);
|
|
4965
4979
|
const [displayValue, setDisplayValue] = (0, import_react29.useState)(
|
|
4966
|
-
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4980
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat, locale) : ""
|
|
4967
4981
|
);
|
|
4968
4982
|
const [anchorEl, setAnchorEl] = (0, import_react29.useState)(null);
|
|
4969
4983
|
const open = Boolean(anchorEl);
|
|
@@ -4975,14 +4989,14 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4975
4989
|
if (value) {
|
|
4976
4990
|
try {
|
|
4977
4991
|
const dates = parseDates(value, format);
|
|
4978
|
-
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4992
|
+
const newDisplayValue = formatValueString2(dates, displayFormat, locale);
|
|
4979
4993
|
setDisplayValue(newDisplayValue);
|
|
4980
4994
|
} catch (error2) {
|
|
4981
4995
|
}
|
|
4982
4996
|
} else {
|
|
4983
4997
|
setDisplayValue("");
|
|
4984
4998
|
}
|
|
4985
|
-
}, [displayFormat, value, format]);
|
|
4999
|
+
}, [displayFormat, locale, value, format]);
|
|
4986
5000
|
(0, import_react29.useEffect)(() => {
|
|
4987
5001
|
if (!anchorEl) {
|
|
4988
5002
|
innerRef.current?.blur();
|
|
@@ -4992,10 +5006,10 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
4992
5006
|
const handleChange = (0, import_react29.useCallback)(
|
|
4993
5007
|
(event) => {
|
|
4994
5008
|
const value2 = event.target.value;
|
|
4995
|
-
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2);
|
|
5009
|
+
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat, locale) : value2);
|
|
4996
5010
|
setValue(value2);
|
|
4997
5011
|
},
|
|
4998
|
-
[displayFormat, format, setValue]
|
|
5012
|
+
[displayFormat, format, locale, setValue]
|
|
4999
5013
|
);
|
|
5000
5014
|
const handleDisplayInputChange = (0, import_react29.useCallback)(
|
|
5001
5015
|
(event) => {
|
|
@@ -5036,21 +5050,21 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5036
5050
|
if (props.value !== void 0) {
|
|
5037
5051
|
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
5038
5052
|
} else {
|
|
5039
|
-
setDisplayValue(formatValueString2([date1, date2], displayFormat));
|
|
5053
|
+
setDisplayValue(formatValueString2([date1, date2], displayFormat, locale));
|
|
5040
5054
|
setValue(formattedValue);
|
|
5041
5055
|
}
|
|
5042
5056
|
setAnchorEl(null);
|
|
5043
5057
|
},
|
|
5044
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
5058
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
5045
5059
|
);
|
|
5046
5060
|
const handleInputMouseDown = (0, import_react29.useCallback)(
|
|
5047
5061
|
(event) => {
|
|
5048
|
-
if (inputReadOnly) {
|
|
5062
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
5049
5063
|
event.preventDefault();
|
|
5050
5064
|
buttonRef.current?.focus();
|
|
5051
5065
|
}
|
|
5052
5066
|
},
|
|
5053
|
-
[inputReadOnly, buttonRef]
|
|
5067
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
5054
5068
|
);
|
|
5055
5069
|
const handlePresetClick = (0, import_react29.useCallback)(
|
|
5056
5070
|
(presetValue) => {
|
|
@@ -5058,12 +5072,12 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5058
5072
|
onChange?.({ target: { name: props.name, value: presetValue } });
|
|
5059
5073
|
} else {
|
|
5060
5074
|
const dates = parseDates(presetValue, format);
|
|
5061
|
-
setDisplayValue(formatValueString2(dates, displayFormat));
|
|
5075
|
+
setDisplayValue(formatValueString2(dates, displayFormat, locale));
|
|
5062
5076
|
setValue(presetValue);
|
|
5063
5077
|
}
|
|
5064
5078
|
setAnchorEl(null);
|
|
5065
5079
|
},
|
|
5066
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
5080
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
5067
5081
|
);
|
|
5068
5082
|
const isPresetDisabled = (0, import_react29.useCallback)(
|
|
5069
5083
|
(presetValue) => {
|
|
@@ -5098,12 +5112,11 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5098
5112
|
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
5099
5113
|
slotProps: {
|
|
5100
5114
|
input: {
|
|
5101
|
-
component: TextMaskAdapter5,
|
|
5115
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter5, format: displayFormat },
|
|
5102
5116
|
ref: innerRef,
|
|
5103
|
-
format: displayFormat,
|
|
5104
5117
|
sx: {
|
|
5105
5118
|
"&:hover": {
|
|
5106
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
5119
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
5107
5120
|
}
|
|
5108
5121
|
},
|
|
5109
5122
|
onMouseDown: handleInputMouseDown
|
|
@@ -5128,7 +5141,7 @@ var DateRangePicker = (0, import_react29.forwardRef)((inProps, ref) => {
|
|
|
5128
5141
|
),
|
|
5129
5142
|
label,
|
|
5130
5143
|
helperText,
|
|
5131
|
-
readOnly: readOnly || inputReadOnly
|
|
5144
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
5132
5145
|
}
|
|
5133
5146
|
), open && /* @__PURE__ */ import_react29.default.createElement(import_base4.ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ import_react29.default.createElement(
|
|
5134
5147
|
StyledPopper2,
|
|
@@ -5803,8 +5816,9 @@ var formatValueString3 = (date, format, locale = "default") => {
|
|
|
5803
5816
|
const year = date.getFullYear().toString();
|
|
5804
5817
|
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
5805
5818
|
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
5819
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
5806
5820
|
const day = "01";
|
|
5807
|
-
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
5821
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
5808
5822
|
};
|
|
5809
5823
|
function parseDate3(dateString, format) {
|
|
5810
5824
|
const dateParts = dateString.split(/[-./\s]/);
|
|
@@ -6031,6 +6045,7 @@ var import_react_imask3 = require("react-imask");
|
|
|
6031
6045
|
var import_CalendarToday4 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
6032
6046
|
var import_joy50 = require("@mui/joy");
|
|
6033
6047
|
var import_base6 = require("@mui/base");
|
|
6048
|
+
var hasAlphabeticMonth3 = (format) => /MMMM|MMM/.test(format);
|
|
6034
6049
|
var StyledPopper4 = (0, import_joy50.styled)(import_base6.Popper, {
|
|
6035
6050
|
name: "MonthRangePicker",
|
|
6036
6051
|
slot: "popper"
|
|
@@ -6054,12 +6069,14 @@ var MonthRangePickerRoot = (0, import_joy50.styled)("div", {
|
|
|
6054
6069
|
})({
|
|
6055
6070
|
width: "100%"
|
|
6056
6071
|
});
|
|
6057
|
-
var formatValueString4 = ([date1, date2], format) => {
|
|
6072
|
+
var formatValueString4 = ([date1, date2], format, locale = "default") => {
|
|
6058
6073
|
const getStr = (date) => {
|
|
6059
6074
|
let month = `${date.getMonth() + 1}`;
|
|
6060
6075
|
const year = date.getFullYear();
|
|
6061
6076
|
if (Number(month) < 10) month = "0" + month;
|
|
6062
|
-
|
|
6077
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
6078
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
6079
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/YYYY/g, year.toString());
|
|
6063
6080
|
};
|
|
6064
6081
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
6065
6082
|
};
|
|
@@ -6131,18 +6148,38 @@ var MonthRangePicker = (0, import_react39.forwardRef)((inProps, ref) => {
|
|
|
6131
6148
|
sx,
|
|
6132
6149
|
className,
|
|
6133
6150
|
format = "YYYY/MM",
|
|
6151
|
+
displayFormat: displayFormatProp,
|
|
6134
6152
|
size,
|
|
6153
|
+
locale = "default",
|
|
6135
6154
|
...innerProps
|
|
6136
6155
|
} = props;
|
|
6156
|
+
const displayFormat = displayFormatProp ?? format;
|
|
6157
|
+
const isAlphabeticDisplay = hasAlphabeticMonth3(displayFormat);
|
|
6137
6158
|
const innerRef = (0, import_react39.useRef)(null);
|
|
6159
|
+
const buttonRef = (0, import_react39.useRef)(null);
|
|
6138
6160
|
const [value, setValue] = useControlledState(
|
|
6139
6161
|
props.value,
|
|
6140
6162
|
props.defaultValue || "",
|
|
6141
6163
|
(0, import_react39.useCallback)((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
6142
6164
|
);
|
|
6165
|
+
const [displayValue, setDisplayValue] = (0, import_react39.useState)(
|
|
6166
|
+
() => value ? formatValueString4(parseDates2(value), displayFormat, locale) : ""
|
|
6167
|
+
);
|
|
6143
6168
|
const [anchorEl, setAnchorEl] = (0, import_react39.useState)(null);
|
|
6144
6169
|
const open = Boolean(anchorEl);
|
|
6145
6170
|
const calendarValue = (0, import_react39.useMemo)(() => value ? parseDates2(value) : void 0, [value]);
|
|
6171
|
+
(0, import_react39.useEffect)(() => {
|
|
6172
|
+
if (value) {
|
|
6173
|
+
try {
|
|
6174
|
+
const dates = parseDates2(value);
|
|
6175
|
+
const newDisplayValue = formatValueString4(dates, displayFormat, locale);
|
|
6176
|
+
setDisplayValue(newDisplayValue);
|
|
6177
|
+
} catch {
|
|
6178
|
+
}
|
|
6179
|
+
} else {
|
|
6180
|
+
setDisplayValue("");
|
|
6181
|
+
}
|
|
6182
|
+
}, [displayFormat, locale, value]);
|
|
6146
6183
|
(0, import_react39.useEffect)(() => {
|
|
6147
6184
|
if (!anchorEl) {
|
|
6148
6185
|
innerRef.current?.blur();
|
|
@@ -6151,9 +6188,21 @@ var MonthRangePicker = (0, import_react39.forwardRef)((inProps, ref) => {
|
|
|
6151
6188
|
(0, import_react39.useImperativeHandle)(ref, () => innerRef.current, [innerRef]);
|
|
6152
6189
|
const handleChange = (0, import_react39.useCallback)(
|
|
6153
6190
|
(event) => {
|
|
6191
|
+
setDisplayValue(
|
|
6192
|
+
event.target.value ? formatValueString4(parseDates2(event.target.value), displayFormat, locale) : ""
|
|
6193
|
+
);
|
|
6154
6194
|
setValue(event.target.value);
|
|
6155
6195
|
},
|
|
6156
|
-
[setValue]
|
|
6196
|
+
[displayFormat, locale, setValue]
|
|
6197
|
+
);
|
|
6198
|
+
const handleInputMouseDown = (0, import_react39.useCallback)(
|
|
6199
|
+
(event) => {
|
|
6200
|
+
if (isAlphabeticDisplay) {
|
|
6201
|
+
event.preventDefault();
|
|
6202
|
+
buttonRef.current?.focus();
|
|
6203
|
+
}
|
|
6204
|
+
},
|
|
6205
|
+
[isAlphabeticDisplay, buttonRef]
|
|
6157
6206
|
);
|
|
6158
6207
|
const handleCalendarToggle = (0, import_react39.useCallback)(
|
|
6159
6208
|
(event) => {
|
|
@@ -6165,10 +6214,12 @@ var MonthRangePicker = (0, import_react39.forwardRef)((inProps, ref) => {
|
|
|
6165
6214
|
const handleCalendarChange = (0, import_react39.useCallback)(
|
|
6166
6215
|
([date1, date2]) => {
|
|
6167
6216
|
if (!date1 || !date2) return;
|
|
6168
|
-
|
|
6217
|
+
const formattedValue = formatValueString4([date1, date2], format);
|
|
6218
|
+
setDisplayValue(formatValueString4([date1, date2], displayFormat, locale));
|
|
6219
|
+
setValue(formattedValue);
|
|
6169
6220
|
setAnchorEl(null);
|
|
6170
6221
|
},
|
|
6171
|
-
[setValue, setAnchorEl, format]
|
|
6222
|
+
[setValue, setAnchorEl, format, displayFormat, locale]
|
|
6172
6223
|
);
|
|
6173
6224
|
return /* @__PURE__ */ import_react39.default.createElement(MonthRangePickerRoot, null, /* @__PURE__ */ import_react39.default.createElement(import_base6.FocusTrap, { open: true }, /* @__PURE__ */ import_react39.default.createElement(import_react39.default.Fragment, null, /* @__PURE__ */ import_react39.default.createElement(
|
|
6174
6225
|
Input_default,
|
|
@@ -6177,14 +6228,22 @@ var MonthRangePicker = (0, import_react39.forwardRef)((inProps, ref) => {
|
|
|
6177
6228
|
color: error ? "danger" : innerProps.color,
|
|
6178
6229
|
ref,
|
|
6179
6230
|
size,
|
|
6180
|
-
value,
|
|
6231
|
+
value: isAlphabeticDisplay ? displayValue : value,
|
|
6181
6232
|
onChange: handleChange,
|
|
6182
6233
|
disabled,
|
|
6183
6234
|
required,
|
|
6184
|
-
placeholder: `${
|
|
6235
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
6185
6236
|
slotProps: {
|
|
6186
|
-
input: {
|
|
6237
|
+
input: {
|
|
6238
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter7, format },
|
|
6239
|
+
ref: innerRef,
|
|
6240
|
+
...isAlphabeticDisplay ? {
|
|
6241
|
+
sx: { "&:hover": { cursor: "default" } },
|
|
6242
|
+
onMouseDown: handleInputMouseDown
|
|
6243
|
+
} : {}
|
|
6244
|
+
}
|
|
6187
6245
|
},
|
|
6246
|
+
readOnly: isAlphabeticDisplay || void 0,
|
|
6188
6247
|
error,
|
|
6189
6248
|
className,
|
|
6190
6249
|
sx: {
|
|
@@ -6195,6 +6254,7 @@ var MonthRangePicker = (0, import_react39.forwardRef)((inProps, ref) => {
|
|
|
6195
6254
|
endDecorator: /* @__PURE__ */ import_react39.default.createElement(
|
|
6196
6255
|
IconButton_default,
|
|
6197
6256
|
{
|
|
6257
|
+
ref: buttonRef,
|
|
6198
6258
|
variant: "plain",
|
|
6199
6259
|
onClick: handleCalendarToggle,
|
|
6200
6260
|
"aria-label": "Toggle Calendar",
|