deepsea-components 5.10.3 → 5.10.5
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/dist/cjs/components/AutoScroll.js +2 -2
- package/dist/cjs/components/AutoScroll.js.map +2 -2
- package/dist/cjs/components/CopyButton.js +3 -3
- package/dist/cjs/components/CopyButton.js.map +2 -2
- package/dist/cjs/components/Flow.js +3 -3
- package/dist/cjs/components/Flow.js.map +2 -2
- package/dist/cjs/components/ImportExcel.js.map +2 -2
- package/dist/cjs/components/InfiniteScroll.js +3 -3
- package/dist/cjs/components/InfiniteScroll.js.map +2 -2
- package/dist/cjs/components/InputFileButton.js.map +2 -2
- package/dist/cjs/components/TransitionBox.js +2 -2
- package/dist/cjs/components/TransitionBox.js.map +2 -2
- package/dist/cjs/components/Unify.js +1 -1
- package/dist/cjs/components/Unify.js.map +2 -2
- package/dist/esm/components/AutoScroll.js +1 -1
- package/dist/esm/components/AutoScroll.js.map +1 -1
- package/dist/esm/components/CopyButton.js +1 -1
- package/dist/esm/components/CopyButton.js.map +1 -1
- package/dist/esm/components/Flow.js +2 -2
- package/dist/esm/components/Flow.js.map +1 -1
- package/dist/esm/components/ImportExcel.js.map +1 -1
- package/dist/esm/components/InfiniteScroll.js +1 -1
- package/dist/esm/components/InfiniteScroll.js.map +1 -1
- package/dist/esm/components/InputFileButton.js +2 -2
- package/dist/esm/components/InputFileButton.js.map +1 -1
- package/dist/esm/components/TransitionBox.js +1 -1
- package/dist/esm/components/TransitionBox.js.map +1 -1
- package/dist/esm/components/Unify.js +1 -1
- package/dist/esm/components/Unify.js.map +1 -1
- package/package.json +3 -3
- package/src/components/AutoScroll.tsx +1 -1
- package/src/components/CopyButton.tsx +1 -1
- package/src/components/Flow.tsx +2 -2
- package/src/components/ImportExcel.tsx +1 -1
- package/src/components/InfiniteScroll.tsx +1 -1
- package/src/components/InputFileButton.tsx +122 -121
- package/src/components/TransitionBox.tsx +1 -1
- package/src/components/Unify.tsx +38 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useEffect","useImperativeHandle","useRef","css","
|
|
1
|
+
{"version":3,"names":["forwardRef","useEffect","useImperativeHandle","useRef","css","clsx","useSize","jsx","_jsx","jsxs","_jsxs","InfiniteScroll","props","ref","className","direction","children","containerClassName","containerStyle","gap","duration","withGap","withEqual","pauseOnHover","onMouseEnter","onMouseLeave","rest","wrapper","wrapperSize","ele","current","container","containerSize","bigger","overflow","height","width","animation","undefined","animate","transform","iterations","Infinity","cancel","enter","e","pause","leave","play","playState","style","position"],"sources":["../../../src/components/InfiniteScroll.tsx"],"sourcesContent":["\"use client\"\n\nimport { CSSProperties, ComponentPropsWithoutRef, MouseEvent as ReactMouseEvent, forwardRef, useEffect, useImperativeHandle, useRef } from \"react\"\nimport { css } from \"@emotion/css\"\nimport { clsx } from \"deepsea-tools\"\nimport { useSize } from \"soda-hooks\"\n\nexport type InfiniteScrollProps = ComponentPropsWithoutRef<\"div\"> & {\n /**\n * 滚动的方向\n * @default \"vertical\"\n */\n direction?: \"vertical\" | \"horizontal\"\n /** 渲染 children 的容器的类名 */\n containerClassName?: string\n /** 渲染 children 的容器的样式 */\n containerStyle?: CSSProperties\n /**\n * 两个 children 容器之间的间距\n * @default 0\n */\n gap?: number\n /** 一个周期的时间,单位:毫秒 */\n duration: number\n /** 是否将 gap 的距离也加入 overflow 的计算 */\n withGap?: boolean\n /** 尺寸刚好相同时,是否视为溢出 */\n withEqual?: boolean\n /** 鼠标移入时,是否停止动画 */\n pauseOnHover?: boolean\n}\n\n/**\n * 无限滚动的组件\n * 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果\n * 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画\n */\nexport const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((props, ref) => {\n const {\n className,\n direction = \"vertical\",\n children,\n containerClassName,\n containerStyle,\n gap = 0,\n duration,\n withGap,\n withEqual,\n pauseOnHover,\n onMouseEnter,\n onMouseLeave,\n ...rest\n } = props\n\n const wrapper = useRef<HTMLDivElement>(null)\n const wrapperSize = useSize(wrapper)\n\n const ele = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(ref, () => wrapper.current as HTMLDivElement, [wrapper.current])\n\n const container = useRef<HTMLDivElement>(null)\n const containerSize = useSize(container)\n\n function bigger(containerSize: number, wrapperSize: number) {\n return withEqual ? containerSize + (withGap ? gap : 0) >= wrapperSize : containerSize + (withGap ? gap : 0) > wrapperSize\n }\n\n const overflow =\n wrapperSize && containerSize\n ? direction === \"vertical\"\n ? bigger(containerSize.height, wrapperSize.height)\n : bigger(containerSize.width, wrapperSize.width)\n : false\n\n const animation = useRef<Animation | undefined>(undefined)\n\n useEffect(() => {\n if (!wrapperSize || !containerSize || !overflow) return\n animation.current = ele.current?.animate(\n {\n transform:\n direction === \"vertical\"\n ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`]\n : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`],\n },\n { duration, iterations: Infinity },\n )\n return () => animation.current?.cancel()\n }, [wrapperSize, containerSize, overflow, direction, duration])\n\n function enter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {\n if (pauseOnHover) animation.current?.pause()\n onMouseEnter?.(e)\n }\n\n function leave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {\n if (pauseOnHover) animation.current?.play()\n onMouseLeave?.(e)\n }\n\n useEffect(() => {\n if (!pauseOnHover && animation.current?.playState === \"paused\") animation.current?.play()\n }, [animation.current, pauseOnHover])\n\n return (\n <div\n ref={wrapper}\n className={clsx(\n css`\n position: relative;\n ${direction === \"vertical\" ? \"overflow-y: hidden;\" : \"overflow-x: hidden;\"}\n `,\n className,\n )}\n onMouseEnter={enter}\n onMouseLeave={leave}\n {...rest}\n >\n <div\n ref={ele}\n style={{\n position: \"absolute\",\n width: direction === \"vertical\" ? \"100%\" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),\n height: direction === \"horizontal\" ? \"100%\" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width),\n }}\n >\n <div\n ref={container}\n className={clsx(\n css`\n position: absolute;\n left: 0;\n top: 0;\n ${direction === \"vertical\" ? \"width: 100%;\" : \"height: 100%;\"}\n `,\n containerClassName,\n )}\n style={containerStyle}\n >\n {children}\n </div>\n {overflow && (\n <div\n ref={container}\n className={clsx(\n css`\n position: absolute;\n right: 0;\n bottom: 0;\n ${direction === \"vertical\" ? \"width: 100%;\" : \"height: 100%;\"}\n `,\n containerClassName,\n )}\n style={containerStyle}\n >\n {children}\n </div>\n )}\n </div>\n </div>\n )\n})\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAiFA,UAAU,EAAEC,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,QAAQ,OAAO;AAClJ,SAASC,GAAG,QAAQ,cAAc;AAClC,SAASC,IAAI,QAAQ,eAAe;AACpC,SAASC,OAAO,QAAQ,YAAY;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AA2BpC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,gBAAGX,UAAU,CAAsC,CAACY,KAAK,EAAEC,GAAG,KAAK;EAC1F,MAAM;IACFC,SAAS;IACTC,SAAS,GAAG,UAAU;IACtBC,QAAQ;IACRC,kBAAkB;IAClBC,cAAc;IACdC,GAAG,GAAG,CAAC;IACPC,QAAQ;IACRC,OAAO;IACPC,SAAS;IACTC,YAAY;IACZC,YAAY;IACZC,YAAY;IACZ,GAAGC;EACP,CAAC,GAAGd,KAAK;EAET,MAAMe,OAAO,GAAGxB,MAAM,CAAiB,IAAI,CAAC;EAC5C,MAAMyB,WAAW,GAAGtB,OAAO,CAACqB,OAAO,CAAC;EAEpC,MAAME,GAAG,GAAG1B,MAAM,CAAiB,IAAI,CAAC;EAExCD,mBAAmB,CAACW,GAAG,EAAE,MAAMc,OAAO,CAACG,OAAyB,EAAE,CAACH,OAAO,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IK,GAAG,EAAEkB,SAAU;QACfjB,SAAS,EAAET,IAAI,CACXD,GAAI;AAC5B;AACA;AACA;AACA,8BAA8BW,SAAS,KAAK,UAAU,GAAG,cAAc,GAAG,eAAgB;AAC1F,yBAAyB,EACDE,kBACJ,CAAE;QACFiC,KAAK,EAAEhC,cAAe;QAAAF,QAAA,EAErBA;MAAQ,CACR,CAAC,EACLkB,QAAQ,iBACL1B,IAAA;QACIK,GAAG,EAAEkB,SAAU;QACfjB,SAAS,EAAET,IAAI,CACXD,GAAI;AAChC;AACA;AACA;AACA,kCAAkCW,SAAS,KAAK,UAAU,GAAG,cAAc,GAAG,eAAgB;AAC9F,6BAA6B,EACDE,kBACJ,CAAE;QACFiC,KAAK,EAAEhC,cAAe;QAAAF,QAAA,EAErBA;MAAQ,CACR,CACR;IAAA,CACA;EAAC,CACL,CAAC;AAEd,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Fragment, createElement, useImperativeHandle, useRef, useState } from "react";
|
|
4
|
+
import { InputFile, getFileData } from "./InputFile";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
/** 专用于读取文件的 button 组件 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Fragment","createElement","useImperativeHandle","useRef","useState","InputFile","getFileData","jsx","_jsx","jsxs","_jsxs","InputFileButton","props","as","onClick","_onClick","inputProps","accept","onDrop","_onDrop","onDragOver","_onDragOver","dragFile","disabled","_disabled","type","multiple","onValueChange","onFileChange","clearAfterChange","rest","ref","style","__disabled","restInputProps","setDisabled","input","current","e","click","preventDefault","files","dataTransfer","length","files2","Array","from","values","file","value","push","children","display"],"sources":["../../../src/components/InputFileButton.tsx"],"sourcesContent":["\"use client\"\n\nimport {\n ComponentProps,\n ComponentRef,\n DragEvent,\n Fragment,\n JSX,\n JSXElementConstructor,\n MouseEvent as ReactMouseEvent,\n createElement,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\"\n\nimport { FileType, InputFile, InputFileBaseProps, InputFileDataType, InputFileDataTypeMap, InputFileExtraProps, ValueType, getFileData } from \"./InputFile\"\n\nexport type InputFileButtonProps<\n Multiple extends boolean = false,\n Type extends InputFileDataType = \"file\",\n AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = \"button\",\n> = Omit<ComponentProps<AS>, \"as\" | \"type\" | \"disabled\"> &\n InputFileExtraProps<Multiple, Type> & {\n disabled?: boolean\n inputProps?: Omit<InputFileBaseProps, \"accept\">\n accept?: string\n dragFile?: boolean\n as?: AS\n }\n\n/** 专用于读取文件的 button 组件 */\nexport function InputFileButton<\n Multiple extends boolean = false,\n Type extends InputFileDataType = \"file\",\n AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = \"button\",\n>(props: InputFileButtonProps<Multiple, Type, AS>) {\n const {\n as = \"button\",\n onClick: _onClick,\n inputProps = {},\n accept,\n onDrop: _onDrop,\n onDragOver: _onDragOver,\n dragFile,\n disabled: _disabled,\n type = \"file\",\n multiple,\n onValueChange,\n onFileChange,\n clearAfterChange,\n ...rest\n } = props\n\n const { ref, style, disabled: __disabled, ...restInputProps } = inputProps\n const [disabled, setDisabled] = useState(false)\n const input = useRef<HTMLInputElement>(null)\n\n useImperativeHandle(ref, () => input.current!, [input.current])\n\n function onClick(e: ReactMouseEvent<ComponentRef<AS>, MouseEvent>) {\n input.current?.click()\n _onClick?.(e as any)\n }\n\n async function onDrop(e: DragEvent<ComponentRef<AS>>) {\n _onDrop?.(e as any)\n if (disabled || !dragFile) return\n e.preventDefault()\n const { files } = e.dataTransfer\n if (!files || files.length === 0) return\n setDisabled(true)\n try {\n if (multiple) {\n const files2: File[] = Array.from(files)\n const values: InputFileDataTypeMap[Type][] = []\n for (const file of files2) {\n const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]\n values.push(value)\n }\n onFileChange?.(files2 as FileType<Multiple>)\n onValueChange?.(values as ValueType<Multiple, Type>)\n } else {\n const file = files[0]\n onFileChange?.(file as FileType<Multiple>)\n onValueChange?.((await getFileData(file, type)) as ValueType<Multiple, Type>)\n }\n } finally {\n setDisabled(false)\n }\n }\n\n function onDragOver(e: DragEvent<ComponentRef<AS>>) {\n _onDragOver?.(e as any)\n if (disabled || !dragFile) return\n e.preventDefault()\n }\n\n return (\n <Fragment>\n <InputFile<Multiple, Type>\n ref={input}\n disabled={disabled || _disabled || __disabled}\n style={{ display: \"none\", ...style }}\n multiple={multiple}\n accept={accept}\n type={type as Type}\n onValueChange={onValueChange}\n onFileChange={onFileChange}\n clearAfterChange={clearAfterChange}\n {...restInputProps}\n />\n {createElement(as, {\n disabled: disabled || _disabled,\n onClick,\n onDrop,\n onDragOver,\n ...rest,\n })}\n </Fragment>\n )\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAIIA,QAAQ,EAIRC,aAAa,EACbC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AAEd,SAAmBC,SAAS,EAA+FC,WAAW;AAAqB,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAe3J;AACA,OAAO,SAASC,eAAeA,CAI7BC,KAA+C,EAAE;EAC/C,MAAM;IACFC,EAAE,GAAG,QAAQ;IACbC,OAAO,EAAEC,QAAQ;IACjBC,UAAU,GAAG,CAAC,CAAC;IACfC,MAAM;IACNC,MAAM,EAAEC,OAAO;IACfC,UAAU,EAAEC,WAAW;IACvBC,QAAQ;IACRC,QAAQ,EAAEC,SAAS;IACnBC,IAAI,GAAG,MAAM;IACbC,QAAQ;IACRC,aAAa;IACbC,YAAY;IACZC,gBAAgB;IAChB,GAAGC;EACP,CAAC,GAAGlB,KAAK;EAET,MAAM;IAAEmB,GAAG;IAAEC,KAAK;IAAET,QAAQ,EAAEU,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AAa,GAAI,MAAMrB,WAAW,CAAC0C,IAAI,EAAEvB,IAAI,CAA+B,CAAC;MACjF;IACJ,CAAC,SAAS;MACNU,WAAW,CAAC,KAAK,CAAC;IACtB;EACJ;EAEA,SAASf,UAAUA,CAACkB,CAA8B,EAAE;IAChDjB,WAAW,GAAGiB,CAAQ,CAAC;IACvB,IAAIf,QAAQ,IAAI,CAACD,QAAQ,EAAE;IAC3BgB,CAAC,CAACE,cAAc,CAAC,CAAC;EACtB;EAEA,oBACI9B,KAAA,CAACV,QAAQ;IAAAmD,QAAA,gBACL3C,IAAA,CAACH,SAAS;MACN0B,GAAG,EAAEK,KAAM;MACXb,QAAQ,EAAEA,QAAQ,IAAIC,SAAS,IAAIS,UAAW;MAC9CD,KAAK,EAAE;QAAEoB,OAAO,EAAE,MAAM;QAAE,GAAGpB;MAAM,CAAE;MACrCN,QAAQ,EAAEA,QAAS;MACnBT,MAAM,EAAEA,MAAO;MACfQ,IAAI,EAAEA,IAAa;MACnBE,aAAa,EAAEA,aAAc;MAC7BC,YAAY,EAAEA,YAAa;MAC3BC,gBAAgB,EAAEA,gBAAiB;MAAA,GAC/BK;IAAc,CACrB,CAAC,eACDjC,aAAa,CAACY,EAAE,EAAE;MACfU,QAAQ,EAAEA,QAAQ,IAAIC,SAAS;MAC/BV,OAAO;MACPI,MAAM;MACNE,UAAU;MACV,GAAGU;IACP,CAAC,CAAC;EAAA,CACI,CAAC;AAEnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
4
|
-
import { useSize } from "
|
|
4
|
+
import { useSize } from "soda-hooks";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
/** 尺寸渐变的组件 */
|
|
7
7
|
export const TransitionBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useEffect","useRef","useState","useSize","jsx","_jsx","TransitionBox","props","ref","style","containerClassName","containerStyle","children","vertical","horizontal","time","rest","container","size","width","height","count","setCount","Math","min","outerStyle","transitionProperty","filter","Boolean","join","undefined","transitionDuration","overflow","position","className"],"sources":["../../../src/components/TransitionBox.tsx"],"sourcesContent":["\"use client\"\n\nimport { CSSProperties, FC, HTMLAttributes, forwardRef, useEffect, useRef, useState } from \"react\"\nimport { useSize } from \"
|
|
1
|
+
{"version":3,"names":["forwardRef","useEffect","useRef","useState","useSize","jsx","_jsx","TransitionBox","props","ref","style","containerClassName","containerStyle","children","vertical","horizontal","time","rest","container","size","width","height","count","setCount","Math","min","outerStyle","transitionProperty","filter","Boolean","join","undefined","transitionDuration","overflow","position","className"],"sources":["../../../src/components/TransitionBox.tsx"],"sourcesContent":["\"use client\"\n\nimport { CSSProperties, FC, HTMLAttributes, forwardRef, useEffect, useRef, useState } from \"react\"\nimport { useSize } from \"soda-hooks\"\n\nexport interface TransitionBoxProps extends HTMLAttributes<HTMLDivElement> {\n containerClassName?: string\n containerStyle?: CSSProperties\n vertical?: boolean\n horizontal?: boolean\n time?: number\n}\n\n/** 尺寸渐变的组件 */\nexport const TransitionBox: FC<TransitionBoxProps> = forwardRef<HTMLDivElement, TransitionBoxProps>((props, ref) => {\n const { style, containerClassName, containerStyle, children, vertical = true, horizontal = true, time = 3000, ...rest } = props\n const container = useRef<HTMLDivElement>(null)\n const size = useSize(container)\n const width = size?.width ?? 0\n const height = size?.height ?? 0\n const [count, setCount] = useState(0)\n\n useEffect(() => {\n setCount(count => Math.min(count + 1, 3))\n }, [width, height])\n\n const outerStyle: CSSProperties = {\n transitionProperty: count === 3 ? [horizontal && \"width\", vertical && \"height\"].filter(Boolean).join(\", \") : undefined,\n transitionDuration: count === 3 ? `${time}ms` : undefined,\n width,\n height,\n overflow: \"hidden\",\n position: \"relative\",\n ...style,\n }\n\n return (\n <div ref={ref} style={outerStyle} {...rest}>\n <div className={containerClassName} style={{ position: \"absolute\", ...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GAAGe,SAAS;IACzDX,KAAK;IACLC,MAAM;IACNY,QAAQ,EAAE,QAAQ;IAClBC,QAAQ,EAAE,UAAU;IACpB,GAAGxB;EACP,CAAC;EAED,oBACIJ,IAAA;IAAKG,GAAG,EAAEA,GAAI;IAACC,KAAK,EAAEgB,UAAW;IAAA,GAAKT,IAAI;IAAAJ,QAAA,eACtCP,IAAA;MAAK6B,SAAS,EAAExB,kBAAmB;MAACD,KAAK,EAAE;QAAEwB,QAAQ,EAAE,UAAU;QAAE,GAAGtB;MAAe,CAAE;MAACH,GAAG,EAAES,SAAU;MAAAL,QAAA,EAClGA;IAAQ,CACR;EAAC,CACL,CAAC;AAEd,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { clsx } from "deepsea-tools";
|
|
4
3
|
import { createContext, createElement, useContext } from "react";
|
|
4
|
+
import { clsx } from "deepsea-tools";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
const UnifyConfigContext = /*#__PURE__*/createContext({});
|
|
7
7
|
export const UnifyConfigProvider = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createContext","createElement","useContext","clsx","jsx","_jsx","UnifyConfigContext","UnifyConfigProvider","className","style","children","_className","_style","Provider","value","Unify","props","as","rest"],"sources":["../../../src/components/Unify.tsx"],"sourcesContent":["\"use client\"\n\nimport { CSSProperties, ComponentProps, FC, JSX, JSXElementConstructor, ReactNode, createContext, createElement, useContext } from \"react\"\nimport { clsx } from \"deepsea-tools\"\n\nexport interface UnifyConfig {\n className?: string\n style?: CSSProperties\n}\n\nconst UnifyConfigContext = createContext<UnifyConfig>({})\n\nexport interface UnifyConfigProviderProps extends UnifyConfig {\n children?: ReactNode\n}\n\nexport const UnifyConfigProvider: FC<UnifyConfigProviderProps> = ({ className, style, children }) => {\n const { className: _className, style: _style } = useContext(UnifyConfigContext)\n\n return (\n <UnifyConfigContext.Provider value={{ className: clsx(_className, className), style: { ..._style, ...style } }}>{children}</UnifyConfigContext.Provider>\n )\n}\n\nexport type UnifyProps<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = \"div\"> = Omit<ComponentProps<AS>, \"as\"> & {\n as?: AS\n}\n\nexport function Unify<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = \"div\">(props: UnifyProps<AS>) {\n const { as = \"div\", className, style, ...rest } = props\n const { className: _className, style: _style } = useContext(UnifyConfigContext)\n\n return createElement(as, {\n className: clsx(_className, className),\n style: { ..._style, ...style },\n ...rest,\n }) as ReactNode\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAmFA,aAAa,EAAEC,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAC1I,SAASC,IAAI,QAAQ,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOpC,MAAMC,kBAAkB,gBAAGN,aAAa,CAAc,CAAC,CAAC,CAAC;AAMzD,OAAO,MAAMO,mBAAiD,GAAGA,CAAC;EAAEC,SAAS;EAAEC,KAAK;EAAEC;AAAS,CAAC,KAAK;EACjG,MAAM;IAAEF,SAAS,EAAEG,UAAU;IAAEF,KAAK,EAAEG;EAAO,CAAC,GAAGV,UAAU,CAACI,kBAAkB,CAAC;EAE/E,oBACID,IAAA,CAACC,kBAAkB,CAACO,QAAQ;IAACC,KAAK,EAAE;MAAEN,SAAS,EAAEL,IAAI,CAACQ,UAAU,EAAEH,SAAS,CAAC;MAAEC,KAAK,EAAE;QAAE,GAAGG,MAAM;QAAE,GAAGH;MAAM;IAAE,CAAE;IAAAC,QAAA,EAAEA;EAAQ,CAA8B,CAAC;AAEhK,CAAC;AAMD,OAAO,SAASK,KAAKA,CAA8EC,KAAqB,EAAE;EACtH,MAAM;IAAEC,EAAE,GAAG,KAAK;IAAET,SAAS;IAAEC,KAAK;IAAE,GAAGS;EAAK,CAAC,GAAGF,KAAK;EACvD,MAAM;IAAER,SAAS,EAAEG,UAAU;IAAEF,KAAK,EAAEG;EAAO,CAAC,GAAGV,UAAU,CAACI,kBAAkB,CAAC;EAE/E,oBAAOL,aAAa,CAACgB,EAAE,EAAE;IACrBT,SAAS,EAAEL,IAAI,CAACQ,UAAU,EAAEH,SAAS,CAAC;IACtCC,KAAK,EAAE;MAAE,GAAGG,MAAM;MAAE,GAAGH;IAAM,CAAC;IAC9B,GAAGS;EACP,CAAC,CAAC;AACN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepsea-components",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.5",
|
|
4
4
|
"description": "格数科技自用组件库",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@emotion/css": "^11.13.5",
|
|
30
|
-
"ahooks": "^3.8.4",
|
|
31
30
|
"clipboard": "^2.0.11",
|
|
32
31
|
"echarts": "^5.6.0",
|
|
33
32
|
"hls.js": "^1.5.20",
|
|
34
33
|
"smooth-scrollbar": "^8.8.4",
|
|
35
|
-
"deepsea-tools": "5.19.3"
|
|
34
|
+
"deepsea-tools": "5.19.3",
|
|
35
|
+
"soda-hooks": "6.5.9"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@types/react": ">=18.3.18",
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { CSSProperties, MouseEvent as ReactMouseEvent, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
4
|
import { css } from "@emotion/css"
|
|
5
|
-
import { useSize } from "ahooks"
|
|
6
5
|
import { clsx, getArray } from "deepsea-tools"
|
|
7
6
|
import Scrollbar from "smooth-scrollbar"
|
|
8
7
|
import { ScrollStatus } from "smooth-scrollbar/interfaces/scrollbar"
|
|
8
|
+
import { useSize } from "soda-hooks"
|
|
9
9
|
|
|
10
10
|
import { px, transformCSSVariable } from "@/utils"
|
|
11
11
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ComponentPropsWithoutRef, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
|
-
import { useLatest } from "ahooks"
|
|
5
4
|
import ClipboardJS, { Event } from "clipboard"
|
|
5
|
+
import { useLatest } from "soda-hooks"
|
|
6
6
|
|
|
7
7
|
export { Event } from "clipboard"
|
|
8
8
|
|
package/src/components/Flow.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { CSSProperties, HTMLAttributes, Key, ReactNode, Ref, useEffect, useImperativeHandle, useRef, useState } from "react"
|
|
3
4
|
import { css } from "@emotion/css"
|
|
4
|
-
import { useSize } from "ahooks"
|
|
5
5
|
import { clsx } from "deepsea-tools"
|
|
6
|
-
import {
|
|
6
|
+
import { useSize } from "soda-hooks"
|
|
7
7
|
|
|
8
8
|
import { px, transformCSSVariable } from "@/utils"
|
|
9
9
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { CSSProperties, ComponentPropsWithoutRef, MouseEvent as ReactMouseEvent, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
4
|
import { css } from "@emotion/css"
|
|
5
|
-
import { useSize } from "ahooks"
|
|
6
5
|
import { clsx } from "deepsea-tools"
|
|
6
|
+
import { useSize } from "soda-hooks"
|
|
7
7
|
|
|
8
8
|
export type InfiniteScrollProps = ComponentPropsWithoutRef<"div"> & {
|
|
9
9
|
/**
|
|
@@ -1,121 +1,122 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ComponentProps,
|
|
5
|
-
ComponentRef,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
useImperativeHandle,
|
|
13
|
-
useRef,
|
|
14
|
-
useState,
|
|
15
|
-
} from "react"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ComponentProps,
|
|
5
|
+
ComponentRef,
|
|
6
|
+
DragEvent,
|
|
7
|
+
Fragment,
|
|
8
|
+
JSX,
|
|
9
|
+
JSXElementConstructor,
|
|
10
|
+
MouseEvent as ReactMouseEvent,
|
|
11
|
+
createElement,
|
|
12
|
+
useImperativeHandle,
|
|
13
|
+
useRef,
|
|
14
|
+
useState,
|
|
15
|
+
} from "react"
|
|
16
|
+
|
|
17
|
+
import { FileType, InputFile, InputFileBaseProps, InputFileDataType, InputFileDataTypeMap, InputFileExtraProps, ValueType, getFileData } from "./InputFile"
|
|
18
|
+
|
|
19
|
+
export type InputFileButtonProps<
|
|
20
|
+
Multiple extends boolean = false,
|
|
21
|
+
Type extends InputFileDataType = "file",
|
|
22
|
+
AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "button",
|
|
23
|
+
> = Omit<ComponentProps<AS>, "as" | "type" | "disabled"> &
|
|
24
|
+
InputFileExtraProps<Multiple, Type> & {
|
|
25
|
+
disabled?: boolean
|
|
26
|
+
inputProps?: Omit<InputFileBaseProps, "accept">
|
|
27
|
+
accept?: string
|
|
28
|
+
dragFile?: boolean
|
|
29
|
+
as?: AS
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 专用于读取文件的 button 组件 */
|
|
33
|
+
export function InputFileButton<
|
|
34
|
+
Multiple extends boolean = false,
|
|
35
|
+
Type extends InputFileDataType = "file",
|
|
36
|
+
AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "button",
|
|
37
|
+
>(props: InputFileButtonProps<Multiple, Type, AS>) {
|
|
38
|
+
const {
|
|
39
|
+
as = "button",
|
|
40
|
+
onClick: _onClick,
|
|
41
|
+
inputProps = {},
|
|
42
|
+
accept,
|
|
43
|
+
onDrop: _onDrop,
|
|
44
|
+
onDragOver: _onDragOver,
|
|
45
|
+
dragFile,
|
|
46
|
+
disabled: _disabled,
|
|
47
|
+
type = "file",
|
|
48
|
+
multiple,
|
|
49
|
+
onValueChange,
|
|
50
|
+
onFileChange,
|
|
51
|
+
clearAfterChange,
|
|
52
|
+
...rest
|
|
53
|
+
} = props
|
|
54
|
+
|
|
55
|
+
const { ref, style, disabled: __disabled, ...restInputProps } = inputProps
|
|
56
|
+
const [disabled, setDisabled] = useState(false)
|
|
57
|
+
const input = useRef<HTMLInputElement>(null)
|
|
58
|
+
|
|
59
|
+
useImperativeHandle(ref, () => input.current!, [input.current])
|
|
60
|
+
|
|
61
|
+
function onClick(e: ReactMouseEvent<ComponentRef<AS>, MouseEvent>) {
|
|
62
|
+
input.current?.click()
|
|
63
|
+
_onClick?.(e as any)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function onDrop(e: DragEvent<ComponentRef<AS>>) {
|
|
67
|
+
_onDrop?.(e as any)
|
|
68
|
+
if (disabled || !dragFile) return
|
|
69
|
+
e.preventDefault()
|
|
70
|
+
const { files } = e.dataTransfer
|
|
71
|
+
if (!files || files.length === 0) return
|
|
72
|
+
setDisabled(true)
|
|
73
|
+
try {
|
|
74
|
+
if (multiple) {
|
|
75
|
+
const files2: File[] = Array.from(files)
|
|
76
|
+
const values: InputFileDataTypeMap[Type][] = []
|
|
77
|
+
for (const file of files2) {
|
|
78
|
+
const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]
|
|
79
|
+
values.push(value)
|
|
80
|
+
}
|
|
81
|
+
onFileChange?.(files2 as FileType<Multiple>)
|
|
82
|
+
onValueChange?.(values as ValueType<Multiple, Type>)
|
|
83
|
+
} else {
|
|
84
|
+
const file = files[0]
|
|
85
|
+
onFileChange?.(file as FileType<Multiple>)
|
|
86
|
+
onValueChange?.((await getFileData(file, type)) as ValueType<Multiple, Type>)
|
|
87
|
+
}
|
|
88
|
+
} finally {
|
|
89
|
+
setDisabled(false)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function onDragOver(e: DragEvent<ComponentRef<AS>>) {
|
|
94
|
+
_onDragOver?.(e as any)
|
|
95
|
+
if (disabled || !dragFile) return
|
|
96
|
+
e.preventDefault()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Fragment>
|
|
101
|
+
<InputFile<Multiple, Type>
|
|
102
|
+
ref={input}
|
|
103
|
+
disabled={disabled || _disabled || __disabled}
|
|
104
|
+
style={{ display: "none", ...style }}
|
|
105
|
+
multiple={multiple}
|
|
106
|
+
accept={accept}
|
|
107
|
+
type={type as Type}
|
|
108
|
+
onValueChange={onValueChange}
|
|
109
|
+
onFileChange={onFileChange}
|
|
110
|
+
clearAfterChange={clearAfterChange}
|
|
111
|
+
{...restInputProps}
|
|
112
|
+
/>
|
|
113
|
+
{createElement(as, {
|
|
114
|
+
disabled: disabled || _disabled,
|
|
115
|
+
onClick,
|
|
116
|
+
onDrop,
|
|
117
|
+
onDragOver,
|
|
118
|
+
...rest,
|
|
119
|
+
})}
|
|
120
|
+
</Fragment>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { CSSProperties, FC, HTMLAttributes, forwardRef, useEffect, useRef, useState } from "react"
|
|
4
|
-
import { useSize } from "
|
|
4
|
+
import { useSize } from "soda-hooks"
|
|
5
5
|
|
|
6
6
|
export interface TransitionBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
7
|
containerClassName?: string
|
package/src/components/Unify.tsx
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export interface UnifyConfig {
|
|
7
|
-
className?: string
|
|
8
|
-
style?: CSSProperties
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const UnifyConfigContext = createContext<UnifyConfig>({})
|
|
12
|
-
|
|
13
|
-
export interface UnifyConfigProviderProps extends UnifyConfig {
|
|
14
|
-
children?: ReactNode
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const UnifyConfigProvider: FC<UnifyConfigProviderProps> = ({ className, style, children }) => {
|
|
18
|
-
const { className: _className, style: _style } = useContext(UnifyConfigContext)
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<UnifyConfigContext.Provider value={{ className: clsx(_className, className), style: { ..._style, ...style } }}>{children}</UnifyConfigContext.Provider>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type UnifyProps<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "div"> = Omit<ComponentProps<AS>, "as"> & {
|
|
26
|
-
as?: AS
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function Unify<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "div">(props: UnifyProps<AS>) {
|
|
30
|
-
const { as = "div", className, style, ...rest } = props
|
|
31
|
-
const { className: _className, style: _style } = useContext(UnifyConfigContext)
|
|
32
|
-
|
|
33
|
-
return createElement(as, {
|
|
34
|
-
className: clsx(_className, className),
|
|
35
|
-
style: { ..._style, ...style },
|
|
36
|
-
...rest,
|
|
37
|
-
}) as ReactNode
|
|
38
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { CSSProperties, ComponentProps, FC, JSX, JSXElementConstructor, ReactNode, createContext, createElement, useContext } from "react"
|
|
4
|
+
import { clsx } from "deepsea-tools"
|
|
5
|
+
|
|
6
|
+
export interface UnifyConfig {
|
|
7
|
+
className?: string
|
|
8
|
+
style?: CSSProperties
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const UnifyConfigContext = createContext<UnifyConfig>({})
|
|
12
|
+
|
|
13
|
+
export interface UnifyConfigProviderProps extends UnifyConfig {
|
|
14
|
+
children?: ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const UnifyConfigProvider: FC<UnifyConfigProviderProps> = ({ className, style, children }) => {
|
|
18
|
+
const { className: _className, style: _style } = useContext(UnifyConfigContext)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<UnifyConfigContext.Provider value={{ className: clsx(_className, className), style: { ..._style, ...style } }}>{children}</UnifyConfigContext.Provider>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type UnifyProps<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "div"> = Omit<ComponentProps<AS>, "as"> & {
|
|
26
|
+
as?: AS
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function Unify<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "div">(props: UnifyProps<AS>) {
|
|
30
|
+
const { as = "div", className, style, ...rest } = props
|
|
31
|
+
const { className: _className, style: _style } = useContext(UnifyConfigContext)
|
|
32
|
+
|
|
33
|
+
return createElement(as, {
|
|
34
|
+
className: clsx(_className, className),
|
|
35
|
+
style: { ..._style, ...style },
|
|
36
|
+
...rest,
|
|
37
|
+
}) as ReactNode
|
|
38
|
+
}
|