@ioca/react 1.4.6 → 1.4.61
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 +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 +0 -3
- 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.map +1 -1
- 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 +1 -2
- 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.map +1 -1
- package/lib/cjs/components/modal/hookModal.js.map +1 -1
- 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 +5 -5
- package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/cjs/components/popup/content.js +4 -1
- package/lib/cjs/components/popup/content.js.map +1 -1
- package/lib/cjs/components/popup/popup.js +5 -2
- 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.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/js/hooks.js.map +1 -1
- 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.map +1 -1
- 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 +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 +0 -3
- 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.map +1 -1
- 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 +1 -2
- 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.map +1 -1
- package/lib/es/components/modal/hookModal.js.map +1 -1
- 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 +5 -5
- package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/es/components/popup/content.js +4 -1
- package/lib/es/components/popup/content.js.map +1 -1
- package/lib/es/components/popup/popup.js +5 -2
- 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.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/js/hooks.js.map +1 -1
- 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.map +1 -1
- package/lib/es/js/utils.js.map +1 -1
- package/lib/index.js +22 -20
- package/lib/types/components/datagrid/type.d.ts +2 -2
- package/lib/types/components/dropdown/dropdown.d.ts +1 -2
- package/lib/types/components/icon/icon.d.ts +1 -1
- package/lib/types/components/input/type.d.ts +0 -1
- package/lib/types/components/message/message.d.ts +5 -5
- package/lib/types/js/useTheme/index.d.ts +3 -3
- package/package.json +102 -102
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\";\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,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,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AC,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\";\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,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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;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -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;
|
|
@@ -763,7 +763,7 @@ function Cell(props) {
|
|
|
763
763
|
const style = getCellStyle({ justify, fixed, col, row, rowSpan });
|
|
764
764
|
return (jsx("div", { className: classNames("i-datagrid-cell", {
|
|
765
765
|
[`i-datagrid-cell-fixed-${fixed}`]: fixed,
|
|
766
|
-
}), "data-col": id, style: style, onClick: (e) => onCellClick?.(data, column, row, col, e), onDoubleClick: (e) => onCellDoubleClick?.(data, column, row, col, e), children: render?.(data[id], data,
|
|
766
|
+
}), "data-col": id, style: style, onClick: (e) => onCellClick?.(data, column, row, col, e), onDoubleClick: (e) => onCellDoubleClick?.(data, column, row, col, e), children: render?.(data[id], data, col) ?? (jsx("div", { className: classNames("i-datagrid-cell-content", {
|
|
767
767
|
"i-datagrid-cell-content-ellipsis": cellEllipsis,
|
|
768
768
|
}), children: data[id] })) }));
|
|
769
769
|
}
|
|
@@ -1212,7 +1212,10 @@ const Content$2 = (props) => {
|
|
|
1212
1212
|
};
|
|
1213
1213
|
}, [arrowProps]);
|
|
1214
1214
|
const content = (jsxs("div", { ref: ref, className: classNames("i-popup", className), ...restProps, children: [arrow && (jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', className: 'i-popup-arrow', style: arrowCSS, children: jsx("path", { d: 'M0.5 0L1.5 0C1.5 4, 3 5.5, 5 7.5S8,10 8,12S7 14.5, 5 16.5S1.5,20 1.5,24L0.5 24L0.5 0z' }) })), children] }));
|
|
1215
|
-
|
|
1215
|
+
const container = getContainer(trigger);
|
|
1216
|
+
if (!container)
|
|
1217
|
+
return null;
|
|
1218
|
+
return createPortal(content, container);
|
|
1216
1219
|
};
|
|
1217
1220
|
|
|
1218
1221
|
function Popup(props) {
|
|
@@ -1255,9 +1258,9 @@ function Popup(props) {
|
|
|
1255
1258
|
statusRef.current = "showing";
|
|
1256
1259
|
state.show = true;
|
|
1257
1260
|
timerRef.current = setTimeout(() => {
|
|
1258
|
-
if (statusRef.current !== "showing")
|
|
1259
|
-
return;
|
|
1260
1261
|
requestAnimationFrame(() => {
|
|
1262
|
+
if (statusRef.current !== "showing")
|
|
1263
|
+
return;
|
|
1261
1264
|
const [left, top, { arrowX, arrowY, arrowPos }] = getPosition(triggerRef.current, contentRef.current, {
|
|
1262
1265
|
position,
|
|
1263
1266
|
gap,
|
|
@@ -1407,6 +1410,9 @@ function Popup(props) {
|
|
|
1407
1410
|
useLayoutEffect(() => {
|
|
1408
1411
|
handleToggle(visible);
|
|
1409
1412
|
}, [visible]);
|
|
1413
|
+
useEffect(() => {
|
|
1414
|
+
clearTimer();
|
|
1415
|
+
}, []);
|
|
1410
1416
|
return (jsxs(Fragment, { children: [Children.map(children, (child) => {
|
|
1411
1417
|
if (!isValidElement(child))
|
|
1412
1418
|
return;
|
|
@@ -1444,9 +1450,6 @@ const Item$3 = (props) => {
|
|
|
1444
1450
|
const Dropdown = (props) => {
|
|
1445
1451
|
const { visible, width, content, children, ...restProps } = props;
|
|
1446
1452
|
const [active, setActive] = useState(visible);
|
|
1447
|
-
if (!content) {
|
|
1448
|
-
return children;
|
|
1449
|
-
}
|
|
1450
1453
|
return (jsx(Popup, { trigger: 'click', position: 'bottom', content: jsx(List$1, { className: 'i-dropdown-content', style: { minWidth: width }, children: typeof content === "function"
|
|
1451
1454
|
? content(() => setActive(false))
|
|
1452
1455
|
: content }), ...restProps, touchable: true, visible: active, onVisibleChange: setActive, children: children }));
|
|
@@ -2812,7 +2815,7 @@ const Textarea = (props) => {
|
|
|
2812
2815
|
};
|
|
2813
2816
|
|
|
2814
2817
|
const Input = ((props) => {
|
|
2815
|
-
const { ref, type = "text", label, name, value = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, underline, required, maxLength, onChange, onEnter,
|
|
2818
|
+
const { ref, type = "text", label, name, value = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, underline, required, maxLength, onChange, onEnter, style, ...restProps } = props;
|
|
2816
2819
|
const state = useReactive({
|
|
2817
2820
|
value,
|
|
2818
2821
|
type,
|
|
@@ -2836,7 +2839,6 @@ const Input = ((props) => {
|
|
|
2836
2839
|
}
|
|
2837
2840
|
const v = "";
|
|
2838
2841
|
onChange?.(v);
|
|
2839
|
-
onClear?.();
|
|
2840
2842
|
};
|
|
2841
2843
|
const HelperIcon = useMemo(() => {
|
|
2842
2844
|
if (type === "password") {
|
|
@@ -3614,13 +3616,13 @@ const Popconfirm = (props) => {
|
|
|
3614
3616
|
const handleOk = async (e) => {
|
|
3615
3617
|
state.loading = true;
|
|
3616
3618
|
ok.onClick?.(e);
|
|
3617
|
-
|
|
3618
|
-
?.
|
|
3619
|
+
try {
|
|
3620
|
+
await onOk?.();
|
|
3619
3621
|
state.visible = false;
|
|
3620
|
-
}
|
|
3621
|
-
|
|
3622
|
+
}
|
|
3623
|
+
finally {
|
|
3622
3624
|
state.loading = false;
|
|
3623
|
-
}
|
|
3625
|
+
}
|
|
3624
3626
|
};
|
|
3625
3627
|
const handleCancel = async (e) => {
|
|
3626
3628
|
cancel.onClick?.(e);
|
|
@@ -10,8 +10,8 @@ interface IColumn {
|
|
|
10
10
|
colSpan?: number;
|
|
11
11
|
width?: string;
|
|
12
12
|
fixed?: "left" | "right";
|
|
13
|
-
render?: (value?: any, data?: IData,
|
|
14
|
-
renderHeader?: (column?: IColumn,
|
|
13
|
+
render?: (value?: any, data?: IData, index?: number) => ReactNode;
|
|
14
|
+
renderHeader?: (column?: IColumn, index?: number) => ReactNode;
|
|
15
15
|
}
|
|
16
16
|
interface IDatagrid {
|
|
17
17
|
data: IData[];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { IDropdown, IDropItem } from './type.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import * as react from 'react';
|
|
4
3
|
|
|
5
4
|
declare const Dropdown: {
|
|
6
|
-
(props: IDropdown):
|
|
5
|
+
(props: IDropdown): react_jsx_runtime.JSX.Element;
|
|
7
6
|
Item: (props: IDropItem) => react_jsx_runtime.JSX.Element;
|
|
8
7
|
};
|
|
9
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { IIcon } from './type.js';
|
|
3
3
|
|
|
4
|
-
declare const Icon: (props: IIcon) => string | number | bigint | boolean | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode
|
|
4
|
+
declare const Icon: (props: IIcon) => string | number | bigint | boolean | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode>> | react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
5
|
|
|
6
6
|
export { Icon as default };
|
|
@@ -8,7 +8,6 @@ interface IInput extends BaseInput, Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
8
8
|
prepend?: ReactNode;
|
|
9
9
|
append?: ReactNode;
|
|
10
10
|
hideVisible?: boolean;
|
|
11
|
-
onClear?: () => void;
|
|
12
11
|
}
|
|
13
12
|
interface ITextarea extends Omit<BaseInput, "ref">, Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue" | "onChange"> {
|
|
14
13
|
ref?: RefObject<RefTextarea | null>;
|
|
@@ -3,24 +3,24 @@ import { IMessage } from './type.js';
|
|
|
3
3
|
|
|
4
4
|
declare function message(config: IMessage | ReactNode): {
|
|
5
5
|
instance: IMessage;
|
|
6
|
-
close:
|
|
6
|
+
close: any;
|
|
7
7
|
};
|
|
8
8
|
declare namespace message {
|
|
9
9
|
var error: (content: ReactNode) => {
|
|
10
10
|
instance: IMessage;
|
|
11
|
-
close:
|
|
11
|
+
close: any;
|
|
12
12
|
};
|
|
13
13
|
var success: (content: ReactNode) => {
|
|
14
14
|
instance: IMessage;
|
|
15
|
-
close:
|
|
15
|
+
close: any;
|
|
16
16
|
};
|
|
17
17
|
var warning: (content: ReactNode) => {
|
|
18
18
|
instance: IMessage;
|
|
19
|
-
close:
|
|
19
|
+
close: any;
|
|
20
20
|
};
|
|
21
21
|
var info: (content: ReactNode) => {
|
|
22
22
|
instance: IMessage;
|
|
23
|
-
close:
|
|
23
|
+
close: any;
|
|
24
24
|
};
|
|
25
25
|
var one: (config: IMessage) => void;
|
|
26
26
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as ahooks_lib_createUseStorageState from '
|
|
1
|
+
import * as ahooks_lib_createUseStorageState from '/Users/iann/codes/ioca-react/node_modules/ahooks/lib/createUseStorageState/index.d.ts';
|
|
2
2
|
import { ITheme } from './type.js';
|
|
3
3
|
|
|
4
4
|
declare const useTheme: (props?: ITheme) => {
|
|
5
|
-
theme: string
|
|
6
|
-
setTheme: (value?: ahooks_lib_createUseStorageState.SetState<string>
|
|
5
|
+
theme: string;
|
|
6
|
+
setTheme: (value?: ahooks_lib_createUseStorageState.SetState<string>) => void;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export { useTheme as default };
|
package/package.json
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ioca/react",
|
|
3
|
-
"version": "1.4.
|
|
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": "^
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@ioca/react",
|
|
3
|
+
"version": "1.4.61",
|
|
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": "^7.1.9",
|
|
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
|
+
}
|