@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.js
CHANGED
|
@@ -745,6 +745,9 @@ var getMonthName = (date, locale, options) => {
|
|
|
745
745
|
...options?.hideYear ? {} : { year: "numeric" }
|
|
746
746
|
});
|
|
747
747
|
};
|
|
748
|
+
var getShortMonthName = (date, locale) => {
|
|
749
|
+
return date.toLocaleString(locale, { month: "short" });
|
|
750
|
+
};
|
|
748
751
|
var getMonthNameFromIndex = (index, locale) => {
|
|
749
752
|
return new Date(0, index).toLocaleString(locale, { month: "short" });
|
|
750
753
|
};
|
|
@@ -2411,6 +2414,7 @@ DialogActions.displayName = "DialogActions";
|
|
|
2411
2414
|
var DialogActions_default = DialogActions;
|
|
2412
2415
|
|
|
2413
2416
|
// src/components/DatePicker/DatePicker.tsx
|
|
2417
|
+
var hasAlphabeticMonth = (format) => /MMMM|MMM/.test(format);
|
|
2414
2418
|
var CalendarButton = styled10(IconButton_default, {
|
|
2415
2419
|
name: "DatePicker",
|
|
2416
2420
|
slot: "calendarButton"
|
|
@@ -2481,6 +2485,7 @@ var DatePickerRoot = styled10("div", {
|
|
|
2481
2485
|
width: "100%"
|
|
2482
2486
|
});
|
|
2483
2487
|
var validValueFormat = (value, format) => {
|
|
2488
|
+
if (hasAlphabeticMonth(format)) return true;
|
|
2484
2489
|
try {
|
|
2485
2490
|
const parsedValue = parseDate(value, format);
|
|
2486
2491
|
if (parsedValue.toString() === "Invalid Date") {
|
|
@@ -2495,13 +2500,15 @@ var validValueFormat = (value, format) => {
|
|
|
2495
2500
|
return false;
|
|
2496
2501
|
}
|
|
2497
2502
|
};
|
|
2498
|
-
var formatValueString = (date, format) => {
|
|
2503
|
+
var formatValueString = (date, format, locale = "default") => {
|
|
2499
2504
|
let day = `${date.getDate()}`;
|
|
2500
2505
|
let month = `${date.getMonth() + 1}`;
|
|
2501
2506
|
const year = date.getFullYear();
|
|
2502
2507
|
if (Number(day) < 10) day = "0" + day;
|
|
2503
2508
|
if (Number(month) < 10) month = "0" + month;
|
|
2504
|
-
|
|
2509
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
2510
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
2511
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
2505
2512
|
};
|
|
2506
2513
|
function parseDate(dateString, format) {
|
|
2507
2514
|
const formatParts = format.split(/[-./\s]/);
|
|
@@ -2586,6 +2593,7 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2586
2593
|
format = "YYYY/MM/DD",
|
|
2587
2594
|
displayFormat = "YYYY/MM/DD",
|
|
2588
2595
|
size,
|
|
2596
|
+
locale = "default",
|
|
2589
2597
|
inputReadOnly,
|
|
2590
2598
|
hideClearButton,
|
|
2591
2599
|
readOnly,
|
|
@@ -2600,8 +2608,9 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2600
2608
|
props.defaultValue || "",
|
|
2601
2609
|
useCallback8((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
2602
2610
|
);
|
|
2611
|
+
const isAlphabeticDisplay = hasAlphabeticMonth(displayFormat);
|
|
2603
2612
|
const [displayValue, setDisplayValue] = useState7(
|
|
2604
|
-
() => value ? formatValueString(parseDate(value, format), displayFormat) : ""
|
|
2613
|
+
() => value ? formatValueString(parseDate(value, format), displayFormat, locale) : ""
|
|
2605
2614
|
);
|
|
2606
2615
|
const [anchorEl, setAnchorEl] = useState7(null);
|
|
2607
2616
|
const open = Boolean(anchorEl);
|
|
@@ -2615,19 +2624,19 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2615
2624
|
setDisplayValue("");
|
|
2616
2625
|
return;
|
|
2617
2626
|
}
|
|
2618
|
-
const formattedValue = formatValueString(parseDate(value, format), displayFormat);
|
|
2627
|
+
const formattedValue = formatValueString(parseDate(value, format), displayFormat, locale);
|
|
2619
2628
|
if (validValueFormat(formattedValue, displayFormat) && formattedValue !== displayValue) {
|
|
2620
2629
|
setDisplayValue(formattedValue);
|
|
2621
2630
|
}
|
|
2622
|
-
}, [displayFormat, displayValue, format, value]);
|
|
2631
|
+
}, [displayFormat, displayValue, format, locale, value]);
|
|
2623
2632
|
useImperativeHandle(ref, () => innerRef.current, [innerRef]);
|
|
2624
2633
|
const handleChange = useCallback8(
|
|
2625
2634
|
(event) => {
|
|
2626
2635
|
const value2 = event.target.value;
|
|
2627
|
-
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2);
|
|
2636
|
+
setDisplayValue(value2 ? formatValueString(parseDate(value2, format), displayFormat, locale) : value2);
|
|
2628
2637
|
setValue(value2);
|
|
2629
2638
|
},
|
|
2630
|
-
[displayFormat, format, setValue]
|
|
2639
|
+
[displayFormat, format, locale, setValue]
|
|
2631
2640
|
);
|
|
2632
2641
|
const handleDisplayInputChange = useCallback8(
|
|
2633
2642
|
(event) => {
|
|
@@ -2665,12 +2674,12 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2665
2674
|
);
|
|
2666
2675
|
const handleInputMouseDown = useCallback8(
|
|
2667
2676
|
(event) => {
|
|
2668
|
-
if (inputReadOnly) {
|
|
2677
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
2669
2678
|
event.preventDefault();
|
|
2670
2679
|
buttonRef.current?.focus();
|
|
2671
2680
|
}
|
|
2672
2681
|
},
|
|
2673
|
-
[inputReadOnly, buttonRef]
|
|
2682
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
2674
2683
|
);
|
|
2675
2684
|
const handlePresetClick = useCallback8(
|
|
2676
2685
|
(presetValue) => {
|
|
@@ -2716,12 +2725,11 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2716
2725
|
error,
|
|
2717
2726
|
slotProps: {
|
|
2718
2727
|
input: {
|
|
2719
|
-
component: TextMaskAdapter3,
|
|
2728
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter3, format: displayFormat },
|
|
2720
2729
|
ref: innerRef,
|
|
2721
|
-
format: displayFormat,
|
|
2722
2730
|
sx: {
|
|
2723
2731
|
"&:hover": {
|
|
2724
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
2732
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
2725
2733
|
}
|
|
2726
2734
|
},
|
|
2727
2735
|
onMouseDown: handleInputMouseDown
|
|
@@ -2745,7 +2753,7 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2745
2753
|
),
|
|
2746
2754
|
label,
|
|
2747
2755
|
helperText,
|
|
2748
|
-
readOnly: readOnly || inputReadOnly
|
|
2756
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
2749
2757
|
}
|
|
2750
2758
|
), open && /* @__PURE__ */ React18.createElement(ClickAwayListener, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ React18.createElement(
|
|
2751
2759
|
StyledPopper,
|
|
@@ -2783,7 +2791,8 @@ var DatePicker = forwardRef6((inProps, ref) => {
|
|
|
2783
2791
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
2784
2792
|
disableFuture,
|
|
2785
2793
|
disablePast,
|
|
2786
|
-
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0
|
|
2794
|
+
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0,
|
|
2795
|
+
locale
|
|
2787
2796
|
}
|
|
2788
2797
|
), !hideClearButton && /* @__PURE__ */ React18.createElement(
|
|
2789
2798
|
DialogActions_default,
|
|
@@ -4634,6 +4643,7 @@ import { IMaskInput as IMaskInput2, IMask as IMask2 } from "react-imask";
|
|
|
4634
4643
|
import CalendarTodayIcon2 from "@mui/icons-material/CalendarToday";
|
|
4635
4644
|
import { styled as styled14, useThemeProps as useThemeProps5 } from "@mui/joy";
|
|
4636
4645
|
import { FocusTrap as FocusTrap2, ClickAwayListener as ClickAwayListener2, Popper as Popper3 } from "@mui/base";
|
|
4646
|
+
var hasAlphabeticMonth2 = (format) => /MMMM|MMM/.test(format);
|
|
4637
4647
|
var CalendarButton2 = styled14(IconButton_default, {
|
|
4638
4648
|
name: "DateRangePicker",
|
|
4639
4649
|
slot: "calendarButton"
|
|
@@ -4705,6 +4715,7 @@ var DateRangePickerRoot = styled14("div", {
|
|
|
4705
4715
|
width: "100%"
|
|
4706
4716
|
});
|
|
4707
4717
|
var validValueFormat2 = (value, format) => {
|
|
4718
|
+
if (hasAlphabeticMonth2(format)) return true;
|
|
4708
4719
|
try {
|
|
4709
4720
|
const [date1Str, date2Str] = value.split(" - ");
|
|
4710
4721
|
if (!date1Str || !date2Str) {
|
|
@@ -4727,14 +4738,16 @@ var validValueFormat2 = (value, format) => {
|
|
|
4727
4738
|
return false;
|
|
4728
4739
|
}
|
|
4729
4740
|
};
|
|
4730
|
-
var formatValueString2 = ([date1, date2], format) => {
|
|
4741
|
+
var formatValueString2 = ([date1, date2], format, locale = "default") => {
|
|
4731
4742
|
const getStr = (date) => {
|
|
4732
4743
|
let day = `${date.getDate()}`;
|
|
4733
4744
|
let month = `${date.getMonth() + 1}`;
|
|
4734
4745
|
const year = date.getFullYear();
|
|
4735
4746
|
if (Number(day) < 10) day = "0" + day;
|
|
4736
4747
|
if (Number(month) < 10) month = "0" + month;
|
|
4737
|
-
|
|
4748
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
4749
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
4750
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year.toString());
|
|
4738
4751
|
};
|
|
4739
4752
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
4740
4753
|
};
|
|
@@ -4822,6 +4835,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4822
4835
|
format = "YYYY/MM/DD",
|
|
4823
4836
|
displayFormat = "YYYY/MM/DD",
|
|
4824
4837
|
size,
|
|
4838
|
+
locale = "default",
|
|
4825
4839
|
inputReadOnly,
|
|
4826
4840
|
hideClearButton,
|
|
4827
4841
|
readOnly,
|
|
@@ -4835,8 +4849,9 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4835
4849
|
props.defaultValue || "",
|
|
4836
4850
|
useCallback13((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
4837
4851
|
);
|
|
4852
|
+
const isAlphabeticDisplay = hasAlphabeticMonth2(displayFormat);
|
|
4838
4853
|
const [displayValue, setDisplayValue] = useState10(
|
|
4839
|
-
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4854
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat, locale) : ""
|
|
4840
4855
|
);
|
|
4841
4856
|
const [anchorEl, setAnchorEl] = useState10(null);
|
|
4842
4857
|
const open = Boolean(anchorEl);
|
|
@@ -4848,14 +4863,14 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4848
4863
|
if (value) {
|
|
4849
4864
|
try {
|
|
4850
4865
|
const dates = parseDates(value, format);
|
|
4851
|
-
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4866
|
+
const newDisplayValue = formatValueString2(dates, displayFormat, locale);
|
|
4852
4867
|
setDisplayValue(newDisplayValue);
|
|
4853
4868
|
} catch (error2) {
|
|
4854
4869
|
}
|
|
4855
4870
|
} else {
|
|
4856
4871
|
setDisplayValue("");
|
|
4857
4872
|
}
|
|
4858
|
-
}, [displayFormat, value, format]);
|
|
4873
|
+
}, [displayFormat, locale, value, format]);
|
|
4859
4874
|
useEffect8(() => {
|
|
4860
4875
|
if (!anchorEl) {
|
|
4861
4876
|
innerRef.current?.blur();
|
|
@@ -4865,10 +4880,10 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4865
4880
|
const handleChange = useCallback13(
|
|
4866
4881
|
(event) => {
|
|
4867
4882
|
const value2 = event.target.value;
|
|
4868
|
-
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2);
|
|
4883
|
+
setDisplayValue(value2 ? formatValueString2(parseDates(value2, format), displayFormat, locale) : value2);
|
|
4869
4884
|
setValue(value2);
|
|
4870
4885
|
},
|
|
4871
|
-
[displayFormat, format, setValue]
|
|
4886
|
+
[displayFormat, format, locale, setValue]
|
|
4872
4887
|
);
|
|
4873
4888
|
const handleDisplayInputChange = useCallback13(
|
|
4874
4889
|
(event) => {
|
|
@@ -4909,21 +4924,21 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4909
4924
|
if (props.value !== void 0) {
|
|
4910
4925
|
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
4911
4926
|
} else {
|
|
4912
|
-
setDisplayValue(formatValueString2([date1, date2], displayFormat));
|
|
4927
|
+
setDisplayValue(formatValueString2([date1, date2], displayFormat, locale));
|
|
4913
4928
|
setValue(formattedValue);
|
|
4914
4929
|
}
|
|
4915
4930
|
setAnchorEl(null);
|
|
4916
4931
|
},
|
|
4917
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4932
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4918
4933
|
);
|
|
4919
4934
|
const handleInputMouseDown = useCallback13(
|
|
4920
4935
|
(event) => {
|
|
4921
|
-
if (inputReadOnly) {
|
|
4936
|
+
if (inputReadOnly || isAlphabeticDisplay) {
|
|
4922
4937
|
event.preventDefault();
|
|
4923
4938
|
buttonRef.current?.focus();
|
|
4924
4939
|
}
|
|
4925
4940
|
},
|
|
4926
|
-
[inputReadOnly, buttonRef]
|
|
4941
|
+
[inputReadOnly, isAlphabeticDisplay, buttonRef]
|
|
4927
4942
|
);
|
|
4928
4943
|
const handlePresetClick = useCallback13(
|
|
4929
4944
|
(presetValue) => {
|
|
@@ -4931,12 +4946,12 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4931
4946
|
onChange?.({ target: { name: props.name, value: presetValue } });
|
|
4932
4947
|
} else {
|
|
4933
4948
|
const dates = parseDates(presetValue, format);
|
|
4934
|
-
setDisplayValue(formatValueString2(dates, displayFormat));
|
|
4949
|
+
setDisplayValue(formatValueString2(dates, displayFormat, locale));
|
|
4935
4950
|
setValue(presetValue);
|
|
4936
4951
|
}
|
|
4937
4952
|
setAnchorEl(null);
|
|
4938
4953
|
},
|
|
4939
|
-
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat]
|
|
4954
|
+
[props.value, props.name, onChange, setValue, setAnchorEl, format, displayFormat, locale]
|
|
4940
4955
|
);
|
|
4941
4956
|
const isPresetDisabled = useCallback13(
|
|
4942
4957
|
(presetValue) => {
|
|
@@ -4971,12 +4986,11 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
4971
4986
|
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
4972
4987
|
slotProps: {
|
|
4973
4988
|
input: {
|
|
4974
|
-
component: TextMaskAdapter5,
|
|
4989
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter5, format: displayFormat },
|
|
4975
4990
|
ref: innerRef,
|
|
4976
|
-
format: displayFormat,
|
|
4977
4991
|
sx: {
|
|
4978
4992
|
"&:hover": {
|
|
4979
|
-
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
4993
|
+
cursor: isAlphabeticDisplay || inputReadOnly || readOnly ? "default" : "text"
|
|
4980
4994
|
}
|
|
4981
4995
|
},
|
|
4982
4996
|
onMouseDown: handleInputMouseDown
|
|
@@ -5001,7 +5015,7 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
5001
5015
|
),
|
|
5002
5016
|
label,
|
|
5003
5017
|
helperText,
|
|
5004
|
-
readOnly: readOnly || inputReadOnly
|
|
5018
|
+
readOnly: readOnly || inputReadOnly || isAlphabeticDisplay
|
|
5005
5019
|
}
|
|
5006
5020
|
), open && /* @__PURE__ */ React26.createElement(ClickAwayListener2, { onClickAway: () => setAnchorEl(null) }, /* @__PURE__ */ React26.createElement(
|
|
5007
5021
|
StyledPopper2,
|
|
@@ -5031,7 +5045,8 @@ var DateRangePicker = forwardRef8((inProps, ref) => {
|
|
|
5031
5045
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
5032
5046
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
5033
5047
|
disableFuture,
|
|
5034
|
-
disablePast
|
|
5048
|
+
disablePast,
|
|
5049
|
+
locale
|
|
5035
5050
|
}
|
|
5036
5051
|
), !hideClearButton && /* @__PURE__ */ React26.createElement(
|
|
5037
5052
|
DialogActions_default,
|
|
@@ -6690,8 +6705,9 @@ var formatValueString3 = (date, format, locale = "default") => {
|
|
|
6690
6705
|
const year = date.getFullYear().toString();
|
|
6691
6706
|
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
6692
6707
|
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
6708
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
6693
6709
|
const day = "01";
|
|
6694
|
-
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6710
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
6695
6711
|
};
|
|
6696
6712
|
function parseDate3(dateString, format) {
|
|
6697
6713
|
const dateParts = dateString.split(/[-./\s]/);
|
|
@@ -6918,6 +6934,7 @@ import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
|
|
|
6918
6934
|
import CalendarTodayIcon4 from "@mui/icons-material/CalendarToday";
|
|
6919
6935
|
import { styled as styled23, useThemeProps as useThemeProps8 } from "@mui/joy";
|
|
6920
6936
|
import { FocusTrap as FocusTrap4, ClickAwayListener as ClickAwayListener4, Popper as Popper5 } from "@mui/base";
|
|
6937
|
+
var hasAlphabeticMonth3 = (format) => /MMMM|MMM/.test(format);
|
|
6921
6938
|
var StyledPopper4 = styled23(Popper5, {
|
|
6922
6939
|
name: "MonthRangePicker",
|
|
6923
6940
|
slot: "popper"
|
|
@@ -6941,12 +6958,14 @@ var MonthRangePickerRoot = styled23("div", {
|
|
|
6941
6958
|
})({
|
|
6942
6959
|
width: "100%"
|
|
6943
6960
|
});
|
|
6944
|
-
var formatValueString4 = ([date1, date2], format) => {
|
|
6961
|
+
var formatValueString4 = ([date1, date2], format, locale = "default") => {
|
|
6945
6962
|
const getStr = (date) => {
|
|
6946
6963
|
let month = `${date.getMonth() + 1}`;
|
|
6947
6964
|
const year = date.getFullYear();
|
|
6948
6965
|
if (Number(month) < 10) month = "0" + month;
|
|
6949
|
-
|
|
6966
|
+
const monthName = getMonthName(date, locale, { hideYear: true });
|
|
6967
|
+
const shortMonthName = getShortMonthName(date, locale);
|
|
6968
|
+
return format.replace(/MMMM/g, monthName).replace(/MMM/g, shortMonthName).replace(/MM/g, month).replace(/YYYY/g, year.toString());
|
|
6950
6969
|
};
|
|
6951
6970
|
return [getStr(date1), date2 ? getStr(date2) : ""].join(" - ");
|
|
6952
6971
|
};
|
|
@@ -7018,18 +7037,38 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7018
7037
|
sx,
|
|
7019
7038
|
className,
|
|
7020
7039
|
format = "YYYY/MM",
|
|
7040
|
+
displayFormat: displayFormatProp,
|
|
7021
7041
|
size,
|
|
7042
|
+
locale = "default",
|
|
7022
7043
|
...innerProps
|
|
7023
7044
|
} = props;
|
|
7045
|
+
const displayFormat = displayFormatProp ?? format;
|
|
7046
|
+
const isAlphabeticDisplay = hasAlphabeticMonth3(displayFormat);
|
|
7024
7047
|
const innerRef = useRef12(null);
|
|
7048
|
+
const buttonRef = useRef12(null);
|
|
7025
7049
|
const [value, setValue] = useControlledState(
|
|
7026
7050
|
props.value,
|
|
7027
7051
|
props.defaultValue || "",
|
|
7028
7052
|
useCallback27((value2) => onChange?.({ target: { name: props.name, value: value2 } }), [props.name, onChange])
|
|
7029
7053
|
);
|
|
7054
|
+
const [displayValue, setDisplayValue] = useState17(
|
|
7055
|
+
() => value ? formatValueString4(parseDates2(value), displayFormat, locale) : ""
|
|
7056
|
+
);
|
|
7030
7057
|
const [anchorEl, setAnchorEl] = useState17(null);
|
|
7031
7058
|
const open = Boolean(anchorEl);
|
|
7032
7059
|
const calendarValue = useMemo16(() => value ? parseDates2(value) : void 0, [value]);
|
|
7060
|
+
useEffect14(() => {
|
|
7061
|
+
if (value) {
|
|
7062
|
+
try {
|
|
7063
|
+
const dates = parseDates2(value);
|
|
7064
|
+
const newDisplayValue = formatValueString4(dates, displayFormat, locale);
|
|
7065
|
+
setDisplayValue(newDisplayValue);
|
|
7066
|
+
} catch {
|
|
7067
|
+
}
|
|
7068
|
+
} else {
|
|
7069
|
+
setDisplayValue("");
|
|
7070
|
+
}
|
|
7071
|
+
}, [displayFormat, locale, value]);
|
|
7033
7072
|
useEffect14(() => {
|
|
7034
7073
|
if (!anchorEl) {
|
|
7035
7074
|
innerRef.current?.blur();
|
|
@@ -7038,9 +7077,21 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7038
7077
|
useImperativeHandle5(ref, () => innerRef.current, [innerRef]);
|
|
7039
7078
|
const handleChange = useCallback27(
|
|
7040
7079
|
(event) => {
|
|
7080
|
+
setDisplayValue(
|
|
7081
|
+
event.target.value ? formatValueString4(parseDates2(event.target.value), displayFormat, locale) : ""
|
|
7082
|
+
);
|
|
7041
7083
|
setValue(event.target.value);
|
|
7042
7084
|
},
|
|
7043
|
-
[setValue]
|
|
7085
|
+
[displayFormat, locale, setValue]
|
|
7086
|
+
);
|
|
7087
|
+
const handleInputMouseDown = useCallback27(
|
|
7088
|
+
(event) => {
|
|
7089
|
+
if (isAlphabeticDisplay) {
|
|
7090
|
+
event.preventDefault();
|
|
7091
|
+
buttonRef.current?.focus();
|
|
7092
|
+
}
|
|
7093
|
+
},
|
|
7094
|
+
[isAlphabeticDisplay, buttonRef]
|
|
7044
7095
|
);
|
|
7045
7096
|
const handleCalendarToggle = useCallback27(
|
|
7046
7097
|
(event) => {
|
|
@@ -7052,10 +7103,12 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7052
7103
|
const handleCalendarChange = useCallback27(
|
|
7053
7104
|
([date1, date2]) => {
|
|
7054
7105
|
if (!date1 || !date2) return;
|
|
7055
|
-
|
|
7106
|
+
const formattedValue = formatValueString4([date1, date2], format);
|
|
7107
|
+
setDisplayValue(formatValueString4([date1, date2], displayFormat, locale));
|
|
7108
|
+
setValue(formattedValue);
|
|
7056
7109
|
setAnchorEl(null);
|
|
7057
7110
|
},
|
|
7058
|
-
[setValue, setAnchorEl, format]
|
|
7111
|
+
[setValue, setAnchorEl, format, displayFormat, locale]
|
|
7059
7112
|
);
|
|
7060
7113
|
return /* @__PURE__ */ React47.createElement(MonthRangePickerRoot, null, /* @__PURE__ */ React47.createElement(FocusTrap4, { open: true }, /* @__PURE__ */ React47.createElement(React47.Fragment, null, /* @__PURE__ */ React47.createElement(
|
|
7061
7114
|
Input_default,
|
|
@@ -7064,14 +7117,22 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7064
7117
|
color: error ? "danger" : innerProps.color,
|
|
7065
7118
|
ref,
|
|
7066
7119
|
size,
|
|
7067
|
-
value,
|
|
7120
|
+
value: isAlphabeticDisplay ? displayValue : value,
|
|
7068
7121
|
onChange: handleChange,
|
|
7069
7122
|
disabled,
|
|
7070
7123
|
required,
|
|
7071
|
-
placeholder: `${
|
|
7124
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
7072
7125
|
slotProps: {
|
|
7073
|
-
input: {
|
|
7126
|
+
input: {
|
|
7127
|
+
...isAlphabeticDisplay ? {} : { component: TextMaskAdapter9, format },
|
|
7128
|
+
ref: innerRef,
|
|
7129
|
+
...isAlphabeticDisplay ? {
|
|
7130
|
+
sx: { "&:hover": { cursor: "default" } },
|
|
7131
|
+
onMouseDown: handleInputMouseDown
|
|
7132
|
+
} : {}
|
|
7133
|
+
}
|
|
7074
7134
|
},
|
|
7135
|
+
readOnly: isAlphabeticDisplay || void 0,
|
|
7075
7136
|
error,
|
|
7076
7137
|
className,
|
|
7077
7138
|
sx: {
|
|
@@ -7082,6 +7143,7 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7082
7143
|
endDecorator: /* @__PURE__ */ React47.createElement(
|
|
7083
7144
|
IconButton_default,
|
|
7084
7145
|
{
|
|
7146
|
+
ref: buttonRef,
|
|
7085
7147
|
variant: "plain",
|
|
7086
7148
|
onClick: handleCalendarToggle,
|
|
7087
7149
|
"aria-label": "Toggle Calendar",
|
|
@@ -7124,7 +7186,8 @@ var MonthRangePicker = forwardRef10((inProps, ref) => {
|
|
|
7124
7186
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
7125
7187
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
7126
7188
|
disableFuture,
|
|
7127
|
-
disablePast
|
|
7189
|
+
disablePast,
|
|
7190
|
+
locale
|
|
7128
7191
|
}
|
|
7129
7192
|
), /* @__PURE__ */ React47.createElement(
|
|
7130
7193
|
DialogActions_default,
|