@inseefr/lunatic 3.0.9 → 3.1.1
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/lib/components/CheckboxOne/CheckboxOne.d.ts +1 -1
- package/lib/components/CheckboxOne/CheckboxOne.js +2 -2
- package/lib/components/CheckboxOne/CheckboxOne.js.map +1 -1
- package/lib/components/Radio/Radio.d.ts +1 -0
- package/lib/components/Radio/Radio.js +2 -2
- package/lib/components/Radio/Radio.js.map +1 -1
- package/lib/components/Roundabout/CustomRoundabout.d.ts +4 -12
- package/lib/components/Roundabout/CustomRoundabout.js +26 -15
- package/lib/components/Roundabout/CustomRoundabout.js.map +1 -1
- package/lib/components/Roundabout/Roundabout.d.ts +1 -1
- package/lib/components/Roundabout/Roundabout.js +15 -8
- package/lib/components/Roundabout/Roundabout.js.map +1 -1
- package/lib/components/Roundabout/roundabout.spec.js +17 -24
- package/lib/components/Roundabout/roundabout.spec.js.map +1 -1
- package/lib/components/library.d.ts +1 -0
- package/lib/components/shared/Button/Button.d.ts +1 -0
- package/lib/components/shared/Button/Button.js +4 -4
- package/lib/components/shared/Button/Button.js.map +1 -1
- package/lib/components/shared/HOC/slottableComponent.d.ts +0 -8
- package/lib/components/shared/HOC/slottableComponent.js.map +1 -1
- package/lib/components/shared/Radio/RadioGroup.d.ts +1 -1
- package/lib/components/shared/Radio/RadioGroup.js +6 -6
- package/lib/components/shared/Radio/RadioGroup.js.map +1 -1
- package/lib/components/shared/Radio/RadioOption.js +2 -3
- package/lib/components/shared/Radio/RadioOption.js.map +1 -1
- package/lib/components/shared/Radio/RadioOption.spec.js +4 -4
- package/lib/components/shared/Radio/RadioOption.spec.js.map +1 -1
- package/lib/components/type.d.ts +9 -7
- package/lib/hooks/useListKeyboardHandler.d.ts +1 -0
- package/lib/hooks/useListKeyboardHandler.js +5 -1
- package/lib/hooks/useListKeyboardHandler.js.map +1 -1
- package/lib/main.css +33 -7
- package/lib/main.css.map +1 -1
- package/lib/type.source.d.ts +5 -4
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/lib/use-lunatic/props/getComponentTypeProps.d.ts +13 -11
- package/lib/use-lunatic/props/getComponentTypeProps.js +10 -9
- package/lib/use-lunatic/props/getComponentTypeProps.js.map +1 -1
- package/lib/use-lunatic/reducer/reduce-go-next-page.js +28 -0
- package/lib/use-lunatic/reducer/reduce-go-next-page.js.map +1 -1
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js +1 -0
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js.map +1 -1
- package/lib/use-lunatic/reducer/reduce-go-to-page.js +1 -0
- package/lib/use-lunatic/reducer/reduce-go-to-page.js.map +1 -1
- package/lib/use-lunatic/reducer/reducerInitializer.js +12 -9
- package/lib/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/lib/use-lunatic/type.d.ts +1 -0
- package/package.json +1 -1
- package/lib/components/Roundabout/RoundaboutItButton.d.ts +0 -11
- package/lib/components/Roundabout/RoundaboutItButton.js +0 -41
- package/lib/components/Roundabout/RoundaboutItButton.js.map +0 -1
- package/lib/components/Roundabout/RoundaboutItButton.spec.d.ts +0 -1
- package/lib/components/Roundabout/RoundaboutItButton.spec.js +0 -48
- package/lib/components/Roundabout/RoundaboutItButton.spec.js.map +0 -1
- package/lib/components/Roundabout/RoundaboutRedirect.d.ts +0 -6
- package/lib/components/Roundabout/RoundaboutRedirect.js +0 -11
- package/lib/components/Roundabout/RoundaboutRedirect.js.map +0 -1
- package/lib/components/Roundabout/extra.d.ts +0 -14
- package/lib/components/Roundabout/extra.js +0 -9
- package/lib/components/Roundabout/extra.js.map +0 -1
- package/lib/components/Roundabout/redirect.spec.d.ts +0 -1
- package/lib/components/Roundabout/redirect.spec.js +0 -13
- package/lib/components/Roundabout/redirect.spec.js.map +0 -1
|
@@ -2,4 +2,4 @@ import type { LunaticComponentProps } from '../type';
|
|
|
2
2
|
/**
|
|
3
3
|
* Checkbox acting as a radio (only one option can be checked at a time)
|
|
4
4
|
*/
|
|
5
|
-
export declare function CheckboxOne({ options, value, id, label, description, errors, disabled, readOnly, shortcut, declarations, }: LunaticComponentProps<'CheckboxOne'>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function CheckboxOne({ options, value, id, label, description, errors, disabled, readOnly, shortcut, declarations, orientation, }: LunaticComponentProps<'CheckboxOne'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { getComponentErrors } from '../shared/ComponentErrors/ComponentErrors';
|
|
|
4
4
|
/**
|
|
5
5
|
* Checkbox acting as a radio (only one option can be checked at a time)
|
|
6
6
|
*/
|
|
7
|
-
export function CheckboxOne({ options, value, id, label, description, errors, disabled, readOnly, shortcut, declarations, }) {
|
|
8
|
-
return (_jsx(RadioGroup, { id: id, className: "lunatic-checkbox-one", options: options, value: value, disabled: disabled, readOnly: readOnly, errors: getComponentErrors(errors, id), label: label, description: description, checkboxStyle: true, shortcut: shortcut, declarations: declarations, clearable: true }));
|
|
7
|
+
export function CheckboxOne({ options, value, id, label, description, errors, disabled, readOnly, shortcut, declarations, orientation, }) {
|
|
8
|
+
return (_jsx(RadioGroup, { id: id, className: "lunatic-checkbox-one", options: options, value: value, disabled: disabled, readOnly: readOnly, errors: getComponentErrors(errors, id), label: label, description: description, checkboxStyle: true, shortcut: shortcut, declarations: declarations, orientation: orientation ?? 'vertical', clearable: true }));
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=CheckboxOne.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxOne.js","sourceRoot":"","sources":["../../../src/components/CheckboxOne/CheckboxOne.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,EAAE,EACF,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,YAAY,
|
|
1
|
+
{"version":3,"file":"CheckboxOne.js","sourceRoot":"","sources":["../../../src/components/CheckboxOne/CheckboxOne.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,EAAE,EACF,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,GAC2B;IACtC,OAAO,CACN,KAAC,UAAU,IACV,EAAE,EAAE,EAAE,EACN,SAAS,EAAC,sBAAsB,EAChC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC,EACtC,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,IAAI,EACnB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,IAAI,UAAU,EACtC,SAAS,SACR,CACF,CAAC;AACH,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { getComponentErrors } from '../shared/ComponentErrors/ComponentErrors';
|
|
|
3
3
|
import { RadioGroup } from '../shared/Radio/RadioGroup';
|
|
4
4
|
import { slottableComponent } from '../shared/HOC/slottableComponent';
|
|
5
5
|
function LunaticRadio(props) {
|
|
6
|
-
const { id, options, value, checkboxStyle, errors, label, shortcut, className = 'lunatic-radio-group', disabled, readOnly, description, declarations, } = props;
|
|
7
|
-
return (_jsx(RadioGroup, { id: id, options: options, value: value, description: description, checkboxStyle: checkboxStyle, errors: getComponentErrors(errors, id), label: label, className: className, shortcut: shortcut, disabled: disabled, readOnly: readOnly, declarations: declarations }));
|
|
6
|
+
const { id, options, value, checkboxStyle, errors, label, shortcut, className = 'lunatic-radio-group', disabled, readOnly, description, declarations, orientation, } = props;
|
|
7
|
+
return (_jsx(RadioGroup, { id: id, options: options, value: value, description: description, checkboxStyle: checkboxStyle, errors: getComponentErrors(errors, id), label: label, className: className, shortcut: shortcut, disabled: disabled, readOnly: readOnly, declarations: declarations, orientation: orientation ?? 'vertical' }));
|
|
8
8
|
}
|
|
9
9
|
export const Radio = slottableComponent('Radio', LunaticRadio);
|
|
10
10
|
//# sourceMappingURL=Radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../../src/components/Radio/Radio.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,SAAS,YAAY,CAAC,KAAqC;IAC1D,MAAM,EACL,EAAE,EACF,OAAO,EACP,KAAK,EACL,aAAa,EACb,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,qBAAqB,EACjC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,YAAY,
|
|
1
|
+
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../../src/components/Radio/Radio.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,SAAS,YAAY,CAAC,KAAqC;IAC1D,MAAM,EACL,EAAE,EACF,OAAO,EACP,KAAK,EACL,aAAa,EACb,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,qBAAqB,EACjC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,GACX,GAAG,KAAK,CAAC;IACV,OAAO,CACN,KAAC,UAAU,IACV,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC,EACtC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,IAAI,UAAU,GACrC,CACF,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
iterations?: unknown;
|
|
5
|
-
expressions: {
|
|
6
|
-
label?: Array<ReactNode | undefined>;
|
|
7
|
-
complete?: Array<boolean | undefined>;
|
|
8
|
-
partial?: Array<boolean | undefined>;
|
|
9
|
-
unnecessary?: Array<boolean | undefined>;
|
|
10
|
-
};
|
|
11
|
-
locked?: boolean;
|
|
1
|
+
import type { LunaticComponentProps } from '../type';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type Props = Pick<LunaticComponentProps<'Roundabout'>, 'items' | 'label'> & {
|
|
12
4
|
goToIteration: (v: number) => void;
|
|
13
5
|
};
|
|
14
|
-
export declare const CustomRoundabout:
|
|
6
|
+
export declare const CustomRoundabout: React.ComponentType<Props>;
|
|
15
7
|
export {};
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {} from 'react';
|
|
3
|
-
import { RoundaboutItButton } from './RoundaboutItButton';
|
|
4
2
|
import { slottableComponent } from '../shared/HOC/slottableComponent';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { Label } from '../shared/Label/Label';
|
|
4
|
+
import { Button } from '../shared/Button/Button';
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
function RoundaboutItem({ label, progress, description, onClick, disabled, iteration, }) {
|
|
8
|
+
return (_jsxs("section", { className: "lunatic-roundabout__item", children: [_jsxs("div", { children: [label && (_jsx("label", { className: "lunatic-roundabout__label", htmlFor: `action${iteration}`, children: label })), description && (_jsx("div", { className: "lunatic-roundabout__description", children: description }))] }), !disabled && (_jsx(Button, { id: `action${iteration}`, className: classnames('lunatic-roundabout__button', getButtonClass(progress)), onClick: onClick, children: getButtonLabel(progress) }))] }));
|
|
8
9
|
}
|
|
9
|
-
export const CustomRoundabout = slottableComponent('Roundabout', ({
|
|
10
|
-
|
|
11
|
-
const { complete = emptyArray, partial = emptyArray, label: iterationLabels = emptyArray, unnecessary = emptyArray, } = expressions;
|
|
12
|
-
if (iterationLabels !== undefined && partial !== undefined) {
|
|
13
|
-
const subElements = new Array(iterations).fill(null).map(function (_, i) {
|
|
14
|
-
return (_jsx(RoundaboutIteration, { index: i, label: iterationLabels[i], complete: complete[i], partial: partial[i], unnecessary: unnecessary[i], goToIteration: goToIteration, locked: locked }, i));
|
|
15
|
-
});
|
|
16
|
-
return (_jsxs(RoundaboutContainer, { children: [_jsx(RoundaboutLabel, { value: label }), subElements] }));
|
|
17
|
-
}
|
|
18
|
-
return _jsx(RoundaboutPending, {});
|
|
10
|
+
export const CustomRoundabout = slottableComponent('Roundabout', ({ items, goToIteration, label }) => {
|
|
11
|
+
return (_jsxs("div", { className: "lunatic-roundabout", children: [_jsx(Label, { children: label }), _jsx("div", { className: "lunatic-roundabout__items", children: items.map((item, k) => (_jsx(RoundaboutItem, { iteration: k, ...item, onClick: () => goToIteration(k) }, k))) })] }));
|
|
19
12
|
});
|
|
13
|
+
function getButtonLabel(progress) {
|
|
14
|
+
if (progress === 1) {
|
|
15
|
+
return 'Complété';
|
|
16
|
+
}
|
|
17
|
+
if (progress === 0) {
|
|
18
|
+
return 'Modifier';
|
|
19
|
+
}
|
|
20
|
+
return 'Commencer';
|
|
21
|
+
}
|
|
22
|
+
function getButtonClass(progress) {
|
|
23
|
+
if (progress === 1) {
|
|
24
|
+
return 'lunatic-roundabout__button-completed';
|
|
25
|
+
}
|
|
26
|
+
if (progress === 0) {
|
|
27
|
+
return 'lunatic-roundabout__button-progress';
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
20
31
|
//# sourceMappingURL=CustomRoundabout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomRoundabout.js","sourceRoot":"","sources":["../../../src/components/Roundabout/CustomRoundabout.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CustomRoundabout.js","sourceRoot":"","sources":["../../../src/components/Roundabout/CustomRoundabout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,SAAS,cAAc,CAAC,EACvB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,GACE;IACX,OAAO,CACN,mBAAS,SAAS,EAAC,0BAA0B,aAC5C,0BACE,KAAK,IAAI,CACT,gBACC,SAAS,EAAC,2BAA2B,EACrC,OAAO,EAAE,SAAS,SAAS,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AO,qCAAqC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -2,4 +2,4 @@ import type { LunaticComponentProps } from '../type';
|
|
|
2
2
|
/**
|
|
3
3
|
* Roundabout is a special loop component where the user can select the iteration to go to
|
|
4
4
|
*/
|
|
5
|
-
export declare function Roundabout(
|
|
5
|
+
export declare function Roundabout(props: LunaticComponentProps<'Roundabout'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
2
|
import { CustomRoundabout } from './CustomRoundabout';
|
|
4
3
|
/**
|
|
5
4
|
* Roundabout is a special loop component where the user can select the iteration to go to
|
|
6
5
|
*/
|
|
7
|
-
export function Roundabout(
|
|
8
|
-
const goToIteration =
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export function Roundabout(props) {
|
|
7
|
+
const goToIteration = (iteration) => {
|
|
8
|
+
// Update progress
|
|
9
|
+
console.log(props.items);
|
|
10
|
+
if (props.items[iteration].progress !== 1 &&
|
|
11
|
+
props.items[iteration].progress !== 0) {
|
|
12
|
+
props.handleChanges([
|
|
13
|
+
{ name: props.progressVariable, value: 0, iteration: [iteration] },
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
16
|
+
props.goToPage({
|
|
17
|
+
page: props.page,
|
|
11
18
|
subPage: 0,
|
|
12
19
|
iteration,
|
|
13
|
-
nbIterations: iterations,
|
|
20
|
+
nbIterations: props.iterations,
|
|
14
21
|
});
|
|
15
|
-
}
|
|
16
|
-
return
|
|
22
|
+
};
|
|
23
|
+
return _jsx(CustomRoundabout, { ...props, goToIteration: goToIteration });
|
|
17
24
|
}
|
|
18
25
|
//# sourceMappingURL=Roundabout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Roundabout.js","sourceRoot":"","sources":["../../../src/components/Roundabout/Roundabout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Roundabout.js","sourceRoot":"","sources":["../../../src/components/Roundabout/Roundabout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAA0C;IACpE,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE;QAC3C,kBAAkB;QAClB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,IACC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,QAAQ,KAAK,CAAC;YACrC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,QAAQ,KAAK,CAAC,EACpC,CAAC;YACF,KAAK,CAAC,aAAa,CAAC;gBACnB,EAAE,IAAI,EAAE,KAAK,CAAC,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE;aAClE,CAAC,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC;YACd,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,CAAC;YACV,SAAS;YACT,YAAY,EAAE,KAAK,CAAC,UAAU;SAC9B,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,KAAC,gBAAgB,OAAK,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,CAAC;AACtE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, {} from 'react';
|
|
3
3
|
import { render, fireEvent } from '@testing-library/react';
|
|
4
4
|
import { CustomRoundabout } from './CustomRoundabout';
|
|
5
5
|
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
@@ -8,17 +8,23 @@ describe('Roundabout', () => {
|
|
|
8
8
|
afterEach(() => {
|
|
9
9
|
mockGoToIteration.mockClear();
|
|
10
10
|
});
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const items = [
|
|
12
|
+
{
|
|
13
|
+
label: 'Step 1',
|
|
14
|
+
progress: -1,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: 'Step 2',
|
|
18
|
+
progress: 0,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: 'Step 3',
|
|
22
|
+
progress: 1,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
18
25
|
const label = 'My Roundabout';
|
|
19
|
-
const locked = false;
|
|
20
26
|
it('renders the roundabout correctly', () => {
|
|
21
|
-
const { getByText } = render(_jsx(CustomRoundabout, {
|
|
27
|
+
const { getByText } = render(_jsx(CustomRoundabout, { items: items, goToIteration: mockGoToIteration }));
|
|
22
28
|
expect(getByText('Step 1')).toBeInTheDocument();
|
|
23
29
|
expect(getByText('Step 2')).toBeInTheDocument();
|
|
24
30
|
expect(getByText('Step 3')).toBeInTheDocument();
|
|
@@ -27,24 +33,11 @@ describe('Roundabout', () => {
|
|
|
27
33
|
expect(getByText('Commencer')).toBeInTheDocument();
|
|
28
34
|
});
|
|
29
35
|
it('calls the goToIteration function when a button is clicked', () => {
|
|
30
|
-
const { getByText } = render(_jsx(CustomRoundabout, {
|
|
36
|
+
const { getByText } = render(_jsx(CustomRoundabout, { items: items, goToIteration: mockGoToIteration, label: label }));
|
|
31
37
|
const button = getByText('Modifier');
|
|
32
38
|
fireEvent.click(button);
|
|
33
39
|
expect(mockGoToIteration).toHaveBeenCalledTimes(1);
|
|
34
40
|
expect(mockGoToIteration).toHaveBeenCalledWith(1);
|
|
35
41
|
});
|
|
36
|
-
it('disables buttons correctly when necessary', () => {
|
|
37
|
-
const lockedExpressions = {
|
|
38
|
-
complete: [true, false, false],
|
|
39
|
-
partial: [false, true, false],
|
|
40
|
-
iterationLabels: ['Step 1', 'Step 2', 'Step 3'],
|
|
41
|
-
unnecessary: [false, false, false],
|
|
42
|
-
};
|
|
43
|
-
const { getByText } = render(_jsx(CustomRoundabout, { iterations: iterations, expressions: lockedExpressions, goToIteration: mockGoToIteration, label: label, locked: true }));
|
|
44
|
-
const completeButton = getByText('Complété');
|
|
45
|
-
const unstartedButton = getByText('Commencer');
|
|
46
|
-
expect(completeButton).toBeDisabled();
|
|
47
|
-
expect(unstartedButton).not.toBeDisabled();
|
|
48
|
-
});
|
|
49
42
|
});
|
|
50
43
|
//# sourceMappingURL=roundabout.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundabout.spec.js","sourceRoot":"","sources":["../../../src/components/Roundabout/roundabout.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"roundabout.spec.js","sourceRoot":"","sources":["../../../src/components/Roundabout/roundabout.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAkB,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE7D,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC3B,MAAM,iBAAiB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAElC,SAAS,CAAC,GAAG,EAAE;QACd,iBAAiB,CAAC,SAAS,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG;QACb;YACC,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,CAAC,CAAC;SACZ;QACD;YACC,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,CAAC;SACX;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AAC,CAAC,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import {} from 'react';
|
|
4
4
|
import { prevent } from '../../../utils/dom';
|
|
5
5
|
import { isElement } from '../../../utils/is-element';
|
|
6
6
|
import { slottableComponent } from '../HOC/slottableComponent';
|
|
7
|
-
function LunaticButton({ children, onClick, disabled, label, className, value, type = 'button', selected, readOnly, }) {
|
|
7
|
+
function LunaticButton({ id, children, onClick, disabled, label, className, value, type = 'button', selected, readOnly, }) {
|
|
8
8
|
const handleClick = prevent(onClick);
|
|
9
9
|
if (isElement(children) || value)
|
|
10
|
-
return (_jsx("button", { disabled: disabled || readOnly, type: type, className: classnames('button-lunatic', className, { disabled }), onClick: handleClick, value: value, "aria-pressed": selected, children: children }));
|
|
11
|
-
return (_jsx(
|
|
10
|
+
return (_jsx("button", { id: id, disabled: disabled || readOnly, type: type, className: classnames('button-lunatic', className, { disabled }), onClick: handleClick, value: value, "aria-pressed": selected, children: children }));
|
|
11
|
+
return (_jsx("input", { id: id, "aria-pressed": selected, disabled: disabled || readOnly, type: "button", className: classnames('button-lunatic', className, { disabled }), value: label ?? children?.toString(), onClick: handleClick }));
|
|
12
12
|
}
|
|
13
13
|
export const Button = slottableComponent('Button', LunaticButton);
|
|
14
14
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/shared/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,C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Aa,CAAC,CAAC"}
|
|
@@ -7,8 +7,6 @@ import type { Table, Tbody, Td, Th, Thead, Tr } from '../Table';
|
|
|
7
7
|
import type { CustomTextarea } from '../../Textarea/Textarea';
|
|
8
8
|
import type { RadioGroup } from '../Radio/RadioGroup';
|
|
9
9
|
import type { CustomRoundabout } from '../../Roundabout/CustomRoundabout';
|
|
10
|
-
import type { RoundaboutContainer, RoundaboutItContainer, RoundaboutItTitle, RoundaboutLabel, RoundaboutPending } from '../../Roundabout/extra';
|
|
11
|
-
import type { RoundaboutItButton } from '../../Roundabout/RoundaboutItButton';
|
|
12
10
|
import type { Button } from '../Button/Button';
|
|
13
11
|
import type { CustomCheckboxBoolean } from '../../CheckboxBoolean/CheckboxBoolean';
|
|
14
12
|
import type { CheckboxOption } from '../Checkbox/CheckboxOption';
|
|
@@ -70,12 +68,6 @@ export type LunaticSlotComponents = {
|
|
|
70
68
|
ComboboxClearButton: typeof ComboboxClearButton;
|
|
71
69
|
ComboboxLabelSelection: typeof ComboboxLabelSelection;
|
|
72
70
|
Roundabout: typeof CustomRoundabout;
|
|
73
|
-
RoundaboutContainer: typeof RoundaboutContainer;
|
|
74
|
-
RoundaboutLabel: typeof RoundaboutLabel;
|
|
75
|
-
RoundaboutItTitle: typeof RoundaboutItTitle;
|
|
76
|
-
RoundaboutItContainer: typeof RoundaboutItContainer;
|
|
77
|
-
RoundaboutItButton: typeof RoundaboutItButton;
|
|
78
|
-
RoundaboutPending: typeof RoundaboutPending;
|
|
79
71
|
SuggesterNotification: typeof SuggesterNotification;
|
|
80
72
|
SummaryTitle: typeof SummaryTitle;
|
|
81
73
|
SummaryResponses: typeof SummaryResponses;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slottableComponent.js","sourceRoot":"","sources":["../../../../src/components/shared/HOC/slottableComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEN,aAAa,EAGb,UAAU,GACV,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"slottableComponent.js","sourceRoot":"","sources":["../../../../src/components/shared/HOC/slottableComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEN,aAAa,EAGb,UAAU,GACV,MAAM,OAAO,CAAC;AA2Gf,MAAM,KAAK,GAAG,EAAgD,CAAC;AAE/D,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC7B,KAAK,EACL,QAAQ,GACuD,EAAE,EAAE;IACnE,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,4BAAG,QAAQ,GAAI,CAAC;IACxB,CAAC;IACD,OAAO,CACN,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAI,KAAK,YAC1C,QAAQ,GACc,CACxB,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAiC,EACjC,iBAAuC;IAEvC,MAAM,kBAAkB,GAAG,CAAC,KAAQ,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC;QAEjD,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YAC9B,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAqB,CAAC;YACvD,uBAAuB;YACvB,OAAO,KAAC,aAAa,OAAK,KAAK,GAAI,CAAC;QACrC,CAAC;QAED,uBAAuB;QACvB,OAAO,KAAC,iBAAiB,OAAK,KAAK,GAAI,CAAC;IACzC,CAAC,CAAC;IACF,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC;IACtC,OAAO,kBAAkB,CAAC;AAC3B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { LunaticError } from '../../../use-lunatic/type';
|
|
3
3
|
import type { LunaticComponentProps } from '../../type';
|
|
4
|
-
export type RadioGroupProps = Pick<LunaticComponentProps<'Radio'>, 'id' | 'options' | 'value' | 'checkboxStyle' | 'label' | 'shortcut' | 'className' | 'disabled' | 'readOnly' | 'description' | 'declarations'> & {
|
|
4
|
+
export type RadioGroupProps = Pick<LunaticComponentProps<'Radio'>, 'id' | 'options' | 'value' | 'checkboxStyle' | 'label' | 'shortcut' | 'className' | 'disabled' | 'readOnly' | 'description' | 'declarations' | 'orientation'> & {
|
|
5
5
|
errors?: LunaticError[];
|
|
6
6
|
clearable?: boolean;
|
|
7
7
|
};
|
|
@@ -10,14 +10,14 @@ import { Declarations } from '../Declarations/Declarations';
|
|
|
10
10
|
/**
|
|
11
11
|
* Stack of radios fields surrounded by a fieldset
|
|
12
12
|
*/
|
|
13
|
-
function LunaticRadioGroup({ options, value, id, label, description, checkboxStyle = false, errors, className, shortcut, disabled, readOnly, declarations, }) {
|
|
13
|
+
function LunaticRadioGroup({ options, value, id, label, description, checkboxStyle = false, errors, className, shortcut, disabled, readOnly, declarations, orientation, }) {
|
|
14
14
|
const onKeyDown = useListKeyboardHandler(options);
|
|
15
15
|
const maxIndex = options.length;
|
|
16
|
-
return (_jsxs(Fieldset, { className: className, legend: label, description: description, children: [_jsx(Declarations, { type: "AFTER_QUESTION_TEXT", declarations: declarations }), options.map(function (option, index) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
return (_jsxs(Fieldset, { className: className, legend: label, description: description, children: [_jsx(Declarations, { type: "AFTER_QUESTION_TEXT", declarations: declarations }), _jsx("div", { className: `lunatic-checkboxes lunatic-checkboxes--${orientation}`, children: options.map(function (option, index) {
|
|
17
|
+
const radioId = `lunatic-radio-${id}-${option.value}`;
|
|
18
|
+
const codeModality = getShortcutKey(index, maxIndex);
|
|
19
|
+
return (_createElement(RadioOption, { ...option, key: radioId, id: radioId, index: index, checked: value === option.value, onKeyDown: onKeyDown, checkboxStyle: checkboxStyle, codeModality: shortcut ? codeModality : undefined, shortcut: shortcut, disabled: disabled, readOnly: readOnly, invalid: !!errors }));
|
|
20
|
+
}) }), _jsx(ComponentErrors, { errors: errors })] }));
|
|
21
21
|
}
|
|
22
22
|
export const RadioGroup = slottableComponent('RadioGroup', LunaticRadioGroup);
|
|
23
23
|
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../../../src/components/shared/Radio/RadioGroup.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../../../src/components/shared/Radio/RadioGroup.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAsB5D;;GAEG;AACH,SAAS,iBAAiB,CAAC,EAC1B,OAAO,EACP,KAAK,EACL,EAAE,EACF,KAAK,EACL,WAAW,EACX,aAAa,GAAG,KAAK,EACr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names from 'classnames';
|
|
|
7
7
|
import { CustomInput } from '../../Input/Input';
|
|
8
8
|
function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle, value, onKeyDown, index, shortcut, codeModality, id, labelledBy, description, label, onDetailChange, detailLabel, detailValue, onCheck, }) {
|
|
9
9
|
const divEl = useRef(null);
|
|
10
|
-
const tabIndex = checked ? 0 : -1;
|
|
11
10
|
const isEnabled = !disabled && !readOnly;
|
|
12
11
|
const isRadio = !checkboxStyle;
|
|
13
12
|
const hasDetail = !!onDetailChange;
|
|
14
13
|
const onClickOption = () => {
|
|
15
|
-
if (!isEnabled || !onCheck) {
|
|
14
|
+
if (!isEnabled || !onCheck || checked) {
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
17
|
onCheck();
|
|
@@ -32,7 +31,7 @@ function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle, value,
|
|
|
32
31
|
e.preventDefault();
|
|
33
32
|
onClickOption();
|
|
34
33
|
}, hasKeyboardShortcut);
|
|
35
|
-
return (_jsxs("div", { className: "lunatic-input-checkbox-wrapper", children: [_jsxs("div", { id: id, role: "radio", "aria-disabled": disabled, className: classnames('lunatic-input-checkbox', isRadio && 'lunatic-input-radio'), "aria-checked": checked, tabIndex:
|
|
34
|
+
return (_jsxs("div", { className: "lunatic-input-checkbox-wrapper", children: [_jsxs("div", { id: id, role: "radio", "aria-disabled": disabled, className: classnames('lunatic-input-checkbox', isRadio && 'lunatic-input-radio'), "aria-checked": checked, tabIndex: checked ? -1 : 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelledBy, ref: divEl, children: [_jsx("div", { className: "lunatic-input-checkbox__icon", children: checked && checkboxStyle && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: _jsx("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), _jsxs(Label, { id: labelledBy, htmlFor: id, description: description, children: [codeModality && (_jsx("span", { className: "code-modality", children: codeModality.toUpperCase() })), label] })] }), hasDetail && checked && (_jsx(CustomInput, { id: "detailId", label: detailLabel ?? 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', onChange: onDetailChange, disabled: disabled }))] }));
|
|
36
35
|
}
|
|
37
36
|
export const RadioOption = slottableComponent('RadioOption', LunaticRadioOption);
|
|
38
37
|
//# sourceMappingURL=RadioOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioOption.js","sourceRoot":"","sources":["../../../../src/components/shared/Radio/RadioOption.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA6B,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgBhD,SAAS,kBAAkB,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,UAAU,EACV,WAAW,EACX,KAAK,EACL,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,GACA;IACP,MAAM,KAAK,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC3C,MAAM,
|
|
1
|
+
{"version":3,"file":"RadioOption.js","sourceRoot":"","sources":["../../../../src/components/shared/Radio/RadioOption.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA6B,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,C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CAAC,EAAE,EACzD,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,GACjB,CACF,IACI,CACN,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAC5C,aAAa,EACb,kBAAkB,CAClB,CAAC"}
|
|
@@ -15,13 +15,13 @@ describe('RadioOption', () => {
|
|
|
15
15
|
fireEvent.click(option);
|
|
16
16
|
expect(onClickMock).toHaveBeenCalled();
|
|
17
17
|
});
|
|
18
|
-
it('sets the tabIndex to
|
|
18
|
+
it('sets the tabIndex to 0 when unchecked', () => {
|
|
19
19
|
const { getByRole } = render(_jsx(RadioOption, { id: "radio-option", label: "Test Option", checked: false }));
|
|
20
|
-
expect(getByRole('radio')).toHaveAttribute('tabIndex', '
|
|
20
|
+
expect(getByRole('radio')).toHaveAttribute('tabIndex', '0');
|
|
21
21
|
});
|
|
22
|
-
it('sets the tabIndex to
|
|
22
|
+
it('sets the tabIndex to -1 when checked', () => {
|
|
23
23
|
const { getByRole } = render(_jsx(RadioOption, { id: "radio-option", label: "Test Option", checked: true }));
|
|
24
|
-
expect(getByRole('radio')).toHaveAttribute('tabIndex', '
|
|
24
|
+
expect(getByRole('radio')).toHaveAttribute('tabIndex', '-1');
|
|
25
25
|
});
|
|
26
26
|
it('applies the disabled aria when disabled prop is present', () => {
|
|
27
27
|
const { getByRole } = render(_jsx(RadioOption, { id: "radio-option", label: "Test Option", disabled: true }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioOption.spec.js","sourceRoot":"","sources":["../../../../src/components/shared/Radio/RadioOption.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;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SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3D,MAAM,CAAC,aAAa,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/lib/components/type.d.ts
CHANGED
|
@@ -175,6 +175,7 @@ export type ComponentPropsByType = {
|
|
|
175
175
|
CheckboxOne: LunaticBaseProps<string | null> & LunaticExtraProps & {
|
|
176
176
|
options: Array<InterpretedOption>;
|
|
177
177
|
componentType?: 'CheckboxOne';
|
|
178
|
+
orientation?: 'horizontal' | 'vertical';
|
|
178
179
|
};
|
|
179
180
|
Switch: LunaticBaseProps<boolean> & LunaticExtraProps & {
|
|
180
181
|
response: {
|
|
@@ -199,18 +200,19 @@ export type ComponentPropsByType = {
|
|
|
199
200
|
name: string;
|
|
200
201
|
};
|
|
201
202
|
componentType?: 'Radio';
|
|
203
|
+
orientation?: 'horizontal' | 'vertical';
|
|
202
204
|
};
|
|
203
205
|
Roundabout: LunaticBaseProps<string> & LunaticExtraProps & {
|
|
204
206
|
iterations: number;
|
|
205
207
|
goToPage: ReturnType<typeof useLunatic>['goToPage'];
|
|
206
208
|
page: number;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
};
|
|
209
|
+
progressVariable: string;
|
|
210
|
+
items: {
|
|
211
|
+
label?: ReactNode;
|
|
212
|
+
progress: number;
|
|
213
|
+
description?: ReactNode;
|
|
214
|
+
disabled?: boolean;
|
|
215
|
+
}[];
|
|
214
216
|
componentType?: 'Roundabout';
|
|
215
217
|
};
|
|
216
218
|
Dropdown: LunaticBaseProps<string | null> & LunaticExtraProps & {
|
|
@@ -5,7 +5,11 @@ import { useCallback } from 'react';
|
|
|
5
5
|
export function useListKeyboardHandler(options) {
|
|
6
6
|
return useCallback(({ key, index }) => {
|
|
7
7
|
const { length } = options;
|
|
8
|
-
|
|
8
|
+
const currentOption = options[index];
|
|
9
|
+
if (key === ' ' && !currentOption.checked && currentOption.onCheck) {
|
|
10
|
+
currentOption.onCheck();
|
|
11
|
+
}
|
|
12
|
+
else if (key === 'ArrowRight' || key === 'ArrowDown') {
|
|
9
13
|
const next = index === length - 1 ? 0 : index + 1;
|
|
10
14
|
const option = options[next];
|
|
11
15
|
if (option.onCheck) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListKeyboardHandler.js","sourceRoot":"","sources":["../../src/hooks/useListKeyboardHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACrC,
|
|
1
|
+
{"version":3,"file":"useListKeyboardHandler.js","sourceRoot":"","sources":["../../src/hooks/useListKeyboardHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAAsE;IAEtE,OAAO,WAAW,CACjB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAkC,EAAE,EAAE;QAClD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3B,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;YACpE,aAAa,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;aAAM,IAAI,GAAG,KAAK,YAAY,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;YACxD,MAAM,IAAI,GAAG,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;YAClD,MAAM,MAAM,GAAG,OAAO,CAA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