@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
|
@@ -9,6 +9,10 @@ import {
|
|
|
9
9
|
} from 'vue'
|
|
10
10
|
import { useEventListener } from '@vueuse/core'
|
|
11
11
|
import type { DataTableColumn } from '../types'
|
|
12
|
+
import {
|
|
13
|
+
resizeHandlePositions,
|
|
14
|
+
type DataTableHandlePosition,
|
|
15
|
+
} from '../../../../../shared/src/lib/data-table/resize'
|
|
12
16
|
|
|
13
17
|
export function useTableResizeHandles<T extends object>(
|
|
14
18
|
element: Ref<HTMLTableElement | undefined>,
|
|
@@ -16,7 +20,7 @@ export function useTableResizeHandles<T extends object>(
|
|
|
16
20
|
columns: Ref<DataTableColumn<T>[]>,
|
|
17
21
|
enabled: () => boolean,
|
|
18
22
|
) {
|
|
19
|
-
const positions = shallowRef<Record<string,
|
|
23
|
+
const positions = shallowRef<Record<string, DataTableHandlePosition>>({})
|
|
20
24
|
let frame = 0
|
|
21
25
|
let observer: ResizeObserver | undefined
|
|
22
26
|
function update() {
|
|
@@ -35,26 +39,7 @@ export function useTableResizeHandles<T extends object>(
|
|
|
35
39
|
cell.getBoundingClientRect(),
|
|
36
40
|
]),
|
|
37
41
|
)
|
|
38
|
-
|
|
39
|
-
let right = box.right
|
|
40
|
-
for (const column of columns.value) {
|
|
41
|
-
const rect = cells.get(column.key)
|
|
42
|
-
if (!rect || !column.pin) continue
|
|
43
|
-
if ((column.pin === 'start') !== rtl) left = Math.max(left, rect.right)
|
|
44
|
-
else right = Math.min(right, rect.left)
|
|
45
|
-
}
|
|
46
|
-
const next: typeof positions.value = {}
|
|
47
|
-
for (const column of columns.value) {
|
|
48
|
-
const rect = cells.get(column.key)
|
|
49
|
-
if (!rect) continue
|
|
50
|
-
const start = Math.max(rect.left, column.pin ? box.left : left)
|
|
51
|
-
const end = Math.min(rect.right, column.pin ? box.right : right)
|
|
52
|
-
const fromLeft = (column.pin === 'end') !== rtl
|
|
53
|
-
next[column.key] = {
|
|
54
|
-
inset: Math.max(0, (fromLeft ? start - rect.left : rect.right - end) / scale),
|
|
55
|
-
visible: end - start >= 9 * scale - 0.01,
|
|
56
|
-
}
|
|
57
|
-
}
|
|
42
|
+
const next = resizeHandlePositions(columns.value, cells, box, scale, rtl)
|
|
58
43
|
if (JSON.stringify(next) !== JSON.stringify(positions.value)) positions.value = next
|
|
59
44
|
}
|
|
60
45
|
function schedule() {
|
|
@@ -1,85 +1,22 @@
|
|
|
1
1
|
import type { VirtualizeOptions } from '../../lib/virtual/types'
|
|
2
2
|
import type { CSSProperties } from 'vue'
|
|
3
3
|
import type { TableVariants } from '../table/table.variants'
|
|
4
|
+
import type {
|
|
5
|
+
DataTableCellContext,
|
|
6
|
+
DataTableColumn,
|
|
7
|
+
DataTableEdit,
|
|
8
|
+
DataTableEditorContext,
|
|
9
|
+
DataTableGroupContext,
|
|
10
|
+
DataTableHeaderCell,
|
|
11
|
+
DataTableHeaderContext,
|
|
12
|
+
DataTableKey,
|
|
13
|
+
DataTableKeyField,
|
|
14
|
+
DataTableRowContext,
|
|
15
|
+
DataTableState,
|
|
16
|
+
} from '../../../../shared/src/types/data-table'
|
|
4
17
|
|
|
5
|
-
export
|
|
6
|
-
export type DataTableKeyField<T> = {
|
|
7
|
-
[K in keyof T]-?: T[K] extends DataTableKey ? K : never
|
|
8
|
-
}[keyof T] &
|
|
9
|
-
string
|
|
10
|
-
export type DataTableAggregate = 'sum' | 'min' | 'max' | 'mean' | 'count' | 'uniqueCount'
|
|
11
|
-
export type DataTableScope = 'page' | 'filtered' | 'selected' | 'all'
|
|
12
|
-
export type DataTableFilterMode = 'contains' | 'equals' | 'in' | 'range'
|
|
18
|
+
export * from '../../../../shared/src/types/data-table'
|
|
13
19
|
|
|
14
|
-
export interface DataTableColumn<T> {
|
|
15
|
-
key: string
|
|
16
|
-
label: string
|
|
17
|
-
children?: DataTableColumn<T>[]
|
|
18
|
-
field?: keyof T
|
|
19
|
-
accessor?: (row: T) => unknown
|
|
20
|
-
sortable?: boolean
|
|
21
|
-
sort?: (a: T, b: T) => number
|
|
22
|
-
filterable?: boolean
|
|
23
|
-
filter?: (row: T, query: string) => boolean
|
|
24
|
-
filterValue?: (row: T, value: unknown) => boolean
|
|
25
|
-
filterMode?: DataTableFilterMode
|
|
26
|
-
format?: (value: unknown, row: T) => string | number
|
|
27
|
-
align?: 'start' | 'center' | 'end'
|
|
28
|
-
width?: number | string
|
|
29
|
-
minWidth?: number | string
|
|
30
|
-
maxWidth?: number | string
|
|
31
|
-
pin?: 'start' | 'end'
|
|
32
|
-
truncate?: boolean
|
|
33
|
-
resizable?: boolean
|
|
34
|
-
reorderable?: boolean
|
|
35
|
-
aggregate?: DataTableAggregate | ((rows: T[]) => unknown)
|
|
36
|
-
footer?: boolean | string | ((rows: T[]) => string | number)
|
|
37
|
-
editable?: boolean | ((row: T) => boolean)
|
|
38
|
-
parse?: (value: unknown, row: T) => unknown
|
|
39
|
-
validate?: (value: unknown, row: T) => string | undefined | Promise<string | undefined>
|
|
40
|
-
exportable?: boolean
|
|
41
|
-
exportValue?: (row: T) => unknown
|
|
42
|
-
headerClass?: string
|
|
43
|
-
cellClass?: string | ((row: T) => string | undefined)
|
|
44
|
-
}
|
|
45
|
-
export interface DataTableSort {
|
|
46
|
-
key: string
|
|
47
|
-
desc: boolean
|
|
48
|
-
}
|
|
49
|
-
export interface DataTableFilter {
|
|
50
|
-
key: string
|
|
51
|
-
value: unknown
|
|
52
|
-
}
|
|
53
|
-
export interface DataTableQuery {
|
|
54
|
-
page: number
|
|
55
|
-
pageSize: number
|
|
56
|
-
sorting: DataTableSort[]
|
|
57
|
-
filter: string
|
|
58
|
-
columnFilters: DataTableFilter[]
|
|
59
|
-
grouping: string[]
|
|
60
|
-
}
|
|
61
|
-
export interface DataTableEdit<T> {
|
|
62
|
-
key: DataTableKey
|
|
63
|
-
row: T
|
|
64
|
-
values: Record<string, unknown>
|
|
65
|
-
column?: string
|
|
66
|
-
}
|
|
67
|
-
export interface DataTableReorder<T> {
|
|
68
|
-
row: T
|
|
69
|
-
target: T
|
|
70
|
-
parent?: T
|
|
71
|
-
from: number
|
|
72
|
-
to: number
|
|
73
|
-
rows: T[]
|
|
74
|
-
}
|
|
75
|
-
export interface DataTableExportOptions {
|
|
76
|
-
scope?: DataTableScope
|
|
77
|
-
columns?: string[]
|
|
78
|
-
formatted?: boolean
|
|
79
|
-
delimiter?: ',' | ';' | '\t'
|
|
80
|
-
bom?: boolean
|
|
81
|
-
filename?: string
|
|
82
|
-
}
|
|
83
20
|
export interface DataTableProps<T> {
|
|
84
21
|
rows: T[]
|
|
85
22
|
columns: DataTableColumn<T>[]
|
|
@@ -122,74 +59,6 @@ export interface DataTableProps<T> {
|
|
|
122
59
|
class?: string
|
|
123
60
|
tableClass?: string
|
|
124
61
|
}
|
|
125
|
-
export interface DataTableRowContext<T> {
|
|
126
|
-
row: T
|
|
127
|
-
key: DataTableKey
|
|
128
|
-
index: number
|
|
129
|
-
depth: number
|
|
130
|
-
selected: boolean
|
|
131
|
-
indeterminate: boolean
|
|
132
|
-
selectable: boolean
|
|
133
|
-
expanded: boolean
|
|
134
|
-
expandable: boolean
|
|
135
|
-
toggleSelected: (selected?: boolean) => void
|
|
136
|
-
toggleExpanded: (expanded?: boolean) => void
|
|
137
|
-
startEdit: (column?: string) => void
|
|
138
|
-
}
|
|
139
|
-
export interface DataTableCellContext<T> extends DataTableRowContext<T> {
|
|
140
|
-
column: DataTableColumn<T>
|
|
141
|
-
value: unknown
|
|
142
|
-
}
|
|
143
|
-
export interface DataTableHeaderContext<T> {
|
|
144
|
-
column: DataTableColumn<T>
|
|
145
|
-
sorting: 'asc' | 'desc' | false
|
|
146
|
-
sortIndex: number
|
|
147
|
-
filterValue: unknown
|
|
148
|
-
toggleSort: (multi?: boolean) => void
|
|
149
|
-
setFilter: (value: unknown) => void
|
|
150
|
-
}
|
|
151
|
-
export interface DataTableGroupContext<T> {
|
|
152
|
-
key: string
|
|
153
|
-
column: DataTableColumn<T>
|
|
154
|
-
value: unknown
|
|
155
|
-
rows: T[]
|
|
156
|
-
depth: number
|
|
157
|
-
expanded: boolean
|
|
158
|
-
toggleExpanded: (expanded?: boolean) => void
|
|
159
|
-
aggregate: (column: string) => unknown
|
|
160
|
-
}
|
|
161
|
-
export interface DataTableEditorContext<T> extends DataTableCellContext<T> {
|
|
162
|
-
value: unknown
|
|
163
|
-
pending: boolean
|
|
164
|
-
error?: string
|
|
165
|
-
updateValue: (value: unknown) => void
|
|
166
|
-
commit: () => Promise<void>
|
|
167
|
-
cancel: () => void
|
|
168
|
-
}
|
|
169
|
-
export interface DataTableApi<T> {
|
|
170
|
-
getRows: (scope?: DataTableScope) => T[]
|
|
171
|
-
toggleSelected: (key: DataTableKey, selected?: boolean) => void
|
|
172
|
-
toggleExpanded: (key: DataTableKey, expanded?: boolean) => void
|
|
173
|
-
setFilter: (column: string, value: unknown) => void
|
|
174
|
-
setColumnHidden: (column: string, hidden: boolean) => void
|
|
175
|
-
setColumnWidth: (column: string, width: number) => void
|
|
176
|
-
moveColumn: (column: string, target: string) => void
|
|
177
|
-
moveRow: (key: DataTableKey, target: DataTableKey) => void
|
|
178
|
-
startEdit: (key: DataTableKey, column?: string) => void
|
|
179
|
-
cancelEdit: () => void
|
|
180
|
-
commitEdit: () => Promise<void>
|
|
181
|
-
scrollToRow: (key: DataTableKey) => void
|
|
182
|
-
toCsv: (options?: DataTableExportOptions) => string
|
|
183
|
-
exportCsv: (options?: DataTableExportOptions) => void
|
|
184
|
-
}
|
|
185
|
-
export interface DataTableState<T> extends DataTableQuery {
|
|
186
|
-
total: number
|
|
187
|
-
rows: T[]
|
|
188
|
-
selected: DataTableKey[]
|
|
189
|
-
expanded: DataTableKey[]
|
|
190
|
-
visibleColumns: DataTableColumn<T>[]
|
|
191
|
-
api: DataTableApi<T>
|
|
192
|
-
}
|
|
193
62
|
export type DataTableSlots<T> = {
|
|
194
63
|
toolbar?(state: DataTableState<T>): unknown
|
|
195
64
|
footer?(state: DataTableState<T>): unknown
|
|
@@ -207,13 +76,4 @@ export type DataTableSlots<T> = {
|
|
|
207
76
|
[K in `footer-${string}`]?: (context: { column: DataTableColumn<T>; rows: T[] }) => unknown
|
|
208
77
|
}
|
|
209
78
|
|
|
210
|
-
export interface DataTableHeader<T> extends
|
|
211
|
-
id: string
|
|
212
|
-
colspan: number
|
|
213
|
-
rowspan: number
|
|
214
|
-
leaf: boolean
|
|
215
|
-
top: number
|
|
216
|
-
style: CSSProperties
|
|
217
|
-
ariaSort?: 'ascending' | 'descending'
|
|
218
|
-
nextLabel: string
|
|
219
|
-
}
|
|
79
|
+
export interface DataTableHeader<T> extends DataTableHeaderCell<T, CSSProperties> {}
|
|
@@ -1,75 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function rowId(key: DataTableKey) {
|
|
4
|
-
return `${typeof key}:${key}`
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function rowKey(id: string): DataTableKey {
|
|
8
|
-
return id.startsWith('number:') ? Number(id.slice(7)) : id.slice(7)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function positiveInteger(value: number, fallback: number) {
|
|
12
|
-
return Number.isFinite(value) ? Math.max(1, Math.floor(value)) : fallback
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function cssSize(value: number | string | undefined) {
|
|
16
|
-
return typeof value === 'number' ? `${value}px` : value
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function isRowAction(event: MouseEvent | KeyboardEvent) {
|
|
20
|
-
const target = event.target as HTMLElement | null
|
|
21
|
-
if (!target || event.defaultPrevented) return false
|
|
22
|
-
if (event.type === 'keydown') return target === event.currentTarget
|
|
23
|
-
const control = target.closest(
|
|
24
|
-
'a, button, input, select, textarea, label, [role="button"], [role="checkbox"], [role="switch"], [contenteditable]:not([contenteditable="false"]), [tabindex]',
|
|
25
|
-
)
|
|
26
|
-
return !control || control === event.currentTarget
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function flattenColumns<T>(columns: DataTableColumn<T>[]): DataTableColumn<T>[] {
|
|
30
|
-
return columns.flatMap(column =>
|
|
31
|
-
column.children?.length ? flattenColumns(column.children) : [column],
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
export function filterValue(
|
|
35
|
-
value: unknown,
|
|
36
|
-
filter: unknown,
|
|
37
|
-
mode: DataTableFilterMode = 'contains',
|
|
38
|
-
locale = 'en',
|
|
39
|
-
) {
|
|
40
|
-
if (mode === 'equals') return Object.is(value, filter)
|
|
41
|
-
if (mode === 'in') return Array.isArray(filter) && filter.some(item => Object.is(item, value))
|
|
42
|
-
if (mode === 'range') {
|
|
43
|
-
if (!Array.isArray(filter)) return true
|
|
44
|
-
const numeric = value instanceof Date ? value.getTime() : Number(value)
|
|
45
|
-
const bound = (value: unknown) => (value instanceof Date ? value.getTime() : Number(value))
|
|
46
|
-
return (
|
|
47
|
-
value != null &&
|
|
48
|
-
Number.isFinite(numeric) &&
|
|
49
|
-
(filter[0] == null || numeric >= bound(filter[0])) &&
|
|
50
|
-
(filter[1] == null || numeric <= bound(filter[1]))
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
return String(value ?? '')
|
|
54
|
-
.toLocaleLowerCase(locale)
|
|
55
|
-
.includes(String(filter ?? '').toLocaleLowerCase(locale))
|
|
56
|
-
}
|
|
57
|
-
export function aggregate<T>(
|
|
58
|
-
rows: T[],
|
|
59
|
-
column: DataTableColumn<T>,
|
|
60
|
-
valueOf: (row: T, column: DataTableColumn<T>) => unknown,
|
|
61
|
-
) {
|
|
62
|
-
if (typeof column.aggregate === 'function') return column.aggregate(rows)
|
|
63
|
-
if (!column.aggregate) return undefined
|
|
64
|
-
if (column.aggregate === 'count') return rows.length
|
|
65
|
-
const values = rows.map(row => valueOf(row, column))
|
|
66
|
-
if (column.aggregate === 'uniqueCount') return new Set(values).size
|
|
67
|
-
const numbers = values.filter(
|
|
68
|
-
(value): value is number => typeof value === 'number' && Number.isFinite(value),
|
|
69
|
-
)
|
|
70
|
-
if (!numbers.length) return column.aggregate === 'sum' ? 0 : undefined
|
|
71
|
-
if (column.aggregate === 'min') return numbers.reduce((a, b) => Math.min(a, b))
|
|
72
|
-
if (column.aggregate === 'max') return numbers.reduce((a, b) => Math.max(a, b))
|
|
73
|
-
const sum = numbers.reduce((a, b) => a + b, 0)
|
|
74
|
-
return column.aggregate === 'mean' ? sum / numbers.length : sum
|
|
75
|
-
}
|
|
1
|
+
export * from '../../../../shared/src/lib/data-table/utils'
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface Bounds {
|
|
4
|
-
min?: DateValue
|
|
5
|
-
max?: DateValue
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface Parts {
|
|
9
|
-
start?: DateValue
|
|
10
|
-
end?: DateValue
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function outside(value: DateValue | undefined, { min, max }: Bounds) {
|
|
14
|
-
if (!value) return false
|
|
15
|
-
return (!!min && value.compare(min) < 0) || (!!max && value.compare(max) > 0)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function isRangeInvalid({ start, end }: Parts, bounds: Bounds) {
|
|
19
|
-
if (outside(start, bounds) || outside(end, bounds)) return true
|
|
20
|
-
return !!start && !!end && start.compare(end) > 0
|
|
21
|
-
}
|
|
1
|
+
export * from '../../../../../shared/src/lib/date-range-field/validity'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '../../../../shared/src/variants/editable'
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export interface FileUploadRejection {
|
|
4
|
-
file: File
|
|
5
|
-
reason: FileUploadReason
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface Rules {
|
|
9
|
-
accept?: string
|
|
10
|
-
maxSize?: number
|
|
11
|
-
maxFiles?: number
|
|
12
|
-
multiple?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function matchesAccept(file: File, accept: string | undefined) {
|
|
16
|
-
if (!accept) return true
|
|
17
|
-
const name = file.name.toLowerCase()
|
|
18
|
-
const type = file.type.toLowerCase()
|
|
19
|
-
return accept
|
|
20
|
-
.split(',')
|
|
21
|
-
.map(rule => rule.trim().toLowerCase())
|
|
22
|
-
.filter(Boolean)
|
|
23
|
-
.some(rule => {
|
|
24
|
-
if (rule.startsWith('.')) return name.endsWith(rule)
|
|
25
|
-
if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1))
|
|
26
|
-
return type === rule
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function sameFile(a: File, b: File) {
|
|
31
|
-
return a.name === b.name && a.size === b.size && a.lastModified === b.lastModified
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function selectFiles(current: File[], incoming: File[], rules: Rules) {
|
|
35
|
-
const rejected: FileUploadRejection[] = []
|
|
36
|
-
const next = rules.multiple ? [...current] : current.slice(0, 1)
|
|
37
|
-
for (const file of incoming) {
|
|
38
|
-
if (!matchesAccept(file, rules.accept)) {
|
|
39
|
-
rejected.push({ file, reason: 'type' })
|
|
40
|
-
continue
|
|
41
|
-
}
|
|
42
|
-
if (rules.maxSize !== undefined && file.size > rules.maxSize) {
|
|
43
|
-
rejected.push({ file, reason: 'size' })
|
|
44
|
-
continue
|
|
45
|
-
}
|
|
46
|
-
if (next.some(existing => sameFile(existing, file))) continue
|
|
47
|
-
if (!rules.multiple) {
|
|
48
|
-
next.splice(0, next.length, file)
|
|
49
|
-
continue
|
|
50
|
-
}
|
|
51
|
-
if (rules.maxFiles !== undefined && next.length >= rules.maxFiles) {
|
|
52
|
-
rejected.push({ file, reason: 'count' })
|
|
53
|
-
continue
|
|
54
|
-
}
|
|
55
|
-
next.push(file)
|
|
56
|
-
}
|
|
57
|
-
return { next, rejected }
|
|
58
|
-
}
|
|
1
|
+
export * from '../../../../../shared/src/lib/file-upload/select'
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function formatSize(tag: string, bytes: number) {
|
|
4
|
-
let value = bytes
|
|
5
|
-
let index = 0
|
|
6
|
-
while (value >= 1024 && index < UNITS.length - 1) {
|
|
7
|
-
value /= 1024
|
|
8
|
-
index += 1
|
|
9
|
-
}
|
|
10
|
-
return new Intl.NumberFormat(tag, {
|
|
11
|
-
style: 'unit',
|
|
12
|
-
unit: UNITS[index],
|
|
13
|
-
unitDisplay: 'narrow',
|
|
14
|
-
maximumFractionDigits: index === 0 ? 0 : 1,
|
|
15
|
-
}).format(value)
|
|
16
|
-
}
|
|
1
|
+
export * from '../../../../../shared/src/lib/file-upload/size'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '../../../../shared/src/variants/float-button'
|
|
@@ -1,144 +1,33 @@
|
|
|
1
|
-
import { computed,
|
|
2
|
-
import
|
|
3
|
-
import { ROOT, readPath, runRules } from '../utils/errors'
|
|
4
|
-
import { same, snapshot } from '../utils/values'
|
|
1
|
+
import { computed, shallowRef } from 'vue'
|
|
2
|
+
import { createForm, type FormOptions } from '../../../../../shared/src/behavior/form'
|
|
5
3
|
|
|
6
|
-
export type FormValidateOn
|
|
4
|
+
export type { FormValidateOn } from '../../../../../shared/src/behavior/form'
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
interface ServerError {
|
|
15
|
-
message: string
|
|
16
|
-
value: unknown
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function useForm(options: Options) {
|
|
20
|
-
const found = shallowRef<FormErrors>({})
|
|
21
|
-
const touched = ref(new Set<string>())
|
|
22
|
-
const submitted = ref(false)
|
|
23
|
-
const submitting = ref(false)
|
|
24
|
-
const server = shallowRef(new Map<string, ServerError>())
|
|
25
|
-
let pending: { values: FormValues; rules: FormRules | undefined } | undefined
|
|
26
|
-
let validation = 0
|
|
27
|
-
let submission = 0
|
|
28
|
-
let initial = snapshot(options.values()) as FormValues
|
|
29
|
-
|
|
30
|
-
function shown(key: string) {
|
|
31
|
-
if (submitted.value || touched.value.has(key)) return true
|
|
32
|
-
const mode = options.validateOn()
|
|
33
|
-
return mode === 'change' && !same(readPath(options.values(), key), readPath(initial, key))
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const errors = computed<FormErrors>(() => {
|
|
37
|
-
const result: FormErrors = {}
|
|
38
|
-
for (const [key, message] of Object.entries(found.value)) {
|
|
39
|
-
if (key !== ROOT && shown(key)) result[key] = message
|
|
40
|
-
}
|
|
41
|
-
for (const [key, entry] of server.value) result[key] = entry.message
|
|
42
|
-
return result
|
|
6
|
+
export function useForm(options: FormOptions) {
|
|
7
|
+
const form = createForm(options)
|
|
8
|
+
const version = shallowRef(form.version())
|
|
9
|
+
form.subscribe(() => {
|
|
10
|
+
version.value = form.version()
|
|
43
11
|
})
|
|
44
|
-
const formError = computed(() => found.value[ROOT])
|
|
45
|
-
const invalid = computed(() => Object.keys(errors.value).length > 0 || !!formError.value)
|
|
46
|
-
|
|
47
|
-
async function validate() {
|
|
48
|
-
const version = ++validation
|
|
49
|
-
const values = snapshot(options.values()) as FormValues
|
|
50
|
-
const rules = options.rules()
|
|
51
|
-
const request = { values, rules }
|
|
52
|
-
pending = request
|
|
53
|
-
try {
|
|
54
|
-
const result = await runRules(rules, values)
|
|
55
|
-
if (version !== validation || rules !== options.rules() || !same(values, options.values())) {
|
|
56
|
-
return false
|
|
57
|
-
}
|
|
58
|
-
found.value = result
|
|
59
|
-
return Object.keys(result).length === 0
|
|
60
|
-
} finally {
|
|
61
|
-
if (pending === request) pending = undefined
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function revalidate() {
|
|
66
|
-
if (pending && pending.rules === options.rules() && same(pending.values, options.values()))
|
|
67
|
-
return
|
|
68
|
-
void validate()
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function touch(name: string) {
|
|
72
|
-
if (touched.value.has(name)) return
|
|
73
|
-
touched.value = new Set(touched.value).add(name)
|
|
74
|
-
if (options.validateOn() !== 'submit') revalidate()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function onChange() {
|
|
78
|
-
const values = options.values()
|
|
79
|
-
if (server.value.size) {
|
|
80
|
-
const next = new Map(server.value)
|
|
81
|
-
for (const [key, entry] of next) if (readPath(values, key) !== entry.value) next.delete(key)
|
|
82
|
-
if (next.size !== server.value.size) server.value = next
|
|
83
|
-
}
|
|
84
|
-
if (submitted.value || options.validateOn() !== 'submit') revalidate()
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function submit(handler?: (values: FormValues) => unknown) {
|
|
88
|
-
if (submitting.value) return false
|
|
89
|
-
const version = ++submission
|
|
90
|
-
const values = snapshot(options.values()) as FormValues
|
|
91
|
-
submitted.value = true
|
|
92
|
-
submitting.value = true
|
|
93
|
-
try {
|
|
94
|
-
const valid = await validate()
|
|
95
|
-
if (
|
|
96
|
-
!valid ||
|
|
97
|
-
version !== submission ||
|
|
98
|
-
server.value.size ||
|
|
99
|
-
!same(values, options.values())
|
|
100
|
-
) {
|
|
101
|
-
return false
|
|
102
|
-
}
|
|
103
|
-
await handler?.(options.values())
|
|
104
|
-
return true
|
|
105
|
-
} finally {
|
|
106
|
-
if (version === submission) submitting.value = false
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function setErrors(next: FormErrors) {
|
|
111
|
-
const values = options.values()
|
|
112
|
-
const map = new Map<string, ServerError>()
|
|
113
|
-
for (const [key, message] of Object.entries(next)) {
|
|
114
|
-
map.set(key, { message, value: readPath(values, key) })
|
|
115
|
-
}
|
|
116
|
-
server.value = map
|
|
117
|
-
}
|
|
118
12
|
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
found.value = {}
|
|
125
|
-
touched.value = new Set()
|
|
126
|
-
submitted.value = false
|
|
127
|
-
server.value = new Map()
|
|
128
|
-
initial = snapshot(options.values()) as FormValues
|
|
13
|
+
function track<T>(read: () => T) {
|
|
14
|
+
return computed(() => {
|
|
15
|
+
void version.value
|
|
16
|
+
return read()
|
|
17
|
+
})
|
|
129
18
|
}
|
|
130
19
|
|
|
131
20
|
return {
|
|
132
|
-
errors,
|
|
133
|
-
formError,
|
|
134
|
-
invalid,
|
|
135
|
-
submitted,
|
|
136
|
-
submitting,
|
|
137
|
-
validate,
|
|
138
|
-
touch,
|
|
139
|
-
onChange,
|
|
140
|
-
submit,
|
|
141
|
-
setErrors,
|
|
142
|
-
reset,
|
|
21
|
+
errors: track(form.errors),
|
|
22
|
+
formError: track(form.formError),
|
|
23
|
+
invalid: track(form.invalid),
|
|
24
|
+
submitted: track(form.submitted),
|
|
25
|
+
submitting: track(form.submitting),
|
|
26
|
+
validate: form.validate,
|
|
27
|
+
touch: form.touch,
|
|
28
|
+
onChange: form.onChange,
|
|
29
|
+
submit: form.submit,
|
|
30
|
+
setErrors: form.setErrors,
|
|
31
|
+
reset: form.reset,
|
|
143
32
|
}
|
|
144
33
|
}
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
message: string
|
|
3
|
-
path?: ReadonlyArray<PropertyKey | { key: PropertyKey }>
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface StandardSchemaResult {
|
|
7
|
-
value?: unknown
|
|
8
|
-
issues?: ReadonlyArray<StandardSchemaIssue>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface StandardSchema {
|
|
12
|
-
'~standard': {
|
|
13
|
-
version: 1
|
|
14
|
-
vendor: string
|
|
15
|
-
validate: (value: unknown) => StandardSchemaResult | Promise<StandardSchemaResult>
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type FormValues = Record<string, unknown>
|
|
20
|
-
export type FormErrors = Record<string, string>
|
|
21
|
-
export type FormValidator = (values: FormValues) => FormErrors | Promise<FormErrors>
|
|
22
|
-
export type FormRules = StandardSchema | FormValidator
|
|
23
|
-
|
|
24
|
-
export function isStandardSchema(rules: FormRules): rules is StandardSchema {
|
|
25
|
-
return typeof rules === 'object' && rules !== null && '~standard' in rules
|
|
26
|
-
}
|
|
1
|
+
export * from '../../../../shared/src/lib/form/standard-schema'
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
isStandardSchema,
|
|
3
|
-
type FormErrors,
|
|
4
|
-
type FormRules,
|
|
5
|
-
type FormValues,
|
|
6
|
-
type StandardSchemaIssue,
|
|
7
|
-
} from '../standard-schema'
|
|
8
|
-
|
|
9
|
-
export const ROOT = ''
|
|
10
|
-
|
|
11
|
-
export function issueKey(issue: StandardSchemaIssue) {
|
|
12
|
-
return (issue.path ?? [])
|
|
13
|
-
.map(part => String(typeof part === 'object' && part !== null ? part.key : part))
|
|
14
|
-
.join('.')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function issuesToErrors(issues: ReadonlyArray<StandardSchemaIssue>): FormErrors {
|
|
18
|
-
const errors: FormErrors = {}
|
|
19
|
-
for (const issue of issues) {
|
|
20
|
-
const key = issueKey(issue)
|
|
21
|
-
if (!(key in errors)) errors[key] = issue.message
|
|
22
|
-
}
|
|
23
|
-
return errors
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function readPath(values: FormValues, key: string): unknown {
|
|
27
|
-
return key
|
|
28
|
-
.split('.')
|
|
29
|
-
.reduce<unknown>(
|
|
30
|
-
(current, part) =>
|
|
31
|
-
current && typeof current === 'object'
|
|
32
|
-
? (current as Record<string, unknown>)[part]
|
|
33
|
-
: undefined,
|
|
34
|
-
values,
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function runRules(
|
|
39
|
-
rules: FormRules | undefined,
|
|
40
|
-
values: FormValues,
|
|
41
|
-
): Promise<FormErrors> {
|
|
42
|
-
if (!rules) return {}
|
|
43
|
-
if (isStandardSchema(rules)) {
|
|
44
|
-
const result = await rules['~standard'].validate(values)
|
|
45
|
-
return result.issues ? issuesToErrors(result.issues) : {}
|
|
46
|
-
}
|
|
47
|
-
return await rules(values)
|
|
48
|
-
}
|
|
1
|
+
export * from '../../../../../shared/src/lib/form/errors'
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function focusFirstInvalid(root: HTMLElement) {
|
|
4
|
-
const invalid = root.querySelector<HTMLElement>('[aria-invalid="true"]')
|
|
5
|
-
if (!invalid) return
|
|
6
|
-
const target = invalid.matches(FOCUSABLE)
|
|
7
|
-
? invalid
|
|
8
|
-
: invalid.querySelector<HTMLElement>(FOCUSABLE)
|
|
9
|
-
target?.focus()
|
|
10
|
-
}
|
|
1
|
+
export * from '../../../../../shared/src/lib/form/focus'
|