@inseefr/lunatic 3.4.0 → 3.4.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/Roundabout/CustomRoundabout.d.ts +11 -1
- package/lib/components/Roundabout/CustomRoundabout.js +3 -3
- package/lib/components/Roundabout/CustomRoundabout.js.map +1 -1
- package/lib/components/Roundabout/Roundabout.js +6 -1
- package/lib/components/Roundabout/Roundabout.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { LunaticComponentProps } from '../type';
|
|
2
|
-
type
|
|
2
|
+
import type { LunaticError } from '../../use-lunatic/type';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
type Props = Pick<LunaticComponentProps<'Roundabout'>, 'label' | 'locked' | 'id'> & {
|
|
3
5
|
goToIteration: (v: number) => void;
|
|
6
|
+
errors?: LunaticError[];
|
|
7
|
+
items: {
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
progress: number;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
errors?: LunaticError[] | undefined;
|
|
13
|
+
}[];
|
|
4
14
|
};
|
|
5
15
|
export declare const CustomRoundabout: import("react").ComponentType<Props>;
|
|
6
16
|
export {};
|
|
@@ -3,12 +3,12 @@ import { slottableComponent } from '../shared/HOC/slottableComponent';
|
|
|
3
3
|
import { Label } from '../shared/Label/Label';
|
|
4
4
|
import { Button } from '../shared/Button/Button';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
|
-
import { ComponentErrors
|
|
6
|
+
import { ComponentErrors } from '../shared/ComponentErrors/ComponentErrors';
|
|
7
7
|
function RoundaboutItem({ label, progress, description, onClick, disabled, iteration, locked, errors, }) {
|
|
8
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, disabled: locked && progress === 1, children: getButtonLabel(progress) })), _jsx(ComponentErrors, { errors: errors })] }));
|
|
9
9
|
}
|
|
10
|
-
export const CustomRoundabout = slottableComponent('Roundabout', ({ items, goToIteration, label, locked
|
|
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, errors:
|
|
10
|
+
export const CustomRoundabout = slottableComponent('Roundabout', ({ items, goToIteration, label, locked }) => {
|
|
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, errors: item.errors, onClick: () => goToIteration(k), locked: locked }, k))) })] }));
|
|
12
12
|
});
|
|
13
13
|
function getButtonLabel(progress) {
|
|
14
14
|
if (progress === 1) {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EA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AM,EACnB,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAC/B,MAAM,EAAE,MAAM,IALT,CAAC,CAML,CACF,CAAC,GACG,IACD,CACN,CAAC;AACH,CAAC,CACD,CAAC;AAEF,SAAS,cAAc,CAAC,QAAgB;IACvC,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,UAAU,CAAC;IACnB,CAAC;IACD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,UAAU,CAAC;IACnB,CAAC;IACD,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACvC,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,sCAAsC,CAAC;IAC/C,CAAC;IACD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,qCAAqC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { CustomRoundabout } from './CustomRoundabout';
|
|
3
|
+
import { getComponentErrors } from '../shared/ComponentErrors/ComponentErrors';
|
|
3
4
|
/**
|
|
4
5
|
* Roundabout is a special loop component where the user can select the iteration to go to
|
|
5
6
|
*/
|
|
@@ -18,6 +19,10 @@ export function Roundabout(props) {
|
|
|
18
19
|
nbIterations: props.iterations,
|
|
19
20
|
});
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
+
const itemsWithErrors = props.items.map((item, k) => ({
|
|
23
|
+
...item,
|
|
24
|
+
errors: getComponentErrors(props.errors, `${props.id}-${k}`),
|
|
25
|
+
}));
|
|
26
|
+
return (_jsx(CustomRoundabout, { ...props, errors: getComponentErrors(props.errors, props.id), items: itemsWithErrors, goToIteration: goToIteration }));
|
|
22
27
|
}
|
|
23
28
|
//# sourceMappingURL=Roundabout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Roundabout.js","sourceRoot":"","sources":["../../../src/components/Roundabout/Roundabout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Roundabout.js","sourceRoot":"","sources":["../../../src/components/Roundabout/Roundabout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAA0C;IACpE,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE;QAC3C,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,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACrD,GAAG,IAAI;QACP,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;KAC5D,CAAC,CAAC,CAAC;IAEJ,OAAO,CACN,KAAC,gBAAg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