@ioca/react 1.3.75 → 1.3.77

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 (65) hide show
  1. package/lib/cjs/components/affix/totop.js +1 -2
  2. package/lib/cjs/components/affix/totop.js.map +1 -1
  3. package/lib/cjs/components/button/button.js +4 -0
  4. package/lib/cjs/components/button/button.js.map +1 -1
  5. package/lib/cjs/components/button/index.js +0 -1
  6. package/lib/cjs/components/button/index.js.map +1 -1
  7. package/lib/cjs/components/editor/controls.js +1 -2
  8. package/lib/cjs/components/editor/controls.js.map +1 -1
  9. package/lib/cjs/components/image/image.js +2 -2
  10. package/lib/cjs/components/image/image.js.map +1 -1
  11. package/lib/cjs/components/modal/modal.js +1 -2
  12. package/lib/cjs/components/modal/modal.js.map +1 -1
  13. package/lib/cjs/components/picker/colors/footer.js +1 -2
  14. package/lib/cjs/components/picker/colors/footer.js.map +1 -1
  15. package/lib/cjs/components/popconfirm/popconfirm.js +1 -2
  16. package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -1
  17. package/lib/cjs/components/popup/popup.js +1 -1
  18. package/lib/cjs/components/popup/popup.js.map +1 -1
  19. package/lib/cjs/components/tabs/tabs.js +1 -2
  20. package/lib/cjs/components/tabs/tabs.js.map +1 -1
  21. package/lib/cjs/components/upload/upload.js +1 -2
  22. package/lib/cjs/components/upload/upload.js.map +1 -1
  23. package/lib/cjs/components/video/video.js +1 -2
  24. package/lib/cjs/components/video/video.js.map +1 -1
  25. package/lib/cjs/index.js +2 -3
  26. package/lib/cjs/index.js.map +1 -1
  27. package/lib/cjs/js/usePreview/content.js +1 -2
  28. package/lib/cjs/js/usePreview/content.js.map +1 -1
  29. package/lib/css/index.css +1 -1
  30. package/lib/css/index.css.map +1 -1
  31. package/lib/es/components/affix/totop.js +1 -2
  32. package/lib/es/components/affix/totop.js.map +1 -1
  33. package/lib/es/components/button/button.js +4 -0
  34. package/lib/es/components/button/button.js.map +1 -1
  35. package/lib/es/components/button/index.js +0 -1
  36. package/lib/es/components/button/index.js.map +1 -1
  37. package/lib/es/components/editor/controls.js +1 -2
  38. package/lib/es/components/editor/controls.js.map +1 -1
  39. package/lib/es/components/image/image.js +2 -2
  40. package/lib/es/components/image/image.js.map +1 -1
  41. package/lib/es/components/modal/modal.js +1 -2
  42. package/lib/es/components/modal/modal.js.map +1 -1
  43. package/lib/es/components/picker/colors/footer.js +1 -2
  44. package/lib/es/components/picker/colors/footer.js.map +1 -1
  45. package/lib/es/components/popconfirm/popconfirm.js +1 -2
  46. package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
  47. package/lib/es/components/popup/popup.js +1 -1
  48. package/lib/es/components/popup/popup.js.map +1 -1
  49. package/lib/es/components/tabs/tabs.js +1 -2
  50. package/lib/es/components/tabs/tabs.js.map +1 -1
  51. package/lib/es/components/upload/upload.js +1 -2
  52. package/lib/es/components/upload/upload.js.map +1 -1
  53. package/lib/es/components/video/video.js +1 -2
  54. package/lib/es/components/video/video.js.map +1 -1
  55. package/lib/es/index.js +1 -2
  56. package/lib/es/index.js.map +1 -1
  57. package/lib/es/js/usePreview/content.js +1 -2
  58. package/lib/es/js/usePreview/content.js.map +1 -1
  59. package/lib/index.js +54 -55
  60. package/package.json +1 -1
  61. package/lib/cjs/components/button/merged.js +0 -13
  62. package/lib/cjs/components/button/merged.js.map +0 -1
  63. package/lib/es/components/button/merged.js +0 -9
  64. package/lib/es/components/button/merged.js.map +0 -1
  65. package/lib/types/components/button/merged.d.ts +0 -5
