@kine-design/core 0.0.1-beta.1 → 0.0.1-beta.10
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/.vlaude/last-session-id +1 -0
- package/.vlaude/session-switch.signal +1 -0
- package/assets/style/global.css +1 -0
- package/assets/style/var/Wuxing.css +71 -0
- package/assets/style/var.css +23 -0
- package/components/base/affix/api.ts +16 -0
- package/components/base/affix/index.ts +17 -0
- package/components/base/affix/props.d.ts +34 -0
- package/components/base/affix/useAffix.ts +124 -0
- package/components/base/alert/api.ts +18 -0
- package/components/base/alert/index.ts +15 -0
- package/components/base/alert/props.d.ts +50 -0
- package/components/base/anchor/api.ts +20 -0
- package/components/base/anchor/index.ts +18 -0
- package/components/base/anchor/props.d.ts +46 -0
- package/components/base/anchor/useAnchor.ts +84 -0
- package/components/base/autoComplete/api.ts +24 -0
- package/components/base/autoComplete/index.ts +17 -0
- package/components/base/autoComplete/props.d.ts +75 -0
- package/components/base/autoComplete/useAutoComplete.ts +157 -0
- package/components/base/avatar/api.ts +17 -0
- package/components/base/avatar/avatar.css +61 -0
- package/components/base/avatar/index.ts +15 -0
- package/components/base/avatar/props.d.ts +37 -0
- package/components/base/backTop/api.ts +17 -0
- package/components/base/backTop/index.ts +17 -0
- package/components/base/backTop/props.d.ts +38 -0
- package/components/base/backTop/useBackTop.ts +62 -0
- package/components/base/badge/api.ts +22 -0
- package/components/base/badge/index.ts +15 -0
- package/components/base/badge/props.d.ts +50 -0
- package/components/base/button/api.ts +28 -0
- package/components/base/button/button.css +34 -0
- package/components/base/button/index.ts +17 -0
- package/components/base/button/props.d.ts +66 -0
- package/components/base/button/useButton.ts +37 -0
- package/components/base/card/api.ts +17 -0
- package/components/base/card/index.ts +15 -0
- package/components/base/card/props.d.ts +37 -0
- package/components/base/carousel/api.ts +28 -0
- package/components/base/carousel/index.ts +17 -0
- package/components/base/carousel/props.d.ts +72 -0
- package/components/base/carousel/useCarousel.ts +150 -0
- package/components/base/cascader/api.ts +23 -0
- package/components/base/cascader/index.ts +18 -0
- package/components/base/cascader/props.d.ts +103 -0
- package/components/base/cascader/useCascader.ts +335 -0
- package/components/base/checkbox/api.ts +24 -0
- package/components/base/checkbox/checkbox.css +0 -0
- package/components/base/checkbox/index.ts +17 -0
- package/components/base/checkbox/props.d.ts +77 -0
- package/components/base/checkbox/useCheckbox.ts +43 -0
- package/components/base/collapse/api.ts +21 -0
- package/components/base/collapse/index.ts +18 -0
- package/components/base/collapse/props.d.ts +45 -0
- package/components/base/collapse/useCollapse.ts +81 -0
- package/components/base/datePicker/__tests__/useDatePicker.test.ts +244 -0
- package/components/base/datePicker/api.ts +22 -0
- package/components/base/datePicker/index.ts +19 -0
- package/components/base/datePicker/props.d.ts +86 -0
- package/components/base/datePicker/useDatePicker.ts +392 -0
- package/components/base/divider/api.ts +15 -0
- package/components/base/divider/divider.css +11 -0
- package/components/base/divider/index.ts +15 -0
- package/components/base/divider/props.d.ts +30 -0
- package/components/base/dropdown/api.ts +33 -0
- package/components/base/dropdown/index.ts +18 -0
- package/components/base/dropdown/props.d.ts +60 -0
- package/components/base/dropdown/useDropdown.ts +124 -0
- package/components/base/empty/api.ts +15 -0
- package/components/base/empty/index.ts +15 -0
- package/components/base/empty/props.d.ts +26 -0
- package/components/base/image/__tests__/useImage.test.ts +176 -0
- package/components/base/image/api.ts +25 -0
- package/components/base/image/index.ts +18 -0
- package/components/base/image/props.d.ts +67 -0
- package/components/base/image/useImage.ts +119 -0
- package/components/base/input/api.ts +23 -0
- package/components/base/input/index.ts +17 -0
- package/components/base/input/input.css +19 -0
- package/components/base/input/props.d.ts +85 -0
- package/components/base/input/useInput.ts +63 -0
- package/components/base/inputNumber/__tests__/useInputNumber.test.ts +189 -0
- package/components/base/inputNumber/api.ts +23 -0
- package/components/base/inputNumber/index.ts +17 -0
- package/components/base/inputNumber/props.d.ts +78 -0
- package/components/base/inputNumber/useInputNumber.ts +182 -0
- package/components/base/li/api.ts +15 -0
- package/components/base/li/index.ts +15 -0
- package/components/base/li/props.d.ts +30 -0
- package/components/base/list/api.ts +16 -0
- package/components/base/list/index.ts +17 -0
- package/components/base/list/props.d.ts +33 -0
- package/components/base/list/useList.ts +36 -0
- package/components/base/loading/api.ts +17 -0
- package/components/base/loading/index.ts +15 -0
- package/components/base/loading/props.d.ts +40 -0
- package/components/base/popover/api.ts +28 -0
- package/components/base/popover/index.ts +17 -0
- package/components/base/popover/props.d.ts +73 -0
- package/components/base/popover/usePopover.ts +193 -0
- package/components/base/progress/api.ts +20 -0
- package/components/base/progress/index.ts +17 -0
- package/components/base/progress/props.d.ts +68 -0
- package/components/base/progress/useProgress.ts +28 -0
- package/components/base/radio/api.ts +19 -0
- package/components/base/radio/index.ts +19 -0
- package/components/base/radio/props.d.ts +59 -0
- package/components/base/radio/useRadio.ts +11 -0
- package/components/base/rate/api.ts +18 -0
- package/components/base/rate/index.ts +17 -0
- package/components/base/rate/props.d.ts +49 -0
- package/components/base/rate/useRate.ts +76 -0
- package/components/base/result/api.ts +20 -0
- package/components/base/result/index.ts +15 -0
- package/components/base/result/props.d.ts +36 -0
- package/components/base/select/api.ts +34 -0
- package/components/base/select/index.ts +18 -0
- package/components/base/select/props.d.ts +152 -0
- package/components/base/select/select.css +7 -0
- package/components/base/select/useSelect.ts +281 -0
- package/components/base/select/useSelectTools.ts +60 -0
- package/components/base/skeleton/api.ts +18 -0
- package/components/base/skeleton/index.ts +15 -0
- package/components/base/skeleton/props.d.ts +41 -0
- package/components/base/slider/api.ts +22 -0
- package/components/base/slider/index.ts +17 -0
- package/components/base/slider/props.d.ts +79 -0
- package/components/base/slider/useSlider.ts +87 -0
- package/components/base/space/api.ts +17 -0
- package/components/base/space/index.ts +15 -0
- package/components/base/space/props.d.ts +39 -0
- package/components/base/steps/__tests__/useSteps.test.ts +46 -0
- package/components/base/steps/api.ts +30 -0
- package/components/base/steps/index.ts +22 -0
- package/components/base/steps/props.d.ts +88 -0
- package/components/base/steps/useSteps.ts +101 -0
- package/components/base/switch/api.ts +22 -0
- package/components/base/switch/index.ts +19 -0
- package/components/base/switch/props.d.ts +66 -0
- package/components/base/switch/useSwitch.tsx +80 -0
- package/components/base/tabs/api.ts +23 -0
- package/components/base/tabs/index.ts +18 -0
- package/components/base/tabs/props.d.ts +41 -0
- package/components/base/tabs/useTabs.ts +67 -0
- package/components/base/tag/api.ts +17 -0
- package/components/base/tag/index.ts +15 -0
- package/components/base/tag/props.d.ts +51 -0
- package/components/base/timePicker/__tests__/useTimePicker.test.ts +124 -0
- package/components/base/timePicker/api.ts +24 -0
- package/components/base/timePicker/index.ts +18 -0
- package/components/base/timePicker/props.d.ts +86 -0
- package/components/base/timePicker/useTimePicker.ts +161 -0
- package/components/base/timeline/api.ts +24 -0
- package/components/base/timeline/index.ts +16 -0
- package/components/base/timeline/props.d.ts +60 -0
- package/components/base/tooltip/api.ts +21 -0
- package/components/base/tooltip/index.ts +18 -0
- package/components/base/tooltip/props.d.ts +46 -0
- package/components/base/tooltip/useTooltip.ts +208 -0
- package/components/base/transfer/api.ts +18 -0
- package/components/base/transfer/index.ts +17 -0
- package/components/base/transfer/props.d.ts +63 -0
- package/components/base/transfer/useTransfer.ts +208 -0
- package/components/base/tree/__tests__/tree.test.ts +223 -0
- package/components/base/tree/api.ts +47 -0
- package/components/base/tree/index.ts +29 -0
- package/components/base/tree/props.d.ts +108 -0
- package/components/base/tree/tree.ts +263 -0
- package/components/base/tree/useTree.ts +114 -0
- package/components/message/confirm/api.ts +21 -0
- package/components/message/confirm/index.ts +15 -0
- package/components/message/confirm/props.d.ts +69 -0
- package/components/message/dialog/api.ts +20 -0
- package/components/message/dialog/index.ts +15 -0
- package/components/message/dialog/props.d.ts +62 -0
- package/components/message/drawer/api.ts +33 -0
- package/components/message/drawer/index.ts +15 -0
- package/components/message/drawer/props.d.ts +80 -0
- package/components/message/message/api.ts +27 -0
- package/components/message/message/index.ts +20 -0
- package/components/message/message/props.d.ts +54 -0
- package/components/message/message/useMessage.ts +61 -0
- package/components/message/notification/__tests__/useNotification.test.ts +129 -0
- package/components/message/notification/api.ts +23 -0
- package/components/message/notification/index.ts +19 -0
- package/components/message/notification/props.d.ts +64 -0
- package/components/message/notification/useNotification.ts +79 -0
- package/components/message/popover/MPopover.tsx +94 -0
- package/components/message/popover/api.ts +54 -0
- package/components/message/popover/index.ts +17 -0
- package/components/message/popover/popover.css +21 -0
- package/components/message/popover/props.d.ts +76 -0
- package/components/message/popover/usePopover.ts +234 -0
- package/components/other/darkMode/api.ts +17 -0
- package/components/other/darkMode/index.ts +17 -0
- package/components/other/darkMode/props.d.ts +37 -0
- package/components/other/darkMode/useDarkMode.ts +129 -0
- package/components/template/border/api.ts +18 -0
- package/components/template/border/index.ts +15 -0
- package/components/template/border/props.d.ts +41 -0
- package/components/template/breadcrumb/api.ts +15 -0
- package/components/template/breadcrumb/index.ts +15 -0
- package/components/template/breadcrumb/props.d.ts +45 -0
- package/components/template/descriptions/api.ts +23 -0
- package/components/template/descriptions/index.ts +16 -0
- package/components/template/descriptions/props.d.ts +54 -0
- package/components/template/form/api.ts +23 -0
- package/components/template/form/index.ts +20 -0
- package/components/template/form/props.d.ts +60 -0
- package/components/template/grid/api.ts +20 -0
- package/components/template/grid/index.ts +15 -0
- package/components/template/grid/props.d.ts +48 -0
- package/components/template/menu/__tests__/useMenu.test.ts +157 -0
- package/components/template/menu/api.ts +26 -0
- package/components/template/menu/index.ts +18 -0
- package/components/template/menu/props.d.ts +93 -0
- package/components/template/menu/useMenu.ts +155 -0
- package/components/template/pagination/__tests__/usePagination.test.ts +138 -0
- package/components/template/pagination/api.ts +22 -0
- package/components/template/pagination/index.ts +19 -0
- package/components/template/pagination/props.d.ts +65 -0
- package/components/template/pagination/usePagination.ts +186 -0
- package/components/template/table/__tests__/useTable.test.ts +138 -0
- package/components/template/table/api.ts +18 -0
- package/components/template/table/index.ts +18 -0
- package/components/template/table/props.d.ts +36 -0
- package/components/template/table/useTable.ts +136 -0
- package/components/template/tableColumn/api.ts +17 -0
- package/components/template/tableColumn/index.ts +15 -0
- package/components/template/tableColumn/props.d.ts +32 -0
- package/components/template/virtualList/api.ts +16 -0
- package/components/template/virtualList/index.ts +17 -0
- package/components/template/virtualList/props.d.ts +25 -0
- package/components/template/virtualList/useVirtualList.ts +237 -0
- package/components/types/hook.d.ts +24 -0
- package/components/types/props.d.ts +57 -0
- package/components/types/template.d.ts +59 -0
- package/compositions/commandPalette/index.ts +11 -0
- package/compositions/commandPalette/types.ts +29 -0
- package/compositions/commandPalette/useCommandPalette.ts +135 -0
- package/compositions/common/__tests__/useDebounceFn.test.ts +62 -0
- package/compositions/common/__tests__/useEventListener.test.ts +98 -0
- package/compositions/common/__tests__/usePopover.test.ts +43 -0
- package/compositions/common/__tests__/useTeleport.test.ts +32 -0
- package/compositions/common/defineCore.ts +55 -0
- package/compositions/common/testAnchor.ts +211 -0
- package/compositions/common/useComponentSize.ts +17 -0
- package/compositions/common/useDebounceFn.ts +27 -0
- package/compositions/common/useDrag.ts +65 -0
- package/compositions/common/useElementSize.ts +37 -0
- package/compositions/common/useEventListener.ts +48 -0
- package/compositions/common/usePopover.ts +45 -0
- package/compositions/common/useResizeObserver.ts +47 -0
- package/compositions/common/useTeleport.ts +24 -0
- package/compositions/contextMenu/index.ts +10 -0
- package/compositions/contextMenu/types.ts +21 -0
- package/compositions/contextMenu/useContextMenu.ts +101 -0
- package/compositions/editor/index.ts +18 -0
- package/compositions/editor/types.ts +147 -0
- package/compositions/editor/useEditor.ts +224 -0
- package/compositions/index.ts +15 -0
- package/compositions/input/__tests__/useBooleanInput.test.ts +73 -0
- package/compositions/input/useBooleanInput.ts +52 -0
- package/compositions/modal/__tests__/useModal.test.ts +110 -0
- package/compositions/modal/useModal.ts +72 -0
- package/compositions/overlay/index.ts +14 -0
- package/compositions/overlay/useOverlayStack.ts +146 -0
- package/compositions/peekView/index.ts +10 -0
- package/compositions/peekView/usePeekView.ts +99 -0
- package/compositions/popper/useClickAway.ts +41 -0
- package/compositions/popper/usePopper.ts +63 -0
- package/compositions/theme/index.ts +17 -0
- package/compositions/theme/presets/compact.ts +117 -0
- package/compositions/theme/presets/dark.ts +113 -0
- package/compositions/theme/presets/index.ts +11 -0
- package/compositions/theme/presets/light.ts +113 -0
- package/compositions/theme/types.ts +46 -0
- package/compositions/theme/useTheme.ts +269 -0
- package/compositions/toast/index.ts +10 -0
- package/compositions/toast/useToast.ts +176 -0
- package/compositions/tooltip/index.ts +9 -0
- package/compositions/tooltip/useTooltip.ts +10 -0
- package/compositions/utils/__tests__/filters.test.ts +136 -0
- package/compositions/utils/filters.ts +135 -0
- package/compositions/virtualList/__tests__/useHeightCache.test.ts +97 -0
- package/compositions/virtualList/enums.ts +52 -0
- package/compositions/virtualList/useContainerObserver.ts +89 -0
- package/compositions/virtualList/useEntries.ts +248 -0
- package/compositions/virtualList/useHeightCache.ts +83 -0
- package/compositions/virtualList/useSentinelObserver.ts +81 -0
- package/dist/components/base/affix/index.d.ts +2 -1
- package/dist/components/base/affix/useAffix.d.ts +7 -5
- package/dist/components/base/anchor/index.d.ts +2 -1
- package/dist/components/base/anchor/useAnchor.d.ts +3 -2
- package/dist/components/base/autoComplete/useAutoComplete.d.ts +14 -5
- package/dist/components/base/avatar/index.d.ts +1 -0
- package/dist/components/base/backTop/index.d.ts +2 -1
- package/dist/components/base/backTop/useBackTop.d.ts +2 -2
- package/dist/components/base/button/index.d.ts +3 -21
- package/dist/components/base/button/useButton.d.ts +5 -2
- package/dist/components/base/carousel/useCarousel.d.ts +7 -3
- package/dist/components/base/cascader/useCascader.d.ts +25 -12
- package/dist/components/base/checkbox/index.d.ts +2 -1
- package/dist/components/base/checkbox/useCheckbox.d.ts +5 -3
- package/dist/components/base/collapse/index.d.ts +2 -1
- package/dist/components/base/collapse/useCollapse.d.ts +4 -3
- package/dist/components/base/datePicker/__tests__/useDatePicker.test.d.ts +1 -0
- package/dist/components/base/datePicker/useDatePicker.d.ts +140 -8
- package/dist/components/base/dropdown/index.d.ts +2 -1
- package/dist/components/base/dropdown/useDropdown.d.ts +13 -6
- package/dist/components/base/image/__tests__/useImage.test.d.ts +1 -0
- package/dist/components/base/image/useImage.d.ts +5 -5
- package/dist/components/base/input/index.d.ts +2 -1
- package/dist/components/base/input/useInput.d.ts +4 -2
- package/dist/components/base/inputNumber/__tests__/useInputNumber.test.d.ts +1 -0
- package/dist/components/base/inputNumber/index.d.ts +2 -1
- package/dist/components/base/inputNumber/useInputNumber.d.ts +4 -3
- package/dist/components/base/li/index.d.ts +1 -0
- package/dist/components/base/list/index.d.ts +2 -1
- package/dist/components/base/list/useList.d.ts +1 -1
- package/dist/components/base/popover/index.d.ts +2 -1
- package/dist/components/base/popover/usePopover.d.ts +10 -9
- package/dist/components/base/progress/index.d.ts +2 -1
- package/dist/components/base/progress/useProgress.d.ts +2 -2
- package/dist/components/base/rate/index.d.ts +2 -1
- package/dist/components/base/rate/useRate.d.ts +3 -2
- package/dist/components/base/select/useSelect.d.ts +10 -9
- package/dist/components/base/slider/index.d.ts +2 -1
- package/dist/components/base/slider/useSlider.d.ts +5 -4
- package/dist/components/base/steps/__tests__/useSteps.test.d.ts +1 -0
- package/dist/components/base/steps/index.d.ts +1 -1
- package/dist/components/base/steps/useSteps.d.ts +5 -5
- package/dist/components/base/switch/index.d.ts +2 -1
- package/dist/components/base/switch/useSwitch.d.ts +9 -3
- package/dist/components/base/tabs/index.d.ts +1 -1
- package/dist/components/base/tabs/useTabs.d.ts +4 -3
- package/dist/components/base/tag/index.d.ts +1 -0
- package/dist/components/base/timePicker/__tests__/useTimePicker.test.d.ts +1 -0
- package/dist/components/base/timePicker/useTimePicker.d.ts +14 -6
- package/dist/components/base/tooltip/index.d.ts +2 -1
- package/dist/components/base/tooltip/useTooltip.d.ts +24 -11
- package/dist/components/base/transfer/useTransfer.d.ts +17 -16
- package/dist/components/base/tree/__tests__/tree.test.d.ts +1 -0
- package/dist/components/base/tree/index.d.ts +1 -1
- package/dist/components/base/tree/useTree.d.ts +2 -1
- package/dist/components/message/drawer/index.d.ts +2 -2
- package/dist/components/message/message/useMessage.d.ts +11 -1
- package/dist/components/message/notification/__tests__/useNotification.test.d.ts +1 -0
- package/dist/components/message/notification/useNotification.d.ts +17 -1
- package/dist/components/message/popover/MPopover.d.ts +6 -1
- package/dist/components/message/popover/index.d.ts +1 -1
- package/dist/components/message/popover/usePopover.d.ts +7 -7
- package/dist/components/other/darkMode/useDarkMode.d.ts +3 -4
- package/dist/components/template/menu/__tests__/useMenu.test.d.ts +1 -0
- package/dist/components/template/menu/index.d.ts +0 -1
- package/dist/components/template/menu/useMenu.d.ts +2 -1
- package/dist/components/template/pagination/__tests__/usePagination.test.d.ts +1 -0
- package/dist/components/template/pagination/index.d.ts +2 -1
- package/dist/components/template/table/__tests__/useTable.test.d.ts +1 -0
- package/dist/components/template/virtualList/index.d.ts +0 -1
- package/dist/components/template/virtualList/useVirtualList.d.ts +10 -7
- package/dist/compositions/commandPalette/index.d.ts +11 -0
- package/dist/compositions/commandPalette/types.d.ts +20 -0
- package/dist/compositions/commandPalette/useCommandPalette.d.ts +32 -0
- package/dist/compositions/common/__tests__/useDebounceFn.test.d.ts +1 -0
- package/dist/compositions/common/__tests__/useEventListener.test.d.ts +1 -0
- package/dist/compositions/common/__tests__/usePopover.test.d.ts +1 -0
- package/dist/compositions/common/__tests__/useTeleport.test.d.ts +1 -0
- package/dist/compositions/common/testAnchor.d.ts +40 -0
- package/dist/compositions/common/useComponentSize.d.ts +6 -0
- package/dist/compositions/common/useDrag.d.ts +1 -1
- package/dist/compositions/common/useElementSize.d.ts +2 -2
- package/dist/compositions/common/useEventListener.d.ts +2 -2
- package/dist/compositions/common/useTeleport.d.ts +4 -2
- package/dist/compositions/contextMenu/index.d.ts +10 -0
- package/dist/compositions/contextMenu/types.d.ts +12 -0
- package/dist/compositions/contextMenu/useContextMenu.d.ts +52 -0
- package/dist/compositions/editor/index.d.ts +10 -0
- package/dist/compositions/editor/types.d.ts +132 -0
- package/dist/compositions/editor/useEditor.d.ts +13 -0
- package/dist/compositions/index.d.ts +15 -0
- package/dist/compositions/input/__tests__/useBooleanInput.test.d.ts +1 -0
- package/dist/compositions/modal/__tests__/useModal.test.d.ts +1 -0
- package/dist/compositions/modal/useModal.d.ts +3 -2
- package/dist/compositions/overlay/index.d.ts +10 -0
- package/dist/compositions/overlay/useOverlayStack.d.ts +188 -0
- package/dist/compositions/peekView/index.d.ts +10 -0
- package/dist/compositions/peekView/usePeekView.d.ts +16 -0
- package/dist/compositions/popper/useClickAway.d.ts +3 -3
- package/dist/compositions/theme/index.d.ts +11 -0
- package/dist/compositions/theme/presets/compact.d.ts +6 -0
- package/dist/compositions/theme/presets/dark.d.ts +2 -0
- package/dist/compositions/theme/presets/index.d.ts +11 -0
- package/dist/compositions/theme/presets/light.d.ts +2 -0
- package/dist/compositions/theme/types.d.ts +41 -0
- package/dist/compositions/theme/useTheme.d.ts +167 -0
- package/dist/compositions/toast/index.d.ts +10 -0
- package/dist/compositions/toast/useToast.d.ts +71 -0
- package/dist/compositions/tooltip/index.d.ts +9 -0
- package/dist/compositions/tooltip/useTooltip.d.ts +10 -0
- package/dist/compositions/utils/__tests__/filters.test.d.ts +1 -0
- package/dist/compositions/virtualList/__tests__/useHeightCache.test.d.ts +1 -0
- package/dist/core.js +7050 -4188
- package/dist/index.d.ts +1 -0
- package/dist/runtime/defineHook.d.ts +1 -1
- package/dist/tools/__tests__/empty.test.d.ts +1 -0
- package/dist/tools/empty.d.ts +2 -2
- package/dist/tools/types.d.ts +1 -1
- package/dist/vitest.config.d.ts +10 -0
- package/index.css +1 -0
- package/index.ts +73 -0
- package/package.json +41 -22
- package/runtime/defineHook.ts +21 -0
- package/tools/__tests__/empty.test.ts +91 -0
- package/tools/empty.ts +81 -0
- package/tools/index.ts +15 -0
- package/tools/types.ts +11 -0
- package/tsconfig.json +8 -0
- package/types/common/common.d.ts +25 -0
- package/types/common/model.d.ts +25 -0
- package/types/index.d.ts +11 -0
- package/types/props.d.ts +13 -0
- package/vite.config.build.ts +41 -0
- package/vitest.config.ts +17 -0
- package/dist/vite.config.build.d.ts +0 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description skeleton api
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO } from '../../types/props';
|
|
10
|
+
import { SkeletonProps } from './props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<SkeletonProps> = {
|
|
13
|
+
loading: { type: Boolean, default: true },
|
|
14
|
+
rows: { type: Number, default: 3 },
|
|
15
|
+
animated: { type: Boolean, default: true },
|
|
16
|
+
avatar: { type: Boolean, default: false },
|
|
17
|
+
title: { type: Boolean, default: true },
|
|
18
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description skeleton core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
|
|
11
|
+
export const SkeletonCore = {
|
|
12
|
+
props,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { SkeletonProps } from './props';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description skeleton api type
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export declare type SkeletonProps = {
|
|
11
|
+
/**
|
|
12
|
+
* @description 是否显示骨架屏(true=显示骨架,false=显示真实内容)
|
|
13
|
+
* @type boolean
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
loading?: boolean,
|
|
17
|
+
/**
|
|
18
|
+
* @description 文本行数
|
|
19
|
+
* @type number
|
|
20
|
+
* @default 3
|
|
21
|
+
*/
|
|
22
|
+
rows?: number,
|
|
23
|
+
/**
|
|
24
|
+
* @description 是否开启脉冲动画
|
|
25
|
+
* @type boolean
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
animated?: boolean,
|
|
29
|
+
/**
|
|
30
|
+
* @description 是否显示头像占位圆
|
|
31
|
+
* @type boolean
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
avatar?: boolean,
|
|
35
|
+
/**
|
|
36
|
+
* @description 是否显示标题占位条(较宽)
|
|
37
|
+
* @type boolean
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
title?: boolean,
|
|
41
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description slider 运行时 props
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25 00:00
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { SliderProps } from './props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<SliderProps> = {
|
|
13
|
+
modelValue: { type: Number, default: 0 },
|
|
14
|
+
min: { type: Number, default: 0 },
|
|
15
|
+
max: { type: Number, default: 100 },
|
|
16
|
+
step: { type: Number, default: 1 },
|
|
17
|
+
disabled: { type: Boolean, default: false },
|
|
18
|
+
showInfo: { type: Boolean, default: false },
|
|
19
|
+
showStops: { type: Boolean, default: false },
|
|
20
|
+
readonly: { type: Boolean, default: false },
|
|
21
|
+
size: { type: String as unknown as MPropType<NonNullable<SliderProps['size']>>, default: undefined },
|
|
22
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description slider core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25 00:00
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
import { useSlider } from './useSlider';
|
|
11
|
+
|
|
12
|
+
export const SliderCore = {
|
|
13
|
+
props,
|
|
14
|
+
useSlider,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { SliderProps } from './props';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description slider 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25 00:00
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* @name m-slider
|
|
8
|
+
* @docDescription Slider component.
|
|
9
|
+
* 滑动条组件。
|
|
10
|
+
* @docUrl https://shuimo.design/slider
|
|
11
|
+
*
|
|
12
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { KineSize } from '../../types/props';
|
|
16
|
+
|
|
17
|
+
export declare type SliderProps = {
|
|
18
|
+
/**
|
|
19
|
+
* @description slider value
|
|
20
|
+
* 滑动条绑定值
|
|
21
|
+
* @type number
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
modelValue?: number;
|
|
25
|
+
/**
|
|
26
|
+
* @description slider min
|
|
27
|
+
* 滑动条最小值
|
|
28
|
+
* @type number
|
|
29
|
+
* @default 0
|
|
30
|
+
*/
|
|
31
|
+
min?: number;
|
|
32
|
+
/**
|
|
33
|
+
* @description slider max
|
|
34
|
+
* 滑动条最大值
|
|
35
|
+
* @type number
|
|
36
|
+
* @default 100
|
|
37
|
+
*/
|
|
38
|
+
max?: number;
|
|
39
|
+
/**
|
|
40
|
+
* @description slider step
|
|
41
|
+
* 滑动条步长
|
|
42
|
+
* @type number
|
|
43
|
+
* @default 1
|
|
44
|
+
*/
|
|
45
|
+
step?: number;
|
|
46
|
+
/**
|
|
47
|
+
* @description slider disabled
|
|
48
|
+
* 是否禁用
|
|
49
|
+
* @type boolean
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @description slider show-info
|
|
55
|
+
* 是否显示信息
|
|
56
|
+
* @type boolean
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
showInfo?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* @description slider show-stops
|
|
62
|
+
* 是否显示刻度点
|
|
63
|
+
* @type boolean
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
showStops?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* @description slider readonly. 是否只读
|
|
69
|
+
* @type boolean
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
readonly?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* @description 尺寸
|
|
75
|
+
* @type KineSize
|
|
76
|
+
* @default undefined
|
|
77
|
+
*/
|
|
78
|
+
size?: KineSize;
|
|
79
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description slider composable
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25 00:00
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { onMounted, ref } from 'vue';
|
|
10
|
+
import { SliderProps } from './props';
|
|
11
|
+
import { useElementSize } from '../../../compositions/common/useElementSize.ts';
|
|
12
|
+
import useDrag, { DragOption, DragPosition, InteractEvent } from '../../../compositions/common/useDrag.ts';
|
|
13
|
+
import { type HookContext } from '../../types/hook';
|
|
14
|
+
|
|
15
|
+
export function useSlider(props: Required<SliderProps>, ctx: HookContext) {
|
|
16
|
+
const sliderRef = ref<HTMLElement | null>(null);
|
|
17
|
+
const sliderSize = useElementSize(sliderRef);
|
|
18
|
+
|
|
19
|
+
const perRef = ref(0);
|
|
20
|
+
|
|
21
|
+
const option: DragOption = { startAxis: 'x', lockAxis: 'x' };
|
|
22
|
+
|
|
23
|
+
// 按钮宽度固定值,用于计算可拖拽区域
|
|
24
|
+
const btnW = 20;
|
|
25
|
+
|
|
26
|
+
const sub = props.max - props.min;
|
|
27
|
+
|
|
28
|
+
// 处理拖拽移动,计算并约束位置,更新百分比
|
|
29
|
+
const movePositionHandler = (event: InteractEvent, position: DragPosition): DragPosition => {
|
|
30
|
+
if (props.readonly) {
|
|
31
|
+
return position;
|
|
32
|
+
}
|
|
33
|
+
const totalW = sliderSize.w.value - btnW;
|
|
34
|
+
|
|
35
|
+
let positionX = position.x + event.dx;
|
|
36
|
+
if (positionX > totalW) {
|
|
37
|
+
positionX = totalW;
|
|
38
|
+
} else if (positionX < 0) {
|
|
39
|
+
positionX = 0;
|
|
40
|
+
}
|
|
41
|
+
perRef.value = positionX / totalW;
|
|
42
|
+
ctx.emit('update:modelValue', getValue());
|
|
43
|
+
return { x: positionX > 0 ? positionX : 0, y: 0 };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// 根据当前百分比和 step 计算实际 value
|
|
47
|
+
const getValue = () => {
|
|
48
|
+
const addStep = Math.round(perRef.value * sub / props.step) * props.step;
|
|
49
|
+
return props.min + addStep;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const { init: initDrag, domRef: btnRef } = useDrag({
|
|
53
|
+
direction: 'top-right',
|
|
54
|
+
event: {
|
|
55
|
+
getOption: () => option,
|
|
56
|
+
movePositionHandler,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// 根据当前 modelValue 初始化按钮位置
|
|
61
|
+
const init = () => {
|
|
62
|
+
if (btnRef.value) {
|
|
63
|
+
const { max, min, modelValue } = props;
|
|
64
|
+
const per = (modelValue - min) / (max - min);
|
|
65
|
+
if (window && sliderRef.value) {
|
|
66
|
+
const w = Number.parseFloat(window.getComputedStyle(sliderRef.value).width);
|
|
67
|
+
|
|
68
|
+
const totalW = w - btnW;
|
|
69
|
+
perRef.value = per;
|
|
70
|
+
const x = per * totalW;
|
|
71
|
+
btnRef.value.style.transform = `translate(${x}px, 0)`;
|
|
72
|
+
|
|
73
|
+
initDrag({ x });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
init();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
btnRef,
|
|
84
|
+
sliderRef,
|
|
85
|
+
perRef,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description space api
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { SpaceProps } from './props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<SpaceProps> = {
|
|
13
|
+
direction: { type: String as MPropType<'horizontal' | 'vertical'>, default: 'horizontal' },
|
|
14
|
+
size: { type: [String, Number] as MPropType<'small' | 'medium' | 'large' | number>, default: 'medium' },
|
|
15
|
+
wrap: { type: Boolean, default: false },
|
|
16
|
+
align: { type: String as MPropType<'start' | 'center' | 'end' | 'baseline'>, default: 'center' },
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description space core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
|
|
11
|
+
export const SpaceCore = {
|
|
12
|
+
props,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { SpaceProps } from './props';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description space api type
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* @name m-space
|
|
8
|
+
* @docDescription Space component with shuimo-ui style.
|
|
9
|
+
* 水墨组件的间距组件。
|
|
10
|
+
*
|
|
11
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export declare type SpaceProps = {
|
|
15
|
+
/**
|
|
16
|
+
* @description 排列方向
|
|
17
|
+
* @type 'horizontal' | 'vertical'
|
|
18
|
+
* @default 'horizontal'
|
|
19
|
+
*/
|
|
20
|
+
direction?: 'horizontal' | 'vertical';
|
|
21
|
+
/**
|
|
22
|
+
* @description 间距大小,支持预设或数字(px)
|
|
23
|
+
* @type 'small' | 'medium' | 'large' | number
|
|
24
|
+
* @default 'medium'
|
|
25
|
+
*/
|
|
26
|
+
size?: 'small' | 'medium' | 'large' | number;
|
|
27
|
+
/**
|
|
28
|
+
* @description 是否自动换行(仅水平方向有效)
|
|
29
|
+
* @type boolean
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
wrap?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @description 交叉轴对齐方式
|
|
35
|
+
* @type 'start' | 'center' | 'end' | 'baseline'
|
|
36
|
+
* @default 'center'
|
|
37
|
+
*/
|
|
38
|
+
align?: 'start' | 'center' | 'end' | 'baseline';
|
|
39
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description resolveStepStatus 测试
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/3/23
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { describe, expect, it } from 'vitest';
|
|
10
|
+
import { resolveStepStatus, type StepsContext } from '../useSteps';
|
|
11
|
+
|
|
12
|
+
const createCtx = (active: number): StepsContext => ({
|
|
13
|
+
active,
|
|
14
|
+
finishStatus: 'finish',
|
|
15
|
+
processStatus: 'process',
|
|
16
|
+
total: 4,
|
|
17
|
+
direction: 'horizontal',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('resolveStepStatus', () => {
|
|
21
|
+
it('显式状态优先', () => {
|
|
22
|
+
expect(resolveStepStatus(0, 'error', createCtx(2))).toBe('error');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('index < active 返回 finishStatus', () => {
|
|
26
|
+
expect(resolveStepStatus(0, undefined, createCtx(2))).toBe('finish');
|
|
27
|
+
expect(resolveStepStatus(1, undefined, createCtx(2))).toBe('finish');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('index === active 返回 processStatus', () => {
|
|
31
|
+
expect(resolveStepStatus(2, undefined, createCtx(2))).toBe('process');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('index > active 返回 wait', () => {
|
|
35
|
+
expect(resolveStepStatus(3, undefined, createCtx(2))).toBe('wait');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('active=0 时第一步为 process', () => {
|
|
39
|
+
expect(resolveStepStatus(0, undefined, createCtx(0))).toBe('process');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('自定义 finishStatus=success', () => {
|
|
43
|
+
const ctx = { ...createCtx(2), finishStatus: 'success' as const };
|
|
44
|
+
expect(resolveStepStatus(0, undefined, ctx)).toBe('success');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description steps runtime props 定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { StepsProps, StepProps, StepsDirection, StepStatus } from './props';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Steps 容器组件运行时 props
|
|
14
|
+
*/
|
|
15
|
+
export const stepsProps: MCOPO<StepsProps> = {
|
|
16
|
+
active: { type: Number, default: 0 },
|
|
17
|
+
direction: { type: String as MPropType<StepsDirection>, default: 'horizontal' },
|
|
18
|
+
finishStatus: { type: String as MPropType<'success' | 'finish'>, default: 'finish' },
|
|
19
|
+
processStatus: { type: String as MPropType<'process' | 'finish'>, default: 'process' },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Step 单个步骤组件运行时 props
|
|
24
|
+
*/
|
|
25
|
+
export const stepProps: MCOPO<StepProps> = {
|
|
26
|
+
title: { type: String, required: true },
|
|
27
|
+
description: { type: String, default: '' },
|
|
28
|
+
icon: { type: String, default: '' },
|
|
29
|
+
status: { type: String as MPropType<StepStatus>, default: undefined },
|
|
30
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description steps core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { stepsProps, stepProps } from './api';
|
|
10
|
+
import { useSteps, useStep, stepsContextKey, resolveStepStatus } from './useSteps';
|
|
11
|
+
|
|
12
|
+
export const StepsCore = {
|
|
13
|
+
stepsProps,
|
|
14
|
+
stepProps,
|
|
15
|
+
useSteps,
|
|
16
|
+
useStep,
|
|
17
|
+
stepsContextKey,
|
|
18
|
+
resolveStepStatus,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type { StepsProps, StepProps, StepItem, StepStatus, StepsDirection } from './props';
|
|
22
|
+
export type { StepsContext } from './useSteps';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description steps 组件 props 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 步骤状态类型
|
|
12
|
+
*/
|
|
13
|
+
export type StepStatus = 'wait' | 'process' | 'finish' | 'error';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 步骤条方向
|
|
17
|
+
*/
|
|
18
|
+
export type StepsDirection = 'horizontal' | 'vertical';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 单个步骤数据(用于数据驱动模式)
|
|
22
|
+
*/
|
|
23
|
+
export declare type StepItem = {
|
|
24
|
+
/**
|
|
25
|
+
* @description 步骤标题
|
|
26
|
+
*/
|
|
27
|
+
title: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description 步骤描述
|
|
30
|
+
*/
|
|
31
|
+
description?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @description 自定义图标
|
|
34
|
+
*/
|
|
35
|
+
icon?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description 强制指定步骤状态,不指定时由 active 自动推算
|
|
38
|
+
*/
|
|
39
|
+
status?: StepStatus;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Steps 容器组件 props
|
|
44
|
+
*/
|
|
45
|
+
export declare type StepsProps = {
|
|
46
|
+
/**
|
|
47
|
+
* @description 当前激活步骤(从 0 开始)
|
|
48
|
+
* @default 0
|
|
49
|
+
*/
|
|
50
|
+
active?: number;
|
|
51
|
+
/**
|
|
52
|
+
* @description 步骤条方向
|
|
53
|
+
* @default 'horizontal'
|
|
54
|
+
*/
|
|
55
|
+
direction?: StepsDirection;
|
|
56
|
+
/**
|
|
57
|
+
* @description 已完成步骤的状态
|
|
58
|
+
* @default 'finish'
|
|
59
|
+
*/
|
|
60
|
+
finishStatus?: 'success' | 'finish';
|
|
61
|
+
/**
|
|
62
|
+
* @description 当前步骤的状态
|
|
63
|
+
* @default 'process'
|
|
64
|
+
*/
|
|
65
|
+
processStatus?: 'process' | 'finish';
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Step 单个步骤组件 props
|
|
70
|
+
*/
|
|
71
|
+
export declare type StepProps = {
|
|
72
|
+
/**
|
|
73
|
+
* @description 步骤标题
|
|
74
|
+
*/
|
|
75
|
+
title: string;
|
|
76
|
+
/**
|
|
77
|
+
* @description 步骤描述
|
|
78
|
+
*/
|
|
79
|
+
description?: string;
|
|
80
|
+
/**
|
|
81
|
+
* @description 自定义图标
|
|
82
|
+
*/
|
|
83
|
+
icon?: string;
|
|
84
|
+
/**
|
|
85
|
+
* @description 强制指定步骤状态,不指定时由父级 Steps 推算
|
|
86
|
+
*/
|
|
87
|
+
status?: StepStatus;
|
|
88
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description steps composable
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { computed, InjectionKey, provide, inject } from 'vue';
|
|
10
|
+
import { StepsProps, StepStatus } from './props';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Steps 向子 Step 注入的上下文结构
|
|
14
|
+
*/
|
|
15
|
+
export interface StepsContext {
|
|
16
|
+
/** 当前激活步骤索引 */
|
|
17
|
+
active: number;
|
|
18
|
+
/** 已完成步骤状态 */
|
|
19
|
+
finishStatus: 'success' | 'finish';
|
|
20
|
+
/** 当前步骤状态 */
|
|
21
|
+
processStatus: 'process' | 'finish';
|
|
22
|
+
/** 步骤总数(由子步骤注册后更新) */
|
|
23
|
+
total: number;
|
|
24
|
+
/** 方向 */
|
|
25
|
+
direction: 'horizontal' | 'vertical';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 注入键 */
|
|
29
|
+
export const stepsContextKey: InjectionKey<StepsContext> = Symbol('stepsContext');
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Steps 容器 composable
|
|
33
|
+
* 负责将当前激活状态通过 provide 下发给 MStep 子组件
|
|
34
|
+
*/
|
|
35
|
+
export function useSteps(props: StepsProps) {
|
|
36
|
+
const context: StepsContext = {
|
|
37
|
+
get active() { return props.active ?? 0; },
|
|
38
|
+
get finishStatus() { return props.finishStatus ?? 'finish'; },
|
|
39
|
+
get processStatus() { return props.processStatus ?? 'process'; },
|
|
40
|
+
get direction() { return props.direction ?? 'horizontal'; },
|
|
41
|
+
total: 0,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
provide(stepsContextKey, context);
|
|
45
|
+
|
|
46
|
+
/** 容器 class 列表 */
|
|
47
|
+
const stepsClass = computed(() => [
|
|
48
|
+
'm-steps',
|
|
49
|
+
`m-steps-${props.direction ?? 'horizontal'}`,
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
return { stepsClass, context };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 根据步骤索引和父级上下文推算当前步骤状态
|
|
57
|
+
* @param index 当前步骤序号(从 0 开始)
|
|
58
|
+
* @param overrideStatus 显式指定的状态,优先级最高
|
|
59
|
+
* @param ctx 父级 Steps 上下文
|
|
60
|
+
*/
|
|
61
|
+
export function resolveStepStatus(
|
|
62
|
+
index: number,
|
|
63
|
+
overrideStatus: StepStatus | undefined,
|
|
64
|
+
ctx: StepsContext,
|
|
65
|
+
): StepStatus {
|
|
66
|
+
// 显式指定时直接使用
|
|
67
|
+
if (overrideStatus) return overrideStatus;
|
|
68
|
+
|
|
69
|
+
const active = ctx.active;
|
|
70
|
+
if (index < active) return ctx.finishStatus as StepStatus;
|
|
71
|
+
if (index === active) return ctx.processStatus as StepStatus;
|
|
72
|
+
return 'wait';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Step 单个步骤 composable
|
|
77
|
+
* 从父级注入 StepsContext,计算当前步骤的状态与样式类
|
|
78
|
+
*/
|
|
79
|
+
export function useStep(index: number, overrideStatus?: StepStatus) {
|
|
80
|
+
const ctx = inject(stepsContextKey, null);
|
|
81
|
+
|
|
82
|
+
const status = computed<StepStatus>(() => {
|
|
83
|
+
if (!ctx) {
|
|
84
|
+
// 未嵌套在 Steps 中时默认为 wait
|
|
85
|
+
return overrideStatus ?? 'wait';
|
|
86
|
+
}
|
|
87
|
+
return resolveStepStatus(index, overrideStatus, ctx);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const stepClass = computed(() => [
|
|
91
|
+
'm-step',
|
|
92
|
+
`m-step-${status.value}`,
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
const isLast = computed(() => {
|
|
96
|
+
if (!ctx) return true;
|
|
97
|
+
return index >= ctx.total - 1;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return { status, stepClass, isLast, ctx };
|
|
101
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description switch api
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2023/4/23 11:52
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO } from '../../types/props';
|
|
10
|
+
import { SwitchProps } from './props';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export const props: MCOPO<SwitchProps> = {
|
|
14
|
+
modelValue: { type: undefined, required: true },
|
|
15
|
+
disabled: { type: Boolean, default: false },
|
|
16
|
+
loading: { type: Boolean, default: false },
|
|
17
|
+
activeInfo: { type: String, default: '' },
|
|
18
|
+
inactiveInfo: { type: String, default: '' },
|
|
19
|
+
activeValue: { type: undefined, default: undefined },
|
|
20
|
+
inactiveValue: { type: undefined, default: undefined },
|
|
21
|
+
onControl: { type: Boolean, default: false },
|
|
22
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2025/1/13 10:35
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
import { useSwitch, getIsActive, switchIsBoolean } from './useSwitch';
|
|
11
|
+
|
|
12
|
+
export const SwitchCore = {
|
|
13
|
+
props,
|
|
14
|
+
switchIsBoolean,
|
|
15
|
+
getIsActive,
|
|
16
|
+
useSwitch,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type { SwitchProps } from './props';
|