@arquimedes.co/eureka-forms 3.0.50-test → 3.0.52-new-steps
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/AvailabilityFormStep.d.ts +48 -0
- package/dist/@Types/AvailabilityFormStep.js +24 -0
- package/dist/@Types/BankAccountFormStep.d.ts +67 -0
- package/dist/@Types/BankAccountFormStep.js +14 -0
- package/dist/@Types/BookingFormStep.d.ts +166 -0
- package/dist/@Types/BookingFormStep.js +44 -0
- package/dist/@Types/CalendarFormStep.d.ts +192 -0
- package/dist/@Types/CalendarFormStep.js +48 -0
- package/dist/@Types/CommunicationChannelFormStep.d.ts +51 -0
- package/dist/@Types/CommunicationChannelFormStep.js +15 -0
- package/dist/@Types/ConsentFormStep.d.ts +36 -0
- package/dist/@Types/ConsentFormStep.js +8 -0
- package/dist/@Types/EntityFormFormStep.d.ts +66 -0
- package/dist/@Types/EntityFormFormStep.js +20 -0
- package/dist/@Types/EventFormStep.d.ts +52 -0
- package/dist/@Types/EventFormStep.js +13 -0
- package/dist/@Types/ExternalReferenceFormStep.d.ts +74 -0
- package/dist/@Types/ExternalReferenceFormStep.js +20 -0
- package/dist/@Types/FormStep.d.ts +7 -2
- package/dist/@Types/FormStep.js +2 -1
- package/dist/@Types/LocationFormStep.d.ts +159 -0
- package/dist/@Types/LocationFormStep.js +46 -0
- package/dist/@Types/NumericFormSteps.d.ts +108 -0
- package/dist/@Types/NumericFormSteps.js +20 -0
- package/dist/@Types/PredefinedSelectorFormStep.d.ts +51 -0
- package/dist/@Types/PredefinedSelectorFormStep.js +39 -0
- package/dist/@Types/StepRef.d.ts +135 -0
- package/dist/@Types/StepRef.js +49 -0
- package/dist/App/App.stories.d.ts +30 -0
- package/dist/App/App.stories.js +298 -0
- package/dist/App/App.stories.test.d.ts +1 -0
- package/dist/App/App.stories.test.js +56 -0
- package/dist/FormSteps/BookingStep/BookingStep.d.ts +17 -0
- package/dist/FormSteps/BookingStep/BookingStep.js +14 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +7 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +31 -0
- package/dist/FormSteps/CalendarStep/CalendarStep.d.ts +7 -0
- package/dist/FormSteps/CalendarStep/CalendarStep.js +14 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.d.ts +3 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.js +269 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.module.css +531 -0
- package/dist/FormSteps/DatePickerStep/DatePickerStep.required.test.d.ts +1 -0
- package/dist/FormSteps/DatePickerStep/DatePickerStep.required.test.js +94 -0
- package/dist/FormSteps/LocationStep/LocationStep.d.ts +10 -0
- package/dist/FormSteps/LocationStep/LocationStep.js +14 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +3 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +47 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +18 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +3 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +168 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +94 -0
- package/dist/FormSteps/NumberStep/NumberStep.d.ts +10 -0
- package/dist/FormSteps/NumberStep/NumberStep.js +14 -0
- package/dist/FormSteps/Step.js +16 -0
- package/dist/FormSteps/StepFunctions.js +14 -0
- package/dist/FormSteps/StepFunctions.test.js +54 -0
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +3 -1
- package/dist/Icons/AddIcon.d.ts +3 -0
- package/dist/Icons/AddIcon.js +7 -0
- package/dist/Icons/EditIcon.d.ts +3 -0
- package/dist/Icons/EditIcon.js +7 -0
- package/dist/Icons/RemoveIcon.d.ts +3 -0
- package/dist/Icons/RemoveIcon.js +7 -0
- package/dist/Icons/ViewDayIcon.d.ts +3 -0
- package/dist/Icons/ViewDayIcon.js +7 -0
- package/dist/Icons/ViewWeekIcon.d.ts +3 -0
- package/dist/Icons/ViewWeekIcon.js +7 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +19 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +80 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +82 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
- package/dist/Shared/ErkAutocompleteOption.d.ts +12 -0
- package/dist/Shared/ErkAutocompleteOption.js +37 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +28 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +149 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +113 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +3 -10
- package/dist/Shared/ErkDatePicker/ErkDatePicker.required.test.d.ts +1 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.required.test.js +30 -0
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +2 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +1 -2
- package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +23 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.js +73 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.module.css +29 -0
- package/dist/Shared/ErkLocationField/addressFields.d.ts +12 -0
- package/dist/Shared/ErkLocationField/addressFields.js +34 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +6 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.js +51 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +15 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.js +502 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +115 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.js +170 -0
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.js +2 -1
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.test.d.ts +1 -0
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.test.js +33 -0
- package/dist/Shared/SmartDraftRenderer/SmartDraftRenderer.d.ts +7 -1
- package/dist/Shared/SmartDraftRenderer/SmartDraftRenderer.js +2 -2
- package/dist/constants/FormStepTypes.d.ts +5 -1
- package/dist/constants/FormStepTypes.js +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { NumberField as BaseNumberField } from '@base-ui/react/number-field';
|
|
4
|
+
import { FormControl, FormHelperText, InputAdornment, InputLabel, OutlinedInput, styled, useTheme, } from '@mui/material';
|
|
5
|
+
import { alpha } from '@mui/material/styles';
|
|
6
|
+
import AddIcon from '../../Icons/AddIcon';
|
|
7
|
+
import RemoveIcon from '../../Icons/RemoveIcon';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Styled FormControl shell — same conventions as ErkTextField / ErkSelect
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
const StyledFormControl = styled(FormControl)(({ theme, size }) => ({
|
|
12
|
+
'& .Erk-MuiOutlinedInput-root': {
|
|
13
|
+
borderRadius: 10,
|
|
14
|
+
backgroundColor: theme.palette.stepBackgroundColor.default,
|
|
15
|
+
minHeight: size === 'small' ? 31 : size === 'medium' ? 40 : undefined,
|
|
16
|
+
'&.Mui-focused .Erk-MuiOutlinedInput-notchedOutline': {
|
|
17
|
+
borderColor: theme.palette.primary.main,
|
|
18
|
+
borderWidth: 2,
|
|
19
|
+
},
|
|
20
|
+
// ErkNF-readOnly is set manually via className — Mui-readOnly is unreliable here
|
|
21
|
+
'&:hover:not(.ErkNF-readOnly) .Erk-MuiOutlinedInput-notchedOutline': {
|
|
22
|
+
borderColor: theme.palette.primary.main,
|
|
23
|
+
},
|
|
24
|
+
'&.ErkNF-readOnly.Mui-focused .Erk-MuiOutlinedInput-notchedOutline': {
|
|
25
|
+
borderColor: theme.palette.outline.main,
|
|
26
|
+
borderWidth: 1,
|
|
27
|
+
},
|
|
28
|
+
'&.ErkNF-readOnly': {
|
|
29
|
+
cursor: 'default',
|
|
30
|
+
'& input': { cursor: 'default' },
|
|
31
|
+
},
|
|
32
|
+
'& .Erk-MuiOutlinedInput-notchedOutline': {
|
|
33
|
+
borderRadius: 10,
|
|
34
|
+
borderColor: theme.palette.outline.main,
|
|
35
|
+
'& legend': { fontSize: '0.75rem' },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
'& .Erk-MuiOutlinedInput-root.Mui-error .Erk-MuiOutlinedInput-notchedOutline': {
|
|
39
|
+
borderColor: theme.palette.error.main,
|
|
40
|
+
},
|
|
41
|
+
'& .Erk-MuiOutlinedInput-root.Mui-error.Mui-focused .Erk-MuiOutlinedInput-notchedOutline': {
|
|
42
|
+
borderWidth: 2,
|
|
43
|
+
},
|
|
44
|
+
'& .Erk-MuiFormLabel-root': {
|
|
45
|
+
color: alpha(theme.palette.text.primary, 0.54),
|
|
46
|
+
},
|
|
47
|
+
'& label.Mui-focused': { color: theme.palette.primary.main },
|
|
48
|
+
'& label.Mui-error': { color: theme.palette.error.main },
|
|
49
|
+
'& .Erk-MuiFormLabel-root:not(.Erk-MuiInputLabel-shrink)': {
|
|
50
|
+
fontSize: '1rem',
|
|
51
|
+
transform: `translate(12px, ${size === 'small' ? 5 : 9}px) scale(1)`,
|
|
52
|
+
},
|
|
53
|
+
'& .Erk-MuiFormHelperText-root': {
|
|
54
|
+
color: theme.palette.helperText.primary,
|
|
55
|
+
minHeight: 20,
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
textOverflow: 'ellipsis',
|
|
58
|
+
},
|
|
59
|
+
'& .Erk-MuiFormHelperText-root.Mui-error': { color: theme.palette.error.main },
|
|
60
|
+
'& input': {
|
|
61
|
+
fontSize: '1rem',
|
|
62
|
+
padding: '6px 12px',
|
|
63
|
+
lineHeight: size === 'small' ? '1.188em' : '1.75em',
|
|
64
|
+
height: size === 'small' ? '1.188em' : '1.75em',
|
|
65
|
+
color: theme.palette.text.primary,
|
|
66
|
+
MozAppearance: 'textfield',
|
|
67
|
+
'&::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
|
|
68
|
+
WebkitAppearance: 'none',
|
|
69
|
+
margin: 0,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// SSR label-shrink hint — muiName='Input' lets FormControl know an input
|
|
75
|
+
// exists so it can compute the initial shrink state before hydration.
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
+
function SSRInitialFilled(_props) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
SSRInitialFilled.muiName = 'Input';
|
|
82
|
+
function SpinnerBtn({ children, style, ...rest }) {
|
|
83
|
+
const theme = useTheme();
|
|
84
|
+
const [hovered, setHovered] = React.useState(false);
|
|
85
|
+
const [active, setActive] = React.useState(false);
|
|
86
|
+
return (_jsx("button", { type: "button", tabIndex: -1, ...rest, onMouseEnter: (e) => {
|
|
87
|
+
setHovered(true);
|
|
88
|
+
rest.onMouseEnter?.(e);
|
|
89
|
+
}, onMouseLeave: (e) => {
|
|
90
|
+
setHovered(false);
|
|
91
|
+
setActive(false);
|
|
92
|
+
rest.onMouseLeave?.(e);
|
|
93
|
+
}, onMouseDown: (e) => {
|
|
94
|
+
setActive(true);
|
|
95
|
+
rest.onMouseDown?.(e);
|
|
96
|
+
}, onMouseUp: (e) => {
|
|
97
|
+
setActive(false);
|
|
98
|
+
rest.onMouseUp?.(e);
|
|
99
|
+
}, style: {
|
|
100
|
+
display: 'inline-flex',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
justifyContent: 'center',
|
|
103
|
+
width: 22,
|
|
104
|
+
height: 22,
|
|
105
|
+
minWidth: 22,
|
|
106
|
+
padding: 0,
|
|
107
|
+
border: 'none',
|
|
108
|
+
borderRadius: 4,
|
|
109
|
+
background: active
|
|
110
|
+
? alpha(theme.palette.primary.main, 0.16)
|
|
111
|
+
: hovered
|
|
112
|
+
? alpha(theme.palette.primary.main, 0.08)
|
|
113
|
+
: 'transparent',
|
|
114
|
+
cursor: rest.disabled ? 'default' : 'pointer',
|
|
115
|
+
color: hovered && !rest.disabled ? theme.palette.primary.main : alpha(theme.palette.text.primary, 0.6),
|
|
116
|
+
flexShrink: 0,
|
|
117
|
+
transition: 'color 0.15s, background-color 0.15s',
|
|
118
|
+
opacity: rest.disabled ? 0.35 : 1,
|
|
119
|
+
pointerEvents: rest.disabled ? 'none' : undefined,
|
|
120
|
+
...style,
|
|
121
|
+
}, children: children }));
|
|
122
|
+
}
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Implementation
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
function CustomErkNumberField({ value, onChange, label, min, max, step = 1, decimals, required, error, errorBorder, helperText, disabled, readOnly, placeholder, size = 'small', fullWidth = true, suffix, spinner = true, inputRef, }) {
|
|
127
|
+
const theme = useTheme();
|
|
128
|
+
const id = React.useId();
|
|
129
|
+
// Rounds to max decimals on spinner click / arrow key / wheel scrub.
|
|
130
|
+
// Typing restriction is handled separately inside slotProps.input.onChange.
|
|
131
|
+
const handleValueChange = (num) => {
|
|
132
|
+
if (num === null || decimals === undefined) {
|
|
133
|
+
onChange?.(num);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const factor = Math.pow(10, decimals);
|
|
137
|
+
onChange?.(Math.round(num * factor) / factor);
|
|
138
|
+
};
|
|
139
|
+
return (_jsxs(BaseNumberField.Root, { value: value ?? null, onValueChange: handleValueChange, min: min, max: max, step: step, format: decimals !== undefined ? { minimumFractionDigits: 0, maximumFractionDigits: decimals } : undefined, disabled: disabled, readOnly: readOnly, ref: inputRef, render: (rootProps, rootState) => (_jsx(StyledFormControl, { ref: rootProps.ref, size: size, disabled: rootState.disabled, required: required, error: error && !!errorBorder, variant: "outlined", fullWidth: fullWidth, children: rootProps.children })), children: [_jsx(SSRInitialFilled, { value: value ?? undefined }), label && (_jsx(InputLabel, { htmlFor: id, size: size === 'small' ? 'small' : undefined, disabled: disabled, children: label })), _jsx(BaseNumberField.Input, { id: id, render: (inputProps, inputState) => {
|
|
140
|
+
return (_jsx(OutlinedInput, { label: label, className: readOnly ? 'ErkNF-readOnly' : undefined, inputRef: inputProps.ref, value: inputState.inputValue, onBlur: inputProps.onBlur, onChange: inputProps.onChange, onKeyUp: inputProps.onKeyUp, onKeyDown: inputProps.onKeyDown, onFocus: inputProps.onFocus, placeholder: placeholder, slotProps: {
|
|
141
|
+
input: {
|
|
142
|
+
...inputProps, // Base UI handlers + ref + aria attrs
|
|
143
|
+
},
|
|
144
|
+
}, endAdornment: suffix || spinner ? (_jsxs(InputAdornment, { position: "end", sx: { gap: '2px', mr: '2px', alignItems: 'center' }, children: [suffix && (_jsx("span", { style: {
|
|
145
|
+
fontSize: 13,
|
|
146
|
+
fontWeight: 600,
|
|
147
|
+
color: theme.palette.primary.main,
|
|
148
|
+
userSelect: 'none',
|
|
149
|
+
whiteSpace: 'nowrap',
|
|
150
|
+
marginRight: spinner ? 2 : 4,
|
|
151
|
+
}, children: suffix })), spinner && (_jsxs(_Fragment, { children: [_jsx(BaseNumberField.Decrement, { render: (decProps) => {
|
|
152
|
+
const { disabled: baseDisabled, ...restDec } = decProps;
|
|
153
|
+
return (_jsx(SpinnerBtn, { ...restDec, disabled: !!readOnly || !!baseDisabled, children: _jsx(RemoveIcon, { size: 14 }) }));
|
|
154
|
+
} }), _jsx(BaseNumberField.Increment, { render: (incProps) => {
|
|
155
|
+
const { disabled: baseDisabled, ...restInc } = incProps;
|
|
156
|
+
return (_jsx(SpinnerBtn, { ...restInc, disabled: !!readOnly || !!baseDisabled, children: _jsx(AddIcon, { size: 14 }) }));
|
|
157
|
+
} })] }))] })) : undefined, sx: { pr: suffix || spinner ? 0 : undefined } }));
|
|
158
|
+
} }), helperText && _jsx(FormHelperText, { error: error && !!errorBorder, children: helperText })] }));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Pure number input built on Base UI NumberField + MUI styling.
|
|
162
|
+
* No form-step system dependency.
|
|
163
|
+
* Class wrapper for react-hook-form ref compatibility.
|
|
164
|
+
*/
|
|
165
|
+
class ErkNumberField extends React.Component {
|
|
166
|
+
render() {
|
|
167
|
+
return _jsx(CustomErkNumberField, { ...this.props });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export default ErkNumberField;
|
|
@@ -3,6 +3,7 @@ import { createFilterOptions, CircularProgress, Autocomplete as MuiAutocomplete,
|
|
|
3
3
|
import ErkSelect from '../ErkSelect/ErkSelect';
|
|
4
4
|
import { StyledTextField } from '../ErkTextField/ErkTextField';
|
|
5
5
|
import ErkMenuItem from '../ErkMenuItem';
|
|
6
|
+
import ErkAutocompleteOption from '../ErkAutocompleteOption';
|
|
6
7
|
const filter = createFilterOptions();
|
|
7
8
|
const StyledAutoComplete = styled(MuiAutocomplete)(({ theme, readOnly, ...props }) => ({
|
|
8
9
|
'& .Erk-MuiInputBase-root': {
|
|
@@ -34,7 +35,7 @@ export default function ErkSmartSelect({ options, value = '', onChange, label, g
|
|
|
34
35
|
else {
|
|
35
36
|
return filter(options, params);
|
|
36
37
|
}
|
|
37
|
-
}, renderOption: ({ key, ...props }, option) => (_jsx(
|
|
38
|
+
}, renderOption: ({ key, ...props }, option, state) => (_jsx(ErkAutocompleteOption, { ...props, selected: state.selected, children: option.label }, key)), getOptionKey: (option) => getValueString(option), getOptionLabel: (option) => {
|
|
38
39
|
// Value selected with enter, right from the input
|
|
39
40
|
if (typeof option === 'string') {
|
|
40
41
|
return option;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
import ErkSmartSelect from './ErkSmartSelect';
|
|
7
|
+
import MaterialProviders from '../../Utils/MaterialProviders';
|
|
8
|
+
import InternalFormStyle from '../../constants/InternalFormStyle';
|
|
9
|
+
const options = [
|
|
10
|
+
{ label: 'Uno', value: '1' },
|
|
11
|
+
{ label: 'Dos', value: '2' },
|
|
12
|
+
];
|
|
13
|
+
describe('ErkSmartSelect (searchable)', () => {
|
|
14
|
+
it('renders the options as listbox <li> items when opened, with no prop leaking to the DOM', async () => {
|
|
15
|
+
const user = userEvent.setup();
|
|
16
|
+
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
17
|
+
render(_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(ErkSmartSelect, { searchable: true, label: "Selector", options: options, value: "", onChange: () => { } }) }));
|
|
18
|
+
await user.click(screen.getByRole('combobox'));
|
|
19
|
+
const option = await screen.findByRole('option', { name: 'Uno' });
|
|
20
|
+
expect(option.tagName).toBe('LI');
|
|
21
|
+
expect(screen.getByRole('option', { name: 'Dos' })).toBeInTheDocument();
|
|
22
|
+
// `ownerState`/`selected` must not reach the <li> (styled shouldForwardProp filters them).
|
|
23
|
+
expect(option).not.toHaveAttribute('ownerState');
|
|
24
|
+
expect(consoleError).not.toHaveBeenCalled();
|
|
25
|
+
consoleError.mockRestore();
|
|
26
|
+
});
|
|
27
|
+
it('marks the selected option', async () => {
|
|
28
|
+
const user = userEvent.setup();
|
|
29
|
+
render(_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(ErkSmartSelect, { searchable: true, label: "Selector", options: options, value: options[0], onChange: () => { } }) }));
|
|
30
|
+
await user.click(screen.getByRole('combobox'));
|
|
31
|
+
expect(await screen.findByRole('option', { name: 'Uno' })).toHaveAttribute('aria-selected', 'true');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -3,9 +3,15 @@ import { EurekaDraft } from '../../@Types/Draft/Draft';
|
|
|
3
3
|
interface SmartDraftRendererProps {
|
|
4
4
|
property: string;
|
|
5
5
|
draft: EurekaDraft;
|
|
6
|
+
/**
|
|
7
|
+
* The unmapped draft from the form definition. `draft` may be a previously mapped copy
|
|
8
|
+
* (entities already resolved and stripped), so whether mapping runs — and keeps re-running
|
|
9
|
+
* when `dependencies` change — must be decided from the original.
|
|
10
|
+
*/
|
|
11
|
+
sourceDraft?: EurekaDraft;
|
|
6
12
|
margin?: React.CSSProperties['margin'];
|
|
7
13
|
dependencies: Record<string, any>;
|
|
8
14
|
onChange?: (value: EurekaDraft) => void;
|
|
9
15
|
}
|
|
10
|
-
declare function SmartDraftRenderer({ draft, margin, onChange, property, dependencies }: SmartDraftRendererProps): JSX.Element;
|
|
16
|
+
declare function SmartDraftRenderer({ draft, sourceDraft, margin, onChange, property, dependencies, }: SmartDraftRendererProps): JSX.Element;
|
|
11
17
|
export default SmartDraftRenderer;
|
|
@@ -11,11 +11,11 @@ import { skipToken } from '@reduxjs/toolkit/query';
|
|
|
11
11
|
import { useAppSelector } from '../../hooks';
|
|
12
12
|
import { IdFormContext } from '../../Contexts/FormContext';
|
|
13
13
|
import { DraftLoadingContext } from './DraftLoadingContext';
|
|
14
|
-
function SmartDraftRenderer({ draft, margin, onChange, property, dependencies }) {
|
|
14
|
+
function SmartDraftRenderer({ draft, sourceDraft, margin, onChange, property, dependencies, }) {
|
|
15
15
|
const idForm = useContext(IdFormContext);
|
|
16
16
|
const mapDraftEntities = useContext(CustomContext).mapDraftEntities;
|
|
17
17
|
const postview = useAppSelector((state) => state.global.postview);
|
|
18
|
-
const hasEntities = useMemo(() => Object.keys(draft.entityMap).length > 0, [draft]);
|
|
18
|
+
const hasEntities = useMemo(() => Object.keys((sourceDraft ?? draft).entityMap).length > 0, [sourceDraft, draft]);
|
|
19
19
|
const { data: mapped, isFetching } = DraftApi.useMapDraftQuery(!hasEntities || postview
|
|
20
20
|
? skipToken
|
|
21
21
|
: {
|
|
@@ -21,7 +21,11 @@ export declare enum FormStepTypes {
|
|
|
21
21
|
COLLAPSIBLE = "COLLAPSIBLE",
|
|
22
22
|
MAPPER = "MAPPER",
|
|
23
23
|
ENTITYVALUEPICKER = "ENTITYVALUEPICKER",
|
|
24
|
-
API_SELECTOR = "API_SELECTOR"
|
|
24
|
+
API_SELECTOR = "API_SELECTOR",
|
|
25
|
+
LOCATION = "LOCATION",
|
|
26
|
+
NUMBER = "NUMBER",
|
|
27
|
+
CALENDAR = "CALENDAR",
|
|
28
|
+
BOOKING = "BOOKING"
|
|
25
29
|
}
|
|
26
30
|
export declare enum OptionTypes {
|
|
27
31
|
DEFAULT = "DEFAULT",
|
|
@@ -25,6 +25,10 @@ export var FormStepTypes;
|
|
|
25
25
|
FormStepTypes["MAPPER"] = "MAPPER";
|
|
26
26
|
FormStepTypes["ENTITYVALUEPICKER"] = "ENTITYVALUEPICKER";
|
|
27
27
|
FormStepTypes["API_SELECTOR"] = "API_SELECTOR";
|
|
28
|
+
FormStepTypes["LOCATION"] = "LOCATION";
|
|
29
|
+
FormStepTypes["NUMBER"] = "NUMBER";
|
|
30
|
+
FormStepTypes["CALENDAR"] = "CALENDAR";
|
|
31
|
+
FormStepTypes["BOOKING"] = "BOOKING";
|
|
28
32
|
})(FormStepTypes || (FormStepTypes = {}));
|
|
29
33
|
export var OptionTypes;
|
|
30
34
|
(function (OptionTypes) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arquimedes.co/eureka-forms",
|
|
3
3
|
"repository": "git://github.com/Arquimede5/Eureka-Forms.git",
|
|
4
|
-
"version":"3.0.
|
|
4
|
+
"version":"3.0.52-new-steps",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"watch": "tsgo --noEmit --watch --project tsconfig.app.json",
|
|
7
7
|
"start": "vite",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"build-storybook": "storybook build"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@base-ui/react": "^1.6.0",
|
|
19
20
|
"@reduxjs/toolkit": "2.11.2",
|
|
20
21
|
"axios": "1.16.0",
|
|
21
22
|
"date-fns": "4.1.0",
|