@hina-ui/vue 1.7.4 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/index.js +2251 -992
- package/dist/index.js.map +1 -1
- package/dist/shared/behavior/anchor-follow.ts +95 -0
- package/dist/shared/behavior/form.ts +187 -0
- package/dist/shared/behavior/ripple.ts +222 -0
- package/dist/shared/behavior/spoiler/painter.ts +197 -0
- package/dist/shared/behavior/spoiler/worklet.ts +199 -0
- package/dist/shared/behavior/toast.ts +243 -0
- package/dist/shared/lib/anchor.ts +83 -0
- package/dist/shared/lib/banner.ts +10 -0
- package/dist/shared/lib/calendar/format.ts +23 -0
- package/dist/shared/lib/caret.ts +48 -0
- package/dist/shared/lib/collapse.ts +29 -0
- package/dist/shared/lib/command-palette/hotkey.ts +27 -0
- package/dist/shared/lib/command-palette/match.ts +92 -0
- package/dist/shared/lib/data-list.ts +40 -0
- package/dist/shared/lib/data-table/column-sizing-styles.ts +41 -0
- package/dist/shared/lib/data-table/column-sizing.ts +101 -0
- package/dist/shared/lib/data-table/csv.ts +51 -0
- package/dist/shared/lib/data-table/layout.ts +199 -0
- package/dist/shared/lib/data-table/resize.ts +66 -0
- package/dist/shared/lib/data-table/state.ts +226 -0
- package/dist/shared/lib/data-table/utils.ts +80 -0
- package/dist/shared/lib/date-range-field/validity.ts +21 -0
- package/dist/shared/lib/date.ts +111 -0
- package/dist/shared/lib/field-focus.ts +36 -0
- package/dist/shared/lib/file-upload/select.ts +58 -0
- package/dist/shared/lib/file-upload/size.ts +16 -0
- package/dist/shared/lib/form/errors.ts +48 -0
- package/dist/shared/lib/form/focus.ts +10 -0
- package/dist/shared/lib/form/standard-schema.ts +26 -0
- package/dist/shared/lib/form/values.ts +23 -0
- package/dist/shared/lib/highlighter.ts +98 -0
- package/dist/shared/lib/iris-origin.ts +40 -0
- package/dist/shared/lib/lightbox/clip.ts +117 -0
- package/dist/shared/lib/lightbox/download.ts +29 -0
- package/dist/shared/lib/lightbox/gesture.ts +54 -0
- package/dist/shared/lib/lightbox/paging.ts +33 -0
- package/dist/shared/lib/lightbox/pose.ts +142 -0
- package/dist/shared/lib/lightbox/source.ts +17 -0
- package/dist/shared/lib/lightbox/types.ts +14 -0
- package/dist/shared/lib/lightbox/zoom.ts +127 -0
- package/dist/shared/lib/meter-group.ts +16 -0
- package/dist/shared/lib/overlay-anchor.ts +42 -0
- package/dist/shared/lib/pagination.ts +16 -0
- package/dist/shared/lib/pointer-corridor.ts +26 -0
- package/dist/shared/lib/qr-code-export.ts +68 -0
- package/dist/shared/lib/range-calendar/limit.ts +11 -0
- package/dist/shared/lib/rating.ts +4 -0
- package/dist/shared/lib/relative-time.ts +20 -0
- package/dist/shared/lib/scroll-area.ts +77 -0
- package/dist/shared/lib/scroll-restore.ts +148 -0
- package/dist/shared/lib/toast-layout.ts +42 -0
- package/dist/shared/lib/tree/selection.ts +131 -0
- package/dist/shared/lib/tree-select/filter.ts +19 -0
- package/dist/shared/lib/virtual/choices.ts +193 -0
- package/dist/shared/lib/virtual/collection.ts +71 -0
- package/dist/shared/lib/virtual/filter.ts +26 -0
- package/dist/shared/lib/virtual/flow.ts +32 -0
- package/dist/shared/lib/virtual/list.ts +63 -0
- package/dist/shared/lib/virtual/navigation.ts +26 -0
- package/dist/shared/lib/virtual/tree.ts +98 -0
- package/dist/shared/locale/en-US.ts +220 -0
- package/dist/shared/locale/index.ts +52 -0
- package/dist/shared/locale/types.ts +225 -0
- package/dist/shared/locale/zh-CN.ts +215 -0
- package/dist/shared/primitives/number-field/LICENSE +21 -0
- package/dist/shared/primitives/number-field/index.ts +407 -0
- package/dist/shared/styles/semantic.css +10 -2
- package/dist/shared/types/autocomplete.ts +16 -0
- package/dist/shared/types/data-table.ts +170 -0
- package/dist/shared/types/pagination.ts +19 -0
- package/dist/shared/types/select.ts +23 -0
- package/dist/shared/types/tree-select.ts +34 -0
- package/dist/shared/types/tree.ts +20 -0
- package/dist/types/shared/src/behavior/anchor-follow.d.ts +13 -0
- package/dist/types/shared/src/behavior/anchor-follow.d.ts.map +1 -0
- package/dist/types/shared/src/behavior/form.d.ts +24 -0
- package/dist/types/shared/src/behavior/form.d.ts.map +1 -0
- package/dist/types/shared/src/behavior/ripple.d.ts +11 -0
- package/dist/types/shared/src/behavior/ripple.d.ts.map +1 -0
- package/dist/types/shared/src/behavior/spoiler/painter.d.ts +35 -0
- package/dist/types/shared/src/behavior/spoiler/painter.d.ts.map +1 -0
- package/dist/types/shared/src/behavior/spoiler/worklet.d.ts +2 -0
- package/dist/types/shared/src/behavior/spoiler/worklet.d.ts.map +1 -0
- package/dist/types/shared/src/behavior/toast.d.ts +72 -0
- package/dist/types/shared/src/behavior/toast.d.ts.map +1 -0
- package/dist/types/shared/src/lib/anchor.d.ts +31 -0
- package/dist/types/shared/src/lib/anchor.d.ts.map +1 -0
- package/dist/types/shared/src/lib/banner.d.ts +3 -0
- package/dist/types/shared/src/lib/banner.d.ts.map +1 -0
- package/dist/types/shared/src/lib/calendar/format.d.ts +7 -0
- package/dist/types/shared/src/lib/calendar/format.d.ts.map +1 -0
- package/dist/types/shared/src/lib/caret.d.ts +2 -0
- package/dist/types/shared/src/lib/caret.d.ts.map +1 -0
- package/dist/types/shared/src/lib/collapse.d.ts +9 -0
- package/dist/types/shared/src/lib/collapse.d.ts.map +1 -0
- package/dist/types/shared/src/lib/command-palette/hotkey.d.ts +9 -0
- package/dist/types/shared/src/lib/command-palette/hotkey.d.ts.map +1 -0
- package/dist/types/shared/src/lib/command-palette/match.d.ts +21 -0
- package/dist/types/shared/src/lib/command-palette/match.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-list.d.ts +7 -0
- package/dist/types/shared/src/lib/data-list.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-table/column-sizing-styles.d.ts +8 -0
- package/dist/types/shared/src/lib/data-table/column-sizing-styles.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-table/column-sizing.d.ts +22 -0
- package/dist/types/shared/src/lib/data-table/column-sizing.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-table/csv.d.ts +5 -0
- package/dist/types/shared/src/lib/data-table/csv.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-table/layout.d.ts +28 -0
- package/dist/types/shared/src/lib/data-table/layout.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-table/resize.d.ts +15 -0
- package/dist/types/shared/src/lib/data-table/resize.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-table/state.d.ts +103 -0
- package/dist/types/shared/src/lib/data-table/state.d.ts.map +1 -0
- package/dist/types/shared/src/lib/data-table/utils.d.ts +11 -0
- package/dist/types/shared/src/lib/data-table/utils.d.ts.map +1 -0
- package/dist/types/shared/src/lib/date-range-field/validity.d.ts +12 -0
- package/dist/types/shared/src/lib/date-range-field/validity.d.ts.map +1 -0
- package/dist/types/shared/src/lib/date.d.ts +28 -0
- package/dist/types/shared/src/lib/date.d.ts.map +1 -0
- package/dist/types/shared/src/lib/field-focus.d.ts +2 -0
- package/dist/types/shared/src/lib/field-focus.d.ts.map +1 -0
- package/dist/types/shared/src/lib/file-upload/select.d.ts +17 -0
- package/dist/types/shared/src/lib/file-upload/select.d.ts.map +1 -0
- package/dist/types/shared/src/lib/file-upload/size.d.ts +2 -0
- package/dist/types/shared/src/lib/file-upload/size.d.ts.map +1 -0
- package/dist/types/shared/src/lib/form/errors.d.ts +7 -0
- package/dist/types/shared/src/lib/form/errors.d.ts.map +1 -0
- package/dist/types/shared/src/lib/form/focus.d.ts +2 -0
- package/dist/types/shared/src/lib/form/focus.d.ts.map +1 -0
- package/dist/types/shared/src/lib/form/standard-schema.d.ts +23 -0
- package/dist/types/shared/src/lib/form/standard-schema.d.ts.map +1 -0
- package/dist/types/shared/src/lib/form/values.d.ts +3 -0
- package/dist/types/shared/src/lib/form/values.d.ts.map +1 -0
- package/dist/types/shared/src/lib/highlighter.d.ts +4 -0
- package/dist/types/shared/src/lib/highlighter.d.ts.map +1 -0
- package/dist/types/shared/src/lib/iris-origin.d.ts +6 -0
- package/dist/types/shared/src/lib/iris-origin.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/clip.d.ts +16 -0
- package/dist/types/shared/src/lib/lightbox/clip.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/download.d.ts +3 -0
- package/dist/types/shared/src/lib/lightbox/download.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/gesture.d.ts +26 -0
- package/dist/types/shared/src/lib/lightbox/gesture.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/paging.d.ts +9 -0
- package/dist/types/shared/src/lib/lightbox/paging.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/pose.d.ts +38 -0
- package/dist/types/shared/src/lib/lightbox/pose.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/source.d.ts +4 -0
- package/dist/types/shared/src/lib/lightbox/source.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/types.d.ts +16 -0
- package/dist/types/shared/src/lib/lightbox/types.d.ts.map +1 -0
- package/dist/types/shared/src/lib/lightbox/zoom.d.ts +40 -0
- package/dist/types/shared/src/lib/lightbox/zoom.d.ts.map +1 -0
- package/dist/types/shared/src/lib/meter-group.d.ts +5 -0
- package/dist/types/shared/src/lib/meter-group.d.ts.map +1 -0
- package/dist/types/shared/src/lib/overlay-anchor.d.ts +10 -0
- package/dist/types/shared/src/lib/overlay-anchor.d.ts.map +1 -0
- package/dist/types/shared/src/lib/pagination.d.ts +4 -0
- package/dist/types/shared/src/lib/pagination.d.ts.map +1 -0
- package/dist/types/shared/src/lib/pointer-corridor.d.ts +7 -0
- package/dist/types/shared/src/lib/pointer-corridor.d.ts.map +1 -0
- package/dist/types/shared/src/lib/qr-code-export.d.ts +6 -0
- package/dist/types/shared/src/lib/qr-code-export.d.ts.map +1 -0
- package/dist/types/shared/src/lib/range-calendar/limit.d.ts +3 -0
- package/dist/types/shared/src/lib/range-calendar/limit.d.ts.map +1 -0
- package/dist/types/shared/src/lib/rating.d.ts +2 -0
- package/dist/types/shared/src/lib/rating.d.ts.map +1 -0
- package/dist/types/shared/src/lib/relative-time.d.ts +2 -0
- package/dist/types/shared/src/lib/relative-time.d.ts.map +1 -0
- package/dist/types/shared/src/lib/scroll-area.d.ts +50 -0
- package/dist/types/shared/src/lib/scroll-area.d.ts.map +1 -0
- package/dist/types/shared/src/lib/scroll-restore.d.ts +34 -0
- package/dist/types/shared/src/lib/scroll-restore.d.ts.map +1 -0
- package/dist/types/shared/src/lib/toast-layout.d.ts +13 -0
- package/dist/types/shared/src/lib/toast-layout.d.ts.map +1 -0
- package/dist/types/shared/src/lib/tree/selection.d.ts +23 -0
- package/dist/types/shared/src/lib/tree/selection.d.ts.map +1 -0
- package/dist/types/shared/src/lib/tree-select/filter.d.ts +7 -0
- package/dist/types/shared/src/lib/tree-select/filter.d.ts.map +1 -0
- package/dist/types/shared/src/lib/virtual/choices.d.ts +59 -0
- package/dist/types/shared/src/lib/virtual/choices.d.ts.map +1 -0
- package/dist/types/shared/src/lib/virtual/collection.d.ts +25 -0
- package/dist/types/shared/src/lib/virtual/collection.d.ts.map +1 -0
- package/dist/types/shared/src/lib/virtual/flow.d.ts +18 -0
- package/dist/types/shared/src/lib/virtual/flow.d.ts.map +1 -0
- package/dist/types/shared/src/lib/virtual/list.d.ts +46 -0
- package/dist/types/shared/src/lib/virtual/list.d.ts.map +1 -0
- package/dist/types/shared/src/lib/virtual/navigation.d.ts +3 -0
- package/dist/types/shared/src/lib/virtual/navigation.d.ts.map +1 -0
- package/dist/types/shared/src/lib/virtual/tree.d.ts +31 -0
- package/dist/types/shared/src/lib/virtual/tree.d.ts.map +1 -0
- package/dist/types/shared/src/locale/en-US.d.ts +3 -0
- package/dist/types/shared/src/locale/en-US.d.ts.map +1 -0
- package/dist/types/shared/src/locale/index.d.ts +6 -0
- package/dist/types/shared/src/locale/index.d.ts.map +1 -0
- package/dist/types/shared/src/locale/types.d.ts +235 -0
- package/dist/types/shared/src/locale/types.d.ts.map +1 -0
- package/dist/types/shared/src/locale/zh-CN.d.ts +3 -0
- package/dist/types/shared/src/locale/zh-CN.d.ts.map +1 -0
- package/dist/types/shared/src/primitives/number-field/index.d.ts +155 -0
- package/dist/types/shared/src/primitives/number-field/index.d.ts.map +1 -0
- package/dist/types/shared/src/types/autocomplete.d.ts +14 -0
- package/dist/types/shared/src/types/autocomplete.d.ts.map +1 -0
- package/dist/types/shared/src/types/data-table.d.ts +169 -0
- package/dist/types/shared/src/types/data-table.d.ts.map +1 -0
- package/dist/types/shared/src/types/pagination.d.ts +23 -0
- package/dist/types/shared/src/types/pagination.d.ts.map +1 -0
- package/dist/types/shared/src/types/select.d.ts +14 -0
- package/dist/types/shared/src/types/select.d.ts.map +1 -0
- package/dist/types/shared/src/types/tree-select.d.ts +10 -0
- package/dist/types/shared/src/types/tree-select.d.ts.map +1 -0
- package/dist/types/shared/src/types/tree.d.ts +18 -0
- package/dist/types/shared/src/types/tree.d.ts.map +1 -0
- package/dist/types/shared/src/variants/autocomplete.d.ts +3 -0
- package/dist/types/shared/src/variants/autocomplete.d.ts.map +1 -0
- package/dist/types/shared/src/variants/editable.d.ts +52 -0
- package/dist/types/shared/src/variants/editable.d.ts.map +1 -0
- package/dist/types/shared/src/variants/float-button.d.ts +74 -0
- package/dist/types/shared/src/variants/float-button.d.ts.map +1 -0
- package/dist/types/shared/src/variants/split-button.d.ts +18 -0
- package/dist/types/shared/src/variants/split-button.d.ts.map +1 -0
- package/dist/types/vue/src/components/accordion/AccordionTrigger.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/anchor/Anchor.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/anchor/composables/useAnchor.d.ts +2 -7
- package/dist/types/vue/src/components/anchor/composables/useAnchor.d.ts.map +1 -1
- package/dist/types/vue/src/components/anchor/composables/useAnchorFollow.d.ts +1 -1
- package/dist/types/vue/src/components/anchor/composables/useAnchorFollow.d.ts.map +1 -1
- package/dist/types/vue/src/components/anchor/composables/useScrollSpy.d.ts +2 -5
- package/dist/types/vue/src/components/anchor/composables/useScrollSpy.d.ts.map +1 -1
- package/dist/types/vue/src/components/anchor/types.d.ts +1 -8
- package/dist/types/vue/src/components/anchor/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/autocomplete/autocomplete.variants.d.ts +1 -1
- package/dist/types/vue/src/components/autocomplete/autocomplete.variants.d.ts.map +1 -1
- package/dist/types/vue/src/components/autocomplete/types.d.ts +1 -13
- package/dist/types/vue/src/components/autocomplete/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/banner/utils/direction.d.ts +1 -2
- package/dist/types/vue/src/components/banner/utils/direction.d.ts.map +1 -1
- package/dist/types/vue/src/components/calendar/utils/format.d.ts +1 -6
- package/dist/types/vue/src/components/calendar/utils/format.d.ts.map +1 -1
- package/dist/types/vue/src/components/code-block/highlighter.d.ts +1 -3
- package/dist/types/vue/src/components/code-block/highlighter.d.ts.map +1 -1
- package/dist/types/vue/src/components/collapsible/CollapsibleTrigger.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/command-palette/composables/useCommandItems.d.ts +1 -1
- package/dist/types/vue/src/components/command-palette/utils/hotkey.d.ts +1 -8
- package/dist/types/vue/src/components/command-palette/utils/hotkey.d.ts.map +1 -1
- package/dist/types/vue/src/components/command-palette/utils/match.d.ts +5 -12
- package/dist/types/vue/src/components/command-palette/utils/match.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-list/composables/useDataList.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-list/utils/scroll.d.ts +1 -2
- package/dist/types/vue/src/components/data-list/utils/scroll.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/column-sizing-styles.d.ts +1 -3
- package/dist/types/vue/src/components/data-table/column-sizing-styles.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/column-sizing.d.ts +1 -21
- package/dist/types/vue/src/components/data-table/column-sizing.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/composables/useDataTable.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/composables/useTableColumns.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/composables/useTableDrag.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/composables/useTableExport.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/composables/useTableResize.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/composables/useTableResizeHandles.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/composables/useTableVirtual.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/types.d.ts +3 -153
- package/dist/types/vue/src/components/data-table/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/data-table/utils.d.ts +1 -9
- package/dist/types/vue/src/components/data-table/utils.d.ts.map +1 -1
- package/dist/types/vue/src/components/date-range-field/utils/validity.d.ts +1 -11
- package/dist/types/vue/src/components/date-range-field/utils/validity.d.ts.map +1 -1
- package/dist/types/vue/src/components/editable/editable.variants.d.ts +1 -1
- package/dist/types/vue/src/components/editable/editable.variants.d.ts.map +1 -1
- package/dist/types/vue/src/components/file-upload/utils/select.d.ts +1 -16
- package/dist/types/vue/src/components/file-upload/utils/select.d.ts.map +1 -1
- package/dist/types/vue/src/components/file-upload/utils/size.d.ts +1 -1
- package/dist/types/vue/src/components/file-upload/utils/size.d.ts.map +1 -1
- package/dist/types/vue/src/components/float-button/float-button.variants.d.ts +1 -1
- package/dist/types/vue/src/components/float-button/float-button.variants.d.ts.map +1 -1
- package/dist/types/vue/src/components/form/Form.vue.d.ts +1 -1
- package/dist/types/vue/src/components/form/composables/useForm.d.ts +9 -15
- package/dist/types/vue/src/components/form/composables/useForm.d.ts.map +1 -1
- package/dist/types/vue/src/components/form/standard-schema.d.ts +1 -22
- package/dist/types/vue/src/components/form/standard-schema.d.ts.map +1 -1
- package/dist/types/vue/src/components/form/utils/errors.d.ts +1 -6
- package/dist/types/vue/src/components/form/utils/errors.d.ts.map +1 -1
- package/dist/types/vue/src/components/form/utils/focus.d.ts +1 -1
- package/dist/types/vue/src/components/form/utils/focus.d.ts.map +1 -1
- package/dist/types/vue/src/components/form/utils/values.d.ts +1 -2
- package/dist/types/vue/src/components/form/utils/values.d.ts.map +1 -1
- package/dist/types/vue/src/components/form-field/FormField.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/composables/useLightboxHint.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/types.d.ts +1 -15
- package/dist/types/vue/src/components/lightbox/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/utils/clip.d.ts +1 -15
- package/dist/types/vue/src/components/lightbox/utils/clip.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/utils/download.d.ts +1 -2
- package/dist/types/vue/src/components/lightbox/utils/download.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/utils/gesture.d.ts +1 -25
- package/dist/types/vue/src/components/lightbox/utils/gesture.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/utils/paging.d.ts +1 -8
- package/dist/types/vue/src/components/lightbox/utils/paging.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/utils/pose.d.ts +1 -37
- package/dist/types/vue/src/components/lightbox/utils/pose.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/utils/source.d.ts +1 -3
- package/dist/types/vue/src/components/lightbox/utils/source.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/utils/zoom.d.ts +1 -39
- package/dist/types/vue/src/components/lightbox/utils/zoom.d.ts.map +1 -1
- package/dist/types/vue/src/components/meter-group/utils/tones.d.ts +1 -3
- package/dist/types/vue/src/components/meter-group/utils/tones.d.ts.map +1 -1
- package/dist/types/vue/src/components/month-grid/MonthGrid.vue.d.ts +1 -1
- package/dist/types/vue/src/components/multi-select/MultiSelect.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/pagination/composables/usePagination.d.ts +2 -2
- package/dist/types/vue/src/components/pagination/composables/usePagination.d.ts.map +1 -1
- package/dist/types/vue/src/components/pagination/types.d.ts +1 -22
- package/dist/types/vue/src/components/pagination/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/pagination/utils/ranges.d.ts +1 -2
- package/dist/types/vue/src/components/pagination/utils/ranges.d.ts.map +1 -1
- package/dist/types/vue/src/components/password-input/PasswordInput.vue.d.ts +4 -1
- package/dist/types/vue/src/components/password-input/PasswordInput.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/prev-next/PrevNextLink.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/qr-code/export.d.ts +1 -2
- package/dist/types/vue/src/components/qr-code/export.d.ts.map +1 -1
- package/dist/types/vue/src/components/range-calendar/utils/limit.d.ts +1 -2
- package/dist/types/vue/src/components/range-calendar/utils/limit.d.ts.map +1 -1
- package/dist/types/vue/src/components/range-slider/RangeSlider.vue.d.ts +2 -2
- package/dist/types/vue/src/components/rating/utils/fill.d.ts +1 -1
- package/dist/types/vue/src/components/rating/utils/fill.d.ts.map +1 -1
- package/dist/types/vue/src/components/ripple/useRipple.d.ts.map +1 -1
- package/dist/types/vue/src/components/scroll-area/ScrollArea.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/scroll-area/composables/useEdgeShadow.d.ts +2 -1
- package/dist/types/vue/src/components/scroll-area/composables/useEdgeShadow.d.ts.map +1 -1
- package/dist/types/vue/src/components/scroll-area/composables/useLayerLock.d.ts.map +1 -1
- package/dist/types/vue/src/components/scroll-area/composables/useWheelRedirect.d.ts.map +1 -1
- package/dist/types/vue/src/components/scroll-area/scroll-restore.d.ts +1 -33
- package/dist/types/vue/src/components/scroll-area/scroll-restore.d.ts.map +1 -1
- package/dist/types/vue/src/components/search-input/SearchInput.vue.d.ts +4 -1
- package/dist/types/vue/src/components/search-input/SearchInput.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/select/types.d.ts +1 -13
- package/dist/types/vue/src/components/select/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/slider/Slider.vue.d.ts +2 -2
- package/dist/types/vue/src/components/split-button/split-button.variants.d.ts +1 -1
- package/dist/types/vue/src/components/split-button/split-button.variants.d.ts.map +1 -1
- package/dist/types/vue/src/components/spoiler/SpoilerPainter.d.ts +1 -34
- package/dist/types/vue/src/components/spoiler/SpoilerPainter.d.ts.map +1 -1
- package/dist/types/vue/src/components/spoiler/utils/irisOrigin.d.ts +1 -5
- package/dist/types/vue/src/components/spoiler/utils/irisOrigin.d.ts.map +1 -1
- package/dist/types/vue/src/components/spoiler/worklet.d.ts +1 -1
- package/dist/types/vue/src/components/spoiler/worklet.d.ts.map +1 -1
- package/dist/types/vue/src/components/table/Table.vue.d.ts +6 -3
- package/dist/types/vue/src/components/table/Table.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/tabs/TabsList.vue.d.ts +6 -3
- package/dist/types/vue/src/components/tabs/TabsList.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/time/utils/relativeTime.d.ts +1 -1
- package/dist/types/vue/src/components/time/utils/relativeTime.d.ts.map +1 -1
- package/dist/types/vue/src/components/toast/composables/useToastLayout.d.ts +4 -11
- package/dist/types/vue/src/components/toast/composables/useToastLayout.d.ts.map +1 -1
- package/dist/types/vue/src/components/toast/store.d.ts +14 -62
- package/dist/types/vue/src/components/toast/store.d.ts.map +1 -1
- package/dist/types/vue/src/components/tree/composables/useTree.d.ts.map +1 -1
- package/dist/types/vue/src/components/tree/types.d.ts +1 -17
- package/dist/types/vue/src/components/tree/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/tree/utils/selection.d.ts +1 -15
- package/dist/types/vue/src/components/tree/utils/selection.d.ts.map +1 -1
- package/dist/types/vue/src/components/tree-select/types.d.ts +1 -9
- package/dist/types/vue/src/components/tree-select/types.d.ts.map +1 -1
- package/dist/types/vue/src/components/tree-select/utils/filterTree.d.ts +1 -6
- package/dist/types/vue/src/components/tree-select/utils/filterTree.d.ts.map +1 -1
- package/dist/types/vue/src/components/virtual-list/composables/useVirtualList.d.ts +1 -1
- package/dist/types/vue/src/components/virtual-list/composables/useVirtualList.d.ts.map +1 -1
- package/dist/types/vue/src/components/visually-hidden/VisuallyHidden.vue.d.ts +4 -1
- package/dist/types/vue/src/components/visually-hidden/VisuallyHidden.vue.d.ts.map +1 -1
- package/dist/types/vue/src/lib/caret.d.ts +1 -1
- package/dist/types/vue/src/lib/caret.d.ts.map +1 -1
- package/dist/types/vue/src/lib/collapse.d.ts +2 -8
- package/dist/types/vue/src/lib/collapse.d.ts.map +1 -1
- package/dist/types/vue/src/lib/date.d.ts +1 -27
- package/dist/types/vue/src/lib/date.d.ts.map +1 -1
- package/dist/types/vue/src/lib/field-focus.d.ts +1 -1
- package/dist/types/vue/src/lib/field-focus.d.ts.map +1 -1
- package/dist/types/vue/src/lib/overlay-anchor.d.ts +2 -7
- package/dist/types/vue/src/lib/overlay-anchor.d.ts.map +1 -1
- package/dist/types/vue/src/lib/pointer-corridor.d.ts +1 -6
- package/dist/types/vue/src/lib/pointer-corridor.d.ts.map +1 -1
- package/dist/types/vue/src/lib/reka/useVirtualChoices.d.ts +3 -11
- package/dist/types/vue/src/lib/reka/useVirtualChoices.d.ts.map +1 -1
- package/dist/types/vue/src/lib/reka/useVirtualTree.d.ts +1 -1
- package/dist/types/vue/src/lib/reka/useVirtualTree.d.ts.map +1 -1
- package/dist/types/vue/src/lib/virtual/navigation.d.ts +1 -2
- package/dist/types/vue/src/lib/virtual/navigation.d.ts.map +1 -1
- package/dist/types/vue/src/lib/virtual/useVirtualCollection.d.ts +1 -1
- package/dist/types/vue/src/lib/virtual/useVirtualCollection.d.ts.map +1 -1
- package/dist/types/vue/src/lib/virtual/useVirtualWindow.d.ts +2 -15
- package/dist/types/vue/src/lib/virtual/useVirtualWindow.d.ts.map +1 -1
- package/dist/types/vue/src/locale/en-US.d.ts +1 -2
- package/dist/types/vue/src/locale/en-US.d.ts.map +1 -1
- package/dist/types/vue/src/locale/index.d.ts +3 -4
- package/dist/types/vue/src/locale/index.d.ts.map +1 -1
- package/dist/types/vue/src/locale/types.d.ts +1 -234
- package/dist/types/vue/src/locale/types.d.ts.map +1 -1
- package/dist/types/vue/src/locale/zh-CN.d.ts +1 -2
- package/dist/types/vue/src/locale/zh-CN.d.ts.map +1 -1
- package/dist/types/vue/src/primitives/number-field/NumberFieldDecrement.vue.d.ts +17 -0
- package/dist/types/vue/src/primitives/number-field/NumberFieldDecrement.vue.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/number-field/NumberFieldIncrement.vue.d.ts +17 -0
- package/dist/types/vue/src/primitives/number-field/NumberFieldIncrement.vue.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/number-field/NumberFieldInput.vue.d.ts +16 -0
- package/dist/types/vue/src/primitives/number-field/NumberFieldInput.vue.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/number-field/NumberFieldRoot.vue.d.ts +47 -0
- package/dist/types/vue/src/primitives/number-field/NumberFieldRoot.vue.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/number-field/context.d.ts +41 -0
- package/dist/types/vue/src/primitives/number-field/context.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/number-field/index.d.ts +5 -0
- package/dist/types/vue/src/primitives/number-field/index.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/utils/timers.d.ts +6 -0
- package/dist/types/vue/src/primitives/utils/timers.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/utils/usePrimitiveElement.d.ts +6 -0
- package/dist/types/vue/src/primitives/utils/usePrimitiveElement.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/utils/useVModel.d.ts +7 -0
- package/dist/types/vue/src/primitives/utils/useVModel.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/visually-hidden/VisuallyHiddenInput.d.ts +66 -0
- package/dist/types/vue/src/primitives/visually-hidden/VisuallyHiddenInput.d.ts.map +1 -0
- package/dist/types/vue/src/primitives/visually-hidden/VisuallyHiddenInputBubble.vue.d.ts +28 -0
- package/dist/types/vue/src/primitives/visually-hidden/VisuallyHiddenInputBubble.vue.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/components/accordion/AccordionTrigger.vue +9 -1
- package/src/components/anchor/Anchor.vue +13 -9
- package/src/components/anchor/composables/useAnchor.ts +3 -12
- package/src/components/anchor/composables/useAnchorFollow.ts +10 -63
- package/src/components/anchor/composables/useScrollSpy.ts +22 -38
- package/src/components/anchor/types.ts +1 -8
- package/src/components/autocomplete/autocomplete.variants.ts +1 -1
- package/src/components/autocomplete/composables/useAutocomplete.ts +1 -1
- package/src/components/autocomplete/types.ts +1 -16
- package/src/components/banner/utils/direction.ts +1 -10
- package/src/components/calendar/utils/format.ts +1 -23
- package/src/components/code-block/highlighter.ts +1 -98
- package/src/components/collapsible/CollapsibleTrigger.vue +8 -1
- package/src/components/command-palette/utils/hotkey.ts +1 -27
- package/src/components/command-palette/utils/match.ts +5 -75
- package/src/components/data-list/composables/useDataList.ts +2 -4
- package/src/components/data-list/utils/scroll.ts +1 -26
- package/src/components/data-table/column-sizing-styles.ts +1 -40
- package/src/components/data-table/column-sizing.ts +1 -101
- package/src/components/data-table/composables/useDataTable.ts +103 -123
- package/src/components/data-table/composables/useTableColumns.ts +38 -113
- package/src/components/data-table/composables/useTableDrag.ts +21 -11
- package/src/components/data-table/composables/useTableExport.ts +8 -32
- package/src/components/data-table/composables/useTableResize.ts +13 -17
- package/src/components/data-table/composables/useTableResizeHandles.ts +6 -21
- package/src/components/data-table/types.ts +15 -155
- package/src/components/data-table/utils.ts +1 -75
- package/src/components/date-range-field/utils/validity.ts +1 -21
- package/src/components/editable/editable.variants.ts +1 -1
- package/src/components/file-upload/utils/select.ts +1 -58
- package/src/components/file-upload/utils/size.ts +1 -16
- package/src/components/float-button/float-button.variants.ts +1 -1
- package/src/components/form/composables/useForm.ts +24 -135
- package/src/components/form/standard-schema.ts +1 -26
- package/src/components/form/utils/errors.ts +1 -48
- package/src/components/form/utils/focus.ts +1 -10
- package/src/components/form/utils/values.ts +1 -23
- package/src/components/form-field/FormField.vue +3 -2
- package/src/components/lightbox/composables/useLightboxHint.ts +6 -1
- package/src/components/lightbox/types.ts +1 -14
- package/src/components/lightbox/utils/clip.ts +1 -117
- package/src/components/lightbox/utils/download.ts +1 -29
- package/src/components/lightbox/utils/gesture.ts +1 -54
- package/src/components/lightbox/utils/paging.ts +1 -33
- package/src/components/lightbox/utils/pose.ts +1 -142
- package/src/components/lightbox/utils/source.ts +1 -17
- package/src/components/lightbox/utils/zoom.ts +1 -127
- package/src/components/meter-group/utils/tones.ts +1 -14
- package/src/components/multi-select/MultiSelect.vue +1 -2
- package/src/components/number-input/NumberInput.vue +2 -2
- package/src/components/pagination/composables/usePagination.ts +2 -3
- package/src/components/pagination/types.ts +1 -19
- package/src/components/pagination/utils/ranges.ts +1 -12
- package/src/components/password-input/PasswordInput.vue +6 -0
- package/src/components/prev-next/PrevNext.vue +1 -1
- package/src/components/prev-next/PrevNextLink.vue +1 -1
- package/src/components/qr-code/export.ts +1 -65
- package/src/components/range-calendar/utils/limit.ts +1 -11
- package/src/components/rating/utils/fill.ts +1 -4
- package/src/components/ripple/useRipple.ts +10 -198
- package/src/components/scroll-area/ScrollArea.vue +6 -18
- package/src/components/scroll-area/composables/useEdgeShadow.ts +7 -16
- package/src/components/scroll-area/composables/useLayerLock.ts +2 -9
- package/src/components/scroll-area/composables/useWheelRedirect.ts +2 -10
- package/src/components/scroll-area/scroll-restore.ts +1 -148
- package/src/components/search-input/SearchInput.vue +6 -0
- package/src/components/select/types.ts +1 -23
- package/src/components/split-button/split-button.variants.ts +1 -1
- package/src/components/spoiler/SpoilerPainter.ts +1 -197
- package/src/components/spoiler/utils/irisOrigin.ts +1 -40
- package/src/components/spoiler/worklet.ts +1 -199
- package/src/components/table/Table.vue +9 -0
- package/src/components/tabs/TabsList.vue +9 -0
- package/src/components/time/utils/relativeTime.ts +1 -20
- package/src/components/toast/composables/useToastLayout.ts +12 -24
- package/src/components/toast/store.ts +16 -228
- package/src/components/tree/composables/useTree.ts +17 -33
- package/src/components/tree/types.ts +1 -20
- package/src/components/tree/utils/selection.ts +1 -78
- package/src/components/tree-select/types.ts +1 -34
- package/src/components/tree-select/utils/filterTree.ts +1 -19
- package/src/components/virtual-list/composables/useVirtualList.ts +16 -42
- package/src/components/visually-hidden/VisuallyHidden.vue +21 -3
- package/src/lib/caret.ts +1 -48
- package/src/lib/collapse.ts +6 -29
- package/src/lib/date.ts +1 -111
- package/src/lib/field-focus.ts +1 -36
- package/src/lib/overlay-anchor.ts +11 -37
- package/src/lib/pointer-corridor.ts +1 -26
- package/src/lib/reka/useVirtualChoices.ts +55 -133
- package/src/lib/reka/useVirtualTree.ts +22 -65
- package/src/lib/virtual/navigation.ts +1 -26
- package/src/lib/virtual/useVirtualCollection.ts +28 -47
- package/src/lib/virtual/useVirtualWindow.ts +15 -25
- package/src/locale/en-US.ts +1 -220
- package/src/locale/index.ts +9 -53
- package/src/locale/types.ts +1 -225
- package/src/locale/zh-CN.ts +1 -215
- package/src/primitives/number-field/LICENSE +21 -0
- package/src/primitives/number-field/NumberFieldDecrement.vue +21 -0
- package/src/primitives/number-field/NumberFieldIncrement.vue +21 -0
- package/src/primitives/number-field/NumberFieldInput.vue +114 -0
- package/src/primitives/number-field/NumberFieldRoot.vue +169 -0
- package/src/primitives/number-field/context.ts +111 -0
- package/src/primitives/number-field/index.ts +14 -0
- package/src/primitives/utils/LICENSE +44 -0
- package/src/primitives/utils/timers.ts +6 -0
- package/src/primitives/utils/usePrimitiveElement.ts +12 -0
- package/src/primitives/utils/useVModel.ts +37 -0
- package/src/primitives/visually-hidden/LICENSE +21 -0
- package/src/primitives/visually-hidden/VisuallyHiddenInput.ts +97 -0
- package/src/primitives/visually-hidden/VisuallyHiddenInputBubble.vue +49 -0
|
@@ -1,19 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
page: number
|
|
3
|
-
pageSize: number
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface PaginationState extends PaginationChange {
|
|
7
|
-
total: number
|
|
8
|
-
pageCount: number
|
|
9
|
-
from: number
|
|
10
|
-
to: number
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type PaginationEntry = { type: 'page'; value: number } | { type: 'ellipsis' }
|
|
14
|
-
export type PaginationSide = 'prev' | 'next'
|
|
15
|
-
export interface PaginationRange {
|
|
16
|
-
side: PaginationSide
|
|
17
|
-
from: number
|
|
18
|
-
to: number
|
|
19
|
-
}
|
|
1
|
+
export * from '../../../../shared/src/types/pagination'
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function paginationRanges(items: PaginationEntry[]): PaginationRange[] {
|
|
4
|
-
return items.flatMap((item, index) => {
|
|
5
|
-
if (item.type !== 'ellipsis') return []
|
|
6
|
-
const previous = items[index - 1]
|
|
7
|
-
const next = items[index + 1]
|
|
8
|
-
if (previous?.type !== 'page' || next?.type !== 'page' || next.value <= previous.value + 1)
|
|
9
|
-
return []
|
|
10
|
-
return [{ side: index === 1 ? 'prev' : 'next', from: previous.value + 1, to: next.value - 1 }]
|
|
11
|
-
})
|
|
12
|
-
}
|
|
1
|
+
export * from '../../../../../shared/src/lib/pagination'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { shallowRef } from 'vue'
|
|
2
3
|
import { Eye, EyeOff } from '@lucide/vue'
|
|
3
4
|
import { cn } from '../../lib/cn'
|
|
4
5
|
import { useUiLocale } from '../../locale'
|
|
@@ -20,10 +21,15 @@
|
|
|
20
21
|
const visible = defineModel<boolean>('visible', { default: false })
|
|
21
22
|
|
|
22
23
|
const t = useUiLocale()
|
|
24
|
+
|
|
25
|
+
const base = shallowRef<InstanceType<typeof InputBase> | null>(null)
|
|
26
|
+
|
|
27
|
+
defineExpose({ clear: () => base.value?.clear(), focus: () => base.value?.focus() })
|
|
23
28
|
</script>
|
|
24
29
|
|
|
25
30
|
<template>
|
|
26
31
|
<InputBase
|
|
32
|
+
ref="base"
|
|
27
33
|
v-bind="$attrs"
|
|
28
34
|
v-model="model"
|
|
29
35
|
:type="visible ? 'text' : 'password'"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<ArrowRight v-else class="size-4" aria-hidden="true" />
|
|
38
38
|
{{ props.label ?? (props.direction === 'prev' ? t.pagination.prev : t.pagination.next) }}
|
|
39
39
|
</span>
|
|
40
|
-
<span class="text-fg font-medium">
|
|
40
|
+
<span class="text-fg max-w-full font-medium">
|
|
41
41
|
<slot />
|
|
42
42
|
</span>
|
|
43
43
|
</Primitive>
|
|
@@ -1,65 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function dataURL(blob: Blob): Promise<string> {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
const reader = new FileReader()
|
|
6
|
-
reader.onload = () => resolve(reader.result as string)
|
|
7
|
-
reader.onerror = () => reject(reader.error)
|
|
8
|
-
reader.readAsDataURL(blob)
|
|
9
|
-
})
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function exportQRCode(
|
|
13
|
-
svg: SVGSVGElement,
|
|
14
|
-
size: number,
|
|
15
|
-
{ type = 'image/png', scale = 2 }: QRCodeExportOptions = {},
|
|
16
|
-
): Promise<Blob> {
|
|
17
|
-
const clone = svg.cloneNode(true) as SVGSVGElement
|
|
18
|
-
const source = [svg, ...svg.querySelectorAll('*')]
|
|
19
|
-
const target = [clone, ...clone.querySelectorAll('*')]
|
|
20
|
-
target.forEach((el, index) => {
|
|
21
|
-
const style = getComputedStyle(source[index]!)
|
|
22
|
-
el.removeAttribute('class')
|
|
23
|
-
el.removeAttribute('style')
|
|
24
|
-
el.setAttribute('fill', style.fill)
|
|
25
|
-
})
|
|
26
|
-
clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
|
|
27
|
-
clone.setAttribute('width', String(size))
|
|
28
|
-
clone.setAttribute('height', String(size))
|
|
29
|
-
for (const image of clone.querySelectorAll('image')) {
|
|
30
|
-
const href = image.getAttribute('href')
|
|
31
|
-
if (!href) continue
|
|
32
|
-
let embedded = href
|
|
33
|
-
if (!href.startsWith('data:')) {
|
|
34
|
-
const response = await fetch(new URL(href, svg.ownerDocument.baseURI))
|
|
35
|
-
if (!response.ok) throw new Error('Unable to export the QR code logo')
|
|
36
|
-
embedded = await dataURL(await response.blob())
|
|
37
|
-
}
|
|
38
|
-
const decoded = new Image()
|
|
39
|
-
decoded.src = embedded
|
|
40
|
-
await decoded.decode()
|
|
41
|
-
image.setAttribute('href', embedded)
|
|
42
|
-
}
|
|
43
|
-
const blob = new Blob([new XMLSerializer().serializeToString(clone)], { type: 'image/svg+xml' })
|
|
44
|
-
if (type === 'image/svg+xml') return blob
|
|
45
|
-
const url = URL.createObjectURL(blob)
|
|
46
|
-
try {
|
|
47
|
-
const image = new Image()
|
|
48
|
-
image.src = url
|
|
49
|
-
await image.decode()
|
|
50
|
-
const factor = Number.isFinite(scale) ? Math.max(1, Math.min(8, scale)) : 2
|
|
51
|
-
const canvas = svg.ownerDocument.createElement('canvas')
|
|
52
|
-
canvas.width = canvas.height = Math.min(8192, Math.round(size * factor))
|
|
53
|
-
const context = canvas.getContext('2d')
|
|
54
|
-
if (!context) throw new Error('Canvas is unavailable')
|
|
55
|
-
context.drawImage(image, 0, 0, canvas.width, canvas.height)
|
|
56
|
-
return await new Promise<Blob>((resolve, reject) => {
|
|
57
|
-
canvas.toBlob(
|
|
58
|
-
result => (result ? resolve(result) : reject(new Error('Unable to export the QR code'))),
|
|
59
|
-
'image/png',
|
|
60
|
-
)
|
|
61
|
-
})
|
|
62
|
-
} finally {
|
|
63
|
-
URL.revokeObjectURL(url)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
export * from '../../../../shared/src/lib/qr-code-export'
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function maximumDaysMatcher(
|
|
4
|
-
start: DateValue | undefined,
|
|
5
|
-
end: DateValue | undefined,
|
|
6
|
-
maximumDays: number | undefined,
|
|
7
|
-
) {
|
|
8
|
-
if (!start || end || !maximumDays) return undefined
|
|
9
|
-
const reach = maximumDays - 1
|
|
10
|
-
return (date: DateValue) => Math.abs(date.compare(start)) > reach
|
|
11
|
-
}
|
|
1
|
+
export * from '../../../../../shared/src/lib/range-calendar/limit'
|
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const INITIAL_ORIGIN_SCALE = 0.2
|
|
5
|
-
const PADDING = 12
|
|
6
|
-
const SOFT_EDGE_MINIMUM_SIZE = 75
|
|
7
|
-
const SOFT_EDGE_CONTAINER_RATIO = 0.35
|
|
8
|
-
const GROW_MS = 150
|
|
9
|
-
const MINIMUM_PRESS_MS = 225
|
|
10
|
-
const TOUCH_DELAY_MS = 150
|
|
11
|
-
|
|
12
|
-
const STATE = {
|
|
13
|
-
inactive: 0,
|
|
14
|
-
touchDelay: 1,
|
|
15
|
-
holding: 2,
|
|
16
|
-
waitingForClick: 3,
|
|
17
|
-
} as const
|
|
18
|
-
|
|
19
|
-
type RippleState = (typeof STATE)[keyof typeof STATE]
|
|
2
|
+
import { createRipple } from '../../../../shared/src/behavior/ripple'
|
|
20
3
|
|
|
21
4
|
export function useRipple(
|
|
22
5
|
container: Ref<HTMLElement | null>,
|
|
@@ -24,188 +7,17 @@ export function useRipple(
|
|
|
24
7
|
isDisabled: () => boolean,
|
|
25
8
|
) {
|
|
26
9
|
const pressed = ref(false)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let rippleScale = ''
|
|
35
|
-
let rippleSize = ''
|
|
36
|
-
|
|
37
|
-
const isTouch = ({ pointerType }: PointerEvent) => pointerType === 'touch'
|
|
38
|
-
|
|
39
|
-
function shouldReact(event: PointerEvent) {
|
|
40
|
-
if (isDisabled() || !event.isPrimary) return false
|
|
41
|
-
if (startEvent && startEvent.pointerId !== event.pointerId) return false
|
|
42
|
-
if (event.type === 'pointerenter' || event.type === 'pointerleave') return !isTouch(event)
|
|
43
|
-
return isTouch(event) || event.buttons === 1
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function inBounds({ x, y }: PointerEvent) {
|
|
47
|
-
const rect = container.value?.getBoundingClientRect()
|
|
48
|
-
if (!rect) return false
|
|
49
|
-
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function determineRippleSize() {
|
|
53
|
-
const rect = container.value?.getBoundingClientRect()
|
|
54
|
-
if (!rect) return
|
|
55
|
-
const maxDim = Math.max(rect.height, rect.width)
|
|
56
|
-
const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE)
|
|
57
|
-
initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE)
|
|
58
|
-
const maxRadius = Math.hypot(rect.width, rect.height) + PADDING
|
|
59
|
-
rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`
|
|
60
|
-
rippleSize = `${initialSize}px`
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function normalizedCoords(event: PointerEvent) {
|
|
64
|
-
const rect = container.value?.getBoundingClientRect()
|
|
65
|
-
if (!rect) return { x: 0, y: 0 }
|
|
66
|
-
return {
|
|
67
|
-
x: event.pageX - (window.scrollX + rect.left),
|
|
68
|
-
y: event.pageY - (window.scrollY + rect.top),
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function translationCoords(positionEvent?: PointerEvent) {
|
|
73
|
-
const rect = container.value?.getBoundingClientRect()
|
|
74
|
-
if (!rect) return { startPoint: { x: 0, y: 0 }, endPoint: { x: 0, y: 0 } }
|
|
75
|
-
const endPoint = {
|
|
76
|
-
x: (rect.width - initialSize) / 2,
|
|
77
|
-
y: (rect.height - initialSize) / 2,
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
startPoint: positionEvent ? normalizedCoords(positionEvent) : endPoint,
|
|
81
|
-
endPoint,
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function startPress(positionEvent?: PointerEvent) {
|
|
86
|
-
const el = surface.value
|
|
87
|
-
if (!el) return
|
|
88
|
-
pressed.value = true
|
|
89
|
-
growAnimation?.cancel()
|
|
90
|
-
growAnimation = undefined
|
|
91
|
-
determineRippleSize()
|
|
92
|
-
const { startPoint, endPoint } = translationCoords(positionEvent)
|
|
93
|
-
if (typeof el.animate !== 'function') return
|
|
94
|
-
if (prefersReducedMotion()) return
|
|
95
|
-
growAnimation = el.animate(
|
|
96
|
-
{
|
|
97
|
-
height: [rippleSize, rippleSize],
|
|
98
|
-
width: [rippleSize, rippleSize],
|
|
99
|
-
transform: [
|
|
100
|
-
`translate(${startPoint.x}px,${startPoint.y}px) scale(1)`,
|
|
101
|
-
`translate(${endPoint.x}px,${endPoint.y}px) scale(${rippleScale})`,
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
pseudoElement: '::after',
|
|
106
|
-
duration: GROW_MS,
|
|
107
|
-
easing: 'linear',
|
|
108
|
-
fill: 'forwards',
|
|
109
|
-
},
|
|
110
|
-
)
|
|
111
|
-
growAnimation.finished.catch(() => {})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function endPress() {
|
|
115
|
-
startEvent = undefined
|
|
116
|
-
state = STATE.inactive
|
|
117
|
-
const animation = growAnimation
|
|
118
|
-
let playedMs = Infinity
|
|
119
|
-
if (typeof animation?.currentTime === 'number') playedMs = animation.currentTime
|
|
120
|
-
else if (animation?.currentTime) playedMs = animation.currentTime.to('ms').value
|
|
121
|
-
if (playedMs >= MINIMUM_PRESS_MS) {
|
|
122
|
-
pressed.value = false
|
|
123
|
-
return
|
|
124
|
-
}
|
|
125
|
-
window.setTimeout(() => {
|
|
126
|
-
if (growAnimation !== animation) return
|
|
127
|
-
pressed.value = false
|
|
128
|
-
}, MINIMUM_PRESS_MS - playedMs)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function onPointerDown(event: PointerEvent) {
|
|
132
|
-
if (!shouldReact(event)) return
|
|
133
|
-
startEvent = event
|
|
134
|
-
if (!isTouch(event)) {
|
|
135
|
-
state = STATE.waitingForClick
|
|
136
|
-
startPress(event)
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
|
-
if (checkBoundsAfterContextMenu && !inBounds(event)) return
|
|
140
|
-
checkBoundsAfterContextMenu = false
|
|
141
|
-
state = STATE.touchDelay
|
|
142
|
-
window.setTimeout(() => {
|
|
143
|
-
if (state !== STATE.touchDelay) return
|
|
144
|
-
state = STATE.holding
|
|
145
|
-
startPress(event)
|
|
146
|
-
}, TOUCH_DELAY_MS)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function onPointerUp(event: PointerEvent) {
|
|
150
|
-
if (!shouldReact(event)) return
|
|
151
|
-
if (state === STATE.holding) {
|
|
152
|
-
state = STATE.waitingForClick
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
if (state === STATE.touchDelay) {
|
|
156
|
-
state = STATE.waitingForClick
|
|
157
|
-
startPress(startEvent)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function onPointerLeave(event: PointerEvent) {
|
|
162
|
-
if (!shouldReact(event)) return
|
|
163
|
-
if (state !== STATE.inactive) endPress()
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function onPointerCancel(event: PointerEvent) {
|
|
167
|
-
if (!shouldReact(event)) return
|
|
168
|
-
endPress()
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function onClick() {
|
|
172
|
-
if (isDisabled()) return
|
|
173
|
-
if (state === STATE.waitingForClick) {
|
|
174
|
-
endPress()
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
if (state === STATE.inactive) {
|
|
178
|
-
startPress()
|
|
179
|
-
endPress()
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function onContextMenu() {
|
|
184
|
-
if (isDisabled()) return
|
|
185
|
-
checkBoundsAfterContextMenu = true
|
|
186
|
-
endPress()
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const listeners: [string, EventListener][] = [
|
|
190
|
-
['click', onClick as EventListener],
|
|
191
|
-
['contextmenu', onContextMenu as EventListener],
|
|
192
|
-
['pointercancel', onPointerCancel as EventListener],
|
|
193
|
-
['pointerdown', onPointerDown as EventListener],
|
|
194
|
-
['pointerleave', onPointerLeave as EventListener],
|
|
195
|
-
['pointerup', onPointerUp as EventListener],
|
|
196
|
-
]
|
|
197
|
-
|
|
198
|
-
onMounted(() => {
|
|
199
|
-
host = container.value?.parentElement ?? null
|
|
200
|
-
if (!host) return
|
|
201
|
-
for (const [name, fn] of listeners) host.addEventListener(name, fn, true)
|
|
10
|
+
const ripple = createRipple({
|
|
11
|
+
container: () => container.value,
|
|
12
|
+
surface: () => surface.value,
|
|
13
|
+
disabled: isDisabled,
|
|
14
|
+
onPressedChange: value => {
|
|
15
|
+
pressed.value = value
|
|
16
|
+
},
|
|
202
17
|
})
|
|
203
18
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
for (const [name, fn] of listeners) host.removeEventListener(name, fn, true)
|
|
207
|
-
host = null
|
|
208
|
-
})
|
|
19
|
+
onMounted(ripple.connect)
|
|
20
|
+
onBeforeUnmount(ripple.disconnect)
|
|
209
21
|
|
|
210
22
|
return { pressed }
|
|
211
23
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { useWheelRedirect } from './composables/useWheelRedirect'
|
|
8
8
|
import { useLayerLock } from './composables/useLayerLock'
|
|
9
9
|
import { useScrollFocus } from './composables/useScrollFocus'
|
|
10
|
+
import { scrollAreaOptions } from '../../../../shared/src/lib/scroll-area'
|
|
10
11
|
|
|
11
12
|
defineOptions({ name: 'HnScrollArea', inheritAttrs: false })
|
|
12
13
|
|
|
@@ -36,25 +37,12 @@
|
|
|
36
37
|
const host = shallowRef<HTMLElement>()
|
|
37
38
|
const content = shallowRef<HTMLElement>()
|
|
38
39
|
|
|
39
|
-
const overflow = {
|
|
40
|
-
vertical: { x: 'hidden', y: 'scroll' },
|
|
41
|
-
horizontal: { x: 'scroll', y: 'hidden' },
|
|
42
|
-
both: { x: 'scroll', y: 'scroll' },
|
|
43
|
-
} as const
|
|
44
|
-
|
|
45
40
|
function options() {
|
|
46
|
-
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
autoHideDelay: 800,
|
|
52
|
-
},
|
|
53
|
-
overflow: overflow[props.direction],
|
|
54
|
-
update: {
|
|
55
|
-
elementEvents: [['img', 'load']] as Array<[string, string]>,
|
|
56
|
-
},
|
|
57
|
-
}
|
|
41
|
+
return scrollAreaOptions({
|
|
42
|
+
direction: props.direction,
|
|
43
|
+
autoHide: props.autoHide,
|
|
44
|
+
scrollbar: props.scrollbar,
|
|
45
|
+
})
|
|
58
46
|
}
|
|
59
47
|
|
|
60
48
|
const { viewport, instance, onEvent } = useOverlayScrollbars(host, content, options)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { shallowRef, type ShallowRef } from 'vue'
|
|
2
|
+
import { scrollEdges, type ScrollDirection } from '../../../../../shared/src/lib/scroll-area'
|
|
2
3
|
|
|
3
4
|
export function useEdgeShadow(
|
|
4
5
|
viewport: ShallowRef<HTMLElement | undefined>,
|
|
5
|
-
opts: () => { direction:
|
|
6
|
+
opts: () => { direction: ScrollDirection; shadow: boolean },
|
|
6
7
|
) {
|
|
7
8
|
const showXStart = shallowRef(false)
|
|
8
9
|
const showXEnd = shallowRef(false)
|
|
@@ -10,22 +11,12 @@ export function useEdgeShadow(
|
|
|
10
11
|
const showYEnd = shallowRef(false)
|
|
11
12
|
|
|
12
13
|
function updateEdges() {
|
|
13
|
-
const el = viewport.value
|
|
14
14
|
const { direction, shadow } = opts()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
const room = 1
|
|
23
|
-
const x = direction !== 'vertical'
|
|
24
|
-
const y = direction !== 'horizontal'
|
|
25
|
-
showXStart.value = x && Math.abs(el.scrollLeft) > room
|
|
26
|
-
showXEnd.value = x && Math.abs(el.scrollLeft) + el.clientWidth < el.scrollWidth - room
|
|
27
|
-
showYStart.value = y && el.scrollTop > room
|
|
28
|
-
showYEnd.value = y && el.scrollTop + el.clientHeight < el.scrollHeight - room
|
|
15
|
+
const edges = scrollEdges(viewport.value, direction, shadow)
|
|
16
|
+
showXStart.value = edges.xStart
|
|
17
|
+
showXEnd.value = edges.xEnd
|
|
18
|
+
showYStart.value = edges.yStart
|
|
19
|
+
showYEnd.value = edges.yEnd
|
|
29
20
|
}
|
|
30
21
|
|
|
31
22
|
return { showXStart, showXEnd, showYStart, showYEnd, updateEdges }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSharedComposable, useMutationObserver } from '@vueuse/core'
|
|
2
2
|
import { onBeforeUnmount, ref, watch, type ShallowRef } from 'vue'
|
|
3
|
+
import { blockWhenInert } from '../../../../../shared/src/lib/scroll-area'
|
|
3
4
|
|
|
4
5
|
const useBodyPointerLock = createSharedComposable(() => {
|
|
5
6
|
const locked = ref(false)
|
|
@@ -22,15 +23,7 @@ export function useLayerLock(viewport: ShallowRef<HTMLElement | undefined>) {
|
|
|
22
23
|
release = undefined
|
|
23
24
|
const el = viewport.value
|
|
24
25
|
if (!el || !locked.value) return
|
|
25
|
-
|
|
26
|
-
if (getComputedStyle(el).pointerEvents === 'none') event.preventDefault()
|
|
27
|
-
}
|
|
28
|
-
el.addEventListener('wheel', block, { passive: false, capture: true })
|
|
29
|
-
el.addEventListener('touchmove', block, { passive: false, capture: true })
|
|
30
|
-
release = () => {
|
|
31
|
-
el.removeEventListener('wheel', block, true)
|
|
32
|
-
el.removeEventListener('touchmove', block, true)
|
|
33
|
-
}
|
|
26
|
+
release = blockWhenInert(el)
|
|
34
27
|
}
|
|
35
28
|
|
|
36
29
|
watch([locked, viewport], apply, { flush: 'post' })
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { watch, type ShallowRef } from 'vue'
|
|
2
|
+
import { redirectWheel } from '../../../../../shared/src/lib/scroll-area'
|
|
2
3
|
|
|
3
4
|
export function useWheelRedirect(
|
|
4
5
|
viewport: ShallowRef<HTMLElement | undefined>,
|
|
@@ -8,16 +9,7 @@ export function useWheelRedirect(
|
|
|
8
9
|
if (event.defaultPrevented || !enabled()) return
|
|
9
10
|
const el = viewport.value
|
|
10
11
|
if (!el) return
|
|
11
|
-
|
|
12
|
-
const max = el.scrollWidth - el.clientWidth
|
|
13
|
-
if (max <= 0) return
|
|
14
|
-
const sign = getComputedStyle(el).direction === 'rtl' ? -1 : 1
|
|
15
|
-
const offset = Math.max(0, Math.min(max, el.scrollLeft * sign))
|
|
16
|
-
const atStart = offset <= 1 && event.deltaY < 0
|
|
17
|
-
const atEnd = offset >= max - 1 && event.deltaY > 0
|
|
18
|
-
if (atStart || atEnd) return
|
|
19
|
-
event.preventDefault()
|
|
20
|
-
el.scrollLeft = (offset + event.deltaY) * sign
|
|
12
|
+
redirectWheel(el, event)
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
watch(
|
|
@@ -1,148 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export const RESTORE_DEADLINE_MS = 3000
|
|
3
|
-
export const SAVE_THROTTLE_MS = 500
|
|
4
|
-
export const SCROLL_RESTORE_ATTR = 'data-scroll-restore'
|
|
5
|
-
export const SCROLL_ATOP_ATTR = 'data-scroll-atop'
|
|
6
|
-
export const SCROLL_AT_ATTR = 'data-scroll-at'
|
|
7
|
-
export const SCROLL_ATOP_HIDE_PX = 8
|
|
8
|
-
|
|
9
|
-
export function atopOff(top: number, off: boolean) {
|
|
10
|
-
if (top > SCROLL_ATOP_HIDE_PX) return true
|
|
11
|
-
if (top <= 0) return false
|
|
12
|
-
return off
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function firstPaintRestoreScript() {
|
|
16
|
-
return `(function(){try{if(document.readyState!=="loading")return;
|
|
17
|
-
var r=(history.state&&history.state.${SCROLL_STATE_FIELD})||{};
|
|
18
|
-
var coarse=!!(window.matchMedia&&matchMedia("(pointer: coarse)").matches);
|
|
19
|
-
var cs=
|
|
20
|
-
document.querySelectorAll('[${SCROLL_ATOP_ATTR}]');
|
|
21
|
-
var mark=function(c,t){if(!coarse){c.style.marginTop=-Math.round(Math.max(0,t))+"px";return;}
|
|
22
|
-
if(t>${SCROLL_ATOP_HIDE_PX})c.setAttribute("data-off","true");else if(t<=0)c.setAttribute("data-off","false");};
|
|
23
|
-
for(var i=0;i<cs.length;i++){mark(cs[i],Math.max(0,r[cs[i].getAttribute("${SCROLL_ATOP_ATTR}")]||0));}
|
|
24
|
-
for(var k in r){var t=Math.max(0,r[k]);var e=
|
|
25
|
-
document.querySelector('[${SCROLL_RESTORE_ATTR}="'+k+'"]');if(e){e.scrollTop=t;e.setAttribute("${SCROLL_AT_ATTR}",String(e.scrollTop));}}
|
|
26
|
-
for(var i=0;i<cs.length;i++){(function(c){
|
|
27
|
-
var e=
|
|
28
|
-
document.querySelector('[${SCROLL_RESTORE_ATTR}="'+c.getAttribute("${SCROLL_ATOP_ATTR}")+'"]');
|
|
29
|
-
if(!e)return;
|
|
30
|
-
var sync=function(){if(e.scrollHeight<=e.clientHeight){e.removeEventListener("scroll",sync);return;}mark(c,e.scrollTop);};
|
|
31
|
-
e.addEventListener("scroll",sync,{passive:true});
|
|
32
|
-
})(cs[i]);}
|
|
33
|
-
}catch{}})()`.replace(/\n/g, '')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type ScrollRecord = Record<string, number>
|
|
37
|
-
|
|
38
|
-
export interface ScrollRestorerPorts {
|
|
39
|
-
getViewport: () => HTMLElement | null
|
|
40
|
-
takeFirstPaintTop: () => number | undefined
|
|
41
|
-
readState: () => unknown
|
|
42
|
-
writeState: (state: Record<string, unknown>) => void
|
|
43
|
-
setTimer: (fn: () => void, ms: number) => () => void
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ScrollRestorer {
|
|
47
|
-
restore: (initial?: boolean) => void
|
|
48
|
-
settle: () => void
|
|
49
|
-
abandon: () => void
|
|
50
|
-
save: () => void
|
|
51
|
-
saveSoon: () => void
|
|
52
|
-
dispose: () => void
|
|
53
|
-
isPending: () => boolean
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function readScrollRecord(state: unknown): ScrollRecord {
|
|
57
|
-
if (!state || typeof state !== 'object') return {}
|
|
58
|
-
const record = (state as Record<string, unknown>)[SCROLL_STATE_FIELD]
|
|
59
|
-
if (!record || typeof record !== 'object') return {}
|
|
60
|
-
return record as ScrollRecord
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function writeScrollRecord(state: unknown, key: string, top: number) {
|
|
64
|
-
const base = state && typeof state === 'object' ? (state as Record<string, unknown>) : {}
|
|
65
|
-
return {
|
|
66
|
-
...base,
|
|
67
|
-
[SCROLL_STATE_FIELD]: { ...readScrollRecord(base), [key]: top },
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function readEntryId(state: unknown) {
|
|
72
|
-
if (!state || typeof state !== 'object') return undefined
|
|
73
|
-
return (state as Record<string, unknown>).position
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function createScrollRestorer(key: string, ports: ScrollRestorerPorts): ScrollRestorer {
|
|
77
|
-
let pending: number | null = null
|
|
78
|
-
let clearDeadline: (() => void) | null = null
|
|
79
|
-
let clearThrottle: (() => void) | null = null
|
|
80
|
-
let entry: unknown
|
|
81
|
-
|
|
82
|
-
function stopWaiting() {
|
|
83
|
-
pending = null
|
|
84
|
-
clearDeadline?.()
|
|
85
|
-
clearDeadline = null
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function apply(top: number) {
|
|
89
|
-
const el = ports.getViewport()
|
|
90
|
-
if (!el) return false
|
|
91
|
-
el.scrollTop = top
|
|
92
|
-
return el.scrollHeight - el.clientHeight + 1 >= top
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function save() {
|
|
96
|
-
if (pending !== null) return
|
|
97
|
-
if (readEntryId(ports.readState()) !== entry) return
|
|
98
|
-
const el = ports.getViewport()
|
|
99
|
-
if (!el) return
|
|
100
|
-
ports.writeState(writeScrollRecord(ports.readState(), key, el.scrollTop))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
restore(initial) {
|
|
105
|
-
stopWaiting()
|
|
106
|
-
entry = readEntryId(ports.readState())
|
|
107
|
-
|
|
108
|
-
const saved = readScrollRecord(ports.readState())[key]
|
|
109
|
-
const firstPaintTop = ports.takeFirstPaintTop()
|
|
110
|
-
|
|
111
|
-
if (initial) {
|
|
112
|
-
if (saved === undefined) return
|
|
113
|
-
const el = ports.getViewport()
|
|
114
|
-
if (firstPaintTop !== undefined && el && el.scrollTop !== firstPaintTop) return
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const top = saved ?? 0
|
|
118
|
-
if (apply(top)) return
|
|
119
|
-
pending = top
|
|
120
|
-
clearDeadline = ports.setTimer(stopWaiting, RESTORE_DEADLINE_MS)
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
settle() {
|
|
124
|
-
if (pending === null) return
|
|
125
|
-
if (apply(pending)) stopWaiting()
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
abandon: stopWaiting,
|
|
129
|
-
|
|
130
|
-
isPending: () => pending !== null,
|
|
131
|
-
|
|
132
|
-
save,
|
|
133
|
-
|
|
134
|
-
saveSoon() {
|
|
135
|
-
if (clearThrottle) return
|
|
136
|
-
clearThrottle = ports.setTimer(() => {
|
|
137
|
-
clearThrottle = null
|
|
138
|
-
save()
|
|
139
|
-
}, SAVE_THROTTLE_MS)
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
dispose() {
|
|
143
|
-
stopWaiting()
|
|
144
|
-
clearThrottle?.()
|
|
145
|
-
clearThrottle = null
|
|
146
|
-
},
|
|
147
|
-
}
|
|
148
|
-
}
|
|
1
|
+
export * from '../../../../shared/src/lib/scroll-restore'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { shallowRef } from 'vue'
|
|
2
3
|
import { Search } from '@lucide/vue'
|
|
3
4
|
import { cn } from '../../lib/cn'
|
|
4
5
|
import InputBase from '../input/InputBase.vue'
|
|
@@ -27,10 +28,15 @@
|
|
|
27
28
|
model.value = ''
|
|
28
29
|
emit('clear')
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
const base = shallowRef<InstanceType<typeof InputBase> | null>(null)
|
|
33
|
+
|
|
34
|
+
defineExpose({ clear: () => base.value?.clear(), focus: () => base.value?.focus() })
|
|
30
35
|
</script>
|
|
31
36
|
|
|
32
37
|
<template>
|
|
33
38
|
<InputBase
|
|
39
|
+
ref="base"
|
|
34
40
|
type="search"
|
|
35
41
|
enterkeyhint="search"
|
|
36
42
|
v-bind="$attrs"
|