@fibrae/semi-foundation 0.5.0 → 0.7.0
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 +20 -18
- package/README.zh-CN.md +20 -18
- package/dist/base/auto-close-foundation.d.ts +3 -10
- package/dist/base/auto-close-foundation.js +21 -42
- package/dist/base/constants.d.ts +1 -0
- package/dist/base/focus-handle.js +2 -2
- package/dist/base/focus-scope.js +1 -20
- package/dist/base/foundation.d.ts +0 -1
- package/dist/base/hook-api.d.ts +21 -0
- package/dist/base/hook-api.js +20 -0
- package/dist/base/index.d.ts +15 -0
- package/dist/base/index.js +15 -0
- package/dist/base/list-store.d.ts +53 -13
- package/dist/base/list-store.js +126 -48
- package/dist/base/modal-resources.js +1 -1
- package/dist/base/overlay-session.d.ts +16 -0
- package/dist/base/overlay-session.js +36 -0
- package/dist/base/static-list-wrapper.d.ts +6 -1
- package/dist/base/static-list-wrapper.js +12 -3
- package/dist/components/anchor/anchor.css +0 -4
- package/dist/components/anchor/anchor.scss +0 -3
- package/dist/components/anchor/foundation.d.ts +10 -2
- package/dist/components/anchor/foundation.js +45 -6
- package/dist/components/audio-player/audio-player.css +1 -1
- package/dist/components/audio-player/audio-player.scss +3 -1
- package/dist/components/audio-player/foundation.d.ts +7 -5
- package/dist/components/audio-player/foundation.js +5 -1
- package/dist/components/auto-complete/auto-complete.css +0 -4
- package/dist/components/auto-complete/auto-complete.scss +0 -2
- package/dist/components/auto-complete/constants.d.ts +3 -1
- package/dist/components/auto-complete/foundation.d.ts +5 -7
- package/dist/components/auto-complete/foundation.js +32 -28
- package/dist/components/avatar/avatar.css +1 -4
- package/dist/components/avatar/avatar.scss +1 -3
- package/dist/components/avatar/foundation.d.ts +3 -0
- package/dist/components/avatar/foundation.js +6 -2
- package/dist/components/backtop/backtop.css +0 -4
- package/dist/components/backtop/backtop.scss +0 -3
- package/dist/components/backtop/constants.d.ts +4 -0
- package/dist/components/backtop/constants.js +5 -1
- package/dist/components/backtop/foundation.d.ts +1 -0
- package/dist/components/backtop/foundation.js +7 -3
- package/dist/components/badge/badge.css +1 -4
- package/dist/components/badge/badge.scss +1 -3
- package/dist/components/badge/constants.d.ts +3 -1
- package/dist/components/banner/banner.css +0 -4
- package/dist/components/banner/banner.scss +0 -3
- package/dist/components/banner/foundation.d.ts +1 -0
- package/dist/components/breadcrumb/breadcrumb.css +9 -8
- package/dist/components/breadcrumb/breadcrumb.scss +10 -6
- package/dist/components/breadcrumb/foundation.d.ts +1 -0
- package/dist/components/breadcrumb/item-foundation.d.ts +3 -1
- package/dist/components/breadcrumb/item-foundation.js +1 -1
- package/dist/components/button/button.css +0 -9
- package/dist/components/button/constants.d.ts +3 -1
- package/dist/components/button/icon-button.css +0 -10
- package/dist/components/button/icon-button.scss +0 -1
- package/dist/components/button/rtl.scss +0 -7
- package/dist/components/calendar/calendar.css +0 -6
- package/dist/components/calendar/calendar.scss +0 -3
- package/dist/components/calendar/event-util.d.ts +3 -3
- package/dist/components/calendar/foundation.d.ts +15 -7
- package/dist/components/calendar/foundation.js +28 -17
- package/dist/components/calendar/month-foundation.d.ts +7 -2
- package/dist/components/calendar/month-foundation.js +11 -3
- package/dist/components/card/card.css +0 -14
- package/dist/components/card/card.scss +0 -3
- package/dist/components/card/constants.d.ts +3 -1
- package/dist/components/carousel/carousel.css +0 -4
- package/dist/components/carousel/foundation.d.ts +4 -1
- package/dist/components/carousel/foundation.js +20 -8
- package/dist/components/carousel/rtl.scss +0 -4
- package/dist/components/cascader/cascader.css +1 -6
- package/dist/components/cascader/cascader.scss +1 -1
- package/dist/components/cascader/constants.d.ts +2 -0
- package/dist/components/cascader/foundation.d.ts +8 -7
- package/dist/components/cascader/foundation.js +16 -7
- package/dist/components/cascader/rtl.scss +0 -5
- package/dist/components/cascader/util.d.ts +2 -2
- package/dist/components/cascader/util.js +2 -2
- package/dist/components/checkbox/checkbox-foundation.d.ts +4 -4
- package/dist/components/checkbox/checkbox-foundation.js +3 -1
- package/dist/components/checkbox/checkbox-group-foundation.d.ts +5 -0
- package/dist/components/checkbox/checkbox-group-foundation.js +4 -0
- package/dist/components/checkbox/checkbox.css +0 -5
- package/dist/components/checkbox/checkbox.scss +0 -3
- package/dist/components/code-highlight/code-highlight.css +1 -1
- package/dist/components/code-highlight/code-highlight.scss +1 -1
- package/dist/components/code-highlight/index.d.ts +2 -0
- package/dist/components/code-highlight/index.js +3 -0
- package/dist/components/collapse/collapse.css +1 -4
- package/dist/components/collapse/collapse.scss +1 -3
- package/dist/components/collapse/foundation.d.ts +1 -0
- package/dist/components/collapsible/foundation.d.ts +1 -0
- package/dist/components/color-picker/color-choose-area-foundation.d.ts +1 -0
- package/dist/components/color-picker/color-picker.css +1 -3
- package/dist/components/color-picker/color-picker.scss +1 -3
- package/dist/components/color-picker/color-slider-foundation.d.ts +1 -0
- package/dist/components/color-picker/data-part-foundation.d.ts +2 -1
- package/dist/components/color-picker/data-part-foundation.js +1 -1
- package/dist/components/color-picker/foundation.d.ts +9 -1
- package/dist/components/color-picker/foundation.js +20 -5
- package/dist/components/color-picker/utils/round.js +1 -1
- package/dist/components/config-provider/inherit-config.d.ts +5 -2
- package/dist/components/config-provider/inherit-config.js +1 -0
- package/dist/components/config-provider/responsive-types.d.ts +0 -3
- package/dist/components/cropper/constants.d.ts +2 -0
- package/dist/components/cropper/cropper.css +20 -22
- package/dist/components/cropper/cropper.scss +21 -23
- package/dist/components/cropper/foundation.d.ts +2 -15
- package/dist/components/cropper/foundation.js +139 -132
- package/dist/components/cropper/utils.d.ts +0 -1
- package/dist/components/cropper/utils.js +0 -1
- package/dist/components/date-picker/_utils/get-default-picker-date.d.ts +6 -4
- package/dist/components/date-picker/_utils/get-default-picker-date.js +12 -27
- package/dist/components/date-picker/_utils/index.d.ts +3 -4
- package/dist/components/date-picker/_utils/index.js +2 -3
- package/dist/components/date-picker/_utils/is-timestamp.js +1 -1
- package/dist/components/date-picker/_utils/parse-value.d.ts +13 -0
- package/dist/components/date-picker/_utils/parse-value.js +21 -0
- package/dist/components/date-picker/_utils/parser.d.ts +1 -0
- package/dist/components/date-picker/_utils/parser.js +5 -7
- package/dist/components/date-picker/_utils/picker-type.js +1 -1
- package/dist/components/date-picker/_utils/to-callback-args.d.ts +2 -5
- package/dist/components/date-picker/_utils/to-callback-args.js +4 -9
- package/dist/components/date-picker/constants.d.ts +2 -0
- package/dist/components/date-picker/constants.js +1 -1
- package/dist/components/date-picker/date-picker.css +0 -4
- package/dist/components/date-picker/foundation.d.ts +16 -26
- package/dist/components/date-picker/foundation.js +49 -42
- package/dist/components/date-picker/input-foundation.d.ts +11 -6
- package/dist/components/date-picker/input-foundation.js +13 -13
- package/dist/components/date-picker/month-foundation.d.ts +23 -8
- package/dist/components/date-picker/month-foundation.js +49 -10
- package/dist/components/date-picker/months-grid-foundation.d.ts +12 -10
- package/dist/components/date-picker/months-grid-foundation.js +60 -31
- package/dist/components/date-picker/rtl.scss +0 -4
- package/dist/components/date-picker/year-and-month-foundation.d.ts +2 -6
- package/dist/components/date-picker/year-and-month-foundation.js +5 -8
- package/dist/components/descriptions/constants.d.ts +3 -1
- package/dist/components/descriptions/descriptions.css +0 -4
- package/dist/components/descriptions/descriptions.scss +0 -3
- package/dist/components/divider/constants.d.ts +1 -1
- package/dist/components/divider/constants.js +1 -1
- package/dist/components/drag-move/foundation.d.ts +1 -0
- package/dist/components/dropdown/constants.d.ts +2 -0
- package/dist/components/dropdown/dropdown.css +0 -4
- package/dist/components/dropdown/dropdown.scss +0 -3
- package/dist/components/dropdown/foundation.d.ts +13 -0
- package/dist/components/dropdown/foundation.js +18 -7
- package/dist/components/dropdown/menu-foundation.d.ts +2 -1
- package/dist/components/dropdown/menu-foundation.js +2 -2
- package/dist/components/empty/constants.d.ts +3 -1
- package/dist/components/empty/empty.css +0 -4
- package/dist/components/empty/empty.scss +0 -3
- package/dist/components/feedback/constants.d.ts +3 -1
- package/dist/components/feedback/foundation.d.ts +9 -0
- package/dist/components/feedback/foundation.js +9 -0
- package/dist/components/float-button/float-button.css +2 -2
- package/dist/components/float-button/float-button.scss +2 -5
- package/dist/components/form/array-field-rows.d.ts +37 -8
- package/dist/components/form/array-field-rows.js +72 -18
- package/dist/components/form/errors.d.ts +3 -1
- package/dist/components/form/errors.js +5 -1
- package/dist/components/form/form.css +0 -10
- package/dist/components/form/form.scss +0 -7
- package/dist/components/form/foundation.d.ts +7 -2
- package/dist/components/form/foundation.js +14 -2
- package/dist/components/form/interface.d.ts +9 -2
- package/dist/components/form/utils.d.ts +54 -1
- package/dist/components/form/utils.js +43 -5
- package/dist/components/grid/grid.css +88 -4154
- package/dist/components/grid/grid.scss +32 -59
- package/dist/components/grid/gutter.d.ts +1 -1
- package/dist/components/grid/mixin.scss +20 -101
- package/dist/components/grid/utils.d.ts +8 -4
- package/dist/components/grid/utils.js +40 -27
- package/dist/components/grid/variables.scss +0 -1
- package/dist/components/highlight/constants.d.ts +3 -1
- package/dist/components/highlight/foundation.d.ts +7 -4
- package/dist/components/highlight/foundation.js +9 -7
- package/dist/components/hot-keys/foundation.d.ts +1 -0
- package/dist/components/image/constants.d.ts +5 -1
- package/dist/components/image/image-foundation.d.ts +1 -0
- package/dist/components/image/image.css +0 -6
- package/dist/components/image/preview-footer-foundation.d.ts +1 -0
- package/dist/components/image/preview-foundation.d.ts +1 -0
- package/dist/components/image/preview-image-foundation.d.ts +1 -0
- package/dist/components/image/preview-inner-foundation.d.ts +9 -6
- package/dist/components/image/preview-inner-foundation.js +59 -44
- package/dist/components/image/rtl.scss +0 -6
- package/dist/components/input/constants.d.ts +5 -1
- package/dist/components/input/foundation.d.ts +22 -2
- package/dist/components/input/foundation.js +26 -1
- package/dist/components/input/input.css +0 -18
- package/dist/components/input/input.scss +0 -17
- package/dist/components/input/text-entry-foundation.d.ts +8 -1
- package/dist/components/input/text-entry-foundation.js +13 -1
- package/dist/components/input/textarea-foundation.d.ts +23 -5
- package/dist/components/input/textarea-foundation.js +30 -6
- package/dist/components/input/textarea.css +0 -6
- package/dist/components/input/textarea.scss +0 -3
- package/dist/components/input/variables.scss +0 -3
- package/dist/components/input-number/constants.d.ts +3 -1
- package/dist/components/input-number/foundation.d.ts +1 -0
- package/dist/components/input-number/foundation.js +2 -2
- package/dist/components/input-number/input-number.css +0 -4
- package/dist/components/input-number/input-number.scss +0 -3
- package/dist/components/json-viewer/foundation.d.ts +10 -5
- package/dist/components/json-viewer/foundation.js +38 -23
- package/dist/components/layout/layout.css +0 -4
- package/dist/components/layout/layout.scss +0 -3
- package/dist/components/list/list.css +0 -5
- package/dist/components/list/list.scss +0 -3
- package/dist/components/lottie/foundation.d.ts +2 -2
- package/dist/components/lottie/foundation.js +23 -7
- package/dist/components/markdown-render/foundation.d.ts +2 -2
- package/dist/components/markdown-render/foundation.js +5 -2
- package/dist/components/markdown-render/markdown-render.css +2 -1
- package/dist/components/markdown-render/markdown-render.scss +2 -1
- package/dist/components/modal/confirm-instance.d.ts +28 -0
- package/dist/components/modal/confirm-instance.js +54 -0
- package/dist/components/modal/constants.d.ts +3 -1
- package/dist/components/modal/modal-content-foundation.d.ts +5 -5
- package/dist/components/modal/modal-content-foundation.js +6 -4
- package/dist/components/modal/modal-foundation.d.ts +3 -4
- package/dist/components/modal/modal-foundation.js +9 -18
- package/dist/components/modal/modal.css +0 -4
- package/dist/components/modal/modal.scss +0 -3
- package/dist/components/navigation/constants.d.ts +4 -0
- package/dist/components/navigation/foundation.d.ts +12 -4
- package/dist/components/navigation/foundation.js +19 -15
- package/dist/components/navigation/item-foundation.d.ts +14 -4
- package/dist/components/navigation/item-foundation.js +23 -10
- package/dist/components/navigation/navigation.css +0 -4
- package/dist/components/navigation/rtl.scss +0 -4
- package/dist/components/navigation/sub-nav-foundation.d.ts +1 -0
- package/dist/components/notification/constants.d.ts +1 -4
- package/dist/components/notification/constants.js +1 -6
- package/dist/components/notification/notification-api-foundation.d.ts +4 -2
- package/dist/components/notification/notification-api-foundation.js +14 -4
- package/dist/components/notification/notification-foundation.d.ts +1 -0
- package/dist/components/notification/notification-list-foundation.d.ts +14 -51
- package/dist/components/notification/notification-list-foundation.js +7 -63
- package/dist/components/notification/notification.css +0 -4
- package/dist/components/notification/notification.scss +0 -3
- package/dist/components/overflow-list/constants.d.ts +2 -0
- package/dist/components/overflow-list/foundation.d.ts +27 -15
- package/dist/components/overflow-list/foundation.js +105 -31
- package/dist/components/overflow-list/overflow-list.css +0 -4
- package/dist/components/overflow-list/overflow-list.scss +0 -3
- package/dist/components/pagination/foundation.d.ts +20 -2
- package/dist/components/pagination/foundation.js +32 -4
- package/dist/components/pagination/pagination.css +0 -4
- package/dist/components/pagination/rtl.scss +0 -4
- package/dist/components/pincode/foundation.d.ts +9 -2
- package/dist/components/pincode/foundation.js +11 -5
- package/dist/components/pincode/pincode.css +6 -8
- package/dist/components/pincode/pincode.scss +6 -9
- package/dist/components/popconfirm/constants.d.ts +3 -1
- package/dist/components/popconfirm/popconfirm-foundation.d.ts +4 -1
- package/dist/components/popconfirm/popconfirm-foundation.js +2 -1
- package/dist/components/popconfirm/popconfirm.css +0 -4
- package/dist/components/popconfirm/rtl.scss +0 -4
- package/dist/components/popover/constants.d.ts +2 -0
- package/dist/components/popover/popover.css +1 -4
- package/dist/components/popover/popover.scss +0 -2
- package/dist/components/progress/progress.css +2 -4
- package/dist/components/progress/progress.scss +2 -0
- package/dist/components/progress/rtl.scss +0 -4
- package/dist/components/radio/constants.d.ts +3 -1
- package/dist/components/radio/radio-foundation.d.ts +3 -5
- package/dist/components/radio/radio-foundation.js +3 -5
- package/dist/components/radio/radio-group-foundation.d.ts +6 -0
- package/dist/components/radio/radio-group-foundation.js +7 -0
- package/dist/components/radio/radio.css +0 -5
- package/dist/components/radio/radio.scss +0 -3
- package/dist/components/rating/foundation.d.ts +6 -0
- package/dist/components/rating/foundation.js +7 -2
- package/dist/components/rating/rating.css +0 -4
- package/dist/components/rating/rating.scss +0 -3
- package/dist/components/resizable/group/index.d.ts +1 -0
- package/dist/components/resizable/group/index.js +11 -1
- package/dist/components/resizable/resizable.css +6 -0
- package/dist/components/resizable/resizable.scss +3 -0
- package/dist/components/resizable/single/index.d.ts +1 -0
- package/dist/components/resizable/utils.js +1 -1
- package/dist/components/scroll-list/item-foundation.d.ts +17 -5
- package/dist/components/scroll-list/item-foundation.js +44 -29
- package/dist/components/scroll-list/scroll-list.css +0 -4
- package/dist/components/scroll-list/scroll-list.scss +0 -3
- package/dist/components/select/constants.d.ts +2 -0
- package/dist/components/select/constants.js +1 -1
- package/dist/components/select/foundation.d.ts +34 -11
- package/dist/components/select/foundation.js +126 -85
- package/dist/components/select/select.css +4 -7
- package/dist/components/select/select.scss +10 -5
- package/dist/components/side-sheet/constants.d.ts +2 -0
- package/dist/components/side-sheet/side-sheet-foundation.d.ts +10 -7
- package/dist/components/side-sheet/side-sheet-foundation.js +40 -30
- package/dist/components/side-sheet/side-sheet.css +0 -4
- package/dist/components/side-sheet/side-sheet.scss +0 -3
- package/dist/components/skeleton/skeleton.css +0 -4
- package/dist/components/skeleton/skeleton.scss +0 -3
- package/dist/components/slider/constants.d.ts +3 -1
- package/dist/components/slider/foundation.d.ts +39 -6
- package/dist/components/slider/foundation.js +56 -11
- package/dist/components/slider/rtl.scss +0 -2
- package/dist/components/slider/slider.css +2 -4
- package/dist/components/slider/slider.scss +2 -0
- package/dist/components/space/space.css +0 -4
- package/dist/components/space/space.scss +0 -3
- package/dist/components/spin/constants.d.ts +3 -1
- package/dist/components/spin/foundation.d.ts +1 -0
- package/dist/components/spin/foundation.js +1 -1
- package/dist/components/spin/spin.css +0 -5
- package/dist/components/spin/spin.scss +0 -3
- package/dist/components/steps/fill-steps.css +1 -1
- package/dist/components/steps/fill-steps.scss +1 -1
- package/dist/components/steps/steps.css +1 -7
- package/dist/components/steps/steps.scss +0 -2
- package/dist/components/switch/foundation.d.ts +1 -0
- package/dist/components/switch/rtl.scss +0 -4
- package/dist/components/switch/switch.css +0 -4
- package/dist/components/table/constants.d.ts +2 -0
- package/dist/components/table/foundation.d.ts +4 -3
- package/dist/components/table/foundation.js +40 -47
- package/dist/components/table/rtl.scss +0 -5
- package/dist/components/table/table.css +1 -6
- package/dist/components/table/table.scss +2 -1
- package/dist/components/table/utils.d.ts +59 -7
- package/dist/components/table/utils.js +90 -9
- package/dist/components/tabs/constants.d.ts +2 -0
- package/dist/components/tabs/foundation.d.ts +1 -9
- package/dist/components/tabs/foundation.js +21 -90
- package/dist/components/tabs/rtl.scss +0 -4
- package/dist/components/tabs/tab-bar-foundation.d.ts +45 -0
- package/dist/components/tabs/tab-bar-foundation.js +94 -0
- package/dist/components/tabs/tabs.css +4 -6
- package/dist/components/tabs/tabs.scss +4 -2
- package/dist/components/tabs/variables.scss +1 -1
- package/dist/components/tag/tag.css +0 -7
- package/dist/components/tag/tag.scss +0 -3
- package/dist/components/tag-input/foundation.d.ts +37 -14
- package/dist/components/tag-input/foundation.js +27 -1
- package/dist/components/tag-input/tag-input.css +0 -4
- package/dist/components/tag-input/tag-input.scss +0 -3
- package/dist/components/time-picker/combobox-options.d.ts +69 -0
- package/dist/components/time-picker/combobox-options.js +98 -0
- package/dist/components/time-picker/constants.d.ts +2 -0
- package/dist/components/time-picker/foundation.d.ts +19 -4
- package/dist/components/time-picker/foundation.js +46 -26
- package/dist/components/time-picker/input-foundation.d.ts +9 -2
- package/dist/components/time-picker/input-foundation.js +7 -0
- package/dist/components/time-picker/time-picker.css +0 -6
- package/dist/components/time-picker/time-picker.scss +0 -3
- package/dist/components/time-picker/utils/index.d.ts +4 -2
- package/dist/components/time-picker/utils/index.js +4 -6
- package/dist/components/timeline/rtl.scss +0 -4
- package/dist/components/timeline/timeline.css +0 -4
- package/dist/components/toast/constants.d.ts +0 -2
- package/dist/components/toast/constants.js +0 -2
- package/dist/components/toast/toast-api-foundation.d.ts +3 -2
- package/dist/components/toast/toast-api-foundation.js +14 -6
- package/dist/components/toast/toast-foundation.d.ts +1 -0
- package/dist/components/toast/toast-list-foundation.d.ts +11 -29
- package/dist/components/toast/toast-list-foundation.js +6 -74
- package/dist/components/toast/toast.css +0 -4
- package/dist/components/toast/toast.scss +0 -3
- package/dist/components/tooltip/constants.d.ts +2 -6
- package/dist/components/tooltip/constants.js +1 -7
- package/dist/components/tooltip/foundation.d.ts +15 -16
- package/dist/components/tooltip/foundation.js +60 -20
- package/dist/components/tooltip/tooltip.css +1 -4
- package/dist/components/tooltip/tooltip.scss +0 -2
- package/dist/components/transfer/constants.d.ts +1 -0
- package/dist/components/transfer/constants.js +2 -1
- package/dist/components/transfer/foundation.d.ts +37 -0
- package/dist/components/transfer/foundation.js +42 -1
- package/dist/components/transfer/transfer-utils.js +1 -1
- package/dist/components/transfer/transfer.css +0 -4
- package/dist/components/transfer/transfer.scss +0 -3
- package/dist/components/tree/constants.d.ts +2 -0
- package/dist/components/tree/foundation.d.ts +19 -4
- package/dist/components/tree/foundation.js +39 -4
- package/dist/components/tree/rtl.scss +0 -7
- package/dist/components/tree/shared.d.ts +50 -7
- package/dist/components/tree/shared.js +51 -9
- package/dist/components/tree/tree-util.d.ts +37 -38
- package/dist/components/tree/tree-util.js +5 -5
- package/dist/components/tree/tree.css +0 -7
- package/dist/components/tree-select/constants.d.ts +2 -0
- package/dist/components/tree-select/constants.js +1 -1
- package/dist/components/tree-select/foundation.d.ts +22 -14
- package/dist/components/tree-select/foundation.js +58 -13
- package/dist/components/tree-select/tree-select.css +0 -5
- package/dist/components/tree-select/tree-select.scss +0 -3
- package/dist/components/typography/copy.d.ts +8 -0
- package/dist/components/typography/copy.js +11 -0
- package/dist/components/typography/ellipsis.d.ts +31 -0
- package/dist/components/typography/ellipsis.js +30 -1
- package/dist/components/typography/rtl.scss +0 -4
- package/dist/components/typography/typography.css +0 -4
- package/dist/components/upload/constants.d.ts +4 -2
- package/dist/components/upload/constants.js +1 -1
- package/dist/components/upload/foundation.d.ts +26 -0
- package/dist/components/upload/foundation.js +28 -3
- package/dist/components/upload/rtl.scss +0 -4
- package/dist/components/upload/upload.css +0 -4
- package/dist/components/upload/utils.d.ts +7 -1
- package/dist/components/upload/utils.js +14 -4
- package/dist/components/user-guide/foundation.d.ts +5 -13
- package/dist/components/user-guide/foundation.js +91 -39
- package/dist/components/video-player/constants.d.ts +3 -0
- package/dist/components/video-player/constants.js +13 -1
- package/dist/components/video-player/foundation.d.ts +5 -4
- package/dist/components/video-player/foundation.js +7 -3
- package/dist/components/video-player/progress-foundation.d.ts +1 -1
- package/dist/components/video-player/progress-foundation.js +2 -2
- package/dist/components/video-player/seek-foundation.d.ts +7 -4
- package/dist/components/video-player/seek-foundation.js +26 -16
- package/dist/components/video-player/utils.d.ts +0 -2
- package/dist/components/video-player/utils.js +1 -14
- package/dist/components/video-player/video-player.css +10 -16
- package/dist/components/video-player/video-player.scss +12 -16
- package/dist/locale/index.d.ts +6 -0
- package/dist/locale/index.js +5 -0
- package/dist/locale/interface.d.ts +16 -5
- package/dist/locale/resolve-locale.d.ts +3 -3
- package/dist/locale/resolve-locale.js +20 -6
- package/dist/locale/source/en_US.js +4 -2
- package/dist/locale/source/zh_CN.js +4 -2
- package/dist/utils/a11y.d.ts +23 -11
- package/dist/utils/a11y.js +32 -17
- package/dist/utils/announcer.d.ts +0 -17
- package/dist/utils/announcer.js +1 -19
- package/dist/utils/assert-client.d.ts +1 -0
- package/dist/utils/assert-client.js +5 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +25 -1
- package/dist/utils/date-fns-extra.d.ts +1 -0
- package/dist/utils/date-fns-extra.js +4 -1
- package/dist/utils/date-fns-locale.d.ts +6 -0
- package/dist/utils/date-fns-locale.js +15 -0
- package/dist/utils/dom.d.ts +10 -6
- package/dist/utils/dom.js +17 -6
- package/dist/utils/focus-handover.js +2 -2
- package/dist/utils/index.d.ts +32 -0
- package/dist/utils/index.js +31 -0
- package/dist/utils/layer.d.ts +15 -0
- package/dist/utils/layer.js +38 -1
- package/dist/utils/media.d.ts +2 -0
- package/dist/utils/media.js +15 -0
- package/dist/utils/zoned-time.d.ts +6 -0
- package/dist/utils/zoned-time.js +18 -0
- package/package.json +10 -7
- package/dist/components/anchor/rtl.scss +0 -9
- package/dist/components/auto-complete/rtl.scss +0 -9
- package/dist/components/avatar/rtl.scss +0 -11
- package/dist/components/backtop/rtl.scss +0 -8
- package/dist/components/badge/rtl.scss +0 -8
- package/dist/components/banner/rtl.scss +0 -8
- package/dist/components/breadcrumb/rtl.scss +0 -9
- package/dist/components/calendar/rtl.scss +0 -10
- package/dist/components/card/rtl.scss +0 -18
- package/dist/components/checkbox/rtl.scss +0 -11
- package/dist/components/collapse/rtl.scss +0 -8
- package/dist/components/date-picker/_utils/is-valid-date.d.ts +0 -1
- package/dist/components/date-picker/_utils/is-valid-date.js +0 -5
- package/dist/components/descriptions/rtl.scss +0 -8
- package/dist/components/dropdown/rtl.scss +0 -9
- package/dist/components/empty/rtl.scss +0 -8
- package/dist/components/float-button/rtl.scss +0 -2
- package/dist/components/form/rtl.scss +0 -13
- package/dist/components/grid/rtl.scss +0 -10
- package/dist/components/input/rtl.scss +0 -11
- package/dist/components/input-number/rtl.scss +0 -9
- package/dist/components/layout/rtl.scss +0 -7
- package/dist/components/list/rtl.scss +0 -9
- package/dist/components/modal/rtl.scss +0 -10
- package/dist/components/notification/rtl.scss +0 -9
- package/dist/components/overflow-list/rtl.scss +0 -7
- package/dist/components/popover/rtl.scss +0 -9
- package/dist/components/radio/rtl.scss +0 -11
- package/dist/components/rating/rtl.scss +0 -9
- package/dist/components/scroll-list/rtl.scss +0 -9
- package/dist/components/select/rtl.scss +0 -10
- package/dist/components/side-sheet/rtl.scss +0 -9
- package/dist/components/skeleton/rtl.scss +0 -9
- package/dist/components/space/rtl.scss +0 -8
- package/dist/components/spin/rtl.scss +0 -11
- package/dist/components/steps/rtl.scss +0 -14
- package/dist/components/tag/rtl.scss +0 -12
- package/dist/components/tag-input/rtl.scss +0 -9
- package/dist/components/time-picker/combox-foundation.d.ts +0 -64
- package/dist/components/time-picker/combox-foundation.js +0 -96
- package/dist/components/time-picker/rtl.scss +0 -10
- package/dist/components/toast/rtl.scss +0 -9
- package/dist/components/tooltip/rtl.scss +0 -9
- package/dist/components/transfer/rtl.scss +0 -9
- package/dist/components/tree-select/rtl.scss +0 -9
- package/dist/locale/source/ar.d.ts +0 -3
- package/dist/locale/source/ar.js +0 -520
- package/dist/locale/source/az.d.ts +0 -3
- package/dist/locale/source/az.js +0 -520
- package/dist/locale/source/bg.d.ts +0 -3
- package/dist/locale/source/bg.js +0 -520
- package/dist/locale/source/bn_IN.d.ts +0 -3
- package/dist/locale/source/bn_IN.js +0 -520
- package/dist/locale/source/ca.d.ts +0 -3
- package/dist/locale/source/ca.js +0 -520
- package/dist/locale/source/ceb_PH.d.ts +0 -3
- package/dist/locale/source/ceb_PH.js +0 -520
- package/dist/locale/source/cs_CZ.d.ts +0 -3
- package/dist/locale/source/cs_CZ.js +0 -520
- package/dist/locale/source/da.d.ts +0 -3
- package/dist/locale/source/da.js +0 -520
- package/dist/locale/source/de.d.ts +0 -3
- package/dist/locale/source/de.js +0 -520
- package/dist/locale/source/el_GR.d.ts +0 -3
- package/dist/locale/source/el_GR.js +0 -520
- package/dist/locale/source/en_GB.d.ts +0 -3
- package/dist/locale/source/en_GB.js +0 -520
- package/dist/locale/source/es.d.ts +0 -3
- package/dist/locale/source/es.js +0 -520
- package/dist/locale/source/es_419.d.ts +0 -3
- package/dist/locale/source/es_419.js +0 -520
- package/dist/locale/source/et.d.ts +0 -3
- package/dist/locale/source/et.js +0 -520
- package/dist/locale/source/fa_IR.d.ts +0 -3
- package/dist/locale/source/fa_IR.js +0 -520
- package/dist/locale/source/fi_FI.d.ts +0 -3
- package/dist/locale/source/fi_FI.js +0 -520
- package/dist/locale/source/fil_PH.d.ts +0 -3
- package/dist/locale/source/fil_PH.js +0 -520
- package/dist/locale/source/fr.d.ts +0 -3
- package/dist/locale/source/fr.js +0 -520
- package/dist/locale/source/fr_CA.d.ts +0 -3
- package/dist/locale/source/fr_CA.js +0 -520
- package/dist/locale/source/ga.d.ts +0 -3
- package/dist/locale/source/ga.js +0 -520
- package/dist/locale/source/he_IL.d.ts +0 -3
- package/dist/locale/source/he_IL.js +0 -520
- package/dist/locale/source/hi_IN.d.ts +0 -3
- package/dist/locale/source/hi_IN.js +0 -520
- package/dist/locale/source/hr.d.ts +0 -3
- package/dist/locale/source/hr.js +0 -520
- package/dist/locale/source/hu_HU.d.ts +0 -3
- package/dist/locale/source/hu_HU.js +0 -520
- package/dist/locale/source/id_ID.d.ts +0 -3
- package/dist/locale/source/id_ID.js +0 -520
- package/dist/locale/source/is.d.ts +0 -3
- package/dist/locale/source/is.js +0 -520
- package/dist/locale/source/it.d.ts +0 -3
- package/dist/locale/source/it.js +0 -520
- package/dist/locale/source/ja_JP.d.ts +0 -3
- package/dist/locale/source/ja_JP.js +0 -520
- package/dist/locale/source/jv_ID.d.ts +0 -3
- package/dist/locale/source/jv_ID.js +0 -520
- package/dist/locale/source/kk.d.ts +0 -3
- package/dist/locale/source/kk.js +0 -520
- package/dist/locale/source/km_KH.d.ts +0 -3
- package/dist/locale/source/km_KH.js +0 -520
- package/dist/locale/source/ko_KR.d.ts +0 -3
- package/dist/locale/source/ko_KR.js +0 -520
- package/dist/locale/source/lt.d.ts +0 -3
- package/dist/locale/source/lt.js +0 -520
- package/dist/locale/source/lv.d.ts +0 -3
- package/dist/locale/source/lv.js +0 -520
- package/dist/locale/source/ms_MY.d.ts +0 -3
- package/dist/locale/source/ms_MY.js +0 -520
- package/dist/locale/source/my_MM.d.ts +0 -3
- package/dist/locale/source/my_MM.js +0 -520
- package/dist/locale/source/nb.d.ts +0 -3
- package/dist/locale/source/nb.js +0 -520
- package/dist/locale/source/nl_NL.d.ts +0 -3
- package/dist/locale/source/nl_NL.js +0 -520
- package/dist/locale/source/pl_PL.d.ts +0 -3
- package/dist/locale/source/pl_PL.js +0 -520
- package/dist/locale/source/pt.d.ts +0 -3
- package/dist/locale/source/pt.js +0 -520
- package/dist/locale/source/pt_BR.d.ts +0 -3
- package/dist/locale/source/pt_BR.js +0 -520
- package/dist/locale/source/ro.d.ts +0 -3
- package/dist/locale/source/ro.js +0 -520
- package/dist/locale/source/ru_RU.d.ts +0 -3
- package/dist/locale/source/ru_RU.js +0 -520
- package/dist/locale/source/sk.d.ts +0 -3
- package/dist/locale/source/sk.js +0 -520
- package/dist/locale/source/sl.d.ts +0 -3
- package/dist/locale/source/sl.js +0 -520
- package/dist/locale/source/sq.d.ts +0 -3
- package/dist/locale/source/sq.js +0 -520
- package/dist/locale/source/sv_SE.d.ts +0 -3
- package/dist/locale/source/sv_SE.js +0 -520
- package/dist/locale/source/sw.d.ts +0 -3
- package/dist/locale/source/sw.js +0 -520
- package/dist/locale/source/th_TH.d.ts +0 -3
- package/dist/locale/source/th_TH.js +0 -520
- package/dist/locale/source/tr_TR.d.ts +0 -3
- package/dist/locale/source/tr_TR.js +0 -520
- package/dist/locale/source/uk_UA.d.ts +0 -3
- package/dist/locale/source/uk_UA.js +0 -520
- package/dist/locale/source/ur.d.ts +0 -3
- package/dist/locale/source/ur.js +0 -520
- package/dist/locale/source/uz.d.ts +0 -3
- package/dist/locale/source/uz.js +0 -520
- package/dist/locale/source/vi_VN.d.ts +0 -3
- package/dist/locale/source/vi_VN.js +0 -520
- package/dist/locale/source/zh_TW.d.ts +0 -3
- package/dist/locale/source/zh_TW.js +0 -520
- package/dist/utils/is-element.d.ts +0 -1
- package/dist/utils/is-element.js +0 -5
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isValidDate } from "../../utils/date-fns-extra.js";
|
|
2
|
+
import { strings } from "./constants.js";
|
|
3
|
+
// src/components/time-picker/combobox-options.ts
|
|
4
|
+
function formatOption(option, disabledOptions) {
|
|
5
|
+
return {
|
|
6
|
+
value: String(option).padStart(2, "0"),
|
|
7
|
+
disabled: Boolean(disabledOptions?.includes(option))
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function generateOptions(length, disabledOptions, hideDisabledOptions, step, stepName) {
|
|
11
|
+
if (step !== void 0 && !(Number.isInteger(step) && step > 0)) throw new RangeError(`${stepName} must be a positive integer, got ${step}`);
|
|
12
|
+
const arr = [];
|
|
13
|
+
for (let value = 0; value < length; value += step ?? 1) if (!hideDisabledOptions || !disabledOptions?.includes(value)) arr.push(value);
|
|
14
|
+
return arr;
|
|
15
|
+
}
|
|
16
|
+
function toColumn(options, disabledOptions, selected) {
|
|
17
|
+
return {
|
|
18
|
+
list: options.map((option) => formatOption(option, disabledOptions)),
|
|
19
|
+
selectedIndex: options.indexOf(selected)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `disabledHours()`, mapped onto the 12-hour column of the half day `isAM` names when `use12Hours`; the hours of
|
|
24
|
+
* the other half day drop out
|
|
25
|
+
*/
|
|
26
|
+
function getDisabledHours({ use12Hours, disabledHours, isAM }) {
|
|
27
|
+
const disabledOptions = disabledHours && disabledHours();
|
|
28
|
+
if (use12Hours && Array.isArray(disabledOptions)) return disabledOptions.filter((h) => h < 12 === Boolean(isAM)).map((h) => h % 12 || 12);
|
|
29
|
+
return disabledOptions;
|
|
30
|
+
}
|
|
31
|
+
function getDisplayDateFromTimeStamp(timeStamp, defaultIsPM = false) {
|
|
32
|
+
if (!hasValue(timeStamp)) {
|
|
33
|
+
const now = /* @__PURE__ */ new Date();
|
|
34
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate(), defaultIsPM ? 12 : 0);
|
|
35
|
+
}
|
|
36
|
+
return new Date(timeStamp);
|
|
37
|
+
}
|
|
38
|
+
/** A timestamp of 0 is a value; only nothing and '' are not */
|
|
39
|
+
function hasValue(timeStamp) {
|
|
40
|
+
return timeStamp != null && timeStamp !== "" && isValidDate(new Date(timeStamp));
|
|
41
|
+
}
|
|
42
|
+
function isAM(timeStamp, defaultIsAM = true) {
|
|
43
|
+
return hasValue(timeStamp) ? getDisplayDateFromTimeStamp(timeStamp).getHours() < 12 : defaultIsAM;
|
|
44
|
+
}
|
|
45
|
+
function getColumns(format) {
|
|
46
|
+
return {
|
|
47
|
+
showHour: /HH|hh|H|h/.test(format),
|
|
48
|
+
showMinute: format.includes("mm"),
|
|
49
|
+
showSecond: format.includes("ss")
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Every column reads the shown time (midnight, or noon in a PM panel, while there is no value), the time a picked
|
|
54
|
+
* item is applied to.
|
|
55
|
+
*/
|
|
56
|
+
function getOptions(props) {
|
|
57
|
+
const { timeStampValue, use12Hours, hourStep, disabledMinutes, disabledSeconds, hideDisabledOptions, minuteStep, secondStep } = props;
|
|
58
|
+
const format = typeof props.format === "string" ? props.format : strings.DEFAULT_FORMAT;
|
|
59
|
+
const am = isAM(timeStampValue, props.defaultIsAM);
|
|
60
|
+
const dateTime = getDisplayDateFromTimeStamp(timeStampValue, use12Hours && !am);
|
|
61
|
+
const hours = dateTime.getHours();
|
|
62
|
+
const minutes = dateTime.getMinutes();
|
|
63
|
+
const disabledHourOptions = getDisabledHours({
|
|
64
|
+
...props,
|
|
65
|
+
isAM: am
|
|
66
|
+
});
|
|
67
|
+
const disabledMinuteOptions = disabledMinutes?.(hours);
|
|
68
|
+
const disabledSecondOptions = disabledSeconds?.(hours, minutes);
|
|
69
|
+
const hourOptions = use12Hours ? generateOptions(12, void 0, false, hourStep, "hourStep").map((hour) => hour || 12).filter((hour) => !hideDisabledOptions || !disabledHourOptions?.includes(hour)) : generateOptions(24, disabledHourOptions, hideDisabledOptions, hourStep, "hourStep");
|
|
70
|
+
const minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions, minuteStep, "minuteStep");
|
|
71
|
+
const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions, secondStep, "secondStep");
|
|
72
|
+
return {
|
|
73
|
+
...getColumns(format),
|
|
74
|
+
isAM: am,
|
|
75
|
+
ampm: {
|
|
76
|
+
list: [{ value: "AM" }, { value: "PM" }],
|
|
77
|
+
selectedIndex: am ? 0 : 1
|
|
78
|
+
},
|
|
79
|
+
hour: toColumn(hourOptions, disabledHourOptions, use12Hours ? hours % 12 || 12 : hours),
|
|
80
|
+
minute: toColumn(minuteOptions, disabledMinuteOptions, minutes),
|
|
81
|
+
second: toColumn(secondOptions, disabledSecondOptions, dateTime.getSeconds())
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** A 12-hour hour keeps the half day `isAMValue` names; AM/PM moves the time by 12 hours only when it is in the other half day */
|
|
85
|
+
function applyItem(timeStampValue, type, itemValue, use12Hours, isAMValue) {
|
|
86
|
+
const date = getDisplayDateFromTimeStamp(timeStampValue, use12Hours && !isAMValue);
|
|
87
|
+
const hours = date.getHours();
|
|
88
|
+
if (type === "hour") date.setHours(use12Hours ? Number(itemValue) % 12 + (isAMValue ? 0 : 12) : Number(itemValue));
|
|
89
|
+
else if (type === "minute") date.setMinutes(Number(itemValue));
|
|
90
|
+
else if (type === "second") date.setSeconds(Number(itemValue));
|
|
91
|
+
else if (use12Hours) {
|
|
92
|
+
const toPM = itemValue.toUpperCase() === "PM";
|
|
93
|
+
if (toPM && hours < 12) date.setHours(hours + 12);
|
|
94
|
+
else if (!toPM && hours >= 12) date.setHours(hours - 12);
|
|
95
|
+
}
|
|
96
|
+
return date;
|
|
97
|
+
}
|
|
98
|
+
export { applyItem, formatOption, getColumns, getOptions, hasValue, isAM };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../../base/foundation.js";
|
|
2
|
+
import "../../base/index.js";
|
|
2
3
|
import { PanelType, strings } from "./constants.js";
|
|
3
4
|
import { isEqual } from "es-toolkit";
|
|
4
5
|
import { Locale } from "date-fns";
|
|
@@ -13,7 +14,9 @@ export interface TimePickerAdapter<P extends TimePickerBaseProps = TimePickerBas
|
|
|
13
14
|
/** focus is in the panel and came from the keyboard (`:focus-visible`), not from a click */
|
|
14
15
|
isKeyboardFocusInPanel: () => boolean;
|
|
15
16
|
/** focuses the input, or the focus target of a custom trigger */
|
|
16
|
-
setTriggerFocus: () => void;
|
|
17
|
+
setTriggerFocus: (options?: FocusOptions) => void;
|
|
18
|
+
/** blurs the focused element of the trigger or the panel */
|
|
19
|
+
blurFocusedElement: () => void;
|
|
17
20
|
}
|
|
18
21
|
export interface TimePickerBaseProps {
|
|
19
22
|
dateFnsLocale?: Locale;
|
|
@@ -22,7 +25,8 @@ export interface TimePickerBaseProps {
|
|
|
22
25
|
disabledHours?: () => number[];
|
|
23
26
|
disabledMinutes?: (selectedHour: number) => number[];
|
|
24
27
|
disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
|
|
25
|
-
|
|
28
|
+
/** The unpicked side of a range is undefined */
|
|
29
|
+
disabledTime?: (value: (Date | undefined)[], panelType: PanelType) => DisabledTimeFns;
|
|
26
30
|
format?: string;
|
|
27
31
|
open?: boolean;
|
|
28
32
|
rangeSeparator?: string;
|
|
@@ -62,7 +66,14 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
|
|
|
62
66
|
* range-only: it gives the left and right panel their own rules, and each callback it leaves out falls back to the
|
|
63
67
|
* top-level prop.
|
|
64
68
|
*/
|
|
65
|
-
static getDisabledTimeFns({ disabledHours, disabledMinutes, disabledSeconds, disabledTime }: TimePickerBaseProps, dates: Date[], panelType: PanelType, isRange: boolean): DisabledTimeFns;
|
|
69
|
+
static getDisabledTimeFns({ disabledHours, disabledMinutes, disabledSeconds, disabledTime, timeZone }: TimePickerBaseProps, dates: (Date | undefined)[], panelType: PanelType, isRange: boolean): DisabledTimeFns;
|
|
70
|
+
/** The class names of the panel: it is narrow while a time column is missing, and its width follows the column count */
|
|
71
|
+
static getPanelClassNames(props: {
|
|
72
|
+
prefixCls: string;
|
|
73
|
+
format?: string;
|
|
74
|
+
use12Hours?: boolean;
|
|
75
|
+
type?: string;
|
|
76
|
+
}): string[];
|
|
66
77
|
static getPosition(props: Record<string, any>, direction?: string): Position;
|
|
67
78
|
/** A controlled `open` is not copied into state, so the shown panel comes from props when they carry it; a disabled picker shows none */
|
|
68
79
|
static isPanelShown(props: Record<string, any>, state: Record<string, any>): boolean;
|
|
@@ -72,9 +83,11 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
|
|
|
72
83
|
handlePanelChange: (result: {
|
|
73
84
|
timeStampValue: number;
|
|
74
85
|
}, index?: number) => void;
|
|
86
|
+
focus: (options?: FocusOptions) => void;
|
|
87
|
+
blur: () => void;
|
|
75
88
|
handleFocus: (e: E) => void;
|
|
76
89
|
/** A custom trigger without a focus target of its own is a button: Enter, Space and Down Arrow open the panel */
|
|
77
|
-
handleTriggerKeyDown: (e: Pick<KeyboardEvent, "key" | "preventDefault">) => void;
|
|
90
|
+
handleTriggerKeyDown: (e: Pick<KeyboardEvent, "key" | "preventDefault"> & Partial<Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey">>) => void;
|
|
78
91
|
/** Closes the panel and reports openChange(false), without blur and without moving focus */
|
|
79
92
|
close: () => void;
|
|
80
93
|
/**
|
|
@@ -86,6 +99,8 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
|
|
|
86
99
|
handlePanelOpen: () => void;
|
|
87
100
|
/** Called for a mousedown outside the trigger and the panel while the panel is shown */
|
|
88
101
|
handleClickOutside: (e: MouseEvent) => void;
|
|
102
|
+
/** Called for a focusin anywhere while the panel is shown; `root` contains the trigger the panel opens from */
|
|
103
|
+
handleDocumentFocusIn: (e: Pick<FocusEvent, "composedPath">, root?: Node | null) => void;
|
|
89
104
|
handleInputChange: (input: string) => void;
|
|
90
105
|
handleInputBlur: () => void;
|
|
91
106
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import BaseFoundation from "../../base/foundation.js";
|
|
2
|
-
import {
|
|
2
|
+
import { zonedTimeToUtc } from "../../utils/date-fns-extra.js";
|
|
3
|
+
import { containsWithPopups } from "../../utils/layer.js";
|
|
4
|
+
import { isBrowserChord } from "../../utils/a11y.js";
|
|
3
5
|
import isValidTimeZone from "../../utils/is-valid-time-zone.js";
|
|
4
|
-
import {
|
|
6
|
+
import { fromWallTime, parseReference, toWallTime } from "../../utils/zoned-time.js";
|
|
7
|
+
import { getColumns } from "./combobox-options.js";
|
|
8
|
+
import { cssClasses, strings } from "./constants.js";
|
|
5
9
|
import { formatToString, hourIsDisabled, isTimeFormatLike, minuteIsDisabled, parseToDate, secondIsDisabled, transformToArray } from "./utils/index.js";
|
|
6
10
|
import { isEqual } from "es-toolkit";
|
|
7
11
|
import { isValid } from "date-fns";
|
|
@@ -24,14 +28,16 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
24
28
|
* The dates a `value` shows, on mount and on every update. An empty side of a range ('' or undefined) stays
|
|
25
29
|
* undefined, as the panel reports it, so one picked side shows with its separator. No picked side at all is no
|
|
26
30
|
* value, and so is a time that cannot be parsed: an Invalid Date in the state would make every later format throw.
|
|
27
|
-
*
|
|
31
|
+
* A Date or timestamp is an instant and a string a `timeZone` wall time. With `prevTimeZone`, `value` is the shown
|
|
32
|
+
* value in that zone and is re-zoned into `timeZone`.
|
|
28
33
|
*/
|
|
29
34
|
static #parseDates(value, props, timeZone, prevTimeZone) {
|
|
30
35
|
const formatToken = TimePickerFoundation.getValidFormat(props);
|
|
31
|
-
const
|
|
36
|
+
const values = Array.isArray(value) ? value : isEmptyValue(value) ? [] : [value];
|
|
37
|
+
const reference = parseReference(timeZone);
|
|
38
|
+
const dates = values.map((v) => parseToDate(v, formatToken, props.dateFnsLocale, reference));
|
|
32
39
|
if (dates.every((d) => d === void 0) || dates.some((d) => d !== void 0 && isNaN(Number(d)))) return [];
|
|
33
|
-
|
|
34
|
-
return dates.map((date) => date === void 0 ? void 0 : utcToZonedTime(isValidTimeZone(prevTimeZone) ? zonedTimeToUtc(date, prevTimeZone) : date, timeZone));
|
|
40
|
+
return dates.map((date) => date && toWallTime(isValidTimeZone(prevTimeZone) ? zonedTimeToUtc(date, prevTimeZone) : date, timeZone));
|
|
35
41
|
}
|
|
36
42
|
static #formatDates(dates, props) {
|
|
37
43
|
const formatToken = TimePickerFoundation.getValidFormat(props);
|
|
@@ -51,26 +57,14 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
51
57
|
#refreshInputValue() {
|
|
52
58
|
this.setState({ inputValue: this.formatValue(this.getState("value")) });
|
|
53
59
|
}
|
|
60
|
+
/** The string is the input text, a `timeZone` wall time, so it can be passed back as `value` */
|
|
54
61
|
#notifyChange(value, inputValue) {
|
|
55
|
-
let str = inputValue;
|
|
56
|
-
let _value = value;
|
|
57
62
|
const timeZone = this.getProp("timeZone");
|
|
63
|
+
const dates = value.map((date) => date && fromWallTime(date, timeZone));
|
|
58
64
|
if (this.#isRange()) {
|
|
59
65
|
const parts = inputValue.split(this.getProp("rangeSeparator"));
|
|
60
|
-
|
|
61
|
-
} else
|
|
62
|
-
if (isValidTimeZone(timeZone) && _value) {
|
|
63
|
-
const formatToken = this.getValidFormat();
|
|
64
|
-
const dateFnsLocale = this.getProp("dateFnsLocale");
|
|
65
|
-
if (Array.isArray(_value)) {
|
|
66
|
-
_value = _value.map((v) => v === void 0 ? void 0 : zonedTimeToUtc(v, timeZone));
|
|
67
|
-
str = _value.map((v) => v === void 0 ? "" : formatToString(v, formatToken, dateFnsLocale));
|
|
68
|
-
} else {
|
|
69
|
-
_value = zonedTimeToUtc(_value, timeZone);
|
|
70
|
-
str = formatToString(_value, formatToken, dateFnsLocale);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
this.adapter.notifyChange(_value, str);
|
|
66
|
+
this.adapter.notifyChange(dates, value.length === 2 ? [parts[0], parts[1] ?? ""] : parts);
|
|
67
|
+
} else this.adapter.notifyChange(dates[0], inputValue);
|
|
74
68
|
}
|
|
75
69
|
#hasChanged(dates = [], oldDates = []) {
|
|
76
70
|
const formatToken = this.getValidFormat();
|
|
@@ -136,14 +130,30 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
136
130
|
* range-only: it gives the left and right panel their own rules, and each callback it leaves out falls back to the
|
|
137
131
|
* top-level prop.
|
|
138
132
|
*/
|
|
139
|
-
static getDisabledTimeFns({ disabledHours, disabledMinutes, disabledSeconds, disabledTime }, dates, panelType, isRange) {
|
|
140
|
-
const panel = typeof disabledTime === "function" && isRange && disabledTime(dates, panelType) || {};
|
|
133
|
+
static getDisabledTimeFns({ disabledHours, disabledMinutes, disabledSeconds, disabledTime, timeZone }, dates, panelType, isRange) {
|
|
134
|
+
const panel = typeof disabledTime === "function" && isRange && disabledTime(dates.map((date) => date && fromWallTime(date, timeZone)), panelType) || {};
|
|
141
135
|
return {
|
|
142
136
|
disabledHours: panel.disabledHours || disabledHours,
|
|
143
137
|
disabledMinutes: panel.disabledMinutes || disabledMinutes,
|
|
144
138
|
disabledSeconds: panel.disabledSeconds || disabledSeconds
|
|
145
139
|
};
|
|
146
140
|
}
|
|
141
|
+
/** The class names of the panel: it is narrow while a time column is missing, and its width follows the column count */
|
|
142
|
+
static getPanelClassNames(props) {
|
|
143
|
+
const { prefixCls, use12Hours, type } = props;
|
|
144
|
+
const { showHour, showMinute, showSecond } = getColumns(TimePickerFoundation.getValidFormat(props));
|
|
145
|
+
const columnCount = [
|
|
146
|
+
showHour,
|
|
147
|
+
showMinute,
|
|
148
|
+
showSecond,
|
|
149
|
+
use12Hours
|
|
150
|
+
].filter(Boolean).length;
|
|
151
|
+
const classNames = [`${prefixCls}-panel`];
|
|
152
|
+
if (!(showHour && showMinute && showSecond) && !use12Hours) classNames.push(`${prefixCls}-panel-narrow`);
|
|
153
|
+
if (type === strings.TYPE_TIME_RANGE_PICKER) classNames.push(cssClasses.RANGE_PICKER);
|
|
154
|
+
classNames.push(`${prefixCls}-panel-column-${columnCount}`);
|
|
155
|
+
return classNames;
|
|
156
|
+
}
|
|
147
157
|
static getPosition(props, direction) {
|
|
148
158
|
const type = props.type || strings.DEFAULT_TYPE;
|
|
149
159
|
const rtlDirection = direction === "rtl" ? "bottomRight" : "";
|
|
@@ -166,7 +176,7 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
166
176
|
/** A new value wins (back to undefined clears it), else a new timeZone re-zones the shown value, else only the text is re-formatted */
|
|
167
177
|
handlePropsChange(prev) {
|
|
168
178
|
const { value, timeZone, disabled } = this.getProps();
|
|
169
|
-
if (!isEqual(value, prev.value)) this.#syncValueFromProps({
|
|
179
|
+
if (!isEqual(value, prev.value) || timeZone !== prev.timeZone && this.isControlledComponent("value")) this.#syncValueFromProps({
|
|
170
180
|
value,
|
|
171
181
|
timeZone
|
|
172
182
|
});
|
|
@@ -197,13 +207,19 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
197
207
|
if (this.#hasChanged(value, oldValue)) this.#notifyChange(value, inputValue);
|
|
198
208
|
}
|
|
199
209
|
};
|
|
210
|
+
focus = (options) => {
|
|
211
|
+
this.adapter.setTriggerFocus(options);
|
|
212
|
+
};
|
|
213
|
+
blur = () => {
|
|
214
|
+
this.adapter.blurFocusedElement();
|
|
215
|
+
};
|
|
200
216
|
handleFocus = (e) => {
|
|
201
217
|
this.handlePanelOpen();
|
|
202
218
|
this.adapter.notifyFocus(e);
|
|
203
219
|
};
|
|
204
220
|
/** A custom trigger without a focus target of its own is a button: Enter, Space and Down Arrow open the panel */
|
|
205
221
|
handleTriggerKeyDown = (e) => {
|
|
206
|
-
if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
|
|
222
|
+
if (!isBrowserChord(e) && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {
|
|
207
223
|
e.preventDefault();
|
|
208
224
|
this.handlePanelOpen();
|
|
209
225
|
}
|
|
@@ -232,6 +248,10 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
232
248
|
this.close();
|
|
233
249
|
this.adapter.notifyBlur(e);
|
|
234
250
|
};
|
|
251
|
+
/** Called for a focusin anywhere while the panel is shown; `root` contains the trigger the panel opens from */
|
|
252
|
+
handleDocumentFocusIn = (e, root) => {
|
|
253
|
+
if (root && !containsWithPopups(root, e.composedPath()[0]) && TimePickerFoundation.isPanelShown(this.getProps(), this.getStates())) this.close();
|
|
254
|
+
};
|
|
235
255
|
handleInputChange = (input) => {
|
|
236
256
|
this.setState({ inputValue: input });
|
|
237
257
|
const rangeSeparator = this.getProp("rangeSeparator");
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../../base/foundation.js";
|
|
2
|
+
import "../../base/index.js";
|
|
2
3
|
export type TimeInputState = Record<string, never>;
|
|
4
|
+
export interface TimeInputBaseProps {
|
|
5
|
+
/** Focuses and selects the text once mounted */
|
|
6
|
+
focusOnOpen?: boolean;
|
|
7
|
+
preventScroll?: boolean;
|
|
8
|
+
}
|
|
3
9
|
/** `E` is the focus and blur event of the host framework, which the foundation only passes on */
|
|
4
|
-
export interface TimeInputAdapter<P extends
|
|
10
|
+
export interface TimeInputAdapter<P extends TimeInputBaseProps = TimeInputBaseProps, E = unknown> extends DefaultAdapter<P, TimeInputState> {
|
|
5
11
|
notifyChange: (value: string) => void;
|
|
6
12
|
notifyFocus: (e: E) => void;
|
|
7
13
|
notifyBlur: (e: E) => void;
|
|
8
14
|
getInputNode: () => HTMLInputElement | null;
|
|
9
15
|
}
|
|
10
|
-
export default class TimeInputFoundation<P extends
|
|
16
|
+
export default class TimeInputFoundation<P extends TimeInputBaseProps = TimeInputBaseProps, E = unknown> extends BaseFoundation<TimeInputAdapter<P, E>, P, TimeInputState> {
|
|
11
17
|
#private;
|
|
12
18
|
static readonly propKeys: string[];
|
|
19
|
+
protected initOnce(): void;
|
|
13
20
|
/** Re-formatting the text moves the caret to the end; the host calls this after the input shows the new text */
|
|
14
21
|
handlePropsChange(): void;
|
|
15
22
|
handleFocus: (e: E) => void;
|
|
@@ -10,6 +10,13 @@ var TimeInputFoundation = class extends BaseFoundation {
|
|
|
10
10
|
#clearCursor() {
|
|
11
11
|
this.#cursorIndex = null;
|
|
12
12
|
}
|
|
13
|
+
initOnce() {
|
|
14
|
+
const inputNode = this.adapter.getInputNode();
|
|
15
|
+
if (this.getProp("focusOnOpen") && inputNode) {
|
|
16
|
+
inputNode.focus({ preventScroll: this.getProp("preventScroll") });
|
|
17
|
+
inputNode.select();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
13
20
|
/** Re-formatting the text moves the caret to the end; the host calls this after the input shows the new text */
|
|
14
21
|
handlePropsChange() {
|
|
15
22
|
const inputNode = this.adapter.getInputNode();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Locale } from "date-fns";
|
|
2
|
+
/** A TZDate `reference` reads a string as a wall time of its zone */
|
|
3
|
+
export declare function parseToDate(input: string | Date | number, formatToken?: string, dateFnsLocale?: Locale, reference?: Date): Date;
|
|
4
|
+
export declare function formatToString(dateOrTimestamp: Date | number, formatToken?: string, dateFnsLocale?: Locale): string;
|
|
3
5
|
export declare function hourIsDisabled(disabledHours: () => number[], hour: number): boolean;
|
|
4
6
|
export declare function minuteIsDisabled(disabledMinutes: (hour: number) => number[], hour: number, minute: number): boolean;
|
|
5
7
|
export declare function secondIsDisabled(disabledSeconds: (hour: number, minute: number) => number[], hour: number, minute: number, second: number): boolean;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { strings } from "../constants.js";
|
|
2
|
-
import { zhCN } from "date-fns/locale/zh-CN";
|
|
3
2
|
import { escapeRegExp } from "es-toolkit";
|
|
4
3
|
import { format, parse } from "date-fns";
|
|
5
4
|
// src/components/time-picker/utils/index.ts
|
|
6
|
-
|
|
5
|
+
/** A TZDate `reference` reads a string as a wall time of its zone */
|
|
6
|
+
function parseToDate(input, formatToken = strings.DEFAULT_FORMAT, dateFnsLocale, reference = /* @__PURE__ */ new Date()) {
|
|
7
7
|
if (input instanceof Date) return input;
|
|
8
8
|
else if (typeof input === "number") return new Date(input);
|
|
9
9
|
else if (typeof input === "string") {
|
|
10
10
|
if (input === "") return void 0;
|
|
11
|
-
|
|
12
|
-
curDate = parse(input, formatToken, curDate, { locale: dateFnsLocale });
|
|
13
|
-
return curDate;
|
|
11
|
+
return parse(input, formatToken, reference, { locale: dateFnsLocale });
|
|
14
12
|
} else if (typeof input === "undefined") return;
|
|
15
13
|
return /* @__PURE__ */ new Date();
|
|
16
14
|
}
|
|
17
|
-
function formatToString(dateOrTimestamp, formatToken = strings.DEFAULT_FORMAT, dateFnsLocale
|
|
15
|
+
function formatToString(dateOrTimestamp, formatToken = strings.DEFAULT_FORMAT, dateFnsLocale) {
|
|
18
16
|
return format(dateOrTimestamp, formatToken, { locale: dateFnsLocale });
|
|
19
17
|
}
|
|
20
18
|
function includesNumber(options, value) {
|
|
@@ -14,8 +14,6 @@ export declare const positions: readonly ["top", "left", "bottom", "right"];
|
|
|
14
14
|
export declare function setPosition(wrapper: HTMLElement, opts: Partial<Record<(typeof positions)[number], number | string>>): void;
|
|
15
15
|
export declare const numbers: {
|
|
16
16
|
duration: number;
|
|
17
|
-
stackThreshold: number;
|
|
18
|
-
stackVisibleCount: number;
|
|
19
17
|
stackLayerDepth: number;
|
|
20
18
|
};
|
|
21
19
|
/** Reserves depth for the newer toasts in front, so a collapsed stack keeps them on top */
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import ListStore from "../../base/list-store.js";
|
|
2
|
+
import "../../base/index.js";
|
|
1
3
|
import { ConfigProps, ToastInstance } from "./toast-foundation.js";
|
|
2
|
-
import ToastListStore from "./toast-list-foundation.js";
|
|
3
4
|
/** What the framework supplies to the static `Toast` */
|
|
4
5
|
export interface ToastApiHost {
|
|
5
6
|
/** Throws outside a browser, naming the API */
|
|
6
7
|
assertClient: () => void;
|
|
7
8
|
readGlobalDefaults: () => Partial<ToastInstance>;
|
|
8
9
|
/** Renders the toast list of `store` into `wrapper` and returns what unmounts it */
|
|
9
|
-
mount: (wrapper: HTMLDivElement, store:
|
|
10
|
+
mount: (wrapper: HTMLDivElement, store: ListStore<ToastInstance>) => () => void;
|
|
10
11
|
}
|
|
11
12
|
/** The static `Toast` (and `ToastFactory.create()`): one list in one wrapper, created by the first toast. `O` is the framework's toast options. */
|
|
12
13
|
export default class ToastApi<O extends object> {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import StaticListWrapper from "../../base/static-list-wrapper.js";
|
|
2
|
-
import { cssClasses, setPosition } from "./constants.js";
|
|
3
|
-
import
|
|
2
|
+
import { builtInOpts, cssClasses, positions, setPosition, strings } from "./constants.js";
|
|
3
|
+
import { createToastListStore } from "./toast-list-foundation.js";
|
|
4
4
|
// src/components/toast/toast-api-foundation.ts
|
|
5
5
|
/** The static `Toast` (and `ToastFactory.create()`): one list in one wrapper, created by the first toast. `O` is the framework's toast options. */
|
|
6
6
|
var ToastApi = class {
|
|
7
7
|
#host;
|
|
8
|
-
#store;
|
|
8
|
+
#store = createToastListStore();
|
|
9
9
|
#wrapper = new StaticListWrapper(cssClasses.WRAPPER, "toast-wrapper");
|
|
10
|
+
#initialConfig;
|
|
10
11
|
constructor(host, initialConfig) {
|
|
11
12
|
this.#host = host;
|
|
12
|
-
this.#
|
|
13
|
+
this.#initialConfig = initialConfig && { ...initialConfig };
|
|
14
|
+
this.resetConfig();
|
|
13
15
|
}
|
|
14
16
|
#show(opts, type) {
|
|
15
17
|
return this.create({
|
|
@@ -40,10 +42,16 @@ var ToastApi = class {
|
|
|
40
42
|
error = (opts) => this.#show(opts, "error");
|
|
41
43
|
success = (opts) => this.#show(opts, "success");
|
|
42
44
|
config = (opts) => {
|
|
43
|
-
this.#store.
|
|
45
|
+
const defaults = this.#store.defaults;
|
|
46
|
+
for (const pos of positions) if (pos in opts) defaults[pos] = opts[pos];
|
|
47
|
+
if (typeof opts.theme === "string" && strings.themes.includes(opts.theme)) defaults.theme = opts.theme;
|
|
48
|
+
if (typeof opts.zIndex === "number") defaults.zIndex = opts.zIndex;
|
|
49
|
+
if (typeof opts.duration === "number") defaults.duration = opts.duration;
|
|
50
|
+
if (typeof opts.getPopupContainer === "function") defaults.getPopupContainer = opts.getPopupContainer;
|
|
44
51
|
};
|
|
45
52
|
resetConfig = () => {
|
|
46
|
-
this.#store.
|
|
53
|
+
this.#store.defaults = { ...builtInOpts };
|
|
54
|
+
if (this.#initialConfig) this.config(this.#initialConfig);
|
|
47
55
|
};
|
|
48
56
|
};
|
|
49
57
|
export { ToastApi as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AutoCloseFoundation, { AutoCloseAdapter, AutoCloseBaseProps } from "../../base/auto-close-foundation.js";
|
|
2
|
+
import "../../base/index.js";
|
|
2
3
|
export type ToastType = 'success' | 'warning' | 'error' | 'info' | 'default';
|
|
3
4
|
export type ToastTheme = 'light' | 'normal';
|
|
4
5
|
export type Directions = 'ltr' | 'rtl';
|
|
@@ -1,31 +1,13 @@
|
|
|
1
|
-
import { ListStoreState } from "../../base/list-store.js";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import ListStore, { ListStoreState } from "../../base/list-store.js";
|
|
2
|
+
import "../../base/index.js";
|
|
3
|
+
import { ToastInstance } from "./toast-foundation.js";
|
|
4
|
+
/** A toast of the list: `open` gives every toast an id */
|
|
5
|
+
export type ToastItem = ToastInstance & {
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
export type ToastListState = ListStoreState<ToastItem>;
|
|
7
9
|
export interface ToastListProps {
|
|
8
|
-
store:
|
|
10
|
+
store: ListStore<ToastInstance>;
|
|
9
11
|
}
|
|
10
|
-
/** Toasts of one list, shown at the end
|
|
11
|
-
export
|
|
12
|
-
#private;
|
|
13
|
-
defaults: ToastInstance;
|
|
14
|
-
constructor(initialConfig?: ConfigProps);
|
|
15
|
-
subscribe: (listener: () => void) => () => void;
|
|
16
|
-
getSnapshot: () => ToastListState;
|
|
17
|
-
/** Shows a toast at the end, or updates the shown one with the same id in place */
|
|
18
|
-
add: (toast: ToastInstance) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Shows a toast with `opts` over the list's defaults and the global defaults, which is where the global defaults
|
|
21
|
-
* take effect: an explicit undefined replaces nothing. `beforeShow` gets the merged options before the toast is
|
|
22
|
-
* added, so a static API can place its wrapper by them. Returns the id.
|
|
23
|
-
*/
|
|
24
|
-
open: (opts: ToastInstance, globalDefaults: Partial<ToastInstance>, beforeShow?: (merged: ToastInstance) => void) => string;
|
|
25
|
-
remove: (id: string) => void;
|
|
26
|
-
finishLeave: (id: string) => void;
|
|
27
|
-
clear: () => void;
|
|
28
|
-
setStack: (option?: boolean | number) => void;
|
|
29
|
-
config: (opts: ConfigProps) => void;
|
|
30
|
-
resetConfig: () => void;
|
|
31
|
-
}
|
|
12
|
+
/** Toasts of one list, shown at the end */
|
|
13
|
+
export declare function createToastListStore(): ListStore<ToastInstance>;
|
|
@@ -1,76 +1,8 @@
|
|
|
1
1
|
import ListStore from "../../base/list-store.js";
|
|
2
|
-
import {
|
|
3
|
-
import { builtInOpts, numbers, positions, strings } from "./constants.js";
|
|
4
|
-
import { omitBy } from "es-toolkit";
|
|
2
|
+
import { builtInOpts } from "./constants.js";
|
|
5
3
|
// src/components/toast/toast-list-foundation.ts
|
|
6
|
-
/** Toasts of one list, shown at the end
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
updatedItems: [],
|
|
12
|
-
order: [],
|
|
13
|
-
stack: 0
|
|
14
|
-
});
|
|
15
|
-
#initialConfig;
|
|
16
|
-
defaults;
|
|
17
|
-
constructor(initialConfig) {
|
|
18
|
-
this.#initialConfig = initialConfig;
|
|
19
|
-
this.resetConfig();
|
|
20
|
-
}
|
|
21
|
-
subscribe = (listener) => this.#items.subscribe(listener);
|
|
22
|
-
getSnapshot = () => this.#items.getSnapshot();
|
|
23
|
-
/** Shows a toast at the end, or updates the shown one with the same id in place */
|
|
24
|
-
add = (toast) => {
|
|
25
|
-
this.#items.add(toast);
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Shows a toast with `opts` over the list's defaults and the global defaults, which is where the global defaults
|
|
29
|
-
* take effect: an explicit undefined replaces nothing. `beforeShow` gets the merged options before the toast is
|
|
30
|
-
* added, so a static API can place its wrapper by them. Returns the id.
|
|
31
|
-
*/
|
|
32
|
-
open = (opts, globalDefaults, beforeShow) => {
|
|
33
|
-
const merged = {
|
|
34
|
-
...this.defaults,
|
|
35
|
-
...globalDefaults,
|
|
36
|
-
...omitBy(opts, (value) => value === void 0)
|
|
37
|
-
};
|
|
38
|
-
const id = merged.id ?? createId("toast");
|
|
39
|
-
beforeShow?.(merged);
|
|
40
|
-
this.setStack(merged.stack);
|
|
41
|
-
this.add({
|
|
42
|
-
...merged,
|
|
43
|
-
id
|
|
44
|
-
});
|
|
45
|
-
return id;
|
|
46
|
-
};
|
|
47
|
-
remove = (id) => {
|
|
48
|
-
this.#items.remove(id);
|
|
49
|
-
};
|
|
50
|
-
finishLeave = (id) => {
|
|
51
|
-
this.#items.finishLeave(id);
|
|
52
|
-
};
|
|
53
|
-
clear = () => {
|
|
54
|
-
this.#items.clear();
|
|
55
|
-
};
|
|
56
|
-
setStack = (option) => {
|
|
57
|
-
const stack = option === true ? numbers.stackThreshold : typeof option === "number" ? Math.max(option, 0) : 0;
|
|
58
|
-
const { stack: current, updatedItems } = this.#items.getSnapshot();
|
|
59
|
-
if (stack !== current) this.#items.set({
|
|
60
|
-
stack,
|
|
61
|
-
updatedItems
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
config = (opts) => {
|
|
65
|
-
for (const pos of positions) if (pos in opts) this.defaults[pos] = opts[pos];
|
|
66
|
-
if (typeof opts.theme === "string" && strings.themes.includes(opts.theme)) this.defaults.theme = opts.theme;
|
|
67
|
-
if (typeof opts.zIndex === "number") this.defaults.zIndex = opts.zIndex;
|
|
68
|
-
if (typeof opts.duration === "number") this.defaults.duration = opts.duration;
|
|
69
|
-
if (typeof opts.getPopupContainer === "function") this.defaults.getPopupContainer = opts.getPopupContainer;
|
|
70
|
-
};
|
|
71
|
-
resetConfig = () => {
|
|
72
|
-
this.defaults = { ...builtInOpts };
|
|
73
|
-
if (this.#initialConfig) this.config(this.#initialConfig);
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
export { ToastListStore as default };
|
|
4
|
+
/** Toasts of one list, shown at the end */
|
|
5
|
+
function createToastListStore() {
|
|
6
|
+
return new ListStore("end", "toast", { ...builtInOpts });
|
|
7
|
+
}
|
|
8
|
+
export { createToastListStore };
|