@unicom-cloud/ui-common 0.1.46 → 0.1.47
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/.virtual/_rolldown/runtime.js +3 -1
- package/animation/Animation.d.ts +2 -1
- package/animation/Animation.js +30 -28
- package/animation/constants.js +3 -1
- package/animation/context.js +3 -1
- package/animation/index.d.ts +4 -0
- package/animation/index.js +5 -3
- package/animation/style/index.js +3 -1
- package/animation/utils.js +3 -1
- package/base/Base.js +3 -1
- package/base/constants.js +3 -1
- package/base/context.js +3 -1
- package/base/index.d.ts +0 -1
- package/base/index.js +3 -1
- package/base/style/index.js +3 -1
- package/base/utils.js +3 -1
- package/border-beam/BorderBeam.d.ts +2 -0
- package/border-beam/BorderBeam.js +37 -31
- package/border-beam/Effect.js +3 -1
- package/border-beam/constants.js +3 -1
- package/border-beam/context.js +3 -1
- package/border-beam/hooks/useBorderSize.js +3 -1
- package/border-beam/hooks/useChildDom.js +10 -8
- package/border-beam/index.d.ts +4 -0
- package/border-beam/index.js +4 -2
- package/border-beam/style/index.js +3 -1
- package/border-beam/utils.js +4 -2
- package/development/Development.d.ts +2 -1
- package/development/Development.js +24 -16
- package/development/constants.js +3 -1
- package/development/context.js +3 -1
- package/development/index.d.ts +4 -1
- package/development/index.js +4 -2
- package/development/style/index.js +3 -1
- package/development/utils.js +3 -1
- package/empty/Empty.d.ts +2 -2
- package/empty/Empty.js +20 -13
- package/empty/constants.js +3 -1
- package/empty/context.js +3 -1
- package/empty/index.d.ts +4 -1
- package/empty/index.js +5 -3
- package/empty/style/index.js +3 -1
- package/empty/utils.js +3 -1
- package/flex/Flex.d.ts +3 -8
- package/flex/Flex.js +45 -42
- package/flex/FlexVertical.d.ts +10 -0
- package/flex/FlexVertical.js +19 -0
- package/flex/constants.js +3 -1
- package/flex/context.js +3 -1
- package/flex/index.d.ts +9 -4
- package/flex/index.js +8 -5
- package/flex/interface.d.ts +14 -7
- package/flex/style/index.js +3 -1
- package/flex/utils.d.ts +7 -3
- package/flex/utils.js +27 -18
- package/globe/Globe.d.ts +10 -0
- package/globe/Globe.js +140 -0
- package/globe/constants.d.ts +0 -0
- package/globe/constants.js +4 -0
- package/globe/context.d.ts +3 -0
- package/globe/context.js +26 -0
- package/globe/globe.json.js +42585 -0
- package/globe/hooks/index.d.ts +0 -0
- package/globe/index.d.ts +19 -0
- package/globe/index.js +15 -0
- package/globe/interface.d.ts +46 -0
- package/globe/style/index.css +1 -0
- package/globe/style/index.d.ts +1 -0
- package/globe/style/index.js +5 -0
- package/globe/utils.d.ts +0 -0
- package/globe/utils.js +4 -0
- package/grid/Grid.d.ts +10 -0
- package/grid/Grid.js +58 -0
- package/grid/Item.d.ts +10 -0
- package/grid/Item.js +40 -0
- package/grid/constants.d.ts +0 -0
- package/grid/constants.js +4 -0
- package/grid/context.d.ts +12 -0
- package/grid/context.js +13 -0
- package/grid/hooks/index.d.ts +0 -0
- package/grid/index.d.ts +35 -0
- package/grid/index.js +18 -0
- package/grid/interface.d.ts +89 -0
- package/grid/style/index.css +1 -0
- package/grid/style/index.d.ts +1 -0
- package/grid/style/index.js +5 -0
- package/grid/utils.d.ts +3 -0
- package/grid/utils.js +26 -0
- package/higher-order/index.js +3 -1
- package/higher-order/with-speech-synthesis/context.js +5 -3
- package/higher-order/with-speech-synthesis/index.d.ts +2 -1
- package/higher-order/with-speech-synthesis/index.js +4 -2
- package/higher-order/with-speech-synthesis/style/index.js +3 -1
- package/higher-order/with-speech-synthesis/withSpeechSynthesis.js +62 -57
- package/hoc/withContext.js +3 -1
- package/hooks/create-deep-compare-effect/index.js +8 -6
- package/hooks/create-update-effect/index.js +3 -1
- package/hooks/create-use-storage-state/index.js +24 -22
- package/hooks/index.d.ts +3 -2
- package/hooks/index.js +7 -4
- package/hooks/use-async-effect/index.js +12 -10
- package/hooks/use-boolean/index.js +3 -1
- package/hooks/use-click-away/index.js +3 -1
- package/hooks/use-computed-state/index.js +3 -1
- package/hooks/use-controllable-value/index.js +34 -39
- package/hooks/use-cookie-state/index.js +14 -12
- package/hooks/use-count-down/index.js +9 -7
- package/hooks/use-counter/index.js +16 -14
- package/hooks/use-create/index.js +3 -1
- package/hooks/use-creation/index.js +3 -1
- package/hooks/use-debounce/index.js +3 -1
- package/hooks/use-debounce-effect/index.js +3 -1
- package/hooks/use-debounce-fn/index.js +11 -9
- package/hooks/use-deep-compare-effect/index.js +3 -1
- package/hooks/use-deep-compare-layout-effect/index.js +3 -1
- package/hooks/use-document-visibility/index.js +3 -1
- package/hooks/use-drag/index.js +21 -19
- package/hooks/use-drag-move/index.js +31 -29
- package/hooks/use-drop/index.js +31 -29
- package/hooks/use-effect-event/index.js +3 -1
- package/hooks/use-event/index.js +5 -3
- package/hooks/use-event-emitter/index.js +3 -1
- package/hooks/use-event-listener/index.js +3 -1
- package/hooks/use-event-target/index.js +10 -8
- package/hooks/use-external/index.js +30 -28
- package/hooks/use-favicon/index.js +3 -1
- package/hooks/use-focus-within/index.js +3 -1
- package/hooks/use-force-update/index.js +3 -1
- package/hooks/use-fullscreen/index.js +20 -18
- package/hooks/use-get-state/index.d.ts +1 -1
- package/hooks/use-get-state/index.js +3 -1
- package/hooks/use-history-travel/index.js +23 -21
- package/hooks/use-hover/index.js +3 -1
- package/hooks/use-id/index.js +7 -5
- package/hooks/use-in-viewport/index.js +17 -14
- package/hooks/use-infinite-scroll/index.js +47 -45
- package/hooks/use-intersection-observer/index.js +11 -8
- package/hooks/use-intersection-observers/index.js +22 -20
- package/hooks/use-interval/index.js +9 -7
- package/hooks/use-is-first-render/index.js +3 -1
- package/hooks/use-isomorphic-layout-effect/index.js +3 -1
- package/hooks/use-key-press/index.js +30 -28
- package/hooks/use-keyboard-event/index.js +3 -1
- package/hooks/use-latest/index.js +3 -1
- package/hooks/use-listen-window-resize/index.js +3 -1
- package/hooks/use-local-storage-state/index.js +3 -1
- package/hooks/use-lock-fn/index.js +3 -1
- package/hooks/use-long-press/index.js +3 -1
- package/hooks/use-map/index.js +3 -1
- package/hooks/use-media/index.js +13 -11
- package/hooks/use-memo/index.js +3 -1
- package/hooks/use-memoized-fn/index.js +9 -7
- package/hooks/use-merge-component-props/index.d.ts +14 -0
- package/hooks/use-merge-component-props/index.js +14 -0
- package/hooks/use-merge-value/index.js +13 -11
- package/hooks/use-mobile/index.js +3 -1
- package/hooks/use-mount/index.js +8 -6
- package/hooks/use-mouse/index.js +3 -1
- package/hooks/use-move/index.js +3 -1
- package/hooks/use-mutation-observer/index.js +3 -1
- package/hooks/use-mutation-observers/index.js +22 -20
- package/hooks/use-network/index.js +10 -8
- package/hooks/use-online-status/index.js +3 -1
- package/hooks/use-overflow-hidden/index.js +3 -1
- package/hooks/use-override-ref/index.js +3 -1
- package/hooks/use-pagination/index.js +3 -1
- package/hooks/use-paste-image/index.js +15 -13
- package/hooks/use-persist-callback/index.js +3 -1
- package/hooks/use-prefers-color-scheme-dark/index.js +3 -1
- package/hooks/use-previous/index.js +3 -1
- package/hooks/use-raf-interval/index.js +17 -15
- package/hooks/use-raf-state/index.js +3 -1
- package/hooks/use-raf-timeout/index.js +16 -14
- package/hooks/use-reactive/index.js +26 -24
- package/hooks/use-ref-latest/index.js +3 -1
- package/hooks/use-ref-map/index.d.ts +3 -0
- package/hooks/use-ref-map/index.js +14 -0
- package/hooks/use-refs/index.d.ts +1 -2
- package/hooks/use-refs/index.js +8 -12
- package/hooks/use-request/index.js +3 -1
- package/hooks/use-request/src/Fetch.js +11 -9
- package/hooks/use-request/src/plugins/useAutoRunPlugin.js +3 -1
- package/hooks/use-request/src/plugins/useCachePlugin.js +3 -1
- package/hooks/use-request/src/plugins/useDebouncePlugin.js +14 -12
- package/hooks/use-request/src/plugins/useLoadingDelayPlugin.js +3 -1
- package/hooks/use-request/src/plugins/usePollingPlugin.js +3 -1
- package/hooks/use-request/src/plugins/useRefreshOnWindowFocusPlugin.js +3 -1
- package/hooks/use-request/src/plugins/useRetryPlugin.js +3 -1
- package/hooks/use-request/src/plugins/useThrottlePlugin.js +7 -5
- package/hooks/use-request/src/useRequest.js +3 -1
- package/hooks/use-request/src/useRequestImplement.js +39 -37
- package/hooks/use-request/src/utils/cache.js +3 -1
- package/hooks/use-request/src/utils/cachePromise.js +3 -1
- package/hooks/use-request/src/utils/cacheSubscribe.js +3 -1
- package/hooks/use-request/src/utils/isDocumentVisible.js +3 -1
- package/hooks/use-request/src/utils/isOnline.js +6 -4
- package/hooks/use-request/src/utils/limit.js +3 -1
- package/hooks/use-request/src/utils/subscribeFocus.js +3 -1
- package/hooks/use-request/src/utils/subscribeReVisible.js +3 -1
- package/hooks/use-reset-state/index.js +9 -7
- package/hooks/use-resize-observer/index.js +3 -1
- package/hooks/use-resize-observers/index.js +22 -20
- package/hooks/use-responsive/index.js +3 -1
- package/hooks/use-safe-state/index.d.ts +1 -1
- package/hooks/use-safe-state/index.js +3 -1
- package/hooks/use-scroll/index.js +3 -1
- package/hooks/use-selections/index.js +21 -19
- package/hooks/use-session-storage-state/index.js +3 -1
- package/hooks/use-set/index.js +3 -1
- package/hooks/use-set-state/index.d.ts +7 -2
- package/hooks/use-set-state/index.js +15 -13
- package/hooks/use-size/index.js +22 -20
- package/hooks/use-state-callback/index.d.ts +2 -2
- package/hooks/use-state-callback/index.js +13 -11
- package/hooks/use-state-with-promise/index.js +15 -13
- package/hooks/use-sync-state/index.d.ts +1 -1
- package/hooks/use-sync-state/index.js +10 -8
- package/hooks/use-text-selection/index.js +3 -1
- package/hooks/use-theme/index.js +3 -1
- package/hooks/use-throttle/index.js +3 -1
- package/hooks/use-throttle-effect/index.js +3 -1
- package/hooks/use-throttle-fn/index.js +11 -9
- package/hooks/use-throttle-fn-with-raf/index.js +14 -12
- package/hooks/use-timeout/index.js +9 -7
- package/hooks/use-title/index.js +3 -1
- package/hooks/use-toggle/index.js +10 -8
- package/hooks/use-tracked-effect/index.js +3 -1
- package/hooks/use-unmount/index.js +10 -8
- package/hooks/use-unmounted-ref/index.js +3 -1
- package/hooks/use-update/index.js +13 -11
- package/hooks/use-update-effect/index.js +3 -1
- package/hooks/use-update-layout-effect/index.js +3 -1
- package/hooks/use-url-state/index.js +11 -9
- package/hooks/use-virtual-list/index.js +35 -33
- package/hooks/use-watch/index.js +9 -7
- package/hooks/use-web-socket/index.js +3 -1
- package/hooks/use-why-did-you-update/index.js +3 -1
- package/hooks/use-window-size/index.js +17 -15
- package/hooks/utils/createEffectWithTarget.js +3 -1
- package/hooks/utils/depsAreSame.js +3 -1
- package/hooks/utils/depsEqual.js +4 -2
- package/hooks/utils/domTarget.js +7 -5
- package/hooks/utils/getDocumentOrShadow.js +3 -1
- package/hooks/utils/index.js +3 -1
- package/hooks/utils/isAppleDevice.js +3 -1
- package/hooks/utils/isBrowser.js +3 -1
- package/hooks/utils/isDev.js +3 -1
- package/hooks/utils/rect.js +3 -1
- package/hooks/utils/useDeepCompareWithTarget.js +3 -1
- package/hooks/utils/useEffectWithTarget.js +3 -1
- package/hooks/utils/useIsomorphicLayoutEffectWithTarget.js +3 -1
- package/hooks/utils/useLayoutEffectWithTarget.js +3 -1
- package/icons/file/File.d.ts +2 -1
- package/icons/file/File.js +39 -34
- package/icons/file/context.js +5 -3
- package/icons/file/index.d.ts +4 -1
- package/icons/file/index.js +4 -2
- package/icons/file/style/index.js +3 -1
- package/index.d.ts +3 -1
- package/index.js +572 -652
- package/liquid-logo/LiquidLogo.d.ts +10 -0
- package/liquid-logo/LiquidLogo.js +122 -0
- package/liquid-logo/constants.d.ts +0 -0
- package/liquid-logo/constants.js +4 -0
- package/liquid-logo/context.d.ts +3 -0
- package/liquid-logo/context.js +17 -0
- package/liquid-logo/hooks/index.d.ts +0 -0
- package/liquid-logo/index.d.ts +21 -0
- package/liquid-logo/index.js +17 -0
- package/liquid-logo/interface.d.ts +12 -0
- package/liquid-logo/parseLogoImage.d.ts +4 -0
- package/liquid-logo/parseLogoImage.js +77 -0
- package/liquid-logo/shader.d.ts +2 -0
- package/liquid-logo/shader.js +8 -0
- package/liquid-logo/style/index.d.ts +1 -0
- package/liquid-logo/style/index.js +5 -0
- package/liquid-logo/utils.d.ts +0 -0
- package/liquid-logo/utils.js +4 -0
- package/morphicons/adapters/canvas.d.ts +43 -0
- package/morphicons/adapters/index.d.ts +3 -0
- package/morphicons/adapters/mask.d.ts +42 -0
- package/morphicons/adapters/svg.d.ts +8 -0
- package/morphicons/core/interpolate.d.ts +6 -0
- package/morphicons/core/interpolate.js +29 -0
- package/morphicons/core/normalize.d.ts +16 -0
- package/morphicons/core/normalize.js +166 -0
- package/morphicons/core/parse.d.ts +27 -0
- package/morphicons/core/parse.js +131 -0
- package/morphicons/core/plan.d.ts +64 -0
- package/morphicons/core/plan.js +198 -0
- package/morphicons/core/resample.d.ts +18 -0
- package/morphicons/core/resample.js +132 -0
- package/morphicons/core/serialize.d.ts +7 -0
- package/morphicons/core/serialize.js +32 -0
- package/morphicons/core/spring.d.ts +30 -0
- package/morphicons/core/spring.js +39 -0
- package/morphicons/core/types.d.ts +27 -0
- package/morphicons/dom/controller.d.ts +53 -0
- package/morphicons/dom/index.d.ts +46 -0
- package/morphicons/element/index.d.ts +39 -0
- package/morphicons/index.d.ts +7 -0
- package/morphicons/index.js +11 -0
- package/morphicons/react/index.d.ts +36 -0
- package/package.json +1 -1
- package/progress/Progress.js +24 -22
- package/progress/constants.js +3 -1
- package/progress/context.d.ts +0 -0
- package/progress/context.js +4 -0
- package/progress/index.js +3 -1
- package/progress/style/index.js +3 -1
- package/progress/utils.js +3 -1
- package/resize-observer/Collection.js +3 -1
- package/resize-observer/ResizeObserver.d.ts +2 -0
- package/resize-observer/ResizeObserver.js +23 -16
- package/resize-observer/SingleObserver.js +35 -33
- package/resize-observer/constants.js +3 -1
- package/resize-observer/context.js +3 -1
- package/resize-observer/index.d.ts +4 -1
- package/resize-observer/index.js +4 -2
- package/resize-observer/observerUtil.js +3 -1
- package/resize-observer/style/index.js +3 -1
- package/resize-observer/utils.js +3 -1
- package/space/Space.d.ts +3 -8
- package/space/Space.js +60 -51
- package/space/SpaceVertical.d.ts +10 -0
- package/space/SpaceVertical.js +16 -0
- package/space/constants.js +3 -1
- package/space/context.js +3 -1
- package/space/index.d.ts +7 -2
- package/space/index.js +6 -3
- package/space/interface.d.ts +3 -25
- package/space/style/index.js +3 -1
- package/space/utils.js +3 -1
- package/splash-cursor/FluidCursor.d.ts +2 -0
- package/splash-cursor/FluidCursor.js +9 -0
- package/splash-cursor/SplashCursor.d.ts +10 -0
- package/splash-cursor/SplashCursor.js +437 -0
- package/splash-cursor/constants.d.ts +0 -0
- package/splash-cursor/constants.js +4 -0
- package/splash-cursor/context.d.ts +3 -0
- package/splash-cursor/context.js +9 -0
- package/splash-cursor/hooks/index.d.ts +0 -0
- package/splash-cursor/index.d.ts +21 -0
- package/splash-cursor/index.js +16 -0
- package/splash-cursor/interface.d.ts +59 -0
- package/splash-cursor/style/index.css +1 -0
- package/splash-cursor/style/index.d.ts +1 -0
- package/splash-cursor/style/index.js +5 -0
- package/splash-cursor/utils.d.ts +2 -0
- package/splash-cursor/utils.js +25 -0
- package/style/global.less +22 -1
- package/style.css +1 -1
- package/suspense-fallback-test/SuspenseFallbackTest.d.ts +2 -0
- package/suspense-fallback-test/SuspenseFallbackTest.js +11 -4
- package/suspense-fallback-test/constants.js +3 -1
- package/suspense-fallback-test/context.js +3 -1
- package/suspense-fallback-test/index.d.ts +4 -1
- package/suspense-fallback-test/index.js +4 -2
- package/suspense-fallback-test/style/index.js +3 -1
- package/suspense-fallback-test/utils.js +3 -1
- package/test.js +3 -1
- package/timer/Timer.d.ts +2 -0
- package/timer/Timer.js +23 -17
- package/timer/constants.js +3 -1
- package/timer/context.js +3 -1
- package/timer/index.d.ts +4 -1
- package/timer/index.js +4 -2
- package/timer/style/index.js +3 -1
- package/timer/utils.js +3 -1
- package/transition/Transition.d.ts +2 -1
- package/transition/Transition.js +77 -67
- package/transition/TransitionCSS.d.ts +2 -1
- package/transition/TransitionCSS.js +28 -26
- package/transition/TransitionGroup.d.ts +2 -1
- package/transition/TransitionGroup.js +38 -36
- package/transition/TransitionStyle.d.ts +2 -1
- package/transition/TransitionStyle.js +22 -20
- package/transition/constants.js +3 -1
- package/transition/context.js +3 -1
- package/transition/index.d.ts +21 -13
- package/transition/index.js +8 -6
- package/transition/style/index.js +3 -1
- package/transition/utils.js +45 -43
- package/typewriter/Typewriter.d.ts +2 -0
- package/typewriter/Typewriter.js +25 -18
- package/typewriter/constants.js +3 -1
- package/typewriter/context.js +3 -1
- package/typewriter/index.d.ts +4 -0
- package/typewriter/index.js +4 -2
- package/typewriter/style/index.js +3 -1
- package/typewriter/utils.js +3 -1
- package/utils/callOrReturn.js +3 -1
- package/utils/callbackOriginRef.d.ts +1 -2
- package/utils/callbackOriginRef.js +3 -1
- package/utils/caseName.d.ts +1 -1
- package/utils/caseName.js +5 -3
- package/utils/className.d.ts +1 -1
- package/utils/className.js +5 -3
- package/utils/confetti.d.ts +20 -0
- package/utils/confetti.js +31 -0
- package/utils/constants.js +3 -1
- package/utils/copy.js +3 -1
- package/utils/css.js +3 -1
- package/utils/date.js +3 -1
- package/utils/dayjs.js +3 -1
- package/utils/document.js +3 -1
- package/utils/dom.js +38 -35
- package/utils/emitter.js +3 -1
- package/utils/file.js +3 -1
- package/utils/fileRead.js +3 -1
- package/utils/fileToDataURL.js +3 -1
- package/utils/fillNBSP.js +4 -2
- package/utils/getCompatProp.d.ts +9 -0
- package/utils/getCompatProp.js +12 -0
- package/utils/getElement.js +16 -14
- package/utils/getHighlightText.js +20 -17
- package/utils/getHotkeyHandler.js +13 -11
- package/utils/getPrefixCls.d.ts +2 -0
- package/utils/getPrefixCls.js +11 -0
- package/utils/getScrollBarHeight.js +3 -1
- package/utils/getScrollBarSize.js +9 -7
- package/utils/getScrollBarWidth.js +3 -1
- package/utils/getScrollParent.js +3 -1
- package/utils/getStringLength.js +3 -1
- package/utils/include.js +3 -1
- package/utils/index.d.ts +6 -0
- package/utils/index.js +270 -354
- package/utils/initAllLineClamp.js +3 -1
- package/utils/intersectionObserver.js +17 -15
- package/utils/is.d.ts +2 -6
- package/utils/is.js +29 -139
- package/utils/keyboardCode.js +3 -1
- package/utils/lodash.d.ts +2 -1
- package/utils/lodash.js +55 -52
- package/utils/math.js +3 -1
- package/utils/mergeProps.d.ts +3 -1
- package/utils/mergeProps.js +15 -8
- package/utils/mergedToString.js +14 -11
- package/utils/migrateLegacyProps.d.ts +14 -0
- package/utils/migrateLegacyProps.js +19 -0
- package/utils/mutationObserver.js +15 -13
- package/utils/names.d.ts +31 -19
- package/utils/names.js +63 -31
- package/utils/object.js +3 -1
- package/utils/omit.js +3 -1
- package/utils/pad.js +3 -1
- package/utils/pick.d.ts +7 -2
- package/utils/pick.js +11 -9
- package/utils/pinyin.js +3 -1
- package/utils/react19Adapter.js +3 -1
- package/utils/reactNode.js +11 -9
- package/utils/ref.js +23 -19
- package/utils/resizeObserver.js +7 -5
- package/utils/saveAs.js +3 -1
- package/utils/screenfull.js +3 -1
- package/utils/scrollIntoViewIfNeeded.js +3 -1
- package/utils/scrollTo.js +7 -5
- package/utils/setCreateRoot.js +14 -11
- package/utils/setDarkTheme.js +16 -14
- package/utils/setDir.js +7 -5
- package/utils/setPrimaryColor.js +4 -2
- package/utils/setTheme.js +14 -12
- package/utils/string.js +3 -1
- package/utils/style.js +3 -1
- package/utils/tinycolor.js +3 -1
- package/utils/toArray.js +7 -5
- package/utils/tree.js +3 -1
- package/utils/tunnel.d.ts +6 -5
- package/utils/tunnel.js +22 -20
- package/utils/tween.js +3 -1
- package/utils/uuid.js +3 -1
- package/utils/validate.js +3 -1
- package/utils/warning.js +3 -1
- package/version/index.d.ts +0 -1
- package/version/index.js +10 -8
- package/hooks/use-merge-props/index.d.ts +0 -5
- package/hooks/use-merge-props/index.js +0 -10
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* 潘启宝 2026-09-03 10:06:59 星期四 山东省济南市 */
|
|
2
|
+
/* 世界因你而美丽 */
|
|
3
|
+
import { iconToCubics as e } from "./normalize.js";
|
|
4
|
+
//#region components/common/morphicons/core/resample.ts
|
|
5
|
+
var t = Math.PI / 8, n = [
|
|
6
|
+
.18343464249564978,
|
|
7
|
+
.525532409916329,
|
|
8
|
+
.7966664774136267,
|
|
9
|
+
.9602898564975363
|
|
10
|
+
], r = [
|
|
11
|
+
.362683783378362,
|
|
12
|
+
.31370664587788727,
|
|
13
|
+
.22238103445337448,
|
|
14
|
+
.10122853629037626
|
|
15
|
+
];
|
|
16
|
+
function i(e, t, n) {
|
|
17
|
+
let r = 6 * t, i = 1 - n, a = 3 * i * i, o = 6 * i * n, s = 3 * n * n, c = a * (e[r + 2] - e[r]) + o * (e[r + 4] - e[r + 2]) + s * (e[r + 6] - e[r + 4]), l = a * (e[r + 3] - e[r + 1]) + o * (e[r + 5] - e[r + 3]) + s * (e[r + 7] - e[r + 5]);
|
|
18
|
+
return Math.hypot(c, l);
|
|
19
|
+
}
|
|
20
|
+
function a(e, t, a = 1) {
|
|
21
|
+
let o = a / 2, s = 0;
|
|
22
|
+
for (let a = 0; a < 4; a++) s += r[a] * (i(e, t, o + o * n[a]) + i(e, t, o - o * n[a]));
|
|
23
|
+
return s * o;
|
|
24
|
+
}
|
|
25
|
+
function o(e, t, n, r, i) {
|
|
26
|
+
let a = 6 * t, o = 1 - n, s = o * o * o, c = 3 * o * o * n, l = 3 * o * n * n, u = n * n * n;
|
|
27
|
+
r[i] = s * e[a] + c * e[a + 2] + l * e[a + 4] + u * e[a + 6], r[i + 1] = s * e[a + 1] + c * e[a + 3] + l * e[a + 5] + u * e[a + 7];
|
|
28
|
+
}
|
|
29
|
+
function s(e, t, n) {
|
|
30
|
+
let r = 6 * t, i = n ? r + 6 : r, a = n ? -1 : 1;
|
|
31
|
+
for (let t of n ? [
|
|
32
|
+
4,
|
|
33
|
+
2,
|
|
34
|
+
0
|
|
35
|
+
] : [
|
|
36
|
+
2,
|
|
37
|
+
4,
|
|
38
|
+
6
|
|
39
|
+
]) {
|
|
40
|
+
let n = a * (e[r + t] - e[i]), o = a * (e[r + t + 1] - e[i + 1]);
|
|
41
|
+
if (n * n + o * o > 1e-18) return [n, o];
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function c(e, n = t) {
|
|
46
|
+
let r = e.pts, i = (r.length / 2 - 1) / 3, o = [];
|
|
47
|
+
for (let e = 0; e < i; e++) a(r, e) > 1e-9 && o.push(e);
|
|
48
|
+
if (o.length === 0) return [];
|
|
49
|
+
let c = /* @__PURE__ */ new Set(), l = (e, t) => {
|
|
50
|
+
let i = s(r, e, !0), a = s(r, t, !1);
|
|
51
|
+
!i || !a || Math.abs(Math.atan2(i[0] * a[1] - i[1] * a[0], i[0] * a[0] + i[1] * a[1])) > n && c.add(t);
|
|
52
|
+
};
|
|
53
|
+
for (let e = 0; e + 1 < o.length; e++) l(o[e], o[e + 1]);
|
|
54
|
+
return e.closed && o.length > 1 && l(o[o.length - 1], o[0]), [...c].sort((e, t) => e - t);
|
|
55
|
+
}
|
|
56
|
+
function l(e, t, n, r) {
|
|
57
|
+
if (n <= 0) return 0;
|
|
58
|
+
if (n >= r) return 1;
|
|
59
|
+
let o = 0, s = 1, c = n / r;
|
|
60
|
+
for (let l = 0; l < 12; l++) {
|
|
61
|
+
let l = a(e, t, c) - n;
|
|
62
|
+
if (Math.abs(l) < 1e-10 * r + 1e-14) break;
|
|
63
|
+
l > 0 ? s = c : o = c;
|
|
64
|
+
let u = i(e, t, c), d = u > 1e-12 ? c - l / u : (o + s) / 2;
|
|
65
|
+
d > o && d < s || (d = (o + s) / 2), c = d;
|
|
66
|
+
}
|
|
67
|
+
return c;
|
|
68
|
+
}
|
|
69
|
+
function u(e, n = 64, r = t) {
|
|
70
|
+
let i = e.pts, s = (i.length / 2 - 1) / 3, u = new Float64Array(2 * n), d = () => {
|
|
71
|
+
for (let e = 0; e < n; e++) u[2 * e] = i[0], u[2 * e + 1] = i[1];
|
|
72
|
+
return u;
|
|
73
|
+
};
|
|
74
|
+
if (s < 1) return d();
|
|
75
|
+
let f = Array(s), p = 0;
|
|
76
|
+
for (let e = 0; e < s; e++) f[e] = a(i, e), p += f[e];
|
|
77
|
+
if (p < 1e-12) return d();
|
|
78
|
+
let m = c(e, r), h = e.closed ? m.length > 0 ? m : [0] : [.../* @__PURE__ */ new Set([
|
|
79
|
+
0,
|
|
80
|
+
...m,
|
|
81
|
+
s
|
|
82
|
+
])].sort((e, t) => e - t), g = [];
|
|
83
|
+
if (e.closed) for (let e = 0; e < h.length; e++) {
|
|
84
|
+
let t = h[e], n = e + 1 < h.length ? h[e + 1] : h[0] + s;
|
|
85
|
+
g.push([t, n]);
|
|
86
|
+
}
|
|
87
|
+
else for (let e = 0; e + 1 < h.length; e++) g.push([h[e], h[e + 1]]);
|
|
88
|
+
let _ = g.map(([e, t]) => {
|
|
89
|
+
let n = 0;
|
|
90
|
+
for (let r = e; r < t; r++) n += f[r % s];
|
|
91
|
+
return n;
|
|
92
|
+
}), v = e.closed ? n : n - 1;
|
|
93
|
+
if (g.length > v) throw Error(`morphicons: N=${n} too small (${g.length} runs)`);
|
|
94
|
+
let y = _.reduce((e, t) => e + t, 0) || 1, b = _.map((e) => v * e / y), x = b.map((e) => Math.max(1, Math.floor(e))), S = v - x.reduce((e, t) => e + t, 0);
|
|
95
|
+
if (S > 0) {
|
|
96
|
+
let e = b.map((e, t) => [Math.round((e - Math.floor(e)) * 1e9), t]).sort((e, t) => t[0] - e[0] || e[1] - t[1]);
|
|
97
|
+
for (let t = 0; t < S; t++) x[e[t % x.length][1]]++;
|
|
98
|
+
}
|
|
99
|
+
for (; S < 0;) {
|
|
100
|
+
let e = 0;
|
|
101
|
+
for (let t = 1; t < x.length; t++) x[t] > x[e] && (e = t);
|
|
102
|
+
if (x[e] <= 1) break;
|
|
103
|
+
x[e]--, S++;
|
|
104
|
+
}
|
|
105
|
+
let C = 0;
|
|
106
|
+
for (let e = 0; e < g.length; e++) {
|
|
107
|
+
let [t, n] = g[e], r = x[e], a = _[e], c = t % s * 6;
|
|
108
|
+
u[2 * C] = i[c], u[2 * C + 1] = i[c + 1], C++;
|
|
109
|
+
let d = t, p = 0;
|
|
110
|
+
for (let e = 1; e < r; e++) {
|
|
111
|
+
let t = a * e / r;
|
|
112
|
+
for (; d < n - 1 && p + f[d % s] < t;) p += f[d % s], d++;
|
|
113
|
+
let c = d % s, m = f[c];
|
|
114
|
+
o(i, c, m > 1e-12 ? l(i, c, t - p, m) : 0, u, 2 * C), C++;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!e.closed) {
|
|
118
|
+
let e = 6 * s;
|
|
119
|
+
u[2 * C] = i[e], u[2 * C + 1] = i[e + 1];
|
|
120
|
+
}
|
|
121
|
+
return u;
|
|
122
|
+
}
|
|
123
|
+
function d(t, n = 64) {
|
|
124
|
+
return e(t).map((e) => ({
|
|
125
|
+
pts: u(e, n),
|
|
126
|
+
closed: e.closed
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { t as CORNER_THRESHOLD, c as detectCorners, d as resampleIcon, u as resamplePath };
|
|
131
|
+
/* 欲穷千里目,更上一层楼 */
|
|
132
|
+
/* 独立思考,明辨是非 */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CubicPath } from './types';
|
|
2
|
+
/** Sampled subpaths → polyline `d` attribute. `closed[k]` appends Z to
|
|
3
|
+
* subpath k (closed loops in flight); without flags everything is open. */
|
|
4
|
+
export declare function serialize(subs: readonly Float64Array[], closed?: readonly boolean[]): string;
|
|
5
|
+
/** Cubic subpaths → canonical `d`, quantized to 4 decimals (engine-stable
|
|
6
|
+
* bytes; see fmtCanon). */
|
|
7
|
+
export declare function cubicsToPathD(paths: readonly CubicPath[]): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* 潘启宝 2026-09-03 10:06:59 星期四 山东省济南市 */
|
|
2
|
+
/* 世界因你而美丽 */
|
|
3
|
+
//#region components/common/morphicons/core/serialize.ts
|
|
4
|
+
function e(e) {
|
|
5
|
+
return String(Math.round(e * 100) / 100);
|
|
6
|
+
}
|
|
7
|
+
function t(t, n) {
|
|
8
|
+
let r = "";
|
|
9
|
+
for (let i = 0; i < t.length; i++) {
|
|
10
|
+
let a = t[i], o = a.length / 2;
|
|
11
|
+
r += `M${e(a[0])} ${e(a[1])}`;
|
|
12
|
+
for (let t = 1; t < o; t++) r += `L${e(a[2 * t])} ${e(a[2 * t + 1])}`;
|
|
13
|
+
n?.[i] && (r += "Z");
|
|
14
|
+
}
|
|
15
|
+
return r;
|
|
16
|
+
}
|
|
17
|
+
function n(e) {
|
|
18
|
+
return String(Math.round(e * 1e4) / 1e4);
|
|
19
|
+
}
|
|
20
|
+
function r(e) {
|
|
21
|
+
let t = "";
|
|
22
|
+
for (let { pts: r, closed: i } of e) {
|
|
23
|
+
t += `M${n(r[0])} ${n(r[1])}`;
|
|
24
|
+
for (let e = 2; e < r.length; e += 6) t += `C${n(r[e])} ${n(r[e + 1])} ${n(r[e + 2])} ${n(r[e + 3])} ${n(r[e + 4])} ${n(r[e + 5])}`;
|
|
25
|
+
i && (t += "Z");
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { r as cubicsToPathD, t as serialize };
|
|
31
|
+
/* 欲穷千里目,更上一层楼 */
|
|
32
|
+
/* 独立思考,明辨是非 */
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare class Spring {
|
|
2
|
+
x: number;
|
|
3
|
+
v: number;
|
|
4
|
+
k: number;
|
|
5
|
+
c: number;
|
|
6
|
+
config(k: number, c: number): void;
|
|
7
|
+
/** Starts (or restarts mid-flight) preserving velocity. */
|
|
8
|
+
start(): void;
|
|
9
|
+
/** Advances dt seconds. Returns true on settle (|1−x| < 0.001 ∧ |v| < 0.02). */
|
|
10
|
+
step(dt: number): boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Spring presets (ζ = c/(2√k)) with the API's public names. */
|
|
13
|
+
export declare const SPRING_PRESETS: {
|
|
14
|
+
/** ζ = 1.00 — critically damped, no overshoot. */
|
|
15
|
+
readonly smooth: {
|
|
16
|
+
readonly k: 170;
|
|
17
|
+
readonly c: 26;
|
|
18
|
+
};
|
|
19
|
+
/** ζ = 0.73 — fast, subtle overshoot. */
|
|
20
|
+
readonly snappy: {
|
|
21
|
+
readonly k: 420;
|
|
22
|
+
readonly c: 30;
|
|
23
|
+
};
|
|
24
|
+
/** ζ = 0.40 — playful. */
|
|
25
|
+
readonly bouncy: {
|
|
26
|
+
readonly k: 300;
|
|
27
|
+
readonly c: 14;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type SpringPreset = keyof typeof SPRING_PRESETS;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* 潘启宝 2026-09-03 10:06:59 星期四 山东省济南市 */
|
|
2
|
+
/* 世界因你而美丽 */
|
|
3
|
+
//#region components/common/morphicons/core/spring.ts
|
|
4
|
+
var e = class {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.x = 1, this.v = 0, this.k = 250, this.c = 24;
|
|
7
|
+
}
|
|
8
|
+
config(e, t) {
|
|
9
|
+
this.k = e, this.c = t;
|
|
10
|
+
}
|
|
11
|
+
start() {
|
|
12
|
+
this.x = 0, this.v > 14 && (this.v = 14), this.v < -14 && (this.v = -14);
|
|
13
|
+
}
|
|
14
|
+
step(e) {
|
|
15
|
+
let t = Math.max(1, Math.min(16, Math.ceil(e / (1 / 240)))), n = e / t;
|
|
16
|
+
for (let e = 0; e < t; e++) {
|
|
17
|
+
let e = this.k * (1 - this.x) - this.c * this.v;
|
|
18
|
+
this.v += e * n, this.x += this.v * n;
|
|
19
|
+
}
|
|
20
|
+
return Math.abs(1 - this.x) < .001 && Math.abs(this.v) < .02;
|
|
21
|
+
}
|
|
22
|
+
}, t = {
|
|
23
|
+
smooth: {
|
|
24
|
+
k: 170,
|
|
25
|
+
c: 26
|
|
26
|
+
},
|
|
27
|
+
snappy: {
|
|
28
|
+
k: 420,
|
|
29
|
+
c: 30
|
|
30
|
+
},
|
|
31
|
+
bouncy: {
|
|
32
|
+
k: 300,
|
|
33
|
+
c: 14
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { t as SPRING_PRESETS, e as Spring };
|
|
38
|
+
/* 欲穷千里目,更上一层楼 */
|
|
39
|
+
/* 独立思考,明辨是非 */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Attributes of an icon node (values as Lucide exports them: string or
|
|
2
|
+
* number). `undefined` is allowed on purpose — lucide's SVGProps includes it
|
|
3
|
+
* and the runtime treats an undefined attr as absent (fallback). */
|
|
4
|
+
export type IconNodeAttrs = Record<string, string | number | undefined>;
|
|
5
|
+
/** Lucide-style icon data: a `[tag, attrs]` list. Structurally typed —
|
|
6
|
+
* Lucide is neither a dependency nor a peer; Feather/Tabler/custom paths
|
|
7
|
+
* work just the same. */
|
|
8
|
+
export type IconNode = ReadonlyArray<readonly [string, IconNodeAttrs]>;
|
|
9
|
+
/** Input accepted by the core: an IconNode or a raw `d` attribute.
|
|
10
|
+
* (SVGElement is resolved in the dom layer — the core never touches DOM.) */
|
|
11
|
+
export type IconInput = IconNode | string;
|
|
12
|
+
/** Normalized subpath: a chain of cubics packed as points
|
|
13
|
+
* [p0, c1, c2, p1, c1', c2', p2, …] → Float64Array of length 2·(3m+1),
|
|
14
|
+
* with m = number of segments. Consecutive segments share an endpoint. */
|
|
15
|
+
export interface CubicPath {
|
|
16
|
+
pts: Float64Array;
|
|
17
|
+
closed: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Subpath sampled at N points by arc length + its topology. It is the
|
|
20
|
+
* currency between resample and plan; an intermediate shape (interruption)
|
|
21
|
+
* is also a list of Sampled. */
|
|
22
|
+
export interface Sampled {
|
|
23
|
+
pts: Float64Array;
|
|
24
|
+
closed: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Number of cubic segments in a CubicPath. */
|
|
27
|
+
export declare function segCount(path: CubicPath): number;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SpringPreset } from '../core/spring';
|
|
2
|
+
import type { IconInput } from '../core/types';
|
|
3
|
+
import type { ReducedMotionMode } from './index';
|
|
4
|
+
import { type MorphOptions, type PathEl } from './index';
|
|
5
|
+
/** Imperative surface exposed by every binding (ref / bind:this / element). */
|
|
6
|
+
export interface MorphHandle {
|
|
7
|
+
morphTo(icon: IconInput, spring?: SpringPreset | MorphOptions): void;
|
|
8
|
+
set(icon: IconInput): void;
|
|
9
|
+
}
|
|
10
|
+
/** The mode-deciding props, shared by every binding's prop surface. */
|
|
11
|
+
export interface MorphModeProps {
|
|
12
|
+
icon?: IconInput;
|
|
13
|
+
from?: IconInput;
|
|
14
|
+
to?: IconInput;
|
|
15
|
+
progress?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface MorphCtrlProps extends MorphModeProps {
|
|
18
|
+
reducedMotion?: ReducedMotionMode;
|
|
19
|
+
}
|
|
20
|
+
export interface MorphWatchProps extends MorphCtrlProps {
|
|
21
|
+
spring?: SpringPreset | MorphOptions;
|
|
22
|
+
}
|
|
23
|
+
/** The initial d is a constant for every binding: computed once from the
|
|
24
|
+
* mount-time props (server and client produce the same string → hydration
|
|
25
|
+
* without mismatch) and from then on only the driver mutates it outside the
|
|
26
|
+
* template. */
|
|
27
|
+
export declare function computeInitialD({ icon, from, to, progress, }: MorphModeProps): string;
|
|
28
|
+
/** Per-instance driver state — the exact logic of the React/Vue bindings
|
|
29
|
+
* (mount, mode watch, controlled seek with re-basing, imperative). Takes the
|
|
30
|
+
* init-time props: they seed the watch baselines so a watcher that fires on
|
|
31
|
+
* mount (Svelte's $effect, unlike Vue's watch) is a no-op. All change
|
|
32
|
+
* detection lives HERE, under tsc — the shells only wire their reactive
|
|
33
|
+
* surface to these methods.
|
|
34
|
+
*
|
|
35
|
+
* Lifecycle contract (shared verbatim by the bindings):
|
|
36
|
+
* - Lazy driver: an iconless mount keeps the element and births the driver
|
|
37
|
+
* on the FIRST icon that shows up (prop or imperative). `morphTo` with no
|
|
38
|
+
* driver behaves as `set` — there is nothing to fly from.
|
|
39
|
+
* - Controlled wins: while `from` and `to` are both present the pair owns
|
|
40
|
+
* the path and `icon` changes are ignored; dropping the pair hands the
|
|
41
|
+
* path back to `icon`.
|
|
42
|
+
* - Every exit from controlled mode (imperative call or icon takeover)
|
|
43
|
+
* invalidates the frozen pair, so returning to it re-bases on `from`. */
|
|
44
|
+
export declare function createController({ icon, from, to, progress, reducedMotion, }: MorphCtrlProps): {
|
|
45
|
+
mount(mountEl: PathEl, { icon, from, to, progress, reducedMotion }: MorphCtrlProps): void;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
/** Prop watcher: ONE owner decides per run — the controlled pair while it
|
|
48
|
+
* is fully present, `icon` otherwise (mount doesn't fire thanks to the
|
|
49
|
+
* init-time baselines). */
|
|
50
|
+
watch({ icon, from, to, progress, spring, reducedMotion, }: MorphWatchProps): void;
|
|
51
|
+
morphTo(icon: IconInput, spring?: SpringPreset | MorphOptions): void;
|
|
52
|
+
set(icon: IconInput): void;
|
|
53
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type SpringPreset } from '../core/spring';
|
|
2
|
+
import type { IconInput } from '../core/types';
|
|
3
|
+
/** Target element, structurally typed: any object with setAttribute works
|
|
4
|
+
* (a real SVGPathElement, or a fake in tests). */
|
|
5
|
+
export interface PathEl {
|
|
6
|
+
setAttribute(name: string, value: string): void;
|
|
7
|
+
}
|
|
8
|
+
/** Morph physics: named preset or custom spring. */
|
|
9
|
+
export interface MorphOptions {
|
|
10
|
+
stiffness?: number;
|
|
11
|
+
damping?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Reduced-motion policy. `"never"` (default): morphs always animate,
|
|
14
|
+
* ignoring the OS setting. `"user"`: while the OS reduce-motion setting is
|
|
15
|
+
* on, `morphTo` degrades to an instant `set`. `"always"`: every `morphTo`
|
|
16
|
+
* jumps (tests, screenshots). */
|
|
17
|
+
export type ReducedMotionMode = 'never' | 'user' | 'always';
|
|
18
|
+
export interface CreateMorphOptions {
|
|
19
|
+
/** Reduced-motion policy; also live via the `reducedMotion` property. */
|
|
20
|
+
reducedMotion?: ReducedMotionMode;
|
|
21
|
+
}
|
|
22
|
+
export interface Morph {
|
|
23
|
+
/** Animates toward the icon with spring physics. Interruptible: mid-flight
|
|
24
|
+
* it re-plans from the intermediate shape while preserving velocity. */
|
|
25
|
+
morphTo(icon: IconInput, spring?: SpringPreset | MorphOptions): void;
|
|
26
|
+
/** Jumps to the icon without animating (canonical d, no frames). */
|
|
27
|
+
set(icon: IconInput): void;
|
|
28
|
+
/** Renders the morph toward `icon` frozen at t (no spring) — the
|
|
29
|
+
* controlled-mode primitive: scrubbing, gestures, scroll. A later
|
|
30
|
+
* morphTo takes off from that intermediate shape. */
|
|
31
|
+
seek(icon: IconInput, t: number): void;
|
|
32
|
+
/** Current progress (t of the last frame; 1 at rest). Assigning it is
|
|
33
|
+
* equivalent to seek(target, t) on the active target. */
|
|
34
|
+
progress: number;
|
|
35
|
+
/** Reduced-motion policy, live: assigning it applies to the next morphTo. */
|
|
36
|
+
reducedMotion: ReducedMotionMode;
|
|
37
|
+
/** Unregisters the instance; later calls are no-ops. */
|
|
38
|
+
destroy(): void;
|
|
39
|
+
}
|
|
40
|
+
/** Canonical `d` of an icon: the input string verbatim, or the real cubics
|
|
41
|
+
* quantized to 4 decimals (the at-rest snap; engine-stable bytes so SSR
|
|
42
|
+
* hydration matches, see fmtCanon in core/serialize). Exported because it
|
|
43
|
+
* is what a binding renders at SSR/rest before any runtime exists. */
|
|
44
|
+
export declare function canonicalD(icon: IconInput): string;
|
|
45
|
+
/** Creates the morph instance over a `<path>` and paints the initial icon. */
|
|
46
|
+
export declare function createMorph(el: PathEl, icon: IconInput, options?: CreateMorphOptions): Morph;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SpringPreset } from '../core/spring';
|
|
2
|
+
import type { IconInput } from '../core/types';
|
|
3
|
+
import { type MorphHandle } from '../dom/controller';
|
|
4
|
+
import type { MorphOptions, ReducedMotionMode } from '../dom/index';
|
|
5
|
+
declare const Base: typeof HTMLElement;
|
|
6
|
+
export declare class MorphIconElement extends Base implements MorphHandle {
|
|
7
|
+
#private;
|
|
8
|
+
static observedAttributes: string[];
|
|
9
|
+
get icon(): IconInput | undefined;
|
|
10
|
+
set icon(v: IconInput | undefined);
|
|
11
|
+
get from(): IconInput | undefined;
|
|
12
|
+
set from(v: IconInput | undefined);
|
|
13
|
+
get to(): IconInput | undefined;
|
|
14
|
+
set to(v: IconInput | undefined);
|
|
15
|
+
get progress(): number | undefined;
|
|
16
|
+
set progress(v: number | undefined);
|
|
17
|
+
get spring(): SpringPreset | MorphOptions | undefined;
|
|
18
|
+
set spring(v: SpringPreset | MorphOptions | undefined);
|
|
19
|
+
get reducedMotion(): ReducedMotionMode | undefined;
|
|
20
|
+
set reducedMotion(v: ReducedMotionMode | undefined);
|
|
21
|
+
morphTo(icon: IconInput, spring?: SpringPreset | MorphOptions): void;
|
|
22
|
+
set(icon: IconInput): void;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
26
|
+
}
|
|
27
|
+
/** Defines `<morph-icon>` (or a custom tag). Idempotent per tag; a no-op
|
|
28
|
+
* without a DOM (safe to call from code that also runs during SSR). */
|
|
29
|
+
export declare function defineMorphIcon(tag?: string): void;
|
|
30
|
+
declare global {
|
|
31
|
+
interface HTMLElementTagNameMap {
|
|
32
|
+
'morph-icon': MorphIconElement;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export type { IconInput, IconNode, Sampled } from '../core/types';
|
|
36
|
+
export { computeInitialD } from '../dom/controller';
|
|
37
|
+
export type { MorphHandle } from '../dom/controller';
|
|
38
|
+
export type { Morph, MorphOptions, PathEl, ReducedMotionMode, } from '../dom/index';
|
|
39
|
+
export type { SpringPreset };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { allocOutputs, interpLinear, interpPolar } from './core/interpolate';
|
|
2
|
+
export { fitIcon, iconToCubics, type ViewBox } from './core/normalize';
|
|
3
|
+
export { buildPlan, type MorphPlan, type PlanItem } from './core/plan';
|
|
4
|
+
export { resampleIcon, resamplePath } from './core/resample';
|
|
5
|
+
export { cubicsToPathD, serialize } from './core/serialize';
|
|
6
|
+
export { Spring, SPRING_PRESETS, type SpringPreset } from './core/spring';
|
|
7
|
+
export type { CubicPath, IconInput, IconNode, IconNodeAttrs, Sampled, } from './core/types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* 潘启宝 2026-09-03 10:06:59 星期四 山东省济南市 */
|
|
2
|
+
/* 世界因你而美丽 */
|
|
3
|
+
import { allocOutputs as e, interpLinear as t, interpPolar as n } from "./core/interpolate.js";
|
|
4
|
+
import { cubicsToPathD as r, serialize as i } from "./core/serialize.js";
|
|
5
|
+
import { fitIcon as a, iconToCubics as o } from "./core/normalize.js";
|
|
6
|
+
import { buildPlan as s } from "./core/plan.js";
|
|
7
|
+
import { resampleIcon as c, resamplePath as l } from "./core/resample.js";
|
|
8
|
+
import { SPRING_PRESETS as u, Spring as d } from "./core/spring.js";
|
|
9
|
+
export { u as SPRING_PRESETS, d as Spring, e as allocOutputs, s as buildPlan, r as cubicsToPathD, a as fitIcon, o as iconToCubics, t as interpLinear, n as interpPolar, c as resampleIcon, l as resamplePath, i as serialize };
|
|
10
|
+
/* 欲穷千里目,更上一层楼 */
|
|
11
|
+
/* 独立思考,明辨是非 */
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type SVGProps } from 'react';
|
|
2
|
+
import type { SpringPreset } from '../core/spring';
|
|
3
|
+
import type { IconInput } from '../core/types';
|
|
4
|
+
import { type MorphOptions, type ReducedMotionMode } from '../dom/index';
|
|
5
|
+
/** Imperative surface exposed via ref. */
|
|
6
|
+
export interface MorphHandle {
|
|
7
|
+
morphTo(icon: IconInput, spring?: SpringPreset | MorphOptions): void;
|
|
8
|
+
set(icon: IconInput): void;
|
|
9
|
+
}
|
|
10
|
+
export interface MorphIconProps extends Omit<SVGProps<SVGSVGElement>, 'from' | 'to' | 'ref'> {
|
|
11
|
+
/** Uncontrolled mode: the current icon; changing the prop animates. */
|
|
12
|
+
icon?: IconInput;
|
|
13
|
+
/** Controlled mode: source endpoint of the pair. */
|
|
14
|
+
from?: IconInput;
|
|
15
|
+
/** Controlled mode: target endpoint of the pair. */
|
|
16
|
+
to?: IconInput;
|
|
17
|
+
/** Controlled mode: 0..1 progress of the frozen morph (no spring). */
|
|
18
|
+
progress?: number;
|
|
19
|
+
/** Physics for uncontrolled/imperative mode: preset or custom spring. */
|
|
20
|
+
spring?: SpringPreset | MorphOptions;
|
|
21
|
+
/** Reduced-motion policy: "never" (default) animates regardless of the OS
|
|
22
|
+
* setting, "user" honors prefers-reduced-motion (morphs degrade to an
|
|
23
|
+
* instant swap while it is on), "always" always jumps. */
|
|
24
|
+
reducedMotion?: ReducedMotionMode;
|
|
25
|
+
size?: number | string;
|
|
26
|
+
color?: string;
|
|
27
|
+
strokeWidth?: number | string;
|
|
28
|
+
/** Like lucide-react: stroke width does not scale with `size`. */
|
|
29
|
+
absoluteStrokeWidth?: boolean;
|
|
30
|
+
/** Accessibility: with label → role="img" + <title>; without → aria-hidden. */
|
|
31
|
+
label?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare const MorphIcon: import("react").ForwardRefExoticComponent<MorphIconProps & import("react").RefAttributes<MorphHandle>>;
|
|
34
|
+
export type { IconInput, IconNode, Sampled } from '../core/types';
|
|
35
|
+
export type { Morph, MorphOptions, PathEl, ReducedMotionMode, } from '../dom/index';
|
|
36
|
+
export type { SpringPreset };
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@unicom-cloud/ui-common","version":"0.1.
|
|
1
|
+
{"name":"@unicom-cloud/ui-common","version":"0.1.47","dependencies":{"@unicom-cloud/utils":"^0.1.0","@unicom-cloud/icons":"^0.1.0","react-compiler-runtime":"^1.0.0"},"peerDependencies":{"dayjs":"^1.11.23","lodash":"^4.18.1","react":"^18.3.1","react-dom":"^18.3.1","react-is":"^18.3.1"},"type":"module","types":"./index.d.ts","main":"./index.js","bin":{"ui":"./test.js"},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
|
package/progress/Progress.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
/* 潘启宝 2026-
|
|
2
|
-
|
|
3
|
-
import { clamp as
|
|
4
|
-
import { getBody as
|
|
5
|
-
import
|
|
1
|
+
/* 潘启宝 2026-09-03 10:06:59 星期四 山东省济南市 */
|
|
2
|
+
/* 世界因你而美丽 */
|
|
3
|
+
import { clamp as e } from "../utils/lodash.js";
|
|
4
|
+
import { getBody as t } from "../utils/dom.js";
|
|
5
|
+
import n from "../utils/getPrefixCls.js";
|
|
6
|
+
import { isNumber as r, isUndefined as i } from "@unicom-cloud/utils/is";
|
|
6
7
|
//#region components/common/progress/Progress.ts
|
|
7
8
|
var a = {
|
|
8
9
|
status: null,
|
|
9
10
|
settings: {
|
|
10
|
-
parent:
|
|
11
|
+
parent: t(),
|
|
11
12
|
progress: document.createElement("div"),
|
|
12
13
|
bar: document.createElement("div"),
|
|
13
14
|
minimum: .07,
|
|
@@ -20,18 +21,18 @@ var a = {
|
|
|
20
21
|
configure(e) {
|
|
21
22
|
return Object.assign(a.settings, e), a;
|
|
22
23
|
},
|
|
23
|
-
set(
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
let r = a.render(!
|
|
27
|
-
return r.offsetWidth, d(function(
|
|
28
|
-
f(a.settings.bar, s(
|
|
29
|
-
a.remove(),
|
|
30
|
-
}, i)) : setTimeout(
|
|
24
|
+
set(t) {
|
|
25
|
+
let n = a.isStarted();
|
|
26
|
+
t = e(t, a.settings.minimum, 1), a.status = t === 1 ? null : t;
|
|
27
|
+
let r = a.render(!n), i = a.settings.speed;
|
|
28
|
+
return r.offsetWidth, d(function(e) {
|
|
29
|
+
f(a.settings.bar, s(t, i)), t === 1 ? (r.offsetWidth, setTimeout(function() {
|
|
30
|
+
a.remove(), e();
|
|
31
|
+
}, i)) : setTimeout(e, i);
|
|
31
32
|
}), a;
|
|
32
33
|
},
|
|
33
34
|
isStarted() {
|
|
34
|
-
return
|
|
35
|
+
return r(a.status);
|
|
35
36
|
},
|
|
36
37
|
start() {
|
|
37
38
|
return a.status || a.set(0), a.settings.trickle && c(), a;
|
|
@@ -40,16 +41,16 @@ var a = {
|
|
|
40
41
|
return e || a.status ? a.inc(.3 + .5 * Math.random()).set(1) : a;
|
|
41
42
|
},
|
|
42
43
|
inc(t) {
|
|
43
|
-
let
|
|
44
|
-
if (!
|
|
45
|
-
if (!(
|
|
44
|
+
let n = a.status;
|
|
45
|
+
if (!n) return a.start();
|
|
46
|
+
if (!(n > 1)) return r(t) || (n >= 0 && n < .2 && (t = .1), n >= .2 && n < .5 && (t = .04), n >= .5 && n < .8 && (t = .02), n >= .8 && n < .99 && (t = .005)), t ??= 7e-4, n = e(n + t, 0, .994), a.set(n);
|
|
46
47
|
},
|
|
47
48
|
trickle() {
|
|
48
49
|
return a.inc();
|
|
49
50
|
},
|
|
50
51
|
render(e) {
|
|
51
52
|
if (a.settings.parent.contains(a.settings.progress)) return a.settings.progress;
|
|
52
|
-
a.settings.progress.hasAttribute("class"), a.settings.bar.hasAttribute("class"), a.settings.progress.setAttribute("class",
|
|
53
|
+
a.settings.progress.hasAttribute("class"), a.settings.bar.hasAttribute("class"), a.settings.progress.setAttribute("class", n("progress")), a.settings.bar.setAttribute("class", n("progress-bar")), a.settings.progress.contains(a.settings.bar) || a.settings.progress.append(a.settings.bar);
|
|
53
54
|
let t = e ? "-100" : o(a.status || 0);
|
|
54
55
|
return f(a.settings.bar, s(0, t)), a.settings.parent.append(a.settings.progress), a.settings.progress;
|
|
55
56
|
},
|
|
@@ -79,11 +80,12 @@ function u() {
|
|
|
79
80
|
function d(e) {
|
|
80
81
|
l.push(e), l.length && u();
|
|
81
82
|
}
|
|
82
|
-
function f(e,
|
|
83
|
-
Object.entries(
|
|
84
|
-
|
|
83
|
+
function f(e, t) {
|
|
84
|
+
Object.entries(t).forEach(([t, n], r, a) => {
|
|
85
|
+
i(n) || (e.style[t] = n);
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
88
|
//#endregion
|
|
88
89
|
export { a as default };
|
|
90
|
+
/* 欲穷千里目,更上一层楼 */
|
|
89
91
|
/* 独立思考,明辨是非 */
|
package/progress/constants.js
CHANGED
|
File without changes
|
package/progress/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
/* 潘启宝 2026-
|
|
1
|
+
/* 潘启宝 2026-09-03 10:06:59 星期四 山东省济南市 */
|
|
2
|
+
/* 世界因你而美丽 */
|
|
2
3
|
import "./style/index.js";
|
|
3
4
|
import e from "./Progress.js";
|
|
4
5
|
//#region components/common/progress/index.ts
|
|
5
6
|
var t = e;
|
|
6
7
|
//#endregion
|
|
7
8
|
export { t as default };
|
|
9
|
+
/* 欲穷千里目,更上一层楼 */
|
|
8
10
|
/* 独立思考,明辨是非 */
|
package/progress/style/index.js
CHANGED
package/progress/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/* 潘启宝 2026-
|
|
1
|
+
/* 潘启宝 2026-09-03 10:06:59 星期四 山东省济南市 */
|
|
2
|
+
/* 世界因你而美丽 */
|
|
2
3
|
import { CollectionContext as e } from "./context.js";
|
|
3
4
|
import { useCallback as t, useContext as n, useRef as r } from "react";
|
|
4
5
|
import { jsx as i } from "react/jsx-runtime";
|
|
@@ -22,4 +23,5 @@ function a({ children: a, onBatchResize: o }) {
|
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
25
|
export { a as Collection };
|
|
26
|
+
/* 欲穷千里目,更上一层楼 */
|
|
25
27
|
/* 独立思考,明辨是非 */
|