@uipath/apollo-react 6.59.0 → 6.60.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.
Files changed (37) hide show
  1. package/dist/canvas/components/Guardrails/components/guardrail-field-picker.cjs +227 -0
  2. package/dist/canvas/components/Guardrails/components/guardrail-field-picker.d.ts +23 -0
  3. package/dist/canvas/components/Guardrails/components/guardrail-field-picker.d.ts.map +1 -0
  4. package/dist/canvas/components/Guardrails/components/guardrail-field-picker.js +193 -0
  5. package/dist/canvas/components/Guardrails/components/guardrail-rule-card.cjs +276 -0
  6. package/dist/canvas/components/Guardrails/components/guardrail-rule-card.d.ts +17 -0
  7. package/dist/canvas/components/Guardrails/components/guardrail-rule-card.d.ts.map +1 -0
  8. package/dist/canvas/components/Guardrails/components/guardrail-rule-card.js +242 -0
  9. package/dist/canvas/components/Guardrails/guardrail-filter-field-selector.cjs +76 -0
  10. package/dist/canvas/components/Guardrails/guardrail-filter-field-selector.d.ts +13 -0
  11. package/dist/canvas/components/Guardrails/guardrail-filter-field-selector.d.ts.map +1 -0
  12. package/dist/canvas/components/Guardrails/guardrail-filter-field-selector.js +42 -0
  13. package/dist/canvas/components/Guardrails/guardrail-rules-section.cjs +159 -0
  14. package/dist/canvas/components/Guardrails/guardrail-rules-section.d.ts +15 -0
  15. package/dist/canvas/components/Guardrails/guardrail-rules-section.d.ts.map +1 -0
  16. package/dist/canvas/components/Guardrails/guardrail-rules-section.js +125 -0
  17. package/dist/canvas/components/Guardrails/i18n.cjs +273 -3
  18. package/dist/canvas/components/Guardrails/i18n.d.ts +59 -0
  19. package/dist/canvas/components/Guardrails/i18n.d.ts.map +1 -1
  20. package/dist/canvas/components/Guardrails/i18n.js +248 -2
  21. package/dist/canvas/components/Guardrails/index.cjs +56 -4
  22. package/dist/canvas/components/Guardrails/index.d.ts +10 -2
  23. package/dist/canvas/components/Guardrails/index.d.ts.map +1 -1
  24. package/dist/canvas/components/Guardrails/index.js +6 -2
  25. package/dist/canvas/components/Guardrails/rules-types.cjs +61 -0
  26. package/dist/canvas/components/Guardrails/rules-types.d.ts +75 -0
  27. package/dist/canvas/components/Guardrails/rules-types.d.ts.map +1 -0
  28. package/dist/canvas/components/Guardrails/rules-types.js +27 -0
  29. package/dist/canvas/components/Guardrails/rules-utils.cjs +213 -0
  30. package/dist/canvas/components/Guardrails/rules-utils.d.ts +22 -0
  31. package/dist/canvas/components/Guardrails/rules-utils.d.ts.map +1 -0
  32. package/dist/canvas/components/Guardrails/rules-utils.js +140 -0
  33. package/dist/canvas/locales/en.cjs +1 -1
  34. package/dist/canvas/locales/en.d.ts.map +1 -1
  35. package/dist/canvas/locales/en.js +1 -1
  36. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  37. package/package.json +3 -3
