@inseefr/lunatic 3.5.1 → 3.5.2
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/FilterDescription/FilterDescription.d.ts +5 -7
- package/components/FilterDescription/FilterDescription.js +10 -3
- package/components/FilterDescription/FilterDescription.js.map +1 -1
- package/components/InputNumber/InputNumber.js +2 -2
- package/components/InputNumber/InputNumber.js.map +1 -1
- package/components/InputNumber/InputNumberThousand.d.ts +2 -1
- package/components/InputNumber/InputNumberThousand.js +9 -6
- package/components/InputNumber/InputNumberThousand.js.map +1 -1
- package/components/library.d.ts +2 -4
- package/components/shared/HOC/slottableComponent.d.ts +2 -0
- package/components/shared/HOC/slottableComponent.js.map +1 -1
- package/esm/components/FilterDescription/FilterDescription.d.ts +5 -7
- package/esm/components/FilterDescription/FilterDescription.js +8 -1
- package/esm/components/FilterDescription/FilterDescription.js.map +1 -1
- package/esm/components/InputNumber/InputNumber.js +2 -2
- package/esm/components/InputNumber/InputNumber.js.map +1 -1
- package/esm/components/InputNumber/InputNumberThousand.d.ts +2 -1
- package/esm/components/InputNumber/InputNumberThousand.js +9 -6
- package/esm/components/InputNumber/InputNumberThousand.js.map +1 -1
- package/esm/components/library.d.ts +2 -4
- package/esm/components/shared/HOC/slottableComponent.d.ts +2 -0
- package/esm/components/shared/HOC/slottableComponent.js.map +1 -1
- package/esm/type.source.d.ts +5 -1
- package/esm/use-lunatic/commons/fill-components/fill-component.spec.d.ts +1 -0
- package/esm/use-lunatic/commons/fill-components/fill-component.spec.js +485 -0
- package/esm/use-lunatic/commons/fill-components/fill-component.spec.js.map +1 -0
- package/esm/use-lunatic/commons/fill-components/fill-components.d.ts +3 -3
- package/esm/use-lunatic/commons/fill-components/fill-components.js +29 -5
- package/esm/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
- package/esm/use-lunatic/props/getComponentTypeProps.js +1 -1
- package/esm/use-lunatic/props/getComponentTypeProps.js.map +1 -1
- package/esm/use-lunatic/props/propOptions.d.ts +1 -1
- package/esm/use-lunatic/props/propOptions.js +5 -3
- package/esm/use-lunatic/props/propOptions.js.map +1 -1
- package/esm/use-lunatic/props/propOptions.spec.js +100 -2
- package/esm/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/esm/use-lunatic/reducer/reducerInitializer.d.ts +2 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js +3 -3
- package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/esm/use-lunatic/replace-component-sequence.d.ts +1 -1
- package/esm/use-lunatic/type.d.ts +3 -0
- package/esm/use-lunatic/use-lunatic.js +3 -1
- package/esm/use-lunatic/use-lunatic.js.map +1 -1
- package/esm/utils/number.d.ts +4 -0
- package/esm/utils/number.js +10 -0
- package/esm/utils/number.js.map +1 -1
- package/esm/utils/number.spec.js +44 -1
- package/esm/utils/number.spec.js.map +1 -1
- package/package.json +8 -2
- package/src/components/FilterDescription/FilterDescription.tsx +24 -13
- package/src/components/InputNumber/InputNumber.tsx +2 -0
- package/src/components/InputNumber/InputNumberThousand.tsx +9 -4
- package/src/components/shared/HOC/slottableComponent.tsx +2 -0
- package/src/stories/behaviour/paste/test.stories.jsx +5 -0
- package/src/stories/filter-description/filter-description.stories.jsx +7 -3
- package/src/stories/loop/roster-for-loop.stories.jsx +1 -4
- package/src/stories/loop/source-roster.json +65 -2
- package/src/stories/utils/default-arg-types.js +1 -1
- package/src/stories/utils/orchestrator.jsx +3 -3
- package/src/type.source.ts +6 -1
- package/src/use-lunatic/commons/fill-components/fill-component.spec.ts +581 -0
- package/src/use-lunatic/commons/fill-components/fill-components.ts +39 -7
- package/src/use-lunatic/props/getComponentTypeProps.ts +15 -11
- package/src/use-lunatic/props/propOptions.spec.ts +140 -2
- package/src/use-lunatic/props/propOptions.ts +8 -3
- package/src/use-lunatic/reducer/reducerInitializer.tsx +4 -2
- package/src/use-lunatic/type.ts +5 -0
- package/src/use-lunatic/use-lunatic.ts +3 -0
- package/src/utils/number.spec.ts +45 -1
- package/src/utils/number.ts +18 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +5 -1
- package/use-lunatic/commons/fill-components/fill-component.spec.d.ts +1 -0
- package/use-lunatic/commons/fill-components/fill-component.spec.js +487 -0
- package/use-lunatic/commons/fill-components/fill-component.spec.js.map +1 -0
- package/use-lunatic/commons/fill-components/fill-components.d.ts +3 -3
- package/use-lunatic/commons/fill-components/fill-components.js +26 -5
- package/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
- package/use-lunatic/props/getComponentTypeProps.js +1 -1
- package/use-lunatic/props/getComponentTypeProps.js.map +1 -1
- package/use-lunatic/props/propOptions.d.ts +1 -1
- package/use-lunatic/props/propOptions.js +5 -3
- package/use-lunatic/props/propOptions.js.map +1 -1
- package/use-lunatic/props/propOptions.spec.js +100 -2
- package/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/use-lunatic/reducer/reducerInitializer.d.ts +2 -1
- package/use-lunatic/reducer/reducerInitializer.js +3 -3
- package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/use-lunatic/replace-component-sequence.d.ts +1 -1
- package/use-lunatic/type.d.ts +3 -0
- package/use-lunatic/use-lunatic.js +3 -1
- package/use-lunatic/use-lunatic.js.map +1 -1
- package/utils/number.d.ts +4 -0
- package/utils/number.js +11 -0
- package/utils/number.js.map +1 -1
- package/utils/number.spec.js +43 -0
- package/utils/number.spec.js.map +1 -1
- package/src/stories/loop/source-with-header.json +0 -128
|
@@ -25,6 +25,23 @@ describe('getOptionsProp()', () => {
|
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
27
|
} satisfies DeepTranslateExpression<LunaticComponentDefinition>;
|
|
28
|
+
|
|
29
|
+
const radioDefinition = {
|
|
30
|
+
id: 'RadioGroup',
|
|
31
|
+
componentType: 'Radio',
|
|
32
|
+
response: { name: 'RADIO' },
|
|
33
|
+
options: [
|
|
34
|
+
{
|
|
35
|
+
label: 'Option 1',
|
|
36
|
+
value: 'id1',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: 'Option 2',
|
|
40
|
+
value: 'id2',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
} satisfies DeepTranslateExpression<LunaticComponentDefinition>;
|
|
44
|
+
|
|
28
45
|
let mockChange: LunaticChangesHandler;
|
|
29
46
|
const mockLogger = vi.fn();
|
|
30
47
|
|
|
@@ -100,6 +117,68 @@ describe('getOptionsProp()', () => {
|
|
|
100
117
|
{ name: 'O2', value: false },
|
|
101
118
|
]);
|
|
102
119
|
});
|
|
120
|
+
it('should filter responses (CheckboxGroup) with conditionFilter evaluated to false', () => {
|
|
121
|
+
const definition = {
|
|
122
|
+
...checkboxGroupDefinition,
|
|
123
|
+
responses: [
|
|
124
|
+
{
|
|
125
|
+
label: 'Option 1',
|
|
126
|
+
response: { name: 'O1' },
|
|
127
|
+
id: 'id1',
|
|
128
|
+
conditionFilter: { type: 'VTL', value: 'false' },
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: 'Option 2',
|
|
132
|
+
response: { name: 'O2' },
|
|
133
|
+
id: 'id2',
|
|
134
|
+
conditionFilter: { type: 'VTL', value: 'true' },
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
} satisfies DeepTranslateExpression<LunaticComponentDefinition>;
|
|
138
|
+
|
|
139
|
+
const options = getOptionsProp(
|
|
140
|
+
definition,
|
|
141
|
+
variables,
|
|
142
|
+
mockChange,
|
|
143
|
+
undefined,
|
|
144
|
+
undefined,
|
|
145
|
+
mockLogger
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// First option should be filtered out since its conditionFilter is evaluated to false
|
|
149
|
+
expect(options).toHaveLength(1);
|
|
150
|
+
expect(options[0].label).toBe('Option 2');
|
|
151
|
+
});
|
|
152
|
+
it('should filter options (Radio) with conditionFilter evaluated to false', () => {
|
|
153
|
+
const definition = {
|
|
154
|
+
...radioDefinition,
|
|
155
|
+
options: [
|
|
156
|
+
{
|
|
157
|
+
label: 'Option 1',
|
|
158
|
+
value: 'id1',
|
|
159
|
+
conditionFilter: { type: 'VTL', value: 'false' },
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: 'Option 2',
|
|
163
|
+
value: 'id2',
|
|
164
|
+
conditionFilter: { type: 'VTL', value: 'true' },
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
} as any as DeepTranslateExpression<LunaticComponentDefinition>;
|
|
168
|
+
|
|
169
|
+
const options = getOptionsProp(
|
|
170
|
+
definition,
|
|
171
|
+
variables,
|
|
172
|
+
mockChange,
|
|
173
|
+
undefined,
|
|
174
|
+
undefined,
|
|
175
|
+
mockLogger
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// First option should be filtered out since its conditionFilter is evaluated to false
|
|
179
|
+
expect(options).toHaveLength(1);
|
|
180
|
+
expect(options[0].label).toBe('Option 2');
|
|
181
|
+
});
|
|
103
182
|
it('should not filter response (checkboxGroup) when its conditionFilter evaluation fails', () => {
|
|
104
183
|
const definition = {
|
|
105
184
|
...checkboxGroupDefinition,
|
|
@@ -132,8 +211,7 @@ describe('getOptionsProp()', () => {
|
|
|
132
211
|
});
|
|
133
212
|
it('should not filter option (radio) when its conditionFilter evaluation fails', () => {
|
|
134
213
|
const definition = {
|
|
135
|
-
|
|
136
|
-
componentType: 'Radio',
|
|
214
|
+
...radioDefinition,
|
|
137
215
|
options: [
|
|
138
216
|
{
|
|
139
217
|
label: 'Option 1',
|
|
@@ -160,5 +238,65 @@ describe('getOptionsProp()', () => {
|
|
|
160
238
|
// Ensure the option is not filtered
|
|
161
239
|
expect(options).toHaveLength(1);
|
|
162
240
|
});
|
|
241
|
+
it('should not filter any response (CheckboxGroup) when disableFilters is true', () => {
|
|
242
|
+
const definition = {
|
|
243
|
+
...checkboxGroupDefinition,
|
|
244
|
+
responses: [
|
|
245
|
+
{
|
|
246
|
+
label: 'Option 1',
|
|
247
|
+
response: { name: 'O1' },
|
|
248
|
+
id: 'id1',
|
|
249
|
+
conditionFilter: { type: 'VTL', value: 'expression' },
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
} satisfies DeepTranslateExpression<LunaticComponentDefinition>;
|
|
253
|
+
|
|
254
|
+
// ensure interpreted expression is false
|
|
255
|
+
vi.spyOn(variables, 'run').mockImplementation(() => {
|
|
256
|
+
return false;
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const options = getOptionsProp(
|
|
260
|
+
definition,
|
|
261
|
+
variables,
|
|
262
|
+
mockChange,
|
|
263
|
+
undefined,
|
|
264
|
+
undefined,
|
|
265
|
+
mockLogger,
|
|
266
|
+
true // disableFilters = true
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
// Ensure the option is not filtered
|
|
270
|
+
expect(options).toHaveLength(1);
|
|
271
|
+
});
|
|
272
|
+
it('should not filter any option (Radio) when disableFilters is true', () => {
|
|
273
|
+
const definition = {
|
|
274
|
+
...radioDefinition,
|
|
275
|
+
options: [
|
|
276
|
+
{
|
|
277
|
+
label: 'Option 1',
|
|
278
|
+
value: 'id1',
|
|
279
|
+
conditionFilter: { type: 'VTL', value: 'expression' },
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
} as any as DeepTranslateExpression<LunaticComponentDefinition>;
|
|
283
|
+
|
|
284
|
+
// ensure interpreted expression is false
|
|
285
|
+
vi.spyOn(variables, 'run').mockImplementation(() => {
|
|
286
|
+
return false;
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
const options = getOptionsProp(
|
|
290
|
+
definition,
|
|
291
|
+
variables,
|
|
292
|
+
mockChange,
|
|
293
|
+
undefined,
|
|
294
|
+
undefined,
|
|
295
|
+
mockLogger,
|
|
296
|
+
true // disableFilters = true
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
expect(options).toHaveLength(1);
|
|
300
|
+
});
|
|
163
301
|
});
|
|
164
302
|
});
|
|
@@ -31,7 +31,8 @@ export function getOptionsProp(
|
|
|
31
31
|
handleChanges: LunaticChangesHandler,
|
|
32
32
|
pagerIteration: LunaticState['pager']['iteration'],
|
|
33
33
|
value: unknown,
|
|
34
|
-
logger: LunaticLogger
|
|
34
|
+
logger: LunaticLogger,
|
|
35
|
+
disableFilters?: boolean
|
|
35
36
|
) {
|
|
36
37
|
const iteration = isNumber(pagerIteration) ? [pagerIteration] : undefined;
|
|
37
38
|
//const iteration = pagerIteration ? [pagerIteration] : undefined;
|
|
@@ -39,7 +40,7 @@ export function getOptionsProp(
|
|
|
39
40
|
if (definition.componentType === 'CheckboxGroup') {
|
|
40
41
|
return definition.responses
|
|
41
42
|
.filter((response) => {
|
|
42
|
-
if (!response.conditionFilter) {
|
|
43
|
+
if (disableFilters || !response.conditionFilter) {
|
|
43
44
|
return true;
|
|
44
45
|
}
|
|
45
46
|
try {
|
|
@@ -82,7 +83,11 @@ export function getOptionsProp(
|
|
|
82
83
|
|
|
83
84
|
return definition.options
|
|
84
85
|
.filter((option) => {
|
|
85
|
-
if (
|
|
86
|
+
if (
|
|
87
|
+
disableFilters ||
|
|
88
|
+
!('conditionFilter' in option) ||
|
|
89
|
+
!option.conditionFilter
|
|
90
|
+
) {
|
|
86
91
|
return true;
|
|
87
92
|
}
|
|
88
93
|
try {
|
|
@@ -35,7 +35,7 @@ const baseState = {
|
|
|
35
35
|
overview: [],
|
|
36
36
|
updateBindings: () => {},
|
|
37
37
|
executeExpression: <T,>() => null as T,
|
|
38
|
-
options: { disableFilters: false },
|
|
38
|
+
options: { disableFilters: false, disableFiltersDescription: true },
|
|
39
39
|
} satisfies LunaticReducerState;
|
|
40
40
|
|
|
41
41
|
export function reducerInitializer({
|
|
@@ -46,6 +46,7 @@ export function reducerInitializer({
|
|
|
46
46
|
lastReachedPage = undefined,
|
|
47
47
|
withOverview = false,
|
|
48
48
|
disableFilters = false,
|
|
49
|
+
disableFiltersDescription = true,
|
|
49
50
|
getReferentiel,
|
|
50
51
|
onVariableChange,
|
|
51
52
|
logger,
|
|
@@ -57,6 +58,7 @@ export function reducerInitializer({
|
|
|
57
58
|
lastReachedPage?: LunaticOptions['lastReachedPage'];
|
|
58
59
|
withOverview?: LunaticOptions['withOverview'];
|
|
59
60
|
disableFilters?: LunaticOptions['disableFilters'];
|
|
61
|
+
disableFiltersDescription?: LunaticOptions['disableFiltersDescription'];
|
|
60
62
|
getReferentiel?: LunaticOptions['getReferentiel'];
|
|
61
63
|
onVariableChange: RefObject<LunaticOptions['onVariableChange']>;
|
|
62
64
|
logger: LunaticLogger;
|
|
@@ -149,7 +151,7 @@ export function reducerInitializer({
|
|
|
149
151
|
overview: withOverview ? buildOverview(source) : [],
|
|
150
152
|
updateBindings,
|
|
151
153
|
executeExpression,
|
|
152
|
-
options: { disableFilters },
|
|
154
|
+
options: { disableFilters, disableFiltersDescription },
|
|
153
155
|
});
|
|
154
156
|
}
|
|
155
157
|
|
package/src/use-lunatic/type.ts
CHANGED
|
@@ -179,6 +179,7 @@ export type LunaticReducerState = {
|
|
|
179
179
|
) => unknown;
|
|
180
180
|
options: {
|
|
181
181
|
disableFilters?: boolean;
|
|
182
|
+
disableFiltersDescription?: boolean;
|
|
182
183
|
};
|
|
183
184
|
};
|
|
184
185
|
|
|
@@ -186,6 +187,10 @@ export type LunaticReducerState = {
|
|
|
186
187
|
export type LunaticOptions = {
|
|
187
188
|
/** Ignore filters. (default: `false`) */
|
|
188
189
|
disableFilters?: boolean;
|
|
190
|
+
|
|
191
|
+
/** Disable filters description. (default: `true`) */
|
|
192
|
+
disableFiltersDescription?: boolean;
|
|
193
|
+
|
|
189
194
|
/** Enable VTL and Markdown support. */
|
|
190
195
|
features?: ('MD' | 'VTL')[];
|
|
191
196
|
preferences?: ['COLLECTED'];
|
|
@@ -44,6 +44,7 @@ const DEFAULT_REFUSED = D.RF;
|
|
|
44
44
|
|
|
45
45
|
const defaultOptions = {
|
|
46
46
|
disableFilters: false,
|
|
47
|
+
disableFiltersDescription: true,
|
|
47
48
|
features: DEFAULT_FEATURES,
|
|
48
49
|
preferences: DEFAULT_PREFERENCES,
|
|
49
50
|
savingType: COLLECTED,
|
|
@@ -83,6 +84,7 @@ export function useLunatic(
|
|
|
83
84
|
const options = mergeDefault(argOptions, defaultOptions);
|
|
84
85
|
const {
|
|
85
86
|
disableFilters,
|
|
87
|
+
disableFiltersDescription,
|
|
86
88
|
management,
|
|
87
89
|
missing,
|
|
88
90
|
missingStrategy,
|
|
@@ -198,6 +200,7 @@ export function useLunatic(
|
|
|
198
200
|
|
|
199
201
|
const components = fillComponents(getComponentsFromState(state), {
|
|
200
202
|
disableFilters,
|
|
203
|
+
disableFiltersDescription,
|
|
201
204
|
handleChanges,
|
|
202
205
|
preferences,
|
|
203
206
|
goToPage,
|
package/src/utils/number.spec.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { between } from './number';
|
|
2
|
+
import { between, isNumberInInterval } from './number';
|
|
3
3
|
|
|
4
4
|
describe('between', () => {
|
|
5
5
|
it('should work', () => {
|
|
@@ -8,3 +8,47 @@ describe('between', () => {
|
|
|
8
8
|
expect(between(-23.22, -5, 100)).toBe(-5);
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
|
+
|
|
12
|
+
describe('isNumberInInterval', () => {
|
|
13
|
+
it('allows value within range', () => {
|
|
14
|
+
expect(isNumberInInterval(25, 10, 50)).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
it('disallows value above max', () => {
|
|
17
|
+
expect(isNumberInInterval(55, 10, 50)).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
it('disallows value below min', () => {
|
|
20
|
+
expect(isNumberInInterval(5, 10, 50)).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
it('allows negative within bounds', () => {
|
|
23
|
+
expect(isNumberInInterval(-4, -5, 0)).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
it('disallows negative if min is 0 or positive', () => {
|
|
26
|
+
expect(isNumberInInterval(-1, 0, 10)).toBe(false);
|
|
27
|
+
expect(isNumberInInterval(-1, 5, 10)).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it('allows only value above min when max is undefined', () => {
|
|
30
|
+
expect(isNumberInInterval(999, 100)).toBe(true);
|
|
31
|
+
expect(isNumberInInterval(50, 100)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
it('allows only value below max when min is undefined', () => {
|
|
34
|
+
expect(isNumberInInterval(50, undefined, 100)).toBe(true);
|
|
35
|
+
// accepts negative values
|
|
36
|
+
expect(isNumberInInterval(-50, undefined, 100)).toBe(true);
|
|
37
|
+
expect(isNumberInInterval(150, undefined, 100)).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
it('allows decimal value within range', () => {
|
|
40
|
+
expect(isNumberInInterval(9.99, 0, 10)).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
it('disallows decimal value above max', () => {
|
|
43
|
+
expect(isNumberInInterval(10.01, 0, 10)).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
it('disallows decimal value below min', () => {
|
|
46
|
+
expect(isNumberInInterval(-5.01, -5, 5)).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
it('allows decimal value equal to max', () => {
|
|
49
|
+
expect(isNumberInInterval(10.0, 0, 10)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
it('allows decimal value equal to min', () => {
|
|
52
|
+
expect(isNumberInInterval(-5.0, -5, 5)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
package/src/utils/number.ts
CHANGED
|
@@ -31,3 +31,21 @@ export function between(n: number, min: number, max: number): number {
|
|
|
31
31
|
export function isNumber(n: unknown): n is number {
|
|
32
32
|
return typeof n === 'number' && Number.isFinite(n);
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
/** Check if a value is within an interval.
|
|
36
|
+
* Both minimum and maximum can be undefined, then we just compare with the defined bounds.
|
|
37
|
+
*/
|
|
38
|
+
export function isNumberInInterval(
|
|
39
|
+
value: number,
|
|
40
|
+
min?: number,
|
|
41
|
+
max?: number
|
|
42
|
+
): boolean {
|
|
43
|
+
if (
|
|
44
|
+
(min !== undefined && value < min) ||
|
|
45
|
+
(max !== undefined && value > max)
|
|
46
|
+
) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return true;
|
|
51
|
+
}
|