@uipath/apollo-wind 2.75.1 → 2.76.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-actions.cjs +53 -12
- package/dist/components/forms/field-actions.d.ts +47 -10
- package/dist/components/forms/field-actions.js +50 -12
- package/dist/components/forms/index.cjs +4 -0
- package/dist/components/forms/index.d.ts +2 -1
- package/dist/components/forms/index.js +2 -1
- package/dist/components/forms/variable-mode-control.cjs +65 -0
- package/dist/components/forms/variable-mode-control.d.ts +20 -0
- package/dist/components/forms/variable-mode-control.js +31 -0
- package/dist/components/ui/field-actions/ai-assist-action.cjs +57 -47
- package/dist/components/ui/field-actions/ai-assist-action.d.ts +14 -2
- package/dist/components/ui/field-actions/ai-assist-action.js +59 -49
- package/dist/components/ui/field-actions/index.d.ts +1 -1
- package/dist/components/ui/field-actions/insert-variable-action.cjs +5 -3
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +20 -10
- package/dist/components/ui/field-actions/insert-variable-action.js +5 -3
- package/dist/components/ui/form-field.cjs +3 -2
- package/dist/components/ui/form-field.d.ts +11 -3
- package/dist/components/ui/form-field.js +3 -2
- package/dist/components/ui/index.cjs +16 -16
- package/dist/components/ui/reference-chip.cjs +1 -1
- package/dist/components/ui/reference-chip.d.ts +1 -1
- package/dist/components/ui/reference-chip.js +1 -1
- package/dist/components/ui/variable-picker/index.d.ts +1 -1
- package/dist/components/ui/variable-picker/variable-picker.cjs +17 -3
- package/dist/components/ui/variable-picker/variable-picker.d.ts +24 -1
- package/dist/components/ui/variable-picker/variable-picker.js +14 -3
- package/dist/components/ui/variable-value-control.cjs +23 -7
- package/dist/components/ui/variable-value-control.d.ts +27 -5
- package/dist/components/ui/variable-value-control.js +23 -7
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -1
- package/dist/styles.css +6 -0
- package/package.json +1 -1
|
@@ -24,11 +24,12 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
createClearAction: ()=>createClearAction,
|
|
28
27
|
resolveVariables: ()=>resolveVariables,
|
|
29
28
|
createInsertVariableAction: ()=>createInsertVariableAction,
|
|
30
29
|
resolveFieldActions: ()=>resolveFieldActions,
|
|
31
30
|
DEFAULT_FIELD_ACTION_REGISTRY: ()=>DEFAULT_FIELD_ACTION_REGISTRY,
|
|
31
|
+
createClearAction: ()=>createClearAction,
|
|
32
|
+
bindVariablePicker: ()=>bindVariablePicker,
|
|
32
33
|
buildFieldActionRegistry: ()=>buildFieldActionRegistry,
|
|
33
34
|
createAiAssistAction: ()=>createAiAssistAction
|
|
34
35
|
});
|
|
@@ -36,6 +37,20 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
|
36
37
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
37
38
|
const ai_assist_action_cjs_namespaceObject = require("../ui/field-actions/ai-assist-action.cjs");
|
|
38
39
|
const insert_variable_action_cjs_namespaceObject = require("../ui/field-actions/insert-variable-action.cjs");
|
|
40
|
+
function bindVariablePicker(picker) {
|
|
41
|
+
const bound = new WeakMap();
|
|
42
|
+
return (field)=>{
|
|
43
|
+
let render = bound.get(field);
|
|
44
|
+
if (!render) {
|
|
45
|
+
render = (props)=>picker({
|
|
46
|
+
...props,
|
|
47
|
+
field
|
|
48
|
+
});
|
|
49
|
+
bound.set(field, render);
|
|
50
|
+
}
|
|
51
|
+
return render;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
39
54
|
function resolveVariables(source, field) {
|
|
40
55
|
if (!source) return [];
|
|
41
56
|
return 'function' == typeof source ? source({
|
|
@@ -74,7 +89,8 @@ function insertTarget(ctx, formatReference, text) {
|
|
|
74
89
|
confirm
|
|
75
90
|
});
|
|
76
91
|
}
|
|
77
|
-
function createInsertVariableAction({ variables, formatReference, strings, id = 'insert-variable' }) {
|
|
92
|
+
function createInsertVariableAction({ variables, renderPicker, formatReference, strings, id = 'insert-variable' }) {
|
|
93
|
+
const pickerFor = renderPicker && bindVariablePicker(renderPicker);
|
|
78
94
|
return {
|
|
79
95
|
id,
|
|
80
96
|
render: (ctx)=>{
|
|
@@ -84,30 +100,53 @@ function createInsertVariableAction({ variables, formatReference, strings, id =
|
|
|
84
100
|
...strings
|
|
85
101
|
};
|
|
86
102
|
const insert = insertTarget(ctx, formatReference, text);
|
|
103
|
+
const onInsert = insert && ((reference)=>insertTarget(ctx, formatReference, text)?.(reference));
|
|
104
|
+
if (pickerFor) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(insert_variable_action_cjs_namespaceObject.InsertVariableAction, {
|
|
105
|
+
renderPicker: pickerFor(ctx.field),
|
|
106
|
+
onInsert: onInsert,
|
|
107
|
+
disabled: ctx.disabled,
|
|
108
|
+
strings: text
|
|
109
|
+
});
|
|
87
110
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(insert_variable_action_cjs_namespaceObject.InsertVariableAction, {
|
|
88
111
|
variables: Array.isArray(variables) ? variables : ()=>variables ? resolveVariables(variables, ctx.field) : ctx.variables(),
|
|
89
|
-
onInsert:
|
|
112
|
+
onInsert: onInsert,
|
|
90
113
|
disabled: ctx.disabled,
|
|
91
114
|
strings: text
|
|
92
115
|
});
|
|
93
116
|
}
|
|
94
117
|
};
|
|
95
118
|
}
|
|
96
|
-
function
|
|
119
|
+
function writeResult(ctx, result) {
|
|
120
|
+
if (!result || ctx.disabled) return;
|
|
121
|
+
const mode = result.mode ?? ctx.mode?.mode;
|
|
122
|
+
if (ctx.setModeValue && mode) ctx.setModeValue(mode, result.value);
|
|
123
|
+
else ctx.setValue(result.value);
|
|
124
|
+
}
|
|
125
|
+
function createAiAssistAction({ generate, renderContent, hint, placeholder, strings, id = 'ai-assist' }) {
|
|
97
126
|
return {
|
|
98
127
|
id,
|
|
99
128
|
render: (ctx)=>{
|
|
129
|
+
if (renderContent) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ai_assist_action_cjs_namespaceObject.AiAssistAction, {
|
|
130
|
+
renderContent: ({ close, disabled })=>renderContent({
|
|
131
|
+
close,
|
|
132
|
+
disabled,
|
|
133
|
+
apply: (result)=>{
|
|
134
|
+
writeResult(ctx, result);
|
|
135
|
+
close();
|
|
136
|
+
},
|
|
137
|
+
ctx
|
|
138
|
+
}),
|
|
139
|
+
disabled: ctx.disabled,
|
|
140
|
+
strings: {
|
|
141
|
+
...ctx.strings.aiAssist,
|
|
142
|
+
...strings
|
|
143
|
+
}
|
|
144
|
+
});
|
|
100
145
|
const promptPlaceholder = 'function' == typeof placeholder ? placeholder(ctx) : placeholder;
|
|
101
146
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ai_assist_action_cjs_namespaceObject.AiAssistAction, {
|
|
102
|
-
onGenerate: async (prompt)=>{
|
|
103
|
-
const result = await generate({
|
|
147
|
+
onGenerate: async (prompt)=>writeResult(ctx, await generate({
|
|
104
148
|
prompt
|
|
105
|
-
}, ctx)
|
|
106
|
-
if (!result || ctx.disabled) return;
|
|
107
|
-
const mode = result.mode ?? ctx.mode?.mode;
|
|
108
|
-
if (ctx.setModeValue && mode) ctx.setModeValue(mode, result.value);
|
|
109
|
-
else ctx.setValue(result.value);
|
|
110
|
-
},
|
|
149
|
+
}, ctx)),
|
|
111
150
|
hint: 'function' == typeof hint ? hint(ctx) : hint,
|
|
112
151
|
disabled: ctx.disabled,
|
|
113
152
|
strings: {
|
|
@@ -161,6 +200,7 @@ function resolveFieldActions(field, registry) {
|
|
|
161
200
|
};
|
|
162
201
|
}
|
|
163
202
|
exports.DEFAULT_FIELD_ACTION_REGISTRY = __webpack_exports__.DEFAULT_FIELD_ACTION_REGISTRY;
|
|
203
|
+
exports.bindVariablePicker = __webpack_exports__.bindVariablePicker;
|
|
164
204
|
exports.buildFieldActionRegistry = __webpack_exports__.buildFieldActionRegistry;
|
|
165
205
|
exports.createAiAssistAction = __webpack_exports__.createAiAssistAction;
|
|
166
206
|
exports.createClearAction = __webpack_exports__.createClearAction;
|
|
@@ -169,6 +209,7 @@ exports.resolveFieldActions = __webpack_exports__.resolveFieldActions;
|
|
|
169
209
|
exports.resolveVariables = __webpack_exports__.resolveVariables;
|
|
170
210
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
171
211
|
"DEFAULT_FIELD_ACTION_REGISTRY",
|
|
212
|
+
"bindVariablePicker",
|
|
172
213
|
"buildFieldActionRegistry",
|
|
173
214
|
"createAiAssistAction",
|
|
174
215
|
"createClearAction",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type LucideIcon } from 'lucide-react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import type { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
4
|
-
import { type AiAssistActionStrings } from '../ui/field-actions/ai-assist-action';
|
|
4
|
+
import { type AiAssistActionStrings, type AiAssistContentProps } from '../ui/field-actions/ai-assist-action';
|
|
5
5
|
import { type InsertVariableActionStrings } from '../ui/field-actions/insert-variable-action';
|
|
6
|
-
import type { VariablePickerItem } from '../ui/variable-picker';
|
|
6
|
+
import type { RenderVariablePicker, VariablePickerItem, VariablePickerSlotProps } from '../ui/variable-picker';
|
|
7
7
|
import type { FieldMetadata, FormPlugin, FormVariables, ValueModeId } from './form-schema';
|
|
8
8
|
import type { ClearActionStrings, MetadataFormStrings } from './form-strings';
|
|
9
9
|
import type { DecodedValue, ValueModeControlHandle } from './value-modes';
|
|
@@ -62,6 +62,15 @@ export interface FieldMenuAction {
|
|
|
62
62
|
}
|
|
63
63
|
/** A variable Insert variable offers, rendered as supplied. */
|
|
64
64
|
export type ValueModeVariable = VariablePickerItem;
|
|
65
|
+
/**
|
|
66
|
+
* A host's own variable picker for a form field, rendered in place of the built-in tree. Called
|
|
67
|
+
* only while the picker is open, with the field it picks for.
|
|
68
|
+
*/
|
|
69
|
+
export type FormVariablePicker = (props: VariablePickerSlotProps & {
|
|
70
|
+
field: FieldMetadata;
|
|
71
|
+
}) => React.ReactNode;
|
|
72
|
+
/** Binds `picker` to each field once, so the action's props stay stable across renders. */
|
|
73
|
+
export declare function bindVariablePicker(picker: FormVariablePicker): (field: FieldMetadata) => RenderVariablePicker;
|
|
65
74
|
/** `source` for `field`: a function is called now, so only call this when a picker opens. */
|
|
66
75
|
export declare function resolveVariables(source: FormVariables | undefined, field: FieldMetadata): ValueModeVariable[];
|
|
67
76
|
/**
|
|
@@ -70,10 +79,7 @@ export declare function resolveVariables(source: FormVariables | undefined, fiel
|
|
|
70
79
|
*/
|
|
71
80
|
export type FieldActionGenerate = (request: {
|
|
72
81
|
prompt: string;
|
|
73
|
-
}, ctx: FieldActionContext) => Promise<
|
|
74
|
-
mode?: ValueModeId;
|
|
75
|
-
value: unknown;
|
|
76
|
-
} | undefined | void>;
|
|
82
|
+
}, ctx: FieldActionContext) => Promise<FieldActionResult | undefined | void>;
|
|
77
83
|
export interface FieldActionsPluginConfig {
|
|
78
84
|
/** Header actions by id, in the order fields list them. */
|
|
79
85
|
header?: Record<string, FieldHeaderAction>;
|
|
@@ -88,6 +94,11 @@ export interface FieldActionRegistry {
|
|
|
88
94
|
export interface InsertVariableActionOptions {
|
|
89
95
|
/** Defaults to the form's `FormPlugin.variables`. */
|
|
90
96
|
variables?: FormVariables;
|
|
97
|
+
/**
|
|
98
|
+
* The host's own picker, rendered in place of a picker over `variables`, which it wins over. Its
|
|
99
|
+
* pick is written like a picked variable: at the caret, or as the value once confirmed.
|
|
100
|
+
*/
|
|
101
|
+
renderPicker?: FormVariablePicker;
|
|
91
102
|
/**
|
|
92
103
|
* How a picked reference is written at the caret, such as `{{ ref }}` inside fixed-value text.
|
|
93
104
|
* A field that switches to `expression` or `variable` to take the reference gets it as picked.
|
|
@@ -101,9 +112,23 @@ export interface InsertVariableActionOptions {
|
|
|
101
112
|
id?: string;
|
|
102
113
|
}
|
|
103
114
|
/** Insert variable: a variable picker behind the label that writes the picked reference. */
|
|
104
|
-
export declare function createInsertVariableAction({ variables, formatReference, strings, id, }: InsertVariableActionOptions): FieldHeaderAction;
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
export declare function createInsertVariableAction({ variables, renderPicker, formatReference, strings, id, }: InsertVariableActionOptions): FieldHeaderAction;
|
|
116
|
+
/** A generated or host-produced value: in `mode`, or else the mode the field is in when written. */
|
|
117
|
+
export interface FieldActionResult {
|
|
118
|
+
mode?: ValueModeId;
|
|
119
|
+
value: unknown;
|
|
120
|
+
}
|
|
121
|
+
/** What a host-rendered AI-assist panel gets inside a form. */
|
|
122
|
+
export interface AiAssistFieldContentProps extends AiAssistContentProps {
|
|
123
|
+
/**
|
|
124
|
+
* Writes `result` and closes the popover. Nothing is written if the field was disabled
|
|
125
|
+
* meanwhile.
|
|
126
|
+
*/
|
|
127
|
+
apply(result: FieldActionResult): void;
|
|
128
|
+
/** The field the panel generates for, read when accessed. */
|
|
129
|
+
ctx: FieldActionContext;
|
|
130
|
+
}
|
|
131
|
+
interface AiAssistActionBaseOptions {
|
|
107
132
|
/** Guidance under the prompt, such as the value type expected. */
|
|
108
133
|
hint?: React.ReactNode | ((ctx: FieldActionContext) => React.ReactNode);
|
|
109
134
|
/** The prompt's placeholder, such as an example request for this field. */
|
|
@@ -112,8 +137,19 @@ export interface AiAssistActionOptions {
|
|
|
112
137
|
/** Defaults to `ai-assist`. */
|
|
113
138
|
id?: string;
|
|
114
139
|
}
|
|
140
|
+
export type AiAssistActionOptions = AiAssistActionBaseOptions & ({
|
|
141
|
+
generate: FieldActionGenerate;
|
|
142
|
+
renderContent?: undefined;
|
|
143
|
+
} | {
|
|
144
|
+
generate?: undefined;
|
|
145
|
+
/**
|
|
146
|
+
* The host's own panel, in place of the built-in prompt form, whose `hint` and
|
|
147
|
+
* `placeholder` it then does not use. Called only while the popover is open.
|
|
148
|
+
*/
|
|
149
|
+
renderContent: (props: AiAssistFieldContentProps) => React.ReactNode;
|
|
150
|
+
});
|
|
115
151
|
/** AI assist: a prompt behind the label whose generated value is written to the field. */
|
|
116
|
-
export declare function createAiAssistAction({ generate, hint, placeholder, strings, id, }: AiAssistActionOptions): FieldHeaderAction;
|
|
152
|
+
export declare function createAiAssistAction({ generate, renderContent, hint, placeholder, strings, id, }: AiAssistActionOptions): FieldHeaderAction;
|
|
117
153
|
export interface ClearActionOptions {
|
|
118
154
|
strings?: Partial<ClearActionStrings>;
|
|
119
155
|
/** Defaults to `clear`. */
|
|
@@ -129,3 +165,4 @@ export declare function resolveFieldActions(field: FieldMetadata, registry: Fiel
|
|
|
129
165
|
header: FieldHeaderAction[];
|
|
130
166
|
menu: FieldMenuAction[];
|
|
131
167
|
};
|
|
168
|
+
export {};
|
|
@@ -2,6 +2,20 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Eraser } from "lucide-react";
|
|
3
3
|
import { AiAssistAction } from "../ui/field-actions/ai-assist-action.js";
|
|
4
4
|
import { InsertVariableAction } from "../ui/field-actions/insert-variable-action.js";
|
|
5
|
+
function bindVariablePicker(picker) {
|
|
6
|
+
const bound = new WeakMap();
|
|
7
|
+
return (field)=>{
|
|
8
|
+
let render = bound.get(field);
|
|
9
|
+
if (!render) {
|
|
10
|
+
render = (props)=>picker({
|
|
11
|
+
...props,
|
|
12
|
+
field
|
|
13
|
+
});
|
|
14
|
+
bound.set(field, render);
|
|
15
|
+
}
|
|
16
|
+
return render;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
5
19
|
function resolveVariables(source, field) {
|
|
6
20
|
if (!source) return [];
|
|
7
21
|
return 'function' == typeof source ? source({
|
|
@@ -40,7 +54,8 @@ function insertTarget(ctx, formatReference, text) {
|
|
|
40
54
|
confirm
|
|
41
55
|
});
|
|
42
56
|
}
|
|
43
|
-
function createInsertVariableAction({ variables, formatReference, strings, id = 'insert-variable' }) {
|
|
57
|
+
function createInsertVariableAction({ variables, renderPicker, formatReference, strings, id = 'insert-variable' }) {
|
|
58
|
+
const pickerFor = renderPicker && bindVariablePicker(renderPicker);
|
|
44
59
|
return {
|
|
45
60
|
id,
|
|
46
61
|
render: (ctx)=>{
|
|
@@ -50,30 +65,53 @@ function createInsertVariableAction({ variables, formatReference, strings, id =
|
|
|
50
65
|
...strings
|
|
51
66
|
};
|
|
52
67
|
const insert = insertTarget(ctx, formatReference, text);
|
|
68
|
+
const onInsert = insert && ((reference)=>insertTarget(ctx, formatReference, text)?.(reference));
|
|
69
|
+
if (pickerFor) return /*#__PURE__*/ jsx(InsertVariableAction, {
|
|
70
|
+
renderPicker: pickerFor(ctx.field),
|
|
71
|
+
onInsert: onInsert,
|
|
72
|
+
disabled: ctx.disabled,
|
|
73
|
+
strings: text
|
|
74
|
+
});
|
|
53
75
|
return /*#__PURE__*/ jsx(InsertVariableAction, {
|
|
54
76
|
variables: Array.isArray(variables) ? variables : ()=>variables ? resolveVariables(variables, ctx.field) : ctx.variables(),
|
|
55
|
-
onInsert:
|
|
77
|
+
onInsert: onInsert,
|
|
56
78
|
disabled: ctx.disabled,
|
|
57
79
|
strings: text
|
|
58
80
|
});
|
|
59
81
|
}
|
|
60
82
|
};
|
|
61
83
|
}
|
|
62
|
-
function
|
|
84
|
+
function writeResult(ctx, result) {
|
|
85
|
+
if (!result || ctx.disabled) return;
|
|
86
|
+
const mode = result.mode ?? ctx.mode?.mode;
|
|
87
|
+
if (ctx.setModeValue && mode) ctx.setModeValue(mode, result.value);
|
|
88
|
+
else ctx.setValue(result.value);
|
|
89
|
+
}
|
|
90
|
+
function createAiAssistAction({ generate, renderContent, hint, placeholder, strings, id = 'ai-assist' }) {
|
|
63
91
|
return {
|
|
64
92
|
id,
|
|
65
93
|
render: (ctx)=>{
|
|
94
|
+
if (renderContent) return /*#__PURE__*/ jsx(AiAssistAction, {
|
|
95
|
+
renderContent: ({ close, disabled })=>renderContent({
|
|
96
|
+
close,
|
|
97
|
+
disabled,
|
|
98
|
+
apply: (result)=>{
|
|
99
|
+
writeResult(ctx, result);
|
|
100
|
+
close();
|
|
101
|
+
},
|
|
102
|
+
ctx
|
|
103
|
+
}),
|
|
104
|
+
disabled: ctx.disabled,
|
|
105
|
+
strings: {
|
|
106
|
+
...ctx.strings.aiAssist,
|
|
107
|
+
...strings
|
|
108
|
+
}
|
|
109
|
+
});
|
|
66
110
|
const promptPlaceholder = 'function' == typeof placeholder ? placeholder(ctx) : placeholder;
|
|
67
111
|
return /*#__PURE__*/ jsx(AiAssistAction, {
|
|
68
|
-
onGenerate: async (prompt)=>{
|
|
69
|
-
const result = await generate({
|
|
112
|
+
onGenerate: async (prompt)=>writeResult(ctx, await generate({
|
|
70
113
|
prompt
|
|
71
|
-
}, ctx)
|
|
72
|
-
if (!result || ctx.disabled) return;
|
|
73
|
-
const mode = result.mode ?? ctx.mode?.mode;
|
|
74
|
-
if (ctx.setModeValue && mode) ctx.setModeValue(mode, result.value);
|
|
75
|
-
else ctx.setValue(result.value);
|
|
76
|
-
},
|
|
114
|
+
}, ctx)),
|
|
77
115
|
hint: 'function' == typeof hint ? hint(ctx) : hint,
|
|
78
116
|
disabled: ctx.disabled,
|
|
79
117
|
strings: {
|
|
@@ -126,4 +164,4 @@ function resolveFieldActions(field, registry) {
|
|
|
126
164
|
menu: pick(field.menuActions, registry.menu)
|
|
127
165
|
};
|
|
128
166
|
}
|
|
129
|
-
export { DEFAULT_FIELD_ACTION_REGISTRY, buildFieldActionRegistry, createAiAssistAction, createClearAction, createInsertVariableAction, resolveFieldActions, resolveVariables };
|
|
167
|
+
export { DEFAULT_FIELD_ACTION_REGISTRY, bindVariablePicker, buildFieldActionRegistry, createAiAssistAction, createClearAction, createInsertVariableAction, resolveFieldActions, resolveVariables };
|
|
@@ -52,6 +52,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
52
52
|
DataFetcher: ()=>external_data_fetcher_cjs_namespaceObject.DataFetcher,
|
|
53
53
|
DataTransformers: ()=>external_data_fetcher_cjs_namespaceObject.DataTransformers,
|
|
54
54
|
createAiAssistAction: ()=>external_field_actions_cjs_namespaceObject.createAiAssistAction,
|
|
55
|
+
createVariableModeControl: ()=>external_variable_mode_control_cjs_namespaceObject.createVariableModeControl,
|
|
55
56
|
RulesEngine: ()=>external_rules_engine_cjs_namespaceObject.RulesEngine,
|
|
56
57
|
RuleBuilder: ()=>external_rules_engine_cjs_namespaceObject.RuleBuilder,
|
|
57
58
|
DataSourceBuilder: ()=>external_data_fetcher_cjs_namespaceObject.DataSourceBuilder,
|
|
@@ -76,6 +77,7 @@ const external_mode_aware_field_cjs_namespaceObject = require("./mode-aware-fiel
|
|
|
76
77
|
const external_rules_engine_cjs_namespaceObject = require("./rules-engine.cjs");
|
|
77
78
|
const external_string_list_field_cjs_namespaceObject = require("./string-list-field.cjs");
|
|
78
79
|
const external_value_modes_cjs_namespaceObject = require("./value-modes.cjs");
|
|
80
|
+
const external_variable_mode_control_cjs_namespaceObject = require("./variable-mode-control.cjs");
|
|
79
81
|
exports.DEFAULT_METADATA_FORM_STRINGS = __webpack_exports__.DEFAULT_METADATA_FORM_STRINGS;
|
|
80
82
|
exports.DataFetcher = __webpack_exports__.DataFetcher;
|
|
81
83
|
exports.DataSourceBuilder = __webpack_exports__.DataSourceBuilder;
|
|
@@ -99,6 +101,7 @@ exports.autoSavePlugin = __webpack_exports__.autoSavePlugin;
|
|
|
99
101
|
exports.createAiAssistAction = __webpack_exports__.createAiAssistAction;
|
|
100
102
|
exports.createClearAction = __webpack_exports__.createClearAction;
|
|
101
103
|
exports.createInsertVariableAction = __webpack_exports__.createInsertVariableAction;
|
|
104
|
+
exports.createVariableModeControl = __webpack_exports__.createVariableModeControl;
|
|
102
105
|
exports.envelopeCodec = __webpack_exports__.envelopeCodec;
|
|
103
106
|
exports.formatTemplate = __webpack_exports__.formatTemplate;
|
|
104
107
|
exports.formattingPlugin = __webpack_exports__.formattingPlugin;
|
|
@@ -137,6 +140,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
137
140
|
"createAiAssistAction",
|
|
138
141
|
"createClearAction",
|
|
139
142
|
"createInsertVariableAction",
|
|
143
|
+
"createVariableModeControl",
|
|
140
144
|
"envelopeCodec",
|
|
141
145
|
"formatTemplate",
|
|
142
146
|
"formattingPlugin",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Enterprise-grade metadata-driven form system
|
|
4
4
|
*/
|
|
5
5
|
export { type AdapterRequest, type AdapterResponse, type DataAdapter, DataFetcher, DataSourceBuilder, DataTransformers, FetchAdapter, } from './data-fetcher';
|
|
6
|
-
export { type AiAssistActionOptions, type ClearActionOptions, createAiAssistAction, createClearAction, createInsertVariableAction, type FieldActionContext, type FieldActionGenerate, type FieldActionRegistry, type FieldActionsPluginConfig, type FieldHeaderAction, type FieldMenuAction, type InsertVariableActionOptions, resolveVariables, type ValueModeVariable, } from './field-actions';
|
|
6
|
+
export { type AiAssistActionOptions, type AiAssistFieldContentProps, type ClearActionOptions, createAiAssistAction, createClearAction, createInsertVariableAction, type FieldActionContext, type FieldActionGenerate, type FieldActionRegistry, type FieldActionResult, type FieldActionsPluginConfig, type FieldHeaderAction, type FieldMenuAction, type FormVariablePicker, type InsertVariableActionOptions, resolveVariables, type ValueModeVariable, } from './field-actions';
|
|
7
7
|
export { FIELD_CONTROL_GEOMETRY, FieldControl, type FieldControlFormField, type FieldControlGeometry, type FieldControlLabelTarget, type FieldControlProps, } from './field-control';
|
|
8
8
|
export { FormFieldRenderer } from './field-renderer';
|
|
9
9
|
export { FormDesigner } from './form-designer';
|
|
@@ -17,3 +17,4 @@ export { ModeAwareField, type ModeAwareFieldProps, } from './mode-aware-field';
|
|
|
17
17
|
export { ExpressionBuilder, RuleBuilder, RulesEngine } from './rules-engine';
|
|
18
18
|
export { formatTemplate, StringListField, type StringListFieldProps } from './string-list-field';
|
|
19
19
|
export { type CodecContext, type ConvertResult, type DecodedValue, envelopeCodec, type FieldControlRegistration, isEmptyModeValue, isValueModeEnvelope, literalValues, VALUE_MODE_OPAQUE, type ValueModeCodec, type ValueModeControlHandle, type ValueModeControlProps, type ValueModeControlRegistration, type ValueModeDefinition, type ValueModeEnvelope, type ValueModeRegistry, type ValueModesPluginConfig, } from './value-modes';
|
|
20
|
+
export { createVariableModeControl, type VariableModeControlOptions, } from './variable-mode-control';
|
|
@@ -12,4 +12,5 @@ import { ModeAwareField } from "./mode-aware-field.js";
|
|
|
12
12
|
import { ExpressionBuilder, RuleBuilder, RulesEngine } from "./rules-engine.js";
|
|
13
13
|
import { StringListField, formatTemplate } from "./string-list-field.js";
|
|
14
14
|
import { VALUE_MODE_OPAQUE, envelopeCodec, isEmptyModeValue, isValueModeEnvelope, literalValues } from "./value-modes.js";
|
|
15
|
-
|
|
15
|
+
import { createVariableModeControl } from "./variable-mode-control.js";
|
|
16
|
+
export { DEFAULT_METADATA_FORM_STRINGS, DataFetcher, DataSourceBuilder, DataTransformers, ExpressionBuilder, FIELD_CONTROL_GEOMETRY, FetchAdapter, FieldControl, FormDesigner, FormFieldRenderer, FormStateViewer, MetadataForm, ModeAwareField, RuleBuilder, RulesEngine, StringListField, VALUE_MODE_OPAQUE, analyticsPlugin, auditPlugin, autoSavePlugin, createAiAssistAction, createClearAction, createInsertVariableAction, createVariableModeControl, envelopeCodec, formatTemplate, formattingPlugin, hasMinMaxStep, hasOptions, isCustomField, isEmptyModeValue, isFileField, isValueModeEnvelope, literalValues, resolveVariables, useWatch, validationPlugin, workflowPlugin };
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
createVariableModeControl: ()=>createVariableModeControl
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const variable_value_control_cjs_namespaceObject = require("../ui/variable-value-control.cjs");
|
|
31
|
+
const external_field_actions_cjs_namespaceObject = require("./field-actions.cjs");
|
|
32
|
+
const Control = variable_value_control_cjs_namespaceObject.VariableValueControl;
|
|
33
|
+
function createVariableModeControl({ renderPicker, describeReference }) {
|
|
34
|
+
const pickerFor = renderPicker && (0, external_field_actions_cjs_namespaceObject.bindVariablePicker)(renderPicker);
|
|
35
|
+
const described = new WeakMap();
|
|
36
|
+
const describerFor = (field)=>{
|
|
37
|
+
if (!describeReference) return;
|
|
38
|
+
let describe = described.get(field);
|
|
39
|
+
if (!describe) {
|
|
40
|
+
describe = (reference)=>describeReference(reference, {
|
|
41
|
+
field
|
|
42
|
+
});
|
|
43
|
+
described.set(field, describe);
|
|
44
|
+
}
|
|
45
|
+
return describe;
|
|
46
|
+
};
|
|
47
|
+
function HostVariableValueControl(props) {
|
|
48
|
+
const { field } = props;
|
|
49
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Control, {
|
|
50
|
+
...props,
|
|
51
|
+
renderPicker: field && pickerFor?.(field),
|
|
52
|
+
describeReference: field && describerFor(field)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
component: HostVariableValueControl
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.createVariableModeControl = __webpack_exports__.createVariableModeControl;
|
|
60
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
61
|
+
"createVariableModeControl"
|
|
62
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
63
|
+
Object.defineProperty(exports, '__esModule', {
|
|
64
|
+
value: true
|
|
65
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type VariableReferenceDescription } from '../ui/variable-value-control';
|
|
2
|
+
import { type FormVariablePicker } from './field-actions';
|
|
3
|
+
import type { FieldMetadata } from './form-schema';
|
|
4
|
+
import type { ValueModeControlRegistration } from './value-modes';
|
|
5
|
+
export interface VariableModeControlOptions {
|
|
6
|
+
/** The host's own picker, rendered in place of a picker over the form's variables. */
|
|
7
|
+
renderPicker?: FormVariablePicker;
|
|
8
|
+
/**
|
|
9
|
+
* The chip's label and type icon for a bound reference. Returning nothing shows the reference
|
|
10
|
+
* as stored.
|
|
11
|
+
*/
|
|
12
|
+
describeReference?: (reference: string, ctx: {
|
|
13
|
+
field: FieldMetadata;
|
|
14
|
+
}) => VariableReferenceDescription | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The `variable` mode's control with the host's own picker or reference labels. Register it as
|
|
18
|
+
* `FormPlugin.valueModes.definitions.variable.control`; call this once, at module scope.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createVariableModeControl({ renderPicker, describeReference, }: VariableModeControlOptions): ValueModeControlRegistration;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { VariableValueControl } from "../ui/variable-value-control.js";
|
|
3
|
+
import { bindVariablePicker } from "./field-actions.js";
|
|
4
|
+
const Control = VariableValueControl;
|
|
5
|
+
function createVariableModeControl({ renderPicker, describeReference }) {
|
|
6
|
+
const pickerFor = renderPicker && bindVariablePicker(renderPicker);
|
|
7
|
+
const described = new WeakMap();
|
|
8
|
+
const describerFor = (field)=>{
|
|
9
|
+
if (!describeReference) return;
|
|
10
|
+
let describe = described.get(field);
|
|
11
|
+
if (!describe) {
|
|
12
|
+
describe = (reference)=>describeReference(reference, {
|
|
13
|
+
field
|
|
14
|
+
});
|
|
15
|
+
described.set(field, describe);
|
|
16
|
+
}
|
|
17
|
+
return describe;
|
|
18
|
+
};
|
|
19
|
+
function HostVariableValueControl(props) {
|
|
20
|
+
const { field } = props;
|
|
21
|
+
return /*#__PURE__*/ jsx(Control, {
|
|
22
|
+
...props,
|
|
23
|
+
renderPicker: field && pickerFor?.(field),
|
|
24
|
+
describeReference: field && describerFor(field)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
component: HostVariableValueControl
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export { createVariableModeControl };
|
|
@@ -44,7 +44,7 @@ const DEFAULT_AI_ASSIST_ACTION_STRINGS = {
|
|
|
44
44
|
generating: 'Generating',
|
|
45
45
|
error: 'Could not generate a value. Try again.'
|
|
46
46
|
};
|
|
47
|
-
function AiAssistAction({ onGenerate, hint, disabled, strings }) {
|
|
47
|
+
function AiAssistAction({ onGenerate, hint, renderContent, disabled, strings }) {
|
|
48
48
|
const promptId = (0, external_react_namespaceObject.useId)();
|
|
49
49
|
const errorId = (0, external_react_namespaceObject.useId)();
|
|
50
50
|
const [prompt, setPrompt] = (0, external_react_namespaceObject.useState)('');
|
|
@@ -59,6 +59,7 @@ function AiAssistAction({ onGenerate, hint, disabled, strings }) {
|
|
|
59
59
|
setFailed(false);
|
|
60
60
|
setOpen(next);
|
|
61
61
|
};
|
|
62
|
+
const close = (0, external_react_namespaceObject.useCallback)(()=>setOpen(false), []);
|
|
62
63
|
const generate = async ()=>{
|
|
63
64
|
setFailed(false);
|
|
64
65
|
const result = onGenerate?.(prompt);
|
|
@@ -99,58 +100,67 @@ function AiAssistAction({ onGenerate, hint, disabled, strings }) {
|
|
|
99
100
|
})
|
|
100
101
|
]
|
|
101
102
|
}),
|
|
102
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
103
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
103
104
|
align: "end",
|
|
104
105
|
className: "space-y-3",
|
|
105
|
-
children:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
106
|
+
children: renderContent ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AiAssistSlot, {
|
|
107
|
+
render: renderContent,
|
|
108
|
+
close: close,
|
|
109
|
+
disabled: !!disabled
|
|
110
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
113
|
+
className: "space-y-1.5",
|
|
114
|
+
children: [
|
|
115
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
|
|
116
|
+
htmlFor: promptId,
|
|
117
|
+
className: "text-xs font-medium text-foreground-muted",
|
|
118
|
+
children: text.prompt
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_textarea_cjs_namespaceObject.Textarea, {
|
|
121
|
+
id: promptId,
|
|
122
|
+
rows: 3,
|
|
123
|
+
value: prompt,
|
|
124
|
+
onChange: (e)=>setPrompt(e.target.value),
|
|
125
|
+
placeholder: text.promptPlaceholder,
|
|
126
|
+
"aria-describedby": failed ? errorId : void 0,
|
|
127
|
+
className: "resize-none text-sm"
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
}),
|
|
131
|
+
hint && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
132
|
+
className: "block text-[11px] text-foreground-subtle",
|
|
133
|
+
children: hint
|
|
134
|
+
}),
|
|
135
|
+
failed && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
136
|
+
id: errorId,
|
|
137
|
+
role: "alert",
|
|
138
|
+
className: "text-xs text-error",
|
|
139
|
+
children: text.error
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
142
|
+
size: "sm",
|
|
143
|
+
className: "w-full",
|
|
144
|
+
disabled: !onGenerate || pending,
|
|
145
|
+
"aria-busy": pending || void 0,
|
|
146
|
+
onClick: ()=>generate(),
|
|
147
|
+
children: [
|
|
148
|
+
pending && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Loader2, {
|
|
149
|
+
className: "animate-spin",
|
|
150
|
+
"aria-hidden": "true"
|
|
151
|
+
}),
|
|
152
|
+
pending ? text.generating : text.generate
|
|
153
|
+
]
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
})
|
|
150
157
|
})
|
|
151
158
|
]
|
|
152
159
|
});
|
|
153
160
|
}
|
|
161
|
+
function AiAssistSlot({ render, ...props }) {
|
|
162
|
+
return render(props);
|
|
163
|
+
}
|
|
154
164
|
function isThenable(value) {
|
|
155
165
|
return ('object' == typeof value || 'function' == typeof value) && null !== value && 'function' == typeof value.then;
|
|
156
166
|
}
|