package/lib/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as Affix } from './components/affix/affix.js';
2
2
  export { default as Badge } from './components/badge/badge.js';
3
- import './components/button/merged.js';
3
+ export { default as Button } from './components/button/button.js';
4
4
  export { default as Card } from './components/card/card.js';
5
5
  export { default as Checkbox } from './components/checkbox/checkbox.js';
6
6
  export { default as Collapse } from './components/collapse/collapse.js';
@@ -37,5 +37,4 @@ export { default as Tree } from './components/tree/tree.js';
37
37
  export { default as Upload } from './components/upload/upload.js';
38
38
  export { default as Video } from './components/video/video.js';
39
39
  export { default as usePreview } from './js/usePreview/index.js';
40
- export { default as Button } from './components/button/button.js';
41
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import '../../components/button/merged.js';
2
+ import Button from '../../components/button/button.js';
3
3
  import Icon from '../../components/icon/icon.js';
4
4
  import { CloseRound, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound } from '@ricons/material';
5
5
  import { useReactive } from 'ahooks';
@@ -10,7 +10,6 @@ import { useMouseMove, useMouseUp } from '../hooks.js';
10
10
  import { getSuffixByUrl, getFileType } from '../utils.js';
11
11
  import renderFile from './renderFile.js';
12
12
  import { TFileType } from './type.js';
13
- import Button from '../../components/button/button.js';
14
13
 
