@hina-ui/vue 1.7.5 → 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 +2222 -987
- 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/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.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/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/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/composables/useAnchor.ts +3 -12
- package/src/components/anchor/composables/useAnchorFollow.ts +8 -76
- 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/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/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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type OverlayAnchor =
|
|
2
|
+
| HTMLElement
|
|
3
|
+
| {
|
|
4
|
+
getBoundingClientRect: () => Pick<
|
|
5
|
+
DOMRect,
|
|
6
|
+
'x' | 'y' | 'width' | 'height' | 'top' | 'right' | 'bottom' | 'left'
|
|
7
|
+
>
|
|
8
|
+
contextElement?: Element
|
|
9
|
+
}
|
|
10
|
+
export type OverlayPositionStrategy = 'optimized' | 'always'
|
|
11
|
+
export type OverlayReference = Exclude<OverlayAnchor, HTMLElement>
|
|
12
|
+
|
|
13
|
+
export function overlayAnchorElement(anchor?: OverlayAnchor | null): HTMLElement | undefined {
|
|
14
|
+
return anchor && 'nodeType' in anchor ? anchor : undefined
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function overlayAnchorContext(anchor?: OverlayAnchor | null): Element | undefined {
|
|
18
|
+
return (
|
|
19
|
+
overlayAnchorElement(anchor) ??
|
|
20
|
+
(anchor && 'contextElement' in anchor ? anchor.contextElement : undefined)
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createOverlayReference(
|
|
25
|
+
anchor: OverlayAnchor,
|
|
26
|
+
current: () => boolean,
|
|
27
|
+
): OverlayReference | undefined {
|
|
28
|
+
const contextElement = overlayAnchorContext(anchor)
|
|
29
|
+
if (contextElement && !contextElement.isConnected) return undefined
|
|
30
|
+
const measure = () => {
|
|
31
|
+
const { x, y, width, height, top, right, bottom, left } = anchor.getBoundingClientRect()
|
|
32
|
+
return { x, y, width, height, top, right, bottom, left }
|
|
33
|
+
}
|
|
34
|
+
let rect = measure()
|
|
35
|
+
return {
|
|
36
|
+
contextElement,
|
|
37
|
+
getBoundingClientRect: () => {
|
|
38
|
+
if (current() && (!contextElement || contextElement.isConnected)) rect = measure()
|
|
39
|
+
return rect
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PaginationEntry, PaginationRange } from '../types/pagination'
|
|
2
|
+
|
|
3
|
+
export function paginationInteger(value: number, fallback: number, minimum: number) {
|
|
4
|
+
return Number.isFinite(value) ? Math.max(minimum, Math.floor(value)) : fallback
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function paginationRanges(items: PaginationEntry[]): PaginationRange[] {
|
|
8
|
+
return items.flatMap((item, index) => {
|
|
9
|
+
if (item.type !== 'ellipsis') return []
|
|
10
|
+
const previous = items[index - 1]
|
|
11
|
+
const next = items[index + 1]
|
|
12
|
+
if (previous?.type !== 'page' || next?.type !== 'page' || next.value <= previous.value + 1)
|
|
13
|
+
return []
|
|
14
|
+
return [{ side: index === 1 ? 'prev' : 'next', from: previous.value + 1, to: next.value - 1 }]
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type Point = { x: number; y: number }
|
|
2
|
+
const cross = (a: Point, b: Point, c: Point) =>
|
|
3
|
+
(b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
|
4
|
+
|
|
5
|
+
export function inPointerCorridor(point: Point, first: DOMRect, second: DOMRect) {
|
|
6
|
+
const points = [first, second]
|
|
7
|
+
.flatMap(rect => [
|
|
8
|
+
{ x: rect.left - 6, y: rect.top - 6 },
|
|
9
|
+
{ x: rect.right + 6, y: rect.top - 6 },
|
|
10
|
+
{ x: rect.left - 6, y: rect.bottom + 6 },
|
|
11
|
+
{ x: rect.right + 6, y: rect.bottom + 6 },
|
|
12
|
+
])
|
|
13
|
+
.sort((a, b) => a.x - b.x || a.y - b.y)
|
|
14
|
+
const half = (values: Point[]) => {
|
|
15
|
+
const hull: Point[] = []
|
|
16
|
+
for (const value of values) {
|
|
17
|
+
while (hull.length > 1 && cross(hull[hull.length - 2]!, hull[hull.length - 1]!, value) <= 0)
|
|
18
|
+
hull.pop()
|
|
19
|
+
hull.push(value)
|
|
20
|
+
}
|
|
21
|
+
hull.pop()
|
|
22
|
+
return hull
|
|
23
|
+
}
|
|
24
|
+
const hull = [...half(points), ...half([...points].reverse())]
|
|
25
|
+
return hull.every((a, i) => cross(a, hull[(i + 1) % hull.length]!, point) >= 0)
|
|
26
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface QRCodeExportOptions {
|
|
2
|
+
type?: 'image/svg+xml' | 'image/png'
|
|
3
|
+
scale?: number
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function dataURL(blob: Blob): Promise<string> {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const reader = new FileReader()
|
|
9
|
+
reader.onload = () => resolve(reader.result as string)
|
|
10
|
+
reader.onerror = () => reject(reader.error)
|
|
11
|
+
reader.readAsDataURL(blob)
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function exportQRCode(
|
|
16
|
+
svg: SVGSVGElement,
|
|
17
|
+
size: number,
|
|
18
|
+
{ type = 'image/png', scale = 2 }: QRCodeExportOptions = {},
|
|
19
|
+
): Promise<Blob> {
|
|
20
|
+
const clone = svg.cloneNode(true) as SVGSVGElement
|
|
21
|
+
const source = [svg, ...svg.querySelectorAll('*')]
|
|
22
|
+
const target = [clone, ...clone.querySelectorAll('*')]
|
|
23
|
+
target.forEach((el, index) => {
|
|
24
|
+
const style = getComputedStyle(source[index]!)
|
|
25
|
+
el.removeAttribute('class')
|
|
26
|
+
el.removeAttribute('style')
|
|
27
|
+
el.setAttribute('fill', style.fill)
|
|
28
|
+
})
|
|
29
|
+
clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
|
|
30
|
+
clone.setAttribute('width', String(size))
|
|
31
|
+
clone.setAttribute('height', String(size))
|
|
32
|
+
for (const image of clone.querySelectorAll('image')) {
|
|
33
|
+
const href = image.getAttribute('href')
|
|
34
|
+
if (!href) continue
|
|
35
|
+
let embedded = href
|
|
36
|
+
if (!href.startsWith('data:')) {
|
|
37
|
+
const response = await fetch(new URL(href, svg.ownerDocument.baseURI))
|
|
38
|
+
if (!response.ok) throw new Error('Unable to export the QR code logo')
|
|
39
|
+
embedded = await dataURL(await response.blob())
|
|
40
|
+
}
|
|
41
|
+
const decoded = new Image()
|
|
42
|
+
decoded.src = embedded
|
|
43
|
+
await decoded.decode()
|
|
44
|
+
image.setAttribute('href', embedded)
|
|
45
|
+
}
|
|
46
|
+
const blob = new Blob([new XMLSerializer().serializeToString(clone)], { type: 'image/svg+xml' })
|
|
47
|
+
if (type === 'image/svg+xml') return blob
|
|
48
|
+
const url = URL.createObjectURL(blob)
|
|
49
|
+
try {
|
|
50
|
+
const image = new Image()
|
|
51
|
+
image.src = url
|
|
52
|
+
await image.decode()
|
|
53
|
+
const factor = Number.isFinite(scale) ? Math.max(1, Math.min(8, scale)) : 2
|
|
54
|
+
const canvas = svg.ownerDocument.createElement('canvas')
|
|
55
|
+
canvas.width = canvas.height = Math.min(8192, Math.round(size * factor))
|
|
56
|
+
const context = canvas.getContext('2d')
|
|
57
|
+
if (!context) throw new Error('Canvas is unavailable')
|
|
58
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height)
|
|
59
|
+
return await new Promise<Blob>((resolve, reject) => {
|
|
60
|
+
canvas.toBlob(
|
|
61
|
+
result => (result ? resolve(result) : reject(new Error('Unable to export the QR code'))),
|
|
62
|
+
'image/png',
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
} finally {
|
|
66
|
+
URL.revokeObjectURL(url)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DateValue } from '@internationalized/date'
|
|
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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const DIVISIONS = [
|
|
2
|
+
[60, 'second'],
|
|
3
|
+
[60, 'minute'],
|
|
4
|
+
[24, 'hour'],
|
|
5
|
+
[7, 'day'],
|
|
6
|
+
[4.34524, 'week'],
|
|
7
|
+
[12, 'month'],
|
|
8
|
+
[Infinity, 'year'],
|
|
9
|
+
] as const
|
|
10
|
+
|
|
11
|
+
export function relativeTime(target: Date, nowMs: number, tag: string, justNow: string): string {
|
|
12
|
+
let duration = (target.getTime() - nowMs) / 1000
|
|
13
|
+
if (Math.abs(duration) < 45) return justNow
|
|
14
|
+
const rtf = new Intl.RelativeTimeFormat(tag, { numeric: 'auto' })
|
|
15
|
+
for (const [amount, unit] of DIVISIONS) {
|
|
16
|
+
if (Math.abs(duration) < amount) return rtf.format(Math.round(duration), unit)
|
|
17
|
+
duration /= amount
|
|
18
|
+
}
|
|
19
|
+
return ''
|
|
20
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type ScrollDirection = 'vertical' | 'horizontal' | 'both'
|
|
2
|
+
|
|
3
|
+
export interface ScrollEdges {
|
|
4
|
+
xStart: boolean
|
|
5
|
+
xEnd: boolean
|
|
6
|
+
yStart: boolean
|
|
7
|
+
yEnd: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const NONE: ScrollEdges = { xStart: false, xEnd: false, yStart: false, yEnd: false }
|
|
11
|
+
|
|
12
|
+
export function scrollEdges(
|
|
13
|
+
element: HTMLElement | undefined | null,
|
|
14
|
+
direction: ScrollDirection,
|
|
15
|
+
shadow: boolean,
|
|
16
|
+
): ScrollEdges {
|
|
17
|
+
if (!element || !shadow) return NONE
|
|
18
|
+
const room = 1
|
|
19
|
+
const x = direction !== 'vertical'
|
|
20
|
+
const y = direction !== 'horizontal'
|
|
21
|
+
return {
|
|
22
|
+
xStart: x && Math.abs(element.scrollLeft) > room,
|
|
23
|
+
xEnd: x && Math.abs(element.scrollLeft) + element.clientWidth < element.scrollWidth - room,
|
|
24
|
+
yStart: y && element.scrollTop > room,
|
|
25
|
+
yEnd: y && element.scrollTop + element.clientHeight < element.scrollHeight - room,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function redirectWheel(element: HTMLElement, event: WheelEvent) {
|
|
30
|
+
if (Math.abs(event.deltaY) <= Math.abs(event.deltaX)) return
|
|
31
|
+
const max = element.scrollWidth - element.clientWidth
|
|
32
|
+
if (max <= 0) return
|
|
33
|
+
const sign = getComputedStyle(element).direction === 'rtl' ? -1 : 1
|
|
34
|
+
const offset = Math.max(0, Math.min(max, element.scrollLeft * sign))
|
|
35
|
+
const atStart = offset <= 1 && event.deltaY < 0
|
|
36
|
+
const atEnd = offset >= max - 1 && event.deltaY > 0
|
|
37
|
+
if (atStart || atEnd) return
|
|
38
|
+
event.preventDefault()
|
|
39
|
+
element.scrollLeft = (offset + event.deltaY) * sign
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function blockWhenInert(element: HTMLElement) {
|
|
43
|
+
const block = (event: Event) => {
|
|
44
|
+
if (getComputedStyle(element).pointerEvents === 'none') event.preventDefault()
|
|
45
|
+
}
|
|
46
|
+
element.addEventListener('wheel', block, { passive: false, capture: true })
|
|
47
|
+
element.addEventListener('touchmove', block, { passive: false, capture: true })
|
|
48
|
+
return () => {
|
|
49
|
+
element.removeEventListener('wheel', block, true)
|
|
50
|
+
element.removeEventListener('touchmove', block, true)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const SCROLL_AREA_OVERFLOW = {
|
|
55
|
+
vertical: { x: 'hidden', y: 'scroll' },
|
|
56
|
+
horizontal: { x: 'scroll', y: 'hidden' },
|
|
57
|
+
both: { x: 'scroll', y: 'scroll' },
|
|
58
|
+
} as const
|
|
59
|
+
|
|
60
|
+
export function scrollAreaOptions(options: {
|
|
61
|
+
direction: ScrollDirection
|
|
62
|
+
autoHide: 'never' | 'scroll' | 'leave' | 'move'
|
|
63
|
+
scrollbar: boolean
|
|
64
|
+
}) {
|
|
65
|
+
return {
|
|
66
|
+
scrollbars: {
|
|
67
|
+
theme: 'os-theme-dark',
|
|
68
|
+
visibility: options.scrollbar ? ('auto' as const) : ('hidden' as const),
|
|
69
|
+
autoHide: options.autoHide,
|
|
70
|
+
autoHideDelay: 800,
|
|
71
|
+
},
|
|
72
|
+
overflow: SCROLL_AREA_OVERFLOW[options.direction],
|
|
73
|
+
update: {
|
|
74
|
+
elementEvents: [['img', 'load']] as Array<[string, string]>,
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export const SCROLL_STATE_FIELD = 'hnScroll'
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const VISIBLE_STACK = 3
|
|
2
|
+
|
|
3
|
+
export const TOAST_GAP = 12
|
|
4
|
+
|
|
5
|
+
export const TOAST_CARD_CHROME_BLOCK = 34
|
|
6
|
+
|
|
7
|
+
export interface ToastSlot {
|
|
8
|
+
index: number
|
|
9
|
+
offset: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function toastLayout(
|
|
13
|
+
open: readonly { id: number | string }[],
|
|
14
|
+
heightOf: (id: number | string) => number | undefined,
|
|
15
|
+
) {
|
|
16
|
+
const map = new Map<number | string, ToastSlot>()
|
|
17
|
+
let offset = 0
|
|
18
|
+
for (let i = open.length - 1; i >= 0; i -= 1) {
|
|
19
|
+
const item = open[i]!
|
|
20
|
+
const index = open.length - 1 - i
|
|
21
|
+
map.set(item.id, { index, offset })
|
|
22
|
+
offset += (heightOf(item.id) ?? 0) + TOAST_GAP
|
|
23
|
+
}
|
|
24
|
+
return map
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function toastItemStyle(
|
|
28
|
+
slot: ToastSlot,
|
|
29
|
+
selfHeight: number | undefined,
|
|
30
|
+
frontHeight: number,
|
|
31
|
+
): Record<string, string> {
|
|
32
|
+
return {
|
|
33
|
+
'--hn-t-index': String(slot.index),
|
|
34
|
+
'--hn-t-offset': `${slot.offset}px`,
|
|
35
|
+
...(selfHeight ? { '--hn-t-self-h': `${selfHeight}px` } : {}),
|
|
36
|
+
...(frontHeight > 0 ? { '--hn-t-front-h': `${frontHeight}px` } : {}),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function toastCardHeight(body: HTMLElement) {
|
|
41
|
+
return body.offsetHeight + TOAST_CARD_CHROME_BLOCK
|
|
42
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { TreeNode, TreeNodeState, TreeValue } from '../../types/tree'
|
|
2
|
+
|
|
3
|
+
interface Entry {
|
|
4
|
+
node: TreeNode
|
|
5
|
+
parent?: TreeValue
|
|
6
|
+
children: TreeValue[]
|
|
7
|
+
disabled: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface TreeIndex {
|
|
11
|
+
roots: TreeValue[]
|
|
12
|
+
entries: Map<TreeValue, Entry>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function indexTree(nodes: TreeNode[]): TreeIndex {
|
|
16
|
+
const entries = new Map<TreeValue, Entry>()
|
|
17
|
+
function visit(node: TreeNode, parent?: TreeValue, disabled = false) {
|
|
18
|
+
const entry = {
|
|
19
|
+
node,
|
|
20
|
+
parent,
|
|
21
|
+
disabled: disabled || !!node.disabled,
|
|
22
|
+
children: node.children?.map(child => child.value) ?? [],
|
|
23
|
+
}
|
|
24
|
+
entries.set(node.value, entry)
|
|
25
|
+
node.children?.forEach(child => visit(child, node.value, entry.disabled))
|
|
26
|
+
}
|
|
27
|
+
nodes.forEach(node => visit(node))
|
|
28
|
+
return { roots: nodes.map(node => node.value), entries }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function checkedState(tree: TreeIndex, values: TreeValue[]) {
|
|
32
|
+
const checked = new Set(values)
|
|
33
|
+
const states = new Map<TreeValue, TreeNodeState>()
|
|
34
|
+
function visit(value: TreeValue, inherited = false): TreeNodeState {
|
|
35
|
+
const entry = tree.entries.get(value)!
|
|
36
|
+
const own = checked.has(value) || (!entry.disabled && inherited)
|
|
37
|
+
const children = entry.children.map(child => visit(child, !entry.disabled && own))
|
|
38
|
+
const enabled = children.filter(child => !child.disabled)
|
|
39
|
+
const selected =
|
|
40
|
+
entry.disabled || enabled.length === 0 ? own : enabled.every(child => child.selected)
|
|
41
|
+
const indeterminate =
|
|
42
|
+
!entry.disabled && !selected && enabled.some(child => child.selected || child.indeterminate)
|
|
43
|
+
const state = { selected, indeterminate, disabled: entry.disabled }
|
|
44
|
+
states.set(value, state)
|
|
45
|
+
return state
|
|
46
|
+
}
|
|
47
|
+
tree.roots.forEach(value => visit(value))
|
|
48
|
+
return states
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function toggleChecked(tree: TreeIndex, values: TreeValue[], value: TreeValue): TreeValue[] {
|
|
52
|
+
const entry = tree.entries.get(value)
|
|
53
|
+
if (!entry || entry.disabled) return values
|
|
54
|
+
const states = checkedState(tree, values)
|
|
55
|
+
const checked = new Set(values.filter(value => !tree.entries.has(value)))
|
|
56
|
+
states.forEach((state, value) => {
|
|
57
|
+
if (state.selected) checked.add(value)
|
|
58
|
+
})
|
|
59
|
+
const selected = !states.get(value)!.selected
|
|
60
|
+
function visit(value: TreeValue) {
|
|
61
|
+
const entry = tree.entries.get(value)!
|
|
62
|
+
if (entry.disabled) return
|
|
63
|
+
if (selected) checked.add(value)
|
|
64
|
+
else checked.delete(value)
|
|
65
|
+
entry.children.forEach(visit)
|
|
66
|
+
}
|
|
67
|
+
visit(value)
|
|
68
|
+
let parent = entry.parent
|
|
69
|
+
while (parent !== undefined) {
|
|
70
|
+
checked.delete(parent)
|
|
71
|
+
parent = tree.entries.get(parent)!.parent
|
|
72
|
+
}
|
|
73
|
+
const next = checkedState(tree, [...checked])
|
|
74
|
+
return [
|
|
75
|
+
...[...checked].filter(value => !tree.entries.has(value)),
|
|
76
|
+
...[...tree.entries.keys()].filter(value => next.get(value)!.selected),
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function treeKey(node: Pick<TreeNode, 'value'>) {
|
|
81
|
+
return `${typeof node.value}:${node.value}`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function treeStates(
|
|
85
|
+
tree: TreeIndex,
|
|
86
|
+
multiple: boolean | undefined,
|
|
87
|
+
model: TreeValue | TreeValue[] | null | undefined,
|
|
88
|
+
) {
|
|
89
|
+
if (multiple) return checkedState(tree, Array.isArray(model) ? model : [])
|
|
90
|
+
return new Map<TreeValue, TreeNodeState>(
|
|
91
|
+
[...tree.entries].map(([value, entry]) => [
|
|
92
|
+
value,
|
|
93
|
+
{
|
|
94
|
+
selected: value === model,
|
|
95
|
+
indeterminate: false,
|
|
96
|
+
disabled: entry.disabled,
|
|
97
|
+
},
|
|
98
|
+
]),
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function selectedTreeNodes(tree: TreeIndex, states: Map<TreeValue, TreeNodeState>) {
|
|
103
|
+
return [...tree.entries.values()]
|
|
104
|
+
.filter(entry => states.get(entry.node.value)?.selected)
|
|
105
|
+
.map(entry => entry.node)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function treeKeyMap(tree: TreeIndex) {
|
|
109
|
+
return new Map([...tree.entries].map(([value, entry]) => [treeKey(entry.node), value]))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function expandedTreeKeys(values: readonly TreeValue[]) {
|
|
113
|
+
return values.map(value => treeKey({ value }))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function expandedTreeValues(keys: Map<string, TreeValue>, expanded: readonly string[]) {
|
|
117
|
+
return expanded.flatMap(key => (keys.has(key) ? [keys.get(key)!] : []))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function nextTreeModel(
|
|
121
|
+
tree: TreeIndex,
|
|
122
|
+
multiple: boolean | undefined,
|
|
123
|
+
model: TreeValue | TreeValue[] | null | undefined,
|
|
124
|
+
value: TreeValue,
|
|
125
|
+
): TreeValue | TreeValue[] | null {
|
|
126
|
+
return multiple
|
|
127
|
+
? toggleChecked(tree, Array.isArray(model) ? model : [], value)
|
|
128
|
+
: model === value
|
|
129
|
+
? null
|
|
130
|
+
: value
|
|
131
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TreeSelectNode } from '../../types/tree-select'
|
|
2
|
+
|
|
3
|
+
export function filterTree(nodes: TreeSelectNode[], matches: (node: TreeSelectNode) => boolean) {
|
|
4
|
+
const children = new Map<TreeSelectNode, TreeSelectNode[]>()
|
|
5
|
+
const expanded: string[] = []
|
|
6
|
+
|
|
7
|
+
function visit(items: TreeSelectNode[]): TreeSelectNode[] {
|
|
8
|
+
return items.filter(node => {
|
|
9
|
+
const descendants = visit(node.children ?? [])
|
|
10
|
+
if (descendants.length) {
|
|
11
|
+
children.set(node, descendants)
|
|
12
|
+
expanded.push(String(node.value))
|
|
13
|
+
}
|
|
14
|
+
return descendants.length > 0 || matches(node)
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return { items: visit(nodes), children, expanded }
|
|
19
|
+
}
|