@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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { prefersReducedMotion } from '../motion'
|
|
2
|
+
|
|
3
|
+
function findViewport(nav: HTMLElement, target: HTMLElement) {
|
|
4
|
+
const doc = nav.ownerDocument
|
|
5
|
+
const view = doc.defaultView!
|
|
6
|
+
for (
|
|
7
|
+
let node: HTMLElement | null = nav;
|
|
8
|
+
node && node !== doc.body && node !== doc.documentElement;
|
|
9
|
+
node = node.parentElement
|
|
10
|
+
) {
|
|
11
|
+
if (node.contains(target)) break
|
|
12
|
+
if (/^(auto|scroll|overlay)$/.test(view.getComputedStyle(node).overflowY)) return node
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AnchorFollowInput {
|
|
17
|
+
nav: HTMLElement | null | undefined
|
|
18
|
+
current: string | undefined
|
|
19
|
+
lastCovered: string | undefined
|
|
20
|
+
enabled: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AnchorFollowResult {
|
|
24
|
+
viewport: HTMLElement | undefined
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function createAnchorFollow() {
|
|
28
|
+
let lastCurrent: string | undefined
|
|
29
|
+
let lastEnd: string | undefined
|
|
30
|
+
|
|
31
|
+
function follow({
|
|
32
|
+
nav,
|
|
33
|
+
current: id,
|
|
34
|
+
lastCovered,
|
|
35
|
+
enabled,
|
|
36
|
+
}: AnchorFollowInput): AnchorFollowResult | undefined {
|
|
37
|
+
if (!enabled || !nav || !id) return
|
|
38
|
+
const target = nav.ownerDocument.getElementById(id)
|
|
39
|
+
const link = nav.querySelector<HTMLElement>('a[aria-current="location"]')
|
|
40
|
+
if (!target || !link || !link.getClientRects().length) return
|
|
41
|
+
const port = findViewport(nav, target)
|
|
42
|
+
const result = { viewport: port }
|
|
43
|
+
const endId = lastCovered ?? id
|
|
44
|
+
const changed = lastCurrent !== undefined && (lastCurrent !== id || lastEnd !== endId)
|
|
45
|
+
lastCurrent = id
|
|
46
|
+
lastEnd = endId
|
|
47
|
+
if (!port || port.clientHeight <= 0 || port.scrollHeight <= port.clientHeight) return result
|
|
48
|
+
|
|
49
|
+
const box = port.getBoundingClientRect()
|
|
50
|
+
let row: Pick<DOMRect, 'top' | 'bottom' | 'height'> = link.getBoundingClientRect()
|
|
51
|
+
const scale = port.offsetHeight ? box.height / port.offsetHeight : 1
|
|
52
|
+
if (scale <= 0) return result
|
|
53
|
+
if (endId !== id) {
|
|
54
|
+
const end = nav.querySelector<HTMLElement>(`a[href="#${CSS.escape(endId)}"]`)
|
|
55
|
+
if (end?.getClientRects().length) {
|
|
56
|
+
const bottom = end.getBoundingClientRect().bottom
|
|
57
|
+
const height = bottom - row.top
|
|
58
|
+
if (height >= row.height && height <= port.clientHeight * scale)
|
|
59
|
+
row = { top: row.top, bottom, height }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const top = box.top + port.clientTop * scale
|
|
63
|
+
const bottom = top + port.clientHeight * scale
|
|
64
|
+
if (row.top >= top && row.bottom <= bottom) return result
|
|
65
|
+
if (row.top <= top && row.bottom >= bottom) return result
|
|
66
|
+
|
|
67
|
+
const style = port.ownerDocument.defaultView!.getComputedStyle(port)
|
|
68
|
+
const margin = Math.min(row.height / scale / 2, port.clientHeight / 4)
|
|
69
|
+
const padding = (value: string) =>
|
|
70
|
+
Math.min(
|
|
71
|
+
Math.max(0, (port.clientHeight - row.height / scale) / 2),
|
|
72
|
+
value === 'auto'
|
|
73
|
+
? margin
|
|
74
|
+
: (parseFloat(value) || 0) * (value.endsWith('%') ? port.clientHeight / 100 : 1),
|
|
75
|
+
)
|
|
76
|
+
const before = padding(style.scrollPaddingTop)
|
|
77
|
+
const after = padding(style.scrollPaddingBottom)
|
|
78
|
+
const delta =
|
|
79
|
+
row.height > bottom - top || row.top < top
|
|
80
|
+
? (row.top - top) / scale - before
|
|
81
|
+
: (row.bottom - bottom) / scale + after
|
|
82
|
+
const next = Math.max(
|
|
83
|
+
0,
|
|
84
|
+
Math.min(port.scrollHeight - port.clientHeight, port.scrollTop + delta),
|
|
85
|
+
)
|
|
86
|
+
if (Math.abs(next - port.scrollTop) < 1) return result
|
|
87
|
+
port.scrollTo({
|
|
88
|
+
top: next,
|
|
89
|
+
behavior: changed && !prefersReducedMotion() ? 'smooth' : 'instant',
|
|
90
|
+
})
|
|
91
|
+
return result
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return { follow }
|
|
95
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { FormErrors, FormRules, FormValues } from '../lib/form/standard-schema'
|
|
2
|
+
import { ROOT, readPath, runRules } from '../lib/form/errors'
|
|
3
|
+
import { same, snapshot } from '../lib/form/values'
|
|
4
|
+
|
|
5
|
+
export type FormValidateOn = 'submit' | 'blur' | 'change'
|
|
6
|
+
|
|
7
|
+
export interface FormOptions {
|
|
8
|
+
values: () => FormValues
|
|
9
|
+
rules: () => FormRules | undefined
|
|
10
|
+
validateOn: () => FormValidateOn
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ServerError {
|
|
14
|
+
message: string
|
|
15
|
+
value: unknown
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface FormController {
|
|
19
|
+
errors: () => FormErrors
|
|
20
|
+
formError: () => string | undefined
|
|
21
|
+
invalid: () => boolean
|
|
22
|
+
submitted: () => boolean
|
|
23
|
+
submitting: () => boolean
|
|
24
|
+
version: () => number
|
|
25
|
+
subscribe: (listener: () => void) => () => void
|
|
26
|
+
validate: () => Promise<boolean>
|
|
27
|
+
touch: (name: string) => void
|
|
28
|
+
onChange: () => void
|
|
29
|
+
submit: (handler?: (values: FormValues) => unknown) => Promise<boolean>
|
|
30
|
+
setErrors: (errors: FormErrors) => void
|
|
31
|
+
reset: () => void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createForm(options: FormOptions): FormController {
|
|
35
|
+
let found: FormErrors = {}
|
|
36
|
+
let touched = new Set<string>()
|
|
37
|
+
let submitted = false
|
|
38
|
+
let submitting = false
|
|
39
|
+
let server = new Map<string, ServerError>()
|
|
40
|
+
let pending: { values: FormValues; rules: FormRules | undefined } | undefined
|
|
41
|
+
let validation = 0
|
|
42
|
+
let submission = 0
|
|
43
|
+
let initial = snapshot(options.values()) as FormValues
|
|
44
|
+
let version = 0
|
|
45
|
+
const listeners = new Set<() => void>()
|
|
46
|
+
|
|
47
|
+
function notify() {
|
|
48
|
+
version++
|
|
49
|
+
for (const listener of [...listeners]) listener()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function shown(key: string) {
|
|
53
|
+
if (submitted || touched.has(key)) return true
|
|
54
|
+
const mode = options.validateOn()
|
|
55
|
+
return mode === 'change' && !same(readPath(options.values(), key), readPath(initial, key))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function errors() {
|
|
59
|
+
const result: FormErrors = {}
|
|
60
|
+
for (const [key, message] of Object.entries(found)) {
|
|
61
|
+
if (key !== ROOT && shown(key)) result[key] = message
|
|
62
|
+
}
|
|
63
|
+
for (const [key, entry] of server) result[key] = entry.message
|
|
64
|
+
return result
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function formError() {
|
|
68
|
+
return found[ROOT]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function invalid() {
|
|
72
|
+
return Object.keys(errors()).length > 0 || !!formError()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function validate() {
|
|
76
|
+
const current = ++validation
|
|
77
|
+
const values = snapshot(options.values()) as FormValues
|
|
78
|
+
const rules = options.rules()
|
|
79
|
+
const request = { values, rules }
|
|
80
|
+
pending = request
|
|
81
|
+
try {
|
|
82
|
+
const result = await runRules(rules, values)
|
|
83
|
+
if (current !== validation || rules !== options.rules() || !same(values, options.values())) {
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
found = result
|
|
87
|
+
notify()
|
|
88
|
+
return Object.keys(result).length === 0
|
|
89
|
+
} finally {
|
|
90
|
+
if (pending === request) pending = undefined
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function revalidate() {
|
|
95
|
+
if (pending && pending.rules === options.rules() && same(pending.values, options.values()))
|
|
96
|
+
return
|
|
97
|
+
void validate()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function touch(name: string) {
|
|
101
|
+
if (touched.has(name)) return
|
|
102
|
+
touched = new Set(touched).add(name)
|
|
103
|
+
notify()
|
|
104
|
+
if (options.validateOn() !== 'submit') revalidate()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function onChange() {
|
|
108
|
+
const values = options.values()
|
|
109
|
+
if (server.size) {
|
|
110
|
+
const next = new Map(server)
|
|
111
|
+
for (const [key, entry] of next) if (readPath(values, key) !== entry.value) next.delete(key)
|
|
112
|
+
if (next.size !== server.size) {
|
|
113
|
+
server = next
|
|
114
|
+
notify()
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (submitted || options.validateOn() !== 'submit') revalidate()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function submit(handler?: (values: FormValues) => unknown) {
|
|
121
|
+
if (submitting) return false
|
|
122
|
+
const current = ++submission
|
|
123
|
+
const values = snapshot(options.values()) as FormValues
|
|
124
|
+
submitted = true
|
|
125
|
+
submitting = true
|
|
126
|
+
notify()
|
|
127
|
+
try {
|
|
128
|
+
const valid = await validate()
|
|
129
|
+
if (!valid || current !== submission || server.size || !same(values, options.values())) {
|
|
130
|
+
return false
|
|
131
|
+
}
|
|
132
|
+
await handler?.(options.values())
|
|
133
|
+
return true
|
|
134
|
+
} finally {
|
|
135
|
+
if (current === submission) {
|
|
136
|
+
submitting = false
|
|
137
|
+
notify()
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function setErrors(next: FormErrors) {
|
|
143
|
+
const values = options.values()
|
|
144
|
+
const map = new Map<string, ServerError>()
|
|
145
|
+
for (const [key, message] of Object.entries(next)) {
|
|
146
|
+
map.set(key, { message, value: readPath(values, key) })
|
|
147
|
+
}
|
|
148
|
+
server = map
|
|
149
|
+
notify()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function reset() {
|
|
153
|
+
validation++
|
|
154
|
+
submission++
|
|
155
|
+
pending = undefined
|
|
156
|
+
submitting = false
|
|
157
|
+
found = {}
|
|
158
|
+
touched = new Set()
|
|
159
|
+
submitted = false
|
|
160
|
+
server = new Map()
|
|
161
|
+
initial = snapshot(options.values()) as FormValues
|
|
162
|
+
notify()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function subscribe(listener: () => void) {
|
|
166
|
+
listeners.add(listener)
|
|
167
|
+
return () => {
|
|
168
|
+
listeners.delete(listener)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
errors,
|
|
174
|
+
formError,
|
|
175
|
+
invalid,
|
|
176
|
+
submitted: () => submitted,
|
|
177
|
+
submitting: () => submitting,
|
|
178
|
+
version: () => version,
|
|
179
|
+
subscribe,
|
|
180
|
+
validate,
|
|
181
|
+
touch,
|
|
182
|
+
onChange,
|
|
183
|
+
submit,
|
|
184
|
+
setErrors,
|
|
185
|
+
reset,
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { prefersReducedMotion } from '../motion'
|
|
2
|
+
|
|
3
|
+
const INITIAL_ORIGIN_SCALE = 0.2
|
|
4
|
+
const PADDING = 12
|
|
5
|
+
const SOFT_EDGE_MINIMUM_SIZE = 75
|
|
6
|
+
const SOFT_EDGE_CONTAINER_RATIO = 0.35
|
|
7
|
+
const GROW_MS = 150
|
|
8
|
+
const MINIMUM_PRESS_MS = 225
|
|
9
|
+
const TOUCH_DELAY_MS = 150
|
|
10
|
+
|
|
11
|
+
const STATE = {
|
|
12
|
+
inactive: 0,
|
|
13
|
+
touchDelay: 1,
|
|
14
|
+
holding: 2,
|
|
15
|
+
waitingForClick: 3,
|
|
16
|
+
} as const
|
|
17
|
+
|
|
18
|
+
type RippleState = (typeof STATE)[keyof typeof STATE]
|
|
19
|
+
|
|
20
|
+
export interface RippleOptions {
|
|
21
|
+
container: () => HTMLElement | null
|
|
22
|
+
surface: () => HTMLElement | null
|
|
23
|
+
disabled: () => boolean
|
|
24
|
+
onPressedChange: (pressed: boolean) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function createRipple(options: RippleOptions) {
|
|
28
|
+
let host: HTMLElement | null = null
|
|
29
|
+
let state: RippleState = STATE.inactive
|
|
30
|
+
let startEvent: PointerEvent | undefined
|
|
31
|
+
let checkBoundsAfterContextMenu = false
|
|
32
|
+
let growAnimation: Animation | undefined
|
|
33
|
+
let initialSize = 0
|
|
34
|
+
let rippleScale = ''
|
|
35
|
+
let rippleSize = ''
|
|
36
|
+
const timers = new Set<number>()
|
|
37
|
+
|
|
38
|
+
function later(callback: () => void, ms: number) {
|
|
39
|
+
const timer = window.setTimeout(() => {
|
|
40
|
+
timers.delete(timer)
|
|
41
|
+
callback()
|
|
42
|
+
}, ms)
|
|
43
|
+
timers.add(timer)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const isTouch = ({ pointerType }: PointerEvent) => pointerType === 'touch'
|
|
47
|
+
|
|
48
|
+
function shouldReact(event: PointerEvent) {
|
|
49
|
+
if (options.disabled() || !event.isPrimary) return false
|
|
50
|
+
if (startEvent && startEvent.pointerId !== event.pointerId) return false
|
|
51
|
+
if (event.type === 'pointerenter' || event.type === 'pointerleave') return !isTouch(event)
|
|
52
|
+
return isTouch(event) || event.buttons === 1
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function inBounds({ x, y }: PointerEvent) {
|
|
56
|
+
const rect = options.container()?.getBoundingClientRect()
|
|
57
|
+
if (!rect) return false
|
|
58
|
+
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function determineRippleSize() {
|
|
62
|
+
const rect = options.container()?.getBoundingClientRect()
|
|
63
|
+
if (!rect) return
|
|
64
|
+
const maxDim = Math.max(rect.height, rect.width)
|
|
65
|
+
const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE)
|
|
66
|
+
initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE)
|
|
67
|
+
const maxRadius = Math.hypot(rect.width, rect.height) + PADDING
|
|
68
|
+
rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`
|
|
69
|
+
rippleSize = `${initialSize}px`
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function normalizedCoords(event: PointerEvent) {
|
|
73
|
+
const rect = options.container()?.getBoundingClientRect()
|
|
74
|
+
if (!rect) return { x: 0, y: 0 }
|
|
75
|
+
return {
|
|
76
|
+
x: event.pageX - (window.scrollX + rect.left),
|
|
77
|
+
y: event.pageY - (window.scrollY + rect.top),
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function translationCoords(positionEvent?: PointerEvent) {
|
|
82
|
+
const rect = options.container()?.getBoundingClientRect()
|
|
83
|
+
if (!rect) return { startPoint: { x: 0, y: 0 }, endPoint: { x: 0, y: 0 } }
|
|
84
|
+
const endPoint = {
|
|
85
|
+
x: (rect.width - initialSize) / 2,
|
|
86
|
+
y: (rect.height - initialSize) / 2,
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
startPoint: positionEvent ? normalizedCoords(positionEvent) : endPoint,
|
|
90
|
+
endPoint,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function startPress(positionEvent?: PointerEvent) {
|
|
95
|
+
const el = options.surface()
|
|
96
|
+
if (!el) return
|
|
97
|
+
options.onPressedChange(true)
|
|
98
|
+
growAnimation?.cancel()
|
|
99
|
+
growAnimation = undefined
|
|
100
|
+
determineRippleSize()
|
|
101
|
+
const { startPoint, endPoint } = translationCoords(positionEvent)
|
|
102
|
+
if (typeof el.animate !== 'function') return
|
|
103
|
+
if (prefersReducedMotion()) return
|
|
104
|
+
growAnimation = el.animate(
|
|
105
|
+
{
|
|
106
|
+
height: [rippleSize, rippleSize],
|
|
107
|
+
width: [rippleSize, rippleSize],
|
|
108
|
+
transform: [
|
|
109
|
+
`translate(${startPoint.x}px,${startPoint.y}px) scale(1)`,
|
|
110
|
+
`translate(${endPoint.x}px,${endPoint.y}px) scale(${rippleScale})`,
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
pseudoElement: '::after',
|
|
115
|
+
duration: GROW_MS,
|
|
116
|
+
easing: 'linear',
|
|
117
|
+
fill: 'forwards',
|
|
118
|
+
},
|
|
119
|
+
)
|
|
120
|
+
growAnimation.finished.catch(() => {})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function endPress() {
|
|
124
|
+
startEvent = undefined
|
|
125
|
+
state = STATE.inactive
|
|
126
|
+
const animation = growAnimation
|
|
127
|
+
let playedMs = Infinity
|
|
128
|
+
if (typeof animation?.currentTime === 'number') playedMs = animation.currentTime
|
|
129
|
+
else if (animation?.currentTime) playedMs = animation.currentTime.to('ms').value
|
|
130
|
+
if (playedMs >= MINIMUM_PRESS_MS) {
|
|
131
|
+
options.onPressedChange(false)
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
later(() => {
|
|
135
|
+
if (growAnimation !== animation) return
|
|
136
|
+
options.onPressedChange(false)
|
|
137
|
+
}, MINIMUM_PRESS_MS - playedMs)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function onPointerDown(event: PointerEvent) {
|
|
141
|
+
if (!shouldReact(event)) return
|
|
142
|
+
startEvent = event
|
|
143
|
+
if (!isTouch(event)) {
|
|
144
|
+
state = STATE.waitingForClick
|
|
145
|
+
startPress(event)
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
if (checkBoundsAfterContextMenu && !inBounds(event)) return
|
|
149
|
+
checkBoundsAfterContextMenu = false
|
|
150
|
+
state = STATE.touchDelay
|
|
151
|
+
later(() => {
|
|
152
|
+
if (state !== STATE.touchDelay) return
|
|
153
|
+
state = STATE.holding
|
|
154
|
+
startPress(event)
|
|
155
|
+
}, TOUCH_DELAY_MS)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function onPointerUp(event: PointerEvent) {
|
|
159
|
+
if (!shouldReact(event)) return
|
|
160
|
+
if (state === STATE.holding) {
|
|
161
|
+
state = STATE.waitingForClick
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
if (state === STATE.touchDelay) {
|
|
165
|
+
state = STATE.waitingForClick
|
|
166
|
+
startPress(startEvent)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function onPointerLeave(event: PointerEvent) {
|
|
171
|
+
if (!shouldReact(event)) return
|
|
172
|
+
if (state !== STATE.inactive) endPress()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function onPointerCancel(event: PointerEvent) {
|
|
176
|
+
if (!shouldReact(event)) return
|
|
177
|
+
endPress()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function onClick() {
|
|
181
|
+
if (options.disabled()) return
|
|
182
|
+
if (state === STATE.waitingForClick) {
|
|
183
|
+
endPress()
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
if (state === STATE.inactive) {
|
|
187
|
+
startPress()
|
|
188
|
+
endPress()
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function onContextMenu() {
|
|
193
|
+
if (options.disabled()) return
|
|
194
|
+
checkBoundsAfterContextMenu = true
|
|
195
|
+
endPress()
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const listeners: [string, EventListener][] = [
|
|
199
|
+
['click', onClick as EventListener],
|
|
200
|
+
['contextmenu', onContextMenu as EventListener],
|
|
201
|
+
['pointercancel', onPointerCancel as EventListener],
|
|
202
|
+
['pointerdown', onPointerDown as EventListener],
|
|
203
|
+
['pointerleave', onPointerLeave as EventListener],
|
|
204
|
+
['pointerup', onPointerUp as EventListener],
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
function connect() {
|
|
208
|
+
host = options.container()?.parentElement ?? null
|
|
209
|
+
if (!host) return
|
|
210
|
+
for (const [name, fn] of listeners) host.addEventListener(name, fn, true)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function disconnect() {
|
|
214
|
+
for (const timer of timers) window.clearTimeout(timer)
|
|
215
|
+
timers.clear()
|
|
216
|
+
if (!host) return
|
|
217
|
+
for (const [name, fn] of listeners) host.removeEventListener(name, fn, true)
|
|
218
|
+
host = null
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return { connect, disconnect }
|
|
222
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { workletSource } from './worklet'
|
|
2
|
+
import { prefersReducedMotion } from '../../motion'
|
|
3
|
+
|
|
4
|
+
export const isPaintWorkletSupported =
|
|
5
|
+
typeof CSS !== 'undefined' && (CSS as { paintWorklet?: unknown }).paintWorklet !== undefined
|
|
6
|
+
|
|
7
|
+
let workletRegistered = false
|
|
8
|
+
|
|
9
|
+
export function registerSpoilerWorklet() {
|
|
10
|
+
if (workletRegistered || !isPaintWorkletSupported) return
|
|
11
|
+
workletRegistered = true
|
|
12
|
+
const paintWorklet = (CSS as unknown as { paintWorklet: { addModule(url: string): void } })
|
|
13
|
+
.paintWorklet
|
|
14
|
+
paintWorklet.addModule(
|
|
15
|
+
URL.createObjectURL(new Blob([workletSource], { type: 'application/javascript' })),
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SpoilerPainterOptions {
|
|
20
|
+
fps?: number
|
|
21
|
+
gap?: number
|
|
22
|
+
density?: number
|
|
23
|
+
mimicWords?: boolean
|
|
24
|
+
accent?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const DEFAULTS = {
|
|
28
|
+
fps: 24,
|
|
29
|
+
gap: 6,
|
|
30
|
+
density: 0.12,
|
|
31
|
+
mimicWords: true,
|
|
32
|
+
accent: '0 0% 20%',
|
|
33
|
+
} as const
|
|
34
|
+
|
|
35
|
+
const BLOCK_MAX_TILE = 293
|
|
36
|
+
const INLINE_MAX_TILE = 333
|
|
37
|
+
const GAP_RATIO = 8
|
|
38
|
+
const DEFAULT_FADE_S = 1.5
|
|
39
|
+
|
|
40
|
+
export class SpoilerPainter {
|
|
41
|
+
readonly el: HTMLElement
|
|
42
|
+
maxFPS: number = DEFAULTS.fps
|
|
43
|
+
|
|
44
|
+
private t = 0
|
|
45
|
+
private t0 = 0
|
|
46
|
+
private tstop: number | null = null
|
|
47
|
+
private raf: number | null = null
|
|
48
|
+
private fadeS = 0
|
|
49
|
+
private hidden = false
|
|
50
|
+
private destroyed = false
|
|
51
|
+
|
|
52
|
+
constructor(el: HTMLElement, options: SpoilerPainterOptions = {}) {
|
|
53
|
+
registerSpoilerWorklet()
|
|
54
|
+
this.el = el
|
|
55
|
+
this.update(options)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get isHidden() {
|
|
59
|
+
return this.hidden
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
update({
|
|
63
|
+
fps = DEFAULTS.fps,
|
|
64
|
+
gap = DEFAULTS.gap,
|
|
65
|
+
density = DEFAULTS.density,
|
|
66
|
+
mimicWords = DEFAULTS.mimicWords,
|
|
67
|
+
accent = DEFAULTS.accent,
|
|
68
|
+
}: SpoilerPainterOptions = {}) {
|
|
69
|
+
if (this.destroyed) return
|
|
70
|
+
|
|
71
|
+
this.maxFPS = prefersReducedMotion() ? 0 : fps
|
|
72
|
+
|
|
73
|
+
this.el.style.setProperty('--hn-nz-density', String(density))
|
|
74
|
+
this.el.style.setProperty('--hn-nz-accent', accent)
|
|
75
|
+
|
|
76
|
+
const isBlockElement = getComputedStyle(this.el).getPropertyValue('display') !== 'inline'
|
|
77
|
+
this.useBackgroundStyle('auto', 'auto', false)
|
|
78
|
+
|
|
79
|
+
if (isBlockElement) {
|
|
80
|
+
this.el.style.setProperty('--hn-nz-words', 'false')
|
|
81
|
+
const rect = this.el.getBoundingClientRect()
|
|
82
|
+
|
|
83
|
+
if (rect.width * rect.height > BLOCK_MAX_TILE * BLOCK_MAX_TILE) {
|
|
84
|
+
this.useBackgroundStyle(
|
|
85
|
+
Math.min(rect.width, BLOCK_MAX_TILE),
|
|
86
|
+
Math.min(rect.height, BLOCK_MAX_TILE),
|
|
87
|
+
true,
|
|
88
|
+
)
|
|
89
|
+
} else {
|
|
90
|
+
const capGap = Math.floor(Math.min(gap, rect.width / GAP_RATIO, rect.height / GAP_RATIO))
|
|
91
|
+
this.el.style.setProperty('--hn-nz-gap', `${capGap}px ${capGap}px`)
|
|
92
|
+
}
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.el.style.setProperty('--hn-nz-words', String(mimicWords))
|
|
97
|
+
const rects = [...this.el.getClientRects()]
|
|
98
|
+
const heightOfLine = Math.min(...rects.map(r => r.height))
|
|
99
|
+
|
|
100
|
+
this.useBackgroundStyle(INLINE_MAX_TILE, heightOfLine, true)
|
|
101
|
+
const capGap = Math.floor(Math.min(heightOfLine / GAP_RATIO, gap))
|
|
102
|
+
this.el.style.setProperty('--hn-nz-gap', `0 ${capGap}px`)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private useBackgroundStyle(ws: string | number, hs: string | number, tile: boolean) {
|
|
106
|
+
const w = typeof ws === 'number' ? `${ws}px` : ws
|
|
107
|
+
const h = typeof hs === 'number' ? `${hs}px` : hs
|
|
108
|
+
const repeatAndPosition = tile ? 'repeat left center' : 'no-repeat center center'
|
|
109
|
+
this.el.style.background = `paint(hn-spoiler) ${repeatAndPosition} / ${w} ${h}`
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private setFade(value: number) {
|
|
113
|
+
this.fadeS = value
|
|
114
|
+
this.el.style.setProperty('--hn-nz-fade', `${value}s`)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private setT(value: number) {
|
|
118
|
+
this.t = value
|
|
119
|
+
this.el.style.setProperty('--hn-nz-t', value.toFixed(3))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private setTstop(value: number | null) {
|
|
123
|
+
this.tstop = value
|
|
124
|
+
if (value !== null) {
|
|
125
|
+
this.el.style.setProperty('--hn-nz-stop', value.toFixed(3))
|
|
126
|
+
} else {
|
|
127
|
+
this.el.style.removeProperty('--hn-nz-stop')
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private parseFade(value: number | boolean | undefined) {
|
|
132
|
+
if (this.maxFPS <= 0) return 0
|
|
133
|
+
return value === true || value === undefined ? DEFAULT_FADE_S : Number(value)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
hide(animate?: number | boolean) {
|
|
137
|
+
if (this.destroyed) return
|
|
138
|
+
this.hidden = true
|
|
139
|
+
this.setFade(this.parseFade(animate))
|
|
140
|
+
this.setTstop(null)
|
|
141
|
+
this.setT(0)
|
|
142
|
+
this.startAnimation()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
reveal(animate?: number | boolean) {
|
|
146
|
+
if (this.destroyed) return
|
|
147
|
+
this.hidden = false
|
|
148
|
+
const duration = this.parseFade(animate)
|
|
149
|
+
this.setFade(duration)
|
|
150
|
+
this.setTstop(this.t)
|
|
151
|
+
if (duration <= 0) this.stopAnimation()
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private frame = (now: DOMHighResTimeStamp) => {
|
|
155
|
+
if (this.destroyed) return
|
|
156
|
+
const shouldStop = this.tstop !== null && this.t > this.tstop + this.fadeS
|
|
157
|
+
|
|
158
|
+
if (this.maxFPS > 0 && !shouldStop) {
|
|
159
|
+
this.raf = requestAnimationFrame(this.frame)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const dt = now - this.t0
|
|
163
|
+
if (dt > 0 && dt < 1000 / this.maxFPS) return
|
|
164
|
+
|
|
165
|
+
this.setT(this.t + dt / 1000)
|
|
166
|
+
this.t0 = now
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private startAnimation() {
|
|
170
|
+
this.t0 = performance.now()
|
|
171
|
+
this.frame(this.t0)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private stopAnimation() {
|
|
175
|
+
if (this.raf !== null) {
|
|
176
|
+
cancelAnimationFrame(this.raf)
|
|
177
|
+
this.raf = null
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
destroy() {
|
|
182
|
+
this.destroyed = true
|
|
183
|
+
this.stopAnimation()
|
|
184
|
+
this.el.style.removeProperty('background')
|
|
185
|
+
for (const prop of [
|
|
186
|
+
'--hn-nz-t',
|
|
187
|
+
'--hn-nz-stop',
|
|
188
|
+
'--hn-nz-fade',
|
|
189
|
+
'--hn-nz-gap',
|
|
190
|
+
'--hn-nz-words',
|
|
191
|
+
'--hn-nz-density',
|
|
192
|
+
'--hn-nz-accent',
|
|
193
|
+
]) {
|
|
194
|
+
this.el.style.removeProperty(prop)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|