15
14
  function Content(props) {
16
15
  const { items = [], initial = 0, renderFile: renderFile$1 = renderFile, onRotate, onChange, onClose, onZoom, } = props;
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sources":["../../../../packages/js/usePreview/content.tsx"],"sourcesContent":["import Button from \"@p/components/button\";\nimport Icon from \"@p/components/icon\";\nimport {\n\tAspectRatioRound,\n\tCloseRound,\n\tFileDownloadOutlined,\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tOpenInNewRound,\n\tRotateLeftRound,\n\tRotateRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useMemo, useRef } from \"react\";\nimport { useMouseMove, useMouseUp } from \"../hooks\";\nimport { getFileType, getSuffixByUrl } from \"../utils\";\nimport DefaultRenderFile from \"./renderFile\";\nimport { IPreview, TFileType, TPreviewItem } from \"./type\";\n\nexport default function Content(props: IPreview) {\n\tconst {\n\t\titems = [],\n\t\tinitial = 0,\n\t\trenderFile = DefaultRenderFile,\n\t\tonRotate,\n\t\tonChange,\n\t\tonClose,\n\t\tonZoom,\n\t} = props;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\trotate: 0,\n\t\tscale: 1,\n\t\ttranslate: [0, 0],\n\t\tstart: [0, 0],\n\t\tdragging: false,\n\t\tcontrolHidden: true,\n\t});\n\tconst box = useRef<HTMLDivElement>(null);\n\tconst translate = useRef<number[]>([0, 0]);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst files = useMemo(() => {\n\t\treturn items.map((item) => {\n\t\t\tconst o: TPreviewItem = {\n\t\t\t\tsrc: \"\",\n\t\t\t};\n\t\t\tif (typeof item === \"string\") {\n\t\t\t\to.src = item;\n\t\t\t} else {\n\t\t\t\tObject.assign(o, item);\n\t\t\t}\n\n\t\t\to.suffix = getSuffixByUrl(o.src) || \"\";\n\t\t\to.type = getFileType(o.suffix, item[\"type\"]);\n\n\t\t\treturn o;\n\t\t});\n\t}, [items]);\n\n\tconst { file, content } = useMemo(() => {\n\t\tconst file = files[state.current];\n\t\tconst content = renderFile(file);\n\n\t\treturn {\n\t\t\tfile,\n\t\t\tcontent,\n\t\t};\n\t}, [state.current, items]);\n\n\tconst isImage = file.type === TFileType.IMAGE;\n\n\tconst handleSwitch = (next: number) => {\n\t\tconst l = files.length;\n\t\tconst { current: before } = state;\n\t\tif (next >= l) {\n\t\t\tstate.current = 0;\n\t\t} else if (next < 0) {\n\t\t\tstate.current = l - 1;\n\t\t} else {\n\t\t\tstate.current = next;\n\t\t}\n\t\tonChange?.(state.current, before);\n\n\t\tstate.rotate = files[state.current].rotate || 0;\n\n\t\tif (state.scale !== 1) {\n\t\t\tstate.scale = 1;\n\t\t\tonZoom?.(1);\n\t\t}\n\t\tonRotate?.(state.rotate);\n\t\tstate.translate = translate.current = [0, 0];\n\t};\n\n\tconst handleRotate = (deg: number) => {\n\t\tstate.rotate += deg;\n\n\t\tonRotate?.(state.rotate);\n\t};\n\n\tconst handleMouseWheel = throttle({ interval: 60 }, (e) => {\n\t\tif (!isImage) return;\n\t\tlet after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);\n\t\tif (after > 2) after = 2;\n\t\tif (after < 0.25) after = 0.25;\n\n\t\tonZoom?.(after);\n\t\tstate.scale = after;\n\t});\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!isImage) return;\n\t\te.preventDefault();\n\t\tstate.dragging = true;\n\t\tstate.start = [e.pageX, e.pageY];\n\t};\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current || state.controlHidden) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst throttleMouseMove = throttle({ interval: 300 }, setHiddenFalse);\n\n\tconst handleMouseMove = (e) => {\n\t\tthrottleMouseMove();\n\t\tif (!state.dragging) return;\n\t\te.preventDefault();\n\n\t\tconst [x, y] = translate.current;\n\t\tconst [ox, oy] = state.start;\n\t\tconst offsetX = e.pageX - ox;\n\t\tconst offsetY = e.pageY - oy;\n\n\t\tstate.translate = [x + offsetX, y + offsetY];\n\t};\n\n\tconst handleMouseUp = () => {\n\t\tif (!state.dragging) return;\n\t\tstate.dragging = false;\n\t\ttranslate.current = state.translate;\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={box}\n\t\t\t\tclassName={classNames(\"i-preview-content\", {\n\t\t\t\t\t\"no-transition\": state.dragging,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\ttransform: `translate(${state.translate\n\t\t\t\t\t\t.map((n) => `${n}px`)\n\t\t\t\t\t\t.join(\",\")}) rotate(${state.rotate}deg) scale(${\n\t\t\t\t\t\tstate.scale\n\t\t\t\t\t})`,\n\t\t\t\t}}\n\t\t\t\tonWheel={handleMouseWheel}\n\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-preview-controls\", {\n\t\t\t\t\t\"i-preview-controls-hidden\": state.controlHidden,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<Button square flat onClick={onClose}>\n\t\t\t\t\t<Icon icon={<CloseRound />} />\n\t\t\t\t</Button>\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<span className='px-8'>\n\t\t\t\t\t\t{state.current + 1} / {files.length}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state.scale !== 1 && (\n\t\t\t\t\t<Button flat onClick={() => (state.scale = 1)}>\n\t\t\t\t\t\t<Icon icon={<AspectRatioRound />} />\n\t\t\t\t\t\t<span className='mt-2'>\n\t\t\t\t\t\t\t{(state.scale * 100).toFixed(0)}%\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Button>\n\t\t\t\t)}\n\t\t\t\t<Button square flat href={file.src} target='_blank'>\n\t\t\t\t\t<Icon icon={<OpenInNewRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat href={file.src} download target='_blank'>\n\t\t\t\t\t<Icon icon={<FileDownloadOutlined />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(90)}>\n\t\t\t\t\t<Icon icon={<RotateRightRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(-90)}>\n\t\t\t\t\t<Icon icon={<RotateLeftRound />} />\n\t\t\t\t</Button>\n\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current - 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowLeftRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current + 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowRightRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"names":["renderFile","DefaultRenderFile","_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;;AAqBwB,SAAA,OAAO,CAAC,KAAe,EAAA;IAC9C,MAAM,EACL,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,CAAC,cACXA,YAAU,GAAGC,UAAiB,EAC9B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,GACN,GAAG,KAAK;IACT,MAAM,KAAK,GAAG,WAAW,CAAC;AACzB,QAAA,OAAO,EAAE,OAAO;AAChB,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACR,QAAA,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,QAAA,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACb,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,aAAa,EAAE,IAAI;AACnB,KAAA,CAAC;AACF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC;IACxC,MAAM,SAAS,GAAG,MAAM,CAA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AAI,GACnC,CACP,EAAA,CAAA,CACH,CACI,EAAA,CAAA,CAAA,EAAA,CACJ;AAEL;;;;"}
1
+ {"version":3,"file":"content.js","sources":["../../../../packages/js/usePreview/content.tsx"],"sourcesContent":["import Button from \"@p/components/button\";\nimport Icon from \"@p/components/icon\";\nimport {\n\tAspectRatioRound,\n\tCloseRound,\n\tFileDownloadOutlined,\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tOpenInNewRound,\n\tRotateLeftRound,\n\tRotateRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useMemo, useRef } from \"react\";\nimport { useMouseMove, useMouseUp } from \"../hooks\";\nimport { getFileType, getSuffixByUrl } from \"../utils\";\nimport DefaultRenderFile from \"./renderFile\";\nimport { IPreview, TFileType, TPreviewItem } from \"./type\";\n\nexport default function Content(props: IPreview) {\n\tconst {\n\t\titems = [],\n\t\tinitial = 0,\n\t\trenderFile = DefaultRenderFile,\n\t\tonRotate,\n\t\tonChange,\n\t\tonClose,\n\t\tonZoom,\n\t} = props;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\trotate: 0,\n\t\tscale: 1,\n\t\ttranslate: [0, 0],\n\t\tstart: [0, 0],\n\t\tdragging: false,\n\t\tcontrolHidden: true,\n\t});\n\tconst box = useRef<HTMLDivElement>(null);\n\tconst translate = useRef<number[]>([0, 0]);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst files = useMemo(() => {\n\t\treturn items.map((item) => {\n\t\t\tconst o: TPreviewItem = {\n\t\t\t\tsrc: \"\",\n\t\t\t};\n\t\t\tif (typeof item === \"string\") {\n\t\t\t\to.src = item;\n\t\t\t} else {\n\t\t\t\tObject.assign(o, item);\n\t\t\t}\n\n\t\t\to.suffix = getSuffixByUrl(o.src) || \"\";\n\t\t\to.type = getFileType(o.suffix, item[\"type\"]);\n\n\t\t\treturn o;\n\t\t});\n\t}, [items]);\n\n\tconst { file, content } = useMemo(() => {\n\t\tconst file = files[state.current];\n\t\tconst content = renderFile(file);\n\n\t\treturn {\n\t\t\tfile,\n\t\t\tcontent,\n\t\t};\n\t}, [state.current, items]);\n\n\tconst isImage = file.type === TFileType.IMAGE;\n\n\tconst handleSwitch = (next: number) => {\n\t\tconst l = files.length;\n\t\tconst { current: before } = state;\n\t\tif (next >= l) {\n\t\t\tstate.current = 0;\n\t\t} else if (next < 0) {\n\t\t\tstate.current = l - 1;\n\t\t} else {\n\t\t\tstate.current = next;\n\t\t}\n\t\tonChange?.(state.current, before);\n\n\t\tstate.rotate = files[state.current].rotate || 0;\n\n\t\tif (state.scale !== 1) {\n\t\t\tstate.scale = 1;\n\t\t\tonZoom?.(1);\n\t\t}\n\t\tonRotate?.(state.rotate);\n\t\tstate.translate = translate.current = [0, 0];\n\t};\n\n\tconst handleRotate = (deg: number) => {\n\t\tstate.rotate += deg;\n\n\t\tonRotate?.(state.rotate);\n\t};\n\n\tconst handleMouseWheel = throttle({ interval: 60 }, (e) => {\n\t\tif (!isImage) return;\n\t\tlet after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);\n\t\tif (after > 2) after = 2;\n\t\tif (after < 0.25) after = 0.25;\n\n\t\tonZoom?.(after);\n\t\tstate.scale = after;\n\t});\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!isImage) return;\n\t\te.preventDefault();\n\t\tstate.dragging = true;\n\t\tstate.start = [e.pageX, e.pageY];\n\t};\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current || state.controlHidden) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst throttleMouseMove = throttle({ interval: 300 }, setHiddenFalse);\n\n\tconst handleMouseMove = (e) => {\n\t\tthrottleMouseMove();\n\t\tif (!state.dragging) return;\n\t\te.preventDefault();\n\n\t\tconst [x, y] = translate.current;\n\t\tconst [ox, oy] = state.start;\n\t\tconst offsetX = e.pageX - ox;\n\t\tconst offsetY = e.pageY - oy;\n\n\t\tstate.translate = [x + offsetX, y + offsetY];\n\t};\n\n\tconst handleMouseUp = () => {\n\t\tif (!state.dragging) return;\n\t\tstate.dragging = false;\n\t\ttranslate.current = state.translate;\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={box}\n\t\t\t\tclassName={classNames(\"i-preview-content\", {\n\t\t\t\t\t\"no-transition\": state.dragging,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\ttransform: `translate(${state.translate\n\t\t\t\t\t\t.map((n) => `${n}px`)\n\t\t\t\t\t\t.join(\",\")}) rotate(${state.rotate}deg) scale(${\n\t\t\t\t\t\tstate.scale\n\t\t\t\t\t})`,\n\t\t\t\t}}\n\t\t\t\tonWheel={handleMouseWheel}\n\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-preview-controls\", {\n\t\t\t\t\t\"i-preview-controls-hidden\": state.controlHidden,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<Button square flat onClick={onClose}>\n\t\t\t\t\t<Icon icon={<CloseRound />} />\n\t\t\t\t</Button>\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<span className='px-8'>\n\t\t\t\t\t\t{state.current + 1} / {files.length}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state.scale !== 1 && (\n\t\t\t\t\t<Button flat onClick={() => (state.scale = 1)}>\n\t\t\t\t\t\t<Icon icon={<AspectRatioRound />} />\n\t\t\t\t\t\t<span className='mt-2'>\n\t\t\t\t\t\t\t{(state.scale * 100).toFixed(0)}%\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Button>\n\t\t\t\t)}\n\t\t\t\t<Button square flat href={file.src} target='_blank'>\n\t\t\t\t\t<Icon icon={<OpenInNewRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat href={file.src} download target='_blank'>\n\t\t\t\t\t<Icon icon={<FileDownloadOutlined />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(90)}>\n\t\t\t\t\t<Icon icon={<RotateRightRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(-90)}>\n\t\t\t\t\t<Icon icon={<RotateLeftRound />} />\n\t\t\t\t</Button>\n\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current - 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowLeftRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current + 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowRightRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"names":["renderFile","DefaultRenderFile","_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;AAqBwB,SAAA,OAAO,CAAC,KAAe,EAAA;IAC9C,MAAM,EACL,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,CAAC,cACXA,YAAU,GAAGC,UAAiB,EAC9B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,GAC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Y,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,EAE9C,QAAA,EAAAA,GAAA,CAAC,IAAI,EAAA,EAAC,IAAI,EAAEA,GAAA,CAAC,sBAAsB,EAAA,EAAA,CAAG,GAAI,EAClC,CAAA,EACTA,GAAC,CAAA,MAAM,EACN,EAAA,MAAM,EACN,IAAA,EAAA,IAAI,QACJ,OAAO,EAAE,MAAM,YAAY,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,EAAA,QAAA,EAE9CA,GAAC,CAAA,IAAI,EAAC,EAAA,IAAI,EAAEA,GAAC,CAAA,uBAAuB,EAAG,EAAA,CAAA,EAAA,CAAI,GACnC,CACP,EAAA,CAAA,CACH,CACI,EAAA,CAAA,CAAA,EAAA,CACJ;AAEL;;;;"}
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import classNames from 'classnames';
3
3
  import { debounce, uid, throttle, pick, title } from 'radash';
4
- import { createElement, useEffect, useMemo, Children, cloneElement, isValidElement, useState, useRef, Fragment as Fragment$1, useLayoutEffect, useImperativeHandle, createContext, useContext } from 'react';
4
+ import { useMemo, Children, cloneElement, useEffect, createElement, isValidElement, useState, useRef, Fragment as Fragment$1, useLayoutEffect, useImperativeHandle, createContext, useContext } from 'react';
5
5
  import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, RedoRound, UndoRound, ClearAllRound, PauseRound, PlayArrowRound, StopRound, VolumeOffRound, VolumeDownRound, FullscreenExitRound, FullscreenRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, HideImageTwotone, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, ListAltRound, PlusSharp } from '@ricons/material';
6
6
  import { useReactive, useCreation, useSize } from 'ahooks';
7
7
  import { createRoot } from 'react-dom/client';
@@ -71,56 +71,6 @@ const Loading = (props) => {
71
71
  }, children: jsx("circle", { cx: '12', cy: '12', r: '9.5', fill: 'none', strokeWidth: '3', strokeLinecap: 'round', strokeDasharray: 40, strokeDashoffset: 0 }) })), text] }));
