@ioca/react 1.3.77 → 1.3.81

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 (62) hide show
  1. package/lib/cjs/components/editor/editor.js +1 -0
  2. package/lib/cjs/components/editor/editor.js.map +1 -1
  3. package/lib/cjs/components/form/form.js +2 -0
  4. package/lib/cjs/components/form/form.js.map +1 -1
  5. package/lib/cjs/components/form/useConfig.js +38 -0
  6. package/lib/cjs/components/form/useConfig.js.map +1 -0
  7. package/lib/cjs/components/form/useForm.js +2 -0
  8. package/lib/cjs/components/form/useForm.js.map +1 -1
  9. package/lib/cjs/components/image/image.js +12 -12
  10. package/lib/cjs/components/image/image.js.map +1 -1
  11. package/lib/cjs/components/input/input.js +2 -2
  12. package/lib/cjs/components/input/input.js.map +1 -1
  13. package/lib/cjs/components/input/number.js +2 -2
  14. package/lib/cjs/components/input/number.js.map +1 -1
  15. package/lib/cjs/components/input/range.js +16 -6
  16. package/lib/cjs/components/input/range.js.map +1 -1
  17. package/lib/cjs/components/input/textarea.js +2 -2
  18. package/lib/cjs/components/input/textarea.js.map +1 -1
  19. package/lib/cjs/components/modal/modal.js +1 -1
  20. package/lib/cjs/components/modal/modal.js.map +1 -1
  21. package/lib/cjs/components/popup/popup.js +1 -1
  22. package/lib/cjs/components/popup/popup.js.map +1 -1
  23. package/lib/cjs/components/swiper/swiper.js +1 -1
  24. package/lib/cjs/components/swiper/swiper.js.map +1 -1
  25. package/lib/cjs/js/hooks.js +7 -7
  26. package/lib/cjs/js/hooks.js.map +1 -1
  27. package/lib/css/index.css +1 -1
  28. package/lib/css/index.css.map +1 -1
  29. package/lib/es/components/editor/editor.js +1 -0
  30. package/lib/es/components/editor/editor.js.map +1 -1
  31. package/lib/es/components/form/form.js +2 -0
  32. package/lib/es/components/form/form.js.map +1 -1
  33. package/lib/es/components/form/useConfig.js +34 -0
  34. package/lib/es/components/form/useConfig.js.map +1 -0
  35. package/lib/es/components/form/useForm.js +2 -0
  36. package/lib/es/components/form/useForm.js.map +1 -1
  37. package/lib/es/components/image/image.js +12 -12
  38. package/lib/es/components/image/image.js.map +1 -1
  39. package/lib/es/components/input/input.js +2 -2
  40. package/lib/es/components/input/input.js.map +1 -1
  41. package/lib/es/components/input/number.js +2 -2
  42. package/lib/es/components/input/number.js.map +1 -1
  43. package/lib/es/components/input/range.js +16 -6
  44. package/lib/es/components/input/range.js.map +1 -1
  45. package/lib/es/components/input/textarea.js +2 -2
  46. package/lib/es/components/input/textarea.js.map +1 -1
  47. package/lib/es/components/modal/modal.js +1 -1
  48. package/lib/es/components/modal/modal.js.map +1 -1
  49. package/lib/es/components/popup/popup.js +1 -1
  50. package/lib/es/components/popup/popup.js.map +1 -1
  51. package/lib/es/components/swiper/swiper.js +1 -1
  52. package/lib/es/components/swiper/swiper.js.map +1 -1
  53. package/lib/es/js/hooks.js +7 -7
  54. package/lib/es/js/hooks.js.map +1 -1
  55. package/lib/index.js +74 -34
  56. package/lib/types/components/editor/type.d.ts +1 -0
  57. package/lib/types/components/form/form.d.ts +2 -0
  58. package/lib/types/components/form/type.d.ts +13 -1
  59. package/lib/types/components/form/useConfig.d.ts +10 -0
  60. package/lib/types/components/input/type.d.ts +2 -0
  61. package/lib/types/components/modal/type.d.ts +1 -1
  62. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"swiper.js","sources":["../../../../packages/components/swiper/swiper.tsx"],"sourcesContent":["import {\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport {\n\tChildren,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseRef,\n} from \"react\";\nimport { useMouseMove, useMouseUp } from \"../../js/hooks\";\nimport { clamp } from \"../../js/utils\";\nimport Icon from \"../icon\";\nimport \"./index.css\";\nimport Item from \"./item\";\nimport { CompositionSwiper, ISwiper } from \"./type\";\n\nconst Swiper = ((props: ISwiper) => {\n\tconst {\n\t\tref,\n\t\ttype = \"normal\",\n\t\tinitial = 0,\n\t\tdisplay = 1,\n\t\tscroll = 1,\n\t\tloop = true,\n\t\tvertical,\n\t\tprev = <Icon icon={<KeyboardArrowLeftRound />} size='2em' />,\n\t\tnext = <Icon icon={<KeyboardArrowRightRound />} size='2em' />,\n\t\tduration = 600,\n\t\tinterval = 3000,\n\t\tautoplay,\n\t\tpauseOnHover,\n\t\tarrow = true,\n\t\treverse,\n\t\tdraggable,\n\t\tdragOffset = 40,\n\t\tgap = 0,\n\t\titemHeight,\n\t\tindicator,\n\t\tfixedIndicator,\n\t\tstyle,\n\t\tclassName,\n\t\tchildren,\n\t\trenderIndicator,\n\t\tonBeforeSwipe,\n\t\tonAfterSwipe,\n\t\tonItemClick,\n\t} = props;\n\n\tconst listRef = useRef<HTMLDivElement>(null);\n\tconst timerRef = useRef<any>(null);\n\tconst transition = `all ${duration / 1000}s`;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\tswipable: true,\n\t\ttransition: type === \"fade\" ? \"none\" : transition,\n\t\tdragStart: 0,\n\t\tdragging: false,\n\t\tinitialized: false,\n\t});\n\n\tconst items = useMemo(() => {\n\t\treturn Children.map(children, (node: any) => {\n\t\t\tif (node.type !== Item) return;\n\n\t\t\treturn node;\n\t\t});\n\t}, [children]);\n\n\tconst [displayItems, extra, size, total, listSize] = useMemo(() => {\n\t\tconst extra =\n\t\t\ttype === \"normal\" && loop && items.length > display\n\t\t\t\t? display + 1\n\t\t\t\t: 0;\n\t\tlet list: any = [];\n\n\t\tif (extra <= 0) {\n\t\t\tlist = [...items];\n\t\t} else {\n\t\t\tconst head = items.slice(0, extra);\n\t\t\tconst tail = items.slice(-extra);\n\t\t\tlist = [...tail, ...items, ...head];\n\t\t}\n\n\t\tconst listSize = `${(list.length / display) * 100}%`;\n\n\t\treturn [list, extra, items.length, list.length, listSize];\n\t}, [display, loop, type, items]);\n\n\tconst offsetPercent = useMemo(\n\t\t() => (-100 * (state.current + extra)) / total,\n\t\t[state.current, total]\n\t);\n\n\tconst position = useMemo(() => {\n\t\tif (size <= display || type === \"fade\") return;\n\n\t\tconst offset = vertical\n\t\t\t? `0, ${offsetPercent}%`\n\t\t\t: `${offsetPercent}%, 0`;\n\t\treturn `translate3d(${offset}, 0)`;\n\t}, [offsetPercent, vertical, display, size, type]);\n\n\tconst trackStyle = useMemo(() => {\n\t\tif (!vertical || !itemHeight) return;\n\n\t\treturn {\n\t\t\theight: itemHeight * display,\n\t\t};\n\t}, [vertical, itemHeight, display]);\n\n\tconst indicatorsLoop = useMemo(() => {\n\t\treturn Array.from({\n\t\t\tlength: Math.ceil((size - display) / scroll) + 1,\n\t\t});\n\t}, [loop, indicator]);\n\n\tconst clearTimer = () => {\n\t\tclearTimeout(timerRef.current);\n\t\ttimerRef.current = null;\n\t};\n\n\tconst swipeTo = (i: number) => {\n\t\tif (!state.swipable || i === state.current) return;\n\t\tstate.swipable = false;\n\t\tonBeforeSwipe?.(state.current);\n\n\t\tlet reset = false;\n\t\tlet next = i;\n\t\tconst lastDisplay = size - display;\n\n\t\tif (loop) {\n\t\t\tif (i > lastDisplay) {\n\t\t\t\treset = true;\n\t\t\t\ti = size;\n\t\t\t\tnext = 0;\n\t\t\t} else if (i < 0) {\n\t\t\t\treset = true;\n\t\t\t\ti = -display;\n\t\t\t\tnext = lastDisplay;\n\t\t\t}\n\t\t} else {\n\t\t\tnext = clamp(next, 0, lastDisplay);\n\t\t\ti = next;\n\t\t}\n\n\t\tsetTimeout(() => {\n\t\t\tstate.swipable = true;\n\t\t}, duration + 32);\n\n\t\tif (type === \"fade\") {\n\t\t\tstate.current = next;\n\t\t\tonAfterSwipe?.(next);\n\t\t\treturn;\n\t\t}\n\n\t\tstate.current = i;\n\n\t\tif (!reset) {\n\t\t\tif (autoplay) {\n\t\t\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\t\t\t}\n\t\t\tsetTimeout(() => {\n\t\t\t\tonAfterSwipe?.(next);\n\t\t\t}, duration + 12);\n\t\t\treturn;\n\t\t}\n\n\t\tsetTimeout(() => {\n\t\t\tstate.transition = \"none\";\n\t\t\tstate.current = next;\n\t\t\tonAfterSwipe?.(next);\n\t\t\tif (autoplay) {\n\t\t\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\t\t\t}\n\t\t\tsetTimeout(() => {\n\t\t\t\tstate.transition = transition;\n\t\t\t}, 60);\n\t\t}, duration + 20);\n\t};\n\tconst swipeNext = () => {\n\t\tswipeTo(reverse ? state.current - scroll : state.current + scroll);\n\t};\n\n\tconst swipePrev = () => {\n\t\tswipeTo(reverse ? state.current + scroll : state.current - scroll);\n\t};\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!draggable || !state.swipable || type === \"fade\") return;\n\t\te.stopPropagation();\n\t\te.preventDefault();\n\n\t\tif (e.touches) {\n\t\t\te = e.touches[0];\n\t\t}\n\n\t\tObject.assign(state, {\n\t\t\tdragStart: vertical ? e.clientY : e.clientX,\n\t\t\tdragging: true,\n\t\t\ttransition: \"none\",\n\t\t});\n\t};\n\n\tconst handleMouseMove = (e) => {\n\t\tif (!state.dragging || !listRef.current) return;\n\t\te.preventDefault();\n\n\t\tif (e.touches) {\n\t\t\te = e.touches[0];\n\t\t}\n\n\t\tconst dragEnd = vertical ? e.clientY : e.clientX;\n\t\tconst offset =\n\t\t\t((dragEnd - state.dragStart) * 61.8) /\n\t\t\t\tlistRef.current[vertical ? \"offsetHeight\" : \"offsetWidth\"] +\n\t\t\toffsetPercent;\n\n\t\tlistRef.current.style.transform = `translate3d(${\n\t\t\tvertical ? `0, ${offset}%` : `${offset}%, 0`\n\t\t}, 0)`;\n\t};\n\n\tconst handleMouseUp = (e) => {\n\t\tif (!state.dragging || !listRef.current) return;\n\n\t\tif (e.changedTouches) {\n\t\t\te = e.changedTouches[0];\n\t\t}\n\n\t\tconst dragEnd = vertical ? e.clientY : e.clientX;\n\t\tconst part =\n\t\t\tlistRef.current[vertical ? \"offsetHeight\" : \"offsetWidth\"] / total;\n\t\tconst offset = (dragEnd - state.dragStart) * 0.618;\n\t\tconst absOffset = Math.abs(offset);\n\n\t\tif (absOffset > dragOffset) {\n\t\t\tconst base = Math.floor(absOffset / part);\n\t\t\tconst mod = (absOffset % part) - dragOffset > 0 ? 1 : 0;\n\t\t\tconst p = base + mod;\n\n\t\t\tlet to = state.current + (offset > 0 ? -p : p);\n\n\t\t\tswipeTo(to);\n\t\t}\n\n\t\tlistRef.current.style.transform = position || \"\";\n\n\t\tObject.assign(state, {\n\t\t\tdragging: false,\n\t\t\ttransition,\n\t\t});\n\t};\n\n\tconst handleMouseOver = () => {\n\t\tif (!pauseOnHover) return;\n\t\tclearTimer();\n\t};\n\n\tconst handleMouseLeave = () => {\n\t\tif (!pauseOnHover) return;\n\t\tclearTimer();\n\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\tuseImperativeHandle(ref, () => ({\n\t\tswipeTo,\n\t\tswipeNext,\n\t\tswipePrev,\n\t}));\n\n\tuseEffect(() => {\n\t\tif (!autoplay) return;\n\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\n\t\treturn () => {\n\t\t\tclearTimeout(timerRef.current);\n\t\t\ttimerRef.current = null;\n\t\t};\n\t}, [autoplay, interval]);\n\n\treturn (\n\t\t<div\n\t\t\tstyle={style}\n\t\t\tclassName={classNames(\n\t\t\t\t\"i-swiper\",\n\t\t\t\t{\n\t\t\t\t\t\"i-swiper-vertical\": vertical,\n\t\t\t\t\t\"i-swiper-initialized\": state.initialized,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName='i-swiper-track'\n\t\t\t\tstyle={trackStyle}\n\t\t\t\tonMouseOver={handleMouseOver}\n\t\t\t\tonMouseLeave={handleMouseLeave}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={listRef}\n\t\t\t\t\tclassName={classNames(\"i-swiper-list\", {\n\t\t\t\t\t\t\"i-swiper-fade\": type === \"fade\",\n\t\t\t\t\t})}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t[vertical ? \"height\" : \"width\"]: listSize,\n\t\t\t\t\t\ttransform: position,\n\t\t\t\t\t\ttransition: state.transition,\n\t\t\t\t\t}}\n\t\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\t\tonTouchStart={handleMouseDown}\n\t\t\t\t>\n\t\t\t\t\t{displayItems.map((item, i) => {\n\t\t\t\t\t\tconst { props: itemProps } = item;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\t\tindex={i}\n\t\t\t\t\t\t\t\titemIndex={(i - extra + size) % size}\n\t\t\t\t\t\t\t\tactive={i - extra === state.current}\n\t\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t\t\tgap={gap}\n\t\t\t\t\t\t\t\ttransition={transition}\n\t\t\t\t\t\t\t\titemHeight={itemHeight}\n\t\t\t\t\t\t\t\tvertical={vertical}\n\t\t\t\t\t\t\t\tonItemClick={onItemClick}\n\t\t\t\t\t\t\t\t{...itemProps}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\n\t\t\t\t{arrow && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{(loop || state.current !== 0) && (\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName='i-swiper-arrow i-swiper-prev'\n\t\t\t\t\t\t\t\tonClick={swipePrev}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{prev}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{(loop || state.current < size - display) && (\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName='i-swiper-arrow i-swiper-next'\n\t\t\t\t\t\t\t\tonClick={swipeNext}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{next}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t{indicator && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames(\"i-swiper-indicators\", {\n\t\t\t\t\t\t\"i-swiper-indicators-fixed\": fixedIndicator,\n\t\t\t\t\t})}\n\t\t\t\t>\n\t\t\t\t\t{indicatorsLoop.map((_, i) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\t\tclassName={classNames(\"i-swiper-indicator\", {\n\t\t\t\t\t\t\t\t\t\"i-indicator-active\":\n\t\t\t\t\t\t\t\t\t\ti ===\n\t\t\t\t\t\t\t\t\t\tMath[loop ? \"floor\" : \"ceil\"](\n\t\t\t\t\t\t\t\t\t\t\t((state.current + size) % size) /\n\t\t\t\t\t\t\t\t\t\t\t\tscroll\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\tonClick={() => swipeTo(i * scroll)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderIndicator?.(i)}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}) as CompositionSwiper;\n\nSwiper.Item = Item;\n\nexport default Swiper;\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;AAoBA,MAAM,MAAM,IAAI,CAAC,KAAc,KAAI;IAClC,MAAM,EACL,GAAG,EACH,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,CAAC,EACX,MAAM,GAAG,CAAC,EACV,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,IAAI,GAAGA,GAAA,CAAC,IAAI,EAAA,EAAC,IAAI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ACxC,OAAO,EAAE,SAAS,EAEjB,QAAA,EAAA,IAAI,EACF,CAAA,CACJ,CACC,EAAA,CAAA,CACH,IACI,EACL,SAAS,KACTA,aACC,SAAS,EAAE,UAAU,CAAC,qBAAqB,EAAE;AAC5C,oBAAA,2BAA2B,EAAE,cAAc;iBAC3C,CAAC,EAAA,QAAA,EAED,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAI;AAC5B,oBAAA,QACCA,GAEC,CAAA,GAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE;AAC3C,4BAAA,oBAAoB,EACnB,CAAC;gCACD,IAAI,CAAC,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,CAC5B,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,IAAI,IAAI;AAC7B,oCAAA,MAAM,CACP;yBACF,CAAC,EACF,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,EAEjC,QAAA,EAAA,eAAe,GAAG,CAAC,CAAC,EAXhB,EAAA,CAAC,CAYH;AAEN,iBAAC,CAAC,EAAA,CACG,CACN,CAAA,EAAA,CACI;AAER,CAAC;AAED,MAAM,CAAC,IAAI,GAAG,IAAI;;;;"}
