@uipath/apollo-wind 2.92.0 → 2.94.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/components/forms/field-renderer.cjs +1 -1
- package/dist/components/forms/field-renderer.js +1 -1
- package/dist/components/forms/field-rules-strings.cjs +40 -0
- package/dist/components/forms/field-rules-strings.d.ts +17 -0
- package/dist/components/forms/field-rules-strings.js +6 -0
- package/dist/components/forms/field-rules.cjs +526 -0
- package/dist/components/forms/field-rules.d.ts +97 -0
- package/dist/components/forms/field-rules.js +468 -0
- package/dist/components/forms/form-designer.cjs +208 -592
- package/dist/components/forms/form-designer.js +210 -594
- package/dist/components/forms/form-schema.d.ts +5 -0
- package/dist/components/forms/index.cjs +43 -3
- package/dist/components/forms/index.d.ts +4 -0
- package/dist/components/forms/index.js +5 -1
- package/dist/components/forms/metadata-form.cjs +1 -1
- package/dist/components/forms/metadata-form.js +1 -1
- package/dist/components/forms/rules-engine-dialect.cjs +644 -0
- package/dist/components/forms/rules-engine-dialect.d.ts +90 -0
- package/dist/components/forms/rules-engine-dialect.js +537 -0
- package/dist/components/forms/rules-engine.cjs +99 -10
- package/dist/components/forms/rules-engine.d.ts +5 -0
- package/dist/components/forms/rules-engine.js +99 -10
- package/dist/components/forms/use-field-rules.cjs +122 -0
- package/dist/components/forms/use-field-rules.d.ts +31 -0
- package/dist/components/forms/use-field-rules.js +88 -0
- package/dist/components/ui/conditions-editor/condition-row.cjs +458 -0
- package/dist/components/ui/conditions-editor/condition-row.d.ts +23 -0
- package/dist/components/ui/conditions-editor/condition-row.js +421 -0
- package/dist/components/ui/conditions-editor/conditions-editor.cjs +363 -0
- package/dist/components/ui/conditions-editor/conditions-editor.d.ts +67 -0
- package/dist/components/ui/conditions-editor/conditions-editor.js +329 -0
- package/dist/components/ui/conditions-editor/context.cjs +45 -0
- package/dist/components/ui/conditions-editor/context.d.ts +54 -0
- package/dist/components/ui/conditions-editor/context.js +8 -0
- package/dist/components/ui/conditions-editor/index.cjs +55 -0
- package/dist/components/ui/conditions-editor/index.d.ts +6 -0
- package/dist/components/ui/conditions-editor/index.js +6 -0
- package/dist/components/ui/conditions-editor/model.cjs +126 -0
- package/dist/components/ui/conditions-editor/model.d.ts +39 -0
- package/dist/components/ui/conditions-editor/model.js +71 -0
- package/dist/components/ui/conditions-editor/status.cjs +198 -0
- package/dist/components/ui/conditions-editor/status.d.ts +44 -0
- package/dist/components/ui/conditions-editor/status.js +131 -0
- package/dist/components/ui/conditions-editor/strings.cjs +86 -0
- package/dist/components/ui/conditions-editor/strings.d.ts +62 -0
- package/dist/components/ui/conditions-editor/strings.js +52 -0
- package/dist/components/ui/conditions-editor/vocabulary.cjs +163 -0
- package/dist/components/ui/conditions-editor/vocabulary.d.ts +51 -0
- package/dist/components/ui/conditions-editor/vocabulary.js +129 -0
- package/dist/components/ui/data-table.cjs +493 -104
- package/dist/components/ui/data-table.d.ts +88 -5
- package/dist/components/ui/data-table.js +491 -105
- package/dist/components/ui/editable-cell.cjs +91 -27
- package/dist/components/ui/editable-cell.d.ts +14 -1
- package/dist/components/ui/editable-cell.js +91 -27
- package/dist/components/ui/field-actions/index.cjs +9 -2
- package/dist/components/ui/field-actions/index.d.ts +1 -0
- package/dist/components/ui/field-actions/index.js +2 -1
- package/dist/components/ui/field-actions/insert-variable-action.cjs +3 -1
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +4 -1
- package/dist/components/ui/field-actions/insert-variable-action.js +3 -1
- package/dist/components/ui/field-actions/rules-action.cjs +244 -0
- package/dist/components/ui/field-actions/rules-action.d.ts +42 -0
- package/dist/components/ui/field-actions/rules-action.js +207 -0
- package/dist/components/ui/index.cjs +282 -243
- package/dist/components/ui/index.d.ts +3 -0
- package/dist/components/ui/index.js +3 -0
- package/dist/components/ui/quick-form-field/components/field-header.cjs +137 -167
- package/dist/components/ui/quick-form-field/components/field-header.d.ts +1 -1
- package/dist/components/ui/quick-form-field/components/field-header.js +138 -168
- package/dist/components/ui/quick-form-field/components/header-actions.cjs +187 -0
- package/dist/components/ui/quick-form-field/components/header-actions.d.ts +59 -0
- package/dist/components/ui/quick-form-field/components/header-actions.js +138 -0
- package/dist/components/ui/quick-form-field/components/header-context.cjs +59 -0
- package/dist/components/ui/quick-form-field/components/header-context.d.ts +33 -0
- package/dist/components/ui/quick-form-field/components/header-context.js +16 -0
- package/dist/components/ui/quick-form-field/index.cjs +18 -4
- package/dist/components/ui/quick-form-field/index.d.ts +2 -0
- package/dist/components/ui/quick-form-field/index.js +3 -1
- package/dist/components/ui/quick-form-field/quick-form-field.cjs +1 -1
- package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -6
- package/dist/components/ui/quick-form-field/quick-form-field.js +1 -1
- package/dist/components/ui/quick-form-field/types.d.ts +42 -11
- package/dist/components/ui/row-groups/add-row-button.cjs +54 -0
- package/dist/components/ui/row-groups/add-row-button.d.ts +10 -0
- package/dist/components/ui/row-groups/add-row-button.js +20 -0
- package/dist/components/ui/row-groups/after-press.cjs +73 -0
- package/dist/components/ui/row-groups/after-press.d.ts +7 -0
- package/dist/components/ui/row-groups/after-press.js +36 -0
- package/dist/components/ui/row-groups/collapsible-row-group.cjs +83 -0
- package/dist/components/ui/row-groups/collapsible-row-group.d.ts +13 -0
- package/dist/components/ui/row-groups/collapsible-row-group.js +49 -0
- package/dist/components/ui/row-groups/empty-rows.cjs +42 -0
- package/dist/components/ui/row-groups/empty-rows.d.ts +7 -0
- package/dist/components/ui/row-groups/empty-rows.js +8 -0
- package/dist/components/ui/row-groups/group-mode-toggle.cjs +80 -0
- package/dist/components/ui/row-groups/group-mode-toggle.d.ts +26 -0
- package/dist/components/ui/row-groups/group-mode-toggle.js +40 -0
- package/dist/components/ui/row-groups/index.cjs +62 -0
- package/dist/components/ui/row-groups/index.d.ts +6 -0
- package/dist/components/ui/row-groups/index.js +7 -0
- package/dist/components/ui/row-groups/row-delete-button.cjs +54 -0
- package/dist/components/ui/row-groups/row-delete-button.d.ts +18 -0
- package/dist/components/ui/row-groups/row-delete-button.js +20 -0
- package/dist/components/ui/row-groups/use-row-focus.cjs +82 -0
- package/dist/components/ui/row-groups/use-row-focus.d.ts +17 -0
- package/dist/components/ui/row-groups/use-row-focus.js +48 -0
- package/dist/components/ui/rules-editor/context.cjs +45 -0
- package/dist/components/ui/rules-editor/context.d.ts +52 -0
- package/dist/components/ui/rules-editor/context.js +8 -0
- package/dist/components/ui/rules-editor/index.cjs +56 -0
- package/dist/components/ui/rules-editor/index.d.ts +4 -0
- package/dist/components/ui/rules-editor/index.js +4 -0
- package/dist/components/ui/rules-editor/model.cjs +205 -0
- package/dist/components/ui/rules-editor/model.d.ts +128 -0
- package/dist/components/ui/rules-editor/model.js +144 -0
- package/dist/components/ui/rules-editor/rule-card.cjs +470 -0
- package/dist/components/ui/rules-editor/rule-card.d.ts +14 -0
- package/dist/components/ui/rules-editor/rule-card.js +436 -0
- package/dist/components/ui/rules-editor/rules-editor.cjs +160 -0
- package/dist/components/ui/rules-editor/rules-editor.d.ts +66 -0
- package/dist/components/ui/rules-editor/rules-editor.js +126 -0
- package/dist/components/ui/rules-editor/strings.cjs +68 -0
- package/dist/components/ui/rules-editor/strings.d.ts +56 -0
- package/dist/components/ui/rules-editor/strings.js +34 -0
- package/dist/index.cjs +132 -8
- package/dist/index.d.ts +19 -6
- package/dist/index.js +11 -4
- package/dist/styles.css +119 -24
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Moves focus after a repeatable list changes, so keyboard users keep their place.
|
|
4
|
+
*
|
|
5
|
+
* Items are the `[data-row]` direct children of `listRef`. After an add, focus lands on the new
|
|
6
|
+
* last item's `[data-row-first]` control, or its first button or input. After a delete, it lands
|
|
7
|
+
* on the `[data-row-delete]` action of the item now at the same position, or on `addRef` once the
|
|
8
|
+
* list is empty. Call `afterAdd` / `afterDelete` alongside the change. Focus moves on the next
|
|
9
|
+
* render only if the list grew or shrank by one, so a change the host rejects or defers leaves
|
|
10
|
+
* focus where it is.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useRowFocus(): {
|
|
13
|
+
listRef: React.RefObject<HTMLDivElement | null>;
|
|
14
|
+
addRef: React.RefObject<HTMLButtonElement | null>;
|
|
15
|
+
afterAdd: () => void;
|
|
16
|
+
afterDelete: (position: number) => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
const ROWS = ':scope > [data-row]';
|
|
3
|
+
function rowCount(list) {
|
|
4
|
+
return list?.querySelectorAll(ROWS).length ?? 0;
|
|
5
|
+
}
|
|
6
|
+
function useRowFocus() {
|
|
7
|
+
const listRef = useRef(null);
|
|
8
|
+
const addRef = useRef(null);
|
|
9
|
+
const pending = useRef(null);
|
|
10
|
+
useEffect(()=>{
|
|
11
|
+
const next = pending.current;
|
|
12
|
+
const list = listRef.current;
|
|
13
|
+
if (!next || !list) return;
|
|
14
|
+
pending.current = null;
|
|
15
|
+
const rows = Array.from(list.querySelectorAll(ROWS));
|
|
16
|
+
if (rows.length !== next.rows) return;
|
|
17
|
+
if ('add' === next.kind) {
|
|
18
|
+
const row = rows[rows.length - 1];
|
|
19
|
+
(row?.querySelector('[data-row-first]') ?? row?.querySelector('button, input, textarea'))?.focus();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const target = rows[Math.min(next.position, rows.length - 1)];
|
|
23
|
+
(target?.querySelector('[data-row-delete]') ?? addRef.current)?.focus();
|
|
24
|
+
});
|
|
25
|
+
const afterAdd = useCallback(()=>{
|
|
26
|
+
pending.current = {
|
|
27
|
+
kind: 'add',
|
|
28
|
+
rows: rowCount(listRef.current) + 1
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
const afterDelete = useCallback((position)=>{
|
|
32
|
+
pending.current = {
|
|
33
|
+
kind: 'delete',
|
|
34
|
+
position,
|
|
35
|
+
rows: Math.max(rowCount(listRef.current) - 1, 0)
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
return useMemo(()=>({
|
|
39
|
+
listRef,
|
|
40
|
+
addRef,
|
|
41
|
+
afterAdd,
|
|
42
|
+
afterDelete
|
|
43
|
+
}), [
|
|
44
|
+
afterAdd,
|
|
45
|
+
afterDelete
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
export { useRowFocus };
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
RulesEditorContext: ()=>RulesEditorContext,
|
|
28
|
+
useRulesEditor: ()=>useRulesEditor
|
|
29
|
+
});
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const RulesEditorContext = external_react_namespaceObject.createContext(null);
|
|
32
|
+
function useRulesEditor() {
|
|
33
|
+
const value = external_react_namespaceObject.useContext(RulesEditorContext);
|
|
34
|
+
if (!value) throw new Error('RuleCard must be rendered inside a RulesEditor.');
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
exports.RulesEditorContext = __webpack_exports__.RulesEditorContext;
|
|
38
|
+
exports.useRulesEditor = __webpack_exports__.useRulesEditor;
|
|
39
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
|
+
"RulesEditorContext",
|
|
41
|
+
"useRulesEditor"
|
|
42
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
43
|
+
Object.defineProperty(exports, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ConditionsEditorStrings, ConditionVocabulary, RenderConditionValue } from '../conditions-editor';
|
|
3
|
+
import type { ValueModeStrings } from '../field-addons';
|
|
4
|
+
import type { MultiSelectStrings } from '../multi-select';
|
|
5
|
+
import type { VariablePickerItem } from '../variable-picker';
|
|
6
|
+
import type { ExpressionRule, Rule, RuleOutcome, RulesDialect } from './model';
|
|
7
|
+
import type { RulesEditorStrings } from './strings';
|
|
8
|
+
export interface RuleExpressionEditorProps {
|
|
9
|
+
rule: ExpressionRule;
|
|
10
|
+
/** For the control, so the rule's hidden label names it. */
|
|
11
|
+
id: string;
|
|
12
|
+
value: string;
|
|
13
|
+
onChange: (expression: string) => void;
|
|
14
|
+
/** Call when focus leaves the editor, so its message can show. */
|
|
15
|
+
onBlur: () => void;
|
|
16
|
+
/** Ids of the rule name and the editor's label, for `aria-labelledby`. */
|
|
17
|
+
labelledBy: string;
|
|
18
|
+
invalid: boolean;
|
|
19
|
+
/** The message's id, for `aria-describedby` and `aria-errormessage`, while it shows. */
|
|
20
|
+
errorId?: string;
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Replaces a rule's expression editor with the host's own, such as a code editor that knows its
|
|
26
|
+
* variables. Return `undefined` to keep the built-in one.
|
|
27
|
+
*
|
|
28
|
+
* It is called during render, not mounted as a component, so it cannot call hooks itself. Return
|
|
29
|
+
* a component that does.
|
|
30
|
+
*/
|
|
31
|
+
export type RenderRuleExpressionEditor = (props: RuleExpressionEditorProps) => React.ReactNode | undefined;
|
|
32
|
+
export interface RulesEditorContextValue {
|
|
33
|
+
outcomes: readonly RuleOutcome[];
|
|
34
|
+
vocabulary: ConditionVocabulary;
|
|
35
|
+
variables?: VariablePickerItem[];
|
|
36
|
+
renderValue?: RenderConditionValue;
|
|
37
|
+
showMatchMode: boolean;
|
|
38
|
+
allowExpressions: boolean;
|
|
39
|
+
dialect?: RulesDialect;
|
|
40
|
+
renderExpressionEditor?: RenderRuleExpressionEditor;
|
|
41
|
+
forceErrors: boolean;
|
|
42
|
+
defaultTouched?: readonly string[];
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
strings: RulesEditorStrings;
|
|
45
|
+
conditionsStrings: Partial<ConditionsEditorStrings>;
|
|
46
|
+
valueModeStrings?: Partial<ValueModeStrings>;
|
|
47
|
+
multiSelectStrings?: Partial<MultiSelectStrings>;
|
|
48
|
+
/** Stable: replaces the rule with the same id. */
|
|
49
|
+
updateRule: (rule: Rule) => void;
|
|
50
|
+
}
|
|
51
|
+
export declare const RulesEditorContext: React.Context<RulesEditorContextValue | null>;
|
|
52
|
+
export declare function useRulesEditor(): RulesEditorContextValue;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const RulesEditorContext = createContext(null);
|
|
3
|
+
function useRulesEditor() {
|
|
4
|
+
const value = useContext(RulesEditorContext);
|
|
5
|
+
if (!value) throw new Error('RuleCard must be rendered inside a RulesEditor.');
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
export { RulesEditorContext, useRulesEditor };
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
DEFAULT_RULES_EDITOR_STRINGS: ()=>external_strings_cjs_namespaceObject.DEFAULT_RULES_EDITOR_STRINGS,
|
|
28
|
+
findRuleIssues: ()=>external_model_cjs_namespaceObject.findRuleIssues,
|
|
29
|
+
issueIds: ()=>external_model_cjs_namespaceObject.issueIds,
|
|
30
|
+
createRule: ()=>external_model_cjs_namespaceObject.createRule,
|
|
31
|
+
isRuleComplete: ()=>external_model_cjs_namespaceObject.isRuleComplete,
|
|
32
|
+
isUnconditionalRule: ()=>external_model_cjs_namespaceObject.isUnconditionalRule,
|
|
33
|
+
RulesEditor: ()=>external_rules_editor_cjs_namespaceObject.RulesEditor
|
|
34
|
+
});
|
|
35
|
+
const external_model_cjs_namespaceObject = require("./model.cjs");
|
|
36
|
+
const external_rules_editor_cjs_namespaceObject = require("./rules-editor.cjs");
|
|
37
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
38
|
+
exports.DEFAULT_RULES_EDITOR_STRINGS = __webpack_exports__.DEFAULT_RULES_EDITOR_STRINGS;
|
|
39
|
+
exports.RulesEditor = __webpack_exports__.RulesEditor;
|
|
40
|
+
exports.createRule = __webpack_exports__.createRule;
|
|
41
|
+
exports.findRuleIssues = __webpack_exports__.findRuleIssues;
|
|
42
|
+
exports.isRuleComplete = __webpack_exports__.isRuleComplete;
|
|
43
|
+
exports.isUnconditionalRule = __webpack_exports__.isUnconditionalRule;
|
|
44
|
+
exports.issueIds = __webpack_exports__.issueIds;
|
|
45
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
46
|
+
"DEFAULT_RULES_EDITOR_STRINGS",
|
|
47
|
+
"RulesEditor",
|
|
48
|
+
"createRule",
|
|
49
|
+
"findRuleIssues",
|
|
50
|
+
"isRuleComplete",
|
|
51
|
+
"isUnconditionalRule",
|
|
52
|
+
"issueIds"
|
|
53
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
54
|
+
Object.defineProperty(exports, '__esModule', {
|
|
55
|
+
value: true
|
|
56
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { RenderRuleExpressionEditor, RuleExpressionEditorProps } from './context';
|
|
2
|
+
export { type ConditionsRule, createRule, type ExpressionRule, findRuleIssues, isRuleComplete, issueIds, isUnconditionalRule, type PreservedRule, type Rule, type RuleExpressionProblem, type RuleIssue, type RuleIssueKind, type RuleMode, type RuleOutcome, type RuleRepair, type RulesDialect, type RuleVocabulary, } from './model';
|
|
3
|
+
export { RulesEditor, type RulesEditorProps } from './rules-editor';
|
|
4
|
+
export { DEFAULT_RULES_EDITOR_STRINGS, type RulesEditorStrings } from './strings';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRule, findRuleIssues, isRuleComplete, isUnconditionalRule, issueIds } from "./model.js";
|
|
2
|
+
import { RulesEditor } from "./rules-editor.js";
|
|
3
|
+
import { DEFAULT_RULES_EDITOR_STRINGS } from "./strings.js";
|
|
4
|
+
export { DEFAULT_RULES_EDITOR_STRINGS, RulesEditor, createRule, findRuleIssues, isRuleComplete, isUnconditionalRule, issueIds };
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
unknownValueFields: ()=>unknownValueFields,
|
|
28
|
+
withMode: ()=>withMode,
|
|
29
|
+
isBlank: ()=>isBlank,
|
|
30
|
+
issueIds: ()=>issueIds,
|
|
31
|
+
missingFields: ()=>missingFields,
|
|
32
|
+
createRule: ()=>createRule,
|
|
33
|
+
isRuleComplete: ()=>isRuleComplete,
|
|
34
|
+
unknownFields: ()=>unknownFields,
|
|
35
|
+
isUnconditionalRule: ()=>isUnconditionalRule,
|
|
36
|
+
findRuleIssues: ()=>findRuleIssues
|
|
37
|
+
});
|
|
38
|
+
const index_cjs_namespaceObject = require("../conditions-editor/index.cjs");
|
|
39
|
+
const status_cjs_namespaceObject = require("../conditions-editor/status.cjs");
|
|
40
|
+
function newId(prefix) {
|
|
41
|
+
return `${prefix}-${crypto.randomUUID()}`;
|
|
42
|
+
}
|
|
43
|
+
function createRule(init) {
|
|
44
|
+
const id = init.id ?? newId('rule');
|
|
45
|
+
return void 0 !== init.expression ? {
|
|
46
|
+
id,
|
|
47
|
+
outcome: init.outcome,
|
|
48
|
+
mode: 'expression',
|
|
49
|
+
expression: init.expression
|
|
50
|
+
} : {
|
|
51
|
+
id,
|
|
52
|
+
outcome: init.outcome,
|
|
53
|
+
mode: 'conditions',
|
|
54
|
+
conditions: init.conditions ?? (0, index_cjs_namespaceObject.createConditionGroup)('all', [
|
|
55
|
+
(0, index_cjs_namespaceObject.createCondition)()
|
|
56
|
+
])
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function withMode(rule, next) {
|
|
60
|
+
const rest = Object.fromEntries(Object.entries(rule).filter(([key])=>'conditions' !== key && 'expression' !== key && 'preservedSource' !== key));
|
|
61
|
+
return {
|
|
62
|
+
...rest,
|
|
63
|
+
...next
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function conditionsOf(node) {
|
|
67
|
+
return 'condition' === node.kind ? [
|
|
68
|
+
node
|
|
69
|
+
] : node.children.flatMap(conditionsOf);
|
|
70
|
+
}
|
|
71
|
+
function isBlank(rule) {
|
|
72
|
+
if ('preserved' === rule.mode) return false;
|
|
73
|
+
return 'expression' === rule.mode ? '' === rule.expression.trim() : conditionsOf(rule.conditions).every((c)=>!c.field && !c.value && (c.values?.length ?? 0) === 0);
|
|
74
|
+
}
|
|
75
|
+
function isUnconditionalRule(rule) {
|
|
76
|
+
return 'conditions' === rule.mode && 0 === rule.conditions.children.length;
|
|
77
|
+
}
|
|
78
|
+
function groupComplete(group, vocabulary, nested) {
|
|
79
|
+
if (nested && 0 === group.children.length) return false;
|
|
80
|
+
return group.children.every((child)=>'condition' === child.kind ? (0, index_cjs_namespaceObject.isConditionComplete)(child, vocabulary) : groupComplete(child, vocabulary, true));
|
|
81
|
+
}
|
|
82
|
+
function isRuleComplete(rule, vocabulary) {
|
|
83
|
+
if (!vocabulary.outcomes.some((option)=>option.value === rule.outcome)) return false;
|
|
84
|
+
if ('preserved' === rule.mode) return true;
|
|
85
|
+
if ('expression' === rule.mode) return '' !== rule.expression.trim();
|
|
86
|
+
return groupComplete(rule.conditions, {
|
|
87
|
+
fields: vocabulary.fields,
|
|
88
|
+
operators: vocabulary.operators ?? index_cjs_namespaceObject.DEFAULT_CONDITION_OPERATORS,
|
|
89
|
+
valueModes: vocabulary.valueModes ?? (0, status_cjs_namespaceObject.defaultValueModes)(vocabulary.variables)
|
|
90
|
+
}, false);
|
|
91
|
+
}
|
|
92
|
+
function missingFields(names, fields) {
|
|
93
|
+
return names.filter((name)=>!fields.some((field)=>name === field.value || name.startsWith(`${field.value}.`)));
|
|
94
|
+
}
|
|
95
|
+
function unknownFields(expression, fields, dialect) {
|
|
96
|
+
return missingFields(dialect?.fieldsOf?.(expression) ?? [], fields);
|
|
97
|
+
}
|
|
98
|
+
function unknownValueFields(c, vocabulary, dialect) {
|
|
99
|
+
const value = c.value?.trim();
|
|
100
|
+
if (!value || 'expression' !== (0, status_cjs_namespaceObject.resolveCondition)(c, vocabulary).mode) return [];
|
|
101
|
+
return unknownFields(value, vocabulary.fields, dialect);
|
|
102
|
+
}
|
|
103
|
+
function findRuleIssues(rules, vocabulary, dialect) {
|
|
104
|
+
const resolved = {
|
|
105
|
+
fields: vocabulary.fields,
|
|
106
|
+
operators: vocabulary.operators ?? index_cjs_namespaceObject.DEFAULT_CONDITION_OPERATORS,
|
|
107
|
+
valueModes: vocabulary.valueModes ?? (0, status_cjs_namespaceObject.defaultValueModes)(vocabulary.variables)
|
|
108
|
+
};
|
|
109
|
+
const issues = [];
|
|
110
|
+
for (const rule of rules){
|
|
111
|
+
const ruleId = rule.id;
|
|
112
|
+
if (!vocabulary.outcomes.some((option)=>option.value === rule.outcome)) issues.push({
|
|
113
|
+
ruleId,
|
|
114
|
+
kind: 'outcome'
|
|
115
|
+
});
|
|
116
|
+
if (dialect?.repair?.(rule)) issues.push({
|
|
117
|
+
ruleId,
|
|
118
|
+
kind: 'repair'
|
|
119
|
+
});
|
|
120
|
+
if ('preserved' === rule.mode) {
|
|
121
|
+
if (missingFields(rule.fieldKeys ?? [], resolved.fields).length > 0) issues.push({
|
|
122
|
+
ruleId,
|
|
123
|
+
kind: 'unknownField'
|
|
124
|
+
});
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if ('expression' === rule.mode) {
|
|
128
|
+
if ('' === rule.expression.trim()) {
|
|
129
|
+
issues.push({
|
|
130
|
+
ruleId,
|
|
131
|
+
kind: 'incomplete'
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (unknownFields(rule.expression, resolved.fields, dialect).length > 0) issues.push({
|
|
136
|
+
ruleId,
|
|
137
|
+
kind: 'unknownField'
|
|
138
|
+
});
|
|
139
|
+
if (dialect?.checkExpression?.(rule, resolved) === 'invalid') issues.push({
|
|
140
|
+
ruleId,
|
|
141
|
+
kind: 'expression'
|
|
142
|
+
});
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const visit = (group, nested)=>{
|
|
146
|
+
if (nested && 0 === group.children.length) issues.push({
|
|
147
|
+
ruleId,
|
|
148
|
+
nodeId: group.id,
|
|
149
|
+
kind: 'incomplete'
|
|
150
|
+
});
|
|
151
|
+
for (const child of group.children)if ('group' === child.kind) visit(child, true);
|
|
152
|
+
else if (child.field && !resolved.fields.some((field)=>field.value === child.field)) issues.push({
|
|
153
|
+
ruleId,
|
|
154
|
+
nodeId: child.id,
|
|
155
|
+
kind: 'unknownField'
|
|
156
|
+
});
|
|
157
|
+
else if ((0, index_cjs_namespaceObject.isConditionComplete)(child, resolved)) {
|
|
158
|
+
if (unknownValueFields(child, resolved, dialect).length > 0) issues.push({
|
|
159
|
+
ruleId,
|
|
160
|
+
nodeId: child.id,
|
|
161
|
+
kind: 'unknownField'
|
|
162
|
+
});
|
|
163
|
+
} else issues.push({
|
|
164
|
+
ruleId,
|
|
165
|
+
nodeId: child.id,
|
|
166
|
+
kind: 'incomplete'
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
visit(rule.conditions, false);
|
|
170
|
+
}
|
|
171
|
+
return issues;
|
|
172
|
+
}
|
|
173
|
+
function issueIds(issues) {
|
|
174
|
+
return issues.flatMap((issue)=>[
|
|
175
|
+
issue.ruleId,
|
|
176
|
+
...issue.nodeId ? [
|
|
177
|
+
issue.nodeId
|
|
178
|
+
] : []
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
exports.createRule = __webpack_exports__.createRule;
|
|
182
|
+
exports.findRuleIssues = __webpack_exports__.findRuleIssues;
|
|
183
|
+
exports.isBlank = __webpack_exports__.isBlank;
|
|
184
|
+
exports.isRuleComplete = __webpack_exports__.isRuleComplete;
|
|
185
|
+
exports.isUnconditionalRule = __webpack_exports__.isUnconditionalRule;
|
|
186
|
+
exports.issueIds = __webpack_exports__.issueIds;
|
|
187
|
+
exports.missingFields = __webpack_exports__.missingFields;
|
|
188
|
+
exports.unknownFields = __webpack_exports__.unknownFields;
|
|
189
|
+
exports.unknownValueFields = __webpack_exports__.unknownValueFields;
|
|
190
|
+
exports.withMode = __webpack_exports__.withMode;
|
|
191
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
192
|
+
"createRule",
|
|
193
|
+
"findRuleIssues",
|
|
194
|
+
"isBlank",
|
|
195
|
+
"isRuleComplete",
|
|
196
|
+
"isUnconditionalRule",
|
|
197
|
+
"issueIds",
|
|
198
|
+
"missingFields",
|
|
199
|
+
"unknownFields",
|
|
200
|
+
"unknownValueFields",
|
|
201
|
+
"withMode"
|
|
202
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
203
|
+
Object.defineProperty(exports, '__esModule', {
|
|
204
|
+
value: true
|
|
205
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { type Condition, type ConditionGroup, type ConditionVocabulary } from '../conditions-editor';
|
|
2
|
+
import type { VariablePickerItem } from '../variable-picker';
|
|
3
|
+
/** How an author writes when a rule applies: rows of conditions, or one written expression. */
|
|
4
|
+
export type RuleMode = 'conditions' | 'expression';
|
|
5
|
+
interface RuleBase {
|
|
6
|
+
id: string;
|
|
7
|
+
/** The outcome's `value`, such as "show" or "require". */
|
|
8
|
+
outcome: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ConditionsRule extends RuleBase {
|
|
11
|
+
mode: 'conditions';
|
|
12
|
+
conditions: ConditionGroup;
|
|
13
|
+
}
|
|
14
|
+
export interface ExpressionRule extends RuleBase {
|
|
15
|
+
mode: 'expression';
|
|
16
|
+
expression: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A rule the host stored in a form neither mode can show, which still runs. It is kept as stored
|
|
20
|
+
* and shown read-only as `preservedSource`; its outcome can change, and switching its mode replaces it.
|
|
21
|
+
*/
|
|
22
|
+
export interface PreservedRule extends RuleBase {
|
|
23
|
+
mode: 'preserved';
|
|
24
|
+
preservedSource: string;
|
|
25
|
+
/** The field keys its stored conditions read, so the editor can flag the ones removed. */
|
|
26
|
+
fieldKeys?: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/** A rule. Other properties a host adds, such as its own metadata, are kept through every edit. */
|
|
29
|
+
export type Rule = ConditionsRule | ExpressionRule | PreservedRule;
|
|
30
|
+
/** What a rule does when it applies. */
|
|
31
|
+
export interface RuleOutcome {
|
|
32
|
+
value: string;
|
|
33
|
+
label: string;
|
|
34
|
+
}
|
|
35
|
+
/** Why a rule's expression cannot run. */
|
|
36
|
+
export type RuleExpressionProblem = 'invalid';
|
|
37
|
+
/**
|
|
38
|
+
* Converts a rule's conditions to and from an expression in the host's language, so switching a
|
|
39
|
+
* rule between them keeps what the author wrote. Without one, a switch that would lose content
|
|
40
|
+
* asks first.
|
|
41
|
+
*/
|
|
42
|
+
export interface RulesDialect {
|
|
43
|
+
/** The conditions as an expression, or `undefined` when they cannot be written as one. */
|
|
44
|
+
toExpression?: (conditions: ConditionGroup, vocabulary: ConditionVocabulary) => string | undefined;
|
|
45
|
+
/** The expression as conditions, or `undefined` when it cannot be read as rows. */
|
|
46
|
+
fromExpression?: (expression: string, vocabulary: ConditionVocabulary) => ConditionGroup | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The field keys an expression names, so the editor can flag the ones `fields` no longer lists,
|
|
49
|
+
* such as after a field is removed.
|
|
50
|
+
*/
|
|
51
|
+
fieldsOf?: (expression: string) => string[];
|
|
52
|
+
/** Whether the host can run a rule's expression. Each problem shows on the rule. */
|
|
53
|
+
checkExpression?: (rule: ExpressionRule, vocabulary: ConditionVocabulary) => RuleExpressionProblem | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The rule rewritten so the host's runtime can evaluate it as it shows, with why it cannot now,
|
|
56
|
+
* or `undefined` when it already can. The editor flags each with its reason, and offers to
|
|
57
|
+
* repair them all at once.
|
|
58
|
+
*/
|
|
59
|
+
repair?: (rule: Rule) => RuleRepair | undefined;
|
|
60
|
+
}
|
|
61
|
+
export interface RuleRepair {
|
|
62
|
+
rule: Rule;
|
|
63
|
+
/** Why the rule cannot be evaluated as it shows, to follow "cannot be evaluated: ". */
|
|
64
|
+
reason: string;
|
|
65
|
+
}
|
|
66
|
+
interface RuleInitBase {
|
|
67
|
+
outcome: string;
|
|
68
|
+
id?: string;
|
|
69
|
+
}
|
|
70
|
+
/** A conditions rule, starting with one empty condition, or an expression rule. */
|
|
71
|
+
export declare function createRule(init: RuleInitBase & {
|
|
72
|
+
expression: string;
|
|
73
|
+
conditions?: never;
|
|
74
|
+
}): ExpressionRule;
|
|
75
|
+
export declare function createRule(init: RuleInitBase & {
|
|
76
|
+
conditions?: ConditionGroup;
|
|
77
|
+
expression?: never;
|
|
78
|
+
}): ConditionsRule;
|
|
79
|
+
export declare function createRule(init: RuleInitBase & {
|
|
80
|
+
conditions?: ConditionGroup;
|
|
81
|
+
expression?: string;
|
|
82
|
+
}): Rule;
|
|
83
|
+
/** The rule in another mode, keeping its id, outcome, and any properties the host added. */
|
|
84
|
+
export declare function withMode(rule: Rule, next: Pick<ConditionsRule, 'mode' | 'conditions'> | Pick<ExpressionRule, 'mode' | 'expression'>): Rule;
|
|
85
|
+
/** Nothing typed or picked, so switching away loses nothing. */
|
|
86
|
+
export declare function isBlank(rule: Rule): boolean;
|
|
87
|
+
/** A rule with no conditions, which always applies. */
|
|
88
|
+
export declare function isUnconditionalRule(rule: Rule): rule is ConditionsRule;
|
|
89
|
+
/** What the editor offers, so a check agrees with what it flags. Pass the editor's own props. */
|
|
90
|
+
export interface RuleVocabulary {
|
|
91
|
+
outcomes: readonly RuleOutcome[];
|
|
92
|
+
fields: ConditionVocabulary['fields'];
|
|
93
|
+
/** Defaults to the English set, as the editor's does. */
|
|
94
|
+
operators?: ConditionVocabulary['operators'];
|
|
95
|
+
/** Defaults to the editor's: Fixed value and Expression, plus Variable with `variables`. */
|
|
96
|
+
valueModes?: ConditionVocabulary['valueModes'];
|
|
97
|
+
variables?: readonly VariablePickerItem[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Whether the rule runs as written, by the same checks the editor flags: an outcome it offers, and
|
|
101
|
+
* an expression that is not blank or conditions it flags none of. No conditions is complete, as
|
|
102
|
+
* the rule then always applies, and so is a preserved rule, which runs as stored.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isRuleComplete(rule: Rule, vocabulary: RuleVocabulary): boolean;
|
|
105
|
+
/** The keys that are no fields, a field's own sub-paths aside. */
|
|
106
|
+
export declare function missingFields(names: readonly string[], fields: ConditionVocabulary['fields']): string[];
|
|
107
|
+
/** The keys an expression names that are no fields, a field's own sub-paths aside. */
|
|
108
|
+
export declare function unknownFields(expression: string, fields: ConditionVocabulary['fields'], dialect: RulesDialect | undefined): string[];
|
|
109
|
+
/** The keys a row's Expression value names that are no fields, as `unknownFields` finds them. */
|
|
110
|
+
export declare function unknownValueFields(c: Condition, vocabulary: ConditionVocabulary, dialect: RulesDialect | undefined): string[];
|
|
111
|
+
/** What makes a rule need attention. `repair` is a rule the dialect cannot evaluate as it shows. */
|
|
112
|
+
export type RuleIssueKind = 'outcome' | 'incomplete' | 'unknownField' | 'expression' | 'repair';
|
|
113
|
+
export interface RuleIssue {
|
|
114
|
+
ruleId: string;
|
|
115
|
+
/** The condition or group it is on, for a row's issue. */
|
|
116
|
+
nodeId?: string;
|
|
117
|
+
kind: RuleIssueKind;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Everything the editor would flag in the rules, by the same checks: an outcome it does not offer,
|
|
121
|
+
* a condition on a field `fields` no longer lists, an unfinished condition or blank expression,
|
|
122
|
+
* an expression or a row's Expression value naming such a field, one the dialect cannot run, and
|
|
123
|
+
* a rule it would repair. An unfinished rule counts, as it is not stored until it is finished.
|
|
124
|
+
*/
|
|
125
|
+
export declare function findRuleIssues(rules: readonly Rule[], vocabulary: RuleVocabulary, dialect?: RulesDialect): RuleIssue[];
|
|
126
|
+
/** The ids of the rules and nodes with issues, as `defaultTouched` takes them to show at once. */
|
|
127
|
+
export declare function issueIds(issues: readonly RuleIssue[]): string[];
|
|
128
|
+
export {};
|