@@ -0,0 +1,42 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { FormField, FormFieldError, FormFieldLabel } from "@uipath/apollo-wind";
3
+ import { useId } from "react";
4
+ import { GuardrailFieldPicker } from "./components/guardrail-field-picker.js";
5
+ import { useGuardrailFilterFieldSelectorLabels } from "./i18n.js";
6
+ import { toggleGuardrailFieldReference } from "./rules-utils.js";
7
+ function GuardrailFilterFieldSelector({ fields, value, onChange, error, selectionChips = false, labels: labelOverrides, className }) {
8
+ const labels = useGuardrailFilterFieldSelectorLabels(labelOverrides);
9
+ const uid = useId();
10
+ return /*#__PURE__*/ jsx("div", {
11
+ "data-slot": "guardrail-filter-field-selector",
12
+ className: className,
13
+ children: fields ? /*#__PURE__*/ jsx(GuardrailFieldPicker, {
14
+ id: `${uid}-fields`,
15
+ labelId: `${uid}-label`,
16
+ label: labels.filterFieldsLabel,
17
+ tooltip: labels.filterFieldsTooltip,
18
+ fields: fields,
19
+ selected: value,
20
+ onToggle: (field)=>onChange(toggleGuardrailFieldReference(value, field)),
21
+ chips: selectionChips,
22
+ error: error,
23
+ labels: labels
24
+ }) : /*#__PURE__*/ jsxs(FormField, {
25
+ children: [
26
+ /*#__PURE__*/ jsx(FormFieldLabel, {
27
+ id: `${uid}-label`,
28
+ required: true,
29
+ children: labels.filterFieldsLabel
30
+ }),
31
+ /*#__PURE__*/ jsx("p", {
32
+ className: "text-sm italic text-muted-foreground",
33
+ children: labels.filterNoSchema
34
+ }),
35
+ /*#__PURE__*/ jsx(FormFieldError, {
36
+ children: error
37
+ })
38
+ ]
39
+ })
40
+ });
41
+ }
42
+ export { GuardrailFilterFieldSelector };
@@ -0,0 +1,159 @@
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
+ GuardrailRulesSection: ()=>GuardrailRulesSection
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
31
+ const external_lucide_react_namespaceObject = require("lucide-react");
32
+ const external_react_namespaceObject = require("react");
33
+ const guardrail_rule_card_cjs_namespaceObject = require("./components/guardrail-rule-card.cjs");
34
+ const external_i18n_cjs_namespaceObject = require("./i18n.cjs");
35
+ const external_rules_utils_cjs_namespaceObject = require("./rules-utils.cjs");
36
+ const APPLY_TO_LABEL_KEYS = {
37
+ input: 'applyToInput',
38
+ output: 'applyToOutput',
39
+ inputAndOutput: 'applyToInputAndOutput'
40
+ };
41
+ function GuardrailRulesSection({ rules, onRulesChange, fields, onRequestAlwaysEnforce, renderFieldSelector, selectionChips = false, errors, labels: labelOverrides, className }) {
42
+ const labels = (0, external_i18n_cjs_namespaceObject.useGuardrailRulesLabels)(labelOverrides);
43
+ const uid = (0, external_react_namespaceObject.useId)();
44
+ const ruleTypes = (0, external_react_namespaceObject.useMemo)(()=>(0, external_rules_utils_cjs_namespaceObject.getGuardrailRuleTypeOptions)(fields), [
45
+ fields
46
+ ]);
47
+ const defaultType = ruleTypes[0] ?? 'word';
48
+ const enforced = (0, external_rules_utils_cjs_namespaceObject.isGuardrailAlwaysEnforced)(rules);
49
+ const alwaysRule = rules.find((rule)=>'always' === rule.$ruleType);
50
+ const handleAlwaysEnforceChange = (checked)=>{
51
+ const next = (0, external_rules_utils_cjs_namespaceObject.setGuardrailAlwaysEnforced)(rules, checked, defaultType);
52
+ const dropsEdits = checked && rules.some((rule)=>'always' !== rule.$ruleType && !(0, external_rules_utils_cjs_namespaceObject.isPristineGuardrailRule)(rule));
53
+ if (dropsEdits && onRequestAlwaysEnforce) onRequestAlwaysEnforce(next);
54
+ else onRulesChange(next);
55
+ };
56
+ const fieldRules = rules.flatMap((rule, index)=>'always' === rule.$ruleType ? [] : [
57
+ {
58
+ rule,
59
+ index
60
+ }
61
+ ]);
62
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
63
+ "data-slot": "guardrail-rules-section",
64
+ className: (0, apollo_wind_namespaceObject.cn)('@container space-y-3', className),
65
+ children: [
66
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
67
+ className: "flex items-center justify-between gap-3",
68
+ children: [
69
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.FormFieldLabel, {
70
+ htmlFor: `${uid}-always`,
71
+ tooltip: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
72
+ children: [
73
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
74
+ children: labels.alwaysEnforceEnabledHint
75
+ }),
76
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
77
+ className: "mt-1",
78
+ children: labels.alwaysEnforceDisabledHint
79
+ })
80
+ ]
81
+ }),
82
+ tooltipAriaLabel: labels.moreInformation,
83
+ children: labels.alwaysEnforceLabel
84
+ }),
85
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Switch, {
86
+ id: `${uid}-always`,
87
+ checked: enforced,
88
+ disabled: 0 === ruleTypes.length && enforced && 1 === rules.length,
89
+ onCheckedChange: handleAlwaysEnforceChange
90
+ })
91
+ ]
92
+ }),
93
+ alwaysRule && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.FormField, {
94
+ children: [
95
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.FormFieldLabel, {
96
+ htmlFor: `${uid}-apply-to`,
97
+ required: true,
98
+ children: labels.applyToLabel
99
+ }),
100
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Select, {
101
+ value: alwaysRule.applyTo,
102
+ onValueChange: (applyTo)=>onRulesChange(rules.map((rule)=>rule === alwaysRule ? {
103
+ ...alwaysRule,
104
+ applyTo: applyTo
105
+ } : rule)),
106
+ children: [
107
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.SelectTrigger, {
108
+ id: `${uid}-apply-to`,
109
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.SelectValue, {})
110
+ }),
111
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.SelectContent, {
112
+ children: Object.keys(APPLY_TO_LABEL_KEYS).map((applyTo)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.SelectItem, {
113
+ value: applyTo,
114
+ children: labels[APPLY_TO_LABEL_KEYS[applyTo]]
115
+ }, applyTo))
116
+ })
117
+ ]
118
+ })
119
+ ]
120
+ }),
121
+ fieldRules.map(({ rule, index }, i)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(guardrail_rule_card_cjs_namespaceObject.GuardrailRuleCard, {
122
+ index: index,
123
+ position: i + 1,
124
+ rule: rule,
125
+ ruleTypes: ruleTypes,
126
+ fields: (0, external_rules_utils_cjs_namespaceObject.getGuardrailFieldGroup)(fields, rule.$ruleType),
127
+ onChange: (next)=>onRulesChange(rules.map((current, j)=>j === index ? next : current)),
128
+ onDelete: ()=>onRulesChange(rules.filter((_, j)=>j !== index)),
129
+ errors: errors?.perRule?.[index],
130
+ renderFieldSelector: renderFieldSelector,
131
+ selectionChips: selectionChips,
132
+ labels: labels
133
+ }, index)),
134
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.FormFieldError, {
135
+ children: errors?.rules
136
+ }),
137
+ !enforced && ruleTypes.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
138
+ type: "button",
139
+ variant: "ghost",
140
+ size: "sm",
141
+ onClick: ()=>onRulesChange([
142
+ ...rules,
143
+ (0, external_rules_utils_cjs_namespaceObject.createGuardrailRule)(defaultType)
144
+ ]),
145
+ children: [
146
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {}),
147
+ labels.addRule
148
+ ]
149
+ })
150
+ ]
151
+ });
152
+ }
153
+ exports.GuardrailRulesSection = __webpack_exports__.GuardrailRulesSection;
154
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
155
+ "GuardrailRulesSection"
156
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
157
+ Object.defineProperty(exports, '__esModule', {
158
+ value: true
159
+ });
@@ -0,0 +1,15 @@
1
+ import { type GuardrailRulesLabels } from './i18n';
2
+ import type { GuardrailRule, GuardrailRuleFieldSelectorRenderer, GuardrailRuleFields, GuardrailRulesErrors } from './rules-types';
3
+ export interface GuardrailRulesSectionProps {
4
+ rules: readonly GuardrailRule[];
5
+ onRulesChange: (rules: GuardrailRule[]) => void;
6
+ fields?: GuardrailRuleFields;
7
+ onRequestAlwaysEnforce?: (rules: GuardrailRule[]) => void;
8
+ renderFieldSelector?: GuardrailRuleFieldSelectorRenderer;
9
+ selectionChips?: boolean;
10
+ errors?: GuardrailRulesErrors;
11
+ labels?: Partial<GuardrailRulesLabels>;
12
+ className?: string;
13
+ }
14
+ export declare function GuardrailRulesSection({ rules, onRulesChange, fields, onRequestAlwaysEnforce, renderFieldSelector, selectionChips, errors, labels: labelOverrides, className, }: GuardrailRulesSectionProps): import("react/jsx-runtime").JSX.Element;
15
+ //# sourceMappingURL=guardrail-rules-section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrail-rules-section.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Guardrails/guardrail-rules-section.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,QAAQ,CAAC;AAC5E,OAAO,KAAK,EAEV,aAAa,EAEb,kCAAkC,EAClC,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAUvB,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAEhC,aAAa,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IAMhD,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAM7B,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IAE1D,mBAAmB,CAAC,EAAE,kCAAkC,CAAC;IAKzD,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,aAAa,EACb,MAAM,EACN,sBAAsB,EACtB,mBAAmB,EACnB,cAAsB,EACtB,MAAM,EACN,MAAM,EAAE,cAAc,EACtB,SAAS,GACV,EAAE,0BAA0B,2CAqH5B"}
@@ -0,0 +1,125 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button, FormField, FormFieldError, FormFieldLabel, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, cn } from "@uipath/apollo-wind";
3
+ import { Plus } from "lucide-react";
4
+ import { useId, useMemo } from "react";
5
+ import { GuardrailRuleCard } from "./components/guardrail-rule-card.js";
6
+ import { useGuardrailRulesLabels } from "./i18n.js";
7
+ import { createGuardrailRule, getGuardrailFieldGroup, getGuardrailRuleTypeOptions, isGuardrailAlwaysEnforced, isPristineGuardrailRule, setGuardrailAlwaysEnforced } from "./rules-utils.js";
8
+ const APPLY_TO_LABEL_KEYS = {
9
+ input: 'applyToInput',
10
+ output: 'applyToOutput',
11
+ inputAndOutput: 'applyToInputAndOutput'
12
+ };
13
+ function GuardrailRulesSection({ rules, onRulesChange, fields, onRequestAlwaysEnforce, renderFieldSelector, selectionChips = false, errors, labels: labelOverrides, className }) {
14
+ const labels = useGuardrailRulesLabels(labelOverrides);
15
+ const uid = useId();
16
+ const ruleTypes = useMemo(()=>getGuardrailRuleTypeOptions(fields), [
17
+ fields
18
+ ]);
19
+ const defaultType = ruleTypes[0] ?? 'word';
20
+ const enforced = isGuardrailAlwaysEnforced(rules);
21
+ const alwaysRule = rules.find((rule)=>'always' === rule.$ruleType);
22
+ const handleAlwaysEnforceChange = (checked)=>{
23
+ const next = setGuardrailAlwaysEnforced(rules, checked, defaultType);
24
+ const dropsEdits = checked && rules.some((rule)=>'always' !== rule.$ruleType && !isPristineGuardrailRule(rule));
25
+ if (dropsEdits && onRequestAlwaysEnforce) onRequestAlwaysEnforce(next);
26
+ else onRulesChange(next);
27
+ };
28
+ const fieldRules = rules.flatMap((rule, index)=>'always' === rule.$ruleType ? [] : [
29
+ {
30
+ rule,
31
+ index
32
+ }
33
+ ]);
34
+ return /*#__PURE__*/ jsxs("div", {
35
+ "data-slot": "guardrail-rules-section",
36
+ className: cn('@container space-y-3', className),
37
+ children: [
38
+ /*#__PURE__*/ jsxs("div", {
39
+ className: "flex items-center justify-between gap-3",
40
+ children: [
41
+ /*#__PURE__*/ jsx(FormFieldLabel, {
42
+ htmlFor: `${uid}-always`,
43
+ tooltip: /*#__PURE__*/ jsxs(Fragment, {
44
+ children: [
45
+ /*#__PURE__*/ jsx("p", {
46
+ children: labels.alwaysEnforceEnabledHint
47
+ }),
48
+ /*#__PURE__*/ jsx("p", {
49
+ className: "mt-1",
50
+ children: labels.alwaysEnforceDisabledHint
51
+ })
52
+ ]
53
+ }),
54
+ tooltipAriaLabel: labels.moreInformation,
55
+ children: labels.alwaysEnforceLabel
56
+ }),
57
+ /*#__PURE__*/ jsx(Switch, {
58
+ id: `${uid}-always`,
59
+ checked: enforced,
60
+ disabled: 0 === ruleTypes.length && enforced && 1 === rules.length,
61
+ onCheckedChange: handleAlwaysEnforceChange
62
+ })
63
+ ]
64
+ }),
65
+ alwaysRule && /*#__PURE__*/ jsxs(FormField, {
66
+ children: [
67
+ /*#__PURE__*/ jsx(FormFieldLabel, {
68
+ htmlFor: `${uid}-apply-to`,
69
+ required: true,
70
+ children: labels.applyToLabel
71
+ }),
72
+ /*#__PURE__*/ jsxs(Select, {
73
+ value: alwaysRule.applyTo,
74
+ onValueChange: (applyTo)=>onRulesChange(rules.map((rule)=>rule === alwaysRule ? {
75
+ ...alwaysRule,
76
+ applyTo: applyTo
77
+ } : rule)),
78
+ children: [
79
+ /*#__PURE__*/ jsx(SelectTrigger, {
80
+ id: `${uid}-apply-to`,
81
+ children: /*#__PURE__*/ jsx(SelectValue, {})
82
+ }),
83
+ /*#__PURE__*/ jsx(SelectContent, {
84
+ children: Object.keys(APPLY_TO_LABEL_KEYS).map((applyTo)=>/*#__PURE__*/ jsx(SelectItem, {
85
+ value: applyTo,
86
+ children: labels[APPLY_TO_LABEL_KEYS[applyTo]]
87
+ }, applyTo))
88
+ })
89
+ ]
90
+ })
91
+ ]
92
+ }),
93
+ fieldRules.map(({ rule, index }, i)=>/*#__PURE__*/ jsx(GuardrailRuleCard, {
94
+ index: index,
95
+ position: i + 1,
96
+ rule: rule,
97
+ ruleTypes: ruleTypes,
98
+ fields: getGuardrailFieldGroup(fields, rule.$ruleType),
99
+ onChange: (next)=>onRulesChange(rules.map((current, j)=>j === index ? next : current)),
100
+ onDelete: ()=>onRulesChange(rules.filter((_, j)=>j !== index)),
101
+ errors: errors?.perRule?.[index],
102
+ renderFieldSelector: renderFieldSelector,
103
+ selectionChips: selectionChips,
104
+ labels: labels
105
+ }, index)),
106
+ /*#__PURE__*/ jsx(FormFieldError, {
107
+ children: errors?.rules
108
+ }),
109
+ !enforced && ruleTypes.length > 0 && /*#__PURE__*/ jsxs(Button, {
110
+ type: "button",
111
+ variant: "ghost",
112
+ size: "sm",
113
+ onClick: ()=>onRulesChange([
114
+ ...rules,
115
+ createGuardrailRule(defaultType)
116
+ ]),
117
+ children: [
118
+ /*#__PURE__*/ jsx(Plus, {}),
119
+ labels.addRule
120
+ ]
121
+ })
122
+ ]
123
+ });
124
+ }
125
+ export { GuardrailRulesSection };