72
72
  };
73
73
 
74
- const formatClass = ({ outline, flat, loading, disabled, size = "normal", block, round, square, secondary, className, }) => classNames("i-btn", className, {
75
- "i-btn-outline": outline,
76
- "i-btn-flat": flat,
77
- "i-btn-block": block,
78
- "i-btn-loading": loading,
79
- "i-btn-square": square,
80
- "i-btn-secondary": secondary,
81
- [`i-btn-${size}`]: size !== "normal",
82
- round,
83
- disabled,
84
- });
85
- const Button = (props) => {
86
- const { as: As = "a", ref, children, className, loading, flat, outline, square, secondary, size, round, href, ripple = true, onClick, ...restProps } = props;
87
- const handleClick = (e) => {
88
- if (loading || restProps.disabled) {
89
- e.stopPropagation();
90
- e.preventDefault();
91
- return;
92
- }
93
- onClick?.(e);
94
- };
95
- if (!children)
96
- return jsx(Fragment, {});
97
- const childNodes = [
98
- loading && jsx(Loading, {}, 'loading'),
99
- createElement("span", { key: "content", className: "i-btn-content" }, children),
100
- ];
101
- const attrs = {
102
- className: formatClass(props),
103
- ["data-ripple"]: ripple && !loading && !restProps.disabled ? "" : undefined,
104
- onClick: handleClick,
105
- };
106
- useEffect(() => {
107
- ripple && useRipple();
108
- }, [ripple]);
109
- if (typeof As === "string") {
110
- return createElement(As, {
111
- ref,
112
- href,
113
- ...attrs,
114
- ...restProps,
115
- }, childNodes);
116
- }
117
- return createElement(As, {
118
- to: href || "",
119
- ...attrs,
120
- ...restProps,
121
- }, childNodes);
122
- };
123
-
124
74
  function Group(props) {
125
75
  const { children, vertical, buttonProps, className, style } = props;
126
76
  const nodes = useMemo(() => {
@@ -173,8 +123,57 @@ function Toggle(props) {
173
123
  }), children: state.active ? after ?? children : children }) }));