1
+ {"version":3,"file":"swiper.js","sources":["../../../../packages/components/swiper/swiper.tsx"],"sourcesContent":["import {\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport {\n\tChildren,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseRef,\n} from \"react\";\nimport { useMouseMove, useMouseUp } from \"../../js/hooks\";\nimport { clamp } from \"../../js/utils\";\nimport Icon from \"../icon\";\nimport \"./index.css\";\nimport Item from \"./item\";\nimport { CompositionSwiper, ISwiper } from \"./type\";\n\nconst Swiper = ((props: ISwiper) => {\n\tconst {\n\t\tref,\n\t\ttype = \"normal\",\n\t\tinitial = 0,\n\t\tdisplay = 1,\n\t\tscroll = 1,\n\t\tloop = true,\n\t\tvertical,\n\t\tprev = <Icon icon={<KeyboardArrowLeftRound />} size='2em' />,\n\t\tnext = <Icon icon={<KeyboardArrowRightRound />} size='2em' />,\n\t\tduration = 600,\n\t\tinterval = 3000,\n\t\tautoplay,\n\t\tpauseOnHover,\n\t\tarrow = true,\n\t\treverse,\n\t\tdraggable,\n\t\tdragOffset = 40,\n\t\tgap = 0,\n\t\titemHeight,\n\t\tindicator,\n\t\tfixedIndicator,\n\t\tstyle,\n\t\tclassName,\n\t\tchildren,\n\t\trenderIndicator,\n\t\tonBeforeSwipe,\n\t\tonAfterSwipe,\n\t\tonItemClick,\n\t} = props;\n\n\tconst listRef = useRef<HTMLDivElement>(null);\n\tconst timerRef = useRef<any>(null);\n\tconst transition = `all ${duration / 1000}s`;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\tswipable: true,\n\t\ttransition: type === \"fade\" ? \"none\" : transition,\n\t\tdragStart: 0,\n\t\tdragging: false,\n\t\tinitialized: false,\n\t});\n\n\tconst items = useMemo(() => {\n\t\treturn Children.map(children, (node: any) => {\n\t\t\tif (node.type !== Item) return;\n\n\t\t\treturn node;\n\t\t});\n\t}, [children]);\n\n\tconst [displayItems, extra, size, total, listSize] = useMemo(() => {\n\t\tconst extra =\n\t\t\ttype === \"normal\" && loop && items.length > display\n\t\t\t\t? display + 1\n\t\t\t\t: 0;\n\t\tlet list: any = [];\n\n\t\tif (extra <= 0) {\n\t\t\tlist = [...items];\n\t\t} else {\n\t\t\tconst head = items.slice(0, extra);\n\t\t\tconst tail = items.slice(-extra);\n\t\t\tlist = [...tail, ...items, ...head];\n\t\t}\n\n\t\tconst listSize = `${(list.length / display) * 100}%`;\n\n\t\treturn [list, extra, items.length, list.length, listSize];\n\t}, [display, loop, type, items]);\n\n\tconst offsetPercent = useMemo(\n\t\t() => (-100 * (state.current + extra)) / total,\n\t\t[state.current, total]\n\t);\n\n\tconst position = useMemo(() => {\n\t\tif (size <= display || type === \"fade\") return;\n\n\t\tconst offset = vertical\n\t\t\t? `0, ${offsetPercent}%`\n\t\t\t: `${offsetPercent}%, 0`;\n\t\treturn `translate3d(${offset}, 0)`;\n\t}, [offsetPercent, vertical, display, size, type]);\n\n\tconst trackStyle = useMemo(() => {\n\t\tif (!vertical || !itemHeight) return;\n\n\t\treturn {\n\t\t\theight: itemHeight * display,\n\t\t};\n\t}, [vertical, itemHeight, display]);\n\n\tconst indicatorsLoop = useMemo(() => {\n\t\treturn Array.from({\n\t\t\tlength: Math.ceil((size - display) / scroll) + 1,\n\t\t});\n\t}, [loop, indicator]);\n\n\tconst clearTimer = () => {\n\t\tclearTimeout(timerRef.current);\n\t\ttimerRef.current = null;\n\t};\n\n\tconst swipeTo = (i: number) => {\n\t\tif (!state.swipable || i === state.current) return;\n\t\tstate.swipable = false;\n\t\tonBeforeSwipe?.(state.current);\n\n\t\tlet reset = false;\n\t\tlet next = i;\n\t\tconst lastDisplay = size - display;\n\n\t\tif (loop) {\n\t\t\tif (i > lastDisplay) {\n\t\t\t\treset = true;\n\t\t\t\ti = size;\n\t\t\t\tnext = 0;\n\t\t\t} else if (i < 0) {\n\t\t\t\treset = true;\n\t\t\t\ti = -display;\n\t\t\t\tnext = lastDisplay;\n\t\t\t}\n\t\t} else {\n\t\t\tnext = clamp(next, 0, lastDisplay);\n\t\t\ti = next;\n\t\t}\n\n\t\tsetTimeout(() => {\n\t\t\tstate.swipable = true;\n\t\t}, duration + 32);\n\n\t\tif (type === \"fade\") {\n\t\t\tstate.current = next;\n\t\t\tonAfterSwipe?.(next);\n\t\t\treturn;\n\t\t}\n\n\t\tstate.current = i;\n\n\t\tif (!reset) {\n\t\t\tif (autoplay) {\n\t\t\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\t\t\t}\n\t\t\tsetTimeout(() => {\n\t\t\t\tonAfterSwipe?.(next);\n\t\t\t}, duration + 12);\n\t\t\treturn;\n\t\t}\n\n\t\tsetTimeout(() => {\n\t\t\tstate.transition = \"none\";\n\t\t\tstate.current = next;\n\t\t\tonAfterSwipe?.(next);\n\t\t\tif (autoplay) {\n\t\t\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\t\t\t}\n\t\t\tsetTimeout(() => {\n\t\t\t\tstate.transition = transition;\n\t\t\t}, 60);\n\t\t}, duration + 20);\n\t};\n\tconst swipeNext = () => {\n\t\tswipeTo(reverse ? state.current - scroll : state.current + scroll);\n\t};\n\n\tconst swipePrev = () => {\n\t\tswipeTo(reverse ? state.current + scroll : state.current - scroll);\n\t};\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!draggable || !state.swipable || type === \"fade\") return;\n\t\te.stopPropagation();\n\t\te.preventDefault();\n\n\t\tif (e.touches) {\n\t\t\te = e.touches[0];\n\t\t}\n\n\t\tObject.assign(state, {\n\t\t\tdragStart: vertical ? e.clientY : e.clientX,\n\t\t\tdragging: true,\n\t\t\ttransition: \"none\",\n\t\t});\n\t};\n\n\tconst handleMouseMove = (e) => {\n\t\tif (!state.dragging || !listRef.current) return;\n\t\te.preventDefault();\n\n\t\tif (e.touches) {\n\t\t\te = e.touches[0];\n\t\t}\n\n\t\tconst dragEnd = vertical ? e.clientY : e.clientX;\n\t\tconst offset =\n\t\t\t((dragEnd - state.dragStart) * 61.8) /\n\t\t\t\tlistRef.current[vertical ? \"offsetHeight\" : \"offsetWidth\"] +\n\t\t\toffsetPercent;\n\n\t\tlistRef.current.style.transform = `translate3d(${\n\t\t\tvertical ? `0, ${offset}%` : `${offset}%, 0`\n\t\t}, 0)`;\n\t};\n\n\tconst handleMouseUp = (e) => {\n\t\tif (!state.dragging || !listRef.current) return;\n\n\t\tif (e.changedTouches) {\n\t\t\te = e.changedTouches[0];\n\t\t}\n\n\t\tconst dragEnd = vertical ? e.clientY : e.clientX;\n\t\tconst part =\n\t\t\tlistRef.current[vertical ? \"offsetHeight\" : \"offsetWidth\"] / total;\n\t\tconst offset = (dragEnd - state.dragStart) * 0.618;\n\t\tconst absOffset = Math.abs(offset);\n\n\t\tif (absOffset > dragOffset) {\n\t\t\tconst base = Math.floor(absOffset / part);\n\t\t\tconst mod = (absOffset % part) - dragOffset > 0 ? 1 : 0;\n\t\t\tconst p = base + mod;\n\n\t\t\tlet to = state.current + (offset > 0 ? -p : p);\n\n\t\t\tswipeTo(to);\n\t\t}\n\n\t\tlistRef.current.style.transform = position || \"\";\n\n\t\tObject.assign(state, {\n\t\t\tdragging: false,\n\t\t\ttransition,\n\t\t});\n\t};\n\n\tconst handleMouseOver = () => {\n\t\tif (!pauseOnHover) return;\n\t\tclearTimer();\n\t};\n\n\tconst handleMouseLeave = () => {\n\t\tif (!pauseOnHover) return;\n\t\tclearTimer();\n\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\tuseImperativeHandle(ref, () => ({\n\t\tswipeTo,\n\t\tswipeNext,\n\t\tswipePrev,\n\t}));\n\n\tuseEffect(() => {\n\t\tif (!autoplay) return;\n\t\ttimerRef.current = setTimeout(swipeNext, interval);\n\n\t\treturn () => {\n\t\t\tclearTimeout(timerRef.current);\n\t\t\ttimerRef.current = null;\n\t\t};\n\t}, [autoplay, interval]);\n\n\treturn (\n\t\t<div\n\t\t\tstyle={style}\n\t\t\tclassName={classNames(\n\t\t\t\t\"i-swiper\",\n\t\t\t\t{\n\t\t\t\t\t\"i-swiper-vertical\": vertical,\n\t\t\t\t\t\"i-swiper-initialized\": state.initialized,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName='i-swiper-track'\n\t\t\t\tstyle={trackStyle}\n\t\t\t\tonMouseOver={handleMouseOver}\n\t\t\t\tonMouseLeave={handleMouseLeave}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={listRef}\n\t\t\t\t\tclassName={classNames(\"i-swiper-list\", {\n\t\t\t\t\t\t\"i-swiper-fade\": type === \"fade\",\n\t\t\t\t\t})}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t[vertical ? \"height\" : \"width\"]: listSize,\n\t\t\t\t\t\ttransform: position,\n\t\t\t\t\t\ttransition: state.transition,\n\t\t\t\t\t}}\n\t\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\t\tonTouchStart={handleMouseDown}\n\t\t\t\t>\n\t\t\t\t\t{displayItems.map((item, i) => {\n\t\t\t\t\t\tconst { props: itemProps } = item;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\t\tindex={i}\n\t\t\t\t\t\t\t\titemIndex={(i - extra + size) % size}\n\t\t\t\t\t\t\t\tactive={i - extra === state.current}\n\t\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t\t\tgap={gap}\n\t\t\t\t\t\t\t\ttransition={transition}\n\t\t\t\t\t\t\t\titemHeight={itemHeight}\n\t\t\t\t\t\t\t\tvertical={vertical}\n\t\t\t\t\t\t\t\tonItemClick={onItemClick}\n\t\t\t\t\t\t\t\t{...itemProps}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\n\t\t\t\t{arrow && size > 1 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{(loop || state.current !== 0) && (\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName='i-swiper-arrow i-swiper-prev'\n\t\t\t\t\t\t\t\tonClick={swipePrev}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{prev}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{(loop || state.current < size - display) && (\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName='i-swiper-arrow i-swiper-next'\n\t\t\t\t\t\t\t\tonClick={swipeNext}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{next}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t{indicator && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames(\"i-swiper-indicators\", {\n\t\t\t\t\t\t\"i-swiper-indicators-fixed\": fixedIndicator,\n\t\t\t\t\t})}\n\t\t\t\t>\n\t\t\t\t\t{indicatorsLoop.map((_, i) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\t\tclassName={classNames(\"i-swiper-indicator\", {\n\t\t\t\t\t\t\t\t\t\"i-indicator-active\":\n\t\t\t\t\t\t\t\t\t\ti ===\n\t\t\t\t\t\t\t\t\t\tMath[loop ? \"floor\" : \"ceil\"](\n\t\t\t\t\t\t\t\t\t\t\t((state.current + size) % size) /\n\t\t\t\t\t\t\t\t\t\t\t\tscroll\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\tonClick={() => swipeTo(i * scroll)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderIndicator?.(i)}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}) as CompositionSwiper;\n\nSwiper.Item = Item;\n\nexport default Swiper;\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;AAoBA,MAAM,MAAM,IAAI,CAAC,KAAc,KAAI;IAClC,MAAM,EACL,GAAG,EACH,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,CAAC,EACX,MAAM,GAAG,CAAC,EACV,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,IAAI,GAAGA,GAAA,CAAC,IAAI,EAAA,EAAC,IAAI,EAAEA,IAAC,sBAAsB,EAAA,EAAA,CAAG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E,SAAS,EAAA,QAAA,EAEjB,IAAI,EACF,CAAA,CACJ,CACC,EAAA,CAAA,CACH,IACI,EACL,SAAS,KACTA,aACC,SAAS,EAAE,UAAU,CAAC,qBAAqB,EAAE;AAC5C,oBAAA,2BAA2B,EAAE,cAAc;iBAC3C,CAAC,EAAA,QAAA,EAED,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAI;AAC5B,oBAAA,QACCA,GAEC,CAAA,GAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE;AAC3C,4BAAA,oBAAoB,EACnB,CAAC;gCACD,IAAI,CAAC,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,CAC5B,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,IAAI,IAAI;AAC7B,oCAAA,MAAM,CACP;yBACF,CAAC,EACF,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,EAEjC,QAAA,EAAA,eAAe,GAAG,CAAC,CAAC,EAXhB,EAAA,CAAC,CAYH;AAEN,iBAAC,CAAC,EAAA,CACG,CACN,CAAA,EAAA,CACI;AAER,CAAC;AAED,MAAM,CAAC,IAAI,GAAG,IAAI;;;;"}
@@ -30,29 +30,29 @@ const initEvents = () => {
30
30
  }
31
31
  });
