@arquimedes.co/eureka-forms 3.0.43-test → 3.0.44-mui9
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 -2
- package/dist/@Types/GenericFormSteps.d.ts +1 -1
- package/dist/App/AppHooks.js +13 -13
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +7 -5
- package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +5 -3
- package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +7 -5
- package/dist/FormSteps/@StoryDecorators/FormStepDecorator.d.ts +9 -0
- package/dist/FormSteps/@StoryDecorators/FormStepDecorator.js +84 -0
- package/dist/FormSteps/AYFStepMapper.js +2 -2
- package/dist/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.js +3 -3
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.js +7 -5
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +1 -1
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +1 -1
- package/dist/FormSteps/StepFunctions.js +1 -1
- package/dist/Shared/ErkCheckbox/ErkCheckBox.d.ts +1 -0
- package/dist/Shared/ErkCheckbox/ErkCheckBox.js +2 -2
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +44 -33
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +4 -1
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +40 -23
- package/dist/Shared/ErkMenuItem.d.ts +1 -1
- package/dist/Shared/ErkSelect/ErkSelect.d.ts +2 -2
- package/dist/Shared/ErkTextField/ErkTextField.d.ts +17 -2
- package/dist/Shared/ErkTextField/ErkTextField.js +3 -3
- package/dist/Shared/ErkTimePicker/ErkTimePicker.js +1 -1
- package/dist/Shared/Rating/Ratings/ScaleRating.js +1 -1
- package/dist/States/GlobalSlice.d.ts +8 -26
- package/dist/States/GlobalSlice.js +3 -2
- package/dist/States/SiteSlice.d.ts +8 -33
- package/dist/States/SiteSlice.js +11 -9
- package/dist/States/WidthStatsSlice.d.ts +5 -1
- package/dist/Utils/DraftFunctions.js +1 -1
- package/dist/index.css +7 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.js +1 -1
- package/package.json +34 -33
- package/dist/Shared/ErkButton/ErkButton.stories.d.ts +0 -16
- package/dist/Shared/ErkButton/ErkButton.stories.js +0 -28
- package/dist/Shared/ErkCheckbox/ErkCheckBox.stories.d.ts +0 -13
- package/dist/Shared/ErkCheckbox/ErkCheckBox.stories.js +0 -34
- package/dist/Shared/ErkDatePicker/ErkDatePicker.stories.d.ts +0 -23
- package/dist/Shared/ErkDatePicker/ErkDatePicker.stories.js +0 -98
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.stories.d.ts +0 -36
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.stories.js +0 -274
- package/dist/Shared/ErkSelect/ErkSelect.stories.d.ts +0 -21
- package/dist/Shared/ErkSelect/ErkSelect.stories.js +0 -87
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.stories.d.ts +0 -26
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.stories.js +0 -159
- package/dist/Shared/ErkTextField/ErkTextField.stories.d.ts +0 -24
- package/dist/Shared/ErkTextField/ErkTextField.stories.js +0 -99
- package/dist/Shared/Navbar/Navbar.stories.d.ts +0 -13
- package/dist/Shared/Navbar/Navbar.stories.js +0 -13
- package/dist/Shared/Rating/Rating.stories.d.ts +0 -15
- package/dist/Shared/Rating/Rating.stories.js +0 -47
|
@@ -47,9 +47,11 @@ export interface TextInput extends GSteps.GTextInput {
|
|
|
47
47
|
}
|
|
48
48
|
export interface DatePicker extends GSteps.GDatePicker {
|
|
49
49
|
type: FormStepTypes.DATEPICKER;
|
|
50
|
+
defaultValue?: string;
|
|
50
51
|
}
|
|
51
52
|
export interface DatePickerRange extends GSteps.GDatePickerRange {
|
|
52
53
|
type: FormStepTypes.DATEPICKER_RANGE;
|
|
54
|
+
defaultValue?: string[];
|
|
53
55
|
}
|
|
54
56
|
export interface Collapsible extends GSteps.GBaseStep {
|
|
55
57
|
type: FormStepTypes.COLLAPSIBLE;
|
|
@@ -60,10 +62,10 @@ export interface Collapsible extends GSteps.GBaseStep {
|
|
|
60
62
|
export interface FormSelector extends GSteps.GBaseStep {
|
|
61
63
|
type: FormStepTypes.SELECTOR;
|
|
62
64
|
label: string;
|
|
63
|
-
description: string;
|
|
65
|
+
description: string | null;
|
|
64
66
|
required: boolean;
|
|
65
67
|
searchable: boolean;
|
|
66
|
-
options: FormSelectorOption[];
|
|
68
|
+
options: readonly FormSelectorOption[];
|
|
67
69
|
size: 1 | 2 | 3 | 4;
|
|
68
70
|
maxSize?: number;
|
|
69
71
|
defaultValue?: string;
|
package/dist/App/AppHooks.js
CHANGED
|
@@ -57,33 +57,33 @@ export const useSetupApp = (isEmbedded, props) => {
|
|
|
57
57
|
idOrganization = match ? match[1] : '';
|
|
58
58
|
}
|
|
59
59
|
if (form) {
|
|
60
|
-
form = createNextState(form, (
|
|
61
|
-
const firstSection =
|
|
62
|
-
if (firstSection.steps === undefined &&
|
|
63
|
-
firstSection.steps =
|
|
60
|
+
form = createNextState(form, (draft) => {
|
|
61
|
+
const firstSection = draft.sections[draft.firstSection];
|
|
62
|
+
if (firstSection.steps === undefined && draft.rootSteps !== undefined) {
|
|
63
|
+
firstSection.steps = draft.rootSteps;
|
|
64
64
|
}
|
|
65
65
|
//If a rootStep is a mapper of type section
|
|
66
|
-
if (
|
|
67
|
-
|
|
66
|
+
if (classifiers)
|
|
67
|
+
draft.classifiers = classifiers;
|
|
68
68
|
/** Assign the idSection to all the forms steps */
|
|
69
|
-
for (const section of Object.values(
|
|
69
|
+
for (const section of Object.values(draft.sections)) {
|
|
70
70
|
for (const idStep of section.steps) {
|
|
71
|
-
iterateNestedSteps(idStep,
|
|
71
|
+
iterateNestedSteps(idStep, draft.steps, (step, path) => {
|
|
72
72
|
step.idSection = section.id;
|
|
73
73
|
step.stepPath = path;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
for (const idStep of
|
|
77
|
-
iterateNestedSteps(idStep,
|
|
76
|
+
for (const idStep of draft.hiddenSteps ?? []) {
|
|
77
|
+
iterateNestedSteps(idStep, draft.steps, (step, path) => {
|
|
78
78
|
step.idSection = section.id;
|
|
79
79
|
step.stepPath = path;
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
const CBRStep = Object.values(form.steps).find((step) => step.type.startsWith('CBR'));
|
|
84
|
-
if (CBRStep)
|
|
85
|
-
form = calcCbrForm(form, valuesData ?? {});
|
|
86
83
|
});
|
|
84
|
+
const CBRStep = Object.values(form.steps).find((step) => step.type.startsWith('CBR'));
|
|
85
|
+
if (CBRStep)
|
|
86
|
+
form = calcCbrForm(form, valuesData ?? {});
|
|
87
87
|
}
|
|
88
88
|
setForm(form);
|
|
89
89
|
if (!form || !idOrganization)
|
|
@@ -46,11 +46,13 @@ function ConfirmationDialog({ onClose, confirmation, customConfirmation }) {
|
|
|
46
46
|
fontSize: widthStats.isMobile ? '1rem' : '1.2rem',
|
|
47
47
|
}, children: confirmation.url })] }));
|
|
48
48
|
};
|
|
49
|
-
return (_jsx(Dialog, {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
return (_jsx(Dialog, { slotProps: {
|
|
50
|
+
paper: {
|
|
51
|
+
style: {
|
|
52
|
+
borderRadius: '20px',
|
|
53
|
+
maxWidth: '100vw',
|
|
54
|
+
boxSizing: 'content-box',
|
|
55
|
+
},
|
|
54
56
|
},
|
|
55
57
|
}, open: true, children: _jsxs("div", { className: styles.confirmationContainer, style: {
|
|
56
58
|
color: '#293241',
|
|
@@ -44,9 +44,11 @@ function TermComponent({ term, tempError }) {
|
|
|
44
44
|
return parts;
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Dialog, {
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
return (_jsxs(React.Fragment, { children: [_jsx(Dialog, { slotProps: {
|
|
48
|
+
paper: {
|
|
49
|
+
style: {
|
|
50
|
+
borderRadius: '20px',
|
|
51
|
+
},
|
|
50
52
|
},
|
|
51
53
|
}, onClose: () => {
|
|
52
54
|
setShowDialog(false);
|
|
@@ -66,11 +66,13 @@ function CBRPropertyStepComponent(props) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
: undefined, getOptions: getInmueblesOptions }), showWarning !== undefined && (_jsx(Dialog, {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
: undefined, getOptions: getInmueblesOptions }), showWarning !== undefined && (_jsx(Dialog, { slotProps: {
|
|
70
|
+
paper: {
|
|
71
|
+
style: {
|
|
72
|
+
borderRadius: '20px',
|
|
73
|
+
maxWidth: '100vw',
|
|
74
|
+
boxSizing: 'content-box',
|
|
75
|
+
},
|
|
74
76
|
},
|
|
75
77
|
}, open: true, children: _jsxs("div", { className: styles.confirmationContainer, style: { color: formStyle.textColor }, children: [_jsx("div", { className: styles.closeIcon, onClick: () => {
|
|
76
78
|
setShowWarning(undefined);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form } from '../../@Types';
|
|
3
|
+
/** Minimal form object shared across FormStep stories */
|
|
4
|
+
export declare const storyForm: Form;
|
|
5
|
+
/**
|
|
6
|
+
* Decorator for FormStep stories.
|
|
7
|
+
* Provides: Redux store, form ID, react-hook-form, FormContext, SectionContext.
|
|
8
|
+
*/
|
|
9
|
+
export declare function withFormStepProviders(Story: React.ComponentType): JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Provider } from 'react-redux';
|
|
3
|
+
import { useForm, FormProvider } from 'react-hook-form';
|
|
4
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
5
|
+
import { EurekaFormsReducer, defaultRootState } from '../../Utils/store';
|
|
6
|
+
import { RootApi } from '../../Utils/_api';
|
|
7
|
+
import FormStepTypes from '../../constants/FormStepTypes';
|
|
8
|
+
import { StoreContext } from '../../Utils/StoreContext';
|
|
9
|
+
import { IdFormContext } from '../../Contexts/FormContext';
|
|
10
|
+
import FormContext from '../../Contexts/FormContext';
|
|
11
|
+
import SectionContext from '../../Contexts/SectionContext';
|
|
12
|
+
const STORY_FORM_ID = 'STORY_FORM';
|
|
13
|
+
/** Minimal form object shared across FormStep stories */
|
|
14
|
+
export const storyForm = {
|
|
15
|
+
firstSection: 'SECTION_1',
|
|
16
|
+
sections: {
|
|
17
|
+
SECTION_1: {
|
|
18
|
+
id: 'SECTION_1',
|
|
19
|
+
name: 'Sección 1',
|
|
20
|
+
steps: [],
|
|
21
|
+
nextSection: null,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
steps: {
|
|
25
|
+
'inner-step-1': {
|
|
26
|
+
id: 'inner-step-1',
|
|
27
|
+
idSection: 'SECTION_1',
|
|
28
|
+
stepPath: ['inner-step-1'],
|
|
29
|
+
type: FormStepTypes.TEXTINPUT,
|
|
30
|
+
label: 'Campo interior 1',
|
|
31
|
+
description: null,
|
|
32
|
+
required: false,
|
|
33
|
+
size: 4,
|
|
34
|
+
editable: true,
|
|
35
|
+
},
|
|
36
|
+
'inner-step-2': {
|
|
37
|
+
id: 'inner-step-2',
|
|
38
|
+
idSection: 'SECTION_1',
|
|
39
|
+
stepPath: ['inner-step-2'],
|
|
40
|
+
type: FormStepTypes.TEXTINPUT,
|
|
41
|
+
label: 'Campo interior 2',
|
|
42
|
+
description: null,
|
|
43
|
+
required: false,
|
|
44
|
+
size: 4,
|
|
45
|
+
editable: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
confirmationMessage: {
|
|
49
|
+
blocks: [],
|
|
50
|
+
entityMap: {},
|
|
51
|
+
},
|
|
52
|
+
showLink: false,
|
|
53
|
+
size: {
|
|
54
|
+
blockSize: 200,
|
|
55
|
+
blockNum: 4,
|
|
56
|
+
spacingSize: 10,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
function createStoryStore() {
|
|
60
|
+
return configureStore({
|
|
61
|
+
reducer: {
|
|
62
|
+
forms: EurekaFormsReducer,
|
|
63
|
+
[RootApi.reducerPath]: RootApi.reducer,
|
|
64
|
+
},
|
|
65
|
+
preloadedState: {
|
|
66
|
+
forms: {
|
|
67
|
+
[STORY_FORM_ID]: defaultRootState,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(RootApi.middleware),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Decorator for FormStep stories.
|
|
75
|
+
* Provides: Redux store, form ID, react-hook-form, FormContext, SectionContext.
|
|
76
|
+
*/
|
|
77
|
+
export function withFormStepProviders(Story) {
|
|
78
|
+
const store = createStoryStore();
|
|
79
|
+
function FormStepWrapper({ children }) {
|
|
80
|
+
const methods = useForm({ mode: 'onChange' });
|
|
81
|
+
return _jsx(FormProvider, { ...methods, children: children });
|
|
82
|
+
}
|
|
83
|
+
return (_jsx(Provider, { store: store, context: StoreContext, children: _jsx(IdFormContext.Provider, { value: STORY_FORM_ID, children: _jsx(FormContext.Provider, { value: storyForm, children: _jsx(SectionContext.Provider, { value: "SECTION_1", children: _jsx(FormStepWrapper, { children: _jsx(Story, {}) }) }) }) }) }));
|
|
84
|
+
}
|
|
@@ -64,7 +64,7 @@ function AYFStepMapper(props) {
|
|
|
64
64
|
switch (props.step.type) {
|
|
65
65
|
case AYFFormStepTypes.AYF_START_MONTH:
|
|
66
66
|
case AYFFormStepTypes.AYF_END_MONTH:
|
|
67
|
-
return (_jsx(SmartSelectStep, { ...props, step: props.step, getOptions: getMonths, getOptionSelected: (option, value) => option.id === value.id, defaultValue: props.step.type === AYFFormStepTypes.AYF_START_MONTH
|
|
67
|
+
return (_jsx(SmartSelectStep, { ...props, step: { ...props.step, searchable: false }, getOptions: getMonths, getOptionSelected: (option, value) => option.id === value.id, defaultValue: props.step.type === AYFFormStepTypes.AYF_START_MONTH
|
|
68
68
|
? { id: '1', label: 'Enero' }
|
|
69
69
|
: { id: '12', label: 'Diciembre' }, getValueString: (value) => value?.id, IconComponent: () => _jsx(CalendarIcon, {}) }));
|
|
70
70
|
case AYFFormStepTypes.AYF_YEAR:
|
|
@@ -78,7 +78,7 @@ function AYFStepMapper(props) {
|
|
|
78
78
|
case AYFFormStepTypes.AYF_CUT_OFF_DATE:
|
|
79
79
|
return _jsx(DatePickerStep, { ...props, step: props.step, defaultValue: new Date().toString() });
|
|
80
80
|
case AYFFormStepTypes.AYF_ICA_CITY:
|
|
81
|
-
return (_jsx(SmartSelectStep, { ...props, step: props.step, getOptions: getCiudadesOptions, getOptionSelected: (option, value) => option === value, getValueString: (value) => value, IconComponent: () => _jsx(LocationIcon, {}) }));
|
|
81
|
+
return (_jsx(SmartSelectStep, { ...props, step: { ...props.step, searchable: false }, getOptions: getCiudadesOptions, getOptionSelected: (option, value) => option === value, getValueString: (value) => value, IconComponent: () => _jsx(LocationIcon, {}) }));
|
|
82
82
|
default:
|
|
83
83
|
return _jsx("div", {});
|
|
84
84
|
}
|
|
@@ -20,11 +20,11 @@ function MaterialDatePickerRangeStep({ step, editable, defaultValue }) {
|
|
|
20
20
|
});
|
|
21
21
|
const handleChange = useCallback((dateRange) => {
|
|
22
22
|
const [start, end] = dateRange;
|
|
23
|
-
if (start && end) {
|
|
24
|
-
onChange(
|
|
23
|
+
if (!start && !end) {
|
|
24
|
+
onChange(null);
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
onChange(null);
|
|
27
|
+
onChange([start?.toISOString() ?? null, end?.toISOString() ?? null]);
|
|
28
28
|
}
|
|
29
29
|
}, [onChange]);
|
|
30
30
|
const [minDate, maxDate] = [safeDate(step.minDate), safeDate(step.maxDate)];
|
|
@@ -18,11 +18,13 @@ function MaterialEntityValueDialog({ type, entity, message, entityValue, handleC
|
|
|
18
18
|
const editorState = useMemo(() => {
|
|
19
19
|
return EditorState.createWithContent(convertFromRaw(mapDraftEntities({ form, dependencies, entity, entityValue }, message)));
|
|
20
20
|
}, [form, message, dependencies, entity, entityValue]);
|
|
21
|
-
return (_jsx(Dialog, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
return (_jsx(Dialog, { slotProps: {
|
|
22
|
+
paper: {
|
|
23
|
+
style: {
|
|
24
|
+
borderRadius: '20px',
|
|
25
|
+
maxWidth: '100vw',
|
|
26
|
+
boxSizing: 'content-box',
|
|
27
|
+
},
|
|
26
28
|
},
|
|
27
29
|
}, open: true, children: _jsxs("div", { className: styles.confirmationContainer, style: { color: formStyle.textColor }, children: [_jsx("div", { className: styles.closeIcon, onClick: () => handleClose(), children: _jsx(CloseIcon, { style: { fontSize: 'inherit' } }) }), _jsxs("div", { className: styles.container, children: [_jsxs("div", { className: styles.contentContainer, children: [_jsx("div", { className: styles.warningContainer, style: {
|
|
28
30
|
color: type === 'INFO' ? formStyle.primaryColor : formStyle.errorColor,
|
|
@@ -58,7 +58,7 @@ function FileUploadStep({ step, editable }) {
|
|
|
58
58
|
postFile(pFile.file, pFile.postInfo),
|
|
59
59
|
new Promise((resolve) => setTimeout(resolve, 1000)),
|
|
60
60
|
]);
|
|
61
|
-
setFileChange(
|
|
61
|
+
setFileChange((prev) => prev.map((f) => (f.file === pFile.file ? { ...f, state: 'DONE', ...resp[0] } : f)));
|
|
62
62
|
}
|
|
63
63
|
catch (error) {
|
|
64
64
|
console.error(error);
|
|
@@ -64,7 +64,7 @@ function SelectorStep({ step, editable }) {
|
|
|
64
64
|
}
|
|
65
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
66
|
}, [filteredOptions]);
|
|
67
|
-
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkSmartSelect, { ...field, value: value, inputRef: ref, error: !!error, label: step.label, onChange: onChange, required: step.required, options: filteredOptions, searchable: step.searchable, readOnly: !editable || postview, helperText: error?.message?.toString() ?? step.description, getOptionSelected: (option, value) => option?.value === value?.value }) }), value && mapNestedOption()] }));
|
|
67
|
+
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkSmartSelect, { ...field, value: value, inputRef: ref, error: !!error, label: step.label, onChange: onChange, required: step.required, options: filteredOptions, searchable: step.searchable, readOnly: !editable || postview, helperText: error?.message?.toString() ?? step.description ?? undefined, getOptionSelected: (option, value) => option?.value === value?.value }) }), value && mapNestedOption()] }));
|
|
68
68
|
}
|
|
69
69
|
function SelectorStepContainer(props) {
|
|
70
70
|
return (_jsx(StepFillerContainer, { step: props.step, children: _jsx(SelectorStep, { ...props }) }));
|
|
@@ -483,7 +483,7 @@ const evaluateEntityPropertyCondition = (condition, entity, entityValue) => {
|
|
|
483
483
|
return !boolFactor;
|
|
484
484
|
}
|
|
485
485
|
const property = entity.steps[condition.idProperty];
|
|
486
|
-
if (
|
|
486
|
+
if (property?.type !== condition.propertyType) {
|
|
487
487
|
return false;
|
|
488
488
|
}
|
|
489
489
|
const value = entityValue[condition.idProperty];
|
|
@@ -9,6 +9,7 @@ interface ErkCheckboxProps extends Omit<StyleProps, 'error'>, Omit<MuiCheckboxPr
|
|
|
9
9
|
onChange?: (checked: boolean) => void;
|
|
10
10
|
checked: boolean;
|
|
11
11
|
error?: boolean;
|
|
12
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Generic datepicker with apps designs. Is class due to the use in the react-hook-forms library
|
|
@@ -17,8 +17,8 @@ const StyledCheckbox = styled(MuiCheckbox, { shouldForwardProp: (prop) => prop !
|
|
|
17
17
|
/**
|
|
18
18
|
* Generic capta checkbox
|
|
19
19
|
*/
|
|
20
|
-
function CustomCheckBox({ onChange, error = false, readOnly = false, disabled = false, ...others }) {
|
|
21
|
-
return (_jsx(FormControl, { error: true, children: _jsx(StyledCheckbox, { ...others, error: +error, readOnly: readOnly, disabled: disabled,
|
|
20
|
+
function CustomCheckBox({ onChange, error = false, readOnly = false, disabled = false, inputRef, ...others }) {
|
|
21
|
+
return (_jsx(FormControl, { error: true, children: _jsx(StyledCheckbox, { ...others, error: +error, readOnly: readOnly, disabled: disabled, slotProps: { input: { disabled: disabled ?? readOnly, ref: inputRef } }, icon: _jsx(CheckboxUncheckedIcon, {}), checkedIcon: _jsx(CheckboxCheckedIcon, {}), onChange: (event) => onChange?.(typeof event === 'boolean' ? event : event.target.checked) }) }));
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Generic datepicker with apps designs. Is class due to the use in the react-hook-forms library
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React, {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { format as dateFnsFormat, isValid } from 'date-fns';
|
|
4
|
+
import { InputAdornment, styled, Dialog as MuiDialog } from '@mui/material';
|
|
5
|
+
import { MobileDatePicker as MuiDatePicker, MobileDateTimePicker as MuiDateTimePicker, DatePickerToolbar as MuiDatePickerToolbar, DateTimePickerToolbar as MuiDateTimePickerToolbar, usePickerContext, } from '@mui/x-date-pickers';
|
|
6
|
+
import { PickerDay as MuiPickerDay } from '@mui/x-date-pickers/PickerDay';
|
|
5
7
|
import { StyledTextField } from '../ErkTextField/ErkTextField';
|
|
6
8
|
import CalendarIcon from '../../Icons/CalendarIcon';
|
|
7
9
|
import { renderTimeViewClock } from '@mui/x-date-pickers/timeViewRenderers';
|
|
@@ -136,17 +138,36 @@ const StyledDay = styled(MuiPickerDay)(({ theme }) => ({
|
|
|
136
138
|
},
|
|
137
139
|
},
|
|
138
140
|
}));
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
const
|
|
141
|
+
function CustomPickerField({ error, required, helperText, size = 'small', labelMargin = 5, inputRef, fullWidth = true, }) {
|
|
142
|
+
const { value, fieldFormat, setOpen, disabled, readOnly, label } = usePickerContext();
|
|
143
|
+
const { displayValue, isInvalid } = useMemo(() => {
|
|
144
|
+
if (!value)
|
|
145
|
+
return { displayValue: '', isInvalid: false };
|
|
146
|
+
if (!isValid(value))
|
|
147
|
+
return { displayValue: '', isInvalid: true };
|
|
148
|
+
try {
|
|
149
|
+
return { displayValue: dateFnsFormat(value, fieldFormat ?? 'P'), isInvalid: false };
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return { displayValue: '', isInvalid: true };
|
|
153
|
+
}
|
|
154
|
+
}, [value, fieldFormat]);
|
|
142
155
|
const handleClick = () => {
|
|
143
|
-
if (!
|
|
144
|
-
|
|
156
|
+
if (!disabled && !readOnly) {
|
|
157
|
+
setOpen((prev) => !prev);
|
|
145
158
|
}
|
|
146
159
|
};
|
|
147
|
-
return _jsx(StyledTextField, {
|
|
148
|
-
|
|
149
|
-
|
|
160
|
+
return (_jsx(StyledTextField, { value: displayValue, label: label, disabled: disabled, readOnly: readOnly, error: isInvalid || error, required: required, helperText: isInvalid ? 'Fecha inválida' : helperText, size: size, labelMargin: labelMargin, inputRef: inputRef, onClick: handleClick, fullWidth: fullWidth, placeholder: "", slotProps: {
|
|
161
|
+
input: {
|
|
162
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(CalendarIcon, { style: {
|
|
163
|
+
fontSize: size === 'small' ? 18 : 20,
|
|
164
|
+
opacity: disabled || readOnly ? 0.5 : 1,
|
|
165
|
+
} }) })),
|
|
166
|
+
readOnly: true,
|
|
167
|
+
},
|
|
168
|
+
} }));
|
|
169
|
+
}
|
|
170
|
+
function CustomDatePicker({ error, required, disabled, readOnly, helperText, size = 'small', labelMargin = 5, pickTime = false, inputRef,
|
|
150
171
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
151
172
|
orientation: _orientation, ...others }) {
|
|
152
173
|
if (pickTime) {
|
|
@@ -189,18 +210,14 @@ orientation: _orientation, ...others }) {
|
|
|
189
210
|
hidden: false,
|
|
190
211
|
toolbarPlaceholder: '– –',
|
|
191
212
|
},
|
|
192
|
-
|
|
213
|
+
field: {
|
|
193
214
|
error,
|
|
194
|
-
|
|
195
|
-
disabled,
|
|
196
|
-
readOnly: !disabled && readOnly,
|
|
215
|
+
required,
|
|
197
216
|
helperText,
|
|
217
|
+
size,
|
|
198
218
|
labelMargin,
|
|
199
|
-
placeholder: '',
|
|
200
219
|
fullWidth: true,
|
|
201
|
-
|
|
202
|
-
readOnly: !disabled && readOnly,
|
|
203
|
-
},
|
|
220
|
+
inputRef,
|
|
204
221
|
},
|
|
205
222
|
}, viewRenderers: {
|
|
206
223
|
hours: renderTimeViewClock,
|
|
@@ -210,9 +227,8 @@ orientation: _orientation, ...others }) {
|
|
|
210
227
|
day: StyledDay,
|
|
211
228
|
dialog: StyledDialog,
|
|
212
229
|
toolbar: StyledDateTimeToolBar,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}, enableAccessibleFieldDOMStructure: false }));
|
|
230
|
+
field: CustomPickerField,
|
|
231
|
+
} }));
|
|
216
232
|
}
|
|
217
233
|
else {
|
|
218
234
|
return (_jsx(StyledDatePicker, { ...others, size: size, reduceAnimations: true, readOnly: readOnly, disabled: disabled, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, views: ['year', 'month', 'day'], slotProps: {
|
|
@@ -244,26 +260,21 @@ orientation: _orientation, ...others }) {
|
|
|
244
260
|
hidden: false,
|
|
245
261
|
toolbarPlaceholder: '– –',
|
|
246
262
|
},
|
|
247
|
-
|
|
248
|
-
size,
|
|
263
|
+
field: {
|
|
249
264
|
error,
|
|
250
|
-
|
|
251
|
-
readOnly: !disabled && readOnly,
|
|
265
|
+
required,
|
|
252
266
|
helperText,
|
|
267
|
+
size,
|
|
253
268
|
labelMargin,
|
|
254
269
|
fullWidth: true,
|
|
255
|
-
|
|
256
|
-
InputProps: {
|
|
257
|
-
readOnly: !disabled && readOnly,
|
|
258
|
-
},
|
|
270
|
+
inputRef,
|
|
259
271
|
},
|
|
260
272
|
}, slots: {
|
|
261
273
|
day: StyledDay,
|
|
262
274
|
dialog: StyledDialog,
|
|
263
275
|
toolbar: StyledDateToolBar,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}, enableAccessibleFieldDOMStructure: false }));
|
|
276
|
+
field: CustomPickerField,
|
|
277
|
+
} }));
|
|
267
278
|
}
|
|
268
279
|
}
|
|
269
280
|
/**
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MobileDateRangePickerProps as MuiDateRangePickerProps } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
|
|
3
3
|
import { DateRange } from '@mui/x-date-pickers-pro';
|
|
4
|
+
import { PickersShortcutsItem } from '@mui/x-date-pickers/PickersShortcuts';
|
|
4
5
|
import { ErkTextFieldProps } from '../ErkTextField/ErkTextField';
|
|
5
|
-
interface ErkDateRangePickerProps extends Omit<MuiDateRangePickerProps
|
|
6
|
+
interface ErkDateRangePickerProps extends Omit<MuiDateRangePickerProps, 'ref' | 'onChange' | 'value' | 'slotProps'>, Pick<ErkTextFieldProps, 'error' | 'required' | 'helperText' | 'size'> {
|
|
6
7
|
onChange?: (dateRange: DateRange<Date>) => void;
|
|
7
8
|
value?: DateRange<Date>;
|
|
8
9
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
9
10
|
/** labelMargin */
|
|
10
11
|
labelMargin?: number;
|
|
12
|
+
/** Shortcuts to display in the picker */
|
|
13
|
+
shortcuts?: PickersShortcutsItem<DateRange<Date>>[];
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Generic datepicker with apps designs. Is class due to the use in the react-hook-forms library
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { styled, Dialog as MuiDialog } from '@mui/material';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { InputAdornment, styled, Dialog as MuiDialog } from '@mui/material';
|
|
4
4
|
import { DatePickerToolbar as MuiDatePickerToolbar, usePickerContext, } from '@mui/x-date-pickers';
|
|
5
5
|
import { MobileDateRangePicker as MuiDateRangePicker, } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
|
|
6
6
|
import { DateRangePickerDay as MuiDateRangePickerDay } from '@mui/x-date-pickers-pro';
|
|
7
|
-
import { SingleInputDateRangeField } from '@mui/x-date-pickers-pro/SingleInputDateRangeField';
|
|
8
7
|
import { format, isValid } from 'date-fns';
|
|
9
8
|
import { StyledTextField } from '../ErkTextField/ErkTextField';
|
|
10
9
|
import CalendarIcon from '../../Icons/CalendarIcon';
|
|
@@ -85,22 +84,47 @@ const StyledDay = styled(MuiDateRangePickerDay)(({ theme }) => ({
|
|
|
85
84
|
backgroundColor: theme.palette.primary.main + '1a',
|
|
86
85
|
},
|
|
87
86
|
}));
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const
|
|
87
|
+
const CustomRangePickerField = React.forwardRef(function CustomRangePickerField({ error, required, helperText, size = 'small', labelMargin = 5, fullWidth = true, inputRef, }, ref) {
|
|
88
|
+
const { value, fieldFormat, setOpen, disabled, readOnly, label } = usePickerContext();
|
|
89
|
+
const { displayValue, isInvalid } = useMemo(() => {
|
|
90
|
+
const [startDate, endDate] = value ?? [null, null];
|
|
91
|
+
if (!startDate)
|
|
92
|
+
return { displayValue: '', isInvalid: false };
|
|
93
|
+
if (!isValid(startDate))
|
|
94
|
+
return { displayValue: '', isInvalid: true };
|
|
95
|
+
if (endDate && !isValid(endDate))
|
|
96
|
+
return { displayValue: '', isInvalid: true };
|
|
97
|
+
try {
|
|
98
|
+
const fmt = fieldFormat ?? 'P';
|
|
99
|
+
const start = format(startDate, fmt);
|
|
100
|
+
const end = endDate ? format(endDate, fmt) : '';
|
|
101
|
+
return { displayValue: end ? `${start} – ${end}` : start, isInvalid: false };
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return { displayValue: '', isInvalid: true };
|
|
105
|
+
}
|
|
106
|
+
}, [value, fieldFormat]);
|
|
91
107
|
const handleClick = () => {
|
|
92
|
-
if (!
|
|
93
|
-
|
|
108
|
+
if (!disabled && !readOnly) {
|
|
109
|
+
setOpen((prev) => !prev);
|
|
94
110
|
}
|
|
95
111
|
};
|
|
96
|
-
return _jsx(StyledTextField, {
|
|
112
|
+
return (_jsx(StyledTextField, { ref: ref, value: displayValue, label: label, disabled: disabled, readOnly: readOnly, error: isInvalid || error, required: required, helperText: isInvalid ? 'Fecha inválida' : helperText, size: size, labelMargin: labelMargin, inputRef: inputRef, onClick: handleClick, fullWidth: fullWidth, placeholder: "", slotProps: {
|
|
113
|
+
input: {
|
|
114
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(CalendarIcon, { style: {
|
|
115
|
+
fontSize: size === 'small' ? 18 : 20,
|
|
116
|
+
opacity: disabled || readOnly ? 0.5 : 1,
|
|
117
|
+
} }) })),
|
|
118
|
+
readOnly: true,
|
|
119
|
+
},
|
|
120
|
+
} }));
|
|
97
121
|
});
|
|
98
122
|
const formatDate = (date, showYear) => {
|
|
99
123
|
if (!date || !isValid(date))
|
|
100
124
|
return '';
|
|
101
125
|
return format(date, showYear ? 'PP' : 'dd MMM');
|
|
102
126
|
};
|
|
103
|
-
function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = 'small', labelMargin = 5, value, onChange, ...others }) {
|
|
127
|
+
function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = 'small', labelMargin = 5, value, onChange, inputRef, shortcuts, ...others }) {
|
|
104
128
|
const [startDate, endDate] = value ?? [null, null];
|
|
105
129
|
const hasCompleteRange = Boolean(startDate) && Boolean(endDate);
|
|
106
130
|
const showYear = startDate &&
|
|
@@ -111,19 +135,16 @@ function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = '
|
|
|
111
135
|
const formattedStartDate = formatDate(startDate, Boolean(showYear));
|
|
112
136
|
const formattedEndDate = formatDate(endDate, Boolean(showYear));
|
|
113
137
|
const toolbarText = hasCompleteRange ? `${formattedStartDate} – ${formattedEndDate}` : '– –';
|
|
114
|
-
return (_jsx(StyledDateRangePicker, { ...others, value: value, onChange: onChange, size: size, disabled: disabled, readOnly: readOnly, reduceAnimations: true, showDaysOutsideCurrentMonth: true,
|
|
115
|
-
|
|
116
|
-
shortcuts: undefined,
|
|
117
|
-
field: SingleInputDateRangeField,
|
|
138
|
+
return (_jsx(StyledDateRangePicker, { ...others, value: value, onChange: onChange, size: size, disabled: disabled, readOnly: readOnly, reduceAnimations: true, showDaysOutsideCurrentMonth: true, slots: {
|
|
139
|
+
field: CustomRangePickerField,
|
|
118
140
|
day: StyledDay,
|
|
119
141
|
dialog: StyledDialog,
|
|
120
142
|
toolbar: StyledDateToolBar,
|
|
121
|
-
openPickerIcon: CalendarIcon,
|
|
122
|
-
textField: CustomTextField,
|
|
123
143
|
}, slotProps: {
|
|
124
144
|
actionBar: {
|
|
125
145
|
actions: ['clear', 'accept'],
|
|
126
146
|
},
|
|
147
|
+
shortcuts: shortcuts ? { items: shortcuts } : undefined,
|
|
127
148
|
layout: {
|
|
128
149
|
sx: {
|
|
129
150
|
backgroundColor: '#ffffff',
|
|
@@ -154,18 +175,14 @@ function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = '
|
|
|
154
175
|
hidden: false,
|
|
155
176
|
toolbarPlaceholder: toolbarText,
|
|
156
177
|
},
|
|
157
|
-
|
|
178
|
+
field: {
|
|
158
179
|
size,
|
|
159
180
|
error,
|
|
160
|
-
|
|
161
|
-
readOnly: !disabled && readOnly,
|
|
181
|
+
required: others.required,
|
|
162
182
|
helperText,
|
|
163
183
|
labelMargin,
|
|
164
184
|
fullWidth: true,
|
|
165
|
-
|
|
166
|
-
InputProps: {
|
|
167
|
-
readOnly: !disabled && readOnly,
|
|
168
|
-
},
|
|
185
|
+
inputRef,
|
|
169
186
|
},
|
|
170
187
|
} }));
|
|
171
188
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const Styled: import("@emotion/styled").StyledComponent<import("@mui/material").MenuItemOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "
|
|
1
|
+
declare const Styled: import("@emotion/styled").StyledComponent<import("@mui/material").MenuItemOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, keyof import("@mui/material").MenuItemOwnProps> & Omit<import("@mui/material").ButtonBaseOwnProps, "children" | "tabIndex" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | keyof import("@mui/material").MenuItemOwnProps> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "children" | "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "dense" | "disableGutters" | "divider" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
2
2
|
export default Styled;
|
|
@@ -6,12 +6,12 @@ export interface SelectorStyleProps {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const StyledSelect: import("@emotion/styled").StyledComponent<(import("@mui/material").FilledSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").StandardSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").OutlinedSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>), {}, {}>;
|
|
8
8
|
export declare const StyledInputLabel: import("@emotion/styled").StyledComponent<import("@mui/material").InputLabelOwnProps & Pick<import("@mui/material").FormLabelOwnProps, "color" | "filled"> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused" | "disableAnimation" | "shrink"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
9
|
-
component?: React.ElementType;
|
|
9
|
+
component?: React.ElementType | undefined;
|
|
10
10
|
} & {
|
|
11
11
|
open: boolean;
|
|
12
12
|
}, {}, {}>;
|
|
13
13
|
export declare const StyledHelperText: import("@emotion/styled").StyledComponent<import("@mui/material").FormHelperTextOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "required" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
14
|
-
component?: React.ElementType;
|
|
14
|
+
component?: React.ElementType | undefined;
|
|
15
15
|
}, {}, {}>;
|
|
16
16
|
export type ErkSelectValue<Type extends string | number, Multiple, Clearable> = Multiple extends true ? Type[] : Clearable extends true ? Type | undefined : Type;
|
|
17
17
|
export interface ErkSelectProps<Type extends string | number = string, Multiple extends boolean | undefined = false, Clearable extends boolean | undefined = true> extends Omit<MuiSelectProps, 'color' | 'onChange' | 'ref'>, SelectorStyleProps {
|