@ioca/react 1.3.66 → 1.3.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/affix/affix.js +8 -4
- package/lib/cjs/components/affix/affix.js.map +1 -1
- package/lib/cjs/components/affix/totop.js +3 -3
- package/lib/cjs/components/affix/totop.js.map +1 -1
- package/lib/cjs/components/badge/badge.js +3 -3
- package/lib/cjs/components/badge/badge.js.map +1 -1
- package/lib/cjs/components/button/button.js +3 -3
- package/lib/cjs/components/button/button.js.map +1 -1
- package/lib/cjs/components/button/group.js +3 -3
- package/lib/cjs/components/button/group.js.map +1 -1
- package/lib/cjs/components/button/toggle.js +3 -3
- package/lib/cjs/components/button/toggle.js.map +1 -1
- package/lib/cjs/components/card/card.js +3 -3
- package/lib/cjs/components/card/card.js.map +1 -1
- package/lib/cjs/components/checkbox/checkbox.js +4 -4
- package/lib/cjs/components/checkbox/checkbox.js.map +1 -1
- package/lib/cjs/components/checkbox/item.js +4 -4
- package/lib/cjs/components/checkbox/item.js.map +1 -1
- package/lib/cjs/components/collapse/collapse.js +4 -4
- package/lib/cjs/components/collapse/collapse.js.map +1 -1
- package/lib/cjs/components/datagrid/cell.js +4 -4
- package/lib/cjs/components/datagrid/cell.js.map +1 -1
- package/lib/cjs/components/datagrid/datagrid.js +4 -4
- package/lib/cjs/components/datagrid/datagrid.js.map +1 -1
- package/lib/cjs/components/datagrid/row.js +4 -4
- package/lib/cjs/components/datagrid/row.js.map +1 -1
- package/lib/cjs/components/datagrid/sorter.js +3 -3
- package/lib/cjs/components/datagrid/sorter.js.map +1 -1
- package/lib/cjs/components/description/description.js +4 -4
- package/lib/cjs/components/description/description.js.map +1 -1
- package/lib/cjs/components/drawer/drawer.js +4 -4
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/editor/controls.js +5 -1
- package/lib/cjs/components/editor/controls.js.map +1 -1
- package/lib/cjs/components/editor/editor.js +6 -6
- package/lib/cjs/components/editor/editor.js.map +1 -1
- package/lib/cjs/components/flex/flex.js +3 -3
- package/lib/cjs/components/flex/flex.js.map +1 -1
- package/lib/cjs/components/form/field.js +7 -7
- package/lib/cjs/components/form/field.js.map +1 -1
- package/lib/cjs/components/form/form.js +6 -6
- package/lib/cjs/components/form/form.js.map +1 -1
- package/lib/cjs/components/form/useForm.js +9 -9
- package/lib/cjs/components/form/useForm.js.map +1 -1
- package/lib/cjs/components/icon/icon.js +3 -3
- package/lib/cjs/components/icon/icon.js.map +1 -1
- package/lib/cjs/components/image/image.js +4 -4
- package/lib/cjs/components/image/image.js.map +1 -1
- package/lib/cjs/components/input/container.js +4 -4
- package/lib/cjs/components/input/container.js.map +1 -1
- package/lib/cjs/components/input/input.js +4 -4
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/input/number.js +3 -3
- package/lib/cjs/components/input/number.js.map +1 -1
- package/lib/cjs/components/input/range.js +3 -3
- package/lib/cjs/components/input/range.js.map +1 -1
- package/lib/cjs/components/input/textarea.js +3 -3
- package/lib/cjs/components/input/textarea.js.map +1 -1
- package/lib/cjs/components/list/item.js +3 -3
- package/lib/cjs/components/list/item.js.map +1 -1
- package/lib/cjs/components/list/list.js +3 -3
- package/lib/cjs/components/list/list.js.map +1 -1
- package/lib/cjs/components/loading/loading.js +3 -3
- package/lib/cjs/components/loading/loading.js.map +1 -1
- package/lib/cjs/components/message/message.js +15 -5
- package/lib/cjs/components/message/message.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +11 -6
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/pagination/page.js +3 -3
- package/lib/cjs/components/pagination/page.js.map +1 -1
- package/lib/cjs/components/pagination/pagination.js +3 -3
- package/lib/cjs/components/pagination/pagination.js.map +1 -1
- package/lib/cjs/components/picker/colors/handle.js +3 -3
- package/lib/cjs/components/picker/colors/handle.js.map +1 -1
- package/lib/cjs/components/picker/colors/index.js +4 -4
- package/lib/cjs/components/picker/colors/index.js.map +1 -1
- package/lib/cjs/components/picker/dates/dates.js +5 -5
- package/lib/cjs/components/picker/dates/dates.js.map +1 -1
- package/lib/cjs/components/picker/dates/index.js +6 -6
- package/lib/cjs/components/picker/dates/index.js.map +1 -1
- package/lib/cjs/components/picker/dates/panel.js +9 -9
- package/lib/cjs/components/picker/dates/panel.js.map +1 -1
- package/lib/cjs/components/picker/time/item.js +3 -3
- package/lib/cjs/components/picker/time/item.js.map +1 -1
- package/lib/cjs/components/popup/content.js +8 -4
- package/lib/cjs/components/popup/content.js.map +1 -1
- package/lib/cjs/components/progress/line.js +4 -4
- package/lib/cjs/components/progress/line.js.map +1 -1
- package/lib/cjs/components/progress/progress.js +3 -3
- package/lib/cjs/components/progress/progress.js.map +1 -1
- package/lib/cjs/components/radio/item.js +4 -4
- package/lib/cjs/components/radio/item.js.map +1 -1
- package/lib/cjs/components/radio/radio.js +4 -4
- package/lib/cjs/components/radio/radio.js.map +1 -1
- package/lib/cjs/components/resizable/resizable.js +4 -4
- package/lib/cjs/components/resizable/resizable.js.map +1 -1
- package/lib/cjs/components/select/options.js +3 -3
- package/lib/cjs/components/select/options.js.map +1 -1
- package/lib/cjs/components/select/select.js +5 -5
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/step/item.js +3 -3
- package/lib/cjs/components/step/item.js.map +1 -1
- package/lib/cjs/components/step/step.js +3 -3
- package/lib/cjs/components/step/step.js.map +1 -1
- package/lib/cjs/components/swiper/item.js +3 -3
- package/lib/cjs/components/swiper/item.js.map +1 -1
- package/lib/cjs/components/swiper/swiper.js +6 -6
- package/lib/cjs/components/swiper/swiper.js.map +1 -1
- package/lib/cjs/components/tabs/tabs.js +8 -8
- package/lib/cjs/components/tabs/tabs.js.map +1 -1
- package/lib/cjs/components/tag/tag.js +4 -4
- package/lib/cjs/components/tag/tag.js.map +1 -1
- package/lib/cjs/components/text/text.js +3 -3
- package/lib/cjs/components/text/text.js.map +1 -1
- package/lib/cjs/components/tree/item.js +5 -5
- package/lib/cjs/components/tree/item.js.map +1 -1
- package/lib/cjs/components/upload/renderFile.js +3 -3
- package/lib/cjs/components/upload/renderFile.js.map +1 -1
- package/lib/cjs/components/upload/upload.js +3 -3
- package/lib/cjs/components/upload/upload.js.map +1 -1
- package/lib/cjs/components/utils/empty/index.js +3 -3
- package/lib/cjs/components/utils/empty/index.js.map +1 -1
- package/lib/cjs/components/utils/helpericon/helpericon.js +3 -3
- package/lib/cjs/components/utils/helpericon/helpericon.js.map +1 -1
- package/lib/cjs/components/video/video.js +7 -3
- package/lib/cjs/components/video/video.js.map +1 -1
- package/lib/cjs/js/hooks.js +90 -50
- package/lib/cjs/js/hooks.js.map +1 -1
- package/lib/cjs/js/usePreview/content.js +4 -4
- package/lib/cjs/js/usePreview/content.js.map +1 -1
- package/lib/cjs/js/useRipple/index.js +6 -2
- package/lib/cjs/js/useRipple/index.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 +5 -1
- package/lib/es/components/affix/affix.js.map +1 -1
- package/lib/es/components/drawer/drawer.js +1 -1
- package/lib/es/components/drawer/drawer.js.map +1 -1
- package/lib/es/components/editor/controls.js +5 -1
- package/lib/es/components/editor/controls.js.map +1 -1
- package/lib/es/components/message/message.js +12 -2
- package/lib/es/components/message/message.js.map +1 -1
- package/lib/es/components/modal/modal.js +7 -2
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/popup/content.js +5 -1
- package/lib/es/components/popup/content.js.map +1 -1
- package/lib/es/components/video/video.js +4 -0
- package/lib/es/components/video/video.js.map +1 -1
- package/lib/es/js/hooks.js +91 -51
- package/lib/es/js/hooks.js.map +1 -1
- package/lib/es/js/useRipple/index.js +6 -2
- package/lib/es/js/useRipple/index.js.map +1 -1
- package/lib/index.js +135 -60
- package/package.json +2 -2
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const TIMEOUT = 500;
|
|
2
2
|
const useRipple = () => {
|
|
3
|
-
if (document
|
|
3
|
+
if (!document)
|
|
4
4
|
return;
|
|
5
|
-
document.documentElement.dataset["
|
|
5
|
+
if (document.documentElement.dataset["ioca-ripple"])
|
|
6
|
+
return;
|
|
7
|
+
document.documentElement.dataset["ioca-ripple"] = "enable";
|
|
6
8
|
document.addEventListener("mousedown", listener);
|
|
7
9
|
};
|
|
8
10
|
function listener(e) {
|
|
@@ -13,6 +15,8 @@ function listener(e) {
|
|
|
13
15
|
triggerRipple(parent, e);
|
|
14
16
|
}
|
|
15
17
|
function triggerRipple(target, e) {
|
|
18
|
+
if (!document)
|
|
19
|
+
return;
|
|
16
20
|
const [$box, $ripple] = createRipple();
|
|
17
21
|
const rect = target.getBoundingClientRect();
|
|
18
22
|
const size = Math.max(rect.width, rect.height) * 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/js/useRipple/index.ts"],"sourcesContent":["import \"./ripple.css\";\n\nconst TIMEOUT = 500;\n\nconst useRipple = () => {\n\tif (document.documentElement.dataset[\"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/js/useRipple/index.ts"],"sourcesContent":["import \"./ripple.css\";\n\nconst TIMEOUT = 500;\n\nconst useRipple = () => {\n\tif (!document) return;\n\tif (document.documentElement.dataset[\"ioca-ripple\"]) return;\n\tdocument.documentElement.dataset[\"ioca-ripple\"] = \"enable\";\n\n\tdocument.addEventListener(\"mousedown\", listener);\n};\n\nfunction listener(e: MouseEvent) {\n\tconst target = e.target as HTMLElement;\n\tconst parent = target.closest(\"[data-ripple]\") as HTMLElement;\n\n\tif (!target || !parent) return;\n\n\ttriggerRipple(parent, e);\n}\n\nfunction triggerRipple(target: HTMLElement, e: MouseEvent) {\n\tif (!document) return;\n\tconst [$box, $ripple] = createRipple();\n\tconst rect = target.getBoundingClientRect();\n\tconst size = Math.max(rect.width, rect.height) * 2;\n\n\t$ripple.style.cssText = `\n left: ${e.pageX - rect.left}px;\n top: ${e.pageY - rect.top}px;\n width: ${size}px;\n height: ${size}px;\n transition: all ${TIMEOUT / 1000}s;\n `;\n\ttarget.insertAdjacentElement(\"afterbegin\", $box);\n\ttarget.offsetHeight;\n\t$ripple.classList.add(\"i-ripple-active\");\n\n\tsetTimeout(() => {\n\t\t$box.remove();\n\t}, TIMEOUT);\n}\n\nfunction createRipple() {\n\tconst $box = document.createElement(\"SPAN\");\n\tconst $ripple = document.createElement(\"SPAN\");\n\n\t$box.className = \"i-ripple-container\";\n\t$ripple.className = \"i-ripple\";\n\n\t$box.append($ripple);\n\n\treturn [$box, $ripple];\n}\n\nexport default useRipple;\n"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,GAAG;AAEb,MAAA,SAAS,GAAG,MAAK;AACtB,IAAA,IAAI,CAAC,QAAQ;QAAE;AACf,IAAA,IAAI,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC;QAAE;IACrD,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,QAAQ;AAE1D,IAAA,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC;AACjD;AAEA,SAAS,QAAQ,CAAC,CAAa,EAAA;AAC9B,IAAA,MAAM,MAAM,GAAG,CAAC,CAAC,MAAqB;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAgB;AAE7D,IAAA,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE;AAExB,IAAA,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;AACzB;AAEA,SAAS,aAAa,CAAC,MAAmB,EAAE,CAAa,EAAA;AACxD,IAAA,IAAI,CAAC,QAAQ;QAAE;IACf,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,YAAY,EAAE;AACtC,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,qBAAqB,EAAE;AAC3C,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;AAElD,IAAA,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG;AACT,cAAA,EAAA,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAA;AACpB,aAAA,EAAA,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAA;iBAChB,IAAI,CAAA;kBACH,IAAI,CAAA;AACI,wBAAA,EAAA,OAAO,GAAG,IAAI,CAAA;KACnC;AACJ,IAAA,MAAM,CAAC,qBAAqB,CAAC,YAAY,EAAE,IAAI,CAAC;IAChD,MAAM,CAAC,YAAY;AACnB,IAAA,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAExC,UAAU,CAAC,MAAK;QACf,IAAI,CAAC,MAAM,EAAE;KACb,EAAE,OAAO,CAAC;AACZ;AAEA,SAAS,YAAY,GAAA;IACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;IAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;AAE9C,IAAA,IAAI,CAAC,SAAS,GAAG,oBAAoB;AACrC,IAAA,OAAO,CAAC,SAAS,GAAG,UAAU;AAE9B,IAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;AAEpB,IAAA,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;AACvB;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -16,9 +16,11 @@ import SortableContainer, { SortableItem } from 'react-easy-sort';
|
|
|
16
16
|
|
|
17
17
|
const TIMEOUT = 500;
|
|
18
18
|
const useRipple = () => {
|
|
19
|
-
if (document
|
|
19
|
+
if (!document)
|
|
20
20
|
return;
|
|
21
|
-
document.documentElement.dataset["
|
|
21
|
+
if (document.documentElement.dataset["ioca-ripple"])
|
|
22
|
+
return;
|
|
23
|
+
document.documentElement.dataset["ioca-ripple"] = "enable";
|
|
22
24
|
document.addEventListener("mousedown", listener);
|
|
23
25
|
};
|
|
24
26
|
function listener(e) {
|
|
@@ -29,6 +31,8 @@ function listener(e) {
|
|
|
29
31
|
triggerRipple(parent, e);
|
|
30
32
|
}
|
|
31
33
|
function triggerRipple(target, e) {
|
|
34
|
+
if (!document)
|
|
35
|
+
return;
|
|
32
36
|
const [$box, $ripple] = createRipple();
|
|
33
37
|
const rect = target.getBoundingClientRect();
|
|
34
38
|
const size = Math.max(rect.width, rect.height) * 2;
|
|
@@ -196,7 +200,11 @@ function ToTop(props) {
|
|
|
196
200
|
}
|
|
197
201
|
|
|
198
202
|
const Affix = (props) => {
|
|
199
|
-
const { position = "fixed", left, top, right, bottom, offset, style, className, children, getContainer = () =>
|
|
203
|
+
const { position = "fixed", left, top, right, bottom, offset, style, className, children, getContainer = () => {
|
|
204
|
+
if (typeof document === "undefined")
|
|
205
|
+
return null;
|
|
206
|
+
return document.body;
|
|
207
|
+
}, } = props;
|
|
200
208
|
const [hidden, setHidden] = useState(false);
|
|
201
209
|
const hijackChildren = useMemo(() => {
|
|
202
210
|
return Children.map(children, (node) => {
|
|
@@ -692,32 +700,42 @@ function Cell(props) {
|
|
|
692
700
|
}), children: data[id] })) }));
|
|
693
701
|
}
|
|
694
702
|
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
703
|
+
const isBrowser = typeof window !== "undefined";
|
|
704
|
+
let MouseMoveEvents;
|
|
705
|
+
let MouseUpEvents;
|
|
706
|
+
let KeydownEvents;
|
|
707
|
+
let touchable;
|
|
708
|
+
let EVENTS;
|
|
709
|
+
if (isBrowser) {
|
|
710
|
+
MouseMoveEvents = new Set();
|
|
711
|
+
MouseUpEvents = new Set();
|
|
712
|
+
KeydownEvents = new Set();
|
|
713
|
+
touchable = "ontouchend" in document;
|
|
714
|
+
EVENTS = {
|
|
715
|
+
MOVE: touchable ? "touchmove" : "mousemove",
|
|
716
|
+
UP: touchable ? "touchend" : "mouseup",
|
|
717
|
+
KEYDOWN: "keydown",
|
|
718
|
+
};
|
|
719
|
+
document.addEventListener(EVENTS.MOVE, (e) => {
|
|
720
|
+
for (const listener of MouseMoveEvents.values()) {
|
|
721
|
+
listener(e);
|
|
722
|
+
}
|
|
723
|
+
}, { passive: false });
|
|
724
|
+
document.addEventListener(EVENTS.UP, (e) => {
|
|
725
|
+
for (const listener of MouseUpEvents.values()) {
|
|
726
|
+
listener(e);
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
document.addEventListener(EVENTS.KEYDOWN, (e) => {
|
|
730
|
+
for (const listener of KeydownEvents.values()) {
|
|
731
|
+
listener(e);
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
}
|
|
719
735
|
function useMouseMove(listener, options) {
|
|
720
736
|
useEffect(() => {
|
|
737
|
+
if (!isBrowser || options?.disabled)
|
|
738
|
+
return;
|
|
721
739
|
MouseMoveEvents.add(listener);
|
|
722
740
|
return () => {
|
|
723
741
|
MouseMoveEvents.delete(listener);
|
|
@@ -726,6 +744,8 @@ function useMouseMove(listener, options) {
|
|
|
726
744
|
}
|
|
727
745
|
function useMouseUp(listener, options) {
|
|
728
746
|
useEffect(() => {
|
|
747
|
+
if (!isBrowser || options?.disabled)
|
|
748
|
+
return;
|
|
729
749
|
MouseUpEvents.add(listener);
|
|
730
750
|
return () => {
|
|
731
751
|
MouseUpEvents.delete(listener);
|
|
@@ -734,7 +754,7 @@ function useMouseUp(listener, options) {
|
|
|
734
754
|
}
|
|
735
755
|
function useKeydown(listener, options) {
|
|
736
756
|
useEffect(() => {
|
|
737
|
-
if (options?.disabled)
|
|
757
|
+
if (!isBrowser || options?.disabled)
|
|
738
758
|
return;
|
|
739
759
|
KeydownEvents.add(listener);
|
|
740
760
|
return () => {
|
|
@@ -743,25 +763,39 @@ function useKeydown(listener, options) {
|
|
|
743
763
|
}, [listener]);
|
|
744
764
|
}
|
|
745
765
|
function useIntersectionObserver(configs) {
|
|
746
|
-
const WM = new WeakMap();
|
|
747
|
-
const IO =
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
766
|
+
const WM = useRef(new WeakMap());
|
|
767
|
+
const IO = useRef(null);
|
|
768
|
+
useEffect(() => {
|
|
769
|
+
if (!isBrowser)
|
|
770
|
+
return;
|
|
771
|
+
IO.current = new IntersectionObserver((entries) => {
|
|
772
|
+
entries.map((entry) => {
|
|
773
|
+
const callback = WM.current.get(entry.target);
|
|
774
|
+
callback?.(entry.target, entry.isIntersecting);
|
|
775
|
+
});
|
|
776
|
+
}, configs);
|
|
777
|
+
return () => {
|
|
778
|
+
IO.current?.disconnect();
|
|
779
|
+
};
|
|
780
|
+
}, []);
|
|
753
781
|
function observe(target, callback) {
|
|
754
|
-
if (
|
|
782
|
+
if (!isBrowser || !IO.current || !target)
|
|
755
783
|
return;
|
|
756
|
-
WM.
|
|
757
|
-
|
|
784
|
+
if (WM.current.get(target))
|
|
785
|
+
return;
|
|
786
|
+
WM.current.set(target, callback);
|
|
787
|
+
IO.current.observe(target);
|
|
758
788
|
}
|
|
759
789
|
function unobserve(target) {
|
|
760
|
-
|
|
761
|
-
|
|
790
|
+
if (!isBrowser || !IO.current || !target)
|
|
791
|
+
return;
|
|
792
|
+
IO.current.unobserve(target);
|
|
793
|
+
WM.current.delete(target);
|
|
762
794
|
}
|
|
763
795
|
function disconnect() {
|
|
764
|
-
IO.
|
|
796
|
+
if (!isBrowser || !IO.current)
|
|
797
|
+
return;
|
|
798
|
+
IO.current.disconnect();
|
|
765
799
|
}
|
|
766
800
|
return {
|
|
767
801
|
observe,
|
|
@@ -770,25 +804,39 @@ function useIntersectionObserver(configs) {
|
|
|
770
804
|
};
|
|
771
805
|
}
|
|
772
806
|
function useResizeObserver() {
|
|
773
|
-
const WM = new WeakMap();
|
|
774
|
-
const IO =
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
807
|
+
const WM = useRef(new WeakMap());
|
|
808
|
+
const IO = useRef(null);
|
|
809
|
+
useEffect(() => {
|
|
810
|
+
if (!isBrowser)
|
|
811
|
+
return;
|
|
812
|
+
IO.current = new ResizeObserver((entries) => {
|
|
813
|
+
entries.map((entry) => {
|
|
814
|
+
const callback = WM.current.get(entry.target);
|
|
815
|
+
callback?.(entry.target);
|
|
816
|
+
});
|
|
778
817
|
});
|
|
779
|
-
|
|
818
|
+
return () => {
|
|
819
|
+
IO.current?.disconnect();
|
|
820
|
+
};
|
|
821
|
+
}, []);
|
|
780
822
|
function observe(target, callback) {
|
|
781
|
-
if (
|
|
823
|
+
if (!isBrowser || !IO.current || !target)
|
|
824
|
+
return;
|
|
825
|
+
if (WM.current.get(target))
|
|
782
826
|
return;
|
|
783
|
-
|
|
784
|
-
WM.set(target, callback);
|
|
827
|
+
IO.current.observe(target);
|
|
828
|
+
WM.current.set(target, callback);
|
|
785
829
|
}
|
|
786
830
|
function unobserve(target) {
|
|
787
|
-
|
|
788
|
-
|
|
831
|
+
if (!isBrowser || !IO.current || !target)
|
|
832
|
+
return;
|
|
833
|
+
IO.current.unobserve(target);
|
|
834
|
+
WM.current.delete(target);
|
|
789
835
|
}
|
|
790
836
|
function disconnect() {
|
|
791
|
-
IO.
|
|
837
|
+
if (!isBrowser || !IO.current)
|
|
838
|
+
return;
|
|
839
|
+
IO.current.disconnect();
|
|
792
840
|
}
|
|
793
841
|
return {
|
|
794
842
|
observe,
|
|
@@ -1037,7 +1085,7 @@ function Drawer(props) {
|
|
|
1037
1085
|
});
|
|
1038
1086
|
return createPortal(state.show && (jsx("div", { className: classNames("i-backdrop-drawer", className, {
|
|
1039
1087
|
"i-active": state.active,
|
|
1040
|
-
}), onClick: handleBackdropClick, ...restProps, children: jsxs("div", { className: classNames("i-drawer", `i-drawer-${position}`), onClick: (e) => e.stopPropagation(), children: [jsxs("header", { className: 'i-drawer-header', children: [header, jsx(Helpericon, { active: !hideCloseButton, className: 'i-drawer-close', onClick: handleHide })] }), jsx("div", { className: 'i-drawer-content', children: children }), jsx("div", { className: 'i-drawer-footer', children: footer })] }) })), document
|
|
1088
|
+
}), onClick: handleBackdropClick, ...restProps, children: jsxs("div", { className: classNames("i-drawer", `i-drawer-${position}`), onClick: (e) => e.stopPropagation(), children: [jsxs("header", { className: 'i-drawer-header', children: [header, jsx(Helpericon, { active: !hideCloseButton, className: 'i-drawer-close', onClick: handleHide })] }), jsx("div", { className: 'i-drawer-content', children: children }), jsx("div", { className: 'i-drawer-footer', children: footer })] }) })), document?.body ?? null);
|
|
1041
1089
|
}
|
|
1042
1090
|
|
|
1043
1091
|
const Item$4 = (props) => {
|
|
@@ -1067,7 +1115,11 @@ const List$1 = (props) => {
|
|
|
1067
1115
|
List$1.Item = Item$4;
|
|
1068
1116
|
|
|
1069
1117
|
const Content$1 = (props) => {
|
|
1070
|
-
const { ref, getContainer = (trigger) =>
|
|
1118
|
+
const { ref, getContainer = (trigger) => {
|
|
1119
|
+
if (typeof document === "undefined")
|
|
1120
|
+
return null;
|
|
1121
|
+
return trigger?.offsetParent ?? document.body;
|
|
1122
|
+
}, trigger, arrow, arrowProps = {}, className, children, ...restProps } = props;
|
|
1071
1123
|
const arrowCSS = useMemo(() => {
|
|
1072
1124
|
let { left, top, pos } = arrowProps;
|
|
1073
1125
|
let transform = "";
|
|
@@ -1327,7 +1379,11 @@ const Dropdown = (props) => {
|
|
|
1327
1379
|
};
|
|
1328
1380
|
Dropdown.Item = Item$3;
|
|
1329
1381
|
|
|
1330
|
-
const exec = (a, b, c) =>
|
|
1382
|
+
const exec = (a, b, c) => {
|
|
1383
|
+
if (typeof document === "undefined")
|
|
1384
|
+
return;
|
|
1385
|
+
return document.execCommand(a, b, c);
|
|
1386
|
+
};
|
|
1331
1387
|
const xssOptions = {
|
|
1332
1388
|
onIgnoreTagAttr: function (tag, name, value) {
|
|
1333
1389
|
if (["data-", "style"].includes(name.substr(0, 5))) {
|
|
@@ -1795,6 +1851,11 @@ function Modal(props) {
|
|
|
1795
1851
|
useEffect(() => {
|
|
1796
1852
|
visible ? handleShow() : handleHide();
|
|
1797
1853
|
}, [visible]);
|
|
1854
|
+
const handleClick = () => {
|
|
1855
|
+
if (typeof document === "undefined")
|
|
1856
|
+
return;
|
|
1857
|
+
document.documentElement.click();
|
|
1858
|
+
};
|
|
1798
1859
|
if (!show)
|
|
1799
1860
|
return null;
|
|
1800
1861
|
return createPortal(jsx("div", { className: classNames("i-modal-container", {
|
|
@@ -1810,9 +1871,9 @@ function Modal(props) {
|
|
|
1810
1871
|
height,
|
|
1811
1872
|
}, onClick: (e) => {
|
|
1812
1873
|
e.stopPropagation();
|
|
1813
|
-
|
|
1874
|
+
handleClick();
|
|
1814
1875
|
onClick?.(e);
|
|
1815
|
-
}, ...restProps, children: [customized && children, !customized && (jsx(DefaultContent, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document
|
|
1876
|
+
}, ...restProps, children: [customized && children, !customized && (jsx(DefaultContent, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
|
|
1816
1877
|
}
|
|
1817
1878
|
|
|
1818
1879
|
const HookModal = (props) => {
|
|
@@ -2035,6 +2096,8 @@ const Video = (props) => {
|
|
|
2035
2096
|
state.playing = !e.target.paused;
|
|
2036
2097
|
};
|
|
2037
2098
|
const fsChangeListener = () => {
|
|
2099
|
+
if (typeof document === "undefined")
|
|
2100
|
+
return;
|
|
2038
2101
|
const tar = videoRef.current?.parentElement;
|
|
2039
2102
|
if (!tar)
|
|
2040
2103
|
return;
|
|
@@ -2136,6 +2199,8 @@ const Video = (props) => {
|
|
|
2136
2199
|
getVideo: () => videoRef.current,
|
|
2137
2200
|
}));
|
|
2138
2201
|
useEffect(() => {
|
|
2202
|
+
if (typeof document === "undefined")
|
|
2203
|
+
return;
|
|
2139
2204
|
const v = videoRef.current;
|
|
2140
2205
|
if (!v)
|
|
2141
2206
|
return;
|
|
@@ -2640,7 +2705,6 @@ const ItemDefaultConfig = {
|
|
|
2640
2705
|
closable: true,
|
|
2641
2706
|
active: false,
|
|
2642
2707
|
};
|
|
2643
|
-
const container = createContainer();
|
|
2644
2708
|
const handler = {
|
|
2645
2709
|
oneInstance: null,
|
|
2646
2710
|
callout(item) { },
|
|
@@ -2656,7 +2720,6 @@ const heights = {
|
|
|
2656
2720
|
center: [],
|
|
2657
2721
|
right: [],
|
|
2658
2722
|
};
|
|
2659
|
-
createRoot(container).render(jsx(Messages, {}));
|
|
2660
2723
|
const MessageItem = function ({ ref, active, content, top, className, style, onClick, }) {
|
|
2661
2724
|
return (jsx("div", { ref: ref, className: classNames("i-message", className, {
|
|
2662
2725
|
"i-message-active": active,
|
|
@@ -2748,6 +2811,8 @@ function message(config) {
|
|
|
2748
2811
|
};
|
|
2749
2812
|
}
|
|
2750
2813
|
function createContainer() {
|
|
2814
|
+
if (typeof document === "undefined")
|
|
2815
|
+
return null;
|
|
2751
2816
|
const container = document.createElement("div");
|
|
2752
2817
|
container.dataset.id = "messages";
|
|
2753
2818
|
document.body.append(container);
|
|
@@ -2789,6 +2854,16 @@ message.one = (config) => {
|
|
|
2789
2854
|
handler.oneInstance = instance;
|
|
2790
2855
|
}
|
|
2791
2856
|
};
|
|
2857
|
+
// 初始化消息容器
|
|
2858
|
+
let container = null;
|
|
2859
|
+
let root = null;
|
|
2860
|
+
if (typeof window !== "undefined") {
|
|
2861
|
+
container = createContainer();
|
|
2862
|
+
if (container) {
|
|
2863
|
+
root = createRoot(container);
|
|
2864
|
+
root.render(jsx(Messages, {}));
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2792
2867
|
|
|
2793
2868
|
function useModal() {
|
|
2794
2869
|
const ref = useRef(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ioca/react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.69",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=16.8.0",
|
|
54
54
|
"react-dom": ">=16.8.0",
|
|
55
|
-
"
|
|
55
|
+
"ahooks": ">=3.8.0"
|
|
56
56
|
},
|
|
57
57
|
"main": "lib/cjs/index.js",
|
|
58
58
|
"module": "lib/es/index.js",
|