32
32
  };
33
- function useInitEvents() {
33
+ function initEventsOnce() {
34
34
  useEffect(initEvents, []);
35
35
  }
36
36
  function useMouseMove(listener, options) {
37
- useInitEvents();
37
+ initEventsOnce();
38
38
  useEffect(() => {
39
39
  MouseMoveEvents.add(listener);
40
40
  return () => {
41
41
  MouseMoveEvents.delete(listener);
42
42
  };
43
- }, [listener]);
43
+ }, []);
44
44
  }
45
45
  function useMouseUp(listener, options) {
46
- useInitEvents();
46
+ initEventsOnce();
47
47
  useEffect(() => {
48
48
  MouseUpEvents.add(listener);
49
49
  return () => {
50
50
  MouseUpEvents.delete(listener);
51
51
  };
52
- }, [listener]);
52
+ }, []);
53
53
  }
54
54
  function useKeydown(listener, options) {
55
- useInitEvents();
55
+ initEventsOnce();
56
56
  useEffect(() => {
57
57
  if (options?.disabled)
58
58
  return;
@@ -60,7 +60,7 @@ function useKeydown(listener, options) {
60
60
  return () => {
61
61
  KeydownEvents.delete(listener);
62
62
  };
63
- }, [listener]);
63
+ }, []);
64
64
  }
