@uipath/apollo-react 7.27.0 → 7.28.0
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/dist/decision-table/DecisionText.cjs +8 -3
- package/dist/decision-table/DecisionText.d.ts +5 -5
- package/dist/decision-table/DecisionText.d.ts.map +1 -1
- package/dist/decision-table/DecisionText.js +8 -3
- package/dist/decision-table/ValueFields.cjs +9 -5
- package/dist/decision-table/ValueFields.d.ts +0 -2
- package/dist/decision-table/ValueFields.d.ts.map +1 -1
- package/dist/decision-table/ValueFields.js +9 -5
- package/dist/decision-table/ValuePopover.cjs +18 -28
- package/dist/decision-table/ValuePopover.d.ts +5 -4
- package/dist/decision-table/ValuePopover.d.ts.map +1 -1
- package/dist/decision-table/ValuePopover.js +18 -28
- package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts +4 -3
- package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts +13 -0
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/storyTableHost.d.ts +6 -3
- package/dist/decision-table/__fixtures__/storyTableHost.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/textMode.d.ts +7 -3
- package/dist/decision-table/__fixtures__/textMode.d.ts.map +1 -1
- package/dist/decision-table/decisionTextTypes.d.ts +8 -6
- package/dist/decision-table/decisionTextTypes.d.ts.map +1 -1
- package/dist/decision-table/hostValues.cjs +90 -0
- package/dist/decision-table/hostValues.d.ts +13 -0
- package/dist/decision-table/hostValues.d.ts.map +1 -0
- package/dist/decision-table/hostValues.js +50 -0
- package/dist/decision-table/index.d.ts +2 -1
- package/dist/decision-table/index.d.ts.map +1 -1
- package/dist/decision-table/locales/de.cjs +1 -1
- package/dist/decision-table/locales/de.d.ts.map +1 -1
- package/dist/decision-table/locales/de.js +1 -1
- package/dist/decision-table/locales/en.cjs +1 -1
- package/dist/decision-table/locales/en.d.ts.map +1 -1
- package/dist/decision-table/locales/en.js +1 -1
- package/dist/decision-table/locales/es-MX.cjs +1 -1
- package/dist/decision-table/locales/es-MX.d.ts.map +1 -1
- package/dist/decision-table/locales/es-MX.js +1 -1
- package/dist/decision-table/locales/es.cjs +1 -1
- package/dist/decision-table/locales/es.d.ts.map +1 -1
- package/dist/decision-table/locales/es.js +1 -1
- package/dist/decision-table/locales/fr.cjs +1 -1
- package/dist/decision-table/locales/fr.d.ts.map +1 -1
- package/dist/decision-table/locales/fr.js +1 -1
- package/dist/decision-table/locales/ja.cjs +1 -1
- package/dist/decision-table/locales/ja.d.ts.map +1 -1
- package/dist/decision-table/locales/ja.js +1 -1
- package/dist/decision-table/locales/ko.cjs +1 -1
- package/dist/decision-table/locales/ko.d.ts.map +1 -1
- package/dist/decision-table/locales/ko.js +1 -1
- package/dist/decision-table/locales/pt-BR.cjs +1 -1
- package/dist/decision-table/locales/pt-BR.d.ts.map +1 -1
- package/dist/decision-table/locales/pt-BR.js +1 -1
- package/dist/decision-table/locales/pt.cjs +1 -1
- package/dist/decision-table/locales/pt.d.ts.map +1 -1
- package/dist/decision-table/locales/pt.js +1 -1
- package/dist/decision-table/locales/ro.cjs +1 -1
- package/dist/decision-table/locales/ro.d.ts.map +1 -1
- package/dist/decision-table/locales/ro.js +1 -1
- package/dist/decision-table/locales/ru.cjs +1 -1
- package/dist/decision-table/locales/ru.d.ts.map +1 -1
- package/dist/decision-table/locales/ru.js +1 -1
- package/dist/decision-table/locales/tr.cjs +1 -1
- package/dist/decision-table/locales/tr.d.ts.map +1 -1
- package/dist/decision-table/locales/tr.js +1 -1
- package/dist/decision-table/locales/zh-CN.cjs +1 -1
- package/dist/decision-table/locales/zh-CN.d.ts.map +1 -1
- package/dist/decision-table/locales/zh-CN.js +1 -1
- package/dist/decision-table/locales/zh-TW.cjs +1 -1
- package/dist/decision-table/locales/zh-TW.d.ts.map +1 -1
- package/dist/decision-table/locales/zh-TW.js +1 -1
- package/dist/decision-table/useDecisionTextStrings.cjs +0 -4
- package/dist/decision-table/useDecisionTextStrings.d.ts.map +1 -1
- package/dist/decision-table/useDecisionTextStrings.js +0 -4
- package/dist/decision-table/useEditState.cjs +17 -1
- package/dist/decision-table/useEditState.d.ts +3 -1
- package/dist/decision-table/useEditState.d.ts.map +1 -1
- package/dist/decision-table/useEditState.js +17 -1
- package/dist/decision-table/useHostValueEdit.cjs +91 -0
- package/dist/decision-table/useHostValueEdit.d.ts +5 -0
- package/dist/decision-table/useHostValueEdit.d.ts.map +1 -0
- package/dist/decision-table/useHostValueEdit.js +57 -0
- package/dist/decision-table/usePendingCondition.cjs +6 -5
- package/dist/decision-table/usePendingCondition.d.ts.map +1 -1
- package/dist/decision-table/usePendingCondition.js +7 -6
- package/dist/decision-table/useShapeDraft.cjs +93 -65
- package/dist/decision-table/useShapeDraft.d.ts +17 -14
- package/dist/decision-table/useShapeDraft.d.ts.map +1 -1
- package/dist/decision-table/useShapeDraft.js +93 -62
- package/dist/decision-table/useValueEditing.cjs +3 -7
- package/dist/decision-table/useValueEditing.d.ts.map +1 -1
- package/dist/decision-table/useValueEditing.js +3 -7
- package/dist/decision-table/valueTypes.d.ts +57 -19
- package/dist/decision-table/valueTypes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -25,12 +25,10 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
operatorsOf: ()=>operatorsOf,
|
|
28
|
-
useShapeDraft: ()=>useShapeDraft
|
|
29
|
-
operatorOf: ()=>operatorOf
|
|
28
|
+
useShapeDraft: ()=>useShapeDraft
|
|
30
29
|
});
|
|
31
30
|
const external_react_namespaceObject = require("react");
|
|
32
31
|
const NO_OPERATORS = [];
|
|
33
|
-
const NO_VALUES = [];
|
|
34
32
|
const BOTH_INCLUDED = {
|
|
35
33
|
lowInclusive: true,
|
|
36
34
|
highInclusive: true
|
|
@@ -38,50 +36,64 @@ const BOTH_INCLUDED = {
|
|
|
38
36
|
const filled = (values)=>[
|
|
39
37
|
...new Set(values.filter((value)=>'' !== value.trim()))
|
|
40
38
|
];
|
|
41
|
-
const operatorsOf = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const operatorsOf = (field)=>'condition' === field.kind ? field.operators.map(({ operator, label, shape })=>({
|
|
40
|
+
id: String(operator),
|
|
41
|
+
place: operator,
|
|
42
|
+
label,
|
|
43
|
+
shape
|
|
44
|
+
})) : NO_OPERATORS;
|
|
45
|
+
const heldValuesOf = (held)=>{
|
|
46
|
+
switch(held.shape){
|
|
47
|
+
case 'single':
|
|
48
|
+
return [
|
|
49
|
+
held.value
|
|
50
|
+
];
|
|
51
|
+
case 'range':
|
|
52
|
+
return [
|
|
53
|
+
held.low,
|
|
54
|
+
held.high
|
|
55
|
+
];
|
|
56
|
+
case 'list':
|
|
57
|
+
return held.values;
|
|
58
|
+
case 'valueless':
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
51
61
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
const problemOf = (commit, adds, hidesHeld)=>{
|
|
63
|
+
switch(commit.kind){
|
|
64
|
+
case 'range':
|
|
65
|
+
return '' === commit.low.trim() || '' === commit.high.trim() ? 'missingEnd' : null;
|
|
66
|
+
case 'list':
|
|
67
|
+
return commit.values.length > 0 ? null : 'noValueChecked';
|
|
68
|
+
case 'valueless':
|
|
69
|
+
return null;
|
|
70
|
+
case 'expression':
|
|
71
|
+
return (adds || hidesHeld) && '' === commit.text.trim() ? 'missingValue' : null;
|
|
72
|
+
default:
|
|
73
|
+
return (adds || hidesHeld) && '' === commit.value.trim() ? 'missingValue' : null;
|
|
58
74
|
}
|
|
59
|
-
if ('list' === shape) return values.length > 0 ? null : 'noValueChecked';
|
|
60
|
-
return (adds || hidesHeld) && '' === low.trim() ? 'missingValue' : null;
|
|
61
75
|
};
|
|
62
76
|
const useShapeDraft = (field, value, adds)=>{
|
|
63
|
-
const
|
|
64
|
-
value
|
|
65
|
-
]
|
|
66
|
-
const [
|
|
67
|
-
const [
|
|
68
|
-
|
|
69
|
-
]));
|
|
77
|
+
const opened = 'condition' === field.kind ? heldValuesOf(field.held) : [
|
|
78
|
+
'expression' === field.kind ? field.expression : value
|
|
79
|
+
];
|
|
80
|
+
const [values, setValues] = (0, external_react_namespaceObject.useState)(opened);
|
|
81
|
+
const [ends, setEnds] = (0, external_react_namespaceObject.useState)('condition' === field.kind && 'range' === field.held.shape ? field.held.ends : BOTH_INCLUDED);
|
|
82
|
+
const [held] = (0, external_react_namespaceObject.useState)(()=>filled(opened));
|
|
70
83
|
const [entries, setEntries] = (0, external_react_namespaceObject.useState)(held);
|
|
71
84
|
const [adding, setAdding] = (0, external_react_namespaceObject.useState)('');
|
|
72
|
-
const [operator, setOperator] = (0, external_react_namespaceObject.useState)(()=>
|
|
85
|
+
const [operator, setOperator] = (0, external_react_namespaceObject.useState)(()=>'condition' === field.kind ? field.held.operator : void 0);
|
|
73
86
|
const operators = operatorsOf(field);
|
|
74
|
-
const allowedValues = filled(field.allowedValues
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const shape = shapeOf(picked);
|
|
87
|
+
const allowedValues = filled(field.allowedValues);
|
|
88
|
+
const shapeOf = (place)=>operators.find((option)=>option.place === place)?.shape ?? 'single';
|
|
89
|
+
const shape = shapeOf(operator);
|
|
78
90
|
const [text = '', high = ''] = values;
|
|
79
91
|
const listed = filled([
|
|
80
92
|
...allowedValues,
|
|
81
93
|
...entries
|
|
82
94
|
]);
|
|
83
95
|
const offered = new Set(listed);
|
|
84
|
-
const checked = filled(values).filter((
|
|
96
|
+
const checked = filled(values).filter((candidate)=>offered.has(candidate));
|
|
85
97
|
const withChecked = (option)=>{
|
|
86
98
|
const next = filled([
|
|
87
99
|
...checked,
|
|
@@ -94,34 +106,49 @@ const useShapeDraft = (field, value, adds)=>{
|
|
|
94
106
|
return next.sort((left, right)=>rank(left) - rank(right));
|
|
95
107
|
};
|
|
96
108
|
const typed = adding.trim();
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
kind: '
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
const commitOf = (single)=>{
|
|
110
|
+
if ('outcome' === field.kind) return {
|
|
111
|
+
kind: 'outcome',
|
|
112
|
+
value: single
|
|
113
|
+
};
|
|
114
|
+
if ('expression' === field.kind || void 0 === operator) return {
|
|
115
|
+
kind: 'expression',
|
|
116
|
+
text: single
|
|
117
|
+
};
|
|
118
|
+
switch(shape){
|
|
119
|
+
case 'range':
|
|
120
|
+
return {
|
|
121
|
+
kind: 'range',
|
|
122
|
+
operator,
|
|
123
|
+
low: single,
|
|
124
|
+
high,
|
|
125
|
+
ends
|
|
126
|
+
};
|
|
127
|
+
case 'list':
|
|
128
|
+
return {
|
|
129
|
+
kind: 'list',
|
|
130
|
+
operator,
|
|
131
|
+
values: typed ? withChecked(typed) : checked
|
|
132
|
+
};
|
|
133
|
+
case 'valueless':
|
|
134
|
+
return {
|
|
135
|
+
kind: 'valueless',
|
|
136
|
+
operator
|
|
137
|
+
};
|
|
138
|
+
default:
|
|
139
|
+
return {
|
|
140
|
+
kind: 'single',
|
|
141
|
+
operator,
|
|
142
|
+
value: single
|
|
143
|
+
};
|
|
118
144
|
}
|
|
119
145
|
};
|
|
120
|
-
const current =
|
|
146
|
+
const current = commitOf(text);
|
|
121
147
|
return {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
148
|
+
picker: void 0 === operator ? null : {
|
|
149
|
+
operators,
|
|
150
|
+
operator
|
|
151
|
+
},
|
|
125
152
|
shape,
|
|
126
153
|
values,
|
|
127
154
|
text,
|
|
@@ -130,9 +157,12 @@ const useShapeDraft = (field, value, adds)=>{
|
|
|
130
157
|
allowedValues,
|
|
131
158
|
listed,
|
|
132
159
|
checked,
|
|
160
|
+
heldList: 'condition' === field.kind && 'list' === field.held.shape ? field.held.values : [],
|
|
161
|
+
heldValueAt: (index)=>'condition' === field.kind ? opened[index] : opened[0],
|
|
133
162
|
adding,
|
|
134
163
|
current,
|
|
135
|
-
|
|
164
|
+
commitOf,
|
|
165
|
+
problem: problemOf(current, adds, held.length > 0 && allowedValues.length > 0),
|
|
136
166
|
setText: (next)=>setValues([
|
|
137
167
|
next,
|
|
138
168
|
...values.slice(1)
|
|
@@ -155,20 +185,18 @@ const useShapeDraft = (field, value, adds)=>{
|
|
|
155
185
|
setAdding('');
|
|
156
186
|
},
|
|
157
187
|
setAdding,
|
|
158
|
-
changeOperator: (
|
|
159
|
-
if ('list' === shapeOf(
|
|
188
|
+
changeOperator: (place)=>{
|
|
189
|
+
if ('list' === shapeOf(place)) setEntries(filled([
|
|
160
190
|
...entries,
|
|
161
191
|
...values
|
|
162
192
|
]));
|
|
163
|
-
setOperator(
|
|
193
|
+
setOperator(place);
|
|
164
194
|
}
|
|
165
195
|
};
|
|
166
196
|
};
|
|
167
|
-
exports.operatorOf = __webpack_exports__.operatorOf;
|
|
168
197
|
exports.operatorsOf = __webpack_exports__.operatorsOf;
|
|
169
198
|
exports.useShapeDraft = __webpack_exports__.useShapeDraft;
|
|
170
199
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
171
|
-
"operatorOf",
|
|
172
200
|
"operatorsOf",
|
|
173
201
|
"useShapeDraft"
|
|
174
202
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import type { AllowedValueListProps } from './AllowedValueList';
|
|
2
|
+
import type { PopoverSelectOption } from './PopoverSelect';
|
|
2
3
|
import type { RangeFieldsProps } from './RangeFields';
|
|
3
4
|
import type { ValueChecklistProps } from './ValueChecklist';
|
|
4
|
-
import type { RangeEnds, ValueCommit,
|
|
5
|
-
export
|
|
6
|
-
|
|
5
|
+
import type { RangeEnds, ValueCommit, ValueFieldData, ValueShape } from './valueTypes';
|
|
6
|
+
export interface OperatorChoice extends PopoverSelectOption {
|
|
7
|
+
place: number;
|
|
8
|
+
shape: ValueShape;
|
|
9
|
+
}
|
|
10
|
+
export declare const operatorsOf: (field: ValueFieldData<number>) => readonly OperatorChoice[];
|
|
7
11
|
export interface DraftProblemLabels {
|
|
8
12
|
missingValue: string;
|
|
9
13
|
missingEnd: string;
|
|
10
|
-
endsOutOfOrder: string;
|
|
11
14
|
noValueChecked: string;
|
|
12
15
|
}
|
|
13
16
|
export type DraftProblem = keyof DraftProblemLabels;
|
|
14
|
-
type ValuesCommit = Extract<ValueCommit, {
|
|
15
|
-
kind: 'values';
|
|
16
|
-
}>;
|
|
17
17
|
export interface ShapeDraft {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
picker: {
|
|
19
|
+
operators: readonly OperatorChoice[];
|
|
20
|
+
operator: number;
|
|
21
|
+
} | null;
|
|
21
22
|
shape: ValueShape;
|
|
22
23
|
values: readonly string[];
|
|
23
24
|
text: string;
|
|
@@ -26,16 +27,18 @@ export interface ShapeDraft {
|
|
|
26
27
|
allowedValues: readonly string[];
|
|
27
28
|
listed: readonly string[];
|
|
28
29
|
checked: readonly string[];
|
|
30
|
+
heldList: readonly string[];
|
|
31
|
+
heldValueAt: (index: number) => string | undefined;
|
|
29
32
|
adding: string;
|
|
30
|
-
current:
|
|
33
|
+
current: ValueCommit<number>;
|
|
34
|
+
commitOf: (text: string) => ValueCommit<number>;
|
|
31
35
|
problem: DraftProblem | null;
|
|
32
36
|
setText: AllowedValueListProps['onChoose'];
|
|
33
37
|
setRange: RangeFieldsProps['onChange'];
|
|
34
38
|
toggle: ValueChecklistProps['onToggle'];
|
|
35
39
|
add: NonNullable<ValueChecklistProps['onAdd']>;
|
|
36
40
|
setAdding: ValueChecklistProps['onAddingChange'];
|
|
37
|
-
changeOperator: (
|
|
41
|
+
changeOperator: (place: number) => void;
|
|
38
42
|
}
|
|
39
|
-
export declare const useShapeDraft: (field:
|
|
40
|
-
export {};
|
|
43
|
+
export declare const useShapeDraft: (field: ValueFieldData<number>, value: string, adds: boolean) => ShapeDraft;
|
|
41
44
|
//# sourceMappingURL=useShapeDraft.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShapeDraft.d.ts","sourceRoot":"","sources":["../../src/decision-table/useShapeDraft.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useShapeDraft.d.ts","sourceRoot":"","sources":["../../src/decision-table/useShapeDraft.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAc,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGnG,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;CAC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CAAC,CAAC,CAAC;IAC/C,SAAS,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IACjD,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAGD,eAAO,MAAM,aAAa,GACxB,OAAO,cAAc,CAAC,MAAM,CAAC,EAC7B,OAAO,MAAM,EACb,MAAM,OAAO,KACZ,UAoFF,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
const NO_OPERATORS = [];
|
|
3
|
-
const NO_VALUES = [];
|
|
4
3
|
const BOTH_INCLUDED = {
|
|
5
4
|
lowInclusive: true,
|
|
6
5
|
highInclusive: true
|
|
@@ -8,50 +7,64 @@ const BOTH_INCLUDED = {
|
|
|
8
7
|
const filled = (values)=>[
|
|
9
8
|
...new Set(values.filter((value)=>'' !== value.trim()))
|
|
10
9
|
];
|
|
11
|
-
const operatorsOf = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
const operatorsOf = (field)=>'condition' === field.kind ? field.operators.map(({ operator, label, shape })=>({
|
|
11
|
+
id: String(operator),
|
|
12
|
+
place: operator,
|
|
13
|
+
label,
|
|
14
|
+
shape
|
|
15
|
+
})) : NO_OPERATORS;
|
|
16
|
+
const heldValuesOf = (held)=>{
|
|
17
|
+
switch(held.shape){
|
|
18
|
+
case 'single':
|
|
19
|
+
return [
|
|
20
|
+
held.value
|
|
21
|
+
];
|
|
22
|
+
case 'range':
|
|
23
|
+
return [
|
|
24
|
+
held.low,
|
|
25
|
+
held.high
|
|
26
|
+
];
|
|
27
|
+
case 'list':
|
|
28
|
+
return held.values;
|
|
29
|
+
case 'valueless':
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
21
32
|
};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
const problemOf = (commit, adds, hidesHeld)=>{
|
|
34
|
+
switch(commit.kind){
|
|
35
|
+
case 'range':
|
|
36
|
+
return '' === commit.low.trim() || '' === commit.high.trim() ? 'missingEnd' : null;
|
|
37
|
+
case 'list':
|
|
38
|
+
return commit.values.length > 0 ? null : 'noValueChecked';
|
|
39
|
+
case 'valueless':
|
|
40
|
+
return null;
|
|
41
|
+
case 'expression':
|
|
42
|
+
return (adds || hidesHeld) && '' === commit.text.trim() ? 'missingValue' : null;
|
|
43
|
+
default:
|
|
44
|
+
return (adds || hidesHeld) && '' === commit.value.trim() ? 'missingValue' : null;
|
|
28
45
|
}
|
|
29
|
-
if ('list' === shape) return values.length > 0 ? null : 'noValueChecked';
|
|
30
|
-
return (adds || hidesHeld) && '' === low.trim() ? 'missingValue' : null;
|
|
31
46
|
};
|
|
32
47
|
const useShapeDraft = (field, value, adds)=>{
|
|
33
|
-
const
|
|
34
|
-
value
|
|
35
|
-
]
|
|
36
|
-
const [
|
|
37
|
-
const [
|
|
38
|
-
|
|
39
|
-
]));
|
|
48
|
+
const opened = 'condition' === field.kind ? heldValuesOf(field.held) : [
|
|
49
|
+
'expression' === field.kind ? field.expression : value
|
|
50
|
+
];
|
|
51
|
+
const [values, setValues] = useState(opened);
|
|
52
|
+
const [ends, setEnds] = useState('condition' === field.kind && 'range' === field.held.shape ? field.held.ends : BOTH_INCLUDED);
|
|
53
|
+
const [held] = useState(()=>filled(opened));
|
|
40
54
|
const [entries, setEntries] = useState(held);
|
|
41
55
|
const [adding, setAdding] = useState('');
|
|
42
|
-
const [operator, setOperator] = useState(()=>
|
|
56
|
+
const [operator, setOperator] = useState(()=>'condition' === field.kind ? field.held.operator : void 0);
|
|
43
57
|
const operators = operatorsOf(field);
|
|
44
|
-
const allowedValues = filled(field.allowedValues
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const shape = shapeOf(picked);
|
|
58
|
+
const allowedValues = filled(field.allowedValues);
|
|
59
|
+
const shapeOf = (place)=>operators.find((option)=>option.place === place)?.shape ?? 'single';
|
|
60
|
+
const shape = shapeOf(operator);
|
|
48
61
|
const [text = '', high = ''] = values;
|
|
49
62
|
const listed = filled([
|
|
50
63
|
...allowedValues,
|
|
51
64
|
...entries
|
|
52
65
|
]);
|
|
53
66
|
const offered = new Set(listed);
|
|
54
|
-
const checked = filled(values).filter((
|
|
67
|
+
const checked = filled(values).filter((candidate)=>offered.has(candidate));
|
|
55
68
|
const withChecked = (option)=>{
|
|
56
69
|
const next = filled([
|
|
57
70
|
...checked,
|
|
@@ -64,34 +77,49 @@ const useShapeDraft = (field, value, adds)=>{
|
|
|
64
77
|
return next.sort((left, right)=>rank(left) - rank(right));
|
|
65
78
|
};
|
|
66
79
|
const typed = adding.trim();
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
kind: '
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
const commitOf = (single)=>{
|
|
81
|
+
if ('outcome' === field.kind) return {
|
|
82
|
+
kind: 'outcome',
|
|
83
|
+
value: single
|
|
84
|
+
};
|
|
85
|
+
if ('expression' === field.kind || void 0 === operator) return {
|
|
86
|
+
kind: 'expression',
|
|
87
|
+
text: single
|
|
88
|
+
};
|
|
89
|
+
switch(shape){
|
|
90
|
+
case 'range':
|
|
91
|
+
return {
|
|
92
|
+
kind: 'range',
|
|
93
|
+
operator,
|
|
94
|
+
low: single,
|
|
95
|
+
high,
|
|
96
|
+
ends
|
|
97
|
+
};
|
|
98
|
+
case 'list':
|
|
99
|
+
return {
|
|
100
|
+
kind: 'list',
|
|
101
|
+
operator,
|
|
102
|
+
values: typed ? withChecked(typed) : checked
|
|
103
|
+
};
|
|
104
|
+
case 'valueless':
|
|
105
|
+
return {
|
|
106
|
+
kind: 'valueless',
|
|
107
|
+
operator
|
|
108
|
+
};
|
|
109
|
+
default:
|
|
110
|
+
return {
|
|
111
|
+
kind: 'single',
|
|
112
|
+
operator,
|
|
113
|
+
value: single
|
|
114
|
+
};
|
|
88
115
|
}
|
|
89
116
|
};
|
|
90
|
-
const current =
|
|
117
|
+
const current = commitOf(text);
|
|
91
118
|
return {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
119
|
+
picker: void 0 === operator ? null : {
|
|
120
|
+
operators,
|
|
121
|
+
operator
|
|
122
|
+
},
|
|
95
123
|
shape,
|
|
96
124
|
values,
|
|
97
125
|
text,
|
|
@@ -100,9 +128,12 @@ const useShapeDraft = (field, value, adds)=>{
|
|
|
100
128
|
allowedValues,
|
|
101
129
|
listed,
|
|
102
130
|
checked,
|
|
131
|
+
heldList: 'condition' === field.kind && 'list' === field.held.shape ? field.held.values : [],
|
|
132
|
+
heldValueAt: (index)=>'condition' === field.kind ? opened[index] : opened[0],
|
|
103
133
|
adding,
|
|
104
134
|
current,
|
|
105
|
-
|
|
135
|
+
commitOf,
|
|
136
|
+
problem: problemOf(current, adds, held.length > 0 && allowedValues.length > 0),
|
|
106
137
|
setText: (next)=>setValues([
|
|
107
138
|
next,
|
|
108
139
|
...values.slice(1)
|
|
@@ -125,13 +156,13 @@ const useShapeDraft = (field, value, adds)=>{
|
|
|
125
156
|
setAdding('');
|
|
126
157
|
},
|
|
127
158
|
setAdding,
|
|
128
|
-
changeOperator: (
|
|
129
|
-
if ('list' === shapeOf(
|
|
159
|
+
changeOperator: (place)=>{
|
|
160
|
+
if ('list' === shapeOf(place)) setEntries(filled([
|
|
130
161
|
...entries,
|
|
131
162
|
...values
|
|
132
163
|
]));
|
|
133
|
-
setOperator(
|
|
164
|
+
setOperator(place);
|
|
134
165
|
}
|
|
135
166
|
};
|
|
136
167
|
};
|
|
137
|
-
export {
|
|
168
|
+
export { operatorsOf, useShapeDraft };
|
|
@@ -75,11 +75,7 @@ const useValueEditing = ({ edit, rules, bands, selected, onSelect, navigation, l
|
|
|
75
75
|
if (!edit || !target || !rule) return null;
|
|
76
76
|
const token = (0, external_sentenceParts_cjs_namespaceObject.valueTokenOf)(rule, target);
|
|
77
77
|
const column = (0, external_sentenceParts_cjs_namespaceObject.columnNameOf)(rule, target.columnId) || (0, external_sentenceParts_cjs_namespaceObject.bandColumnNameOf)(bands, target.columnId);
|
|
78
|
-
const
|
|
79
|
-
const field = {
|
|
80
|
-
...hostField,
|
|
81
|
-
icon: hostField?.icon ?? (0, external_sentenceParts_cjs_namespaceObject.bandColumnOf)(bands, target.columnId)?.icon
|
|
82
|
-
};
|
|
78
|
+
const field = edit.valueField(target);
|
|
83
79
|
const held = (0, external_sentenceParts_cjs_namespaceObject.hasStop)(rule, target.columnId);
|
|
84
80
|
const cancel = ()=>{
|
|
85
81
|
awaitHost({
|
|
@@ -95,6 +91,7 @@ const useValueEditing = ({ edit, rules, bands, selected, onSelect, navigation, l
|
|
|
95
91
|
value: token?.text ?? '',
|
|
96
92
|
ariaLabel: held ? labels.cell(column, token ? (0, external_sentenceParts_cjs_namespaceObject.tokenText)(token, labels.emptyValue) : '', row + 1) : edit.labels.newCondition(column, row + 1),
|
|
97
93
|
column,
|
|
94
|
+
icon: (0, external_sentenceParts_cjs_namespaceObject.bandColumnOf)(bands, target.columnId)?.icon,
|
|
98
95
|
field,
|
|
99
96
|
adds: !held,
|
|
100
97
|
onCommit: (commit, move, refocus)=>{
|
|
@@ -173,8 +170,7 @@ const useValueEditing = ({ edit, rules, bands, selected, onSelect, navigation, l
|
|
|
173
170
|
text: textIn(rules, selection),
|
|
174
171
|
scroll
|
|
175
172
|
};
|
|
176
|
-
edit?.onClearCell(cell);
|
|
177
|
-
cancelEditOf(selection);
|
|
173
|
+
if (edit?.onClearCell(cell) === void 0) cancelEditOf(selection);
|
|
178
174
|
if (refocusNow && staysOn(cell.rowId)) navigation.refocus(scroll);
|
|
179
175
|
};
|
|
180
176
|
const onKeyDown = (event)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useValueEditing.d.ts","sourceRoot":"","sources":["../../src/decision-table/useValueEditing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAmBtD,OAAO,KAAK,EACV,YAAY,EAEZ,YAAY,EACZ,iBAAiB,EACjB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,QAAQ,EAAE,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC;IACpD,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CACpC;AAqBD,MAAM,WAAW,YAAY;IAE3B,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAE/B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,C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,CAAC,CAAC;CACpC;AAqBD,MAAM,WAAW,YAAY;IAE3B,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAE/B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC;IAEhE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC;IAE3D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAUD,eAAO,MAAM,QAAQ,GAAI,4BAA4B,eAAe,KAAG,MAC7B,CAAC;AAc3C,eAAO,MAAM,eAAe,GAAI,4EAS7B,kBAAkB,KAAG,YAsLvB,CAAC"}
|
|
@@ -46,11 +46,7 @@ const useValueEditing = ({ edit, rules, bands, selected, onSelect, navigation, l
|
|
|
46
46
|
if (!edit || !target || !rule) return null;
|
|
47
47
|
const token = valueTokenOf(rule, target);
|
|
48
48
|
const column = columnNameOf(rule, target.columnId) || bandColumnNameOf(bands, target.columnId);
|
|
49
|
-
const
|
|
50
|
-
const field = {
|
|
51
|
-
...hostField,
|
|
52
|
-
icon: hostField?.icon ?? bandColumnOf(bands, target.columnId)?.icon
|
|
53
|
-
};
|
|
49
|
+
const field = edit.valueField(target);
|
|
54
50
|
const held = hasStop(rule, target.columnId);
|
|
55
51
|
const cancel = ()=>{
|
|
56
52
|
awaitHost({
|
|
@@ -66,6 +62,7 @@ const useValueEditing = ({ edit, rules, bands, selected, onSelect, navigation, l
|
|
|
66
62
|
value: token?.text ?? '',
|
|
67
63
|
ariaLabel: held ? labels.cell(column, token ? tokenText(token, labels.emptyValue) : '', row + 1) : edit.labels.newCondition(column, row + 1),
|
|
68
64
|
column,
|
|
65
|
+
icon: bandColumnOf(bands, target.columnId)?.icon,
|
|
69
66
|
field,
|
|
70
67
|
adds: !held,
|
|
71
68
|
onCommit: (commit, move, refocus)=>{
|
|
@@ -144,8 +141,7 @@ const useValueEditing = ({ edit, rules, bands, selected, onSelect, navigation, l
|
|
|
144
141
|
text: textIn(rules, selection),
|
|
145
142
|
scroll
|
|
146
143
|
};
|
|
147
|
-
edit?.onClearCell(cell);
|
|
148
|
-
cancelEditOf(selection);
|
|
144
|
+
if (edit?.onClearCell(cell) === void 0) cancelEditOf(selection);
|
|
149
145
|
if (refocusNow && staysOn(cell.rowId)) navigation.refocus(scroll);
|
|
150
146
|
};
|
|
151
147
|
const onKeyDown = (event)=>{
|