@quirekit/ui 0.0.0-stage → 0.0.1-alpha.1
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/LICENSE.md +21 -0
- package/README.md +41 -2
- package/README.zh-CN.md +42 -0
- package/THIRD_PARTY_NOTICES.md +141 -0
- package/dist/catalog-AqWLE58Z.mjs +7114 -0
- package/dist/catalog-AqWLE58Z.mjs.map +1 -0
- package/dist/chat-BAee3Pg0.mjs +9092 -0
- package/dist/chat-BAee3Pg0.mjs.map +1 -0
- package/dist/chat.d.mts +3 -0
- package/dist/chat.mjs +2 -0
- package/dist/code-block-D1kd-gAB.mjs +731 -0
- package/dist/code-block-D1kd-gAB.mjs.map +1 -0
- package/dist/html-sandbox-BYIni0q6.mjs +531 -0
- package/dist/html-sandbox-BYIni0q6.mjs.map +1 -0
- package/dist/html-sandbox.d.mts +2 -0
- package/dist/html-sandbox.mjs +2 -0
- package/dist/index-Cc6zEK6c.d.mts +369 -0
- package/dist/index-Cc6zEK6c.d.mts.map +1 -0
- package/dist/index-DbtTJnJq.d.mts +51 -0
- package/dist/index-DbtTJnJq.d.mts.map +1 -0
- package/dist/index-Su5SBM61.d.mts +10070 -0
- package/dist/index-Su5SBM61.d.mts.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1053 -0
- package/dist/index.mjs.map +1 -0
- package/dist/model-CeJjdZm_.mjs +1604 -0
- package/dist/model-CeJjdZm_.mjs.map +1 -0
- package/dist/resolve-CGFbhFiM.mjs +1531 -0
- package/dist/resolve-CGFbhFiM.mjs.map +1 -0
- package/dist/style.css +24 -0
- package/dist/vue.d.mts +10667 -0
- package/dist/vue.d.mts.map +1 -0
- package/dist/vue.mjs +31552 -0
- package/dist/vue.mjs.map +1 -0
- package/package.json +72 -3
- package/src/color-palette/conversion.test.ts +23 -0
- package/src/color-palette/conversion.ts +115 -0
- package/src/color-palette/custom/elements.ts +96 -0
- package/src/color-palette/custom/index.ts +1 -0
- package/src/color-palette/custom/panel.test.ts +71 -0
- package/src/color-palette/custom/panel.ts +166 -0
- package/src/color-palette/custom/style.ts +142 -0
- package/src/color-palette/index.ts +22 -0
- package/src/color-palette/labels.ts +36 -0
- package/src/color-palette/palette.test.ts +100 -0
- package/src/color-palette/palette.ts +213 -0
- package/src/color-palette/presets.ts +10 -0
- package/src/color-palette/style.ts +133 -0
- package/src/color-palette/types.ts +115 -0
- package/src/components/accordion/index.ts +5 -0
- package/src/components/accordion/types.ts +19 -0
- package/src/components/action-menu/index.ts +2 -0
- package/src/components/action-menu/types.ts +98 -0
- package/src/components/action-sheet/groups.test.ts +26 -0
- package/src/components/action-sheet/groups.ts +20 -0
- package/src/components/action-sheet/index.ts +1 -0
- package/src/components/action-sheet/types.ts +31 -0
- package/src/components/alert/index.ts +1 -0
- package/src/components/alert/types.ts +8 -0
- package/src/components/attachment/index.ts +1 -0
- package/src/components/attachment/types.ts +60 -0
- package/src/components/avatar/index.ts +12 -0
- package/src/components/avatar/types.ts +63 -0
- package/src/components/badge/create.test.ts +21 -0
- package/src/components/badge/create.ts +34 -0
- package/src/components/badge/index.ts +3 -0
- package/src/components/badge/types.ts +43 -0
- package/src/components/badge/variables/declarations.ts +23 -0
- package/src/components/button/create.test.ts +145 -0
- package/src/components/button/create.ts +153 -0
- package/src/components/button/index.ts +8 -0
- package/src/components/button/types.ts +104 -0
- package/src/components/button/variables/declarations.ts +92 -0
- package/src/components/button/variables/index.ts +6 -0
- package/src/components/button/variables/names.ts +83 -0
- package/src/components/button/variables/references.ts +54 -0
- package/src/components/candidate-list/index.ts +1 -0
- package/src/components/candidate-list/types.ts +23 -0
- package/src/components/chat/composer/types.ts +82 -0
- package/src/components/chat/composer-input/types.ts +33 -0
- package/src/components/chat/composer-submit/types.ts +17 -0
- package/src/components/chat/confirmation/types.ts +35 -0
- package/src/components/chat/index.ts +16 -0
- package/src/components/chat/message/types.ts +72 -0
- package/src/components/chat/message-action/types.ts +9 -0
- package/src/components/chat/message-actions/types.ts +19 -0
- package/src/components/chat/message-branch/types.ts +11 -0
- package/src/components/chat/message-list/types.ts +67 -0
- package/src/components/chat/message-part/types.ts +216 -0
- package/src/components/chat/process/types.ts +27 -0
- package/src/components/chat/question/types.ts +98 -0
- package/src/components/chat/reasoning/types.ts +7 -0
- package/src/components/chat/rich-input/types.ts +99 -0
- package/src/components/chat/shared/types.ts +34 -0
- package/src/components/chat/tool/types.ts +7 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox/types.ts +7 -0
- package/src/components/checkbox-group/create.ts +10 -0
- package/src/components/checkbox-group/index.ts +3 -0
- package/src/components/checkbox-group/types.ts +63 -0
- package/src/components/checkbox-group/variables/declarations.ts +9 -0
- package/src/components/choice-picker/index.ts +1 -0
- package/src/components/choice-picker/types.ts +104 -0
- package/src/components/clipboard/index.ts +2 -0
- package/src/components/clipboard/types.ts +38 -0
- package/src/components/collapsible/index.ts +1 -0
- package/src/components/collapsible/types.ts +8 -0
- package/src/components/color-picker/color.test.ts +19 -0
- package/src/components/color-picker/color.ts +35 -0
- package/src/components/color-picker/index.ts +13 -0
- package/src/components/color-picker/types.ts +82 -0
- package/src/components/combobox/index.ts +12 -0
- package/src/components/combobox/types.ts +125 -0
- package/src/components/comment-rail/index.ts +2 -0
- package/src/components/comment-rail/layout.test.ts +76 -0
- package/src/components/comment-rail/layout.ts +37 -0
- package/src/components/comment-rail/types.ts +27 -0
- package/src/components/control/index.ts +3 -0
- package/src/components/control/modality.test.ts +30 -0
- package/src/components/control/modality.ts +33 -0
- package/src/components/control/sizes.ts +10 -0
- package/src/components/control/types.ts +5 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/dialog/types.ts +5 -0
- package/src/components/diff-viewer/index.ts +1 -0
- package/src/components/diff-viewer/types.ts +20 -0
- package/src/components/drawer/index.ts +1 -0
- package/src/components/drawer/types.ts +67 -0
- package/src/components/editable/index.ts +1 -0
- package/src/components/editable/types.ts +31 -0
- package/src/components/emoji-picker/catalog.ts +61 -0
- package/src/components/emoji-picker/index.ts +3 -0
- package/src/components/emoji-picker/search.test.ts +43 -0
- package/src/components/emoji-picker/search.ts +20 -0
- package/src/components/emoji-picker/sections.test.ts +30 -0
- package/src/components/emoji-picker/sections.ts +40 -0
- package/src/components/emoji-picker/types.ts +34 -0
- package/src/components/empty-state/index.ts +6 -0
- package/src/components/empty-state/types.ts +16 -0
- package/src/components/field/index.ts +5 -0
- package/src/components/field/types.ts +41 -0
- package/src/components/fieldset/index.ts +1 -0
- package/src/components/fieldset/types.ts +15 -0
- package/src/components/file-icon/index.ts +2 -0
- package/src/components/file-icon/resolve.test.ts +17 -0
- package/src/components/file-icon/resolve.ts +42 -0
- package/src/components/file-icon/types.ts +24 -0
- package/src/components/file-upload/index.ts +2 -0
- package/src/components/file-upload/messages.ts +11 -0
- package/src/components/file-upload/types.ts +96 -0
- package/src/components/icon/catalog.test.ts +195 -0
- package/src/components/icon/catalog.ts +80 -0
- package/src/components/icon/custom/formatting.ts +24 -0
- package/src/components/icon/custom/indicators.ts +5 -0
- package/src/components/icon/custom/insert.ts +20 -0
- package/src/components/icon/custom/table.ts +29 -0
- package/src/components/icon/custom.ts +12 -0
- package/src/components/icon/define.test.ts +80 -0
- package/src/components/icon/define.ts +113 -0
- package/src/components/icon/index.ts +25 -0
- package/src/components/icon/labels.test.ts +44 -0
- package/src/components/icon/labels.ts +62 -0
- package/src/components/icon/lucide.ts +359 -0
- package/src/components/icon/metadata.ts +1784 -0
- package/src/components/icon/registry.test.ts +36 -0
- package/src/components/icon/registry.ts +64 -0
- package/src/components/icon/review.ts +19 -0
- package/src/components/icon/types.ts +138 -0
- package/src/components/index.ts +80 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input/types.ts +58 -0
- package/src/components/input-number/index.ts +8 -0
- package/src/components/input-number/types.ts +98 -0
- package/src/components/input-number-unit/index.ts +1 -0
- package/src/components/input-number-unit/types.ts +34 -0
- package/src/components/inspector/index.ts +1 -0
- package/src/components/inspector/types.ts +14 -0
- package/src/components/json-viewer/index.ts +1 -0
- package/src/components/json-viewer/types.ts +24 -0
- package/src/components/kbd/create.test.ts +16 -0
- package/src/components/kbd/create.ts +37 -0
- package/src/components/kbd/index.ts +3 -0
- package/src/components/kbd/types.ts +35 -0
- package/src/components/kbd/variables/declarations.ts +20 -0
- package/src/components/listbox/index.ts +9 -0
- package/src/components/listbox/types.ts +57 -0
- package/src/components/media-player/index.ts +1 -0
- package/src/components/media-player/types.ts +40 -0
- package/src/components/menu/context/index.ts +5 -0
- package/src/components/menu/context/types.ts +48 -0
- package/src/components/menu/create.test.ts +52 -0
- package/src/components/menu/create.ts +60 -0
- package/src/components/menu/index.ts +19 -0
- package/src/components/menu/types.ts +152 -0
- package/src/components/menu/variables/declarations.ts +48 -0
- package/src/components/menu/variables/index.ts +6 -0
- package/src/components/menu/variables/names.ts +59 -0
- package/src/components/menu/variables/references.ts +42 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pagination/types.ts +42 -0
- package/src/components/popover/create.test.ts +60 -0
- package/src/components/popover/create.ts +45 -0
- package/src/components/popover/index.ts +9 -0
- package/src/components/popover/types.ts +87 -0
- package/src/components/popover/variables/declarations.ts +45 -0
- package/src/components/popover/variables/index.ts +6 -0
- package/src/components/popover/variables/names.ts +42 -0
- package/src/components/popover/variables/references.ts +55 -0
- package/src/components/preset-gallery/geometry.test.ts +19 -0
- package/src/components/preset-gallery/geometry.ts +27 -0
- package/src/components/preset-gallery/index.ts +1 -0
- package/src/components/preset-gallery/types.ts +25 -0
- package/src/components/preset-picker/index.ts +1 -0
- package/src/components/preset-picker/types.ts +52 -0
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/normalize.ts +25 -0
- package/src/components/progress/types.ts +26 -0
- package/src/components/radio-group/index.ts +5 -0
- package/src/components/radio-group/types.ts +19 -0
- package/src/components/scroll-area/index.ts +7 -0
- package/src/components/scroll-area/types.ts +19 -0
- package/src/components/segmented/create.test.ts +71 -0
- package/src/components/segmented/create.ts +99 -0
- package/src/components/segmented/index.ts +14 -0
- package/src/components/segmented/types.ts +74 -0
- package/src/components/segmented/variables/declarations.ts +64 -0
- package/src/components/segmented/variables/index.ts +6 -0
- package/src/components/segmented/variables/names.ts +54 -0
- package/src/components/segmented/variables/references.ts +52 -0
- package/src/components/select/index.ts +7 -0
- package/src/components/select/types.ts +26 -0
- package/src/components/selection-gesture/index.ts +5 -0
- package/src/components/selection-gesture/mount.ts +128 -0
- package/src/components/selection-gesture/session/controller.test.ts +77 -0
- package/src/components/selection-gesture/session/controller.ts +105 -0
- package/src/components/selection-gesture/session/types.ts +30 -0
- package/src/components/selection-gesture/types.ts +65 -0
- package/src/components/selection-handles/dom/handles.test.ts +53 -0
- package/src/components/selection-handles/dom/handles.ts +73 -0
- package/src/components/selection-handles/dom/types.ts +23 -0
- package/src/components/selection-handles/drag/controller.test.ts +180 -0
- package/src/components/selection-handles/drag/controller.ts +84 -0
- package/src/components/selection-handles/drag/hold.ts +55 -0
- package/src/components/selection-handles/drag/types.ts +64 -0
- package/src/components/selection-handles/index.ts +7 -0
- package/src/components/selection-handles/mount.test.ts +105 -0
- package/src/components/selection-handles/mount.ts +183 -0
- package/src/components/selection-handles/types.ts +120 -0
- package/src/components/sheet/index.ts +1 -0
- package/src/components/sheet/types.ts +5 -0
- package/src/components/shimmer/index.ts +1 -0
- package/src/components/shimmer/types.ts +9 -0
- package/src/components/skeleton/create.test.ts +13 -0
- package/src/components/skeleton/create.ts +10 -0
- package/src/components/skeleton/index.ts +3 -0
- package/src/components/skeleton/types.ts +17 -0
- package/src/components/skeleton/variables/declarations.ts +9 -0
- package/src/components/slider/index.ts +1 -0
- package/src/components/slider/types.ts +5 -0
- package/src/components/sources/index.ts +1 -0
- package/src/components/sources/types.ts +45 -0
- package/src/components/splitter/index.ts +12 -0
- package/src/components/splitter/types.ts +90 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/types.ts +2 -0
- package/src/components/table/create.test.ts +14 -0
- package/src/components/table/create.ts +21 -0
- package/src/components/table/index.ts +3 -0
- package/src/components/table/types.ts +128 -0
- package/src/components/table/variables/declarations.ts +20 -0
- package/src/components/table-size-picker/index.ts +2 -0
- package/src/components/table-size-picker/model.ts +112 -0
- package/src/components/table-size-picker/types.ts +39 -0
- package/src/components/tabs/index.ts +1 -0
- package/src/components/tabs/types.ts +23 -0
- package/src/components/tag/create.test.ts +22 -0
- package/src/components/tag/create.ts +29 -0
- package/src/components/tag/index.ts +3 -0
- package/src/components/tag/types.ts +35 -0
- package/src/components/tag/variables/declarations.ts +19 -0
- package/src/components/tags-input/index.ts +1 -0
- package/src/components/tags-input/types.ts +42 -0
- package/src/components/task/index.ts +1 -0
- package/src/components/task/types.ts +47 -0
- package/src/components/task-panel/index.ts +1 -0
- package/src/components/task-panel/types.ts +21 -0
- package/src/components/terminal-output/index.ts +1 -0
- package/src/components/terminal-output/types.ts +30 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/types.ts +17 -0
- package/src/components/toast/index.ts +6 -0
- package/src/components/toast/types.ts +22 -0
- package/src/components/toggle-group/create.ts +10 -0
- package/src/components/toggle-group/index.ts +3 -0
- package/src/components/toggle-group/types.ts +54 -0
- package/src/components/toggle-group/variables/declarations.ts +9 -0
- package/src/components/toolbar/collapse.test.ts +17 -0
- package/src/components/toolbar/collapse.ts +31 -0
- package/src/components/toolbar/create.test.ts +95 -0
- package/src/components/toolbar/create.ts +45 -0
- package/src/components/toolbar/index.ts +39 -0
- package/src/components/toolbar/navigation.ts +78 -0
- package/src/components/toolbar/span.test.ts +26 -0
- package/src/components/toolbar/span.ts +41 -0
- package/src/components/toolbar/types.ts +292 -0
- package/src/components/toolbar/variables/declarations.ts +41 -0
- package/src/components/toolbar/variables/index.ts +6 -0
- package/src/components/toolbar/variables/names.ts +44 -0
- package/src/components/toolbar/variables/references.ts +36 -0
- package/src/components/tooltip/create.test.ts +111 -0
- package/src/components/tooltip/create.ts +76 -0
- package/src/components/tooltip/index.ts +13 -0
- package/src/components/tooltip/types.ts +74 -0
- package/src/components/tooltip/variables/declarations.ts +38 -0
- package/src/components/tooltip/variables/index.ts +6 -0
- package/src/components/tooltip/variables/names.ts +33 -0
- package/src/components/tooltip/variables/references.ts +46 -0
- package/src/components/tree-view/index.ts +10 -0
- package/src/components/tree-view/types.ts +73 -0
- package/src/components/typography/index.ts +1 -0
- package/src/components/typography/types.ts +23 -0
- package/src/index.ts +29 -0
- package/src/locale/components/action-menu.ts +33 -0
- package/src/locale/components/action-sheet.ts +15 -0
- package/src/locale/components/alert.ts +11 -0
- package/src/locale/components/anchor.ts +11 -0
- package/src/locale/components/attachment.ts +45 -0
- package/src/locale/components/avatar.ts +39 -0
- package/src/locale/components/badge.ts +11 -0
- package/src/locale/components/breadcrumb.ts +15 -0
- package/src/locale/components/calendar.ts +47 -0
- package/src/locale/components/carousel.ts +35 -0
- package/src/locale/components/cascader.ts +11 -0
- package/src/locale/components/chat.ts +241 -0
- package/src/locale/components/choice-picker.ts +45 -0
- package/src/locale/components/clipboard.ts +40 -0
- package/src/locale/components/code-block.ts +17 -0
- package/src/locale/components/color-picker.ts +87 -0
- package/src/locale/components/combobox.ts +27 -0
- package/src/locale/components/command-palette.ts +29 -0
- package/src/locale/components/comment.ts +115 -0
- package/src/locale/components/date-input.ts +11 -0
- package/src/locale/components/date-picker.ts +11 -0
- package/src/locale/components/date-range-picker.ts +35 -0
- package/src/locale/components/date-time-picker.ts +43 -0
- package/src/locale/components/date-time-range-picker.ts +47 -0
- package/src/locale/components/dialog.ts +11 -0
- package/src/locale/components/diff-viewer.ts +68 -0
- package/src/locale/components/drawer.ts +11 -0
- package/src/locale/components/editable.ts +31 -0
- package/src/locale/components/emoji-picker.ts +124 -0
- package/src/locale/components/field.ts +23 -0
- package/src/locale/components/fieldset.ts +15 -0
- package/src/locale/components/file-upload.ts +64 -0
- package/src/locale/components/form-field.ts +19 -0
- package/src/locale/components/form.ts +15 -0
- package/src/locale/components/hierarchy-picker.ts +33 -0
- package/src/locale/components/html-sandbox.ts +57 -0
- package/src/locale/components/icon-catalog/en.ts +457 -0
- package/src/locale/components/icon-catalog/zh-hans.ts +457 -0
- package/src/locale/components/icon-catalog.ts +19 -0
- package/src/locale/components/image-cropper.ts +51 -0
- package/src/locale/components/image-preview.ts +83 -0
- package/src/locale/components/image.ts +31 -0
- package/src/locale/components/input-number.ts +27 -0
- package/src/locale/components/input.ts +33 -0
- package/src/locale/components/inspector.ts +19 -0
- package/src/locale/components/json-viewer.ts +62 -0
- package/src/locale/components/listbox.ts +11 -0
- package/src/locale/components/media-player.ts +30 -0
- package/src/locale/components/navigation-menu.ts +11 -0
- package/src/locale/components/pagination.ts +47 -0
- package/src/locale/components/picker.ts +95 -0
- package/src/locale/components/pin-input.ts +19 -0
- package/src/locale/components/popconfirm.ts +15 -0
- package/src/locale/components/popover.ts +11 -0
- package/src/locale/components/preset-gallery.ts +11 -0
- package/src/locale/components/preset-picker.ts +37 -0
- package/src/locale/components/progress.ts +11 -0
- package/src/locale/components/prose.ts +29 -0
- package/src/locale/components/qr-code.ts +27 -0
- package/src/locale/components/rating.ts +28 -0
- package/src/locale/components/select.ts +11 -0
- package/src/locale/components/selection-handles.ts +15 -0
- package/src/locale/components/sources.ts +35 -0
- package/src/locale/components/splitter.ts +11 -0
- package/src/locale/components/statistic.ts +13 -0
- package/src/locale/components/steps.ts +15 -0
- package/src/locale/components/table.ts +27 -0
- package/src/locale/components/tag.ts +11 -0
- package/src/locale/components/tags-input.ts +76 -0
- package/src/locale/components/terminal-output.ts +45 -0
- package/src/locale/components/time-input.ts +11 -0
- package/src/locale/components/time-picker.ts +23 -0
- package/src/locale/components/time-range-picker.ts +47 -0
- package/src/locale/components/timeline.ts +32 -0
- package/src/locale/components/toast.ts +11 -0
- package/src/locale/components/toolbar.ts +15 -0
- package/src/locale/components/transfer.ts +44 -0
- package/src/locale/components/tree-select.ts +11 -0
- package/src/locale/index.ts +4 -0
- package/src/locale/packs/en.ts +160 -0
- package/src/locale/packs/zh-cn.ts +160 -0
- package/src/locale/resolve.test.ts +28 -0
- package/src/locale/resolve.ts +52 -0
- package/src/locale/types.ts +253 -0
- package/src/selection-geometry/bands.test.ts +40 -0
- package/src/selection-geometry/bands.ts +43 -0
- package/src/selection-geometry/index.ts +2 -0
- package/src/selection-geometry/types.ts +35 -0
- package/src/styles/index.ts +1 -0
- package/src/styles/theme.test.ts +58 -0
- package/src/styles/theme.ts +48 -0
- package/src/theme/create.ts +218 -0
- package/src/theme/defaults.ts +7 -0
- package/src/theme/feedback.test.ts +79 -0
- package/src/theme/feedback.ts +90 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/palette.test.ts +183 -0
- package/src/theme/text/create.test.ts +80 -0
- package/src/theme/text/create.ts +26 -0
- package/src/theme/text/index.ts +1 -0
- package/src/theme/theme.test.ts +343 -0
- package/src/theme/types.ts +330 -0
- package/src/theme/typography.test.ts +14 -0
- package/src/theme/variables/declarations.ts +71 -0
- package/src/theme/variables/index.ts +7 -0
- package/src/theme/variables/names.ts +192 -0
- package/src/theme/variables/references.ts +163 -0
- package/src/tokens/color/alpha.ts +79 -0
- package/src/tokens/color/conversion/channels.ts +35 -0
- package/src/tokens/color/conversion/contrast.ts +27 -0
- package/src/tokens/color/conversion/hex.ts +77 -0
- package/src/tokens/color/conversion/index.ts +5 -0
- package/src/tokens/color/conversion/oklch.ts +107 -0
- package/src/tokens/color/conversion/types.ts +19 -0
- package/src/tokens/color/generate.ts +202 -0
- package/src/tokens/color/index.ts +22 -0
- package/src/tokens/color/neutral-palettes.ts +25 -0
- package/src/tokens/defaults.ts +125 -0
- package/src/tokens/index.ts +3 -0
- package/src/tokens/types.ts +292 -0
- package/src/vue/accordion/accordion.vue +153 -0
- package/src/vue/accordion/index.ts +1 -0
- package/src/vue/action-menu/anchor.ts +28 -0
- package/src/vue/action-menu/bottom.test.ts +112 -0
- package/src/vue/action-menu/bottom.vue +126 -0
- package/src/vue/action-menu/desktop.vue +61 -0
- package/src/vue/action-menu/directory.test.ts +34 -0
- package/src/vue/action-menu/directory.vue +45 -0
- package/src/vue/action-menu/focus.ts +37 -0
- package/src/vue/action-menu/index.ts +2 -0
- package/src/vue/action-menu/keyboard.ts +59 -0
- package/src/vue/action-menu/path.test.ts +35 -0
- package/src/vue/action-menu/path.ts +56 -0
- package/src/vue/action-menu/root.test.ts +200 -0
- package/src/vue/action-menu/root.vue +62 -0
- package/src/vue/action-menu/rows.vue +57 -0
- package/src/vue/action-menu/search.test.ts +21 -0
- package/src/vue/action-menu/search.ts +7 -0
- package/src/vue/action-menu/types.ts +62 -0
- package/src/vue/action-menu/use-action-menu.ts +163 -0
- package/src/vue/action-sheet/action-sheet.vue +141 -0
- package/src/vue/action-sheet/index.ts +1 -0
- package/src/vue/action-sheet/locale.test.ts +33 -0
- package/src/vue/alert/alert.test.ts +74 -0
- package/src/vue/alert/alert.vue +85 -0
- package/src/vue/alert/index.ts +1 -0
- package/src/vue/alert/locale.test.ts +33 -0
- package/src/vue/anchor/anchor.test.ts +18 -0
- package/src/vue/anchor/anchor.vue +26 -0
- package/src/vue/anchor/dom.ts +47 -0
- package/src/vue/anchor/index.ts +2 -0
- package/src/vue/anchor/lifecycle.test.ts +75 -0
- package/src/vue/anchor/list.vue +24 -0
- package/src/vue/anchor/locale.test.ts +31 -0
- package/src/vue/anchor/position.test.ts +30 -0
- package/src/vue/anchor/position.ts +28 -0
- package/src/vue/anchor/types.ts +49 -0
- package/src/vue/anchor/use-anchor.ts +125 -0
- package/src/vue/attachment/actions.vue +27 -0
- package/src/vue/attachment/attachment.test.ts +113 -0
- package/src/vue/attachment/attachment.vue +53 -0
- package/src/vue/attachment/attachments.vue +72 -0
- package/src/vue/attachment/index.ts +3 -0
- package/src/vue/attachment/model.test.ts +24 -0
- package/src/vue/attachment/model.ts +30 -0
- package/src/vue/avatar/avatar-group.vue +62 -0
- package/src/vue/avatar/avatar.test.ts +46 -0
- package/src/vue/avatar/avatar.vue +115 -0
- package/src/vue/avatar/index.ts +2 -0
- package/src/vue/badge/badge.vue +42 -0
- package/src/vue/badge/count.test.ts +10 -0
- package/src/vue/badge/count.ts +11 -0
- package/src/vue/badge/index.ts +1 -0
- package/src/vue/badge/locale.test.ts +31 -0
- package/src/vue/breadcrumb/breadcrumb.vue +76 -0
- package/src/vue/breadcrumb/crumb.vue +29 -0
- package/src/vue/breadcrumb/index.ts +2 -0
- package/src/vue/breadcrumb/locale.test.ts +31 -0
- package/src/vue/breadcrumb/projection.test.ts +17 -0
- package/src/vue/breadcrumb/projection.ts +15 -0
- package/src/vue/breadcrumb/types.ts +40 -0
- package/src/vue/button/button.vue +100 -0
- package/src/vue/button/icon-button.vue +82 -0
- package/src/vue/button/index.ts +2 -0
- package/src/vue/calendar/announcements.ts +13 -0
- package/src/vue/calendar/calendar.vue +88 -0
- package/src/vue/calendar/day-view.vue +33 -0
- package/src/vue/calendar/index.ts +2 -0
- package/src/vue/calendar/navigation.vue +14 -0
- package/src/vue/calendar/period-view.vue +25 -0
- package/src/vue/calendar/types.ts +53 -0
- package/src/vue/calendar/value.test.ts +16 -0
- package/src/vue/calendar/value.ts +44 -0
- package/src/vue/candidate-list/candidate-list.vue +29 -0
- package/src/vue/candidate-list/index.ts +2 -0
- package/src/vue/card/card.vue +39 -0
- package/src/vue/card/index.ts +2 -0
- package/src/vue/card/types.ts +21 -0
- package/src/vue/carousel/card-stage.test.ts +60 -0
- package/src/vue/carousel/card-stage.vue +138 -0
- package/src/vue/carousel/carousel.test.ts +95 -0
- package/src/vue/carousel/carousel.vue +142 -0
- package/src/vue/carousel/index.ts +2 -0
- package/src/vue/carousel/item.vue +34 -0
- package/src/vue/carousel/types.ts +81 -0
- package/src/vue/cascader/cascader.vue +42 -0
- package/src/vue/cascader/flyout.vue +21 -0
- package/src/vue/cascader/index.ts +2 -0
- package/src/vue/cascader/level.vue +62 -0
- package/src/vue/cascader/locale.test.ts +38 -0
- package/src/vue/cascader/panels.vue +102 -0
- package/src/vue/cascader/types.ts +11 -0
- package/src/vue/cascader/use-flyout.ts +40 -0
- package/src/vue/chat/composer/composer.test.ts +164 -0
- package/src/vue/chat/composer/composer.vue +160 -0
- package/src/vue/chat/composer-input/composer-input.test.ts +24 -0
- package/src/vue/chat/composer-input/composer-input.vue +48 -0
- package/src/vue/chat/composer-submit/composer-submit.test.ts +30 -0
- package/src/vue/chat/composer-submit/composer-submit.vue +35 -0
- package/src/vue/chat/confirmation/confirmation.test.ts +45 -0
- package/src/vue/chat/confirmation/confirmation.vue +36 -0
- package/src/vue/chat/index.ts +16 -0
- package/src/vue/chat/locale.test.ts +80 -0
- package/src/vue/chat/message/message.test.ts +83 -0
- package/src/vue/chat/message/message.vue +98 -0
- package/src/vue/chat/message-action/message-action.vue +32 -0
- package/src/vue/chat/message-actions/message-actions.test.ts +56 -0
- package/src/vue/chat/message-actions/message-actions.vue +68 -0
- package/src/vue/chat/message-branch/message-branch.vue +46 -0
- package/src/vue/chat/message-list/anchors.test.ts +25 -0
- package/src/vue/chat/message-list/anchors.ts +36 -0
- package/src/vue/chat/message-list/message-list.test.ts +111 -0
- package/src/vue/chat/message-list/message-list.vue +117 -0
- package/src/vue/chat/message-list/types.ts +34 -0
- package/src/vue/chat/message-list/use-scroll.test.ts +96 -0
- package/src/vue/chat/message-list/use-scroll.ts +102 -0
- package/src/vue/chat/message-part/message-part.test.ts +134 -0
- package/src/vue/chat/message-part/message-part.vue +83 -0
- package/src/vue/chat/process/process.test.ts +30 -0
- package/src/vue/chat/process/process.vue +16 -0
- package/src/vue/chat/question/question.test.ts +211 -0
- package/src/vue/chat/question/question.vue +182 -0
- package/src/vue/chat/reasoning/reasoning.vue +25 -0
- package/src/vue/chat/rich-input/history.ts +33 -0
- package/src/vue/chat/rich-input/model.test.ts +23 -0
- package/src/vue/chat/rich-input/model.ts +80 -0
- package/src/vue/chat/rich-input/rich-input.test.ts +140 -0
- package/src/vue/chat/rich-input/rich-input.vue +273 -0
- package/src/vue/chat/rich-input/use-candidate-position.ts +36 -0
- package/src/vue/chat/rich-input/use-candidates.ts +78 -0
- package/src/vue/chat/shared/disclosure.vue +53 -0
- package/src/vue/chat/shared/focus-recovery.ts +24 -0
- package/src/vue/chat/shared/locale-direction.vue +7 -0
- package/src/vue/chat/shared/locale-scope.vue +17 -0
- package/src/vue/chat/shared/part-actions.ts +23 -0
- package/src/vue/chat/shared/state-icon.ts +11 -0
- package/src/vue/chat/shared/types.ts +9 -0
- package/src/vue/chat/ssr.test.ts +28 -0
- package/src/vue/chat/tool/tool.vue +35 -0
- package/src/vue/checkbox/checkbox.vue +119 -0
- package/src/vue/checkbox/index.ts +1 -0
- package/src/vue/checkbox/readonly.test.ts +62 -0
- package/src/vue/checkbox-group/checkbox-group.vue +64 -0
- package/src/vue/checkbox-group/contract.test.ts +75 -0
- package/src/vue/checkbox-group/form.test.ts +24 -0
- package/src/vue/checkbox-group/index.ts +1 -0
- package/src/vue/checkbox-group/model.test.ts +12 -0
- package/src/vue/checkbox-group/model.ts +23 -0
- package/src/vue/choice-picker/content.vue +121 -0
- package/src/vue/choice-picker/index.ts +1 -0
- package/src/vue/choice-picker/locale.test.ts +38 -0
- package/src/vue/choice-picker/public-props.test.ts +30 -0
- package/src/vue/choice-picker/root.test.ts +219 -0
- package/src/vue/choice-picker/root.vue +89 -0
- package/src/vue/choice-picker/ssr.test.ts +29 -0
- package/src/vue/choice-picker/types.ts +27 -0
- package/src/vue/choice-picker/use-choice-picker.ts +12 -0
- package/src/vue/clipboard/clipboard.test.ts +126 -0
- package/src/vue/clipboard/clipboard.vue +110 -0
- package/src/vue/clipboard/control.test.ts +25 -0
- package/src/vue/clipboard/index.ts +1 -0
- package/src/vue/clipboard/locale.test.ts +36 -0
- package/src/vue/clipboard/use-copy-feedback.ts +69 -0
- package/src/vue/code-block/appearance.ts +16 -0
- package/src/vue/code-block/code-block-header.vue +29 -0
- package/src/vue/code-block/code-block.test.ts +178 -0
- package/src/vue/code-block/code-block.vue +123 -0
- package/src/vue/code-block/code-lines.vue +29 -0
- package/src/vue/code-block/fixtures/scoped-theme.vue +16 -0
- package/src/vue/code-block/index.ts +10 -0
- package/src/vue/code-block/theme-surface.vue +56 -0
- package/src/vue/code-block/theme.test.ts +170 -0
- package/src/vue/code-block/types.ts +79 -0
- package/src/vue/collapsible/collapsible.test.ts +23 -0
- package/src/vue/collapsible/collapsible.vue +107 -0
- package/src/vue/collapsible/index.ts +1 -0
- package/src/vue/color-picker/color-channel-inputs.vue +136 -0
- package/src/vue/color-picker/color-editor.vue +176 -0
- package/src/vue/color-picker/color-palette.vue +198 -0
- package/src/vue/color-picker/color-picker-root.vue +172 -0
- package/src/vue/color-picker/color-picker.test.ts +253 -0
- package/src/vue/color-picker/color-picker.vue +238 -0
- package/src/vue/color-picker/index.ts +4 -0
- package/src/vue/color-picker/use-reset-state.ts +23 -0
- package/src/vue/combobox/collection.test.ts +19 -0
- package/src/vue/combobox/collection.ts +22 -0
- package/src/vue/combobox/combobox.vue +187 -0
- package/src/vue/combobox/form.test.ts +108 -0
- package/src/vue/combobox/form.ts +69 -0
- package/src/vue/combobox/index.ts +1 -0
- package/src/vue/combobox/lazy-mount.test.ts +88 -0
- package/src/vue/combobox/locale.test.ts +41 -0
- package/src/vue/combobox/model.test.ts +105 -0
- package/src/vue/combobox/types.ts +57 -0
- package/src/vue/combobox/use-combobox-model.ts +167 -0
- package/src/vue/command-list/command-list.vue +165 -0
- package/src/vue/command-list/focus.test.ts +62 -0
- package/src/vue/command-list/focus.ts +22 -0
- package/src/vue/command-list/index.ts +2 -0
- package/src/vue/command-list/navigation.test.ts +22 -0
- package/src/vue/command-list/navigation.ts +29 -0
- package/src/vue/command-list/types.ts +60 -0
- package/src/vue/command-palette/command-palette-dialog.vue +41 -0
- package/src/vue/command-palette/command-palette.vue +104 -0
- package/src/vue/command-palette/index.ts +3 -0
- package/src/vue/command-palette/locale.test.ts +36 -0
- package/src/vue/command-palette/projection.test.ts +14 -0
- package/src/vue/command-palette/projection.ts +16 -0
- package/src/vue/command-palette/types.ts +88 -0
- package/src/vue/comment/comment.test.ts +113 -0
- package/src/vue/comment/draft.vue +60 -0
- package/src/vue/comment/field.vue +97 -0
- package/src/vue/comment/index.ts +7 -0
- package/src/vue/comment/mentions.ts +31 -0
- package/src/vue/comment/message.vue +89 -0
- package/src/vue/comment/presentation.ts +17 -0
- package/src/vue/comment/rail.vue +39 -0
- package/src/vue/comment/thread.vue +146 -0
- package/src/vue/comment/types.ts +123 -0
- package/src/vue/control-group/control-group.vue +21 -0
- package/src/vue/control-group/index.ts +2 -0
- package/src/vue/control-group/types.ts +10 -0
- package/src/vue/date-input/date-input.vue +107 -0
- package/src/vue/date-input/formatter.test.ts +15 -0
- package/src/vue/date-input/formatter.ts +23 -0
- package/src/vue/date-input/index.ts +2 -0
- package/src/vue/date-input/types.ts +46 -0
- package/src/vue/date-input/value.test.ts +9 -0
- package/src/vue/date-input/value.ts +15 -0
- package/src/vue/date-picker/date-picker.vue +45 -0
- package/src/vue/date-picker/family.test.ts +27 -0
- package/src/vue/date-picker/index.ts +2 -0
- package/src/vue/date-picker/single.vue +114 -0
- package/src/vue/date-picker/types.ts +50 -0
- package/src/vue/date-range-picker/date-range-picker.vue +119 -0
- package/src/vue/date-range-picker/endpoint.vue +32 -0
- package/src/vue/date-range-picker/index.ts +2 -0
- package/src/vue/date-range-picker/types.ts +43 -0
- package/src/vue/date-range-picker/value.test.ts +25 -0
- package/src/vue/date-range-picker/value.ts +41 -0
- package/src/vue/date-time-picker/date-time-picker.vue +63 -0
- package/src/vue/date-time-picker/draft.ts +21 -0
- package/src/vue/date-time-picker/editor.vue +60 -0
- package/src/vue/date-time-picker/formatter.ts +19 -0
- package/src/vue/date-time-picker/index.ts +2 -0
- package/src/vue/date-time-picker/input.vue +108 -0
- package/src/vue/date-time-picker/panel.vue +48 -0
- package/src/vue/date-time-picker/rules.ts +56 -0
- package/src/vue/date-time-picker/types.ts +51 -0
- package/src/vue/date-time-picker/value.test.ts +54 -0
- package/src/vue/date-time-picker/value.ts +34 -0
- package/src/vue/date-time-range-picker/date-time-range-picker.vue +85 -0
- package/src/vue/date-time-range-picker/draft.test.ts +30 -0
- package/src/vue/date-time-range-picker/draft.ts +18 -0
- package/src/vue/date-time-range-picker/endpoint.vue +34 -0
- package/src/vue/date-time-range-picker/index.ts +2 -0
- package/src/vue/date-time-range-picker/panel.vue +87 -0
- package/src/vue/date-time-range-picker/types.ts +57 -0
- package/src/vue/date-time-range-picker/value.test.ts +64 -0
- package/src/vue/date-time-range-picker/value.ts +50 -0
- package/src/vue/descriptions/descriptions.test.ts +36 -0
- package/src/vue/descriptions/descriptions.vue +36 -0
- package/src/vue/descriptions/index.ts +2 -0
- package/src/vue/descriptions/types.ts +36 -0
- package/src/vue/dialog/close-trigger.vue +30 -0
- package/src/vue/dialog/content.vue +99 -0
- package/src/vue/dialog/index.ts +4 -0
- package/src/vue/dialog/locale.test.ts +35 -0
- package/src/vue/dialog/presence.test.ts +31 -0
- package/src/vue/dialog/root.vue +116 -0
- package/src/vue/dialog/theme.test.ts +170 -0
- package/src/vue/dialog/trigger.vue +31 -0
- package/src/vue/diff-viewer/diff-hunk.vue +73 -0
- package/src/vue/diff-viewer/diff-viewer.test.ts +97 -0
- package/src/vue/diff-viewer/diff-viewer.vue +67 -0
- package/src/vue/diff-viewer/index.ts +1 -0
- package/src/vue/diff-viewer/parse.ts +81 -0
- package/src/vue/diff-viewer/types.ts +35 -0
- package/src/vue/drawer/close-boundary.test.ts +47 -0
- package/src/vue/drawer/close-boundary.ts +38 -0
- package/src/vue/drawer/close-trigger.vue +33 -0
- package/src/vue/drawer/content-frame.test.ts +82 -0
- package/src/vue/drawer/content-frame.vue +78 -0
- package/src/vue/drawer/content.vue +36 -0
- package/src/vue/drawer/context.ts +9 -0
- package/src/vue/drawer/index.ts +4 -0
- package/src/vue/drawer/locale.test.ts +32 -0
- package/src/vue/drawer/root.vue +75 -0
- package/src/vue/drawer/runtime-identity.test.ts +78 -0
- package/src/vue/drawer/theme.test.ts +105 -0
- package/src/vue/drawer/trigger.vue +31 -0
- package/src/vue/drawer/types.ts +91 -0
- package/src/vue/drawer/use-runtime.test.ts +116 -0
- package/src/vue/drawer/use-runtime.ts +116 -0
- package/src/vue/editable/editable.test.ts +22 -0
- package/src/vue/editable/editable.vue +124 -0
- package/src/vue/editable/index.ts +1 -0
- package/src/vue/editable/locale.test.ts +39 -0
- package/src/vue/emoji-picker/emoji-picker.test.ts +60 -0
- package/src/vue/emoji-picker/emoji-picker.vue +89 -0
- package/src/vue/emoji-picker/index.ts +1 -0
- package/src/vue/emoji-picker/navigation.test.ts +14 -0
- package/src/vue/emoji-picker/navigation.ts +74 -0
- package/src/vue/emoji-picker/types.ts +11 -0
- package/src/vue/empty-state/empty-state.test.ts +37 -0
- package/src/vue/empty-state/empty-state.vue +90 -0
- package/src/vue/empty-state/illustration.vue +73 -0
- package/src/vue/empty-state/index.ts +1 -0
- package/src/vue/field/context.ts +16 -0
- package/src/vue/field/field.test.ts +84 -0
- package/src/vue/field/field.vue +152 -0
- package/src/vue/field/index.ts +1 -0
- package/src/vue/field/locale.test.ts +45 -0
- package/src/vue/field/placeholder.test.ts +54 -0
- package/src/vue/fieldset/fieldset.test.ts +67 -0
- package/src/vue/fieldset/fieldset.vue +128 -0
- package/src/vue/fieldset/index.ts +1 -0
- package/src/vue/file-icon/file-icon.test.ts +12 -0
- package/src/vue/file-icon/file-icon.vue +18 -0
- package/src/vue/file-icon/index.ts +1 -0
- package/src/vue/file-upload/file-list.vue +79 -0
- package/src/vue/file-upload/file-upload.test.ts +209 -0
- package/src/vue/file-upload/file-upload.vue +167 -0
- package/src/vue/file-upload/hidden-input.vue +23 -0
- package/src/vue/file-upload/index.ts +2 -0
- package/src/vue/file-upload/types.ts +68 -0
- package/src/vue/floating-panel/geometry.test.ts +26 -0
- package/src/vue/floating-panel/geometry.ts +22 -0
- package/src/vue/floating-panel/index.ts +2 -0
- package/src/vue/floating-panel/panel.vue +90 -0
- package/src/vue/floating-panel/types.ts +36 -0
- package/src/vue/form/context.ts +15 -0
- package/src/vue/form/contract.test.ts +46 -0
- package/src/vue/form/fixtures/template.vue +40 -0
- package/src/vue/form/focus.ts +20 -0
- package/src/vue/form/form.test.ts +90 -0
- package/src/vue/form/form.vue +39 -0
- package/src/vue/form/index.ts +3 -0
- package/src/vue/form/lifecycle.ts +38 -0
- package/src/vue/form/locale.test.ts +40 -0
- package/src/vue/form/ssr.test.ts +48 -0
- package/src/vue/form/template.test.ts +50 -0
- package/src/vue/form/testing.ts +33 -0
- package/src/vue/form/types.ts +95 -0
- package/src/vue/form/use-controller.ts +116 -0
- package/src/vue/form-field/form-field.vue +64 -0
- package/src/vue/form-field/index.ts +2 -0
- package/src/vue/form-field/path.ts +23 -0
- package/src/vue/form-field/types.ts +74 -0
- package/src/vue/form-field/use-binding.ts +112 -0
- package/src/vue/form-field/validation.test.ts +94 -0
- package/src/vue/hierarchy-picker/data.test.ts +19 -0
- package/src/vue/hierarchy-picker/data.ts +54 -0
- package/src/vue/hierarchy-picker/field.vue +79 -0
- package/src/vue/hierarchy-picker/state.test.ts +43 -0
- package/src/vue/hierarchy-picker/types.ts +65 -0
- package/src/vue/hierarchy-picker/use-form.ts +29 -0
- package/src/vue/hierarchy-picker/use-picker.ts +39 -0
- package/src/vue/hover-card/content.vue +39 -0
- package/src/vue/hover-card/hover-card.test.ts +36 -0
- package/src/vue/hover-card/index.ts +4 -0
- package/src/vue/hover-card/root.vue +39 -0
- package/src/vue/hover-card/trigger.vue +20 -0
- package/src/vue/hover-card/types.ts +19 -0
- package/src/vue/html-sandbox/html-sandbox.vue +68 -0
- package/src/vue/html-sandbox/index.ts +2 -0
- package/src/vue/html-sandbox/lifecycle.test.ts +28 -0
- package/src/vue/html-sandbox/ssr.test.ts +10 -0
- package/src/vue/html-sandbox/types.ts +25 -0
- package/src/vue/html-sandbox/use-runtime.ts +104 -0
- package/src/vue/icon/catalog.test.ts +39 -0
- package/src/vue/icon/catalog.ts +17 -0
- package/src/vue/icon/context.ts +7 -0
- package/src/vue/icon/icon-provider.vue +19 -0
- package/src/vue/icon/icon.vue +65 -0
- package/src/vue/icon/index.ts +4 -0
- package/src/vue/icon/types.ts +10 -0
- package/src/vue/image/image.test.ts +100 -0
- package/src/vue/image/image.vue +73 -0
- package/src/vue/image/index.ts +2 -0
- package/src/vue/image/media.test.ts +35 -0
- package/src/vue/image/media.vue +38 -0
- package/src/vue/image/types.ts +26 -0
- package/src/vue/image-cropper/export.ts +31 -0
- package/src/vue/image-cropper/geometry.test.ts +25 -0
- package/src/vue/image-cropper/geometry.ts +43 -0
- package/src/vue/image-cropper/image-cropper.test.ts +24 -0
- package/src/vue/image-cropper/image-cropper.vue +176 -0
- package/src/vue/image-cropper/index.ts +2 -0
- package/src/vue/image-cropper/session-types.ts +9 -0
- package/src/vue/image-cropper/session.vue +84 -0
- package/src/vue/image-cropper/types.ts +47 -0
- package/src/vue/image-cropper/use-source.ts +41 -0
- package/src/vue/image-preview/appearance.ts +10 -0
- package/src/vue/image-preview/geometry.test.ts +46 -0
- package/src/vue/image-preview/geometry.ts +21 -0
- package/src/vue/image-preview/group/context.ts +5 -0
- package/src/vue/image-preview/group/types.ts +40 -0
- package/src/vue/image-preview/group/use.test.ts +73 -0
- package/src/vue/image-preview/group/use.ts +63 -0
- package/src/vue/image-preview/image-preview.vue +75 -0
- package/src/vue/image-preview/index.ts +3 -0
- package/src/vue/image-preview/lifecycle.test.ts +74 -0
- package/src/vue/image-preview/mask-dismiss.ts +26 -0
- package/src/vue/image-preview/stage.vue +41 -0
- package/src/vue/image-preview/surface.vue +116 -0
- package/src/vue/image-preview/theme-surface.vue +27 -0
- package/src/vue/image-preview/theme.test.ts +145 -0
- package/src/vue/image-preview/toolbar/index.ts +2 -0
- package/src/vue/image-preview/toolbar/layout.test.ts +14 -0
- package/src/vue/image-preview/toolbar/layout.ts +28 -0
- package/src/vue/image-preview/toolbar/toolbar.test.ts +28 -0
- package/src/vue/image-preview/toolbar/toolbar.vue +47 -0
- package/src/vue/image-preview/toolbar/types.ts +17 -0
- package/src/vue/image-preview/types.ts +65 -0
- package/src/vue/image-preview/use-gestures.ts +81 -0
- package/src/vue/image-preview/use-transform.ts +48 -0
- package/src/vue/index.ts +134 -0
- package/src/vue/input/index.ts +1 -0
- package/src/vue/input/input.vue +161 -0
- package/src/vue/input/password-field.vue +64 -0
- package/src/vue/input/ssr.test.ts +123 -0
- package/src/vue/input-number/index.ts +1 -0
- package/src/vue/input-number/input-number.vue +180 -0
- package/src/vue/input-number/locale.test.ts +50 -0
- package/src/vue/input-number-unit/index.ts +1 -0
- package/src/vue/input-number-unit/input-number-unit.test.ts +42 -0
- package/src/vue/input-number-unit/input-number-unit.vue +47 -0
- package/src/vue/inspector/index.ts +2 -0
- package/src/vue/inspector/index.vue +146 -0
- package/src/vue/inspector/inspector.test.ts +61 -0
- package/src/vue/inspector/section.vue +44 -0
- package/src/vue/json-viewer/index.ts +1 -0
- package/src/vue/json-viewer/json-node.vue +75 -0
- package/src/vue/json-viewer/json-viewer.test.ts +89 -0
- package/src/vue/json-viewer/json-viewer.vue +61 -0
- package/src/vue/json-viewer/parse.ts +19 -0
- package/src/vue/kbd/index.ts +1 -0
- package/src/vue/kbd/kbd.vue +19 -0
- package/src/vue/kbd/labels.test.ts +8 -0
- package/src/vue/kbd/labels.ts +9 -0
- package/src/vue/listbox/collection.test.ts +87 -0
- package/src/vue/listbox/collection.ts +95 -0
- package/src/vue/listbox/index.ts +1 -0
- package/src/vue/listbox/item.vue +75 -0
- package/src/vue/listbox/keyboard.test.ts +78 -0
- package/src/vue/listbox/keyboard.ts +29 -0
- package/src/vue/listbox/listbox.vue +210 -0
- package/src/vue/listbox/locale.test.ts +28 -0
- package/src/vue/listbox/pointer.test.ts +73 -0
- package/src/vue/locale-provider/context.ts +27 -0
- package/src/vue/locale-provider/index.ts +3 -0
- package/src/vue/locale-provider/locale-provider.vue +13 -0
- package/src/vue/locale-provider/types.ts +9 -0
- package/src/vue/media-player/action.vue +20 -0
- package/src/vue/media-player/fullscreen.ts +27 -0
- package/src/vue/media-player/index.ts +1 -0
- package/src/vue/media-player/media-player.vue +48 -0
- package/src/vue/media-player/options.vue +33 -0
- package/src/vue/media-player/playback.test.ts +58 -0
- package/src/vue/media-player/playback.ts +96 -0
- package/src/vue/media-player/seek.vue +28 -0
- package/src/vue/media-player/time.ts +6 -0
- package/src/vue/menu/content-size.test.ts +43 -0
- package/src/vue/menu/content-size.ts +78 -0
- package/src/vue/menu/context/anchor.test.ts +66 -0
- package/src/vue/menu/context/anchor.ts +53 -0
- package/src/vue/menu/context/context-menu.vue +119 -0
- package/src/vue/menu/context/focus.test.ts +87 -0
- package/src/vue/menu/context/focus.ts +25 -0
- package/src/vue/menu/context/keyboard.test.ts +29 -0
- package/src/vue/menu/context/keyboard.ts +23 -0
- package/src/vue/menu/context/trigger.vue +184 -0
- package/src/vue/menu/default-state.test.ts +136 -0
- package/src/vue/menu/index.ts +10 -0
- package/src/vue/menu/initial-focus.test.ts +42 -0
- package/src/vue/menu/initial-focus.ts +22 -0
- package/src/vue/menu/items/items.test.ts +109 -0
- package/src/vue/menu/items/items.vue +64 -0
- package/src/vue/menu/menu-checkbox-item.vue +77 -0
- package/src/vue/menu/menu-group.vue +34 -0
- package/src/vue/menu/menu-item.vue +81 -0
- package/src/vue/menu/menu-radio-group.vue +37 -0
- package/src/vue/menu/menu-radio-item.vue +70 -0
- package/src/vue/menu/menu-separator.vue +7 -0
- package/src/vue/menu/menu-submenu.vue +193 -0
- package/src/vue/menu/menu.vue +208 -0
- package/src/vue/menu/submenu.test.ts +137 -0
- package/src/vue/menu/surface/anchor.ts +11 -0
- package/src/vue/menu/surface/portal.test.ts +18 -0
- package/src/vue/menu/surface/portal.ts +14 -0
- package/src/vue/menu/surface/scroll.test.ts +38 -0
- package/src/vue/menu/surface/scroll.ts +35 -0
- package/src/vue/menu/surface/siblings.ts +29 -0
- package/src/vue/menu/surface/trigger.vue +25 -0
- package/src/vue/menu/surface/use-layer.ts +23 -0
- package/src/vue/navigation-menu/collapsed.vue +60 -0
- package/src/vue/navigation-menu/entry-content.vue +10 -0
- package/src/vue/navigation-menu/index.ts +2 -0
- package/src/vue/navigation-menu/interaction.ts +21 -0
- package/src/vue/navigation-menu/link.vue +27 -0
- package/src/vue/navigation-menu/locale.test.ts +33 -0
- package/src/vue/navigation-menu/navigation-menu.vue +89 -0
- package/src/vue/navigation-menu/panel-tree.vue +24 -0
- package/src/vue/navigation-menu/positioned-content.vue +46 -0
- package/src/vue/navigation-menu/projection.test.ts +23 -0
- package/src/vue/navigation-menu/projection.ts +42 -0
- package/src/vue/navigation-menu/types.ts +75 -0
- package/src/vue/navigation-menu/vertical-tree.vue +37 -0
- package/src/vue/overlay-provider/context.test.ts +29 -0
- package/src/vue/overlay-provider/context.ts +19 -0
- package/src/vue/overlay-provider/index.ts +3 -0
- package/src/vue/overlay-provider/provider.vue +9 -0
- package/src/vue/overlay-provider/types.ts +7 -0
- package/src/vue/pagination/index.ts +1 -0
- package/src/vue/pagination/options.vue +79 -0
- package/src/vue/pagination/pagination.test.ts +50 -0
- package/src/vue/pagination/pagination.vue +184 -0
- package/src/vue/pin-input/form.ts +24 -0
- package/src/vue/pin-input/index.ts +2 -0
- package/src/vue/pin-input/locale.test.ts +36 -0
- package/src/vue/pin-input/pin-input.test.ts +95 -0
- package/src/vue/pin-input/pin-input.vue +148 -0
- package/src/vue/pin-input/types.ts +50 -0
- package/src/vue/popconfirm/index.ts +2 -0
- package/src/vue/popconfirm/locale.test.ts +35 -0
- package/src/vue/popconfirm/popconfirm.test.ts +85 -0
- package/src/vue/popconfirm/popconfirm.vue +58 -0
- package/src/vue/popconfirm/types.ts +45 -0
- package/src/vue/popconfirm/use-popconfirm.ts +63 -0
- package/src/vue/popover/anchor.vue +28 -0
- package/src/vue/popover/close-trigger.vue +48 -0
- package/src/vue/popover/content.vue +107 -0
- package/src/vue/popover/description.vue +21 -0
- package/src/vue/popover/index.ts +7 -0
- package/src/vue/popover/locale.test.ts +35 -0
- package/src/vue/popover/modal-layer.test.ts +112 -0
- package/src/vue/popover/modal-owner.test.ts +60 -0
- package/src/vue/popover/root.vue +53 -0
- package/src/vue/popover/title.vue +21 -0
- package/src/vue/popover/trigger.vue +32 -0
- package/src/vue/popover/types.ts +64 -0
- package/src/vue/popover/use-runtime.test.ts +99 -0
- package/src/vue/popover/use-runtime.ts +56 -0
- package/src/vue/preset-gallery/actions.test.ts +35 -0
- package/src/vue/preset-gallery/actions.vue +62 -0
- package/src/vue/preset-gallery/index.ts +1 -0
- package/src/vue/preset-gallery/locale.test.ts +31 -0
- package/src/vue/preset-gallery/preset-gallery.test.ts +37 -0
- package/src/vue/preset-gallery/preset-gallery.vue +136 -0
- package/src/vue/preset-gallery/selection.test.ts +91 -0
- package/src/vue/preset-gallery/types.ts +19 -0
- package/src/vue/preset-gallery/use-gallery-columns.ts +35 -0
- package/src/vue/preset-picker/content.vue +104 -0
- package/src/vue/preset-picker/index.ts +1 -0
- package/src/vue/preset-picker/locale.test.ts +35 -0
- package/src/vue/preset-picker/root.test.ts +261 -0
- package/src/vue/preset-picker/root.vue +69 -0
- package/src/vue/preset-picker/types.ts +18 -0
- package/src/vue/preset-picker/use-preset-picker.ts +55 -0
- package/src/vue/progress/index.ts +2 -0
- package/src/vue/progress/progress-enhancements.test.ts +267 -0
- package/src/vue/progress/progress.test.ts +59 -0
- package/src/vue/progress/progress.vue +129 -0
- package/src/vue/progress/types.ts +45 -0
- package/src/vue/prose/blocks/blockquote.vue +7 -0
- package/src/vue/prose/blocks/hr.vue +3 -0
- package/src/vue/prose/blocks/index.ts +4 -0
- package/src/vue/prose/blocks/p.vue +7 -0
- package/src/vue/prose/blocks/pre.vue +11 -0
- package/src/vue/prose/container/container.test.ts +13 -0
- package/src/vue/prose/container/container.vue +25 -0
- package/src/vue/prose/container/index.ts +2 -0
- package/src/vue/prose/container/types.ts +9 -0
- package/src/vue/prose/elements.test.ts +81 -0
- package/src/vue/prose/files/files.test.ts +33 -0
- package/src/vue/prose/files/files.vue +21 -0
- package/src/vue/prose/files/index.ts +2 -0
- package/src/vue/prose/files/types.ts +13 -0
- package/src/vue/prose/headings/h1.vue +8 -0
- package/src/vue/prose/headings/h2.vue +8 -0
- package/src/vue/prose/headings/h3.vue +8 -0
- package/src/vue/prose/headings/h4.vue +8 -0
- package/src/vue/prose/headings/h5.vue +8 -0
- package/src/vue/prose/headings/h6.vue +8 -0
- package/src/vue/prose/headings/index.ts +6 -0
- package/src/vue/prose/image/image.test.ts +58 -0
- package/src/vue/prose/image/image.vue +60 -0
- package/src/vue/prose/image/index.ts +2 -0
- package/src/vue/prose/image/types.ts +25 -0
- package/src/vue/prose/index.ts +14 -0
- package/src/vue/prose/inline/annotations/abbr.vue +10 -0
- package/src/vue/prose/inline/annotations/del.vue +7 -0
- package/src/vue/prose/inline/annotations/index.ts +9 -0
- package/src/vue/prose/inline/annotations/ins.vue +7 -0
- package/src/vue/prose/inline/annotations/mark.vue +7 -0
- package/src/vue/prose/inline/annotations/s.vue +7 -0
- package/src/vue/prose/inline/annotations/small.vue +7 -0
- package/src/vue/prose/inline/annotations/sub.vue +7 -0
- package/src/vue/prose/inline/annotations/sup.vue +7 -0
- package/src/vue/prose/inline/annotations/u.vue +7 -0
- package/src/vue/prose/inline/code/code.vue +7 -0
- package/src/vue/prose/inline/code/index.ts +3 -0
- package/src/vue/prose/inline/code/kbd.vue +7 -0
- package/src/vue/prose/inline/code/samp.vue +7 -0
- package/src/vue/prose/inline/emphasis/b.vue +7 -0
- package/src/vue/prose/inline/emphasis/cite.vue +7 -0
- package/src/vue/prose/inline/emphasis/dfn.vue +7 -0
- package/src/vue/prose/inline/emphasis/em.vue +7 -0
- package/src/vue/prose/inline/emphasis/i.vue +7 -0
- package/src/vue/prose/inline/emphasis/index.ts +7 -0
- package/src/vue/prose/inline/emphasis/strong.vue +7 -0
- package/src/vue/prose/inline/emphasis/var.vue +7 -0
- package/src/vue/prose/inline/index.ts +4 -0
- package/src/vue/prose/inline/links/a.vue +8 -0
- package/src/vue/prose/inline/links/br.vue +3 -0
- package/src/vue/prose/inline/links/index.ts +2 -0
- package/src/vue/prose/lists/dd.vue +7 -0
- package/src/vue/prose/lists/dl.vue +7 -0
- package/src/vue/prose/lists/dt.vue +7 -0
- package/src/vue/prose/lists/index.ts +6 -0
- package/src/vue/prose/lists/li.vue +7 -0
- package/src/vue/prose/lists/ol.vue +7 -0
- package/src/vue/prose/lists/ul.vue +7 -0
- package/src/vue/prose/locale.test.ts +36 -0
- package/src/vue/prose/mapping/index.ts +2 -0
- package/src/vue/prose/mapping/native.ts +59 -0
- package/src/vue/prose/mapping/rich.ts +6 -0
- package/src/vue/prose/media/figcaption.vue +7 -0
- package/src/vue/prose/media/figure.vue +7 -0
- package/src/vue/prose/media/img.vue +7 -0
- package/src/vue/prose/media/index.ts +3 -0
- package/src/vue/prose/preview/index.ts +2 -0
- package/src/vue/prose/preview/preview.test.ts +25 -0
- package/src/vue/prose/preview/preview.vue +31 -0
- package/src/vue/prose/preview/types.ts +20 -0
- package/src/vue/prose/prose.test.ts +35 -0
- package/src/vue/prose/prose.vue +25 -0
- package/src/vue/prose/shared/image-group.ts +5 -0
- package/src/vue/prose/shared/props.ts +10 -0
- package/src/vue/prose/shared/types.ts +6 -0
- package/src/vue/prose/source/index.ts +2 -0
- package/src/vue/prose/source/source.test.ts +40 -0
- package/src/vue/prose/source/source.vue +50 -0
- package/src/vue/prose/source/types.ts +52 -0
- package/src/vue/prose/table/caption.vue +7 -0
- package/src/vue/prose/table/index.ts +8 -0
- package/src/vue/prose/table/table.vue +9 -0
- package/src/vue/prose/table/tbody.vue +7 -0
- package/src/vue/prose/table/td.vue +7 -0
- package/src/vue/prose/table/tfoot.vue +7 -0
- package/src/vue/prose/table/th.vue +7 -0
- package/src/vue/prose/table/thead.vue +7 -0
- package/src/vue/prose/table/tr.vue +7 -0
- package/src/vue/prose/types.ts +120 -0
- package/src/vue/qr-code/index.ts +2 -0
- package/src/vue/qr-code/qr-code.test.ts +96 -0
- package/src/vue/qr-code/qr-code.vue +80 -0
- package/src/vue/qr-code/types.ts +54 -0
- package/src/vue/radio-group/index.ts +1 -0
- package/src/vue/radio-group/keyboard.ts +13 -0
- package/src/vue/radio-group/radio-group.vue +154 -0
- package/src/vue/radio-group/readonly.test.ts +70 -0
- package/src/vue/rating/index.ts +2 -0
- package/src/vue/rating/locale.test.ts +38 -0
- package/src/vue/rating/rating.test.ts +141 -0
- package/src/vue/rating/rating.vue +138 -0
- package/src/vue/rating/types.ts +50 -0
- package/src/vue/rating/value.ts +18 -0
- package/src/vue/result/illustration.vue +71 -0
- package/src/vue/result/index.ts +2 -0
- package/src/vue/result/result.test.ts +83 -0
- package/src/vue/result/result.vue +56 -0
- package/src/vue/result/types.ts +49 -0
- package/src/vue/schema-form/controls/boolean.vue +51 -0
- package/src/vue/schema-form/controls/registry.ts +23 -0
- package/src/vue/schema-form/index.ts +2 -0
- package/src/vue/schema-form/render-control.ts +29 -0
- package/src/vue/schema-form/schema-form.test.ts +140 -0
- package/src/vue/schema-form/schema-form.vue +41 -0
- package/src/vue/schema-form/tree.ts +67 -0
- package/src/vue/schema-form/types.ts +96 -0
- package/src/vue/schema-form/validate-tree.test.ts +17 -0
- package/src/vue/schema-form/validate-tree.ts +27 -0
- package/src/vue/scroll-area/index.ts +1 -0
- package/src/vue/scroll-area/scroll-area.test.ts +53 -0
- package/src/vue/scroll-area/scroll-area.vue +191 -0
- package/src/vue/scroll-area/use-scroll-sync.ts +203 -0
- package/src/vue/segmented/index.ts +1 -0
- package/src/vue/segmented/segmented.vue +116 -0
- package/src/vue/select/index.ts +1 -0
- package/src/vue/select/lazy-mount.test.ts +71 -0
- package/src/vue/select/locale.test.ts +31 -0
- package/src/vue/select/select.test.ts +78 -0
- package/src/vue/select/select.vue +224 -0
- package/src/vue/select/theme.test.ts +137 -0
- package/src/vue/selection-gesture/index.ts +2 -0
- package/src/vue/selection-gesture/selection-gesture.vue +42 -0
- package/src/vue/selection-handles/index.ts +2 -0
- package/src/vue/selection-handles/locale.test.ts +20 -0
- package/src/vue/selection-handles/selection-handles.vue +47 -0
- package/src/vue/separator/index.ts +2 -0
- package/src/vue/separator/separator.vue +26 -0
- package/src/vue/separator/types.ts +21 -0
- package/src/vue/shared/choice-state/field-item.vue +14 -0
- package/src/vue/shared/choice-state/model.test.ts +52 -0
- package/src/vue/shared/choice-state/model.ts +62 -0
- package/src/vue/shared/choice-state/types.ts +13 -0
- package/src/vue/shared/horizontal-scroll/geometry.ts +33 -0
- package/src/vue/shared/horizontal-scroll/icons.ts +7 -0
- package/src/vue/shared/horizontal-scroll/strip.vue +38 -0
- package/src/vue/shared/horizontal-scroll/types.ts +39 -0
- package/src/vue/shared/horizontal-scroll/use-scroll.ts +129 -0
- package/src/vue/shared/motion/content.ts +26 -0
- package/src/vue/shared/picker/anchor.vue +11 -0
- package/src/vue/shared/picker/content.vue +33 -0
- package/src/vue/shared/picker/context.ts +7 -0
- package/src/vue/shared/picker/control-anchor.vue +13 -0
- package/src/vue/shared/picker/index.ts +4 -0
- package/src/vue/shared/picker/locale.test.ts +109 -0
- package/src/vue/shared/picker/positioning.ts +29 -0
- package/src/vue/shared/picker/root.vue +56 -0
- package/src/vue/shared/picker/trigger.vue +7 -0
- package/src/vue/shared/picker/types.ts +21 -0
- package/src/vue/shared/segmented-input/label.ts +13 -0
- package/src/vue/shared/segmented-input/root.vue +48 -0
- package/src/vue/shared/segmented-input/types.ts +29 -0
- package/src/vue/shared/surface/geometry.ts +4 -0
- package/src/vue/shared/surface/modal-portal.test.ts +146 -0
- package/src/vue/shared/surface/open-default.test.ts +135 -0
- package/src/vue/shared/surface/use-modal-owner.test.ts +24 -0
- package/src/vue/shared/surface/use-modal-owner.ts +35 -0
- package/src/vue/shared/surface/use-modal-portal.ts +17 -0
- package/src/vue/shared/task/presentation/media.ts +61 -0
- package/src/vue/shared/task/presentation/types.ts +66 -0
- package/src/vue/shared/task/presentation/use-adaptive-presentation.ssr.test.ts +21 -0
- package/src/vue/shared/task/presentation/use-adaptive-presentation.test.ts +247 -0
- package/src/vue/shared/task/presentation/use-adaptive-presentation.ts +134 -0
- package/src/vue/shared/task/selection/controller.test.ts +135 -0
- package/src/vue/shared/task/selection/controller.ts +89 -0
- package/src/vue/shared/task/selection/desktop-frame.vue +35 -0
- package/src/vue/shared/task/selection/query.test.ts +33 -0
- package/src/vue/shared/task/selection/query.ts +51 -0
- package/src/vue/shared/task/selection/types.ts +104 -0
- package/src/vue/shared/task/selection/use-picker.ts +98 -0
- package/src/vue/shared/task/selection/value.ts +20 -0
- package/src/vue/shared/task/session/lifecycle.test.ts +99 -0
- package/src/vue/shared/task/session/lifecycle.ts +126 -0
- package/src/vue/shared/task/session/request-types.ts +52 -0
- package/src/vue/shared/task/session/requests.test.ts +175 -0
- package/src/vue/shared/task/session/requests.ts +118 -0
- package/src/vue/shared/task/session/types.ts +67 -0
- package/src/vue/shared/task/trigger.test.ts +296 -0
- package/src/vue/shared/task/trigger.vue +118 -0
- package/src/vue/sheet/index.ts +8 -0
- package/src/vue/shimmer/index.ts +1 -0
- package/src/vue/shimmer/shimmer.test.ts +39 -0
- package/src/vue/shimmer/shimmer.vue +14 -0
- package/src/vue/skeleton/index.ts +1 -0
- package/src/vue/skeleton/skeleton.vue +24 -0
- package/src/vue/slider/index.ts +1 -0
- package/src/vue/slider/slider.test.ts +52 -0
- package/src/vue/slider/slider.vue +116 -0
- package/src/vue/sources/index.ts +3 -0
- package/src/vue/sources/inline-citation.test.ts +45 -0
- package/src/vue/sources/inline-citation.vue +50 -0
- package/src/vue/sources/sources.test.ts +86 -0
- package/src/vue/sources/sources.vue +54 -0
- package/src/vue/space/index.ts +2 -0
- package/src/vue/space/space.vue +26 -0
- package/src/vue/space/spacing.ts +19 -0
- package/src/vue/space/types.ts +29 -0
- package/src/vue/splitter/index.ts +1 -0
- package/src/vue/splitter/locale.test.ts +29 -0
- package/src/vue/splitter/splitter.test.ts +67 -0
- package/src/vue/splitter/splitter.vue +255 -0
- package/src/vue/statistic/index.ts +2 -0
- package/src/vue/statistic/statistic.test.ts +116 -0
- package/src/vue/statistic/statistic.vue +42 -0
- package/src/vue/statistic/types.ts +46 -0
- package/src/vue/steps/index.ts +2 -0
- package/src/vue/steps/locale.test.ts +33 -0
- package/src/vue/steps/position.test.ts +12 -0
- package/src/vue/steps/position.ts +9 -0
- package/src/vue/steps/steps.vue +87 -0
- package/src/vue/steps/types.ts +81 -0
- package/src/vue/switch/default-state.test.ts +97 -0
- package/src/vue/switch/index.ts +1 -0
- package/src/vue/switch/switch.vue +109 -0
- package/src/vue/table/index.ts +2 -0
- package/src/vue/table/model.test.ts +29 -0
- package/src/vue/table/model.ts +40 -0
- package/src/vue/table/selection.test.ts +15 -0
- package/src/vue/table/selection.ts +29 -0
- package/src/vue/table/sorting.test.ts +28 -0
- package/src/vue/table/sorting.ts +65 -0
- package/src/vue/table/ssr.test.ts +83 -0
- package/src/vue/table/table.vue +98 -0
- package/src/vue/table/types.ts +6 -0
- package/src/vue/table/use-table-interaction.test.ts +39 -0
- package/src/vue/table/use-table-interaction.ts +63 -0
- package/src/vue/table-size-picker/index.ts +2 -0
- package/src/vue/table-size-picker/table-size-picker.vue +92 -0
- package/src/vue/tabs/index.ts +1 -0
- package/src/vue/tabs/tabs.test.ts +51 -0
- package/src/vue/tabs/tabs.vue +138 -0
- package/src/vue/tag/index.ts +1 -0
- package/src/vue/tag/locale.test.ts +29 -0
- package/src/vue/tag/tag.vue +77 -0
- package/src/vue/tags-input/index.ts +1 -0
- package/src/vue/tags-input/paste.test.ts +79 -0
- package/src/vue/tags-input/paste.ts +32 -0
- package/src/vue/tags-input/tags-input.test.ts +40 -0
- package/src/vue/tags-input/tags-input.vue +276 -0
- package/src/vue/tags-input/types.ts +23 -0
- package/src/vue/task-panel/index.ts +1 -0
- package/src/vue/task-panel/root.test.ts +38 -0
- package/src/vue/task-panel/root.vue +73 -0
- package/src/vue/task-panel/runtime.ts +69 -0
- package/src/vue/task-panel/types.ts +6 -0
- package/src/vue/task-panel/viewport.test.ts +22 -0
- package/src/vue/task-panel/viewport.ts +24 -0
- package/src/vue/terminal-output/index.ts +2 -0
- package/src/vue/terminal-output/parse.ts +131 -0
- package/src/vue/terminal-output/terminal-output.test.ts +78 -0
- package/src/vue/terminal-output/terminal-output.vue +72 -0
- package/src/vue/textarea/auto-resize.ts +101 -0
- package/src/vue/textarea/index.ts +1 -0
- package/src/vue/textarea/textarea.vue +194 -0
- package/src/vue/textarea/types.ts +9 -0
- package/src/vue/theme-provider/context.ts +33 -0
- package/src/vue/theme-provider/index.ts +3 -0
- package/src/vue/theme-provider/portal.vue +36 -0
- package/src/vue/theme-provider/styles.ts +34 -0
- package/src/vue/theme-provider/surface.vue +36 -0
- package/src/vue/theme-provider/theme-provider.test.ts +129 -0
- package/src/vue/theme-provider/theme-provider.vue +25 -0
- package/src/vue/theme-provider/types.ts +9 -0
- package/src/vue/time-input/formatter.ts +13 -0
- package/src/vue/time-input/index.ts +2 -0
- package/src/vue/time-input/time-input.vue +112 -0
- package/src/vue/time-input/types.ts +48 -0
- package/src/vue/time-input/value.test.ts +8 -0
- package/src/vue/time-input/value.ts +25 -0
- package/src/vue/time-picker/columns.vue +49 -0
- package/src/vue/time-picker/index.ts +2 -0
- package/src/vue/time-picker/options.test.ts +22 -0
- package/src/vue/time-picker/options.ts +53 -0
- package/src/vue/time-picker/panel.vue +43 -0
- package/src/vue/time-picker/single.vue +67 -0
- package/src/vue/time-picker/time-picker.vue +30 -0
- package/src/vue/time-picker/types.ts +60 -0
- package/src/vue/time-picker/value.test.ts +20 -0
- package/src/vue/time-picker/value.ts +61 -0
- package/src/vue/time-range-picker/endpoint.vue +34 -0
- package/src/vue/time-range-picker/index.ts +2 -0
- package/src/vue/time-range-picker/panel.vue +66 -0
- package/src/vue/time-range-picker/time-range-picker.vue +84 -0
- package/src/vue/time-range-picker/types.ts +55 -0
- package/src/vue/time-range-picker/value.test.ts +45 -0
- package/src/vue/time-range-picker/value.ts +56 -0
- package/src/vue/timeline/index.ts +2 -0
- package/src/vue/timeline/locale.test.ts +32 -0
- package/src/vue/timeline/timeline.test.ts +53 -0
- package/src/vue/timeline/timeline.vue +68 -0
- package/src/vue/timeline/types.ts +62 -0
- package/src/vue/toast/create-toaster.ts +30 -0
- package/src/vue/toast/index.ts +9 -0
- package/src/vue/toast/locale.test.ts +33 -0
- package/src/vue/toast/toaster.vue +116 -0
- package/src/vue/toggle-group/index.ts +1 -0
- package/src/vue/toggle-group/toggle-group.vue +43 -0
- package/src/vue/toolbar/activation.test.ts +53 -0
- package/src/vue/toolbar/collapse/layout.test.ts +47 -0
- package/src/vue/toolbar/collapse/more.vue +117 -0
- package/src/vue/toolbar/collapse/separators.test.ts +36 -0
- package/src/vue/toolbar/collapse/separators.ts +52 -0
- package/src/vue/toolbar/collapse/types.ts +42 -0
- package/src/vue/toolbar/collapse/units.test.ts +26 -0
- package/src/vue/toolbar/collapse/units.ts +61 -0
- package/src/vue/toolbar/collapse/use-collapse.ts +124 -0
- package/src/vue/toolbar/context.ts +51 -0
- package/src/vue/toolbar/index.ts +13 -0
- package/src/vue/toolbar/items/body.vue +66 -0
- package/src/vue/toolbar/items/configuration.test.ts +134 -0
- package/src/vue/toolbar/items/control.vue +126 -0
- package/src/vue/toolbar/items/items.test.ts +40 -0
- package/src/vue/toolbar/items/items.vue +67 -0
- package/src/vue/toolbar/items/popup-body.vue +26 -0
- package/src/vue/toolbar/items/rows.test.ts +105 -0
- package/src/vue/toolbar/items/types.ts +35 -0
- package/src/vue/toolbar/items/use-entry.ts +57 -0
- package/src/vue/toolbar/presentation/field.vue +34 -0
- package/src/vue/toolbar/presentation/mobile.test.ts +81 -0
- package/src/vue/toolbar/presentation/mode.test.ts +27 -0
- package/src/vue/toolbar/presentation/mode.ts +27 -0
- package/src/vue/toolbar/presentation/presentation.test.ts +184 -0
- package/src/vue/toolbar/presentation/tooltip.vue +41 -0
- package/src/vue/toolbar/scrolling/icons.ts +1 -0
- package/src/vue/toolbar/scrolling/scrolling.test.ts +232 -0
- package/src/vue/toolbar/scrolling/types.ts +17 -0
- package/src/vue/toolbar/scrolling/use-scroll.ts +12 -0
- package/src/vue/toolbar/toolbar-action.vue +86 -0
- package/src/vue/toolbar/toolbar-color-picker-disclosure.test.ts +94 -0
- package/src/vue/toolbar/toolbar-color-picker-disclosure.vue +89 -0
- package/src/vue/toolbar/toolbar-disclosure.vue +134 -0
- package/src/vue/toolbar/toolbar-group.vue +36 -0
- package/src/vue/toolbar/toolbar-selector.vue +127 -0
- package/src/vue/toolbar/toolbar-separator.vue +20 -0
- package/src/vue/toolbar/toolbar-split-button.test.ts +54 -0
- package/src/vue/toolbar/toolbar-split-button.vue +223 -0
- package/src/vue/toolbar/toolbar-toggle.vue +89 -0
- package/src/vue/toolbar/toolbar.vue +155 -0
- package/src/vue/toolbar/types.ts +55 -0
- package/src/vue/toolbar/use-toolbar-item.ts +48 -0
- package/src/vue/toolbar/use-toolbar-root.ts +161 -0
- package/src/vue/tooltip/content.vue +98 -0
- package/src/vue/tooltip/focus-reveal.test.ts +211 -0
- package/src/vue/tooltip/focus-reveal.ts +120 -0
- package/src/vue/tooltip/hydration.test.ts +73 -0
- package/src/vue/tooltip/index.ts +3 -0
- package/src/vue/tooltip/root.vue +135 -0
- package/src/vue/tooltip/trigger.vue +63 -0
- package/src/vue/tooltip/types.ts +9 -0
- package/src/vue/transfer/index.ts +2 -0
- package/src/vue/transfer/model.test.ts +35 -0
- package/src/vue/transfer/model.ts +54 -0
- package/src/vue/transfer/panel.vue +84 -0
- package/src/vue/transfer/transfer.test.ts +113 -0
- package/src/vue/transfer/transfer.vue +123 -0
- package/src/vue/transfer/types.ts +75 -0
- package/src/vue/tree-select/index.ts +2 -0
- package/src/vue/tree-select/locale.test.ts +39 -0
- package/src/vue/tree-select/tree-select.vue +60 -0
- package/src/vue/tree-select/types.ts +13 -0
- package/src/vue/tree-view/index.ts +1 -0
- package/src/vue/tree-view/tree-checkbox.vue +29 -0
- package/src/vue/tree-view/tree-node.vue +114 -0
- package/src/vue/tree-view/tree-view.test.ts +60 -0
- package/src/vue/tree-view/tree-view.vue +224 -0
- package/src/vue/tree-view/use-collection.ts +63 -0
- package/src/vue/typography/abbreviation.test.ts +38 -0
- package/src/vue/typography/abbreviation.vue +23 -0
- package/src/vue/typography/index.ts +2 -0
- package/src/vue/typography/typography.test.ts +75 -0
- package/src/vue/typography/typography.vue +18 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { QuireKitImageCrop, QuireKitImageCropSize } from './types';
|
|
2
|
+
|
|
3
|
+
/** Uncropped source geometry. */
|
|
4
|
+
export const fullImageCrop: QuireKitImageCrop = Object.freeze({ top: 0, right: 0, bottom: 0, left: 0 });
|
|
5
|
+
/** @param crop - Untrusted public geometry. @returns Whether it describes a nonempty source rectangle. */
|
|
6
|
+
export function isImageCrop(crop: QuireKitImageCrop): boolean {
|
|
7
|
+
return [crop.top, crop.right, crop.bottom, crop.left].every(value => Number.isFinite(value) && value >= 0)
|
|
8
|
+
&& crop.top + crop.bottom < 1 && crop.left + crop.right < 1;
|
|
9
|
+
}
|
|
10
|
+
/** @param a - First geometry. @param b - Second geometry. @returns Whether both represent the same source region. */
|
|
11
|
+
export function equalImageCrop(a: QuireKitImageCrop, b: QuireKitImageCrop): boolean {
|
|
12
|
+
return (['top', 'right', 'bottom', 'left'] as const).every(edge => Math.abs(a[edge] - b[edge]) < 1e-8);
|
|
13
|
+
}
|
|
14
|
+
/** Projects source insets into a viewport, fitting a requested ratio inside that region.
|
|
15
|
+
* @param crop - Valid normalized insets.
|
|
16
|
+
* @param size - Viewport with the same aspect as the original image.
|
|
17
|
+
* @param ratio - Optional positive output ratio.
|
|
18
|
+
* @returns Viewport crop rectangle.
|
|
19
|
+
*/
|
|
20
|
+
export function projectImageCrop(crop: QuireKitImageCrop, size: QuireKitImageCropSize, ratio?: number) {
|
|
21
|
+
let width = size.width * (1 - crop.left - crop.right);
|
|
22
|
+
let height = size.height * (1 - crop.top - crop.bottom);
|
|
23
|
+
const centerX = size.width * crop.left + width / 2;
|
|
24
|
+
const centerY = size.height * crop.top + height / 2;
|
|
25
|
+
if (ratio && Number.isFinite(ratio) && ratio > 0) {
|
|
26
|
+
if (width / height > ratio) width = height * ratio;
|
|
27
|
+
else height = width / ratio;
|
|
28
|
+
}
|
|
29
|
+
return { x: centerX - width / 2, y: centerY - height / 2, width, height };
|
|
30
|
+
}
|
|
31
|
+
/** Keeps floating-point edge noise out of persistent source geometry.
|
|
32
|
+
* @param x - Natural source left.
|
|
33
|
+
* @param y - Natural source top.
|
|
34
|
+
* @param right - Natural source right.
|
|
35
|
+
* @param bottom - Natural source bottom.
|
|
36
|
+
* @param size - Natural source dimensions.
|
|
37
|
+
* @returns Valid normalized insets, or null when no source pixels remain.
|
|
38
|
+
*/
|
|
39
|
+
export function sourceImageCrop(x: number, y: number, right: number, bottom: number, size: QuireKitImageCropSize): QuireKitImageCrop | null {
|
|
40
|
+
const crop = { left: Math.max(0, x / size.width), top: Math.max(0, y / size.height),
|
|
41
|
+
right: Math.max(0, 1 - right / size.width), bottom: Math.max(0, 1 - bottom / size.height) };
|
|
42
|
+
return isImageCrop(crop) ? crop : null;
|
|
43
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createSSRApp, h } from 'vue';
|
|
2
|
+
import { renderToString } from 'vue/server-renderer';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import QuireImageCropper from './image-cropper.vue';
|
|
5
|
+
import QuireLocaleProvider from '../locale-provider/locale-provider.vue';
|
|
6
|
+
describe('ImageCropper server rendering', () => {
|
|
7
|
+
it('renders a named loading workspace without browser image or canvas access', async () => {
|
|
8
|
+
const html = await renderToString(createSSRApp({ render: () => h(QuireImageCropper, { src: '/photo.png', alt: '海岸' }) }));
|
|
9
|
+
expect(html).toContain('aria-label="图片裁剪"');
|
|
10
|
+
expect(html).toContain('正在加载图片');
|
|
11
|
+
expect(html).toContain('role="status"');
|
|
12
|
+
expect(html).not.toContain('<canvas');
|
|
13
|
+
});
|
|
14
|
+
it('takes text from the active language in a compact consumer without built-in toolbar', async () => {
|
|
15
|
+
const html = await renderToString(createSSRApp({ render: () => h(QuireLocaleProvider, { locale: 'en' }, () => h(QuireImageCropper, {
|
|
16
|
+
src: '/photo.png', alt: 'Coast', toolbar: false, disabled: true
|
|
17
|
+
})) }));
|
|
18
|
+
expect(html).toContain('aria-label="Image crop"');
|
|
19
|
+
expect(html).toContain('Loading image');
|
|
20
|
+
expect(html).not.toMatch(/[\p{Script=Han}]/u);
|
|
21
|
+
expect(html).toContain('data-disabled');
|
|
22
|
+
expect(html).not.toContain('qk-image-cropper__toolbar');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
|
|
3
|
+
import QuireButton from '../button/button.vue';
|
|
4
|
+
import QuireSegmented from '../segmented/segmented.vue';
|
|
5
|
+
import QuireSelect from '../select/select.vue';
|
|
6
|
+
import QuireSlider from '../slider/slider.vue';
|
|
7
|
+
import { equalImageCrop, fullImageCrop, isImageCrop } from './geometry';
|
|
8
|
+
import { useQuireKitMessages } from '../locale-provider/context';
|
|
9
|
+
import CropperSession from './session.vue';
|
|
10
|
+
import { useCropperSource } from './use-source';
|
|
11
|
+
import type { QuireKitImageCrop, QuireKitImageCropExportOptions, QuireKitImageCropperProps, QuireKitImageCropResult } from './types';
|
|
12
|
+
const props = withDefaults(defineProps<QuireKitImageCropperProps>(), {
|
|
13
|
+
height: 360, toolbar: true, grid: true, fixedCropArea: false, disabled: false
|
|
14
|
+
});
|
|
15
|
+
/** Non-destructive source crop; source replacement uses the current model. */
|
|
16
|
+
const model = defineModel<QuireKitImageCrop>();
|
|
17
|
+
/** Output width / height; undefined enables free resizing. */
|
|
18
|
+
const aspectRatio = defineModel<number>('aspectRatio');
|
|
19
|
+
const emit = defineEmits<{ change: [result: QuireKitImageCropResult]; error: [error: Error]; ready: [result: QuireKitImageCropResult] }>();
|
|
20
|
+
const copy = useQuireKitMessages('imageCropper');
|
|
21
|
+
const source = useCropperSource(props, error => emit('error', error));
|
|
22
|
+
const host = shallowRef<HTMLElement | null>(null);
|
|
23
|
+
const session = shallowRef<InstanceType<typeof CropperSession> | null>(null);
|
|
24
|
+
const width = ref(0);
|
|
25
|
+
const revision = ref(0);
|
|
26
|
+
const mode = ref('frame');
|
|
27
|
+
const zoom = ref(1);
|
|
28
|
+
const current = shallowRef<QuireKitImageCropResult | null>(null);
|
|
29
|
+
const initial = shallowRef<QuireKitImageCrop>(model.value && isImageCrop(model.value) ? { ...model.value } : fullImageCrop);
|
|
30
|
+
const ratio = computed(() => Number.isFinite(aspectRatio.value) && (aspectRatio.value ?? 0) > 0 ? aspectRatio.value : undefined);
|
|
31
|
+
const fixed = computed(() => props.fixedCropArea || mode.value === 'pan');
|
|
32
|
+
const size = computed(() => {
|
|
33
|
+
const natural = source.size.value;
|
|
34
|
+
if (!natural || width.value <= 0) return null;
|
|
35
|
+
const maxHeight = Number.isFinite(props.height) ? Math.max(80, props.height) : 360;
|
|
36
|
+
const scale = Math.min(width.value / natural.width, maxHeight / natural.height);
|
|
37
|
+
return { width: natural.width * scale, height: natural.height * scale };
|
|
38
|
+
});
|
|
39
|
+
const sessionKey = computed(() => `${revision.value}:${size.value?.width}:${size.value?.height}`);
|
|
40
|
+
const ratioItems = computed(() => [
|
|
41
|
+
{ value: 'free', label: copy.value.free }, { value: '1', label: '1:1' },
|
|
42
|
+
{ value: String(4 / 3), label: '4:3' }, { value: String(16 / 9), label: '16:9' },
|
|
43
|
+
...(ratio.value && ![1, 4 / 3, 16 / 9].includes(ratio.value) ? [{ value: String(ratio.value), label: copy.value.custom }] : [])
|
|
44
|
+
]);
|
|
45
|
+
let observer: ResizeObserver | undefined;
|
|
46
|
+
let lastEmitted: QuireKitImageCrop | undefined;
|
|
47
|
+
let announced = false;
|
|
48
|
+
let restoreFocus = false;
|
|
49
|
+
/** Starts a fresh Ark session using normalized source geometry.
|
|
50
|
+
* @param crop - Source geometry to restore.
|
|
51
|
+
*/
|
|
52
|
+
function restart(crop: QuireKitImageCrop): void {
|
|
53
|
+
restoreFocus ||= !!host.value?.contains(host.value.ownerDocument.activeElement);
|
|
54
|
+
initial.value = { ...crop };
|
|
55
|
+
current.value = null;
|
|
56
|
+
announced = false;
|
|
57
|
+
zoom.value = 1;
|
|
58
|
+
revision.value++;
|
|
59
|
+
}
|
|
60
|
+
watch([() => props.src, () => props.crossorigin, () => props.referrerpolicy, source.attempt], () => {
|
|
61
|
+
lastEmitted = undefined;
|
|
62
|
+
restart(model.value && isImageCrop(model.value) ? model.value : fullImageCrop);
|
|
63
|
+
}, { flush: 'sync' });
|
|
64
|
+
watch(model, value => {
|
|
65
|
+
if (value && !isImageCrop(value)) { emit('error', new RangeError('Image crop must contain finite nonnegative insets with a nonempty visible area.')); return; }
|
|
66
|
+
const next = value ?? fullImageCrop;
|
|
67
|
+
if (lastEmitted && equalImageCrop(next, lastEmitted)) return;
|
|
68
|
+
restart(next);
|
|
69
|
+
}, { deep: true, flush: 'sync' });
|
|
70
|
+
watch(fixed, () => {
|
|
71
|
+
// Pan mode only covers the frame. Rebase source geometry before editable handles can expose its margins.
|
|
72
|
+
if (current.value) restart(current.value.crop);
|
|
73
|
+
}, { flush: 'sync' });
|
|
74
|
+
watch(size, () => {
|
|
75
|
+
restoreFocus ||= !!host.value?.contains(host.value.ownerDocument.activeElement);
|
|
76
|
+
// A resized viewport restores source insets instead of reusing stale CSS pan offsets.
|
|
77
|
+
if (current.value) initial.value = { ...current.value.crop };
|
|
78
|
+
current.value = null;
|
|
79
|
+
announced = false;
|
|
80
|
+
}, { flush: 'sync' });
|
|
81
|
+
onMounted(() => {
|
|
82
|
+
if (model.value && !isImageCrop(model.value)) emit('error', new RangeError('Invalid initial image crop.'));
|
|
83
|
+
if (!host.value) return;
|
|
84
|
+
let settled = false;
|
|
85
|
+
let measuring = false;
|
|
86
|
+
let pendingWidth = 0;
|
|
87
|
+
observer = new ResizeObserver(async entries => {
|
|
88
|
+
pendingWidth = entries[0]?.contentRect.width ?? 0;
|
|
89
|
+
if (settled) { width.value = pendingWidth; return; }
|
|
90
|
+
if (measuring) return;
|
|
91
|
+
measuring = true;
|
|
92
|
+
// Wait for finite ancestor opening animations so Ark does not measure a scaled dialog.
|
|
93
|
+
const animations: Animation[] = [];
|
|
94
|
+
for (let element: HTMLElement | null = host.value; element; element = element.parentElement) {
|
|
95
|
+
animations.push(...element.getAnimations().filter(animation =>
|
|
96
|
+
animation.playState === 'running' && animation.effect?.getTiming().iterations !== Infinity));
|
|
97
|
+
}
|
|
98
|
+
await Promise.allSettled(animations.map(animation => animation.finished));
|
|
99
|
+
settled = true;
|
|
100
|
+
if (host.value) width.value = pendingWidth;
|
|
101
|
+
});
|
|
102
|
+
observer.observe(host.value);
|
|
103
|
+
});
|
|
104
|
+
onBeforeUnmount(() => observer?.disconnect());
|
|
105
|
+
/** @param result - Geometry produced by the current Ark session. */
|
|
106
|
+
function update(result: QuireKitImageCropResult): void {
|
|
107
|
+
current.value = result;
|
|
108
|
+
lastEmitted = result.crop;
|
|
109
|
+
if (!model.value || !equalImageCrop(model.value, result.crop)) model.value = { ...result.crop };
|
|
110
|
+
emit('change', result);
|
|
111
|
+
if (!announced) {
|
|
112
|
+
announced = true;
|
|
113
|
+
emit('ready', result);
|
|
114
|
+
if (restoreFocus) {
|
|
115
|
+
restoreFocus = false;
|
|
116
|
+
void nextTick(() => {
|
|
117
|
+
// Do not steal focus if the consumer moved to another control while the image loaded.
|
|
118
|
+
const doc = host.value?.ownerDocument;
|
|
119
|
+
if (doc && doc.activeElement === doc.body) session.value?.focusSelection();
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** @param error - Failure from the actual mounted image after its preload. */
|
|
125
|
+
function failSession(error: Error): void {
|
|
126
|
+
source.failed.value = true;
|
|
127
|
+
current.value = null;
|
|
128
|
+
emit('error', error);
|
|
129
|
+
}
|
|
130
|
+
/** @param value - Selected ratio token. */
|
|
131
|
+
function selectRatio(value: string | undefined): void { aspectRatio.value = value === 'free' || !value ? undefined : Number(value); }
|
|
132
|
+
/** @param values - Slider percent values. */
|
|
133
|
+
function setZoom(values: number[] | undefined): void { session.value?.setZoom((values?.[0] ?? 100) / 100); }
|
|
134
|
+
/** @param event - Interaction blocked before upstream listeners when disabled. */
|
|
135
|
+
function blockDisabled(event: Event): void {
|
|
136
|
+
if (!props.disabled) return;
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
event.stopImmediatePropagation();
|
|
139
|
+
}
|
|
140
|
+
/** @returns Current valid source crop, or null during loading or replacement. */
|
|
141
|
+
function getCrop(): QuireKitImageCropResult | null { return source.failed.value || !source.size.value ? null : session.value?.getCrop() ?? null; }
|
|
142
|
+
/** Restores the largest centered region allowed by the selected aspect ratio. */
|
|
143
|
+
function reset(): void { if (!props.disabled) restart(fullImageCrop); }
|
|
144
|
+
/** @param options - Requested raster export. @returns Blob produced from the current source. */
|
|
145
|
+
async function getCroppedImage(options?: QuireKitImageCropExportOptions): Promise<Blob> {
|
|
146
|
+
const active = session.value;
|
|
147
|
+
if (!active || !getCrop()) throw new Error('Image cropper is not ready.');
|
|
148
|
+
return active.getCroppedImage(options);
|
|
149
|
+
}
|
|
150
|
+
defineExpose({ getCrop, reset, getCroppedImage });
|
|
151
|
+
</script>
|
|
152
|
+
<template>
|
|
153
|
+
<section class="qk-image-cropper" :aria-label="copy.label" :data-disabled="disabled ? '' : undefined">
|
|
154
|
+
<div v-if="toolbar" class="qk-image-cropper__toolbar">
|
|
155
|
+
<QuireSegmented v-if="!fixedCropArea" v-model="mode" :label="copy.label" :items="[{ value: 'frame', label: copy.frame }, { value: 'pan', label: copy.pan }]" :disabled="disabled || !current" />
|
|
156
|
+
<QuireSelect :model-value="ratio ? String(ratio) : 'free'" :items="ratioItems" :label="copy.aspectRatio" :disabled="disabled || !current" class="qk-image-cropper__ratio" @update:model-value="selectRatio" />
|
|
157
|
+
<QuireButton variant="outline" :disabled="disabled || !current" class="qk-image-cropper__reset" @click="reset">{{ copy.reset }}</QuireButton>
|
|
158
|
+
</div>
|
|
159
|
+
<div ref="host" class="qk-image-cropper__stage" :style="{ minHeight: `${Math.min(160, height)}px` }"
|
|
160
|
+
@pointerdown.capture="blockDisabled" @wheel.capture="blockDisabled" @touchstart.capture="blockDisabled" @touchmove.capture="blockDisabled" @keydown.capture="blockDisabled">
|
|
161
|
+
<div v-if="source.failed.value" class="qk-image-cropper__status" role="alert">
|
|
162
|
+
<span>{{ copy.unavailable }}</span><QuireButton variant="outline" :disabled="disabled" @click="source.retry">{{ copy.retry }}</QuireButton>
|
|
163
|
+
</div>
|
|
164
|
+
<CropperSession v-else-if="size" :key="sessionKey" ref="session" :src="src" :alt="alt" :size="size" :source-image="source.loadedImage.value" :initial="initial" :ratio="ratio" :copy="copy"
|
|
165
|
+
:grid="grid" :fixed-crop-area="fixed" :disabled="disabled" :crossorigin="crossorigin" :referrerpolicy="referrerpolicy"
|
|
166
|
+
:inert="disabled || undefined" @change="update" @error="failSession" @zoom="zoom = $event" />
|
|
167
|
+
<div v-else class="qk-image-cropper__status" role="status">{{ copy.loading }}</div>
|
|
168
|
+
</div>
|
|
169
|
+
<div v-if="toolbar" class="qk-image-cropper__footer">
|
|
170
|
+
<QuireSlider :label="copy.zoom" :model-value="[Math.round(zoom * 100)]" :min="100" :max="500" :step="1" unit="%" :disabled="disabled || !current" class="qk-image-cropper__zoom" @update:model-value="setZoom" />
|
|
171
|
+
<span v-if="current" class="qk-image-cropper__dimensions">{{ current.outputSize.width }} × {{ current.outputSize.height }} px</span>
|
|
172
|
+
</div>
|
|
173
|
+
<p class="qk-image-cropper__help">{{ fixed ? copy.panInstructions : copy.instructions }}</p>
|
|
174
|
+
<slot :result="current" :reset="reset" />
|
|
175
|
+
</section>
|
|
176
|
+
</template>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { default as QuireImageCropper } from './image-cropper.vue';
|
|
2
|
+
export type { QuireKitImageCrop, QuireKitImageCropSize, QuireKitImageCropResult, QuireKitImageCropperProps, QuireKitImageCropperLabels, QuireKitImageCropExportOptions, QuireKitImageCropperApi } from './types';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { QuireKitImageCrop, QuireKitImageCropperLabels, QuireKitImageCropperProps, QuireKitImageCropSize } from './types';
|
|
2
|
+
/** One measured source session; changing source or geometry creates a new session. */
|
|
3
|
+
export interface CropperSessionProps extends QuireKitImageCropperProps {
|
|
4
|
+
/** Unstyled, decoded original used for browser-consistent SVG raster export. */ readonly sourceImage: HTMLImageElement | null;
|
|
5
|
+
/** Starting source geometry. */ readonly initial: QuireKitImageCrop;
|
|
6
|
+
/** Measured image viewport. */ readonly size: QuireKitImageCropSize;
|
|
7
|
+
/** Resolved output ratio. */ readonly ratio?: number | undefined;
|
|
8
|
+
/** Fully resolved localized copy. */ readonly copy: QuireKitImageCropperLabels;
|
|
9
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ImageCropper, useImageCropper } from '@ark-ui/vue/image-cropper';
|
|
3
|
+
import { computed, onBeforeUnmount, shallowRef, watch } from 'vue';
|
|
4
|
+
import { exportImageCrop } from './export';
|
|
5
|
+
import { projectImageCrop, sourceImageCrop } from './geometry';
|
|
6
|
+
import type { CropperSessionProps } from './session-types';
|
|
7
|
+
import type { QuireKitImageCropExportOptions, QuireKitImageCropResult } from './types';
|
|
8
|
+
const props = defineProps<CropperSessionProps>();
|
|
9
|
+
const emit = defineEmits<{ change: [result: QuireKitImageCropResult]; zoom: [zoom: number]; error: [error: Error] }>();
|
|
10
|
+
const api = useImageCropper(computed(() => ({
|
|
11
|
+
initialCrop: projectImageCrop(props.initial, props.size, props.ratio),
|
|
12
|
+
aspectRatio: props.ratio, minWidth: 1, minHeight: 1, minZoom: 1, maxZoom: 5,
|
|
13
|
+
fixedCropArea: props.fixedCropArea,
|
|
14
|
+
translations: {
|
|
15
|
+
rootLabel: props.copy.root(props.alt), rootRoleDescription: props.copy.label,
|
|
16
|
+
previewLoading: props.copy.loading, previewDescription: () => props.alt,
|
|
17
|
+
selectionLabel: () => props.copy.selection, selectionRoleDescription: props.copy.selection,
|
|
18
|
+
selectionInstructions: props.fixedCropArea ? props.copy.panInstructions : props.copy.instructions,
|
|
19
|
+
selectionValueText: ({ width, height }) => `${Math.round(width)} × ${Math.round(height)}`
|
|
20
|
+
}
|
|
21
|
+
})));
|
|
22
|
+
const root = shallowRef<HTMLElement | null>(null);
|
|
23
|
+
let active = true;
|
|
24
|
+
onBeforeUnmount(() => { active = false; });
|
|
25
|
+
/** @returns Exact source-space crop, independent of rounded upstream pixel bounds. */
|
|
26
|
+
function getCrop(): QuireKitImageCropResult | null {
|
|
27
|
+
const value = api.value;
|
|
28
|
+
if (!active || !value.naturalSize.width || !value.viewportRect.width || !value.crop.width) return null;
|
|
29
|
+
// Ark owns interaction; project its floating-point viewport state before any DOM integer rounding.
|
|
30
|
+
const { size } = props;
|
|
31
|
+
const x = ((value.crop.x - size.width / 2 - value.offset.x) / value.zoom + size.width / 2) / size.width;
|
|
32
|
+
const y = ((value.crop.y - size.height / 2 - value.offset.y) / value.zoom + size.height / 2) / size.height;
|
|
33
|
+
const right = x + value.crop.width / value.zoom / size.width;
|
|
34
|
+
const bottom = y + value.crop.height / value.zoom / size.height;
|
|
35
|
+
const crop = sourceImageCrop(x, y, right, bottom, { width: 1, height: 1 });
|
|
36
|
+
if (!crop) return null;
|
|
37
|
+
return { crop, naturalSize: { ...value.naturalSize }, outputSize: {
|
|
38
|
+
width: Math.max(1, Math.round((1 - crop.left - crop.right) * value.naturalSize.width)),
|
|
39
|
+
height: Math.max(1, Math.round((1 - crop.top - crop.bottom) * value.naturalSize.height))
|
|
40
|
+
} };
|
|
41
|
+
}
|
|
42
|
+
watch(() => [api.value.crop, api.value.offset, api.value.zoom, api.value.naturalSize, api.value.viewportRect], () => {
|
|
43
|
+
const result = getCrop();
|
|
44
|
+
if (result) emit('change', result);
|
|
45
|
+
emit('zoom', api.value.zoom);
|
|
46
|
+
}, { flush: 'post' });
|
|
47
|
+
/** Uses Ark's ratio-aware resize path for its Alt-arrow shortcut gap.
|
|
48
|
+
* @param event - Keyboard event from the crop selection.
|
|
49
|
+
*/
|
|
50
|
+
function resizeWithKeyboard(event: KeyboardEvent): void {
|
|
51
|
+
if (!props.ratio || !event.altKey || props.fixedCropArea || props.disabled) return;
|
|
52
|
+
if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) return;
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
event.stopPropagation();
|
|
55
|
+
const step = event.ctrlKey || event.metaKey ? 50 : event.shiftKey ? 10 : 1;
|
|
56
|
+
api.value.resize(event.key === 'ArrowLeft' || event.key === 'ArrowRight' ? 'e' : 's',
|
|
57
|
+
step * (event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1));
|
|
58
|
+
}
|
|
59
|
+
/** @param zoom - Requested source magnification. */
|
|
60
|
+
function setZoom(zoom: number): void { if (!props.disabled) api.value.setZoom(zoom); }
|
|
61
|
+
/** @param options - Explicit export options. @returns A current-session Blob or rejects. */
|
|
62
|
+
async function getCroppedImage(options: QuireKitImageCropExportOptions = {}): Promise<Blob> {
|
|
63
|
+
const result = getCrop();
|
|
64
|
+
const image = props.sourceImage;
|
|
65
|
+
if (!result || !image) throw new Error('Image cropper is not ready.');
|
|
66
|
+
const blob = await exportImageCrop(image, result, options);
|
|
67
|
+
if (!active) throw new Error('Image cropper source changed during export.');
|
|
68
|
+
return blob;
|
|
69
|
+
}
|
|
70
|
+
/** Restores keyboard editing after a source-preserving session replacement. */
|
|
71
|
+
function focusSelection(): void { if (!props.disabled) root.value?.querySelector<HTMLElement>('[data-part="selection"]')?.focus(); }
|
|
72
|
+
defineExpose({ getCrop, setZoom, getCroppedImage, focusSelection });
|
|
73
|
+
</script>
|
|
74
|
+
<template>
|
|
75
|
+
<ImageCropper.RootProvider :value="api" class="qk-image-cropper__session" :style="{ width: `${size.width}px`, height: `${size.height}px` }">
|
|
76
|
+
<div ref="root" class="qk-image-cropper__viewport"><ImageCropper.Viewport class="qk-image-cropper__viewport">
|
|
77
|
+
<ImageCropper.Image :src="src" @error="emit('error', new Error('Image cropper source became unavailable.'))" :crossorigin="crossorigin" :referrerpolicy="referrerpolicy" class="qk-image-cropper__image" />
|
|
78
|
+
<ImageCropper.Selection class="qk-image-cropper__selection" @keydown.capture="resizeWithKeyboard">
|
|
79
|
+
<template v-if="grid"><ImageCropper.Grid axis="horizontal" class="qk-image-cropper__grid" /><ImageCropper.Grid axis="vertical" class="qk-image-cropper__grid" /></template>
|
|
80
|
+
<template v-if="!fixedCropArea"><ImageCropper.Handle v-for="position in (['n','e','s','w','ne','se','sw','nw'] as const)" :key="position" :position="position" class="qk-image-cropper__handle"><span /></ImageCropper.Handle></template>
|
|
81
|
+
</ImageCropper.Selection>
|
|
82
|
+
</ImageCropper.Viewport></div>
|
|
83
|
+
</ImageCropper.RootProvider>
|
|
84
|
+
</template>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Messages as QuireKitImageCropperMessages } from '../../locale/components/image-cropper';
|
|
2
|
+
import type { ImgHTMLAttributes } from 'vue';
|
|
3
|
+
|
|
4
|
+
/** Normalized fractions removed from the original image edges. */
|
|
5
|
+
export interface QuireKitImageCrop {
|
|
6
|
+
/** Fraction removed from the top. */ readonly top: number;
|
|
7
|
+
/** Fraction removed from the right. */ readonly right: number;
|
|
8
|
+
/** Fraction removed from the bottom. */ readonly bottom: number;
|
|
9
|
+
/** Fraction removed from the left. */ readonly left: number;
|
|
10
|
+
}
|
|
11
|
+
/** Image or viewport dimensions in their owning coordinate space. */
|
|
12
|
+
export interface QuireKitImageCropSize {
|
|
13
|
+
/** Width in pixels. */ readonly width: number;
|
|
14
|
+
/** Height in pixels. */ readonly height: number;
|
|
15
|
+
}
|
|
16
|
+
/** Source crop and its natural image dimensions. */
|
|
17
|
+
export interface QuireKitImageCropResult {
|
|
18
|
+
/** Non-destructive source insets. */ readonly crop: QuireKitImageCrop;
|
|
19
|
+
/** Browser-decoded original image dimensions. */ readonly naturalSize: QuireKitImageCropSize;
|
|
20
|
+
/** Rounded size of the retained source pixels. */ readonly outputSize: QuireKitImageCropSize;
|
|
21
|
+
}
|
|
22
|
+
/** Crop controls and accessible instructions, supplied by the active language. */
|
|
23
|
+
export type QuireKitImageCropperLabels = QuireKitImageCropperMessages;
|
|
24
|
+
/** Reusable image crop workspace; mounting and persistence belong to the consumer. */
|
|
25
|
+
export interface QuireKitImageCropperProps {
|
|
26
|
+
/** Browser-readable original image URL. */ readonly src: string;
|
|
27
|
+
/** Description of the original image. */ readonly alt: string;
|
|
28
|
+
/** Maximum image stage height in CSS pixels, default 360. */ readonly height?: number;
|
|
29
|
+
/** Show ratio, mode, zoom and reset controls, default true. */ readonly toolbar?: boolean;
|
|
30
|
+
/** Show thirds guides, default true. */ readonly grid?: boolean;
|
|
31
|
+
/** Lock the crop frame and move the image underneath, default false. */ readonly fixedCropArea?: boolean;
|
|
32
|
+
/** Disable all edits, default false. */ readonly disabled?: boolean;
|
|
33
|
+
/** Native image CORS setting; omitted by default. */ readonly crossorigin?: ImgHTMLAttributes['crossorigin'];
|
|
34
|
+
/** Native image referrer policy. */ readonly referrerpolicy?: ImgHTMLAttributes['referrerpolicy'];
|
|
35
|
+
}
|
|
36
|
+
/** Explicit raster export settings. */
|
|
37
|
+
export interface QuireKitImageCropExportOptions {
|
|
38
|
+
/** Browser image encoding, default image/png. */ readonly type?: 'image/png' | 'image/jpeg' | 'image/webp';
|
|
39
|
+
/** Lossy encoding quality from 0 to 1, default 0.92. */ readonly quality?: number;
|
|
40
|
+
/** Proportional maximum size, default 4096 by 4096. */ readonly maxSize?: QuireKitImageCropSize;
|
|
41
|
+
}
|
|
42
|
+
/** Instance methods for consumer-owned confirmation and export. */
|
|
43
|
+
export interface QuireKitImageCropperApi {
|
|
44
|
+
/** @returns Current valid source geometry, or null before ready. */ getCrop(): QuireKitImageCropResult | null;
|
|
45
|
+
/** Restores the largest centered crop for the active ratio. */ reset(): void;
|
|
46
|
+
/** @param options - Raster encoding and size limits. @returns Cropped image; rejects when unavailable, stale or blocked. */ getCroppedImage(options?: QuireKitImageCropExportOptions): Promise<Blob>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { onMounted, ref, shallowRef, watch } from 'vue';
|
|
2
|
+
import type { QuireKitImageCropperProps, QuireKitImageCropSize } from './types';
|
|
3
|
+
|
|
4
|
+
/** Loads one current source without allowing stale requests to replace its dimensions.
|
|
5
|
+
* @param props - Current native image request inputs.
|
|
6
|
+
* @param onError - Consumer failure notification.
|
|
7
|
+
* @returns Reactive source state and retry action.
|
|
8
|
+
*/
|
|
9
|
+
export function useCropperSource(props: QuireKitImageCropperProps, onError: (error: Error) => void) {
|
|
10
|
+
const mounted = ref(false);
|
|
11
|
+
const attempt = ref(0);
|
|
12
|
+
const loadedImage = shallowRef<HTMLImageElement | null>(null);
|
|
13
|
+
const size = shallowRef<QuireKitImageCropSize | null>(null);
|
|
14
|
+
const failed = ref(false);
|
|
15
|
+
onMounted(() => { mounted.value = true; });
|
|
16
|
+
watch([mounted, () => props.src, () => props.crossorigin, () => props.referrerpolicy, attempt], (_, __, cleanup) => {
|
|
17
|
+
loadedImage.value = null;
|
|
18
|
+
size.value = null;
|
|
19
|
+
failed.value = false;
|
|
20
|
+
if (!mounted.value) return;
|
|
21
|
+
let active = true;
|
|
22
|
+
const image = new Image();
|
|
23
|
+
image.onload = () => {
|
|
24
|
+
if (!active) return;
|
|
25
|
+
if (!image.naturalWidth || !image.naturalHeight) { image.onerror?.(new Event('error')); return; }
|
|
26
|
+
loadedImage.value = image;
|
|
27
|
+
size.value = { width: image.naturalWidth, height: image.naturalHeight };
|
|
28
|
+
};
|
|
29
|
+
image.onerror = () => {
|
|
30
|
+
if (!active) return;
|
|
31
|
+
failed.value = true;
|
|
32
|
+
onError(new Error('Image cropper source could not be loaded.'));
|
|
33
|
+
};
|
|
34
|
+
if (props.crossorigin !== undefined) image.crossOrigin = props.crossorigin ?? '';
|
|
35
|
+
if (props.referrerpolicy !== undefined) image.referrerPolicy = props.referrerpolicy ?? '';
|
|
36
|
+
if (props.src) image.src = props.src;
|
|
37
|
+
else image.onerror(new Event('error'));
|
|
38
|
+
cleanup(() => { active = false; image.onload = null; image.onerror = null; image.removeAttribute('src'); });
|
|
39
|
+
}, { immediate: true, flush: 'sync' });
|
|
40
|
+
return { size, loadedImage, failed, attempt, retry: () => { attempt.value++; } };
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createTheme } from '../../theme';
|
|
2
|
+
import { createUiThemeCssVariables } from '../../styles';
|
|
3
|
+
|
|
4
|
+
/** @param scheme - Surface contrast appropriate for the chosen mask. @returns Semantic colors without replacing host geometry or typography. */
|
|
5
|
+
function colors(scheme: 'light' | 'dark'): Readonly<Record<string, string>> {
|
|
6
|
+
return Object.freeze(Object.fromEntries(Object.entries(createUiThemeCssVariables(createTheme({ scheme })))
|
|
7
|
+
.filter(([name]) => name.startsWith('--qk-color-') || (name.startsWith('--qk-button-') && /foreground|background|border-color|focus-color/.test(name)))));
|
|
8
|
+
}
|
|
9
|
+
/** Reuses public theme colors for preview controls on dark or light masks. */
|
|
10
|
+
export const previewColors = { light: colors('light'), dark: colors('dark') };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { effectScope, nextTick, ref } from 'vue';
|
|
2
|
+
import { expect, it } from 'vitest';
|
|
3
|
+
import { anchoredPan, clampPan, fitScale, rotatedSize } from './geometry';
|
|
4
|
+
import { useImageTransform } from './use-transform';
|
|
5
|
+
|
|
6
|
+
it('fits portrait, landscape, rotated and small images without cropping or upscaling', () => {
|
|
7
|
+
const viewport = { width: 800, height: 600 };
|
|
8
|
+
expect(fitScale({ width: 2000, height: 1000 }, viewport)).toBe(.4);
|
|
9
|
+
expect(fitScale({ width: 400, height: 1600 }, viewport)).toBe(.375);
|
|
10
|
+
expect(fitScale({ width: 100, height: 100 }, viewport)).toBe(1);
|
|
11
|
+
expect(rotatedSize({ width: 2000, height: 1000 }, 90)).toEqual({ width: 1000, height: 2000 });
|
|
12
|
+
expect(fitScale(rotatedSize({ width: 2000, height: 1000 }, 270), viewport)).toBe(.3);
|
|
13
|
+
});
|
|
14
|
+
it('anchors zoom under the pointer and keeps the image recoverable at every boundary', () => {
|
|
15
|
+
const center = anchoredPan({ x: 10, y: 20 }, { x: 100, y: 50 }, 2);
|
|
16
|
+
expect(center).toEqual({ x: -80, y: -10 });
|
|
17
|
+
expect(clampPan({ x: 900, y: -900 }, { width: 2000, height: 1000 }, { width: 800, height: 600 }, .5)).toEqual({ x: 100, y: 0 });
|
|
18
|
+
});
|
|
19
|
+
it('preserves fit on resize, clamps zoomed pan, rotates and resets on a new resource', async () => {
|
|
20
|
+
const scope = effectScope();
|
|
21
|
+
const viewport = ref({ width: 800, height: 600 });
|
|
22
|
+
const api = scope.run(() => useImageTransform(viewport))!;
|
|
23
|
+
api.load({ width: 2000, height: 1000 }); expect(api.scale.value).toBe(.4);
|
|
24
|
+
viewport.value = { width: 400, height: 600 }; await nextTick(); expect(api.scale.value).toBe(.2);
|
|
25
|
+
api.actual(); expect(api.scale.value).toBe(1);
|
|
26
|
+
api.panTo({ x: 9000, y: -9000 }); expect(api.offset.value).toEqual({ x: 800, y: -200 });
|
|
27
|
+
api.rotate(); expect(api.angle.value).toBe(90); expect(api.scale.value).toBe(.3);
|
|
28
|
+
api.rotate(-1); expect(api.angle.value).toBe(0); expect(api.scale.value).toBe(.2);
|
|
29
|
+
api.zoomTo(100); expect(api.scale.value).toBe(8);
|
|
30
|
+
api.load({ width: 200, height: 200 }); expect(api.scale.value).toBe(1); expect(api.angle.value).toBe(0); expect(api.offset.value).toEqual({ x: 0, y: 0 });
|
|
31
|
+
scope.stop();
|
|
32
|
+
});
|
|
33
|
+
it('allows shrinking below fit and preserves manual zoom when the viewport changes', () => {
|
|
34
|
+
const scope = effectScope();
|
|
35
|
+
const viewport = ref({ width: 800, height: 600 });
|
|
36
|
+
const api = scope.run(() => useImageTransform(viewport))!;
|
|
37
|
+
api.load({ width: 2000, height: 1000 });
|
|
38
|
+
api.zoomBy(.8); expect(api.scale.value).toBeCloseTo(.32);
|
|
39
|
+
viewport.value = { width: 1000, height: 800 }; expect(api.scale.value).toBeCloseTo(.32);
|
|
40
|
+
api.zoomTo(0); expect(api.scale.value).toBe(.1);
|
|
41
|
+
api.fit(); expect(api.scale.value).toBe(.5);
|
|
42
|
+
api.load({ width: 40000, height: 20000 });
|
|
43
|
+
const fitted = api.scale.value;
|
|
44
|
+
api.zoomBy(.8); expect(api.scale.value).toBeCloseTo(fitted * .8);
|
|
45
|
+
scope.stop();
|
|
46
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PreviewPoint, PreviewSize } from './types';
|
|
2
|
+
|
|
3
|
+
/** @param size - Natural dimensions. @param angle - Rotation in degrees. @returns Screen-aligned dimensions. */
|
|
4
|
+
export function rotatedSize(size: PreviewSize, angle: number): PreviewSize {
|
|
5
|
+
return Math.abs(angle % 180) === 90 ? { width: size.height, height: size.width } : size;
|
|
6
|
+
}
|
|
7
|
+
/** @param image - Rotated natural dimensions. @param viewport - Stage dimensions. @returns Fit scale without enlarging small images. */
|
|
8
|
+
export function fitScale(image: PreviewSize, viewport: PreviewSize): number {
|
|
9
|
+
if (image.width <= 0 || image.height <= 0 || viewport.width <= 0 || viewport.height <= 0) return 1;
|
|
10
|
+
return Math.min(1, viewport.width / image.width, viewport.height / image.height);
|
|
11
|
+
}
|
|
12
|
+
/** @param point - Requested pan. @param image - Rotated natural dimensions. @param viewport - Stage dimensions. @param scale - Natural image scale. @returns Pan that never loses the image outside the viewport. */
|
|
13
|
+
export function clampPan(point: PreviewPoint, image: PreviewSize, viewport: PreviewSize, scale: number): PreviewPoint {
|
|
14
|
+
const x = Math.max(0, (image.width * scale - viewport.width) / 2);
|
|
15
|
+
const y = Math.max(0, (image.height * scale - viewport.height) / 2);
|
|
16
|
+
return { x: x ? Math.max(-x, Math.min(x, point.x)) : 0, y: y ? Math.max(-y, Math.min(y, point.y)) : 0 };
|
|
17
|
+
}
|
|
18
|
+
/** @param offset - Existing image center. @param anchor - Fixed screen point. @param ratio - New scale divided by previous scale. @returns Center preserving the image point under the pointer. */
|
|
19
|
+
export function anchoredPan(offset: PreviewPoint, anchor: PreviewPoint, ratio: number): PreviewPoint {
|
|
20
|
+
return { x: anchor.x - (anchor.x - offset.x) * ratio, y: anchor.y - (anchor.y - offset.y) * ratio };
|
|
21
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InjectionKey } from "vue";
|
|
2
|
+
import type { ImagePreviewGroupContext } from "./types";
|
|
3
|
+
|
|
4
|
+
/** Only explicit adapters opt an Image into a containing group. */
|
|
5
|
+
export const imagePreviewGroupKey: InjectionKey<ImagePreviewGroupContext | null> = Symbol("quirekit.image-preview-group");
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComputedRef, Ref, ShallowRef, WritableComputedRef } from "vue";
|
|
2
|
+
import type { QuireKitImagePreviewItem, QuireKitImagePreviewOptions } from "../types";
|
|
3
|
+
|
|
4
|
+
/** One mounted image supplies its own resource and eligibility state. */
|
|
5
|
+
export interface ImagePreviewGroupMember {
|
|
6
|
+
/** Stable instance identity, independent of duplicate source URLs. */
|
|
7
|
+
readonly id: string;
|
|
8
|
+
/** Image-owned element used to determine document order. */
|
|
9
|
+
readonly element: Readonly<Ref<HTMLElement | null>>;
|
|
10
|
+
/** Original or responsive resource selected by the Image owner. */
|
|
11
|
+
readonly item: ComputedRef<QuireKitImagePreviewItem>;
|
|
12
|
+
/** Whether this image participates, including images still loading. */
|
|
13
|
+
readonly enabled: ComputedRef<boolean>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Internal bridge from an image to its containing preview group. */
|
|
17
|
+
export interface ImagePreviewGroupContext {
|
|
18
|
+
/** @param member - Mounted image. @returns Unregister callback. */
|
|
19
|
+
readonly register: (member: ImagePreviewGroupMember) => () => void;
|
|
20
|
+
/** @param id - Clicked image identity. @param trigger - Focus restoration target. @param options - Per-image overrides. @returns Whether the group handled this request. */
|
|
21
|
+
readonly open: (id: string, trigger: HTMLElement, options?: QuireKitImagePreviewOptions) => boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Reactive inputs for the existing ImagePreview presentation and controls. */
|
|
25
|
+
export interface ImagePreviewGroupState {
|
|
26
|
+
/** Registration and open bridge provided by the owning container. */
|
|
27
|
+
readonly context: ImagePreviewGroupContext;
|
|
28
|
+
/** Re-evaluate reading order after the owning collection reorders mounted children. */
|
|
29
|
+
readonly refresh: () => void;
|
|
30
|
+
/** Eligible resources in reading order. */
|
|
31
|
+
readonly items: ComputedRef<readonly QuireKitImagePreviewItem[]>;
|
|
32
|
+
/** Shared preview visibility. */
|
|
33
|
+
readonly opened: Ref<boolean>;
|
|
34
|
+
/** Current resource index, preserving identity during membership changes. */
|
|
35
|
+
readonly index: WritableComputedRef<number>;
|
|
36
|
+
/** Options supplied by the image that opened the group. */
|
|
37
|
+
readonly options: ShallowRef<QuireKitImagePreviewOptions | undefined>;
|
|
38
|
+
/** @returns Connected original trigger, if still mounted. */
|
|
39
|
+
readonly finalFocusEl: () => HTMLElement | null;
|
|
40
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { computed, effectScope, nextTick, ref, shallowRef } from "vue";
|
|
3
|
+
import { expect, it, vi } from "vitest";
|
|
4
|
+
import { useImagePreviewGroup } from "./use";
|
|
5
|
+
|
|
6
|
+
it("orders mounted instances, preserves identity on updates and removes stale members", async () => {
|
|
7
|
+
const root = document.createElement("article");
|
|
8
|
+
const first = document.createElement("button");
|
|
9
|
+
const second = document.createElement("button");
|
|
10
|
+
root.append(first, second); document.body.append(root);
|
|
11
|
+
const scope = effectScope();
|
|
12
|
+
const accepts = vi.fn((element: HTMLElement) => root.contains(element));
|
|
13
|
+
const group = scope.run(() => useImagePreviewGroup(accepts))!;
|
|
14
|
+
const source = ref("/same.svg");
|
|
15
|
+
const enabled = ref(true);
|
|
16
|
+
const secondMember = { id: "second", element: shallowRef<HTMLElement | null>(second), item: computed(() => ({ id: "ignored", src: source.value, alt: "second" })), enabled: computed(() => enabled.value) };
|
|
17
|
+
const firstMember = { id: "first", element: shallowRef<HTMLElement | null>(first), item: computed(() => ({ id: "ignored", src: "/same.svg", alt: "first" })), enabled: computed(() => true) };
|
|
18
|
+
const removeSecond = group.context.register(secondMember);
|
|
19
|
+
const removeFirst = group.context.register(firstMember);
|
|
20
|
+
try {
|
|
21
|
+
expect(group.context.open("second", second)).toBe(true);
|
|
22
|
+
expect(group.items.value.map(item => item.id)).toEqual(["first", "second"]);
|
|
23
|
+
expect(group.index.value).toBe(1);
|
|
24
|
+
await nextTick();
|
|
25
|
+
root.prepend(second);
|
|
26
|
+
group.refresh();
|
|
27
|
+
expect(group.items.value.map(item => item.id)).toEqual(["second", "first"]);
|
|
28
|
+
expect(group.index.value).toBe(0);
|
|
29
|
+
root.prepend(first); group.refresh();
|
|
30
|
+
expect(group.index.value).toBe(1);
|
|
31
|
+
accepts.mockClear();
|
|
32
|
+
group.index.value = 0;
|
|
33
|
+
group.index.value = 1;
|
|
34
|
+
source.value = "/responsive.svg";
|
|
35
|
+
expect(group.items.value[1]?.src).toBe("/responsive.svg");
|
|
36
|
+
expect(group.index.value).toBe(1);
|
|
37
|
+
expect(group.finalFocusEl()).toBe(second);
|
|
38
|
+
await nextTick();
|
|
39
|
+
expect(accepts).not.toHaveBeenCalled();
|
|
40
|
+
removeFirst(); await nextTick();
|
|
41
|
+
expect(group.items.value.map(item => item.id)).toEqual(["second"]);
|
|
42
|
+
expect(group.index.value).toBe(0);
|
|
43
|
+
enabled.value = false; await nextTick();
|
|
44
|
+
expect(group.opened.value).toBe(false);
|
|
45
|
+
enabled.value = true; await nextTick();
|
|
46
|
+
expect(group.context.open("second", second)).toBe(true);
|
|
47
|
+
removeSecond(); await nextTick();
|
|
48
|
+
expect(group.items.value).toEqual([]);
|
|
49
|
+
expect(group.opened.value).toBe(false);
|
|
50
|
+
second.remove();
|
|
51
|
+
expect(group.finalFocusEl()).toBeNull();
|
|
52
|
+
} finally { scope.stop(); root.remove(); }
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("declines isolated images and refreshes DOM order when reopening", () => {
|
|
56
|
+
const root = document.createElement("article");
|
|
57
|
+
const scope = effectScope();
|
|
58
|
+
const group = scope.run(() => useImagePreviewGroup(element => element.parentElement === root))!;
|
|
59
|
+
const buttons = [document.createElement("button"), document.createElement("button")];
|
|
60
|
+
root.append(...buttons); document.body.append(root);
|
|
61
|
+
buttons.forEach((element, index) => group.context.register({ id: String(index), element: shallowRef(element), item: computed(() => ({ id: String(index), src: `/${index}.svg`, alt: "" })), enabled: computed(() => true) }));
|
|
62
|
+
try {
|
|
63
|
+
expect(group.context.open("0", buttons[0]!)).toBe(true);
|
|
64
|
+
group.opened.value = false;
|
|
65
|
+
root.prepend(buttons[1]!);
|
|
66
|
+
expect(group.context.open("0", buttons[0]!)).toBe(true);
|
|
67
|
+
expect(group.index.value).toBe(1);
|
|
68
|
+
group.opened.value = false;
|
|
69
|
+
const island = document.createElement("div"); root.append(island); island.append(buttons[0]!);
|
|
70
|
+
expect(group.context.open("0", buttons[0]!)).toBe(false);
|
|
71
|
+
expect(group.items.value.map(item => item.id)).toEqual(["1"]);
|
|
72
|
+
} finally { scope.stop(); root.remove(); }
|
|
73
|
+
});
|