@lattice-php/lattice 0.17.2 → 0.19.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/README.md +1 -1
- package/dist/action/components/action-form.d.ts +2 -2
- package/dist/action/components/action-form.js +11 -11
- package/dist/action/components/action-form.js.map +1 -1
- package/dist/action/components/action-group.d.ts +1 -1
- package/dist/action/components/action-group.js +6 -4
- package/dist/action/components/action-group.js.map +1 -1
- package/dist/action/components/action-trigger-provider.d.ts +10 -0
- package/dist/action/components/action-trigger-provider.js +24 -0
- package/dist/action/components/action-trigger-provider.js.map +1 -0
- package/dist/action/components/action.d.ts +1 -1
- package/dist/action/components/action.js +4 -4
- package/dist/action/components/action.js.map +1 -1
- package/dist/action/{use-action.d.ts → hooks/use-action.d.ts} +1 -1
- package/dist/action/{use-action.js → hooks/use-action.js} +7 -7
- package/dist/action/hooks/use-action.js.map +1 -0
- package/dist/action/index.d.ts +10 -1
- package/dist/action/index.js +8 -13
- package/dist/action/{run-action.d.ts → lib/run-action.d.ts} +1 -1
- package/dist/action/{run-action.js → lib/run-action.js} +2 -2
- package/dist/action/lib/run-action.js.map +1 -0
- package/dist/action/plugin.d.ts +1 -0
- package/dist/action/plugin.js +15 -0
- package/dist/action/plugin.js.map +1 -0
- package/dist/appearance/index.d.ts +4 -1
- package/dist/appearance/index.js +11 -2
- package/dist/appearance/index.js.map +1 -1
- package/dist/chat/components/chat-box.d.ts +1 -1
- package/dist/chat/components/chat-box.js +2 -2
- package/dist/chat/components/chat-box.js.map +1 -1
- package/dist/chat/components/message-list.d.ts +1 -1
- package/dist/chat/components/message-list.js.map +1 -1
- package/dist/chat/components/message.d.ts +1 -1
- package/dist/chat/components/message.js.map +1 -1
- package/dist/chat/components/prompt-input.js +1 -1
- package/dist/chat/components/prompt-input.js.map +1 -1
- package/dist/chat/{use-chat.d.ts → hooks/use-chat.d.ts} +1 -1
- package/dist/chat/{use-chat.js → hooks/use-chat.js} +2 -2
- package/dist/chat/hooks/use-chat.js.map +1 -0
- package/dist/chat/index.d.ts +4 -1
- package/dist/chat/index.js +3 -17
- package/dist/chat/{transport.d.ts → lib/transport.d.ts} +2 -2
- package/dist/chat/{transport.js → lib/transport.js} +2 -2
- package/dist/chat/lib/transport.js.map +1 -0
- package/dist/chat/parts/text.d.ts +1 -1
- package/dist/chat/parts/tool-call.d.ts +1 -1
- package/dist/chat/plugin.d.ts +2 -0
- package/dist/chat/plugin.js +17 -0
- package/dist/chat/plugin.js.map +1 -0
- package/dist/chat/types.d.ts +2 -2
- package/dist/clipboard/index.d.ts +1 -2
- package/dist/clipboard/index.js +1 -10
- package/dist/clipboard/index.js.map +1 -1
- package/dist/core/api.d.ts +1 -1
- package/dist/core/api.js.map +1 -1
- package/dist/core/headers.js.map +1 -1
- package/dist/core/{column-sizing.d.ts → hooks/column-sizing.d.ts} +2 -2
- package/dist/core/{column-sizing.js → hooks/column-sizing.js} +1 -1
- package/dist/core/hooks/column-sizing.js.map +1 -0
- package/dist/core/{use-column-resizing.d.ts → hooks/use-column-resizing.d.ts} +2 -1
- package/dist/core/{use-column-resizing.js → hooks/use-column-resizing.js} +59 -31
- package/dist/core/hooks/use-column-resizing.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +10 -0
- package/dist/core/materialize.d.ts +9 -0
- package/dist/core/materialize.js +39 -0
- package/dist/core/materialize.js.map +1 -0
- package/dist/core/nodes.d.ts +6 -1
- package/dist/core/nodes.js +8 -1
- package/dist/core/nodes.js.map +1 -1
- package/dist/core/registry-context.d.ts +3 -3
- package/dist/core/registry-context.js.map +1 -1
- package/dist/core/registry.d.ts +5 -3
- package/dist/core/registry.js.map +1 -1
- package/dist/core/renderer.d.ts +1 -1
- package/dist/core/renderer.js +4 -6
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/test-id.d.ts +1 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/create-app.d.ts +3 -3
- package/dist/effects/dispatch.d.ts +2 -2
- package/dist/effects/registry.d.ts +4 -3
- package/dist/effects/registry.js +7 -7
- package/dist/effects/registry.js.map +1 -1
- package/dist/effects/use-effect-dispatcher.d.ts +1 -1
- package/dist/{events/event-bridge.d.ts → event-bridge.d.ts} +2 -3
- package/dist/{events/event-bridge.js → event-bridge.js} +4 -11
- package/dist/event-bridge.js.map +1 -0
- package/dist/events/event-names.d.ts +0 -3
- package/dist/events/event-names.js +0 -3
- package/dist/events/event-names.js.map +1 -1
- package/dist/form/components/base/field.d.ts +1 -1
- package/dist/form/components/base/field.js +5 -5
- package/dist/form/components/base/field.js.map +1 -1
- package/dist/form/components/base/submit-button.d.ts +1 -1
- package/dist/form/components/base/submit-button.js +3 -3
- package/dist/form/components/base/submit-button.js.map +1 -1
- package/dist/form/components/fields/{block-add-menu.d.ts → add-row-menu.d.ts} +3 -3
- package/dist/form/components/fields/{block-add-menu.js → add-row-menu.js} +10 -10
- package/dist/form/components/fields/add-row-menu.js.map +1 -0
- package/dist/form/components/fields/builder.d.ts +1 -1
- package/dist/form/components/fields/builder.js +80 -75
- package/dist/form/components/fields/builder.js.map +1 -1
- package/dist/form/components/fields/checkbox.d.ts +1 -1
- package/dist/form/components/fields/checkbox.js +12 -9
- package/dist/form/components/fields/checkbox.js.map +1 -1
- package/dist/form/components/fields/choice.d.ts +1 -1
- package/dist/form/components/fields/choice.js +4 -4
- package/dist/form/components/fields/choice.js.map +1 -1
- package/dist/form/components/fields/date-input.d.ts +1 -1
- package/dist/form/components/fields/date-picker-field.js +2 -2
- package/dist/form/components/fields/date-picker-field.js.map +1 -1
- package/dist/form/components/fields/date-picker.d.ts +1 -1
- package/dist/form/components/fields/date-time-input.d.ts +1 -1
- package/dist/form/components/fields/file-upload.d.ts +1 -1
- package/dist/form/components/fields/file-upload.js +4 -4
- package/dist/form/components/fields/file-upload.js.map +1 -1
- package/dist/form/components/fields/hidden-input.d.ts +1 -1
- package/dist/form/components/fields/hidden-input.js +1 -1
- package/dist/form/components/fields/hidden-input.js.map +1 -1
- package/dist/form/components/fields/number-input.d.ts +1 -1
- package/dist/form/components/fields/number-input.js +2 -2
- package/dist/form/components/fields/number-input.js.map +1 -1
- package/dist/form/components/fields/otp-input.d.ts +1 -1
- package/dist/form/components/fields/otp-input.js +1 -1
- package/dist/form/components/fields/otp-input.js.map +1 -1
- package/dist/form/components/fields/password-input.d.ts +1 -1
- package/dist/form/components/fields/password-input.js +6 -6
- package/dist/form/components/fields/password-input.js.map +1 -1
- package/dist/form/components/fields/repeater-rows.d.ts +6 -1
- package/dist/form/components/fields/repeater-rows.js +9 -5
- package/dist/form/components/fields/repeater-rows.js.map +1 -1
- package/dist/form/components/fields/repeater.d.ts +1 -1
- package/dist/form/components/fields/repeater.js +57 -48
- package/dist/form/components/fields/repeater.js.map +1 -1
- package/dist/form/components/fields/rich-editor-field.d.ts +1 -1
- package/dist/form/components/fields/rich-editor-field.js +8 -6
- package/dist/form/components/fields/rich-editor-field.js.map +1 -1
- package/dist/form/components/fields/rich-editor.d.ts +1 -1
- package/dist/form/components/fields/row-action-menu.d.ts +2 -2
- package/dist/form/components/fields/row-actions.js +1 -1
- package/dist/form/components/fields/row-actions.js.map +1 -1
- package/dist/form/components/fields/row-item.d.ts +3 -3
- package/dist/form/components/fields/row-item.js +3 -2
- package/dist/form/components/fields/row-item.js.map +1 -1
- package/dist/form/components/fields/row-key-inputs.d.ts +7 -0
- package/dist/form/components/fields/row-key-inputs.js +16 -0
- package/dist/form/components/fields/row-key-inputs.js.map +1 -0
- package/dist/form/components/fields/row-templates.d.ts +9 -0
- package/dist/form/components/fields/row-templates.js +14 -0
- package/dist/form/components/fields/row-templates.js.map +1 -0
- package/dist/form/components/fields/select.d.ts +1 -1
- package/dist/form/components/fields/select.js +23 -13
- package/dist/form/components/fields/select.js.map +1 -1
- package/dist/form/components/fields/simple-field.d.ts +2 -2
- package/dist/form/components/fields/simple-field.js +2 -2
- package/dist/form/components/fields/simple-field.js.map +1 -1
- package/dist/form/components/fields/table-rows.d.ts +3 -3
- package/dist/form/components/fields/table-rows.js +13 -13
- package/dist/form/components/fields/table-rows.js.map +1 -1
- package/dist/form/components/fields/text-input.d.ts +1 -1
- package/dist/form/components/fields/text-input.js +2 -2
- package/dist/form/components/fields/text-input.js.map +1 -1
- package/dist/form/components/fields/textarea.d.ts +1 -1
- package/dist/form/components/fields/textarea.js +1 -1
- package/dist/form/components/fields/textarea.js.map +1 -1
- package/dist/form/components/fields/time-input.d.ts +1 -1
- package/dist/form/components/fields/time-input.js +3 -3
- package/dist/form/components/fields/time-input.js.map +1 -1
- package/dist/form/components/fields/time-picker.d.ts +1 -1
- package/dist/form/components/fields/toggle.d.ts +1 -1
- package/dist/form/components/fields/toggle.js +10 -9
- package/dist/form/components/fields/toggle.js.map +1 -1
- package/dist/form/components/fields/use-row-collection.d.ts +1 -1
- package/dist/form/components/fields/use-row-collection.js +2 -2
- package/dist/form/components/fields/use-row-collection.js.map +1 -1
- package/dist/form/components/form.d.ts +1 -1
- package/dist/form/components/form.js +6 -6
- package/dist/form/components/form.js.map +1 -1
- package/dist/form/components/index.d.ts +17 -17
- package/dist/form/embed.d.ts +17 -0
- package/dist/form/embed.js +10 -0
- package/dist/form/{components → hooks}/context.d.ts +3 -0
- package/dist/form/{components → hooks}/context.js +2 -1
- package/dist/form/hooks/context.js.map +1 -0
- package/dist/form/{components → hooks}/field-scope.js +3 -3
- package/dist/form/hooks/field-scope.js.map +1 -0
- package/dist/form/{components → hooks}/prefill-context.js +1 -1
- package/dist/form/hooks/prefill-context.js.map +1 -0
- package/dist/form/{components → hooks}/resolved-nodes.d.ts +1 -1
- package/dist/form/{components → hooks}/resolved-nodes.js +2 -2
- package/dist/form/hooks/resolved-nodes.js.map +1 -0
- package/dist/form/{components → hooks}/row-layout-context.js +1 -1
- package/dist/form/hooks/row-layout-context.js.map +1 -0
- package/dist/form/{components → hooks}/use-controlled-field.d.ts +2 -2
- package/dist/form/{components → hooks}/use-controlled-field.js +6 -5
- package/dist/form/hooks/use-controlled-field.js.map +1 -0
- package/dist/form/hooks/use-dependent-field.d.ts +3 -0
- package/dist/form/{components → hooks}/use-dependent-field.js +6 -6
- package/dist/form/hooks/use-dependent-field.js.map +1 -0
- package/dist/form/{components → hooks}/use-field-commit.d.ts +5 -0
- package/dist/form/{components → hooks}/use-field-commit.js +9 -2
- package/dist/form/hooks/use-field-commit.js.map +1 -0
- package/dist/form/{components → hooks}/use-form-resolver.d.ts +2 -2
- package/dist/form/{components → hooks}/use-form-resolver.js +5 -5
- package/dist/form/hooks/use-form-resolver.js.map +1 -0
- package/dist/form/{components → hooks}/use-seed-default.js +1 -1
- package/dist/form/hooks/use-seed-default.js.map +1 -0
- package/dist/form/{components → hooks}/values.d.ts +3 -1
- package/dist/form/hooks/values.js +136 -0
- package/dist/form/hooks/values.js.map +1 -0
- package/dist/form/index.d.ts +4 -1
- package/dist/form/index.js +3 -30
- package/dist/form/{components → lib}/conditions.d.ts +2 -1
- package/dist/form/{components → lib}/conditions.js +12 -2
- package/dist/form/lib/conditions.js.map +1 -0
- package/dist/form/lib/field-dom-name.d.ts +1 -0
- package/dist/form/lib/field-dom-name.js +10 -0
- package/dist/form/lib/field-dom-name.js.map +1 -0
- package/dist/form/{components → lib}/field-props.d.ts +2 -3
- package/dist/form/{components → lib}/field-props.js +1 -1
- package/dist/form/lib/field-props.js.map +1 -0
- package/dist/form/{components → lib}/form-path.js +1 -1
- package/dist/form/lib/form-path.js.map +1 -0
- package/dist/form/{components → lib}/form-transport.d.ts +1 -1
- package/dist/form/lib/form-transport.js +21 -0
- package/dist/form/lib/form-transport.js.map +1 -0
- package/dist/form/lib/override-keys.js +12 -0
- package/dist/form/lib/override-keys.js.map +1 -0
- package/dist/form/{components → lib}/prefill-targets.d.ts +2 -2
- package/dist/form/{components → lib}/prefill-targets.js +4 -5
- package/dist/form/lib/prefill-targets.js.map +1 -0
- package/dist/form/plugin.d.ts +1 -0
- package/dist/form/plugin.js +47 -0
- package/dist/form/plugin.js.map +1 -0
- package/dist/form/toolkit.d.ts +17 -0
- package/dist/form/toolkit.js +14 -0
- package/dist/form/{components/types.d.ts → types.d.ts} +3 -3
- package/dist/format/number.d.ts +1 -1
- package/dist/format/value.d.ts +1 -1
- package/dist/i18n/backend.d.ts +1 -1
- package/dist/i18n/config.d.ts +1 -1
- package/dist/i18n/index.d.ts +13 -13
- package/dist/i18n/locale-reload.js +1 -1
- package/dist/i18n/locale-reload.js.map +1 -1
- package/dist/i18n/locale.js.map +1 -1
- package/dist/i18n/page-props.d.ts +1 -1
- package/dist/i18n/timezone.js.map +1 -1
- package/dist/i18n/translatable.d.ts +1 -1
- package/dist/icons/icon-renderer.js.map +1 -1
- package/dist/icons/index.d.ts +4 -4
- package/dist/icons/sprite.js.map +1 -1
- package/dist/index.d.ts +37 -38
- package/dist/index.js +10 -9
- package/dist/inertia.js +1 -1
- package/dist/lattice.css +12 -10
- package/dist/layout/{breadcrumbs.d.ts → components/breadcrumbs.d.ts} +1 -1
- package/dist/layout/{breadcrumbs.js → components/breadcrumbs.js} +2 -2
- package/dist/layout/components/breadcrumbs.js.map +1 -0
- package/dist/layout/{callouts.d.ts → components/callouts.d.ts} +1 -1
- package/dist/layout/{callouts.js → components/callouts.js} +7 -7
- package/dist/layout/components/callouts.js.map +1 -0
- package/dist/layout/{dropdown.d.ts → components/dropdown.d.ts} +1 -1
- package/dist/layout/{dropdown.js → components/dropdown.js} +2 -2
- package/dist/layout/components/dropdown.js.map +1 -0
- package/dist/layout/{menu-item.d.ts → components/menu-item.d.ts} +1 -1
- package/dist/layout/{menu-item.js → components/menu-item.js} +9 -8
- package/dist/layout/components/menu-item.js.map +1 -0
- package/dist/layout/{menu.d.ts → components/menu.d.ts} +1 -1
- package/dist/layout/{menu.js → components/menu.js} +2 -2
- package/dist/layout/components/menu.js.map +1 -0
- package/dist/layout/{outlet.d.ts → components/outlet.d.ts} +1 -1
- package/dist/layout/{outlet.js → components/outlet.js} +2 -2
- package/dist/layout/components/outlet.js.map +1 -0
- package/dist/layout/{popover.js → components/popover.js} +4 -4
- package/dist/layout/components/popover.js.map +1 -0
- package/dist/layout/{schema-layout.js → components/schema-layout.js} +3 -3
- package/dist/layout/components/schema-layout.js.map +1 -0
- package/dist/layout/{sidebar.d.ts → components/sidebar.d.ts} +1 -1
- package/dist/layout/{sidebar.js → components/sidebar.js} +5 -5
- package/dist/layout/components/sidebar.js.map +1 -0
- package/dist/layout/{topbar.d.ts → components/topbar.d.ts} +1 -1
- package/dist/layout/{topbar.js → components/topbar.js} +3 -3
- package/dist/layout/components/topbar.js.map +1 -0
- package/dist/layout/{context.d.ts → hooks/context.d.ts} +1 -1
- package/dist/layout/{context.js → hooks/context.js} +2 -2
- package/dist/layout/hooks/context.js.map +1 -0
- package/dist/layout/index.d.ts +4 -4
- package/dist/layout/index.js +4 -4
- package/dist/layout/plugin.d.ts +2 -0
- package/dist/layout/{components.js → plugin.js} +10 -10
- package/dist/layout/plugin.js.map +1 -0
- package/dist/notifications/api.d.ts +1 -1
- package/dist/notifications/components/notification-item.d.ts +1 -1
- package/dist/notifications/components/notification-item.js.map +1 -1
- package/dist/notifications/components/notification-list.d.ts +2 -2
- package/dist/notifications/components/notification-list.js +1 -1
- package/dist/notifications/components/notification-list.js.map +1 -1
- package/dist/notifications/components/notifications-echo.d.ts +1 -1
- package/dist/notifications/components/notifications-echo.js.map +1 -1
- package/dist/notifications/components/notifications.d.ts +1 -1
- package/dist/notifications/components/notifications.js +3 -3
- package/dist/notifications/components/notifications.js.map +1 -1
- package/dist/notifications/index.d.ts +2 -1
- package/dist/notifications/index.js +1 -10
- package/dist/notifications/plugin.d.ts +2 -0
- package/dist/notifications/plugin.js +11 -0
- package/dist/notifications/plugin.js.map +1 -0
- package/dist/notifications/store.d.ts +1 -1
- package/dist/notifications/types.d.ts +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/provider-base.d.ts +2 -2
- package/dist/provider-base.js +5 -4
- package/dist/provider-base.js.map +1 -1
- package/dist/provider.d.ts +3 -3
- package/dist/realtime/build-effects.d.ts +2 -2
- package/dist/realtime/listeners.d.ts +1 -1
- package/dist/realtime/subscriptions.d.ts +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js +9 -9
- package/dist/registry.js.map +1 -1
- package/dist/remote/components/data-list.d.ts +2 -2
- package/dist/remote/components/data-list.js +1 -34
- package/dist/remote/components/data-list.js.map +1 -1
- package/dist/remote/index.d.ts +1 -1
- package/dist/remote/index.js +1 -10
- package/dist/remote/plugin.d.ts +2 -0
- package/dist/remote/plugin.js +11 -0
- package/dist/remote/plugin.js.map +1 -0
- package/dist/table/components/bulk-bar.d.ts +1 -1
- package/dist/table/components/bulk-bar.js +4 -4
- package/dist/table/components/bulk-bar.js.map +1 -1
- package/dist/table/components/cells/badge-cell.d.ts +1 -1
- package/dist/table/components/cells/badge-cell.js +1 -1
- package/dist/table/components/cells/badge-cell.js.map +1 -1
- package/dist/table/components/cells/boolean-cell.d.ts +1 -1
- package/dist/table/components/cells/boolean-cell.js.map +1 -1
- package/dist/table/components/cells/icon-cell.d.ts +1 -1
- package/dist/table/components/cells/icon-cell.js.map +1 -1
- package/dist/table/components/cells/image-cell.d.ts +1 -1
- package/dist/table/components/cells/image-cell.js +1 -1
- package/dist/table/components/cells/image-cell.js.map +1 -1
- package/dist/table/components/cells/money-cell.d.ts +1 -1
- package/dist/table/components/cells/money-cell.js +1 -1
- package/dist/table/components/cells/money-cell.js.map +1 -1
- package/dist/table/components/cells/number-cell.d.ts +1 -1
- package/dist/table/components/cells/number-cell.js +1 -1
- package/dist/table/components/cells/number-cell.js.map +1 -1
- package/dist/table/components/cells/stack-cell.d.ts +1 -1
- package/dist/table/components/cells/stack-cell.js +3 -7
- package/dist/table/components/cells/stack-cell.js.map +1 -1
- package/dist/table/components/cells/text-cell.d.ts +1 -1
- package/dist/table/components/cells/text-cell.js +4 -4
- package/dist/table/components/cells/text-cell.js.map +1 -1
- package/dist/table/components/column-filter-control.d.ts +3 -3
- package/dist/table/components/column-filter-control.js +34 -19
- package/dist/table/components/column-filter-control.js.map +1 -1
- package/dist/table/components/column-header.d.ts +1 -1
- package/dist/table/components/column-header.js +7 -7
- package/dist/table/components/column-header.js.map +1 -1
- package/dist/table/components/column-visibility-menu.d.ts +1 -1
- package/dist/table/components/column-visibility-menu.js +3 -3
- package/dist/table/components/column-visibility-menu.js.map +1 -1
- package/dist/table/components/filter-bar.d.ts +9 -7
- package/dist/table/components/filter-bar.js +62 -52
- package/dist/table/components/filter-bar.js.map +1 -1
- package/dist/table/components/filter-controls.d.ts +5 -9
- package/dist/table/components/filter-controls.js +96 -224
- package/dist/table/components/filter-controls.js.map +1 -1
- package/dist/table/components/filter-value-input.d.ts +1 -1
- package/dist/table/components/filter-value-input.js +1 -1
- package/dist/table/components/filter-value-input.js.map +1 -1
- package/dist/table/components/pagination.d.ts +2 -2
- package/dist/table/components/pagination.js.map +1 -1
- package/dist/table/components/sort-bar.d.ts +1 -1
- package/dist/table/components/sort-bar.js +2 -2
- package/dist/table/components/sort-bar.js.map +1 -1
- package/dist/table/components/table-action-node.d.ts +1 -1
- package/dist/table/components/table-action-node.js +1 -1
- package/dist/table/components/table-action-node.js.map +1 -1
- package/dist/table/components/table-cell.d.ts +1 -1
- package/dist/table/components/table-cell.js +2 -2
- package/dist/table/components/table-cell.js.map +1 -1
- package/dist/table/components/table.d.ts +1 -1
- package/dist/table/components/table.js +23 -31
- package/dist/table/components/table.js.map +1 -1
- package/dist/{core → table/hooks}/use-column-visibility.d.ts +5 -3
- package/dist/{core → table/hooks}/use-column-visibility.js +4 -4
- package/dist/table/hooks/use-column-visibility.js.map +1 -0
- package/dist/table/{use-table-selection.js → hooks/use-table-selection.js} +1 -1
- package/dist/table/hooks/use-table-selection.js.map +1 -0
- package/dist/table/{use-table.d.ts → hooks/use-table.d.ts} +7 -7
- package/dist/table/{use-table.js → hooks/use-table.js} +12 -9
- package/dist/table/hooks/use-table.js.map +1 -0
- package/dist/table/index.d.ts +6 -1
- package/dist/table/index.js +5 -11
- package/dist/table/{align.d.ts → lib/align.d.ts} +1 -1
- package/dist/table/{align.js → lib/align.js} +1 -1
- package/dist/table/lib/align.js.map +1 -0
- package/dist/table/{bulk.d.ts → lib/bulk.d.ts} +3 -3
- package/dist/table/{bulk.js → lib/bulk.js} +1 -1
- package/dist/table/lib/bulk.js.map +1 -0
- package/dist/table/{filter-values.d.ts → lib/filter-values.d.ts} +10 -3
- package/dist/table/{filter-values.js → lib/filter-values.js} +14 -4
- package/dist/table/lib/filter-values.js.map +1 -0
- package/dist/table/{format.d.ts → lib/format.d.ts} +2 -2
- package/dist/table/{format.js → lib/format.js} +3 -3
- package/dist/table/lib/format.js.map +1 -0
- package/dist/table/{payload.d.ts → lib/payload.d.ts} +2 -3
- package/dist/table/{payload.js → lib/payload.js} +12 -9
- package/dist/table/lib/payload.js.map +1 -0
- package/dist/table/{query.d.ts → lib/query.d.ts} +3 -3
- package/dist/table/{query.js → lib/query.js} +27 -27
- package/dist/table/lib/query.js.map +1 -0
- package/dist/table/plugin.d.ts +2 -0
- package/dist/table/plugin.js +11 -0
- package/dist/table/plugin.js.map +1 -0
- package/dist/table/registry.d.ts +3 -1
- package/dist/table/registry.js.map +1 -1
- package/dist/table/types.d.ts +57 -7
- package/dist/toast/callout.d.ts +1 -1
- package/dist/toast/callout.js.map +1 -1
- package/dist/toast/index.d.ts +6 -5
- package/dist/toast/index.js +2 -1
- package/dist/toast/toast.d.ts +1 -1
- package/dist/toast/toaster.js.map +1 -1
- package/dist/toast/variant-styles.d.ts +1 -1
- package/dist/types/generated.d.ts +118 -64
- package/dist/types/index.d.ts +1 -1
- package/dist/{action/components → ui}/action-menu-context.js +1 -1
- package/dist/ui/action-menu-context.js.map +1 -0
- package/dist/{form/components/base → ui}/affix-group.d.ts +1 -1
- package/dist/{form/components/base → ui}/affix-group.js +3 -3
- package/dist/ui/affix-group.js.map +1 -0
- package/dist/{core/components → ui}/badge.d.ts +1 -1
- package/dist/{core/components → ui}/badge.js +2 -2
- package/dist/ui/badge.js.map +1 -0
- package/dist/{core/components → ui}/button.d.ts +2 -2
- package/dist/{core/components → ui}/button.js +5 -5
- package/dist/ui/button.js.map +1 -0
- package/dist/{core/components → ui}/card.d.ts +1 -1
- package/dist/{core/components → ui}/card.js +3 -3
- package/dist/ui/card.js.map +1 -0
- package/dist/{core/components → ui}/chart-view.d.ts +1 -1
- package/dist/{core/components → ui}/chart-view.js +5 -5
- package/dist/ui/chart-view.js.map +1 -0
- package/dist/{core/components → ui}/chart.d.ts +1 -1
- package/dist/{core/components → ui}/chart.js +1 -1
- package/dist/ui/chart.js.map +1 -0
- package/dist/{core/components → ui}/checkbox.js +3 -3
- package/dist/ui/checkbox.js.map +1 -0
- package/dist/{core/use-click-behavior.d.ts → ui/click-behavior.d.ts} +17 -19
- package/dist/ui/click-behavior.js +46 -0
- package/dist/ui/click-behavior.js.map +1 -0
- package/dist/{core/components → ui}/collapsible.d.ts +1 -1
- package/dist/{core/components → ui}/collapsible.js +6 -6
- package/dist/ui/collapsible.js.map +1 -0
- package/dist/{core/components → ui}/combobox.d.ts +1 -1
- package/dist/{core/components → ui}/combobox.js +4 -4
- package/dist/ui/combobox.js.map +1 -0
- package/dist/{core/components → ui}/confirm-dialog.d.ts +1 -1
- package/dist/{core/components → ui}/confirm-dialog.js +1 -1
- package/dist/ui/confirm-dialog.js.map +1 -0
- package/dist/{core/components → ui}/control.d.ts +1 -1
- package/dist/{core/components → ui}/control.js +1 -1
- package/dist/ui/control.js.map +1 -0
- package/dist/{clipboard → ui}/copyable-text.d.ts +1 -0
- package/dist/{clipboard → ui}/copyable-text.js +11 -3
- package/dist/ui/copyable-text.js.map +1 -0
- package/dist/{core/components → ui}/dialog.js +3 -3
- package/dist/ui/dialog.js.map +1 -0
- package/dist/{core/components → ui}/dropdown-menu.d.ts +1 -1
- package/dist/{core/components → ui}/dropdown-menu.js +3 -3
- package/dist/ui/dropdown-menu.js.map +1 -0
- package/dist/{core/components → ui}/floating-panel.d.ts +1 -1
- package/dist/{core/components → ui}/floating-panel.js +4 -4
- package/dist/ui/floating-panel.js.map +1 -0
- package/dist/{core/components → ui}/fragment.d.ts +1 -1
- package/dist/{core/components → ui}/fragment.js +5 -5
- package/dist/ui/fragment.js.map +1 -0
- package/dist/{core/components → ui}/grid.d.ts +1 -1
- package/dist/{core/components → ui}/grid.js +3 -3
- package/dist/ui/grid.js.map +1 -0
- package/dist/{core/components → ui}/heading.d.ts +1 -1
- package/dist/{core/components → ui}/heading.js +2 -2
- package/dist/ui/heading.js.map +1 -0
- package/dist/{core/components → ui}/icon.d.ts +1 -1
- package/dist/{core/components → ui}/icon.js +3 -3
- package/dist/ui/icon.js.map +1 -0
- package/dist/ui/index.d.ts +27 -0
- package/dist/ui/index.js +26 -0
- package/dist/{core/components → ui}/info-tooltip.js +3 -3
- package/dist/ui/info-tooltip.js.map +1 -0
- package/dist/{form/components/base → ui}/input-error.js +2 -2
- package/dist/ui/input-error.js.map +1 -0
- package/dist/{form/components/base → ui}/input-otp.js +2 -2
- package/dist/ui/input-otp.js.map +1 -0
- package/dist/{form/components/base → ui}/input.js +3 -3
- package/dist/ui/input.js.map +1 -0
- package/dist/{form/components/base → ui}/label.js +2 -2
- package/dist/ui/label.js.map +1 -0
- package/dist/{core/components → ui}/link.d.ts +1 -1
- package/dist/{core/components → ui}/link.js +8 -7
- package/dist/ui/link.js.map +1 -0
- package/dist/{core/components → ui}/modal.d.ts +1 -1
- package/dist/{core/components → ui}/modal.js +2 -2
- package/dist/ui/modal.js.map +1 -0
- package/dist/{form/components/base → ui}/password-input.js +3 -3
- package/dist/ui/password-input.js.map +1 -0
- package/dist/ui/plugin.d.ts +1 -0
- package/dist/{core/components/index.js → ui/plugin.js} +6 -6
- package/dist/ui/plugin.js.map +1 -0
- package/dist/{core/components → ui}/popover.js +2 -2
- package/dist/ui/popover.js.map +1 -0
- package/dist/{core/components → ui}/raw-block.d.ts +1 -1
- package/dist/{core/components → ui}/raw-block.js +1 -1
- package/dist/ui/raw-block.js.map +1 -0
- package/dist/{core/components → ui}/section.d.ts +1 -1
- package/dist/{core/components → ui}/section.js +6 -6
- package/dist/ui/section.js.map +1 -0
- package/dist/{core/components → ui}/segmented-control.d.ts +1 -1
- package/dist/{core/components → ui}/segmented-control.js +1 -1
- package/dist/ui/segmented-control.js.map +1 -0
- package/dist/{core/components → ui}/segmented-pills.d.ts +1 -1
- package/dist/{core/components → ui}/segmented-pills.js +2 -2
- package/dist/ui/segmented-pills.js.map +1 -0
- package/dist/{core/components → ui}/skeleton.js +2 -2
- package/dist/ui/skeleton.js.map +1 -0
- package/dist/{core/components → ui}/spinner.js +4 -4
- package/dist/ui/spinner.js.map +1 -0
- package/dist/{core/components → ui}/stack.d.ts +1 -1
- package/dist/{core/components → ui}/stack.js +3 -3
- package/dist/ui/stack.js.map +1 -0
- package/dist/{core/components → ui}/tabs.d.ts +1 -1
- package/dist/{core/components → ui}/tabs.js +3 -3
- package/dist/ui/tabs.js.map +1 -0
- package/dist/{core/components → ui}/text.d.ts +1 -1
- package/dist/{core/components → ui}/text.js +4 -4
- package/dist/ui/text.js.map +1 -0
- package/dist/{form/components/base → ui}/textarea.js +3 -3
- package/dist/ui/textarea.js.map +1 -0
- package/dist/{core/components → ui}/tooltip.d.ts +1 -1
- package/dist/{core/components → ui}/tooltip.js +3 -3
- package/dist/ui/tooltip.js.map +1 -0
- package/dist/vite.js +2 -2
- package/dist/vite.js.map +1 -1
- package/dist-standalone/chunks/chart-view-CK5fKIkR.js +36 -0
- package/dist-standalone/chunks/date-picker-field-BlCPFhZd.js +1 -0
- package/dist-standalone/chunks/dist-PaT1gYi_.js +2 -0
- package/dist-standalone/chunks/jsx-runtime-CJ_btYLc.js +1 -0
- package/dist-standalone/chunks/notifications-echo-DsfNc4Ge.js +1 -0
- package/dist-standalone/chunks/react-B8IZ02wI.js +1 -0
- package/dist-standalone/chunks/rich-editor-field-DH5dS5c1.js +154 -0
- package/dist-standalone/chunks/subscriptions-B3UuDBmx.js +1 -0
- package/dist-standalone/chunks/test-id-Dh3L6Gfh.js +1 -0
- package/dist-standalone/chunks/use-effect-dispatcher-k98Nzf9M.js +97 -0
- package/dist-standalone/chunks/with-selector-BwDoCrJJ.js +1 -0
- package/dist-standalone/lattice.css +3 -0
- package/dist-standalone/lattice.js +66 -0
- package/dist-standalone/manifest.json +18 -0
- package/dist-standalone/sprite.svg +1 -0
- package/package.json +33 -95
- package/resources/icons/align-center.svg +1 -1
- package/resources/icons/align-justify.svg +1 -1
- package/resources/icons/align-left.svg +1 -1
- package/resources/icons/align-right.svg +1 -1
- package/resources/icons/arrow-down.svg +1 -1
- package/resources/icons/arrow-up.svg +1 -1
- package/resources/icons/bell.svg +1 -1
- package/resources/icons/bold.svg +1 -1
- package/resources/icons/calendar.svg +1 -1
- package/resources/icons/check.svg +1 -1
- package/resources/icons/chevron-down.svg +1 -1
- package/resources/icons/chevron-left.svg +1 -1
- package/resources/icons/chevron-right.svg +1 -1
- package/resources/icons/chevrons-up-down.svg +1 -1
- package/resources/icons/circle-alert.svg +1 -1
- package/resources/icons/circle-check.svg +1 -1
- package/resources/icons/circle-help.svg +1 -1
- package/resources/icons/circle-x.svg +1 -1
- package/resources/icons/clock.svg +1 -1
- package/resources/icons/code.svg +1 -1
- package/resources/icons/columns-3.svg +1 -1
- package/resources/icons/copy.svg +1 -1
- package/resources/icons/external-link.svg +1 -1
- package/resources/icons/eye-off.svg +1 -1
- package/resources/icons/eye.svg +1 -1
- package/resources/icons/filter.svg +1 -1
- package/resources/icons/heading-1.svg +1 -1
- package/resources/icons/heading-2.svg +1 -1
- package/resources/icons/heading-3.svg +1 -1
- package/resources/icons/highlighter.svg +1 -1
- package/resources/icons/info.svg +1 -1
- package/resources/icons/italic.svg +1 -1
- package/resources/icons/layout-dashboard.svg +1 -1
- package/resources/icons/link.svg +1 -1
- package/resources/icons/list-ordered.svg +1 -1
- package/resources/icons/list.svg +1 -1
- package/resources/icons/loader-2.svg +1 -1
- package/resources/icons/minus.svg +1 -1
- package/resources/icons/more-horizontal.svg +1 -1
- package/resources/icons/panel-left.svg +1 -1
- package/resources/icons/pencil-line.svg +1 -1
- package/resources/icons/pencil.svg +1 -1
- package/resources/icons/plus.svg +1 -1
- package/resources/icons/quote.svg +1 -1
- package/resources/icons/rotate-ccw.svg +1 -1
- package/resources/icons/rows-3.svg +1 -1
- package/resources/icons/search.svg +1 -1
- package/resources/icons/send.svg +1 -1
- package/resources/icons/settings.svg +1 -1
- package/resources/icons/smile.svg +1 -1
- package/resources/icons/strikethrough.svg +1 -1
- package/resources/icons/table.svg +1 -1
- package/resources/icons/trash-2.svg +1 -1
- package/resources/icons/underline.svg +1 -1
- package/resources/icons/x.svg +1 -1
- package/dist/action/components/action-menu-context.js.map +0 -1
- package/dist/action/index.js.map +0 -1
- package/dist/action/run-action.js.map +0 -1
- package/dist/action/use-action.js.map +0 -1
- package/dist/chat/index.js.map +0 -1
- package/dist/chat/transport.js.map +0 -1
- package/dist/chat/use-chat.js.map +0 -1
- package/dist/clipboard/copyable-text.js.map +0 -1
- package/dist/core/column-sizing.js.map +0 -1
- package/dist/core/components/badge.js.map +0 -1
- package/dist/core/components/button.js.map +0 -1
- package/dist/core/components/card.js.map +0 -1
- package/dist/core/components/chart-view.js.map +0 -1
- package/dist/core/components/chart.js.map +0 -1
- package/dist/core/components/checkbox.js.map +0 -1
- package/dist/core/components/collapsible.js.map +0 -1
- package/dist/core/components/combobox.js.map +0 -1
- package/dist/core/components/confirm-dialog.js.map +0 -1
- package/dist/core/components/control.js.map +0 -1
- package/dist/core/components/dialog.js.map +0 -1
- package/dist/core/components/dropdown-menu.js.map +0 -1
- package/dist/core/components/floating-panel.js.map +0 -1
- package/dist/core/components/fragment.js.map +0 -1
- package/dist/core/components/grid.js.map +0 -1
- package/dist/core/components/heading.js.map +0 -1
- package/dist/core/components/icon.js.map +0 -1
- package/dist/core/components/index.d.ts +0 -1
- package/dist/core/components/index.js.map +0 -1
- package/dist/core/components/info-tooltip.js.map +0 -1
- package/dist/core/components/link.js.map +0 -1
- package/dist/core/components/modal.js.map +0 -1
- package/dist/core/components/popover.js.map +0 -1
- package/dist/core/components/raw-block.js.map +0 -1
- package/dist/core/components/section.js.map +0 -1
- package/dist/core/components/segmented-control.js.map +0 -1
- package/dist/core/components/segmented-pills.js.map +0 -1
- package/dist/core/components/skeleton.js.map +0 -1
- package/dist/core/components/spinner.js.map +0 -1
- package/dist/core/components/stack.js.map +0 -1
- package/dist/core/components/tabs.js.map +0 -1
- package/dist/core/components/text.js.map +0 -1
- package/dist/core/components/tooltip.js.map +0 -1
- package/dist/core/use-click-behavior.js +0 -46
- package/dist/core/use-click-behavior.js.map +0 -1
- package/dist/core/use-column-resizing.js.map +0 -1
- package/dist/core/use-column-visibility.js.map +0 -1
- package/dist/events/event-bridge.js.map +0 -1
- package/dist/form/components/base/affix-group.js.map +0 -1
- package/dist/form/components/base/input-error.js.map +0 -1
- package/dist/form/components/base/input-otp.js.map +0 -1
- package/dist/form/components/base/input.js.map +0 -1
- package/dist/form/components/base/label.js.map +0 -1
- package/dist/form/components/base/password-input.js.map +0 -1
- package/dist/form/components/base/textarea.js.map +0 -1
- package/dist/form/components/conditions.js.map +0 -1
- package/dist/form/components/context.js.map +0 -1
- package/dist/form/components/field-props.js.map +0 -1
- package/dist/form/components/field-scope.js.map +0 -1
- package/dist/form/components/fields/block-add-menu.js.map +0 -1
- package/dist/form/components/form-path.js.map +0 -1
- package/dist/form/components/form-transport.js +0 -30
- package/dist/form/components/form-transport.js.map +0 -1
- package/dist/form/components/override-keys.js +0 -12
- package/dist/form/components/override-keys.js.map +0 -1
- package/dist/form/components/prefill-context.js.map +0 -1
- package/dist/form/components/prefill-targets.js.map +0 -1
- package/dist/form/components/resolved-nodes.js.map +0 -1
- package/dist/form/components/row-layout-context.js.map +0 -1
- package/dist/form/components/use-controlled-field.js.map +0 -1
- package/dist/form/components/use-dependent-field.d.ts +0 -3
- package/dist/form/components/use-dependent-field.js.map +0 -1
- package/dist/form/components/use-field-commit.js.map +0 -1
- package/dist/form/components/use-form-resolver.js.map +0 -1
- package/dist/form/components/use-seed-default.js.map +0 -1
- package/dist/form/components/values.js +0 -52
- package/dist/form/components/values.js.map +0 -1
- package/dist/form/index.js.map +0 -1
- package/dist/layout/breadcrumbs.js.map +0 -1
- package/dist/layout/callouts.js.map +0 -1
- package/dist/layout/components.d.ts +0 -1
- package/dist/layout/components.js.map +0 -1
- package/dist/layout/context.js.map +0 -1
- package/dist/layout/dropdown.js.map +0 -1
- package/dist/layout/menu-item.js.map +0 -1
- package/dist/layout/menu.js.map +0 -1
- package/dist/layout/outlet.js.map +0 -1
- package/dist/layout/popover.js.map +0 -1
- package/dist/layout/schema-layout.js.map +0 -1
- package/dist/layout/sidebar.js.map +0 -1
- package/dist/layout/topbar.js.map +0 -1
- package/dist/notifications/index.js.map +0 -1
- package/dist/remote/index.js.map +0 -1
- package/dist/svg-sprite-client/index.d.ts +0 -1
- package/dist/svg-sprite-client/index.js +0 -0
- package/dist/table/align.js.map +0 -1
- package/dist/table/bulk.js.map +0 -1
- package/dist/table/components/filter-stack-bar.d.ts +0 -7
- package/dist/table/components/filter-stack-bar.js +0 -38
- package/dist/table/components/filter-stack-bar.js.map +0 -1
- package/dist/table/filter-values.js.map +0 -1
- package/dist/table/format.js.map +0 -1
- package/dist/table/index.js.map +0 -1
- package/dist/table/payload.js.map +0 -1
- package/dist/table/query.js.map +0 -1
- package/dist/table/use-table-selection.js.map +0 -1
- package/dist/table/use-table.js.map +0 -1
- package/dist/types/generated.js +0 -0
- package/dist/types/index.js +0 -0
- /package/dist/form/{components → hooks}/field-scope.d.ts +0 -0
- /package/dist/form/{components → hooks}/prefill-context.d.ts +0 -0
- /package/dist/form/{components → hooks}/row-layout-context.d.ts +0 -0
- /package/dist/form/{components → hooks}/use-seed-default.d.ts +0 -0
- /package/dist/form/{components → lib}/form-path.d.ts +0 -0
- /package/dist/form/{components → lib}/override-keys.d.ts +0 -0
- /package/dist/form/{components/types.js → types.js} +0 -0
- /package/dist/layout/{popover.d.ts → components/popover.d.ts} +0 -0
- /package/dist/layout/{schema-layout.d.ts → components/schema-layout.d.ts} +0 -0
- /package/dist/table/{use-table-selection.d.ts → hooks/use-table-selection.d.ts} +0 -0
- /package/dist/{action/components → ui}/action-menu-context.d.ts +0 -0
- /package/dist/{core/components → ui}/checkbox.d.ts +0 -0
- /package/dist/{core/components → ui}/dialog.d.ts +0 -0
- /package/dist/{core/components → ui}/info-tooltip.d.ts +0 -0
- /package/dist/{form/components/base → ui}/input-error.d.ts +0 -0
- /package/dist/{form/components/base → ui}/input-otp.d.ts +0 -0
- /package/dist/{form/components/base → ui}/input.d.ts +0 -0
- /package/dist/{form/components/base → ui}/label.d.ts +0 -0
- /package/dist/{form/components/base → ui}/password-input.d.ts +0 -0
- /package/dist/{core/components → ui}/popover.d.ts +0 -0
- /package/dist/{core/components → ui}/skeleton.d.ts +0 -0
- /package/dist/{core/components → ui}/spinner.d.ts +0 -0
- /package/dist/{form/components/base → ui}/textarea.d.ts +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LATTICE_EVENT } from "../../events/event-names.js";
|
|
2
2
|
import { withHeaders } from "../../core/headers.js";
|
|
3
|
-
import { FormProvider } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ResolvedNodesProvider } from "
|
|
7
|
-
import { FormValuesProvider } from "
|
|
8
|
-
import { useFormResolver } from "
|
|
3
|
+
import { FormProvider } from "../hooks/context.js";
|
|
4
|
+
import { PrefillProvider } from "../hooks/prefill-context.js";
|
|
5
|
+
import { walkFields } from "../lib/field-props.js";
|
|
6
|
+
import { ResolvedNodesProvider } from "../hooks/resolved-nodes.js";
|
|
7
|
+
import { FormValuesProvider } from "../hooks/values.js";
|
|
8
|
+
import { useFormResolver } from "../hooks/use-form-resolver.js";
|
|
9
9
|
import { FormSubmitButton } from "./base/submit-button.js";
|
|
10
10
|
import { Form } from "@inertiajs/react";
|
|
11
11
|
import { useEffect, useMemo } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.js","names":[],"sources":["../../../resources/js/form/components/form.tsx"],"sourcesContent":["import { Form as InertiaForm } from \"@inertiajs/react\";\nimport { withHeaders } from \"@lattice-php/lattice/core/headers\";\nimport { LATTICE_EVENT } from \"@lattice-php/lattice/events/event-names\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useEffect, useMemo } from \"react\";\nimport { FormSubmitButton } from \"./base/submit-button\";\nimport { FormProvider } from \"
|
|
1
|
+
{"version":3,"file":"form.js","names":[],"sources":["../../../resources/js/form/components/form.tsx"],"sourcesContent":["import { Form as InertiaForm } from \"@inertiajs/react\";\nimport { withHeaders } from \"@lattice-php/lattice/core/headers\";\nimport { LATTICE_EVENT } from \"@lattice-php/lattice/events/event-names\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useEffect, useMemo } from \"react\";\nimport { FormSubmitButton } from \"./base/submit-button\";\nimport { FormProvider } from \"@lattice-php/lattice/form/hooks/context\";\nimport { walkFields } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { PrefillProvider } from \"@lattice-php/lattice/form/hooks/prefill-context\";\nimport { ResolvedNodesProvider } from \"@lattice-php/lattice/form/hooks/resolved-nodes\";\nimport { useFormResolver } from \"@lattice-php/lattice/form/hooks/use-form-resolver\";\nimport { FormValuesProvider } from \"@lattice-php/lattice/form/hooks/values\";\n\ntype CollectedFields = {\n labels: Record<string, string>;\n values: Record<string, unknown>;\n};\n\nfunction collectFields(nodes: Node[] | undefined): CollectedFields {\n const collected: CollectedFields = { labels: {}, values: {} };\n\n walkFields(nodes, (props) => {\n if (!props.name) {\n return;\n }\n if (props.label) {\n collected.labels[props.name] = props.label;\n }\n if (props.value !== undefined) {\n collected.values[props.name] = props.value;\n }\n });\n\n return collected;\n}\n\nfunction FormResetListener({\n componentId,\n reset,\n}: {\n componentId?: string;\n reset: (...fields: string[]) => void;\n}) {\n useEffect(() => {\n const handler = (event: Event) => {\n const detail = (event as CustomEvent<{ form: string | null }>).detail;\n\n if (!detail?.form || detail.form === componentId) {\n reset();\n }\n };\n\n window.addEventListener(LATTICE_EVENT.resetForm, handler);\n\n return () => window.removeEventListener(LATTICE_EVENT.resetForm, handler);\n }, [componentId, reset]);\n\n return null;\n}\n\nfunction FormBody({\n action,\n children,\n componentRef,\n nodes,\n shouldRenderSubmitButton,\n submitLabel,\n summaryLabel,\n}: {\n action: string;\n children: React.ReactNode;\n componentRef: string;\n nodes: Node[] | undefined;\n shouldRenderSubmitButton: boolean;\n submitLabel: string;\n summaryLabel: string;\n}) {\n const { nodes: resolvedNodes, markUserEdit } = useFormResolver(action, componentRef, nodes);\n\n return (\n <PrefillProvider value={{ markUserEdit }}>\n <ResolvedNodesProvider nodes={resolvedNodes}>\n <div className=\"flex flex-col gap-6\">\n {children}\n\n {shouldRenderSubmitButton && (\n <div className=\"flex justify-end rounded-lt border border-lt-border bg-lt-surface px-lt-gutter py-4 shadow-lt-sm\">\n <FormSubmitButton label={submitLabel} summaryLabel={summaryLabel} />\n </div>\n )}\n </div>\n </ResolvedNodesProvider>\n </PrefillProvider>\n );\n}\n\nexport const FormComponent: RendererComponent<\"form\"> = ({ children, node }) => {\n const props = node.props;\n const action = props.action ?? \"#\";\n const errorBag = props.errorBag;\n const componentRef = props.ref ?? \"\";\n const method = props.method ?? \"post\";\n const precognitive = props.precognitive;\n const resetOnError = props.resetOnError ?? false;\n const resetOnSuccess = props.resetOnSuccess ?? [];\n const state = props.state;\n const { labels: fieldLabels, values: fieldValues } = useMemo(\n () => collectFields(node.schema),\n [node.schema],\n );\n const initialValues = useMemo(() => ({ ...fieldValues, ...state }), [fieldValues, state]);\n const shouldRenderSubmitButton = props.submitButton;\n const submitLabel = props.submitLabel ?? \"Submit\";\n const summaryLabel = props.validationSummaryLabel;\n const validationTimeout = props.validationTimeout ?? undefined;\n\n return (\n <InertiaForm\n action={action}\n data-slot=\"form\"\n data-lattice-component={node.id}\n errorBag={errorBag}\n method={method}\n resetOnError={resetOnError}\n resetOnSuccess={resetOnSuccess}\n validationTimeout={precognitive ? validationTimeout : undefined}\n headers={withHeaders(componentRef)}\n className=\"mx-auto flex w-full max-w-2xl flex-col gap-6\"\n >\n {({ clearErrors, errors, processing, reset, validate }) => (\n <FormProvider\n value={{\n action,\n clearErrors: (field) => clearErrors(field),\n componentId: node.id,\n componentRef,\n errors: errors as Record<string, string | undefined>,\n fieldLabels,\n precognitive,\n processing,\n validate: (field) => validate(field),\n }}\n >\n <FormResetListener componentId={node.id} reset={reset} />\n\n {props.status && (\n <div className=\"text-center text-sm font-medium text-lt-success\">{props.status}</div>\n )}\n\n <FormValuesProvider initial={initialValues}>\n <FormBody\n action={action}\n componentRef={componentRef}\n nodes={node.schema}\n shouldRenderSubmitButton={shouldRenderSubmitButton}\n submitLabel={submitLabel}\n summaryLabel={summaryLabel}\n >\n {children}\n </FormBody>\n </FormValuesProvider>\n </FormProvider>\n )}\n </InertiaForm>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,cAAc,OAA4C;CACjE,MAAM,YAA6B;EAAE,QAAQ,CAAC;EAAG,QAAQ,CAAC;CAAE;CAE5D,WAAW,QAAQ,UAAU;EAC3B,IAAI,CAAC,MAAM,MACT;EAEF,IAAI,MAAM,OACR,UAAU,OAAO,MAAM,QAAQ,MAAM;EAEvC,IAAI,MAAM,UAAU,KAAA,GAClB,UAAU,OAAO,MAAM,QAAQ,MAAM;CAEzC,CAAC;CAED,OAAO;AACT;AAEA,SAAS,kBAAkB,EACzB,aACA,SAIC;CACD,gBAAgB;EACd,MAAM,WAAW,UAAiB;GAChC,MAAM,SAAU,MAA+C;GAE/D,IAAI,CAAC,QAAQ,QAAQ,OAAO,SAAS,aACnC,MAAM;EAEV;EAEA,OAAO,iBAAiB,cAAc,WAAW,OAAO;EAExD,aAAa,OAAO,oBAAoB,cAAc,WAAW,OAAO;CAC1E,GAAG,CAAC,aAAa,KAAK,CAAC;CAEvB,OAAO;AACT;AAEA,SAAS,SAAS,EAChB,QACA,UACA,cACA,OACA,0BACA,aACA,gBASC;CACD,MAAM,EAAE,OAAO,eAAe,iBAAiB,gBAAgB,QAAQ,cAAc,KAAK;CAE1F,OACE,oBAAC,iBAAD;EAAiB,OAAO,EAAE,aAAa;YACrC,oBAAC,uBAAD;GAAuB,OAAO;aAC5B,qBAAC,OAAD;IAAK,WAAU;cAAf,CACG,UAEA,4BACC,oBAAC,OAAD;KAAK,WAAU;eACb,oBAAC,kBAAD;MAAkB,OAAO;MAA2B;KAAe,CAAA;IAChE,CAAA,CAEJ;;EACgB,CAAA;CACR,CAAA;AAErB;AAEA,IAAa,iBAA4C,EAAE,UAAU,WAAW;CAC9E,MAAM,QAAQ,KAAK;CACnB,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,WAAW,MAAM;CACvB,MAAM,eAAe,MAAM,OAAO;CAClC,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,eAAe,MAAM;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAC3C,MAAM,iBAAiB,MAAM,kBAAkB,CAAC;CAChD,MAAM,QAAQ,MAAM;CACpB,MAAM,EAAE,QAAQ,aAAa,QAAQ,gBAAgB,cAC7C,cAAc,KAAK,MAAM,GAC/B,CAAC,KAAK,MAAM,CACd;CACA,MAAM,gBAAgB,eAAe;EAAE,GAAG;EAAa,GAAG;CAAM,IAAI,CAAC,aAAa,KAAK,CAAC;CACxF,MAAM,2BAA2B,MAAM;CACvC,MAAM,cAAc,MAAM,eAAe;CACzC,MAAM,eAAe,MAAM;CAC3B,MAAM,oBAAoB,MAAM,qBAAqB,KAAA;CAErD,OACE,oBAAC,MAAD;EACU;EACR,aAAU;EACV,0BAAwB,KAAK;EACnB;EACF;EACM;EACE;EAChB,mBAAmB,eAAe,oBAAoB,KAAA;EACtD,SAAS,YAAY,YAAY;EACjC,WAAU;aAER,EAAE,aAAa,QAAQ,YAAY,OAAO,eAC1C,qBAAC,cAAD;GACE,OAAO;IACL;IACA,cAAc,UAAU,YAAY,KAAK;IACzC,aAAa,KAAK;IAClB;IACQ;IACR;IACA;IACA;IACA,WAAW,UAAU,SAAS,KAAK;GACrC;aAXF;IAaE,oBAAC,mBAAD;KAAmB,aAAa,KAAK;KAAW;IAAQ,CAAA;IAEvD,MAAM,UACL,oBAAC,OAAD;KAAK,WAAU;eAAmD,MAAM;IAAY,CAAA;IAGtF,oBAAC,oBAAD;KAAoB,SAAS;eAC3B,oBAAC,UAAD;MACU;MACM;MACd,OAAO,KAAK;MACc;MACb;MACC;MAEb;KACO,CAAA;IACQ,CAAA;GACR;;CAEL,CAAA;AAEjB"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export { BuilderComponent } from './fields/builder';
|
|
2
|
-
export { CheckboxComponent } from './fields/checkbox';
|
|
3
|
-
export { ChoiceComponent } from './fields/choice';
|
|
4
|
-
export { DateInputComponent } from './fields/date-input';
|
|
5
|
-
export { DateTimeInputComponent } from './fields/date-time-input';
|
|
6
|
-
export { FileUploadComponent } from './fields/file-upload';
|
|
7
|
-
export { FormComponent } from './form';
|
|
8
|
-
export { HiddenInputComponent } from './fields/hidden-input';
|
|
9
|
-
export { NumberInputComponent } from './fields/number-input';
|
|
10
|
-
export { OtpInputComponent } from './fields/otp-input';
|
|
11
|
-
export { PasswordInputComponent } from './fields/password-input';
|
|
12
|
-
export { RepeaterComponent } from './fields/repeater';
|
|
13
|
-
export { SelectComponent } from './fields/select';
|
|
14
|
-
export { TextareaComponent } from './fields/textarea';
|
|
15
|
-
export { TextInputComponent } from './fields/text-input';
|
|
16
|
-
export { TimeInputComponent } from './fields/time-input';
|
|
17
|
-
export { ToggleComponent } from './fields/toggle';
|
|
1
|
+
export { BuilderComponent } from './fields/builder.js';
|
|
2
|
+
export { CheckboxComponent } from './fields/checkbox.js';
|
|
3
|
+
export { ChoiceComponent } from './fields/choice.js';
|
|
4
|
+
export { DateInputComponent } from './fields/date-input.js';
|
|
5
|
+
export { DateTimeInputComponent } from './fields/date-time-input.js';
|
|
6
|
+
export { FileUploadComponent } from './fields/file-upload.js';
|
|
7
|
+
export { FormComponent } from './form.js';
|
|
8
|
+
export { HiddenInputComponent } from './fields/hidden-input.js';
|
|
9
|
+
export { NumberInputComponent } from './fields/number-input.js';
|
|
10
|
+
export { OtpInputComponent } from './fields/otp-input.js';
|
|
11
|
+
export { PasswordInputComponent } from './fields/password-input.js';
|
|
12
|
+
export { RepeaterComponent } from './fields/repeater.js';
|
|
13
|
+
export { SelectComponent } from './fields/select.js';
|
|
14
|
+
export { TextareaComponent } from './fields/textarea.js';
|
|
15
|
+
export { TextInputComponent } from './fields/text-input.js';
|
|
16
|
+
export { TimeInputComponent } from './fields/time-input.js';
|
|
17
|
+
export { ToggleComponent } from './fields/toggle.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for hosting a form runtime outside the `<Form>` component — action
|
|
3
|
+
* dialogs, table filter rows, and similar schema-driven surfaces. The counterpart
|
|
4
|
+
* to `toolkit.ts` (which serves custom-field authors): everything a host needs to
|
|
5
|
+
* provide form state, prefill, and dependent-field resolution around rendered
|
|
6
|
+
* fields. Form modules not re-exported here or in the toolkit are internal and
|
|
7
|
+
* may change without notice.
|
|
8
|
+
*/
|
|
9
|
+
export { FormProvider } from './hooks/context.js';
|
|
10
|
+
export { PrefillProvider } from './hooks/prefill-context.js';
|
|
11
|
+
export { ResolvedNodesProvider } from './hooks/resolved-nodes.js';
|
|
12
|
+
export { FieldCommitOverrideProvider } from './hooks/use-field-commit.js';
|
|
13
|
+
export { useFormResolver } from './hooks/use-form-resolver.js';
|
|
14
|
+
export { FormValuesProvider, useFormValues, useSetFormValue } from './hooks/values.js';
|
|
15
|
+
export { walkFields } from './lib/field-props.js';
|
|
16
|
+
export { appendPath, getPath, setPath } from './lib/form-path.js';
|
|
17
|
+
export { FORM_DEBOUNCE_MS } from './lib/form-transport.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormProvider } from "./hooks/context.js";
|
|
2
|
+
import { PrefillProvider } from "./hooks/prefill-context.js";
|
|
3
|
+
import { walkFields } from "./lib/field-props.js";
|
|
4
|
+
import { appendPath, getPath, setPath } from "./lib/form-path.js";
|
|
5
|
+
import { ResolvedNodesProvider } from "./hooks/resolved-nodes.js";
|
|
6
|
+
import { FormValuesProvider, useFormValues, useSetFormValue } from "./hooks/values.js";
|
|
7
|
+
import { FieldCommitOverrideProvider } from "./hooks/use-field-commit.js";
|
|
8
|
+
import { FORM_DEBOUNCE_MS } from "./lib/form-transport.js";
|
|
9
|
+
import { useFormResolver } from "./hooks/use-form-resolver.js";
|
|
10
|
+
export { FORM_DEBOUNCE_MS, FieldCommitOverrideProvider, FormProvider, FormValuesProvider, PrefillProvider, ResolvedNodesProvider, appendPath, getPath, setPath, useFormResolver, useFormValues, useSetFormValue, walkFields };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { Option } from '../../core/types.js';
|
|
1
2
|
type FormContextValue = {
|
|
2
3
|
action: string;
|
|
3
4
|
clearErrors: (field: string) => void;
|
|
4
5
|
componentId?: string;
|
|
5
6
|
componentRef: string;
|
|
6
7
|
errors: Record<string, string | undefined>;
|
|
8
|
+
fieldIdPrefix?: string;
|
|
7
9
|
fieldLabels: Record<string, string>;
|
|
8
10
|
precognitive: boolean;
|
|
9
11
|
processing: boolean;
|
|
12
|
+
searchOptions?: (field: string, query: string, values: Record<string, unknown>, signal: AbortSignal) => Promise<Option[]>;
|
|
10
13
|
validate: (field: string) => void;
|
|
11
14
|
};
|
|
12
15
|
export declare function FormProvider({ children, value, }: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
//#region resources/js/form/
|
|
3
|
+
//#region resources/js/form/hooks/context.tsx
|
|
4
4
|
var FormContext = createContext({
|
|
5
5
|
action: "#",
|
|
6
6
|
clearErrors: () => {},
|
|
7
7
|
componentId: void 0,
|
|
8
8
|
componentRef: "",
|
|
9
9
|
errors: {},
|
|
10
|
+
fieldIdPrefix: void 0,
|
|
10
11
|
fieldLabels: {},
|
|
11
12
|
precognitive: false,
|
|
12
13
|
processing: false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../resources/js/form/hooks/context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { Option } from \"@lattice-php/lattice/core/types\";\n\ntype FormContextValue = {\n action: string;\n clearErrors: (field: string) => void;\n componentId?: string;\n componentRef: string;\n errors: Record<string, string | undefined>;\n fieldIdPrefix?: string;\n fieldLabels: Record<string, string>;\n precognitive: boolean;\n processing: boolean;\n searchOptions?: (\n field: string,\n query: string,\n values: Record<string, unknown>,\n signal: AbortSignal,\n ) => Promise<Option[]>;\n validate: (field: string) => void;\n};\n\nconst FormContext = createContext<FormContextValue>({\n action: \"#\",\n clearErrors: () => {},\n componentId: undefined,\n componentRef: \"\",\n errors: {},\n fieldIdPrefix: undefined,\n fieldLabels: {},\n precognitive: false,\n processing: false,\n validate: () => {},\n});\n\nexport function FormProvider({\n children,\n value,\n}: {\n children: React.ReactNode;\n value: FormContextValue;\n}) {\n return <FormContext.Provider value={value}>{children}</FormContext.Provider>;\n}\n\nexport function useFormContext() {\n return useContext(FormContext);\n}\n"],"mappings":";;;AAsBA,IAAM,cAAc,cAAgC;CAClD,QAAQ;CACR,mBAAmB,CAAC;CACpB,aAAa,KAAA;CACb,cAAc;CACd,QAAQ,CAAC;CACT,eAAe,KAAA;CACf,aAAa,CAAC;CACd,cAAc;CACd,YAAY;CACZ,gBAAgB,CAAC;AACnB,CAAC;AAED,SAAgB,aAAa,EAC3B,UACA,SAIC;CACD,OAAO,oBAAC,YAAY,UAAb;EAA6B;EAAQ;CAA+B,CAAA;AAC7E;AAEA,SAAgB,iBAAiB;CAC/B,OAAO,WAAW,WAAW;AAC/B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { appendPath, getPath, toHtmlName } from "
|
|
2
|
-
import { buildOverrideKey, rowIdFrom } from "
|
|
1
|
+
import { appendPath, getPath, toHtmlName } from "../lib/form-path.js";
|
|
2
|
+
import { buildOverrideKey, rowIdFrom } from "../lib/override-keys.js";
|
|
3
3
|
import { createContext, useContext, useMemo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region resources/js/form/
|
|
5
|
+
//#region resources/js/form/hooks/field-scope.tsx
|
|
6
6
|
var FieldScopeContext = createContext(null);
|
|
7
7
|
function childCollectionIdentity(base, parent) {
|
|
8
8
|
if (!parent) return base;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-scope.js","names":[],"sources":["../../../resources/js/form/hooks/field-scope.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport { appendPath, getPath, toHtmlName } from \"@lattice-php/lattice/form/lib/form-path\";\nimport { buildOverrideKey, rowIdFrom } from \"@lattice-php/lattice/form/lib/override-keys\";\n\ntype FieldScopeValue = {\n row: Record<string, unknown>;\n rowId: string | null;\n path: string;\n values: Record<string, unknown>;\n identityPath: string;\n getValue: (name: string) => unknown;\n setValue: (name: string, value: unknown) => void;\n scopedName: (name: string) => string;\n errorKey: (name: string) => string;\n overrideKey: (name: string) => string;\n};\n\nconst FieldScopeContext = createContext<FieldScopeValue | null>(null);\n\nfunction childCollectionIdentity(base: string, parent: FieldScopeValue | null): string {\n if (!parent) {\n return base;\n }\n\n const local = base.startsWith(`${parent.path}.`) ? base.slice(parent.path.length + 1) : base;\n\n return appendPath(parent.identityPath, local);\n}\n\nexport function FieldScopeProvider({\n base,\n index,\n row,\n onChange,\n children,\n}: {\n base: string;\n index: number;\n row: Record<string, unknown>;\n onChange: (name: string, value: unknown) => void;\n children: React.ReactNode;\n}) {\n const parent = useContext(FieldScopeContext);\n\n const value = useMemo<FieldScopeValue>(() => {\n const scopedRow = row ?? {};\n const rowId = rowIdFrom(scopedRow);\n const path = appendPath(base, index);\n const identityCollection = childCollectionIdentity(base, parent);\n const identityPath = appendPath(identityCollection, rowId ?? index);\n\n return {\n row: scopedRow,\n rowId,\n path,\n values: parent ? { ...parent.values, ...scopedRow } : scopedRow,\n identityPath,\n getValue: (name) => getPath(scopedRow, name),\n setValue: onChange,\n scopedName: (name) => toHtmlName(appendPath(path, name)),\n errorKey: (name) => appendPath(path, name),\n overrideKey: (name) => buildOverrideKey(identityCollection, rowId, index, name),\n };\n }, [base, index, row, onChange, parent]);\n\n return <FieldScopeContext.Provider value={value}>{children}</FieldScopeContext.Provider>;\n}\n\n/** Null outside a row so callers can preserve top-level behavior without a wrapper. */\nexport function useFieldScope(): FieldScopeValue | null {\n return useContext(FieldScopeContext);\n}\n"],"mappings":";;;;;AAiBA,IAAM,oBAAoB,cAAsC,IAAI;AAEpE,SAAS,wBAAwB,MAAc,QAAwC;CACrF,IAAI,CAAC,QACH,OAAO;CAGT,MAAM,QAAQ,KAAK,WAAW,GAAG,OAAO,KAAK,EAAE,IAAI,KAAK,MAAM,OAAO,KAAK,SAAS,CAAC,IAAI;CAExF,OAAO,WAAW,OAAO,cAAc,KAAK;AAC9C;AAEA,SAAgB,mBAAmB,EACjC,MACA,OACA,KACA,UACA,YAOC;CACD,MAAM,SAAS,WAAW,iBAAiB;CAE3C,MAAM,QAAQ,cAA+B;EAC3C,MAAM,YAAY,OAAO,CAAC;EAC1B,MAAM,QAAQ,UAAU,SAAS;EACjC,MAAM,OAAO,WAAW,MAAM,KAAK;EACnC,MAAM,qBAAqB,wBAAwB,MAAM,MAAM;EAC/D,MAAM,eAAe,WAAW,oBAAoB,SAAS,KAAK;EAElE,OAAO;GACL,KAAK;GACL;GACA;GACA,QAAQ,SAAS;IAAE,GAAG,OAAO;IAAQ,GAAG;GAAU,IAAI;GACtD;GACA,WAAW,SAAS,QAAQ,WAAW,IAAI;GAC3C,UAAU;GACV,aAAa,SAAS,WAAW,WAAW,MAAM,IAAI,CAAC;GACvD,WAAW,SAAS,WAAW,MAAM,IAAI;GACzC,cAAc,SAAS,iBAAiB,oBAAoB,OAAO,OAAO,IAAI;EAChF;CACF,GAAG;EAAC;EAAM;EAAO;EAAK;EAAU;CAAM,CAAC;CAEvC,OAAO,oBAAC,kBAAkB,UAAnB;EAAmC;EAAQ;CAAqC,CAAA;AACzF;;AAGA,SAAgB,gBAAwC;CACtD,OAAO,WAAW,iBAAiB;AACrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
//#region resources/js/form/
|
|
2
|
+
//#region resources/js/form/hooks/prefill-context.ts
|
|
3
3
|
var PrefillContext = createContext(null);
|
|
4
4
|
var PrefillProvider = PrefillContext.Provider;
|
|
5
5
|
function usePrefillController() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefill-context.js","names":[],"sources":["../../../resources/js/form/hooks/prefill-context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport type PrefillController = {\n markUserEdit: (overrideKey: string) => void;\n};\n\nconst PrefillContext = createContext<PrefillController | null>(null);\n\nexport const PrefillProvider = PrefillContext.Provider;\n\nexport function usePrefillController(): PrefillController | null {\n return useContext(PrefillContext);\n}\n"],"mappings":";;AAMA,IAAM,iBAAiB,cAAwC,IAAI;AAEnE,IAAa,kBAAkB,eAAe;AAE9C,SAAgB,uBAAiD;CAC/D,OAAO,WAAW,cAAc;AAClC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { fieldProps } from "
|
|
1
|
+
import { fieldProps } from "../lib/field-props.js";
|
|
2
2
|
import { useFieldScope } from "./field-scope.js";
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region resources/js/form/
|
|
5
|
+
//#region resources/js/form/hooks/resolved-nodes.tsx
|
|
6
6
|
var ResolvedNodesContext = createContext({});
|
|
7
7
|
function ResolvedNodesProvider({ nodes, children }) {
|
|
8
8
|
return /* @__PURE__ */ jsx(ResolvedNodesContext.Provider, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolved-nodes.js","names":[],"sources":["../../../resources/js/form/hooks/resolved-nodes.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { Node } from \"@lattice-php/lattice/core/types\";\nimport { fieldProps } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { useFieldScope } from \"./field-scope\";\n\nconst ResolvedNodesContext = createContext<Record<string, Node>>({});\n\nexport function ResolvedNodesProvider({\n nodes,\n children,\n}: {\n nodes: Record<string, Node>;\n children: React.ReactNode;\n}) {\n return <ResolvedNodesContext.Provider value={nodes}>{children}</ResolvedNodesContext.Provider>;\n}\n\nexport function useResolvedNode(node: Node): Node {\n const nodes = useContext(ResolvedNodesContext);\n const name = fieldProps(node).name ?? \"\";\n const scope = useFieldScope();\n const path = name && scope ? scope.errorKey(name) : name;\n\n return (path && nodes[path]) || (name && nodes[name]) || node;\n}\n"],"mappings":";;;;;AAKA,IAAM,uBAAuB,cAAoC,CAAC,CAAC;AAEnE,SAAgB,sBAAsB,EACpC,OACA,YAIC;CACD,OAAO,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO;EAAQ;CAAwC,CAAA;AAC/F;AAEA,SAAgB,gBAAgB,MAAkB;CAChD,MAAM,QAAQ,WAAW,oBAAoB;CAC7C,MAAM,OAAO,WAAW,IAAI,EAAE,QAAQ;CACtC,MAAM,QAAQ,cAAc;CAC5B,MAAM,OAAO,QAAQ,QAAQ,MAAM,SAAS,IAAI,IAAI;CAEpD,OAAQ,QAAQ,MAAM,SAAW,QAAQ,MAAM,SAAU;AAC3D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
//#region resources/js/form/
|
|
3
|
+
//#region resources/js/form/hooks/row-layout-context.tsx
|
|
4
4
|
var TableCellContext = createContext(false);
|
|
5
5
|
function TableCellProvider({ children }) {
|
|
6
6
|
return /* @__PURE__ */ jsx(TableCellContext.Provider, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-layout-context.js","names":[],"sources":["../../../resources/js/form/hooks/row-layout-context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nconst TableCellContext = createContext(false);\n\nexport function TableCellProvider({ children }: { children: React.ReactNode }) {\n return <TableCellContext.Provider value={true}>{children}</TableCellContext.Provider>;\n}\n\n/** True when a field is being rendered inside a table-layout cell (no own label). */\nexport function useInTableCell(): boolean {\n return useContext(TableCellContext);\n}\n"],"mappings":";;;AAEA,IAAM,mBAAmB,cAAc,KAAK;AAE5C,SAAgB,kBAAkB,EAAE,YAA2C;CAC7E,OAAO,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAAO;CAAoC,CAAA;AACtF;;AAGA,SAAgB,iBAA0B;CACxC,OAAO,WAAW,gBAAgB;AACpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node } from '../../core/types';
|
|
2
|
-
import { FieldState } from '
|
|
1
|
+
import { Node } from '../../core/types.js';
|
|
2
|
+
import { FieldState } from '../lib/conditions.js';
|
|
3
3
|
export type ControlledField = FieldState & {
|
|
4
4
|
localName: string;
|
|
5
5
|
name: string;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { testIdentity } from "../../core/test-id.js";
|
|
2
2
|
import { useFormContext } from "./context.js";
|
|
3
|
-
import { fieldProps } from "
|
|
3
|
+
import { fieldProps } from "../lib/field-props.js";
|
|
4
4
|
import { useFieldScope } from "./field-scope.js";
|
|
5
5
|
import { useFormValue } from "./values.js";
|
|
6
|
-
import { useDependentField } from "./use-dependent-field.js";
|
|
7
6
|
import { useFieldCommit } from "./use-field-commit.js";
|
|
8
|
-
|
|
7
|
+
import { useDependentField } from "./use-dependent-field.js";
|
|
8
|
+
import { fieldDomName } from "../lib/field-dom-name.js";
|
|
9
|
+
//#region resources/js/form/hooks/use-controlled-field.ts
|
|
9
10
|
function useControlledField(node) {
|
|
10
|
-
const { errors } = useFormContext();
|
|
11
|
+
const { errors, fieldIdPrefix } = useFormContext();
|
|
11
12
|
const scope = useFieldScope();
|
|
12
13
|
const state = useDependentField(node);
|
|
13
14
|
const props = fieldProps(node);
|
|
@@ -16,7 +17,7 @@ function useControlledField(node) {
|
|
|
16
17
|
const storedValue = scope ? scope.getValue(localName) : globalValue;
|
|
17
18
|
const currentValue = storedValue !== void 0 ? storedValue : props.value;
|
|
18
19
|
const value = typeof currentValue === "string" || typeof currentValue === "number" ? String(currentValue) : "";
|
|
19
|
-
const domName = scope ? scope.scopedName(localName) : localName;
|
|
20
|
+
const domName = fieldDomName(scope ? scope.scopedName(localName) : localName, fieldIdPrefix);
|
|
20
21
|
const errorKey = scope ? scope.errorKey(localName) : localName;
|
|
21
22
|
const { commit: commitField, change: changeField, blur: blurField } = useFieldCommit();
|
|
22
23
|
const commit = (next) => commitField(localName, next);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-controlled-field.js","names":[],"sources":["../../../resources/js/form/hooks/use-controlled-field.ts"],"sourcesContent":["import type { Node } from \"@lattice-php/lattice/core/types\";\nimport { testIdentity } from \"@lattice-php/lattice/core/test-id\";\nimport type { FieldState } from \"@lattice-php/lattice/form/lib/conditions\";\nimport { fieldProps } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormContext } from \"./context\";\nimport { fieldDomName } from \"@lattice-php/lattice/form/lib/field-dom-name\";\nimport { useDependentField } from \"./use-dependent-field\";\nimport { useFieldCommit } from \"./use-field-commit\";\nimport { useFormValue } from \"./values\";\n\nexport type ControlledField = FieldState & {\n localName: string;\n name: string;\n testId?: string;\n value: string;\n error?: string;\n commit: (value: unknown) => void;\n change: (value: unknown) => void;\n blur: () => void;\n};\n\nexport function useControlledField(node: Node): ControlledField {\n const { errors, fieldIdPrefix } = useFormContext();\n const scope = useFieldScope();\n const state = useDependentField(node);\n const props = fieldProps(node);\n const localName = props.name ?? \"\";\n\n const globalValue = useFormValue(localName);\n const storedValue = scope ? scope.getValue(localName) : globalValue;\n const currentValue = storedValue !== undefined ? storedValue : props.value;\n const value =\n typeof currentValue === \"string\" || typeof currentValue === \"number\"\n ? String(currentValue)\n : \"\";\n\n const domName = fieldDomName(scope ? scope.scopedName(localName) : localName, fieldIdPrefix);\n const errorKey = scope ? scope.errorKey(localName) : localName;\n\n const { commit: commitField, change: changeField, blur: blurField } = useFieldCommit();\n const commit = (next: unknown): void => commitField(localName, next);\n const change = (next: unknown): void => changeField(localName, next);\n const blur = (): void => blurField(localName);\n\n return {\n ...state,\n localName,\n name: domName,\n testId: testIdentity(localName),\n value,\n error: errors[errorKey],\n commit,\n change,\n blur,\n };\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,mBAAmB,MAA6B;CAC9D,MAAM,EAAE,QAAQ,kBAAkB,eAAe;CACjD,MAAM,QAAQ,cAAc;CAC5B,MAAM,QAAQ,kBAAkB,IAAI;CACpC,MAAM,QAAQ,WAAW,IAAI;CAC7B,MAAM,YAAY,MAAM,QAAQ;CAEhC,MAAM,cAAc,aAAa,SAAS;CAC1C,MAAM,cAAc,QAAQ,MAAM,SAAS,SAAS,IAAI;CACxD,MAAM,eAAe,gBAAgB,KAAA,IAAY,cAAc,MAAM;CACrE,MAAM,QACJ,OAAO,iBAAiB,YAAY,OAAO,iBAAiB,WACxD,OAAO,YAAY,IACnB;CAEN,MAAM,UAAU,aAAa,QAAQ,MAAM,WAAW,SAAS,IAAI,WAAW,aAAa;CAC3F,MAAM,WAAW,QAAQ,MAAM,SAAS,SAAS,IAAI;CAErD,MAAM,EAAE,QAAQ,aAAa,QAAQ,aAAa,MAAM,cAAc,eAAe;CACrF,MAAM,UAAU,SAAwB,YAAY,WAAW,IAAI;CACnE,MAAM,UAAU,SAAwB,YAAY,WAAW,IAAI;CACnE,MAAM,aAAmB,UAAU,SAAS;CAE5C,OAAO;EACL,GAAG;EACH;EACA,MAAM;EACN,QAAQ,aAAa,SAAS;EAC9B;EACA,OAAO,OAAO;EACd;EACA;EACA;CACF;AACF"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { fieldProps } from "
|
|
1
|
+
import { fieldProps } from "../lib/field-props.js";
|
|
2
2
|
import { useFieldScope } from "./field-scope.js";
|
|
3
|
-
import {
|
|
4
|
-
import { evaluateConditions } from "
|
|
5
|
-
|
|
3
|
+
import { useFormValuesFor } from "./values.js";
|
|
4
|
+
import { conditionFields, evaluateConditions } from "../lib/conditions.js";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
//#region resources/js/form/hooks/use-dependent-field.ts
|
|
6
7
|
function useDependentField(node) {
|
|
7
|
-
const values = useFormValues();
|
|
8
8
|
const scope = useFieldScope();
|
|
9
9
|
const props = fieldProps(node);
|
|
10
|
+
const values = useFormValuesFor(useMemo(() => conditionFields(props.conditions), [props.conditions]));
|
|
10
11
|
const conditionValues = scope ? {
|
|
11
12
|
...values,
|
|
12
13
|
...scope.values
|
|
13
14
|
} : values;
|
|
14
15
|
return evaluateConditions(props.conditions ?? void 0, conditionValues, {
|
|
15
|
-
hidden: props.hidden ?? false,
|
|
16
16
|
required: props.required ?? false,
|
|
17
17
|
readOnly: props.readOnly ?? false,
|
|
18
18
|
disabled: props.disabled ?? false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dependent-field.js","names":[],"sources":["../../../resources/js/form/hooks/use-dependent-field.ts"],"sourcesContent":["import type { Node } from \"@lattice-php/lattice/core/types\";\nimport { useMemo } from \"react\";\nimport {\n conditionFields,\n type FieldState,\n evaluateConditions,\n} from \"@lattice-php/lattice/form/lib/conditions\";\nimport { fieldProps } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormValuesFor } from \"./values\";\n\nexport function useDependentField(node: Node): FieldState {\n const scope = useFieldScope();\n const props = fieldProps(node);\n const fields = useMemo(() => conditionFields(props.conditions), [props.conditions]);\n const values = useFormValuesFor(fields);\n // Bare condition names resolve to row siblings first; form values remain the fallback.\n const conditionValues = scope ? { ...values, ...scope.values } : values;\n\n return evaluateConditions(props.conditions ?? undefined, conditionValues, {\n required: props.required ?? false,\n readOnly: props.readOnly ?? false,\n disabled: props.disabled ?? false,\n });\n}\n"],"mappings":";;;;;;AAWA,SAAgB,kBAAkB,MAAwB;CACxD,MAAM,QAAQ,cAAc;CAC5B,MAAM,QAAQ,WAAW,IAAI;CAE7B,MAAM,SAAS,iBADA,cAAc,gBAAgB,MAAM,UAAU,GAAG,CAAC,MAAM,UAAU,CACjD,CAAM;CAEtC,MAAM,kBAAkB,QAAQ;EAAE,GAAG;EAAQ,GAAG,MAAM;CAAO,IAAI;CAEjE,OAAO,mBAAmB,MAAM,cAAc,KAAA,GAAW,iBAAiB;EACxE,UAAU,MAAM,YAAY;EAC5B,UAAU,MAAM,YAAY;EAC5B,UAAU,MAAM,YAAY;CAC9B,CAAC;AACH"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
type FieldCommit = {
|
|
2
3
|
/** Write the value and validate immediately (precognitive) or clear errors. */
|
|
3
4
|
commit: (name: string, value: unknown) => void;
|
|
@@ -6,6 +7,10 @@ type FieldCommit = {
|
|
|
6
7
|
/** Validate the field now if precognitive (e.g. on blur or popover close). */
|
|
7
8
|
blur: (name: string) => void;
|
|
8
9
|
};
|
|
10
|
+
export declare function FieldCommitOverrideProvider({ children, value, }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
value: FieldCommit;
|
|
13
|
+
}): import('react').FunctionComponentElement<import('react').ProviderProps<FieldCommit | null>>;
|
|
9
14
|
/**
|
|
10
15
|
* The shared field-mutation contract every form field uses to write its value
|
|
11
16
|
* and drive precognition. Fields that validate on change call `commit`; fields
|
|
@@ -2,7 +2,12 @@ import { useFormContext } from "./context.js";
|
|
|
2
2
|
import { usePrefillController } from "./prefill-context.js";
|
|
3
3
|
import { useFieldScope } from "./field-scope.js";
|
|
4
4
|
import { useSetFormValue } from "./values.js";
|
|
5
|
-
|
|
5
|
+
import { createContext, createElement, useContext } from "react";
|
|
6
|
+
//#region resources/js/form/hooks/use-field-commit.ts
|
|
7
|
+
var FieldCommitOverrideContext = createContext(null);
|
|
8
|
+
function FieldCommitOverrideProvider({ children, value }) {
|
|
9
|
+
return createElement(FieldCommitOverrideContext.Provider, { value }, children);
|
|
10
|
+
}
|
|
6
11
|
/**
|
|
7
12
|
* The shared field-mutation contract every form field uses to write its value
|
|
8
13
|
* and drive precognition. Fields that validate on change call `commit`; fields
|
|
@@ -13,10 +18,12 @@ import { useSetFormValue } from "./values.js";
|
|
|
13
18
|
* behavior is identical to before.
|
|
14
19
|
*/
|
|
15
20
|
function useFieldCommit() {
|
|
21
|
+
const override = useContext(FieldCommitOverrideContext);
|
|
16
22
|
const { clearErrors, precognitive, validate } = useFormContext();
|
|
17
23
|
const setGlobal = useSetFormValue();
|
|
18
24
|
const scope = useFieldScope();
|
|
19
25
|
const prefill = usePrefillController();
|
|
26
|
+
if (override) return override;
|
|
20
27
|
const write = (name, value) => {
|
|
21
28
|
if (scope) scope.setValue(name, value);
|
|
22
29
|
else setGlobal(name, value);
|
|
@@ -39,6 +46,6 @@ function useFieldCommit() {
|
|
|
39
46
|
};
|
|
40
47
|
}
|
|
41
48
|
//#endregion
|
|
42
|
-
export { useFieldCommit };
|
|
49
|
+
export { FieldCommitOverrideProvider, useFieldCommit };
|
|
43
50
|
|
|
44
51
|
//# sourceMappingURL=use-field-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-field-commit.js","names":[],"sources":["../../../resources/js/form/hooks/use-field-commit.ts"],"sourcesContent":["import { createContext, createElement, useContext } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormContext } from \"./context\";\nimport { usePrefillController } from \"./prefill-context\";\nimport { useSetFormValue } from \"./values\";\n\ntype FieldCommit = {\n /** Write the value and validate immediately (precognitive) or clear errors. */\n commit: (name: string, value: unknown) => void;\n /** Write the value and clear errors, deferring validation to a later `blur`. */\n change: (name: string, value: unknown) => void;\n /** Validate the field now if precognitive (e.g. on blur or popover close). */\n blur: (name: string) => void;\n};\n\nconst FieldCommitOverrideContext = createContext<FieldCommit | null>(null);\n\nexport function FieldCommitOverrideProvider({\n children,\n value,\n}: {\n children: ReactNode;\n value: FieldCommit;\n}) {\n return createElement(FieldCommitOverrideContext.Provider, { value }, children);\n}\n\n/**\n * The shared field-mutation contract every form field uses to write its value\n * and drive precognition. Fields that validate on change call `commit`; fields\n * that validate on blur/close (rich editor, select) call `change` then `blur`.\n *\n * When called inside a `FieldScopeProvider`, writes go through the scope's\n * `setValue` and error paths use the scoped dot-key; outside a scope the\n * behavior is identical to before.\n */\nexport function useFieldCommit(): FieldCommit {\n const override = useContext(FieldCommitOverrideContext);\n const { clearErrors, precognitive, validate } = useFormContext();\n const setGlobal = useSetFormValue();\n const scope = useFieldScope();\n const prefill = usePrefillController();\n\n if (override) {\n return override;\n }\n\n const write = (name: string, value: unknown): void => {\n if (scope) {\n scope.setValue(name, value);\n } else {\n setGlobal(name, value);\n }\n prefill?.markUserEdit(scope ? scope.overrideKey(name) : name);\n };\n const errorPath = (name: string): string => (scope ? scope.errorKey(name) : name);\n\n return {\n commit(name, value) {\n write(name, value);\n if (precognitive) {\n validate(errorPath(name));\n } else {\n clearErrors(errorPath(name));\n }\n },\n change(name, value) {\n write(name, value);\n clearErrors(errorPath(name));\n },\n blur(name) {\n if (precognitive) {\n validate(errorPath(name));\n }\n },\n };\n}\n"],"mappings":";;;;;;AAgBA,IAAM,6BAA6B,cAAkC,IAAI;AAEzE,SAAgB,4BAA4B,EAC1C,UACA,SAIC;CACD,OAAO,cAAc,2BAA2B,UAAU,EAAE,MAAM,GAAG,QAAQ;AAC/E;;;;;;;;;;AAWA,SAAgB,iBAA8B;CAC5C,MAAM,WAAW,WAAW,0BAA0B;CACtD,MAAM,EAAE,aAAa,cAAc,aAAa,eAAe;CAC/D,MAAM,YAAY,gBAAgB;CAClC,MAAM,QAAQ,cAAc;CAC5B,MAAM,UAAU,qBAAqB;CAErC,IAAI,UACF,OAAO;CAGT,MAAM,SAAS,MAAc,UAAyB;EACpD,IAAI,OACF,MAAM,SAAS,MAAM,KAAK;OAE1B,UAAU,MAAM,KAAK;EAEvB,SAAS,aAAa,QAAQ,MAAM,YAAY,IAAI,IAAI,IAAI;CAC9D;CACA,MAAM,aAAa,SAA0B,QAAQ,MAAM,SAAS,IAAI,IAAI;CAE5E,OAAO;EACL,OAAO,MAAM,OAAO;GAClB,MAAM,MAAM,KAAK;GACjB,IAAI,cACF,SAAS,UAAU,IAAI,CAAC;QAExB,YAAY,UAAU,IAAI,CAAC;EAE/B;EACA,OAAO,MAAM,OAAO;GAClB,MAAM,MAAM,KAAK;GACjB,YAAY,UAAU,IAAI,CAAC;EAC7B;EACA,KAAK,MAAM;GACT,IAAI,cACF,SAAS,UAAU,IAAI,CAAC;EAE5B;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node } from '../../core/types';
|
|
2
|
-
import { PrefillController } from './prefill-context';
|
|
1
|
+
import { Node } from '../../core/types.js';
|
|
2
|
+
import { PrefillController } from './prefill-context.js';
|
|
3
3
|
type FormResolver = {
|
|
4
4
|
nodes: Record<string, Node>;
|
|
5
5
|
markUserEdit: PrefillController["markUserEdit"];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { walkFields } from "
|
|
2
|
-
import {
|
|
3
|
-
import { getPath } from "./form-path.js";
|
|
4
|
-
import { collectPrefillTargets, pathsToClear, pruneOverrides, seededOverrides } from "./prefill-targets.js";
|
|
1
|
+
import { walkFields } from "../lib/field-props.js";
|
|
2
|
+
import { getPath } from "../lib/form-path.js";
|
|
5
3
|
import { useFormValues, useSetFormValue } from "./values.js";
|
|
4
|
+
import { postFormAction } from "../lib/form-transport.js";
|
|
5
|
+
import { collectPrefillTargets, pathsToClear, pruneOverrides, seededOverrides } from "../lib/prefill-targets.js";
|
|
6
6
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
//#region resources/js/form/
|
|
7
|
+
//#region resources/js/form/hooks/use-form-resolver.ts
|
|
8
8
|
function useFormResolver(action, componentRef, nodes) {
|
|
9
9
|
const values = useFormValues();
|
|
10
10
|
const setValue = useSetFormValue();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-form-resolver.js","names":[],"sources":["../../../resources/js/form/hooks/use-form-resolver.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { Node } from \"@lattice-php/lattice/core/types\";\nimport { walkFields } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { FORM_DEBOUNCE_MS, postFormAction } from \"@lattice-php/lattice/form/lib/form-transport\";\nimport {\n collectPrefillTargets,\n getPath,\n pathsToClear,\n pruneOverrides,\n seededOverrides,\n} from \"@lattice-php/lattice/form/lib/prefill-targets\";\nimport type { PrefillController } from \"./prefill-context\";\nimport { useFormValues, useSetFormValue } from \"./values\";\n\ntype ResolveResponse = {\n fields?: Record<string, Node>;\n values?: Record<string, unknown>;\n prefill?: Record<string, unknown>;\n};\n\ntype FormResolver = {\n nodes: Record<string, Node>;\n markUserEdit: PrefillController[\"markUserEdit\"];\n};\n\nexport function useFormResolver(\n action: string,\n componentRef: string,\n nodes: Node[] | undefined,\n): FormResolver {\n const values = useFormValues();\n const setValue = useSetFormValue();\n const [resolved, setResolved] = useState<Record<string, Node>>({});\n\n const targets = useMemo(() => collectPrefillTargets(nodes, values), [nodes, values]);\n\n const overrides = useRef<Set<string>>(new Set());\n const seededOverrideKeys = useRef<Set<string>>(new Set());\n const previousValues = useRef<Record<string, unknown>>(values);\n const previousTargets = useRef(targets);\n\n // Read targets via a ref inside the effect: `targets` changes identity on every\n // value change, but the effect must fire only when `watchSignature` changes\n // (which already reflects added/removed target paths). Keeping `targets` out of\n // the dep array preserves the targeted watch in non-\"any\" mode.\n const targetsRef = useRef(targets);\n targetsRef.current = targets;\n\n useLayoutEffect(() => {\n const liveOverrideKeys = new Set(targets.map((target) => target.overrideKey));\n seededOverrideKeys.current = new Set(\n [...seededOverrideKeys.current].filter((overrideKey) => liveOverrideKeys.has(overrideKey)),\n );\n const freshTargets = targets.filter(\n (target) => !seededOverrideKeys.current.has(target.overrideKey),\n );\n\n // Layout ordering seeds loaded values before the first resolve effect can apply prefill.\n for (const overrideKey of seededOverrides(freshTargets, values)) {\n overrides.current.add(overrideKey);\n }\n\n for (const target of freshTargets) {\n seededOverrideKeys.current.add(target.overrideKey);\n }\n }, [targets, values]);\n\n const markUserEdit = useCallback((overrideKey: string) => {\n overrides.current.add(overrideKey);\n }, []);\n\n const watch = useMemo(() => {\n const keys = new Set<string>();\n let any = false;\n walkFields(nodes, (props) => {\n if (Array.isArray(props.dependsOnKeys)) {\n for (const key of props.dependsOnKeys) {\n keys.add(String(key));\n }\n }\n if (props.dependsOnAny) {\n any = true;\n }\n });\n return { keys: [...keys], any };\n }, [nodes]);\n\n const watchPaths = useMemo(() => {\n const set = new Set<string>(watch.keys);\n for (const target of targets) {\n for (const dep of target.resetOn) {\n set.add(dep);\n }\n for (const dep of target.refreshOn) {\n set.add(dep);\n }\n }\n return [...set];\n }, [watch.keys, targets]);\n\n // In \"any\" mode the values store keeps a stable reference until something\n // actually changes, so its identity is the change signal. Otherwise hash the\n // watched paths (form-level and per-row).\n const watchSignature = watch.any\n ? values\n : JSON.stringify(watchPaths.map((path) => getPath(values, path)));\n\n useEffect(() => {\n if (watchPaths.length === 0 && !watch.any) {\n return;\n }\n\n const previous = previousValues.current;\n previousValues.current = values;\n\n // `resetOn` deps unlock a path (a fresh product gives a fresh price); `refreshOn`\n // deps only re-ask the server and never clear an override (a customer change\n // re-prices untouched rows but leaves user-edited ones alone).\n for (const overrideKey of pathsToClear(\n { targets: previousTargets.current, values: previous },\n { targets: targetsRef.current, values },\n )) {\n overrides.current.delete(overrideKey);\n }\n previousTargets.current = targetsRef.current;\n\n // Override ownership is row-id keyed, so pruning removes departed rows without reindex drift.\n overrides.current = pruneOverrides(overrides.current, targetsRef.current);\n\n const controller = new AbortController();\n\n const timer = window.setTimeout(() => {\n void postFormAction<ResolveResponse>(\n action,\n componentRef,\n { _resolve: true, ...values },\n controller.signal,\n )\n .then((response) => {\n if (!response) {\n return;\n }\n for (const [name, value] of Object.entries(response.values ?? {})) {\n setValue(name, value);\n }\n const targetsByPath = new Map(\n targetsRef.current.map((target) => [target.path, target] as const),\n );\n for (const [path, value] of Object.entries(response.prefill ?? {})) {\n const target = targetsByPath.get(path);\n\n if (target && !overrides.current.has(target.overrideKey)) {\n setValue(path, value);\n }\n }\n if (response.fields) {\n setResolved(response.fields);\n }\n })\n .catch(() => {});\n }, FORM_DEBOUNCE_MS);\n\n return () => {\n window.clearTimeout(timer);\n controller.abort();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [watchSignature, action, componentRef, watch.any, setValue]);\n\n return { nodes: resolved, markUserEdit };\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,gBACd,QACA,cACA,OACc;CACd,MAAM,SAAS,cAAc;CAC7B,MAAM,WAAW,gBAAgB;CACjC,MAAM,CAAC,UAAU,eAAe,SAA+B,CAAC,CAAC;CAEjE,MAAM,UAAU,cAAc,sBAAsB,OAAO,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC;CAEnF,MAAM,YAAY,uBAAoB,IAAI,IAAI,CAAC;CAC/C,MAAM,qBAAqB,uBAAoB,IAAI,IAAI,CAAC;CACxD,MAAM,iBAAiB,OAAgC,MAAM;CAC7D,MAAM,kBAAkB,OAAO,OAAO;CAMtC,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAErB,sBAAsB;EACpB,MAAM,mBAAmB,IAAI,IAAI,QAAQ,KAAK,WAAW,OAAO,WAAW,CAAC;EAC5E,mBAAmB,UAAU,IAAI,IAC/B,CAAC,GAAG,mBAAmB,OAAO,EAAE,QAAQ,gBAAgB,iBAAiB,IAAI,WAAW,CAAC,CAC3F;EACA,MAAM,eAAe,QAAQ,QAC1B,WAAW,CAAC,mBAAmB,QAAQ,IAAI,OAAO,WAAW,CAChE;EAGA,KAAK,MAAM,eAAe,gBAAgB,cAAc,MAAM,GAC5D,UAAU,QAAQ,IAAI,WAAW;EAGnC,KAAK,MAAM,UAAU,cACnB,mBAAmB,QAAQ,IAAI,OAAO,WAAW;CAErD,GAAG,CAAC,SAAS,MAAM,CAAC;CAEpB,MAAM,eAAe,aAAa,gBAAwB;EACxD,UAAU,QAAQ,IAAI,WAAW;CACnC,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,cAAc;EAC1B,MAAM,uBAAO,IAAI,IAAY;EAC7B,IAAI,MAAM;EACV,WAAW,QAAQ,UAAU;GAC3B,IAAI,MAAM,QAAQ,MAAM,aAAa,GACnC,KAAK,MAAM,OAAO,MAAM,eACtB,KAAK,IAAI,OAAO,GAAG,CAAC;GAGxB,IAAI,MAAM,cACR,MAAM;EAEV,CAAC;EACD,OAAO;GAAE,MAAM,CAAC,GAAG,IAAI;GAAG;EAAI;CAChC,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,aAAa,cAAc;EAC/B,MAAM,MAAM,IAAI,IAAY,MAAM,IAAI;EACtC,KAAK,MAAM,UAAU,SAAS;GAC5B,KAAK,MAAM,OAAO,OAAO,SACvB,IAAI,IAAI,GAAG;GAEb,KAAK,MAAM,OAAO,OAAO,WACvB,IAAI,IAAI,GAAG;EAEf;EACA,OAAO,CAAC,GAAG,GAAG;CAChB,GAAG,CAAC,MAAM,MAAM,OAAO,CAAC;CASxB,gBAAgB;EACd,IAAI,WAAW,WAAW,KAAK,CAAC,MAAM,KACpC;EAGF,MAAM,WAAW,eAAe;EAChC,eAAe,UAAU;EAKzB,KAAK,MAAM,eAAe,aACxB;GAAE,SAAS,gBAAgB;GAAS,QAAQ;EAAS,GACrD;GAAE,SAAS,WAAW;GAAS;EAAO,CACxC,GACE,UAAU,QAAQ,OAAO,WAAW;EAEtC,gBAAgB,UAAU,WAAW;EAGrC,UAAU,UAAU,eAAe,UAAU,SAAS,WAAW,OAAO;EAExE,MAAM,aAAa,IAAI,gBAAgB;EAEvC,MAAM,QAAQ,OAAO,iBAAiB;GACpC,eACE,QACA,cACA;IAAE,UAAU;IAAM,GAAG;GAAO,GAC5B,WAAW,MACb,EACG,MAAM,aAAa;IAClB,IAAI,CAAC,UACH;IAEF,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,UAAU,CAAC,CAAC,GAC9D,SAAS,MAAM,KAAK;IAEtB,MAAM,gBAAgB,IAAI,IACxB,WAAW,QAAQ,KAAK,WAAW,CAAC,OAAO,MAAM,MAAM,CAAU,CACnE;IACA,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,WAAW,CAAC,CAAC,GAAG;KAClE,MAAM,SAAS,cAAc,IAAI,IAAI;KAErC,IAAI,UAAU,CAAC,UAAU,QAAQ,IAAI,OAAO,WAAW,GACrD,SAAS,MAAM,KAAK;IAExB;IACA,IAAI,SAAS,QACX,YAAY,SAAS,MAAM;GAE/B,CAAC,EACA,YAAY,CAAC,CAAC;EACnB,GAAA,GAAmB;EAEnB,aAAa;GACX,OAAO,aAAa,KAAK;GACzB,WAAW,MAAM;EACnB;CAEF,GAAG;EAhEoB,MAAM,MACzB,SACA,KAAK,UAAU,WAAW,KAAK,SAAS,QAAQ,QAAQ,IAAI,CAAC,CAAC;EA8D9C;EAAQ;EAAc,MAAM;EAAK;CAAQ,CAAC;CAE9D,OAAO;EAAE,OAAO;EAAU;CAAa;AACzC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useFieldScope } from "./field-scope.js";
|
|
2
2
|
import { useFormValue, useSetFormValue } from "./values.js";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
|
-
//#region resources/js/form/
|
|
4
|
+
//#region resources/js/form/hooks/use-seed-default.ts
|
|
5
5
|
/**
|
|
6
6
|
* Seed a field's default into the store so dependent fields and the submitted
|
|
7
7
|
* payload reflect it before the user interacts. Pass undefined to skip.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-seed-default.js","names":[],"sources":["../../../resources/js/form/hooks/use-seed-default.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormValue, useSetFormValue } from \"./values\";\n\n/**\n * Seed a field's default into the store so dependent fields and the submitted\n * payload reflect it before the user interacts. Pass undefined to skip.\n */\nexport function useSeedDefault(name: string, value: unknown): void {\n const scope = useFieldScope();\n const globalStored = useFormValue(name);\n const stored = scope ? scope.getValue(name) : globalStored;\n const setValue = useSetFormValue();\n\n useEffect(() => {\n if (stored === undefined && value !== undefined) {\n if (scope) {\n scope.setValue(name, value);\n } else {\n setValue(name, value);\n }\n }\n }, [name, value, stored, setValue, scope]);\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,eAAe,MAAc,OAAsB;CACjE,MAAM,QAAQ,cAAc;CAC5B,MAAM,eAAe,aAAa,IAAI;CACtC,MAAM,SAAS,QAAQ,MAAM,SAAS,IAAI,IAAI;CAC9C,MAAM,WAAW,gBAAgB;CAEjC,gBAAgB;EACd,IAAI,WAAW,KAAA,KAAa,UAAU,KAAA,GACpC,IAAI,OACF,MAAM,SAAS,MAAM,KAAK;OAE1B,SAAS,MAAM,KAAK;CAG1B,GAAG;EAAC;EAAM;EAAO;EAAQ;EAAU;CAAK,CAAC;AAC3C"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export type SetFormValue = (name: string, value: unknown | ((previous: unknown) => unknown)) => void;
|
|
1
2
|
export declare function FormValuesProvider({ initial, children, }: {
|
|
2
3
|
initial: Record<string, unknown>;
|
|
3
4
|
children: React.ReactNode;
|
|
4
5
|
}): import("react").JSX.Element;
|
|
5
6
|
export declare function useFormValues(): Record<string, unknown>;
|
|
6
7
|
export declare function useFormValue(name: string): unknown;
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function useFormValuesFor(paths: string[]): Record<string, unknown>;
|
|
9
|
+
export declare function useSetFormValue(): SetFormValue;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { getPath, setPath } from "../lib/form-path.js";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region resources/js/form/hooks/values.tsx
|
|
5
|
+
var emptyValues = {};
|
|
6
|
+
var emptySelectedValues = {};
|
|
7
|
+
var FormValuesStoreContext = createContext(null);
|
|
8
|
+
var SetFormValueContext = createContext(() => {});
|
|
9
|
+
function valuesEqual(a, b) {
|
|
10
|
+
if (Object.is(a, b)) return true;
|
|
11
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
12
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((value, index) => valuesEqual(value, b[index]));
|
|
13
|
+
const aEntries = Object.entries(a);
|
|
14
|
+
const bObject = b;
|
|
15
|
+
return aEntries.length === Object.keys(bObject).length && aEntries.every(([key, value]) => valuesEqual(value, bObject[key]));
|
|
16
|
+
}
|
|
17
|
+
function normalizePath(path) {
|
|
18
|
+
return path.split(".").filter((part) => part !== "").join(".");
|
|
19
|
+
}
|
|
20
|
+
function pathsOverlap(left, right) {
|
|
21
|
+
return left === "" || right === "" || left === right || left.startsWith(`${right}.`) || right.startsWith(`${left}.`);
|
|
22
|
+
}
|
|
23
|
+
function createFormValuesStore(initial) {
|
|
24
|
+
let initialValues = initial;
|
|
25
|
+
let values = initial;
|
|
26
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
27
|
+
const pathListeners = /* @__PURE__ */ new Map();
|
|
28
|
+
const selectedCache = /* @__PURE__ */ new Map();
|
|
29
|
+
const notify = (path) => {
|
|
30
|
+
for (const listener of listeners) listener();
|
|
31
|
+
const normalizedPath = normalizePath(path);
|
|
32
|
+
for (const [subscribedPath, subscribedListeners] of pathListeners) {
|
|
33
|
+
if (!pathsOverlap(subscribedPath, normalizedPath)) continue;
|
|
34
|
+
for (const listener of subscribedListeners) listener();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const updateValues = (next, path) => {
|
|
38
|
+
if (Object.is(values, next)) return;
|
|
39
|
+
values = next;
|
|
40
|
+
selectedCache.clear();
|
|
41
|
+
notify(path);
|
|
42
|
+
};
|
|
43
|
+
const subscribePath = (path, listener) => {
|
|
44
|
+
const normalizedPath = normalizePath(path);
|
|
45
|
+
const listenersForPath = pathListeners.get(normalizedPath) ?? /* @__PURE__ */ new Set();
|
|
46
|
+
listenersForPath.add(listener);
|
|
47
|
+
pathListeners.set(normalizedPath, listenersForPath);
|
|
48
|
+
return () => {
|
|
49
|
+
listenersForPath.delete(listener);
|
|
50
|
+
if (listenersForPath.size === 0) pathListeners.delete(normalizedPath);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
getPathSnapshot: (path) => getPath(values, path),
|
|
55
|
+
getPathsSnapshot: (paths) => {
|
|
56
|
+
if (paths.length === 0) return emptySelectedValues;
|
|
57
|
+
const normalizedPaths = paths.map(normalizePath);
|
|
58
|
+
const key = JSON.stringify(paths);
|
|
59
|
+
const selectedValues = normalizedPaths.map((path) => getPath(values, path));
|
|
60
|
+
const cached = selectedCache.get(key);
|
|
61
|
+
if (cached && cached.values.length === selectedValues.length && selectedValues.every((value, index) => Object.is(value, cached.values[index]))) return cached.snapshot;
|
|
62
|
+
const snapshot = Object.fromEntries(paths.map((path, index) => [path, selectedValues[index]]));
|
|
63
|
+
selectedCache.set(key, {
|
|
64
|
+
snapshot,
|
|
65
|
+
values: selectedValues
|
|
66
|
+
});
|
|
67
|
+
return snapshot;
|
|
68
|
+
},
|
|
69
|
+
getSnapshot: () => values,
|
|
70
|
+
replaceInitial: (nextInitial) => {
|
|
71
|
+
if (valuesEqual(initialValues, nextInitial)) return;
|
|
72
|
+
initialValues = nextInitial;
|
|
73
|
+
updateValues(nextInitial, "");
|
|
74
|
+
},
|
|
75
|
+
setValue: (name, value) => {
|
|
76
|
+
const previous = getPath(values, name);
|
|
77
|
+
const next = typeof value === "function" ? value(previous) : value;
|
|
78
|
+
if (Object.is(previous, next)) return;
|
|
79
|
+
updateValues(setPath(values, name, next), name);
|
|
80
|
+
},
|
|
81
|
+
subscribe: (listener) => {
|
|
82
|
+
listeners.add(listener);
|
|
83
|
+
return () => listeners.delete(listener);
|
|
84
|
+
},
|
|
85
|
+
subscribePath,
|
|
86
|
+
subscribePaths: (paths, listener) => {
|
|
87
|
+
const unsubscribers = Array.from(new Set(paths.map(normalizePath))).map((path) => subscribePath(path, listener));
|
|
88
|
+
return () => {
|
|
89
|
+
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
var fallbackFormValuesStore = createFormValuesStore(emptyValues);
|
|
95
|
+
function FormValuesProvider({ initial, children }) {
|
|
96
|
+
const storeRef = useRef(null);
|
|
97
|
+
if (storeRef.current === null) storeRef.current = createFormValuesStore(initial);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
storeRef.current?.replaceInitial(initial);
|
|
100
|
+
}, [initial]);
|
|
101
|
+
return /* @__PURE__ */ jsx(FormValuesStoreContext.Provider, {
|
|
102
|
+
value: storeRef.current,
|
|
103
|
+
children: /* @__PURE__ */ jsx(SetFormValueContext.Provider, {
|
|
104
|
+
value: storeRef.current.setValue,
|
|
105
|
+
children
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function useFormValuesStore() {
|
|
110
|
+
return useContext(FormValuesStoreContext) ?? fallbackFormValuesStore;
|
|
111
|
+
}
|
|
112
|
+
function useFormValues() {
|
|
113
|
+
const store = useFormValuesStore();
|
|
114
|
+
return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
115
|
+
}
|
|
116
|
+
function useFormValue(name) {
|
|
117
|
+
const store = useFormValuesStore();
|
|
118
|
+
const subscribe = useCallback((listener) => store.subscribePath(name, listener), [name, store]);
|
|
119
|
+
const getSnapshot = useCallback(() => store.getPathSnapshot(name), [name, store]);
|
|
120
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
121
|
+
}
|
|
122
|
+
function useFormValuesFor(paths) {
|
|
123
|
+
const store = useFormValuesStore();
|
|
124
|
+
const pathsKey = JSON.stringify(paths);
|
|
125
|
+
const selectedPaths = useMemo(() => JSON.parse(pathsKey), [pathsKey]);
|
|
126
|
+
const subscribe = useCallback((listener) => store.subscribePaths(selectedPaths, listener), [selectedPaths, store]);
|
|
127
|
+
const getSnapshot = useCallback(() => store.getPathsSnapshot(selectedPaths), [selectedPaths, store]);
|
|
128
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
129
|
+
}
|
|
130
|
+
function useSetFormValue() {
|
|
131
|
+
return useContext(SetFormValueContext);
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { FormValuesProvider, useFormValue, useFormValues, useFormValuesFor, useSetFormValue };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=values.js.map
|