deepsea-components 5.7.0 → 5.7.2

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.
Files changed (81) hide show
  1. package/README.md +23 -23
  2. package/dist/cjs/components/AutoFit.js +3 -1
  3. package/dist/cjs/components/AutoFit.js.map +2 -2
  4. package/dist/cjs/components/AutoScroll.js +16 -1
  5. package/dist/cjs/components/AutoScroll.js.map +2 -2
  6. package/dist/cjs/components/AutoSizeTextarea.js.map +1 -1
  7. package/dist/cjs/components/CircleText.js +31 -2
  8. package/dist/cjs/components/CircleText.js.map +2 -2
  9. package/dist/cjs/components/CopyButton.js.map +1 -1
  10. package/dist/cjs/components/Echart.js.map +2 -2
  11. package/dist/cjs/components/Flow.js +56 -3
  12. package/dist/cjs/components/Flow.js.map +2 -2
  13. package/dist/cjs/components/FormLabel.js.map +1 -1
  14. package/dist/cjs/components/HlsPlayer.js.map +1 -1
  15. package/dist/cjs/components/InfiniteScroll.js +15 -1
  16. package/dist/cjs/components/InfiniteScroll.js.map +2 -2
  17. package/dist/cjs/components/InputFile.js.map +1 -1
  18. package/dist/cjs/components/LoopSwiper.js +23 -2
  19. package/dist/cjs/components/LoopSwiper.js.map +2 -2
  20. package/dist/cjs/components/Ring.js +13 -1
  21. package/dist/cjs/components/Ring.js.map +2 -2
  22. package/dist/cjs/components/Scroll.js.map +2 -2
  23. package/dist/cjs/components/SectionRing.js +3 -1
  24. package/dist/cjs/components/SectionRing.js.map +2 -2
  25. package/dist/cjs/components/Skeleton.js.map +2 -2
  26. package/dist/cjs/components/Title.js.map +2 -2
  27. package/dist/cjs/components/TransitionBox.js +9 -1
  28. package/dist/cjs/components/TransitionBox.js.map +2 -2
  29. package/dist/cjs/components/TransitionNum.js.map +1 -1
  30. package/dist/cjs/components/Trapezium.js.map +1 -1
  31. package/dist/cjs/utils/getReactVersion.js.map +1 -1
  32. package/dist/cjs/utils/index.js.map +1 -1
  33. package/dist/esm/components/AutoFit.js +9 -9
  34. package/dist/esm/components/AutoFit.js.map +1 -1
  35. package/dist/esm/components/AutoScroll.js.map +1 -1
  36. package/dist/esm/components/AutoSizeTextarea.js +2 -2
  37. package/dist/esm/components/AutoSizeTextarea.js.map +1 -1
  38. package/dist/esm/components/CircleText.js.map +1 -1
  39. package/dist/esm/components/CopyButton.js.map +1 -1
  40. package/dist/esm/components/Echart.js.map +1 -1
  41. package/dist/esm/components/Flow.js.map +1 -1
  42. package/dist/esm/components/FormLabel.js +2 -2
  43. package/dist/esm/components/FormLabel.js.map +1 -1
  44. package/dist/esm/components/HlsPlayer.js.map +1 -1
  45. package/dist/esm/components/InfiniteScroll.js +4 -4
  46. package/dist/esm/components/InfiniteScroll.js.map +1 -1
  47. package/dist/esm/components/InputFile.js.map +1 -1
  48. package/dist/esm/components/LoopSwiper.js.map +1 -1
  49. package/dist/esm/components/Ring.js.map +1 -1
  50. package/dist/esm/components/Scroll.js.map +1 -1
  51. package/dist/esm/components/SectionRing.js.map +1 -1
  52. package/dist/esm/components/Skeleton.js.map +1 -1
  53. package/dist/esm/components/Title.js.map +1 -1
  54. package/dist/esm/components/TransitionBox.js.map +1 -1
  55. package/dist/esm/components/TransitionNum.js.map +1 -1
  56. package/dist/esm/components/Trapezium.js.map +1 -1
  57. package/dist/esm/utils/getReactVersion.js.map +1 -1
  58. package/dist/esm/utils/index.js.map +1 -1
  59. package/package.json +2 -2
  60. package/src/components/AutoFit.tsx +103 -101
  61. package/src/components/AutoScroll.tsx +148 -132
  62. package/src/components/AutoSizeTextarea.tsx +49 -49
  63. package/src/components/CircleText.tsx +81 -56
  64. package/src/components/CopyButton.tsx +29 -29
  65. package/src/components/Echart.tsx +67 -44
  66. package/src/components/Flow.tsx +270 -214
  67. package/src/components/FormLabel.tsx +38 -38
  68. package/src/components/HlsPlayer.tsx +34 -34
  69. package/src/components/InfiniteScroll.tsx +161 -135
  70. package/src/components/InputFile.tsx +234 -234
  71. package/src/components/LoopSwiper.tsx +125 -101
  72. package/src/components/Ring.tsx +30 -19
  73. package/src/components/Scroll.tsx +96 -95
  74. package/src/components/SectionRing.tsx +39 -36
  75. package/src/components/Skeleton.tsx +47 -46
  76. package/src/components/Title.tsx +23 -24
  77. package/src/components/TransitionBox.tsx +44 -36
  78. package/src/components/TransitionNum.tsx +54 -54
  79. package/src/components/Trapezium.tsx +59 -59
  80. package/src/utils/getReactVersion.ts +7 -7
  81. package/src/utils/index.ts +33 -33