174
124
  }
175
125
 
176
- Button.Group = Group;
126
+ const formatClass = ({ outline, flat, loading, disabled, size = "normal", block, round, square, secondary, className, }) => classNames("i-btn", className, {
127
+ "i-btn-outline": outline,
128
+ "i-btn-flat": flat,
129
+ "i-btn-block": block,
130
+ "i-btn-loading": loading,
131
+ "i-btn-square": square,
132
+ "i-btn-secondary": secondary,
133
+ [`i-btn-${size}`]: size !== "normal",
134
+ round,
135
+ disabled,
136
+ });
137
+ const Button = (props) => {
138
+ const { as: As = "a", ref, children, className, loading, flat, outline, square, secondary, size, round, href, ripple = true, onClick, ...restProps } = props;
139
+ const handleClick = (e) => {
140
+ if (loading || restProps.disabled) {
141
+ e.stopPropagation();
142
+ e.preventDefault();
143
+ return;
144
+ }
145
+ onClick?.(e);
146
+ };
147
+ if (!children)
148
+ return jsx(Fragment, {});
149
+ const childNodes = [
150
+ loading && jsx(Loading, {}, 'loading'),
151
+ createElement("span", { key: "content", className: "i-btn-content" }, children),
152
+ ];
153
+ const attrs = {
154
+ className: formatClass(props),
155
+ ["data-ripple"]: ripple && !loading && !restProps.disabled ? "" : undefined,
156
+ onClick: handleClick,
157
+ };
158
+ useEffect(() => {
159
+ ripple && useRipple();
160
+ }, [ripple]);
161
+ if (typeof As === "string") {
162
+ return createElement(As, {
163
+ ref,
164
+ href,
165
+ ...attrs,
166
+ ...restProps,
167
+ }, childNodes);
168
+ }
169
+ return createElement(As, {
170
+ to: href || "",
171
+ ...attrs,
172
+ ...restProps,
173
+ }, childNodes);
174
+ };
177
175
  Button.Toggle = Toggle;
