@uipath/apollo-wind 2.93.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/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 +273 -234
- 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 +129 -8
- package/dist/index.d.ts +17 -4
- package/dist/index.js +10 -3
- package/dist/styles.css +97 -24
- package/package.json +2 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type RulesEditorProps, type RulesEditorStrings } from '../rules-editor';
|
|
2
|
+
export interface RulesActionStrings {
|
|
3
|
+
/**
|
|
4
|
+
* The trigger's accessible name and tooltip, given how many rules are set and how many of them
|
|
5
|
+
* need attention: unfinished, on a field the form no longer has, or not runnable.
|
|
6
|
+
*/
|
|
7
|
+
trigger: (count: number, issues: number) => string;
|
|
8
|
+
/** The popover's heading, which also names the rules list. */
|
|
9
|
+
title: string;
|
|
10
|
+
/** The Required switch's label. */
|
|
11
|
+
required: string;
|
|
12
|
+
/** Turns the Required switch's rule into one with conditions. */
|
|
13
|
+
makeConditional: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const DEFAULT_RULES_ACTION_STRINGS: RulesActionStrings;
|
|
16
|
+
export interface RulesActionProps extends Omit<RulesEditorProps, 'label' | 'disabled' | 'className' | 'strings'> {
|
|
17
|
+
/**
|
|
18
|
+
* The outcome that requires the field. Its rule with no conditions, which always applies, shows
|
|
19
|
+
* as a Required switch above the other rules. Omit where requiring the field is no choice.
|
|
20
|
+
*/
|
|
21
|
+
requiredOutcome?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Disables every control in the popover, which still opens so the rules can be read. Disabled
|
|
24
|
+
* while an enclosing QuickFormField is, too.
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Overrides for any subset of the action's English strings. */
|
|
28
|
+
strings?: Partial<RulesActionStrings>;
|
|
29
|
+
/** Overrides for the rules editor's strings. */
|
|
30
|
+
editorStrings?: Partial<RulesEditorStrings>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The field-rules header action: a RulesEditor in a popover, with an optional Required switch,
|
|
34
|
+
* behind a trigger that counts the rules and turns red while any needs attention, whose messages
|
|
35
|
+
* then show as the popover opens. The switch is a rule like the others, shown apart: on, it is a
|
|
36
|
+
* `requiredOutcome` rule with no conditions, and Make conditional gives it one. Inside a
|
|
37
|
+
* QuickFormField's `headerActions` it follows the field's `disabled`; disabled, the popover still
|
|
38
|
+
* opens, read-only. Requires an ancestor `TooltipProvider`.
|
|
39
|
+
*
|
|
40
|
+
* Pair it with `useFieldRules` to store the rules as RulesEngine `FieldRule`s.
|
|
41
|
+
*/
|
|
42
|
+
export declare function RulesAction({ requiredOutcome, disabled, strings, editorStrings, value, onChange, defaultTouched, ...editor }: RulesActionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Network } from "lucide-react";
|
|
3
|
+
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Button } from "../button.js";
|
|
5
|
+
import { createCondition, createConditionGroup } from "../conditions-editor/index.js";
|
|
6
|
+
import { Label } from "../label.js";
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../popover.js";
|
|
8
|
+
import { useQuickFormFieldHeader } from "../quick-form-field/components/header-context.js";
|
|
9
|
+
import { RulesEditor, createRule, findRuleIssues, isUnconditionalRule, issueIds } from "../rules-editor/index.js";
|
|
10
|
+
import { Switch } from "../switch.js";
|
|
11
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip.js";
|
|
12
|
+
import { cn } from "../../../lib/index.js";
|
|
13
|
+
import { FIELD_ACTION_CLASS } from "./collapse.js";
|
|
14
|
+
const DEFAULT_RULES_ACTION_STRINGS = {
|
|
15
|
+
trigger: (count, issues)=>0 === count ? 'Field rules' : 0 === issues ? `Field rules (${count})` : `Field rules (${count}), ${issues} ${1 === issues ? 'needs' : 'need'} attention`,
|
|
16
|
+
title: 'Field rules',
|
|
17
|
+
required: 'Required field',
|
|
18
|
+
makeConditional: 'Make conditional'
|
|
19
|
+
};
|
|
20
|
+
function RulesAction({ requiredOutcome, disabled, strings, editorStrings, value, onChange, defaultTouched, ...editor }) {
|
|
21
|
+
const header = useQuickFormFieldHeader();
|
|
22
|
+
const inert = !!disabled || !!header?.disabled;
|
|
23
|
+
const text = {
|
|
24
|
+
...DEFAULT_RULES_ACTION_STRINGS,
|
|
25
|
+
...strings
|
|
26
|
+
};
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const titleId = useId();
|
|
29
|
+
const requiredId = useId();
|
|
30
|
+
const rulesList = useRef(null);
|
|
31
|
+
const focusRule = useRef(null);
|
|
32
|
+
const count = value.length;
|
|
33
|
+
const { outcomes, fields, operators, valueModes, variables, dialect } = editor;
|
|
34
|
+
const issues = useMemo(()=>findRuleIssues(value, {
|
|
35
|
+
outcomes,
|
|
36
|
+
fields,
|
|
37
|
+
operators,
|
|
38
|
+
valueModes,
|
|
39
|
+
variables
|
|
40
|
+
}, dialect), [
|
|
41
|
+
value,
|
|
42
|
+
outcomes,
|
|
43
|
+
fields,
|
|
44
|
+
operators,
|
|
45
|
+
valueModes,
|
|
46
|
+
variables,
|
|
47
|
+
dialect
|
|
48
|
+
]);
|
|
49
|
+
const flagged = new Set(issues.map((issue)=>issue.ruleId)).size;
|
|
50
|
+
const [openedIssues, setOpenedIssues] = useState([]);
|
|
51
|
+
const changeOpen = (next)=>{
|
|
52
|
+
if (next) setOpenedIssues(issueIds(issues));
|
|
53
|
+
setOpen(next);
|
|
54
|
+
};
|
|
55
|
+
const touched = useMemo(()=>[
|
|
56
|
+
...defaultTouched ?? [],
|
|
57
|
+
...openedIssues
|
|
58
|
+
], [
|
|
59
|
+
defaultTouched,
|
|
60
|
+
openedIssues
|
|
61
|
+
]);
|
|
62
|
+
const triggerLabel = text.trigger(count, flagged);
|
|
63
|
+
const requiredIndex = void 0 === requiredOutcome ? -1 : value.findIndex((rule)=>rule.outcome === requiredOutcome && isUnconditionalRule(rule));
|
|
64
|
+
const requiredRule = requiredIndex < 0 ? void 0 : value[requiredIndex];
|
|
65
|
+
const rules = requiredRule ? value.filter((rule)=>rule !== requiredRule) : value;
|
|
66
|
+
const showSwitch = void 0 !== requiredOutcome && (!!requiredRule || !rules.some((rule)=>rule.outcome === requiredOutcome));
|
|
67
|
+
const changeRules = (next)=>{
|
|
68
|
+
if (!requiredRule) return onChange(next);
|
|
69
|
+
const before = new Set(value.slice(0, requiredIndex).map((rule)=>rule.id));
|
|
70
|
+
const after = next.reduce((at, rule, position)=>before.has(rule.id) ? position + 1 : at, 0);
|
|
71
|
+
onChange([
|
|
72
|
+
...next.slice(0, after),
|
|
73
|
+
requiredRule,
|
|
74
|
+
...next.slice(after)
|
|
75
|
+
]);
|
|
76
|
+
};
|
|
77
|
+
const setRequired = (on)=>{
|
|
78
|
+
if (!requiredOutcome) return;
|
|
79
|
+
onChange(on ? [
|
|
80
|
+
createRule({
|
|
81
|
+
outcome: requiredOutcome,
|
|
82
|
+
conditions: createConditionGroup()
|
|
83
|
+
}),
|
|
84
|
+
...value
|
|
85
|
+
] : [
|
|
86
|
+
...rules
|
|
87
|
+
]);
|
|
88
|
+
};
|
|
89
|
+
const makeConditional = ()=>{
|
|
90
|
+
onChange(value.map((rule)=>rule === requiredRule && 'conditions' === rule.mode ? {
|
|
91
|
+
...rule,
|
|
92
|
+
conditions: {
|
|
93
|
+
...rule.conditions,
|
|
94
|
+
children: [
|
|
95
|
+
createCondition()
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
} : rule));
|
|
99
|
+
focusRule.current = {
|
|
100
|
+
position: requiredIndex,
|
|
101
|
+
rules: rules.length + 1
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
useEffect(()=>{
|
|
105
|
+
const next = focusRule.current;
|
|
106
|
+
const cards = rulesList.current?.querySelectorAll(':scope > fieldset > div > [data-row]');
|
|
107
|
+
if (!next || !cards || cards.length !== next.rules) return;
|
|
108
|
+
focusRule.current = null;
|
|
109
|
+
cards[next.position]?.querySelector(':scope [data-row] [data-row-first]')?.focus();
|
|
110
|
+
});
|
|
111
|
+
const rulesStrings = useMemo(()=>showSwitch ? {
|
|
112
|
+
...editorStrings,
|
|
113
|
+
empty: ''
|
|
114
|
+
} : editorStrings, [
|
|
115
|
+
showSwitch,
|
|
116
|
+
editorStrings
|
|
117
|
+
]);
|
|
118
|
+
return /*#__PURE__*/ jsxs(Popover, {
|
|
119
|
+
open: open,
|
|
120
|
+
onOpenChange: changeOpen,
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ jsxs(Tooltip, {
|
|
123
|
+
children: [
|
|
124
|
+
/*#__PURE__*/ jsx(TooltipTrigger, {
|
|
125
|
+
asChild: true,
|
|
126
|
+
children: /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
127
|
+
asChild: true,
|
|
128
|
+
children: /*#__PURE__*/ jsxs(Button, {
|
|
129
|
+
type: "button",
|
|
130
|
+
variant: "ghost",
|
|
131
|
+
size: "3xs",
|
|
132
|
+
icon: true,
|
|
133
|
+
"aria-label": triggerLabel,
|
|
134
|
+
className: cn('relative', FIELD_ACTION_CLASS, (open || count > 0) && 'text-brand', flagged > 0 && 'text-destructive'),
|
|
135
|
+
children: [
|
|
136
|
+
/*#__PURE__*/ jsx(Network, {}),
|
|
137
|
+
count > 0 && /*#__PURE__*/ jsx("span", {
|
|
138
|
+
"aria-hidden": true,
|
|
139
|
+
className: cn('absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full px-0.5 text-[9px] font-medium leading-none', flagged > 0 ? 'bg-destructive text-destructive-foreground' : 'bg-brand/15 text-brand'),
|
|
140
|
+
children: count
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ jsx(TooltipContent, {
|
|
147
|
+
children: triggerLabel
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
/*#__PURE__*/ jsxs(PopoverContent, {
|
|
152
|
+
align: "end",
|
|
153
|
+
sideOffset: 6,
|
|
154
|
+
collisionPadding: 8,
|
|
155
|
+
"aria-labelledby": titleId,
|
|
156
|
+
className: "flex max-h-[var(--radix-popover-content-available-height)] w-[min(29rem,calc(100vw-2rem))] flex-col gap-2.5 overflow-y-auto p-3",
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ jsx("div", {
|
|
159
|
+
id: titleId,
|
|
160
|
+
className: "text-xs font-semibold text-foreground",
|
|
161
|
+
children: text.title
|
|
162
|
+
}),
|
|
163
|
+
showSwitch && /*#__PURE__*/ jsxs("div", {
|
|
164
|
+
className: "flex h-10 items-center gap-2.5 rounded-lg border border-solid border-border bg-card px-3",
|
|
165
|
+
children: [
|
|
166
|
+
/*#__PURE__*/ jsx(Switch, {
|
|
167
|
+
id: requiredId,
|
|
168
|
+
size: "sm",
|
|
169
|
+
checked: !!requiredRule,
|
|
170
|
+
onCheckedChange: setRequired,
|
|
171
|
+
disabled: inert
|
|
172
|
+
}),
|
|
173
|
+
/*#__PURE__*/ jsx(Label, {
|
|
174
|
+
htmlFor: requiredId,
|
|
175
|
+
className: "flex-1 text-xs font-normal text-foreground",
|
|
176
|
+
children: text.required
|
|
177
|
+
}),
|
|
178
|
+
requiredRule && /*#__PURE__*/ jsx(Button, {
|
|
179
|
+
type: "button",
|
|
180
|
+
variant: "ghost",
|
|
181
|
+
size: "3xs",
|
|
182
|
+
onClick: makeConditional,
|
|
183
|
+
disabled: inert,
|
|
184
|
+
className: "text-xs text-muted-foreground hover:text-foreground",
|
|
185
|
+
children: text.makeConditional
|
|
186
|
+
})
|
|
187
|
+
]
|
|
188
|
+
}),
|
|
189
|
+
/*#__PURE__*/ jsx("div", {
|
|
190
|
+
ref: rulesList,
|
|
191
|
+
className: "contents",
|
|
192
|
+
children: /*#__PURE__*/ jsx(RulesEditor, {
|
|
193
|
+
...editor,
|
|
194
|
+
value: rules,
|
|
195
|
+
onChange: changeRules,
|
|
196
|
+
label: text.title,
|
|
197
|
+
disabled: inert,
|
|
198
|
+
strings: rulesStrings,
|
|
199
|
+
defaultTouched: touched
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
export { DEFAULT_RULES_ACTION_STRINGS, RulesAction };
|