@ceed/cds 1.5.3 → 1.5.4-next.2
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/MonthPicker/MonthPicker.d.ts +1 -0
- package/dist/index.cjs +83 -70
- package/dist/index.js +83 -70
- package/framer/index.js +37 -37
- package/package.json +3 -2
|
@@ -20,6 +20,7 @@ interface BaseMonthPickerProps {
|
|
|
20
20
|
disableFuture?: boolean;
|
|
21
21
|
disablePast?: boolean;
|
|
22
22
|
format?: string;
|
|
23
|
+
displayFormat?: string;
|
|
23
24
|
}
|
|
24
25
|
export type MonthPickerProps = BaseMonthPickerProps & Omit<React.ComponentProps<typeof Input>, "onChange" | "value" | "defaultValue">;
|
|
25
26
|
declare const MonthPicker: React.ForwardRefExoticComponent<Omit<MonthPickerProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
package/dist/index.cjs
CHANGED
|
@@ -4538,7 +4538,6 @@ MenuButton.displayName = "MenuButton";
|
|
|
4538
4538
|
|
|
4539
4539
|
// src/components/MonthPicker/MonthPicker.tsx
|
|
4540
4540
|
var import_react33 = __toESM(require("react"));
|
|
4541
|
-
var import_react_imask3 = require("react-imask");
|
|
4542
4541
|
var import_CalendarToday3 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
4543
4542
|
var import_joy46 = require("@mui/joy");
|
|
4544
4543
|
var import_base4 = require("@mui/base");
|
|
@@ -4564,60 +4563,38 @@ var MonthPickerRoot = (0, import_joy46.styled)("div", {
|
|
|
4564
4563
|
})({
|
|
4565
4564
|
width: "100%"
|
|
4566
4565
|
});
|
|
4566
|
+
function getMonthName2(date) {
|
|
4567
|
+
return new Intl.DateTimeFormat("en-US", { month: "long" }).format(date);
|
|
4568
|
+
}
|
|
4567
4569
|
var formatValueString3 = (date, format) => {
|
|
4568
|
-
|
|
4569
|
-
const
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
var formatToPattern3 = (format) => {
|
|
4574
|
-
return format.replace(/YYYY/g, "Y").replace(/MM/g, "M").replace(/[^YM\s]/g, (match) => `${match}\``);
|
|
4570
|
+
const year = date.getFullYear().toString();
|
|
4571
|
+
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
4572
|
+
const monthName = getMonthName2(date);
|
|
4573
|
+
const day = "01";
|
|
4574
|
+
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
4575
4575
|
};
|
|
4576
|
-
function parseDate3(dateString) {
|
|
4576
|
+
function parseDate3(dateString, format) {
|
|
4577
|
+
const dateParts = dateString.split(/[-./\s]/);
|
|
4578
|
+
const formatParts = format.split(/[-./\s]/);
|
|
4579
|
+
if (formatParts.length !== dateParts.length) {
|
|
4580
|
+
throw new Error("Invalid date string or format");
|
|
4581
|
+
}
|
|
4577
4582
|
let month, year;
|
|
4578
|
-
const
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4583
|
+
const day = 1;
|
|
4584
|
+
for (let i = 0; i < formatParts.length; i++) {
|
|
4585
|
+
const value = parseInt(dateParts[i], 10);
|
|
4586
|
+
switch (formatParts[i]) {
|
|
4587
|
+
case "MM":
|
|
4588
|
+
month = value - 1;
|
|
4589
|
+
break;
|
|
4590
|
+
case "YYYY":
|
|
4591
|
+
year = value;
|
|
4592
|
+
break;
|
|
4593
|
+
}
|
|
4585
4594
|
}
|
|
4586
|
-
const
|
|
4587
|
-
return
|
|
4595
|
+
const result = new Date(year, month, day);
|
|
4596
|
+
return result;
|
|
4588
4597
|
}
|
|
4589
|
-
var TextMaskAdapter7 = import_react33.default.forwardRef(
|
|
4590
|
-
function TextMaskAdapter8(props, ref) {
|
|
4591
|
-
const { onChange, format, ...other } = props;
|
|
4592
|
-
return /* @__PURE__ */ import_react33.default.createElement(
|
|
4593
|
-
import_react_imask3.IMaskInput,
|
|
4594
|
-
{
|
|
4595
|
-
...other,
|
|
4596
|
-
inputRef: ref,
|
|
4597
|
-
onAccept: (value) => onChange({ target: { name: props.name, value } }),
|
|
4598
|
-
mask: Date,
|
|
4599
|
-
pattern: formatToPattern3(format),
|
|
4600
|
-
blocks: {
|
|
4601
|
-
M: {
|
|
4602
|
-
mask: import_react_imask3.IMask.MaskedRange,
|
|
4603
|
-
from: 1,
|
|
4604
|
-
to: 12,
|
|
4605
|
-
maxLength: 2
|
|
4606
|
-
},
|
|
4607
|
-
Y: {
|
|
4608
|
-
mask: import_react_imask3.IMask.MaskedRange,
|
|
4609
|
-
from: 1900,
|
|
4610
|
-
to: 9999
|
|
4611
|
-
}
|
|
4612
|
-
},
|
|
4613
|
-
format: (date) => formatValueString3(date, format),
|
|
4614
|
-
parse: parseDate3,
|
|
4615
|
-
autofix: "pad",
|
|
4616
|
-
overwrite: true
|
|
4617
|
-
}
|
|
4618
|
-
);
|
|
4619
|
-
}
|
|
4620
|
-
);
|
|
4621
4598
|
var MonthPicker = (0, import_react33.forwardRef)(
|
|
4622
4599
|
(inProps, ref) => {
|
|
4623
4600
|
const props = (0, import_joy46.useThemeProps)({ props: inProps, name: "MonthPicker" });
|
|
@@ -4635,11 +4612,13 @@ var MonthPicker = (0, import_react33.forwardRef)(
|
|
|
4635
4612
|
// NOTE: 스타일 관련된 props는 최상위 엘리먼트에 적용한다.
|
|
4636
4613
|
sx,
|
|
4637
4614
|
className,
|
|
4638
|
-
format = "YYYY/MM",
|
|
4615
|
+
format = "YYYY/MM/DD",
|
|
4616
|
+
displayFormat = "YYYY/MM",
|
|
4639
4617
|
size,
|
|
4640
4618
|
...innerProps
|
|
4641
4619
|
} = props;
|
|
4642
4620
|
const innerRef = (0, import_react33.useRef)(null);
|
|
4621
|
+
const buttonRef = (0, import_react33.useRef)(null);
|
|
4643
4622
|
const [value, setValue] = useControlledState(
|
|
4644
4623
|
props.value,
|
|
4645
4624
|
props.defaultValue || "",
|
|
@@ -4649,6 +4628,9 @@ var MonthPicker = (0, import_react33.forwardRef)(
|
|
|
4649
4628
|
),
|
|
4650
4629
|
{ disableStrict: true }
|
|
4651
4630
|
);
|
|
4631
|
+
const [displayValue, setDisplayValue] = (0, import_react33.useState)(
|
|
4632
|
+
() => value ? formatValueString3(parseDate3(value, format), displayFormat) : ""
|
|
4633
|
+
);
|
|
4652
4634
|
const [anchorEl, setAnchorEl] = (0, import_react33.useState)(null);
|
|
4653
4635
|
const open = Boolean(anchorEl);
|
|
4654
4636
|
(0, import_react33.useEffect)(() => {
|
|
@@ -4659,11 +4641,26 @@ var MonthPicker = (0, import_react33.forwardRef)(
|
|
|
4659
4641
|
(0, import_react33.useImperativeHandle)(ref, () => innerRef.current, [
|
|
4660
4642
|
innerRef
|
|
4661
4643
|
]);
|
|
4644
|
+
(0, import_react33.useEffect)(() => {
|
|
4645
|
+
if (value === "") {
|
|
4646
|
+
setDisplayValue("");
|
|
4647
|
+
return;
|
|
4648
|
+
}
|
|
4649
|
+
const formattedValue = formatValueString3(
|
|
4650
|
+
parseDate3(value, format),
|
|
4651
|
+
displayFormat
|
|
4652
|
+
);
|
|
4653
|
+
setDisplayValue(formattedValue);
|
|
4654
|
+
}, [displayFormat, format, value]);
|
|
4662
4655
|
const handleChange = (0, import_react33.useCallback)(
|
|
4663
4656
|
(event) => {
|
|
4664
|
-
|
|
4657
|
+
const value2 = event.target.value;
|
|
4658
|
+
setDisplayValue(
|
|
4659
|
+
value2 ? formatValueString3(parseDate3(value2, format), displayFormat) : value2
|
|
4660
|
+
);
|
|
4661
|
+
setValue(value2);
|
|
4665
4662
|
},
|
|
4666
|
-
[setValue]
|
|
4663
|
+
[displayFormat, format, setValue]
|
|
4667
4664
|
);
|
|
4668
4665
|
const handleCalendarToggle = (0, import_react33.useCallback)(
|
|
4669
4666
|
(event) => {
|
|
@@ -4672,6 +4669,13 @@ var MonthPicker = (0, import_react33.forwardRef)(
|
|
|
4672
4669
|
},
|
|
4673
4670
|
[anchorEl, setAnchorEl, innerRef]
|
|
4674
4671
|
);
|
|
4672
|
+
const handleInputMouseDown = (0, import_react33.useCallback)(
|
|
4673
|
+
(event) => {
|
|
4674
|
+
event.preventDefault();
|
|
4675
|
+
buttonRef.current?.focus();
|
|
4676
|
+
},
|
|
4677
|
+
[buttonRef]
|
|
4678
|
+
);
|
|
4675
4679
|
return /* @__PURE__ */ import_react33.default.createElement(MonthPickerRoot, null, /* @__PURE__ */ import_react33.default.createElement(import_base4.FocusTrap, { open: true }, /* @__PURE__ */ import_react33.default.createElement(import_react33.default.Fragment, null, /* @__PURE__ */ import_react33.default.createElement(
|
|
4676
4680
|
Input_default,
|
|
4677
4681
|
{
|
|
@@ -4679,13 +4683,21 @@ var MonthPicker = (0, import_react33.forwardRef)(
|
|
|
4679
4683
|
color: error ? "danger" : innerProps.color,
|
|
4680
4684
|
ref: innerRef,
|
|
4681
4685
|
size,
|
|
4682
|
-
value,
|
|
4683
|
-
|
|
4684
|
-
placeholder: format,
|
|
4686
|
+
value: displayValue,
|
|
4687
|
+
placeholder: displayFormat,
|
|
4685
4688
|
disabled,
|
|
4686
4689
|
required,
|
|
4687
4690
|
slotProps: {
|
|
4688
|
-
input: {
|
|
4691
|
+
input: {
|
|
4692
|
+
ref: innerRef,
|
|
4693
|
+
format: displayFormat,
|
|
4694
|
+
sx: {
|
|
4695
|
+
"&:hover": {
|
|
4696
|
+
cursor: "default"
|
|
4697
|
+
}
|
|
4698
|
+
},
|
|
4699
|
+
onMouseDown: handleInputMouseDown
|
|
4700
|
+
}
|
|
4689
4701
|
},
|
|
4690
4702
|
error,
|
|
4691
4703
|
className,
|
|
@@ -4702,7 +4714,8 @@ var MonthPicker = (0, import_react33.forwardRef)(
|
|
|
4702
4714
|
"aria-label": "Toggle Calendar",
|
|
4703
4715
|
"aria-controls": "month-picker-popper",
|
|
4704
4716
|
"aria-haspopup": "dialog",
|
|
4705
|
-
"aria-expanded": open
|
|
4717
|
+
"aria-expanded": open,
|
|
4718
|
+
disabled
|
|
4706
4719
|
},
|
|
4707
4720
|
/* @__PURE__ */ import_react33.default.createElement(import_CalendarToday3.default, null)
|
|
4708
4721
|
),
|
|
@@ -4780,7 +4793,7 @@ var MonthPicker = (0, import_react33.forwardRef)(
|
|
|
4780
4793
|
|
|
4781
4794
|
// src/components/MonthRangePicker/MonthRangePicker.tsx
|
|
4782
4795
|
var import_react34 = __toESM(require("react"));
|
|
4783
|
-
var
|
|
4796
|
+
var import_react_imask3 = require("react-imask");
|
|
4784
4797
|
var import_CalendarToday4 = __toESM(require("@mui/icons-material/CalendarToday"));
|
|
4785
4798
|
var import_joy47 = require("@mui/joy");
|
|
4786
4799
|
var import_base5 = require("@mui/base");
|
|
@@ -4834,29 +4847,29 @@ var parseDates2 = (str) => {
|
|
|
4834
4847
|
const date2 = str.split(" - ")[1] || "";
|
|
4835
4848
|
return [parseDate4(date1), parseDate4(date2)];
|
|
4836
4849
|
};
|
|
4837
|
-
var
|
|
4850
|
+
var formatToPattern3 = (format) => {
|
|
4838
4851
|
return `${format} - ${format}`.replace(/YYYY/g, "Y").replace(/MM/g, "m").replace(/[^YMm\s]/g, (match) => `${match}\``);
|
|
4839
4852
|
};
|
|
4840
|
-
var
|
|
4841
|
-
function
|
|
4853
|
+
var TextMaskAdapter7 = import_react34.default.forwardRef(
|
|
4854
|
+
function TextMaskAdapter8(props, ref) {
|
|
4842
4855
|
const { onChange, format, ...other } = props;
|
|
4843
4856
|
return /* @__PURE__ */ import_react34.default.createElement(
|
|
4844
|
-
|
|
4857
|
+
import_react_imask3.IMaskInput,
|
|
4845
4858
|
{
|
|
4846
4859
|
...other,
|
|
4847
4860
|
inputRef: ref,
|
|
4848
4861
|
onAccept: (value) => onChange({ target: { name: props.name, value } }),
|
|
4849
4862
|
mask: Date,
|
|
4850
|
-
pattern:
|
|
4863
|
+
pattern: formatToPattern3(format),
|
|
4851
4864
|
blocks: {
|
|
4852
4865
|
m: {
|
|
4853
|
-
mask:
|
|
4866
|
+
mask: import_react_imask3.IMask.MaskedRange,
|
|
4854
4867
|
from: 1,
|
|
4855
4868
|
to: 12,
|
|
4856
4869
|
maxLength: 2
|
|
4857
4870
|
},
|
|
4858
4871
|
Y: {
|
|
4859
|
-
mask:
|
|
4872
|
+
mask: import_react_imask3.IMask.MaskedRange,
|
|
4860
4873
|
from: 1900,
|
|
4861
4874
|
to: 9999
|
|
4862
4875
|
}
|
|
@@ -4948,7 +4961,7 @@ var MonthRangePicker = (0, import_react34.forwardRef)(
|
|
|
4948
4961
|
required,
|
|
4949
4962
|
placeholder: `${format} - ${format}`,
|
|
4950
4963
|
slotProps: {
|
|
4951
|
-
input: { component:
|
|
4964
|
+
input: { component: TextMaskAdapter7, ref: innerRef, format }
|
|
4952
4965
|
},
|
|
4953
4966
|
error,
|
|
4954
4967
|
className,
|
|
@@ -5149,8 +5162,8 @@ var padDecimal = (value, decimalScale) => {
|
|
|
5149
5162
|
const [integer, decimal = ""] = `${value}`.split(".");
|
|
5150
5163
|
return Number(`${integer}${decimal.padEnd(decimalScale, "0")}`);
|
|
5151
5164
|
};
|
|
5152
|
-
var
|
|
5153
|
-
function
|
|
5165
|
+
var TextMaskAdapter9 = import_react38.default.forwardRef(
|
|
5166
|
+
function TextMaskAdapter10(props, ref) {
|
|
5154
5167
|
const { onChange, min, max, ...innerProps } = props;
|
|
5155
5168
|
return /* @__PURE__ */ import_react38.default.createElement(
|
|
5156
5169
|
import_react_number_format2.NumericFormat,
|
|
@@ -5246,7 +5259,7 @@ var PercentageInput = import_react38.default.forwardRef(function PercentageInput
|
|
|
5246
5259
|
helperText,
|
|
5247
5260
|
slotProps: {
|
|
5248
5261
|
input: {
|
|
5249
|
-
component:
|
|
5262
|
+
component: TextMaskAdapter9,
|
|
5250
5263
|
"aria-label": innerProps["aria-label"],
|
|
5251
5264
|
decimalScale: maxDecimalScale
|
|
5252
5265
|
}
|
package/dist/index.js
CHANGED
|
@@ -4534,7 +4534,6 @@ import React31, {
|
|
|
4534
4534
|
useRef as useRef6,
|
|
4535
4535
|
useState as useState9
|
|
4536
4536
|
} from "react";
|
|
4537
|
-
import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
|
|
4538
4537
|
import CalendarTodayIcon3 from "@mui/icons-material/CalendarToday";
|
|
4539
4538
|
import { styled as styled20, useThemeProps as useThemeProps6 } from "@mui/joy";
|
|
4540
4539
|
import { FocusTrap as FocusTrap3, ClickAwayListener as ClickAwayListener3, Popper as Popper4 } from "@mui/base";
|
|
@@ -4560,60 +4559,38 @@ var MonthPickerRoot = styled20("div", {
|
|
|
4560
4559
|
})({
|
|
4561
4560
|
width: "100%"
|
|
4562
4561
|
});
|
|
4562
|
+
function getMonthName2(date) {
|
|
4563
|
+
return new Intl.DateTimeFormat("en-US", { month: "long" }).format(date);
|
|
4564
|
+
}
|
|
4563
4565
|
var formatValueString3 = (date, format) => {
|
|
4564
|
-
|
|
4565
|
-
const
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
var formatToPattern3 = (format) => {
|
|
4570
|
-
return format.replace(/YYYY/g, "Y").replace(/MM/g, "M").replace(/[^YM\s]/g, (match) => `${match}\``);
|
|
4566
|
+
const year = date.getFullYear().toString();
|
|
4567
|
+
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
4568
|
+
const monthName = getMonthName2(date);
|
|
4569
|
+
const day = "01";
|
|
4570
|
+
return format.replace(/MMMM/g, monthName).replace(/MM/g, month).replace(/DD/g, day).replace(/YYYY/g, year);
|
|
4571
4571
|
};
|
|
4572
|
-
function parseDate3(dateString) {
|
|
4572
|
+
function parseDate3(dateString, format) {
|
|
4573
|
+
const dateParts = dateString.split(/[-./\s]/);
|
|
4574
|
+
const formatParts = format.split(/[-./\s]/);
|
|
4575
|
+
if (formatParts.length !== dateParts.length) {
|
|
4576
|
+
throw new Error("Invalid date string or format");
|
|
4577
|
+
}
|
|
4573
4578
|
let month, year;
|
|
4574
|
-
const
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4579
|
+
const day = 1;
|
|
4580
|
+
for (let i = 0; i < formatParts.length; i++) {
|
|
4581
|
+
const value = parseInt(dateParts[i], 10);
|
|
4582
|
+
switch (formatParts[i]) {
|
|
4583
|
+
case "MM":
|
|
4584
|
+
month = value - 1;
|
|
4585
|
+
break;
|
|
4586
|
+
case "YYYY":
|
|
4587
|
+
year = value;
|
|
4588
|
+
break;
|
|
4589
|
+
}
|
|
4581
4590
|
}
|
|
4582
|
-
const
|
|
4583
|
-
return
|
|
4591
|
+
const result = new Date(year, month, day);
|
|
4592
|
+
return result;
|
|
4584
4593
|
}
|
|
4585
|
-
var TextMaskAdapter7 = React31.forwardRef(
|
|
4586
|
-
function TextMaskAdapter8(props, ref) {
|
|
4587
|
-
const { onChange, format, ...other } = props;
|
|
4588
|
-
return /* @__PURE__ */ React31.createElement(
|
|
4589
|
-
IMaskInput3,
|
|
4590
|
-
{
|
|
4591
|
-
...other,
|
|
4592
|
-
inputRef: ref,
|
|
4593
|
-
onAccept: (value) => onChange({ target: { name: props.name, value } }),
|
|
4594
|
-
mask: Date,
|
|
4595
|
-
pattern: formatToPattern3(format),
|
|
4596
|
-
blocks: {
|
|
4597
|
-
M: {
|
|
4598
|
-
mask: IMask3.MaskedRange,
|
|
4599
|
-
from: 1,
|
|
4600
|
-
to: 12,
|
|
4601
|
-
maxLength: 2
|
|
4602
|
-
},
|
|
4603
|
-
Y: {
|
|
4604
|
-
mask: IMask3.MaskedRange,
|
|
4605
|
-
from: 1900,
|
|
4606
|
-
to: 9999
|
|
4607
|
-
}
|
|
4608
|
-
},
|
|
4609
|
-
format: (date) => formatValueString3(date, format),
|
|
4610
|
-
parse: parseDate3,
|
|
4611
|
-
autofix: "pad",
|
|
4612
|
-
overwrite: true
|
|
4613
|
-
}
|
|
4614
|
-
);
|
|
4615
|
-
}
|
|
4616
|
-
);
|
|
4617
4594
|
var MonthPicker = forwardRef9(
|
|
4618
4595
|
(inProps, ref) => {
|
|
4619
4596
|
const props = useThemeProps6({ props: inProps, name: "MonthPicker" });
|
|
@@ -4631,11 +4608,13 @@ var MonthPicker = forwardRef9(
|
|
|
4631
4608
|
// NOTE: 스타일 관련된 props는 최상위 엘리먼트에 적용한다.
|
|
4632
4609
|
sx,
|
|
4633
4610
|
className,
|
|
4634
|
-
format = "YYYY/MM",
|
|
4611
|
+
format = "YYYY/MM/DD",
|
|
4612
|
+
displayFormat = "YYYY/MM",
|
|
4635
4613
|
size,
|
|
4636
4614
|
...innerProps
|
|
4637
4615
|
} = props;
|
|
4638
4616
|
const innerRef = useRef6(null);
|
|
4617
|
+
const buttonRef = useRef6(null);
|
|
4639
4618
|
const [value, setValue] = useControlledState(
|
|
4640
4619
|
props.value,
|
|
4641
4620
|
props.defaultValue || "",
|
|
@@ -4645,6 +4624,9 @@ var MonthPicker = forwardRef9(
|
|
|
4645
4624
|
),
|
|
4646
4625
|
{ disableStrict: true }
|
|
4647
4626
|
);
|
|
4627
|
+
const [displayValue, setDisplayValue] = useState9(
|
|
4628
|
+
() => value ? formatValueString3(parseDate3(value, format), displayFormat) : ""
|
|
4629
|
+
);
|
|
4648
4630
|
const [anchorEl, setAnchorEl] = useState9(null);
|
|
4649
4631
|
const open = Boolean(anchorEl);
|
|
4650
4632
|
useEffect8(() => {
|
|
@@ -4655,11 +4637,26 @@ var MonthPicker = forwardRef9(
|
|
|
4655
4637
|
useImperativeHandle4(ref, () => innerRef.current, [
|
|
4656
4638
|
innerRef
|
|
4657
4639
|
]);
|
|
4640
|
+
useEffect8(() => {
|
|
4641
|
+
if (value === "") {
|
|
4642
|
+
setDisplayValue("");
|
|
4643
|
+
return;
|
|
4644
|
+
}
|
|
4645
|
+
const formattedValue = formatValueString3(
|
|
4646
|
+
parseDate3(value, format),
|
|
4647
|
+
displayFormat
|
|
4648
|
+
);
|
|
4649
|
+
setDisplayValue(formattedValue);
|
|
4650
|
+
}, [displayFormat, format, value]);
|
|
4658
4651
|
const handleChange = useCallback11(
|
|
4659
4652
|
(event) => {
|
|
4660
|
-
|
|
4653
|
+
const value2 = event.target.value;
|
|
4654
|
+
setDisplayValue(
|
|
4655
|
+
value2 ? formatValueString3(parseDate3(value2, format), displayFormat) : value2
|
|
4656
|
+
);
|
|
4657
|
+
setValue(value2);
|
|
4661
4658
|
},
|
|
4662
|
-
[setValue]
|
|
4659
|
+
[displayFormat, format, setValue]
|
|
4663
4660
|
);
|
|
4664
4661
|
const handleCalendarToggle = useCallback11(
|
|
4665
4662
|
(event) => {
|
|
@@ -4668,6 +4665,13 @@ var MonthPicker = forwardRef9(
|
|
|
4668
4665
|
},
|
|
4669
4666
|
[anchorEl, setAnchorEl, innerRef]
|
|
4670
4667
|
);
|
|
4668
|
+
const handleInputMouseDown = useCallback11(
|
|
4669
|
+
(event) => {
|
|
4670
|
+
event.preventDefault();
|
|
4671
|
+
buttonRef.current?.focus();
|
|
4672
|
+
},
|
|
4673
|
+
[buttonRef]
|
|
4674
|
+
);
|
|
4671
4675
|
return /* @__PURE__ */ React31.createElement(MonthPickerRoot, null, /* @__PURE__ */ React31.createElement(FocusTrap3, { open: true }, /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(
|
|
4672
4676
|
Input_default,
|
|
4673
4677
|
{
|
|
@@ -4675,13 +4679,21 @@ var MonthPicker = forwardRef9(
|
|
|
4675
4679
|
color: error ? "danger" : innerProps.color,
|
|
4676
4680
|
ref: innerRef,
|
|
4677
4681
|
size,
|
|
4678
|
-
value,
|
|
4679
|
-
|
|
4680
|
-
placeholder: format,
|
|
4682
|
+
value: displayValue,
|
|
4683
|
+
placeholder: displayFormat,
|
|
4681
4684
|
disabled,
|
|
4682
4685
|
required,
|
|
4683
4686
|
slotProps: {
|
|
4684
|
-
input: {
|
|
4687
|
+
input: {
|
|
4688
|
+
ref: innerRef,
|
|
4689
|
+
format: displayFormat,
|
|
4690
|
+
sx: {
|
|
4691
|
+
"&:hover": {
|
|
4692
|
+
cursor: "default"
|
|
4693
|
+
}
|
|
4694
|
+
},
|
|
4695
|
+
onMouseDown: handleInputMouseDown
|
|
4696
|
+
}
|
|
4685
4697
|
},
|
|
4686
4698
|
error,
|
|
4687
4699
|
className,
|
|
@@ -4698,7 +4710,8 @@ var MonthPicker = forwardRef9(
|
|
|
4698
4710
|
"aria-label": "Toggle Calendar",
|
|
4699
4711
|
"aria-controls": "month-picker-popper",
|
|
4700
4712
|
"aria-haspopup": "dialog",
|
|
4701
|
-
"aria-expanded": open
|
|
4713
|
+
"aria-expanded": open,
|
|
4714
|
+
disabled
|
|
4702
4715
|
},
|
|
4703
4716
|
/* @__PURE__ */ React31.createElement(CalendarTodayIcon3, null)
|
|
4704
4717
|
),
|
|
@@ -4784,7 +4797,7 @@ import React32, {
|
|
|
4784
4797
|
useRef as useRef7,
|
|
4785
4798
|
useState as useState10
|
|
4786
4799
|
} from "react";
|
|
4787
|
-
import { IMaskInput as
|
|
4800
|
+
import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
|
|
4788
4801
|
import CalendarTodayIcon4 from "@mui/icons-material/CalendarToday";
|
|
4789
4802
|
import { styled as styled21, useThemeProps as useThemeProps7 } from "@mui/joy";
|
|
4790
4803
|
import { FocusTrap as FocusTrap4, ClickAwayListener as ClickAwayListener4, Popper as Popper5 } from "@mui/base";
|
|
@@ -4838,29 +4851,29 @@ var parseDates2 = (str) => {
|
|
|
4838
4851
|
const date2 = str.split(" - ")[1] || "";
|
|
4839
4852
|
return [parseDate4(date1), parseDate4(date2)];
|
|
4840
4853
|
};
|
|
4841
|
-
var
|
|
4854
|
+
var formatToPattern3 = (format) => {
|
|
4842
4855
|
return `${format} - ${format}`.replace(/YYYY/g, "Y").replace(/MM/g, "m").replace(/[^YMm\s]/g, (match) => `${match}\``);
|
|
4843
4856
|
};
|
|
4844
|
-
var
|
|
4845
|
-
function
|
|
4857
|
+
var TextMaskAdapter7 = React32.forwardRef(
|
|
4858
|
+
function TextMaskAdapter8(props, ref) {
|
|
4846
4859
|
const { onChange, format, ...other } = props;
|
|
4847
4860
|
return /* @__PURE__ */ React32.createElement(
|
|
4848
|
-
|
|
4861
|
+
IMaskInput3,
|
|
4849
4862
|
{
|
|
4850
4863
|
...other,
|
|
4851
4864
|
inputRef: ref,
|
|
4852
4865
|
onAccept: (value) => onChange({ target: { name: props.name, value } }),
|
|
4853
4866
|
mask: Date,
|
|
4854
|
-
pattern:
|
|
4867
|
+
pattern: formatToPattern3(format),
|
|
4855
4868
|
blocks: {
|
|
4856
4869
|
m: {
|
|
4857
|
-
mask:
|
|
4870
|
+
mask: IMask3.MaskedRange,
|
|
4858
4871
|
from: 1,
|
|
4859
4872
|
to: 12,
|
|
4860
4873
|
maxLength: 2
|
|
4861
4874
|
},
|
|
4862
4875
|
Y: {
|
|
4863
|
-
mask:
|
|
4876
|
+
mask: IMask3.MaskedRange,
|
|
4864
4877
|
from: 1900,
|
|
4865
4878
|
to: 9999
|
|
4866
4879
|
}
|
|
@@ -4952,7 +4965,7 @@ var MonthRangePicker = forwardRef10(
|
|
|
4952
4965
|
required,
|
|
4953
4966
|
placeholder: `${format} - ${format}`,
|
|
4954
4967
|
slotProps: {
|
|
4955
|
-
input: { component:
|
|
4968
|
+
input: { component: TextMaskAdapter7, ref: innerRef, format }
|
|
4956
4969
|
},
|
|
4957
4970
|
error,
|
|
4958
4971
|
className,
|
|
@@ -5166,8 +5179,8 @@ var padDecimal = (value, decimalScale) => {
|
|
|
5166
5179
|
const [integer, decimal = ""] = `${value}`.split(".");
|
|
5167
5180
|
return Number(`${integer}${decimal.padEnd(decimalScale, "0")}`);
|
|
5168
5181
|
};
|
|
5169
|
-
var
|
|
5170
|
-
function
|
|
5182
|
+
var TextMaskAdapter9 = React36.forwardRef(
|
|
5183
|
+
function TextMaskAdapter10(props, ref) {
|
|
5171
5184
|
const { onChange, min, max, ...innerProps } = props;
|
|
5172
5185
|
return /* @__PURE__ */ React36.createElement(
|
|
5173
5186
|
NumericFormat2,
|
|
@@ -5263,7 +5276,7 @@ var PercentageInput = React36.forwardRef(function PercentageInput2(inProps, ref)
|
|
|
5263
5276
|
helperText,
|
|
5264
5277
|
slotProps: {
|
|
5265
5278
|
input: {
|
|
5266
|
-
component:
|
|
5279
|
+
component: TextMaskAdapter9,
|
|
5267
5280
|
"aria-label": innerProps["aria-label"],
|
|
5268
5281
|
decimalScale: maxDecimalScale
|
|
5269
5282
|
}
|