65
65
  const defaultObserver = {
66
66
  observe: undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../../../packages/js/hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nlet initialized = false;\n\nconst initEvents = () => {\n\tif (!document || initialized) return;\n\tinitialized = true;\n\n\tconst touchable = \"ontouchend\" in document;\n\tconst EVENTS: Record<string, any> = {\n\t\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\t\tUP: touchable ? \"touchend\" : \"mouseup\",\n\t\tKEYDOWN: \"keydown\",\n\t};\n\n\tdocument.addEventListener(\n\t\tEVENTS.MOVE,\n\t\t(e) => {\n\t\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\t\tlistener(e);\n\t\t\t}\n\t\t},\n\t\t{ passive: false }\n\t);\n\n\tdocument.addEventListener(EVENTS.UP, (e) => {\n\t\tfor (const listener of MouseUpEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n\n\tdocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\t\tfor (const listener of KeydownEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n};\n\nfunction useInitEvents() {\n\tuseEffect(initEvents, []);\n}\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tKeydownEvents.add(listener);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nconst defaultObserver = {\n\tobserve: undefined,\n\tunobserve: undefined,\n\tdisconnect: undefined,\n};\n\nexport function useIntersectionObserver(configs?: IntersectionObserverInit) {\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\tconst WM = new WeakMap();\n\tconst IO = new IntersectionObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\t\t\tcallback?.(entry.target, entry.isIntersecting);\n\t\t});\n\t}, configs);\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\t\tWM.set(target, callback);\n\t\ttarget && IO.observe(target);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target);\n\t}\n\n\tfunction disconnect() {\n\t\tIO.disconnect();\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n\nexport function useResizeObserver() {\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\tconst WM = new WeakMap();\n\tconst IO = new ResizeObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\t\t\tcallback?.(entry.target);\n\t\t});\n\t});\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\t\ttarget && IO.observe(target);\n\t\tWM.set(target, callback);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target);\n\t}\n\n\tfunction disconnect() {\n\t\tIO.disconnect();\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n"],"names":[],"mappings":";;AAQA,MAAM,eAAe,GAAG,IAAI,GAAG,EAAe;AAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAe;AAC5C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB;AAE/C,IAAI,WAAW,GAAG,KAAK;AAEvB,MAAM,UAAU,GAAG,MAAK;IACvB,IAAI,CAAC,QAAQ,IAAI,WAAW;QAAE;IAC9B,WAAW,GAAG,IAAI;AAElB,IAAA,MAAM,SAAS,GAAG,YAAY,IAAI,QAAQ;AAC1C,IAAA,MAAM,MAAM,GAAwB;QACnC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW;QAC3C,EAAE,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS;AACtC,QAAA,OAAO,EAAE,SAAS;KAClB;IAED,QAAQ,CAAC,gBAAgB,CACxB,MAAM,CAAC,IAAI,EACX,CAAC,CAAC,KAAI;QACL,KAAK,MAAM,QAAQ,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE;YAChD,QAAQ,CAAC,CAAC,CAAC;;AAEb,KAAC,EACD,EAAE,OAAO,EAAE,KAAK,EAAE,CAClB;IAED,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,KAAI;QAC1C,KAAK,MAAM,QAAQ,IAAI,aAAa,CAAC,MAAM,EAAE,EAAE;YAC9C,QAAQ,CAAC,CAAC,CAAC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,GAAG,IAAI,cAAc,CAAC,CAAC,OAAO,KAAI;AACzC,QAAA,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;YACrB,MAAM,QAAQ,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;AACrC,YAAA,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC;AACzB,SAAC,CAAC;AACH,KAAC,CAAC;AAEF,IAAA,SAAS,OAAO,CAAC,MAAmB,EAAE,QAAkB,EAAA;AACvD,QAAA,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE;AACpB,QAAA,MAAM,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;AAC5B,QAAA,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;;IAGzB,SAAS,SAAS,CAAC,MAAmB,EAAA;AACrC,QAAA,MAAM,IAAI,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;AAC9B,QAAA,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;AAGlB,IAAA,SAAS,UAAU,GAAA;QAClB,EAAE,CAAC,UAAU,EAAE;;IAGhB,OAAO;QACN,OAAO;QACP,SAAS;QACT,UAAU;KACV;AACF;;;;"}