176
+ Button.Group = Group;
178
177
 
179
178
  const Icon = (props) => {
180
179
  const { ref, icon, size = "1.425em", rotate, style, className, ...restProps } = props;
@@ -1302,8 +1301,8 @@ function Popup(props) {
1302
1301
  arrowProps: { left: arrowX, top: arrowY, pos: arrowPos },
1303
1302
  });
1304
1303
  };
1305
- const { observe, unobserve, disconnect } = useResizeObserver();
1306
1304
  useEffect(() => {
1305
+ const { observe, unobserve, disconnect } = useResizeObserver();
1307
1306
  if (trigger === "contextmenu" || !observe)
1308
1307
  return;
1309
1308
  triggerRef.current && observe(triggerRef.current, computePosition);
@@ -2473,7 +2472,7 @@ const Image = (props) => {
2473
2472
  useEffect(() => {
2474
2473
  if (!src)
2475
2474
  return;
2476
- if (!ref.current?.complete) {
2475
+ if (!ref.current?.complete && observe) {
2477
2476
  state.status = "loading";
2478
2477
  }
2479
2478
  if (!lazyload || !ref.current || !observe)
@@ -2487,7 +2486,7 @@ const Image = (props) => {
2487
2486
  return () => {
2488
2487
  ref.current && unobserve(ref.current);
2489
2488
  };
2490
- }, [src, observe]);
2489
+ }, [src, observe, ref.current]);
2491
2490
  restProps[lazyload ? "data-src" : "src"] = src;
2492
2491
  const iSize = state.status === "loading" ? initSize : undefined;
2493
2492
  return (jsx("div", { style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ioca/react",
3
- "version": "1.3.75",
3
+ "version": "1.3.77",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var button = require('./button.js');
6
- var group = require('./group.js');
7
- var toggle = require('./toggle.js');
8
-
9
- button.default.Group = group.default;
10
- button.default.Toggle = toggle.default;
11
-
12
- exports.default = button.default;
13
- //# sourceMappingURL=merged.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merged.js","sources":["../../../../packages/components/button/merged.ts"],"sourcesContent":["import Button from \"./button\";\nimport Group from \"./group\";\nimport Toggle from \"./toggle\";\n\nButton.Group = Group;\nButton.Toggle = Toggle;\n\nexport default Button;\n"],"names":["Button","Group","Toggle"],"mappings":";;;;;;;;AAIAA,cAAM,CAAC,KAAK,GAAGC,aAAK;AACpBD,cAAM,CAAC,MAAM,GAAGE,cAAM;;;;"}
@@ -1,9 +0,0 @@
1
- import Button from './button.js';
2
- import Group from './group.js';
3
- import Toggle from './toggle.js';
4
-
5
- Button.Group = Group;
6
- Button.Toggle = Toggle;
7
-
8
- export { Button as default };
9
- //# sourceMappingURL=merged.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merged.js","sources":["../../../../packages/components/button/merged.ts"],"sourcesContent":["import Button from \"./button\";\nimport Group from \"./group\";\nimport Toggle from \"./toggle\";\n\nButton.Group = Group;\nButton.Toggle = Toggle;\n\nexport default Button;\n"],"names":[],"mappings":";;;;AAIA,MAAM,CAAC,KAAK,GAAG,KAAK;AACpB,MAAM,CAAC,MAAM,GAAG,MAAM;;;;"}
@@ -1,5 +0,0 @@
1
- import _default from './button.js';
2
-
3
-
4
-
5
- export { _default as default };