@ioca/react 1.3.94 → 1.3.96
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/LICENSE +20 -20
- package/README.md +31 -31
- package/lib/cjs/components/affix/affix.js.map +1 -1
- package/lib/cjs/components/affix/totop.js.map +1 -1
- package/lib/cjs/components/badge/badge.js.map +1 -1
- package/lib/cjs/components/button/button.js.map +1 -1
- package/lib/cjs/components/button/confirm.js.map +1 -1
- package/lib/cjs/components/button/group.js.map +1 -1
- package/lib/cjs/components/button/toggle.js.map +1 -1
- package/lib/cjs/components/card/card.js.map +1 -1
- package/lib/cjs/components/checkbox/checkbox.js.map +1 -1
- package/lib/cjs/components/checkbox/item.js.map +1 -1
- package/lib/cjs/components/collapse/collapse.js.map +1 -1
- package/lib/cjs/components/collapse/item.js.map +1 -1
- package/lib/cjs/components/datagrid/cell.js.map +1 -1
- package/lib/cjs/components/datagrid/datagrid.js.map +1 -1
- package/lib/cjs/components/datagrid/resize.js.map +1 -1
- package/lib/cjs/components/datagrid/row.js.map +1 -1
- package/lib/cjs/components/datagrid/sorter.js.map +1 -1
- package/lib/cjs/components/description/description.js.map +1 -1
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/dropdown/item.js.map +1 -1
- package/lib/cjs/components/editor/controls.js.map +1 -1
- package/lib/cjs/components/editor/editor.js.map +1 -1
- package/lib/cjs/components/flex/flex.js.map +1 -1
- package/lib/cjs/components/form/context.js.map +1 -1
- package/lib/cjs/components/form/field.js.map +1 -1
- package/lib/cjs/components/form/form.js +7 -3
- package/lib/cjs/components/form/form.js.map +1 -1
- package/lib/cjs/components/form/useConfig.js +2 -2
- package/lib/cjs/components/form/useConfig.js.map +1 -1
- package/lib/cjs/components/form/useForm.js.map +1 -1
- package/lib/cjs/components/icon/icon.js.map +1 -1
- package/lib/cjs/components/image/image.js.map +1 -1
- package/lib/cjs/components/image/list.js.map +1 -1
- package/lib/cjs/components/input/container.js.map +1 -1
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/input/number.js.map +1 -1
- package/lib/cjs/components/input/range.js.map +1 -1
- package/lib/cjs/components/input/textarea.js.map +1 -1
- package/lib/cjs/components/list/item.js.map +1 -1
- package/lib/cjs/components/list/list.js.map +1 -1
- package/lib/cjs/components/loading/loading.js.map +1 -1
- package/lib/cjs/components/message/message.js.map +1 -1
- package/lib/cjs/components/modal/content.js.map +1 -1
- package/lib/cjs/components/modal/context.js +10 -0
- package/lib/cjs/components/modal/context.js.map +1 -0
- package/lib/cjs/components/modal/hookModal.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +3 -2
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/modal/useModal.js.map +1 -1
- package/lib/cjs/components/pagination/page.js.map +1 -1
- package/lib/cjs/components/pagination/pagination.js.map +1 -1
- package/lib/cjs/components/picker/colors/footer.js.map +1 -1
- package/lib/cjs/components/picker/colors/handle.js.map +1 -1
- package/lib/cjs/components/picker/colors/index.js.map +1 -1
- package/lib/cjs/components/picker/dates/dates.js.map +1 -1
- package/lib/cjs/components/picker/dates/index.js.map +1 -1
- package/lib/cjs/components/picker/dates/panel.js.map +1 -1
- package/lib/cjs/components/picker/time/index.js.map +1 -1
- package/lib/cjs/components/picker/time/item.js.map +1 -1
- package/lib/cjs/components/picker/time/panel.js.map +1 -1
- package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/cjs/components/popup/content.js.map +1 -1
- package/lib/cjs/components/popup/popup.js +7 -4
- package/lib/cjs/components/popup/popup.js.map +1 -1
- package/lib/cjs/components/progress/circle.js.map +1 -1
- package/lib/cjs/components/progress/line.js.map +1 -1
- package/lib/cjs/components/progress/progress.js.map +1 -1
- package/lib/cjs/components/radio/item.js.map +1 -1
- package/lib/cjs/components/radio/radio.js.map +1 -1
- package/lib/cjs/components/resizable/resizable.js.map +1 -1
- package/lib/cjs/components/river/river.js.map +1 -1
- package/lib/cjs/components/select/options.js.map +1 -1
- package/lib/cjs/components/select/select.js +1 -1
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/step/divider.js.map +1 -1
- package/lib/cjs/components/step/item.js.map +1 -1
- package/lib/cjs/components/step/step.js.map +1 -1
- package/lib/cjs/components/swiper/item.js.map +1 -1
- package/lib/cjs/components/swiper/swiper.js.map +1 -1
- package/lib/cjs/components/tabs/item.js.map +1 -1
- package/lib/cjs/components/tabs/tabs.js.map +1 -1
- package/lib/cjs/components/tag/tag.js.map +1 -1
- package/lib/cjs/components/text/highlight.js.map +1 -1
- package/lib/cjs/components/text/number.js.map +1 -1
- package/lib/cjs/components/text/text.js.map +1 -1
- package/lib/cjs/components/text/time.js.map +1 -1
- package/lib/cjs/components/tree/item.js.map +1 -1
- package/lib/cjs/components/tree/tree.js.map +1 -1
- package/lib/cjs/components/upload/renderFile.js.map +1 -1
- package/lib/cjs/components/upload/upload.js.map +1 -1
- package/lib/cjs/components/utils/empty/index.js.map +1 -1
- package/lib/cjs/components/utils/helpericon/helpericon.js.map +1 -1
- package/lib/cjs/components/video/video.js.map +1 -1
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/js/hooks.js.map +1 -1
- package/lib/cjs/js/usePreview/content.js +2 -0
- package/lib/cjs/js/usePreview/content.js.map +1 -1
- package/lib/cjs/js/usePreview/index.js.map +1 -1
- package/lib/cjs/js/usePreview/renderFile.js.map +1 -1
- package/lib/cjs/js/usePreview/type.js.map +1 -1
- package/lib/cjs/js/useRipple/index.js +6 -6
- package/lib/cjs/js/useRipple/index.js.map +1 -1
- package/lib/cjs/js/useTheme/index.js +31 -0
- package/lib/cjs/js/useTheme/index.js.map +1 -0
- 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/affix/affix.js.map +1 -1
- package/lib/es/components/affix/totop.js.map +1 -1
- package/lib/es/components/badge/badge.js.map +1 -1
- package/lib/es/components/button/button.js.map +1 -1
- package/lib/es/components/button/confirm.js.map +1 -1
- package/lib/es/components/button/group.js.map +1 -1
- package/lib/es/components/button/toggle.js.map +1 -1
- package/lib/es/components/card/card.js.map +1 -1
- package/lib/es/components/checkbox/checkbox.js.map +1 -1
- package/lib/es/components/checkbox/item.js.map +1 -1
- package/lib/es/components/collapse/collapse.js.map +1 -1
- package/lib/es/components/collapse/item.js.map +1 -1
- package/lib/es/components/datagrid/cell.js.map +1 -1
- package/lib/es/components/datagrid/datagrid.js.map +1 -1
- package/lib/es/components/datagrid/resize.js.map +1 -1
- package/lib/es/components/datagrid/row.js.map +1 -1
- package/lib/es/components/datagrid/sorter.js.map +1 -1
- package/lib/es/components/description/description.js.map +1 -1
- package/lib/es/components/drawer/drawer.js.map +1 -1
- package/lib/es/components/dropdown/dropdown.js.map +1 -1
- package/lib/es/components/dropdown/item.js.map +1 -1
- package/lib/es/components/editor/controls.js.map +1 -1
- package/lib/es/components/editor/editor.js.map +1 -1
- package/lib/es/components/flex/flex.js.map +1 -1
- package/lib/es/components/form/context.js.map +1 -1
- package/lib/es/components/form/field.js.map +1 -1
- package/lib/es/components/form/form.js +7 -3
- package/lib/es/components/form/form.js.map +1 -1
- package/lib/es/components/form/useConfig.js +2 -2
- package/lib/es/components/form/useConfig.js.map +1 -1
- package/lib/es/components/form/useForm.js.map +1 -1
- package/lib/es/components/icon/icon.js.map +1 -1
- package/lib/es/components/image/image.js.map +1 -1
- package/lib/es/components/image/list.js.map +1 -1
- package/lib/es/components/input/container.js.map +1 -1
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/input/number.js.map +1 -1
- package/lib/es/components/input/range.js.map +1 -1
- package/lib/es/components/input/textarea.js.map +1 -1
- package/lib/es/components/list/item.js.map +1 -1
- package/lib/es/components/list/list.js.map +1 -1
- package/lib/es/components/loading/loading.js.map +1 -1
- package/lib/es/components/message/message.js.map +1 -1
- package/lib/es/components/modal/content.js.map +1 -1
- package/lib/es/components/modal/context.js +6 -0
- package/lib/es/components/modal/context.js.map +1 -0
- package/lib/es/components/modal/hookModal.js.map +1 -1
- package/lib/es/components/modal/modal.js +3 -2
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/modal/useModal.js.map +1 -1
- package/lib/es/components/pagination/page.js.map +1 -1
- package/lib/es/components/pagination/pagination.js.map +1 -1
- package/lib/es/components/picker/colors/footer.js.map +1 -1
- package/lib/es/components/picker/colors/handle.js.map +1 -1
- package/lib/es/components/picker/colors/index.js.map +1 -1
- package/lib/es/components/picker/dates/dates.js.map +1 -1
- package/lib/es/components/picker/dates/index.js.map +1 -1
- package/lib/es/components/picker/dates/panel.js.map +1 -1
- package/lib/es/components/picker/time/index.js.map +1 -1
- package/lib/es/components/picker/time/item.js.map +1 -1
- package/lib/es/components/picker/time/panel.js.map +1 -1
- package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/es/components/popup/content.js.map +1 -1
- package/lib/es/components/popup/popup.js +8 -5
- package/lib/es/components/popup/popup.js.map +1 -1
- package/lib/es/components/progress/circle.js.map +1 -1
- package/lib/es/components/progress/line.js.map +1 -1
- package/lib/es/components/progress/progress.js.map +1 -1
- package/lib/es/components/radio/item.js.map +1 -1
- package/lib/es/components/radio/radio.js.map +1 -1
- package/lib/es/components/resizable/resizable.js.map +1 -1
- package/lib/es/components/river/river.js.map +1 -1
- package/lib/es/components/select/options.js.map +1 -1
- package/lib/es/components/select/select.js +1 -1
- package/lib/es/components/select/select.js.map +1 -1
- package/lib/es/components/step/divider.js.map +1 -1
- package/lib/es/components/step/item.js.map +1 -1
- package/lib/es/components/step/step.js.map +1 -1
- package/lib/es/components/swiper/item.js.map +1 -1
- package/lib/es/components/swiper/swiper.js.map +1 -1
- package/lib/es/components/tabs/item.js.map +1 -1
- package/lib/es/components/tabs/tabs.js.map +1 -1
- package/lib/es/components/tag/tag.js.map +1 -1
- package/lib/es/components/text/highlight.js.map +1 -1
- package/lib/es/components/text/number.js.map +1 -1
- package/lib/es/components/text/text.js.map +1 -1
- package/lib/es/components/text/time.js.map +1 -1
- package/lib/es/components/tree/item.js.map +1 -1
- package/lib/es/components/tree/tree.js.map +1 -1
- package/lib/es/components/upload/renderFile.js.map +1 -1
- package/lib/es/components/upload/upload.js.map +1 -1
- package/lib/es/components/utils/empty/index.js.map +1 -1
- package/lib/es/components/utils/helpericon/helpericon.js.map +1 -1
- package/lib/es/components/video/video.js.map +1 -1
- package/lib/es/index.js +1 -0
- package/lib/es/index.js.map +1 -1
- package/lib/es/js/hooks.js.map +1 -1
- package/lib/es/js/usePreview/content.js +2 -0
- package/lib/es/js/usePreview/content.js.map +1 -1
- package/lib/es/js/usePreview/index.js.map +1 -1
- package/lib/es/js/usePreview/renderFile.js.map +1 -1
- package/lib/es/js/usePreview/type.js.map +1 -1
- package/lib/es/js/useRipple/index.js +6 -6
- package/lib/es/js/useRipple/index.js.map +1 -1
- package/lib/es/js/useTheme/index.js +27 -0
- package/lib/es/js/useTheme/index.js.map +1 -0
- package/lib/es/js/utils.js.map +1 -1
- package/lib/index.js +53 -21
- package/lib/types/components/form/type.d.ts +1 -0
- package/lib/types/components/popup/type.d.ts +0 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/js/useTheme/index.d.ts +9 -0
- package/lib/types/js/useTheme/type.d.ts +7 -0
- package/package.json +102 -101
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 [\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,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EAAE,GAAG,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ;IACtC,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IAEnE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEnD,OAAO,CAAA,EAAG,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAI,CAAA,EAAA,KAAK,CAAC,CAAC,CAAC,CAAA,CAAE;AACzE;SAEgB,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAA;IAC5D,OAAO,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK;AACrD;AAEa,MAAA,SAAS,GAAG,CAAC,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;;;;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../packages/js/utils.ts"],"sourcesContent":["import type { MouseEvent } from \"react\";\r\nimport { ReactNode, useEffect, useRef, useState } from \"react\";\r\nimport { Root, createRoot } from \"react-dom/client\";\r\nimport type { TOption, TOptions, TRelativeOptions } from \"../type\";\r\n\r\ntype TComputePosition = {\r\n\tcontainerSize: number;\r\n\ttargetSize: number;\r\n\ttargetOffset: number;\r\n\tcontentSize: number;\r\n\tgap: number;\r\n\talign?: \"start\" | \"center\" | \"end\";\r\n};\r\n\r\nexport function getPosition(\r\n\t$source?: HTMLElement | null,\r\n\t$popup?: HTMLElement | null,\r\n\toptions: TRelativeOptions = {}\r\n): [\r\n\tx: number,\r\n\ty: number,\r\n\tz: {\r\n\t\tarrowX: number;\r\n\t\tarrowY: number;\r\n\t\tarrowPos: string;\r\n\t}\r\n] {\r\n\tconst { refWindow, gap = 0, offset = 0, position = \"top\", align } = options;\r\n\r\n\tif (!$source || !$popup)\r\n\t\treturn [\r\n\t\t\t0,\r\n\t\t\t0,\r\n\t\t\t{\r\n\t\t\t\tarrowX: 0,\r\n\t\t\t\tarrowY: 0,\r\n\t\t\t\tarrowPos: \"bottom\",\r\n\t\t\t},\r\n\t\t];\r\n\r\n\tconst rectT = $source.getBoundingClientRect();\r\n\tconst rectC = $popup.getBoundingClientRect();\r\n\r\n\tlet w = window.innerWidth;\r\n\tlet h = window.innerHeight;\r\n\tlet {\r\n\t\tleft: tl,\r\n\t\ttop: tt,\r\n\t\tright: tr,\r\n\t\tbottom: tb,\r\n\t\twidth: tw,\r\n\t\theight: th,\r\n\t} = rectT;\r\n\tconst { height: ch, width: cw } = rectC;\r\n\r\n\tif (!refWindow) {\r\n\t\tconst rectPa = $source.offsetParent?.getBoundingClientRect();\r\n\r\n\t\tw = rectPa?.width || w;\r\n\t\th = rectPa?.height || h;\r\n\t\ttl = $source.offsetLeft;\r\n\t\ttt = $source.offsetTop;\r\n\t\ttr = tl + rectT.width;\r\n\t\ttb = tt + rectT.height;\r\n\t}\r\n\r\n\tlet y = 0;\r\n\tlet x = 0;\r\n\tlet arrowX = 0;\r\n\tlet arrowY = 0;\r\n\tlet arrowPos = \"bottom\";\r\n\r\n\tswitch (position) {\r\n\t\tcase \"left\":\r\n\t\tcase \"right\":\r\n\t\t\ty =\r\n\t\t\t\tth !== ch\r\n\t\t\t\t\t? computePosition({\r\n\t\t\t\t\t\t\tcontainerSize: h,\r\n\t\t\t\t\t\t\ttargetSize: th,\r\n\t\t\t\t\t\t\ttargetOffset: tt,\r\n\t\t\t\t\t\t\tcontentSize: ch,\r\n\t\t\t\t\t\t\tgap,\r\n\t\t\t\t\t\t\talign,\r\n\t\t\t\t\t })\r\n\t\t\t\t\t: tt;\r\n\t\t\tarrowY = y < tt ? tt - y + th / 2 : th / 2;\r\n\r\n\t\t\tconst xl = tl - offset - cw;\r\n\t\t\tconst xr = tr + offset + cw;\r\n\r\n\t\t\tif (position === \"left\") {\r\n\t\t\t\tconst R = xl < 0 && xr <= w;\r\n\t\t\t\tx = R ? tr + offset : xl;\r\n\t\t\t\tarrowX = R ? 0 : cw;\r\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\r\n\t\t\t} else {\r\n\t\t\t\tconst R = w > xr || xl < 0;\r\n\t\t\t\tx = R ? tr + offset : xl;\r\n\t\t\t\tarrowX = R ? 0 : cw;\r\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"top\":\r\n\t\tcase \"bottom\":\r\n\t\t\tx =\r\n\t\t\t\ttw !== cw\r\n\t\t\t\t\t? computePosition({\r\n\t\t\t\t\t\t\tcontainerSize: w,\r\n\t\t\t\t\t\t\ttargetOffset: tl,\r\n\t\t\t\t\t\t\ttargetSize: tw,\r\n\t\t\t\t\t\t\tcontentSize: cw,\r\n\t\t\t\t\t\t\tgap,\r\n\t\t\t\t\t\t\talign,\r\n\t\t\t\t\t })\r\n\t\t\t\t\t: tl;\r\n\t\t\tarrowX = x > tl ? cw / 2 : tl - x + tw / 2;\r\n\r\n\t\t\tconst yt = tt - offset - ch;\r\n\t\t\tconst yb = tb + offset + ch;\r\n\t\t\tif (position === \"top\") {\r\n\t\t\t\tconst T = yt < 0 && yb <= h;\r\n\t\t\t\ty = T ? tb + offset : yt;\r\n\t\t\t\tarrowY = T ? 0 : ch;\r\n\t\t\t\tarrowPos = T ? \"top\" : \"bottom\";\r\n\t\t\t} else {\r\n\t\t\t\tconst B = h > yb || yt < 0;\r\n\t\t\t\ty = B ? tb + offset : yt;\r\n\t\t\t\tarrowY = B ? 0 : ch;\r\n\t\t\t\tarrowPos = B ? \"top\" : \"bottom\";\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\treturn [\r\n\t\tx,\r\n\t\ty,\r\n\t\t{\r\n\t\t\tarrowX,\r\n\t\t\tarrowY,\r\n\t\t\tarrowPos,\r\n\t\t},\r\n\t];\r\n}\r\n\r\nexport function getPointPosition(e: MouseEvent, content: HTMLElement) {\r\n\tconst { width: w, height: h } = content.getBoundingClientRect();\r\n\tconst parent = content.offsetParent;\r\n\tlet pw,\r\n\t\tph,\r\n\t\tpl = 0,\r\n\t\tpt = 0;\r\n\r\n\tif (parent) {\r\n\t\tconst {\r\n\t\t\twidth: ow,\r\n\t\t\theight: oh,\r\n\t\t\tleft: ol,\r\n\t\t\ttop: ot,\r\n\t\t} = parent.getBoundingClientRect();\r\n\t\tconst st = parent.scrollTop ?? 0;\r\n\r\n\t\tpw = ow;\r\n\t\tph = oh;\r\n\t\tpt = ot - st;\r\n\t\tpl = ol;\r\n\t} else {\r\n\t\tpw = window.innerWidth;\r\n\t\tph = window.innerHeight;\r\n\t}\r\n\tconst x = e.pageX - pl;\r\n\tconst y = e.pageY - pt;\r\n\r\n\tconst left = x + w >= pw ? (x - w > 0 ? x - w : x) : x;\r\n\tconst top = y + h >= ph ? (y - h > 0 ? y - h : y) : y;\r\n\r\n\treturn [left, top];\r\n}\r\n\r\nfunction computePosition({\r\n\tcontainerSize,\r\n\ttargetSize,\r\n\ttargetOffset,\r\n\tcontentSize,\r\n\tgap,\r\n\talign = \"center\",\r\n}: TComputePosition) {\r\n\tconst centerPoint = targetOffset + targetSize / 2;\r\n\r\n\tswitch (align) {\r\n\t\tcase \"start\":\r\n\t\t\treturn targetOffset + contentSize > containerSize\r\n\t\t\t\t? containerSize - contentSize - gap\r\n\t\t\t\t: targetOffset;\r\n\t\tcase \"center\":\r\n\t\t\tif (targetSize >= contentSize) {\r\n\t\t\t\treturn centerPoint - contentSize / 2;\r\n\t\t\t}\r\n\r\n\t\t\tif (centerPoint + contentSize / 2 + gap > containerSize) {\r\n\t\t\t\treturn targetOffset + targetSize - contentSize;\r\n\t\t\t}\r\n\r\n\t\t\tif (centerPoint - contentSize / 2 - gap < 0) {\r\n\t\t\t\treturn gap;\r\n\t\t\t}\r\n\r\n\t\t\treturn centerPoint - contentSize / 2;\r\n\t\tcase \"end\":\r\n\t\t\tconst result = targetOffset + targetSize - contentSize;\r\n\t\t\treturn result > 0 ? result : gap;\r\n\t\tdefault:\r\n\t\t\treturn centerPoint - contentSize / 2;\r\n\t}\r\n}\r\n\r\nexport function formatOption(options: TOptions): TOption[] {\r\n\treturn options.map((option) =>\r\n\t\t[\"string\", \"number\"].includes(typeof option)\r\n\t\t\t? { label: option, value: option }\r\n\t\t\t: option\r\n\t) as TOption[];\r\n}\r\n\r\nexport function animate(\r\n\tfrom: number,\r\n\tto: number,\r\n\tduration: number = 1000,\r\n\tcallback?: (v: number) => void,\r\n\teasing: (t: number) => number = (t) => 1 - Math.pow(1 - t, 4)\r\n) {\r\n\tconst start = performance.now();\r\n\tconst diff = to - from;\r\n\tlet raf = requestAnimationFrame(loop);\r\n\r\n\tfunction loop() {\r\n\t\traf = requestAnimationFrame(loop);\r\n\r\n\t\tconst past = performance.now() - start;\r\n\t\tlet percent = past / duration;\r\n\r\n\t\tif (percent >= 1) {\r\n\t\t\tpercent = 1;\r\n\t\t\tcancelAnimationFrame(raf);\r\n\t\t}\r\n\r\n\t\tconst pass = diff * easing(percent);\r\n\t\tcallback?.(pass);\r\n\t}\r\n}\r\n\r\nexport function formatNumber(\r\n\tvalue: number,\r\n\toptions: {\r\n\t\tprecision?: number;\r\n\t\tthousand?: string;\r\n\t} = {}\r\n) {\r\n\tconst { precision, thousand } = options;\r\n\r\n\tconst result = value.toFixed(precision);\r\n\r\n\tif (!thousand) return result;\r\n\r\n\tconst points = result.split(\".\");\r\n\tconst integer = points[0].replace(\r\n\t\t/\\d{1,3}(?=(\\d{3})+(\\.\\d*)?$)/g,\r\n\t\t`$&${thousand}`\r\n\t);\r\n\r\n\tif (points.length === 1) return integer;\r\n\r\n\treturn `${integer}.${points[1]}`;\r\n}\r\n\r\nexport function renderNode(node: ReactNode, container = document.body) {\r\n\tconst div: HTMLDivElement | null = document.createElement(\"div\");\r\n\tcontainer.append(div);\r\n\r\n\tconst root: Root | null = createRoot(div);\r\n\tconst sto = setTimeout(() => {\r\n\t\troot?.render(node);\r\n\t}, 0);\r\n\r\n\treturn () => {\r\n\t\tdiv?.remove();\r\n\t\troot?.unmount();\r\n\t\tsto && clearTimeout(sto);\r\n\t};\r\n}\r\n\r\nexport function getSuffixByUrl(url: string) {\r\n\treturn url.match(/\\.([^\\./\\?]+)($|\\?)/)?.[1];\r\n}\r\n\r\nexport function getFileType(suffix: string, type?: string) {\r\n\tswitch (true) {\r\n\t\tcase [\r\n\t\t\t\"jpg\",\r\n\t\t\t\"jpeg\",\r\n\t\t\t\"png\",\r\n\t\t\t\"webp\",\r\n\t\t\t\"svg\",\r\n\t\t\t\"avif\",\r\n\t\t\t\"heif\",\r\n\t\t\t\"heic\",\r\n\t\t\t\"apng\",\r\n\t\t\t\"bmp\",\r\n\t\t\t\"ico\",\r\n\t\t].includes(suffix) || type?.startsWith(\"image/\"):\r\n\t\t\treturn \"IMAGE\";\r\n\t\tcase [\r\n\t\t\t\"mp4\",\r\n\t\t\t\"avi\",\r\n\t\t\t\"webm\",\r\n\t\t\t\"ogv\",\r\n\t\t\t\"mov\",\r\n\t\t\t\"mkv\",\r\n\t\t\t\"mpd\",\r\n\t\t\t\"m3u8\",\r\n\t\t].includes(suffix) || type?.startsWith(\"video/\"):\r\n\t\t\treturn \"VIDEO\";\r\n\t\tdefault:\r\n\t\t\treturn \"UNKNOWN\";\r\n\t}\r\n}\r\n\r\nexport function fullScreen(el: HTMLElement) {\r\n\tel.requestFullscreen?.();\r\n}\r\n\r\nexport function exitFullScreen() {\r\n\tdocument.exitFullscreen?.();\r\n}\r\n\r\nexport function formatTime(\r\n\ttime: number,\r\n\toptions?: {\r\n\t\tzero?: boolean;\r\n\t\tunits?: string[];\r\n\t}\r\n) {\r\n\tconst result: string[] = [];\r\n\tconst { zero = true, units = [\"\", \":\", \":\"] } = options || {};\r\n\r\n\tconst l = units.length;\r\n\tlet i = 0;\r\n\r\n\twhile (i < l) {\r\n\t\tif (time <= 0 && i > 1) break;\r\n\r\n\t\tconst n = Math.round(time % 60);\r\n\r\n\t\ttime = Math.floor(time / 60);\r\n\r\n\t\tresult.unshift((zero && n < 10 ? `0${n}` : n) + units[i++]);\r\n\t}\r\n\r\n\treturn result.join(\"\");\r\n}\r\n\r\nexport function getNextSorter(\r\n\tprevSortBy: string,\r\n\tprevSortType: string,\r\n\tsortBy: string\r\n): [sortBy: string, sortType: string] {\r\n\tconst types = [\"desc\", \"asc\"];\r\n\r\n\tif (prevSortBy === sortBy) {\r\n\t\tconst i = types.findIndex((t) => t === prevSortType) + 1;\r\n\t\tconst type = types[i] || \"\";\r\n\t\tconst by = type === \"\" ? \"\" : sortBy;\r\n\r\n\t\treturn [by, type];\r\n\t}\r\n\r\n\treturn [sortBy, \"desc\"];\r\n}\r\n\r\nexport function formatBytes(bytes: number, decimals = 2) {\r\n\tif (!+bytes) return \"0 Bytes\";\r\n\r\n\tconst k = 1024;\r\n\tconst dm = decimals < 0 ? 0 : decimals;\r\n\tconst sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\r\n\r\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\r\n\r\n\treturn `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;\r\n}\r\n\r\nexport function clamp(value: number, min: number, max: number) {\r\n\treturn value < min ? min : value > max ? max : value;\r\n}\r\n\r\nexport const arrayMove = (array, fromIndex: number, toIndex: number) => {\r\n\tif (toIndex >= array.length) {\r\n\t\tlet k = toIndex - array.length + 1;\r\n\t\twhile (k--) {\r\n\t\t\tarray.push(undefined);\r\n\t\t}\r\n\t}\r\n\tarray.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);\r\n\treturn array;\r\n};\r\n\r\ntype ReactiveObject<T> = T & { __isReactive?: boolean };\r\n\r\nexport function useReactive<T extends object>(\r\n\tinitialState: T\r\n): ReactiveObject<T> {\r\n\tconst [, setState] = useState<number>(0);\r\n\tconst reactiveState = useRef<ReactiveObject<T>>(initialState);\r\n\r\n\tuseEffect(() => {\r\n\t\tif (!reactiveState.current.__isReactive) {\r\n\t\t\treactiveState.current = createReactiveObject(\r\n\t\t\t\treactiveState.current,\r\n\t\t\t\tsetState\r\n\t\t\t);\r\n\t\t}\r\n\t}, []);\r\n\r\n\treturn reactiveState.current;\r\n}\r\n\r\nfunction createReactiveObject<T extends object>(\r\n\ttarget: T,\r\n\tsetState: React.Dispatch<React.SetStateAction<number>>\r\n): ReactiveObject<T> {\r\n\treturn new Proxy(target, {\r\n\t\tget(obj, prop) {\r\n\t\t\tif (prop === \"__isReactive\") return true;\r\n\t\t\treturn Reflect.get(obj, prop);\r\n\t\t},\r\n\t\tset(obj, prop, value) {\r\n\t\t\tconst result = Reflect.set(obj, prop, value);\r\n\t\t\tsetState((prev) => prev + 1); // Trigger re-render\r\n\t\t\treturn result;\r\n\t\t},\r\n\t}) as ReactiveObject<T>;\r\n}\r\n\r\nexport default useReactive;\r\n"],"names":[],"mappings":";;;AAcM,SAAU,WAAW,CAC1B,OAA4B,EAC5B,MAA2B,EAC3B,UAA4B,EAAE,EAAA;AAU9B,IA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x, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { debounce, uid, throttle, pick, title } from 'radash';
|
|
4
|
-
import { useMemo, Children, cloneElement, useEffect, createElement, isValidElement, useState, useRef, Fragment as Fragment$1, useTransition,
|
|
4
|
+
import { useMemo, Children, cloneElement, useEffect, createElement, isValidElement, useState, useRef, Fragment as Fragment$1, useTransition, createContext, useContext, useLayoutEffect, useImperativeHandle } from 'react';
|
|
5
5
|
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, RedoRound, UndoRound, ClearAllRound, PauseRound, PlayArrowRound, StopRound, VolumeOffRound, VolumeDownRound, FullscreenExitRound, FullscreenRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, HideImageTwotone, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, ListAltRound, DriveFolderUploadOutlined, PlusSharp } from '@ricons/material';
|
|
6
|
-
import { useReactive, useCreation, useSize } from 'ahooks';
|
|
6
|
+
import { useReactive, useCreation, useSize, useLocalStorageState } from 'ahooks';
|
|
7
7
|
import { createRoot } from 'react-dom/client';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
9
9
|
import xss, { escapeAttrValue } from 'xss';
|
|
@@ -36,12 +36,12 @@ function triggerRipple(target, e) {
|
|
|
36
36
|
const [$box, $ripple] = createRipple();
|
|
37
37
|
const rect = target.getBoundingClientRect();
|
|
38
38
|
const size = Math.max(rect.width, rect.height) * 2;
|
|
39
|
-
$ripple.style.cssText = `
|
|
40
|
-
left: ${e.pageX - rect.left}px;
|
|
41
|
-
top: ${e.pageY - rect.top}px;
|
|
42
|
-
width: ${size}px;
|
|
43
|
-
height: ${size}px;
|
|
44
|
-
transition: all ${TIMEOUT / 1000}s;
|
|
39
|
+
$ripple.style.cssText = `
|
|
40
|
+
left: ${e.pageX - rect.left}px;
|
|
41
|
+
top: ${e.pageY - rect.top}px;
|
|
42
|
+
width: ${size}px;
|
|
43
|
+
height: ${size}px;
|
|
44
|
+
transition: all ${TIMEOUT / 1000}s;
|
|
45
45
|
`;
|
|
46
46
|
target.insertAdjacentElement("afterbegin", $box);
|
|
47
47
|
target.offsetHeight;
|
|
@@ -1176,6 +1176,8 @@ const List$1 = (props) => {
|
|
|
1176
1176
|
};
|
|
1177
1177
|
List$1.Item = Item$4;
|
|
1178
1178
|
|
|
1179
|
+
const ModalContext = createContext(false);
|
|
1180
|
+
|
|
1179
1181
|
const Content$2 = (props) => {
|
|
1180
1182
|
const { ref, getContainer = (trigger) => {
|
|
1181
1183
|
if (typeof document === "undefined")
|
|
@@ -1214,14 +1216,16 @@ const Content$2 = (props) => {
|
|
|
1214
1216
|
};
|
|
1215
1217
|
|
|
1216
1218
|
function Popup(props) {
|
|
1217
|
-
const { visible = false, content, trigger = "hover", gap = 12, offset = 8, fixed, position = "top", showDelay = 16, hideDelay = 12, touchable, arrow = true, align, fitSize, watchResize, clickOutside = true, disabled,
|
|
1219
|
+
const { visible = false, content, trigger = "hover", gap = 12, offset = 8, fixed, position = "top", showDelay = 16, hideDelay = 12, touchable, arrow = true, align, fitSize, watchResize, clickOutside = true, disabled, style, className, getContainer, children, onVisibleChange, } = props;
|
|
1218
1220
|
const triggerRef = useRef(null);
|
|
1219
1221
|
const contentRef = useRef(null);
|
|
1220
1222
|
const timerRef = useRef(null);
|
|
1221
1223
|
const statusRef = useRef("");
|
|
1224
|
+
const isInModal = useContext(ModalContext);
|
|
1225
|
+
const refWindow = isInModal || fixed;
|
|
1222
1226
|
const state = useReactive({
|
|
1223
1227
|
show: false,
|
|
1224
|
-
style: { position:
|
|
1228
|
+
style: { position: refWindow ? "fixed" : "absolute" },
|
|
1225
1229
|
arrowProps: {},
|
|
1226
1230
|
});
|
|
1227
1231
|
useMouseUp((e) => {
|
|
@@ -1259,7 +1263,7 @@ function Popup(props) {
|
|
|
1259
1263
|
gap,
|
|
1260
1264
|
offset,
|
|
1261
1265
|
align,
|
|
1262
|
-
refWindow
|
|
1266
|
+
refWindow,
|
|
1263
1267
|
});
|
|
1264
1268
|
state.style = {
|
|
1265
1269
|
...state.style,
|
|
@@ -1370,7 +1374,7 @@ function Popup(props) {
|
|
|
1370
1374
|
gap,
|
|
1371
1375
|
offset,
|
|
1372
1376
|
align,
|
|
1373
|
-
refWindow
|
|
1377
|
+
refWindow,
|
|
1374
1378
|
});
|
|
1375
1379
|
Object.assign(state, {
|
|
1376
1380
|
style: { ...state.style, left, top },
|
|
@@ -1822,11 +1826,11 @@ function useConfig(configs, formProps) {
|
|
|
1822
1826
|
const node = useMemo(() => {
|
|
1823
1827
|
return (jsx(Form, { ...formProps, onChange: handleChange, form: form, children: configs.map((config) => {
|
|
1824
1828
|
const { name, label, required, component: El, componentProps = {}, colspan = 1, render, shouldUpdate, shouldRender, } = config;
|
|
1825
|
-
const { className } = componentProps;
|
|
1829
|
+
const { className, style } = componentProps;
|
|
1826
1830
|
if (shouldRender && !shouldRender(values, form)) {
|
|
1827
1831
|
return jsx(Fragment$1, {}, name);
|
|
1828
1832
|
}
|
|
1829
|
-
return (jsx(Field, { name: name, required: required, children: render?.(config, values) ?? (jsx(El, { label: label, required: required, ...componentProps, className: `${className} ${colspan !== 1
|
|
1833
|
+
return (jsx(Field, { name: name, required: required, children: render?.(config, values) ?? (jsx(El, { label: label, required: required, ...componentProps, className: `${className ?? ""} ${colspan !== 1
|
|
1830
1834
|
? `colspan-${colspan}`
|
|
1831
1835
|
: ""}` })) }, name));
|
|
1832
1836
|
}) }));
|
|
@@ -1838,7 +1842,7 @@ function useConfig(configs, formProps) {
|
|
|
1838
1842
|
}
|
|
1839
1843
|
|
|
1840
1844
|
const Form = (props) => {
|
|
1841
|
-
const { form = {}, rules, initialValues, style, className, width, columns
|
|
1845
|
+
const { form = {}, rules, initialValues, style, className, width, columns, itemMaxWidth, gap = "1em", labelInline, labelWidth, labelRight, children, onKeyDown, onEnter, onChange, ...restProps } = props;
|
|
1842
1846
|
const handleKeyDown = (e) => {
|
|
1843
1847
|
onKeyDown?.(e);
|
|
1844
1848
|
if (e.keyCode !== 13)
|
|
@@ -1846,10 +1850,14 @@ const Form = (props) => {
|
|
|
1846
1850
|
onEnter?.(e, form.data, form);
|
|
1847
1851
|
};
|
|
1848
1852
|
const gridColumns = useMemo(() => {
|
|
1849
|
-
if (!columns)
|
|
1853
|
+
if (!columns && !itemMaxWidth)
|
|
1850
1854
|
return;
|
|
1851
|
-
if (
|
|
1855
|
+
if (itemMaxWidth) {
|
|
1856
|
+
return `repeat(auto-fill, minmax(${itemMaxWidth}, 1fr))`;
|
|
1857
|
+
}
|
|
1858
|
+
if (typeof columns === "number") {
|
|
1852
1859
|
return `minmax(0, 1fr) `.repeat(columns);
|
|
1860
|
+
}
|
|
1853
1861
|
return columns;
|
|
1854
1862
|
}, [columns]);
|
|
1855
1863
|
useEffect(() => {
|
|
@@ -2000,7 +2008,7 @@ function Modal(props) {
|
|
|
2000
2008
|
"i-modal-customized": customized,
|
|
2001
2009
|
"i-modal-active": active,
|
|
2002
2010
|
fixed,
|
|
2003
|
-
}, className), style: style, onClick: handleBackdropClick, "aria-modal": 'true', "aria-hidden": !active, children:
|
|
2011
|
+
}, className), style: style, onClick: handleBackdropClick, "aria-modal": 'true', "aria-hidden": !active, children: jsx("div", { className: classNames("i-modal", {
|
|
2004
2012
|
bounced,
|
|
2005
2013
|
shadow: !hideShadow,
|
|
2006
2014
|
}), style: {
|
|
@@ -2010,7 +2018,7 @@ function Modal(props) {
|
|
|
2010
2018
|
e.stopPropagation();
|
|
2011
2019
|
handleClick();
|
|
2012
2020
|
onClick?.(e);
|
|
2013
|
-
}, role: 'dialog', "aria-labelledby": title ? "modal-title" : undefined, ...restProps, children: [customized && children, !customized && (jsx(Content$1, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
|
|
2021
|
+
}, role: 'dialog', "aria-labelledby": title ? "modal-title" : undefined, ...restProps, children: jsxs(ModalContext.Provider, { value: true, children: [customized && children, !customized && (jsx(Content$1, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }) }), document?.body ?? null);
|
|
2014
2022
|
}
|
|
2015
2023
|
Modal.useModal = useModal;
|
|
2016
2024
|
|
|
@@ -2449,6 +2457,8 @@ function Content(props) {
|
|
|
2449
2457
|
onRotate?.(state.rotate);
|
|
2450
2458
|
};
|
|
2451
2459
|
const handleMouseWheel = throttle({ interval: 60 }, (e) => {
|
|
2460
|
+
e.stopPropagation();
|
|
2461
|
+
e.preventDefault();
|
|
2452
2462
|
if (!isImage)
|
|
2453
2463
|
return;
|
|
2454
2464
|
let after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);
|
|
@@ -3188,7 +3198,7 @@ const Select = (props) => {
|
|
|
3188
3198
|
const text = message ?? tip;
|
|
3189
3199
|
return (jsxs("label", { className: classNames("i-input-label", className, {
|
|
3190
3200
|
"i-input-inline": labelInline,
|
|
3191
|
-
}), style: style, children: [label && jsx("span", { className: 'i-input-label-text', children: label }), jsx(Popup, { position: 'bottom', arrow: false, fitSize: true, ...popupProps, visible: active, trigger: 'none', onVisibleChange: handleVisibleChange, content: jsx(Options, { options: filterOptions, value: state.value, multiple: multiple, filter: !!filter, filterPlaceholder: filterPlaceholder, onSelect: handleSelect, onFilter: handleFilterChange }), children: jsxs("div", { className: classNames("i-input-item", {
|
|
3201
|
+
}), style: style, children: [label && jsx("span", { className: 'i-input-label-text', children: label }), jsx(Popup, { position: 'bottom', arrow: false, fitSize: true, offset: 0, ...popupProps, visible: active, trigger: 'none', onVisibleChange: handleVisibleChange, content: jsx(Options, { options: filterOptions, value: state.value, multiple: multiple, filter: !!filter, filterPlaceholder: filterPlaceholder, onSelect: handleSelect, onFilter: handleFilterChange }), children: jsxs("div", { className: classNames("i-input-item", {
|
|
3192
3202
|
[`i-input-${status}`]: status !== "normal",
|
|
3193
3203
|
"i-input-borderless": !border,
|
|
3194
3204
|
"i-input-focus": active,
|
|
@@ -4619,4 +4629,26 @@ const Upload = (props) => {
|
|
|
4619
4629
|
}) }), state.message && (jsx("span", { className: 'i-upload-message', children: state.message })), state.files.length < limit && (jsxs("label", { children: [jsx("input", { ...restProps, disabled: disabled, ref: inputRef, type: 'file', className: 'i-input-file-hidden', multiple: multiple, onChange: handleChange }), trigger] }))] }) }));
|
|
4620
4630
|
};
|
|
4621
4631
|
|
|
4622
|
-
|
|
4632
|
+
const useTheme = (props) => {
|
|
4633
|
+
const { key = "ioca-react-theme", defaultValue, listenStorageChange, } = props ?? {};
|
|
4634
|
+
const [theme, setTheme] = useLocalStorageState(key, {
|
|
4635
|
+
defaultValue: defaultValue ?? "",
|
|
4636
|
+
listenStorageChange,
|
|
4637
|
+
});
|
|
4638
|
+
useEffect(() => {
|
|
4639
|
+
const cls = document.documentElement.classList;
|
|
4640
|
+
const cns = Array.from(cls);
|
|
4641
|
+
const pre = cns.find((n) => n.startsWith("theme-")) ?? "";
|
|
4642
|
+
if (pre) {
|
|
4643
|
+
cls.replace(pre, theme || "theme-auto");
|
|
4644
|
+
return;
|
|
4645
|
+
}
|
|
4646
|
+
theme && cls.add(theme);
|
|
4647
|
+
}, [theme]);
|
|
4648
|
+
return {
|
|
4649
|
+
theme,
|
|
4650
|
+
setTheme,
|
|
4651
|
+
};
|
|
4652
|
+
};
|
|
4653
|
+
|
|
4654
|
+
export { Affix, Badge, Button, Card, Checkbox, Collapse, ColorPicker, Datagrid, Datepicker as DatePicker, Description, Drawer, Dropdown, Editor, Flex, Form, Icon, Image, Input, List$1 as List, Loading, message as Message, Modal, Pagination, Popconfirm, Popup, Progress, Radio, Resizable, River, Select, Step, Swiper, Tabs, Tag, Text, TimePicker, Tree, Upload, Video, usePreview, useTheme };
|
|
@@ -14,6 +14,7 @@ interface IForm extends Omit<HTMLAttributes<HTMLFormElement>, "onChange"> {
|
|
|
14
14
|
columns?: number | string;
|
|
15
15
|
initialValues?: Record<string, any>;
|
|
16
16
|
width?: string | number;
|
|
17
|
+
itemMaxWidth?: string;
|
|
17
18
|
gap?: string | number;
|
|
18
19
|
labelWidth?: string;
|
|
19
20
|
labelInline?: boolean;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -38,3 +38,4 @@ export { default as Tree } from './components/tree/tree.js';
|
|
|
38
38
|
export { default as Upload } from './components/upload/upload.js';
|
|
39
39
|
export { default as Video } from './components/video/video.js';
|
|
40
40
|
export { default as usePreview } from './js/usePreview/index.js';
|
|
41
|
+
export { default as useTheme } from './js/useTheme/index.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as ahooks_lib_createUseStorageState from 'D:\\codes\\ioca-react\\node_modules\\ahooks\\lib\\createUseStorageState\\index.d.ts';
|
|
2
|
+
import { ITheme } from './type.js';
|
|
3
|
+
|
|
4
|
+
declare const useTheme: (props?: ITheme) => {
|
|
5
|
+
theme: string | undefined;
|
|
6
|
+
setTheme: (value?: ahooks_lib_createUseStorageState.SetState<string> | undefined) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { useTheme as default };
|
package/package.json
CHANGED
|
@@ -1,101 +1,102 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ioca/react",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vite",
|
|
7
|
-
"build": "tsc && vite build",
|
|
8
|
-
"preview": "vite preview",
|
|
9
|
-
"make": "node templates/index.js",
|
|
10
|
-
"lib": "
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@rc-component/color-picker": "^2.0.1",
|
|
14
|
-
"@ricons/material": "^0.12.0",
|
|
15
|
-
"ahooks": "^3.8.1",
|
|
16
|
-
"classnames": "^2.5.1",
|
|
17
|
-
"dayjs": "^1.11.13",
|
|
18
|
-
"highlight-words-core": "^1.2.3",
|
|
19
|
-
"pubsub-js": "^1.9.5",
|
|
20
|
-
"radash": "^12.1.0",
|
|
21
|
-
"react": "^19.0.0",
|
|
22
|
-
"react-dom": "^19.0.0",
|
|
23
|
-
"react-easy-sort": "^1.6.0",
|
|
24
|
-
"react-router": "^7.1.1",
|
|
25
|
-
"xss": "^1.0.15"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@rollup/plugin-commonjs": "^28.0.3",
|
|
29
|
-
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
30
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
31
|
-
"@rollup/plugin-typescript": "^12.1.1",
|
|
32
|
-
"@types/mockjs": "^1.0.10",
|
|
33
|
-
"@types/node": "^22.10.1",
|
|
34
|
-
"@types/pubsub-js": "^1.8.5",
|
|
35
|
-
"@types/react": "^19.0.4",
|
|
36
|
-
"@vitejs/plugin-react": "^4.3.3",
|
|
37
|
-
"chalk": "^5.4.1",
|
|
38
|
-
"fs": "^0.0.1-security",
|
|
39
|
-
"mockjs": "^1.1.0",
|
|
40
|
-
"path": "^0.12.7",
|
|
41
|
-
"react-custom-scrollbars-2": "^4.5.0",
|
|
42
|
-
"react-syntax-highlighter": "^15.6.1",
|
|
43
|
-
"
|
|
44
|
-
"rollup
|
|
45
|
-
"rollup-plugin-
|
|
46
|
-
"rollup-plugin-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"vite
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"react
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
"*.
|
|
100
|
-
|
|
101
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@ioca/react",
|
|
3
|
+
"version": "1.3.96",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "tsc && vite build",
|
|
8
|
+
"preview": "vite preview",
|
|
9
|
+
"make": "node templates/index.js",
|
|
10
|
+
"lib": "rimraf lib && npx rollup -c"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@rc-component/color-picker": "^2.0.1",
|
|
14
|
+
"@ricons/material": "^0.12.0",
|
|
15
|
+
"ahooks": "^3.8.1",
|
|
16
|
+
"classnames": "^2.5.1",
|
|
17
|
+
"dayjs": "^1.11.13",
|
|
18
|
+
"highlight-words-core": "^1.2.3",
|
|
19
|
+
"pubsub-js": "^1.9.5",
|
|
20
|
+
"radash": "^12.1.0",
|
|
21
|
+
"react": "^19.0.0",
|
|
22
|
+
"react-dom": "^19.0.0",
|
|
23
|
+
"react-easy-sort": "^1.6.0",
|
|
24
|
+
"react-router": "^7.1.1",
|
|
25
|
+
"xss": "^1.0.15"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
30
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
31
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
32
|
+
"@types/mockjs": "^1.0.10",
|
|
33
|
+
"@types/node": "^22.10.1",
|
|
34
|
+
"@types/pubsub-js": "^1.8.5",
|
|
35
|
+
"@types/react": "^19.0.4",
|
|
36
|
+
"@vitejs/plugin-react": "^4.3.3",
|
|
37
|
+
"chalk": "^5.4.1",
|
|
38
|
+
"fs": "^0.0.1-security",
|
|
39
|
+
"mockjs": "^1.1.0",
|
|
40
|
+
"path": "^0.12.7",
|
|
41
|
+
"react-custom-scrollbars-2": "^4.5.0",
|
|
42
|
+
"react-syntax-highlighter": "^15.6.1",
|
|
43
|
+
"rimraf": "^6.0.1",
|
|
44
|
+
"rollup": "^4.28.0",
|
|
45
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
46
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
47
|
+
"rollup-plugin-scss": "^4.0.0",
|
|
48
|
+
"sass": "^1.86.0",
|
|
49
|
+
"typescript": "^5.7.2",
|
|
50
|
+
"vite": "^6.0.2",
|
|
51
|
+
"vite-plugin-dynamic-import": "^1.6.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"react": ">=16.8.0",
|
|
55
|
+
"react-dom": ">=16.8.0"
|
|
56
|
+
},
|
|
57
|
+
"main": "lib/cjs/index.js",
|
|
58
|
+
"module": "lib/es/index.js",
|
|
59
|
+
"types": "lib/types/index.d.ts",
|
|
60
|
+
"exports": {
|
|
61
|
+
".": {
|
|
62
|
+
"types": "./lib/types/index.d.ts",
|
|
63
|
+
"import": "./lib/es/index.js",
|
|
64
|
+
"require": "./lib/cjs/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./index.css": "./lib/css/index.css",
|
|
67
|
+
"./*": {
|
|
68
|
+
"types": "./lib/types/*.d.ts",
|
|
69
|
+
"import": "./lib/es/*.js",
|
|
70
|
+
"require": "./lib/cjs/*.js"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"files": [
|
|
74
|
+
"lib"
|
|
75
|
+
],
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"license": "MIT",
|
|
80
|
+
"description": "ioca react ui components",
|
|
81
|
+
"directories": {
|
|
82
|
+
"doc": "docs"
|
|
83
|
+
},
|
|
84
|
+
"repository": {
|
|
85
|
+
"type": "git",
|
|
86
|
+
"url": "git+https://github.com/MunGaaKei/ioca-react.git"
|
|
87
|
+
},
|
|
88
|
+
"keywords": [
|
|
89
|
+
"ioca",
|
|
90
|
+
"react ui",
|
|
91
|
+
"components"
|
|
92
|
+
],
|
|
93
|
+
"author": "iannman",
|
|
94
|
+
"bugs": {
|
|
95
|
+
"url": "https://github.com/MunGaaKei/ioca-react/issues"
|
|
96
|
+
},
|
|
97
|
+
"homepage": "https://github.com/MunGaaKei/ioca-react#readme",
|
|
98
|
+
"sideEffects": [
|
|
99
|
+
"*.css",
|
|
100
|
+
"*.scss"
|
|
101
|
+
]
|
|
102
|
+
}
|