1
+ {"version":3,"file":"hooks.js","sources":["../../../packages/js/hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nlet initialized = false;\n\nconst initEvents = () => {\n\tif (!document || initialized) return;\n\tinitialized = true;\n\n\tconst touchable = \"ontouchend\" in document;\n\tconst EVENTS: Record<string, any> = {\n\t\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\t\tUP: touchable ? \"touchend\" : \"mouseup\",\n\t\tKEYDOWN: \"keydown\",\n\t};\n\n\tdocument.addEventListener(\n\t\tEVENTS.MOVE,\n\t\t(e) => {\n\t\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\t\tlistener(e);\n\t\t\t}\n\t\t},\n\t\t{ passive: false }\n\t);\n\n\tdocument.addEventListener(EVENTS.UP, (e) => {\n\t\tfor (const listener of MouseUpEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n\n\tdocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\t\tfor (const listener of KeydownEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n};\n\nfunction initEventsOnce() {\n\tuseEffect(initEvents, []);\n}\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tKeydownEvents.add(listener);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nconst defaultObserver = {\n\tobserve: undefined,\n\tunobserve: undefined,\n\tdisconnect: undefined,\n};\n\nexport function useIntersectionObserver(configs?: IntersectionObserverInit) {\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\tconst WM = new WeakMap();\n\tconst IO = new IntersectionObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\t\t\tcallback?.(entry.target, entry.isIntersecting);\n\t\t});\n\t}, configs);\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\t\tWM.set(target, callback);\n\t\ttarget && IO.observe(target);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target);\n\t}\n\n\tfunction disconnect() {\n\t\tIO.disconnect();\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n\nexport function useResizeObserver() {\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\tconst WM = new WeakMap();\n\tconst IO = new ResizeObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\t\t\tcallback?.(entry.target);\n\t\t});\n\t});\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\t\ttarget && IO.observe(target);\n\t\tWM.set(target, callback);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target);\n\t}\n\n\tfunction disconnect() {\n\t\tIO.disconnect();\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n"],"names":[],"mappings":";;AAQA,MAAM,eAAe,GAAG,IAAI,GAAG,EAAe;AAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAe;AAC5C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB;AAE/C,IAAI,WAAW,GAAG,KAAK;AAEvB,MAAM,UAAU,GAAG,MAAK;IACvB,IAAI,CAAC,QAAQ,IAAI,WAAW;QAAE;IAC9B,WAAW,GAAG,IAAI;AAElB,IAAA,MAAM,SAAS,GAAG,YAAY,IAAI,QAAQ;AAC1C,IAAA,MAAM,MAAM,GAAwB;QACnC,I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
package/lib/index.js CHANGED
@@ -729,29 +729,29 @@ const initEvents = () => {
729
729
  }
730
730
  });
