@ceed/cds 1.29.1 → 1.30.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 +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 +105 -42
- package/dist/index.js +105 -42
- package/framer/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -755,6 +755,9 @@ var getMonthName = (date, locale, options) => {
|
|
|
755
755
|
...options?.hideYear ? {} : { year: "numeric" }
|
|
756
756
|
});
|
|
757
757
|
};
|
|
758
|
+
var getShortMonthName = (date, locale) => {
|
|
759
|
+
return date.toLocaleString(locale, { month: "short" });
|
|
760
|
+
};
|
|
758
761
|
var getMonthNameFromIndex = (index, locale) => {
|
|
759
762
|
return new Date(0, index).toLocaleString(locale, { month: "short" });
|
|
760
763
|
};
|
|
@@ -2421,6 +2424,7 @@ DialogActions.displayName = "DialogActions";
|
|
|
2421
2424
|
var DialogActions_default = DialogActions;
|
|
2422
2425
|
|
|
2423
2426
|
// src/components/DatePicker/DatePicker.tsx
|
|
2427
|
+
var hasAlphabeticMonth = (format) => /MMMM|MMM/.test(format);
|
|
2424
2428
|
var CalendarButton = styled10(IconButton_default, {
|
|
2425
2429
|
name: "DatePicker",
|
|
2426
2430
|
slot: "calendarButton"
|
|
@@ -2491,6 +2495,7 @@ var DatePickerRoot = styled10("div", {
|
|
|
2491
2495
|
width: "100%"
|
|
2492
2496
|
});
|
|
2493
2497
|
var validValueFormat = (value, format) => {
|
|
2498
|
+
if (hasAlphabeticMonth(format)) return true;
|
|
2494
2499
|
try {
|
|
2495
2500
|
const parsedValue = parseDate(value, format);
|
|
2496
2501
|
if (parsedValue.toString() === "Invalid Date") {
|
|
@@ -2505,13 +2510,15 @@ var validValueFormat = (value, format) => {
|
|
|
2505
2510
|
return false;
|
|
2506
2511
|
}
|
|
2507
2512
|
};
|
|
2508
|
-
var formatValueString = (date, format) => {
|
|
2513
|
+
var formatValueString = (date, format, locale = "default") => {
|
|
2509
2514
|
let day = `${date.getDate()}`;
|
|
2510
2515
|
let month = `${date.getMonth() + 1}`;
|
|
2511
2516
|
const year = date.getFullYear();
|
|
2512
2517
|
if (Number(day) < 10) day = "0" + day;
|
|
2513
2518
|
if (Number(month) < 10) month = "0" + month;
|
|
2514
|
-
|
|
2519
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
2520
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
2521
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
2515
2522
|
};
|
|
2516
2523
|
function parseDate(dateString, format) {
|
|
2517
2524
|
const formatParts = format.split(/[-./\s]/);
|
|
@@ -2596,6 +2603,7 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2596
2603
|
format = "YYYY/MM/DD",
|
|
2597
2604
|
displayFormat = "YYYY/MM/DD",
|
|
2598
2605
|
size,
|
|
2606
|
+
locale = "default",
|
|
2599
2607
|
inputReadOnly,
|
|
2600
2608
|
hideClearButton,
|
|
2601
2609
|
readOnly,
|
|
@@ -2610,8 +2618,9 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2610
2618
|
props.defaultValue || "",
|
|
2611
2619
|
useCallback8((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
2612
2620
|
);
|
|
2621
|
+
const isAlphabeticDisplay = hasAlphabeticMonth(displayFormat);
|
|
2613
2622
|
const [displayValue, setDisplayValue] = useState7(
|
|
2614
|
-
() => value ? formatValueString(parseDate(value, format), displayFormat) : ""
|
|
2623
|
+
() => value ? formatValueString(parseDate(value, format), displayFormat, locale) : ""
|
|
2615
2624
|
);
|
|
2616
2625
|
const [anchorEl, setAnchorEl] = useState7(null);
|
|
2617
2626
|
const open = Boolean(anchorEl);
|
|
@@ -2625,19 +2634,19 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2625
2634
|
setDisplayValue("");
|
|
2626
2635
|
return;
|
|
2627
2636
|
}
|
|
2628
|
-
const formattedValue = formatValueString(parseDate(value, format), displayFormat);
|
|
2637
|
+
const formattedValue = formatValueString(parseDate(value, format), displayFormat, locale);
|
|
2629
2638
|
if (validValueFormat(formattedValue, displayFormat) && formattedValue !== displayValue) {
|
|
2630
2639
|
setDisplayValue(formattedValue);
|
|
2631
2640
|
}
|
|
2632
|
-
}, [displayFormat, displayValue, format, value]);
|
|
2641
|
+
}, [displayFormat, displayValue, format, locale, value]);
|
|
2633
2642
|
useImperativeHandle(ref, () => innerRef.current, [innerRef]);
|
|
2634
2643
|
const handleChange = useCallback8(
|
|
2635
2644
|
(event) => {
|
|
2636
2645
|
const value2 = event.target.value;
|
|
2637
|
-
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2);
|
|
2646
|
+
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat, locale) : value2);
|
|
2638
2647
|
setValue(value2);
|
|
2639
2648
|
},
|
|
2640
|
-
[displayFormat, format, setValue]
|
|
2649
|
+
[displayFormat, format, locale, setValue]
|
|
2641
2650
|
);
|
|
2642
2651
|
const handleDisplayInputChange = useCallback8(
|
|
2643
2652
|
(event) => {
|
|
@@ -2675,12 +2684,12 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2675
2684
|
);
|
|
2676
2685
|
const handleInputMouseDown = useCallback8(
|
|
2677
2686
|
(event) => {
|
|
2678
|
-
if (inputReadOnly) {
|
|
2687
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
2679
2688
|
event.preventDefault();
|
|
2680
2689
|
buttonRef.current?.focus();
|
|
2681
2690
|
}
|
|
2682
2691
|
},
|
|
2683
|
-
[inputReadOnly, buttonRef]
|
|
2692
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
2684
2693
|
);
|
|
2685
2694
|
const handlePresetClick = useCallback8(
|
|
2686
2695
|
(presetValue) => {
|
|
@@ -2726,12 +2735,11 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2726
2735
|
error,
|
|
2727
2736
|
slotProps: {
|
|
2728
2737
|
input: {
|
|
2729
|
-
component: TextMaskAdapter3,
|
|
2738
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter3, format: displayFormat },
|
|
2730
2739
|
ref: innerRef,
|
|
2731
|
-
format: displayFormat,
|
|
2732
2740
|
sx: {
|
|
2733
2741
|
"&:hover": {
|
|
2734
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
2742
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
2735
2743
|
}
|
|
2736
2744
|
},
|
|
2737
2745
|
onMouseDown: handleInputMouseDown
|
|
@@ -2755,7 +2763,7 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2755
2763
|
),
|
|
2756
2764
|
label,
|
|
2757
2765
|
helperText,
|
|
2758
|
-
readOnly: readOnly || inputReadOnly
|
|
2766
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
2759
2767
|
}
|
|
2760
2768
|
), open && /* @__PURE__ */ React18.createElement(ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ React18.createElement(
|
|
2761
2769
|
StyledPopper,
|
|
@@ -2793,7 +2801,8 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2793
2801
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
2794
2802
|
disableFuture,
|
|
2795
2803
|
disablePast,
|
|
2796
|
-
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0
|
|
2804
|
+
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0,
|
|
2805
|
+
locale
|
|
2797
2806
|
}
|
|
2798
2807
|
), !hideClearButton && /* @__PURE__ */ React18.createElement(
|
|
2799
2808
|
DialogActions_default,
|
|
@@ -4644,6 +4653,7 @@ import { IMaskInput as IMaskInput2, IMask as IMask2 } from "react-imask";
|
|
|
4644
4653
|
import CalendarTodayIcon2 from "@mui/icons-material/CalendarToday";
|
|
4645
4654
|
import { styled as styled14, useThemeProps as useThemeProps5 } from "@mui/joy";
|
|
4646
4655
|
import { FocusTrap as FocusTrap2, ClickAwayListener as ClickAwayListener2, Popper as Popper3 } from "@mui/base";
|
|
4656
|
+
var hasAlphabeticMonth2 = (format) => /MMMM|MMM/.test(format);
|
|
4647
4657
|
var CalendarButton2 = styled14(IconButton_default, {
|
|
4648
4658
|
name: "DateRangePicker",
|
|
4649
4659
|
slot: "calendarButton"
|
|
@@ -4715,6 +4725,7 @@ var DateRangePickerRoot = styled14("div", {
|
|
|
4715
4725
|
width: "100%"
|
|
4716
4726
|
});
|
|
4717
4727
|
var validValueFormat2 = (value, format) => {
|
|
4728
|
+
if (hasAlphabeticMonth2(format)) return true;
|
|
4718
4729
|
try {
|
|
4719
4730
|
const [date1Str, date2Str] = value.split(" - ");
|
|
4720
4731
|
if (!date1Str || !date2Str) {
|
|
@@ -4737,14 +4748,16 @@ var validValueFormat2 = (value, format) => {
|
|
|
4737
4748
|
return false;
|
|
4738
4749
|
}
|
|
4739
4750
|
};
|
|
4740
|
-
var formatValueString2 = ([date1, date2], format) => {
|
|
4751
|
+
var formatValueString2 = ([date1, date2], format, locale = "default") => {
|
|
4741
4752
|
const getStr = (date) => {
|
|
4742
4753
|
let day = `${date.getDate()}`;
|
|
4743
4754
|
let month = `${date.getMonth() + 1}`;
|
|
4744
4755
|
const year = date.getFullYear();
|
|
4745
4756
|
if (Number(day) < 10) day = "0" + day;
|
|
4746
4757
|
if (Number(month) < 10) month = "0" + month;
|
|
4747
|
-
|
|
4758
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
4759
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
4760
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
4748
4761
|
};
|
|
4749
4762
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
4750
4763
|
};
|
|
@@ -4832,6 +4845,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4832
4845
|
format = "YYYY/MM/DD",
|
|
4833
4846
|
displayFormat = "YYYY/MM/DD",
|
|
4834
4847
|
size,
|
|
4848
|
+
locale = "default",
|
|
4835
4849
|
inputReadOnly,
|
|
4836
4850
|
hideClearButton,
|
|
4837
4851
|
readOnly,
|
|
@@ -4845,8 +4859,9 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4845
4859
|
props.defaultValue || "",
|
|
4846
4860
|
useCallback13((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
4847
4861
|
);
|
|
4862
|
+
const isAlphabeticDisplay = hasAlphabeticMonth2(displayFormat);
|
|
4848
4863
|
const [displayValue, setDisplayValue] = useState10(
|
|
4849
|
-
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4864
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat, locale) : ""
|
|
4850
4865
|
);
|
|
4851
4866
|
const [anchorEl, setAnchorEl] = useState10(null);
|
|
4852
4867
|
const open = Boolean(anchorEl);
|
|
@@ -4858,14 +4873,14 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4858
4873
|
if (value) {
|
|
4859
4874
|
try {
|
|
4860
4875
|
const dates = parseDates(value, format);
|
|
4861
|
-
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4876
|
+
const newDisplayValue = formatValueString2(dates, displayFormat, locale);
|
|
4862
4877
|
setDisplayValue(newDisplayValue);
|
|
4863
4878
|
} catch (error2) {
|
|
4864
4879
|
}
|
|
4865
4880
|
} else {
|
|
4866
4881
|
setDisplayValue("");
|
|
4867
4882
|
}
|
|
4868
|
-
}, [displayFormat, value, format]);
|
|
4883
|
+
}, [displayFormat, locale, value, format]);
|
|
4869
4884
|
useEffect8(() => {
|
|
4870
4885
|
if (!anchorEl) {
|
|
4871
4886
|
innerRef.current?.blur();
|
|
@@ -4875,10 +4890,10 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4875
4890
|
const handleChange = useCallback13(
|
|
4876
4891
|
(event) => {
|
|
4877
4892
|
const value2 = event.target.value;
|
|
4878
|
-
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2);
|
|
4893
|
+
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat, locale) : value2);
|
|
4879
4894
|
setValue(value2);
|
|
4880
4895
|
},
|
|
4881
|
-
[displayFormat, format, setValue]
|
|
4896
|
+
[displayFormat, format, locale, setValue]
|
|
4882
4897
|
);
|
|
4883
4898
|
const handleDisplayInputChange = useCallback13(
|
|
4884
4899
|
(event) => {
|
|
@@ -4919,21 +4934,21 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4919
4934
|
if (props.value !== void 0) {
|
|
4920
4935
|
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
4921
4936
|
} else {
|
|
4922
|
-
setDisplayValue(formatValueString2([date1, date2], displayFormat));
|
|
4937
|
+
setDisplayValue(formatValueString2([date1, date2], displayFormat, locale));
|
|
4923
4938
|
setValue(formattedValue);
|
|
4924
4939
|
}
|
|
4925
4940
|
setAnchorEl(null);
|
|
4926
4941
|
},
|
|
4927
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4942
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4928
4943
|
);
|
|
4929
4944
|
const handleInputMouseDown = useCallback13(
|
|
4930
4945
|
(event) => {
|
|
4931
|
-
if (inputReadOnly) {
|
|
4946
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
4932
4947
|
event.preventDefault();
|
|
4933
4948
|
buttonRef.current?.focus();
|
|
4934
4949
|
}
|
|
4935
4950
|
},
|
|
4936
|
-
[inputReadOnly, buttonRef]
|
|
4951
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
4937
4952
|
);
|
|
4938
4953
|
const handlePresetClick = useCallback13(
|
|
4939
4954
|
(presetValue) => {
|
|
@@ -4941,12 +4956,12 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4941
4956
|
onChange?.({ target: { name: props.name, value: presetValue } });
|
|
4942
4957
|
} else {
|
|
4943
4958
|
const dates = parseDates(presetValue, format);
|
|
4944
|
-
setDisplayValue(formatValueString2(dates, displayFormat));
|
|
4959
|
+
setDisplayValue(formatValueString2(dates, displayFormat, locale));
|
|
4945
4960
|
setValue(presetValue);
|
|
4946
4961
|
}
|
|
4947
4962
|
setAnchorEl(null);
|
|
4948
4963
|
},
|
|
4949
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4964
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4950
4965
|
);
|
|
4951
4966
|
const isPresetDisabled = useCallback13(
|
|
4952
4967
|
(presetValue) => {
|
|
@@ -4981,12 +4996,11 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4981
4996
|
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
4982
4997
|
slotProps: {
|
|
4983
4998
|
input: {
|
|
4984
|
-
component: TextMaskAdapter5,
|
|
4999
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter5, format: displayFormat },
|
|
4985
5000
|
ref: innerRef,
|
|
4986
|
-
format: displayFormat,
|
|
4987
5001
|
sx: {
|
|
4988
5002
|
"&:hover": {
|
|
4989
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
5003
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
4990
5004
|
}
|
|
4991
5005
|
},
|
|
4992
5006
|
onMouseDown: handleInputMouseDown
|
|
@@ -5011,7 +5025,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
5011
5025
|
),
|
|
5012
5026
|
label,
|
|
5013
5027
|
helperText,
|
|
5014
|
-
readOnly: readOnly || inputReadOnly
|
|
5028
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
5015
5029
|
}
|
|
5016
5030
|
), open && /* @__PURE__ */ React26.createElement(ClickAwayListener2, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ React26.createElement(
|
|
5017
5031
|
StyledPopper2,
|
|
@@ -5041,7 +5055,8 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
5041
5055
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
5042
5056
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
5043
5057
|
disableFuture,
|
|
5044
|
-
disablePast
|
|
5058
|
+
disablePast,
|
|
5059
|
+
locale
|
|
5045
5060
|
}
|
|
5046
5061
|
), !hideClearButton && /* @__PURE__ */ React26.createElement(
|
|
5047
5062
|
DialogActions_default,
|
|
@@ -5692,8 +5707,9 @@ var formatValueString3 = (date, format, locale = "default") => {
|
|
|
5692
5707
|
const year = date.getFullYear().toString();
|
|
5693
5708
|
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
5694
5709
|
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
5710
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
5695
5711
|
const day = "01";
|
|
5696
|
-
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
5712
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
5697
5713
|
};
|
|
5698
5714
|
function parseDate3(dateString, format) {
|
|
5699
5715
|
const dateParts = dateString.split(/[-./\s]/);
|
|
@@ -5920,6 +5936,7 @@ import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
|
|
|
5920
5936
|
import CalendarTodayIcon4 from "@mui/icons-material/CalendarToday";
|
|
5921
5937
|
import { styled as styled22, useThemeProps as useThemeProps7 } from "@mui/joy";
|
|
5922
5938
|
import { FocusTrap as FocusTrap4, ClickAwayListener as ClickAwayListener4, Popper as Popper5 } from "@mui/base";
|
|
5939
|
+
var hasAlphabeticMonth3 = (format) => /MMMM|MMM/.test(format);
|
|
5923
5940
|
var StyledPopper4 = styled22(Popper5, {
|
|
5924
5941
|
name: "MonthRangePicker",
|
|
5925
5942
|
slot: "popper"
|
|
@@ -5943,12 +5960,14 @@ var MonthRangePickerRoot = styled22("div", {
|
|
|
5943
5960
|
})({
|
|
5944
5961
|
width: "100%"
|
|
5945
5962
|
});
|
|
5946
|
-
var formatValueString4 = ([date1, date2], format) => {
|
|
5963
|
+
var formatValueString4 = ([date1, date2], format, locale = "default") => {
|
|
5947
5964
|
const getStr = (date) => {
|
|
5948
5965
|
let month = `${date.getMonth() + 1}`;
|
|
5949
5966
|
const year = date.getFullYear();
|
|
5950
5967
|
if (Number(month) < 10) month = "0" + month;
|
|
5951
|
-
|
|
5968
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
5969
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
5970
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/YYYY/g, year.toString());
|
|
5952
5971
|
};
|
|
5953
5972
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
5954
5973
|
};
|
|
@@ -6020,18 +6039,38 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6020
6039
|
sx,
|
|
6021
6040
|
className,
|
|
6022
6041
|
format = "YYYY/MM",
|
|
6042
|
+
displayFormat: displayFormatProp,
|
|
6023
6043
|
size,
|
|
6044
|
+
locale = "default",
|
|
6024
6045
|
...innerProps
|
|
6025
6046
|
} = props;
|
|
6047
|
+
const displayFormat = displayFormatProp ?? format;
|
|
6048
|
+
const isAlphabeticDisplay = hasAlphabeticMonth3(displayFormat);
|
|
6026
6049
|
const innerRef = useRef11(null);
|
|
6050
|
+
const buttonRef = useRef11(null);
|
|
6027
6051
|
const [value, setValue] = useControlledState(
|
|
6028
6052
|
props.value,
|
|
6029
6053
|
props.defaultValue || "",
|
|
6030
6054
|
useCallback16((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
6031
6055
|
);
|
|
6056
|
+
const [displayValue, setDisplayValue] = useState14(
|
|
6057
|
+
() => value ? formatValueString4(parseDates2(value), displayFormat, locale) : ""
|
|
6058
|
+
);
|
|
6032
6059
|
const [anchorEl, setAnchorEl] = useState14(null);
|
|
6033
6060
|
const open = Boolean(anchorEl);
|
|
6034
6061
|
const calendarValue = useMemo13(() => value ? parseDates2(value) : void 0, [value]);
|
|
6062
|
+
useEffect12(() => {
|
|
6063
|
+
if (value) {
|
|
6064
|
+
try {
|
|
6065
|
+
const dates = parseDates2(value);
|
|
6066
|
+
const newDisplayValue = formatValueString4(dates, displayFormat, locale);
|
|
6067
|
+
setDisplayValue(newDisplayValue);
|
|
6068
|
+
} catch {
|
|
6069
|
+
}
|
|
6070
|
+
} else {
|
|
6071
|
+
setDisplayValue("");
|
|
6072
|
+
}
|
|
6073
|
+
}, [displayFormat, locale, value]);
|
|
6035
6074
|
useEffect12(() => {
|
|
6036
6075
|
if (!anchorEl) {
|
|
6037
6076
|
innerRef.current?.blur();
|
|
@@ -6040,9 +6079,21 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6040
6079
|
useImperativeHandle5(ref, () => innerRef.current, [innerRef]);
|
|
6041
6080
|
const handleChange = useCallback16(
|
|
6042
6081
|
(event) => {
|
|
6082
|
+
setDisplayValue(
|
|
6083
|
+
event.target.value ? formatValueString4(parseDates2(event.target.value), displayFormat, locale) : ""
|
|
6084
|
+
);
|
|
6043
6085
|
setValue(event.target.value);
|
|
6044
6086
|
},
|
|
6045
|
-
[setValue]
|
|
6087
|
+
[displayFormat, locale, setValue]
|
|
6088
|
+
);
|
|
6089
|
+
const handleInputMouseDown = useCallback16(
|
|
6090
|
+
(event) => {
|
|
6091
|
+
if (isAlphabeticDisplay) {
|
|
6092
|
+
event.preventDefault();
|
|
6093
|
+
buttonRef.current?.focus();
|
|
6094
|
+
}
|
|
6095
|
+
},
|
|
6096
|
+
[isAlphabeticDisplay, buttonRef]
|
|
6046
6097
|
);
|
|
6047
6098
|
const handleCalendarToggle = useCallback16(
|
|
6048
6099
|
(event) => {
|
|
@@ -6054,10 +6105,12 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6054
6105
|
const handleCalendarChange = useCallback16(
|
|
6055
6106
|
([date1, date2]) => {
|
|
6056
6107
|
if (!date1 || !date2) return;
|
|
6057
|
-
|
|
6108
|
+
const formattedValue = formatValueString4([date1, date2], format);
|
|
6109
|
+
setDisplayValue(formatValueString4([date1, date2], displayFormat, locale));
|
|
6110
|
+
setValue(formattedValue);
|
|
6058
6111
|
setAnchorEl(null);
|
|
6059
6112
|
},
|
|
6060
|
-
[setValue, setAnchorEl, format]
|
|
6113
|
+
[setValue, setAnchorEl, format, displayFormat, locale]
|
|
6061
6114
|
);
|
|
6062
6115
|
return /* @__PURE__ */ React36.createElement(MonthRangePickerRoot, null, /* @__PURE__ */ React36.createElement(FocusTrap4, { open: true }, /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
6063
6116
|
Input_default,
|
|
@@ -6066,14 +6119,22 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6066
6119
|
color: error ? "danger" : innerProps.color,
|
|
6067
6120
|
ref,
|
|
6068
6121
|
size,
|
|
6069
|
-
value,
|
|
6122
|
+
value: isAlphabeticDisplay ? displayValue : value,
|
|
6070
6123
|
onChange: handleChange,
|
|
6071
6124
|
disabled,
|
|
6072
6125
|
required,
|
|
6073
|
-
placeholder: `${
|
|
6126
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
6074
6127
|
slotProps: {
|
|
6075
|
-
input: {
|
|
6128
|
+
input: {
|
|
6129
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter7, format },
|
|
6130
|
+
ref: innerRef,
|
|
6131
|
+
...isAlphabeticDisplay ? {
|
|
6132
|
+
sx: { "&:hover": { cursor: "default" } },
|
|
6133
|
+
onMouseDown: handleInputMouseDown
|
|
6134
|
+
} : {}
|
|
6135
|
+
}
|
|
6076
6136
|
},
|
|
6137
|
+
readOnly: isAlphabeticDisplay || void 0,
|
|
6077
6138
|
error,
|
|
6078
6139
|
className,
|
|
6079
6140
|
sx: {
|
|
@@ -6084,6 +6145,7 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6084
6145
|
endDecorator: /* @__PURE__ */ React36.createElement(
|
|
6085
6146
|
IconButton_default,
|
|
6086
6147
|
{
|
|
6148
|
+
ref: buttonRef,
|
|
6087
6149
|
variant: "plain",
|
|
6088
6150
|
onClick: handleCalendarToggle,
|
|
6089
6151
|
"aria-label": "Toggle Calendar",
|
|
@@ -6126,7 +6188,8 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6126
6188
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
6127
6189
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
6128
6190
|
disableFuture,
|
|
6129
|
-
disablePast
|
|
6191
|
+
disablePast,
|
|
6192
|
+
locale
|
|
6130
6193
|
}
|
|
6131
6194
|
), /* @__PURE__ */ React36.createElement(
|
|
6132
6195
|
DialogActions_default,
|