nuxt-ui-tools 1.12.0 → 1.13.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 +11 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +46 -0
- package/dist/runtime/dashboard/components/dashboard-stat.d.vue.ts +1 -1
- package/dist/runtime/dashboard/components/dashboard-stat.vue.d.ts +1 -1
- package/dist/runtime/file-preview/components/shell/file-preview-stage.d.vue.ts +2 -2
- package/dist/runtime/file-preview/components/shell/file-preview-stage.vue.d.ts +2 -2
- package/dist/runtime/i18n/locales/en.js +251 -130
- package/dist/runtime/i18n/locales/fr.js +251 -130
- package/dist/runtime/i18n/types.d.ts +241 -119
- package/dist/runtime/shared/types/remote-options.d.ts +11 -0
- package/dist/runtime/shared/utils/define-remote-options.js +6 -0
- package/dist/runtime/shared/utils/file.d.ts +1 -1
- package/dist/runtime/spreadsheet/components/{steps/review/spreadsheet-review-overflow-alert.d.vue.ts → internal/spreadsheet-import-cell-editor.d.vue.ts} +8 -5
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-cell-editor.vue +73 -0
- package/dist/runtime/spreadsheet/components/{steps/review/spreadsheet-review-overflow-alert.vue.d.ts → internal/spreadsheet-import-cell-editor.vue.d.ts} +8 -5
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-column-row.d.vue.ts +17 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-column-row.vue +98 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-column-row.vue.d.ts +17 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-heading.d.vue.ts +17 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-heading.vue +20 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-heading.vue.d.ts +17 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-status-badge.d.vue.ts +10 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-status-badge.vue +34 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-status-badge.vue.d.ts +10 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-value-row.d.vue.ts +13 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-value-row.vue +113 -0
- package/dist/runtime/spreadsheet/components/internal/spreadsheet-import-value-row.vue.d.ts +13 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-column-mapping.d.vue.ts +35 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-column-mapping.vue +154 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-column-mapping.vue.d.ts +35 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-dropzone.d.vue.ts +23 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-dropzone.vue +83 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-dropzone.vue.d.ts +23 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-expected-columns.d.vue.ts +19 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-expected-columns.vue +45 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-expected-columns.vue.d.ts +19 -0
- package/dist/runtime/spreadsheet/components/{shared/spreadsheet-object-preview-table.d.vue.ts → parts/spreadsheet-import-export-button.d.vue.ts} +3 -2
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-export-button.vue +34 -0
- package/dist/runtime/spreadsheet/components/{layout/spreadsheet-import-file-bar.vue.d.ts → parts/spreadsheet-import-export-button.vue.d.ts} +3 -4
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-file-card.d.vue.ts +17 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-file-card.vue +49 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-file-card.vue.d.ts +17 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-progress.d.vue.ts +18 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-progress.vue +101 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-progress.vue.d.ts +18 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-row-inspector.d.vue.ts +22 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-row-inspector.vue +276 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-row-inspector.vue.d.ts +22 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-source-settings.d.vue.ts +11 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-source-settings.vue +164 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-source-settings.vue.d.ts +11 -0
- package/dist/runtime/spreadsheet/components/{shared/spreadsheet-value-preview.d.vue.ts → parts/spreadsheet-import-stat.d.vue.ts} +7 -4
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-stat.vue +30 -0
- package/dist/runtime/spreadsheet/components/{shared/spreadsheet-value-preview.vue.d.ts → parts/spreadsheet-import-stat.vue.d.ts} +7 -4
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-stats.d.vue.ts +26 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-stats.vue +55 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-stats.vue.d.ts +26 -0
- package/dist/runtime/spreadsheet/components/{shared/spreadsheet-object-preview-table.vue.d.ts → parts/spreadsheet-import-submit-button.d.vue.ts} +3 -2
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-submit-button.vue +27 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-submit-button.vue.d.ts +8 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-summary.d.vue.ts +16 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-summary.vue +51 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-summary.vue.d.ts +16 -0
- package/dist/runtime/spreadsheet/components/{layout/spreadsheet-import-file-bar.d.vue.ts → parts/spreadsheet-import-table-toolbar.d.vue.ts} +2 -4
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-table-toolbar.vue +217 -0
- package/dist/runtime/spreadsheet/components/{shared/spreadsheet-raw-preview-table.d.vue.ts → parts/spreadsheet-import-table-toolbar.vue.d.ts} +2 -2
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-table.d.vue.ts +33 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-table.vue +302 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-table.vue.d.ts +33 -0
- package/dist/runtime/spreadsheet/components/{layout/spreadsheet-import-sidebar.d.vue.ts → parts/spreadsheet-import-template-button.d.vue.ts} +5 -4
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-template-button.vue +31 -0
- package/dist/runtime/spreadsheet/components/{layout/spreadsheet-import-sidebar.vue.d.ts → parts/spreadsheet-import-template-button.vue.d.ts} +5 -4
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-value-mapping.d.vue.ts +27 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-value-mapping.vue +162 -0
- package/dist/runtime/spreadsheet/components/parts/spreadsheet-import-value-mapping.vue.d.ts +27 -0
- package/dist/runtime/spreadsheet/components/spreadsheet-import-root.d.vue.ts +24 -0
- package/dist/runtime/spreadsheet/components/spreadsheet-import-root.vue +23 -0
- package/dist/runtime/spreadsheet/components/spreadsheet-import-root.vue.d.ts +24 -0
- package/dist/runtime/spreadsheet/components/spreadsheet-import.d.vue.ts +21 -6
- package/dist/runtime/spreadsheet/components/spreadsheet-import.vue +46 -262
- package/dist/runtime/spreadsheet/components/spreadsheet-import.vue.d.ts +21 -6
- package/dist/runtime/spreadsheet/components/{layout/spreadsheet-import-header.d.vue.ts → steps/spreadsheet-import-step-nav.d.vue.ts} +6 -2
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-step-nav.vue +116 -0
- package/dist/runtime/spreadsheet/components/{layout/spreadsheet-import-header.vue.d.ts → steps/spreadsheet-import-step-nav.vue.d.ts} +6 -2
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-step.d.vue.ts +26 -0
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-step.vue +106 -0
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-step.vue.d.ts +26 -0
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-stepper.d.vue.ts +15 -0
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-stepper.vue +131 -0
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-stepper.vue.d.ts +15 -0
- package/dist/runtime/spreadsheet/composables/index.d.ts +2 -0
- package/dist/runtime/spreadsheet/composables/index.js +2 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-answers.d.ts +8 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-answers.js +19 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-columns.d.ts +23 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-columns.js +75 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-context.d.ts +8 -45
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-context.js +28 -32
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-edits.d.ts +11 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-edits.js +25 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-fields.d.ts +16 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-fields.js +20 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-file.d.ts +14 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-file.js +44 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-import-context.d.ts +12 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-import-context.js +22 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-import.d.ts +18 -7
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-import.js +340 -109
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-layout.d.ts +36 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-layout.js +95 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-options.d.ts +24 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-options.js +159 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-queries.d.ts +14 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-queries.js +11 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-review.d.ts +37 -169
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-review.js +148 -408
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-rows.d.ts +48 -26
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-rows.js +334 -21
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-steps.d.ts +33 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-steps.js +126 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-submit.d.ts +37 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-submit.js +136 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-values.d.ts +27 -0
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-values.js +121 -0
- package/dist/runtime/spreadsheet/index.d.ts +0 -1
- package/dist/runtime/spreadsheet/index.js +0 -1
- package/dist/runtime/spreadsheet/schema/builder.d.ts +8 -0
- package/dist/runtime/spreadsheet/schema/builder.js +31 -0
- package/dist/runtime/spreadsheet/schema/index.d.ts +24 -32
- package/dist/runtime/spreadsheet/schema/index.js +4 -21
- package/dist/runtime/spreadsheet/types/columns.d.ts +252 -273
- package/dist/runtime/spreadsheet/types/fields.d.ts +64 -0
- package/dist/runtime/spreadsheet/types/importer.d.ts +308 -0
- package/dist/runtime/spreadsheet/types/index.d.ts +6 -10
- package/dist/runtime/spreadsheet/types/options.d.ts +47 -9
- package/dist/runtime/spreadsheet/types/rows.d.ts +57 -48
- package/dist/runtime/spreadsheet/types/schema.d.ts +162 -76
- package/dist/runtime/spreadsheet/types/shared.d.ts +19 -21
- package/dist/runtime/spreadsheet/types/source.d.ts +39 -15
- package/dist/runtime/spreadsheet/types/steps.d.ts +76 -0
- package/dist/runtime/spreadsheet/types/validation.d.ts +49 -69
- package/dist/runtime/spreadsheet/types/values.d.ts +77 -0
- package/dist/runtime/spreadsheet/utils/download.d.ts +2 -0
- package/dist/runtime/spreadsheet/utils/download.js +8 -0
- package/dist/runtime/spreadsheet/utils/export.d.ts +26 -0
- package/dist/runtime/spreadsheet/utils/export.js +50 -0
- package/dist/runtime/spreadsheet/utils/fields.d.ts +26 -0
- package/dist/runtime/spreadsheet/utils/fields.js +169 -0
- package/dist/runtime/spreadsheet/utils/guards.d.ts +18 -0
- package/dist/runtime/spreadsheet/utils/guards.js +27 -0
- package/dist/runtime/spreadsheet/utils/headers.d.ts +15 -0
- package/dist/runtime/spreadsheet/utils/headers.js +36 -0
- package/dist/runtime/spreadsheet/utils/identity.d.ts +24 -0
- package/dist/runtime/spreadsheet/utils/identity.js +57 -0
- package/dist/runtime/spreadsheet/utils/index.d.ts +15 -6
- package/dist/runtime/spreadsheet/utils/index.js +15 -6
- package/dist/runtime/spreadsheet/utils/layout.d.ts +12 -0
- package/dist/runtime/spreadsheet/utils/layout.js +37 -0
- package/dist/runtime/spreadsheet/utils/options.d.ts +31 -10
- package/dist/runtime/spreadsheet/utils/options.js +58 -30
- package/dist/runtime/spreadsheet/utils/parse.d.ts +6 -0
- package/dist/runtime/spreadsheet/utils/parse.js +147 -0
- package/dist/runtime/spreadsheet/utils/paths.d.ts +4 -0
- package/dist/runtime/spreadsheet/utils/paths.js +29 -0
- package/dist/runtime/spreadsheet/utils/rows.d.ts +69 -0
- package/dist/runtime/spreadsheet/utils/rows.js +168 -0
- package/dist/runtime/spreadsheet/utils/rules.d.ts +4 -0
- package/dist/runtime/spreadsheet/utils/rules.js +95 -0
- package/dist/runtime/spreadsheet/utils/suggestions.d.ts +20 -0
- package/dist/runtime/spreadsheet/utils/suggestions.js +43 -0
- package/dist/runtime/spreadsheet/utils/text.d.ts +9 -0
- package/dist/runtime/spreadsheet/utils/text.js +11 -0
- package/dist/runtime/spreadsheet/utils/workbook.d.ts +13 -0
- package/dist/runtime/spreadsheet/utils/workbook.js +121 -0
- package/dist/runtime/table/components/filters/tags/boolean-filter-tag.d.vue.ts +2 -2
- package/dist/runtime/table/components/filters/tags/boolean-filter-tag.vue.d.ts +2 -2
- package/dist/runtime/table/components/filters/tags/date-filter-tag.d.vue.ts +2 -2
- package/dist/runtime/table/components/filters/tags/date-filter-tag.vue.d.ts +2 -2
- package/dist/runtime/table/components/filters/tags/number-filter-tag.d.vue.ts +2 -2
- package/dist/runtime/table/components/filters/tags/number-filter-tag.vue.d.ts +2 -2
- package/dist/runtime/table/components/filters/tags/option-filter-tag.d.vue.ts +2 -2
- package/dist/runtime/table/components/filters/tags/option-filter-tag.vue.d.ts +2 -2
- package/dist/runtime/table/components/filters/tags/text-filter-tag.d.vue.ts +2 -2
- package/dist/runtime/table/components/filters/tags/text-filter-tag.vue.d.ts +2 -2
- package/dist/runtime/table/components/table/table-cell-ellipsis.d.ts +1 -1
- package/dist/runtime/table/utils/data-list-ui.d.ts +1 -1
- package/package.json +18 -3
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-file-bar.vue +0 -31
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.d.vue.ts +0 -24
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.vue +0 -69
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.vue.d.ts +0 -24
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-header.vue +0 -36
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-sidebar.vue +0 -63
- package/dist/runtime/spreadsheet/components/shared/spreadsheet-object-preview-table.vue +0 -67
- package/dist/runtime/spreadsheet/components/shared/spreadsheet-raw-preview-table.vue +0 -41
- package/dist/runtime/spreadsheet/components/shared/spreadsheet-raw-preview-table.vue.d.ts +0 -7
- package/dist/runtime/spreadsheet/components/shared/spreadsheet-summary-stats.d.vue.ts +0 -10
- package/dist/runtime/spreadsheet/components/shared/spreadsheet-summary-stats.vue +0 -25
- package/dist/runtime/spreadsheet/components/shared/spreadsheet-summary-stats.vue.d.ts +0 -10
- package/dist/runtime/spreadsheet/components/shared/spreadsheet-value-preview.vue +0 -201
- package/dist/runtime/spreadsheet/components/steps/matching/spreadsheet-matching-summary.d.vue.ts +0 -11
- package/dist/runtime/spreadsheet/components/steps/matching/spreadsheet-matching-summary.vue +0 -38
- package/dist/runtime/spreadsheet/components/steps/matching/spreadsheet-matching-summary.vue.d.ts +0 -11
- package/dist/runtime/spreadsheet/components/steps/matching/spreadsheet-matching-table.d.vue.ts +0 -45
- package/dist/runtime/spreadsheet/components/steps/matching/spreadsheet-matching-table.vue +0 -219
- package/dist/runtime/spreadsheet/components/steps/matching/spreadsheet-matching-table.vue.d.ts +0 -45
- package/dist/runtime/spreadsheet/components/steps/references/spreadsheet-references-accordion.d.vue.ts +0 -51
- package/dist/runtime/spreadsheet/components/steps/references/spreadsheet-references-accordion.vue +0 -166
- package/dist/runtime/spreadsheet/components/steps/references/spreadsheet-references-accordion.vue.d.ts +0 -51
- package/dist/runtime/spreadsheet/components/steps/references/spreadsheet-references-summary.d.vue.ts +0 -11
- package/dist/runtime/spreadsheet/components/steps/references/spreadsheet-references-summary.vue +0 -26
- package/dist/runtime/spreadsheet/components/steps/references/spreadsheet-references-summary.vue.d.ts +0 -11
- package/dist/runtime/spreadsheet/components/steps/review/spreadsheet-review-inspection.d.vue.ts +0 -41
- package/dist/runtime/spreadsheet/components/steps/review/spreadsheet-review-inspection.vue +0 -392
- package/dist/runtime/spreadsheet/components/steps/review/spreadsheet-review-inspection.vue.d.ts +0 -41
- package/dist/runtime/spreadsheet/components/steps/review/spreadsheet-review-overflow-alert.vue +0 -43
- package/dist/runtime/spreadsheet/components/steps/review/spreadsheet-review-stats.d.vue.ts +0 -15
- package/dist/runtime/spreadsheet/components/steps/review/spreadsheet-review-stats.vue +0 -40
- package/dist/runtime/spreadsheet/components/steps/review/spreadsheet-review-stats.vue.d.ts +0 -15
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-matching-step.d.vue.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-matching-step.vue +0 -137
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-matching-step.vue.d.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-references-step.d.vue.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-references-step.vue +0 -222
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-references-step.vue.d.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-review-step.d.vue.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-review-step.vue +0 -191
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-review-step.vue.d.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-structure-step.d.vue.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-structure-step.vue +0 -62
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-structure-step.vue.d.ts +0 -7
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-upload-step.d.vue.ts +0 -8
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-upload-step.vue +0 -81
- package/dist/runtime/spreadsheet/components/steps/spreadsheet-import-upload-step.vue.d.ts +0 -8
- package/dist/runtime/spreadsheet/components/steps/structure/spreadsheet-structure-preview-table.d.vue.ts +0 -15
- package/dist/runtime/spreadsheet/components/steps/structure/spreadsheet-structure-preview-table.vue +0 -95
- package/dist/runtime/spreadsheet/components/steps/structure/spreadsheet-structure-preview-table.vue.d.ts +0 -15
- package/dist/runtime/spreadsheet/components/steps/structure/spreadsheet-structure-sheet-list.d.vue.ts +0 -15
- package/dist/runtime/spreadsheet/components/steps/structure/spreadsheet-structure-sheet-list.vue +0 -56
- package/dist/runtime/spreadsheet/components/steps/structure/spreadsheet-structure-sheet-list.vue.d.ts +0 -15
- package/dist/runtime/spreadsheet/components/types.d.ts +0 -41
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-column-matching.d.ts +0 -18
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-column-matching.js +0 -62
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-internals.d.ts +0 -629
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-internals.js +0 -68
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-references.d.ts +0 -1
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-references.js +0 -3
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-resolutions.d.ts +0 -40
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-resolutions.js +0 -97
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-row-state.d.ts +0 -24
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-row-state.js +0 -74
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-source.d.ts +0 -27
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-source.js +0 -109
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-view.d.ts +0 -15
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-view.js +0 -109
- package/dist/runtime/spreadsheet/schema/normalize.d.ts +0 -73
- package/dist/runtime/spreadsheet/schema/normalize.js +0 -136
- package/dist/runtime/spreadsheet/types/context.d.ts +0 -9
- package/dist/runtime/spreadsheet/types/import.d.ts +0 -55
- package/dist/runtime/spreadsheet/types/inference.d.ts +0 -83
- package/dist/runtime/spreadsheet/types/normalized.d.ts +0 -50
- package/dist/runtime/spreadsheet/types/normalized.js +0 -0
- package/dist/runtime/spreadsheet/types/pipeline.d.ts +0 -7
- package/dist/runtime/spreadsheet/types/pipeline.js +0 -0
- package/dist/runtime/spreadsheet/types/reference-session.d.ts +0 -43
- package/dist/runtime/spreadsheet/types/reference-session.js +0 -0
- package/dist/runtime/spreadsheet/types/references.d.ts +0 -32
- package/dist/runtime/spreadsheet/types/references.js +0 -0
- package/dist/runtime/spreadsheet/types/resolution.d.ts +0 -43
- package/dist/runtime/spreadsheet/types/resolution.js +0 -0
- package/dist/runtime/spreadsheet/utils/builders/core.d.ts +0 -17
- package/dist/runtime/spreadsheet/utils/builders/core.js +0 -262
- package/dist/runtime/spreadsheet/utils/builders/index.d.ts +0 -1
- package/dist/runtime/spreadsheet/utils/builders/index.js +0 -1
- package/dist/runtime/spreadsheet/utils/context.d.ts +0 -20
- package/dist/runtime/spreadsheet/utils/context.js +0 -25
- package/dist/runtime/spreadsheet/utils/display.d.ts +0 -6
- package/dist/runtime/spreadsheet/utils/display.js +0 -26
- package/dist/runtime/spreadsheet/utils/object.d.ts +0 -9
- package/dist/runtime/spreadsheet/utils/object.js +0 -78
- package/dist/runtime/spreadsheet/utils/references/candidates.d.ts +0 -6
- package/dist/runtime/spreadsheet/utils/references/candidates.js +0 -28
- package/dist/runtime/spreadsheet/utils/references/core.d.ts +0 -3
- package/dist/runtime/spreadsheet/utils/references/core.js +0 -3
- package/dist/runtime/spreadsheet/utils/references/guards.d.ts +0 -4
- package/dist/runtime/spreadsheet/utils/references/guards.js +0 -28
- package/dist/runtime/spreadsheet/utils/references/index.d.ts +0 -1
- package/dist/runtime/spreadsheet/utils/references/index.js +0 -1
- package/dist/runtime/spreadsheet/utils/references/resolutions.d.ts +0 -17
- package/dist/runtime/spreadsheet/utils/references/resolutions.js +0 -172
- package/dist/runtime/spreadsheet/utils/references/shared.d.ts +0 -3
- package/dist/runtime/spreadsheet/utils/references/shared.js +0 -26
- package/dist/runtime/spreadsheet/utils/references/sources.d.ts +0 -9
- package/dist/runtime/spreadsheet/utils/references/sources.js +0 -38
- package/dist/runtime/spreadsheet/utils/rows/core.d.ts +0 -4
- package/dist/runtime/spreadsheet/utils/rows/core.js +0 -4
- package/dist/runtime/spreadsheet/utils/rows/headers.d.ts +0 -2
- package/dist/runtime/spreadsheet/utils/rows/headers.js +0 -9
- package/dist/runtime/spreadsheet/utils/rows/index.d.ts +0 -1
- package/dist/runtime/spreadsheet/utils/rows/index.js +0 -1
- package/dist/runtime/spreadsheet/utils/rows/matching.d.ts +0 -5
- package/dist/runtime/spreadsheet/utils/rows/matching.js +0 -209
- package/dist/runtime/spreadsheet/utils/rows/parsing.d.ts +0 -7
- package/dist/runtime/spreadsheet/utils/rows/parsing.js +0 -209
- package/dist/runtime/spreadsheet/utils/rows/shared.d.ts +0 -17
- package/dist/runtime/spreadsheet/utils/rows/shared.js +0 -309
- package/dist/runtime/spreadsheet/utils/rows/summary.d.ts +0 -2
- package/dist/runtime/spreadsheet/utils/rows/summary.js +0 -10
- package/dist/runtime/spreadsheet/utils/source/core.d.ts +0 -9
- package/dist/runtime/spreadsheet/utils/source/core.js +0 -65
- package/dist/runtime/spreadsheet/utils/source/index.d.ts +0 -1
- package/dist/runtime/spreadsheet/utils/source/index.js +0 -1
- package/dist/runtime/spreadsheet/utils/validation/core.d.ts +0 -16
- package/dist/runtime/spreadsheet/utils/validation/core.js +0 -211
- package/dist/runtime/spreadsheet/utils/validation/index.d.ts +0 -1
- package/dist/runtime/spreadsheet/utils/validation/index.js +0 -1
- /package/dist/runtime/spreadsheet/{components/types.js → types/fields.js} +0 -0
- /package/dist/runtime/spreadsheet/types/{context.js → importer.js} +0 -0
- /package/dist/runtime/spreadsheet/types/{import.js → steps.js} +0 -0
- /package/dist/runtime/spreadsheet/types/{inference.js → values.js} +0 -0
|
@@ -1,26 +1,339 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useQueryClient } from "@tanstack/vue-query";
|
|
2
|
+
import { computed, shallowRef, watch } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
createSpreadsheetIssuesWorkbook,
|
|
5
|
+
detectSpreadsheetKeyFields,
|
|
6
|
+
diffSpreadsheetRow,
|
|
7
|
+
getSpreadsheetPathValue,
|
|
8
|
+
isSpreadsheetQueryDefinition,
|
|
9
|
+
isSpreadsheetRecord,
|
|
10
|
+
parseSpreadsheetRow,
|
|
11
|
+
resolveSpreadsheetExistingAction,
|
|
12
|
+
serializeSpreadsheetRowKey,
|
|
13
|
+
toSpreadsheetText
|
|
14
|
+
} from "../utils/index.js";
|
|
15
|
+
import { useSpreadsheetQueries } from "./use-spreadsheet-queries.js";
|
|
16
|
+
const LEVEL_RANK = { error: 3, info: 1, warning: 2 };
|
|
17
|
+
function mostSevere(issues) {
|
|
18
|
+
const byField = {};
|
|
19
|
+
for (const issue of issues) {
|
|
20
|
+
if (!issue.field || issue.code === "value.skipped") continue;
|
|
21
|
+
const current = byField[issue.field];
|
|
22
|
+
if (!current || LEVEL_RANK[issue.level] > LEVEL_RANK[current.level])
|
|
23
|
+
byField[issue.field] = issue;
|
|
24
|
+
}
|
|
25
|
+
return byField;
|
|
26
|
+
}
|
|
27
|
+
function isRecordList(value) {
|
|
28
|
+
return Array.isArray(value);
|
|
29
|
+
}
|
|
3
30
|
export function useSpreadsheetRows(params) {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
params.
|
|
15
|
-
params.
|
|
16
|
-
params.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
const queryClient = useQueryClient();
|
|
32
|
+
const manualDiscards = shallowRef(/* @__PURE__ */ new Set());
|
|
33
|
+
const rejections = shallowRef(/* @__PURE__ */ new Map());
|
|
34
|
+
watch([params.layout.sheet, () => params.layout.selection.value.headerRow], () => {
|
|
35
|
+
manualDiscards.value = /* @__PURE__ */ new Set();
|
|
36
|
+
rejections.value = /* @__PURE__ */ new Map();
|
|
37
|
+
});
|
|
38
|
+
const parseContext = computed(() => {
|
|
39
|
+
void params.options.options.value;
|
|
40
|
+
return {
|
|
41
|
+
answers: params.answers.answers.value,
|
|
42
|
+
columns: params.columns.matches.value,
|
|
43
|
+
ctx: params.context.ctx.value,
|
|
44
|
+
fields: params.fields.fields.value,
|
|
45
|
+
headers: params.layout.headers.value.map((header) => header.text),
|
|
46
|
+
optionsOf: params.options.optionsOf,
|
|
47
|
+
t: params.t
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
let cacheContext = null;
|
|
51
|
+
const cache = /* @__PURE__ */ new Map();
|
|
52
|
+
const parsed = computed(() => {
|
|
53
|
+
const context = parseContext.value;
|
|
54
|
+
if (cacheContext !== context) {
|
|
55
|
+
cache.clear();
|
|
56
|
+
cacheContext = context;
|
|
57
|
+
}
|
|
58
|
+
const raws = params.layout.dataRaws.value;
|
|
59
|
+
return params.layout.dataRows.value.map((cells, index) => {
|
|
60
|
+
const edits = params.edits.edits.value.get(index);
|
|
61
|
+
const cached = cache.get(index);
|
|
62
|
+
if (cached && cached.cells === cells && cached.edits === edits) return cached.result;
|
|
63
|
+
const result = parseSpreadsheetRow({ cells, context, edits, index, raws: raws[index] });
|
|
64
|
+
cache.set(index, { cells, edits, result });
|
|
65
|
+
return result;
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
const validationCache = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
const validated = computed(() => {
|
|
70
|
+
const validate = params.schema.value.validate;
|
|
71
|
+
const ctx = params.context.ctx.value;
|
|
72
|
+
return parsed.value.map((row) => {
|
|
73
|
+
if (!validate) return row.issues;
|
|
74
|
+
const cached = validationCache.get(row);
|
|
75
|
+
if (cached) return cached;
|
|
76
|
+
const extra = validate({
|
|
77
|
+
ctx,
|
|
78
|
+
issue: (field, message, options) => ({
|
|
79
|
+
code: options?.code ?? "validate",
|
|
80
|
+
field,
|
|
81
|
+
level: options?.level ?? "error",
|
|
82
|
+
message
|
|
83
|
+
}),
|
|
84
|
+
row: row.data
|
|
85
|
+
}).flatMap((entry) => entry ? [{ ...entry, field: entry.field }] : []);
|
|
86
|
+
const withExtra = extra.length ? [...row.issues, ...extra] : row.issues;
|
|
87
|
+
validationCache.set(row, withExtra);
|
|
88
|
+
return withExtra;
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
const keyOf = computed(() => params.schema.value.rows?.key);
|
|
92
|
+
const keys = computed(() => {
|
|
93
|
+
const key = keyOf.value;
|
|
94
|
+
if (!key) return parsed.value.map(() => null);
|
|
95
|
+
return parsed.value.map((row) => {
|
|
96
|
+
try {
|
|
97
|
+
const value = key(row.data);
|
|
98
|
+
const serialized = serializeSpreadsheetRowKey(value);
|
|
99
|
+
return serialized === null ? null : { serialized, value };
|
|
100
|
+
} catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
const keyFields = computed(() => {
|
|
106
|
+
const key = keyOf.value;
|
|
107
|
+
const sample = parsed.value.find((row) => Object.keys(row.data).length)?.data;
|
|
108
|
+
return key && sample ? detectSpreadsheetKeyFields(key, sample) : [];
|
|
109
|
+
});
|
|
110
|
+
const duplicates = computed(() => {
|
|
111
|
+
const groups = /* @__PURE__ */ new Map();
|
|
112
|
+
for (const [index, key] of keys.value.entries()) {
|
|
113
|
+
if (!key) continue;
|
|
114
|
+
const group = groups.get(key.serialized);
|
|
115
|
+
if (group) group.push(index);
|
|
116
|
+
else groups.set(key.serialized, [index]);
|
|
117
|
+
}
|
|
118
|
+
const policy = params.schema.value.rows?.duplicates ?? "error";
|
|
119
|
+
const blocked = /* @__PURE__ */ new Map();
|
|
120
|
+
const discarded2 = /* @__PURE__ */ new Set();
|
|
121
|
+
for (const group of groups.values()) {
|
|
122
|
+
if (group.length < 2) continue;
|
|
123
|
+
if (policy === "error")
|
|
124
|
+
for (const index of group)
|
|
125
|
+
blocked.set(index, group.find((other) => other !== index) ?? index);
|
|
126
|
+
else {
|
|
127
|
+
const kept = policy === "keep-first" ? group[0] : group.at(-1);
|
|
128
|
+
for (const index of group) if (index !== kept) discarded2.add(index);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return { blocked, discarded: discarded2 };
|
|
132
|
+
});
|
|
133
|
+
const lookupKeys = computed(() => {
|
|
134
|
+
const seen = /* @__PURE__ */ new Map();
|
|
135
|
+
for (const key of keys.value)
|
|
136
|
+
if (key && !seen.has(key.serialized)) seen.set(key.serialized, key.value);
|
|
137
|
+
return seen;
|
|
138
|
+
});
|
|
139
|
+
const existingQuery = computed(() => {
|
|
140
|
+
const existing = params.schema.value.rows?.existing;
|
|
141
|
+
if (!existing || !lookupKeys.value.size || !params.context.ready.value) return [];
|
|
142
|
+
const values = [...lookupKeys.value.values()];
|
|
143
|
+
const ctx = params.context.ctx.value;
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
queryFn: async () => {
|
|
147
|
+
const result = existing.lookup({ ctx, keys: values });
|
|
148
|
+
return isSpreadsheetQueryDefinition(result) ? queryClient.fetchQuery(result) : await result;
|
|
149
|
+
},
|
|
150
|
+
queryKey: ["spreadsheet", params.schema.value.key, "existing", ...lookupKeys.value.keys()]
|
|
151
|
+
}
|
|
152
|
+
];
|
|
153
|
+
});
|
|
154
|
+
const existingResults = useSpreadsheetQueries(() => existingQuery.value);
|
|
155
|
+
const existingLoading = computed(() => existingResults.value.some((result) => result.pending));
|
|
156
|
+
const existingByKey = computed(() => {
|
|
157
|
+
const map = /* @__PURE__ */ new Map();
|
|
158
|
+
const records = existingResults.value[0]?.data;
|
|
159
|
+
const definition = params.schema.value.rows?.existing;
|
|
160
|
+
const key = keyOf.value;
|
|
161
|
+
if (!isRecordList(records) || !definition || !key) return map;
|
|
162
|
+
for (const record of records) {
|
|
163
|
+
try {
|
|
164
|
+
const value = definition.keyOf ? definition.keyOf(record) : isSpreadsheetRecord(record) ? key(record) : null;
|
|
165
|
+
const serialized = serializeSpreadsheetRowKey(value);
|
|
166
|
+
if (serialized !== null) map.set(serialized, record);
|
|
167
|
+
} catch {
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return map;
|
|
171
|
+
});
|
|
172
|
+
const maxRows = computed(() => params.schema.value.file?.maxRows ?? Infinity);
|
|
173
|
+
const fieldPaths = computed(() => params.fields.fields.value.map((field) => field.path));
|
|
174
|
+
const rows = computed(() => {
|
|
175
|
+
const t = params.t;
|
|
176
|
+
const numbers = params.layout.dataRowNumbers.value;
|
|
177
|
+
const definition = params.schema.value.rows?.existing;
|
|
178
|
+
const ctx = params.context.ctx.value;
|
|
179
|
+
return parsed.value.map((row, index) => {
|
|
180
|
+
const rowIssues = [...validated.value[index] ?? row.issues];
|
|
181
|
+
const key = keys.value[index];
|
|
182
|
+
const duplicateOf = duplicates.value.blocked.get(index);
|
|
183
|
+
if (duplicateOf !== void 0) {
|
|
184
|
+
const message = t("spreadsheet.issues.duplicate", {
|
|
185
|
+
row: numbers[duplicateOf] ?? duplicateOf + 1
|
|
186
|
+
});
|
|
187
|
+
const targets = keyFields.value.length ? keyFields.value : [null];
|
|
188
|
+
for (const field of targets)
|
|
189
|
+
rowIssues.push({ code: "row.duplicate", field, level: "error", message });
|
|
190
|
+
}
|
|
191
|
+
const existing = key ? existingByKey.value.get(key.serialized) : void 0;
|
|
192
|
+
let mode = "create";
|
|
193
|
+
let changed = [];
|
|
194
|
+
if (existing !== void 0 && definition) {
|
|
195
|
+
const action = resolveSpreadsheetExistingAction({
|
|
196
|
+
action: definition.action,
|
|
197
|
+
ctx,
|
|
198
|
+
existing,
|
|
199
|
+
row: row.data
|
|
200
|
+
});
|
|
201
|
+
mode = action === "skip" ? "skip" : "update";
|
|
202
|
+
if (action === "error")
|
|
203
|
+
rowIssues.push({
|
|
204
|
+
code: "row.exists",
|
|
205
|
+
field: keyFields.value[0] ?? null,
|
|
206
|
+
level: "error",
|
|
207
|
+
message: t("spreadsheet.issues.exists")
|
|
208
|
+
});
|
|
209
|
+
else changed = diffSpreadsheetRow({ data: row.data, existing, paths: fieldPaths.value });
|
|
210
|
+
}
|
|
211
|
+
rowIssues.push(...rejections.value.get(index) ?? []);
|
|
212
|
+
const discardReason = index >= maxRows.value ? "limit" : row.skipped ? "value" : duplicates.value.discarded.has(index) ? "duplicate" : mode === "skip" ? "existing" : manualDiscards.value.has(index) ? "manual" : null;
|
|
213
|
+
const errors = rowIssues.filter((issue) => issue.level === "error");
|
|
214
|
+
const warnings = rowIssues.filter((issue) => issue.level === "warning");
|
|
215
|
+
return {
|
|
216
|
+
changed,
|
|
217
|
+
data: row.data,
|
|
218
|
+
discardReason,
|
|
219
|
+
edited: Object.keys(params.edits.edits.value.get(index) ?? {}),
|
|
220
|
+
errors,
|
|
221
|
+
existing,
|
|
222
|
+
fieldIssues: mostSevere(rowIssues),
|
|
223
|
+
importable: !discardReason && !errors.length,
|
|
224
|
+
index,
|
|
225
|
+
issues: rowIssues,
|
|
226
|
+
mode,
|
|
227
|
+
rowNumber: numbers[index] ?? index + 1,
|
|
228
|
+
status: discardReason ? "discarded" : errors.length ? "blocking" : warnings.length ? "warning" : "valid",
|
|
229
|
+
warnings
|
|
230
|
+
};
|
|
231
|
+
});
|
|
21
232
|
});
|
|
233
|
+
const valid = computed(() => rows.value.filter((row) => !row.discardReason && !row.errors.length));
|
|
234
|
+
const invalid = computed(
|
|
235
|
+
() => rows.value.filter((row) => !row.discardReason && row.errors.length > 0)
|
|
236
|
+
);
|
|
237
|
+
const discarded = computed(() => rows.value.filter((row) => row.discardReason));
|
|
238
|
+
const importable = computed(() => rows.value.filter((row) => row.importable));
|
|
239
|
+
const byMode = computed(() => ({
|
|
240
|
+
create: importable.value.filter((row) => row.mode === "create").length,
|
|
241
|
+
skip: rows.value.filter((row) => row.discardReason === "existing").length,
|
|
242
|
+
update: importable.value.filter((row) => row.mode === "update").length
|
|
243
|
+
}));
|
|
244
|
+
function cell(index, field) {
|
|
245
|
+
const row = rows.value[index];
|
|
246
|
+
const result = parsed.value[index]?.cells.get(field);
|
|
247
|
+
const edits = params.edits.edits.value.get(index);
|
|
248
|
+
const stored = row?.changed.includes(field) ? toSpreadsheetText(
|
|
249
|
+
getSpreadsheetPathValue(isSpreadsheetRecord(row.existing) ? row.existing : {}, field)
|
|
250
|
+
) : null;
|
|
251
|
+
return {
|
|
252
|
+
choices: result?.choices ?? [],
|
|
253
|
+
created: result?.created ?? false,
|
|
254
|
+
defaulted: result?.defaulted ?? false,
|
|
255
|
+
display: result?.display ?? "",
|
|
256
|
+
edited: Boolean(edits && field in edits),
|
|
257
|
+
issue: row?.fieldIssues[field] ?? null,
|
|
258
|
+
original: result?.original ?? "",
|
|
259
|
+
stored,
|
|
260
|
+
text: result?.text ?? ""
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function distinct(field) {
|
|
264
|
+
const values = /* @__PURE__ */ new Set();
|
|
265
|
+
for (const row of rows.value) {
|
|
266
|
+
if (row.discardReason) continue;
|
|
267
|
+
const display = parsed.value[row.index]?.cells.get(field)?.display;
|
|
268
|
+
if (display) values.add(display);
|
|
269
|
+
}
|
|
270
|
+
return [...values];
|
|
271
|
+
}
|
|
272
|
+
function issues(field) {
|
|
273
|
+
return rows.value.flatMap(
|
|
274
|
+
(row) => row.discardReason ? [] : row.issues.filter((issue) => field ? issue.field === field : true).map((issue) => ({ issue, row: row.index }))
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
function edit(index, field, text) {
|
|
278
|
+
params.edits.set(index, field, text);
|
|
279
|
+
if (rejections.value.has(index)) {
|
|
280
|
+
const next = new Map(rejections.value);
|
|
281
|
+
next.delete(index);
|
|
282
|
+
rejections.value = next;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function discard(indexes) {
|
|
286
|
+
manualDiscards.value = /* @__PURE__ */ new Set([...manualDiscards.value, ...indexes]);
|
|
287
|
+
}
|
|
288
|
+
function restore(indexes) {
|
|
289
|
+
const next = new Set(manualDiscards.value);
|
|
290
|
+
for (const index of indexes) next.delete(index);
|
|
291
|
+
manualDiscards.value = next;
|
|
292
|
+
}
|
|
293
|
+
function setRejections(next) {
|
|
294
|
+
rejections.value = next;
|
|
295
|
+
}
|
|
296
|
+
function exportInvalid(issuesHeader) {
|
|
297
|
+
const labels = new Map(params.fields.fields.value.map((field) => [field.path, field.label]));
|
|
298
|
+
const matches = params.columns.matches.value;
|
|
299
|
+
return createSpreadsheetIssuesWorkbook({
|
|
300
|
+
headers: params.layout.headers.value.map((header) => header.text),
|
|
301
|
+
issuesHeader,
|
|
302
|
+
labels,
|
|
303
|
+
rows: invalid.value.map((row) => {
|
|
304
|
+
const cells = [...params.layout.dataRows.value[row.index] ?? []];
|
|
305
|
+
for (const [field, text] of Object.entries(params.edits.edits.value.get(row.index) ?? {})) {
|
|
306
|
+
const column = matches.get(field);
|
|
307
|
+
if (column !== void 0) cells[column] = text;
|
|
308
|
+
}
|
|
309
|
+
return { cells, issues: row.issues };
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function reset() {
|
|
314
|
+
manualDiscards.value = /* @__PURE__ */ new Set();
|
|
315
|
+
rejections.value = /* @__PURE__ */ new Map();
|
|
316
|
+
}
|
|
317
|
+
const loading = computed(() => existingLoading.value);
|
|
22
318
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
319
|
+
byMode,
|
|
320
|
+
cell,
|
|
321
|
+
discard,
|
|
322
|
+
discarded,
|
|
323
|
+
distinct,
|
|
324
|
+
edit,
|
|
325
|
+
exportInvalid,
|
|
326
|
+
importable,
|
|
327
|
+
invalid,
|
|
328
|
+
issues,
|
|
329
|
+
keyFields,
|
|
330
|
+
loading,
|
|
331
|
+
parsed,
|
|
332
|
+
rejections,
|
|
333
|
+
reset,
|
|
334
|
+
restore,
|
|
335
|
+
rows,
|
|
336
|
+
setRejections,
|
|
337
|
+
valid
|
|
25
338
|
};
|
|
26
339
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SpreadsheetStep, SpreadsheetStepContext, SpreadsheetSteps } from '../types/index.js';
|
|
2
|
+
type SpreadsheetStepPreset = Omit<SpreadsheetStep, 'key' | 'builtIn'> & {
|
|
3
|
+
key?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* The built-in steps. Each knows when it is ready and what blocks it; override any of `label`,
|
|
7
|
+
* `hint`, `show`, `ready`, `needed`, and `blockers`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const spreadsheetSteps: {
|
|
10
|
+
columns: (options?: SpreadsheetStepPreset) => SpreadsheetStep;
|
|
11
|
+
file: (options?: SpreadsheetStepPreset) => SpreadsheetStep;
|
|
12
|
+
review: (options?: SpreadsheetStepPreset) => SpreadsheetStep;
|
|
13
|
+
submit: (options?: SpreadsheetStepPreset) => SpreadsheetStep;
|
|
14
|
+
values: (options?: SpreadsheetStepPreset) => SpreadsheetStep;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A wizard over an importer: the steps you list, in order, built-in or your own. Steps with
|
|
18
|
+
* `show: 'when-needed'` are skipped when they have nothing to do.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const steps = useSpreadsheetSteps(importer, [
|
|
23
|
+
* { key: 'center', label: 'Centre', ready: () => Boolean(centerId.value) },
|
|
24
|
+
* spreadsheetSteps.file(),
|
|
25
|
+
* spreadsheetSteps.columns({ show: 'when-needed' }),
|
|
26
|
+
* spreadsheetSteps.values({ show: 'when-needed' }),
|
|
27
|
+
* spreadsheetSteps.review(),
|
|
28
|
+
* spreadsheetSteps.submit(),
|
|
29
|
+
* ])
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function useSpreadsheetSteps(importer: SpreadsheetStepContext, steps?: readonly SpreadsheetStep[]): SpreadsheetSteps;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { computed, shallowRef, watch } from "vue";
|
|
2
|
+
function preset(builtIn, defaults) {
|
|
3
|
+
return (options = {}) => ({
|
|
4
|
+
...defaults,
|
|
5
|
+
...options,
|
|
6
|
+
builtIn,
|
|
7
|
+
key: options.key ?? builtIn
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export const spreadsheetSteps = {
|
|
11
|
+
columns: preset("columns", {
|
|
12
|
+
blockers: (importer) => importer.columns.missing.length,
|
|
13
|
+
needed: (importer) => importer.columns.missing.length > 0,
|
|
14
|
+
ready: (importer) => !importer.columns.missing.length
|
|
15
|
+
}),
|
|
16
|
+
file: preset("file", {
|
|
17
|
+
ready: (importer) => importer.file.loaded && !importer.file.reading && !importer.readiness.loading
|
|
18
|
+
}),
|
|
19
|
+
review: preset("review", {
|
|
20
|
+
ready: (importer) => importer.readiness.importable > 0 && !importer.readiness.loading
|
|
21
|
+
}),
|
|
22
|
+
submit: preset("submit", {
|
|
23
|
+
ready: (importer) => importer.submit.status === "done"
|
|
24
|
+
}),
|
|
25
|
+
values: preset("values", {
|
|
26
|
+
blockers: (importer) => importer.values.open.length,
|
|
27
|
+
needed: (importer) => importer.values.questions.length > 0,
|
|
28
|
+
ready: (importer) => !importer.values.open.length
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
export function useSpreadsheetSteps(importer, steps = [
|
|
32
|
+
spreadsheetSteps.file(),
|
|
33
|
+
spreadsheetSteps.columns({ show: "when-needed" }),
|
|
34
|
+
spreadsheetSteps.values({ show: "when-needed" }),
|
|
35
|
+
spreadsheetSteps.review(),
|
|
36
|
+
spreadsheetSteps.submit()
|
|
37
|
+
]) {
|
|
38
|
+
const current = shallowRef(steps[0]?.key ?? "");
|
|
39
|
+
const visited = shallowRef(/* @__PURE__ */ new Set([current.value]));
|
|
40
|
+
watch(current, (key) => {
|
|
41
|
+
if (!visited.value.has(key)) visited.value = /* @__PURE__ */ new Set([...visited.value, key]);
|
|
42
|
+
});
|
|
43
|
+
const list = computed(() => {
|
|
44
|
+
const currentIndex = Math.max(
|
|
45
|
+
steps.findIndex((step2) => step2.key === current.value),
|
|
46
|
+
0
|
|
47
|
+
);
|
|
48
|
+
return steps.map((step2, index2) => {
|
|
49
|
+
const skipped = step2.show === "when-needed" && !visited.value.has(step2.key) && !(step2.needed?.(importer) ?? true);
|
|
50
|
+
return {
|
|
51
|
+
blockers: step2.blockers?.(importer) ?? 0,
|
|
52
|
+
builtIn: step2.builtIn ?? null,
|
|
53
|
+
hint: step2.hint,
|
|
54
|
+
key: step2.key,
|
|
55
|
+
label: step2.label,
|
|
56
|
+
position: index2 + 1,
|
|
57
|
+
ready: step2.ready?.(importer) ?? true,
|
|
58
|
+
skipped,
|
|
59
|
+
state: index2 === currentIndex ? "current" : index2 < currentIndex ? skipped ? "skipped" : "done" : skipped ? "skipped" : "upcoming"
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const index = computed(
|
|
64
|
+
() => Math.max(
|
|
65
|
+
list.value.findIndex((step2) => step2.key === current.value),
|
|
66
|
+
0
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
const step = computed(() => list.value[index.value] ?? null);
|
|
70
|
+
function move(direction) {
|
|
71
|
+
for (let next2 = index.value + direction; next2 >= 0 && next2 < list.value.length; next2 += direction) {
|
|
72
|
+
const candidate = list.value[next2];
|
|
73
|
+
if (candidate && !candidate.skipped) {
|
|
74
|
+
current.value = candidate.key;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function next() {
|
|
80
|
+
if (step.value?.ready) move(1);
|
|
81
|
+
}
|
|
82
|
+
function back() {
|
|
83
|
+
move(-1);
|
|
84
|
+
}
|
|
85
|
+
function goTo(key) {
|
|
86
|
+
const target = list.value.findIndex((entry) => entry.key === key);
|
|
87
|
+
if (target >= 0 && target <= index.value) current.value = key;
|
|
88
|
+
}
|
|
89
|
+
function reset() {
|
|
90
|
+
current.value = steps[0]?.key ?? "";
|
|
91
|
+
visited.value = /* @__PURE__ */ new Set([current.value]);
|
|
92
|
+
}
|
|
93
|
+
watch(
|
|
94
|
+
() => importer.file.loaded,
|
|
95
|
+
(loaded) => {
|
|
96
|
+
if (loaded) return;
|
|
97
|
+
const fileStep = steps.findIndex((entry) => entry.builtIn === "file");
|
|
98
|
+
if (fileStep >= 0 && index.value > fileStep)
|
|
99
|
+
current.value = steps[fileStep]?.key ?? current.value;
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
return {
|
|
103
|
+
back,
|
|
104
|
+
get canBack() {
|
|
105
|
+
return list.value.slice(0, index.value).some((entry) => !entry.skipped);
|
|
106
|
+
},
|
|
107
|
+
get canNext() {
|
|
108
|
+
return Boolean(step.value?.ready) && index.value < list.value.length - 1;
|
|
109
|
+
},
|
|
110
|
+
get current() {
|
|
111
|
+
return current.value;
|
|
112
|
+
},
|
|
113
|
+
goTo,
|
|
114
|
+
get isLast() {
|
|
115
|
+
return index.value === list.value.length - 1;
|
|
116
|
+
},
|
|
117
|
+
get list() {
|
|
118
|
+
return list.value;
|
|
119
|
+
},
|
|
120
|
+
next,
|
|
121
|
+
reset,
|
|
122
|
+
get step() {
|
|
123
|
+
return step.value;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { UiToolsTranslator } from '#ui-tools/i18n';
|
|
3
|
+
import type { SpreadsheetRuntimeSchema, SpreadsheetSubmitParams, SpreadsheetSubmitRejection, SpreadsheetSubmitResult, SpreadsheetSubmitStatus } from '../types/index.js';
|
|
4
|
+
import type { useSpreadsheetContext } from './use-spreadsheet-context.js';
|
|
5
|
+
import type { useSpreadsheetFields } from './use-spreadsheet-fields.js';
|
|
6
|
+
import type { useSpreadsheetRows } from './use-spreadsheet-rows.js';
|
|
7
|
+
import type { useSpreadsheetValues } from './use-spreadsheet-values.js';
|
|
8
|
+
export interface UseSpreadsheetSubmitParams {
|
|
9
|
+
schema: ComputedRef<SpreadsheetRuntimeSchema>;
|
|
10
|
+
context: ReturnType<typeof useSpreadsheetContext>;
|
|
11
|
+
fields: ReturnType<typeof useSpreadsheetFields>;
|
|
12
|
+
rows: ReturnType<typeof useSpreadsheetRows>;
|
|
13
|
+
values: ReturnType<typeof useSpreadsheetValues>;
|
|
14
|
+
onSubmit?: (params: SpreadsheetSubmitParams<unknown, unknown, unknown>) => void | SpreadsheetSubmitResult | Promise<void | SpreadsheetSubmitResult>;
|
|
15
|
+
batchSize?: number;
|
|
16
|
+
t: UiToolsTranslator;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The import itself: creates the new values, builds the payloads with `output`, sends them in
|
|
20
|
+
* batches, and sends rows the server refused back to review.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useSpreadsheetSubmit(params: UseSpreadsheetSubmitParams): {
|
|
23
|
+
error: import("vue").ShallowRef<unknown, unknown>;
|
|
24
|
+
imported: import("vue").ShallowRef<number, number>;
|
|
25
|
+
progress: import("vue").ShallowRef<{
|
|
26
|
+
done: number;
|
|
27
|
+
total: number;
|
|
28
|
+
}, {
|
|
29
|
+
done: number;
|
|
30
|
+
total: number;
|
|
31
|
+
}>;
|
|
32
|
+
rejected: import("vue").ShallowRef<readonly SpreadsheetSubmitRejection[], readonly SpreadsheetSubmitRejection[]>;
|
|
33
|
+
reset: () => void;
|
|
34
|
+
retryRejected: () => Promise<void>;
|
|
35
|
+
run: () => Promise<void>;
|
|
36
|
+
status: import("vue").ShallowRef<SpreadsheetSubmitStatus, SpreadsheetSubmitStatus>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { shallowRef } from "vue";
|
|
2
|
+
import {
|
|
3
|
+
getSpreadsheetPathValue,
|
|
4
|
+
normalizeSpreadsheetText,
|
|
5
|
+
setSpreadsheetPathValue
|
|
6
|
+
} from "../utils/index.js";
|
|
7
|
+
function cloneRecord(record) {
|
|
8
|
+
return structuredClone(record);
|
|
9
|
+
}
|
|
10
|
+
export function useSpreadsheetSubmit(params) {
|
|
11
|
+
const status = shallowRef("idle");
|
|
12
|
+
const progress = shallowRef({ done: 0, total: 0 });
|
|
13
|
+
const rejected = shallowRef([]);
|
|
14
|
+
const imported = shallowRef(0);
|
|
15
|
+
const error = shallowRef(null);
|
|
16
|
+
let controller = null;
|
|
17
|
+
async function createValues() {
|
|
18
|
+
const created = /* @__PURE__ */ new Map();
|
|
19
|
+
const ctx = params.context.ctx.value;
|
|
20
|
+
for (const question of params.values.questions.value) {
|
|
21
|
+
if (question.answer?.action !== "create") continue;
|
|
22
|
+
const create = params.fields.byPath.value.get(question.field)?.select?.create;
|
|
23
|
+
if (!create) continue;
|
|
24
|
+
const key = normalizeSpreadsheetText(question.value);
|
|
25
|
+
const byKey = created.get(question.field) ?? /* @__PURE__ */ new Map();
|
|
26
|
+
if (byKey.has(key)) continue;
|
|
27
|
+
const option = await create.handler({ ctx, label: question.value });
|
|
28
|
+
const value = typeof option === "object" && option !== null && "value" in option ? option.value : option;
|
|
29
|
+
byKey.set(key, value);
|
|
30
|
+
created.set(question.field, byKey);
|
|
31
|
+
}
|
|
32
|
+
return created;
|
|
33
|
+
}
|
|
34
|
+
function withCreatedValues(data, created) {
|
|
35
|
+
if (!created.size) return data;
|
|
36
|
+
const next = cloneRecord(data);
|
|
37
|
+
for (const [field, byKey] of created) {
|
|
38
|
+
const replace = (item) => byKey.get(normalizeSpreadsheetText(item)) ?? item;
|
|
39
|
+
const value = getSpreadsheetPathValue(next, field);
|
|
40
|
+
setSpreadsheetPathValue(
|
|
41
|
+
next,
|
|
42
|
+
field,
|
|
43
|
+
Array.isArray(value) ? value.map(replace) : replace(value)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return next;
|
|
47
|
+
}
|
|
48
|
+
async function send(only) {
|
|
49
|
+
if (status.value === "running") return;
|
|
50
|
+
const selected = params.rows.importable.value.filter((row) => !only || only.has(row.index));
|
|
51
|
+
status.value = "running";
|
|
52
|
+
error.value = null;
|
|
53
|
+
rejected.value = [];
|
|
54
|
+
imported.value = 0;
|
|
55
|
+
progress.value = { done: 0, total: selected.length };
|
|
56
|
+
const current = new AbortController();
|
|
57
|
+
controller = current;
|
|
58
|
+
const { signal } = current;
|
|
59
|
+
const ctx = params.context.ctx.value;
|
|
60
|
+
const output = params.schema.value.output;
|
|
61
|
+
try {
|
|
62
|
+
const created = await createValues();
|
|
63
|
+
if (signal.aborted) return;
|
|
64
|
+
const submitRows = [];
|
|
65
|
+
for (const row of selected) {
|
|
66
|
+
const mode = row.mode === "update" ? "update" : "create";
|
|
67
|
+
const data = withCreatedValues(row.data, created);
|
|
68
|
+
const payload = output ? await output({ ctx, existing: row.existing, mode, row: data }) : data;
|
|
69
|
+
submitRows.push({ existing: row.existing, index: row.index, mode, payload });
|
|
70
|
+
}
|
|
71
|
+
if (signal.aborted) return;
|
|
72
|
+
const size = params.batchSize && params.batchSize > 0 ? params.batchSize : Math.max(submitRows.length, 1);
|
|
73
|
+
const batches = [];
|
|
74
|
+
for (let start = 0; start < submitRows.length; start += size)
|
|
75
|
+
batches.push(submitRows.slice(start, start + size));
|
|
76
|
+
const refused = [];
|
|
77
|
+
let done = 0;
|
|
78
|
+
for (const [index, batch] of batches.entries()) {
|
|
79
|
+
const base = done;
|
|
80
|
+
const result = await params.onSubmit?.({
|
|
81
|
+
batch: { count: batches.length, index },
|
|
82
|
+
create: batch.filter((row) => row.mode === "create").map((row) => row.payload),
|
|
83
|
+
ctx,
|
|
84
|
+
reportProgress: (count) => {
|
|
85
|
+
if (signal.aborted) return;
|
|
86
|
+
progress.value = { done: base + Math.min(count, batch.length), total: selected.length };
|
|
87
|
+
},
|
|
88
|
+
rows: batch,
|
|
89
|
+
signal,
|
|
90
|
+
update: batch.filter((row) => row.mode === "update").map((row) => row.payload)
|
|
91
|
+
});
|
|
92
|
+
if (signal.aborted) return;
|
|
93
|
+
refused.push(...result?.rejected ?? []);
|
|
94
|
+
done += batch.length;
|
|
95
|
+
progress.value = { done, total: selected.length };
|
|
96
|
+
}
|
|
97
|
+
rejected.value = refused;
|
|
98
|
+
imported.value = selected.length - new Set(refused.map((entry) => entry.index)).size;
|
|
99
|
+
const issues = /* @__PURE__ */ new Map();
|
|
100
|
+
for (const entry of refused) {
|
|
101
|
+
const list = issues.get(entry.index) ?? [];
|
|
102
|
+
list.push({
|
|
103
|
+
code: "server",
|
|
104
|
+
field: entry.field ?? null,
|
|
105
|
+
level: "error",
|
|
106
|
+
message: entry.message
|
|
107
|
+
});
|
|
108
|
+
issues.set(entry.index, list);
|
|
109
|
+
}
|
|
110
|
+
params.rows.setRejections(issues);
|
|
111
|
+
status.value = "done";
|
|
112
|
+
} catch (nextError) {
|
|
113
|
+
if (signal.aborted) return;
|
|
114
|
+
error.value = nextError;
|
|
115
|
+
status.value = "error";
|
|
116
|
+
} finally {
|
|
117
|
+
if (controller === current) controller = null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function retryRejected() {
|
|
121
|
+
const indexes = new Set(rejected.value.map((entry) => entry.index));
|
|
122
|
+
if (!indexes.size) return;
|
|
123
|
+
params.rows.setRejections(/* @__PURE__ */ new Map());
|
|
124
|
+
status.value = "idle";
|
|
125
|
+
await send(indexes);
|
|
126
|
+
}
|
|
127
|
+
function reset() {
|
|
128
|
+
controller?.abort();
|
|
129
|
+
status.value = "idle";
|
|
130
|
+
progress.value = { done: 0, total: 0 };
|
|
131
|
+
rejected.value = [];
|
|
132
|
+
imported.value = 0;
|
|
133
|
+
error.value = null;
|
|
134
|
+
}
|
|
135
|
+
return { error, imported, progress, rejected, reset, retryRejected, run: () => send(), status };
|
|
136
|
+
}
|