@pilotiq/pilotiq 0.3.0 → 0.4.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/CLAUDE.md +1 -1
- package/dist/pageData.d.ts +11 -0
- package/dist/pageData.d.ts.map +1 -1
- package/dist/pageData.js +31 -0
- package/dist/pageData.js.map +1 -1
- package/dist/react/FieldLabelSlotRegistry.d.ts +26 -0
- package/dist/react/FieldLabelSlotRegistry.d.ts.map +1 -0
- package/dist/react/FieldLabelSlotRegistry.js +16 -0
- package/dist/react/FieldLabelSlotRegistry.js.map +1 -0
- package/dist/react/SchemaRenderer.d.ts.map +1 -1
- package/dist/react/SchemaRenderer.js +15 -5
- package/dist/react/SchemaRenderer.js.map +1 -1
- package/dist/react/fields/FieldShell.d.ts +4 -1
- package/dist/react/fields/FieldShell.d.ts.map +1 -1
- package/dist/react/fields/FieldShell.js +2 -2
- package/dist/react/fields/FieldShell.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/src/pageData.ts +33 -0
- package/src/react/FieldLabelSlotRegistry.ts +30 -0
- package/src/react/SchemaRenderer.tsx +22 -8
- package/src/react/fields/FieldShell.tsx +5 -1
- package/src/react/index.ts +1 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props the field label slot component receives from `SchemaRenderer`.
|
|
4
|
+
* For AI actions this carries the field name, action list, and the
|
|
5
|
+
* pre-composed agent-run base URL stamped by `tagFieldAiUrls`.
|
|
6
|
+
*/
|
|
7
|
+
export interface FieldLabelSlotProps {
|
|
8
|
+
fieldName: string;
|
|
9
|
+
actions: Array<{
|
|
10
|
+
slug: string;
|
|
11
|
+
label: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
}>;
|
|
14
|
+
agentRunBase: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register a component to render inline next to every field label that
|
|
18
|
+
* has `aiActions` stamped on its meta. Called once at boot by a plugin's
|
|
19
|
+
* `register(panel)` step (e.g. `@pilotiq-pro/ai`). No-op when no plugin
|
|
20
|
+
* registers — `getFieldLabelSlot()` returns `null` and `SchemaRenderer`
|
|
21
|
+
* skips the slot.
|
|
22
|
+
*/
|
|
23
|
+
export declare function registerFieldLabelSlot(C: ComponentType<FieldLabelSlotProps>): void;
|
|
24
|
+
/** Returns the registered field label slot component, or `null`. */
|
|
25
|
+
export declare function getFieldLabelSlot(): ComponentType<FieldLabelSlotProps> | null;
|
|
26
|
+
//# sourceMappingURL=FieldLabelSlotRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldLabelSlotRegistry.d.ts","sourceRoot":"","sources":["../../src/react/FieldLabelSlotRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAK,MAAM,CAAA;IACpB,OAAO,EAAO,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACnE,YAAY,EAAE,MAAM,CAAA;CACrB;AAID;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAElF;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,IAAI,aAAa,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAE7E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
let _component = null;
|
|
2
|
+
/**
|
|
3
|
+
* Register a component to render inline next to every field label that
|
|
4
|
+
* has `aiActions` stamped on its meta. Called once at boot by a plugin's
|
|
5
|
+
* `register(panel)` step (e.g. `@pilotiq-pro/ai`). No-op when no plugin
|
|
6
|
+
* registers — `getFieldLabelSlot()` returns `null` and `SchemaRenderer`
|
|
7
|
+
* skips the slot.
|
|
8
|
+
*/
|
|
9
|
+
export function registerFieldLabelSlot(C) {
|
|
10
|
+
_component = C;
|
|
11
|
+
}
|
|
12
|
+
/** Returns the registered field label slot component, or `null`. */
|
|
13
|
+
export function getFieldLabelSlot() {
|
|
14
|
+
return _component;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=FieldLabelSlotRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldLabelSlotRegistry.js","sourceRoot":"","sources":["../../src/react/FieldLabelSlotRegistry.ts"],"names":[],"mappings":"AAaA,IAAI,UAAU,GAA8C,IAAI,CAAA;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,CAAqC;IAC1E,UAAU,GAAG,CAAC,CAAA;AAChB,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaRenderer.d.ts","sourceRoot":"","sources":["../../src/react/SchemaRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"SchemaRenderer.d.ts","sourceRoot":"","sources":["../../src/react/SchemaRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AA4HvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAG,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sx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { getFieldRenderer } from './registry.js';
|
|
4
|
+
import { getFieldLabelSlot } from './FieldLabelSlotRegistry.js';
|
|
4
5
|
import { FormStateProvider, useFormState, FormIdContext } from './FormStateContext.js';
|
|
5
6
|
import { Checkbox } from './ui/checkbox.js';
|
|
6
7
|
import { Input } from './ui/input.js';
|
|
@@ -88,6 +89,15 @@ function renderField(el, index) {
|
|
|
88
89
|
if (fieldType === 'hidden') {
|
|
89
90
|
return _jsx(HiddenInput, { name: name, defaultValue: defaultValue }, index);
|
|
90
91
|
}
|
|
92
|
+
// Field label slot — rendered next to the label when a plugin registered
|
|
93
|
+
// a component via registerFieldLabelSlot() and the field has aiActions +
|
|
94
|
+
// _agentRunBase stamped on its meta (set by tagFieldAiUrls in pageData).
|
|
95
|
+
const LabelSlot = getFieldLabelSlot();
|
|
96
|
+
const aiActions = Array.isArray(el['aiActions']) ? el['aiActions'] : undefined;
|
|
97
|
+
const agentRunBase = typeof el['_agentRunBase'] === 'string' ? el['_agentRunBase'] : undefined;
|
|
98
|
+
const labelSlot = (LabelSlot && aiActions?.length && agentRunBase)
|
|
99
|
+
? _jsx(LabelSlot, { fieldName: name, actions: aiActions, agentRunBase: agentRunBase })
|
|
100
|
+
: undefined;
|
|
91
101
|
const autofocus = el['autofocus'] === true;
|
|
92
102
|
const extraInput = el['extraInputAttributes'];
|
|
93
103
|
const common = {
|
|
@@ -105,24 +115,24 @@ function renderField(el, index) {
|
|
|
105
115
|
// switch so consumers can override built-ins too if they want.
|
|
106
116
|
const Custom = getFieldRenderer(fieldType);
|
|
107
117
|
if (Custom) {
|
|
108
|
-
return (_jsx(FieldShell, { el: el, name: name, label: label, required: required, children: _jsx(Custom, { el: el, name: name, defaultValue: defaultValue, required: required, disabled: disabled, placeholder: placeholder }) }, index));
|
|
118
|
+
return (_jsx(FieldShell, { el: el, name: name, label: label, required: required, labelSlot: labelSlot, children: _jsx(Custom, { el: el, name: name, defaultValue: defaultValue, required: required, disabled: disabled, placeholder: placeholder }) }, index));
|
|
109
119
|
}
|
|
110
120
|
// TextField (and slug) rich affordances live in a dedicated shell so
|
|
111
121
|
// `useTextInputControls` can hold reveal-toggle / mask state via React
|
|
112
122
|
// hooks (renderField itself is a plain function, hooks would violate
|
|
113
123
|
// rules-of-hooks here).
|
|
114
124
|
if (fieldType === 'text' || fieldType === 'slug') {
|
|
115
|
-
return (_jsx(TextFieldShell, { el: el, name: name, label: label, required: required, common: common }, index));
|
|
125
|
+
return (_jsx(TextFieldShell, { el: el, name: name, label: label, required: required, common: common, labelSlot: labelSlot }, index));
|
|
116
126
|
}
|
|
117
127
|
const input = renderFieldInput(fieldType, el, name, defaultValue, defaultStr, common, disabled, required, placeholder);
|
|
118
|
-
return (_jsx(FieldShell, { el: el, name: name, label: label, required: required, children: input }, index));
|
|
128
|
+
return (_jsx(FieldShell, { el: el, name: name, label: label, required: required, labelSlot: labelSlot, children: input }, index));
|
|
119
129
|
}
|
|
120
130
|
/**
|
|
121
131
|
* Component-shape TextField renderer — wraps the input shell so we can
|
|
122
132
|
* use `useTextInputControls()` (which holds the eye-toggle / mask state).
|
|
123
133
|
* Keeps `renderField` itself hook-free.
|
|
124
134
|
*/
|
|
125
|
-
function TextFieldShell({ el, name, label, required, common, }) {
|
|
135
|
+
function TextFieldShell({ el, name, label, required, common, labelSlot, }) {
|
|
126
136
|
const controls = useTextInputControls(el, name, (m) => renderElement(m, 0));
|
|
127
137
|
// Build the input with all the new HTML attrs (inputMode /
|
|
128
138
|
// autocapitalize / list / maxLength + the password/text type from
|
|
@@ -138,7 +148,7 @@ function TextFieldShell({ el, name, label, required, common, }) {
|
|
|
138
148
|
textExtra['list'] = `${name}__datalist`;
|
|
139
149
|
const datalist = Array.isArray(el['datalist']) ? el['datalist'] : undefined;
|
|
140
150
|
const input = (_jsxs(_Fragment, { children: [_jsx(TextLikeInput, { el: el, name: name, common: common, type: controls.type, extraProps: textExtra, multiline: false, applyMask: controls.applyMask }), datalist && (_jsx("datalist", { id: `${name}__datalist`, children: datalist.map((v, i) => _jsx("option", { value: v }, i)) }))] }));
|
|
141
|
-
return (_jsx(FieldShell, { el: el, name: name, label: label, required: required, before: controls.before, after: controls.after, children: input }));
|
|
151
|
+
return (_jsx(FieldShell, { el: el, name: name, label: label, required: required, before: controls.before, after: controls.after, labelSlot: labelSlot, children: input }));
|
|
142
152
|
}
|
|
143
153
|
function renderFieldInput(fieldType, el, name, defaultValue, defaultStr, common, disabled, required, placeholder) {
|
|
144
154
|
switch (fieldType) {
|