@inseefr/lunatic 3.0.0-rc.8 → 3.0.0-rc.9
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/LunaticComponents.js +19 -15
- package/lib/components/Subsequence/Subsequence.spec.js +1 -1
- package/lib/components/Suggester/Suggester.js +11 -3
- package/lib/components/Suggester/SuggesterType.js +5 -0
- package/lib/components/shared/Declarations/Declarations.js +3 -3
- package/lib/components/shared/Declarations/Declarations.spec.js +5 -5
- package/lib/src/components/Suggester/CustomSuggester.d.ts +3 -3
- package/lib/src/components/Suggester/SuggesterType.d.ts +6 -0
- package/lib/src/components/Suggester/helpers.d.ts +2 -2
- package/lib/src/components/shared/Declarations/Declarations.d.ts +2 -2
- package/lib/src/components/shared/HOC/slottableComponent.d.ts +4 -0
- package/lib/src/components/type.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +4 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +4 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +8 -0
- package/lib/src/use-lunatic/type-source.d.ts +4 -0
- package/package.json +1 -1
|
@@ -19,24 +19,28 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
19
19
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
20
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
21
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
|
+
var LunaticComponentWrapper = (0, _slottableComponent.slottableComponent)('ComponentWrapper', function (_ref) {
|
|
23
|
+
var children = _ref.children;
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
25
|
+
className: "lunatic lunatic-component",
|
|
26
|
+
children: children
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
22
30
|
/**
|
|
23
31
|
* Entry point for orchestrators, this component display the list of fields
|
|
24
32
|
*/
|
|
25
|
-
function LunaticComponents(
|
|
26
|
-
var components =
|
|
27
|
-
autoFocusKey =
|
|
28
|
-
componentProps =
|
|
29
|
-
blocklist =
|
|
30
|
-
memo =
|
|
31
|
-
slots =
|
|
32
|
-
|
|
33
|
-
wrapper =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
className: "lunatic lunatic-component",
|
|
37
|
-
children: children
|
|
38
|
-
});
|
|
39
|
-
} : _ref$wrapper;
|
|
33
|
+
function LunaticComponents(_ref2) {
|
|
34
|
+
var components = _ref2.components,
|
|
35
|
+
autoFocusKey = _ref2.autoFocusKey,
|
|
36
|
+
componentProps = _ref2.componentProps,
|
|
37
|
+
blocklist = _ref2.blocklist,
|
|
38
|
+
memo = _ref2.memo,
|
|
39
|
+
slots = _ref2.slots,
|
|
40
|
+
_ref2$wrapper = _ref2.wrapper,
|
|
41
|
+
wrapper = _ref2$wrapper === void 0 ? function (args) {
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LunaticComponentWrapper, _objectSpread({}, args));
|
|
43
|
+
} : _ref2$wrapper;
|
|
40
44
|
var wrapperRef = (0, _react.useRef)(null);
|
|
41
45
|
var hasComponents = components.length > 0;
|
|
42
46
|
var WrapperComponent = autoFocusKey ? 'div' : _react.Fragment;
|
|
@@ -14,7 +14,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
14
14
|
var mockDeclarations = [{
|
|
15
15
|
id: '1',
|
|
16
16
|
label: 'Declaration 1',
|
|
17
|
-
declarationType: '
|
|
17
|
+
declarationType: 'COMMENT',
|
|
18
18
|
position: 'AFTER_QUESTION_TEXT'
|
|
19
19
|
}];
|
|
20
20
|
var mockProps = {
|
|
@@ -88,13 +88,21 @@ function Suggester(_ref) {
|
|
|
88
88
|
return o.attribute === 'label';
|
|
89
89
|
});
|
|
90
90
|
if (!labelResponse) {
|
|
91
|
-
return [
|
|
91
|
+
return [{
|
|
92
|
+
id: value,
|
|
93
|
+
label: value,
|
|
94
|
+
value: value
|
|
95
|
+
}];
|
|
92
96
|
}
|
|
93
97
|
var label = executeExpression(labelResponse.name, {
|
|
94
98
|
iteration: iteration
|
|
95
99
|
});
|
|
96
|
-
if (
|
|
97
|
-
return [
|
|
100
|
+
if (typeof label !== 'string') {
|
|
101
|
+
return [{
|
|
102
|
+
id: value,
|
|
103
|
+
label: value,
|
|
104
|
+
value: value
|
|
105
|
+
}];
|
|
98
106
|
}
|
|
99
107
|
return [{
|
|
100
108
|
id: value,
|
|
@@ -10,10 +10,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
var Declaration = exports.Declaration = (0, _slottableComponent.slottableComponent)('Declaration', function (_ref) {
|
|
12
12
|
var children = _ref.children,
|
|
13
|
-
|
|
13
|
+
declarationType = _ref.declarationType;
|
|
14
14
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
15
15
|
"data-testid": "declaration",
|
|
16
|
-
className: (0, _classnames["default"])('declaration-lunatic', "declaration-".concat(
|
|
16
|
+
className: (0, _classnames["default"])('declaration-lunatic', "declaration-".concat(declarationType.toLowerCase())),
|
|
17
17
|
children: children
|
|
18
18
|
});
|
|
19
19
|
});
|
|
@@ -37,7 +37,7 @@ function LunaticDeclarations(_ref2) {
|
|
|
37
37
|
label = _ref3.label,
|
|
38
38
|
declarationType = _ref3.declarationType;
|
|
39
39
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Declaration, {
|
|
40
|
-
|
|
40
|
+
declarationType: declarationType,
|
|
41
41
|
children: label
|
|
42
42
|
}, id);
|
|
43
43
|
})
|
|
@@ -7,17 +7,17 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
7
7
|
var declarations = [{
|
|
8
8
|
id: '1',
|
|
9
9
|
label: 'Declaration 1',
|
|
10
|
-
declarationType: '
|
|
10
|
+
declarationType: 'COMMENT',
|
|
11
11
|
position: 'AFTER_QUESTION_TEXT'
|
|
12
12
|
}, {
|
|
13
13
|
id: '2',
|
|
14
14
|
label: 'Declaration 2',
|
|
15
|
-
declarationType: '
|
|
15
|
+
declarationType: 'COMMENT',
|
|
16
16
|
position: 'BEFORE_QUESTION_TEXT'
|
|
17
17
|
}, {
|
|
18
18
|
id: '3',
|
|
19
19
|
label: 'Declaration 3',
|
|
20
|
-
declarationType: '
|
|
20
|
+
declarationType: 'COMMENT',
|
|
21
21
|
position: 'DETACHABLE'
|
|
22
22
|
}];
|
|
23
23
|
(0, _vitest.describe)('Declarations component', function () {
|
|
@@ -38,13 +38,13 @@ var declarations = [{
|
|
|
38
38
|
var declarationElement = getByText('Declaration 1');
|
|
39
39
|
(0, _vitest.expect)(declarationElement).toBeInTheDocument();
|
|
40
40
|
(0, _vitest.expect)(declarationElement).toHaveClass('declaration-lunatic');
|
|
41
|
-
(0, _vitest.expect)(declarationElement).toHaveClass('declaration-
|
|
41
|
+
(0, _vitest.expect)(declarationElement).toHaveClass('declaration-comment');
|
|
42
42
|
});
|
|
43
43
|
(0, _vitest.it)('renders nothing with unfiltered Declarations', function () {
|
|
44
44
|
var declarationstest = [{
|
|
45
45
|
id: '3',
|
|
46
46
|
label: 'Declaration 3',
|
|
47
|
-
declarationType: '
|
|
47
|
+
declarationType: 'COMMENT',
|
|
48
48
|
position: 'DETACHABLE'
|
|
49
49
|
}];
|
|
50
50
|
var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { LunaticError } from '../../use-lunatic/type';
|
|
3
3
|
import type { LunaticComponentProps } from '../type';
|
|
4
|
-
import type {
|
|
4
|
+
import type { SuggesterOptionType } from './SuggesterType';
|
|
5
5
|
type Props = {
|
|
6
6
|
className?: string;
|
|
7
7
|
classNamePrefix?: string;
|
|
@@ -17,13 +17,13 @@ type Props = {
|
|
|
17
17
|
readOnly?: boolean;
|
|
18
18
|
id?: string;
|
|
19
19
|
searching?: (s: string | null) => Promise<{
|
|
20
|
-
results:
|
|
20
|
+
results: SuggesterOptionType[];
|
|
21
21
|
search: string;
|
|
22
22
|
}>;
|
|
23
23
|
label?: ReactNode;
|
|
24
24
|
description?: ReactNode;
|
|
25
25
|
errors?: LunaticError[];
|
|
26
|
-
defaultOptions?:
|
|
26
|
+
defaultOptions?: SuggesterOptionType[];
|
|
27
27
|
};
|
|
28
28
|
export declare const CustomSuggester: import("react").ComponentType<Props>;
|
|
29
29
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SuggesterOptionType } from './SuggesterType';
|
|
2
2
|
export declare function isWorkerCompatible(): boolean;
|
|
3
3
|
export declare function createSearching(name: string, version: string, workersBasePath?: string): (search: string | null) => Promise<{
|
|
4
|
-
results:
|
|
4
|
+
results: SuggesterOptionType[];
|
|
5
5
|
search: string;
|
|
6
6
|
}>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type PropsWithChildren, type ReactNode } from 'react';
|
|
2
2
|
export declare const Declaration: import("react").ComponentType<PropsWithChildren<{
|
|
3
|
-
|
|
3
|
+
declarationType: 'INSTRUCTION' | 'COMMENT' | 'HELP' | 'CODECARD' | 'WARNING' | 'STATEMENT';
|
|
4
4
|
}>>;
|
|
5
5
|
type Props = {
|
|
6
6
|
id?: string;
|
|
7
7
|
type?: 'AFTER_QUESTION_TEXT' | 'BEFORE_QUESTION_TEXT' | 'DETACHABLE';
|
|
8
8
|
declarations?: {
|
|
9
9
|
id: string;
|
|
10
|
-
declarationType:
|
|
10
|
+
declarationType: 'INSTRUCTION' | 'COMMENT' | 'HELP' | 'CODECARD' | 'WARNING' | 'STATEMENT';
|
|
11
11
|
position: string;
|
|
12
12
|
label: ReactNode;
|
|
13
13
|
}[];
|
|
@@ -36,6 +36,7 @@ import type { CustomSuggester } from '../../Suggester/CustomSuggester';
|
|
|
36
36
|
import type { CustomCheckboxGroup } from '../../CheckboxGroup/CustomCheckboxGroup';
|
|
37
37
|
import type { RouterLink } from '../MDLabel/RouterLink';
|
|
38
38
|
import type { SummaryResponses, SummaryTitle } from '../../Summary/Summary';
|
|
39
|
+
import type { FilledLunaticComponentProps } from '../../../use-lunatic/commons/fill-components/fill-components';
|
|
39
40
|
/**
|
|
40
41
|
* Contains the type of every customizable component
|
|
41
42
|
*/
|
|
@@ -89,6 +90,9 @@ export type LunaticSlotComponents = {
|
|
|
89
90
|
Fieldset: typeof Fieldset;
|
|
90
91
|
Notification: typeof Notification;
|
|
91
92
|
RouterLink: typeof RouterLink;
|
|
93
|
+
ComponentWrapper: ComponentType<PropsWithChildren<FilledLunaticComponentProps & {
|
|
94
|
+
index: number;
|
|
95
|
+
}>>;
|
|
92
96
|
};
|
|
93
97
|
export declare const SlotsProvider: ({ slots, children, }: PropsWithChildren<{
|
|
94
98
|
slots?: Partial<LunaticSlotComponents> | undefined;
|
|
@@ -35,7 +35,7 @@ export type LunaticBaseProps<ValueType = unknown> = {
|
|
|
35
35
|
iteration?: number;
|
|
36
36
|
declarations?: {
|
|
37
37
|
id: string;
|
|
38
|
-
declarationType:
|
|
38
|
+
declarationType: 'INSTRUCTION' | 'COMMENT' | 'HELP' | 'CODECARD' | 'WARNING' | 'STATEMENT';
|
|
39
39
|
position: string;
|
|
40
40
|
label: ReactNode;
|
|
41
41
|
}[];
|
|
@@ -362,6 +362,10 @@ export declare function fillComponentRequired(component: LunaticComponentDefinit
|
|
|
362
362
|
componentType: "Suggester";
|
|
363
363
|
storeName: string;
|
|
364
364
|
response: import("../../type-source").ResponseType;
|
|
365
|
+
optionResponses: {
|
|
366
|
+
name: string;
|
|
367
|
+
attribute: string;
|
|
368
|
+
};
|
|
365
369
|
} | {
|
|
366
370
|
required: boolean;
|
|
367
371
|
label: import("../../type-source").LabelType;
|
|
@@ -697,6 +697,10 @@ declare function fillFromState(component: LunaticComponentDefinition, state: Lun
|
|
|
697
697
|
componentType: "Suggester";
|
|
698
698
|
storeName: string;
|
|
699
699
|
response: import("../../type-source").ResponseType;
|
|
700
|
+
optionResponses: {
|
|
701
|
+
name: string;
|
|
702
|
+
attribute: string;
|
|
703
|
+
};
|
|
700
704
|
} | {
|
|
701
705
|
handleChange: (response: {
|
|
702
706
|
name: string;
|
|
@@ -707,6 +707,10 @@ declare function fillSpecificExpressions(component: DeepTranslateExpression<Luna
|
|
|
707
707
|
response: {
|
|
708
708
|
name: string;
|
|
709
709
|
};
|
|
710
|
+
optionResponses: {
|
|
711
|
+
name: string;
|
|
712
|
+
attribute: string;
|
|
713
|
+
};
|
|
710
714
|
} & import("./fill-management").FilledProps & import("./fill-component-value").FilledProps & import("./fill-missing-response").FilledProps & import("./fill-from-state").FilledProps & import("./fill-pagination").FilledProps & {
|
|
711
715
|
conditionFilter?: boolean | undefined;
|
|
712
716
|
}) | ({
|
|
@@ -1124,6 +1128,10 @@ declare function fillSpecificExpressions(component: DeepTranslateExpression<Luna
|
|
|
1124
1128
|
response: {
|
|
1125
1129
|
name: string;
|
|
1126
1130
|
};
|
|
1131
|
+
optionResponses: {
|
|
1132
|
+
name: string;
|
|
1133
|
+
attribute: string;
|
|
1134
|
+
};
|
|
1127
1135
|
} | {
|
|
1128
1136
|
label: import("react").ReactNode;
|
|
1129
1137
|
description?: import("react").ReactNode;
|
|
@@ -205,6 +205,10 @@ export type ComponentSuggesterType = {
|
|
|
205
205
|
componentType: 'Suggester';
|
|
206
206
|
storeName: string;
|
|
207
207
|
response: ResponseType;
|
|
208
|
+
optionResponses: {
|
|
209
|
+
name: string;
|
|
210
|
+
attribute: string;
|
|
211
|
+
};
|
|
208
212
|
};
|
|
209
213
|
export type SuggesterType = {
|
|
210
214
|
name: string;
|