@uipath/apollo-react 7.26.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/BandColumn.d.ts +2 -2
- package/dist/decision-table/BandColumn.d.ts.map +1 -1
- package/dist/decision-table/ColumnEditorOverlay.cjs +3 -3
- package/dist/decision-table/ColumnEditorOverlay.d.ts +6 -5
- package/dist/decision-table/ColumnEditorOverlay.d.ts.map +1 -1
- package/dist/decision-table/ColumnEditorOverlay.js +3 -3
- package/dist/decision-table/ColumnPopover.cjs +52 -31
- package/dist/decision-table/ColumnPopover.d.ts +36 -23
- package/dist/decision-table/ColumnPopover.d.ts.map +1 -1
- package/dist/decision-table/ColumnPopover.js +52 -31
- package/dist/decision-table/DecisionText.cjs +33 -11
- package/dist/decision-table/DecisionText.d.ts +23 -24
- package/dist/decision-table/DecisionText.d.ts.map +1 -1
- package/dist/decision-table/DecisionText.js +33 -11
- package/dist/decision-table/DecisionTextHeader.cjs +10 -8
- package/dist/decision-table/DecisionTextHeader.d.ts +13 -5
- package/dist/decision-table/DecisionTextHeader.d.ts.map +1 -1
- package/dist/decision-table/DecisionTextHeader.js +10 -8
- 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__/diffSentences.fixtures.d.ts +9 -8
- package/dist/decision-table/__fixtures__/diffSentences.fixtures.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts +5 -4
- package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts +25 -7
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/storyTableHost.d.ts +16 -14
- package/dist/decision-table/__fixtures__/storyTableHost.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/textMode.d.ts +13 -5
- package/dist/decision-table/__fixtures__/textMode.d.ts.map +1 -1
- package/dist/decision-table/bandColumns.cjs +22 -35
- package/dist/decision-table/bandColumns.d.ts +2 -4
- package/dist/decision-table/bandColumns.d.ts.map +1 -1
- package/dist/decision-table/bandColumns.js +21 -31
- package/dist/decision-table/decisionTextDiff.d.ts +13 -12
- package/dist/decision-table/decisionTextDiff.d.ts.map +1 -1
- package/dist/decision-table/decisionTextTypes.d.ts +10 -7
- 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.cjs +4 -4
- package/dist/decision-table/index.d.ts +9 -7
- package/dist/decision-table/index.d.ts.map +1 -1
- package/dist/decision-table/index.js +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/sentenceTypes.d.ts +12 -8
- package/dist/decision-table/sentenceTypes.d.ts.map +1 -1
- package/dist/decision-table/useColumnEditing.cjs +7 -5
- package/dist/decision-table/useColumnEditing.d.ts +6 -6
- package/dist/decision-table/useColumnEditing.d.ts.map +1 -1
- package/dist/decision-table/useColumnEditing.js +7 -5
- package/dist/decision-table/useDecisionTextStrings.cjs +1 -5
- package/dist/decision-table/useDecisionTextStrings.d.ts.map +1 -1
- package/dist/decision-table/useDecisionTextStrings.js +1 -5
- package/dist/decision-table/useEditState.cjs +17 -1
- package/dist/decision-table/useEditState.d.ts +4 -2
- 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 +3 -3
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
useHostValueEdit: ()=>useHostValueEdit
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const external_hostValues_cjs_namespaceObject = require("./hostValues.cjs");
|
|
31
|
+
const external_useEditState_cjs_namespaceObject = require("./useEditState.cjs");
|
|
32
|
+
const external_useValueEditing_cjs_namespaceObject = require("./useValueEditing.cjs");
|
|
33
|
+
const wordedEditOf = ({ onCommit, onClearCell, wordRefusal, valueField: hostField, column: _column, ...rest }, opened, rendered, keep, columnNameOf)=>{
|
|
34
|
+
const keptField = ()=>opened && opened.key === rendered.key ? opened.field : null;
|
|
35
|
+
const valueField = (cell)=>{
|
|
36
|
+
const live = hostField(cell);
|
|
37
|
+
const kept = keptField();
|
|
38
|
+
if (kept) return {
|
|
39
|
+
...kept,
|
|
40
|
+
allowedValues: live.allowedValues
|
|
41
|
+
};
|
|
42
|
+
if (null !== rendered.key) keep({
|
|
43
|
+
key: rendered.key,
|
|
44
|
+
field: live
|
|
45
|
+
});
|
|
46
|
+
return live;
|
|
47
|
+
};
|
|
48
|
+
const offersOf = (cell)=>{
|
|
49
|
+
const field = keptField() ?? hostField(cell);
|
|
50
|
+
return 'condition' === field.kind ? field.operators : [];
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
...rest,
|
|
54
|
+
valueField: (cell)=>(0, external_hostValues_cjs_namespaceObject.viewFieldOf)(valueField(cell)),
|
|
55
|
+
onCommit: (value, commit, move)=>{
|
|
56
|
+
const hostCommit = (0, external_hostValues_cjs_namespaceObject.hostCommitOf)(commit, offersOf(value));
|
|
57
|
+
if (!hostCommit) return;
|
|
58
|
+
const refusal = onCommit(value, hostCommit, move);
|
|
59
|
+
return void 0 === refusal ? void 0 : wordRefusal(refusal, {
|
|
60
|
+
action: 'commit',
|
|
61
|
+
column: columnNameOf(value.columnId),
|
|
62
|
+
values: (0, external_hostValues_cjs_namespaceObject.refusedValuesOf)(hostCommit)
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
onClearCell: (cell)=>{
|
|
66
|
+
const refusal = onClearCell(cell);
|
|
67
|
+
return void 0 === refusal ? void 0 : wordRefusal(refusal, {
|
|
68
|
+
action: 'clear',
|
|
69
|
+
column: columnNameOf(cell.columnId)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const useHostValueEdit = (edit, columns, labels, voice)=>{
|
|
75
|
+
const [openField, setOpenField] = (0, external_react_namespaceObject.useState)(null);
|
|
76
|
+
const rendered = {
|
|
77
|
+
key: null
|
|
78
|
+
};
|
|
79
|
+
const columnNameOf = (columnId)=>columns.find((column)=>column.id === columnId)?.name ?? '';
|
|
80
|
+
const state = (0, external_useEditState_cjs_namespaceObject.useEditState)(edit && wordedEditOf(edit, openField, rendered, setOpenField, columnNameOf), labels, voice);
|
|
81
|
+
rendered.key = state.edit?.editing ? (0, external_useValueEditing_cjs_namespaceObject.valueKey)(state.edit.editing) : null;
|
|
82
|
+
if (openField && openField.key !== rendered.key) setOpenField(null);
|
|
83
|
+
return state;
|
|
84
|
+
};
|
|
85
|
+
exports.useHostValueEdit = __webpack_exports__.useHostValueEdit;
|
|
86
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
87
|
+
"useHostValueEdit"
|
|
88
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
89
|
+
Object.defineProperty(exports, '__esModule', {
|
|
90
|
+
value: true
|
|
91
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DecisionTextEdit, DecisionTextEditLabels } from './decisionTextTypes';
|
|
2
|
+
import type { SentenceBandColumn } from './sentenceTypes';
|
|
3
|
+
import { type EditState, type EditVoice } from './useEditState';
|
|
4
|
+
export declare const useHostValueEdit: <Op, Type, Refusal>(edit: DecisionTextEdit<Op, Type, Refusal> | undefined, columns: readonly Pick<SentenceBandColumn<Type>, "id" | "name">[], labels: DecisionTextEditLabels, voice: EditVoice) => EditState;
|
|
5
|
+
//# sourceMappingURL=useHostValueEdit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostValueEdit.d.ts","sourceRoot":"","sources":["../../src/decision-table/useHostValueEdit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE9F,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAgB,MAAM,gBAAgB,CAAC;AAmE9E,eAAO,MAAM,gBAAgB,GAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAChD,MAAM,gBAAgB,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,SAAS,EACrD,SAAS,SAAS,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,EACjE,QAAQ,sBAAsB,EAC9B,OAAO,SAAS,KACf,SAaF,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { hostCommitOf, refusedValuesOf, viewFieldOf } from "./hostValues.js";
|
|
3
|
+
import { useEditState } from "./useEditState.js";
|
|
4
|
+
import { valueKey } from "./useValueEditing.js";
|
|
5
|
+
const wordedEditOf = ({ onCommit, onClearCell, wordRefusal, valueField: hostField, column: _column, ...rest }, opened, rendered, keep, columnNameOf)=>{
|
|
6
|
+
const keptField = ()=>opened && opened.key === rendered.key ? opened.field : null;
|
|
7
|
+
const valueField = (cell)=>{
|
|
8
|
+
const live = hostField(cell);
|
|
9
|
+
const kept = keptField();
|
|
10
|
+
if (kept) return {
|
|
11
|
+
...kept,
|
|
12
|
+
allowedValues: live.allowedValues
|
|
13
|
+
};
|
|
14
|
+
if (null !== rendered.key) keep({
|
|
15
|
+
key: rendered.key,
|
|
16
|
+
field: live
|
|
17
|
+
});
|
|
18
|
+
return live;
|
|
19
|
+
};
|
|
20
|
+
const offersOf = (cell)=>{
|
|
21
|
+
const field = keptField() ?? hostField(cell);
|
|
22
|
+
return 'condition' === field.kind ? field.operators : [];
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
...rest,
|
|
26
|
+
valueField: (cell)=>viewFieldOf(valueField(cell)),
|
|
27
|
+
onCommit: (value, commit, move)=>{
|
|
28
|
+
const hostCommit = hostCommitOf(commit, offersOf(value));
|
|
29
|
+
if (!hostCommit) return;
|
|
30
|
+
const refusal = onCommit(value, hostCommit, move);
|
|
31
|
+
return void 0 === refusal ? void 0 : wordRefusal(refusal, {
|
|
32
|
+
action: 'commit',
|
|
33
|
+
column: columnNameOf(value.columnId),
|
|
34
|
+
values: refusedValuesOf(hostCommit)
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
onClearCell: (cell)=>{
|
|
38
|
+
const refusal = onClearCell(cell);
|
|
39
|
+
return void 0 === refusal ? void 0 : wordRefusal(refusal, {
|
|
40
|
+
action: 'clear',
|
|
41
|
+
column: columnNameOf(cell.columnId)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const useHostValueEdit = (edit, columns, labels, voice)=>{
|
|
47
|
+
const [openField, setOpenField] = useState(null);
|
|
48
|
+
const rendered = {
|
|
49
|
+
key: null
|
|
50
|
+
};
|
|
51
|
+
const columnNameOf = (columnId)=>columns.find((column)=>column.id === columnId)?.name ?? '';
|
|
52
|
+
const state = useEditState(edit && wordedEditOf(edit, openField, rendered, setOpenField, columnNameOf), labels, voice);
|
|
53
|
+
rendered.key = state.edit?.editing ? valueKey(state.edit.editing) : null;
|
|
54
|
+
if (openField && openField.key !== rendered.key) setOpenField(null);
|
|
55
|
+
return state;
|
|
56
|
+
};
|
|
57
|
+
export { useHostValueEdit };
|
|
@@ -37,9 +37,10 @@ const usePendingCondition = ({ edit, rules, bands })=>{
|
|
|
37
37
|
const [picked, setPicked] = (0, external_react_namespaceObject.useState)(null);
|
|
38
38
|
const key = pending ? (0, external_useValueEditing_cjs_namespaceObject.valueKey)(pending) : null;
|
|
39
39
|
if (picked && picked.key !== key) setPicked(null);
|
|
40
|
-
const field = pending ? edit
|
|
41
|
-
const
|
|
42
|
-
const
|
|
40
|
+
const field = pending && edit ? edit.valueField(pending) : void 0;
|
|
41
|
+
const heldOperator = field?.kind === 'condition' ? field.held.operator : void 0;
|
|
42
|
+
const operatorPlace = picked?.key === key ? picked.place : heldOperator;
|
|
43
|
+
const operator = field && (0, external_useShapeDraft_cjs_namespaceObject.operatorsOf)(field).find((option)=>option.place === operatorPlace)?.label;
|
|
43
44
|
const columnId = pending?.columnId;
|
|
44
45
|
const index = pending?.index ?? 0;
|
|
45
46
|
const column = columnId ? (0, external_sentenceParts_cjs_namespaceObject.bandColumnNameOf)(bands, columnId) : '';
|
|
@@ -75,10 +76,10 @@ const usePendingCondition = ({ edit, rules, bands })=>{
|
|
|
75
76
|
operator,
|
|
76
77
|
placeholder
|
|
77
78
|
]);
|
|
78
|
-
const onOperatorChange = (
|
|
79
|
+
const onOperatorChange = (place)=>{
|
|
79
80
|
if (key) setPicked({
|
|
80
81
|
key,
|
|
81
|
-
|
|
82
|
+
place
|
|
82
83
|
});
|
|
83
84
|
};
|
|
84
85
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePendingCondition.d.ts","sourceRoot":"","sources":["../../src/decision-table/usePendingCondition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,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{ useMemo, useState } from "react";
|
|
2
2
|
import { bandColumnNameOf, hasStop } from "./sentenceParts.js";
|
|
3
|
-
import {
|
|
3
|
+
import { operatorsOf } from "./useShapeDraft.js";
|
|
4
4
|
import { valueKey } from "./useValueEditing.js";
|
|
5
5
|
const usePendingCondition = ({ edit, rules, bands })=>{
|
|
6
6
|
const target = edit?.editing ?? null;
|
|
@@ -9,9 +9,10 @@ const usePendingCondition = ({ edit, rules, bands })=>{
|
|
|
9
9
|
const [picked, setPicked] = useState(null);
|
|
10
10
|
const key = pending ? valueKey(pending) : null;
|
|
11
11
|
if (picked && picked.key !== key) setPicked(null);
|
|
12
|
-
const field = pending ? edit
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const field = pending && edit ? edit.valueField(pending) : void 0;
|
|
13
|
+
const heldOperator = field?.kind === 'condition' ? field.held.operator : void 0;
|
|
14
|
+
const operatorPlace = picked?.key === key ? picked.place : heldOperator;
|
|
15
|
+
const operator = field && operatorsOf(field).find((option)=>option.place === operatorPlace)?.label;
|
|
15
16
|
const columnId = pending?.columnId;
|
|
16
17
|
const index = pending?.index ?? 0;
|
|
17
18
|
const column = columnId ? bandColumnNameOf(bands, columnId) : '';
|
|
@@ -47,10 +48,10 @@ const usePendingCondition = ({ edit, rules, bands })=>{
|
|
|
47
48
|
operator,
|
|
48
49
|
placeholder
|
|
49
50
|
]);
|
|
50
|
-
const onOperatorChange = (
|
|
51
|
+
const onOperatorChange = (place)=>{
|
|
51
52
|
if (key) setPicked({
|
|
52
53
|
key,
|
|
53
|
-
|
|
54
|
+
place
|
|
54
55
|
});
|
|
55
56
|
};
|
|
56
57
|
return {
|
|
@@ -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,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