@ceed/ads 1.8.0 → 1.8.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/DateRangePicker/DateRangePicker.d.ts +10 -0
- package/dist/components/FilterMenu/FilterMenu.d.ts +1 -0
- package/dist/components/FilterMenu/components/PercentageRange.d.ts +1 -1
- package/dist/components/FilterMenu/types.d.ts +1 -1
- package/dist/index.cjs +120 -28
- package/dist/index.js +120 -28
- package/framer/index.js +44 -44
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Input from "../Input";
|
|
3
3
|
interface BaseDateRangePickerProps {
|
|
4
|
+
/**
|
|
5
|
+
* props.format 의 형식을 따라야 한다.
|
|
6
|
+
*/
|
|
4
7
|
value?: string;
|
|
5
8
|
defaultValue?: string;
|
|
6
9
|
onChange?: (event: {
|
|
@@ -19,7 +22,14 @@ interface BaseDateRangePickerProps {
|
|
|
19
22
|
maxDate?: string;
|
|
20
23
|
disableFuture?: boolean;
|
|
21
24
|
disablePast?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* value, onChange의 값은 해당 포맷을 따른다.
|
|
27
|
+
*/
|
|
22
28
|
format?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Input 에 표시되는 값의 포맷을 지정한다.
|
|
31
|
+
*/
|
|
32
|
+
displayFormat?: string;
|
|
23
33
|
inputReadOnly?: boolean;
|
|
24
34
|
hideClearButton?: boolean;
|
|
25
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FilterPercentageRangeItem } from "../types";
|
|
3
3
|
interface PercentageRangeProps extends FilterPercentageRangeItem {
|
|
4
|
-
onChange?: (value: [number, number] | null) => void;
|
|
4
|
+
onChange?: (value: [number | null, number | null] | null) => void;
|
|
5
5
|
}
|
|
6
6
|
declare function PercentageRange(props: PercentageRangeProps): React.JSX.Element | null;
|
|
7
7
|
declare namespace PercentageRange {
|
|
@@ -24,7 +24,7 @@ export interface FilterRadioGroupItem extends FilterBaseItem<string | number> {
|
|
|
24
24
|
value: string | number;
|
|
25
25
|
}[];
|
|
26
26
|
}
|
|
27
|
-
export interface FilterDateRangeItem extends FilterBaseItem<[DateTime, DateTime]>, Pick<DateRangePickerProps, "minDate" | "maxDate" | "disableFuture" | "disablePast" | "format" | "inputReadOnly" | "hideClearButton"> {
|
|
27
|
+
export interface FilterDateRangeItem extends FilterBaseItem<[DateTime, DateTime]>, Pick<DateRangePickerProps, "minDate" | "maxDate" | "disableFuture" | "disablePast" | "format" | "displayFormat" | "inputReadOnly" | "hideClearButton"> {
|
|
28
28
|
type: "date-range";
|
|
29
29
|
}
|
|
30
30
|
export interface FilterCurrencyInputItem extends FilterBaseItem<number>, Pick<CurrencyInputProps, "max" | "placeholder" | "useMinorUnit" | "currency"> {
|
package/dist/index.cjs
CHANGED
|
@@ -4157,7 +4157,9 @@ var CalendarButton2 = (0, import_joy34.styled)(IconButton_default, {
|
|
|
4157
4157
|
"&:focus": {
|
|
4158
4158
|
"--Icon-color": "currentColor",
|
|
4159
4159
|
outlineOffset: `${theme.getCssVar("focus-thickness")}`,
|
|
4160
|
-
outline: `${theme.getCssVar("focus-thickness")} solid ${theme.getCssVar(
|
|
4160
|
+
outline: `${theme.getCssVar("focus-thickness")} solid ${theme.getCssVar(
|
|
4161
|
+
"palette-focusVisible"
|
|
4162
|
+
)}`
|
|
4161
4163
|
}
|
|
4162
4164
|
}));
|
|
4163
4165
|
var StyledPopper2 = (0, import_joy34.styled)(import_base3.Popper, {
|
|
@@ -4183,6 +4185,32 @@ var DateRangePickerRoot = (0, import_joy34.styled)("div", {
|
|
|
4183
4185
|
})({
|
|
4184
4186
|
width: "100%"
|
|
4185
4187
|
});
|
|
4188
|
+
var validValueFormat2 = (value, format) => {
|
|
4189
|
+
try {
|
|
4190
|
+
const [date1Str, date2Str] = value.split(" - ");
|
|
4191
|
+
if (!date1Str || !date2Str) {
|
|
4192
|
+
return false;
|
|
4193
|
+
}
|
|
4194
|
+
const parsedDate1 = parseDate2(date1Str, format);
|
|
4195
|
+
const parsedDate2 = parseDate2(date2Str, format);
|
|
4196
|
+
if (parsedDate1.toString() === "Invalid Date" || parsedDate2.toString() === "Invalid Date") {
|
|
4197
|
+
return false;
|
|
4198
|
+
}
|
|
4199
|
+
const formattedValue = formatValueString2(
|
|
4200
|
+
[parsedDate1, parsedDate2],
|
|
4201
|
+
format
|
|
4202
|
+
);
|
|
4203
|
+
if (value !== formattedValue) {
|
|
4204
|
+
return false;
|
|
4205
|
+
}
|
|
4206
|
+
const regex = new RegExp(
|
|
4207
|
+
`^${format.replace(/Y/g, "\\d").replace(/M/g, "\\d").replace(/D/g, "\\d")} - ${format.replace(/Y/g, "\\d").replace(/M/g, "\\d").replace(/D/g, "\\d")}$`
|
|
4208
|
+
);
|
|
4209
|
+
return regex.test(value);
|
|
4210
|
+
} catch (e) {
|
|
4211
|
+
return false;
|
|
4212
|
+
}
|
|
4213
|
+
};
|
|
4186
4214
|
var formatValueString2 = ([date1, date2], format) => {
|
|
4187
4215
|
const getStr = (date) => {
|
|
4188
4216
|
let day = `${date.getDate()}`;
|
|
@@ -4279,6 +4307,7 @@ var DateRangePicker = (0, import_react26.forwardRef)(
|
|
|
4279
4307
|
sx,
|
|
4280
4308
|
className,
|
|
4281
4309
|
format = "YYYY/MM/DD",
|
|
4310
|
+
displayFormat = "YYYY/MM/DD",
|
|
4282
4311
|
size,
|
|
4283
4312
|
inputReadOnly,
|
|
4284
4313
|
hideClearButton,
|
|
@@ -4295,12 +4324,27 @@ var DateRangePicker = (0, import_react26.forwardRef)(
|
|
|
4295
4324
|
[props.name, onChange]
|
|
4296
4325
|
)
|
|
4297
4326
|
);
|
|
4327
|
+
const [displayValue, setDisplayValue] = (0, import_react26.useState)(
|
|
4328
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4329
|
+
);
|
|
4298
4330
|
const [anchorEl, setAnchorEl] = (0, import_react26.useState)(null);
|
|
4299
4331
|
const open = Boolean(anchorEl);
|
|
4300
4332
|
const calendarValue = (0, import_react26.useMemo)(
|
|
4301
4333
|
() => value ? parseDates(value, format) : void 0,
|
|
4302
4334
|
[value, format]
|
|
4303
4335
|
);
|
|
4336
|
+
(0, import_react26.useEffect)(() => {
|
|
4337
|
+
if (value) {
|
|
4338
|
+
try {
|
|
4339
|
+
const dates = parseDates(value, format);
|
|
4340
|
+
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4341
|
+
setDisplayValue(newDisplayValue);
|
|
4342
|
+
} catch (error2) {
|
|
4343
|
+
}
|
|
4344
|
+
} else {
|
|
4345
|
+
setDisplayValue("");
|
|
4346
|
+
}
|
|
4347
|
+
}, [displayFormat, value, format]);
|
|
4304
4348
|
(0, import_react26.useEffect)(() => {
|
|
4305
4349
|
if (!anchorEl) {
|
|
4306
4350
|
innerRef.current?.blur();
|
|
@@ -4311,9 +4355,41 @@ var DateRangePicker = (0, import_react26.forwardRef)(
|
|
|
4311
4355
|
]);
|
|
4312
4356
|
const handleChange = (0, import_react26.useCallback)(
|
|
4313
4357
|
(event) => {
|
|
4314
|
-
|
|
4358
|
+
const value2 = event.target.value;
|
|
4359
|
+
setDisplayValue(
|
|
4360
|
+
value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2
|
|
4361
|
+
);
|
|
4362
|
+
setValue(value2);
|
|
4315
4363
|
},
|
|
4316
|
-
[setValue]
|
|
4364
|
+
[displayFormat, format, setValue]
|
|
4365
|
+
);
|
|
4366
|
+
const handleDisplayInputChange = (0, import_react26.useCallback)(
|
|
4367
|
+
(event) => {
|
|
4368
|
+
if (event.target.value === "") {
|
|
4369
|
+
handleChange({
|
|
4370
|
+
target: {
|
|
4371
|
+
name: props.name,
|
|
4372
|
+
value: ""
|
|
4373
|
+
}
|
|
4374
|
+
});
|
|
4375
|
+
return;
|
|
4376
|
+
}
|
|
4377
|
+
const isValidDisplayValue = validValueFormat2(
|
|
4378
|
+
event.target.value,
|
|
4379
|
+
displayFormat
|
|
4380
|
+
);
|
|
4381
|
+
if (isValidDisplayValue) {
|
|
4382
|
+
const dates = parseDates(event.target.value, displayFormat);
|
|
4383
|
+
const formattedValue = formatValueString2(dates, format);
|
|
4384
|
+
handleChange({
|
|
4385
|
+
target: {
|
|
4386
|
+
name: props.name,
|
|
4387
|
+
value: formattedValue
|
|
4388
|
+
}
|
|
4389
|
+
});
|
|
4390
|
+
}
|
|
4391
|
+
},
|
|
4392
|
+
[displayFormat, format, handleChange, props.name]
|
|
4317
4393
|
);
|
|
4318
4394
|
const handleCalendarToggle = (0, import_react26.useCallback)(
|
|
4319
4395
|
(event) => {
|
|
@@ -4325,10 +4401,26 @@ var DateRangePicker = (0, import_react26.forwardRef)(
|
|
|
4325
4401
|
const handleCalendarChange = (0, import_react26.useCallback)(
|
|
4326
4402
|
([date1, date2]) => {
|
|
4327
4403
|
if (!date1 || !date2) return;
|
|
4328
|
-
|
|
4404
|
+
const formattedValue = formatValueString2([date1, date2], format);
|
|
4405
|
+
if (props.value !== void 0) {
|
|
4406
|
+
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
4407
|
+
} else {
|
|
4408
|
+
setDisplayValue(
|
|
4409
|
+
formatValueString2([date1, date2], displayFormat)
|
|
4410
|
+
);
|
|
4411
|
+
setValue(formattedValue);
|
|
4412
|
+
}
|
|
4329
4413
|
setAnchorEl(null);
|
|
4330
4414
|
},
|
|
4331
|
-
[
|
|
4415
|
+
[
|
|
4416
|
+
props.value,
|
|
4417
|
+
props.name,
|
|
4418
|
+
onChange,
|
|
4419
|
+
setValue,
|
|
4420
|
+
setAnchorEl,
|
|
4421
|
+
format,
|
|
4422
|
+
displayFormat
|
|
4423
|
+
]
|
|
4332
4424
|
);
|
|
4333
4425
|
const handleInputMouseDown = (0, import_react26.useCallback)(
|
|
4334
4426
|
(event) => {
|
|
@@ -4346,17 +4438,21 @@ var DateRangePicker = (0, import_react26.forwardRef)(
|
|
|
4346
4438
|
color: error ? "danger" : innerProps.color,
|
|
4347
4439
|
ref,
|
|
4348
4440
|
size,
|
|
4349
|
-
value,
|
|
4350
|
-
onChange:
|
|
4441
|
+
value: displayValue,
|
|
4442
|
+
onChange: handleDisplayInputChange,
|
|
4351
4443
|
disabled,
|
|
4352
4444
|
required,
|
|
4353
|
-
placeholder: `${
|
|
4445
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
4354
4446
|
slotProps: {
|
|
4355
4447
|
input: {
|
|
4356
4448
|
component: TextMaskAdapter5,
|
|
4357
4449
|
ref: innerRef,
|
|
4358
|
-
format,
|
|
4359
|
-
sx: {
|
|
4450
|
+
format: displayFormat,
|
|
4451
|
+
sx: {
|
|
4452
|
+
"&:hover": {
|
|
4453
|
+
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
4454
|
+
}
|
|
4455
|
+
},
|
|
4360
4456
|
onMouseDown: handleInputMouseDown
|
|
4361
4457
|
}
|
|
4362
4458
|
},
|
|
@@ -4426,6 +4522,7 @@ var DateRangePicker = (0, import_react26.forwardRef)(
|
|
|
4426
4522
|
color: "neutral",
|
|
4427
4523
|
onClick: () => {
|
|
4428
4524
|
setValue("");
|
|
4525
|
+
setDisplayValue("");
|
|
4429
4526
|
setAnchorEl(null);
|
|
4430
4527
|
}
|
|
4431
4528
|
},
|
|
@@ -4582,7 +4679,7 @@ function CheckboxGroup(props) {
|
|
|
4582
4679
|
{
|
|
4583
4680
|
key: `${id}-${option.value}`,
|
|
4584
4681
|
label: option.label,
|
|
4585
|
-
checked: internalValue
|
|
4682
|
+
checked: internalValue?.includes(option.value),
|
|
4586
4683
|
onChange: handleCheckboxChange(option.value)
|
|
4587
4684
|
}
|
|
4588
4685
|
)));
|
|
@@ -4666,6 +4763,7 @@ function DateRange(props) {
|
|
|
4666
4763
|
disableFuture,
|
|
4667
4764
|
disablePast,
|
|
4668
4765
|
format = "YYYY/MM/DD",
|
|
4766
|
+
displayFormat,
|
|
4669
4767
|
inputReadOnly,
|
|
4670
4768
|
hideClearButton
|
|
4671
4769
|
} = props;
|
|
@@ -4820,6 +4918,7 @@ function DateRange(props) {
|
|
|
4820
4918
|
disableFuture,
|
|
4821
4919
|
disablePast,
|
|
4822
4920
|
format,
|
|
4921
|
+
displayFormat,
|
|
4823
4922
|
inputReadOnly,
|
|
4824
4923
|
hideClearButton
|
|
4825
4924
|
}
|
|
@@ -5151,21 +5250,15 @@ function PercentageRange(props) {
|
|
|
5151
5250
|
min,
|
|
5152
5251
|
max
|
|
5153
5252
|
} = props;
|
|
5154
|
-
const [internalValue, setInternalValue] = useControlledState(
|
|
5155
|
-
value,
|
|
5156
|
-
null,
|
|
5157
|
-
onChange
|
|
5158
|
-
);
|
|
5253
|
+
const [internalValue, setInternalValue] = useControlledState(value, null, onChange);
|
|
5159
5254
|
const minValue = internalValue?.[0];
|
|
5160
5255
|
const maxValue = internalValue?.[1];
|
|
5161
5256
|
const handleMinChange = (0, import_react37.useCallback)(
|
|
5162
5257
|
(event) => {
|
|
5163
5258
|
const newMinValue = event.target.value;
|
|
5164
5259
|
const currentMaxValue = maxValue;
|
|
5165
|
-
if (newMinValue !== void 0
|
|
5166
|
-
setInternalValue([newMinValue, currentMaxValue]);
|
|
5167
|
-
} else if (newMinValue !== void 0) {
|
|
5168
|
-
setInternalValue([newMinValue, newMinValue]);
|
|
5260
|
+
if (newMinValue !== void 0) {
|
|
5261
|
+
setInternalValue([newMinValue, currentMaxValue || null]);
|
|
5169
5262
|
} else {
|
|
5170
5263
|
setInternalValue(null);
|
|
5171
5264
|
}
|
|
@@ -5176,10 +5269,8 @@ function PercentageRange(props) {
|
|
|
5176
5269
|
(event) => {
|
|
5177
5270
|
const newMaxValue = event.target.value;
|
|
5178
5271
|
const currentMinValue = minValue;
|
|
5179
|
-
if (
|
|
5180
|
-
setInternalValue([currentMinValue, newMaxValue]);
|
|
5181
|
-
} else if (newMaxValue !== void 0) {
|
|
5182
|
-
setInternalValue([newMaxValue, newMaxValue]);
|
|
5272
|
+
if (newMaxValue !== void 0) {
|
|
5273
|
+
setInternalValue([currentMinValue || null, newMaxValue]);
|
|
5183
5274
|
} else {
|
|
5184
5275
|
setInternalValue(null);
|
|
5185
5276
|
}
|
|
@@ -5202,7 +5293,7 @@ function PercentageRange(props) {
|
|
|
5202
5293
|
PercentageInput,
|
|
5203
5294
|
{
|
|
5204
5295
|
label: "Minimum",
|
|
5205
|
-
value: minValue,
|
|
5296
|
+
value: minValue ?? void 0,
|
|
5206
5297
|
onChange: handleMinChange,
|
|
5207
5298
|
useMinorUnit,
|
|
5208
5299
|
maxDecimalScale,
|
|
@@ -5216,7 +5307,7 @@ function PercentageRange(props) {
|
|
|
5216
5307
|
PercentageInput,
|
|
5217
5308
|
{
|
|
5218
5309
|
label: "Maximum",
|
|
5219
|
-
value: maxValue,
|
|
5310
|
+
value: maxValue ?? void 0,
|
|
5220
5311
|
onChange: handleMaxChange,
|
|
5221
5312
|
useMinorUnit,
|
|
5222
5313
|
maxDecimalScale,
|
|
@@ -5295,6 +5386,7 @@ function FilterMenu(props) {
|
|
|
5295
5386
|
filters,
|
|
5296
5387
|
values,
|
|
5297
5388
|
defaultValues,
|
|
5389
|
+
resetValues = {},
|
|
5298
5390
|
onChange,
|
|
5299
5391
|
onClose,
|
|
5300
5392
|
useClear,
|
|
@@ -5320,11 +5412,11 @@ function FilterMenu(props) {
|
|
|
5320
5412
|
onClose?.();
|
|
5321
5413
|
}, [onChange, onClose, internalValues]);
|
|
5322
5414
|
const handleClear = (0, import_react39.useCallback)(() => {
|
|
5323
|
-
const clearedValues =
|
|
5415
|
+
const clearedValues = resetValues || {};
|
|
5324
5416
|
setInternalValues(clearedValues);
|
|
5325
5417
|
onChange?.(clearedValues);
|
|
5326
5418
|
onClose?.();
|
|
5327
|
-
}, [
|
|
5419
|
+
}, [resetValues, setInternalValues, onChange, onClose]);
|
|
5328
5420
|
return /* @__PURE__ */ import_react39.default.createElement(
|
|
5329
5421
|
ModalDialog,
|
|
5330
5422
|
{
|
package/dist/index.js
CHANGED
|
@@ -4121,7 +4121,9 @@ var CalendarButton2 = styled13(IconButton_default, {
|
|
|
4121
4121
|
"&:focus": {
|
|
4122
4122
|
"--Icon-color": "currentColor",
|
|
4123
4123
|
outlineOffset: `${theme.getCssVar("focus-thickness")}`,
|
|
4124
|
-
outline: `${theme.getCssVar("focus-thickness")} solid ${theme.getCssVar(
|
|
4124
|
+
outline: `${theme.getCssVar("focus-thickness")} solid ${theme.getCssVar(
|
|
4125
|
+
"palette-focusVisible"
|
|
4126
|
+
)}`
|
|
4125
4127
|
}
|
|
4126
4128
|
}));
|
|
4127
4129
|
var StyledPopper2 = styled13(Popper3, {
|
|
@@ -4147,6 +4149,32 @@ var DateRangePickerRoot = styled13("div", {
|
|
|
4147
4149
|
})({
|
|
4148
4150
|
width: "100%"
|
|
4149
4151
|
});
|
|
4152
|
+
var validValueFormat2 = (value, format) => {
|
|
4153
|
+
try {
|
|
4154
|
+
const [date1Str, date2Str] = value.split(" - ");
|
|
4155
|
+
if (!date1Str || !date2Str) {
|
|
4156
|
+
return false;
|
|
4157
|
+
}
|
|
4158
|
+
const parsedDate1 = parseDate2(date1Str, format);
|
|
4159
|
+
const parsedDate2 = parseDate2(date2Str, format);
|
|
4160
|
+
if (parsedDate1.toString() === "Invalid Date" || parsedDate2.toString() === "Invalid Date") {
|
|
4161
|
+
return false;
|
|
4162
|
+
}
|
|
4163
|
+
const formattedValue = formatValueString2(
|
|
4164
|
+
[parsedDate1, parsedDate2],
|
|
4165
|
+
format
|
|
4166
|
+
);
|
|
4167
|
+
if (value !== formattedValue) {
|
|
4168
|
+
return false;
|
|
4169
|
+
}
|
|
4170
|
+
const regex = new RegExp(
|
|
4171
|
+
`^${format.replace(/Y/g, "\\d").replace(/M/g, "\\d").replace(/D/g, "\\d")} - ${format.replace(/Y/g, "\\d").replace(/M/g, "\\d").replace(/D/g, "\\d")}$`
|
|
4172
|
+
);
|
|
4173
|
+
return regex.test(value);
|
|
4174
|
+
} catch (e) {
|
|
4175
|
+
return false;
|
|
4176
|
+
}
|
|
4177
|
+
};
|
|
4150
4178
|
var formatValueString2 = ([date1, date2], format) => {
|
|
4151
4179
|
const getStr = (date) => {
|
|
4152
4180
|
let day = `${date.getDate()}`;
|
|
@@ -4243,6 +4271,7 @@ var DateRangePicker = forwardRef8(
|
|
|
4243
4271
|
sx,
|
|
4244
4272
|
className,
|
|
4245
4273
|
format = "YYYY/MM/DD",
|
|
4274
|
+
displayFormat = "YYYY/MM/DD",
|
|
4246
4275
|
size,
|
|
4247
4276
|
inputReadOnly,
|
|
4248
4277
|
hideClearButton,
|
|
@@ -4259,12 +4288,27 @@ var DateRangePicker = forwardRef8(
|
|
|
4259
4288
|
[props.name, onChange]
|
|
4260
4289
|
)
|
|
4261
4290
|
);
|
|
4291
|
+
const [displayValue, setDisplayValue] = useState7(
|
|
4292
|
+
() => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
|
|
4293
|
+
);
|
|
4262
4294
|
const [anchorEl, setAnchorEl] = useState7(null);
|
|
4263
4295
|
const open = Boolean(anchorEl);
|
|
4264
4296
|
const calendarValue = useMemo9(
|
|
4265
4297
|
() => value ? parseDates(value, format) : void 0,
|
|
4266
4298
|
[value, format]
|
|
4267
4299
|
);
|
|
4300
|
+
useEffect6(() => {
|
|
4301
|
+
if (value) {
|
|
4302
|
+
try {
|
|
4303
|
+
const dates = parseDates(value, format);
|
|
4304
|
+
const newDisplayValue = formatValueString2(dates, displayFormat);
|
|
4305
|
+
setDisplayValue(newDisplayValue);
|
|
4306
|
+
} catch (error2) {
|
|
4307
|
+
}
|
|
4308
|
+
} else {
|
|
4309
|
+
setDisplayValue("");
|
|
4310
|
+
}
|
|
4311
|
+
}, [displayFormat, value, format]);
|
|
4268
4312
|
useEffect6(() => {
|
|
4269
4313
|
if (!anchorEl) {
|
|
4270
4314
|
innerRef.current?.blur();
|
|
@@ -4275,9 +4319,41 @@ var DateRangePicker = forwardRef8(
|
|
|
4275
4319
|
]);
|
|
4276
4320
|
const handleChange = useCallback10(
|
|
4277
4321
|
(event) => {
|
|
4278
|
-
|
|
4322
|
+
const value2 = event.target.value;
|
|
4323
|
+
setDisplayValue(
|
|
4324
|
+
value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2
|
|
4325
|
+
);
|
|
4326
|
+
setValue(value2);
|
|
4279
4327
|
},
|
|
4280
|
-
[setValue]
|
|
4328
|
+
[displayFormat, format, setValue]
|
|
4329
|
+
);
|
|
4330
|
+
const handleDisplayInputChange = useCallback10(
|
|
4331
|
+
(event) => {
|
|
4332
|
+
if (event.target.value === "") {
|
|
4333
|
+
handleChange({
|
|
4334
|
+
target: {
|
|
4335
|
+
name: props.name,
|
|
4336
|
+
value: ""
|
|
4337
|
+
}
|
|
4338
|
+
});
|
|
4339
|
+
return;
|
|
4340
|
+
}
|
|
4341
|
+
const isValidDisplayValue = validValueFormat2(
|
|
4342
|
+
event.target.value,
|
|
4343
|
+
displayFormat
|
|
4344
|
+
);
|
|
4345
|
+
if (isValidDisplayValue) {
|
|
4346
|
+
const dates = parseDates(event.target.value, displayFormat);
|
|
4347
|
+
const formattedValue = formatValueString2(dates, format);
|
|
4348
|
+
handleChange({
|
|
4349
|
+
target: {
|
|
4350
|
+
name: props.name,
|
|
4351
|
+
value: formattedValue
|
|
4352
|
+
}
|
|
4353
|
+
});
|
|
4354
|
+
}
|
|
4355
|
+
},
|
|
4356
|
+
[displayFormat, format, handleChange, props.name]
|
|
4281
4357
|
);
|
|
4282
4358
|
const handleCalendarToggle = useCallback10(
|
|
4283
4359
|
(event) => {
|
|
@@ -4289,10 +4365,26 @@ var DateRangePicker = forwardRef8(
|
|
|
4289
4365
|
const handleCalendarChange = useCallback10(
|
|
4290
4366
|
([date1, date2]) => {
|
|
4291
4367
|
if (!date1 || !date2) return;
|
|
4292
|
-
|
|
4368
|
+
const formattedValue = formatValueString2([date1, date2], format);
|
|
4369
|
+
if (props.value !== void 0) {
|
|
4370
|
+
onChange?.({ target: { name: props.name, value: formattedValue } });
|
|
4371
|
+
} else {
|
|
4372
|
+
setDisplayValue(
|
|
4373
|
+
formatValueString2([date1, date2], displayFormat)
|
|
4374
|
+
);
|
|
4375
|
+
setValue(formattedValue);
|
|
4376
|
+
}
|
|
4293
4377
|
setAnchorEl(null);
|
|
4294
4378
|
},
|
|
4295
|
-
[
|
|
4379
|
+
[
|
|
4380
|
+
props.value,
|
|
4381
|
+
props.name,
|
|
4382
|
+
onChange,
|
|
4383
|
+
setValue,
|
|
4384
|
+
setAnchorEl,
|
|
4385
|
+
format,
|
|
4386
|
+
displayFormat
|
|
4387
|
+
]
|
|
4296
4388
|
);
|
|
4297
4389
|
const handleInputMouseDown = useCallback10(
|
|
4298
4390
|
(event) => {
|
|
@@ -4310,17 +4402,21 @@ var DateRangePicker = forwardRef8(
|
|
|
4310
4402
|
color: error ? "danger" : innerProps.color,
|
|
4311
4403
|
ref,
|
|
4312
4404
|
size,
|
|
4313
|
-
value,
|
|
4314
|
-
onChange:
|
|
4405
|
+
value: displayValue,
|
|
4406
|
+
onChange: handleDisplayInputChange,
|
|
4315
4407
|
disabled,
|
|
4316
4408
|
required,
|
|
4317
|
-
placeholder: `${
|
|
4409
|
+
placeholder: `${displayFormat} - ${displayFormat}`,
|
|
4318
4410
|
slotProps: {
|
|
4319
4411
|
input: {
|
|
4320
4412
|
component: TextMaskAdapter5,
|
|
4321
4413
|
ref: innerRef,
|
|
4322
|
-
format,
|
|
4323
|
-
sx: {
|
|
4414
|
+
format: displayFormat,
|
|
4415
|
+
sx: {
|
|
4416
|
+
"&:hover": {
|
|
4417
|
+
cursor: inputReadOnly || readOnly ? "default" : "text"
|
|
4418
|
+
}
|
|
4419
|
+
},
|
|
4324
4420
|
onMouseDown: handleInputMouseDown
|
|
4325
4421
|
}
|
|
4326
4422
|
},
|
|
@@ -4390,6 +4486,7 @@ var DateRangePicker = forwardRef8(
|
|
|
4390
4486
|
color: "neutral",
|
|
4391
4487
|
onClick: () => {
|
|
4392
4488
|
setValue("");
|
|
4489
|
+
setDisplayValue("");
|
|
4393
4490
|
setAnchorEl(null);
|
|
4394
4491
|
}
|
|
4395
4492
|
},
|
|
@@ -4552,7 +4649,7 @@ function CheckboxGroup(props) {
|
|
|
4552
4649
|
{
|
|
4553
4650
|
key: `${id}-${option.value}`,
|
|
4554
4651
|
label: option.label,
|
|
4555
|
-
checked: internalValue
|
|
4652
|
+
checked: internalValue?.includes(option.value),
|
|
4556
4653
|
onChange: handleCheckboxChange(option.value)
|
|
4557
4654
|
}
|
|
4558
4655
|
)));
|
|
@@ -4636,6 +4733,7 @@ function DateRange(props) {
|
|
|
4636
4733
|
disableFuture,
|
|
4637
4734
|
disablePast,
|
|
4638
4735
|
format = "YYYY/MM/DD",
|
|
4736
|
+
displayFormat,
|
|
4639
4737
|
inputReadOnly,
|
|
4640
4738
|
hideClearButton
|
|
4641
4739
|
} = props;
|
|
@@ -4790,6 +4888,7 @@ function DateRange(props) {
|
|
|
4790
4888
|
disableFuture,
|
|
4791
4889
|
disablePast,
|
|
4792
4890
|
format,
|
|
4891
|
+
displayFormat,
|
|
4793
4892
|
inputReadOnly,
|
|
4794
4893
|
hideClearButton
|
|
4795
4894
|
}
|
|
@@ -5121,21 +5220,15 @@ function PercentageRange(props) {
|
|
|
5121
5220
|
min,
|
|
5122
5221
|
max
|
|
5123
5222
|
} = props;
|
|
5124
|
-
const [internalValue, setInternalValue] = useControlledState(
|
|
5125
|
-
value,
|
|
5126
|
-
null,
|
|
5127
|
-
onChange
|
|
5128
|
-
);
|
|
5223
|
+
const [internalValue, setInternalValue] = useControlledState(value, null, onChange);
|
|
5129
5224
|
const minValue = internalValue?.[0];
|
|
5130
5225
|
const maxValue = internalValue?.[1];
|
|
5131
5226
|
const handleMinChange = useCallback17(
|
|
5132
5227
|
(event) => {
|
|
5133
5228
|
const newMinValue = event.target.value;
|
|
5134
5229
|
const currentMaxValue = maxValue;
|
|
5135
|
-
if (newMinValue !== void 0
|
|
5136
|
-
setInternalValue([newMinValue, currentMaxValue]);
|
|
5137
|
-
} else if (newMinValue !== void 0) {
|
|
5138
|
-
setInternalValue([newMinValue, newMinValue]);
|
|
5230
|
+
if (newMinValue !== void 0) {
|
|
5231
|
+
setInternalValue([newMinValue, currentMaxValue || null]);
|
|
5139
5232
|
} else {
|
|
5140
5233
|
setInternalValue(null);
|
|
5141
5234
|
}
|
|
@@ -5146,10 +5239,8 @@ function PercentageRange(props) {
|
|
|
5146
5239
|
(event) => {
|
|
5147
5240
|
const newMaxValue = event.target.value;
|
|
5148
5241
|
const currentMinValue = minValue;
|
|
5149
|
-
if (
|
|
5150
|
-
setInternalValue([currentMinValue, newMaxValue]);
|
|
5151
|
-
} else if (newMaxValue !== void 0) {
|
|
5152
|
-
setInternalValue([newMaxValue, newMaxValue]);
|
|
5242
|
+
if (newMaxValue !== void 0) {
|
|
5243
|
+
setInternalValue([currentMinValue || null, newMaxValue]);
|
|
5153
5244
|
} else {
|
|
5154
5245
|
setInternalValue(null);
|
|
5155
5246
|
}
|
|
@@ -5172,7 +5263,7 @@ function PercentageRange(props) {
|
|
|
5172
5263
|
PercentageInput,
|
|
5173
5264
|
{
|
|
5174
5265
|
label: "Minimum",
|
|
5175
|
-
value: minValue,
|
|
5266
|
+
value: minValue ?? void 0,
|
|
5176
5267
|
onChange: handleMinChange,
|
|
5177
5268
|
useMinorUnit,
|
|
5178
5269
|
maxDecimalScale,
|
|
@@ -5186,7 +5277,7 @@ function PercentageRange(props) {
|
|
|
5186
5277
|
PercentageInput,
|
|
5187
5278
|
{
|
|
5188
5279
|
label: "Maximum",
|
|
5189
|
-
value: maxValue,
|
|
5280
|
+
value: maxValue ?? void 0,
|
|
5190
5281
|
onChange: handleMaxChange,
|
|
5191
5282
|
useMinorUnit,
|
|
5192
5283
|
maxDecimalScale,
|
|
@@ -5265,6 +5356,7 @@ function FilterMenu(props) {
|
|
|
5265
5356
|
filters,
|
|
5266
5357
|
values,
|
|
5267
5358
|
defaultValues,
|
|
5359
|
+
resetValues = {},
|
|
5268
5360
|
onChange,
|
|
5269
5361
|
onClose,
|
|
5270
5362
|
useClear,
|
|
@@ -5290,11 +5382,11 @@ function FilterMenu(props) {
|
|
|
5290
5382
|
onClose?.();
|
|
5291
5383
|
}, [onChange, onClose, internalValues]);
|
|
5292
5384
|
const handleClear = useCallback19(() => {
|
|
5293
|
-
const clearedValues =
|
|
5385
|
+
const clearedValues = resetValues || {};
|
|
5294
5386
|
setInternalValues(clearedValues);
|
|
5295
5387
|
onChange?.(clearedValues);
|
|
5296
5388
|
onClose?.();
|
|
5297
|
-
}, [
|
|
5389
|
+
}, [resetValues, setInternalValues, onChange, onClose]);
|
|
5298
5390
|
return /* @__PURE__ */ React37.createElement(
|
|
5299
5391
|
ModalDialog,
|
|
5300
5392
|
{
|