@arquimedes.co/eureka-forms 3.0.60 → 3.0.61
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/App/App.stories.d.ts +10 -0
- package/dist/App/App.stories.js +189 -0
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +17 -9
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -13
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +0 -11
- package/package.json +1 -1
|
@@ -28,3 +28,13 @@ export declare const ParseadoConValores: Story;
|
|
|
28
28
|
export declare const PreParseado: Story;
|
|
29
29
|
/** Final view (postview): what the user submitted, rendered read-only. */
|
|
30
30
|
export declare const Postview: Story;
|
|
31
|
+
/**
|
|
32
|
+
* Every checkbox variant in one form: sizes 1–4, required, description, list mode, long
|
|
33
|
+
* labels, nested `steps` / `uncheckedSteps`, and a checkbox inside a collapsible. Resize the
|
|
34
|
+
* preview below ~900px to see the collapsed label mode (100% width, 2-line clamp, "ver más").
|
|
35
|
+
* Inside the collapsible, close/reopen it and then check the checkbox to reproduce the clipped
|
|
36
|
+
* nested steps.
|
|
37
|
+
*/
|
|
38
|
+
export declare const Checkboxes: Story;
|
|
39
|
+
/** Same checkboxes form in postview, read-only. */
|
|
40
|
+
export declare const CheckboxesPostview: Story;
|
package/dist/App/App.stories.js
CHANGED
|
@@ -296,3 +296,192 @@ export const Postview = {
|
|
|
296
296
|
editable: false,
|
|
297
297
|
},
|
|
298
298
|
};
|
|
299
|
+
// ---------------------------------------------------------------------------------------------
|
|
300
|
+
// Checkboxes: a full form exercising every checkbox variant side by side (sizes, required,
|
|
301
|
+
// description, list mode, long label, nested steps, uncheckedSteps and a checkbox inside a
|
|
302
|
+
// collapsible). Resize the preview to see the collapsed (100% width, 2-line clamp) label mode.
|
|
303
|
+
// ---------------------------------------------------------------------------------------------
|
|
304
|
+
const cbTextInput = (id, label, size = 2) => ({
|
|
305
|
+
id,
|
|
306
|
+
type: 'TEXTINPUT',
|
|
307
|
+
label,
|
|
308
|
+
description: '',
|
|
309
|
+
required: false,
|
|
310
|
+
size,
|
|
311
|
+
isSubject: false,
|
|
312
|
+
});
|
|
313
|
+
const checkboxesForm = {
|
|
314
|
+
steps: {
|
|
315
|
+
'CHECKBOX-size-1': {
|
|
316
|
+
id: 'CHECKBOX-size-1',
|
|
317
|
+
type: 'CHECKBOX',
|
|
318
|
+
label: 'Tamaño 1',
|
|
319
|
+
description: null,
|
|
320
|
+
required: false,
|
|
321
|
+
size: 1,
|
|
322
|
+
},
|
|
323
|
+
'CHECKBOX-size-2': {
|
|
324
|
+
id: 'CHECKBOX-size-2',
|
|
325
|
+
type: 'CHECKBOX',
|
|
326
|
+
label: 'Tamaño 2 con descripción',
|
|
327
|
+
description: 'Texto de ayuda debajo del checkbox.',
|
|
328
|
+
required: false,
|
|
329
|
+
size: 2,
|
|
330
|
+
},
|
|
331
|
+
'CHECKBOX-size-1-required': {
|
|
332
|
+
id: 'CHECKBOX-size-1-required',
|
|
333
|
+
type: 'CHECKBOX',
|
|
334
|
+
label: 'Obligatorio',
|
|
335
|
+
description: null,
|
|
336
|
+
required: true,
|
|
337
|
+
size: 1,
|
|
338
|
+
},
|
|
339
|
+
'CHECKBOX-size-3': {
|
|
340
|
+
id: 'CHECKBOX-size-3',
|
|
341
|
+
type: 'CHECKBOX',
|
|
342
|
+
label: 'Tamaño 3 con un label bastante largo que en escritorio se corta con puntos suspensivos',
|
|
343
|
+
description: null,
|
|
344
|
+
required: false,
|
|
345
|
+
size: 3,
|
|
346
|
+
},
|
|
347
|
+
'CHECKBOX-size-1-checked': {
|
|
348
|
+
id: 'CHECKBOX-size-1-checked',
|
|
349
|
+
type: 'CHECKBOX',
|
|
350
|
+
label: 'Marcado',
|
|
351
|
+
description: null,
|
|
352
|
+
required: false,
|
|
353
|
+
size: 1,
|
|
354
|
+
defaultValue: true,
|
|
355
|
+
},
|
|
356
|
+
'CHECKBOX-size-4': {
|
|
357
|
+
id: 'CHECKBOX-size-4',
|
|
358
|
+
type: 'CHECKBOX',
|
|
359
|
+
label: 'Tamaño 4 (ancho completo): confirmo que la información suministrada es veraz, que he leído la ' +
|
|
360
|
+
'política de tratamiento de datos personales y autorizo el uso de mis datos para los fines ' +
|
|
361
|
+
'descritos en el presente formulario',
|
|
362
|
+
description: null,
|
|
363
|
+
required: true,
|
|
364
|
+
size: 4,
|
|
365
|
+
},
|
|
366
|
+
'CHECKBOX-list': {
|
|
367
|
+
id: 'CHECKBOX-list',
|
|
368
|
+
type: 'CHECKBOX',
|
|
369
|
+
label: 'Modo lista (isList): el checkbox va antes del label y sin dos puntos',
|
|
370
|
+
description: null,
|
|
371
|
+
required: false,
|
|
372
|
+
size: 4,
|
|
373
|
+
isList: true,
|
|
374
|
+
},
|
|
375
|
+
'CHECKBOX-nested': {
|
|
376
|
+
id: 'CHECKBOX-nested',
|
|
377
|
+
type: 'CHECKBOX',
|
|
378
|
+
label: '¿Desea agregar una dirección de envío distinta?',
|
|
379
|
+
description: 'Al marcarlo aparecen los campos de la dirección.',
|
|
380
|
+
required: false,
|
|
381
|
+
size: 4,
|
|
382
|
+
steps: ['TEXTINPUT-shipping-address', 'TEXTINPUT-shipping-city'],
|
|
383
|
+
},
|
|
384
|
+
'TEXTINPUT-shipping-address': cbTextInput('TEXTINPUT-shipping-address', 'Dirección de envío', 2),
|
|
385
|
+
'TEXTINPUT-shipping-city': cbTextInput('TEXTINPUT-shipping-city', 'Ciudad', 2),
|
|
386
|
+
'CHECKBOX-unchecked-steps': {
|
|
387
|
+
id: 'CHECKBOX-unchecked-steps',
|
|
388
|
+
type: 'CHECKBOX',
|
|
389
|
+
label: 'Usar los datos de contacto registrados',
|
|
390
|
+
description: 'Al desmarcarlo aparecen los campos de contacto (uncheckedSteps).',
|
|
391
|
+
required: false,
|
|
392
|
+
size: 4,
|
|
393
|
+
defaultValue: true,
|
|
394
|
+
uncheckedSteps: ['TEXTINPUT-contact-phone', 'TEXTINPUT-contact-email'],
|
|
395
|
+
},
|
|
396
|
+
'TEXTINPUT-contact-phone': cbTextInput('TEXTINPUT-contact-phone', 'Teléfono', 2),
|
|
397
|
+
'TEXTINPUT-contact-email': cbTextInput('TEXTINPUT-contact-email', 'Correo', 2),
|
|
398
|
+
'COLLAPSIBLE-checkbox': {
|
|
399
|
+
id: 'COLLAPSIBLE-checkbox',
|
|
400
|
+
type: 'COLLAPSIBLE',
|
|
401
|
+
label: 'Colapsable con checkbox anidado',
|
|
402
|
+
defaultValue: true,
|
|
403
|
+
steps: ['CHECKBOX-in-collapsible'],
|
|
404
|
+
},
|
|
405
|
+
'CHECKBOX-in-collapsible': {
|
|
406
|
+
id: 'CHECKBOX-in-collapsible',
|
|
407
|
+
type: 'CHECKBOX',
|
|
408
|
+
label: '¿Desea agregar información adicional?',
|
|
409
|
+
description: null,
|
|
410
|
+
required: false,
|
|
411
|
+
size: 4,
|
|
412
|
+
steps: ['TEXTINPUT-extra-1', 'TEXTINPUT-extra-2'],
|
|
413
|
+
},
|
|
414
|
+
'TEXTINPUT-extra-1': cbTextInput('TEXTINPUT-extra-1', 'Información adicional 1', 2),
|
|
415
|
+
'TEXTINPUT-extra-2': cbTextInput('TEXTINPUT-extra-2', 'Información adicional 2', 2),
|
|
416
|
+
},
|
|
417
|
+
size: { blockNum: 4, blockSize: 210, spacingSize: 20 },
|
|
418
|
+
rootSteps: [
|
|
419
|
+
'CHECKBOX-size-1',
|
|
420
|
+
'CHECKBOX-size-2',
|
|
421
|
+
'CHECKBOX-size-1-required',
|
|
422
|
+
'CHECKBOX-size-3',
|
|
423
|
+
'CHECKBOX-size-1-checked',
|
|
424
|
+
'CHECKBOX-size-4',
|
|
425
|
+
'CHECKBOX-list',
|
|
426
|
+
'CHECKBOX-nested',
|
|
427
|
+
'CHECKBOX-unchecked-steps',
|
|
428
|
+
'COLLAPSIBLE-checkbox',
|
|
429
|
+
],
|
|
430
|
+
label: 'Enviar',
|
|
431
|
+
firstSection: 'FIRST',
|
|
432
|
+
sections: {
|
|
433
|
+
FIRST: {
|
|
434
|
+
id: 'FIRST',
|
|
435
|
+
steps: [
|
|
436
|
+
'CHECKBOX-size-1',
|
|
437
|
+
'CHECKBOX-size-2',
|
|
438
|
+
'CHECKBOX-size-1-required',
|
|
439
|
+
'CHECKBOX-size-3',
|
|
440
|
+
'CHECKBOX-size-1-checked',
|
|
441
|
+
'CHECKBOX-size-4',
|
|
442
|
+
'CHECKBOX-list',
|
|
443
|
+
'CHECKBOX-nested',
|
|
444
|
+
'CHECKBOX-unchecked-steps',
|
|
445
|
+
'COLLAPSIBLE-checkbox',
|
|
446
|
+
],
|
|
447
|
+
name: '',
|
|
448
|
+
nextSection: null,
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Every checkbox variant in one form: sizes 1–4, required, description, list mode, long
|
|
454
|
+
* labels, nested `steps` / `uncheckedSteps`, and a checkbox inside a collapsible. Resize the
|
|
455
|
+
* preview below ~900px to see the collapsed label mode (100% width, 2-line clamp, "ver más").
|
|
456
|
+
* Inside the collapsible, close/reopen it and then check the checkbox to reproduce the clipped
|
|
457
|
+
* nested steps.
|
|
458
|
+
*/
|
|
459
|
+
export const Checkboxes = {
|
|
460
|
+
args: {
|
|
461
|
+
formData: checkboxesForm,
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
/** Same checkboxes form in postview, read-only. */
|
|
465
|
+
export const CheckboxesPostview = {
|
|
466
|
+
args: {
|
|
467
|
+
formData: checkboxesForm,
|
|
468
|
+
valuesData: {
|
|
469
|
+
'CHECKBOX-size-1': true,
|
|
470
|
+
'CHECKBOX-size-2': false,
|
|
471
|
+
'CHECKBOX-size-1-required': true,
|
|
472
|
+
'CHECKBOX-size-3': true,
|
|
473
|
+
'CHECKBOX-size-1-checked': true,
|
|
474
|
+
'CHECKBOX-size-4': true,
|
|
475
|
+
'CHECKBOX-list': true,
|
|
476
|
+
'CHECKBOX-nested': true,
|
|
477
|
+
'TEXTINPUT-shipping-address': 'Calle 123 # 45-67',
|
|
478
|
+
'TEXTINPUT-shipping-city': 'Bogotá',
|
|
479
|
+
'CHECKBOX-unchecked-steps': true,
|
|
480
|
+
'COLLAPSIBLE-checkbox': true,
|
|
481
|
+
'CHECKBOX-in-collapsible': false,
|
|
482
|
+
},
|
|
483
|
+
postview: true,
|
|
484
|
+
internal: true,
|
|
485
|
+
editable: false,
|
|
486
|
+
},
|
|
487
|
+
};
|
|
@@ -48,7 +48,7 @@ function makeStore(currentBreakPoint) {
|
|
|
48
48
|
...defaultRootState,
|
|
49
49
|
widthStats: {
|
|
50
50
|
currentBreakPoint,
|
|
51
|
-
isMobile: currentBreakPoint <=
|
|
51
|
+
isMobile: currentBreakPoint <= 1,
|
|
52
52
|
isResponsive: true,
|
|
53
53
|
},
|
|
54
54
|
},
|
|
@@ -57,9 +57,9 @@ function makeStore(currentBreakPoint) {
|
|
|
57
57
|
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(RootApi.middleware),
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function Harness({ currentBreakPoint }) {
|
|
60
|
+
function Harness({ currentBreakPoint, step = checkBoxStep, }) {
|
|
61
61
|
const methods = useForm({ mode: 'onTouched' });
|
|
62
|
-
return (_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(Provider, { store: makeStore(currentBreakPoint), context: StoreContext, children: _jsx(IdFormContext.Provider, { value: STORY_FORM_ID, children: _jsx(FormContext.Provider, { value: form, children: _jsx(SectionContext.Provider, { value: "SECTION_1", children: _jsx(FormProvider, { ...methods, children: _jsx(CheckBoxStep, { step:
|
|
62
|
+
return (_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(Provider, { store: makeStore(currentBreakPoint), context: StoreContext, children: _jsx(IdFormContext.Provider, { value: STORY_FORM_ID, children: _jsx(FormContext.Provider, { value: { ...form, steps: { ...form.steps, [step.id]: step } }, children: _jsx(SectionContext.Provider, { value: "SECTION_1", children: _jsx(FormProvider, { ...methods, children: _jsx(CheckBoxStep, { step: step, editable: true }) }) }) }) }) }) }));
|
|
63
63
|
}
|
|
64
64
|
function getLabelDiv() {
|
|
65
65
|
// the leaf div holding only the label text (the wrapping column also matches by textContent)
|
|
@@ -85,22 +85,30 @@ afterEach(() => {
|
|
|
85
85
|
delete HTMLElement.prototype.scrollHeight;
|
|
86
86
|
delete HTMLElement.prototype.clientHeight;
|
|
87
87
|
});
|
|
88
|
-
describe('CheckBoxStep
|
|
88
|
+
describe('CheckBoxStep long labels', () => {
|
|
89
89
|
it('wraps the label (2-line clamp) instead of single-line truncating it when the step collapses to 100% width', () => {
|
|
90
90
|
// breakpoint 1 <= size 2 → MaterialInputContainer renders the step at width: 100%
|
|
91
91
|
render(_jsx(Harness, { currentBreakPoint: 1 }));
|
|
92
92
|
const label = getLabelDiv();
|
|
93
93
|
expect(label.className).toBe(styles.clampLbl);
|
|
94
|
-
|
|
95
|
-
// the fixed desktop pixel maxWidth must not constrain the collapsed label
|
|
94
|
+
// no fixed desktop pixel maxWidth constrains the label
|
|
96
95
|
expect(label.style.maxWidth).toBe('');
|
|
97
96
|
});
|
|
98
|
-
it('
|
|
97
|
+
it('also clamps (with "ver más") when the step keeps a fixed width on a phone where 2 columns fit', () => {
|
|
98
|
+
// regression: a size-1 checkbox at breakpoint 2 used to render a single-line ellipsis with
|
|
99
|
+
// no way to read the full label
|
|
100
|
+
mockLabelOverflow();
|
|
101
|
+
render(_jsx(Harness, { currentBreakPoint: 2, step: { ...checkBoxStep, size: 1 } }));
|
|
102
|
+
const label = getLabelDiv();
|
|
103
|
+
expect(label.className).toBe(styles.clampLbl);
|
|
104
|
+
expect(label.style.maxWidth).toBe('');
|
|
105
|
+
expect(screen.getByRole('button', { name: 'ver más' })).toBeInTheDocument();
|
|
106
|
+
});
|
|
107
|
+
it('clamps on desktop widths too, without a toggle while the label fits', () => {
|
|
99
108
|
// breakpoint 4 > size 2 → the step keeps its fixed desktop width
|
|
100
109
|
render(_jsx(Harness, { currentBreakPoint: 4 }));
|
|
101
110
|
const label = getLabelDiv();
|
|
102
|
-
expect(label.className).toBe(styles.
|
|
103
|
-
expect(label.style.maxWidth).not.toBe('');
|
|
111
|
+
expect(label.className).toBe(styles.clampLbl);
|
|
104
112
|
expect(screen.queryByRole('button', { name: 'ver más' })).not.toBeInTheDocument();
|
|
105
113
|
});
|
|
106
114
|
it('shows no "ver más" toggle when the label fits in the clamp', () => {
|
|
@@ -8,7 +8,6 @@ import { useAppSelector, selectWidthStats } from '../../../hooks';
|
|
|
8
8
|
import { useFormStep } from '../../StepHooks';
|
|
9
9
|
import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
|
|
10
10
|
import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
|
|
11
|
-
import { calcStepWidth, resolveStepSpan } from '../../StepFunctions';
|
|
12
11
|
function CheckBoxStep({ step, editable }) {
|
|
13
12
|
const { ref, value, onChange, error, field } = useFormStep(step, {
|
|
14
13
|
defaultValue: step.defaultValue ?? false,
|
|
@@ -20,15 +19,15 @@ function CheckBoxStep({ step, editable }) {
|
|
|
20
19
|
const { formStyle, postview } = useAppSelector((state) => state.global);
|
|
21
20
|
const form = useContext(FormContext);
|
|
22
21
|
const widthStats = useAppSelector(selectWidthStats);
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
// the
|
|
26
|
-
|
|
22
|
+
// The label is clamped to 2 lines with a "ver más" toggle at every width. A single-line
|
|
23
|
+
// ellipsis was used while the step kept its fixed desktop pixel width, but that left long
|
|
24
|
+
// labels unreadable wherever the step is narrow (e.g. a size-1 checkbox on a phone where 2
|
|
25
|
+
// columns fit).
|
|
27
26
|
const labelRef = useRef(null);
|
|
28
27
|
const [expanded, setExpanded] = useState(false);
|
|
29
28
|
const [clamped, setClamped] = useState(false);
|
|
30
29
|
useLayoutEffect(() => {
|
|
31
|
-
if (
|
|
30
|
+
if (expanded)
|
|
32
31
|
return;
|
|
33
32
|
const measure = () => {
|
|
34
33
|
const label = labelRef.current;
|
|
@@ -38,7 +37,7 @@ function CheckBoxStep({ step, editable }) {
|
|
|
38
37
|
measure();
|
|
39
38
|
window.addEventListener('resize', measure);
|
|
40
39
|
return () => window.removeEventListener('resize', measure);
|
|
41
|
-
}, [
|
|
40
|
+
}, [expanded, step.label, widthStats.currentBreakPoint]);
|
|
42
41
|
const renderNested = () => {
|
|
43
42
|
const steps = value ? step.steps : step.uncheckedSteps;
|
|
44
43
|
return (_jsx(React.Fragment, { children: steps?.map((idStep) => {
|
|
@@ -48,18 +47,12 @@ function CheckBoxStep({ step, editable }) {
|
|
|
48
47
|
};
|
|
49
48
|
const renderLabel = (colon = false) => {
|
|
50
49
|
const label = `${step.label}${step.required ? ' *' : ''}${colon ? ':' : ''}`;
|
|
51
|
-
if (!collapsed) {
|
|
52
|
-
return (_jsx("div", { className: span === 4 ? styles.checkboxLbl : styles.overflowLbl, style: {
|
|
53
|
-
maxWidth: calcStepWidth(span, form.size) - 45,
|
|
54
|
-
}, children: label }));
|
|
55
|
-
}
|
|
56
50
|
return (_jsxs("div", { className: styles.labelColumn, children: [_jsx("div", { ref: labelRef, className: expanded ? styles.expandedLbl : styles.clampLbl, children: label }), (clamped || expanded) && (_jsx("button", { type: "button", className: styles.toggleLbl, style: { color: formStyle.primaryColor }, onClick: (event) => {
|
|
57
51
|
event.stopPropagation();
|
|
58
52
|
setExpanded(!expanded);
|
|
59
53
|
}, children: expanded ? 'ver menos' : 'ver más' }))] }));
|
|
60
54
|
};
|
|
61
55
|
return (_jsxs(StepFillerContainer, { step: step, children: [_jsx(MaterialInputContainer, { step: step, editable: editable, maxHeight: step.size < 4, children: _jsxs("div", { className: styles.container, children: [_jsxs("div", { className: styles.labelCheckBoxContainer, style: {
|
|
62
|
-
height: span < 4 && !collapsed ? 31 : undefined,
|
|
63
56
|
minHeight: 31,
|
|
64
57
|
alignItems: step.isList ? 'start' : 'center',
|
|
65
58
|
}, children: [step.label && !step.isList && renderLabel(true), _jsx(ErkCheckBox, { ...field, padding: "0px", inputRef: ref, error: !!error, checked: value, onChange: onChange, "data-testid": step.id, readOnly: !editable || postview }), step.label && step.isList && renderLabel()] }), (step.description ?? !!error) && (_jsx("div", { className: styles.descriptionPar, style: {
|
|
@@ -3,17 +3,6 @@
|
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
max-width: 100%;
|
|
5
5
|
}
|
|
6
|
-
.checkboxLbl,
|
|
7
|
-
.overflowLbl {
|
|
8
|
-
font-size: 18px;
|
|
9
|
-
margin-right: 10px;
|
|
10
|
-
margin-left: 10px;
|
|
11
|
-
}
|
|
12
|
-
.overflowLbl {
|
|
13
|
-
white-space: nowrap;
|
|
14
|
-
overflow: hidden;
|
|
15
|
-
text-overflow: ellipsis;
|
|
16
|
-
}
|
|
17
6
|
.labelColumn {
|
|
18
7
|
display: flex;
|
|
19
8
|
flex-direction: column;
|
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.61",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"watch": "node node_modules/@typescript/native/bin/tsc --noEmit --watch --project tsconfig.app.json",
|
|
7
7
|
"start": "vite",
|