@inseefr/lunatic 3.6.2 → 3.6.4
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/components/Input/Input.d.ts +1 -0
- package/components/Input/Input.js +2 -2
- package/components/Input/Input.js.map +1 -1
- package/components/PairwiseLinks/PairwiseLinks.js +2 -0
- package/components/PairwiseLinks/PairwiseLinks.js.map +1 -1
- package/components/shared/Checkbox/CheckboxOption.js +1 -1
- package/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/components/shared/Radio/RadioOption.js +2 -8
- package/components/shared/Radio/RadioOption.js.map +1 -1
- package/components/type.d.ts +2 -0
- package/esm/components/Input/Input.d.ts +1 -0
- package/esm/components/Input/Input.js +2 -2
- package/esm/components/Input/Input.js.map +1 -1
- package/esm/components/PairwiseLinks/PairwiseLinks.js +2 -0
- package/esm/components/PairwiseLinks/PairwiseLinks.js.map +1 -1
- package/esm/components/shared/Checkbox/CheckboxOption.js +1 -1
- package/esm/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/esm/components/shared/Radio/RadioOption.js +3 -9
- package/esm/components/shared/Radio/RadioOption.js.map +1 -1
- package/esm/components/type.d.ts +2 -0
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +6 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +2 -0
- package/esm/use-lunatic/props/propOptions.d.ts +2 -1
- package/esm/use-lunatic/props/propOptions.js +1 -1
- package/esm/use-lunatic/props/propOptions.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Input/Input.tsx +3 -0
- package/src/components/PairwiseLinks/PairwiseLinks.tsx +1 -0
- package/src/components/shared/Checkbox/CheckboxOption.tsx +1 -0
- package/src/components/shared/Radio/RadioOption.tsx +2 -12
- package/src/components/type.ts +2 -0
- package/src/stories/pairwise/source.json +4 -1
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +1 -1
- package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +8 -1
- package/src/use-lunatic/props/propOptions.ts +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.js +6 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/props/getComponentTypeProps.d.ts +2 -0
- package/use-lunatic/props/propOptions.d.ts +2 -1
- package/use-lunatic/props/propOptions.js +1 -1
- package/use-lunatic/props/propOptions.js.map +1 -1
|
@@ -11,12 +11,13 @@ export type InterpretedOption = {
|
|
|
11
11
|
detailLabel?: ReactNode;
|
|
12
12
|
detailValue?: string | null;
|
|
13
13
|
detailMaxLength?: number;
|
|
14
|
+
shouldBeFiltered?: boolean;
|
|
14
15
|
onDetailChange?: (value: string) => void;
|
|
15
16
|
onCheck?: () => void;
|
|
16
17
|
onUncheck?: () => void;
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
|
-
* Compute options for checkboxes / radios
|
|
20
|
+
* Compute options for checkboxes / radios / dropdown
|
|
20
21
|
*/
|
|
21
22
|
export declare function getOptionsProp(definition: DeepTranslateExpression<LunaticComponentDefinition>, variables: LunaticVariablesStore, handleChanges: LunaticChangesHandler, pagerIteration: LunaticState['pager']['iteration'], value: unknown, logger: LunaticLogger, disableFilters?: boolean, shouldParentBeFiltered?: boolean): {
|
|
22
23
|
label: ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNumber } from '../../utils/number';
|
|
2
2
|
/**
|
|
3
|
-
* Compute options for checkboxes / radios
|
|
3
|
+
* Compute options for checkboxes / radios / dropdown
|
|
4
4
|
*/
|
|
5
5
|
export function getOptionsProp(definition, variables, handleChanges, pagerIteration, value, logger, disableFilters, shouldParentBeFiltered) {
|
|
6
6
|
const iteration = isNumber(pagerIteration) ? [pagerIteration] : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propOptions.js","sourceRoot":"","sources":["../../../src/use-lunatic/props/propOptions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"propOptions.js","sourceRoot":"","sources":["../../../src/use-lunatic/props/propOptions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAoB9C;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,UAA+D,EAC/D,SAAgC,EAChC,aAAoC,EACpC,cAAkD,EAClD,KAAc,EACd,MAAqB,EACrB,cAAwB,EACxB,sBAAgC;IAEhC,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE1E,IAAI,UAAU,CAAC,aAAa,KAAK,eAAe,EAAE,CAAC;QAClD,OAAO,UAAU,CAAC,SAAS;aACzB,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;YACpB,IAAI,cAAc,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;gBACjD,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,CAAC,mBAAmB,CAC1B,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,CAAC,eAAe,CACxB,CAAC;QACH,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;;YAAC,OAAA,CAAC;gBACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI;gBAC5B,EAAE,EAAE,QAAQ,CAAC,EAAE;gBACf,OAAO,EAAE,CAAC,C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AAc,EACb,QAAQ,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM;gBAClC,CAAC,CAAC,CAAC,KAAa,EAAE,EAAE;oBAClB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;gBAChE,CAAC;gBACF,CAAC,CAAC,IAAI;YACR,gBAAgB,EACf,sBAAsB;gBACtB,CAAC,iBAAiB,IAAI,MAAM;oBAC3B,mBAAmB,CAClB,SAAS,EACT,SAAS,EACT,MAAM,EACN,MAAM,CAAC,eAAe,CACtB,CAAC;SACJ,CAAC,CAAA;KAAA,CAAC,CAAC;AACN,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAC3B,SAAgC,EAChC,SAA+B,EAC/B,MAAqB,EACrB,eAA+B;IAE/B,IAAI,CAAC,eAAe;QAAE,OAAO,KAAK,CAAC;IACnC,IAAI,CAAC;QACJ,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAU,EAAE,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -32,6 +32,7 @@ type CustomProps = Omit<
|
|
|
32
32
|
> & {
|
|
33
33
|
onChange: (v: string) => void;
|
|
34
34
|
errors?: LunaticError[];
|
|
35
|
+
autoFocus?: boolean;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
|
|
@@ -47,6 +48,7 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
|
|
|
47
48
|
errors,
|
|
48
49
|
readOnly,
|
|
49
50
|
declarations,
|
|
51
|
+
autoFocus = false,
|
|
50
52
|
} = props;
|
|
51
53
|
const labelId = `label-${id}`;
|
|
52
54
|
const charactersCountId = getCharactersCountId(id, maxLength);
|
|
@@ -80,6 +82,7 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
|
|
|
80
82
|
onBlur={(e) => {
|
|
81
83
|
e.target.setSelectionRange(0, 0);
|
|
82
84
|
}}
|
|
85
|
+
autoFocus={autoFocus}
|
|
83
86
|
/>
|
|
84
87
|
<CharactersCount id={id} maxLength={maxLength} value={value} />
|
|
85
88
|
</div>
|
|
@@ -44,6 +44,7 @@ export const PairwiseLinks = ({
|
|
|
44
44
|
.map(([x, y]) => {
|
|
45
45
|
const components = getComponents(y, x);
|
|
46
46
|
const firstComponent = components[0];
|
|
47
|
+
if (firstComponent === undefined || firstComponent === null) return;
|
|
47
48
|
if (firstComponent.componentType !== 'Dropdown') {
|
|
48
49
|
return (
|
|
49
50
|
<div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type KeyboardEventHandler,
|
|
1
|
+
import { type KeyboardEventHandler, useRef } from 'react';
|
|
2
2
|
import { slottableComponent } from '../HOC/slottableComponent';
|
|
3
3
|
import { useKeyboardKey } from '../../../hooks/useKeyboardKey';
|
|
4
4
|
import { Label } from '../Label/Label';
|
|
@@ -25,7 +25,6 @@ function LunaticRadioOption({
|
|
|
25
25
|
disabled,
|
|
26
26
|
readOnly,
|
|
27
27
|
checkboxStyle,
|
|
28
|
-
value,
|
|
29
28
|
onKeyDown,
|
|
30
29
|
index,
|
|
31
30
|
shortcut,
|
|
@@ -64,16 +63,6 @@ function LunaticRadioOption({
|
|
|
64
63
|
divEl.current?.blur();
|
|
65
64
|
};
|
|
66
65
|
|
|
67
|
-
useEffect(
|
|
68
|
-
function () {
|
|
69
|
-
const { current } = divEl;
|
|
70
|
-
if (current && checked) {
|
|
71
|
-
current.focus();
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
[checked, divEl, value]
|
|
75
|
-
);
|
|
76
|
-
|
|
77
66
|
const hasKeyboardShortcut = Boolean(shortcut && codeModality && isEnabled);
|
|
78
67
|
useKeyboardKey(
|
|
79
68
|
codeModality ? [codeModality] : [],
|
|
@@ -131,6 +120,7 @@ function LunaticRadioOption({
|
|
|
131
120
|
maxLength={detailMaxLength}
|
|
132
121
|
onChange={onDetailChange}
|
|
133
122
|
disabled={disabled}
|
|
123
|
+
autoFocus
|
|
134
124
|
/>
|
|
135
125
|
)}
|
|
136
126
|
</div>
|
package/src/components/type.ts
CHANGED
|
@@ -198,6 +198,7 @@ export type ComponentPropsByType = {
|
|
|
198
198
|
detailLabel?: ReactNode;
|
|
199
199
|
detailMaxLength?: number;
|
|
200
200
|
detailValue?: string | null;
|
|
201
|
+
shouldBeFiltered?: boolean;
|
|
201
202
|
}[];
|
|
202
203
|
orientation?: 'horizontal' | 'vertical';
|
|
203
204
|
detailAlwaysDisplayed?: boolean;
|
|
@@ -252,6 +253,7 @@ export type ComponentPropsByType = {
|
|
|
252
253
|
description?: ReactNode;
|
|
253
254
|
label: ReactNode;
|
|
254
255
|
value: string;
|
|
256
|
+
shouldBeFiltered?: boolean;
|
|
255
257
|
}>;
|
|
256
258
|
response: { name: string };
|
|
257
259
|
componentType?: 'Dropdown';
|
|
@@ -90,7 +90,10 @@
|
|
|
90
90
|
{
|
|
91
91
|
"componentType": "Dropdown",
|
|
92
92
|
"id": "dropdown-1",
|
|
93
|
-
"conditionFilter": {
|
|
93
|
+
"conditionFilter": {
|
|
94
|
+
"value": "(nvl(xAxis, \"\") <> \"\") and (nvl(yAxis, \"\") <> \"\")",
|
|
95
|
+
"type": "VTL"
|
|
96
|
+
},
|
|
94
97
|
"label": {
|
|
95
98
|
"value": "\"Qui est \" || yAxis || \" pour \" || xAxis || \" ?\"",
|
|
96
99
|
"type": "VTL|MD"
|
|
@@ -268,7 +268,7 @@ describe('lunatic-variables-store', () => {
|
|
|
268
268
|
variables.run('"hello"', { iteration: [0] });
|
|
269
269
|
variables.run('"hello"', { iteration: [1] });
|
|
270
270
|
expect(variables.run('"hello"')).toEqual('hello');
|
|
271
|
-
expect(variables.interpretCount).toBe(
|
|
271
|
+
expect(variables.interpretCount).toBe(1); // only 1 interpretation by the engine since optimisation for primitive value
|
|
272
272
|
});
|
|
273
273
|
it('should handle deep refresh', () => {
|
|
274
274
|
variables.set('LIENS', [
|
|
@@ -372,9 +372,16 @@ class LunaticVariable {
|
|
|
372
372
|
|
|
373
373
|
// Calculate bindings first to refresh "updatedAt" on calculated dependencies
|
|
374
374
|
const bindings = this.getDependenciesValues(iteration);
|
|
375
|
+
const hasNoBinding = Object.keys(bindings).length === 0;
|
|
376
|
+
|
|
377
|
+
// A static expression should not be reevaluated
|
|
378
|
+
if (hasNoBinding && this.value) {
|
|
379
|
+
return this.value;
|
|
380
|
+
}
|
|
381
|
+
|
|
375
382
|
// A variable without binding is a primitive (string, boolean...)
|
|
376
383
|
// it yields the same results for every iteration, so we can ignore iteration
|
|
377
|
-
if (
|
|
384
|
+
if (hasNoBinding) {
|
|
378
385
|
iteration = undefined;
|
|
379
386
|
}
|
|
380
387
|
if (this.shapeFrom && !this.isOutdated(iteration)) {
|
|
@@ -19,13 +19,14 @@ export type InterpretedOption = {
|
|
|
19
19
|
detailLabel?: ReactNode;
|
|
20
20
|
detailValue?: string | null;
|
|
21
21
|
detailMaxLength?: number;
|
|
22
|
+
shouldBeFiltered?: boolean;
|
|
22
23
|
onDetailChange?: (value: string) => void;
|
|
23
24
|
onCheck?: () => void;
|
|
24
25
|
onUncheck?: () => void;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
* Compute options for checkboxes / radios
|
|
29
|
+
* Compute options for checkboxes / radios / dropdown
|
|
29
30
|
*/
|
|
30
31
|
export function getOptionsProp(
|
|
31
32
|
definition: DeepTranslateExpression<LunaticComponentDefinition>,
|