@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.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,
|
|
@@ -4644,6 +4652,7 @@ import { IMaskInput as IMaskInput2, IMask as IMask2 } from "react-imask";
|
|
|
4644
4652
|
import CalendarTodayIcon2 from "@mui/icons-material/CalendarToday";
|
|
4645
4653
|
import { styled as styled14, useThemeProps as useThemeProps5 } from "@mui/joy";
|
|
4646
4654
|
import { FocusTrap as FocusTrap2, ClickAwayListener as ClickAwayListener2, Popper as Popper3 } from "@mui/base";
|
|
4655
|
+
var hasAlphabeticMonth2 = (format) => /MMMM|MMM/.test(format);
|
|
4647
4656
|
var CalendarButton2 = styled14(IconButton_default, {
|
|
4648
4657
|
name: "DateRangePicker",
|
|
4649
4658
|
slot: "calendarButton"
|
|
@@ -4715,6 +4724,7 @@ var DateRangePickerRoot = styled14("div", {
|
|
|
4715
4724
|
width: "100%"
|
|
4716
4725
|
});
|
|
4717
4726
|
var validValueFormat2 = (value, format) => {
|
|
4727
|
+
if (hasAlphabeticMonth2(format)) return true;
|
|
4718
4728
|
try {
|
|
4719
4729
|
const [date1Str, date2Str] = value.split(" - ");
|
|
4720
4730
|
if (!date1Str || !date2Str) {
|
|
@@ -4737,14 +4747,16 @@ var validValueFormat2 = (value, format) => {
|
|
|
4737
4747
|
return false;
|
|
4738
4748
|
}
|
|
4739
4749
|
};
|
|
4740
|
-
var formatValueString2 = ([date1, date2], format) => {
|
|
4750
|
+
var formatValueString2 = ([date1, date2], format, locale = "default") => {
|
|
4741
4751
|
const getStr = (date) => {
|
|
4742
4752
|
let day = `${date.getDate()}`;
|
|
4743
4753
|
let month = `${date.getMonth() + 1}`;
|
|
4744
4754
|
const year = date.getFullYear();
|
|
4745
4755
|
if (Number(day) < 10) day = "0" + day;
|
|
4746
4756
|
if (Number(month) < 10) month = "0" + month;
|
|
4747
|
-
|
|
4757
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
4758
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
4759
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
4748
4760
|
};
|
|
4749
4761
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
4750
4762
|
};
|
|
@@ -4832,6 +4844,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4832
4844
|
format = "YYYY/MM/DD",
|
|
4833
4845
|
displayFormat = "YYYY/MM/DD",
|
|
4834
4846
|
size,
|
|
4847
|
+
locale = "default",
|
|
4835
4848
|
inputReadOnly,
|
|
4836
4849
|
hideClearButton,
|
|
4837
4850
|
readOnly,
|
|
@@ -4845,8 +4858,9 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4845
4858
|
props.defaultValue || "",
|
|
4846
4859
|
useCallback13((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
4847
4860
|
);
|
|
4861
|
+
const isAlphabeticDisplay = hasAlphabeticMonth2(displayFormat);
|
|
4848
4862
|
const [displayValue, setDisplayValue] = useState10(
|
|
4849
|
-
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4863
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat, locale) : ""
|
|
4850
4864
|
);
|
|
4851
4865
|
const [anchorEl, setAnchorEl] = useState10(null);
|
|
4852
4866
|
const open = Boolean(anchorEl);
|
|
@@ -4858,14 +4872,14 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4858
4872
|
if (value) {
|
|
4859
4873
|
try {
|
|
4860
4874
|
const dates = parseDates(value, format);
|
|
4861
|
-
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4875
|
+
const newDisplayValue = formatValueString2(dates, displayFormat, locale);
|
|
4862
4876
|
setDisplayValue(newDisplayValue);
|
|
4863
4877
|
} catch (error2) {
|
|
4864
4878
|
}
|
|
4865
4879
|
} else {
|
|
4866
4880
|
setDisplayValue("");
|
|
4867
4881
|
}
|
|
4868
|
-
}, [displayFormat, value, format]);
|
|
4882
|
+
}, [displayFormat, locale, value, format]);
|
|
4869
4883
|
useEffect8(() => {
|
|
4870
4884
|
if (!anchorEl) {
|
|
4871
4885
|
innerRef.current?.blur();
|
|
@@ -4875,10 +4889,10 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4875
4889
|
const handleChange = useCallback13(
|
|
4876
4890
|
(event) => {
|
|
4877
4891
|
const value2 = event.target.value;
|
|
4878
|
-
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2);
|
|
4892
|
+
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat, locale) : value2);
|
|
4879
4893
|
setValue(value2);
|
|
4880
4894
|
},
|
|
4881
|
-
[displayFormat, format, setValue]
|
|
4895
|
+
[displayFormat, format, locale, setValue]
|
|
4882
4896
|
);
|
|
4883
4897
|
const handleDisplayInputChange = useCallback13(
|
|
4884
4898
|
(event) => {
|
|
@@ -4919,21 +4933,21 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4919
4933
|
if (props.value !== void 0) {
|
|
4920
4934
|
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
4921
4935
|
} else {
|
|
4922
|
-
setDisplayValue(formatValueString2([date1, date2], displayFormat));
|
|
4936
|
+
setDisplayValue(formatValueString2([date1, date2], displayFormat, locale));
|
|
4923
4937
|
setValue(formattedValue);
|
|
4924
4938
|
}
|
|
4925
4939
|
setAnchorEl(null);
|
|
4926
4940
|
},
|
|
4927
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4941
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4928
4942
|
);
|
|
4929
4943
|
const handleInputMouseDown = useCallback13(
|
|
4930
4944
|
(event) => {
|
|
4931
|
-
if (inputReadOnly) {
|
|
4945
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
4932
4946
|
event.preventDefault();
|
|
4933
4947
|
buttonRef.current?.focus();
|
|
4934
4948
|
}
|
|
4935
4949
|
},
|
|
4936
|
-
[inputReadOnly, buttonRef]
|
|
4950
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
4937
4951
|
);
|
|
4938
4952
|
const handlePresetClick = useCallback13(
|
|
4939
4953
|
(presetValue) => {
|
|
@@ -4941,12 +4955,12 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4941
4955
|
onChange?.({ target: { name: props.name, value: presetValue } });
|
|
4942
4956
|
} else {
|
|
4943
4957
|
const dates = parseDates(presetValue, format);
|
|
4944
|
-
setDisplayValue(formatValueString2(dates, displayFormat));
|
|
4958
|
+
setDisplayValue(formatValueString2(dates, displayFormat, locale));
|
|
4945
4959
|
setValue(presetValue);
|
|
4946
4960
|
}
|
|
4947
4961
|
setAnchorEl(null);
|
|
4948
4962
|
},
|
|
4949
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4963
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4950
4964
|
);
|
|
4951
4965
|
const isPresetDisabled = useCallback13(
|
|
4952
4966
|
(presetValue) => {
|
|
@@ -4981,12 +4995,11 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4981
4995
|
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
4982
4996
|
slotProps: {
|
|
4983
4997
|
input: {
|
|
4984
|
-
component: TextMaskAdapter5,
|
|
4998
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter5, format: displayFormat },
|
|
4985
4999
|
ref: innerRef,
|
|
4986
|
-
format: displayFormat,
|
|
4987
5000
|
sx: {
|
|
4988
5001
|
"&:hover": {
|
|
4989
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
5002
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
4990
5003
|
}
|
|
4991
5004
|
},
|
|
4992
5005
|
onMouseDown: handleInputMouseDown
|
|
@@ -5011,7 +5024,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
5011
5024
|
),
|
|
5012
5025
|
label,
|
|
5013
5026
|
helperText,
|
|
5014
|
-
readOnly: readOnly || inputReadOnly
|
|
5027
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
5015
5028
|
}
|
|
5016
5029
|
), open && /* @__PURE__ */ React26.createElement(ClickAwayListener2, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ React26.createElement(
|
|
5017
5030
|
StyledPopper2,
|
|
@@ -5692,8 +5705,9 @@ var formatValueString3 = (date, format, locale = "default") => {
|
|
|
5692
5705
|
const year = date.getFullYear().toString();
|
|
5693
5706
|
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
5694
5707
|
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
5708
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
5695
5709
|
const day = "01";
|
|
5696
|
-
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
5710
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
5697
5711
|
};
|
|
5698
5712
|
function parseDate3(dateString, format) {
|
|
5699
5713
|
const dateParts = dateString.split(/[-./\s]/);
|
|
@@ -5920,6 +5934,7 @@ import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
|
|
|
5920
5934
|
import CalendarTodayIcon4 from "@mui/icons-material/CalendarToday";
|
|
5921
5935
|
import { styled as styled22, useThemeProps as useThemeProps7 } from "@mui/joy";
|
|
5922
5936
|
import { FocusTrap as FocusTrap4, ClickAwayListener as ClickAwayListener4, Popper as Popper5 } from "@mui/base";
|
|
5937
|
+
var hasAlphabeticMonth3 = (format) => /MMMM|MMM/.test(format);
|
|
5923
5938
|
var StyledPopper4 = styled22(Popper5, {
|
|
5924
5939
|
name: "MonthRangePicker",
|
|
5925
5940
|
slot: "popper"
|
|
@@ -5943,12 +5958,14 @@ var MonthRangePickerRoot = styled22("div", {
|
|
|
5943
5958
|
})({
|
|
5944
5959
|
width: "100%"
|
|
5945
5960
|
});
|
|
5946
|
-
var formatValueString4 = ([date1, date2], format) => {
|
|
5961
|
+
var formatValueString4 = ([date1, date2], format, locale = "default") => {
|
|
5947
5962
|
const getStr = (date) => {
|
|
5948
5963
|
let month = `${date.getMonth() + 1}`;
|
|
5949
5964
|
const year = date.getFullYear();
|
|
5950
5965
|
if (Number(month) < 10) month = "0" + month;
|
|
5951
|
-
|
|
5966
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
5967
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
5968
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/YYYY/g, year.toString());
|
|
5952
5969
|
};
|
|
5953
5970
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
5954
5971
|
};
|
|
@@ -6020,18 +6037,38 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6020
6037
|
sx,
|
|
6021
6038
|
className,
|
|
6022
6039
|
format = "YYYY/MM",
|
|
6040
|
+
displayFormat: displayFormatProp,
|
|
6023
6041
|
size,
|
|
6042
|
+
locale = "default",
|
|
6024
6043
|
...innerProps
|
|
6025
6044
|
} = props;
|
|
6045
|
+
const displayFormat = displayFormatProp ?? format;
|
|
6046
|
+
const isAlphabeticDisplay = hasAlphabeticMonth3(displayFormat);
|
|
6026
6047
|
const innerRef = useRef11(null);
|
|
6048
|
+
const buttonRef = useRef11(null);
|
|
6027
6049
|
const [value, setValue] = useControlledState(
|
|
6028
6050
|
props.value,
|
|
6029
6051
|
props.defaultValue || "",
|
|
6030
6052
|
useCallback16((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
6031
6053
|
);
|
|
6054
|
+
const [displayValue, setDisplayValue] = useState14(
|
|
6055
|
+
() => value ? formatValueString4(parseDates2(value), displayFormat, locale) : ""
|
|
6056
|
+
);
|
|
6032
6057
|
const [anchorEl, setAnchorEl] = useState14(null);
|
|
6033
6058
|
const open = Boolean(anchorEl);
|
|
6034
6059
|
const calendarValue = useMemo13(() => value ? parseDates2(value) : void 0, [value]);
|
|
6060
|
+
useEffect12(() => {
|
|
6061
|
+
if (value) {
|
|
6062
|
+
try {
|
|
6063
|
+
const dates = parseDates2(value);
|
|
6064
|
+
const newDisplayValue = formatValueString4(dates, displayFormat, locale);
|
|
6065
|
+
setDisplayValue(newDisplayValue);
|
|
6066
|
+
} catch {
|
|
6067
|
+
}
|
|
6068
|
+
} else {
|
|
6069
|
+
setDisplayValue("");
|
|
6070
|
+
}
|
|
6071
|
+
}, [displayFormat, locale, value]);
|
|
6035
6072
|
useEffect12(() => {
|
|
6036
6073
|
if (!anchorEl) {
|
|
6037
6074
|
innerRef.current?.blur();
|
|
@@ -6040,9 +6077,21 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6040
6077
|
useImperativeHandle5(ref, () => innerRef.current, [innerRef]);
|
|
6041
6078
|
const handleChange = useCallback16(
|
|
6042
6079
|
(event) => {
|
|
6080
|
+
setDisplayValue(
|
|
6081
|
+
event.target.value ? formatValueString4(parseDates2(event.target.value), displayFormat, locale) : ""
|
|
6082
|
+
);
|
|
6043
6083
|
setValue(event.target.value);
|
|
6044
6084
|
},
|
|
6045
|
-
[setValue]
|
|
6085
|
+
[displayFormat, locale, setValue]
|
|
6086
|
+
);
|
|
6087
|
+
const handleInputMouseDown = useCallback16(
|
|
6088
|
+
(event) => {
|
|
6089
|
+
if (isAlphabeticDisplay) {
|
|
6090
|
+
event.preventDefault();
|
|
6091
|
+
buttonRef.current?.focus();
|
|
6092
|
+
}
|
|
6093
|
+
},
|
|
6094
|
+
[isAlphabeticDisplay, buttonRef]
|
|
6046
6095
|
);
|
|
6047
6096
|
const handleCalendarToggle = useCallback16(
|
|
6048
6097
|
(event) => {
|
|
@@ -6054,10 +6103,12 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6054
6103
|
const handleCalendarChange = useCallback16(
|
|
6055
6104
|
([date1, date2]) => {
|
|
6056
6105
|
if (!date1 || !date2) return;
|
|
6057
|
-
|
|
6106
|
+
const formattedValue = formatValueString4([date1, date2], format);
|
|
6107
|
+
setDisplayValue(formatValueString4([date1, date2], displayFormat, locale));
|
|
6108
|
+
setValue(formattedValue);
|
|
6058
6109
|
setAnchorEl(null);
|
|
6059
6110
|
},
|
|
6060
|
-
[setValue, setAnchorEl, format]
|
|
6111
|
+
[setValue, setAnchorEl, format, displayFormat, locale]
|
|
6061
6112
|
);
|
|
6062
6113
|
return /* @__PURE__ */ React36.createElement(MonthRangePickerRoot, null, /* @__PURE__ */ React36.createElement(FocusTrap4, { open: true }, /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
6063
6114
|
Input_default,
|
|
@@ -6066,14 +6117,22 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6066
6117
|
color: error ? "danger" : innerProps.color,
|
|
6067
6118
|
ref,
|
|
6068
6119
|
size,
|
|
6069
|
-
value,
|
|
6120
|
+
value: isAlphabeticDisplay ? displayValue : value,
|
|
6070
6121
|
onChange: handleChange,
|
|
6071
6122
|
disabled,
|
|
6072
6123
|
required,
|
|
6073
|
-
placeholder: `${
|
|
6124
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
6074
6125
|
slotProps: {
|
|
6075
|
-
input: {
|
|
6126
|
+
input: {
|
|
6127
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter7, format },
|
|
6128
|
+
ref: innerRef,
|
|
6129
|
+
...isAlphabeticDisplay ? {
|
|
6130
|
+
sx: { "&:hover": { cursor: "default" } },
|
|
6131
|
+
onMouseDown: handleInputMouseDown
|
|
6132
|
+
} : {}
|
|
6133
|
+
}
|
|
6076
6134
|
},
|
|
6135
|
+
readOnly: isAlphabeticDisplay || void 0,
|
|
6077
6136
|
error,
|
|
6078
6137
|
className,
|
|
6079
6138
|
sx: {
|
|
@@ -6084,6 +6143,7 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
6084
6143
|
endDecorator: /* @__PURE__ */ React36.createElement(
|
|
6085
6144
|
IconButton_default,
|
|
6086
6145
|
{
|
|
6146
|
+
ref: buttonRef,
|
|
6087
6147
|
variant: "plain",
|
|
6088
6148
|
onClick: handleCalendarToggle,
|
|
6089
6149
|
"aria-label": "Toggle Calendar",
|