@arquimedes.co/eureka-forms 3.0.29-test → 3.0.31-date-range
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/@Types/FormStep.d.ts +4 -1
- package/dist/@Types/GenericFormSteps.d.ts +6 -0
- package/dist/App/AppHooks.js +21 -6
- package/dist/Form/Form.js +2 -6
- package/dist/Form/FormHooks.js +0 -1
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +0 -2
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +0 -2
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +0 -1
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +1 -5
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +1 -3
- package/dist/FormSteps/DatePickerRangeStep/DatePickerRangeStep.d.ts +10 -0
- package/dist/FormSteps/DatePickerRangeStep/DatePickerRangeStep.js +14 -0
- package/dist/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.d.ts +3 -0
- package/dist/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.js +27 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +0 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +0 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +0 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.js +1 -5
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +3 -12
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +1 -5
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +2 -9
- package/dist/FormSteps/Step.js +4 -0
- package/dist/FormSteps/StepFunctions.js +1 -0
- package/dist/FormSteps/StepFunctions.test.js +7 -0
- package/dist/FormSteps/StepHooks.js +3 -11
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/DraftEditor.css +2 -2
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +1 -3
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +0 -1
- package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.d.ts +2 -2
- package/dist/Shared/CustomBtn/CustomBtn.js +0 -1
- package/dist/Shared/ErkButton/ErkButton.stories.d.ts +2 -1
- package/dist/Shared/ErkButton/ErkButton.stories.js +2 -0
- package/dist/Shared/ErkCheckbox/ErkCheckBox.stories.d.ts +1 -1
- package/dist/Shared/ErkDatePicker/ErkDatePicker.stories.d.ts +1 -1
- package/dist/Shared/ErkDatePicker/ErkDatePicker.stories.js +6 -11
- package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.d.ts +18 -0
- package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.js +160 -0
- package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.stories.d.ts +36 -0
- package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.stories.js +274 -0
- package/dist/Shared/ErkSelect/ErkSelect.stories.d.ts +5 -2
- package/dist/Shared/ErkSelect/ErkSelect.stories.js +28 -5
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.stories.d.ts +1 -1
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.stories.js +10 -18
- package/dist/Shared/ErkTextField/ErkTextField.stories.d.ts +1 -1
- package/dist/Shared/ErkTextField/ErkTextField.stories.js +5 -11
- package/dist/Shared/Navbar/Navbar.stories.d.ts +1 -1
- package/dist/Shared/Rating/Rating.stories.d.ts +1 -1
- package/dist/Shared/Toggle/Toggle.js +1 -1
- package/dist/Utils/AxiosAPI.js +1 -1
- package/dist/Utils/LocaleUtils.js +1 -1
- package/dist/Utils/MaterialProviders.js +2 -2
- package/dist/Utils/store.d.ts +1 -10
- package/dist/constants/FormStepTypes.d.ts +1 -0
- package/dist/constants/FormStepTypes.js +1 -0
- package/dist/index.css +1 -0
- package/dist/main.js +7 -5
- package/package.json +46 -58
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useArgs } from '@storybook/preview-api';
|
|
3
2
|
import ErkDatePicker from './ErkDatePicker';
|
|
4
|
-
import {
|
|
5
|
-
import { userEvent } from '@storybook/testing-library';
|
|
3
|
+
import { useArgs } from 'storybook/internal/preview-api';
|
|
6
4
|
const meta = {
|
|
7
5
|
component: ErkDatePicker,
|
|
8
6
|
tags: ['autodocs'],
|
|
@@ -36,7 +34,7 @@ export const ValueAndLabel = {
|
|
|
36
34
|
args.onChange?.(value);
|
|
37
35
|
setArgs({ value });
|
|
38
36
|
};
|
|
39
|
-
return _jsx(ErkDatePicker, { ...args,
|
|
37
|
+
return _jsx(ErkDatePicker, { ...args, onChange: onValueChange });
|
|
40
38
|
},
|
|
41
39
|
};
|
|
42
40
|
export const Full = {
|
|
@@ -67,8 +65,7 @@ export const Menu = {
|
|
|
67
65
|
label: 'Label',
|
|
68
66
|
value: null,
|
|
69
67
|
},
|
|
70
|
-
play: async ({
|
|
71
|
-
const canvas = within(canvasElement);
|
|
68
|
+
play: async ({ canvas, userEvent }) => {
|
|
72
69
|
const selector = canvas.getByTestId('date-picker');
|
|
73
70
|
await userEvent.click(selector);
|
|
74
71
|
},
|
|
@@ -79,8 +76,7 @@ export const DateTimeDateMenu = {
|
|
|
79
76
|
value: null,
|
|
80
77
|
pickTime: true,
|
|
81
78
|
},
|
|
82
|
-
play: async ({
|
|
83
|
-
const canvas = within(canvasElement);
|
|
79
|
+
play: async ({ canvas, userEvent }) => {
|
|
84
80
|
const selector = canvas.getByTestId('date-picker');
|
|
85
81
|
await userEvent.click(selector);
|
|
86
82
|
},
|
|
@@ -91,11 +87,10 @@ export const DateTimeTimeMenu = {
|
|
|
91
87
|
value: null,
|
|
92
88
|
pickTime: true,
|
|
93
89
|
},
|
|
94
|
-
play: async ({
|
|
95
|
-
const canvas = within(canvasElement);
|
|
90
|
+
play: async ({ canvas, userEvent }) => {
|
|
96
91
|
const selector = canvas.getByTestId('date-picker');
|
|
97
92
|
await userEvent.click(selector);
|
|
98
|
-
const time =
|
|
93
|
+
const time = canvas.getByText('12', {
|
|
99
94
|
selector: 'h3',
|
|
100
95
|
});
|
|
101
96
|
await userEvent.click(time);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MobileDateRangePickerProps as MuiDateRangePickerProps } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
|
|
3
|
+
import { DateRange } from '@mui/x-date-pickers-pro';
|
|
4
|
+
import { ErkTextFieldProps } from '../ErkTextField/ErkTextField';
|
|
5
|
+
interface ErkDatePickerRangeProps extends Omit<MuiDateRangePickerProps<boolean>, 'ref' | 'onChange' | 'value' | 'slotProps'>, Pick<ErkTextFieldProps, 'error' | 'required' | 'helperText' | 'size'> {
|
|
6
|
+
onChange?: (dateRange: DateRange<Date>) => void;
|
|
7
|
+
value?: DateRange<Date>;
|
|
8
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
9
|
+
/** labelMargin */
|
|
10
|
+
labelMargin?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generic datepicker with apps designs. Is class due to the use in the react-hook-forms library
|
|
14
|
+
*/
|
|
15
|
+
declare class ErkDatePickerRange extends React.Component<ErkDatePickerRangeProps> {
|
|
16
|
+
render(): JSX.Element;
|
|
17
|
+
}
|
|
18
|
+
export default ErkDatePickerRange;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { styled, Dialog as MuiDialog } from '@mui/material';
|
|
4
|
+
import { DatePickerToolbar as MuiDatePickerToolbar, } from '@mui/x-date-pickers';
|
|
5
|
+
import { MobileDateRangePicker as MuiDateRangePicker, } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
|
|
6
|
+
import { DateRangePickerDay as MuiDateRangePickerDay } from '@mui/x-date-pickers-pro';
|
|
7
|
+
import { SingleInputDateRangeField } from '@mui/x-date-pickers-pro/SingleInputDateRangeField';
|
|
8
|
+
import { format } from 'date-fns';
|
|
9
|
+
import CalendarIcon from '../../Icons/CalendarIcon';
|
|
10
|
+
const StyledDateRangePicker = styled(MuiDateRangePicker, {
|
|
11
|
+
shouldForwardProp: (propName) => propName !== 'size',
|
|
12
|
+
})(({ disabled, size }) => ({
|
|
13
|
+
'& .Erk-MuiInputBase-root': {
|
|
14
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
15
|
+
'& input': {
|
|
16
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
17
|
+
paddingRight: '0px',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
'& .Erk-MuiInputBase-adornedEnd': {
|
|
21
|
+
paddingRight: '7px',
|
|
22
|
+
},
|
|
23
|
+
'& .Erk-MuiInputAdornment-root': {
|
|
24
|
+
minWidth: size === 'small' ? 24 : 26,
|
|
25
|
+
'& .Erk-MuiButtonBase-root': {
|
|
26
|
+
margin: '-2px',
|
|
27
|
+
padding: 3,
|
|
28
|
+
width: size === 'small' ? 28 : 26,
|
|
29
|
+
height: size === 'small' ? 28 : 26,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
const StyledDateToolBar = styled(MuiDatePickerToolbar)(({ theme }) => ({
|
|
34
|
+
'&.Erk-MuiPickersToolbar-root': {
|
|
35
|
+
backgroundColor: theme.palette.primary.main,
|
|
36
|
+
color: theme.palette.primary.contrastText,
|
|
37
|
+
maxWidth: 'none',
|
|
38
|
+
'& span': {
|
|
39
|
+
fontSize: '1rem',
|
|
40
|
+
textTransform: 'capitalize',
|
|
41
|
+
color: theme.palette.primary.contrastText,
|
|
42
|
+
},
|
|
43
|
+
'& .Erk-MuiDatePickerToolbar-title': {
|
|
44
|
+
margin: 'auto auto auto 0px',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
cursor: 'default',
|
|
48
|
+
'& .Erk-MuiTypography-root': {
|
|
49
|
+
textTransform: 'capitalize',
|
|
50
|
+
color: theme.palette.primary.contrastText,
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
const StyledDialog = styled(MuiDialog)(({ theme }) => ({
|
|
54
|
+
'& .Erk-MuiDialog-paper': {
|
|
55
|
+
borderRadius: '5px',
|
|
56
|
+
backgroundColor: 'transparent',
|
|
57
|
+
},
|
|
58
|
+
'& .Erk-MuiPickersLayout-root': {
|
|
59
|
+
display: 'flex',
|
|
60
|
+
flexDirection: 'column',
|
|
61
|
+
},
|
|
62
|
+
'& .Erk-MuiDialogActions-root': {
|
|
63
|
+
'& .Erk-MuiButtonBase-root': { fontWeight: 700 },
|
|
64
|
+
},
|
|
65
|
+
'& .Erk-MuiDialogContent-root': {
|
|
66
|
+
scrollbarColor: theme.palette.primary.main + ' white',
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
const StyledDay = styled(MuiDateRangePickerDay)(({ theme }) => ({
|
|
70
|
+
fontWeight: 500,
|
|
71
|
+
fontSize: '0.9rem',
|
|
72
|
+
lineHeight: 'normal',
|
|
73
|
+
'&.Erk-MuiPickersDay-today:not(.Erk-MuiDateRangePickerDay-rangeIntervalDayHighlight)': {
|
|
74
|
+
backgroundColor: theme.palette.primary.main + '33',
|
|
75
|
+
},
|
|
76
|
+
'&.Erk-MuiPickersDay-dayOutsideMonth': {
|
|
77
|
+
color: 'rgb(0,0,0,0.4)',
|
|
78
|
+
'&.Mui-selected': {
|
|
79
|
+
color: theme.palette.primary.contrastText,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
'&.Erk-MuiDateRangePickerDay-rangeIntervalDayHighlight': {
|
|
83
|
+
backgroundColor: theme.palette.primary.main + '1a',
|
|
84
|
+
},
|
|
85
|
+
}));
|
|
86
|
+
const formatDate = (date, showYear) => {
|
|
87
|
+
if (!date)
|
|
88
|
+
return '';
|
|
89
|
+
return format(date, showYear ? 'PP' : 'dd MMM');
|
|
90
|
+
};
|
|
91
|
+
function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = 'small', labelMargin = 5, value, onChange, ...others }) {
|
|
92
|
+
const [startDate, endDate] = value ?? [null, null];
|
|
93
|
+
const hasCompleteRange = Boolean(startDate) && Boolean(endDate);
|
|
94
|
+
const showYear = startDate && endDate && startDate.getFullYear() !== endDate.getFullYear();
|
|
95
|
+
const formattedStartDate = formatDate(startDate, Boolean(showYear));
|
|
96
|
+
const formattedEndDate = formatDate(endDate, Boolean(showYear));
|
|
97
|
+
const toolbarText = hasCompleteRange ? `${formattedStartDate} – ${formattedEndDate}` : '– –';
|
|
98
|
+
return (_jsx(StyledDateRangePicker, { ...others, value: value, onChange: onChange, size: size, disabled: disabled ?? readOnly, reduceAnimations: true, showDaysOutsideCurrentMonth: true, enableAccessibleFieldDOMStructure: false, slots: {
|
|
99
|
+
field: SingleInputDateRangeField,
|
|
100
|
+
day: StyledDay,
|
|
101
|
+
dialog: StyledDialog,
|
|
102
|
+
toolbar: StyledDateToolBar,
|
|
103
|
+
openPickerIcon: CalendarIcon,
|
|
104
|
+
}, slotProps: {
|
|
105
|
+
actionBar: {
|
|
106
|
+
actions: ['clear', 'accept'],
|
|
107
|
+
},
|
|
108
|
+
layout: {
|
|
109
|
+
sx: {
|
|
110
|
+
backgroundColor: '#ffffff',
|
|
111
|
+
textTransform: 'capitalize',
|
|
112
|
+
'& .Erk-MuiDayCalendar-weekDayLabel': {
|
|
113
|
+
cursor: 'default',
|
|
114
|
+
},
|
|
115
|
+
'& .Erk-MuiPickersCalendarHeader-root': {
|
|
116
|
+
marginTop: '5px',
|
|
117
|
+
},
|
|
118
|
+
'& .Erk-MuiDateCalendar-root': {
|
|
119
|
+
height: 'fit-content',
|
|
120
|
+
},
|
|
121
|
+
'& .Erk-MuiPickersToolbar-content > *:first-child': {
|
|
122
|
+
fontSize: showYear ? '1.3rem' : '1.8rem',
|
|
123
|
+
},
|
|
124
|
+
/* TODO: Remove the text "you need a license" this is only temporary */
|
|
125
|
+
'& .Erk-MuiDateRangeCalendar-root > *:first-child': {
|
|
126
|
+
display: 'none',
|
|
127
|
+
},
|
|
128
|
+
'& .Erk-MuiPickersMonth-monthButton': {
|
|
129
|
+
textTransform: 'capitalize',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
toolbar: {
|
|
134
|
+
toolbarFormat: 'eee, d MMM',
|
|
135
|
+
hidden: false,
|
|
136
|
+
toolbarPlaceholder: toolbarText,
|
|
137
|
+
},
|
|
138
|
+
textField: {
|
|
139
|
+
size,
|
|
140
|
+
error,
|
|
141
|
+
disabled,
|
|
142
|
+
helperText,
|
|
143
|
+
labelMargin,
|
|
144
|
+
fullWidth: true,
|
|
145
|
+
placeholder: '',
|
|
146
|
+
InputProps: {
|
|
147
|
+
disabled: disabled ?? readOnly,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
} }));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Generic datepicker with apps designs. Is class due to the use in the react-hook-forms library
|
|
154
|
+
*/
|
|
155
|
+
class ErkDatePickerRange extends React.Component {
|
|
156
|
+
render() {
|
|
157
|
+
return _jsx(CustomDatePickerRange, { ...this.props });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export default ErkDatePickerRange;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import ErkDatePickerRange from './ErkDatePickerRange';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
component: typeof ErkDatePickerRange;
|
|
5
|
+
tags: string[];
|
|
6
|
+
args: {
|
|
7
|
+
readOnly: false;
|
|
8
|
+
};
|
|
9
|
+
parameters: {
|
|
10
|
+
dateRange: Date[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
export declare const Empty: Story;
|
|
16
|
+
export declare const Default: Story;
|
|
17
|
+
export declare const Interactive: Story;
|
|
18
|
+
export declare const ValueAndLabel: Story;
|
|
19
|
+
export declare const Full: Story;
|
|
20
|
+
export declare const Error: Story;
|
|
21
|
+
export declare const Menu: Story;
|
|
22
|
+
export declare const WithSelectedRange: Story;
|
|
23
|
+
export declare const Disabled: Story;
|
|
24
|
+
export declare const ReadOnly: Story;
|
|
25
|
+
export declare const WithError: Story;
|
|
26
|
+
export declare const Required: Story;
|
|
27
|
+
export declare const SmallSize: Story;
|
|
28
|
+
export declare const MediumSize: Story;
|
|
29
|
+
export declare const CurrentMonth: Story;
|
|
30
|
+
export declare const LastWeek: Story;
|
|
31
|
+
export declare const NextMonth: Story;
|
|
32
|
+
export declare const WithMinMaxDates: Story;
|
|
33
|
+
export declare const YearRange: Story;
|
|
34
|
+
export declare const QuarterRange: Story;
|
|
35
|
+
export declare const EventDuration: Story;
|
|
36
|
+
export declare const MultipleStates: Story;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ErkDatePickerRange from './ErkDatePickerRange';
|
|
3
|
+
import { useArgs } from 'storybook/internal/preview-api';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
const meta = {
|
|
6
|
+
component: ErkDatePickerRange,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
readOnly: false,
|
|
10
|
+
},
|
|
11
|
+
parameters: {
|
|
12
|
+
dateRange: [new Date('2021-07-01'), new Date('2021-07-21')],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
export const Empty = {
|
|
17
|
+
args: {
|
|
18
|
+
label: 'Seleccionar Rango',
|
|
19
|
+
value: [null, null],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const Default = {
|
|
23
|
+
args: {
|
|
24
|
+
label: 'Rango de Fechas',
|
|
25
|
+
value: [new Date('2021-07-01'), new Date('2021-07-21')],
|
|
26
|
+
},
|
|
27
|
+
render: function Component(args) {
|
|
28
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
29
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export const Interactive = {
|
|
33
|
+
args: {
|
|
34
|
+
label: 'Rango Interactivo',
|
|
35
|
+
value: [null, null],
|
|
36
|
+
helperText: 'Seleccione un rango de fechas',
|
|
37
|
+
},
|
|
38
|
+
render: function Component(args) {
|
|
39
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
40
|
+
const handleChange = (newValue) => {
|
|
41
|
+
setValue(newValue);
|
|
42
|
+
args.onChange?.(newValue);
|
|
43
|
+
};
|
|
44
|
+
return (_jsxs("div", { children: [_jsx(ErkDatePickerRange, { ...args, value: value, onChange: handleChange }), _jsxs("div", { style: { marginTop: '20px', fontSize: '14px' }, children: [_jsx("strong", { children: "Valor seleccionado:" }), _jsxs("div", { children: ["Inicio: ", value[0]?.toLocaleDateString('es-ES') ?? 'No seleccionado'] }), _jsxs("div", { children: ["Fin: ", value[1]?.toLocaleDateString('es-ES') ?? 'No seleccionado'] })] })] }));
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
export const ValueAndLabel = {
|
|
48
|
+
args: {
|
|
49
|
+
label: 'Rango de Fechas',
|
|
50
|
+
value: [null, null],
|
|
51
|
+
},
|
|
52
|
+
render: function Component(args) {
|
|
53
|
+
const [, setArgs] = useArgs();
|
|
54
|
+
const onValueChange = (value) => {
|
|
55
|
+
args.onChange?.(value);
|
|
56
|
+
setArgs({ value });
|
|
57
|
+
};
|
|
58
|
+
return _jsx(ErkDatePickerRange, { ...args, onChange: onValueChange });
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
export const Full = {
|
|
62
|
+
args: {
|
|
63
|
+
label: 'Rango de Fechas',
|
|
64
|
+
value: [null, null],
|
|
65
|
+
helperText: 'Seleccione un rango de fechas',
|
|
66
|
+
},
|
|
67
|
+
render: function Component(args) {
|
|
68
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
69
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
export const Error = {
|
|
73
|
+
args: {
|
|
74
|
+
label: 'Rango de Fechas',
|
|
75
|
+
value: [null, null],
|
|
76
|
+
helperText: 'Error: Rango de fechas inválido',
|
|
77
|
+
error: true,
|
|
78
|
+
},
|
|
79
|
+
render: function Component(args) {
|
|
80
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
81
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
export const Menu = {
|
|
85
|
+
args: {
|
|
86
|
+
label: 'Rango de Fechas',
|
|
87
|
+
value: [null, null],
|
|
88
|
+
},
|
|
89
|
+
render: function Component(args) {
|
|
90
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
91
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
92
|
+
},
|
|
93
|
+
play: async ({ canvas, userEvent }) => {
|
|
94
|
+
const selector = canvas.getByTestId('date-picker');
|
|
95
|
+
await userEvent.click(selector);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
export const WithSelectedRange = {
|
|
99
|
+
args: {
|
|
100
|
+
label: 'Vacaciones',
|
|
101
|
+
value: [new Date('2024-12-20'), new Date('2025-01-05')],
|
|
102
|
+
helperText: 'Período de vacaciones',
|
|
103
|
+
},
|
|
104
|
+
render: function Component(args) {
|
|
105
|
+
const [, setArgs] = useArgs();
|
|
106
|
+
const onValueChange = (value) => {
|
|
107
|
+
args.onChange?.(value);
|
|
108
|
+
setArgs({ value });
|
|
109
|
+
};
|
|
110
|
+
return _jsx(ErkDatePickerRange, { ...args, onChange: onValueChange });
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
export const Disabled = {
|
|
114
|
+
args: {
|
|
115
|
+
label: 'Rango de Fechas',
|
|
116
|
+
value: [new Date('2021-07-01'), new Date('2021-07-21')],
|
|
117
|
+
disabled: true,
|
|
118
|
+
helperText: 'Campo deshabilitado',
|
|
119
|
+
},
|
|
120
|
+
render: function Component(args) {
|
|
121
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
122
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
export const ReadOnly = {
|
|
126
|
+
args: {
|
|
127
|
+
label: 'Rango de Fechas',
|
|
128
|
+
value: [new Date('2021-07-01'), new Date('2021-07-21')],
|
|
129
|
+
readOnly: true,
|
|
130
|
+
helperText: 'Campo de solo lectura',
|
|
131
|
+
},
|
|
132
|
+
render: function Component(args) {
|
|
133
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
134
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
export const WithError = {
|
|
138
|
+
args: {
|
|
139
|
+
label: 'Rango de Fechas',
|
|
140
|
+
value: [new Date('2021-07-21'), new Date('2021-07-01')],
|
|
141
|
+
helperText: 'La fecha de inicio debe ser anterior a la fecha de fin',
|
|
142
|
+
error: true,
|
|
143
|
+
},
|
|
144
|
+
render: function Component(args) {
|
|
145
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
146
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
export const Required = {
|
|
150
|
+
args: {
|
|
151
|
+
label: 'Rango de Fechas',
|
|
152
|
+
value: [null, null],
|
|
153
|
+
helperText: 'Este campo es obligatorio',
|
|
154
|
+
required: true,
|
|
155
|
+
},
|
|
156
|
+
render: function Component(args) {
|
|
157
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
158
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
export const SmallSize = {
|
|
162
|
+
args: {
|
|
163
|
+
label: 'Rango Pequeño',
|
|
164
|
+
value: [new Date('2021-07-01'), new Date('2021-07-21')],
|
|
165
|
+
size: 'small',
|
|
166
|
+
helperText: 'Tamaño pequeño',
|
|
167
|
+
},
|
|
168
|
+
render: function Component(args) {
|
|
169
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
170
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
export const MediumSize = {
|
|
174
|
+
args: {
|
|
175
|
+
label: 'Rango Mediano',
|
|
176
|
+
value: [new Date('2021-07-01'), new Date('2021-07-21')],
|
|
177
|
+
size: 'medium',
|
|
178
|
+
helperText: 'Tamaño mediano',
|
|
179
|
+
},
|
|
180
|
+
render: function Component(args) {
|
|
181
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
182
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
export const CurrentMonth = {
|
|
186
|
+
args: {
|
|
187
|
+
label: 'Mes Actual',
|
|
188
|
+
value: [new Date(2025, 10, 1), new Date(2025, 10, 30)],
|
|
189
|
+
helperText: 'Noviembre 2025',
|
|
190
|
+
},
|
|
191
|
+
render: function Component(args) {
|
|
192
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
193
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
export const LastWeek = {
|
|
197
|
+
args: {
|
|
198
|
+
label: 'Última Semana',
|
|
199
|
+
value: [new Date(new Date().setDate(new Date().getDate() - 7)), new Date()],
|
|
200
|
+
helperText: 'Últimos 7 días',
|
|
201
|
+
},
|
|
202
|
+
render: function Component(args) {
|
|
203
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
204
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
export const NextMonth = {
|
|
208
|
+
args: {
|
|
209
|
+
label: 'Próximo Mes',
|
|
210
|
+
value: [
|
|
211
|
+
new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1),
|
|
212
|
+
new Date(new Date().getFullYear(), new Date().getMonth() + 2, 0),
|
|
213
|
+
],
|
|
214
|
+
helperText: 'Planificación del próximo mes',
|
|
215
|
+
},
|
|
216
|
+
render: function Component(args) {
|
|
217
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
218
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
export const WithMinMaxDates = {
|
|
222
|
+
args: {
|
|
223
|
+
label: 'Reserva de Hotel',
|
|
224
|
+
value: [null, null],
|
|
225
|
+
helperText: 'Seleccione fechas entre hoy y 3 meses',
|
|
226
|
+
minDate: new Date(),
|
|
227
|
+
maxDate: new Date(new Date().setMonth(new Date().getMonth() + 3)),
|
|
228
|
+
},
|
|
229
|
+
render: function Component(args) {
|
|
230
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
231
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
export const YearRange = {
|
|
235
|
+
args: {
|
|
236
|
+
label: 'Período Fiscal',
|
|
237
|
+
value: [new Date('2025-01-01'), new Date('2025-12-31')],
|
|
238
|
+
helperText: 'Año fiscal 2025',
|
|
239
|
+
},
|
|
240
|
+
render: function Component(args) {
|
|
241
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
242
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
export const QuarterRange = {
|
|
246
|
+
args: {
|
|
247
|
+
label: 'Trimestre Q1 2025',
|
|
248
|
+
value: [new Date('2025-01-01'), new Date('2025-03-31')],
|
|
249
|
+
helperText: 'Primer trimestre del año',
|
|
250
|
+
},
|
|
251
|
+
render: function Component(args) {
|
|
252
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
253
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
export const EventDuration = {
|
|
257
|
+
args: {
|
|
258
|
+
label: 'Duración del Evento',
|
|
259
|
+
value: [new Date('2025-06-15'), new Date('2025-06-18')],
|
|
260
|
+
helperText: 'Conferencia anual (4 días)',
|
|
261
|
+
},
|
|
262
|
+
render: function Component(args) {
|
|
263
|
+
const [value, setValue] = useState(args.value ?? [null, null]);
|
|
264
|
+
return _jsx(ErkDatePickerRange, { ...args, value: value, onChange: setValue });
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
export const MultipleStates = {
|
|
268
|
+
render: function Component() {
|
|
269
|
+
const [range1, setRange1] = useState([null, null]);
|
|
270
|
+
const [range2, setRange2] = useState([new Date('2025-01-01'), new Date('2025-01-31')]);
|
|
271
|
+
const [range3, setRange3] = useState([null, null]);
|
|
272
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '20px' }, children: [_jsx(ErkDatePickerRange, { label: "Fecha de Inicio del Proyecto", value: range1, onChange: setRange1, helperText: "Seleccione el per\u00EDodo del proyecto" }), _jsx(ErkDatePickerRange, { label: "Per\u00EDodo de Pruebas", value: range2, onChange: setRange2, helperText: "Enero 2025" }), _jsx(ErkDatePickerRange, { label: "Fecha de Entrega", value: range3, onChange: setRange3, error: range3[0] === null, helperText: range3[0] === null ? 'Este campo es obligatorio' : 'Fecha confirmada', required: true })] }));
|
|
273
|
+
},
|
|
274
|
+
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import ErkSelect from './ErkSelect';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
component: typeof ErkSelect;
|
|
5
5
|
tags: string[];
|
|
6
6
|
args: {
|
|
7
7
|
readOnly: false;
|
|
8
|
+
MenuProps: {
|
|
9
|
+
disablePortal: false;
|
|
10
|
+
};
|
|
8
11
|
};
|
|
9
12
|
};
|
|
10
13
|
export default meta;
|
|
11
14
|
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const Empty: Story;
|
|
13
15
|
export declare const Default: Story;
|
|
16
|
+
export declare const Empty: Story;
|
|
14
17
|
export declare const ValueAndLabel: Story;
|
|
15
18
|
export declare const Full: Story;
|
|
16
19
|
export declare const Error: Story;
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useArgs } from '@storybook/preview-api';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import ErkSelect from './ErkSelect';
|
|
4
3
|
import { MenuItem } from '@mui/material';
|
|
4
|
+
import { useArgs } from 'storybook/internal/preview-api';
|
|
5
5
|
const meta = {
|
|
6
6
|
component: ErkSelect,
|
|
7
7
|
tags: ['autodocs'],
|
|
8
8
|
args: {
|
|
9
9
|
readOnly: false,
|
|
10
|
+
MenuProps: {
|
|
11
|
+
disablePortal: false,
|
|
12
|
+
},
|
|
10
13
|
},
|
|
11
14
|
};
|
|
12
15
|
export default meta;
|
|
13
|
-
export const Empty = {
|
|
14
|
-
args: {},
|
|
15
|
-
};
|
|
16
16
|
export const Default = {
|
|
17
17
|
args: {
|
|
18
18
|
label: 'Label',
|
|
19
19
|
},
|
|
20
|
+
render: function Component(args) {
|
|
21
|
+
const [, setArgs] = useArgs();
|
|
22
|
+
const onValueChange = (value) => {
|
|
23
|
+
args.onChange?.(value);
|
|
24
|
+
setArgs({ value });
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs(ErkSelect, { ...args, onChange: onValueChange, children: [_jsx(MenuItem, { value: 'option1', children: "Option 1" }), _jsx(MenuItem, { value: 'option2', children: "Option 2" }), _jsx(MenuItem, { value: 'option3', children: "Option 3" })] }));
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const Empty = {
|
|
30
|
+
args: {},
|
|
31
|
+
render: function Component(args) {
|
|
32
|
+
return _jsx(ErkSelect, { ...args });
|
|
33
|
+
},
|
|
20
34
|
};
|
|
21
35
|
export const ValueAndLabel = {
|
|
22
36
|
args: {
|
|
@@ -37,6 +51,9 @@ export const Full = {
|
|
|
37
51
|
label: 'Label',
|
|
38
52
|
helperText: 'Helper text',
|
|
39
53
|
},
|
|
54
|
+
render: function Component(args) {
|
|
55
|
+
return (_jsxs(ErkSelect, { ...args, children: [_jsx(MenuItem, { value: 'option1', children: "Option 1" }), _jsx(MenuItem, { value: 'option2', children: "Option 2" }), _jsx(MenuItem, { value: 'option3', children: "Option 3" })] }));
|
|
56
|
+
},
|
|
40
57
|
};
|
|
41
58
|
export const Error = {
|
|
42
59
|
args: {
|
|
@@ -44,6 +61,9 @@ export const Error = {
|
|
|
44
61
|
helperText: 'Helper text',
|
|
45
62
|
error: true,
|
|
46
63
|
},
|
|
64
|
+
render: function Component(args) {
|
|
65
|
+
return (_jsxs(ErkSelect, { ...args, children: [_jsx(MenuItem, { value: 'option1', children: "Option 1" }), _jsx(MenuItem, { value: 'option2', children: "Option 2" }), _jsx(MenuItem, { value: 'option3', children: "Option 3" })] }));
|
|
66
|
+
},
|
|
47
67
|
};
|
|
48
68
|
export const ErrorColor = {
|
|
49
69
|
args: {
|
|
@@ -51,6 +71,9 @@ export const ErrorColor = {
|
|
|
51
71
|
helperText: 'Helper text',
|
|
52
72
|
error: true,
|
|
53
73
|
},
|
|
74
|
+
render: function Component(args) {
|
|
75
|
+
return (_jsxs(ErkSelect, { ...args, children: [_jsx(MenuItem, { value: 'option1', children: "Option 1" }), _jsx(MenuItem, { value: 'option2', children: "Option 2" }), _jsx(MenuItem, { value: 'option3', children: "Option 3" })] }));
|
|
76
|
+
},
|
|
54
77
|
};
|
|
55
78
|
export const DifferentColors = {
|
|
56
79
|
args: {
|