@pdg/react-form 1.0.43 → 1.0.45
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/FormItemCustom/FormDateRangePicker/CustomDatePickerContainer/CustomDatePickerContainer.types.d.ts +5 -0
- package/dist/FormItemCustom/FormDateRangePicker/FormDateRangePicker.types.d.ts +5 -0
- package/dist/index.esm.js +29 -24
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,11 @@ export interface CustomDatePickerContainerProps {
|
|
|
11
11
|
disableFuture?: boolean;
|
|
12
12
|
minDate?: Dayjs;
|
|
13
13
|
maxDate?: Dayjs;
|
|
14
|
+
onGetActionButtons?(): {
|
|
15
|
+
label: string;
|
|
16
|
+
start: Dayjs;
|
|
17
|
+
end: Dayjs;
|
|
18
|
+
}[];
|
|
14
19
|
onChange(newValue: CustomDatePickerValue): void;
|
|
15
20
|
onValueChange(selectType: CustomDatePickerSelectType, newValue: CustomDatePickerDateValue): void;
|
|
16
21
|
onMonthsChange(months: CustomDatePickerContainerMonths): void;
|
|
@@ -41,6 +41,11 @@ export interface FormDateRangePickerProps extends CommonSxProps, Omit<FormValueI
|
|
|
41
41
|
minDate?: Dayjs;
|
|
42
42
|
maxDate?: Dayjs;
|
|
43
43
|
hidden?: boolean;
|
|
44
|
+
onGetActionButtons?(): {
|
|
45
|
+
label: string;
|
|
46
|
+
start: Dayjs;
|
|
47
|
+
end: Dayjs;
|
|
48
|
+
}[];
|
|
44
49
|
onChange?(value: FormDateRangePickerValue): void;
|
|
45
50
|
onValidate?(value: FormDateRangePickerValue): boolean | string;
|
|
46
51
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -10891,7 +10891,7 @@ for (var i = 0; i < 12; i += 1) {
|
|
|
10891
10891
|
MONTHS[i] = i;
|
|
10892
10892
|
}
|
|
10893
10893
|
var CustomDatePickerContainer = React__default.forwardRef(function (_a, ref) {
|
|
10894
|
-
var selectType = _a.selectType, value = _a.value, calendarCount = _a.calendarCount, months = _a.months, disablePast = _a.disablePast, disableFuture = _a.disableFuture, maxDate = _a.maxDate, minDate = _a.minDate, onChange = _a.onChange, onValueChange = _a.onValueChange, onMonthsChange = _a.onMonthsChange;
|
|
10894
|
+
var selectType = _a.selectType, value = _a.value, calendarCount = _a.calendarCount, months = _a.months, disablePast = _a.disablePast, disableFuture = _a.disableFuture, maxDate = _a.maxDate, minDate = _a.minDate, onGetActionButtons = _a.onGetActionButtons, onChange = _a.onChange, onValueChange = _a.onValueChange, onMonthsChange = _a.onMonthsChange;
|
|
10895
10895
|
var theme = useTheme();
|
|
10896
10896
|
// Ref -------------------------------------------------------------------------------------------------------------
|
|
10897
10897
|
var datePicker1Ref = useRef(null);
|
|
@@ -11049,29 +11049,34 @@ var CustomDatePickerContainer = React__default.forwardRef(function (_a, ref) {
|
|
|
11049
11049
|
}, [onChange, availableDate]);
|
|
11050
11050
|
// Render ----------------------------------------------------------------------------------------------------------
|
|
11051
11051
|
var actionButtons = useMemo(function () {
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
var dayOfWeek = now.day();
|
|
11055
|
-
var lastWeekDate;
|
|
11056
|
-
var thisWeekDate;
|
|
11057
|
-
if (dayOfWeek === 0) {
|
|
11058
|
-
lastWeekDate = [lastWeek.subtract(6, 'd'), lastWeek];
|
|
11059
|
-
thisWeekDate = [now.subtract(6, 'd'), now];
|
|
11052
|
+
if (onGetActionButtons) {
|
|
11053
|
+
return onGetActionButtons().map(function (info, idx) { return (React__default.createElement(React__default.Fragment, { key: idx }, getActionButton(info.start, info.end, info.label))); });
|
|
11060
11054
|
}
|
|
11061
11055
|
else {
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
|
|
11073
|
-
|
|
11074
|
-
|
|
11056
|
+
var now = dayjs().startOf('d');
|
|
11057
|
+
var lastWeek = now.subtract(1, 'week');
|
|
11058
|
+
var dayOfWeek = now.day();
|
|
11059
|
+
var lastWeekDate = void 0;
|
|
11060
|
+
var thisWeekDate = void 0;
|
|
11061
|
+
if (dayOfWeek === 0) {
|
|
11062
|
+
lastWeekDate = [lastWeek.subtract(6, 'd'), lastWeek];
|
|
11063
|
+
thisWeekDate = [now.subtract(6, 'd'), now];
|
|
11064
|
+
}
|
|
11065
|
+
else {
|
|
11066
|
+
lastWeekDate = [lastWeek.subtract(dayOfWeek - 1, 'd'), lastWeek.add(7 - dayOfWeek, 'd')];
|
|
11067
|
+
thisWeekDate = [now.subtract(dayOfWeek - 1, 'd'), now.add(7 - dayOfWeek, 'd')];
|
|
11068
|
+
}
|
|
11069
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
11070
|
+
getActionButton(now.subtract(1, 'month').startOf('month'), now.subtract(1, 'month').endOf('month'), '지난달'),
|
|
11071
|
+
getActionButton(now.startOf('month'), now.endOf('month'), '이번달'),
|
|
11072
|
+
getActionButton(now.subtract(29, 'd'), now, '최근 30일'),
|
|
11073
|
+
getActionButton(now.subtract(6, 'd'), now, '최근 7일'),
|
|
11074
|
+
getActionButton(lastWeekDate[0], lastWeekDate[1], '지난주'),
|
|
11075
|
+
getActionButton(thisWeekDate[0], thisWeekDate[1], '이번주'),
|
|
11076
|
+
getActionButton(now.subtract(1, 'd'), now.subtract(1, 'd'), '어제'),
|
|
11077
|
+
getActionButton(now, now, '오늘')));
|
|
11078
|
+
}
|
|
11079
|
+
}, [onGetActionButtons, getActionButton]);
|
|
11075
11080
|
return (React__default.createElement("div", { className: 'CustomDatePickerContainer' },
|
|
11076
11081
|
React__default.createElement(Grid, { container: true, direction: 'column' },
|
|
11077
11082
|
!yearSelectOpen && !monthSelectOpen && (React__default.createElement(Grid, { item: true },
|
|
@@ -11210,7 +11215,7 @@ var FormDateRangePicker = React__default.forwardRef(function (_a, ref) {
|
|
|
11210
11215
|
// ID --------------------------------------------------------------------------------------------------------------
|
|
11211
11216
|
var initVariant = _a.variant, initSize = _a.size, initColor = _a.color, initFocused = _a.focused, initLabelShrink = _a.labelShrink, initFullWidth = _a.fullWidth,
|
|
11212
11217
|
//--------------------------------------------------------------------------------------------------------------------
|
|
11213
|
-
name = _a.name, initValue = _a.value, initData = _a.data, startLabel = _a.startLabel, startLabelIcon = _a.startLabelIcon, endLabel = _a.endLabel, endLabelIcon = _a.endLabelIcon, initCalendarCount = _a.calendarCount, initFormat = _a.format, formValueFormat = _a.formValueFormat, allowSingleSelect = _a.allowSingleSelect, required = _a.required, requiredStart = _a.requiredStart, requiredEnd = _a.requiredEnd, readOnly = _a.readOnly, readOnlyStart = _a.readOnlyStart, readOnlyEnd = _a.readOnlyEnd, readOnlyInput = _a.readOnlyInput, initDisabled = _a.disabled, inputWidth = _a.inputWidth, exceptValue = _a.exceptValue, initError = _a.error, initHelperText = _a.helperText, formValueStartNameSuffix = _a.formValueStartNameSuffix, formValueEndNameSuffix = _a.formValueEndNameSuffix, icon = _a.icon, startIcon = _a.startIcon, endIcon = _a.endIcon, startAdornment = _a.startAdornment, startStartAdornment = _a.startStartAdornment, endStartAdornment = _a.endStartAdornment, endAdornment = _a.endAdornment, startEndAdornment = _a.startEndAdornment, endEndAdornment = _a.endEndAdornment, disablePast = _a.disablePast, disableFuture = _a.disableFuture, minDate = _a.minDate, maxDate = _a.maxDate, hidden = _a.hidden, onChange = _a.onChange, onValidate = _a.onValidate,
|
|
11218
|
+
name = _a.name, initValue = _a.value, initData = _a.data, startLabel = _a.startLabel, startLabelIcon = _a.startLabelIcon, endLabel = _a.endLabel, endLabelIcon = _a.endLabelIcon, initCalendarCount = _a.calendarCount, initFormat = _a.format, formValueFormat = _a.formValueFormat, allowSingleSelect = _a.allowSingleSelect, required = _a.required, requiredStart = _a.requiredStart, requiredEnd = _a.requiredEnd, readOnly = _a.readOnly, readOnlyStart = _a.readOnlyStart, readOnlyEnd = _a.readOnlyEnd, readOnlyInput = _a.readOnlyInput, initDisabled = _a.disabled, inputWidth = _a.inputWidth, exceptValue = _a.exceptValue, initError = _a.error, initHelperText = _a.helperText, formValueStartNameSuffix = _a.formValueStartNameSuffix, formValueEndNameSuffix = _a.formValueEndNameSuffix, icon = _a.icon, startIcon = _a.startIcon, endIcon = _a.endIcon, startAdornment = _a.startAdornment, startStartAdornment = _a.startStartAdornment, endStartAdornment = _a.endStartAdornment, endAdornment = _a.endAdornment, startEndAdornment = _a.startEndAdornment, endEndAdornment = _a.endEndAdornment, disablePast = _a.disablePast, disableFuture = _a.disableFuture, minDate = _a.minDate, maxDate = _a.maxDate, hidden = _a.hidden, onGetActionButtons = _a.onGetActionButtons, onChange = _a.onChange, onValidate = _a.onValidate,
|
|
11214
11219
|
// -------------------------------------------------------------------------------------------------------------------
|
|
11215
11220
|
className = _a.className;
|
|
11216
11221
|
var id = useId();
|
|
@@ -11724,7 +11729,7 @@ var FormDateRangePicker = React__default.forwardRef(function (_a, ref) {
|
|
|
11724
11729
|
},
|
|
11725
11730
|
],
|
|
11726
11731
|
}, title: React__default.createElement("div", { style: { display: 'flex' } },
|
|
11727
|
-
React__default.createElement(CustomDatePickerContainer, { ref: containerRef, calendarCount: calendarCount, selectType: selectType, value: value, months: months, disablePast: disablePast, disableFuture: disableFuture, minDate: minDate, maxDate: maxDate, onChange: handleChange, onValueChange: handleValueChange, onMonthsChange: setMonths })) },
|
|
11732
|
+
React__default.createElement(CustomDatePickerContainer, { ref: containerRef, calendarCount: calendarCount, selectType: selectType, value: value, months: months, disablePast: disablePast, disableFuture: disableFuture, minDate: minDate, maxDate: maxDate, onGetActionButtons: onGetActionButtons, onChange: handleChange, onValueChange: handleValueChange, onMonthsChange: setMonths })) },
|
|
11728
11733
|
React__default.createElement(Grid, { container: true, alignItems: 'center' },
|
|
11729
11734
|
React__default.createElement(Grid, { item: true, flex: 1 },
|
|
11730
11735
|
React__default.createElement(InputDatePicker, __assign$6({}, inputDatePickerProps, { style: inputStyle, value: value[0], label: startLabel, labelIcon: startLabelIcon, error: error || startError, focused: focused || (open && selectType === 'start'), required: required || requiredStart, readOnly: readOnly || readOnlyStart, readOnlyInput: readOnlyInput, icon: startIcon || icon, startAdornment: startStartAdornment || startAdornment, endAdornment: startEndAdornment || endAdornment, inputRef: startDateTextFieldRef, onChange: function (newValue) { return handleInputDatePickerChange('start', newValue); }, onFocus: function () { return handleInputDatePickerFocus('start'); }, onError: function (reason) { return (startInputDatePickerErrorRef.current = reason); } }))),
|