@pilotiq/pilotiq 0.5.0 → 0.6.1
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 +19 -0
- package/dist/Column.d.ts +36 -0
- package/dist/Column.d.ts.map +1 -1
- package/dist/Column.js +24 -0
- package/dist/Column.js.map +1 -1
- package/dist/RenderHook.d.ts +2 -2
- package/dist/RenderHook.d.ts.map +1 -1
- package/dist/RenderHook.js +8 -0
- package/dist/RenderHook.js.map +1 -1
- package/dist/applyPageHooks.d.ts.map +1 -1
- package/dist/applyPageHooks.js +76 -0
- package/dist/applyPageHooks.js.map +1 -1
- package/dist/elements/dispatchForm.d.ts +14 -6
- package/dist/elements/dispatchForm.d.ts.map +1 -1
- package/dist/elements/dispatchForm.js +28 -8
- package/dist/elements/dispatchForm.js.map +1 -1
- package/dist/fields/TextField.d.ts +10 -0
- package/dist/fields/TextField.d.ts.map +1 -1
- package/dist/fields/TextField.js +11 -0
- package/dist/fields/TextField.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pageData.d.ts.map +1 -1
- package/dist/pageData.js +32 -4
- package/dist/pageData.js.map +1 -1
- package/dist/react/RightSidebarContext.d.ts.map +1 -1
- package/dist/react/RightSidebarContext.js +35 -15
- package/dist/react/RightSidebarContext.js.map +1 -1
- package/dist/react/SchemaRenderer.d.ts.map +1 -1
- package/dist/react/SchemaRenderer.js +25 -4
- package/dist/react/SchemaRenderer.js.map +1 -1
- package/dist/react/cells/EditableCell.d.ts.map +1 -1
- package/dist/react/cells/EditableCell.js +6 -1
- package/dist/react/cells/EditableCell.js.map +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +41 -2
- package/dist/routes.js.map +1 -1
- package/dist/schema/SlotComponent.d.ts +49 -0
- package/dist/schema/SlotComponent.d.ts.map +1 -0
- package/dist/schema/SlotComponent.js +65 -0
- package/dist/schema/SlotComponent.js.map +1 -0
- package/dist/schema/Wizard.d.ts +37 -0
- package/dist/schema/Wizard.d.ts.map +1 -1
- package/dist/schema/Wizard.js +21 -0
- package/dist/schema/Wizard.js.map +1 -1
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/slot-components/index.d.ts +2 -0
- package/dist/slot-components/index.d.ts.map +1 -0
- package/dist/slot-components/index.js +6 -0
- package/dist/slot-components/index.js.map +1 -0
- package/dist/slot-components/registry.d.ts +41 -0
- package/dist/slot-components/registry.d.ts.map +1 -0
- package/dist/slot-components/registry.js +17 -0
- package/dist/slot-components/registry.js.map +1 -0
- package/package.json +5 -1
- package/src/Column.test.ts +23 -0
- package/src/Column.ts +44 -0
- package/src/RenderHook.ts +16 -0
- package/src/applyPageHooks.test.ts +167 -2
- package/src/applyPageHooks.ts +88 -0
- package/src/elements/dispatchForm.test.ts +23 -1
- package/src/elements/dispatchForm.ts +33 -9
- package/src/fields/TextField.test.ts +45 -0
- package/src/fields/TextField.ts +13 -0
- package/src/index.ts +1 -0
- package/src/pageData.test.ts +83 -0
- package/src/pageData.ts +37 -4
- package/src/react/RightSidebarContext.tsx +34 -11
- package/src/react/SchemaRenderer.tsx +43 -4
- package/src/react/cells/EditableCell.tsx +5 -1
- package/src/routes.test.ts +141 -0
- package/src/routes.ts +38 -2
- package/src/schema/SlotComponent.test.ts +77 -0
- package/src/schema/SlotComponent.ts +71 -0
- package/src/schema/Wizard.ts +45 -0
- package/src/schema/containers.test.ts +28 -0
- package/src/schema/index.ts +1 -0
- package/src/slot-components/index.ts +10 -0
- package/src/slot-components/registry.ts +56 -0
|
@@ -399,6 +399,34 @@ describe('Wizard / Step (Plan #8)', () => {
|
|
|
399
399
|
assert.equal(result[0]!['persist'], false)
|
|
400
400
|
})
|
|
401
401
|
|
|
402
|
+
describe('Step.beforeValidation / afterValidation', () => {
|
|
403
|
+
it('accessors return undefined when no hooks are set', () => {
|
|
404
|
+
const step = Step.make('x').schema([])
|
|
405
|
+
assert.equal(step.getBeforeValidation(), undefined)
|
|
406
|
+
assert.equal(step.getAfterValidation(), undefined)
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
it('accessors return the registered hook function', () => {
|
|
410
|
+
const before = async () => {}
|
|
411
|
+
const after = () => {}
|
|
412
|
+
const step = Step.make('x').schema([]).beforeValidation(before).afterValidation(after)
|
|
413
|
+
assert.equal(step.getBeforeValidation(), before)
|
|
414
|
+
assert.equal(step.getAfterValidation(), after)
|
|
415
|
+
})
|
|
416
|
+
|
|
417
|
+
it('hooks are not serialized into the wire shape', async () => {
|
|
418
|
+
const tree = [
|
|
419
|
+
Wizard.make().steps([
|
|
420
|
+
Step.make('a').schema([]).beforeValidation(() => {}).afterValidation(() => {}),
|
|
421
|
+
]),
|
|
422
|
+
]
|
|
423
|
+
const result = await resolveSchema(tree)
|
|
424
|
+
const step = result[0]!.children![0]!
|
|
425
|
+
assert.equal(step['beforeValidation'], undefined)
|
|
426
|
+
assert.equal(step['afterValidation'], undefined)
|
|
427
|
+
})
|
|
428
|
+
})
|
|
429
|
+
|
|
402
430
|
it('all step children resolve so cross-step $get works', async () => {
|
|
403
431
|
// Step 2 has a Section that hides based on a value entered in Step 0;
|
|
404
432
|
// both steps must be resolved on every cycle for the predicate to fire.
|
package/src/schema/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { Group } from './Group.js'
|
|
|
28
28
|
export { Fieldset } from './Fieldset.js'
|
|
29
29
|
export { Split, type SplitFrom } from './Split.js'
|
|
30
30
|
export { Wizard, Step } from './Wizard.js'
|
|
31
|
+
export { SlotComponent } from './SlotComponent.js'
|
|
31
32
|
export {
|
|
32
33
|
resolveSchema,
|
|
33
34
|
registerResolver,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Slot-component runtime registry — opt-in component registration for
|
|
2
|
+
// `SlotComponent` schema elements. Imported by panel `bootstrap/providers.ts`
|
|
3
|
+
// or by a plugin's `register(panel)` step (e.g. `@pilotiq-pro/ai`'s
|
|
4
|
+
// resource-header agents dropdown).
|
|
5
|
+
export {
|
|
6
|
+
registerSlotComponents,
|
|
7
|
+
getSlotComponent,
|
|
8
|
+
type SlotComponent,
|
|
9
|
+
type SlotComponentProps,
|
|
10
|
+
} from './registry.js'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ComponentType } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Render-time component registry for `SlotComponent` schema elements.
|
|
5
|
+
* Mirrors the widget / entry registry pattern: users register components
|
|
6
|
+
* by name in their app's `bootstrap/providers.ts` (or via a plugin's
|
|
7
|
+
* `register(panel)` hook), the `SlotComponent` ships the registered name
|
|
8
|
+
* on the wire (`{ component: 'BookmarkButton' }`), and the renderer
|
|
9
|
+
* looks up the actual component at render through `getSlotComponent()`.
|
|
10
|
+
*
|
|
11
|
+
* Why a runtime registry rather than the build-time `_components.ts`
|
|
12
|
+
* manifest the icon system uses: slot components typically live in plugin
|
|
13
|
+
* packages or app-level bootstrap files, not on Resource / Global / Page
|
|
14
|
+
* top-level statics, so the existing manifest walker doesn't see them. A
|
|
15
|
+
* runtime register-by-name keeps the wire compact and mirrors the
|
|
16
|
+
* `registerWidgetComponents / registerEntryComponents` precedent.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // bootstrap/providers.ts
|
|
20
|
+
* import { registerSlotComponents } from '@pilotiq/pilotiq/slot-components'
|
|
21
|
+
* import { BookmarkButton } from '#components/BookmarkButton.js'
|
|
22
|
+
* registerSlotComponents({ BookmarkButton })
|
|
23
|
+
*
|
|
24
|
+
* // Then a render-hook contribution (or any schema slot) can reference it:
|
|
25
|
+
* panel.renderHook(
|
|
26
|
+
* 'panels::resource.pages.edit-record.header.actions.before',
|
|
27
|
+
* () => [SlotComponent.make('BookmarkButton').props({ … })],
|
|
28
|
+
* )
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Props handed to every registered slot component. The schema-side
|
|
33
|
+
* `SlotComponent.props({...})` setter ships through verbatim — pack
|
|
34
|
+
* everything the component needs into that bag (basePath, recordId,
|
|
35
|
+
* pre-resolved agent metas, etc).
|
|
36
|
+
*/
|
|
37
|
+
export type SlotComponentProps = Record<string, unknown>
|
|
38
|
+
export type SlotComponent = ComponentType<SlotComponentProps>
|
|
39
|
+
|
|
40
|
+
const registry: Record<string, SlotComponent> = {}
|
|
41
|
+
|
|
42
|
+
export function registerSlotComponents(map: Record<string, SlotComponent>): void {
|
|
43
|
+
for (const key of Object.keys(map)) {
|
|
44
|
+
const c = map[key]
|
|
45
|
+
if (c) registry[key] = c
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getSlotComponent(name: string): SlotComponent | undefined {
|
|
50
|
+
return registry[name]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Test-only: clear the registry. Not exported from the public entry. */
|
|
54
|
+
export function _resetSlotComponentRegistryForTests(): void {
|
|
55
|
+
for (const key of Object.keys(registry)) delete registry[key]
|
|
56
|
+
}
|