731
731
  };
732
- function useInitEvents() {
732
+ function initEventsOnce() {
733
733
  useEffect(initEvents, []);
734
734
  }
735
735
  function useMouseMove(listener, options) {
736
- useInitEvents();
736
+ initEventsOnce();
737
737
  useEffect(() => {
738
738
  MouseMoveEvents.add(listener);
739
739
  return () => {
740
740
  MouseMoveEvents.delete(listener);
741
741
  };
742
- }, [listener]);
742
+ }, []);
743
743
  }
744
744
  function useMouseUp(listener, options) {
745
- useInitEvents();
745
+ initEventsOnce();
746
746
  useEffect(() => {
747
747
  MouseUpEvents.add(listener);
748
748
  return () => {
749
749
  MouseUpEvents.delete(listener);
750
750
  };
751
- }, [listener]);
751
+ }, []);
752
752
  }
753
753
  function useKeydown(listener, options) {
754
- useInitEvents();
754
+ initEventsOnce();
755
755
  useEffect(() => {
756
756
  if (options?.disabled)
757
757
  return;
@@ -759,7 +759,7 @@ function useKeydown(listener, options) {
759
759
  return () => {
760
760
  KeydownEvents.delete(listener);
761
761
  };
762
- }, [listener]);
762
+ }, []);
763
763
  }
764
764
  const defaultObserver = {
765
765
  observe: undefined,
@@ -1301,8 +1301,8 @@ function Popup(props) {
1301
1301
  arrowProps: { left: arrowX, top: arrowY, pos: arrowPos },
1302
1302
  });
1303
1303
  };
