@oneflowui/ui 0.4.2 → 0.4.4
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/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
- package/dist/assets/tableWorker-CTsbCPPP.js +1 -0
- package/dist/components/ContextMenu/index.vue.d.ts +2 -1
- package/dist/components/ContextMenu/index.vue.js +7 -0
- package/dist/components/ContextMenu/index.vue2.js +92 -0
- package/dist/components/Dashboard/charts/BarChart.vue.js +7 -0
- package/dist/components/Dashboard/charts/BarChart.vue2.js +43 -0
- package/dist/components/Dashboard/charts/DoughnutChart.vue.js +23 -0
- package/dist/components/Dashboard/charts/DoughnutChart.vue2.js +4 -0
- package/dist/components/Dashboard/charts/NumberCard.vue.js +7 -0
- package/dist/components/Dashboard/charts/NumberCard.vue2.js +41 -0
- package/dist/components/Dashboard/charts/PieChart.vue.js +7 -0
- package/dist/components/Dashboard/charts/PieChart.vue2.js +53 -0
- package/dist/components/Dashboard/charts/TableChart.vue.js +7 -0
- package/dist/components/Dashboard/charts/TableChart.vue2.js +50 -0
- package/dist/components/Dashboard/index.vue.js +7 -0
- package/dist/components/Dashboard/index.vue2.js +104 -0
- package/dist/components/ai/AiMessageBubble.vue.js +7 -0
- package/dist/components/ai/AiMessageBubble.vue2.js +47 -0
- package/dist/components/ai/AiMessageList.vue.js +7 -0
- package/dist/components/ai/AiMessageList.vue2.js +78 -0
- package/dist/components/ai/AiSender.vue.js +7 -0
- package/dist/components/ai/AiSender.vue2.js +86 -0
- package/dist/components/ai/AiStreamingCursor.vue.js +7 -0
- package/dist/components/ai/AiStreamingCursor.vue2.js +16 -0
- package/dist/components/ai/AiThinking.vue.js +7 -0
- package/dist/components/ai/AiThinking.vue2.js +19 -0
- package/dist/components/ai/UserMessageBubble.vue.js +7 -0
- package/dist/components/ai/UserMessageBubble.vue2.js +34 -0
- package/dist/components/auxiliary/ColorPanel.vue.js +7 -0
- package/dist/components/auxiliary/ColorPanel.vue2.js +65 -0
- package/dist/components/auxiliary/FileUpload.vue.js +7 -0
- package/dist/components/auxiliary/FileUpload.vue2.js +90 -0
- package/dist/components/auxiliary/PersonPanel.vue.js +7 -0
- package/dist/components/auxiliary/PersonPanel.vue2.js +66 -0
- package/dist/components/base/Accordion.vue.js +7 -0
- package/dist/components/base/Accordion.vue2.js +78 -0
- package/dist/components/base/AddViewBtn.vue.js +7 -0
- package/dist/components/base/AddViewBtn.vue2.js +25 -0
- package/dist/components/base/Avatar.vue.js +7 -0
- package/dist/components/base/Avatar.vue2.js +72 -0
- package/dist/components/base/Badge.vue.js +7 -0
- package/dist/components/base/Badge.vue2.js +70 -0
- package/dist/components/base/ButtonGroup.vue.js +7 -0
- package/dist/components/base/ButtonGroup.vue2.js +40 -0
- package/dist/components/base/ChainItem.vue.js +7 -0
- package/dist/components/base/ChainItem.vue2.js +68 -0
- package/dist/components/base/DescBlock.vue.js +7 -0
- package/dist/components/base/DescBlock.vue2.js +13 -0
- package/dist/components/base/DropdownMenu.vue.js +7 -0
- package/dist/components/base/DropdownMenu.vue2.js +91 -0
- package/dist/components/base/EmptyState.vue.js +7 -0
- package/dist/components/base/EmptyState.vue2.js +38 -0
- package/dist/components/base/InfoCard.vue.js +7 -0
- package/dist/components/base/InfoCard.vue2.js +167 -0
- package/dist/components/base/MonitorItem.vue.d.ts +1 -1
- package/dist/components/base/MonitorItem.vue.js +7 -0
- package/dist/components/base/MonitorItem.vue2.js +56 -0
- package/dist/components/base/PersonaCard.vue.d.ts +2 -1
- package/dist/components/base/PersonaCard.vue.js +7 -0
- package/dist/components/base/PersonaCard.vue2.js +185 -0
- package/dist/components/base/ProgressBar.vue.js +7 -0
- package/dist/components/base/ProgressBar.vue2.js +49 -0
- package/dist/components/base/RangeSlider.vue.js +7 -0
- package/dist/components/base/RangeSlider.vue2.js +35 -0
- package/dist/components/base/RefTag.vue.d.ts +2 -2
- package/dist/components/base/RefTag.vue.js +7 -0
- package/dist/components/base/RefTag.vue2.js +52 -0
- package/dist/components/base/SearchHighlight.vue.d.ts +6 -0
- package/dist/components/base/SearchHighlight.vue.js +7 -0
- package/dist/components/base/SearchHighlight.vue2.js +21 -0
- package/dist/components/base/SectionBlock.vue.js +7 -0
- package/dist/components/base/SectionBlock.vue2.js +115 -0
- package/dist/components/base/SelectBadge.vue.js +7 -0
- package/dist/components/base/SelectBadge.vue2.js +81 -0
- package/dist/components/base/StatisticCard.vue.js +7 -0
- package/dist/components/base/StatisticCard.vue2.js +57 -0
- package/dist/components/base/StatusIndicator.vue.js +7 -0
- package/dist/components/base/StatusIndicator.vue2.js +54 -0
- package/dist/components/base/StatusSummary.vue.js +7 -0
- package/dist/components/base/StatusSummary.vue2.js +64 -0
- package/dist/components/base/Stepper.vue.js +7 -0
- package/dist/components/base/Stepper.vue2.js +70 -0
- package/dist/components/base/Switch.vue.js +7 -0
- package/dist/components/base/Switch.vue2.js +43 -0
- package/dist/components/base/ToolbarBtn.vue.d.ts +2 -1
- package/dist/components/base/ToolbarBtn.vue.js +7 -0
- package/dist/components/base/ToolbarBtn.vue2.js +30 -0
- package/dist/components/base/ViewModeGroup.vue.d.ts +2 -1
- package/dist/components/base/ViewModeGroup.vue.js +7 -0
- package/dist/components/base/ViewModeGroup.vue2.js +32 -0
- package/dist/components/base/ViewSwitcher.vue.d.ts +2 -1
- package/dist/components/base/ViewSwitcher.vue.js +7 -0
- package/dist/components/base/ViewSwitcher.vue2.js +73 -0
- package/dist/components/base/ViewTab.vue.js +7 -0
- package/dist/components/base/ViewTab.vue2.js +42 -0
- package/dist/components/base/index.d.ts +1 -0
- package/dist/components/breadcrumb/Breadcrumb.vue.js +7 -0
- package/dist/components/breadcrumb/Breadcrumb.vue2.js +52 -0
- package/dist/components/breadcrumb/BreadcrumbItem.vue.js +7 -0
- package/dist/components/breadcrumb/BreadcrumbItem.vue2.js +35 -0
- package/dist/components/detail/CommentItem.vue.js +7 -0
- package/dist/components/detail/CommentItem.vue2.js +29 -0
- package/dist/components/detail/DetailLayout.vue.js +7 -0
- package/dist/components/detail/DetailLayout.vue2.js +118 -0
- package/dist/components/detail/PropPanel.vue.js +7 -0
- package/dist/components/detail/PropPanel.vue2.js +51 -0
- package/dist/components/detail/PropRow.vue.js +7 -0
- package/dist/components/detail/PropRow.vue2.js +51 -0
- package/dist/components/editor/BlockQuote.vue.js +7 -0
- package/dist/components/editor/BlockQuote.vue2.js +45 -0
- package/dist/components/editor/CodeBlock.vue.js +7 -0
- package/dist/components/editor/CodeBlock.vue2.js +48 -0
- package/dist/components/editor/ContentBlock.vue.js +7 -0
- package/dist/components/editor/ContentBlock.vue2.js +49 -0
- package/dist/components/editor/RefLink.vue.js +7 -0
- package/dist/components/editor/RefLink.vue2.js +37 -0
- package/dist/components/editor/RichTextEditor.vue.js +7 -0
- package/dist/components/editor/RichTextEditor.vue2.js +132 -0
- package/dist/components/field/FieldAttachment.vue.d.ts +17 -0
- package/dist/components/field/FieldAttachment.vue.js +7 -0
- package/dist/components/field/FieldAttachment.vue2.js +69 -0
- package/dist/components/field/FieldAutoNumber.vue.d.ts +7 -0
- package/dist/components/field/FieldAutoNumber.vue.js +7 -0
- package/dist/components/field/FieldAutoNumber.vue2.js +15 -0
- package/dist/components/field/FieldCheckbox.vue.js +7 -0
- package/dist/{FieldCheckbox-CV3QtQ4Y.js → components/field/FieldCheckbox.vue2.js} +8 -9
- package/dist/components/field/FieldCreator.vue.d.ts +7 -0
- package/dist/components/field/FieldCreator.vue.js +7 -0
- package/dist/components/field/FieldCreator.vue2.js +24 -0
- package/dist/components/field/FieldCurrency.vue.d.ts +17 -0
- package/dist/components/field/FieldCurrency.vue.js +7 -0
- package/dist/components/field/FieldCurrency.vue2.js +42 -0
- package/dist/components/field/FieldDate.vue.js +7 -0
- package/dist/components/field/FieldDate.vue2.js +36 -0
- package/dist/components/field/FieldDatetime.vue.js +7 -0
- package/dist/{FieldDatetime-B52GfWrK.js → components/field/FieldDatetime.vue2.js} +11 -12
- package/dist/components/field/FieldEmail.vue.js +7 -0
- package/dist/{FieldEmail-UREMoue-.js → components/field/FieldEmail.vue2.js} +12 -13
- package/dist/components/field/FieldMarkdownPreview.vue.d.ts +13 -0
- package/dist/components/field/FieldMarkdownPreview.vue.js +7 -0
- package/dist/components/field/FieldMarkdownPreview.vue2.js +37 -0
- package/dist/components/field/FieldMultiSelect.vue.js +7 -0
- package/dist/{FieldMultiSelect-Dlay1Fop.js → components/field/FieldMultiSelect.vue2.js} +32 -33
- package/dist/components/field/FieldNumber.vue.js +7 -0
- package/dist/{FieldNumber-BjhfFhs6.js → components/field/FieldNumber.vue2.js} +8 -9
- package/dist/components/field/FieldPhone.vue.d.ts +17 -0
- package/dist/components/field/FieldPhone.vue.js +7 -0
- package/dist/components/field/FieldPhone.vue2.js +34 -0
- package/dist/components/field/FieldProgress.vue.d.ts +15 -0
- package/dist/components/field/FieldProgress.vue.js +7 -0
- package/dist/components/field/FieldProgress.vue2.js +40 -0
- package/dist/components/field/FieldRating.vue.js +7 -0
- package/dist/components/field/FieldRating.vue2.js +31 -0
- package/dist/components/field/FieldRelation.vue.d.ts +17 -0
- package/dist/components/field/FieldRelation.vue.js +7 -0
- package/dist/components/field/FieldRelation.vue2.js +67 -0
- package/dist/components/field/FieldRichText.vue.d.ts +17 -0
- package/dist/components/field/FieldRichText.vue.js +7 -0
- package/dist/components/field/FieldRichText.vue2.js +65 -0
- package/dist/components/field/FieldSelect.vue.js +7 -0
- package/dist/{FieldSelect-B39Ad8VH.js → components/field/FieldSelect.vue2.js} +44 -44
- package/dist/components/field/FieldText.vue.js +7 -0
- package/dist/{FieldText-Ry7f72Ug.js → components/field/FieldText.vue2.js} +13 -14
- package/dist/components/field/FieldUrl.vue.js +7 -0
- package/dist/components/field/FieldUrl.vue2.js +33 -0
- package/dist/components/form/FormDesigner.vue.js +7 -0
- package/dist/components/form/FormDesigner.vue2.js +255 -0
- package/dist/components/gallery/GalleryCard.vue.js +7 -0
- package/dist/components/gallery/GalleryCard.vue2.js +87 -0
- package/dist/components/gallery/GalleryView.vue.d.ts +6 -2
- package/dist/components/gallery/GalleryView.vue.js +7 -0
- package/dist/components/gallery/GalleryView.vue2.js +58 -0
- package/dist/components/kanban/KanbanBoard.vue.d.ts +5 -1
- package/dist/components/kanban/KanbanBoard.vue.js +7 -0
- package/dist/components/kanban/KanbanBoard.vue2.js +119 -0
- package/dist/components/kanban/KanbanCard.vue.js +7 -0
- package/dist/components/kanban/KanbanCard.vue2.js +56 -0
- package/dist/components/kanban/KanbanColumn.vue.js +7 -0
- package/dist/components/kanban/KanbanColumn.vue2.js +103 -0
- package/dist/components/kanban/QuickAddRow.vue.js +7 -0
- package/dist/components/kanban/QuickAddRow.vue2.js +58 -0
- package/dist/components/layout/AppLayout.vue.js +7 -0
- package/dist/components/layout/AppLayout.vue2.js +82 -0
- package/dist/components/layout/Navbar.vue.js +7 -0
- package/dist/components/layout/Navbar.vue2.js +70 -0
- package/dist/components/layout/Sidebar.vue.js +7 -0
- package/dist/components/layout/Sidebar.vue2.js +88 -0
- package/dist/components/layout/StatusBar.vue.js +7 -0
- package/dist/components/layout/StatusBar.vue2.js +37 -0
- package/dist/components/mermaid/MermaidChart.vue.js +7 -0
- package/dist/components/mermaid/MermaidChart.vue2.js +75 -0
- package/dist/components/overlay/Dialog.vue.js +7 -0
- package/dist/components/overlay/Dialog.vue2.js +89 -0
- package/dist/components/overlay/Drawer.vue.js +7 -0
- package/dist/components/overlay/Drawer.vue2.js +96 -0
- package/dist/components/overlay/Modal.vue.js +7 -0
- package/dist/components/overlay/Modal.vue2.js +99 -0
- package/dist/components/overlay/SidePanel.vue.js +7 -0
- package/dist/components/overlay/SidePanel.vue2.js +121 -0
- package/dist/components/split/SplitPane.vue.js +8 -0
- package/dist/components/split/SplitPane.vue2.js +68 -0
- package/dist/components/table/ColumnHeaderMenu.vue.d.ts +33 -0
- package/dist/components/table/ColumnHeaderMenu.vue.js +7 -0
- package/dist/components/table/ColumnHeaderMenu.vue2.js +153 -0
- package/dist/components/table/DataTable.vue.d.ts +116 -25
- package/dist/components/table/DataTable.vue.js +7 -0
- package/dist/components/table/DataTable.vue2.js +821 -0
- package/dist/components/table/DetailSheet.vue.d.ts +43 -0
- package/dist/components/table/DetailSheet.vue.js +7 -0
- package/dist/components/table/DetailSheet.vue2.js +140 -0
- package/dist/components/table/FieldCell.vue.d.ts +1 -1
- package/dist/components/table/FieldCell.vue.js +7 -0
- package/dist/components/table/FieldCell.vue2.js +86 -0
- package/dist/components/table/FieldTypePicker.vue.d.ts +15 -0
- package/dist/components/table/FieldTypePicker.vue.js +7 -0
- package/dist/components/table/FieldTypePicker.vue2.js +92 -0
- package/dist/components/table/MobileListView.vue.d.ts +24 -0
- package/dist/components/table/MobileListView.vue.js +7 -0
- package/dist/components/table/MobileListView.vue2.js +90 -0
- package/dist/components/table/NewRowBtn.vue.js +7 -0
- package/dist/components/table/NewRowBtn.vue2.js +22 -0
- package/dist/components/table/TableColumnManager.vue.js +7 -0
- package/dist/components/table/TableColumnManager.vue2.js +100 -0
- package/dist/components/table/TableDataRow.vue.js +7 -0
- package/dist/components/table/TableDataRow.vue2.js +115 -0
- package/dist/components/table/TableFilterPanel.vue.js +7 -0
- package/dist/components/table/TableFilterPanel.vue2.js +142 -0
- package/dist/components/table/TableGroupRow.vue.d.ts +5 -0
- package/dist/components/table/TableGroupRow.vue.js +7 -0
- package/dist/components/table/TableGroupRow.vue2.js +58 -0
- package/dist/components/table/TableHeaderRow.vue.d.ts +16 -0
- package/dist/components/table/TableHeaderRow.vue.js +7 -0
- package/dist/components/table/TableHeaderRow.vue2.js +90 -0
- package/dist/components/table/TableToolbar.vue.d.ts +118 -0
- package/dist/components/table/TableToolbar.vue.js +7 -0
- package/dist/components/table/TableToolbar.vue2.js +273 -0
- package/dist/components/table/index.d.ts +5 -0
- package/dist/components/tabs/TabPanel.vue.js +7 -0
- package/dist/components/tabs/TabPanel.vue2.js +26 -0
- package/dist/components/tabs/Tabs.vue.js +7 -0
- package/dist/components/tabs/Tabs.vue2.js +87 -0
- package/dist/components/timeline/ActivityTimeline.vue.js +7 -0
- package/dist/components/timeline/ActivityTimeline.vue2.js +104 -0
- package/dist/components/timeline/GanttRow.vue.js +7 -0
- package/dist/components/timeline/GanttRow.vue2.js +110 -0
- package/dist/components/timeline/GanttTimeline.vue.js +7 -0
- package/dist/components/timeline/GanttTimeline.vue2.js +186 -0
- package/dist/components/toast/ToastContainer.vue.js +34 -0
- package/dist/components/toast/ToastContainer.vue3.js +5 -0
- package/dist/components/toast/ToastItem.vue.js +7 -0
- package/dist/components/toast/ToastItem.vue2.js +78 -0
- package/dist/composables/index.d.ts +19 -0
- package/dist/composables/useAiChat.js +103 -0
- package/dist/composables/useBadge.js +76 -0
- package/dist/composables/useBreakpoint.d.ts +2 -1
- package/dist/composables/useBreakpoint.js +18 -0
- package/dist/composables/useColumnResize.d.ts +19 -0
- package/dist/composables/useColumnResize.js +58 -0
- package/dist/composables/useDraftRows.d.ts +33 -0
- package/dist/composables/useDraftRows.js +103 -0
- package/dist/composables/useFixedColumns.d.ts +25 -0
- package/dist/composables/useFixedColumns.js +61 -0
- package/dist/composables/useFocusTrap.d.ts +10 -0
- package/dist/composables/useFocusTrap.js +37 -0
- package/dist/composables/useInlineEdit.js +28 -0
- package/dist/composables/useKeyboardNavigation.d.ts +45 -0
- package/dist/composables/useKeyboardNavigation.js +140 -0
- package/dist/composables/useMarkdown.js +69 -0
- package/dist/composables/useRowDrag.d.ts +32 -0
- package/dist/composables/useRowDrag.js +85 -0
- package/dist/composables/useSchemaEngine.d.ts +31 -0
- package/dist/composables/useSchemaEngine.js +129 -0
- package/dist/composables/useSearch.d.ts +30 -0
- package/dist/composables/useSearch.js +59 -0
- package/dist/composables/useStream.js +80 -0
- package/dist/composables/useSupabaseProvider.d.ts +70 -0
- package/dist/composables/useSupabaseProvider.js +126 -0
- package/dist/composables/useTable.d.ts +3 -0
- package/dist/composables/useTable.js +135 -0
- package/dist/composables/useTableColumns.js +24 -0
- package/dist/composables/useTableData.js +16 -0
- package/dist/composables/useTableFilter.js +97 -0
- package/dist/composables/useTableGroup.d.ts +14 -1
- package/dist/composables/useTableGroup.js +70 -0
- package/dist/composables/useToast.js +38 -0
- package/dist/composables/useTypewriter.js +56 -0
- package/dist/composables/useViewPersistence.d.ts +98 -0
- package/dist/composables/useViewPersistence.js +141 -0
- package/dist/composables/useVirtualList.d.ts +4 -1
- package/dist/composables/useVirtualList.js +140 -0
- package/dist/composables/useWorkerSort.d.ts +14 -0
- package/dist/composables/useWorkerSort.js +61 -0
- package/dist/constants/table.js +11 -0
- package/dist/index.d.ts +28 -4
- package/dist/index.js +349 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/core.js +5 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/bash.js +377 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/css.js +923 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/go.js +151 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/java.js +240 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/javascript.js +658 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/json.js +38 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/markdown.js +216 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/plaintext.js +13 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/python.js +399 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/rust.js +305 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/sql.js +615 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/typescript.js +753 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/xml.js +219 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/es/languages/yaml.js +183 -0
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/lib/core.js +1063 -0
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +63 -2
- package/dist/types/index.js +94 -0
- package/dist/types/table-internal.d.ts +64 -0
- package/dist/utils/aggregation.d.ts +5 -0
- package/dist/utils/aggregation.js +38 -0
- package/dist/utils/icon.js +15 -0
- package/dist/utils/supabaseAdapter.d.ts +48 -0
- package/dist/utils/supabaseAdapter.js +76 -0
- package/dist/utils/supabaseSchema.d.ts +81 -0
- package/dist/utils/supabaseSchema.js +202 -0
- package/dist/workers/tableWorker.d.ts +31 -0
- package/package.json +13 -6
- package/dist/FieldDate-Bljx4jb7.js +0 -34
- package/dist/FieldRating-BKHUu-A1.js +0 -32
- package/dist/FieldUrl-bv0EB9sh.js +0 -34
- package/dist/index-DQph5iTq.js +0 -12936
- package/dist/oneflow-ui.js +0 -111
- package/dist/oneflow-ui.umd.cjs +0 -13
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ref as c, readonly as D } from "vue";
|
|
2
|
+
function y(i) {
|
|
3
|
+
const I = c(!1), u = c(null), g = c(null), s = c("before");
|
|
4
|
+
let v = null;
|
|
5
|
+
function f(e) {
|
|
6
|
+
return (e == null ? void 0 : e.__type) === "group-header";
|
|
7
|
+
}
|
|
8
|
+
function d(e) {
|
|
9
|
+
return String(e.id ?? "");
|
|
10
|
+
}
|
|
11
|
+
function T(e, r) {
|
|
12
|
+
if (f(r)) {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
v = r, u.value = d(r), I.value = !0, e.dataTransfer && (e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", u.value));
|
|
17
|
+
}
|
|
18
|
+
function R(e, r) {
|
|
19
|
+
var l;
|
|
20
|
+
if (e.preventDefault(), !v) return;
|
|
21
|
+
if (e.dataTransfer && (e.dataTransfer.dropEffect = "move"), f(r)) {
|
|
22
|
+
(l = i.enableCrossGroupDrag) != null && l.value && (g.value = r.id, s.value = "into-group");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const n = e.currentTarget;
|
|
26
|
+
if (!n) return;
|
|
27
|
+
const t = n.getBoundingClientRect(), p = e.clientY - t.top < t.height / 2;
|
|
28
|
+
g.value = d(r), s.value = p ? "before" : "after";
|
|
29
|
+
}
|
|
30
|
+
function C(e, r, n) {
|
|
31
|
+
var o, p, l, w;
|
|
32
|
+
if (e.preventDefault(), !v || !u.value) {
|
|
33
|
+
h();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const t = u.value;
|
|
37
|
+
if (f(r)) {
|
|
38
|
+
const a = (o = i.groupFieldId) == null ? void 0 : o.value;
|
|
39
|
+
a && ((p = i.enableCrossGroupDrag) != null && p.value) && ((l = n.onGroupChange) == null || l.call(n, {
|
|
40
|
+
rowId: t,
|
|
41
|
+
groupFieldId: a,
|
|
42
|
+
newValue: r.__groupKey
|
|
43
|
+
}));
|
|
44
|
+
} else {
|
|
45
|
+
const a = d(r);
|
|
46
|
+
t !== a && ((w = n.onReorder) == null || w.call(n, {
|
|
47
|
+
rowId: t,
|
|
48
|
+
beforeRowId: s.value === "before" ? a : _(a)
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
h();
|
|
52
|
+
}
|
|
53
|
+
function G() {
|
|
54
|
+
h();
|
|
55
|
+
}
|
|
56
|
+
function _(e) {
|
|
57
|
+
const r = i.processedItems.value;
|
|
58
|
+
for (let n = 0; n < r.length; n++) {
|
|
59
|
+
const t = r[n];
|
|
60
|
+
if (!f(t) && d(t) === e) {
|
|
61
|
+
for (let o = n + 1; o < r.length; o++)
|
|
62
|
+
if (!f(r[o]))
|
|
63
|
+
return d(r[o]);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function h() {
|
|
70
|
+
I.value = !1, u.value = null, g.value = null, v = null;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
isDragging: D(I),
|
|
74
|
+
draggedRowId: D(u),
|
|
75
|
+
dropTargetId: D(g),
|
|
76
|
+
dropPosition: D(s),
|
|
77
|
+
handleDragStart: T,
|
|
78
|
+
handleDragOver: R,
|
|
79
|
+
handleDrop: C,
|
|
80
|
+
handleDragEnd: G
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
y as useRowDrag
|
|
85
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
import { FieldDef, TableColumn, TableSchema, ViewConfig } from '../types';
|
|
3
|
+
export interface ValidationRule {
|
|
4
|
+
fieldId: string;
|
|
5
|
+
type: "required" | "min" | "max" | "pattern" | "custom";
|
|
6
|
+
message: string;
|
|
7
|
+
validate: (value: unknown) => boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FilterFieldConfig {
|
|
10
|
+
fieldId: string;
|
|
11
|
+
label: string;
|
|
12
|
+
type: "string" | "number" | "date" | "select" | "boolean";
|
|
13
|
+
options?: {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
export interface FilterPanelConfig {
|
|
19
|
+
fields: FilterFieldConfig[];
|
|
20
|
+
}
|
|
21
|
+
export interface UseSchemaEngineOptions {
|
|
22
|
+
schema: Ref<TableSchema | undefined>;
|
|
23
|
+
view?: Ref<ViewConfig | undefined>;
|
|
24
|
+
}
|
|
25
|
+
export declare function useSchemaEngine(options: UseSchemaEngineOptions): {
|
|
26
|
+
columns: ComputedRef<TableColumn[]>;
|
|
27
|
+
fieldDefs: ComputedRef<FieldDef[]>;
|
|
28
|
+
validationRules: ComputedRef<Map<string, ValidationRule[]>>;
|
|
29
|
+
filterConfig: ComputedRef<FilterPanelConfig>;
|
|
30
|
+
formulaDependencyGraph: ComputedRef<Map<string, string[]>>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { computed as l } from "vue";
|
|
2
|
+
function b(n) {
|
|
3
|
+
const r = l(() => {
|
|
4
|
+
var e;
|
|
5
|
+
const s = n.schema.value;
|
|
6
|
+
if (!s) return [];
|
|
7
|
+
const i = (e = n.view) == null ? void 0 : e.value;
|
|
8
|
+
if (i != null && i.visibleFields && i.visibleFields.length > 0) {
|
|
9
|
+
const a = new Map(s.fields.map((t) => [t.id, t]));
|
|
10
|
+
return i.visibleFields.map((t) => a.get(t)).filter((t) => t !== void 0 && !t.hidden);
|
|
11
|
+
}
|
|
12
|
+
return s.fields.filter((a) => !a.hidden);
|
|
13
|
+
}), c = l(() => r.value.map((s) => f(s))), m = l(() => {
|
|
14
|
+
const s = /* @__PURE__ */ new Map(), i = n.schema.value;
|
|
15
|
+
if (!i) return s;
|
|
16
|
+
for (const e of i.fields) {
|
|
17
|
+
const a = [];
|
|
18
|
+
if (e.required && a.push({
|
|
19
|
+
fieldId: e.id,
|
|
20
|
+
type: "required",
|
|
21
|
+
message: `${e.name} 为必填项`,
|
|
22
|
+
validate: (t) => t != null && t !== ""
|
|
23
|
+
}), e.type === "number") {
|
|
24
|
+
if (e.min !== void 0) {
|
|
25
|
+
const t = e.min;
|
|
26
|
+
a.push({
|
|
27
|
+
fieldId: e.id,
|
|
28
|
+
type: "min",
|
|
29
|
+
message: `${e.name} 不能小于 ${t}`,
|
|
30
|
+
validate: (d) => typeof d == "number" && d >= t
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (e.max !== void 0) {
|
|
34
|
+
const t = e.max;
|
|
35
|
+
a.push({
|
|
36
|
+
fieldId: e.id,
|
|
37
|
+
type: "max",
|
|
38
|
+
message: `${e.name} 不能大于 ${t}`,
|
|
39
|
+
validate: (d) => typeof d == "number" && d <= t
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
e.type === "email" && a.push({
|
|
44
|
+
fieldId: e.id,
|
|
45
|
+
type: "pattern",
|
|
46
|
+
message: `${e.name} 格式不正确`,
|
|
47
|
+
validate: (t) => typeof t != "string" || t === "" || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)
|
|
48
|
+
}), e.type === "url" && a.push({
|
|
49
|
+
fieldId: e.id,
|
|
50
|
+
type: "pattern",
|
|
51
|
+
message: `${e.name} 不是有效的 URL`,
|
|
52
|
+
validate: (t) => {
|
|
53
|
+
if (typeof t != "string" || t === "") return !0;
|
|
54
|
+
try {
|
|
55
|
+
return new URL(t), !0;
|
|
56
|
+
} catch {
|
|
57
|
+
return !1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}), a.length > 0 && s.set(e.id, a);
|
|
61
|
+
}
|
|
62
|
+
return s;
|
|
63
|
+
}), u = l(() => ({
|
|
64
|
+
fields: r.value.map((s) => y(s))
|
|
65
|
+
})), o = l(() => {
|
|
66
|
+
const s = /* @__PURE__ */ new Map(), i = n.schema.value;
|
|
67
|
+
if (!i) return s;
|
|
68
|
+
for (const e of i.fields)
|
|
69
|
+
e.type === "formula" && e.dependencies && s.set(e.id, [...e.dependencies]);
|
|
70
|
+
return s;
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
columns: c,
|
|
74
|
+
fieldDefs: r,
|
|
75
|
+
validationRules: m,
|
|
76
|
+
filterConfig: u,
|
|
77
|
+
formulaDependencyGraph: o
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const p = {
|
|
81
|
+
text: "string",
|
|
82
|
+
number: "number",
|
|
83
|
+
currency: "number",
|
|
84
|
+
progress: "number",
|
|
85
|
+
rating: "number",
|
|
86
|
+
date: "date",
|
|
87
|
+
datetime: "date",
|
|
88
|
+
select: "status",
|
|
89
|
+
multi_select: "status"
|
|
90
|
+
};
|
|
91
|
+
function f(n) {
|
|
92
|
+
return {
|
|
93
|
+
key: n.id,
|
|
94
|
+
label: n.name,
|
|
95
|
+
width: n.width ?? "fill",
|
|
96
|
+
type: p[n.type] ?? "string",
|
|
97
|
+
hidden: n.hidden
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function y(n) {
|
|
101
|
+
const r = {
|
|
102
|
+
fieldId: n.id,
|
|
103
|
+
label: n.name,
|
|
104
|
+
type: "string"
|
|
105
|
+
};
|
|
106
|
+
switch (n.type) {
|
|
107
|
+
case "number":
|
|
108
|
+
case "currency":
|
|
109
|
+
case "progress":
|
|
110
|
+
case "rating":
|
|
111
|
+
r.type = "number";
|
|
112
|
+
break;
|
|
113
|
+
case "date":
|
|
114
|
+
case "datetime":
|
|
115
|
+
r.type = "date";
|
|
116
|
+
break;
|
|
117
|
+
case "checkbox":
|
|
118
|
+
r.type = "boolean";
|
|
119
|
+
break;
|
|
120
|
+
case "select":
|
|
121
|
+
case "multi_select":
|
|
122
|
+
r.type = "select", r.options = n.options.map((c) => ({ value: c.value, label: c.label }));
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
return r;
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
b as useSchemaEngine
|
|
129
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface UseSearchOptions {
|
|
2
|
+
/** 防抖延迟(ms),默认 300 */
|
|
3
|
+
debounceMs?: number;
|
|
4
|
+
/** 最小搜索字符数,默认 1 */
|
|
5
|
+
minChars?: number;
|
|
6
|
+
/** 搜索模式 */
|
|
7
|
+
mode?: "client" | "server";
|
|
8
|
+
}
|
|
9
|
+
export interface SearchHighlight {
|
|
10
|
+
/** 原始文本 */
|
|
11
|
+
text: string;
|
|
12
|
+
/** 是否为匹配片段 */
|
|
13
|
+
match: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function useSearch(options?: UseSearchOptions): {
|
|
16
|
+
/** 绑定到 input 的 v-model */
|
|
17
|
+
inputKeyword: import('vue').Ref<string, string>;
|
|
18
|
+
/** 防抖后的搜索词(传给 useSupabaseProvider 的 searchKeyword) */
|
|
19
|
+
keyword: Readonly<import('vue').Ref<string, string>>;
|
|
20
|
+
/** 是否有有效搜索词 */
|
|
21
|
+
isSearching: import('vue').ComputedRef<boolean>;
|
|
22
|
+
/** 高亮文本分段 */
|
|
23
|
+
highlightText: (text: string, query?: string) => SearchHighlight[];
|
|
24
|
+
/** 客户端过滤 */
|
|
25
|
+
filterBySearch: <T extends Record<string, unknown>>(data: T[], searchColumns: string[]) => T[];
|
|
26
|
+
/** 清空 */
|
|
27
|
+
clearSearch: () => void;
|
|
28
|
+
/** 直接设置 */
|
|
29
|
+
setKeyword: (val: string) => void;
|
|
30
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ref as f, computed as y, watch as T, readonly as S } from "vue";
|
|
2
|
+
function L(m = {}) {
|
|
3
|
+
const { debounceMs: h = 300, minChars: a = 1 } = m, u = f(""), r = f(""), w = y(() => r.value.length >= a);
|
|
4
|
+
let t = null;
|
|
5
|
+
T(u, (e) => {
|
|
6
|
+
t && clearTimeout(t);
|
|
7
|
+
const n = e.trim();
|
|
8
|
+
if (n.length < a) {
|
|
9
|
+
r.value = "";
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
t = setTimeout(() => {
|
|
13
|
+
r.value = n;
|
|
14
|
+
}, h);
|
|
15
|
+
});
|
|
16
|
+
function d(e, n) {
|
|
17
|
+
const o = n ?? r.value;
|
|
18
|
+
if (!o || !e)
|
|
19
|
+
return [{ text: e, match: !1 }];
|
|
20
|
+
const i = o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), c = new RegExp(`(${i})`, "gi");
|
|
21
|
+
return e.split(c).filter(Boolean).map((s) => ({
|
|
22
|
+
text: s,
|
|
23
|
+
match: s.toLowerCase() === o.toLowerCase()
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
function g(e, n) {
|
|
27
|
+
if (!r.value || !n.length) return e;
|
|
28
|
+
const o = r.value.toLowerCase();
|
|
29
|
+
return e.filter((i) => n.some((c) => {
|
|
30
|
+
const l = i[c];
|
|
31
|
+
return l == null ? !1 : String(l).toLowerCase().includes(o);
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
function p() {
|
|
35
|
+
u.value = "", r.value = "", t && clearTimeout(t);
|
|
36
|
+
}
|
|
37
|
+
function v(e) {
|
|
38
|
+
u.value = e, r.value = e.trim(), t && clearTimeout(t);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
/** 绑定到 input 的 v-model */
|
|
42
|
+
inputKeyword: u,
|
|
43
|
+
/** 防抖后的搜索词(传给 useSupabaseProvider 的 searchKeyword) */
|
|
44
|
+
keyword: S(r),
|
|
45
|
+
/** 是否有有效搜索词 */
|
|
46
|
+
isSearching: w,
|
|
47
|
+
/** 高亮文本分段 */
|
|
48
|
+
highlightText: d,
|
|
49
|
+
/** 客户端过滤 */
|
|
50
|
+
filterBySearch: g,
|
|
51
|
+
/** 清空 */
|
|
52
|
+
clearSearch: p,
|
|
53
|
+
/** 直接设置 */
|
|
54
|
+
setKeyword: v
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
L as useSearch
|
|
59
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ref as y, readonly as b } from "vue";
|
|
2
|
+
function P(e = {}) {
|
|
3
|
+
const t = y(!1), c = y(!1), k = y(null), l = y(0);
|
|
4
|
+
let r = null, n = "";
|
|
5
|
+
async function O(q) {
|
|
6
|
+
var x, I, R, T, A, B, C, E, F;
|
|
7
|
+
c.value = !0, t.value = !1, k.value = null, n = "", r = new AbortController();
|
|
8
|
+
let w = null;
|
|
9
|
+
e.timeout && e.timeout > 0 && (w = setTimeout(() => {
|
|
10
|
+
r == null || r.abort();
|
|
11
|
+
}, e.timeout));
|
|
12
|
+
let m = "", v = [], D = !1;
|
|
13
|
+
const S = () => {
|
|
14
|
+
var a, u;
|
|
15
|
+
if (m && ((a = e.onChunk) == null || a.call(e, m), m = ""), v.length > 0) {
|
|
16
|
+
for (const f of v)
|
|
17
|
+
(u = e.onData) == null || u.call(e, f);
|
|
18
|
+
v = [];
|
|
19
|
+
}
|
|
20
|
+
D = !1;
|
|
21
|
+
}, g = () => {
|
|
22
|
+
D || (D = !0, requestAnimationFrame(S));
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
const a = q.getReader(), u = new TextDecoder();
|
|
26
|
+
for (c.value = !1, t.value = !0; ; ) {
|
|
27
|
+
const { done: f, value: i } = await a.read();
|
|
28
|
+
if (f) break;
|
|
29
|
+
const d = u.decode(i, { stream: !0 });
|
|
30
|
+
if (e.mode === "sse") {
|
|
31
|
+
n += d;
|
|
32
|
+
const L = n.split(`
|
|
33
|
+
`);
|
|
34
|
+
n = L.pop() ?? "";
|
|
35
|
+
for (const J of L) {
|
|
36
|
+
const h = J.trim();
|
|
37
|
+
if (!(!h || h.startsWith(":")) && h.startsWith("data: ")) {
|
|
38
|
+
const s = h.slice(6);
|
|
39
|
+
if (s === "[DONE]") continue;
|
|
40
|
+
try {
|
|
41
|
+
const N = JSON.parse(s);
|
|
42
|
+
(e.bufferInterval ?? 0) > 0 ? (v.push(N), g()) : (x = e.onData) == null || x.call(e, N);
|
|
43
|
+
} catch {
|
|
44
|
+
(e.bufferInterval ?? 0) > 0 ? (m += s, g()) : (I = e.onChunk) == null || I.call(e, s);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} else
|
|
49
|
+
(e.bufferInterval ?? 0) > 0 ? (m += d, g()) : (R = e.onChunk) == null || R.call(e, d);
|
|
50
|
+
}
|
|
51
|
+
S(), (T = e.onDone) == null || T.call(e);
|
|
52
|
+
} catch (a) {
|
|
53
|
+
if (a.name !== "AbortError") {
|
|
54
|
+
const u = ((A = e.retry) == null ? void 0 : A.maxRetries) ?? 0;
|
|
55
|
+
if (l.value < u) {
|
|
56
|
+
const f = ((B = e.retry) == null ? void 0 : B.baseDelay) ?? 1e3, i = ((C = e.retry) == null ? void 0 : C.backoff) === "linear" ? f * (l.value + 1) : f * Math.pow(2, l.value);
|
|
57
|
+
l.value++, await new Promise((d) => setTimeout(d, i)), (E = e.onRetry) == null || E.call(e, l.value);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
k.value = a, (F = e.onError) == null || F.call(e, a);
|
|
61
|
+
}
|
|
62
|
+
} finally {
|
|
63
|
+
w && clearTimeout(w), t.value = !1, c.value = !1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function W() {
|
|
67
|
+
r == null || r.abort(), t.value = !1, c.value = !1;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
isStreaming: b(t),
|
|
71
|
+
isLoading: b(c),
|
|
72
|
+
error: b(k),
|
|
73
|
+
retryCount: b(l),
|
|
74
|
+
start: O,
|
|
75
|
+
cancel: W
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
P as useStream
|
|
80
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { SortState } from './useTable';
|
|
3
|
+
import { FilterCondition as TableFilterCondition, FilterLogic } from './useTableFilter';
|
|
4
|
+
export interface SupabaseQueryBuilder {
|
|
5
|
+
from(table: string): SupabaseFilterBuilder;
|
|
6
|
+
}
|
|
7
|
+
export interface SupabaseFilterBuilder {
|
|
8
|
+
select(columns?: string, options?: {
|
|
9
|
+
count?: "exact" | "planned" | "estimated";
|
|
10
|
+
}): SupabaseFilterBuilder;
|
|
11
|
+
order(column: string, options?: {
|
|
12
|
+
ascending?: boolean;
|
|
13
|
+
}): SupabaseFilterBuilder;
|
|
14
|
+
range(from: number, to: number): SupabaseFilterBuilder;
|
|
15
|
+
eq(column: string, value: unknown): SupabaseFilterBuilder;
|
|
16
|
+
neq(column: string, value: unknown): SupabaseFilterBuilder;
|
|
17
|
+
gt(column: string, value: unknown): SupabaseFilterBuilder;
|
|
18
|
+
gte(column: string, value: unknown): SupabaseFilterBuilder;
|
|
19
|
+
lt(column: string, value: unknown): SupabaseFilterBuilder;
|
|
20
|
+
lte(column: string, value: unknown): SupabaseFilterBuilder;
|
|
21
|
+
like(column: string, pattern: string): SupabaseFilterBuilder;
|
|
22
|
+
ilike(column: string, pattern: string): SupabaseFilterBuilder;
|
|
23
|
+
is(column: string, value: null): SupabaseFilterBuilder;
|
|
24
|
+
not(column: string, operator: string, value: unknown): SupabaseFilterBuilder;
|
|
25
|
+
in(column: string, values: unknown[]): SupabaseFilterBuilder;
|
|
26
|
+
textSearch(column: string, query: string, options?: {
|
|
27
|
+
type?: "plain" | "phrase" | "websearch";
|
|
28
|
+
}): SupabaseFilterBuilder;
|
|
29
|
+
or(filters: string): SupabaseFilterBuilder;
|
|
30
|
+
then<T>(onfulfilled?: (value: any) => T): Promise<T>;
|
|
31
|
+
}
|
|
32
|
+
export interface UseSupabaseProviderOptions {
|
|
33
|
+
/** Supabase client instance (pass your createClient() result) */
|
|
34
|
+
client: SupabaseQueryBuilder;
|
|
35
|
+
/** Supabase table name */
|
|
36
|
+
table: string;
|
|
37
|
+
/** select columns, defaults to '*' */
|
|
38
|
+
select?: string;
|
|
39
|
+
/** Fixed filter conditions always appended (e.g. { project: 'xxx' }) */
|
|
40
|
+
baseFilters?: Record<string, unknown>;
|
|
41
|
+
/** Reactive filter conditions from useTableFilter */
|
|
42
|
+
filterConditions?: Ref<readonly TableFilterCondition[]>;
|
|
43
|
+
/** Filter logic: and / or */
|
|
44
|
+
filterLogic?: Ref<FilterLogic>;
|
|
45
|
+
/** Full-text search keyword */
|
|
46
|
+
searchKeyword?: Ref<string>;
|
|
47
|
+
/** Columns to search with ilike */
|
|
48
|
+
searchColumns?: string[];
|
|
49
|
+
/** Row transformer: Supabase row -> your T type */
|
|
50
|
+
transform?: (row: Record<string, unknown>) => Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
export declare function useSupabaseProvider<T extends Record<string, unknown> = Record<string, unknown>>(options: UseSupabaseProviderOptions): {
|
|
53
|
+
onFetch: (params: {
|
|
54
|
+
page: number;
|
|
55
|
+
pageSize: number;
|
|
56
|
+
sort: SortState;
|
|
57
|
+
}) => Promise<{
|
|
58
|
+
data: T[];
|
|
59
|
+
total: number;
|
|
60
|
+
}>;
|
|
61
|
+
totalCount: Readonly<Ref<number, number>>;
|
|
62
|
+
loading: Readonly<Ref<boolean, boolean>>;
|
|
63
|
+
error: Readonly<Ref<Error | null, Error | null>>;
|
|
64
|
+
/** Exposed for advanced usage */
|
|
65
|
+
buildQuery: (params: {
|
|
66
|
+
page: number;
|
|
67
|
+
pageSize: number;
|
|
68
|
+
sort: SortState;
|
|
69
|
+
}) => SupabaseFilterBuilder;
|
|
70
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ref as d, readonly as $ } from "vue";
|
|
2
|
+
function w(e, r) {
|
|
3
|
+
const { field: n, operator: t, value: l } = r;
|
|
4
|
+
switch (t) {
|
|
5
|
+
case "equals":
|
|
6
|
+
return e.eq(n, l);
|
|
7
|
+
case "not_equals":
|
|
8
|
+
return e.neq(n, l);
|
|
9
|
+
case "contains":
|
|
10
|
+
return e.ilike(n, `%${l}%`);
|
|
11
|
+
case "not_contains":
|
|
12
|
+
return e.not(n, "ilike", `%${l}%`);
|
|
13
|
+
case "starts_with":
|
|
14
|
+
return e.ilike(n, `${l}%`);
|
|
15
|
+
case "ends_with":
|
|
16
|
+
return e.ilike(n, `%${l}`);
|
|
17
|
+
case "gt":
|
|
18
|
+
return e.gt(n, l);
|
|
19
|
+
case "gte":
|
|
20
|
+
return e.gte(n, l);
|
|
21
|
+
case "lt":
|
|
22
|
+
return e.lt(n, l);
|
|
23
|
+
case "lte":
|
|
24
|
+
return e.lte(n, l);
|
|
25
|
+
case "is_empty":
|
|
26
|
+
return e.is(n, null);
|
|
27
|
+
case "is_not_empty":
|
|
28
|
+
return e.not(n, "is", null);
|
|
29
|
+
default:
|
|
30
|
+
return e;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function k(e) {
|
|
34
|
+
const { field: r, operator: n, value: t } = e;
|
|
35
|
+
switch (n) {
|
|
36
|
+
case "equals":
|
|
37
|
+
return `${r}.eq.${t}`;
|
|
38
|
+
case "not_equals":
|
|
39
|
+
return `${r}.neq.${t}`;
|
|
40
|
+
case "contains":
|
|
41
|
+
return `${r}.ilike.%${t}%`;
|
|
42
|
+
case "not_contains":
|
|
43
|
+
return `${r}.not.ilike.%${t}%`;
|
|
44
|
+
case "starts_with":
|
|
45
|
+
return `${r}.ilike.${t}%`;
|
|
46
|
+
case "ends_with":
|
|
47
|
+
return `${r}.ilike.%${t}`;
|
|
48
|
+
case "gt":
|
|
49
|
+
return `${r}.gt.${t}`;
|
|
50
|
+
case "gte":
|
|
51
|
+
return `${r}.gte.${t}`;
|
|
52
|
+
case "lt":
|
|
53
|
+
return `${r}.lt.${t}`;
|
|
54
|
+
case "lte":
|
|
55
|
+
return `${r}.lte.${t}`;
|
|
56
|
+
case "is_empty":
|
|
57
|
+
return `${r}.is.null`;
|
|
58
|
+
case "is_not_empty":
|
|
59
|
+
return `${r}.not.is.null`;
|
|
60
|
+
default:
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function C(e, r, n) {
|
|
65
|
+
if (r.length === 0) return e;
|
|
66
|
+
if (n === "or") {
|
|
67
|
+
const t = r.map((l) => k(l)).filter(Boolean);
|
|
68
|
+
return t.length > 0 && (e = e.or(t.join(","))), e;
|
|
69
|
+
}
|
|
70
|
+
for (const t of r)
|
|
71
|
+
!t.field || !t.value && t.operator !== "is_empty" && t.operator !== "is_not_empty" || (e = w(e, t));
|
|
72
|
+
return e;
|
|
73
|
+
}
|
|
74
|
+
function p(e) {
|
|
75
|
+
const r = d(0), n = d(!1), t = d(null);
|
|
76
|
+
function l(o) {
|
|
77
|
+
var i, g, h, _;
|
|
78
|
+
let a = e.client.from(e.table).select(e.select ?? "*", { count: "exact" });
|
|
79
|
+
if (e.baseFilters)
|
|
80
|
+
for (const [u, f] of Object.entries(e.baseFilters))
|
|
81
|
+
a = a.eq(u, f);
|
|
82
|
+
if ((i = e.filterConditions) != null && i.value && (a = C(
|
|
83
|
+
a,
|
|
84
|
+
e.filterConditions.value,
|
|
85
|
+
((g = e.filterLogic) == null ? void 0 : g.value) ?? "and"
|
|
86
|
+
)), (h = e.searchKeyword) != null && h.value && ((_ = e.searchColumns) != null && _.length)) {
|
|
87
|
+
const u = e.searchKeyword.value.trim();
|
|
88
|
+
if (u) {
|
|
89
|
+
const f = e.searchColumns.map((m) => `${m}.ilike.%${u}%`).join(",");
|
|
90
|
+
a = a.or(f);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
o.sort.field && o.sort.order && (a = a.order(o.sort.field, {
|
|
94
|
+
ascending: o.sort.order === "asc"
|
|
95
|
+
}));
|
|
96
|
+
const s = (o.page - 1) * o.pageSize, c = s + o.pageSize - 1;
|
|
97
|
+
return a = a.range(s, c), a;
|
|
98
|
+
}
|
|
99
|
+
async function v(o) {
|
|
100
|
+
n.value = !0, t.value = null;
|
|
101
|
+
try {
|
|
102
|
+
const s = await l(o);
|
|
103
|
+
if (s.error) throw new Error(s.error.message);
|
|
104
|
+
const c = s.data ?? [], i = e.transform ? c.map(e.transform) : c;
|
|
105
|
+
return r.value = s.count ?? i.length, {
|
|
106
|
+
data: i,
|
|
107
|
+
total: r.value
|
|
108
|
+
};
|
|
109
|
+
} catch (a) {
|
|
110
|
+
return t.value = a, { data: [], total: 0 };
|
|
111
|
+
} finally {
|
|
112
|
+
n.value = !1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
onFetch: v,
|
|
117
|
+
totalCount: $(r),
|
|
118
|
+
loading: $(n),
|
|
119
|
+
error: $(t),
|
|
120
|
+
/** Exposed for advanced usage */
|
|
121
|
+
buildQuery: l
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
p as useSupabaseProvider
|
|
126
|
+
};
|
|
@@ -59,4 +59,7 @@ export declare function useTable<T extends Record<string, unknown>>(options?: Us
|
|
|
59
59
|
refresh: () => void;
|
|
60
60
|
fetchData: () => Promise<void>;
|
|
61
61
|
setData: (data: T[]) => void;
|
|
62
|
+
patchRow: (rowId: string, fields: Partial<Record<string, unknown>>) => void;
|
|
63
|
+
insertRow: (row: T, position?: number) => void;
|
|
64
|
+
removeRows: (rowIds: (string | number)[]) => void;
|
|
62
65
|
};
|