@h-ai/ui 0.1.0-alpha9 → 1.0.0-beta.10
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.en.md +1062 -0
- package/README.ja.md +1062 -0
- package/README.md +696 -119
- package/auto-import.d.ts +49 -0
- package/auto-import.js +51 -69
- package/dist/components/compounds/Accordion.svelte +30 -3
- package/dist/components/compounds/Accordion.svelte.d.ts +37 -1
- package/dist/components/compounds/ActionSheet.svelte +35 -8
- package/dist/components/compounds/ActionSheet.svelte.d.ts +41 -1
- package/dist/components/compounds/Alert.svelte +24 -15
- package/dist/components/compounds/Alert.svelte.d.ts +14 -3
- package/dist/components/compounds/AppBar.svelte +37 -9
- package/dist/components/compounds/AppBar.svelte.d.ts +36 -1
- package/dist/components/compounds/BottomNav.svelte +68 -8
- package/dist/components/compounds/BottomNav.svelte.d.ts +51 -1
- package/dist/components/compounds/Breadcrumb.svelte +18 -5
- package/dist/components/compounds/Breadcrumb.svelte.d.ts +23 -2
- package/dist/components/compounds/Calendar.svelte +31 -12
- package/dist/components/compounds/Calendar.svelte.d.ts +23 -7
- package/dist/components/compounds/Card.svelte +17 -5
- package/dist/components/compounds/Card.svelte.d.ts +13 -2
- package/dist/components/compounds/Combobox.svelte +124 -42
- package/dist/components/compounds/Combobox.svelte.d.ts +42 -20
- package/dist/components/compounds/Confirm.svelte +32 -9
- package/dist/components/compounds/Confirm.svelte.d.ts +24 -2
- package/dist/components/compounds/DataTable.svelte +317 -33
- package/dist/components/compounds/DataTable.svelte.d.ts +28 -14
- package/dist/components/compounds/DatePicker.svelte +62 -18
- package/dist/components/compounds/DatePicker.svelte.d.ts +27 -8
- package/dist/components/compounds/Drawer.svelte +179 -22
- package/dist/components/compounds/Drawer.svelte.d.ts +24 -2
- package/dist/components/compounds/Dropdown.svelte +19 -5
- package/dist/components/compounds/Dropdown.svelte.d.ts +13 -2
- package/dist/components/compounds/Empty.svelte +22 -9
- package/dist/components/compounds/Empty.svelte.d.ts +23 -2
- package/dist/components/compounds/FilterBar.svelte +82 -0
- package/dist/components/compounds/FilterBar.svelte.d.ts +39 -0
- package/dist/components/compounds/Form.svelte +59 -16
- package/dist/components/compounds/Form.svelte.d.ts +23 -2
- package/dist/components/compounds/FormField.svelte +99 -16
- package/dist/components/compounds/FormField.svelte.d.ts +23 -2
- package/dist/components/compounds/FormLayout.svelte +71 -0
- package/dist/components/compounds/FormLayout.svelte.d.ts +17 -0
- package/dist/components/compounds/InfiniteScroll.svelte +34 -7
- package/dist/components/compounds/InfiniteScroll.svelte.d.ts +37 -1
- package/dist/components/compounds/JsonViewer.svelte +214 -0
- package/dist/components/compounds/JsonViewer.svelte.d.ts +26 -0
- package/dist/components/compounds/MessageBoxContainer.svelte +34 -0
- package/dist/components/compounds/MessageBoxContainer.svelte.d.ts +25 -0
- package/dist/components/compounds/MessageBoxDialog.svelte +209 -0
- package/dist/components/compounds/MessageBoxDialog.svelte.d.ts +29 -0
- package/dist/components/compounds/MessageContainer.svelte +24 -0
- package/dist/components/compounds/MessageContainer.svelte.d.ts +18 -0
- package/dist/components/compounds/Modal.svelte +348 -73
- package/dist/components/compounds/Modal.svelte.d.ts +13 -2
- package/dist/components/compounds/PageHeader.svelte +44 -20
- package/dist/components/compounds/PageHeader.svelte.d.ts +24 -9
- package/dist/components/compounds/Pagination.svelte +139 -105
- package/dist/components/compounds/Pagination.svelte.d.ts +23 -2
- package/dist/components/compounds/Popover.svelte +124 -25
- package/dist/components/compounds/Popover.svelte.d.ts +23 -2
- package/dist/components/compounds/PullRefresh.svelte +35 -8
- package/dist/components/compounds/PullRefresh.svelte.d.ts +35 -1
- package/dist/components/compounds/Result.svelte +17 -4
- package/dist/components/compounds/Result.svelte.d.ts +23 -2
- package/dist/components/compounds/SafeArea.svelte +30 -3
- package/dist/components/compounds/SafeArea.svelte.d.ts +35 -1
- package/dist/components/compounds/Skeleton.svelte +19 -7
- package/dist/components/compounds/Skeleton.svelte.d.ts +13 -2
- package/dist/components/compounds/Steps.svelte +17 -4
- package/dist/components/compounds/Steps.svelte.d.ts +23 -2
- package/dist/components/compounds/SwipeCell.svelte +30 -3
- package/dist/components/compounds/SwipeCell.svelte.d.ts +40 -1
- package/dist/components/compounds/TableToolbar.svelte +289 -0
- package/dist/components/compounds/TableToolbar.svelte.d.ts +69 -0
- package/dist/components/compounds/Tabs.svelte +84 -14
- package/dist/components/compounds/Tabs.svelte.d.ts +13 -2
- package/dist/components/compounds/TagInput.svelte +51 -33
- package/dist/components/compounds/TagInput.svelte.d.ts +23 -2
- package/dist/components/compounds/Timeline.svelte +30 -3
- package/dist/components/compounds/Timeline.svelte.d.ts +37 -1
- package/dist/components/compounds/ToastContainer.svelte +397 -28
- package/dist/components/compounds/ToastContainer.svelte.d.ts +27 -1
- package/dist/components/compounds/Tooltip.svelte +143 -9
- package/dist/components/compounds/Tooltip.svelte.d.ts +25 -2
- package/dist/components/compounds/accordion-types.d.ts +10 -1
- package/dist/components/compounds/action-sheet-types.d.ts +9 -0
- package/dist/components/compounds/bottom-nav-types.d.ts +9 -0
- package/dist/components/compounds/index.d.ts +7 -0
- package/dist/components/compounds/index.js +11 -0
- package/dist/components/compounds/swipe-cell-types.d.ts +9 -0
- package/dist/components/compounds/timeline-types.d.ts +9 -0
- package/dist/components/control-size.d.ts +35 -0
- package/dist/components/control-size.js +26 -0
- package/dist/components/primitives/Avatar.svelte +19 -5
- package/dist/components/primitives/Avatar.svelte.d.ts +13 -2
- package/dist/components/primitives/Badge.svelte +16 -4
- package/dist/components/primitives/Badge.svelte.d.ts +13 -2
- package/dist/components/primitives/BareButton.svelte +26 -12
- package/dist/components/primitives/BareButton.svelte.d.ts +23 -2
- package/dist/components/primitives/BareInput.svelte +57 -35
- package/dist/components/primitives/BareInput.svelte.d.ts +23 -2
- package/dist/components/primitives/Button.svelte +30 -9
- package/dist/components/primitives/Button.svelte.d.ts +13 -2
- package/dist/components/primitives/Checkbox.svelte +24 -5
- package/dist/components/primitives/Checkbox.svelte.d.ts +23 -2
- package/dist/components/primitives/IconButton.svelte +35 -10
- package/dist/components/primitives/IconButton.svelte.d.ts +23 -2
- package/dist/components/primitives/Input.svelte +56 -26
- package/dist/components/primitives/Input.svelte.d.ts +13 -2
- package/dist/components/primitives/Progress.svelte +17 -4
- package/dist/components/primitives/Progress.svelte.d.ts +23 -2
- package/dist/components/primitives/Radio.svelte +17 -4
- package/dist/components/primitives/Radio.svelte.d.ts +22 -2
- package/dist/components/primitives/Range.svelte +31 -4
- package/dist/components/primitives/Range.svelte.d.ts +37 -1
- package/dist/components/primitives/Rating.svelte +32 -5
- package/dist/components/primitives/Rating.svelte.d.ts +37 -1
- package/dist/components/primitives/Select.svelte +404 -47
- package/dist/components/primitives/Select.svelte.d.ts +23 -2
- package/dist/components/primitives/Spinner.svelte +17 -4
- package/dist/components/primitives/Spinner.svelte.d.ts +23 -2
- package/dist/components/primitives/Switch.svelte +22 -4
- package/dist/components/primitives/Switch.svelte.d.ts +23 -2
- package/dist/components/primitives/Tag.svelte +17 -4
- package/dist/components/primitives/Tag.svelte.d.ts +23 -2
- package/dist/components/primitives/Textarea.svelte +75 -30
- package/dist/components/primitives/Textarea.svelte.d.ts +24 -2
- package/dist/components/primitives/ToggleCheckbox.svelte +24 -10
- package/dist/components/primitives/ToggleCheckbox.svelte.d.ts +23 -2
- package/dist/components/primitives/ToggleInput.svelte +24 -10
- package/dist/components/primitives/ToggleInput.svelte.d.ts +23 -2
- package/dist/components/primitives/ToggleRadio.svelte +24 -10
- package/dist/components/primitives/ToggleRadio.svelte.d.ts +23 -2
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +54 -23
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte.d.ts +30 -1
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +3428 -693
- package/dist/components/scenes/ai/AiDocumentEditor.svelte.d.ts +26 -1
- package/dist/components/scenes/ai/MarkdownRenderer.svelte +119 -116
- package/dist/components/scenes/ai/MarkdownRenderer.svelte.d.ts +31 -1
- package/dist/components/scenes/ai/code-preview.d.ts +46 -0
- package/dist/components/scenes/ai/code-preview.js +141 -0
- package/dist/components/scenes/ai/document-download.d.ts +52 -0
- package/dist/components/scenes/ai/document-download.js +300 -79
- package/dist/components/scenes/ai/document-parse.d.ts +101 -11
- package/dist/components/scenes/ai/document-parse.js +212 -48
- package/dist/components/scenes/ai/document-types.d.ts +292 -75
- package/dist/components/scenes/ai/editor-markdown-extensions.d.ts +27 -0
- package/dist/components/scenes/ai/editor-markdown-extensions.js +216 -0
- package/dist/components/scenes/ai/highlight.d.ts +37 -0
- package/dist/components/scenes/ai/highlight.js +177 -0
- package/dist/components/scenes/ai/index.d.ts +5 -2
- package/dist/components/scenes/ai/index.js +3 -0
- package/dist/components/scenes/ai/markdown-parse.d.ts +11 -3
- package/dist/components/scenes/ai/markdown-parse.js +85 -47
- package/dist/components/scenes/ai/mermaid-host-sync.d.ts +72 -0
- package/dist/components/scenes/ai/mermaid-host-sync.js +65 -0
- package/dist/components/scenes/ai/mermaid-render.d.ts +30 -0
- package/dist/components/scenes/ai/mermaid-render.js +61 -0
- package/dist/components/scenes/ai/safe-html.d.ts +64 -0
- package/dist/components/scenes/ai/safe-html.js +345 -0
- package/dist/components/scenes/ai/table/AiTableEditor.svelte +1692 -0
- package/dist/components/scenes/ai/table/AiTableEditor.svelte.d.ts +32 -0
- package/dist/components/scenes/ai/table/table-types.d.ts +181 -0
- package/dist/components/scenes/ai/table/table-types.js +1 -0
- package/dist/components/scenes/app/FeedbackDetail.svelte +236 -0
- package/dist/components/scenes/app/FeedbackDetail.svelte.d.ts +40 -0
- package/dist/components/scenes/app/FeedbackForm.svelte +337 -0
- package/dist/components/scenes/app/FeedbackForm.svelte.d.ts +72 -0
- package/dist/components/scenes/app/FeedbackList.svelte +150 -0
- package/dist/components/scenes/app/FeedbackList.svelte.d.ts +28 -0
- package/dist/components/scenes/app/FeedbackModal.svelte +65 -139
- package/dist/components/scenes/app/FeedbackModal.svelte.d.ts +14 -39
- package/dist/components/scenes/app/FeedbackRecorder.svelte +154 -0
- package/dist/components/scenes/app/FeedbackRecorder.svelte.d.ts +9 -0
- package/dist/components/scenes/app/FeedbackReplay.svelte +142 -0
- package/dist/components/scenes/app/FeedbackReplay.svelte.d.ts +7 -0
- package/dist/components/scenes/app/FeedbackScreenshot.svelte +120 -0
- package/dist/components/scenes/app/FeedbackScreenshot.svelte.d.ts +8 -0
- package/dist/components/scenes/app/LanguageSwitch.svelte +38 -21
- package/dist/components/scenes/app/LanguageSwitch.svelte.d.ts +33 -20
- package/dist/components/scenes/app/SettingsLayout.svelte +115 -0
- package/dist/components/scenes/app/SettingsLayout.svelte.d.ts +54 -0
- package/dist/components/scenes/app/SettingsModal.svelte +33 -7
- package/dist/components/scenes/app/SettingsModal.svelte.d.ts +27 -1
- package/dist/components/scenes/app/ThemeColorPicker.svelte +240 -0
- package/dist/components/scenes/app/ThemeColorPicker.svelte.d.ts +57 -0
- package/dist/components/scenes/app/ThemeSelector.svelte +87 -26
- package/dist/components/scenes/app/ThemeSelector.svelte.d.ts +26 -7
- package/dist/components/scenes/app/ThemeToggle.svelte +27 -6
- package/dist/components/scenes/app/ThemeToggle.svelte.d.ts +24 -5
- package/dist/components/scenes/app/WorkspaceLayout.svelte +64 -0
- package/dist/components/scenes/app/WorkspaceLayout.svelte.d.ts +36 -0
- package/dist/components/scenes/app/feedback-functions.d.ts +57 -0
- package/dist/components/scenes/app/feedback-functions.js +107 -0
- package/dist/components/scenes/app/feedback-types.d.ts +224 -0
- package/dist/components/scenes/app/feedback-types.js +1 -0
- package/dist/components/scenes/app/index.d.ts +8 -1
- package/dist/components/scenes/app/index.js +7 -1
- package/dist/components/scenes/charts/Chart.svelte +186 -0
- package/dist/components/scenes/charts/Chart.svelte.d.ts +24 -0
- package/dist/components/scenes/charts/ChartLoadError.svelte +13 -0
- package/dist/components/scenes/charts/ChartLoadError.svelte.d.ts +6 -0
- package/dist/components/scenes/charts/DashboardGrid.svelte +34 -0
- package/dist/components/scenes/charts/DashboardGrid.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/MetricCard.svelte +52 -0
- package/dist/components/scenes/charts/MetricCard.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/ReportCard.svelte +48 -0
- package/dist/components/scenes/charts/ReportCard.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/chart-presets.d.ts +15 -0
- package/dist/components/scenes/charts/chart-presets.js +19 -0
- package/dist/components/scenes/charts/chart-theme.d.ts +47 -0
- package/dist/components/scenes/charts/chart-theme.js +68 -0
- package/dist/components/scenes/charts/chart-types.d.ts +164 -0
- package/dist/components/scenes/charts/chart-types.js +7 -0
- package/dist/components/scenes/charts/dashboard-types.d.ts +79 -0
- package/dist/components/scenes/charts/dashboard-types.js +1 -0
- package/dist/components/scenes/charts/index.d.ts +12 -0
- package/dist/components/scenes/charts/index.js +10 -0
- package/dist/components/scenes/charts/renderers/AreaChart.svelte +19 -0
- package/dist/components/scenes/charts/renderers/AreaChart.svelte.d.ts +6 -0
- package/dist/components/scenes/charts/renderers/BarChart.svelte +19 -0
- package/dist/components/scenes/charts/renderers/BarChart.svelte.d.ts +6 -0
- package/dist/components/scenes/charts/renderers/LineChart.svelte +625 -0
- package/dist/components/scenes/charts/renderers/LineChart.svelte.d.ts +33 -0
- package/dist/components/scenes/charts/renderers/PieChart.svelte +19 -0
- package/dist/components/scenes/charts/renderers/PieChart.svelte.d.ts +6 -0
- package/dist/components/scenes/charts/renderers/ScatterChart.svelte +19 -0
- package/dist/components/scenes/charts/renderers/ScatterChart.svelte.d.ts +6 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte +29 -11
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte.d.ts +13 -1
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +77 -22
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte.d.ts +19 -4
- package/dist/components/scenes/crud/CrudDetailPanel.svelte +242 -0
- package/dist/components/scenes/crud/CrudDetailPanel.svelte.d.ts +66 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte +365 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte.d.ts +48 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte +17 -85
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +13 -25
- package/dist/components/scenes/crud/CrudPage.svelte +564 -185
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +137 -51
- package/dist/components/scenes/crud/crud-controller.svelte.d.ts +335 -0
- package/dist/components/scenes/crud/crud-controller.svelte.js +276 -0
- package/dist/components/scenes/crud/crud-form-validation.d.ts +16 -0
- package/dist/components/scenes/crud/crud-form-validation.js +51 -0
- package/dist/components/scenes/crud/crud-types.d.ts +136 -43
- package/dist/components/scenes/crud/index.d.ts +9 -3
- package/dist/components/scenes/crud/index.js +8 -3
- package/dist/components/scenes/crud/nav-adapter.d.ts +50 -0
- package/dist/components/scenes/crud/nav-adapter.js +39 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte +63 -28
- package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +38 -3
- package/dist/components/scenes/crypto/HashDisplay.svelte +30 -22
- package/dist/components/scenes/crypto/HashDisplay.svelte.d.ts +24 -1
- package/dist/components/scenes/crypto/SignatureDisplay.svelte +41 -40
- package/dist/components/scenes/crypto/SignatureDisplay.svelte.d.ts +24 -1
- package/dist/components/scenes/error/ErrorPage.svelte +135 -0
- package/dist/components/scenes/error/ErrorPage.svelte.d.ts +50 -0
- package/dist/components/scenes/error/error-presets.d.ts +60 -0
- package/dist/components/scenes/error/error-presets.js +51 -0
- package/dist/components/scenes/error/index.d.ts +8 -0
- package/dist/components/scenes/error/index.js +8 -0
- package/dist/components/scenes/guide/GuideHost.svelte +56 -0
- package/dist/components/scenes/guide/GuideHost.svelte.d.ts +35 -0
- package/dist/components/scenes/guide/GuideHostContent.svelte +136 -0
- package/dist/components/scenes/guide/GuideHostContent.svelte.d.ts +43 -0
- package/dist/components/scenes/guide/HelpCenter.svelte +135 -0
- package/dist/components/scenes/guide/HelpCenter.svelte.d.ts +40 -0
- package/dist/components/scenes/guide/index.d.ts +2 -0
- package/dist/components/scenes/guide/index.js +2 -0
- package/dist/components/scenes/iam/AgreementNotice.svelte +48 -0
- package/dist/components/scenes/iam/AgreementNotice.svelte.d.ts +7 -0
- package/dist/components/scenes/iam/AuthPanel.svelte +226 -0
- package/dist/components/scenes/iam/AuthPanel.svelte.d.ts +29 -0
- package/dist/components/scenes/iam/AuthShell.svelte +160 -0
- package/dist/components/scenes/iam/AuthShell.svelte.d.ts +56 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +84 -63
- package/dist/components/scenes/iam/ChangePasswordForm.svelte.d.ts +13 -1
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +113 -89
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte.d.ts +24 -1
- package/dist/components/scenes/iam/LoginForm.svelte +215 -117
- package/dist/components/scenes/iam/LoginForm.svelte.d.ts +13 -1
- package/dist/components/scenes/iam/PasswordInput.svelte +79 -32
- package/dist/components/scenes/iam/PasswordInput.svelte.d.ts +30 -4
- package/dist/components/scenes/iam/PermGuard.svelte +21 -11
- package/dist/components/scenes/iam/PermGuard.svelte.d.ts +30 -0
- package/dist/components/scenes/iam/ReauthenticationDialog.svelte +68 -0
- package/dist/components/scenes/iam/ReauthenticationDialog.svelte.d.ts +17 -0
- package/dist/components/scenes/iam/RegisterForm.svelte +129 -116
- package/dist/components/scenes/iam/RegisterForm.svelte.d.ts +13 -1
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +101 -88
- package/dist/components/scenes/iam/ResetPasswordForm.svelte.d.ts +13 -1
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +76 -0
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte.d.ts +21 -0
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte +64 -0
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte.d.ts +22 -0
- package/dist/components/scenes/iam/UserProfile.svelte +47 -21
- package/dist/components/scenes/iam/UserProfile.svelte.d.ts +24 -1
- package/dist/components/scenes/iam/auth-captcha.d.ts +21 -0
- package/dist/components/scenes/iam/auth-captcha.js +23 -0
- package/dist/components/scenes/iam/auth-error-message.d.ts +13 -0
- package/dist/components/scenes/iam/auth-error-message.js +65 -0
- package/dist/components/scenes/iam/index.d.ts +10 -0
- package/dist/components/scenes/iam/index.js +9 -1
- package/dist/components/scenes/iam/password-utils.d.ts +33 -6
- package/dist/components/scenes/iam/password-utils.js +61 -8
- package/dist/components/scenes/iam/permission-context.svelte.d.ts +33 -23
- package/dist/components/scenes/iam/permission-context.svelte.js +20 -22
- package/dist/components/scenes/iam/sensitive-actions.svelte.d.ts +68 -0
- package/dist/components/scenes/iam/sensitive-actions.svelte.js +101 -0
- package/dist/components/scenes/iam/session-recovery.svelte.d.ts +44 -0
- package/dist/components/scenes/iam/session-recovery.svelte.js +57 -0
- package/dist/components/scenes/index.d.ts +3 -0
- package/dist/components/scenes/index.js +5 -0
- package/dist/components/scenes/storage/AvatarUpload.svelte +82 -68
- package/dist/components/scenes/storage/AvatarUpload.svelte.d.ts +23 -1
- package/dist/components/scenes/storage/FileList.svelte +19 -5
- package/dist/components/scenes/storage/FileList.svelte.d.ts +23 -1
- package/dist/components/scenes/storage/FileUpload.svelte +151 -96
- package/dist/components/scenes/storage/FileUpload.svelte.d.ts +24 -1
- package/dist/components/scenes/storage/ImageUpload.svelte +93 -94
- package/dist/components/scenes/storage/ImageUpload.svelte.d.ts +24 -1
- package/dist/components/scenes/types.d.ts +574 -42
- package/dist/guide-storage.d.ts +18 -0
- package/dist/guide-storage.js +79 -0
- package/dist/guide-types.d.ts +143 -0
- package/dist/guide-types.js +1 -0
- package/dist/guide.d.ts +3 -0
- package/dist/guide.js +3 -0
- package/dist/guide.svelte.d.ts +29 -0
- package/dist/guide.svelte.js +506 -0
- package/dist/i18n.svelte.d.ts +67 -4
- package/dist/i18n.svelte.js +106 -21
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/internal/browser-safety.d.ts +88 -0
- package/dist/internal/browser-safety.js +140 -0
- package/dist/internal/dialog-focus.d.ts +21 -0
- package/dist/internal/dialog-focus.js +77 -0
- package/dist/internal/form-context.d.ts +92 -0
- package/dist/internal/form-context.js +70 -0
- package/dist/internal/form-validation.svelte.d.ts +70 -0
- package/dist/internal/form-validation.svelte.js +142 -0
- package/dist/internal/icon-safety.d.ts +14 -0
- package/dist/internal/icon-safety.js +40 -0
- package/dist/internal/locale.d.ts +21 -0
- package/dist/internal/locale.js +43 -0
- package/dist/message.svelte.d.ts +138 -0
- package/dist/message.svelte.js +149 -0
- package/dist/messagebox.svelte.d.ts +130 -0
- package/dist/messagebox.svelte.js +171 -0
- package/dist/messages/en-US.json +303 -16
- package/dist/messages/ja-JP.json +529 -0
- package/dist/messages/zh-CN.json +303 -16
- package/dist/messages.d.ts +25 -3
- package/dist/messages.js +23 -6
- package/dist/styles/design-tokens.css +4 -2
- package/dist/styles/eye-care.css +55 -0
- package/dist/styles/formal.css +55 -0
- package/dist/styles/global.css +86 -18
- package/dist/styles/guide.css +88 -0
- package/dist/styles/high-contrast.css +64 -0
- package/dist/styles/mobile.css +28 -0
- package/dist/styles/theme.css +43 -0
- package/dist/theme-config.d.ts +263 -10
- package/dist/theme-config.js +253 -17
- package/dist/toast.svelte.d.ts +210 -2
- package/dist/toast.svelte.js +305 -19
- package/dist/types.d.ts +787 -63
- package/dist/utils/platform.svelte.d.ts +28 -15
- package/dist/utils/platform.svelte.js +23 -16
- package/dist/utils.d.ts +121 -1
- package/dist/utils.js +208 -13
- package/dist/workspace-context.d.ts +20 -0
- package/dist/workspace-context.js +9 -0
- package/package.json +120 -24
- package/vite.d.ts +13 -0
- package/vite.js +96 -0
- package/dist/components/scenes/crud/CrudEditDrawer.svelte +0 -225
- package/dist/components/scenes/crud/CrudEditDrawer.svelte.d.ts +0 -48
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component TableToolbar
|
|
3
|
+
统一列表搜索与筛选;条件由查询按钮或原生 Enter 提交,排序由 DataTable 列头承接。
|
|
4
|
+
|
|
5
|
+
使用 Svelte 5 Runes ($props, $state)
|
|
6
|
+
|
|
7
|
+
@example
|
|
8
|
+
```ts
|
|
9
|
+
import { mount, unmount } from 'svelte'
|
|
10
|
+
import type { ComponentProps } from 'svelte'
|
|
11
|
+
import { TableToolbar } from '@h-ai/ui'
|
|
12
|
+
const props: ComponentProps<typeof TableToolbar> = { searchable: true, filterFields: [{ id: 'active', label: '状态', type: 'boolean' }], filterValues: { active: true } }
|
|
13
|
+
const component = mount(TableToolbar, { target: document.body, props })
|
|
14
|
+
await unmount(component)
|
|
15
|
+
```
|
|
16
|
+
-->
|
|
17
|
+
<script lang='ts'>
|
|
18
|
+
import type { Snippet } from 'svelte'
|
|
19
|
+
import type { DataAttributes } from '../../types.js'
|
|
20
|
+
import { uiM } from '../../messages.js'
|
|
21
|
+
import { getDataAttributes } from '../../utils.js'
|
|
22
|
+
import { getFormControlSizeClasses } from '../control-size.js'
|
|
23
|
+
import Button from '../primitives/Button.svelte'
|
|
24
|
+
import Input from '../primitives/Input.svelte'
|
|
25
|
+
import FilterBar from './FilterBar.svelte'
|
|
26
|
+
import FormField from './FormField.svelte'
|
|
27
|
+
import FormLayout from './FormLayout.svelte'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 工具栏过滤字段的局部视图;值由宿主条件查询消费。
|
|
31
|
+
*
|
|
32
|
+
* @example 模块内部上下文
|
|
33
|
+
* ```ts
|
|
34
|
+
* const example: FilterFieldDef = { id: 'active', label: '状态', type: 'boolean' }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
type FilterFieldDef = {
|
|
38
|
+
id: string
|
|
39
|
+
label: string | (() => string)
|
|
40
|
+
type: string
|
|
41
|
+
placeholder?: string | (() => string)
|
|
42
|
+
startKey?: string
|
|
43
|
+
endKey?: string
|
|
44
|
+
min?: number
|
|
45
|
+
max?: number
|
|
46
|
+
step?: number
|
|
47
|
+
options?: Array<{ label: string, value: string | number | boolean }> | (() => Array<{ label: string, value: string | number | boolean }>)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let {
|
|
51
|
+
searchable = true,
|
|
52
|
+
searchPlaceholder = '',
|
|
53
|
+
searchValue = $bindable(''),
|
|
54
|
+
filterFields = [],
|
|
55
|
+
filterValues = $bindable<Record<string, unknown>>({}),
|
|
56
|
+
expanded = $bindable(false),
|
|
57
|
+
leading,
|
|
58
|
+
children,
|
|
59
|
+
searchLabel = '',
|
|
60
|
+
viewMode = $bindable('table'),
|
|
61
|
+
showViewSwitch = false,
|
|
62
|
+
primaryActionLabel = '',
|
|
63
|
+
onPrimaryAction,
|
|
64
|
+
onviewmodechange,
|
|
65
|
+
onsearch,
|
|
66
|
+
onfilterchange,
|
|
67
|
+
onclearfilters,
|
|
68
|
+
class: className = '',
|
|
69
|
+
...restProps
|
|
70
|
+
}: {
|
|
71
|
+
searchable?: boolean
|
|
72
|
+
searchPlaceholder?: string
|
|
73
|
+
searchValue?: string
|
|
74
|
+
filterFields?: FilterFieldDef[]
|
|
75
|
+
filterValues?: Record<string, unknown>
|
|
76
|
+
expanded?: boolean
|
|
77
|
+
leading?: Snippet
|
|
78
|
+
children?: Snippet
|
|
79
|
+
searchLabel?: string
|
|
80
|
+
viewMode?: 'table' | 'card'
|
|
81
|
+
showViewSwitch?: boolean
|
|
82
|
+
primaryActionLabel?: string
|
|
83
|
+
onPrimaryAction?: () => void
|
|
84
|
+
onviewmodechange?: (mode: 'table' | 'card') => void
|
|
85
|
+
/** 点击查询或原生 Enter 提交;读取当前 searchValue/filterValues 一次查询。 */
|
|
86
|
+
onsearch?: (search: string) => void
|
|
87
|
+
/** 草稿字段变化通知;此时不应发起业务查询。 */
|
|
88
|
+
onfilterchange?: (filters: Record<string, unknown>) => void
|
|
89
|
+
onclearfilters?: () => void
|
|
90
|
+
class?: string
|
|
91
|
+
} & DataAttributes = $props()
|
|
92
|
+
|
|
93
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
94
|
+
const toolbarId = $props.id()
|
|
95
|
+
const filterControl = getFormControlSizeClasses('sm')
|
|
96
|
+
|
|
97
|
+
// 条件数量保持可感知,false 和 0 同样是有效草稿值。
|
|
98
|
+
const activeFilterCount = $derived(Object.values(filterValues).filter(v => v !== undefined && v !== '' && v !== null).length)
|
|
99
|
+
|
|
100
|
+
const dateLikeTypes = new Set(['date', 'datetime-local', 'datetime', 'month', 'week'])
|
|
101
|
+
const numberLikeTypes = new Set(['number', 'integer'])
|
|
102
|
+
|
|
103
|
+
function resolveText(text: string | (() => string) | undefined): string {
|
|
104
|
+
if (!text)
|
|
105
|
+
return ''
|
|
106
|
+
return typeof text === 'function' ? text() : text
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function normalizeType(type: string): string {
|
|
110
|
+
return type.trim().toLowerCase()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function isBooleanField(field: FilterFieldDef): boolean {
|
|
114
|
+
const t = normalizeType(field.type)
|
|
115
|
+
return t === 'boolean' || t === 'switch' || t === 'toggle'
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function isDateRangeField(field: FilterFieldDef): boolean {
|
|
119
|
+
const t = normalizeType(field.type)
|
|
120
|
+
return t === 'date-range' || t === 'daterange'
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function isDateField(field: FilterFieldDef): boolean {
|
|
124
|
+
return dateLikeTypes.has(normalizeType(field.type))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function isNumberField(field: FilterFieldDef): boolean {
|
|
128
|
+
return numberLikeTypes.has(normalizeType(field.type))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function resolveOptions(options?: FilterFieldDef['options']): Array<{ label: string, value: string | number | boolean }> {
|
|
132
|
+
if (!options)
|
|
133
|
+
return []
|
|
134
|
+
return typeof options === 'function' ? options() : options
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function handleFilterChange(fieldId: string, value: unknown) {
|
|
138
|
+
filterValues = { ...filterValues, [fieldId]: value }
|
|
139
|
+
onfilterchange?.(filterValues)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function handleFilterPatch(partial: Record<string, unknown>) {
|
|
143
|
+
filterValues = { ...filterValues, ...partial }
|
|
144
|
+
onfilterchange?.(filterValues)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** 输入法候选确认不触发原生隐式查询。 */
|
|
148
|
+
function preventComposingSubmit(event: KeyboardEvent) {
|
|
149
|
+
if (event.key === 'Enter' && event.isComposing)
|
|
150
|
+
event.preventDefault()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function handleReset() {
|
|
154
|
+
searchValue = ''
|
|
155
|
+
filterValues = {}
|
|
156
|
+
onclearfilters?.()
|
|
157
|
+
}
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
{#snippet search()}
|
|
161
|
+
<div class='min-w-0 w-full'>
|
|
162
|
+
<FormField label={searchLabel || searchPlaceholder || uiM('toolbar_search')} class='w-full [&>label]:sr-only'>
|
|
163
|
+
<Input
|
|
164
|
+
type='search'
|
|
165
|
+
size='sm'
|
|
166
|
+
placeholder={searchPlaceholder || uiM('crud_search_placeholder')}
|
|
167
|
+
class='min-w-0 shadow-none'
|
|
168
|
+
bind:value={searchValue}
|
|
169
|
+
onkeydown={preventComposingSubmit}
|
|
170
|
+
autocomplete='off'
|
|
171
|
+
/>
|
|
172
|
+
</FormField>
|
|
173
|
+
</div>
|
|
174
|
+
{/snippet}
|
|
175
|
+
|
|
176
|
+
{#snippet fields()}
|
|
177
|
+
<FormLayout columns={2} class='hai-table-toolbar__filters'>
|
|
178
|
+
{#each filterFields as field (field.id)}
|
|
179
|
+
{@const fieldPlaceholder = resolveText(field.placeholder)}
|
|
180
|
+
{@const opts = resolveOptions(field.options)}
|
|
181
|
+
{@const controlId = `${toolbarId}-${field.id}`}
|
|
182
|
+
<FormField label={resolveText(field.label)} for={controlId} colSpan={isDateRangeField(field) ? 2 : 1}>
|
|
183
|
+
{#if isDateRangeField(field)}
|
|
184
|
+
{@const startKey = field.startKey ?? `${field.id}Start`}
|
|
185
|
+
{@const endKey = field.endKey ?? `${field.id}End`}
|
|
186
|
+
<div class='grid min-w-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2'>
|
|
187
|
+
<input id={controlId} type='date' class='{filterControl.control} min-w-0 w-full rounded-lg border border-base-content/15 bg-base-100 outline-none focus:border-primary/50 focus:ring-2 focus:ring-primary/10' aria-label={fieldPlaceholder || uiM('crud_filter_from')} max={String(filterValues[endKey] ?? '') || undefined} value={String(filterValues[startKey] ?? '')} onchange={event => handleFilterPatch({ [startKey]: event.currentTarget.value })} />
|
|
188
|
+
<span class='text-sm text-base-content/40' aria-hidden='true'>–</span>
|
|
189
|
+
<input type='date' class='{filterControl.control} min-w-0 w-full rounded-lg border border-base-content/15 bg-base-100 outline-none focus:border-primary/50 focus:ring-2 focus:ring-primary/10' aria-label={uiM('crud_filter_to')} min={String(filterValues[startKey] ?? '') || undefined} value={String(filterValues[endKey] ?? '')} onchange={event => handleFilterPatch({ [endKey]: event.currentTarget.value })} />
|
|
190
|
+
</div>
|
|
191
|
+
{:else if isBooleanField(field)}
|
|
192
|
+
<select id={controlId} class='select select-sm {filterControl.control} min-w-0 w-full border-base-content/20 bg-base-100 shadow-none' value={String(filterValues[field.id] ?? '')} onchange={event => handleFilterChange(field.id, event.currentTarget.value)}>
|
|
193
|
+
<option value=''>{uiM('crud_filter_all')}</option>
|
|
194
|
+
<option value='true'>{uiM('crud_filter_yes')}</option>
|
|
195
|
+
<option value='false'>{uiM('crud_filter_no')}</option>
|
|
196
|
+
</select>
|
|
197
|
+
{:else if isDateField(field)}
|
|
198
|
+
<input id={controlId} onkeydown={preventComposingSubmit} type='date' class='{filterControl.control} min-w-0 w-full rounded-lg border border-base-content/15 bg-base-100 outline-none focus:border-primary/50 focus:ring-2 focus:ring-primary/10' aria-label={fieldPlaceholder || resolveText(field.label)} value={String(filterValues[field.id] ?? '')} oninput={event => handleFilterChange(field.id, event.currentTarget.value)} />
|
|
199
|
+
{:else if isNumberField(field)}
|
|
200
|
+
<Input id={controlId} onkeydown={preventComposingSubmit} type='number' size='sm' min={field.min} max={field.max} step={field.step} class='min-w-0 shadow-none' placeholder={fieldPlaceholder || resolveText(field.label)} value={String(filterValues[field.id] ?? '')} oninput={event => handleFilterChange(field.id, event.currentTarget.value)} />
|
|
201
|
+
{:else if opts.length > 0}
|
|
202
|
+
<select id={controlId} class='select select-sm {filterControl.control} min-w-0 w-full border-base-content/20 bg-base-100 shadow-none' value={String(filterValues[field.id] ?? '')} onchange={event => handleFilterChange(field.id, event.currentTarget.value)}>
|
|
203
|
+
<option value=''>{uiM('crud_filter_all')}</option>
|
|
204
|
+
{#each opts as option (String(option.value))}<option value={String(option.value)}>{option.label}</option>{/each}
|
|
205
|
+
</select>
|
|
206
|
+
{:else}
|
|
207
|
+
<Input id={controlId} onkeydown={preventComposingSubmit} type='text' size='sm' class='min-w-0 shadow-none' placeholder={fieldPlaceholder || resolveText(field.label)} value={String(filterValues[field.id] ?? '')} oninput={event => handleFilterChange(field.id, event.currentTarget.value)} />
|
|
208
|
+
{/if}
|
|
209
|
+
</FormField>
|
|
210
|
+
{/each}
|
|
211
|
+
</FormLayout>
|
|
212
|
+
{/snippet}
|
|
213
|
+
|
|
214
|
+
{#snippet buttons()}
|
|
215
|
+
<Button type='submit' variant='outline' size='sm' submitHint>{uiM('crud_query')}</Button>
|
|
216
|
+
{/snippet}
|
|
217
|
+
|
|
218
|
+
<div {...dataAttributes} class={`hai-table-toolbar min-w-0 ${className}`}>
|
|
219
|
+
{#if leading || children || showViewSwitch || (primaryActionLabel && onPrimaryAction)}
|
|
220
|
+
<div class='mb-3 flex min-w-0 flex-wrap items-center justify-between gap-2'>
|
|
221
|
+
<div class='min-w-0 flex-1'>{#if leading}{@render leading()}{/if}</div>
|
|
222
|
+
<div class='flex max-w-full flex-wrap items-center gap-2'>
|
|
223
|
+
{#if showViewSwitch}
|
|
224
|
+
<div class='join' role='group' aria-label={uiM('toolbar_view_switch')}>
|
|
225
|
+
{#each ['table', 'card'] as mode (mode)}
|
|
226
|
+
<button type='button' class='btn btn-sm join-item' class:text-primary={viewMode === mode} aria-label={uiM(mode === 'table' ? 'toolbar_view_table' : 'toolbar_view_card')} aria-pressed={viewMode === mode} onclick={() => {
|
|
227
|
+
viewMode = mode === 'table' ? 'table' : 'card'
|
|
228
|
+
onviewmodechange?.(viewMode)
|
|
229
|
+
}}><span class={mode === 'table' ? 'icon-[tabler--table] size-4' : 'icon-[tabler--layout-grid] size-4'} aria-hidden='true'></span></button>
|
|
230
|
+
{/each}
|
|
231
|
+
</div>
|
|
232
|
+
{/if}
|
|
233
|
+
{#if children}{@render children()}{/if}
|
|
234
|
+
{#if primaryActionLabel && onPrimaryAction}<Button size='sm' variant='primary' onclick={onPrimaryAction}><span class='icon-[tabler--plus] size-4' aria-hidden='true'></span>{primaryActionLabel}</Button>{/if}
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
{/if}
|
|
238
|
+
<form oninvalidcapture={() => { expanded = true }} onsubmit={(event) => {
|
|
239
|
+
event.preventDefault()
|
|
240
|
+
onsearch?.(searchValue)
|
|
241
|
+
}}>
|
|
242
|
+
<FilterBar bind:expanded activeCount={activeFilterCount} leading={searchable ? search : undefined} actions={buttons} onreset={handleReset} children={filterFields.length > 0 ? fields : undefined} />
|
|
243
|
+
</form>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
<style>
|
|
247
|
+
.hai-table-toolbar {
|
|
248
|
+
container: hai-list-query / inline-size;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters) {
|
|
252
|
+
--hai-form-gap: 1rem 1.25rem;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters .hai-form-grid[data-columns]) {
|
|
256
|
+
grid-template-columns: minmax(0, 1fr);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters .hai-form-grid[data-columns] > .hai-form-field[data-col-span='2']) {
|
|
260
|
+
grid-column: auto;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters .field-content) {
|
|
264
|
+
display: flex;
|
|
265
|
+
flex-direction: column;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@container hai-list-query (min-width: 28rem) {
|
|
269
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters .hai-form-grid[data-columns]) {
|
|
270
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters .hai-form-grid[data-columns] > .hai-form-field[data-col-span='2']) {
|
|
274
|
+
grid-column: span 2;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
@container hai-list-query (min-width: 44rem) {
|
|
279
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters .hai-form-grid[data-columns]) {
|
|
280
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
@container hai-list-query (min-width: 64rem) {
|
|
285
|
+
.hai-table-toolbar :global(.hai-table-toolbar__filters .hai-form-grid[data-columns]) {
|
|
286
|
+
grid-template-columns: repeat(6, minmax(0, 1fr));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
</style>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* 工具栏过滤字段的局部视图;值由宿主条件查询消费。
|
|
5
|
+
*
|
|
6
|
+
* @example 模块内部上下文
|
|
7
|
+
* ```ts
|
|
8
|
+
* const example: FilterFieldDef = { id: 'active', label: '状态', type: 'boolean' }
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
type FilterFieldDef = {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string | (() => string);
|
|
14
|
+
type: string;
|
|
15
|
+
placeholder?: string | (() => string);
|
|
16
|
+
startKey?: string;
|
|
17
|
+
endKey?: string;
|
|
18
|
+
min?: number;
|
|
19
|
+
max?: number;
|
|
20
|
+
step?: number;
|
|
21
|
+
options?: Array<{
|
|
22
|
+
label: string;
|
|
23
|
+
value: string | number | boolean;
|
|
24
|
+
}> | (() => Array<{
|
|
25
|
+
label: string;
|
|
26
|
+
value: string | number | boolean;
|
|
27
|
+
}>);
|
|
28
|
+
};
|
|
29
|
+
type $$ComponentProps = {
|
|
30
|
+
searchable?: boolean;
|
|
31
|
+
searchPlaceholder?: string;
|
|
32
|
+
searchValue?: string;
|
|
33
|
+
filterFields?: FilterFieldDef[];
|
|
34
|
+
filterValues?: Record<string, unknown>;
|
|
35
|
+
expanded?: boolean;
|
|
36
|
+
leading?: Snippet;
|
|
37
|
+
children?: Snippet;
|
|
38
|
+
searchLabel?: string;
|
|
39
|
+
viewMode?: 'table' | 'card';
|
|
40
|
+
showViewSwitch?: boolean;
|
|
41
|
+
primaryActionLabel?: string;
|
|
42
|
+
onPrimaryAction?: () => void;
|
|
43
|
+
onviewmodechange?: (mode: 'table' | 'card') => void;
|
|
44
|
+
/** 点击查询或原生 Enter 提交;读取当前 searchValue/filterValues 一次查询。 */
|
|
45
|
+
onsearch?: (search: string) => void;
|
|
46
|
+
/** 草稿字段变化通知;此时不应发起业务查询。 */
|
|
47
|
+
onfilterchange?: (filters: Record<string, unknown>) => void;
|
|
48
|
+
onclearfilters?: () => void;
|
|
49
|
+
class?: string;
|
|
50
|
+
} & DataAttributes;
|
|
51
|
+
/**
|
|
52
|
+
* TableToolbar
|
|
53
|
+
* 统一列表搜索与筛选;条件由查询按钮或原生 Enter 提交,排序由 DataTable 列头承接。
|
|
54
|
+
*
|
|
55
|
+
* 使用 Svelte 5 Runes ($props, $state)
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { mount, unmount } from 'svelte'
|
|
60
|
+
* import type { ComponentProps } from 'svelte'
|
|
61
|
+
* import { TableToolbar } from '@h-ai/ui'
|
|
62
|
+
* const props: ComponentProps<typeof TableToolbar> = { searchable: true, filterFields: [{ id: 'active', label: '状态', type: 'boolean' }], filterValues: { active: true } }
|
|
63
|
+
* const component = mount(TableToolbar, { target: document.body, props })
|
|
64
|
+
* await unmount(component)
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare const TableToolbar: import("svelte").Component<$$ComponentProps, {}, "expanded" | "searchValue" | "filterValues" | "viewMode">;
|
|
68
|
+
type TableToolbar = ReturnType<typeof TableToolbar>;
|
|
69
|
+
export default TableToolbar;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component Tabs
|
|
3
3
|
标签页组件,支持 line/card/pills 三种样式。
|
|
4
|
+
|
|
5
|
+
@example
|
|
6
|
+
```ts
|
|
7
|
+
import { mount, unmount } from 'svelte'
|
|
8
|
+
import type { ComponentProps } from 'svelte'
|
|
9
|
+
import { Tabs } from '@h-ai/ui'
|
|
10
|
+
const props: ComponentProps<typeof Tabs> = { items: [{ key: 'profile', label: '资料' }, { key: 'security', label: '安全' }], active: 'profile', lazy: true }
|
|
11
|
+
const component = mount(Tabs, { target: document.body, props })
|
|
12
|
+
await unmount(component)
|
|
13
|
+
```
|
|
4
14
|
-->
|
|
5
15
|
<script lang='ts'>
|
|
6
|
-
import type { TabsProps } from '../../types.js'
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
16
|
+
import type { DataAttributes, TabsProps } from '../../types.js'
|
|
17
|
+
import { SvelteSet } from 'svelte/reactivity'
|
|
18
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
9
19
|
|
|
10
20
|
let {
|
|
11
21
|
items,
|
|
@@ -14,16 +24,38 @@
|
|
|
14
24
|
type = 'line',
|
|
15
25
|
class: className = '',
|
|
16
26
|
onchange,
|
|
27
|
+
onactivate,
|
|
28
|
+
lazy = false,
|
|
17
29
|
children,
|
|
18
|
-
|
|
30
|
+
...restProps
|
|
31
|
+
}: TabsProps & DataAttributes = $props()
|
|
32
|
+
|
|
33
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
34
|
+
const tabsId = $props.id()
|
|
35
|
+
let tablist = $state<HTMLDivElement>()
|
|
36
|
+
// 已激活过的页签集合,用于惰性挂载(不预加载不可见页签)。
|
|
37
|
+
const activatedKeys = new SvelteSet<string>()
|
|
38
|
+
|
|
39
|
+
// 初始或选项变化后选中可用页签,避免激活禁用项或已删除项。
|
|
40
|
+
$effect(() => {
|
|
41
|
+
if (!items.some(item => item.key === active && !item.disabled)) {
|
|
42
|
+
active = items.find(item => !item.disabled)?.key ?? ''
|
|
43
|
+
}
|
|
44
|
+
})
|
|
19
45
|
|
|
20
|
-
//
|
|
46
|
+
// 记录激活过的页签,并在首次激活时回调一次,供惰性加载对应内容。
|
|
21
47
|
$effect(() => {
|
|
22
|
-
if (
|
|
23
|
-
active
|
|
48
|
+
if (active && !activatedKeys.has(active)) {
|
|
49
|
+
activatedKeys.add(active)
|
|
50
|
+
onactivate?.(active)
|
|
24
51
|
}
|
|
25
52
|
})
|
|
26
53
|
|
|
54
|
+
/** 指定页签是否已激活过;非惰性模式下恒为 true(内容全部预挂载)。 */
|
|
55
|
+
function isActivated(key: string): boolean {
|
|
56
|
+
return !lazy || activatedKeys.has(key)
|
|
57
|
+
}
|
|
58
|
+
|
|
27
59
|
const typeMap = {
|
|
28
60
|
line: 'tabs-border',
|
|
29
61
|
card: 'tabs-box',
|
|
@@ -44,6 +76,7 @@
|
|
|
44
76
|
const tabsClass = $derived(
|
|
45
77
|
cn(
|
|
46
78
|
'tabs',
|
|
79
|
+
'max-w-full flex-nowrap overflow-x-auto',
|
|
47
80
|
typeMap[type],
|
|
48
81
|
sizeMap[size],
|
|
49
82
|
className,
|
|
@@ -51,29 +84,66 @@
|
|
|
51
84
|
)
|
|
52
85
|
|
|
53
86
|
function handleSelect(key: string) {
|
|
87
|
+
if (active === key)
|
|
88
|
+
return
|
|
54
89
|
active = key
|
|
55
90
|
onchange?.(key)
|
|
56
91
|
}
|
|
92
|
+
|
|
93
|
+
// 自动激活模式:方向键移动焦点并选择,跳过禁用项且支持首尾循环。
|
|
94
|
+
function handleKeydown(event: KeyboardEvent, key: string) {
|
|
95
|
+
const enabled = items.filter(item => !item.disabled)
|
|
96
|
+
if (!enabled.length)
|
|
97
|
+
return
|
|
98
|
+
const index = enabled.findIndex(item => item.key === key)
|
|
99
|
+
const rtl = getComputedStyle(event.currentTarget as HTMLElement).direction === 'rtl'
|
|
100
|
+
let next: number
|
|
101
|
+
switch (event.key) {
|
|
102
|
+
case 'ArrowRight':
|
|
103
|
+
next = index + (rtl ? -1 : 1)
|
|
104
|
+
break
|
|
105
|
+
case 'ArrowLeft':
|
|
106
|
+
next = index + (rtl ? 1 : -1)
|
|
107
|
+
break
|
|
108
|
+
case 'Home':
|
|
109
|
+
next = 0
|
|
110
|
+
break
|
|
111
|
+
case 'End':
|
|
112
|
+
next = enabled.length - 1
|
|
113
|
+
break
|
|
114
|
+
default: return
|
|
115
|
+
}
|
|
116
|
+
event.preventDefault()
|
|
117
|
+
const selected = enabled[(next + enabled.length) % enabled.length]
|
|
118
|
+
handleSelect(selected.key)
|
|
119
|
+
tablist?.querySelectorAll<HTMLButtonElement>('[role="tab"]:not(:disabled)')[(next + enabled.length) % enabled.length]?.focus()
|
|
120
|
+
}
|
|
57
121
|
</script>
|
|
58
122
|
|
|
59
|
-
<div role='tablist' class={tabsClass}>
|
|
60
|
-
{#each items as item}
|
|
61
|
-
<
|
|
123
|
+
<div {...dataAttributes} bind:this={tablist} role='tablist' class={tabsClass}>
|
|
124
|
+
{#each items as item (item.key)}
|
|
125
|
+
<button
|
|
126
|
+
type='button'
|
|
127
|
+
id={`${tabsId}-${encodeURIComponent(item.key)}`}
|
|
62
128
|
role='tab'
|
|
63
|
-
|
|
129
|
+
aria-selected={active === item.key}
|
|
130
|
+
aria-controls={children ? `${tabsId}-panel` : undefined}
|
|
131
|
+
tabindex={active === item.key ? 0 : -1}
|
|
132
|
+
class={cn('tab shrink-0', active === item.key && 'tab-active')}
|
|
64
133
|
disabled={item.disabled}
|
|
65
134
|
onclick={() => handleSelect(item.key)}
|
|
135
|
+
onkeydown={event => handleKeydown(event, item.key)}
|
|
66
136
|
>
|
|
67
137
|
{#if item.icon}
|
|
68
138
|
<span class='mr-1'>{item.icon}</span>
|
|
69
139
|
{/if}
|
|
70
140
|
{item.label}
|
|
71
|
-
</
|
|
141
|
+
</button>
|
|
72
142
|
{/each}
|
|
73
143
|
</div>
|
|
74
144
|
|
|
75
145
|
{#if children}
|
|
76
|
-
<div class='py-4'>
|
|
77
|
-
{@render children()}
|
|
146
|
+
<div id={`${tabsId}-panel`} role='tabpanel' aria-labelledby={active ? `${tabsId}-${encodeURIComponent(active)}` : undefined} tabindex='0' class='min-w-0 py-4'>
|
|
147
|
+
{@render children({ active, isActivated })}
|
|
78
148
|
</div>
|
|
79
149
|
{/if}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import type { TabsProps } from '../../types.js';
|
|
1
|
+
import type { DataAttributes, TabsProps } from '../../types.js';
|
|
2
|
+
type $$ComponentProps = TabsProps & DataAttributes;
|
|
2
3
|
/**
|
|
3
4
|
* Tabs
|
|
4
5
|
* 标签页组件,支持 line/card/pills 三种样式。
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { mount, unmount } from 'svelte'
|
|
10
|
+
* import type { ComponentProps } from 'svelte'
|
|
11
|
+
* import { Tabs } from '@h-ai/ui'
|
|
12
|
+
* const props: ComponentProps<typeof Tabs> = { items: [{ key: 'profile', label: '资料' }, { key: 'security', label: '安全' }], active: 'profile', lazy: true }
|
|
13
|
+
* const component = mount(Tabs, { target: document.body, props })
|
|
14
|
+
* await unmount(component)
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
6
|
-
declare const Tabs: import("svelte").Component
|
|
17
|
+
declare const Tabs: import("svelte").Component<$$ComponentProps, {}, "active">;
|
|
7
18
|
type Tabs = ReturnType<typeof Tabs>;
|
|
8
19
|
export default Tabs;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
+
@component TagInput
|
|
2
3
|
=============================================================================
|
|
3
4
|
@h-ai/ui - TagInput 组件
|
|
4
5
|
=============================================================================
|
|
@@ -6,11 +7,22 @@
|
|
|
6
7
|
|
|
7
8
|
使用 Svelte 5 Runes ($props, $state, $bindable)
|
|
8
9
|
=============================================================================
|
|
10
|
+
|
|
11
|
+
@example
|
|
12
|
+
```ts
|
|
13
|
+
import { mount, unmount } from 'svelte'
|
|
14
|
+
import type { ComponentProps } from 'svelte'
|
|
15
|
+
import { TagInput } from '@h-ai/ui'
|
|
16
|
+
const props: ComponentProps<typeof TagInput> = { tags: ['Svelte'], maxTags: 5 }
|
|
17
|
+
const component = mount(TagInput, { target: document.body, props })
|
|
18
|
+
await unmount(component)
|
|
19
|
+
```
|
|
9
20
|
-->
|
|
10
21
|
<script lang='ts'>
|
|
11
|
-
import type { TagInputProps } from '../../types.js'
|
|
22
|
+
import type { DataAttributes, TagInputProps } from '../../types.js'
|
|
12
23
|
import { uiM } from '../../messages.js'
|
|
13
|
-
import { cn,
|
|
24
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
25
|
+
import { getFormControlSizeClasses } from '../control-size.js'
|
|
14
26
|
import BareInput from '../primitives/BareInput.svelte'
|
|
15
27
|
import Tag from '../primitives/Tag.svelte'
|
|
16
28
|
|
|
@@ -23,8 +35,11 @@
|
|
|
23
35
|
size = 'md',
|
|
24
36
|
class: className = '',
|
|
25
37
|
onchange,
|
|
26
|
-
|
|
38
|
+
...restProps
|
|
39
|
+
}: TagInputProps & DataAttributes = $props()
|
|
27
40
|
|
|
41
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
42
|
+
const sizeClasses = $derived(getFormControlSizeClasses(size))
|
|
28
43
|
let inputValue = $state('')
|
|
29
44
|
let inputElement = $state<HTMLInputElement | undefined>(undefined)
|
|
30
45
|
|
|
@@ -32,9 +47,10 @@
|
|
|
32
47
|
|
|
33
48
|
const containerClass = $derived(
|
|
34
49
|
cn(
|
|
35
|
-
'
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
'flex h-auto w-full flex-wrap items-center gap-1 rounded-lg border border-base-content/15 bg-base-100 py-1 transition-[border-color,box-shadow] duration-150 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/10',
|
|
51
|
+
sizeClasses.minHeight,
|
|
52
|
+
sizeClasses.spacing,
|
|
53
|
+
disabled && 'cursor-not-allowed opacity-50',
|
|
38
54
|
className,
|
|
39
55
|
),
|
|
40
56
|
)
|
|
@@ -77,32 +93,34 @@
|
|
|
77
93
|
}
|
|
78
94
|
</script>
|
|
79
95
|
|
|
80
|
-
<div
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
<div {...dataAttributes} class='fieldset w-full' data-form-wide>
|
|
97
|
+
<div
|
|
98
|
+
class={containerClass}
|
|
99
|
+
onclick={() => inputElement?.focus()}
|
|
100
|
+
onkeydown={e => e.key === 'Enter' && inputElement?.focus()}
|
|
101
|
+
role='textbox'
|
|
102
|
+
tabindex='-1'
|
|
103
|
+
>
|
|
104
|
+
{#each tags as tag, index (index)}
|
|
105
|
+
<Tag
|
|
106
|
+
text={tag}
|
|
107
|
+
size='sm'
|
|
108
|
+
closable={!disabled}
|
|
109
|
+
onclose={() => removeTag(index)}
|
|
110
|
+
/>
|
|
111
|
+
{/each}
|
|
95
112
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
{#if canAddMore && !disabled}
|
|
114
|
+
<BareInput
|
|
115
|
+
type='text'
|
|
116
|
+
class='flex-1 min-w-[100px] bg-transparent border-none outline-none'
|
|
117
|
+
bind:value={inputValue}
|
|
118
|
+
bind:inputRef={inputElement}
|
|
119
|
+
placeholder={displayPlaceholder}
|
|
120
|
+
{disabled}
|
|
121
|
+
onkeydown={handleKeydown}
|
|
122
|
+
onblur={handleBlur}
|
|
123
|
+
/>
|
|
124
|
+
{/if}
|
|
125
|
+
</div>
|
|
108
126
|
</div>
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
import type { TagInputProps } from '../../types.js';
|
|
2
|
-
|
|
1
|
+
import type { DataAttributes, TagInputProps } from '../../types.js';
|
|
2
|
+
type $$ComponentProps = TagInputProps & DataAttributes;
|
|
3
|
+
/**
|
|
4
|
+
* TagInput
|
|
5
|
+
* =============================================================================
|
|
6
|
+
* @h-ai/ui - TagInput 组件
|
|
7
|
+
* =============================================================================
|
|
8
|
+
* 标签输入框组件
|
|
9
|
+
*
|
|
10
|
+
* 使用 Svelte 5 Runes ($props, $state, $bindable)
|
|
11
|
+
* =============================================================================
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { mount, unmount } from 'svelte'
|
|
16
|
+
* import type { ComponentProps } from 'svelte'
|
|
17
|
+
* import { TagInput } from '@h-ai/ui'
|
|
18
|
+
* const props: ComponentProps<typeof TagInput> = { tags: ['Svelte'], maxTags: 5 }
|
|
19
|
+
* const component = mount(TagInput, { target: document.body, props })
|
|
20
|
+
* await unmount(component)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const TagInput: import("svelte").Component<$$ComponentProps, {}, "tags">;
|
|
3
24
|
type TagInput = ReturnType<typeof TagInput>;
|
|
4
25
|
export default TagInput;
|