1304
+ const { observe, unobserve, disconnect } = useResizeObserver();
1304
1305
  useEffect(() => {
1305
- const { observe, unobserve, disconnect } = useResizeObserver();
1306
1306
  if (trigger === "contextmenu" || !observe)
1307
1307
  return;
1308
1308
  triggerRef.current && observe(triggerRef.current, computePosition);
@@ -1483,6 +1483,7 @@ const Editor = (props) => {
1483
1483
  };
1484
1484
  useImperativeHandle(ref, () => {
1485
1485
  return {
1486
+ input: editorRef.current,
1486
1487
  setValue(html) {
1487
1488
  if (!editorRef.current)
1488
1489
  return;
@@ -1660,6 +1661,7 @@ class IFormInstance {
1660
1661
  rule.validator = o;
1661
1662
  }
1662
1663
  else if (o === true) {
1664
+ rule.validator = (v) => ![undefined, null, ""].includes(v);
1663
1665
  rule.message = "required";
1664
1666
  }
1665
1667
  else {
@@ -1692,6 +1694,7 @@ class IFormInstance {
1692
1694
  rule.validator = o;
1693
1695
  }
1694
1696
  else if (o === true) {
1697
+ rule.validator = (v) => ![undefined, null, ""].includes(v);
1695
1698
  rule.message = "required";
1696
1699
  }
1697
1700
  else {
@@ -1723,6 +1726,32 @@ function useForm(form) {
1723
1726
  return formRef.current;
1724
1727
  }
1725
1728
 
1729
+ function useConfig(configs, formProps) {
1730
+ const form = useForm();
1731
+ const { onChange } = formProps ?? {};
1732
+ const [values, setValues] = useState({});
1733
+ const handleChange = (name, value) => {
1734
+ setValues(() => ({ ...form.get() }));
1735
+ onChange?.(name, value);
1736
+ };
1737
+ const node = useMemo(() => {
1738
+ return (jsx(Form, { ...formProps, onChange: handleChange, form: form, children: configs.map((config) => {
1739
+ const { name, label, required, component: El, componentProps = {}, colspan = 1, render, shouldUpdate, shouldRender, } = config;
1740
+ const { className } = componentProps;
1741
+ if (shouldRender && !shouldRender(values, form)) {
1742
+ return jsx(Fragment$1, {}, name);
1743
+ }
1744
+ return (jsx(Field, { name: name, required: required, children: render?.(config, values) ?? (jsx(El, { label: label, required: required, ...componentProps, className: `${className} ${colspan !== 1
1745
+ ? `colspan-${colspan}`
1746
+ : ""}` })) }, name));
1747
+ }) }));
1748
+ }, [configs, values]);
1749
+ return {
1750
+ form,
1751
+ node,
1752
+ };
1753
+ }
1754
+
1726
1755
  const Form = (props) => {
1727
1756
  const { form = {}, rules, initialValues, style, className, width, columns = 1, gap = "1em", labelInline, labelWidth, labelRight, children, onKeyDown, onEnter, onChange, ...restProps } = props;
1728
1757
  const handleKeyDown = (e) => {
@@ -1765,6 +1794,7 @@ const Form = (props) => {
1765
1794
  };
1766
1795
  Form.useForm = useForm;
1767
1796
  Form.Field = Field;
1797
+ Form.useConfig = useConfig;
1768
1798
 
1769
1799
  function useModal() {
1770
1800
  const ref = useRef(null);
@@ -1798,7 +1828,7 @@ function DefaultContent(props) {
1798
1828
  const showHeader = title || !hideCloseButton;
1799
1829
  const handleOk = async () => {
1800
1830
  const ret = await onOk?.();
1801
- if (ret)
1831
+ if (ret === false)
1802
1832
  return;
1803
1833
  onClose?.();
1804
1834
  };
@@ -2458,21 +2488,21 @@ const Image = (props) => {
2458
2488
  };
2459
2489
  const handleClick = (e) => {
2460
2490
  onClick?.(e);
2461
- previewable &&
2462
- src &&
2463
- preview({
2464
- items: [
2465
- {
2466
- src,
2467
- type: "IMAGE",
2468
- },
2469
- ],
2470
- });
2491
+ if (!previewable || !src)
2492
+ return;
2493
+ preview({
2494
+ items: [
2495
+ {
2496
+ src,
2497
+ type: "IMAGE",
2498
+ },
2499
+ ],
2500
+ });
2471
2501
  };
2472
2502
  useEffect(() => {
2473
2503
  if (!src)
2474
2504
  return;
2475
- if (!ref.current?.complete && observe) {
2505
+ if (!ref.current?.complete && observe && lazyload) {
2476
2506
  state.status = "loading";
2477
2507
  }
2478
2508
  if (!lazyload || !ref.current || !observe)
@@ -2486,7 +2516,7 @@ const Image = (props) => {
2486
2516
  return () => {
2487
2517
  ref.current && unobserve(ref.current);
2488
2518
  };
2489
- }, [src, observe, ref.current]);
2519
+ }, [src]);
2490
2520
  restProps[lazyload ? "data-src" : "src"] = src;
2491
2521
  const iSize = state.status === "loading" ? initSize : undefined;
2492
2522
  return (jsx("div", { style: {
@@ -2510,7 +2540,7 @@ function InputContainer(props) {
2510
2540
  }
2511
2541
 
2512
2542
  const Number = (props) => {
2513
- const { ref, label, name, value = props.initValue ?? "", initValue, labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, status = "normal", append, border, prepend, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
2543
+ const { ref, label, name, value = props.initValue ?? "", initValue, labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, width, status = "normal", append, border, prepend, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
2514
2544
  const state = useReactive({
2515
2545
  value,
2516
2546
  });
@@ -2546,14 +2576,14 @@ const Number = (props) => {
2546
2576
  onChange: handleChange,
2547
2577
  ...restProps,
2548
2578
  };
2549
- return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
2579
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
2550
2580
  [`i-input-${status}`]: status !== "normal",
2551
2581
  "i-input-borderless": !border,
2552
2582
  }), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: () => handleOperate(-step) })), jsx("input", { ...inputProps }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: () => handleOperate(step) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
2553
2583
  };
2554
2584
 
2555
2585
  const Range = (props) => {
2556
- const { label, name, value = props.initValue ?? "", initValue, labelInline, min = -Infinity, max = Infinity, type, className, status = "normal", message, tip, append, prepend, step = 1, thousand, precision, hideControl, placeholder, border, onChange, onBlur, style, ...restProps } = props;
2586
+ const { label, name, value = props.initValue ?? "", initValue, labelInline, min = -Infinity, max = Infinity, type, className, status = "normal", message, tip, append, prepend, step = 1, width, thousand, precision, hideControl, placeholder, border, autoSwitch, onChange, onBlur, style, ...restProps } = props;
2557
2587
  const state = useReactive({
2558
2588
  value,
2559
2589
  });
@@ -2570,7 +2600,7 @@ const Range = (props) => {
2570
2600
  const { value } = e.target;
2571
2601
  const v = formatInputValue(value.replace(/[^\d\.-]/g, ""));
2572
2602
  const range = Array.isArray(state.value) ? state.value : [];
2573
- range[i] = +v;
2603
+ range[i] = v;
2574
2604
  state.value = range;
2575
2605
  onChange?.(range, e);
2576
2606
  };
@@ -2585,8 +2615,8 @@ const Range = (props) => {
2585
2615
  onChange?.(range, e);
2586
2616
  };
2587
2617
  const handleSwitch = (e) => {
2588
- e.preventDefault();
2589
- e.stopPropagation();
2618
+ e?.preventDefault();
2619
+ e?.stopPropagation();
2590
2620
  const range = state.value ? state.value : [];
2591
2621
  const v = range[0];
2592
2622
  range[0] = range[1];
@@ -2602,14 +2632,24 @@ const Range = (props) => {
2602
2632
  className: "i-input i-input-number",
2603
2633
  ...restProps,
2604
2634
  };
2605
- return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
2635
+ const handleBlur = () => {
2636
+ const range = Array.isArray(state.value) ? state.value : [];
2637
+ if (range.length < 2)
2638
+ return;
2639
+ const l = +range[0];
2640
+ const r = +range[1];
2641
+ if (l <= r)
2642
+ return;
2643
+ handleSwitch();
2644
+ };
2645
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
2606
2646
  [`i-input-${status}`]: status !== "normal",
2607
2647
  "i-input-borderless": !border,
2608
- }), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 0) })), jsx("input", { value: state.value?.[0] || "", placeholder: placeholder?.[0], ...inputProps, onChange: (e) => handleChange(e, 0) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 0) })), jsx(Helpericon, { active: true, icon: jsx(SyncAltRound, {}), style: { margin: 0 }, onClick: handleSwitch }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 1) })), jsx("input", { value: state.value?.[1] || "", placeholder: placeholder?.[1], ...inputProps, onChange: (e) => handleChange(e, 1) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 1) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
2648
+ }), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 0) })), jsx("input", { value: state.value?.[0] || "", placeholder: placeholder?.[0], ...inputProps, onBlur: handleBlur, onChange: (e) => handleChange(e, 0) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 0) })), jsx(Helpericon, { active: true, icon: jsx(SyncAltRound, {}), style: { margin: 0 }, onClick: handleSwitch }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 1) })), jsx("input", { value: state.value?.[1] || "", placeholder: placeholder?.[1], ...inputProps, onBlur: handleBlur, onChange: (e) => handleChange(e, 1) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 1) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
2609
2649
  };
