@veltra/desktop 1.3.2 → 1.3.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/components/action/action-group.vue.d.ts +2 -2
- package/dist/components/action/action.vue.d.ts +3 -1
- package/dist/components/action/index.d.ts +3 -2
- package/dist/components/action/style.d.ts +2 -1
- package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -1
- package/dist/components/auto-complete/index.d.ts +2 -1
- package/dist/components/auto-complete/style.d.ts +4 -1
- package/dist/components/auto-complete/use-keyboard.js +1 -1
- package/dist/components/auto-complete/use-keyboard.js.map +1 -1
- package/dist/components/badge/badge.vue.d.ts +2 -1
- package/dist/components/badge/index.d.ts +2 -1
- package/dist/components/batch-edit/batch-edit.vue.d.ts +3 -1
- package/dist/components/batch-edit/helper.d.ts +1 -0
- package/dist/components/batch-edit/index.d.ts +3 -2
- package/dist/components/batch-edit/style.d.ts +5 -1
- package/dist/components/batch-edit/use-features.js +1 -1
- package/dist/components/batch-edit/use-features.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.vue.d.ts +2 -1
- package/dist/components/breadcrumb/index.d.ts +2 -1
- package/dist/components/button/button-group.vue.d.ts +2 -1
- package/dist/components/button/button.vue.d.ts +2 -1
- package/dist/components/button/index.d.ts +3 -2
- package/dist/components/button/style.d.ts +1 -1
- package/dist/components/calendar/calendar.vue.d.ts +2 -1
- package/dist/components/calendar/index.d.ts +2 -1
- package/dist/components/card/card-action.vue.d.ts +2 -1
- package/dist/components/card/card-content.vue.d.ts +2 -1
- package/dist/components/card/card-cover.vue.d.ts +2 -1
- package/dist/components/card/card-header.vue.d.ts +1 -1
- package/dist/components/card/card.vue.d.ts +2 -1
- package/dist/components/card/index.d.ts +6 -5
- package/dist/components/cascade/cascade.vue.d.ts +3 -2
- package/dist/components/cascade/index.d.ts +2 -1
- package/dist/components/cascade/style.d.ts +3 -1
- package/dist/components/check-tag/check-tag.vue.d.ts +2 -1
- package/dist/components/check-tag/index.d.ts +2 -1
- package/dist/components/checkbox/checkbox-button.vue.d.ts +2 -1
- package/dist/components/checkbox/checkbox.vue.d.ts +2 -1
- package/dist/components/checkbox/index.d.ts +3 -2
- package/dist/components/checkbox/style.d.ts +1 -1
- package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -1
- package/dist/components/checkbox-group/index.d.ts +2 -1
- package/dist/components/checkbox-group/style.d.ts +1 -1
- package/dist/components/code-editor/code-editor.vue.d.ts +2 -1
- package/dist/components/code-editor/index.d.ts +2 -1
- package/dist/components/code-editor/langs/spel/language.js +2 -2
- package/dist/components/code-editor/langs/spel/language.js.map +1 -1
- package/dist/components/code-editor/style.d.ts +1 -1
- package/dist/components/collapse/collapse-item.vue.d.ts +4 -3
- package/dist/components/collapse/collapse.vue.d.ts +2 -1
- package/dist/components/collapse/index.d.ts +3 -2
- package/dist/components/condition-editor/condition-editor.vue.d.ts +3 -1
- package/dist/components/condition-editor/core/evaluator.d.ts +1 -0
- package/dist/components/condition-editor/index.d.ts +3 -2
- package/dist/components/condition-editor/style.d.ts +2 -1
- package/dist/components/contextmenu/api.d.ts +1 -0
- package/dist/components/contextmenu/contextmenu.vue.d.ts +2 -1
- package/dist/components/contextmenu/index.d.ts +3 -2
- package/dist/components/contextmenu/style.d.ts +2 -1
- package/dist/components/date-panel/date-panel.vue.d.ts +2 -1
- package/dist/components/date-panel/index.d.ts +2 -1
- package/dist/components/date-picker/date-picker.vue.d.ts +2 -1
- package/dist/components/date-picker/index.d.ts +2 -1
- package/dist/components/date-picker/style.d.ts +2 -1
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -1
- package/dist/components/date-range-picker/index.d.ts +2 -1
- package/dist/components/date-range-picker/style.d.ts +1 -1
- package/dist/components/dialog/dialog.vue.d.ts +5 -2
- package/dist/components/dialog/index.d.ts +2 -1
- package/dist/components/dialog/style.d.ts +1 -1
- package/dist/components/drawer/drawer.vue.d.ts +3 -1
- package/dist/components/drawer/index.d.ts +2 -1
- package/dist/components/drawer/style.d.ts +1 -1
- package/dist/components/dropdown/dropdown.vue.d.ts +6 -2
- package/dist/components/dropdown/index.d.ts +2 -1
- package/dist/components/dropdown/style.d.ts +1 -1
- package/dist/components/dual-nav/dual-nav.vue.d.ts +2 -1
- package/dist/components/dual-nav/index.d.ts +2 -1
- package/dist/components/dual-nav/style.d.ts +1 -1
- package/dist/components/empty/empty.vue.d.ts +2 -1
- package/dist/components/empty/index.d.ts +2 -1
- package/dist/components/expression-editor/expression-editor.vue.d.ts +3 -1
- package/dist/components/expression-editor/index.d.ts +2 -1
- package/dist/components/file-picker/file-picker.js +6 -3
- package/dist/components/file-picker/file-picker.js.map +1 -1
- package/dist/components/file-picker/file-picker.vue.d.ts +2 -1
- package/dist/components/file-picker/index.d.ts +2 -1
- package/dist/components/file-viewer/file-viewer.js +2 -2
- package/dist/components/file-viewer/file-viewer.js.map +1 -1
- package/dist/components/file-viewer/file-viewer.vue.d.ts +1 -2
- package/dist/components/file-viewer/helper.js +4 -4
- package/dist/components/file-viewer/helper.js.map +1 -1
- package/dist/components/file-viewer/index.d.ts +2 -1
- package/dist/components/float-button/float-button.vue.d.ts +2 -1
- package/dist/components/float-button/index.d.ts +2 -1
- package/dist/components/float-button/style.d.ts +1 -1
- package/dist/components/form/form.vue.d.ts +2 -1
- package/dist/components/form/index.d.ts +2 -1
- package/dist/components/form-item/form-item.vue.d.ts +4 -2
- package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form-item/index.d.ts +2 -1
- package/dist/components/gantt-chart/gantt-chart.vue.d.ts +2 -1
- package/dist/components/gantt-chart/index.d.ts +2 -1
- package/dist/components/grid/grid-item.vue.d.ts +2 -1
- package/dist/components/grid/grid.vue.d.ts +3 -1
- package/dist/components/grid/index.d.ts +3 -2
- package/dist/components/grid/use-responsive.js +2 -1
- package/dist/components/grid/use-responsive.js.map +1 -1
- package/dist/components/grid-input/grid-input.vue.d.ts +3 -1
- package/dist/components/grid-input/index.d.ts +2 -1
- package/dist/components/group-input/group-input.vue.d.ts +4 -3
- package/dist/components/group-input/index.d.ts +2 -1
- package/dist/components/group-input/style.d.ts +1 -1
- package/dist/components/group-nav/group-nav.vue.d.ts +1 -2
- package/dist/components/group-nav/index.d.ts +2 -1
- package/dist/components/icon/icon.vue.d.ts +2 -1
- package/dist/components/icon/index.d.ts +2 -1
- package/dist/components/index.d.ts +168 -92
- package/dist/components/index.js +5 -5
- package/dist/components/input/index.d.ts +2 -1
- package/dist/components/input/input.vue.d.ts +6 -5
- package/dist/components/input/style.d.ts +1 -1
- package/dist/components/kbd/kbd.vue.d.ts +1 -1
- package/dist/components/layout/index.d.ts +2 -1
- package/dist/components/layout/layout.vue.d.ts +2 -1
- package/dist/components/list/index.d.ts +3 -2
- package/dist/components/list/list-item.vue.d.ts +1 -1
- package/dist/components/list/list.vue.d.ts +2 -1
- package/dist/components/list/style.d.ts +1 -1
- package/dist/components/loading/directive.d.ts +0 -1
- package/dist/components/loading/index.d.ts +3 -2
- package/dist/components/loading/loading.vue.d.ts +3 -1
- package/dist/components/loading/style.d.ts +1 -1
- package/dist/components/message/index.d.ts +3 -2
- package/dist/components/message/message.d.ts +1 -0
- package/dist/components/message/message.vue.d.ts +3 -1
- package/dist/components/message-confirm/index.d.ts +3 -2
- package/dist/components/message-confirm/message-confirm-box.js +39 -0
- package/dist/components/message-confirm/message-confirm-box.js.map +1 -0
- package/dist/components/message-confirm/message-confirm.d.ts +5 -7
- package/dist/components/message-confirm/message-confirm.js +32 -46
- package/dist/components/message-confirm/message-confirm.js.map +1 -1
- package/dist/components/message-confirm/message-confirm.vue.d.ts +8 -4
- package/dist/components/message-confirm/message-confirm2.js +98 -23
- package/dist/components/message-confirm/message-confirm2.js.map +1 -1
- package/dist/components/message-confirm/style2.css +9 -9
- package/dist/components/multi-select/index.d.ts +2 -1
- package/dist/components/multi-select/multi-select.vue.d.ts +8 -7
- package/dist/components/multi-select/style.d.ts +5 -1
- package/dist/components/multi-tree-select/index.d.ts +2 -1
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +2 -2
- package/dist/components/multi-tree-select/style.d.ts +6 -1
- package/dist/components/nav/index.d.ts +4 -3
- package/dist/components/nav/nav-item.vue.d.ts +2 -1
- package/dist/components/nav/nav-sub.vue.d.ts +2 -1
- package/dist/components/nav/nav.vue.d.ts +2 -1
- package/dist/components/node-render/index.d.ts +2 -1
- package/dist/components/node-render/node-render.d.ts +1 -2
- package/dist/components/notification/index.d.ts +3 -8
- package/dist/components/notification/notification-box.js +130 -0
- package/dist/components/notification/notification-box.js.map +1 -0
- package/dist/components/notification/notification.d.ts +8 -0
- package/dist/components/notification/notification.js +62 -84
- package/dist/components/notification/notification.js.map +1 -1
- package/dist/components/notification/notification.vue.d.ts +10 -5
- package/dist/components/notification/notification2.js +134 -0
- package/dist/components/notification/notification2.js.map +1 -0
- package/dist/components/notification/style2.css +62 -32
- package/dist/components/number/index.d.ts +2 -1
- package/dist/components/number/number.vue.d.ts +2 -1
- package/dist/components/number-input/index.d.ts +2 -1
- package/dist/components/number-input/number-input.js +2 -1
- package/dist/components/number-input/number-input.js.map +1 -1
- package/dist/components/number-input/number-input.vue.d.ts +4 -2
- package/dist/components/number-input/style.d.ts +2 -1
- package/dist/components/number-range-input/index.d.ts +2 -1
- package/dist/components/number-range-input/number-range-input.js +4 -2
- package/dist/components/number-range-input/number-range-input.js.map +1 -1
- package/dist/components/number-range-input/number-range-input.vue.d.ts +2 -1
- package/dist/components/number-range-input/style.d.ts +1 -1
- package/dist/components/paginator/index.d.ts +2 -1
- package/dist/components/paginator/paginator.vue.d.ts +2 -1
- package/dist/components/paginator/style.d.ts +2 -1
- package/dist/components/palette/index.d.ts +2 -1
- package/dist/components/palette/palette-sv.js +4 -2
- package/dist/components/palette/palette-sv.js.map +1 -1
- package/dist/components/palette/palette.vue.d.ts +2 -1
- package/dist/components/palette/style.d.ts +2 -1
- package/dist/components/password-input/index.d.ts +2 -1
- package/dist/components/password-input/password-input.vue.d.ts +2 -1
- package/dist/components/password-input/style.d.ts +1 -1
- package/dist/components/pop-confirm/index.d.ts +2 -1
- package/dist/components/pop-confirm/pop-confirm.vue.d.ts +4 -2
- package/dist/components/pop-confirm/style.d.ts +1 -1
- package/dist/components/progress/index.d.ts +2 -1
- package/dist/components/progress/progress.vue.d.ts +4 -3
- package/dist/components/progress-nodes/index.d.ts +2 -1
- package/dist/components/progress-nodes/progress-nodes.js +2 -1
- package/dist/components/progress-nodes/progress-nodes.js.map +1 -1
- package/dist/components/progress-nodes/progress-nodes.vue.d.ts +8 -7
- package/dist/components/radio/index.d.ts +2 -1
- package/dist/components/radio/radio.vue.d.ts +2 -1
- package/dist/components/radio/style.d.ts +1 -1
- package/dist/components/radio-group/index.d.ts +2 -1
- package/dist/components/radio-group/radio-group.vue.d.ts +2 -1
- package/dist/components/radio-group/style.d.ts +1 -1
- package/dist/components/rich-text-editor/index.d.ts +2 -1
- package/dist/components/rich-text-editor/rich-text-editor.js +2 -1
- package/dist/components/rich-text-editor/rich-text-editor.js.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +3 -1
- package/dist/components/rich-text-editor/toolbar.js +2 -1
- package/dist/components/rich-text-editor/toolbar.js.map +1 -1
- package/dist/components/scroll/index.d.ts +2 -1
- package/dist/components/scroll/scroll.vue.d.ts +5 -2
- package/dist/components/select/index.d.ts +2 -1
- package/dist/components/select/select.vue.d.ts +5 -2
- package/dist/components/select/style.d.ts +3 -1
- package/dist/components/slider/index.d.ts +2 -1
- package/dist/components/slider/slider.vue.d.ts +4 -3
- package/dist/components/steps/index.d.ts +2 -1
- package/dist/components/steps/steps.vue.d.ts +4 -3
- package/dist/components/switch/index.d.ts +2 -1
- package/dist/components/switch/switch.vue.d.ts +2 -1
- package/dist/components/table/index.d.ts +3 -2
- package/dist/components/table/node/col.d.ts +1 -1
- package/dist/components/table/node/row.d.ts +0 -1
- package/dist/components/table/style.d.ts +3 -1
- package/dist/components/table/table-row.js +2 -1
- package/dist/components/table/table-row.js.map +1 -1
- package/dist/components/table/table.vue.d.ts +3 -1
- package/dist/components/table/use-columns.d.ts +3 -0
- package/dist/components/table/use-columns.js +2 -1
- package/dist/components/table/use-columns.js.map +1 -1
- package/dist/components/table-editor/index.d.ts +2 -1
- package/dist/components/table-editor/style.d.ts +2 -1
- package/dist/components/table-editor/table-editor.vue.d.ts +2 -1
- package/dist/components/tabs/index.d.ts +4 -3
- package/dist/components/tabs/style.d.ts +2 -1
- package/dist/components/tabs/tabs-horizontal.vue.d.ts +3 -2
- package/dist/components/tabs/tabs-vertical.vue.d.ts +3 -2
- package/dist/components/tabs/tabs.vue.d.ts +3 -2
- package/dist/components/tag/index.d.ts +2 -1
- package/dist/components/tag/tag.vue.d.ts +2 -1
- package/dist/components/text/index.d.ts +2 -1
- package/dist/components/text/text.vue.d.ts +2 -1
- package/dist/components/textarea/index.d.ts +2 -1
- package/dist/components/textarea/style.d.ts +1 -1
- package/dist/components/textarea/textarea.js +4 -2
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/textarea/textarea.vue.d.ts +2 -1
- package/dist/components/theme/index.d.ts +2 -1
- package/dist/components/theme/style.d.ts +5 -1
- package/dist/components/theme/theme.vue.d.ts +2 -1
- package/dist/components/tip/index.d.ts +2 -1
- package/dist/components/tip/tip.vue.d.ts +4 -2
- package/dist/components/tree/di.d.ts +2 -0
- package/dist/components/tree/index.d.ts +2 -1
- package/dist/components/tree/style.d.ts +1 -1
- package/dist/components/tree/tree.vue.d.ts +3 -1
- package/dist/components/tree-select/index.d.ts +2 -1
- package/dist/components/tree-select/style.d.ts +3 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +5 -3
- package/dist/components/watermark/index.d.ts +2 -1
- package/dist/components/watermark/watermark.vue.d.ts +2 -1
- package/dist/index.d.ts +97 -98
- package/dist/index.js +3 -3
- package/dist/install.d.ts +1 -1
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +13 -4
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_commands@6.10.4/node_modules/@codemirror/commands/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +3 -2
- package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-html@6.4.11/node_modules/@codemirror/lang-html/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.1/node_modules/@codemirror/lang-markdown/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js +31 -5
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js +5 -3
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js +3 -2
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js +3 -2
- package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js +30 -7
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js +11 -5
- package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js +3 -2
- package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_css@1.3.4/node_modules/@lezer/css/dist/index.js +20 -2
- package/dist/node_modules/.bun/@lezer_css@1.3.4/node_modules/@lezer/css/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js +15 -2
- package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js +42 -3
- package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js +23 -2
- package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_lr@1.4.10/node_modules/@lezer/lr/dist/index.js +1 -1
- package/dist/node_modules/.bun/@lezer_markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js +39 -29
- package/dist/node_modules/.bun/@lezer_markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js +3 -2
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -1
- package/dist/style.d.ts +39 -1
- package/dist/types/action.d.ts +0 -1
- package/dist/types/animation.d.ts +0 -1
- package/dist/types/auto-complete.d.ts +0 -1
- package/dist/types/badge.d.ts +0 -1
- package/dist/types/batch-edit.d.ts +18 -13
- package/dist/types/breadcrumb.d.ts +0 -1
- package/dist/types/button.d.ts +0 -1
- package/dist/types/calendar.d.ts +0 -1
- package/dist/types/card.d.ts +0 -1
- package/dist/types/cascade.d.ts +0 -1
- package/dist/types/check-tag.d.ts +0 -1
- package/dist/types/checkbox-group.d.ts +0 -1
- package/dist/types/checkbox.d.ts +0 -1
- package/dist/types/code-editor.d.ts +0 -1
- package/dist/types/collapse.d.ts +0 -1
- package/dist/types/condition-editor.d.ts +0 -1
- package/dist/types/contextmenu.d.ts +0 -1
- package/dist/types/css-transition.d.ts +0 -1
- package/dist/types/date-panel.d.ts +0 -1
- package/dist/types/date-picker.d.ts +0 -1
- package/dist/types/date-range-picker.d.ts +0 -1
- package/dist/types/dialog.d.ts +0 -1
- package/dist/types/drawer.d.ts +0 -1
- package/dist/types/dropdown.d.ts +2 -2
- package/dist/types/dual-nav.d.ts +0 -1
- package/dist/types/empty.d.ts +0 -1
- package/dist/types/expression-editor.d.ts +0 -1
- package/dist/types/file-picker.d.ts +0 -1
- package/dist/types/file-viewer.d.ts +0 -1
- package/dist/types/float-button.d.ts +0 -1
- package/dist/types/form-item.d.ts +0 -1
- package/dist/types/form.d.ts +0 -1
- package/dist/types/grid-input.d.ts +0 -1
- package/dist/types/grid.d.ts +1 -2
- package/dist/types/group-input.d.ts +0 -1
- package/dist/types/group-nav.d.ts +0 -1
- package/dist/types/index.d.ts +4 -6
- package/dist/types/input.d.ts +0 -1
- package/dist/types/layout.d.ts +0 -1
- package/dist/types/list.d.ts +0 -1
- package/dist/types/loading.d.ts +0 -1
- package/dist/types/message-confirm.d.ts +48 -5
- package/dist/types/message.d.ts +3 -2
- package/dist/types/multi-auto-complete.d.ts +0 -1
- package/dist/types/multi-select.d.ts +0 -1
- package/dist/types/multi-tree-select.d.ts +0 -1
- package/dist/types/nav.d.ts +0 -1
- package/dist/types/node-render.d.ts +0 -1
- package/dist/types/notification.d.ts +67 -17
- package/dist/types/number-input.d.ts +0 -1
- package/dist/types/number-range-input.d.ts +0 -1
- package/dist/types/paginator.d.ts +0 -1
- package/dist/types/palette.d.ts +0 -1
- package/dist/types/password-input.d.ts +0 -1
- package/dist/types/pop-confirm.d.ts +0 -1
- package/dist/types/pop.d.ts +0 -1
- package/dist/types/progress-nodes.d.ts +0 -1
- package/dist/types/progress.d.ts +0 -1
- package/dist/types/quick-batch-edit.d.ts +0 -1
- package/dist/types/radio-group.d.ts +0 -1
- package/dist/types/radio.d.ts +0 -1
- package/dist/types/rich-text-editor.d.ts +0 -1
- package/dist/types/scroll.d.ts +11 -6
- package/dist/types/select.d.ts +0 -1
- package/dist/types/slider.d.ts +0 -1
- package/dist/types/steps.d.ts +0 -1
- package/dist/types/switch.d.ts +0 -1
- package/dist/types/table-editor.d.ts +0 -1
- package/dist/types/table.d.ts +0 -1
- package/dist/types/tabs.d.ts +2 -2
- package/dist/types/tag.d.ts +0 -1
- package/dist/types/text-editor.d.ts +0 -1
- package/dist/types/textarea.d.ts +0 -1
- package/dist/types/theme.d.ts +0 -1
- package/dist/types/tip.d.ts +0 -1
- package/dist/types/tree-select.d.ts +0 -1
- package/dist/types/tree.d.ts +0 -1
- package/dist/types/watermark.d.ts +0 -1
- package/package.json +19 -19
- package/src/components/message-confirm/index.ts +1 -1
- package/src/components/message-confirm/message-confirm-box.vue +36 -0
- package/src/components/message-confirm/message-confirm.ts +113 -21
- package/src/components/message-confirm/message-confirm.vue +30 -37
- package/src/components/message-confirm/style.scss +10 -12
- package/src/components/notification/index.ts +1 -143
- package/src/components/notification/notification-box.vue +150 -0
- package/src/components/notification/notification.ts +142 -0
- package/src/components/notification/notification.vue +40 -66
- package/src/components/notification/style.scss +65 -38
- package/src/types/message-confirm.ts +52 -3
- package/src/types/notification.ts +71 -15
- package/dist/components/notification/index.js +0 -140
- package/dist/components/notification/index.js.map +0 -1
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./progress-nodes.vue.js";
|
|
2
|
+
export { _default as UProgressNodes };
|
|
@@ -89,7 +89,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
89
89
|
return o(node).get(labelKey.value);
|
|
90
90
|
}
|
|
91
91
|
function handleClick(node, index) {
|
|
92
|
-
|
|
92
|
+
const value = o(node).get(valueKey.value);
|
|
93
|
+
emit("update:modelValue", value);
|
|
93
94
|
emit("click", node, index);
|
|
94
95
|
}
|
|
95
96
|
function toCssSize(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-nodes.js","names":[],"sources":["../../../src/components/progress-nodes/progress-nodes.vue"],"sourcesContent":["<template>\n <div ref=\"container\" :class=\"className\" :style=\"containerStyle\" @scroll=\"checkScroll\">\n <ul :class=\"cls.e('list')\">\n <li\n v-for=\"(node, index) in nodes\"\n :key=\"node.key ?? index\"\n :class=\"[\n cls.e('item'),\n bem.is('checked', isChecked(node, index)),\n bem.is('active', isActive(node))\n ]\"\n @click=\"handleClick(node, index)\"\n >\n <div :class=\"cls.e('node')\">\n <!-- 虚线连接 -->\n <div v-if=\"index !== nodes.length - 1\" :class=\"cls.e('link')\"></div>\n\n <!-- 节点圆点 -->\n <span :class=\"cls.e('dot')\">\n <slot name=\"icon\" :node=\"node\" :index=\"index\" />\n </span>\n </div>\n\n <div :class=\"cls.e('label')\">\n <slot :node=\"node\" :index=\"index\">\n {{ getLabel(node) }}\n </slot>\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { o } from '@cat-kit/core'\nimport { useDrag, useResizeObserver } from '@veltra/compositions'\nimport { bem, fieldKey } from '@veltra/utils'\nimport { computed, shallowRef, toRefs, useTemplateRef, watch, nextTick } from 'vue'\n\nimport type { ProgressNodesProps, ProgressNodesEmits } from '../../types'\n\ndefineOptions({ name: 'UProgressNodes' })\n\nconst props = withDefaults(defineProps<ProgressNodesProps>(), {\n colorType: 'primary',\n labelKey: 'label',\n valueKey: 'value'\n})\n\nconst emit = defineEmits<ProgressNodesEmits>()\n\nconst labelKey = computed(() => fieldKey(props.labelKey, 'label'))\nconst valueKey = computed(() => fieldKey(props.valueKey, 'value'))\n\nconst { nodes } = toRefs(props)\n\nconst cls = bem('progress-nodes')\nconst containerRef = useTemplateRef('container')\nconst isDragging = shallowRef(false)\nconst isScrollable = shallowRef(false)\nconst showMaskStart = shallowRef(false)\nconst showMaskEnd = shallowRef(false)\n\nconst className = computed(() => [\n cls.b,\n cls.m(props.colorType),\n bem.is('scrollable', isScrollable.value),\n bem.is('dragging', isDragging.value),\n bem.is('mask-start', showMaskStart.value),\n bem.is('mask-end', showMaskEnd.value)\n])\n\nconst containerStyle = computed(() => {\n const style: Record<string, string> = {}\n const maxWidth = toCssSize(props.maxWidth)\n if (maxWidth) style.maxWidth = maxWidth\n return style\n})\n\nlet startScrollLeft = 0\n\nuseDrag({\n target: containerRef,\n onDragStart() {\n if (!isScrollable.value) return\n const container = containerRef.value\n if (!container) return\n isDragging.value = true\n startScrollLeft = container.scrollLeft\n },\n onDrag({ x }) {\n if (!isScrollable.value) return\n const container = containerRef.value\n if (!container) return\n container.scrollLeft = startScrollLeft - x\n },\n onDragEnd() {\n isDragging.value = false\n }\n})\n\nuseResizeObserver({ targets: containerRef, onResize: checkScroll })\n\nwatch(\n nodes,\n () => {\n nextTick(checkScroll)\n },\n { deep: true }\n)\n\nfunction checkScroll() {\n const container = containerRef.value\n if (!container) return\n\n const { scrollLeft, scrollWidth, clientWidth } = container\n isScrollable.value = scrollWidth > clientWidth + 1\n showMaskStart.value = scrollLeft > 0\n showMaskEnd.value = scrollLeft + clientWidth < scrollWidth - 1\n}\n\nfunction isChecked(node: Record<string, any>, index: number) {\n return props.check?.(node, index) ?? false\n}\n\nfunction isActive(node: Record<string, any>) {\n const value = o(node).get(valueKey.value)\n return props.modelValue === value\n}\n\nfunction getLabel(node: Record<string, any>) {\n return o(node).get(labelKey.value)\n}\n\nfunction handleClick(node: Record<string, any>, index: number) {\n const value = o(node).get(valueKey.value)\n emit('update:modelValue', value)\n emit('click', node, index)\n}\n\nfunction toCssSize(value?: number | string) {\n if (value === undefined) return undefined\n return typeof value === 'number' ? `${value}px` : value\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAMd,MAAM,OAAO;EAEb,MAAM,WAAW,eAAe,SAAS,MAAM,UAAU,OAAO,CAAC;EACjE,MAAM,WAAW,eAAe,SAAS,MAAM,UAAU,OAAO,CAAC;EAEjE,MAAM,EAAE,UAAU,OAAO,KAAK;EAE9B,MAAM,MAAM,IAAI,gBAAgB;EAChC,MAAM,eAAe,eAAe,WAAW;EAC/C,MAAM,aAAa,WAAW,KAAK;EACnC,MAAM,eAAe,WAAW,KAAK;EACrC,MAAM,gBAAgB,WAAW,KAAK;EACtC,MAAM,cAAc,WAAW,KAAK;EAEpC,MAAM,YAAY,eAAe;GAC/B,IAAI;GACJ,IAAI,EAAE,MAAM,SAAS;GACrB,IAAI,GAAG,cAAc,aAAa,KAAK;GACvC,IAAI,GAAG,YAAY,WAAW,KAAK;GACnC,IAAI,GAAG,cAAc,cAAc,KAAK;GACxC,IAAI,GAAG,YAAY,YAAY,KAAK;EACtC,CAAC;EAED,MAAM,iBAAiB,eAAe;GACpC,MAAM,QAAgC,CAAC;GACvC,MAAM,WAAW,UAAU,MAAM,QAAQ;GACzC,IAAI,UAAU,MAAM,WAAW;GAC/B,OAAO;EACT,CAAC;EAED,IAAI,kBAAkB;EAEtB,QAAQ;GACN,QAAQ;GACR,cAAc;IACZ,IAAI,CAAC,aAAa,OAAO;IACzB,MAAM,YAAY,aAAa;IAC/B,IAAI,CAAC,WAAW;IAChB,WAAW,QAAQ;IACnB,kBAAkB,UAAU;GAC9B;GACA,OAAO,EAAE,KAAK;IACZ,IAAI,CAAC,aAAa,OAAO;IACzB,MAAM,YAAY,aAAa;IAC/B,IAAI,CAAC,WAAW;IAChB,UAAU,aAAa,kBAAkB;GAC3C;GACA,YAAY;IACV,WAAW,QAAQ;GACrB;EACF,CAAC;EAED,kBAAkB;GAAE,SAAS;GAAc,UAAU;EAAY,CAAC;EAElE,MACE,aACM;GACJ,SAAS,WAAW;EACtB,GACA,EAAE,MAAM,KAAK,CACf;EAEA,SAAS,cAAc;GACrB,MAAM,YAAY,aAAa;GAC/B,IAAI,CAAC,WAAW;GAEhB,MAAM,EAAE,YAAY,aAAa,gBAAgB;GACjD,aAAa,QAAQ,cAAc,cAAc;GACjD,cAAc,QAAQ,aAAa;GACnC,YAAY,QAAQ,aAAa,cAAc,cAAc;EAC/D;EAEA,SAAS,UAAU,MAA2B,OAAe;GAC3D,OAAO,MAAM,QAAQ,MAAM,KAAK,KAAK;EACvC;EAEA,SAAS,SAAS,MAA2B;GAC3C,MAAM,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,SAAS,KAAK;GACxC,OAAO,MAAM,eAAe;EAC9B;EAEA,SAAS,SAAS,MAA2B;GAC3C,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,SAAS,KAAK;EACnC;EAEA,SAAS,YAAY,MAA2B,OAAe;
|
|
1
|
+
{"version":3,"file":"progress-nodes.js","names":[],"sources":["../../../src/components/progress-nodes/progress-nodes.vue"],"sourcesContent":["<template>\n <div ref=\"container\" :class=\"className\" :style=\"containerStyle\" @scroll=\"checkScroll\">\n <ul :class=\"cls.e('list')\">\n <li\n v-for=\"(node, index) in nodes\"\n :key=\"node.key ?? index\"\n :class=\"[\n cls.e('item'),\n bem.is('checked', isChecked(node, index)),\n bem.is('active', isActive(node))\n ]\"\n @click=\"handleClick(node, index)\"\n >\n <div :class=\"cls.e('node')\">\n <!-- 虚线连接 -->\n <div v-if=\"index !== nodes.length - 1\" :class=\"cls.e('link')\"></div>\n\n <!-- 节点圆点 -->\n <span :class=\"cls.e('dot')\">\n <slot name=\"icon\" :node=\"node\" :index=\"index\" />\n </span>\n </div>\n\n <div :class=\"cls.e('label')\">\n <slot :node=\"node\" :index=\"index\">\n {{ getLabel(node) }}\n </slot>\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { o } from '@cat-kit/core'\nimport { useDrag, useResizeObserver } from '@veltra/compositions'\nimport { bem, fieldKey } from '@veltra/utils'\nimport { computed, shallowRef, toRefs, useTemplateRef, watch, nextTick } from 'vue'\n\nimport type { ProgressNodesProps, ProgressNodesEmits } from '../../types'\n\ndefineOptions({ name: 'UProgressNodes' })\n\nconst props = withDefaults(defineProps<ProgressNodesProps>(), {\n colorType: 'primary',\n labelKey: 'label',\n valueKey: 'value'\n})\n\nconst emit = defineEmits<ProgressNodesEmits>()\n\nconst labelKey = computed(() => fieldKey(props.labelKey, 'label'))\nconst valueKey = computed(() => fieldKey(props.valueKey, 'value'))\n\nconst { nodes } = toRefs(props)\n\nconst cls = bem('progress-nodes')\nconst containerRef = useTemplateRef('container')\nconst isDragging = shallowRef(false)\nconst isScrollable = shallowRef(false)\nconst showMaskStart = shallowRef(false)\nconst showMaskEnd = shallowRef(false)\n\nconst className = computed(() => [\n cls.b,\n cls.m(props.colorType),\n bem.is('scrollable', isScrollable.value),\n bem.is('dragging', isDragging.value),\n bem.is('mask-start', showMaskStart.value),\n bem.is('mask-end', showMaskEnd.value)\n])\n\nconst containerStyle = computed(() => {\n const style: Record<string, string> = {}\n const maxWidth = toCssSize(props.maxWidth)\n if (maxWidth) style.maxWidth = maxWidth\n return style\n})\n\nlet startScrollLeft = 0\n\nuseDrag({\n target: containerRef,\n onDragStart() {\n if (!isScrollable.value) return\n const container = containerRef.value\n if (!container) return\n isDragging.value = true\n startScrollLeft = container.scrollLeft\n },\n onDrag({ x }) {\n if (!isScrollable.value) return\n const container = containerRef.value\n if (!container) return\n container.scrollLeft = startScrollLeft - x\n },\n onDragEnd() {\n isDragging.value = false\n }\n})\n\nuseResizeObserver({ targets: containerRef, onResize: checkScroll })\n\nwatch(\n nodes,\n () => {\n nextTick(checkScroll)\n },\n { deep: true }\n)\n\nfunction checkScroll() {\n const container = containerRef.value\n if (!container) return\n\n const { scrollLeft, scrollWidth, clientWidth } = container\n isScrollable.value = scrollWidth > clientWidth + 1\n showMaskStart.value = scrollLeft > 0\n showMaskEnd.value = scrollLeft + clientWidth < scrollWidth - 1\n}\n\nfunction isChecked(node: Record<string, any>, index: number) {\n return props.check?.(node, index) ?? false\n}\n\nfunction isActive(node: Record<string, any>) {\n const value = o(node).get(valueKey.value)\n return props.modelValue === value\n}\n\nfunction getLabel(node: Record<string, any>) {\n return o(node).get(labelKey.value)\n}\n\nfunction handleClick(node: Record<string, any>, index: number) {\n const value = o(node).get(valueKey.value)\n emit('update:modelValue', value)\n emit('click', node, index)\n}\n\nfunction toCssSize(value?: number | string) {\n if (value === undefined) return undefined\n return typeof value === 'number' ? `${value}px` : value\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAMd,MAAM,OAAO;EAEb,MAAM,WAAW,eAAe,SAAS,MAAM,UAAU,OAAO,CAAC;EACjE,MAAM,WAAW,eAAe,SAAS,MAAM,UAAU,OAAO,CAAC;EAEjE,MAAM,EAAE,UAAU,OAAO,KAAK;EAE9B,MAAM,MAAM,IAAI,gBAAgB;EAChC,MAAM,eAAe,eAAe,WAAW;EAC/C,MAAM,aAAa,WAAW,KAAK;EACnC,MAAM,eAAe,WAAW,KAAK;EACrC,MAAM,gBAAgB,WAAW,KAAK;EACtC,MAAM,cAAc,WAAW,KAAK;EAEpC,MAAM,YAAY,eAAe;GAC/B,IAAI;GACJ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AG,CAAC,EAAC,KAAA,CAAA,EAAA,GAAA,CACjB,WAAgD,KAAA,QAAA,QAAA;MAAvB;MAAc;;WAI3C,mBAIM,OAAA,EAJA,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA,EAAA,GAAA,CAChB,WAEO,KAAA,QAAA,WAAA;KAFM;KAAc;aAEpB,CAAA,gBAAA,gBADF,SAAS,IAAI,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,GAAA,IAAA,UAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ProgressNodesProps } from "../../types/progress-nodes.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/progress-nodes/progress-nodes.vue.d.ts
|
|
3
4
|
declare var __VLS_1: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
node: Record<string, any>;
|
|
6
|
+
index: number;
|
|
7
|
+
}, __VLS_3: {
|
|
8
|
+
node: Record<string, any>;
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
10
11
|
type __VLS_Slots = {} & {
|
|
11
12
|
icon?: (props: typeof __VLS_1) => any;
|
|
12
13
|
} & {
|
|
@@ -31,5 +32,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
31
32
|
};
|
|
32
33
|
};
|
|
33
34
|
//#endregion
|
|
34
|
-
export { _default };
|
|
35
|
+
export { _default as default };
|
|
35
36
|
//# sourceMappingURL=progress-nodes.vue.d.ts.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./radio.vue.js";
|
|
2
|
+
export { _default as URadio };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RadioProps } from "../../types/radio.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/radio/radio.vue.d.ts
|
|
3
4
|
type __VLS_Props = RadioProps;
|
|
4
5
|
type __VLS_ModelProps = {
|
|
@@ -26,5 +27,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
29
|
//#endregion
|
|
29
|
-
export { _default };
|
|
30
|
+
export { _default as default };
|
|
30
31
|
//# sourceMappingURL=radio.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import "@veltra/styles/transitions/zoom-in.scss";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./radio-group.vue.js";
|
|
2
|
+
export { _default as URadioGroup };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RadioGroupProps } from "../../types/radio-group.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/radio-group/radio-group.vue.d.ts
|
|
3
4
|
type __VLS_Props = RadioGroupProps;
|
|
4
5
|
type __VLS_ModelProps = {
|
|
@@ -21,5 +22,5 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
21
22
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
23
|
declare const _default: typeof __VLS_export;
|
|
23
24
|
//#endregion
|
|
24
|
-
export { _default };
|
|
25
|
+
export { _default as default };
|
|
25
26
|
//# sourceMappingURL=radio-group.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import "../radio/style.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./rich-text-editor.vue.js";
|
|
2
|
+
export { _default as URichTextEditor };
|
|
@@ -129,7 +129,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
129
129
|
if (model.value) setEditorContent(editorInstance, model.value);
|
|
130
130
|
cleanupFns.push(editorInstance.registerUpdateListener(({ editorState }) => {
|
|
131
131
|
editorState.read(() => {
|
|
132
|
-
|
|
132
|
+
const textContent = $getRoot().getTextContent();
|
|
133
|
+
showPlaceholder.value = textContent.trim().length === 0;
|
|
133
134
|
if (isComposing) return;
|
|
134
135
|
let value;
|
|
135
136
|
if (props.format === "json") value = JSON.stringify(editorState.toJSON());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-editor.js","names":[],"sources":["../../../src/components/rich-text-editor/rich-text-editor.vue"],"sourcesContent":["<template>\n <div :class=\"className\">\n <toolbar\n v-if=\"!isReadonly && toolbarItems.length > 0\"\n :editor=\"editor\"\n :toolbar=\"toolbarItems\"\n :disabled=\"isDisabled\"\n />\n <div :class=\"cls.e('content')\">\n <div\n ref=\"editorContainer\"\n :class=\"cls.e('editable')\"\n :contenteditable=\"!isDisabled && !isReadonly\"\n ></div>\n <div v-if=\"showPlaceholder\" :class=\"cls.e('placeholder')\">\n {{ placeholder }}\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { ToolbarItem } from '../../types'\n\nconst LEXICAL_THEME = {\n paragraph: 'u-rte-paragraph',\n heading: {\n h1: 'u-rte-h1',\n h2: 'u-rte-h2',\n h3: 'u-rte-h3',\n h4: 'u-rte-h4',\n h5: 'u-rte-h5',\n h6: 'u-rte-h6'\n },\n text: {\n bold: 'u-rte-bold',\n italic: 'u-rte-italic',\n underline: 'u-rte-underline',\n strikethrough: 'u-rte-strikethrough'\n },\n list: {\n ul: 'u-rte-ul',\n ol: 'u-rte-ol',\n listitem: 'u-rte-li',\n nested: { listitem: 'u-rte-li--nested' }\n },\n quote: 'u-rte-blockquote',\n\n link: 'u-rte-link',\n image: 'u-rte-image'\n}\n\nconst DEFAULT_TOOLBAR: ToolbarItem[] = [\n 'undo',\n 'redo',\n '|',\n 'heading',\n '|',\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n '|',\n 'bullet-list',\n 'ordered-list',\n '|',\n 'blockquote',\n '|',\n 'link'\n]\n</script>\n\n<script lang=\"ts\" setup>\nimport { registerHistory, createEmptyHistoryState } from '@lexical/history'\nimport { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html'\nimport { LinkNode, AutoLinkNode } from '@lexical/link'\nimport { ListNode, ListItemNode, registerList } from '@lexical/list'\nimport { registerRichText } from '@lexical/rich-text'\nimport { HeadingNode, QuoteNode } from '@lexical/rich-text'\nimport { useFormFallbackProps } from '@veltra/compositions'\nimport { bem } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { createEditor, $getRoot, $createParagraphNode, type LexicalEditor } from 'lexical'\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, useTemplateRef, watch } from 'vue'\n\nimport type { RichTextEditorProps } from '../../types'\nimport Toolbar from './toolbar.vue'\n\nconst props = withDefaults(defineProps<RichTextEditorProps>(), {\n disabled: undefined,\n readonly: undefined,\n format: 'html',\n toolbar: () => DEFAULT_TOOLBAR,\n placeholder: ''\n})\n\nconst model = defineModel<string>()\n\nconst cls = bem('rich-text-editor')\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props])\n\nconst isDisabled = computed(() => !!disabled.value)\nconst isReadonly = computed(() => !!readonly.value)\n\nconst className = computed<string[]>(() => {\n return [\n cls.b,\n cls.m(size.value),\n bem.is('disabled', isDisabled.value),\n bem.is('readonly', isReadonly.value)\n ]\n})\n\nconst toolbarItems = computed<ToolbarItem[]>(() => {\n return props.toolbar ?? DEFAULT_TOOLBAR\n})\n\nconst editorContainer = useTemplateRef('editorContainer')\nconst editor = shallowRef<LexicalEditor | null>(null)\nconst showPlaceholder = ref(true)\nlet isComposing = false\nlet cleanupFns: (() => void)[] = []\n\nfunction initEditor() {\n if (!editorContainer.value) return\n\n const editorInstance = createEditor({\n namespace: 'URichTextEditor',\n theme: LEXICAL_THEME,\n nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode],\n editable: !isDisabled.value && !isReadonly.value,\n onError: (error: Error) => {\n console.error('Lexical error:', error)\n }\n })\n\n editorInstance.setRootElement(editorContainer.value)\n\n // Register plugins\n cleanupFns.push(registerRichText(editorInstance))\n cleanupFns.push(registerList(editorInstance))\n cleanupFns.push(registerHistory(editorInstance, createEmptyHistoryState(), 300))\n\n // Set initial value\n if (model.value) {\n setEditorContent(editorInstance, model.value)\n }\n\n // Listen for content changes\n cleanupFns.push(\n editorInstance.registerUpdateListener(({ editorState }) => {\n editorState.read(\n () => {\n const root = $getRoot()\n const textContent = root.getTextContent()\n showPlaceholder.value = textContent.trim().length === 0\n\n if (isComposing) return\n\n let value: string\n if (props.format === 'json') {\n value = JSON.stringify(editorState.toJSON())\n } else {\n value = $generateHtmlFromNodes(editorInstance)\n }\n\n // Avoid circular updates: only emit if content really changed\n if (value !== model.value) {\n isComposing = true\n model.value = value\n // Use microtask to reset after Vue processes the update\n queueMicrotask(() => {\n isComposing = false\n })\n }\n },\n { editor: editorInstance }\n )\n })\n )\n\n // Composing event listeners for IME\n const rootElement = editorInstance.getRootElement()\n if (rootElement) {\n const onCompositionStart = () => {\n isComposing = true\n }\n const onCompositionEnd = () => {\n isComposing = false\n }\n rootElement.addEventListener('compositionstart', onCompositionStart)\n rootElement.addEventListener('compositionend', onCompositionEnd)\n cleanupFns.push(() => {\n rootElement.removeEventListener('compositionstart', onCompositionStart)\n rootElement.removeEventListener('compositionend', onCompositionEnd)\n })\n }\n\n editor.value = editorInstance\n}\n\nfunction setEditorContent(editorInstance: LexicalEditor, value: string) {\n editorInstance.update(() => {\n const root = $getRoot()\n root.clear()\n\n if (props.format === 'json') {\n try {\n const parsedState = editorInstance.parseEditorState(value)\n editorInstance.setEditorState(parsedState)\n } catch {\n // If JSON parse fails, treat as empty\n root.append($createParagraphNode())\n }\n } else {\n // HTML format\n const parser = new DOMParser()\n const dom = parser.parseFromString(value, 'text/html')\n const nodes = $generateNodesFromDOM(editorInstance, dom)\n root.append(...nodes)\n }\n })\n}\n\n// Watch external model changes\nwatch(model, (newVal) => {\n if (!editor.value || isComposing) return\n\n const editorInstance = editor.value\n\n // Compare current content to avoid circular updates\n editorInstance.read(() => {\n let currentValue: string\n if (props.format === 'json') {\n currentValue = JSON.stringify(editorInstance.getEditorState().toJSON())\n } else {\n currentValue = $generateHtmlFromNodes(editorInstance)\n }\n\n if (currentValue !== newVal) {\n isComposing = true\n setEditorContent(editorInstance, newVal ?? '')\n queueMicrotask(() => {\n isComposing = false\n })\n }\n })\n})\n\n// Watch disabled/readonly changes\nwatch([isDisabled, isReadonly], () => {\n if (editor.value) {\n editor.value.setEditable(!isDisabled.value && !isReadonly.value)\n }\n})\n\nonMounted(() => {\n initEditor()\n})\n\nonBeforeUnmount(() => {\n cleanupFns.forEach((fn) => fn())\n cleanupFns = []\n editor.value = null\n})\n</script>\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,gBAAgB;CACpB,WAAW;CACX,SAAS;EACP,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;EACR,WAAW;EACX,eAAe;CACjB;CACA,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,UAAU;EACV,QAAQ,EAAE,UAAU,mBAAmB;CACzC;CACA,OAAO;CAEP,MAAM;CACN,OAAO;AACT;AAEA,MAAM,kBAAiC;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBA,MAAM,QAAQ;EAQd,MAAM,QAAQ,SAAmB,SAAA,YAAC;EAElC,MAAM,MAAM,IAAI,kBAAkB;EAElC,MAAM,EAAE,cAAc,kBAAkB;EAExC,MAAM,EAAE,MAAM,UAAU,aAAa,qBAAqB,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;EAElF,MAAM,aAAa,eAAe,CAAC,CAAC,SAAS,KAAK;EAClD,MAAM,aAAa,eAAe,CAAC,CAAC,SAAS,KAAK;EAElD,MAAM,YAAY,eAAyB;GACzC,OAAO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E,CAAC;EAED,gBAAgB;GACd,WAAW;EACb,CAAC;EAED,sBAAsB;GACpB,WAAW,SAAS,OAAO,GAAG,CAAC;GAC/B,aAAa,CAAC;GACd,OAAO,QAAQ;EACjB,CAAC;;uBA1QC,mBAiBM,OAAA,EAjBA,OAAK,eAAE,UAAA,KAAS,EAAA,GAAA,CAAA,CAEX,WAAA,SAAc,aAAA,MAAa,SAAM,KAAA,UAAA,GAD1C,YAKE,aAAA;;IAHC,QAAQ,OAAA;IACR,SAAS,aAAA;IACT,UAAU,WAAA;;;;;2CAEb,mBASM,OAAA,EATA,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,SAAA,CAAA,EAAA,GAAA,CAChB,mBAIO,OAAA;aAHD;IAAJ,KAAI;IACH,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,UAAA,CAAA;IACZ,iBAAe,CAAG,WAAA,SAAU,CAAK,WAAA;6BAEzB,gBAAA,SAAA,UAAA,GAAX,mBAEM,OAAA;;IAFuB,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,aAAA,CAAA;sBACpC,QAAA,WAAW,GAAA,CAAA,KAAA,mBAAA,QAAA,IAAA,CAAA,GAAA,CAAA,CAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"rich-text-editor.js","names":[],"sources":["../../../src/components/rich-text-editor/rich-text-editor.vue"],"sourcesContent":["<template>\n <div :class=\"className\">\n <toolbar\n v-if=\"!isReadonly && toolbarItems.length > 0\"\n :editor=\"editor\"\n :toolbar=\"toolbarItems\"\n :disabled=\"isDisabled\"\n />\n <div :class=\"cls.e('content')\">\n <div\n ref=\"editorContainer\"\n :class=\"cls.e('editable')\"\n :contenteditable=\"!isDisabled && !isReadonly\"\n ></div>\n <div v-if=\"showPlaceholder\" :class=\"cls.e('placeholder')\">\n {{ placeholder }}\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { ToolbarItem } from '../../types'\n\nconst LEXICAL_THEME = {\n paragraph: 'u-rte-paragraph',\n heading: {\n h1: 'u-rte-h1',\n h2: 'u-rte-h2',\n h3: 'u-rte-h3',\n h4: 'u-rte-h4',\n h5: 'u-rte-h5',\n h6: 'u-rte-h6'\n },\n text: {\n bold: 'u-rte-bold',\n italic: 'u-rte-italic',\n underline: 'u-rte-underline',\n strikethrough: 'u-rte-strikethrough'\n },\n list: {\n ul: 'u-rte-ul',\n ol: 'u-rte-ol',\n listitem: 'u-rte-li',\n nested: { listitem: 'u-rte-li--nested' }\n },\n quote: 'u-rte-blockquote',\n\n link: 'u-rte-link',\n image: 'u-rte-image'\n}\n\nconst DEFAULT_TOOLBAR: ToolbarItem[] = [\n 'undo',\n 'redo',\n '|',\n 'heading',\n '|',\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n '|',\n 'bullet-list',\n 'ordered-list',\n '|',\n 'blockquote',\n '|',\n 'link'\n]\n</script>\n\n<script lang=\"ts\" setup>\nimport { registerHistory, createEmptyHistoryState } from '@lexical/history'\nimport { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html'\nimport { LinkNode, AutoLinkNode } from '@lexical/link'\nimport { ListNode, ListItemNode, registerList } from '@lexical/list'\nimport { registerRichText } from '@lexical/rich-text'\nimport { HeadingNode, QuoteNode } from '@lexical/rich-text'\nimport { useFormFallbackProps } from '@veltra/compositions'\nimport { bem } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { createEditor, $getRoot, $createParagraphNode, type LexicalEditor } from 'lexical'\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, useTemplateRef, watch } from 'vue'\n\nimport type { RichTextEditorProps } from '../../types'\nimport Toolbar from './toolbar.vue'\n\nconst props = withDefaults(defineProps<RichTextEditorProps>(), {\n disabled: undefined,\n readonly: undefined,\n format: 'html',\n toolbar: () => DEFAULT_TOOLBAR,\n placeholder: ''\n})\n\nconst model = defineModel<string>()\n\nconst cls = bem('rich-text-editor')\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props])\n\nconst isDisabled = computed(() => !!disabled.value)\nconst isReadonly = computed(() => !!readonly.value)\n\nconst className = computed<string[]>(() => {\n return [\n cls.b,\n cls.m(size.value),\n bem.is('disabled', isDisabled.value),\n bem.is('readonly', isReadonly.value)\n ]\n})\n\nconst toolbarItems = computed<ToolbarItem[]>(() => {\n return props.toolbar ?? DEFAULT_TOOLBAR\n})\n\nconst editorContainer = useTemplateRef('editorContainer')\nconst editor = shallowRef<LexicalEditor | null>(null)\nconst showPlaceholder = ref(true)\nlet isComposing = false\nlet cleanupFns: (() => void)[] = []\n\nfunction initEditor() {\n if (!editorContainer.value) return\n\n const editorInstance = createEditor({\n namespace: 'URichTextEditor',\n theme: LEXICAL_THEME,\n nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode],\n editable: !isDisabled.value && !isReadonly.value,\n onError: (error: Error) => {\n console.error('Lexical error:', error)\n }\n })\n\n editorInstance.setRootElement(editorContainer.value)\n\n // Register plugins\n cleanupFns.push(registerRichText(editorInstance))\n cleanupFns.push(registerList(editorInstance))\n cleanupFns.push(registerHistory(editorInstance, createEmptyHistoryState(), 300))\n\n // Set initial value\n if (model.value) {\n setEditorContent(editorInstance, model.value)\n }\n\n // Listen for content changes\n cleanupFns.push(\n editorInstance.registerUpdateListener(({ editorState }) => {\n editorState.read(\n () => {\n const root = $getRoot()\n const textContent = root.getTextContent()\n showPlaceholder.value = textContent.trim().length === 0\n\n if (isComposing) return\n\n let value: string\n if (props.format === 'json') {\n value = JSON.stringify(editorState.toJSON())\n } else {\n value = $generateHtmlFromNodes(editorInstance)\n }\n\n // Avoid circular updates: only emit if content really changed\n if (value !== model.value) {\n isComposing = true\n model.value = value\n // Use microtask to reset after Vue processes the update\n queueMicrotask(() => {\n isComposing = false\n })\n }\n },\n { editor: editorInstance }\n )\n })\n )\n\n // Composing event listeners for IME\n const rootElement = editorInstance.getRootElement()\n if (rootElement) {\n const onCompositionStart = () => {\n isComposing = true\n }\n const onCompositionEnd = () => {\n isComposing = false\n }\n rootElement.addEventListener('compositionstart', onCompositionStart)\n rootElement.addEventListener('compositionend', onCompositionEnd)\n cleanupFns.push(() => {\n rootElement.removeEventListener('compositionstart', onCompositionStart)\n rootElement.removeEventListener('compositionend', onCompositionEnd)\n })\n }\n\n editor.value = editorInstance\n}\n\nfunction setEditorContent(editorInstance: LexicalEditor, value: string) {\n editorInstance.update(() => {\n const root = $getRoot()\n root.clear()\n\n if (props.format === 'json') {\n try {\n const parsedState = editorInstance.parseEditorState(value)\n editorInstance.setEditorState(parsedState)\n } catch {\n // If JSON parse fails, treat as empty\n root.append($createParagraphNode())\n }\n } else {\n // HTML format\n const parser = new DOMParser()\n const dom = parser.parseFromString(value, 'text/html')\n const nodes = $generateNodesFromDOM(editorInstance, dom)\n root.append(...nodes)\n }\n })\n}\n\n// Watch external model changes\nwatch(model, (newVal) => {\n if (!editor.value || isComposing) return\n\n const editorInstance = editor.value\n\n // Compare current content to avoid circular updates\n editorInstance.read(() => {\n let currentValue: string\n if (props.format === 'json') {\n currentValue = JSON.stringify(editorInstance.getEditorState().toJSON())\n } else {\n currentValue = $generateHtmlFromNodes(editorInstance)\n }\n\n if (currentValue !== newVal) {\n isComposing = true\n setEditorContent(editorInstance, newVal ?? '')\n queueMicrotask(() => {\n isComposing = false\n })\n }\n })\n})\n\n// Watch disabled/readonly changes\nwatch([isDisabled, isReadonly], () => {\n if (editor.value) {\n editor.value.setEditable(!isDisabled.value && !isReadonly.value)\n }\n})\n\nonMounted(() => {\n initEditor()\n})\n\nonBeforeUnmount(() => {\n cleanupFns.forEach((fn) => fn())\n cleanupFns = []\n editor.value = null\n})\n</script>\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,gBAAgB;CACpB,WAAW;CACX,SAAS;EACP,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN;CACA,MAAM;EACJ,MAA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,gBAAA,SAAA,UAAA,GAAX,mBAEM,OAAA;;IAFuB,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,aAAA,CAAA;sBACpC,QAAA,WAAW,GAAA,CAAA,KAAA,mBAAA,QAAA,IAAA,CAAA,GAAA,CAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { RichTextEditorProps, RichTextFormat, ToolbarItem } from "../../types/rich-text-editor.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import "../../index.js";
|
|
2
4
|
//#region src/components/rich-text-editor/rich-text-editor.vue.d.ts
|
|
3
5
|
declare const _default: typeof __VLS_export;
|
|
4
6
|
declare const __VLS_export: import("vue").DefineComponent<RichTextEditorProps & {
|
|
@@ -17,5 +19,5 @@ declare const __VLS_export: import("vue").DefineComponent<RichTextEditorProps &
|
|
|
17
19
|
toolbar: ToolbarItem[];
|
|
18
20
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
21
|
//#endregion
|
|
20
|
-
export { _default };
|
|
22
|
+
export { _default as default };
|
|
21
23
|
//# sourceMappingURL=rich-text-editor.vue.d.ts.map
|
|
@@ -63,7 +63,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
63
63
|
isOrderedList.value = false;
|
|
64
64
|
}
|
|
65
65
|
isBlockquote.value = $isQuoteNode(element);
|
|
66
|
-
|
|
66
|
+
const parent = anchorNode.getParent();
|
|
67
|
+
isLink.value = $isLinkNode(parent);
|
|
67
68
|
}
|
|
68
69
|
watch(() => props.editor, (editorInstance) => {
|
|
69
70
|
if (editorInstance) setupListener(editorInstance);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.js","names":[],"sources":["../../../src/components/rich-text-editor/toolbar.vue"],"sourcesContent":["<template>\n <div :class=\"cls.e('toolbar')\">\n <template v-for=\"(item, index) in toolbar\" :key=\"index\">\n <div v-if=\"item === '|'\" :class=\"cls.e('separator')\"></div>\n\n <div v-else-if=\"item === 'heading'\" :class=\"[cls.e('toolbar-dropdown')]\">\n <select\n :class=\"[cls.e('heading-select'), { 'is-disabled': disabled }]\"\n :value=\"activeHeading\"\n :disabled=\"disabled\"\n @change=\"onHeadingChange\"\n >\n <option value=\"paragraph\">正文</option>\n <option value=\"h1\">Heading 1</option>\n <option value=\"h2\">Heading 2</option>\n <option value=\"h3\">Heading 3</option>\n <option value=\"h4\">Heading 4</option>\n <option value=\"h5\">Heading 5</option>\n <option value=\"h6\">Heading 6</option>\n </select>\n </div>\n\n <button\n v-else\n type=\"button\"\n :class=\"[\n cls.e('toolbar-btn'),\n { 'is-active': isActive(item) },\n { 'is-disabled': disabled }\n ]\"\n :disabled=\"disabled\"\n :title=\"getTitle(item)\"\n @click=\"onToolbarAction(item)\"\n >\n <span :class=\"cls.e('toolbar-icon')\" v-html=\"getIcon(item)\"></span>\n </button>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link'\nimport { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode } from '@lexical/list'\nimport { $createHeadingNode, $isHeadingNode, type HeadingTagType } from '@lexical/rich-text'\nimport { $isQuoteNode, $createQuoteNode } from '@lexical/rich-text'\nimport { $setBlocksType } from '@lexical/selection'\nimport { $getNearestNodeOfType } from '@lexical/utils'\nimport { bem } from '@veltra/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n FORMAT_TEXT_COMMAND,\n UNDO_COMMAND,\n REDO_COMMAND,\n type LexicalEditor,\n $createParagraphNode,\n type RangeSelection\n} from 'lexical'\nimport { ref, onBeforeUnmount, watch } from 'vue'\n\nimport type { ToolbarItem } from '../../types'\n\nconst props = defineProps<{\n editor: LexicalEditor | null\n toolbar: ToolbarItem[]\n disabled: boolean\n}>()\n\nconst cls = bem('rich-text-editor')\n\n// Active states\nconst isBold = ref(false)\nconst isItalic = ref(false)\nconst isUnderline = ref(false)\nconst isStrikethrough = ref(false)\nconst isLink = ref(false)\nconst isBulletList = ref(false)\nconst isOrderedList = ref(false)\nconst isBlockquote = ref(false)\nconst activeHeading = ref('paragraph')\n\nlet cleanupListener: (() => void) | null = null\n\nfunction setupListener(editorInstance: LexicalEditor) {\n cleanupListener?.()\n cleanupListener = editorInstance.registerUpdateListener(({ editorState }) => {\n editorState.read(\n () => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) return\n\n updateToolbarState(selection)\n },\n { editor: editorInstance }\n )\n })\n}\n\nfunction updateToolbarState(selection: RangeSelection) {\n isBold.value = selection.hasFormat('bold')\n isItalic.value = selection.hasFormat('italic')\n isUnderline.value = selection.hasFormat('underline')\n isStrikethrough.value = selection.hasFormat('strikethrough')\n\n // Check block type\n const anchorNode = selection.anchor.getNode()\n let element = anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow()\n\n if ($isHeadingNode(element)) {\n activeHeading.value = (element as any).getTag()\n } else {\n activeHeading.value = 'paragraph'\n }\n\n // Check list\n const parentList = $getNearestNodeOfType(anchorNode, ListNode)\n if (parentList) {\n const listType = (parentList as any).getListType()\n isBulletList.value = listType === 'bullet'\n isOrderedList.value = listType === 'number'\n } else {\n isBulletList.value = false\n isOrderedList.value = false\n }\n\n // Check blockquote\n isBlockquote.value = $isQuoteNode(element)\n\n // Check link\n const parent = anchorNode.getParent()\n isLink.value = $isLinkNode(parent)\n}\n\nwatch(\n () => props.editor,\n (editorInstance) => {\n if (editorInstance) {\n setupListener(editorInstance)\n }\n },\n { immediate: true }\n)\n\nfunction isActive(item: ToolbarItem): boolean {\n switch (item) {\n case 'bold':\n return isBold.value\n case 'italic':\n return isItalic.value\n case 'underline':\n return isUnderline.value\n case 'strikethrough':\n return isStrikethrough.value\n case 'bullet-list':\n return isBulletList.value\n case 'ordered-list':\n return isOrderedList.value\n case 'blockquote':\n return isBlockquote.value\n case 'link':\n return isLink.value\n default:\n return false\n }\n}\n\nfunction onToolbarAction(item: ToolbarItem) {\n const editorInstance = props.editor\n if (!editorInstance || props.disabled) return\n\n switch (item) {\n case 'bold':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')\n break\n case 'italic':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')\n break\n case 'underline':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')\n break\n case 'strikethrough':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')\n break\n case 'code':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'code')\n break\n case 'bullet-list':\n editorInstance.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)\n break\n case 'ordered-list':\n editorInstance.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)\n break\n case 'blockquote':\n editorInstance.update(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n if (isBlockquote.value) {\n $setBlocksType(selection, () => $createParagraphNode())\n } else {\n $setBlocksType(selection, () => $createQuoteNode())\n }\n }\n })\n break\n case 'link':\n toggleLink(editorInstance)\n break\n case 'undo':\n editorInstance.dispatchCommand(UNDO_COMMAND, undefined)\n break\n case 'redo':\n editorInstance.dispatchCommand(REDO_COMMAND, undefined)\n break\n }\n\n // Keep focus on editor\n editorInstance.focus()\n}\n\nfunction onHeadingChange(event: Event) {\n const editorInstance = props.editor\n if (!editorInstance || props.disabled) return\n\n const value = (event.target as HTMLSelectElement).value\n\n editorInstance.update(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n if (value === 'paragraph') {\n $setBlocksType(selection, () => $createParagraphNode())\n } else {\n $setBlocksType(selection, () => $createHeadingNode(value as HeadingTagType))\n }\n }\n })\n\n editorInstance.focus()\n}\n\nfunction toggleLink(editorInstance: LexicalEditor) {\n let shouldRemoveLink = false\n\n editorInstance.read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) return\n\n const parent = selection.anchor.getNode().getParent()\n shouldRemoveLink = $isLinkNode(parent)\n })\n\n if (shouldRemoveLink) {\n editorInstance.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n return\n }\n\n const url = prompt('请输入链接地址:', 'https://')\n if (url && url !== 'https://') {\n editorInstance.dispatchCommand(TOGGLE_LINK_COMMAND, url)\n }\n}\n\nfunction getTitle(item: ToolbarItem): string {\n const titles: Record<string, string> = {\n bold: '加粗',\n italic: '斜体',\n underline: '下划线',\n strikethrough: '删除线',\n code: '行内代码',\n 'bullet-list': '无序列表',\n 'ordered-list': '有序列表',\n blockquote: '引用',\n 'code-block': '代码块',\n link: '链接',\n undo: '撤销',\n redo: '重做'\n }\n return titles[item] ?? item\n}\n\nfunction getIcon(item: ToolbarItem): string {\n const icons: Record<string, string> = {\n bold: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/><path d=\"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/></svg>',\n italic:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/></svg>',\n underline:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/></svg>',\n strikethrough:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4H9a3 3 0 0 0-2.83 4\"/><path d=\"M14 12a4 4 0 0 1 0 8H6\"/><line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/></svg>',\n code: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"16 18 22 12 16 6\"/><polyline points=\"8 6 2 12 8 18\"/></svg>',\n 'bullet-list':\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"/><line x1=\"3\" y1=\"6\" x2=\"3.01\" y2=\"6\"/><line x1=\"3\" y1=\"12\" x2=\"3.01\" y2=\"12\"/><line x1=\"3\" y1=\"18\" x2=\"3.01\" y2=\"18\"/></svg>',\n 'ordered-list':\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1\"/></svg>',\n blockquote:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z\"/><path d=\"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z\"/></svg>',\n 'code-block':\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2\" y=\"3\" width=\"20\" height=\"18\" rx=\"2\"/><path d=\"m8 10-3 2 3 2\"/><path d=\"m16 10 3 2-3 2\"/><path d=\"m13 7-2 10\"/></svg>',\n link: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>',\n undo: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 7v6h6\"/><path d=\"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13\"/></svg>',\n redo: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 7v6h-6\"/><path d=\"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13\"/></svg>'\n }\n return icons[item] ?? ''\n}\n\nonBeforeUnmount(() =>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ACpB,CAAC;;uBAlTC,mBAoCM,OAAA,EApCA,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,SAAA,CAAA,EAAA,GAAA,EAAA,UAAA,IAAA,GAChB,mBAkCW,UAAA,MAAA,WAlCuB,QAAA,UAAhB,MAAM,UAAK;4DAAoB,MAAK,GAAA,CACzC,SAAI,OAAA,UAAA,GAAf,mBAA2D,OAAA;;KAAjC,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,WAAA,CAAA;mBAEtB,SAAI,aAAA,UAAA,GAApB,mBAeM,OAAA;;KAf+B,OAAK,eAAA,CAAG,MAAA,GAAA,CAAG,CAAC,EAAC,kBAAA,CAAA,CAAA;QAChD,mBAaS,UAAA;KAZN,OAAK,eAAA,CAAG,MAAA,GAAA,CAAG,CAAC,EAAC,gBAAA,GAAA,EAAA,eAAqC,QAAA,SAAQ,CAAA,CAAA;KAC1D,OAAO,cAAA;KACP,UAAU,QAAA;KACV,UAAQ;0XAYb,mBAaS,UAAA;;KAXP,MAAK;KACJ,OAAK,eAAA;MAAc,MAAA,GAAA,CAAG,CAAC,EAAC,aAAA;qBAA0C,SAAS,IAAI,EAAA;uBAAgC,QAAA,SAAQ;;KAKvH,UAAU,QAAA;KACV,OAAO,SAAS,IAAI;KACpB,UAAK,WAAE,gBAAgB,IAAI;QAE5B,mBAAmE,QAAA;KAA5D,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,cAAA,CAAA;KAAkB,WAAQ,QAAQ,IAAI"}
|
|
1
|
+
{"version":3,"file":"toolbar.js","names":[],"sources":["../../../src/components/rich-text-editor/toolbar.vue"],"sourcesContent":["<template>\n <div :class=\"cls.e('toolbar')\">\n <template v-for=\"(item, index) in toolbar\" :key=\"index\">\n <div v-if=\"item === '|'\" :class=\"cls.e('separator')\"></div>\n\n <div v-else-if=\"item === 'heading'\" :class=\"[cls.e('toolbar-dropdown')]\">\n <select\n :class=\"[cls.e('heading-select'), { 'is-disabled': disabled }]\"\n :value=\"activeHeading\"\n :disabled=\"disabled\"\n @change=\"onHeadingChange\"\n >\n <option value=\"paragraph\">正文</option>\n <option value=\"h1\">Heading 1</option>\n <option value=\"h2\">Heading 2</option>\n <option value=\"h3\">Heading 3</option>\n <option value=\"h4\">Heading 4</option>\n <option value=\"h5\">Heading 5</option>\n <option value=\"h6\">Heading 6</option>\n </select>\n </div>\n\n <button\n v-else\n type=\"button\"\n :class=\"[\n cls.e('toolbar-btn'),\n { 'is-active': isActive(item) },\n { 'is-disabled': disabled }\n ]\"\n :disabled=\"disabled\"\n :title=\"getTitle(item)\"\n @click=\"onToolbarAction(item)\"\n >\n <span :class=\"cls.e('toolbar-icon')\" v-html=\"getIcon(item)\"></span>\n </button>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link'\nimport { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode } from '@lexical/list'\nimport { $createHeadingNode, $isHeadingNode, type HeadingTagType } from '@lexical/rich-text'\nimport { $isQuoteNode, $createQuoteNode } from '@lexical/rich-text'\nimport { $setBlocksType } from '@lexical/selection'\nimport { $getNearestNodeOfType } from '@lexical/utils'\nimport { bem } from '@veltra/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n FORMAT_TEXT_COMMAND,\n UNDO_COMMAND,\n REDO_COMMAND,\n type LexicalEditor,\n $createParagraphNode,\n type RangeSelection\n} from 'lexical'\nimport { ref, onBeforeUnmount, watch } from 'vue'\n\nimport type { ToolbarItem } from '../../types'\n\nconst props = defineProps<{\n editor: LexicalEditor | null\n toolbar: ToolbarItem[]\n disabled: boolean\n}>()\n\nconst cls = bem('rich-text-editor')\n\n// Active states\nconst isBold = ref(false)\nconst isItalic = ref(false)\nconst isUnderline = ref(false)\nconst isStrikethrough = ref(false)\nconst isLink = ref(false)\nconst isBulletList = ref(false)\nconst isOrderedList = ref(false)\nconst isBlockquote = ref(false)\nconst activeHeading = ref('paragraph')\n\nlet cleanupListener: (() => void) | null = null\n\nfunction setupListener(editorInstance: LexicalEditor) {\n cleanupListener?.()\n cleanupListener = editorInstance.registerUpdateListener(({ editorState }) => {\n editorState.read(\n () => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) return\n\n updateToolbarState(selection)\n },\n { editor: editorInstance }\n )\n })\n}\n\nfunction updateToolbarState(selection: RangeSelection) {\n isBold.value = selection.hasFormat('bold')\n isItalic.value = selection.hasFormat('italic')\n isUnderline.value = selection.hasFormat('underline')\n isStrikethrough.value = selection.hasFormat('strikethrough')\n\n // Check block type\n const anchorNode = selection.anchor.getNode()\n let element = anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow()\n\n if ($isHeadingNode(element)) {\n activeHeading.value = (element as any).getTag()\n } else {\n activeHeading.value = 'paragraph'\n }\n\n // Check list\n const parentList = $getNearestNodeOfType(anchorNode, ListNode)\n if (parentList) {\n const listType = (parentList as any).getListType()\n isBulletList.value = listType === 'bullet'\n isOrderedList.value = listType === 'number'\n } else {\n isBulletList.value = false\n isOrderedList.value = false\n }\n\n // Check blockquote\n isBlockquote.value = $isQuoteNode(element)\n\n // Check link\n const parent = anchorNode.getParent()\n isLink.value = $isLinkNode(parent)\n}\n\nwatch(\n () => props.editor,\n (editorInstance) => {\n if (editorInstance) {\n setupListener(editorInstance)\n }\n },\n { immediate: true }\n)\n\nfunction isActive(item: ToolbarItem): boolean {\n switch (item) {\n case 'bold':\n return isBold.value\n case 'italic':\n return isItalic.value\n case 'underline':\n return isUnderline.value\n case 'strikethrough':\n return isStrikethrough.value\n case 'bullet-list':\n return isBulletList.value\n case 'ordered-list':\n return isOrderedList.value\n case 'blockquote':\n return isBlockquote.value\n case 'link':\n return isLink.value\n default:\n return false\n }\n}\n\nfunction onToolbarAction(item: ToolbarItem) {\n const editorInstance = props.editor\n if (!editorInstance || props.disabled) return\n\n switch (item) {\n case 'bold':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')\n break\n case 'italic':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')\n break\n case 'underline':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')\n break\n case 'strikethrough':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')\n break\n case 'code':\n editorInstance.dispatchCommand(FORMAT_TEXT_COMMAND, 'code')\n break\n case 'bullet-list':\n editorInstance.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)\n break\n case 'ordered-list':\n editorInstance.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)\n break\n case 'blockquote':\n editorInstance.update(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n if (isBlockquote.value) {\n $setBlocksType(selection, () => $createParagraphNode())\n } else {\n $setBlocksType(selection, () => $createQuoteNode())\n }\n }\n })\n break\n case 'link':\n toggleLink(editorInstance)\n break\n case 'undo':\n editorInstance.dispatchCommand(UNDO_COMMAND, undefined)\n break\n case 'redo':\n editorInstance.dispatchCommand(REDO_COMMAND, undefined)\n break\n }\n\n // Keep focus on editor\n editorInstance.focus()\n}\n\nfunction onHeadingChange(event: Event) {\n const editorInstance = props.editor\n if (!editorInstance || props.disabled) return\n\n const value = (event.target as HTMLSelectElement).value\n\n editorInstance.update(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n if (value === 'paragraph') {\n $setBlocksType(selection, () => $createParagraphNode())\n } else {\n $setBlocksType(selection, () => $createHeadingNode(value as HeadingTagType))\n }\n }\n })\n\n editorInstance.focus()\n}\n\nfunction toggleLink(editorInstance: LexicalEditor) {\n let shouldRemoveLink = false\n\n editorInstance.read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) return\n\n const parent = selection.anchor.getNode().getParent()\n shouldRemoveLink = $isLinkNode(parent)\n })\n\n if (shouldRemoveLink) {\n editorInstance.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n return\n }\n\n const url = prompt('请输入链接地址:', 'https://')\n if (url && url !== 'https://') {\n editorInstance.dispatchCommand(TOGGLE_LINK_COMMAND, url)\n }\n}\n\nfunction getTitle(item: ToolbarItem): string {\n const titles: Record<string, string> = {\n bold: '加粗',\n italic: '斜体',\n underline: '下划线',\n strikethrough: '删除线',\n code: '行内代码',\n 'bullet-list': '无序列表',\n 'ordered-list': '有序列表',\n blockquote: '引用',\n 'code-block': '代码块',\n link: '链接',\n undo: '撤销',\n redo: '重做'\n }\n return titles[item] ?? item\n}\n\nfunction getIcon(item: ToolbarItem): string {\n const icons: Record<string, string> = {\n bold: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/><path d=\"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/></svg>',\n italic:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/></svg>',\n underline:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/></svg>',\n strikethrough:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4H9a3 3 0 0 0-2.83 4\"/><path d=\"M14 12a4 4 0 0 1 0 8H6\"/><line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/></svg>',\n code: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"16 18 22 12 16 6\"/><polyline points=\"8 6 2 12 8 18\"/></svg>',\n 'bullet-list':\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"/><line x1=\"3\" y1=\"6\" x2=\"3.01\" y2=\"6\"/><line x1=\"3\" y1=\"12\" x2=\"3.01\" y2=\"12\"/><line x1=\"3\" y1=\"18\" x2=\"3.01\" y2=\"18\"/></svg>',\n 'ordered-list':\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1\"/></svg>',\n blockquote:\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z\"/><path d=\"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z\"/></svg>',\n 'code-block':\n '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2\" y=\"3\" width=\"20\" height=\"18\" rx=\"2\"/><path d=\"m8 10-3 2 3 2\"/><path d=\"m16 10 3 2-3 2\"/><path d=\"m13 7-2 10\"/></svg>',\n link: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>',\n undo: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 7v6h6\"/><path d=\"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13\"/></svg>',\n redo: '<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 7v6h-6\"/><path d=\"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13\"/></svg>'\n }\n return icons[item] ?? ''\n}\n\nonBeforeUnmount(() => {\n cleanupListener?.()\n cleanupListener = null\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA8DA,MAAM,QAAQ;EAMd,MAAM,MAAM,I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EAAA,GAAA,EAAA,UAAA,IAAA,GAChB,mBAkCW,UAAA,MAAA,WAlCuB,QAAA,UAAhB,MAAM,UAAK;4DAAoB,MAAK,GAAA,CACzC,SAAI,OAAA,UAAA,GAAf,mBAA2D,OAAA;;KAAjC,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,WAAA,CAAA;mBAEtB,SAAI,aAAA,UAAA,GAApB,mBAeM,OAAA;;KAf+B,OAAK,eAAA,CAAG,MAAA,GAAA,CAAG,CAAC,EAAC,kBAAA,CAAA,CAAA;QAChD,mBAaS,UAAA;KAZN,OAAK,eAAA,CAAG,MAAA,GAAA,CAAG,CAAC,EAAC,gBAAA,GAAA,EAAA,eAAqC,QAAA,SAAQ,CAAA,CAAA;KAC1D,OAAO,cAAA;KACP,UAAU,QAAA;KACV,UAAQ;0XAYb,mBAaS,UAAA;;KAXP,MAAK;KACJ,OAAK,eAAA;MAAc,MAAA,GAAA,CAAG,CAAC,EAAC,aAAA;qBAA0C,SAAS,IAAI,EAAA;uBAAgC,QAAA,SAAQ;;KAKvH,UAAU,QAAA;KACV,OAAO,SAAS,IAAI;KACpB,UAAK,WAAE,gBAAgB,IAAI;QAE5B,mBAAmE,QAAA;KAA5D,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,cAAA,CAAA;KAAkB,WAAQ,QAAQ,IAAI"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./scroll.vue.js";
|
|
2
|
+
export { _default as UScroll };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ScrollPosition, ScrollProps, _ScrollExposed } from "../../types/scroll.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/scroll/scroll.vue.d.ts
|
|
3
4
|
type __VLS_Slots = {
|
|
4
|
-
/** 默认插槽 */
|
|
5
|
+
/** 默认插槽 */
|
|
6
|
+
default(): any;
|
|
7
|
+
/** 内容插槽 */
|
|
5
8
|
content(): any;
|
|
6
9
|
};
|
|
7
10
|
declare const __VLS_base: import("vue").DefineComponent<ScrollProps, _ScrollExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
@@ -21,5 +24,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
21
24
|
};
|
|
22
25
|
};
|
|
23
26
|
//#endregion
|
|
24
|
-
export { _default };
|
|
27
|
+
export { _default as default };
|
|
25
28
|
//# sourceMappingURL=scroll.vue.d.ts.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./select.vue.js";
|
|
2
|
+
export { _default as USelect };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { SelectProps } from "../../types/select.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/select/select.vue.d.ts
|
|
3
4
|
type __VLS_Props = SelectProps;
|
|
4
5
|
type __VLS_Slots = {
|
|
5
|
-
/** 前缀插槽 */
|
|
6
|
+
/** 前缀插槽 */
|
|
7
|
+
prefix?: () => any;
|
|
8
|
+
/** 默认插槽 */
|
|
6
9
|
default?: (scope: {
|
|
7
10
|
option: Record<string, any>;
|
|
8
11
|
index: number;
|
|
@@ -39,5 +42,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
39
42
|
};
|
|
40
43
|
};
|
|
41
44
|
//#endregion
|
|
42
|
-
export { _default };
|
|
45
|
+
export { _default as default };
|
|
43
46
|
//# sourceMappingURL=select.vue.d.ts.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./slider.vue.js";
|
|
2
|
+
export { _default as USlider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SliderEmits, SliderProps } from "../../types/slider.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/slider/slider.vue.d.ts
|
|
3
4
|
declare const __VLS_export: <T extends number | [number, number]>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
5
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<SliderProps<T> & {
|
|
@@ -11,10 +12,10 @@ declare const __VLS_export: <T extends number | [number, number]>(__VLS_props: N
|
|
|
11
12
|
slots: {};
|
|
12
13
|
emit: SliderEmits<T>;
|
|
13
14
|
}>) => import("vue").VNode & {
|
|
14
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
15
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
15
16
|
};
|
|
16
17
|
declare const _default: typeof __VLS_export;
|
|
17
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
18
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
|
|
18
19
|
//#endregion
|
|
19
|
-
export { _default };
|
|
20
|
+
export { _default as default };
|
|
20
21
|
//# sourceMappingURL=slider.vue.d.ts.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./steps.vue.js";
|
|
2
|
+
export { _default as USteps };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StepsProps, StepsSlotScope } from "../../types/steps.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/steps/steps.vue.d.ts
|
|
3
4
|
type __VLS_Slots = {
|
|
4
5
|
icon?: (scope: StepsSlotScope) => any;
|
|
@@ -6,11 +7,11 @@ type __VLS_Slots = {
|
|
|
6
7
|
tip?: (scope: StepsSlotScope) => any;
|
|
7
8
|
};
|
|
8
9
|
declare const __VLS_base: import("vue").DefineComponent<StepsProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
9
|
-
"update:current": (value?: string | number | undefined) => any;
|
|
10
10
|
"item-click": (item: Record<string, any>, index: number) => any;
|
|
11
|
+
"update:current": (value?: string | number | undefined) => any;
|
|
11
12
|
}, string, import("vue").PublicProps, Readonly<StepsProps> & Readonly<{
|
|
12
|
-
"onUpdate:current"?: ((value?: string | number | undefined) => any) | undefined;
|
|
13
13
|
"onItem-click"?: ((item: Record<string, any>, index: number) => any) | undefined;
|
|
14
|
+
"onUpdate:current"?: ((value?: string | number | undefined) => any) | undefined;
|
|
14
15
|
}>, {
|
|
15
16
|
labelKey: string;
|
|
16
17
|
direction: "horizontal" | "vertical";
|
|
@@ -24,5 +25,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
//#endregion
|
|
27
|
-
export { _default };
|
|
28
|
+
export { _default as default };
|
|
28
29
|
//# sourceMappingURL=steps.vue.d.ts.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _default from "./switch.vue.js";
|
|
2
|
+
export { _default as USwitch };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SwitchProps } from "../../types/switch.js";
|
|
2
|
+
import "../../types/index.js";
|
|
2
3
|
//#region src/components/switch/switch.vue.d.ts
|
|
3
4
|
type __VLS_Props = SwitchProps;
|
|
4
5
|
type __VLS_ModelProps = {
|
|
@@ -19,5 +20,5 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
19
20
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
21
|
declare const _default: typeof __VLS_export;
|
|
21
22
|
//#endregion
|
|
22
|
-
export { _default };
|
|
23
|
+
export { _default as default };
|
|
23
24
|
//# sourceMappingURL=switch.vue.d.ts.map
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { defineTableColumns } from "./use-columns.js";
|
|
1
|
+
import _default from "./table.vue.js";
|
|
2
|
+
import { defineTableColumns } from "./use-columns.js";
|
|
3
|
+
export { _default as UTable, defineTableColumns };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableColumn, TableColumnAlign } from "../../../types/table.js";
|
|
2
|
+
import "../../../types/index.js";
|
|
2
3
|
import { TreeNode } from "@cat-kit/core";
|
|
3
|
-
|
|
4
4
|
//#region src/components/table/node/col.d.ts
|
|
5
5
|
declare class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
|
|
6
6
|
children?: ColumnNode[] | undefined;
|
|
@@ -28,7 +28,8 @@ const ROW_MOD_CLASS = [
|
|
|
28
28
|
"is-current is-checked is-expanded"
|
|
29
29
|
];
|
|
30
30
|
function rowModCls(row) {
|
|
31
|
-
|
|
31
|
+
const i = (row.isCurrent ? 4 : 0) | (row.checked ? 2 : 0) | (row.expanded ? 1 : 0);
|
|
32
|
+
return ROW_MOD_CLASS[i];
|
|
32
33
|
}
|
|
33
34
|
const UTableRow = defineComponent({
|
|
34
35
|
name: "TableRow",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-row.js","names":[],"sources":["../../../src/components/table/table-row.tsx"],"sourcesContent":["import { ArrowRight } from '@veltra/icons/normal'\nimport { defineComponent, type DefineComponent } from 'vue'\nimport { inject, onUnmounted } from 'vue'\nimport type { JSX } from 'vue/jsx-runtime'\n\nimport type { TableRow as ITableRow } from '../../types'\nimport { UButton } from '../button'\nimport { UIcon } from '../icon'\nimport { TableDIKey } from './di'\nimport UTabelCell from './table-cell.vue'\n\n/**\n * A3:行修饰类组合静态查找表。\n *\n * 位模式:bit2 = isCurrent, bit1 = checked, bit0 = expanded。\n * 与 `bem.is('...')` 对于 `'current' | 'checked' | 'expanded'` 的输出完全等价,\n * 直接从 index 读字符串,消除每行渲染期间的字符串拼接和 3 次 bem.is 调用。\n *\n * 放在模块顶层使所有 TableRow 实例共享一份引用(不会随 setup 重建)。\n */\nconst ROW_MOD_CLASS: readonly string[] = [\n '',\n 'is-expanded',\n 'is-checked',\n 'is-checked is-expanded',\n 'is-current',\n 'is-current is-expanded',\n 'is-current is-checked',\n 'is-current is-checked is-expanded'\n] as const\n\nfunction rowModCls(row: ITableRow): string {\n const i = (row.isCurrent ? 4 : 0) | (row.checked ? 2 : 0) | (row.expanded ? 1 : 0)\n return ROW_MOD_CLASS[i]!\n}\n\nexport const UTableRow: DefineComponent<{ row: ITableRow; index: number }> = defineComponent({\n name: 'TableRow',\n\n props: {\n row: { type: Object as () => ITableRow, required: true },\n index: { type: Number, required: true }\n },\n\n setup(props) {\n const {\n cls,\n columnConfig,\n getColumnSlotsNode,\n toggleTreeRowExpand,\n getCellCtx,\n handleRowClick,\n handleCellClick,\n tableProps,\n measureElement,\n getCellClass\n } = inject(TableDIKey)!\n\n // A1:把 cls.e('row') / cls.e('expand-toggle') 等静态字符串提升到 setup 一次性计算,\n // 避免每次 render 重新走 `cls.e` 拼接。\n const rowBaseCls = cls.e('row')\n const expandToggleCls = cls.e('expand-toggle')\n const expandSpaceCls = cls.e('expand-space')\n\n // A2:measureRef 按 index 缓存闭包。\n // 行虚拟化下,同一 TableRow 实例的 props.index 大多稳定,但在虚拟化重排或展开行切换时\n // 仍会发生变化;把 (index) → refFn 缓存起来,既保证引用稳定(利于 Vue 的 ref diff),\n // 又避免在未来可能的\"同实例跨 index 复用\"情形下重复分配闭包。\n const measureRefCache = new Map<number, (el: unknown) => void>()\n const getMeasureRef = (index: number): ((el: unknown) => void) => {\n let ref = measureRefCache.get(index)\n if (ref === undefined) {\n ref = (el: unknown) => {\n measureElement(index, el as Element | null)\n }\n measureRefCache.set(index, ref)\n }\n return ref\n }\n onUnmounted(() => {\n measureRefCache.clear()\n })\n\n const { columns, expandColumn } = columnConfig\n\n return () => {\n const { row } = props\n const _expandColumn = expandColumn.value\n\n let expandCell: JSX.Element | null = null\n if (_expandColumn) {\n const expandCtx = getCellCtx(row, _expandColumn)\n const cellSpan = tableProps.mergeCell?.(expandCtx)\n\n if (!cellSpan || (cellSpan.colspan && cellSpan.rowspan)) {\n const marginLeft = tableProps.tree ? row.depth * 14 : 0\n expandCell = (\n <UTabelCell\n cellClass={getCellClass(_expandColumn)}\n left={_expandColumn.style.left}\n right={_expandColumn.style.right}\n key={row.uid + _expandColumn.key}\n {...tableProps.mergeCell?.(expandCtx)}\n >\n {!row.isLeaf || (tableProps.expandable && !row.isExpandRow) ? (\n <UButton\n text\n class={expandToggleCls}\n type='primary'\n size='small'\n circle\n onClick={(e) => {\n e.stopPropagation()\n toggleTreeRowExpand(row)\n }}\n style={`margin-left: ${marginLeft}px`}\n >\n <UIcon>\n <ArrowRight />\n </UIcon>\n </UButton>\n ) : (\n <i class={expandSpaceCls} style={`margin-left: ${marginLeft}px`}></i>\n )}\n\n {getColumnSlotsNode(expandCtx)}\n </UTabelCell>\n )\n }\n }\n\n // A3:行 class 由 base + 3-bit 组合查找产出,避免 Vue 的 class 数组归一化开销。\n const mod = rowModCls(row)\n const rowCls = mod ? rowBaseCls + ' ' + mod : rowBaseCls\n\n return (\n <tr\n class={rowCls}\n onClick={(e) => handleRowClick(row, e)}\n ref={getMeasureRef(props.index)}\n key={row.uid}\n >\n {expandCell}\n\n {columns.value.map((column) => {\n const cellCtx = getCellCtx(row, column)\n const cellSpan = tableProps.mergeCell?.(cellCtx)\n if (cellSpan && (!cellSpan.colspan || !cellSpan.rowspan)) {\n return null\n }\n\n const cellNode = getColumnSlotsNode(cellCtx)\n\n return (\n <UTabelCell\n cellClass={getCellClass(column)}\n left={column.style.left}\n right={column.style.right}\n key={row.uid + column.key}\n // @ts-ignore\n onClick={(e) => handleCellClick(row, column, e)}\n {...cellSpan}\n >\n {cellNode}\n </UTabelCell>\n )\n })}\n </tr>\n )\n }\n }\n})\n\nexport const UExpandTableRow = defineComponent({\n name: 'ExpandTableRow',\n props: {\n row: { type: Object as () => ITableRow, required: true },\n index: { type: Number, required: true }\n },\n setup(props) {\n const { getExpandRowSlotsNode, cls, measureElement, columnConfig } = inject(TableDIKey)!\n const { leafColumns } = columnConfig\n\n const rowBaseCls = cls.e('row')\n const cellCls = cls.e('cell')\n\n const measureRef = (el: unknown) => {\n measureElement(props.index, el as Element | null)\n }\n\n return () => {\n const { row } = props\n const node = getExpandRowSlotsNode({\n row,\n index: row.index,\n columns: leafColumns.value,\n rowData: row.data\n })\n return (\n <tr class={rowBaseCls} ref={measureRef}>\n <td colspan={leafColumns.value.length} class={cellCls}>\n {node}\n </td>\n </tr>\n )\n }\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,SAAA,QAAA,GAAA;CAAA,OAAA,OAAA,MAAA,cAAA,OAAA,UAAA,SAAA,KAAA,CAAA,MAAA,qBAAA,CAAA,QAAA,CAAA;AAAA;AASA,MAAM,gBAAmC;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAmC;AAGrC,SAAS,UAAU,KAAwB;
|
|
1
|
+
{"version":3,"file":"table-row.js","names":[],"sources":["../../../src/components/table/table-row.tsx"],"sourcesContent":["import { ArrowRight } from '@veltra/icons/normal'\nimport { defineComponent, type DefineComponent } from 'vue'\nimport { inject, onUnmounted } from 'vue'\nimport type { JSX } from 'vue/jsx-runtime'\n\nimport type { TableRow as ITableRow } from '../../types'\nimport { UButton } from '../button'\nimport { UIcon } from '../icon'\nimport { TableDIKey } from './di'\nimport UTabelCell from './table-cell.vue'\n\n/**\n * A3:行修饰类组合静态查找表。\n *\n * 位模式:bit2 = isCurrent, bit1 = checked, bit0 = expanded。\n * 与 `bem.is('...')` 对于 `'current' | 'checked' | 'expanded'` 的输出完全等价,\n * 直接从 index 读字符串,消除每行渲染期间的字符串拼接和 3 次 bem.is 调用。\n *\n * 放在模块顶层使所有 TableRow 实例共享一份引用(不会随 setup 重建)。\n */\nconst ROW_MOD_CLASS: readonly string[] = [\n '',\n 'is-expanded',\n 'is-checked',\n 'is-checked is-expanded',\n 'is-current',\n 'is-current is-expanded',\n 'is-current is-checked',\n 'is-current is-checked is-expanded'\n] as const\n\nfunction rowModCls(row: ITableRow): string {\n const i = (row.isCurrent ? 4 : 0) | (row.checked ? 2 : 0) | (row.expanded ? 1 : 0)\n return ROW_MOD_CLASS[i]!\n}\n\nexport const UTableRow: DefineComponent<{ row: ITableRow; index: number }> = defineComponent({\n name: 'TableRow',\n\n props: {\n row: { type: Object as () => ITableRow, required: true },\n index: { type: Number, required: true }\n },\n\n setup(props) {\n const {\n cls,\n columnConfig,\n getColumnSlotsNode,\n toggleTreeRowExpand,\n getCellCtx,\n handleRowClick,\n handleCellClick,\n tableProps,\n measureElement,\n getCellClass\n } = inject(TableDIKey)!\n\n // A1:把 cls.e('row') / cls.e('expand-toggle') 等静态字符串提升到 setup 一次性计算,\n // 避免每次 render 重新走 `cls.e` 拼接。\n const rowBaseCls = cls.e('row')\n const expandToggleCls = cls.e('expand-toggle')\n const expandSpaceCls = cls.e('expand-space')\n\n // A2:measureRef 按 index 缓存闭包。\n // 行虚拟化下,同一 TableRow 实例的 props.index 大多稳定,但在虚拟化重排或展开行切换时\n // 仍会发生变化;把 (index) → refFn 缓存起来,既保证引用稳定(利于 Vue 的 ref diff),\n // 又避免在未来可能的\"同实例跨 index 复用\"情形下重复分配闭包。\n const measureRefCache = new Map<number, (el: unknown) => void>()\n const getMeasureRef = (index: number): ((el: unknown) => void) => {\n let ref = measureRefCache.get(index)\n if (ref === undefined) {\n ref = (el: unknown) => {\n measureElement(index, el as Element | null)\n }\n measureRefCache.set(index, ref)\n }\n return ref\n }\n onUnmounted(() => {\n measureRefCache.clear()\n })\n\n const { columns, expandColumn } = columnConfig\n\n return () => {\n const { row } = props\n const _expandColumn = expandColumn.value\n\n let expandCell: JSX.Element | null = null\n if (_expandColumn) {\n const expandCtx = getCellCtx(row, _expandColumn)\n const cellSpan = tableProps.mergeCell?.(expandCtx)\n\n if (!cellSpan || (cellSpan.colspan && cellSpan.rowspan)) {\n const marginLeft = tableProps.tree ? row.depth * 14 : 0\n expandCell = (\n <UTabelCell\n cellClass={getCellClass(_expandColumn)}\n left={_expandColumn.style.left}\n right={_expandColumn.style.right}\n key={row.uid + _expandColumn.key}\n {...tableProps.mergeCell?.(expandCtx)}\n >\n {!row.isLeaf || (tableProps.expandable && !row.isExpandRow) ? (\n <UButton\n text\n class={expandToggleCls}\n type='primary'\n size='small'\n circle\n onClick={(e) => {\n e.stopPropagation()\n toggleTreeRowExpand(row)\n }}\n style={`margin-left: ${marginLeft}px`}\n >\n <UIcon>\n <ArrowRight />\n </UIcon>\n </UButton>\n ) : (\n <i class={expandSpaceCls} style={`margin-left: ${marginLeft}px`}></i>\n )}\n\n {getColumnSlotsNode(expandCtx)}\n </UTabelCell>\n )\n }\n }\n\n // A3:行 class 由 base + 3-bit 组合查找产出,避免 Vue 的 class 数组归一化开销。\n const mod = rowModCls(row)\n const rowCls = mod ? rowBaseCls + ' ' + mod : rowBaseCls\n\n return (\n <tr\n class={rowCls}\n onClick={(e) => handleRowClick(row, e)}\n ref={getMeasureRef(props.index)}\n key={row.uid}\n >\n {expandCell}\n\n {columns.value.map((column) => {\n const cellCtx = getCellCtx(row, column)\n const cellSpan = tableProps.mergeCell?.(cellCtx)\n if (cellSpan && (!cellSpan.colspan || !cellSpan.rowspan)) {\n return null\n }\n\n const cellNode = getColumnSlotsNode(cellCtx)\n\n return (\n <UTabelCell\n cellClass={getCellClass(column)}\n left={column.style.left}\n right={column.style.right}\n key={row.uid + column.key}\n // @ts-ignore\n onClick={(e) => handleCellClick(row, column, e)}\n {...cellSpan}\n >\n {cellNode}\n </UTabelCell>\n )\n })}\n </tr>\n )\n }\n }\n})\n\nexport const UExpandTableRow = defineComponent({\n name: 'ExpandTableRow',\n props: {\n row: { type: Object as () => ITableRow, required: true },\n index: { type: Number, required: true }\n },\n setup(props) {\n const { getExpandRowSlotsNode, cls, measureElement, columnConfig } = inject(TableDIKey)!\n const { leafColumns } = columnConfig\n\n const rowBaseCls = cls.e('row')\n const cellCls = cls.e('cell')\n\n const measureRef = (el: unknown) => {\n measureElement(props.index, el as Element | null)\n }\n\n return () => {\n const { row } = props\n const node = getExpandRowSlotsNode({\n row,\n index: row.index,\n columns: leafColumns.value,\n rowData: row.data\n })\n return (\n <tr class={rowBaseCls} ref={measureRef}>\n <td colspan={leafColumns.value.length} class={cellCls}>\n {node}\n </td>\n </tr>\n )\n }\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,SAAA,QAAA,GAAA;CAAA,OAAA,OAAA,MAAA,cAAA,OAAA,UAAA,SAAA,KAAA,CAAA,MAAA,qBAAA,CAAA,QAAA,CAAA;AAAA;AASA,MAAM,gBAAmC;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAmC;AAGrC,SAAS,UAAU,KAAwB;CACzC,MAAM,KAAK,IAAI,YAAY,IAAI,MAAM,IAAI,UAAU,IAAI,MAAM,IAAI,WAAW,IAAI;CAChF,OAAO,cAAc;AACvB;AAEA,MAAa,YAAgE,gBAAgB;CAC3F,MAAM;CAEN,OAAO;EACL,KAAK;GAAE,MAAM;GAA2B,UAAU;EAAK;EACvD,OAAO;GAAE,MAAM;GAAQ,UAAU;EAAK;CACxC;CAEA,MAAM,OAAO;EACX,MAAM,EACJ,KACA,cACA,oBACA,qBACA,YACA,gBACA,iBACA,YACA,gBACA,iBACE,OAAO,UAAU;EAIrB,MAAM,aAAa,IAAI,EAAE,KAAK;EAC9B,MAAM,kBAAkB,IAAI,EAAE,eAAe;EAC7C,MAAM,iBAAiB,IAAI,EAAE,cAAc;EAM3C,MAAM,kCAAkB,IAAI,IAAmC;EAC/D,MAAM,iBAAiB,UAA2C;GAChE,IAAI,MAAM,gBAAgB,IAAI,KAAK;GACnC,IAAI,QAAQ,KAAA,GAAW;IACrB,OAAO,OAAgB;KACrB,eAAe,OAAO,EAAoB;IAC5C;IACA,gBAAgB,IAAI,OAAO,GAAG;GAChC;GACA,OAAO;EACT;EACA,kBAAkB;GAChB,gBAAgB,MAAM;EACxB,CAAC;EAED,MAAM,EAAE,SAAS,iBAAi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../../types/index.js";
|
|
2
3
|
import { ColumnNode } from "./node/col.js";
|
|
3
4
|
import { TableRowNode } from "./node/row.js";
|
|
5
|
+
import "../../index.js";
|
|
4
6
|
//#region src/components/table/table.vue.d.ts
|
|
5
7
|
type __VLS_Slots = {
|
|
6
8
|
[key: `column:${string}`]: (props: TableColumnSlotsScope) => any;
|
|
@@ -48,5 +50,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
48
50
|
};
|
|
49
51
|
};
|
|
50
52
|
//#endregion
|
|
51
|
-
export { _default };
|
|
53
|
+
export { _default as default };
|
|
52
54
|
//# sourceMappingURL=table.vue.d.ts.map
|
|
@@ -98,12 +98,13 @@ function useColumns(options) {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
const result = new Forest({
|
|
102
102
|
data: sortedColumns,
|
|
103
103
|
createNode(data, index, depth, _f, parent) {
|
|
104
104
|
return new ColumnNode(data, index, depth, parent);
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
+
columnForest.value = result;
|
|
107
108
|
}, { immediate: true });
|
|
108
109
|
const headers = computed(() => {
|
|
109
110
|
const headers = [];
|