@@ -1 +1 @@
1
- {"version":3,"names":["css","clsx","forwardRef","px","transformCSSVariable","jsx","_jsx","Trapezium","props","ref","top","bottom","height","borderRadius","className","style","rest","diff","a","Math","atan","b","tan","c","cos","d","sin","e","PI","f","g","h","width","clipath"],"sources":["../../../src/components/Trapezium.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { css } from \"@emotion/css\"\r\nimport { clsx } from \"deepsea-tools\"\r\nimport { HTMLAttributes, forwardRef } from \"react\"\r\nimport { px, transformCSSVariable } from \"../utils\"\r\n\r\nexport interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {\r\n top: number\r\n bottom: number\r\n height: number\r\n borderRadius: number\r\n}\r\n\r\n/** 梯形组件 */\r\nexport const Trapezium = forwardRef<HTMLDivElement, TrapeziumProps>((props, ref) => {\r\n const { top, bottom, height, borderRadius, className, style, ...rest } = props\r\n\r\n const diff = (bottom - top) / 2\r\n\r\n const a = Math.atan(height / diff) / 2\r\n\r\n const b = borderRadius / Math.tan(a)\r\n\r\n const c = b * Math.cos(a * 2)\r\n\r\n const d = b * Math.sin(a * 2)\r\n\r\n const e = Math.PI / 2 - a\r\n\r\n const f = borderRadius / Math.tan(e)\r\n\r\n const g = f * Math.cos(a * 2)\r\n\r\n const h = f * Math.sin(a * 2)\r\n\r\n return (\r\n <div\r\n ref={ref}\r\n className={clsx(\r\n css`\r\n width: var(--width);\r\n height: var(--height);\r\n clip-path: var(--clip-path);\r\n `,\r\n className\r\n )}\r\n style={transformCSSVariable(\r\n {\r\n width: px(bottom),\r\n height: px(height),\r\n clipath: `path(\"M ${diff + f} ${0} A ${borderRadius} ${borderRadius} 0 0 0 ${diff - g} ${h} L ${c} ${height - d} A ${borderRadius} ${borderRadius} 0 0 0 ${b} ${height} L ${bottom - b} ${height} A ${borderRadius} ${borderRadius} 0 0 0 ${bottom - c} ${height - d} L ${top + diff + g} ${h} A ${borderRadius} ${borderRadius} 0 0 0 ${top + diff - f} ${0} Z\")`\r\n },\r\n style\r\n )}\r\n {...rest}\r\n />\r\n )\r\n})\r\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,GAAG,QAAQ,cAAc;AAClC,SAASC,IAAI,QAAQ,eAAe;AACpC,SAAyBC,UAAU,QAAQ,OAAO;AAClD,SAASC,EAAE,EAAEC,oBAAoB;AAAkB,SAAAC,GAAA,IAAAC,IAAA;AASnD;AACA,OAAO,MAAMC,SAAS,gBAAGL,UAAU,CAAiC,CAACM,KAAK,EAAEC,GAAG,KAAK;EAChF,MAAM;IAAEC,GAAG;IAAEC,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,SAAS;IAAEC,KAAK;IAAE,GAAGC;EAAK,CAAC,GAAGR,KAAK;EAE9E,MAAMS,IAAI,GAAG,CAACN,MAAM,GAAGD,GAAG,IAAI,CAAC;EAE/B,MAAMQ,CAAC,GAAGC,IAAI,CAACC,IAAI,CAACR,MAAM,GAAGK,IAAI,CAAC,GAAG,CAAC;EAEtC,MAAMI,CAAC,GAAGR,YAAY,GAAGM,IAAI,CAACG,GAAG,CAACJ,CAAC,CAAC;EAEpC,MAAMK,CAAC,GAAGF,CAAC,GAAGF,IAAI,CAACK,GAAG,CAACN,CAAC,GAAG,CAAC,CAAC;EAE7B,MAAMO,CAAC,GAAGJ,CAAC,GAAGF,IAAI,CAACO,GAAG,CAACR,CAAC,GAAG,CAAC,CAAC;EAE7B,MAAMS,CAAC,GAAGR,IAAI,CAACS,EAAE,GAAG,CAAC,GAAGV,CAAC;EAEzB,MAAMW,CAAC,GAAGhB,YAAY,GAAGM,IAAI,CAACG,GAAG,CAACK,CAAC,CAAC;EAEpC,MAAMG,CAAC,GAAGD,CAAC,GAAGV,IAAI,CAACK,GAAG,CAACN,CAAC,GAAG,CAAC,CAAC;EAE7B,MAAMa,CAAC,GAAGF,CAAC,GAAGV,IAAI,CAACO,GAAG,CAACR,CAAC,GAAG,CAAC,CAAC;EAE7B,oBACIZ,IAAA;IACIG,GAAG,EAAEA,GAAI;IACTK,SAAS,EAAEb,IAAI,CACXD,GAAI;AACpB;AACA;AACA;AACA,iBAAiB,EACDc,SACJ,CAAE;IACFC,KAAK,EAAEX,oBAAoB,CACvB;MACI4B,KAAK,EAAE7B,EAAE,CAACQ,MAAM,CAAC;MACjBC,MAAM,EAAET,EAAE,CAACS,MAAM,CAAC;MAClBqB,OAAO,EAAG,WAAUhB,IAAI,GAAGY,CAAE,IAAG,CAAE,OAAMhB,YAAa,IAAGA,YAAa,UAASI,IAAI,GAAGa,CAAE,IAAGC,CAAE,MAAKR,CAAE,IAAGX,MAAM,GAAGa,CAAE,MAAKZ,YAAa,IAAGA,YAAa,UAASQ,CAAE,IAAGT,MAAO,MAAKD,MAAM,GAAGU,CAAE,IAAGT,MAAO,MAAKC,YAAa,IAAGA,YAAa,UAASF,MAAM,GAAGY,CAAE,IAAGX,MAAM,GAAGa,CAAE,MAAKf,GAAG,GAAGO,IAAI,GAAGa,CAAE,IAAGC,CAAE,MAAKlB,YAAa,IAAGA,YAAa,UAASH,GAAG,GAAGO,IAAI,GAAGY,CAAE,IAAG,CAAE;IAClW,CAAC,EACDd,KACJ,CAAE;IAAA,GACEC;EAAI,CACX,CAAC;AAEV,CAAC,CAAC"}
1
+ {"version":3,"names":["css","clsx","forwardRef","px","transformCSSVariable","jsx","_jsx","Trapezium","props","ref","top","bottom","height","borderRadius","className","style","rest","diff","a","Math","atan","b","tan","c","cos","d","sin","e","PI","f","g","h","width","clipath"],"sources":["../../../src/components/Trapezium.tsx"],"sourcesContent":["\"use client\"\n\nimport { css } from \"@emotion/css\"\nimport { clsx } from \"deepsea-tools\"\nimport { HTMLAttributes, forwardRef } from \"react\"\nimport { px, transformCSSVariable } from \"../utils\"\n\nexport interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {\n top: number\n bottom: number\n height: number\n borderRadius: number\n}\n\n/** 梯形组件 */\nexport const Trapezium = forwardRef<HTMLDivElement, TrapeziumProps>((props, ref) => {\n const { top, bottom, height, borderRadius, className, style, ...rest } = props\n\n const diff = (bottom - top) / 2\n\n const a = Math.atan(height / diff) / 2\n\n const b = borderRadius / Math.tan(a)\n\n const c = b * Math.cos(a * 2)\n\n const d = b * Math.sin(a * 2)\n\n const e = Math.PI / 2 - a\n\n const f = borderRadius / Math.tan(e)\n\n const g = f * Math.cos(a * 2)\n\n const h = f * Math.sin(a * 2)\n\n return (\n <div\n ref={ref}\n className={clsx(\n css`\n width: var(--width);\n height: var(--height);\n clip-path: var(--clip-path);\n `,\n className,\n )}\n style={transformCSSVariable(\n {\n width: px(bottom),\n height: px(height),\n clipath: `path(\"M ${diff + f} ${0} A ${borderRadius} ${borderRadius} 0 0 0 ${diff - g} ${h} L ${c} ${height - d} A ${borderRadius} ${borderRadius} 0 0 0 ${b} ${height} L ${bottom - b} ${height} A ${borderRadius} ${borderRadius} 0 0 0 ${bottom - c} ${height - d} L ${top + diff + g} ${h} A ${borderRadius} ${borderRadius} 0 0 0 ${top + diff - f} ${0} Z\")`,\n },\n style,\n )}\n {...rest}\n />\n )\n})\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,GAAG,QAAQ,cAAc;AAClC,SAASC,IAAI,QAAQ,eAAe;AACpC,SAAyBC,UAAU,QAAQ,OAAO;AAClD,SAASC,EAAE,EAAEC,oBAAoB;AAAkB,SAAAC,GAAA,IAAAC,IAAA;AASnD;AACA,OAAO,MAAMC,SAAS,gBAAGL,UAAU,CAAiC,CAACM,KAAK,EAAEC,GAAG,KAAK;EAChF,MAAM;IAAEC,GAAG;IAAEC,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,SAAS;IAAEC,KAAK;IAAE,GAAGC;EAAK,CAAC,GAAGR,KAAK;EAE9E,MAAMS,IAAI,GAAG,CAACN,MAAM,GAAGD,GAAG,IAAI,CAAC;EAE/B,MAAMQ,CAAC,GAAGC,IAAI,CAACC,IAAI,CAACR,MAAM,GAAGK,IAAI,CAAC,GAAG,CAAC;EAEtC,MAAMI,CAAC,GAAGR,YAAY,GAAGM,IAAI,CAACG,GAAG,CAACJ,CAAC,CAAC;EAEpC,MAAMK,CAAC,GAAGF,CAAC,GAAGF,IAAI,CAACK,GAAG,CAACN,CAAC,GAAG,CAAC,CAAC;EAE7B,MAAMO,CAAC,GAAGJ,CAAC,GAAGF,IAAI,CAACO,GAAG,CAACR,CAAC,GAAG,CAAC,CAAC;EAE7B,MAAMS,CAAC,GAAGR,IAAI,CAACS,EAAE,GAAG,CAAC,GAAGV,CAAC;EAEzB,MAAMW,CAAC,GAAGhB,YAAY,GAAGM,IAAI,CAACG,GAAG,CAACK,CAAC,CAAC;EAEpC,MAAMG,CAAC,GAAGD,CAAC,GAAGV,IAAI,CAACK,GAAG,CAACN,CAAC,GAAG,CAAC,CAAC;EAE7B,MAAMa,CAAC,GAAGF,CAAC,GAAGV,IAAI,CAACO,GAAG,CAACR,CAAC,GAAG,CAAC,CAAC;EAE7B,oBACIZ,IAAA;IACIG,GAAG,EAAEA,GAAI;IACTK,SAAS,EAAEb,IAAI,CACXD,GAAI;AACpB;AACA;AACA;AACA,iBAAiB,EACDc,SACJ,CAAE;IACFC,KAAK,EAAEX,oBAAoB,CACvB;MACI4B,KAAK,EAAE7B,EAAE,CAACQ,MAAM,CAAC;MACjBC,MAAM,EAAET,EAAE,CAACS,MAAM,CAAC;MAClBqB,OAAO,EAAG,WAAUhB,IAAI,GAAGY,CAAE,IAAG,CAAE,OAAMhB,YAAa,IAAGA,YAAa,UAASI,IAAI,GAAGa,CAAE,IAAGC,CAAE,MAAKR,CAAE,IAAGX,MAAM,GAAGa,CAAE,MAAKZ,YAAa,IAAGA,YAAa,UAASQ,CAAE,IAAGT,MAAO,MAAKD,MAAM,GAAGU,CAAE,IAAGT,MAAO,MAAKC,YAAa,IAAGA,YAAa,UAASF,MAAM,GAAGY,CAAE,IAAGX,MAAM,GAAGa,CAAE,MAAKf,GAAG,GAAGO,IAAI,GAAGa,CAAE,IAAGC,CAAE,MAAKlB,YAAa,IAAGA,YAAa,UAASH,GAAG,GAAGO,IAAI,GAAGY,CAAE,IAAG,CAAE;IAClW,CAAC,EACDd,KACJ,CAAE;IAAA,GACEC;EAAI,CACX,CAAC;AAEV,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["version","reg","getReactVersion","match","slice","map","Number"],"sources":["../../../src/utils/getReactVersion.ts"],"sourcesContent":["import { version } from \"react\"\r\n\r\nconst reg = /(\\d+)\\.(\\d+)\\.(\\d+)/\r\n\r\nexport function getReactVersion() {\r\n return version.match(reg)!.slice(1).map(Number)\r\n}\r\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,MAAMC,GAAG,GAAG,qBAAqB;AAEjC,OAAO,SAASC,eAAeA,CAAA,EAAG;EAC9B,OAAOF,OAAO,CAACG,KAAK,CAACF,GAAG,CAAC,CAAEG,KAAK,CAAC,CAAC,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;AACnD"}
1
+ {"version":3,"names":["version","reg","getReactVersion","match","slice","map","Number"],"sources":["../../../src/utils/getReactVersion.ts"],"sourcesContent":["import { version } from \"react\"\n\nconst reg = /(\\d+)\\.(\\d+)\\.(\\d+)/\n\nexport function getReactVersion() {\n return version.match(reg)!.slice(1).map(Number)\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,MAAMC,GAAG,GAAG,qBAAqB;AAEjC,OAAO,SAASC,eAAeA,CAAA,EAAG;EAC9B,OAAOF,OAAO,CAACG,KAAK,CAACF,GAAG,CAAC,CAAEG,KAAK,CAAC,CAAC,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;AACnD"}
@@ -1 +1 @@
1
- {"version":3,"names":["cssVariableReg","addCSSVariableLine","match","transformCSSVariableName","name","replace","toLowerCase","transformCSSVariable","style","style2","Object","assign","entries","reduce","acc","key","value","px"],"sources":["../../../src/utils/index.ts"],"sourcesContent":["import { CSSProperties } from \"react\"\r\n\r\nexport type CSSVariableName = `--${string}`\r\n\r\nexport type CSSVariableValue = string | number | undefined\r\n\r\nexport interface StyleWithCSSVariable extends CSSProperties {\r\n [X: CSSVariableName]: CSSVariableValue\r\n}\r\n\r\nconst cssVariableReg = /[A-Z]/\r\n\r\nfunction addCSSVariableLine(match: string): string {\r\n return `-${match}`\r\n}\r\n\r\nexport function transformCSSVariableName(name: string): CSSVariableName {\r\n return `--${name.replace(cssVariableReg, addCSSVariableLine).toLowerCase()}`\r\n}\r\n\r\nexport function transformCSSVariable(style: Partial<Record<string, CSSVariableValue>>, style2?: CSSProperties): CSSProperties {\r\n return Object.assign(\r\n Object.entries(style).reduce((acc: StyleWithCSSVariable, [key, value]) => {\r\n acc[transformCSSVariableName(key)] = value\r\n return acc\r\n }, {}),\r\n style2\r\n )\r\n}\r\n\r\nexport function px(value: string | number | undefined): string | undefined {\r\n return typeof value === \"number\" ? `${value}px` : value\r\n}\r\n"],"mappings":"AAUA,MAAMA,cAAc,GAAG,OAAO;AAE9B,SAASC,kBAAkBA,CAACC,KAAa,EAAU;EAC/C,OAAQ,IAAGA,KAAM,EAAC;AACtB;AAEA,OAAO,SAASC,wBAAwBA,CAACC,IAAY,EAAmB;EACpE,OAAQ,KAAIA,IAAI,CAACC,OAAO,CAACL,cAAc,EAAEC,kBAAkB,CAAC,CAACK,WAAW,CAAC,CAAE,EAAC;AAChF;AAEA,OAAO,SAASC,oBAAoBA,CAACC,KAAgD,EAAEC,MAAsB,EAAiB;EAC1H,OAAOC,MAAM,CAACC,MAAM,CAChBD,MAAM,CAACE,OAAO,CAACJ,KAAK,CAAC,CAACK,MAAM,CAAC,CAACC,GAAyB,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IACtEF,GAAG,CAACX,wBAAwB,CAACY,GAAG,CAAC,CAAC,GAAGC,KAAK;IAC1C,OAAOF,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC,EACNL,MACJ,CAAC;AACL;AAEA,OAAO,SAASQ,EAAEA,CAACD,KAAkC,EAAsB;EACvE,OAAO,OAAOA,KAAK,KAAK,QAAQ,GAAI,GAAEA,KAAM,IAAG,GAAGA,KAAK;AAC3D"}
1
+ {"version":3,"names":["cssVariableReg","addCSSVariableLine","match","transformCSSVariableName","name","replace","toLowerCase","transformCSSVariable","style","style2","Object","assign","entries","reduce","acc","key","value","px"],"sources":["../../../src/utils/index.ts"],"sourcesContent":["import { CSSProperties } from \"react\"\n\nexport type CSSVariableName = `--${string}`\n\nexport type CSSVariableValue = string | number | undefined\n\nexport interface StyleWithCSSVariable extends CSSProperties {\n [X: CSSVariableName]: CSSVariableValue\n}\n\nconst cssVariableReg = /[A-Z]/\n\nfunction addCSSVariableLine(match: string): string {\n return `-${match}`\n}\n\nexport function transformCSSVariableName(name: string): CSSVariableName {\n return `--${name.replace(cssVariableReg, addCSSVariableLine).toLowerCase()}`\n}\n\nexport function transformCSSVariable(style: Partial<Record<string, CSSVariableValue>>, style2?: CSSProperties): CSSProperties {\n return Object.assign(\n Object.entries(style).reduce((acc: StyleWithCSSVariable, [key, value]) => {\n acc[transformCSSVariableName(key)] = value\n return acc\n }, {}),\n style2,\n )\n}\n\nexport function px(value: string | number | undefined): string | undefined {\n return typeof value === \"number\" ? `${value}px` : value\n}\n"],"mappings":"AAUA,MAAMA,cAAc,GAAG,OAAO;AAE9B,SAASC,kBAAkBA,CAACC,KAAa,EAAU;EAC/C,OAAQ,IAAGA,KAAM,EAAC;AACtB;AAEA,OAAO,SAASC,wBAAwBA,CAACC,IAAY,EAAmB;EACpE,OAAQ,KAAIA,IAAI,CAACC,OAAO,CAACL,cAAc,EAAEC,kBAAkB,CAAC,CAACK,WAAW,CAAC,CAAE,EAAC;AAChF;AAEA,OAAO,SAASC,oBAAoBA,CAACC,KAAgD,EAAEC,MAAsB,EAAiB;EAC1H,OAAOC,MAAM,CAACC,MAAM,CAChBD,MAAM,CAACE,OAAO,CAACJ,KAAK,CAAC,CAACK,MAAM,CAAC,CAACC,GAAyB,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IACtEF,GAAG,CAACX,wBAAwB,CAACY,GAAG,CAAC,CAAC,GAAGC,KAAK;IAC1C,OAAOF,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC,EACNL,MACJ,CAAC;AACL;AAEA,OAAO,SAASQ,EAAEA,CAACD,KAAkC,EAAsB;EACvE,OAAO,OAAOA,KAAK,KAAK,QAAQ,GAAI,GAAEA,KAAM,IAAG,GAAGA,KAAK;AAC3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepsea-components",
3
- "version": "5.7.0",
3
+ "version": "5.7.2",
4
4
  "description": "格数科技自用组件库",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -32,7 +32,7 @@
32
32
  "hls.js": "^1.5.8",
33
33
  "smooth-scrollbar": "^8.8.4",
34
34
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
35
- "deepsea-tools": "5.11.0"
35
+ "deepsea-tools": "5.13.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@types/react": "^18.3.1",
@@ -1,101 +1,103 @@
1
- "use client"
2
-
3
- import { css } from "@emotion/css"
4
- import { clsx } from "deepsea-tools"
5
- import { forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
- import { px, transformCSSVariable } from "../utils"
7
-
8
- export interface AutoFitProps extends HTMLAttributes<HTMLDivElement> {
9
- /** 设计稿宽度,默认 1920 */
10
- width?: number
11
- /** 设计稿高度,默认 1080 */
12
- height?: number
13
- /**
14
- * 在哪些方向进行缩放,默认缩放所有方向
15
- * 1. 水平方向是指,宽度按照设计稿进行占满,高度反向缩放
16
- * 2. 垂直方向是指,高度按照设计稿进行占满,宽度反向缩放
17
- * 3. 默认是水平和垂直方向都进行缩放,类似于 background-size: contain 的效果
18
- */
19
- direction?: "horizontal" | "vertical" | "both"
20
- }
21
-
22
- /**
23
- * 自适应缩放组件
24
- *
25
- * 注意:
26
- * 1. 父元素必须设置非 static 定位方式
27
- * 2. 父元素只能有且仅有一个子元素,那就是 AutoFit
28
- * 3. 不要设置 AutoFit 的 position、left、top、transform、width、height 属性
29
- * 4. 在第一次完成缩放前,无论 props 是什么,返回的都是 <div style={{ display: "none" }} />
30
- * 5. 元素的属性、事件、资源并不是立即加载的,会有一帧的延迟,在第一次完成缩放后才会显示
31
- */
32
- export const AutoFit = forwardRef<HTMLDivElement, AutoFitProps>((props, ref) => {
33
- const { width: designWidth = 1920, height: designHeight = 1080, direction, className, style, ...rest } = props
34
- const ele = useRef<HTMLDivElement>(null)
35
- const [show, setShow] = useState(false)
36
- const [transform, setTransform] = useState<string | undefined>(undefined)
37
- const [width, setWidth] = useState<string | undefined>(undefined)
38
- const [height, setHeight] = useState<string | undefined>(undefined)
39
-
40
- useImperativeHandle(ref, () => ele.current!, [ele.current])
41
- useLayoutEffect(() => {
42
- const element = ele.current
43
- const parent = element?.parentElement
44
- if (!element || !parent) return
45
- function listener(entries: ResizeObserverEntry[]) {
46
- const entry = entries[0]
47
- const { contentRect } = entry
48
- if (direction === "horizontal") {
49
- const scale = contentRect.width / designWidth
50
- setTransform(`scale(${scale})`)
51
- setWidth(px(designWidth))
52
- setHeight(px(contentRect.height / scale))
53
- } else if (direction === "vertical") {
54
- const scale = contentRect.height / designHeight
55
- setTransform(`scale(${scale})`)
56
- setWidth(px(contentRect.width / scale))
57
- setHeight(px(designHeight))
58
- } else {
59
- const scale = Math.min(contentRect.width / designWidth, contentRect.height / designHeight)
60
- setTransform(`translateX(${(contentRect.width - designWidth * scale) / 2}px) translateY(${(contentRect.height - designHeight * scale) / 2}px) scale(${scale})`)
61
- setWidth(px(designWidth))
62
- setHeight(px(designHeight))
63
- }
64
- setShow(true)
65
- }
66
- const observer = new ResizeObserver(listener)
67
- observer.observe(parent)
68
- return () => observer.disconnect()
69
- }, [ele.current?.parentElement, designWidth, designHeight, direction])
70
-
71
- if (process.env.NODE_ENV === "development") {
72
- useEffect(() => {
73
- const parent = ele.current?.parentElement
74
- if (!parent) return
75
- const style = getComputedStyle(parent)
76
- if (style.position === "static") {
77
- console.warn("AutoFit 组件的父元素的 position 属性不应该是 static")
78
- }
79
- }, [ele.current?.parentElement])
80
- }
81
-
82
- if (!show) return <div ref={ele} style={{ display: "none" }} />
83
-
84
- return (
85
- <div
86
- ref={ele}
87
- className={clsx(
88
- css`
89
- position: absolute;
90
- transform: var(--transform);
91
- transform-origin: top left;
92
- width: var(--width);
93
- height: var(--height);
94
- `,
95
- className
96
- )}
97
- style={transformCSSVariable({ transform, width, height }, style)}
98
- {...rest}
99
- />
100
- )
101
- })
1
+ "use client"
2
+
3
+ import { css } from "@emotion/css"
4
+ import { clsx } from "deepsea-tools"
5
+ import { forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
+ import { px, transformCSSVariable } from "../utils"
7
+
8
+ export interface AutoFitProps extends HTMLAttributes<HTMLDivElement> {
9
+ /** 设计稿宽度,默认 1920 */
10
+ width?: number
11
+ /** 设计稿高度,默认 1080 */
12
+ height?: number
13
+ /**
14
+ * 在哪些方向进行缩放,默认缩放所有方向
15
+ * 1. 水平方向是指,宽度按照设计稿进行占满,高度反向缩放
16
+ * 2. 垂直方向是指,高度按照设计稿进行占满,宽度反向缩放
17
+ * 3. 默认是水平和垂直方向都进行缩放,类似于 background-size: contain 的效果
18
+ */
19
+ direction?: "horizontal" | "vertical" | "both"
20
+ }
21
+
22
+ /**
23
+ * 自适应缩放组件
24
+ *
25
+ * 注意:
26
+ * 1. 父元素必须设置非 static 定位方式
27
+ * 2. 父元素只能有且仅有一个子元素,那就是 AutoFit
28
+ * 3. 不要设置 AutoFit 的 position、left、top、transform、width、height 属性
29
+ * 4. 在第一次完成缩放前,无论 props 是什么,返回的都是 <div style={{ display: "none" }} />
30
+ * 5. 元素的属性、事件、资源并不是立即加载的,会有一帧的延迟,在第一次完成缩放后才会显示
31
+ */
32
+ export const AutoFit = forwardRef<HTMLDivElement, AutoFitProps>((props, ref) => {
33
+ const { width: designWidth = 1920, height: designHeight = 1080, direction, className, style, ...rest } = props
34
+ const ele = useRef<HTMLDivElement>(null)
35
+ const [show, setShow] = useState(false)
36
+ const [transform, setTransform] = useState<string | undefined>(undefined)
37
+ const [width, setWidth] = useState<string | undefined>(undefined)
38
+ const [height, setHeight] = useState<string | undefined>(undefined)
39
+
40
+ useImperativeHandle(ref, () => ele.current!, [ele.current])
41
+ useLayoutEffect(() => {
42
+ const element = ele.current
43
+ const parent = element?.parentElement
44
+ if (!element || !parent) return
45
+ function listener(entries: ResizeObserverEntry[]) {
46
+ const entry = entries[0]
47
+ const { contentRect } = entry
48
+ if (direction === "horizontal") {
49
+ const scale = contentRect.width / designWidth
50
+ setTransform(`scale(${scale})`)
51
+ setWidth(px(designWidth))
52
+ setHeight(px(contentRect.height / scale))
53
+ } else if (direction === "vertical") {
54
+ const scale = contentRect.height / designHeight
55
+ setTransform(`scale(${scale})`)
56
+ setWidth(px(contentRect.width / scale))
57
+ setHeight(px(designHeight))
58
+ } else {
59
+ const scale = Math.min(contentRect.width / designWidth, contentRect.height / designHeight)
60
+ setTransform(
61
+ `translateX(${(contentRect.width - designWidth * scale) / 2}px) translateY(${(contentRect.height - designHeight * scale) / 2}px) scale(${scale})`,
62
+ )
63
+ setWidth(px(designWidth))
64
+ setHeight(px(designHeight))
65
+ }
66
+ setShow(true)
67
+ }
68
+ const observer = new ResizeObserver(listener)
69
+ observer.observe(parent)
70
+ return () => observer.disconnect()
71
+ }, [ele.current?.parentElement, designWidth, designHeight, direction])
72
+
73
+ if (process.env.NODE_ENV === "development") {
74
+ useEffect(() => {
75
+ const parent = ele.current?.parentElement
76
+ if (!parent) return
77
+ const style = getComputedStyle(parent)
78
+ if (style.position === "static") {
79
+ console.warn("AutoFit 组件的父元素的 position 属性不应该是 static")
80
+ }
81
+ }, [ele.current?.parentElement])
82
+ }
83
+
84
+ if (!show) return <div ref={ele} style={{ display: "none" }} />
85
+
86
+ return (
87
+ <div
88
+ ref={ele}
89
+ className={clsx(
90
+ css`
91
+ position: absolute;
92
+ transform: var(--transform);
93
+ transform-origin: top left;
94
+ width: var(--width);
95
+ height: var(--height);
96
+ `,
97
+ className,
98
+ )}
99
+ style={transformCSSVariable({ transform, width, height }, style)}
100
+ {...rest}
101
+ />
102
+ )
103
+ })
@@ -1,132 +1,148 @@
1
- "use client"
2
-
3
- import { css } from "@emotion/css"
4
- import { useSize } from "ahooks"
5
- import { clsx, getArray } from "deepsea-tools"
6
- import { CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
7
- import Scrollbar from "smooth-scrollbar"
8
- import { ScrollStatus } from "smooth-scrollbar/interfaces/scrollbar"
9
- import { px, transformCSSVariable } from "../utils"
10
- import { Scroll, ScrollProps } from "./Scroll"
11
-
12
- export interface AutoScrollProps extends ScrollProps {
13
- /** 轮播元素的个数 */
14
- count: number
15
-
16
- /** 轮播元素的高度 */
17
- itemHeight: number
18
-
19
- /**
20
- * 轮播动画的时间,单位毫秒
21
- * @default 1000
22
- */
23
- animation?: number
24
-
25
- /**
26
- * 每个元素的停留时间,单位毫秒
27
- * @default 3000
28
- */
29
- duration?: number
30
-
31
- /**
32
- * 元素之间的间距
33
- * @default 0
34
- */
35
- gap?: number
36
-
37
- /** 容器类名 */
38
- containerClassName?: string
39
-
40
- /** 容器样式 */
41
- containerStyle?: CSSProperties
42
-
43
- /**
44
- * 在鼠标移入时是否继续播放
45
- * @default false
46
- */
47
- playOnMouseEnter?: boolean
48
-
49
- /**
50
- * 是否暂停
51
- * @default false
52
- */
53
- paused?: boolean
54
- }
55
-
56
- export const AutoScroll = forwardRef<HTMLDivElement, AutoScrollProps>((props, ref) => {
57
- const { count, itemHeight, animation = 1000, duration = 3000, onMouseEnter, onMouseLeave, gap = 0, containerClassName, containerStyle, children, playOnMouseEnter, scrollbar, paused, ...rest } = props
58
- const bar = useRef<Scrollbar | null>(null)
59
- const timeout = useRef<NodeJS.Timeout | undefined>(undefined)
60
- const ele = useRef<HTMLDivElement>(null)
61
- const size = useSize(ele)
62
- const pausedRef = useRef(false)
63
- const pausedProps = useRef(paused)
64
- pausedProps.current = paused
65
-
66
- useImperativeHandle(ref, () => ele.current!, [])
67
- useImperativeHandle(scrollbar, () => bar.current!, [])
68
-
69
- useEffect(() => {
70
- if (playOnMouseEnter) pausedRef.current = false
71
- }, [playOnMouseEnter])
72
-
73
- useEffect(() => {
74
- if (!size || count === 0) return
75
- const { height } = size
76
- const range = getArray(count, index => (itemHeight + gap) * (index + 1) - (index === count - 1 ? gap : 0))
77
- const scrollHeight = range[range.length - 1]
78
- if (height >= scrollHeight) return
79
- function scroll(target: number) {
80
- clearTimeout(timeout.current)
81
- timeout.current = setTimeout(() => {
82
- if (pausedRef.current || pausedProps.current) return scroll(target)
83
- bar.current?.scrollTo(0, target, animation)
84
- }, duration)
85
- }
86
- scroll(range[0])
87
- function listener(status: ScrollStatus) {
88
- const { y } = status.offset
89
- const scrollToBottom = Math.abs(y + height - scrollHeight) / itemHeight <= 0.05
90
- const target = scrollToBottom ? 0 : range.find(item => item > y)!
91
- scroll(target)
92
- }
93
- bar.current?.addListener(listener)
94
- return () => {
95
- clearTimeout(timeout.current)
96
- bar.current?.removeListener(listener)
97
- bar.current?.scrollTo(0, 0)
98
- }
99
- }, [size, count, itemHeight, gap, duration, animation])
100
-
101
- function onContainerMouseEnter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
102
- if (playOnMouseEnter) return
103
- pausedRef.current = true
104
- onMouseEnter?.(e)
105
- }
106
-
107
- function onContainerMouseLeave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
108
- if (playOnMouseEnter) return
109
- pausedRef.current = false
110
- onMouseLeave?.(e)
111
- }
112
-
113
- return (
114
- <Scroll ref={ele} scrollbar={bar} onMouseEnter={onContainerMouseEnter} onMouseLeave={onContainerMouseLeave} {...rest}>
115
- <div
116
- className={clsx(
117
- css`
118
- display: flex;
119
- flex-direction: column;
120
- gap: var(--gap, 0);
121
- & > * {
122
- flex: none;
123
- }
124
- `,
125
- containerClassName
126
- )}
127
- style={transformCSSVariable({ gap: px(gap) }, containerStyle)}>
128
- {children}
129
- </div>
130
- </Scroll>
131
- )
132
- })
1
+ "use client"
2
+
3
+ import { css } from "@emotion/css"
4
+ import { useSize } from "ahooks"
5
+ import { clsx, getArray } from "deepsea-tools"
6
+ import { CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
7
+ import Scrollbar from "smooth-scrollbar"
8
+ import { ScrollStatus } from "smooth-scrollbar/interfaces/scrollbar"
9
+ import { px, transformCSSVariable } from "../utils"
10
+ import { Scroll, ScrollProps } from "./Scroll"
11
+
12
+ export interface AutoScrollProps extends ScrollProps {
13
+ /** 轮播元素的个数 */
14
+ count: number
15
+
16
+ /** 轮播元素的高度 */
17
+ itemHeight: number
18
+
19
+ /**
20
+ * 轮播动画的时间,单位毫秒
21
+ * @default 1000
22
+ */
23
+ animation?: number
24
+
25
+ /**
26
+ * 每个元素的停留时间,单位毫秒
27
+ * @default 3000
28
+ */
29
+ duration?: number
30
+
31
+ /**
32
+ * 元素之间的间距
33
+ * @default 0
34
+ */
35
+ gap?: number
36
+
37
+ /** 容器类名 */
38
+ containerClassName?: string
39
+
40
+ /** 容器样式 */
41
+ containerStyle?: CSSProperties
42
+
43
+ /**
44
+ * 在鼠标移入时是否继续播放
45
+ * @default false
46
+ */
47
+ playOnMouseEnter?: boolean
48
+
49
+ /**
50
+ * 是否暂停
51
+ * @default false
52
+ */
53
+ paused?: boolean
54
+ }
55
+
56
+ export const AutoScroll = forwardRef<HTMLDivElement, AutoScrollProps>((props, ref) => {
57
+ const {
58
+ count,
59
+ itemHeight,
60
+ animation = 1000,
61
+ duration = 3000,
62
+ onMouseEnter,
63
+ onMouseLeave,
64
+ gap = 0,
65
+ containerClassName,
66
+ containerStyle,
67
+ children,
68
+ playOnMouseEnter,
69
+ scrollbar,
70
+ paused,
71
+ ...rest
72
+ } = props
73
+ const bar = useRef<Scrollbar | null>(null)
74
+ const timeout = useRef<NodeJS.Timeout | undefined>(undefined)
75
+ const ele = useRef<HTMLDivElement>(null)
76
+ const size = useSize(ele)
77
+ const pausedRef = useRef(false)
78
+ const pausedProps = useRef(paused)
79
+ pausedProps.current = paused
80
+
81
+ useImperativeHandle(ref, () => ele.current!, [])
82
+ useImperativeHandle(scrollbar, () => bar.current!, [])
83
+
84
+ useEffect(() => {
85
+ if (playOnMouseEnter) pausedRef.current = false
86
+ }, [playOnMouseEnter])
87
+
88
+ useEffect(() => {
89
+ if (!size || count === 0) return
90
+ const { height } = size
91
+ const range = getArray(count, index => (itemHeight + gap) * (index + 1) - (index === count - 1 ? gap : 0))
92
+ const scrollHeight = range[range.length - 1]
93
+ if (height >= scrollHeight) return
94
+ function scroll(target: number) {
95
+ clearTimeout(timeout.current)
96
+ timeout.current = setTimeout(() => {
97
+ if (pausedRef.current || pausedProps.current) return scroll(target)
98
+ bar.current?.scrollTo(0, target, animation)
99
+ }, duration)
100
+ }
101
+ scroll(range[0])
102
+ function listener(status: ScrollStatus) {
103
+ const { y } = status.offset
104
+ const scrollToBottom = Math.abs(y + height - scrollHeight) / itemHeight <= 0.05
105
+ const target = scrollToBottom ? 0 : range.find(item => item > y)!
106
+ scroll(target)
107
+ }
108
+ bar.current?.addListener(listener)
109
+ return () => {
110
+ clearTimeout(timeout.current)
111
+ bar.current?.removeListener(listener)
112
+ bar.current?.scrollTo(0, 0)
113
+ }
114
+ }, [size, count, itemHeight, gap, duration, animation])
115
+
116
+ function onContainerMouseEnter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
117
+ if (playOnMouseEnter) return
118
+ pausedRef.current = true
119
+ onMouseEnter?.(e)
120
+ }
121
+
122
+ function onContainerMouseLeave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
123
+ if (playOnMouseEnter) return
124
+ pausedRef.current = false
125
+ onMouseLeave?.(e)
126
+ }
127
+
128
+ return (
129
+ <Scroll ref={ele} scrollbar={bar} onMouseEnter={onContainerMouseEnter} onMouseLeave={onContainerMouseLeave} {...rest}>
130
+ <div
131
+ className={clsx(
132
+ css`
133
+ display: flex;
134
+ flex-direction: column;
135
+ gap: var(--gap, 0);
136
+ & > * {
137
+ flex: none;
138
+ }
139
+ `,
140
+ containerClassName,
141
+ )}
142
+ style={transformCSSVariable({ gap: px(gap) }, containerStyle)}
143
+ >
144
+ {children}
145
+ </div>
146
+ </Scroll>
147
+ )
148
+ })
@@ -1,49 +1,49 @@
1
- "use client"
2
-
3
- import { css } from "@emotion/css"
4
- import { clsx } from "deepsea-tools"
5
- import { forwardRef, TextareaHTMLAttributes, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
- import { px, transformCSSVariable } from "../utils"
7
-
8
- /**
9
- * 自适应高度的文本域
10
- */
11
- export const AutoSizeTextArea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>((props, ref) => {
12
- const { className, style, ...rest } = props
13
- const [height, setHeight] = useState<string | undefined>(undefined)
14
- const ele = useRef<HTMLTextAreaElement>(null)
15
-
16
- useImperativeHandle(ref, () => ele.current!, [])
17
-
18
- useLayoutEffect(() => {
19
- const textarea = ele.current!
20
- function resizeTextarea() {
21
- setHeight("auto")
22
- setHeight(px(textarea.scrollHeight + textarea.offsetHeight - textarea.clientHeight))
23
- }
24
- resizeTextarea()
25
- textarea.addEventListener("input", resizeTextarea)
26
- textarea.addEventListener("change", resizeTextarea)
27
-
28
- return () => {
29
- textarea.removeEventListener("input", resizeTextarea)
30
- textarea.removeEventListener("change", resizeTextarea)
31
- }
32
- }, [])
33
-
34
- return (
35
- <textarea
36
- ref={ele}
37
- className={clsx(
38
- css`
39
- height: var(--height);
40
- resize: none;
41
- overflow-y: hidden;
42
- `,
43
- className
44
- )}
45
- style={transformCSSVariable({ height }, style)}
46
- {...rest}
47
- />
48
- )
49
- })
1
+ "use client"
2
+
3
+ import { css } from "@emotion/css"
4
+ import { clsx } from "deepsea-tools"
5
+ import { forwardRef, TextareaHTMLAttributes, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
+ import { px, transformCSSVariable } from "../utils"
7
+
8
+ /**
9
+ * 自适应高度的文本域
10
+ */
11
+ export const AutoSizeTextArea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>((props, ref) => {
12
+ const { className, style, ...rest } = props
13
+ const [height, setHeight] = useState<string | undefined>(undefined)
14
+ const ele = useRef<HTMLTextAreaElement>(null)
15
+
16
+ useImperativeHandle(ref, () => ele.current!, [])
17
+
18
+ useLayoutEffect(() => {
19
+ const textarea = ele.current!
20
+ function resizeTextarea() {
21
+ setHeight("auto")
22
+ setHeight(px(textarea.scrollHeight + textarea.offsetHeight - textarea.clientHeight))
23
+ }
24
+ resizeTextarea()
25
+ textarea.addEventListener("input", resizeTextarea)
26
+ textarea.addEventListener("change", resizeTextarea)
27
+
28
+ return () => {
29
+ textarea.removeEventListener("input", resizeTextarea)
30
+ textarea.removeEventListener("change", resizeTextarea)
31
+ }
32
+ }, [])
33
+
34
+ return (
35
+ <textarea
36
+ ref={ele}
37
+ className={clsx(
38
+ css`
39
+ height: var(--height);
40
+ resize: none;
41
+ overflow-y: hidden;
42
+ `,
43
+ className,
44
+ )}
45
+ style={transformCSSVariable({ height }, style)}
46
+ {...rest}
47
+ />
48
+ )
49
+ })