@ioca/react 1.3.79 → 1.3.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/editor/editor.js +1 -0
- package/lib/cjs/components/editor/editor.js.map +1 -1
- package/lib/cjs/components/form/useForm.js +2 -0
- package/lib/cjs/components/form/useForm.js.map +1 -1
- package/lib/cjs/components/image/image.js +6 -5
- package/lib/cjs/components/image/image.js.map +1 -1
- package/lib/cjs/components/image/list.js +1 -1
- package/lib/cjs/components/image/list.js.map +1 -1
- package/lib/cjs/components/input/input.js +2 -2
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/input/number.js +2 -2
- package/lib/cjs/components/input/number.js.map +1 -1
- package/lib/cjs/components/input/range.js +16 -6
- package/lib/cjs/components/input/range.js.map +1 -1
- package/lib/cjs/components/input/textarea.js +2 -2
- package/lib/cjs/components/input/textarea.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +1 -1
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/swiper/swiper.js +1 -1
- package/lib/cjs/components/swiper/swiper.js.map +1 -1
- package/lib/cjs/js/utils.js +23 -3
- package/lib/cjs/js/utils.js.map +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/editor/editor.js +1 -0
- package/lib/es/components/editor/editor.js.map +1 -1
- package/lib/es/components/form/useForm.js +2 -0
- package/lib/es/components/form/useForm.js.map +1 -1
- package/lib/es/components/image/image.js +6 -5
- package/lib/es/components/image/image.js.map +1 -1
- package/lib/es/components/image/list.js +1 -1
- package/lib/es/components/image/list.js.map +1 -1
- package/lib/es/components/input/input.js +2 -2
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/input/number.js +2 -2
- package/lib/es/components/input/number.js.map +1 -1
- package/lib/es/components/input/range.js +16 -6
- package/lib/es/components/input/range.js.map +1 -1
- package/lib/es/components/input/textarea.js +2 -2
- package/lib/es/components/input/textarea.js.map +1 -1
- package/lib/es/components/modal/modal.js +1 -1
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/swiper/swiper.js +1 -1
- package/lib/es/components/swiper/swiper.js.map +1 -1
- package/lib/es/js/utils.js +23 -3
- package/lib/es/js/utils.js.map +1 -1
- package/lib/index.js +57 -23
- package/lib/types/components/editor/type.d.ts +1 -0
- package/lib/types/components/image/type.d.ts +6 -1
- package/lib/types/components/input/type.d.ts +2 -0
- package/lib/types/components/modal/type.d.ts +1 -1
- package/package.json +1 -1
package/lib/es/js/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../packages/js/utils.ts"],"sourcesContent":["import type { MouseEvent } from \"react\";\nimport { ReactNode, useEffect, useRef, useState } from \"react\";\nimport { Root, createRoot } from \"react-dom/client\";\nimport type { TOption, TOptions, TRelativeOptions } from \"../type\";\n\ntype TComputePosition = {\n\tcontainerSize: number;\n\ttargetSize: number;\n\ttargetOffset: number;\n\tcontentSize: number;\n\tgap: number;\n\talign?: \"start\" | \"center\" | \"end\";\n};\n\nexport function getPosition(\n\t$source?: HTMLElement | null,\n\t$popup?: HTMLElement | null,\n\toptions: TRelativeOptions = {}\n): [\n\tx: number,\n\ty: number,\n\tz: {\n\t\tarrowX: number;\n\t\tarrowY: number;\n\t\tarrowPos: string;\n\t}\n] {\n\tconst { refWindow, gap = 0, offset = 0, position = \"top\", align } = options;\n\n\tif (!$source || !$popup)\n\t\treturn [\n\t\t\t0,\n\t\t\t0,\n\t\t\t{\n\t\t\t\tarrowX: 0,\n\t\t\t\tarrowY: 0,\n\t\t\t\tarrowPos: \"bottom\",\n\t\t\t},\n\t\t];\n\n\tconst rectT = $source.getBoundingClientRect();\n\tconst rectC = $popup.getBoundingClientRect();\n\n\tlet w = window.innerWidth;\n\tlet h = window.innerHeight;\n\tlet {\n\t\tleft: tl,\n\t\ttop: tt,\n\t\tright: tr,\n\t\tbottom: tb,\n\t\twidth: tw,\n\t\theight: th,\n\t} = rectT;\n\tconst { height: ch, width: cw } = rectC;\n\n\tif (!refWindow) {\n\t\tconst rectPa = $source.offsetParent?.getBoundingClientRect();\n\n\t\tw = rectPa?.width || w;\n\t\th = rectPa?.height || h;\n\t\ttl = $source.offsetLeft;\n\t\ttt = $source.offsetTop;\n\t\ttr = tl + rectT.width;\n\t\ttb = tt + rectT.height;\n\t}\n\n\tlet y = 0;\n\tlet x = 0;\n\tlet arrowX = 0;\n\tlet arrowY = 0;\n\tlet arrowPos = \"bottom\";\n\n\tswitch (position) {\n\t\tcase \"left\":\n\t\tcase \"right\":\n\t\t\ty =\n\t\t\t\tth !== ch\n\t\t\t\t\t? computePosition({\n\t\t\t\t\t\t\tcontainerSize: h,\n\t\t\t\t\t\t\ttargetSize: th,\n\t\t\t\t\t\t\ttargetOffset: tt,\n\t\t\t\t\t\t\tcontentSize: ch,\n\t\t\t\t\t\t\tgap,\n\t\t\t\t\t\t\talign,\n\t\t\t\t\t })\n\t\t\t\t\t: tt;\n\t\t\tarrowY = y < tt ? tt - y + th / 2 : th / 2;\n\n\t\t\tconst xl = tl - offset - cw;\n\t\t\tconst xr = tr + offset + cw;\n\n\t\t\tif (position === \"left\") {\n\t\t\t\tconst R = xl < 0 && xr <= w;\n\t\t\t\tx = R ? tr + offset : xl;\n\t\t\t\tarrowX = R ? 0 : cw;\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\n\t\t\t} else {\n\t\t\t\tconst R = w > xr || xl < 0;\n\t\t\t\tx = R ? tr + offset : xl;\n\t\t\t\tarrowX = R ? 0 : cw;\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase \"top\":\n\t\tcase \"bottom\":\n\t\t\tx =\n\t\t\t\ttw !== cw\n\t\t\t\t\t? computePosition({\n\t\t\t\t\t\t\tcontainerSize: w,\n\t\t\t\t\t\t\ttargetOffset: tl,\n\t\t\t\t\t\t\ttargetSize: tw,\n\t\t\t\t\t\t\tcontentSize: cw,\n\t\t\t\t\t\t\tgap,\n\t\t\t\t\t\t\talign,\n\t\t\t\t\t })\n\t\t\t\t\t: tl;\n\t\t\tarrowX = x > tl ? cw / 2 : tl - x + tw / 2;\n\n\t\t\tconst yt = tt - offset - ch;\n\t\t\tconst yb = tb + offset + ch;\n\t\t\tif (position === \"top\") {\n\t\t\t\tconst T = yt < 0 && yb <= h;\n\t\t\t\ty = T ? tb + offset : yt;\n\t\t\t\tarrowY = T ? 0 : ch;\n\t\t\t\tarrowPos = T ? \"top\" : \"bottom\";\n\t\t\t} else {\n\t\t\t\tconst B = h > yb || yt < 0;\n\t\t\t\ty = B ? tb + offset : yt;\n\t\t\t\tarrowY = B ? 0 : ch;\n\t\t\t\tarrowPos = B ? \"top\" : \"bottom\";\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\treturn [\n\t\tx,\n\t\ty,\n\t\t{\n\t\t\tarrowX,\n\t\t\tarrowY,\n\t\t\tarrowPos,\n\t\t},\n\t];\n}\n\nexport function getPointPosition(e: MouseEvent, content: HTMLElement) {\n\tconst { width: w, height: h } = content.getBoundingClientRect();\n\tconst parent = content.offsetParent;\n\tlet pw,\n\t\tph,\n\t\tpl = 0,\n\t\tpt = 0;\n\n\tif (parent) {\n\t\tconst {\n\t\t\twidth: ow,\n\t\t\theight: oh,\n\t\t\tleft: ol,\n\t\t\ttop: ot,\n\t\t} = parent.getBoundingClientRect();\n\t\tconst st = parent.scrollTop ?? 0;\n\n\t\tpw = ow;\n\t\tph = oh;\n\t\tpt = ot - st;\n\t\tpl = ol;\n\t} else {\n\t\tpw = window.innerWidth;\n\t\tph = window.innerHeight;\n\t}\n\tconst x = e.pageX - pl;\n\tconst y = e.pageY - pt;\n\n\tconst left = x + w >= pw ? (x - w > 0 ? x - w : x) : x;\n\tconst top = y + h >= ph ? (y - h > 0 ? y - h : y) : y;\n\n\treturn [left, top];\n}\n\nfunction computePosition({\n\tcontainerSize,\n\ttargetSize,\n\ttargetOffset,\n\tcontentSize,\n\tgap,\n\talign = \"center\",\n}: TComputePosition) {\n\tconst centerPoint = targetOffset + targetSize / 2;\n\n\tswitch (align) {\n\t\tcase \"start\":\n\t\t\treturn targetOffset + contentSize > containerSize\n\t\t\t\t? containerSize - contentSize - gap\n\t\t\t\t: targetOffset;\n\t\tcase \"center\":\n\t\t\tif (targetSize >= contentSize) {\n\t\t\t\treturn centerPoint - contentSize / 2;\n\t\t\t}\n\n\t\t\tif (centerPoint + contentSize / 2 + gap > containerSize) {\n\t\t\t\treturn targetOffset + targetSize - contentSize;\n\t\t\t}\n\n\t\t\tif (centerPoint - contentSize / 2 - gap < 0) {\n\t\t\t\treturn gap;\n\t\t\t}\n\n\t\t\treturn centerPoint - contentSize / 2;\n\t\tcase \"end\":\n\t\t\tconst result = targetOffset + targetSize - contentSize;\n\t\t\treturn result > 0 ? result : gap;\n\t\tdefault:\n\t\t\treturn centerPoint - contentSize / 2;\n\t}\n}\n\nexport function formatOption(options: TOptions): TOption[] {\n\treturn options.map((option) =>\n\t\t[\"string\", \"number\"].includes(typeof option)\n\t\t\t? { label: option, value: option }\n\t\t\t: option\n\t) as TOption[];\n}\n\nexport function animate(\n\tfrom: number,\n\tto: number,\n\tduration: number = 1000,\n\tcallback?: (v: number) => void,\n\teasing: (t: number) => number = (t) => 1 - Math.pow(1 - t, 4)\n) {\n\tconst start = performance.now();\n\tconst diff = to - from;\n\tlet raf = requestAnimationFrame(loop);\n\n\tfunction loop() {\n\t\traf = requestAnimationFrame(loop);\n\n\t\tconst past = performance.now() - start;\n\t\tlet percent = past / duration;\n\n\t\tif (percent >= 1) {\n\t\t\tpercent = 1;\n\t\t\tcancelAnimationFrame(raf);\n\t\t}\n\n\t\tconst pass = diff * easing(percent);\n\t\tcallback?.(pass);\n\t}\n}\n\nexport function formatNumber(\n\tvalue: number,\n\toptions: {\n\t\tprecision?: number;\n\t\tthousand?: string;\n\t} = {}\n) {\n\tconst { precision, thousand } = options;\n\n\tconst result = value.toFixed(precision);\n\n\tif (!thousand) return result;\n\n\tconst points = result.split(\".\");\n\tconst integer = points[0].replace(\n\t\t/\\d{1,3}(?=(\\d{3})+(\\.\\d*)?$)/g,\n\t\t`$&${thousand}`\n\t);\n\n\tif (points.length === 1) return integer;\n\n\treturn `${integer}.${points[1]}`;\n}\n\nexport function renderNode(node: ReactNode, container = document.body) {\n\tconst div: HTMLDivElement | null = document.createElement(\"div\");\n\tcontainer.append(div);\n\n\tconst root: Root | null = createRoot(div);\n\tconst sto = setTimeout(() => {\n\t\troot?.render(node);\n\t}, 0);\n\n\treturn () => {\n\t\tdiv?.remove();\n\t\troot?.unmount();\n\t\tsto && clearTimeout(sto);\n\t};\n}\n\nexport function getSuffixByUrl(url: string) {\n\treturn url.match(/\\.([^\\./\\?]+)($|\\?)/)?.[1];\n}\n\nexport function getFileType(suffix: string, type?: string) {\n\tswitch (true) {\n\t\tcase [\"jpg\", \"jpeg\", \"png\", \"webp\", \"svg\"].includes(suffix) ||\n\t\t\ttype?.startsWith(\"image/\"):\n\t\t\treturn \"IMAGE\";\n\t\tcase [\"mp4\", \"avi\"].includes(suffix) || type?.startsWith(\"video/\"):\n\t\t\treturn \"VIDEO\";\n\t\tdefault:\n\t\t\treturn \"UNKNOWN\";\n\t}\n}\n\nexport function fullScreen(el: HTMLElement) {\n\tel.requestFullscreen?.();\n}\n\nexport function exitFullScreen() {\n\tdocument.exitFullscreen?.();\n}\n\nexport function formatTime(\n\ttime: number,\n\toptions?: {\n\t\tzero?: boolean;\n\t\tunits?: string[];\n\t}\n) {\n\tconst result: string[] = [];\n\tconst { zero = true, units = [\"\", \":\", \":\"] } = options || {};\n\n\tconst l = units.length;\n\tlet i = 0;\n\n\twhile (i < l) {\n\t\tif (time <= 0 && i > 1) break;\n\n\t\tconst n = Math.round(time % 60);\n\n\t\ttime = Math.floor(time / 60);\n\n\t\tresult.unshift((zero && n < 10 ? `0${n}` : n) + units[i++]);\n\t}\n\n\treturn result.join(\"\");\n}\n\nexport function getNextSorter(\n\tprevSortBy: string,\n\tprevSortType: string,\n\tsortBy: string\n): [sortBy: string, sortType: string] {\n\tconst types = [\"desc\", \"asc\"];\n\n\tif (prevSortBy === sortBy) {\n\t\tconst i = types.findIndex((t) => t === prevSortType) + 1;\n\t\tconst type = types[i] || \"\";\n\t\tconst by = type === \"\" ? \"\" : sortBy;\n\n\t\treturn [by, type];\n\t}\n\n\treturn [sortBy, \"desc\"];\n}\n\nexport function formatBytes(bytes: number, decimals = 2) {\n\tif (!+bytes) return \"0 Bytes\";\n\n\tconst k = 1024;\n\tconst dm = decimals < 0 ? 0 : decimals;\n\tconst sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\n\treturn `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;\n}\n\nexport function clamp(value: number, min: number, max: number) {\n\treturn value < min ? min : value > max ? max : value;\n}\n\nexport const arrayMove = (array, fromIndex: number, toIndex: number) => {\n\tif (toIndex >= array.length) {\n\t\tlet k = toIndex - array.length + 1;\n\t\twhile (k--) {\n\t\t\tarray.push(undefined);\n\t\t}\n\t}\n\tarray.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);\n\treturn array;\n};\n\ntype ReactiveObject<T> = T & { __isReactive?: boolean };\n\nexport function useReactive<T extends object>(\n\tinitialState: T\n): ReactiveObject<T> {\n\tconst [, setState] = useState<number>(0);\n\tconst reactiveState = useRef<ReactiveObject<T>>(initialState);\n\n\tuseEffect(() => {\n\t\tif (!reactiveState.current.__isReactive) {\n\t\t\treactiveState.current = createReactiveObject(\n\t\t\t\treactiveState.current,\n\t\t\t\tsetState\n\t\t\t);\n\t\t}\n\t}, []);\n\n\treturn reactiveState.current;\n}\n\nfunction createReactiveObject<T extends object>(\n\ttarget: T,\n\tsetState: React.Dispatch<React.SetStateAction<number>>\n): ReactiveObject<T> {\n\treturn new Proxy(target, {\n\t\tget(obj, prop) {\n\t\t\tif (prop === \"__isReactive\") return true;\n\t\t\treturn Reflect.get(obj, prop);\n\t\t},\n\t\tset(obj, prop, value) {\n\t\t\tconst result = Reflect.set(obj, prop, value);\n\t\t\tsetState((prev) => prev + 1); // Trigger re-render\n\t\t\treturn result;\n\t\t},\n\t}) as ReactiveObject<T>;\n}\n\nexport default useReactive;\n"],"names":[],"mappings":";;;AAcM,SAAU,WAAW,CAC1B,OAA4B,EAC5B,MAA2B,EAC3B,UAA4B,EAAE,EAAA;AAU9B,IAAA,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO;AAE3E,IAAA,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;QACtB,OAAO;YACN,CAAC;YACD,CAAC;AACD,YAAA;AACC,gBAAA,MAAM,EAAE,CAAC;AACT,gBAAA,MAAM,EAAE,CAAC;AACT,gBAAA,QAAQ,EAAE,QAAQ;AAClB,aAAA;SACD;AAEF,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,qBAAqB,EAAE;AAC7C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,qBAAqB,EAAE;AAE5C,IAAA,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU;AACzB,IAAA,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW;IAC1B,IAAI,EACH,IAAI,EAAE,EAAE,EACR,GAAG,EAAE,EAAE,EACP,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,GACV,GAAG,KAAK;IACT,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,KAAK;IAEvC,IAAI,CAAC,SAAS,EAAE;QACf,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY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AK,CAAC,IAAI,CAAC,SAAS,CAAC;;;AAGvB,IAAA,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,IAAA,OAAO,KAAK;AACb;;;;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../packages/js/utils.ts"],"sourcesContent":["import type { MouseEvent } from \"react\";\nimport { ReactNode, useEffect, useRef, useState } from \"react\";\nimport { Root, createRoot } from \"react-dom/client\";\nimport type { TOption, TOptions, TRelativeOptions } from \"../type\";\n\ntype TComputePosition = {\n\tcontainerSize: number;\n\ttargetSize: number;\n\ttargetOffset: number;\n\tcontentSize: number;\n\tgap: number;\n\talign?: \"start\" | \"center\" | \"end\";\n};\n\nexport function getPosition(\n\t$source?: HTMLElement | null,\n\t$popup?: HTMLElement | null,\n\toptions: TRelativeOptions = {}\n): [\n\tx: number,\n\ty: number,\n\tz: {\n\t\tarrowX: number;\n\t\tarrowY: number;\n\t\tarrowPos: string;\n\t}\n] {\n\tconst { refWindow, gap = 0, offset = 0, position = \"top\", align } = options;\n\n\tif (!$source || !$popup)\n\t\treturn [\n\t\t\t0,\n\t\t\t0,\n\t\t\t{\n\t\t\t\tarrowX: 0,\n\t\t\t\tarrowY: 0,\n\t\t\t\tarrowPos: \"bottom\",\n\t\t\t},\n\t\t];\n\n\tconst rectT = $source.getBoundingClientRect();\n\tconst rectC = $popup.getBoundingClientRect();\n\n\tlet w = window.innerWidth;\n\tlet h = window.innerHeight;\n\tlet {\n\t\tleft: tl,\n\t\ttop: tt,\n\t\tright: tr,\n\t\tbottom: tb,\n\t\twidth: tw,\n\t\theight: th,\n\t} = rectT;\n\tconst { height: ch, width: cw } = rectC;\n\n\tif (!refWindow) {\n\t\tconst rectPa = $source.offsetParent?.getBoundingClientRect();\n\n\t\tw = rectPa?.width || w;\n\t\th = rectPa?.height || h;\n\t\ttl = $source.offsetLeft;\n\t\ttt = $source.offsetTop;\n\t\ttr = tl + rectT.width;\n\t\ttb = tt + rectT.height;\n\t}\n\n\tlet y = 0;\n\tlet x = 0;\n\tlet arrowX = 0;\n\tlet arrowY = 0;\n\tlet arrowPos = \"bottom\";\n\n\tswitch (position) {\n\t\tcase \"left\":\n\t\tcase \"right\":\n\t\t\ty =\n\t\t\t\tth !== ch\n\t\t\t\t\t? computePosition({\n\t\t\t\t\t\t\tcontainerSize: h,\n\t\t\t\t\t\t\ttargetSize: th,\n\t\t\t\t\t\t\ttargetOffset: tt,\n\t\t\t\t\t\t\tcontentSize: ch,\n\t\t\t\t\t\t\tgap,\n\t\t\t\t\t\t\talign,\n\t\t\t\t\t })\n\t\t\t\t\t: tt;\n\t\t\tarrowY = y < tt ? tt - y + th / 2 : th / 2;\n\n\t\t\tconst xl = tl - offset - cw;\n\t\t\tconst xr = tr + offset + cw;\n\n\t\t\tif (position === \"left\") {\n\t\t\t\tconst R = xl < 0 && xr <= w;\n\t\t\t\tx = R ? tr + offset : xl;\n\t\t\t\tarrowX = R ? 0 : cw;\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\n\t\t\t} else {\n\t\t\t\tconst R = w > xr || xl < 0;\n\t\t\t\tx = R ? tr + offset : xl;\n\t\t\t\tarrowX = R ? 0 : cw;\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase \"top\":\n\t\tcase \"bottom\":\n\t\t\tx =\n\t\t\t\ttw !== cw\n\t\t\t\t\t? computePosition({\n\t\t\t\t\t\t\tcontainerSize: w,\n\t\t\t\t\t\t\ttargetOffset: tl,\n\t\t\t\t\t\t\ttargetSize: tw,\n\t\t\t\t\t\t\tcontentSize: cw,\n\t\t\t\t\t\t\tgap,\n\t\t\t\t\t\t\talign,\n\t\t\t\t\t })\n\t\t\t\t\t: tl;\n\t\t\tarrowX = x > tl ? cw / 2 : tl - x + tw / 2;\n\n\t\t\tconst yt = tt - offset - ch;\n\t\t\tconst yb = tb + offset + ch;\n\t\t\tif (position === \"top\") {\n\t\t\t\tconst T = yt < 0 && yb <= h;\n\t\t\t\ty = T ? tb + offset : yt;\n\t\t\t\tarrowY = T ? 0 : ch;\n\t\t\t\tarrowPos = T ? \"top\" : \"bottom\";\n\t\t\t} else {\n\t\t\t\tconst B = h > yb || yt < 0;\n\t\t\t\ty = B ? tb + offset : yt;\n\t\t\t\tarrowY = B ? 0 : ch;\n\t\t\t\tarrowPos = B ? \"top\" : \"bottom\";\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\treturn [\n\t\tx,\n\t\ty,\n\t\t{\n\t\t\tarrowX,\n\t\t\tarrowY,\n\t\t\tarrowPos,\n\t\t},\n\t];\n}\n\nexport function getPointPosition(e: MouseEvent, content: HTMLElement) {\n\tconst { width: w, height: h } = content.getBoundingClientRect();\n\tconst parent = content.offsetParent;\n\tlet pw,\n\t\tph,\n\t\tpl = 0,\n\t\tpt = 0;\n\n\tif (parent) {\n\t\tconst {\n\t\t\twidth: ow,\n\t\t\theight: oh,\n\t\t\tleft: ol,\n\t\t\ttop: ot,\n\t\t} = parent.getBoundingClientRect();\n\t\tconst st = parent.scrollTop ?? 0;\n\n\t\tpw = ow;\n\t\tph = oh;\n\t\tpt = ot - st;\n\t\tpl = ol;\n\t} else {\n\t\tpw = window.innerWidth;\n\t\tph = window.innerHeight;\n\t}\n\tconst x = e.pageX - pl;\n\tconst y = e.pageY - pt;\n\n\tconst left = x + w >= pw ? (x - w > 0 ? x - w : x) : x;\n\tconst top = y + h >= ph ? (y - h > 0 ? y - h : y) : y;\n\n\treturn [left, top];\n}\n\nfunction computePosition({\n\tcontainerSize,\n\ttargetSize,\n\ttargetOffset,\n\tcontentSize,\n\tgap,\n\talign = \"center\",\n}: TComputePosition) {\n\tconst centerPoint = targetOffset + targetSize / 2;\n\n\tswitch (align) {\n\t\tcase \"start\":\n\t\t\treturn targetOffset + contentSize > containerSize\n\t\t\t\t? containerSize - contentSize - gap\n\t\t\t\t: targetOffset;\n\t\tcase \"center\":\n\t\t\tif (targetSize >= contentSize) {\n\t\t\t\treturn centerPoint - contentSize / 2;\n\t\t\t}\n\n\t\t\tif (centerPoint + contentSize / 2 + gap > containerSize) {\n\t\t\t\treturn targetOffset + targetSize - contentSize;\n\t\t\t}\n\n\t\t\tif (centerPoint - contentSize / 2 - gap < 0) {\n\t\t\t\treturn gap;\n\t\t\t}\n\n\t\t\treturn centerPoint - contentSize / 2;\n\t\tcase \"end\":\n\t\t\tconst result = targetOffset + targetSize - contentSize;\n\t\t\treturn result > 0 ? result : gap;\n\t\tdefault:\n\t\t\treturn centerPoint - contentSize / 2;\n\t}\n}\n\nexport function formatOption(options: TOptions): TOption[] {\n\treturn options.map((option) =>\n\t\t[\"string\", \"number\"].includes(typeof option)\n\t\t\t? { label: option, value: option }\n\t\t\t: option\n\t) as TOption[];\n}\n\nexport function animate(\n\tfrom: number,\n\tto: number,\n\tduration: number = 1000,\n\tcallback?: (v: number) => void,\n\teasing: (t: number) => number = (t) => 1 - Math.pow(1 - t, 4)\n) {\n\tconst start = performance.now();\n\tconst diff = to - from;\n\tlet raf = requestAnimationFrame(loop);\n\n\tfunction loop() {\n\t\traf = requestAnimationFrame(loop);\n\n\t\tconst past = performance.now() - start;\n\t\tlet percent = past / duration;\n\n\t\tif (percent >= 1) {\n\t\t\tpercent = 1;\n\t\t\tcancelAnimationFrame(raf);\n\t\t}\n\n\t\tconst pass = diff * easing(percent);\n\t\tcallback?.(pass);\n\t}\n}\n\nexport function formatNumber(\n\tvalue: number,\n\toptions: {\n\t\tprecision?: number;\n\t\tthousand?: string;\n\t} = {}\n) {\n\tconst { precision, thousand } = options;\n\n\tconst result = value.toFixed(precision);\n\n\tif (!thousand) return result;\n\n\tconst points = result.split(\".\");\n\tconst integer = points[0].replace(\n\t\t/\\d{1,3}(?=(\\d{3})+(\\.\\d*)?$)/g,\n\t\t`$&${thousand}`\n\t);\n\n\tif (points.length === 1) return integer;\n\n\treturn `${integer}.${points[1]}`;\n}\n\nexport function renderNode(node: ReactNode, container = document.body) {\n\tconst div: HTMLDivElement | null = document.createElement(\"div\");\n\tcontainer.append(div);\n\n\tconst root: Root | null = createRoot(div);\n\tconst sto = setTimeout(() => {\n\t\troot?.render(node);\n\t}, 0);\n\n\treturn () => {\n\t\tdiv?.remove();\n\t\troot?.unmount();\n\t\tsto && clearTimeout(sto);\n\t};\n}\n\nexport function getSuffixByUrl(url: string) {\n\treturn url.match(/\\.([^\\./\\?]+)($|\\?)/)?.[1];\n}\n\nexport function getFileType(suffix: string, type?: string) {\n\tswitch (true) {\n\t\tcase [\n\t\t\t\"jpg\",\n\t\t\t\"jpeg\",\n\t\t\t\"png\",\n\t\t\t\"webp\",\n\t\t\t\"svg\",\n\t\t\t\"avif\",\n\t\t\t\"heif\",\n\t\t\t\"heic\",\n\t\t\t\"apng\",\n\t\t\t\"bmp\",\n\t\t\t\"ico\",\n\t\t].includes(suffix) || type?.startsWith(\"image/\"):\n\t\t\treturn \"IMAGE\";\n\t\tcase [\n\t\t\t\"mp4\",\n\t\t\t\"avi\",\n\t\t\t\"webm\",\n\t\t\t\"ogv\",\n\t\t\t\"mov\",\n\t\t\t\"mkv\",\n\t\t\t\"mpd\",\n\t\t\t\"m3u8\",\n\t\t].includes(suffix) || type?.startsWith(\"video/\"):\n\t\t\treturn \"VIDEO\";\n\t\tdefault:\n\t\t\treturn \"UNKNOWN\";\n\t}\n}\n\nexport function fullScreen(el: HTMLElement) {\n\tel.requestFullscreen?.();\n}\n\nexport function exitFullScreen() {\n\tdocument.exitFullscreen?.();\n}\n\nexport function formatTime(\n\ttime: number,\n\toptions?: {\n\t\tzero?: boolean;\n\t\tunits?: string[];\n\t}\n) {\n\tconst result: string[] = [];\n\tconst { zero = true, units = [\"\", \":\", \":\"] } = options || {};\n\n\tconst l = units.length;\n\tlet i = 0;\n\n\twhile (i < l) {\n\t\tif (time <= 0 && i > 1) break;\n\n\t\tconst n = Math.round(time % 60);\n\n\t\ttime = Math.floor(time / 60);\n\n\t\tresult.unshift((zero && n < 10 ? `0${n}` : n) + units[i++]);\n\t}\n\n\treturn result.join(\"\");\n}\n\nexport function getNextSorter(\n\tprevSortBy: string,\n\tprevSortType: string,\n\tsortBy: string\n): [sortBy: string, sortType: string] {\n\tconst types = [\"desc\", \"asc\"];\n\n\tif (prevSortBy === sortBy) {\n\t\tconst i = types.findIndex((t) => t === prevSortType) + 1;\n\t\tconst type = types[i] || \"\";\n\t\tconst by = type === \"\" ? \"\" : sortBy;\n\n\t\treturn [by, type];\n\t}\n\n\treturn [sortBy, \"desc\"];\n}\n\nexport function formatBytes(bytes: number, decimals = 2) {\n\tif (!+bytes) return \"0 Bytes\";\n\n\tconst k = 1024;\n\tconst dm = decimals < 0 ? 0 : decimals;\n\tconst sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\n\treturn `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;\n}\n\nexport function clamp(value: number, min: number, max: number) {\n\treturn value < min ? min : value > max ? max : value;\n}\n\nexport const arrayMove = (array, fromIndex: number, toIndex: number) => {\n\tif (toIndex >= array.length) {\n\t\tlet k = toIndex - array.length + 1;\n\t\twhile (k--) {\n\t\t\tarray.push(undefined);\n\t\t}\n\t}\n\tarray.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);\n\treturn array;\n};\n\ntype ReactiveObject<T> = T & { __isReactive?: boolean };\n\nexport function useReactive<T extends object>(\n\tinitialState: T\n): ReactiveObject<T> {\n\tconst [, setState] = useState<number>(0);\n\tconst reactiveState = useRef<ReactiveObject<T>>(initialState);\n\n\tuseEffect(() => {\n\t\tif (!reactiveState.current.__isReactive) {\n\t\t\treactiveState.current = createReactiveObject(\n\t\t\t\treactiveState.current,\n\t\t\t\tsetState\n\t\t\t);\n\t\t}\n\t}, []);\n\n\treturn reactiveState.current;\n}\n\nfunction createReactiveObject<T extends object>(\n\ttarget: T,\n\tsetState: React.Dispatch<React.SetStateAction<number>>\n): ReactiveObject<T> {\n\treturn new Proxy(target, {\n\t\tget(obj, prop) {\n\t\t\tif (prop === \"__isReactive\") return true;\n\t\t\treturn Reflect.get(obj, prop);\n\t\t},\n\t\tset(obj, prop, value) {\n\t\t\tconst result = Reflect.set(obj, prop, value);\n\t\t\tsetState((prev) => prev + 1); // Trigger re-render\n\t\t\treturn result;\n\t\t},\n\t}) as ReactiveObject<T>;\n}\n\nexport default useReactive;\n"],"names":[],"mappings":";;;AAcM,SAAU,WAAW,CAC1B,OAA4B,EAC5B,MAA2B,EAC3B,UAA4B,EAAE,EAAA;AAU9B,IAAA,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO;AAE3E,IAAA,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;QACtB,OAAO;YACN,CAAC;YACD,CAAC;AACD,YAAA;AACC,gBAAA,MAAM,EAAE,CAAC;AACT,gBAAA,MAAM,EAAE,CAAC;AACT,gBAAA,QAAQ,EAAE,QAAQ;AAClB,aAAA;SACD;AAEF,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,qBAAqB,EAAE;AAC7C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,qBAAqB,EAAE;AAE5C,IAAA,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU;AACzB,IAAA,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW;IAC1B,IAAI,EACH,IAAI,EAAE,EAAE,EACR,GAAG,EAAE,EAAE,EACP,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,GACV,GAAG,KAAK;IACT,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EA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KAAK,EAAE,SAAiB,EAAE,OAAe,KAAI;AACtE,IAAA,IAAI,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QAC5B,IAAI,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;QAClC,OAAO,CAAC,EAAE,EAAE;AACX,YAAA,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;;;AAGvB,IAAA,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,IAAA,OAAO,KAAK;AACb;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -468,10 +468,30 @@ function getSuffixByUrl(url) {
|
|
|
468
468
|
}
|
|
469
469
|
function getFileType(suffix, type) {
|
|
470
470
|
switch (true) {
|
|
471
|
-
case [
|
|
472
|
-
|
|
471
|
+
case [
|
|
472
|
+
"jpg",
|
|
473
|
+
"jpeg",
|
|
474
|
+
"png",
|
|
475
|
+
"webp",
|
|
476
|
+
"svg",
|
|
477
|
+
"avif",
|
|
478
|
+
"heif",
|
|
479
|
+
"heic",
|
|
480
|
+
"apng",
|
|
481
|
+
"bmp",
|
|
482
|
+
"ico",
|
|
483
|
+
].includes(suffix) || type?.startsWith("image/"):
|
|
473
484
|
return "IMAGE";
|
|
474
|
-
case [
|
|
485
|
+
case [
|
|
486
|
+
"mp4",
|
|
487
|
+
"avi",
|
|
488
|
+
"webm",
|
|
489
|
+
"ogv",
|
|
490
|
+
"mov",
|
|
491
|
+
"mkv",
|
|
492
|
+
"mpd",
|
|
493
|
+
"m3u8",
|
|
494
|
+
].includes(suffix) || type?.startsWith("video/"):
|
|
475
495
|
return "VIDEO";
|
|
476
496
|
default:
|
|
477
497
|
return "UNKNOWN";
|
|
@@ -1483,6 +1503,7 @@ const Editor = (props) => {
|
|
|
1483
1503
|
};
|
|
1484
1504
|
useImperativeHandle(ref, () => {
|
|
1485
1505
|
return {
|
|
1506
|
+
input: editorRef.current,
|
|
1486
1507
|
setValue(html) {
|
|
1487
1508
|
if (!editorRef.current)
|
|
1488
1509
|
return;
|
|
@@ -1660,6 +1681,7 @@ class IFormInstance {
|
|
|
1660
1681
|
rule.validator = o;
|
|
1661
1682
|
}
|
|
1662
1683
|
else if (o === true) {
|
|
1684
|
+
rule.validator = (v) => ![undefined, null, ""].includes(v);
|
|
1663
1685
|
rule.message = "required";
|
|
1664
1686
|
}
|
|
1665
1687
|
else {
|
|
@@ -1692,6 +1714,7 @@ class IFormInstance {
|
|
|
1692
1714
|
rule.validator = o;
|
|
1693
1715
|
}
|
|
1694
1716
|
else if (o === true) {
|
|
1717
|
+
rule.validator = (v) => ![undefined, null, ""].includes(v);
|
|
1695
1718
|
rule.message = "required";
|
|
1696
1719
|
}
|
|
1697
1720
|
else {
|
|
@@ -1825,7 +1848,7 @@ function DefaultContent(props) {
|
|
|
1825
1848
|
const showHeader = title || !hideCloseButton;
|
|
1826
1849
|
const handleOk = async () => {
|
|
1827
1850
|
const ret = await onOk?.();
|
|
1828
|
-
if (ret)
|
|
1851
|
+
if (ret === false)
|
|
1829
1852
|
return;
|
|
1830
1853
|
onClose?.();
|
|
1831
1854
|
};
|
|
@@ -2462,12 +2485,12 @@ function List(props) {
|
|
|
2462
2485
|
if (!files.length)
|
|
2463
2486
|
return "";
|
|
2464
2487
|
return (jsx(Flex, { className: 'i-image-list', gap: gap, columns: columns, wrap: wrap, direction: direction, children: files.map((img, i) => {
|
|
2465
|
-
return (jsx(Image, { src: img.src,
|
|
2488
|
+
return (jsx(Image, { src: img.src, usePreview: false, onClick: (e) => handleClick(e, i), ...restProps }, i));
|
|
2466
2489
|
}) }));
|
|
2467
2490
|
}
|
|
2468
2491
|
|
|
2469
2492
|
const Image = (props) => {
|
|
2470
|
-
const { src, round, size, initSize, lazyload, fallback = (jsx(Icon, { icon: jsx(HideImageTwotone, {}), size: '2em', className: 'color-5' })), fit, style, className, cover, coverClass, usePreview: previewable, onLoad, onError, onClick, ...restProps } = props;
|
|
2493
|
+
const { src, thumb, round, size, height, width, ratio, initSize, lazyload, fallback = (jsx(Icon, { icon: jsx(HideImageTwotone, {}), size: '2em', className: 'color-5' })), fit, style, className, cover, coverClass, usePreview: previewable, onLoad, onError, onClick, ...restProps } = props;
|
|
2471
2494
|
const state = useReactive({
|
|
2472
2495
|
status: "loading",
|
|
2473
2496
|
});
|
|
@@ -2499,7 +2522,7 @@ const Image = (props) => {
|
|
|
2499
2522
|
useEffect(() => {
|
|
2500
2523
|
if (!src)
|
|
2501
2524
|
return;
|
|
2502
|
-
if (!ref.current?.complete && observe) {
|
|
2525
|
+
if (!ref.current?.complete && observe && lazyload) {
|
|
2503
2526
|
state.status = "loading";
|
|
2504
2527
|
}
|
|
2505
2528
|
if (!lazyload || !ref.current || !observe)
|
|
@@ -2514,11 +2537,12 @@ const Image = (props) => {
|
|
|
2514
2537
|
ref.current && unobserve(ref.current);
|
|
2515
2538
|
};
|
|
2516
2539
|
}, [src]);
|
|
2517
|
-
restProps[lazyload ? "data-src" : "src"] = src;
|
|
2540
|
+
restProps[lazyload ? "data-src" : "src"] = thumb ?? src;
|
|
2518
2541
|
const iSize = state.status === "loading" ? initSize : undefined;
|
|
2519
2542
|
return (jsx("div", { style: {
|
|
2520
|
-
width: size ?? iSize,
|
|
2521
|
-
height: size ?? iSize,
|
|
2543
|
+
width: width ?? size ?? iSize,
|
|
2544
|
+
height: height ?? size ?? iSize,
|
|
2545
|
+
aspectRatio: ratio,
|
|
2522
2546
|
...style,
|
|
2523
2547
|
}, className: classNames("i-image", className, {
|
|
2524
2548
|
rounded: round,
|
|
@@ -2537,7 +2561,7 @@ function InputContainer(props) {
|
|
|
2537
2561
|
}
|
|
2538
2562
|
|
|
2539
2563
|
const Number = (props) => {
|
|
2540
|
-
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;
|
|
2564
|
+
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;
|
|
2541
2565
|
const state = useReactive({
|
|
2542
2566
|
value,
|
|
2543
2567
|
});
|
|
@@ -2573,14 +2597,14 @@ const Number = (props) => {
|
|
|
2573
2597
|
onChange: handleChange,
|
|
2574
2598
|
...restProps,
|
|
2575
2599
|
};
|
|
2576
|
-
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
|
|
2600
|
+
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", {
|
|
2577
2601
|
[`i-input-${status}`]: status !== "normal",
|
|
2578
2602
|
"i-input-borderless": !border,
|
|
2579
2603
|
}), 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 })] }) }));
|
|
2580
2604
|
};
|
|
2581
2605
|
|
|
2582
2606
|
const Range = (props) => {
|
|
2583
|
-
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;
|
|
2607
|
+
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;
|
|
2584
2608
|
const state = useReactive({
|
|
2585
2609
|
value,
|
|
2586
2610
|
});
|
|
@@ -2597,7 +2621,7 @@ const Range = (props) => {
|
|
|
2597
2621
|
const { value } = e.target;
|
|
2598
2622
|
const v = formatInputValue(value.replace(/[^\d\.-]/g, ""));
|
|
2599
2623
|
const range = Array.isArray(state.value) ? state.value : [];
|
|
2600
|
-
range[i] =
|
|
2624
|
+
range[i] = v;
|
|
2601
2625
|
state.value = range;
|
|
2602
2626
|
onChange?.(range, e);
|
|
2603
2627
|
};
|
|
@@ -2612,8 +2636,8 @@ const Range = (props) => {
|
|
|
2612
2636
|
onChange?.(range, e);
|
|
2613
2637
|
};
|
|
2614
2638
|
const handleSwitch = (e) => {
|
|
2615
|
-
e
|
|
2616
|
-
e
|
|
2639
|
+
e?.preventDefault();
|
|
2640
|
+
e?.stopPropagation();
|
|
2617
2641
|
const range = state.value ? state.value : [];
|
|
2618
2642
|
const v = range[0];
|
|
2619
2643
|
range[0] = range[1];
|
|
@@ -2629,14 +2653,24 @@ const Range = (props) => {
|
|
|
2629
2653
|
className: "i-input i-input-number",
|
|
2630
2654
|
...restProps,
|
|
2631
2655
|
};
|
|
2632
|
-
|
|
2656
|
+
const handleBlur = () => {
|
|
2657
|
+
const range = Array.isArray(state.value) ? state.value : [];
|
|
2658
|
+
if (range.length < 2)
|
|
2659
|
+
return;
|
|
2660
|
+
const l = +range[0];
|
|
2661
|
+
const r = +range[1];
|
|
2662
|
+
if (l <= r)
|
|
2663
|
+
return;
|
|
2664
|
+
handleSwitch();
|
|
2665
|
+
};
|
|
2666
|
+
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", {
|
|
2633
2667
|
[`i-input-${status}`]: status !== "normal",
|
|
2634
2668
|
"i-input-borderless": !border,
|
|
2635
|
-
}), 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 })] }) }));
|
|
2669
|
+
}), 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 })] }) }));
|
|
2636
2670
|
};
|
|
2637
2671
|
|
|
2638
2672
|
const Textarea = (props) => {
|
|
2639
|
-
const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, style, onChange, onEnter, ...restProps } = props;
|
|
2673
|
+
const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, width, style, onChange, onEnter, ...restProps } = props;
|
|
2640
2674
|
const state = useReactive({
|
|
2641
2675
|
value,
|
|
2642
2676
|
});
|
|
@@ -2668,14 +2702,14 @@ const Textarea = (props) => {
|
|
|
2668
2702
|
onKeyDown: handleKeydown,
|
|
2669
2703
|
...restProps,
|
|
2670
2704
|
};
|
|
2671
|
-
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", {
|
|
2705
|
+
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", {
|
|
2672
2706
|
[`i-input-${status}`]: status !== "normal",
|
|
2673
2707
|
"i-input-borderless": !border,
|
|
2674
2708
|
}), children: jsx("textarea", { ...inputProps }) }) }));
|
|
2675
2709
|
};
|
|
2676
2710
|
|
|
2677
2711
|
const Input = ((props) => {
|
|
2678
|
-
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;
|
|
2712
|
+
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;
|
|
2679
2713
|
const state = useReactive({
|
|
2680
2714
|
value,
|
|
2681
2715
|
type,
|
|
@@ -2721,7 +2755,7 @@ const Input = ((props) => {
|
|
|
2721
2755
|
};
|
|
2722
2756
|
const clearable = clear && state.value;
|
|
2723
2757
|
const showHelper = type === "password" && !!state.value;
|
|
2724
|
-
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", {
|
|
2758
|
+
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", {
|
|
2725
2759
|
[`i-input-${status}`]: status !== "normal",
|
|
2726
2760
|
"i-input-borderless": !border,
|
|
2727
2761
|
}), 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 })] }) }));
|
|
@@ -3846,7 +3880,7 @@ const Swiper = ((props) => {
|
|
|
3846
3880
|
}, onMouseDown: handleMouseDown, onTouchStart: handleMouseDown, children: displayItems.map((item, i) => {
|
|
3847
3881
|
const { props: itemProps } = item;
|
|
3848
3882
|
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));
|
|
3849
|
-
}) }), 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", {
|
|
3883
|
+
}) }), 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", {
|
|
3850
3884
|
"i-swiper-indicators-fixed": fixedIndicator,
|
|
3851
3885
|
}), children: indicatorsLoop.map((_, i) => {
|
|
3852
3886
|
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,18 +1,23 @@
|
|
|
1
1
|
import { FC, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { TPreviewItem } from '../../js/usePreview/type.js';
|
|
2
3
|
import List from './list.js';
|
|
3
4
|
|
|
4
5
|
interface IImage extends HTMLAttributes<HTMLImageElement> {
|
|
5
6
|
src?: string;
|
|
7
|
+
thumb?: string;
|
|
6
8
|
alt?: string;
|
|
7
9
|
round?: boolean;
|
|
8
10
|
size?: string | number;
|
|
9
11
|
initSize?: string | number;
|
|
12
|
+
width?: string | number;
|
|
13
|
+
height?: string | number;
|
|
10
14
|
lazyload?: boolean;
|
|
11
15
|
fallback?: ReactNode;
|
|
12
16
|
fit?: any;
|
|
17
|
+
ratio?: number;
|
|
13
18
|
cover?: ReactNode;
|
|
14
19
|
coverClass?: string;
|
|
15
|
-
usePreview?: boolean;
|
|
20
|
+
usePreview?: boolean | TPreviewItem;
|
|
16
21
|
}
|
|
17
22
|
interface IImageList extends Omit<IImage, "src" | "alt"> {
|
|
18
23
|
items: string[] | IImage[];
|
|
@@ -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> {
|