@sparqjs/schema-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/action-runtime.d.ts +91 -0
- package/dist/action/action-runtime.d.ts.map +1 -0
- package/dist/action/action-runtime.js +172 -0
- package/dist/action/action-runtime.js.map +1 -0
- package/dist/action/builtin-actions.d.ts +35 -0
- package/dist/action/builtin-actions.d.ts.map +1 -0
- package/dist/action/builtin-actions.js +200 -0
- package/dist/action/builtin-actions.js.map +1 -0
- package/dist/action/index.d.ts +6 -0
- package/dist/action/index.d.ts.map +1 -0
- package/dist/action/index.js +6 -0
- package/dist/action/index.js.map +1 -0
- package/dist/action/merge-action.d.ts +9 -0
- package/dist/action/merge-action.d.ts.map +1 -0
- package/dist/action/merge-action.js +51 -0
- package/dist/action/merge-action.js.map +1 -0
- package/dist/action/resolve-action.d.ts +14 -0
- package/dist/action/resolve-action.d.ts.map +1 -0
- package/dist/action/resolve-action.js +81 -0
- package/dist/action/resolve-action.js.map +1 -0
- package/dist/action/types.d.ts +97 -0
- package/dist/action/types.d.ts.map +1 -0
- package/dist/action/types.js +2 -0
- package/dist/action/types.js.map +1 -0
- package/dist/component-keys.d.ts +49 -0
- package/dist/component-keys.d.ts.map +1 -0
- package/dist/component-keys.js +48 -0
- package/dist/component-keys.js.map +1 -0
- package/dist/data/index.d.ts +3 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +3 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/options.d.ts +33 -0
- package/dist/data/options.d.ts.map +1 -0
- package/dist/data/options.js +147 -0
- package/dist/data/options.js.map +1 -0
- package/dist/data/types.d.ts +303 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/data/types.js +2 -0
- package/dist/data/types.js.map +1 -0
- package/dist/diagnostics/create-diagnostic.d.ts +8 -0
- package/dist/diagnostics/create-diagnostic.d.ts.map +1 -0
- package/dist/diagnostics/create-diagnostic.js +13 -0
- package/dist/diagnostics/create-diagnostic.js.map +1 -0
- package/dist/diagnostics/diagnostic-collector.d.ts +27 -0
- package/dist/diagnostics/diagnostic-collector.d.ts.map +1 -0
- package/dist/diagnostics/diagnostic-collector.js +30 -0
- package/dist/diagnostics/diagnostic-collector.js.map +1 -0
- package/dist/diagnostics/index.d.ts +4 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +4 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/diagnostics/types.d.ts +51 -0
- package/dist/diagnostics/types.d.ts.map +1 -0
- package/dist/diagnostics/types.js +2 -0
- package/dist/diagnostics/types.js.map +1 -0
- package/dist/expression/condition.d.ts +9 -0
- package/dist/expression/condition.d.ts.map +1 -0
- package/dist/expression/condition.js +82 -0
- package/dist/expression/condition.js.map +1 -0
- package/dist/expression/index.d.ts +6 -0
- package/dist/expression/index.d.ts.map +1 -0
- package/dist/expression/index.js +6 -0
- package/dist/expression/index.js.map +1 -0
- package/dist/expression/path.d.ts +8 -0
- package/dist/expression/path.d.ts.map +1 -0
- package/dist/expression/path.js +30 -0
- package/dist/expression/path.js.map +1 -0
- package/dist/expression/template.d.ts +8 -0
- package/dist/expression/template.d.ts.map +1 -0
- package/dist/expression/template.js +23 -0
- package/dist/expression/template.js.map +1 -0
- package/dist/expression/types.d.ts +27 -0
- package/dist/expression/types.d.ts.map +1 -0
- package/dist/expression/types.js +2 -0
- package/dist/expression/types.js.map +1 -0
- package/dist/expression/value.d.ts +12 -0
- package/dist/expression/value.d.ts.map +1 -0
- package/dist/expression/value.js +88 -0
- package/dist/expression/value.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.d.ts +131 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +2 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/icon-keys.d.ts +46 -0
- package/dist/icon-keys.d.ts.map +1 -0
- package/dist/icon-keys.js +100 -0
- package/dist/icon-keys.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/inference/display-components.d.ts +14 -0
- package/dist/inference/display-components.d.ts.map +1 -0
- package/dist/inference/display-components.js +52 -0
- package/dist/inference/display-components.js.map +1 -0
- package/dist/inference/index.d.ts +4 -0
- package/dist/inference/index.d.ts.map +1 -0
- package/dist/inference/index.js +4 -0
- package/dist/inference/index.js.map +1 -0
- package/dist/inference/search-components.d.ts +9 -0
- package/dist/inference/search-components.d.ts.map +1 -0
- package/dist/inference/search-components.js +46 -0
- package/dist/inference/search-components.js.map +1 -0
- package/dist/inference/search-operators.d.ts +9 -0
- package/dist/inference/search-operators.d.ts.map +1 -0
- package/dist/inference/search-operators.js +42 -0
- package/dist/inference/search-operators.js.map +1 -0
- package/dist/normalizer/index.d.ts +12 -0
- package/dist/normalizer/index.d.ts.map +1 -0
- package/dist/normalizer/index.js +12 -0
- package/dist/normalizer/index.js.map +1 -0
- package/dist/normalizer/infer-detail.d.ts +8 -0
- package/dist/normalizer/infer-detail.d.ts.map +1 -0
- package/dist/normalizer/infer-detail.js +19 -0
- package/dist/normalizer/infer-detail.js.map +1 -0
- package/dist/normalizer/infer-form.d.ts +8 -0
- package/dist/normalizer/infer-form.d.ts.map +1 -0
- package/dist/normalizer/infer-form.js +16 -0
- package/dist/normalizer/infer-form.js.map +1 -0
- package/dist/normalizer/infer-search.d.ts +18 -0
- package/dist/normalizer/infer-search.d.ts.map +1 -0
- package/dist/normalizer/infer-search.js +53 -0
- package/dist/normalizer/infer-search.js.map +1 -0
- package/dist/normalizer/infer-table.d.ts +16 -0
- package/dist/normalizer/infer-table.d.ts.map +1 -0
- package/dist/normalizer/infer-table.js +41 -0
- package/dist/normalizer/infer-table.js.map +1 -0
- package/dist/normalizer/normalize-resource.d.ts +10 -0
- package/dist/normalizer/normalize-resource.d.ts.map +1 -0
- package/dist/normalizer/normalize-resource.js +84 -0
- package/dist/normalizer/normalize-resource.js.map +1 -0
- package/dist/normalizer/normalize-views.d.ts +32 -0
- package/dist/normalizer/normalize-views.d.ts.map +1 -0
- package/dist/normalizer/normalize-views.js +194 -0
- package/dist/normalizer/normalize-views.js.map +1 -0
- package/dist/normalizer/types.d.ts +36 -0
- package/dist/normalizer/types.d.ts.map +1 -0
- package/dist/normalizer/types.js +2 -0
- package/dist/normalizer/types.js.map +1 -0
- package/dist/normalizer/validate-nodes.d.ts +9 -0
- package/dist/normalizer/validate-nodes.d.ts.map +1 -0
- package/dist/normalizer/validate-nodes.js +91 -0
- package/dist/normalizer/validate-nodes.js.map +1 -0
- package/dist/normalizer/validate-search.d.ts +9 -0
- package/dist/normalizer/validate-search.d.ts.map +1 -0
- package/dist/normalizer/validate-search.js +20 -0
- package/dist/normalizer/validate-search.js.map +1 -0
- package/dist/normalizer/validate-table.d.ts +9 -0
- package/dist/normalizer/validate-table.d.ts.map +1 -0
- package/dist/normalizer/validate-table.js +52 -0
- package/dist/normalizer/validate-table.js.map +1 -0
- package/dist/normalizer/validate-value-expression.d.ts +4 -0
- package/dist/normalizer/validate-value-expression.d.ts.map +1 -0
- package/dist/normalizer/validate-value-expression.js +43 -0
- package/dist/normalizer/validate-value-expression.js.map +1 -0
- package/dist/registry/action-executor-registry.d.ts +6 -0
- package/dist/registry/action-executor-registry.d.ts.map +1 -0
- package/dist/registry/action-executor-registry.js +6 -0
- package/dist/registry/action-executor-registry.js.map +1 -0
- package/dist/registry/action-handler-registry.d.ts +19 -0
- package/dist/registry/action-handler-registry.d.ts.map +1 -0
- package/dist/registry/action-handler-registry.js +15 -0
- package/dist/registry/action-handler-registry.js.map +1 -0
- package/dist/registry/component-registry.d.ts +17 -0
- package/dist/registry/component-registry.d.ts.map +1 -0
- package/dist/registry/component-registry.js +11 -0
- package/dist/registry/component-registry.js.map +1 -0
- package/dist/registry/effect-handler-registry.d.ts +19 -0
- package/dist/registry/effect-handler-registry.d.ts.map +1 -0
- package/dist/registry/effect-handler-registry.js +15 -0
- package/dist/registry/effect-handler-registry.js.map +1 -0
- package/dist/registry/index.d.ts +6 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/runtime-registries.d.ts +20 -0
- package/dist/registry/runtime-registries.d.ts.map +1 -0
- package/dist/registry/runtime-registries.js +46 -0
- package/dist/registry/runtime-registries.js.map +1 -0
- package/dist/relation-list/index.d.ts +3 -0
- package/dist/relation-list/index.d.ts.map +1 -0
- package/dist/relation-list/index.js +3 -0
- package/dist/relation-list/index.js.map +1 -0
- package/dist/relation-list/runtime.d.ts +19 -0
- package/dist/relation-list/runtime.d.ts.map +1 -0
- package/dist/relation-list/runtime.js +279 -0
- package/dist/relation-list/runtime.js.map +1 -0
- package/dist/relation-list/types.d.ts +32 -0
- package/dist/relation-list/types.d.ts.map +1 -0
- package/dist/relation-list/types.js +2 -0
- package/dist/relation-list/types.js.map +1 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +3 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/resolve-render-view.d.ts +3 -0
- package/dist/render/resolve-render-view.d.ts.map +1 -0
- package/dist/render/resolve-render-view.js +93 -0
- package/dist/render/resolve-render-view.js.map +1 -0
- package/dist/render/types.d.ts +21 -0
- package/dist/render/types.d.ts.map +1 -0
- package/dist/render/types.js +2 -0
- package/dist/render/types.js.map +1 -0
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +31 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scope/index.d.ts +4 -0
- package/dist/scope/index.d.ts.map +1 -0
- package/dist/scope/index.js +4 -0
- package/dist/scope/index.js.map +1 -0
- package/dist/scope/resolve-target.d.ts +9 -0
- package/dist/scope/resolve-target.d.ts.map +1 -0
- package/dist/scope/resolve-target.js +40 -0
- package/dist/scope/resolve-target.js.map +1 -0
- package/dist/scope/scope-tree.d.ts +27 -0
- package/dist/scope/scope-tree.d.ts.map +1 -0
- package/dist/scope/scope-tree.js +55 -0
- package/dist/scope/scope-tree.js.map +1 -0
- package/dist/scope/types.d.ts +63 -0
- package/dist/scope/types.d.ts.map +1 -0
- package/dist/scope/types.js +2 -0
- package/dist/scope/types.js.map +1 -0
- package/dist/session/action-execution.d.ts +16 -0
- package/dist/session/action-execution.d.ts.map +1 -0
- package/dist/session/action-execution.js +349 -0
- package/dist/session/action-execution.js.map +1 -0
- package/dist/session/actions/default-action-handlers.d.ts +21 -0
- package/dist/session/actions/default-action-handlers.d.ts.map +1 -0
- package/dist/session/actions/default-action-handlers.js +446 -0
- package/dist/session/actions/default-action-handlers.js.map +1 -0
- package/dist/session/actions/index.d.ts +4 -0
- package/dist/session/actions/index.d.ts.map +1 -0
- package/dist/session/actions/index.js +26 -0
- package/dist/session/actions/index.js.map +1 -0
- package/dist/session/audit-state.d.ts +16 -0
- package/dist/session/audit-state.d.ts.map +1 -0
- package/dist/session/audit-state.js +130 -0
- package/dist/session/audit-state.js.map +1 -0
- package/dist/session/controller-action-state.d.ts +11 -0
- package/dist/session/controller-action-state.d.ts.map +1 -0
- package/dist/session/controller-action-state.js +89 -0
- package/dist/session/controller-action-state.js.map +1 -0
- package/dist/session/controller.d.ts +20 -0
- package/dist/session/controller.d.ts.map +1 -0
- package/dist/session/controller.js +467 -0
- package/dist/session/controller.js.map +1 -0
- package/dist/session/default-values.d.ts +13 -0
- package/dist/session/default-values.d.ts.map +1 -0
- package/dist/session/default-values.js +64 -0
- package/dist/session/default-values.js.map +1 -0
- package/dist/session/defaults.d.ts +3 -0
- package/dist/session/defaults.d.ts.map +1 -0
- package/dist/session/defaults.js +12 -0
- package/dist/session/defaults.js.map +1 -0
- package/dist/session/effects/default-effect-handlers.d.ts +15 -0
- package/dist/session/effects/default-effect-handlers.d.ts.map +1 -0
- package/dist/session/effects/default-effect-handlers.js +84 -0
- package/dist/session/effects/default-effect-handlers.js.map +1 -0
- package/dist/session/effects/effect-types.d.ts +21 -0
- package/dist/session/effects/effect-types.d.ts.map +1 -0
- package/dist/session/effects/effect-types.js +24 -0
- package/dist/session/effects/effect-types.js.map +1 -0
- package/dist/session/effects/index.d.ts +5 -0
- package/dist/session/effects/index.d.ts.map +1 -0
- package/dist/session/effects/index.js +20 -0
- package/dist/session/effects/index.js.map +1 -0
- package/dist/session/executors/default-action-executors.d.ts +10 -0
- package/dist/session/executors/default-action-executors.d.ts.map +1 -0
- package/dist/session/executors/default-action-executors.js +159 -0
- package/dist/session/executors/default-action-executors.js.map +1 -0
- package/dist/session/executors/executor-keys.d.ts +38 -0
- package/dist/session/executors/executor-keys.d.ts.map +1 -0
- package/dist/session/executors/executor-keys.js +19 -0
- package/dist/session/executors/executor-keys.js.map +1 -0
- package/dist/session/executors/index.d.ts +5 -0
- package/dist/session/executors/index.d.ts.map +1 -0
- package/dist/session/executors/index.js +15 -0
- package/dist/session/executors/index.js.map +1 -0
- package/dist/session/form-state.d.ts +23 -0
- package/dist/session/form-state.d.ts.map +1 -0
- package/dist/session/form-state.js +44 -0
- package/dist/session/form-state.js.map +1 -0
- package/dist/session/index.d.ts +12 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +12 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/page-state.d.ts +36 -0
- package/dist/session/page-state.d.ts.map +1 -0
- package/dist/session/page-state.js +125 -0
- package/dist/session/page-state.js.map +1 -0
- package/dist/session/preset/default-session-preset.d.ts +2 -0
- package/dist/session/preset/default-session-preset.d.ts.map +1 -0
- package/dist/session/preset/default-session-preset.js +12 -0
- package/dist/session/preset/default-session-preset.js.map +1 -0
- package/dist/session/preset/index.d.ts +4 -0
- package/dist/session/preset/index.d.ts.map +1 -0
- package/dist/session/preset/index.js +4 -0
- package/dist/session/preset/index.js.map +1 -0
- package/dist/session/preset/preset.d.ts +6 -0
- package/dist/session/preset/preset.d.ts.map +1 -0
- package/dist/session/preset/preset.js +40 -0
- package/dist/session/preset/preset.js.map +1 -0
- package/dist/session/preset/types.d.ts +7 -0
- package/dist/session/preset/types.d.ts.map +1 -0
- package/dist/session/preset/types.js +2 -0
- package/dist/session/preset/types.js.map +1 -0
- package/dist/session/table-state.d.ts +34 -0
- package/dist/session/table-state.d.ts.map +1 -0
- package/dist/session/table-state.js +211 -0
- package/dist/session/table-state.js.map +1 -0
- package/dist/session/tree-state.d.ts +16 -0
- package/dist/session/tree-state.d.ts.map +1 -0
- package/dist/session/tree-state.js +170 -0
- package/dist/session/tree-state.js.map +1 -0
- package/dist/session/types.d.ts +364 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +2 -0
- package/dist/session/types.js.map +1 -0
- package/dist/ui-keys.d.ts +45 -0
- package/dist/ui-keys.d.ts.map +1 -0
- package/dist/ui-keys.js +45 -0
- package/dist/ui-keys.js.map +1 -0
- package/dist/utils/condition.d.ts +10 -0
- package/dist/utils/condition.d.ts.map +1 -0
- package/dist/utils/condition.js +32 -0
- package/dist/utils/condition.js.map +1 -0
- package/dist/utils/errors.d.ts +8 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +30 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/field-generator.d.ts +3 -0
- package/dist/utils/field-generator.d.ts.map +1 -0
- package/dist/utils/field-generator.js +16 -0
- package/dist/utils/field-generator.js.map +1 -0
- package/dist/utils/field-options.d.ts +7 -0
- package/dist/utils/field-options.d.ts.map +1 -0
- package/dist/utils/field-options.js +65 -0
- package/dist/utils/field-options.js.map +1 -0
- package/dist/utils/field-validation.d.ts +5 -0
- package/dist/utils/field-validation.d.ts.map +1 -0
- package/dist/utils/field-validation.js +206 -0
- package/dist/utils/field-validation.js.map +1 -0
- package/dist/utils/fields.d.ts +71 -0
- package/dist/utils/fields.d.ts.map +1 -0
- package/dist/utils/fields.js +111 -0
- package/dist/utils/fields.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/range-validation.d.ts +32 -0
- package/dist/utils/range-validation.d.ts.map +1 -0
- package/dist/utils/range-validation.js +156 -0
- package/dist/utils/range-validation.js.map +1 -0
- package/dist/utils/validation-format.d.ts +7 -0
- package/dist/utils/validation-format.d.ts.map +1 -0
- package/dist/utils/validation-format.js +105 -0
- package/dist/utils/validation-format.js.map +1 -0
- package/dist/utils/value-expression.d.ts +22 -0
- package/dist/utils/value-expression.d.ts.map +1 -0
- package/dist/utils/value-expression.js +190 -0
- package/dist/utils/value-expression.js.map +1 -0
- package/dist/utils/views.d.ts +9 -0
- package/dist/utils/views.d.ts.map +1 -0
- package/dist/utils/views.js +11 -0
- package/dist/utils/views.js.map +1 -0
- package/dist/view-model/build-detail-view-model.d.ts +7 -0
- package/dist/view-model/build-detail-view-model.d.ts.map +1 -0
- package/dist/view-model/build-detail-view-model.js +17 -0
- package/dist/view-model/build-detail-view-model.js.map +1 -0
- package/dist/view-model/build-form-view-model.d.ts +20 -0
- package/dist/view-model/build-form-view-model.d.ts.map +1 -0
- package/dist/view-model/build-form-view-model.js +74 -0
- package/dist/view-model/build-form-view-model.js.map +1 -0
- package/dist/view-model/build-nodes.d.ts +13 -0
- package/dist/view-model/build-nodes.d.ts.map +1 -0
- package/dist/view-model/build-nodes.js +123 -0
- package/dist/view-model/build-nodes.js.map +1 -0
- package/dist/view-model/build-page-view-model.d.ts +22 -0
- package/dist/view-model/build-page-view-model.d.ts.map +1 -0
- package/dist/view-model/build-page-view-model.js +73 -0
- package/dist/view-model/build-page-view-model.js.map +1 -0
- package/dist/view-model/build-resource-view-model.d.ts +9 -0
- package/dist/view-model/build-resource-view-model.d.ts.map +1 -0
- package/dist/view-model/build-resource-view-model.js +72 -0
- package/dist/view-model/build-resource-view-model.js.map +1 -0
- package/dist/view-model/build-search-view-model.d.ts +7 -0
- package/dist/view-model/build-search-view-model.d.ts.map +1 -0
- package/dist/view-model/build-search-view-model.js +101 -0
- package/dist/view-model/build-search-view-model.js.map +1 -0
- package/dist/view-model/build-table-view-model.d.ts +19 -0
- package/dist/view-model/build-table-view-model.d.ts.map +1 -0
- package/dist/view-model/build-table-view-model.js +443 -0
- package/dist/view-model/build-table-view-model.js.map +1 -0
- package/dist/view-model/index.d.ts +10 -0
- package/dist/view-model/index.d.ts.map +1 -0
- package/dist/view-model/index.js +10 -0
- package/dist/view-model/index.js.map +1 -0
- package/dist/view-model/placeholder.d.ts +6 -0
- package/dist/view-model/placeholder.d.ts.map +1 -0
- package/dist/view-model/placeholder.js +35 -0
- package/dist/view-model/placeholder.js.map +1 -0
- package/dist/view-model/types.d.ts +423 -0
- package/dist/view-model/types.d.ts.map +1 -0
- package/dist/view-model/types.js +2 -0
- package/dist/view-model/types.js.map +1 -0
- package/dist/view-state/index.d.ts +5 -0
- package/dist/view-state/index.d.ts.map +1 -0
- package/dist/view-state/index.js +5 -0
- package/dist/view-state/index.js.map +1 -0
- package/dist/view-state/resolve-action-state.d.ts +8 -0
- package/dist/view-state/resolve-action-state.d.ts.map +1 -0
- package/dist/view-state/resolve-action-state.js +71 -0
- package/dist/view-state/resolve-action-state.js.map +1 -0
- package/dist/view-state/resolve-field-runtime-state.d.ts +30 -0
- package/dist/view-state/resolve-field-runtime-state.d.ts.map +1 -0
- package/dist/view-state/resolve-field-runtime-state.js +85 -0
- package/dist/view-state/resolve-field-runtime-state.js.map +1 -0
- package/dist/view-state/resolve-node-state.d.ts +8 -0
- package/dist/view-state/resolve-node-state.d.ts.map +1 -0
- package/dist/view-state/resolve-node-state.js +14 -0
- package/dist/view-state/resolve-node-state.js.map +1 -0
- package/dist/view-state/types.d.ts +42 -0
- package/dist/view-state/types.d.ts.map +1 -0
- package/dist/view-state/types.js +2 -0
- package/dist/view-state/types.js.map +1 -0
- package/package.json +23 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { normalizeResourceSchema } from '../normalizer';
|
|
2
|
+
import { buildDetailViewModel } from './build-detail-view-model';
|
|
3
|
+
import { buildFormViewModel } from './build-form-view-model';
|
|
4
|
+
import { buildPageViewModel } from './build-page-view-model';
|
|
5
|
+
import { buildSearchViewModel } from './build-search-view-model';
|
|
6
|
+
import { buildTableViewModel } from './build-table-view-model';
|
|
7
|
+
/**
|
|
8
|
+
* 构建资源运行视图模型。
|
|
9
|
+
*
|
|
10
|
+
* 该函数会先执行 normalizer,再把标准化后的 form/table/search/detail 转换为 renderer 更容易消费的结构。
|
|
11
|
+
*/
|
|
12
|
+
export function buildResourceViewModel(resource) {
|
|
13
|
+
const normalized = normalizeResourceSchema(resource);
|
|
14
|
+
const allowDraft = resource.schema.capabilities?.allow_draft === true;
|
|
15
|
+
const pages = new Map();
|
|
16
|
+
const forms = new Map();
|
|
17
|
+
const tables = new Map();
|
|
18
|
+
const searches = new Map();
|
|
19
|
+
const details = new Map();
|
|
20
|
+
const diagnostics = [...normalized.diagnostics];
|
|
21
|
+
for (const [name, form] of normalized.views.forms) {
|
|
22
|
+
const formViewModel = buildFormViewModel(form, normalized.fieldsByName, resource.schema.actions, `schema.views.forms.${name}`, {
|
|
23
|
+
defaultTitle: resource.schema.title ?? resource.resource?.title,
|
|
24
|
+
defaultWrapper: {
|
|
25
|
+
type: 'default',
|
|
26
|
+
},
|
|
27
|
+
footerVariant: 'standalone',
|
|
28
|
+
allowDraft,
|
|
29
|
+
});
|
|
30
|
+
forms.set(name, formViewModel);
|
|
31
|
+
diagnostics.push(...formViewModel.diagnostics);
|
|
32
|
+
}
|
|
33
|
+
for (const [name, table] of normalized.views.tables) {
|
|
34
|
+
const tableViewModel = buildTableViewModel(table, normalized.fieldsByName, resource.schema.actions, `schema.views.tables.${name}`, {
|
|
35
|
+
capabilities: resource.schema.capabilities,
|
|
36
|
+
tree: resource.schema.tree,
|
|
37
|
+
});
|
|
38
|
+
tables.set(name, tableViewModel);
|
|
39
|
+
diagnostics.push(...tableViewModel.diagnostics);
|
|
40
|
+
}
|
|
41
|
+
for (const [name, search] of normalized.views.searches) {
|
|
42
|
+
const searchViewModel = buildSearchViewModel(search, normalized.fieldsByName, resource.schema.actions, `schema.views.searches.${name}`);
|
|
43
|
+
searches.set(name, searchViewModel);
|
|
44
|
+
diagnostics.push(...searchViewModel.diagnostics);
|
|
45
|
+
}
|
|
46
|
+
for (const [name, detail] of normalized.views.details) {
|
|
47
|
+
details.set(name, buildDetailViewModel(detail, normalized.fieldsByName, `schema.views.details.${name}.children`));
|
|
48
|
+
}
|
|
49
|
+
for (const [name, page] of normalized.views.pages) {
|
|
50
|
+
const pageViewModel = buildPageViewModel(page, {
|
|
51
|
+
forms,
|
|
52
|
+
tables,
|
|
53
|
+
searches,
|
|
54
|
+
details,
|
|
55
|
+
}, `schema.views.pages.${name}`);
|
|
56
|
+
pages.set(name, pageViewModel);
|
|
57
|
+
diagnostics.push(...pageViewModel.diagnostics);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
resource: resource.resource,
|
|
61
|
+
schema: resource.schema,
|
|
62
|
+
fieldsByName: normalized.fieldsByName,
|
|
63
|
+
pages,
|
|
64
|
+
forms,
|
|
65
|
+
tables,
|
|
66
|
+
searches,
|
|
67
|
+
details,
|
|
68
|
+
diagnostics,
|
|
69
|
+
fatal: normalized.fatal || diagnostics.some((item) => item.fatal),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=build-resource-view-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-resource-view-model.js","sourceRoot":"","sources":["../../src/view-model/build-resource-view-model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,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,IAAI,EACJ;YACI,KAAK;YACL,MAAM;YACN,QAAQ;YACR,OAAO;SACV,EACD,sBAAsB,IAAI,EAAE,CAC/B,CAAA;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;QAC9B,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;IAClD,CAAC;IAED,OAAO;QACH,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,KAAK;QACL,KAAK;QACL,MAAM;QACN,QAAQ;QACR,OAAO;QACP,WAAW;QACX,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;KACpE,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ActionDefinition, ResourceField, SearchView } from '@sparqjs/schema-protocol';
|
|
2
|
+
import type { RuntimeSearchView } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 构建搜索运行视图。
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildSearchViewModel(search: SearchView, fieldsByName: Map<string, ResourceField>, definitions: Record<string, ActionDefinition> | undefined, path: string): RuntimeSearchView;
|
|
7
|
+
//# sourceMappingURL=build-search-view-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-search-view-model.d.ts","sourceRoot":"","sources":["../../src/view-model/build-search-view-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAc,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAIvG,OAAO,KAAK,EAA6C,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3F;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS,EACzD,IAAI,EAAE,MAAM,GACb,iBAAiB,CAiBnB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { resolveActions } from '../action';
|
|
2
|
+
import { inferSearchComponent, inferSearchOperator } from '../inference';
|
|
3
|
+
import { resolveComponentPlaceholder } from './placeholder';
|
|
4
|
+
/**
|
|
5
|
+
* 构建搜索运行视图。
|
|
6
|
+
*/
|
|
7
|
+
export function buildSearchViewModel(search, fieldsByName, definitions, path) {
|
|
8
|
+
const operation = buildRuntimeSearchOperation(search, definitions, `${path}.actions`);
|
|
9
|
+
return {
|
|
10
|
+
raw: search,
|
|
11
|
+
title: search.title,
|
|
12
|
+
layout: search.layout,
|
|
13
|
+
collapsed: search.collapsed,
|
|
14
|
+
props: search.props,
|
|
15
|
+
span: search.span,
|
|
16
|
+
gap: search.gap,
|
|
17
|
+
items: (search.items ?? []).map((item, index) => buildRuntimeSearchItem(item, fieldsByName, `${path}.items.${index}`)),
|
|
18
|
+
operation: operation.operation,
|
|
19
|
+
diagnostics: operation.diagnostics,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 构建搜索操作区。
|
|
24
|
+
*/
|
|
25
|
+
function buildRuntimeSearchOperation(search, definitions, path) {
|
|
26
|
+
if (search.actions === false) {
|
|
27
|
+
return {
|
|
28
|
+
operation: {
|
|
29
|
+
visible: false,
|
|
30
|
+
actions: [],
|
|
31
|
+
},
|
|
32
|
+
diagnostics: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const result = resolveActions({
|
|
36
|
+
refs: search.actions ?? getDefaultSearchActions(),
|
|
37
|
+
definitions,
|
|
38
|
+
defaultScope: 'form',
|
|
39
|
+
path,
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
operation: {
|
|
43
|
+
visible: true,
|
|
44
|
+
actions: result.actions,
|
|
45
|
+
},
|
|
46
|
+
diagnostics: result.diagnostics,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 构建搜索运行项。
|
|
51
|
+
*/
|
|
52
|
+
function buildRuntimeSearchItem(item, fieldsByName, path) {
|
|
53
|
+
const fieldSchema = fieldsByName.get(item.field);
|
|
54
|
+
const title = item.title ?? fieldSchema?.label;
|
|
55
|
+
const componentKey = item.component ?? (fieldSchema ? inferSearchComponent(fieldSchema) : undefined);
|
|
56
|
+
const placeholder = resolveComponentPlaceholder({
|
|
57
|
+
componentKey,
|
|
58
|
+
label: title,
|
|
59
|
+
explicit: hasOwn(item.props, 'placeholder') ? item.props?.placeholder : undefined,
|
|
60
|
+
});
|
|
61
|
+
const props = {
|
|
62
|
+
...item.props,
|
|
63
|
+
...(placeholder !== undefined ? { placeholder } : {}),
|
|
64
|
+
};
|
|
65
|
+
const operators = resolveSearchItemOperators(item);
|
|
66
|
+
return {
|
|
67
|
+
raw: item,
|
|
68
|
+
id: item.field ?? path,
|
|
69
|
+
field: item.field,
|
|
70
|
+
fieldSchema,
|
|
71
|
+
title,
|
|
72
|
+
operator: item.operator ?? (fieldSchema ? inferSearchOperator(fieldSchema) : undefined),
|
|
73
|
+
operators,
|
|
74
|
+
componentKey,
|
|
75
|
+
showLabel: item.show_label ?? false,
|
|
76
|
+
placeholder,
|
|
77
|
+
span: item.span ?? (operators.length > 0 ? 12 : 6),
|
|
78
|
+
gap: item.gap,
|
|
79
|
+
props,
|
|
80
|
+
dataSource: item.dataSource,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function hasOwn(input, key) {
|
|
84
|
+
return input ? Object.prototype.hasOwnProperty.call(input, key) : false;
|
|
85
|
+
}
|
|
86
|
+
function resolveSearchItemOperators(item) {
|
|
87
|
+
if (item.operators?.length) {
|
|
88
|
+
return item.operators;
|
|
89
|
+
}
|
|
90
|
+
const propsOperators = item.props?.operators ?? item.props?.operatorOptions ?? item.props?.operator_options;
|
|
91
|
+
return Array.isArray(propsOperators)
|
|
92
|
+
? propsOperators.filter((operator) => typeof operator === 'string')
|
|
93
|
+
: [];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 默认搜索操作。
|
|
97
|
+
*/
|
|
98
|
+
function getDefaultSearchActions() {
|
|
99
|
+
return [{ action: 'search.submit' }, { action: 'search.reset' }];
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=build-search-view-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-search-view-model.js","sourceRoot":"","sources":["../../src/view-model/build-search-view-model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAG3D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAChC,MAAkB,EAClB,YAAwC,EACxC,WAAyD,EACzD,IAAY;IAEZ,MAAM,SAAS,GAAG,2BAA2B,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,UAAU,CAAC,CAAA;IAErF,OAAO;QACH,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAC5C,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,UAAU,KAAK,EAAE,C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IAAI,CAAC,KAAK,EAAE,eAAe,IAAI,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAA;IAC3G,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;QAChC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAsB,EAAE,CAAC,OAAO,QAAQ,KAAK,QAAQ,CAAC;QACvF,CAAC,CAAC,EAAE,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ActionDefinition, ResourceField, ResourceSchema, TableView } from '@sparqjs/schema-protocol';
|
|
2
|
+
import { type ResolvedAction } from '../action';
|
|
3
|
+
import type { RuntimeTableView } from './types';
|
|
4
|
+
interface BuildTableViewModelOptions {
|
|
5
|
+
capabilities?: ResourceSchema['capabilities'];
|
|
6
|
+
tree?: ResourceSchema['tree'];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 构建表格运行视图。
|
|
10
|
+
*
|
|
11
|
+
* 字段列会补齐 fieldSchema;toolbar 和 operate 会解析为运行时结构。
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildTableViewModel(table: TableView, fieldsByName: Map<string, ResourceField>, definitions: Record<string, ActionDefinition> | undefined, path: string, options?: BuildTableViewModelOptions): RuntimeTableView;
|
|
14
|
+
/**
|
|
15
|
+
* 根据操作按钮数量、文案和图标推导操作列默认宽度。
|
|
16
|
+
*/
|
|
17
|
+
export declare function inferTableOperateColumnWidth(actions: ResolvedAction[]): number | undefined;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=build-table-view-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-table-view-model.d.ts","sourceRoot":"","sources":["../../src/view-model/build-table-view-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAEhB,aAAa,EACb,cAAc,EAKd,SAAS,EACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAeH,KAAK,cAAc,EACtB,MAAM,WAAW,CAAA;AAElB,OAAO,KAAK,EASR,gBAAgB,EACnB,MAAM,SAAS,CAAA;AAYhB,UAAU,0BAA0B;IAChC,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAA;IAC7C,IAAI,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAChC;AASD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAC/B,KAAK,EAAE,SAAS,EAChB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS,EACzD,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,0BAA+B,GACzC,gBAAgB,CAoClB;AAqaD;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,GAAG,SAAS,CAc1F"}
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { BUILTIN_ACTION_CREATE, BUILTIN_ACTION_CREATE_CHILD, BUILTIN_ACTION_DELETE, BUILTIN_ACTION_DUPLICATE, BUILTIN_ACTION_EXPORT, BUILTIN_ACTION_IMPORT, BUILTIN_ACTION_PRINT, BUILTIN_ACTION_RECYCLE_BIN, BUILTIN_ACTION_RELOAD, BUILTIN_ACTION_RESTORE, BUILTIN_ACTION_RETURN_LIST, BUILTIN_ACTION_PURGE, BUILTIN_ACTION_UPDATE, resolveActions, } from '../action';
|
|
2
|
+
import { inferSearchComponent, inferSearchOperator, inferTableComponent } from '../inference';
|
|
3
|
+
const OPERATE_COLUMN_MIN_WIDTH = 88;
|
|
4
|
+
const OPERATE_ACTION_BASE_WIDTH = 36;
|
|
5
|
+
const OPERATE_ACTION_ICON_WIDTH = 18;
|
|
6
|
+
const OPERATE_ACTION_TEXT_UNIT_WIDTH = 16;
|
|
7
|
+
const OPERATE_ACTION_GAP_WIDTH = 10;
|
|
8
|
+
const OPERATE_INLINE_ACTION_LIMIT = 3;
|
|
9
|
+
/**
|
|
10
|
+
* 构建表格运行视图。
|
|
11
|
+
*
|
|
12
|
+
* 字段列会补齐 fieldSchema;toolbar 和 operate 会解析为运行时结构。
|
|
13
|
+
*/
|
|
14
|
+
export function buildTableViewModel(table, fieldsByName, definitions, path, options = {}) {
|
|
15
|
+
const operateResult = buildRuntimeTableOperate(table, definitions, `${path}.operate`, {
|
|
16
|
+
capabilities: options.capabilities,
|
|
17
|
+
tree: options.tree,
|
|
18
|
+
});
|
|
19
|
+
const toolbarResult = buildRuntimeTableToolbar(table, fieldsByName, definitions, `${path}.toolbar`, options.capabilities);
|
|
20
|
+
const tree = buildRuntimeTableTree(table.tree);
|
|
21
|
+
const columns = buildRuntimeTableColumns(table.columns ?? [], fieldsByName, path, table.mode === 'tree' ? tree?.expandColumn : undefined);
|
|
22
|
+
return {
|
|
23
|
+
raw: table,
|
|
24
|
+
mode: table.mode,
|
|
25
|
+
tree,
|
|
26
|
+
title: table.title,
|
|
27
|
+
help: table.help,
|
|
28
|
+
props: table.props,
|
|
29
|
+
index: buildRuntimeTableIndex(table.index),
|
|
30
|
+
columns,
|
|
31
|
+
selection: buildRuntimeTableSelection(table.selection),
|
|
32
|
+
pagination: buildRuntimeTablePagination(table.pagination, table.mode),
|
|
33
|
+
editing: buildRuntimeTableEditing(table),
|
|
34
|
+
operate: operateResult.operate,
|
|
35
|
+
toolbar: toolbarResult.toolbar,
|
|
36
|
+
diagnostics: [...operateResult.diagnostics, ...toolbarResult.diagnostics],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 构建树形表格运行配置。
|
|
41
|
+
*/
|
|
42
|
+
function buildRuntimeTableTree(tree) {
|
|
43
|
+
if (!tree) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
raw: tree,
|
|
48
|
+
defaultExpand: tree.default_expand,
|
|
49
|
+
expandLevel: tree.expand_level,
|
|
50
|
+
expandedKeys: tree.expanded_keys,
|
|
51
|
+
expandColumn: tree.expand_column,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 构建数据列并标记它们相对显式树展开列的位置。
|
|
56
|
+
*/
|
|
57
|
+
function buildRuntimeTableColumns(columns, fieldsByName, path, expandColumn) {
|
|
58
|
+
const runtimeColumns = columns.map((column, index) => buildRuntimeTableColumn(column, fieldsByName, `${path}.columns.${index}`));
|
|
59
|
+
if (!expandColumn) {
|
|
60
|
+
return runtimeColumns;
|
|
61
|
+
}
|
|
62
|
+
const expandIndex = runtimeColumns.findIndex((column) => column.id === expandColumn || column.field === expandColumn);
|
|
63
|
+
if (expandIndex < 0) {
|
|
64
|
+
return runtimeColumns;
|
|
65
|
+
}
|
|
66
|
+
return runtimeColumns.map((column, index) => ({
|
|
67
|
+
...column,
|
|
68
|
+
treeRole: index < expandIndex ? 'leading' : index === expandIndex ? 'expand' : 'trailing',
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 构建表格运行时序号列。
|
|
73
|
+
*/
|
|
74
|
+
function buildRuntimeTableIndex(index) {
|
|
75
|
+
if (index === false || index === undefined) {
|
|
76
|
+
return {
|
|
77
|
+
raw: index,
|
|
78
|
+
visible: false,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (index === true) {
|
|
82
|
+
return {
|
|
83
|
+
raw: true,
|
|
84
|
+
visible: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
raw: index,
|
|
89
|
+
visible: true,
|
|
90
|
+
title: index.title,
|
|
91
|
+
width: index.width,
|
|
92
|
+
fixed: index.fixed,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 构建表格运行时选择列。
|
|
97
|
+
*/
|
|
98
|
+
function buildRuntimeTableSelection(selection) {
|
|
99
|
+
if (selection === false) {
|
|
100
|
+
return {
|
|
101
|
+
raw: false,
|
|
102
|
+
visible: false,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (!selection) {
|
|
106
|
+
return {
|
|
107
|
+
visible: true,
|
|
108
|
+
type: 'checkbox',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
raw: selection,
|
|
113
|
+
visible: true,
|
|
114
|
+
type: selection.type,
|
|
115
|
+
props: selection.props,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 构建表格运行时分页。
|
|
120
|
+
*/
|
|
121
|
+
function buildRuntimeTablePagination(pagination, mode) {
|
|
122
|
+
if (pagination === false) {
|
|
123
|
+
return {
|
|
124
|
+
raw: false,
|
|
125
|
+
visible: false,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (mode === 'tree' && pagination === undefined) {
|
|
129
|
+
return {
|
|
130
|
+
visible: false,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (pagination === true || pagination === undefined) {
|
|
134
|
+
return {
|
|
135
|
+
raw: pagination,
|
|
136
|
+
visible: true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
raw: pagination,
|
|
141
|
+
visible: true,
|
|
142
|
+
pageSize: pagination.pageSize,
|
|
143
|
+
pageSizes: pagination.pageSizes,
|
|
144
|
+
props: pagination.props,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 构建表格运行时编辑配置。
|
|
149
|
+
*/
|
|
150
|
+
function buildRuntimeTableEditing(table) {
|
|
151
|
+
const editing = table.editing;
|
|
152
|
+
if (!editing || editing.mode === undefined || editing.mode === 'none') {
|
|
153
|
+
return {
|
|
154
|
+
raw: editing,
|
|
155
|
+
enabled: false,
|
|
156
|
+
fields: [],
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
raw: editing,
|
|
161
|
+
enabled: editing.mode === 'inline',
|
|
162
|
+
mode: editing.mode,
|
|
163
|
+
createMode: editing.createMode,
|
|
164
|
+
updateMode: editing.updateMode,
|
|
165
|
+
saveMode: editing.saveMode ?? 'row',
|
|
166
|
+
fields: editing.fields ?? [],
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 构建表格运行时工具栏。
|
|
171
|
+
*/
|
|
172
|
+
function buildRuntimeTableToolbar(table, fieldsByName, definitions, path, capabilities) {
|
|
173
|
+
if (table.toolbar === false) {
|
|
174
|
+
return {
|
|
175
|
+
toolbar: {
|
|
176
|
+
visible: false,
|
|
177
|
+
left: [],
|
|
178
|
+
right: [],
|
|
179
|
+
batch: [],
|
|
180
|
+
filters: [],
|
|
181
|
+
},
|
|
182
|
+
diagnostics: [],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const toolbar = table.toolbar ?? {};
|
|
186
|
+
const leftResult = resolveActions({
|
|
187
|
+
refs: getToolbarLeftActions(toolbar),
|
|
188
|
+
definitions,
|
|
189
|
+
defaultScope: 'collection',
|
|
190
|
+
path: `${path}.left`,
|
|
191
|
+
});
|
|
192
|
+
const rightResult = resolveActions({
|
|
193
|
+
refs: toolbar.right ?? getDefaultToolbarRightActions(capabilities),
|
|
194
|
+
definitions,
|
|
195
|
+
defaultScope: 'collection',
|
|
196
|
+
path: `${path}.right`,
|
|
197
|
+
});
|
|
198
|
+
const batchResult = resolveActions({
|
|
199
|
+
refs: toolbar.batch ?? getDefaultToolbarBatchActions(),
|
|
200
|
+
definitions,
|
|
201
|
+
defaultScope: 'batch',
|
|
202
|
+
path: `${path}.batch`,
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
toolbar: {
|
|
206
|
+
visible: true,
|
|
207
|
+
left: leftResult.actions,
|
|
208
|
+
right: rightResult.actions,
|
|
209
|
+
batch: batchResult.actions,
|
|
210
|
+
filters: (toolbar.filters ?? []).map((filter, index) => buildRuntimeTableFilter(filter, fieldsByName, `${path}.filters.${index}`)),
|
|
211
|
+
props: toolbar.props,
|
|
212
|
+
},
|
|
213
|
+
diagnostics: [...leftResult.diagnostics, ...rightResult.diagnostics, ...batchResult.diagnostics],
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 获取工具栏左侧动作。
|
|
218
|
+
*
|
|
219
|
+
* actions 是 left 的简写;两者都缺失时使用默认 create。
|
|
220
|
+
*/
|
|
221
|
+
function getToolbarLeftActions(toolbar) {
|
|
222
|
+
return toolbar.left ?? toolbar.actions ?? getDefaultToolbarLeftActions();
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 默认工具栏左侧动作。
|
|
226
|
+
*/
|
|
227
|
+
function getDefaultToolbarLeftActions() {
|
|
228
|
+
return [{ action: BUILTIN_ACTION_CREATE }];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* 默认工具栏右侧动作。
|
|
232
|
+
*/
|
|
233
|
+
function getDefaultToolbarRightActions(capabilities) {
|
|
234
|
+
const actions = [{ action: BUILTIN_ACTION_RELOAD }];
|
|
235
|
+
if (capabilityEnabled(capabilities, 'allow_import')) {
|
|
236
|
+
actions.push({ action: BUILTIN_ACTION_IMPORT });
|
|
237
|
+
}
|
|
238
|
+
if (capabilityEnabled(capabilities, 'allow_export')) {
|
|
239
|
+
actions.push({ action: BUILTIN_ACTION_EXPORT });
|
|
240
|
+
}
|
|
241
|
+
if (capabilityEnabled(capabilities, 'allow_recycle')) {
|
|
242
|
+
actions.push({ action: BUILTIN_ACTION_RECYCLE_BIN });
|
|
243
|
+
actions.push({ action: BUILTIN_ACTION_RETURN_LIST });
|
|
244
|
+
}
|
|
245
|
+
return actions;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* 默认工具栏批量动作。
|
|
249
|
+
*/
|
|
250
|
+
function getDefaultToolbarBatchActions() {
|
|
251
|
+
return [{ action: BUILTIN_ACTION_DELETE, disabled_when: { selection_empty: true } }];
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* 构建表格快捷筛选运行项。
|
|
255
|
+
*/
|
|
256
|
+
function buildRuntimeTableFilter(filter, fieldsByName, path) {
|
|
257
|
+
const fieldSchema = filter.field ? fieldsByName.get(filter.field) : undefined;
|
|
258
|
+
return {
|
|
259
|
+
raw: filter,
|
|
260
|
+
id: filter.field ?? path,
|
|
261
|
+
field: filter.field,
|
|
262
|
+
fieldSchema,
|
|
263
|
+
title: filter.title ?? fieldSchema?.label,
|
|
264
|
+
componentKey: filter.component ?? (fieldSchema ? inferSearchComponent(fieldSchema) : undefined),
|
|
265
|
+
operator: filter.operator ?? (fieldSchema ? inferSearchOperator(fieldSchema) : undefined),
|
|
266
|
+
defaultValue: filter.defaultValue,
|
|
267
|
+
dataSource: filter.dataSource ?? (filter.options ? { type: 'static-options', options: filter.options } : undefined),
|
|
268
|
+
props: filter.props,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* 构建表格运行时操作列。
|
|
273
|
+
*
|
|
274
|
+
* operate=false 表示隐藏操作列;数组表示只声明动作;对象形式可以配置列标题、宽度、固定列等属性。
|
|
275
|
+
*/
|
|
276
|
+
function buildRuntimeTableOperate(table, definitions, path, options) {
|
|
277
|
+
if (table.operate === false) {
|
|
278
|
+
return {
|
|
279
|
+
operate: {
|
|
280
|
+
raw: false,
|
|
281
|
+
visible: false,
|
|
282
|
+
group: true,
|
|
283
|
+
actions: [],
|
|
284
|
+
},
|
|
285
|
+
diagnostics: [],
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const config = getOperateConfig(table.operate);
|
|
289
|
+
const refs = getOperateActionRefs(table.operate, table.mode, options);
|
|
290
|
+
const resolvedRefs = config?.collapse === true ? groupOperateActionRefs(refs) : refs;
|
|
291
|
+
const resolved = resolveActions({
|
|
292
|
+
refs: resolvedRefs,
|
|
293
|
+
definitions,
|
|
294
|
+
defaultScope: 'record',
|
|
295
|
+
path: Array.isArray(table.operate) ? path : `${path}.actions`,
|
|
296
|
+
});
|
|
297
|
+
return {
|
|
298
|
+
operate: {
|
|
299
|
+
raw: table.operate,
|
|
300
|
+
visible: true,
|
|
301
|
+
title: config?.title,
|
|
302
|
+
width: config?.width ?? inferTableOperateColumnWidth(resolved.actions),
|
|
303
|
+
minWidth: config?.minWidth,
|
|
304
|
+
fixed: config?.fixed ?? 'right',
|
|
305
|
+
align: config?.align,
|
|
306
|
+
group: config?.group !== false,
|
|
307
|
+
props: config?.props,
|
|
308
|
+
actions: resolved.actions,
|
|
309
|
+
},
|
|
310
|
+
diagnostics: resolved.diagnostics,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* 获取操作列配置对象。
|
|
315
|
+
*/
|
|
316
|
+
function getOperateConfig(operate) {
|
|
317
|
+
return operate && !Array.isArray(operate) ? operate : undefined;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 获取操作列动作引用。
|
|
321
|
+
*
|
|
322
|
+
* operate 缺失时生成保守默认动作;对象形式缺少 actions 时也使用默认动作。
|
|
323
|
+
*/
|
|
324
|
+
function getOperateActionRefs(operate, mode, options) {
|
|
325
|
+
if (Array.isArray(operate)) {
|
|
326
|
+
return operate;
|
|
327
|
+
}
|
|
328
|
+
if (operate && !Array.isArray(operate)) {
|
|
329
|
+
return operate.actions ?? getDefaultOperateActions(mode, options);
|
|
330
|
+
}
|
|
331
|
+
return getDefaultOperateActions(mode, options);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* 默认行操作。
|
|
335
|
+
*
|
|
336
|
+
* 未显式配置 operate 时生成常规编辑和删除操作。
|
|
337
|
+
*/
|
|
338
|
+
function getDefaultOperateActions(mode, options) {
|
|
339
|
+
const capabilities = options.capabilities;
|
|
340
|
+
const actions = [{ action: BUILTIN_ACTION_UPDATE }, { action: BUILTIN_ACTION_DELETE }];
|
|
341
|
+
if (mode === 'tree' && options.tree?.enabled !== false) {
|
|
342
|
+
actions.push({ action: BUILTIN_ACTION_CREATE_CHILD });
|
|
343
|
+
}
|
|
344
|
+
if (capabilityEnabled(capabilities, 'allow_duplicate')) {
|
|
345
|
+
actions.push({ action: BUILTIN_ACTION_DUPLICATE });
|
|
346
|
+
}
|
|
347
|
+
if (capabilityEnabled(capabilities, 'allow_print')) {
|
|
348
|
+
actions.push({ action: BUILTIN_ACTION_PRINT });
|
|
349
|
+
}
|
|
350
|
+
if (capabilityEnabled(capabilities, 'allow_recycle')) {
|
|
351
|
+
actions.push({ action: BUILTIN_ACTION_RESTORE }, { action: BUILTIN_ACTION_PURGE });
|
|
352
|
+
}
|
|
353
|
+
return actions;
|
|
354
|
+
}
|
|
355
|
+
function capabilityEnabled(capabilities, key) {
|
|
356
|
+
return capabilities?.[key] === true;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 显式启用折叠后,将超出直接展示数量的操作收进更多菜单。
|
|
360
|
+
*/
|
|
361
|
+
function groupOperateActionRefs(refs) {
|
|
362
|
+
if (refs.length <= OPERATE_INLINE_ACTION_LIMIT) {
|
|
363
|
+
return refs;
|
|
364
|
+
}
|
|
365
|
+
const recycleActions = refs.filter(isRecycleOperateAction);
|
|
366
|
+
const normalActions = refs.filter((action) => !isRecycleOperateAction(action));
|
|
367
|
+
if (normalActions.length <= OPERATE_INLINE_ACTION_LIMIT) {
|
|
368
|
+
return [...normalActions, ...recycleActions];
|
|
369
|
+
}
|
|
370
|
+
const visible = normalActions.slice(0, OPERATE_INLINE_ACTION_LIMIT - 1);
|
|
371
|
+
const grouped = normalActions.slice(OPERATE_INLINE_ACTION_LIMIT - 1);
|
|
372
|
+
return [
|
|
373
|
+
...visible,
|
|
374
|
+
{
|
|
375
|
+
action: 'more',
|
|
376
|
+
type: 'dropdown',
|
|
377
|
+
children: grouped,
|
|
378
|
+
},
|
|
379
|
+
...recycleActions,
|
|
380
|
+
];
|
|
381
|
+
}
|
|
382
|
+
function isRecycleOperateAction(ref) {
|
|
383
|
+
return ref.action === BUILTIN_ACTION_RESTORE || ref.action === BUILTIN_ACTION_PURGE;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* 根据操作按钮数量、文案和图标推导操作列默认宽度。
|
|
387
|
+
*/
|
|
388
|
+
export function inferTableOperateColumnWidth(actions) {
|
|
389
|
+
if (!actions.length) {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
const normalActions = actions.filter((action) => !isRecycleOperateAction(action));
|
|
393
|
+
const recycleActions = actions.filter(isRecycleOperateAction);
|
|
394
|
+
const widthActions = [
|
|
395
|
+
normalActions.length > 0 ? normalActions : actions,
|
|
396
|
+
recycleActions.length > 0 ? recycleActions : [],
|
|
397
|
+
];
|
|
398
|
+
const contentWidth = Math.max(...widthActions.map(inferOperateActionsWidth));
|
|
399
|
+
return Math.max(contentWidth, OPERATE_COLUMN_MIN_WIDTH);
|
|
400
|
+
}
|
|
401
|
+
function inferOperateActionsWidth(actions) {
|
|
402
|
+
if (actions.length === 0) {
|
|
403
|
+
return 0;
|
|
404
|
+
}
|
|
405
|
+
const contentWidth = actions.reduce((total, action) => total + inferOperateActionWidth(action), 0);
|
|
406
|
+
const gapWidth = Math.max(actions.length - 1, 0) * OPERATE_ACTION_GAP_WIDTH;
|
|
407
|
+
return contentWidth + gapWidth;
|
|
408
|
+
}
|
|
409
|
+
function inferOperateActionWidth(action) {
|
|
410
|
+
const label = action.title ?? action.action;
|
|
411
|
+
const iconWidth = action.icon ? OPERATE_ACTION_ICON_WIDTH : 0;
|
|
412
|
+
return OPERATE_ACTION_BASE_WIDTH + iconWidth + label.length * OPERATE_ACTION_TEXT_UNIT_WIDTH;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* 构建表格运行列。
|
|
416
|
+
*/
|
|
417
|
+
function buildRuntimeTableColumn(column, fieldsByName, path) {
|
|
418
|
+
const fieldSchema = column.field ? fieldsByName.get(column.field) : undefined;
|
|
419
|
+
return {
|
|
420
|
+
raw: column,
|
|
421
|
+
id: column.id ?? column.field ?? path,
|
|
422
|
+
field: column.field,
|
|
423
|
+
fieldSchema,
|
|
424
|
+
title: column.title ?? fieldSchema?.label,
|
|
425
|
+
componentKey: column.component ?? inferColumnComponent(fieldSchema),
|
|
426
|
+
template: column.template,
|
|
427
|
+
value: column.value,
|
|
428
|
+
format: column.format,
|
|
429
|
+
width: column.width,
|
|
430
|
+
minWidth: column.minWidth,
|
|
431
|
+
fixed: column.fixed,
|
|
432
|
+
align: column.align,
|
|
433
|
+
sortable: column.sortable ?? fieldSchema?.sortable,
|
|
434
|
+
props: column.props,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* 推导表格列组件。
|
|
439
|
+
*/
|
|
440
|
+
function inferColumnComponent(field) {
|
|
441
|
+
return field ? inferTableComponent(field) : undefined;
|
|
442
|
+
}
|
|
443
|
+
//# sourceMappingURL=build-table-view-model.js.map
|