2610
2650
 
2611
2651
  const Textarea = (props) => {
2612
- const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, style, onChange, onEnter, ...restProps } = props;
2652
+ const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, width, style, onChange, onEnter, ...restProps } = props;
2613
2653
  const state = useReactive({
2614
2654
  value,
2615
2655
  });
@@ -2641,14 +2681,14 @@ const Textarea = (props) => {
2641
2681
  onKeyDown: handleKeydown,
2642
2682
  ...restProps,
2643
2683
  };
2644
- return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsx("div", { ref: refTextarea, className: classNames("i-input-item", {
2684
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, children: jsx("div", { ref: refTextarea, className: classNames("i-input-item", {
2645
2685
  [`i-input-${status}`]: status !== "normal",
2646
2686
  "i-input-borderless": !border,
2647
2687
  }), children: jsx("textarea", { ...inputProps }) }) }));
2648
2688
  };
2649
2689
 
2650
2690
  const Input = ((props) => {
2651
- const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
2691
+ const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
2652
2692
  const state = useReactive({
2653
2693
  value,
2654
2694
  type,
@@ -2694,7 +2734,7 @@ const Input = ((props) => {
2694
2734
  };
2695
2735
  const clearable = clear && state.value;
2696
2736
  const showHelper = type === "password" && !!state.value;
2697
- return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
2737
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
2698
2738
  [`i-input-${status}`]: status !== "normal",
2699
2739
  "i-input-borderless": !border,
2700
2740
  }), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), jsx("input", { ...inputProps }), jsx(Helpericon, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
@@ -3819,7 +3859,7 @@ const Swiper = ((props) => {
3819
3859
  }, onMouseDown: handleMouseDown, onTouchStart: handleMouseDown, children: displayItems.map((item, i) => {
3820
3860
  const { props: itemProps } = item;
3821
3861
  return (jsx(Item$1, { index: i, itemIndex: (i - extra + size) % size, active: i - extra === state.current, type: type, gap: gap, transition: transition, itemHeight: itemHeight, vertical: vertical, onItemClick: onItemClick, ...itemProps }, i));
3822
- }) }), arrow && (jsxs(Fragment, { children: [(loop || state.current !== 0) && (jsx("a", { className: 'i-swiper-arrow i-swiper-prev', onClick: swipePrev, children: prev })), (loop || state.current < size - display) && (jsx("a", { className: 'i-swiper-arrow i-swiper-next', onClick: swipeNext, children: next }))] }))] }), indicator && (jsx("div", { className: classNames("i-swiper-indicators", {
3862
+ }) }), arrow && size > 1 && (jsxs(Fragment, { children: [(loop || state.current !== 0) && (jsx("a", { className: 'i-swiper-arrow i-swiper-prev', onClick: swipePrev, children: prev })), (loop || state.current < size - display) && (jsx("a", { className: 'i-swiper-arrow i-swiper-next', onClick: swipeNext, children: next }))] }))] }), indicator && (jsx("div", { className: classNames("i-swiper-indicators", {
3823
3863
  "i-swiper-indicators-fixed": fixedIndicator,
3824
3864
  }), children: indicatorsLoop.map((_, i) => {
3825
3865
  return (jsx("a", { className: classNames("i-swiper-indicator", {
@@ -12,6 +12,7 @@ interface IEditor extends Omit<HTMLAttributes<HTMLDivElement>, "onInput"> {
12
12
  onInput?: (html: string, e: FormEvent<HTMLDivElement>) => void;
13
13
  }
14
14
  interface RefEditor {
15
+ input: HTMLDivElement | null;
15
16
  getSafeValue: () => string;
16
17
  setValue: (html: string) => void;
17
18
  }
@@ -1,12 +1,14 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import Field from './field.js';
3
3
  import { IForm } from './type.js';
4
+ import useConfig from './useConfig.js';
4
5
  import useForm from './useForm.js';
5
6
 
6
7
  declare const Form: {
7
8
  (props: IForm): react_jsx_runtime.JSX.Element;
8
9
  useForm: typeof useForm;
9
10
  Field: typeof Field;
11
+ useConfig: typeof useConfig;
10
12
  };
11
13
 
12
14
  export { Form as default };
@@ -26,5 +26,17 @@ interface IField {
26
26
  children?: ReactNode;
27
27
  required?: boolean;
28
28
  }
29
+ interface IFormItem {
30
+ name: string;
31
+ label?: ReactNode;
32
+ required?: boolean;
33
+ component: any;
34
+ componentProps?: Record<string, any>;
35
+ colspan?: number | "full";
36
+ rowspan?: number | "full";
37
+ render?: (config: IFormItem, values: Record<string, any>) => ReactNode;
38
+ shouldRender?: (values: Record<string, any>, form: IFormInstance) => boolean;
39
+ shouldUpdate?: (values: Record<string, any>, form: IFormInstance) => boolean;
40
+ }
29
41
 
30
- export type { IField, IForm, TRule, TValidator };
42
+ export type { IField, IForm, IFormItem, TRule, TValidator };
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { IFormInstance } from './useForm.js';
3
+ import { IFormItem, IForm } from './type.js';
4
+
5
+ declare function useConfig(configs: IFormItem[], formProps?: IForm): {
6
+ form: IFormInstance;
7
+ node: react_jsx_runtime.JSX.Element;
8
+ };
9
+
10
+ export { useConfig as default };
@@ -12,6 +12,7 @@ interface IInput extends BaseInput, Omit<InputHTMLAttributes<HTMLInputElement>,
12
12
  interface ITextarea extends Omit<BaseInput, "ref">, Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue" | "onChange"> {
13
13
  ref?: RefObject<HTMLTextAreaElement | null>;
14
14
  autoSize?: boolean;
15
+ width?: string | number;
15
16
  }
16
17
  interface IInputNumber extends BaseInput, Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "defaultValue"> {
17
18
  value?: string | number;
@@ -35,6 +36,7 @@ interface IInputRange extends Omit<BaseInput, "value" | "onChange">, Omit<InputH
35
36
  thousand?: string;
36
37
  precision?: number;
37
38
  hideControl?: boolean;
39
+ autoSwitch?: boolean;
38
40
  onChange?: (value: (number | string | undefined)[], e?: ChangeEvent<HTMLInputElement> | MouseEvent<Element>) => void;
39
41
  }
40
42
  type CompositionInput = ForwardRefExoticComponent<IInput> & {
@@ -21,7 +21,7 @@ interface IModal extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
21
21
  keepDOM?: boolean;
22
22
  disableEsc?: boolean;
23
23
  onVisibleChange?: (visible: boolean) => void;
24
- onOk?: () => void | Promise<any>;
24
+ onOk?: () => (void | boolean) | Promise<any>;
25
25
  onClose?: () => void;
26
26
  }
27
27
  interface CompositionModal extends FC<IModal> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ioca/react",
3
- "version": "1.3.77",
3
+ "version": "1.3.81",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",