@uxf/core-react 14.0.0 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +5 -3
  2. package/clickable/use-button-props.js +108 -47
  3. package/global-context/index.test.js +23 -2
  4. package/hooks/use-body-scroll-lock.js +56 -27
  5. package/hooks/use-composed-refs.test.js +14 -2
  6. package/hooks/use-debounce.js +21 -8
  7. package/hooks/use-debounce.test.js +15 -3
  8. package/hooks/use-focus-return.js +55 -24
  9. package/hooks/use-focus-trap.js +87 -52
  10. package/hooks/use-increment.js +47 -5
  11. package/hooks/use-input-focus.js +65 -19
  12. package/hooks/use-is-hydrated.js +7 -1
  13. package/hooks/use-is-hydrated.test.js +13 -1
  14. package/hooks/use-is-mounted.js +15 -1
  15. package/hooks/use-key.js +53 -23
  16. package/hooks/use-key.test.js +88 -8
  17. package/hooks/use-media-query.js +77 -18
  18. package/hooks/use-media-query.test.js +29 -8
  19. package/hooks/use-min-window-width.js +39 -19
  20. package/hooks/use-mouse-drag-to-scroll.js +116 -61
  21. package/hooks/use-mouse-drag-to-scroll.test.js +56 -10
  22. package/hooks/use-on-mount.js +20 -3
  23. package/hooks/use-on-unmount.js +22 -3
  24. package/hooks/use-on-update.js +20 -8
  25. package/hooks/use-on-update.test.js +17 -2
  26. package/hooks/use-pagination.js +30 -14
  27. package/hooks/use-previous.js +14 -3
  28. package/hooks/use-raf-state.js +35 -8
  29. package/hooks/use-toggle.js +42 -4
  30. package/hooks/use-window-scroll.d.ts +7 -2
  31. package/hooks/use-window-scroll.js +36 -13
  32. package/hooks/use-window-scroll.test.js +141 -41
  33. package/hooks/use-window-size.d.ts +7 -2
  34. package/hooks/use-window-size.js +34 -13
  35. package/hooks/use-window-size.test.js +147 -31
  36. package/package.json +4 -4
  37. package/swipeable/use-swipeable.test.js +31 -5
  38. package/translations/index.js +1 -1
@@ -2,25 +2,84 @@
2
2
  "use client";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.useMediaQuery = useMediaQuery;
5
+ const compiler_runtime_1 = require("react/compiler-runtime");
5
6
  const react_1 = require("react");
7
+ /**
8
+ * Whether `mediaQueryString` matches, read through `useSyncExternalStore`: false on the server and during hydration,
9
+ * the real value from the first render of a component mounted on the client, and updated on every change.
10
+ */
11
+ /**
12
+ * @deprecated `isSSR` is ignored. It opted client-only components out of the hydration-safe `false`; the hook now
13
+ * reads the real value whenever it is not hydrating. Drop the argument.
14
+ */
6
15
  function useMediaQuery(mediaQueryString, callback) {
7
- const subscribe = (0, react_1.useCallback)((onStoreChange) => {
8
- const controller = new AbortController();
9
- window.matchMedia(mediaQueryString).addEventListener("change", onStoreChange, {
10
- signal: controller.signal,
11
- });
12
- return () => controller.abort();
13
- }, [mediaQueryString]);
14
- const isMatching = (0, react_1.useSyncExternalStore)(subscribe, () => window.matchMedia(mediaQueryString).matches, () => false);
15
- // The callback keeps its own subscription, so it hears the real value on mount and every change after, and
16
- // not the `false` a hydrating render reports.
17
- const onChange = (0, react_1.useEffectEvent)((matches, media) => callback === null || callback === void 0 ? void 0 : callback(matches, media));
18
- (0, react_1.useEffect)(() => {
19
- const controller = new AbortController();
20
- const mqList = window.matchMedia(mediaQueryString);
21
- onChange(mqList.matches, mqList.media);
22
- mqList.addEventListener("change", (e) => onChange(e.matches, e.media), { signal: controller.signal });
23
- return () => controller.abort();
24
- }, [mediaQueryString]);
16
+ const $ = (0, compiler_runtime_1.c)(11);
17
+ let t0;
18
+ if ($[0] !== mediaQueryString) {
19
+ t0 = onStoreChange => {
20
+ const controller = new AbortController();
21
+ window.matchMedia(mediaQueryString).addEventListener("change", onStoreChange, {
22
+ signal: controller.signal
23
+ });
24
+ return () => controller.abort();
25
+ };
26
+ $[0] = mediaQueryString;
27
+ $[1] = t0;
28
+ }
29
+ else {
30
+ t0 = $[1];
31
+ }
32
+ const subscribe = t0;
33
+ let t1;
34
+ if ($[2] !== mediaQueryString) {
35
+ t1 = () => window.matchMedia(mediaQueryString).matches;
36
+ $[2] = mediaQueryString;
37
+ $[3] = t1;
38
+ }
39
+ else {
40
+ t1 = $[3];
41
+ }
42
+ const isMatching = (0, react_1.useSyncExternalStore)(subscribe, t1, _temp);
43
+ let t2;
44
+ if ($[4] !== callback) {
45
+ t2 = (matches, media) => callback === null || callback === void 0 ? void 0 : callback(matches, media);
46
+ $[4] = callback;
47
+ $[5] = t2;
48
+ }
49
+ else {
50
+ t2 = $[5];
51
+ }
52
+ const onChange = (0, react_1.useEffectEvent)(t2);
53
+ let t3;
54
+ if ($[6] !== mediaQueryString || $[7] !== onChange) {
55
+ t3 = () => {
56
+ const controller_0 = new AbortController();
57
+ const mqList = window.matchMedia(mediaQueryString);
58
+ onChange(mqList.matches, mqList.media);
59
+ mqList.addEventListener("change", e => onChange(e.matches, e.media), {
60
+ signal: controller_0.signal
61
+ });
62
+ return () => controller_0.abort();
63
+ };
64
+ $[6] = mediaQueryString;
65
+ $[7] = onChange;
66
+ $[8] = t3;
67
+ }
68
+ else {
69
+ t3 = $[8];
70
+ }
71
+ let t4;
72
+ if ($[9] !== mediaQueryString) {
73
+ t4 = [mediaQueryString];
74
+ $[9] = mediaQueryString;
75
+ $[10] = t4;
76
+ }
77
+ else {
78
+ t4 = $[10];
79
+ }
80
+ (0, react_1.useEffect)(t3, t4);
25
81
  return isMatching;
26
82
  }
83
+ function _temp() {
84
+ return false;
85
+ }
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const compiler_runtime_1 = require("react/compiler-runtime");
6
7
  const react_1 = require("@testing-library/react");
7
8
  const react_2 = __importDefault(require("react"));
8
9
  const server_1 = require("react-dom/server");
@@ -11,19 +12,22 @@ const originalMatchMedia = window.matchMedia;
11
12
  function mockMatchMedia(initiallyMatches) {
12
13
  let matches = initiallyMatches;
13
14
  const listeners = new Set();
14
- window.matchMedia = ((query) => ({
15
+ window.matchMedia = query => ({
15
16
  get matches() {
16
17
  return matches;
17
18
  },
18
19
  media: query,
19
20
  addEventListener: (_type, listener) => listeners.add(listener),
20
- removeEventListener: (_type, listener) => listeners.delete(listener),
21
- }));
21
+ removeEventListener: (_type, listener) => listeners.delete(listener)
22
+ });
22
23
  return {
23
24
  change(next) {
24
25
  matches = next;
25
- listeners.forEach((listener) => listener({ matches: next, media: "(min-width: 640px)" }));
26
- },
26
+ listeners.forEach(listener => listener({
27
+ matches: next,
28
+ media: "(min-width: 640px)"
29
+ }));
30
+ }
27
31
  };
28
32
  }
29
33
  afterEach(() => {
@@ -37,7 +41,18 @@ test("a component mounted on the client gets the real value in its first render"
37
41
  });
38
42
  test("renders false on the server", () => {
39
43
  function Probe() {
40
- return react_2.default.createElement("span", null, String((0, use_media_query_1.useMediaQuery)("(min-width: 640px)")));
44
+ const $ = (0, compiler_runtime_1.c)(2);
45
+ const t0 = String((0, use_media_query_1.useMediaQuery)("(min-width: 640px)"));
46
+ let t1;
47
+ if ($[0] !== t0) {
48
+ t1 = react_2.default.createElement("span", null, t0);
49
+ $[0] = t0;
50
+ $[1] = t1;
51
+ }
52
+ else {
53
+ t1 = $[1];
54
+ }
55
+ return t1;
41
56
  }
42
57
  expect((0, server_1.renderToString)(react_2.default.createElement(Probe, null))).toContain("false");
43
58
  });
@@ -45,8 +60,14 @@ test("follows changes and reports them, and the initial value, to the latest cal
45
60
  const media = mockMatchMedia(false);
46
61
  const first = jest.fn();
47
62
  const latest = jest.fn();
48
- const { result, rerender } = (0, react_1.renderHook)((props) => (0, use_media_query_1.useMediaQuery)("(min-width: 640px)", props.callback), { initialProps: { callback: first } });
49
- rerender({ callback: latest });
63
+ const { result, rerender } = (0, react_1.renderHook)(props => (0, use_media_query_1.useMediaQuery)("(min-width: 640px)", props.callback), {
64
+ initialProps: {
65
+ callback: first
66
+ }
67
+ });
68
+ rerender({
69
+ callback: latest
70
+ });
50
71
  (0, react_1.act)(() => media.change(true));
51
72
  expect(result.current).toBe(true);
52
73
  expect(first).toHaveBeenCalledWith(false, "(min-width: 640px)");
@@ -1,32 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMinWindowWidth = useMinWindowWidth;
4
+ const compiler_runtime_1 = require("react/compiler-runtime");
4
5
  const react_1 = require("react");
5
6
  const use_raf_state_1 = require("./use-raf-state");
6
7
  /**
7
8
  * @deprecated Use useMediaQuery instead
8
9
  */
9
- function useMinWindowWidth(minWidth, debounce = 0) {
10
+ function useMinWindowWidth(minWidth, t0) {
11
+ const $ = (0, compiler_runtime_1.c)(5);
12
+ const debounce = t0 === undefined ? 0 : t0;
10
13
  const [state, setState] = (0, use_raf_state_1.useRafState)();
11
- (0, react_1.useEffect)(() => {
12
- const stateHandler = () => setState(window.innerWidth >= minWidth);
13
- let timer;
14
- const handler = () => {
15
- if (debounce > 0) {
14
+ let t1;
15
+ let t2;
16
+ if ($[0] !== debounce || $[1] !== minWidth || $[2] !== setState) {
17
+ t1 = () => {
18
+ const stateHandler = () => setState(window.innerWidth >= minWidth);
19
+ let timer;
20
+ const handler = () => {
21
+ if (debounce > 0) {
22
+ window.clearTimeout(timer);
23
+ timer = window.setTimeout(stateHandler, debounce);
24
+ }
25
+ else {
26
+ stateHandler();
27
+ }
28
+ };
29
+ stateHandler();
30
+ const controller = new AbortController();
31
+ window.addEventListener("resize", handler, {
32
+ signal: controller.signal
33
+ });
34
+ return () => {
35
+ controller.abort();
16
36
  window.clearTimeout(timer);
17
- timer = window.setTimeout(stateHandler, debounce);
18
- }
19
- else {
20
- stateHandler();
21
- }
37
+ };
22
38
  };
23
- stateHandler();
24
- const controller = new AbortController();
25
- window.addEventListener("resize", handler, { signal: controller.signal });
26
- return () => {
27
- controller.abort();
28
- window.clearTimeout(timer);
29
- };
30
- }, [debounce, minWidth, setState]);
39
+ t2 = [debounce, minWidth, setState];
40
+ $[0] = debounce;
41
+ $[1] = minWidth;
42
+ $[2] = setState;
43
+ $[3] = t1;
44
+ $[4] = t2;
45
+ }
46
+ else {
47
+ t1 = $[3];
48
+ t2 = $[4];
49
+ }
50
+ (0, react_1.useEffect)(t1, t2);
31
51
  return state;
32
52
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMouseDragToScroll = useMouseDragToScroll;
4
+ const compiler_runtime_1 = require("react/compiler-runtime");
4
5
  const react_1 = require("react");
5
6
  // Further than this from where the mouse was pressed is a drag, not a click.
6
7
  const DRAG_THRESHOLD_PX = 5;
@@ -12,70 +13,124 @@ const DRAG_THRESHOLD_PX = 5;
12
13
  * Clicks from the keyboard (Enter, Space) are never swallowed.
13
14
  */
14
15
  function useMouseDragToScroll(containerRef) {
15
- const position = (0, react_1.useRef)({ left: 0, top: 0, x: 0, y: 0 });
16
- const [style, setStyle] = (0, react_1.useState)();
17
- (0, react_1.useEffect)(() => {
18
- const node = containerRef.current;
19
- if (!node) {
20
- return;
21
- }
22
- const controller = new AbortController();
23
- // The document listeners live for one drag, from pressing the mouse to releasing it.
24
- let dragController;
25
- let hasDragged = false;
26
- let isClickSwallowed = false;
27
- let swallowTimeout;
28
- const mouseMoveHandler = (e) => {
29
- const dx = e.clientX - position.current.x;
30
- const dy = e.clientY - position.current.y;
31
- if (Math.abs(dx) > DRAG_THRESHOLD_PX || Math.abs(dy) > DRAG_THRESHOLD_PX) {
32
- hasDragged = true;
33
- }
34
- node.scrollLeft = position.current.left - dx;
35
- node.scrollTop = position.current.top - dy;
36
- };
37
- const mouseUpHandler = () => {
38
- setStyle((prev) => ({ ...prev, cursor: "grab", userSelect: "unset" }));
39
- dragController === null || dragController === void 0 ? void 0 : dragController.abort();
40
- if (hasDragged) {
41
- // Browsers dispatch the click that ends a drag right after `mouseup`, in the same task, so only that
42
- // click is swallowed. Whatever comes later, a click from the keyboard included, goes through. Telling
43
- // a keyboard click apart by the event does not work: Firefox gives Enter on a link `detail` 1, Safari
44
- // gives it the last mouse position as `clientX`.
45
- isClickSwallowed = true;
46
- swallowTimeout = setTimeout(() => {
47
- isClickSwallowed = false;
48
- });
49
- }
16
+ const $ = (0, compiler_runtime_1.c)(4);
17
+ let t0;
18
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
19
+ t0 = {
20
+ left: 0,
21
+ top: 0,
22
+ x: 0,
23
+ y: 0
50
24
  };
51
- const mouseDownHandler = (e) => {
52
- if (e.button !== 0) {
25
+ $[0] = t0;
26
+ }
27
+ else {
28
+ t0 = $[0];
29
+ }
30
+ const position = (0, react_1.useRef)(t0);
31
+ const [style, setStyle] = (0, react_1.useState)();
32
+ let t1;
33
+ let t2;
34
+ if ($[1] !== containerRef) {
35
+ t1 = () => {
36
+ const node = containerRef.current;
37
+ if (!node) {
53
38
  return;
54
39
  }
55
- hasDragged = false;
56
- position.current = { left: node.scrollLeft, top: node.scrollTop, x: e.clientX, y: e.clientY };
57
- setStyle((prev) => ({ ...prev, cursor: "grabbing", userSelect: "none" }));
58
- dragController === null || dragController === void 0 ? void 0 : dragController.abort();
59
- dragController = new AbortController();
60
- document.addEventListener("mousemove", mouseMoveHandler, { signal: dragController.signal });
61
- document.addEventListener("mouseup", mouseUpHandler, { signal: dragController.signal });
62
- };
63
- const clickHandler = (e) => {
64
- if (isClickSwallowed) {
65
- isClickSwallowed = false;
66
- e.preventDefault();
67
- e.stopPropagation();
68
- }
69
- };
70
- node.addEventListener("mousedown", mouseDownHandler, { signal: controller.signal });
71
- // Capture phase, so the click is stopped before the tab's or the link's own handler sees it.
72
- node.addEventListener("click", clickHandler, { capture: true, signal: controller.signal });
73
- node.addEventListener("dragstart", (e) => e.preventDefault(), { signal: controller.signal });
74
- return () => {
75
- controller.abort();
76
- dragController === null || dragController === void 0 ? void 0 : dragController.abort();
77
- clearTimeout(swallowTimeout);
40
+ const controller = new AbortController();
41
+ let dragController;
42
+ let hasDragged = false;
43
+ let isClickSwallowed = false;
44
+ let swallowTimeout;
45
+ const mouseMoveHandler = e => {
46
+ const dx = e.clientX - position.current.x;
47
+ const dy = e.clientY - position.current.y;
48
+ if (Math.abs(dx) > DRAG_THRESHOLD_PX || Math.abs(dy) > DRAG_THRESHOLD_PX) {
49
+ hasDragged = true;
50
+ }
51
+ node.scrollLeft = position.current.left - dx;
52
+ node.scrollTop = position.current.top - dy;
53
+ };
54
+ const mouseUpHandler = () => {
55
+ setStyle(_temp);
56
+ dragController === null || dragController === void 0 ? void 0 : dragController.abort();
57
+ if (hasDragged) {
58
+ isClickSwallowed = true;
59
+ swallowTimeout = setTimeout(() => {
60
+ isClickSwallowed = false;
61
+ });
62
+ }
63
+ };
64
+ const mouseDownHandler = e_0 => {
65
+ if (e_0.button !== 0) {
66
+ return;
67
+ }
68
+ hasDragged = false;
69
+ position.current = {
70
+ left: node.scrollLeft,
71
+ top: node.scrollTop,
72
+ x: e_0.clientX,
73
+ y: e_0.clientY
74
+ };
75
+ setStyle(_temp2);
76
+ dragController === null || dragController === void 0 ? void 0 : dragController.abort();
77
+ dragController = new AbortController();
78
+ document.addEventListener("mousemove", mouseMoveHandler, {
79
+ signal: dragController.signal
80
+ });
81
+ document.addEventListener("mouseup", mouseUpHandler, {
82
+ signal: dragController.signal
83
+ });
84
+ };
85
+ const clickHandler = e_1 => {
86
+ if (isClickSwallowed) {
87
+ isClickSwallowed = false;
88
+ e_1.preventDefault();
89
+ e_1.stopPropagation();
90
+ }
91
+ };
92
+ node.addEventListener("mousedown", mouseDownHandler, {
93
+ signal: controller.signal
94
+ });
95
+ node.addEventListener("click", clickHandler, {
96
+ capture: true,
97
+ signal: controller.signal
98
+ });
99
+ node.addEventListener("dragstart", _temp3, {
100
+ signal: controller.signal
101
+ });
102
+ return () => {
103
+ controller.abort();
104
+ dragController === null || dragController === void 0 ? void 0 : dragController.abort();
105
+ clearTimeout(swallowTimeout);
106
+ };
78
107
  };
79
- }, [containerRef]);
108
+ t2 = [containerRef];
109
+ $[1] = containerRef;
110
+ $[2] = t1;
111
+ $[3] = t2;
112
+ }
113
+ else {
114
+ t1 = $[2];
115
+ t2 = $[3];
116
+ }
117
+ (0, react_1.useEffect)(t1, t2);
80
118
  return style;
81
119
  }
120
+ function _temp3(e_2) {
121
+ return e_2.preventDefault();
122
+ }
123
+ function _temp2(prev_0) {
124
+ return {
125
+ ...prev_0,
126
+ cursor: "grabbing",
127
+ userSelect: "none"
128
+ };
129
+ }
130
+ function _temp(prev) {
131
+ return {
132
+ ...prev,
133
+ cursor: "grab",
134
+ userSelect: "unset"
135
+ };
136
+ }
@@ -33,24 +33,53 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ const compiler_runtime_1 = require("react/compiler-runtime");
36
37
  const react_1 = require("@testing-library/react");
37
38
  const react_2 = __importStar(require("react"));
38
39
  const use_mouse_drag_to_scroll_1 = require("./use-mouse-drag-to-scroll");
39
40
  function Row(props) {
41
+ const $ = (0, compiler_runtime_1.c)(5);
40
42
  const ref = (0, react_2.useRef)(null);
41
43
  const style = (0, use_mouse_drag_to_scroll_1.useMouseDragToScroll)(ref);
42
- return (react_2.default.createElement("div", { "data-testid": "row", ref: ref, style: style },
43
- react_2.default.createElement("button", { onClick: props.onClick, type: "button" }, "Tab")));
44
+ let t0;
45
+ if ($[0] !== props.onClick) {
46
+ t0 = react_2.default.createElement("button", { onClick: props.onClick, type: "button" }, "Tab");
47
+ $[0] = props.onClick;
48
+ $[1] = t0;
49
+ }
50
+ else {
51
+ t0 = $[1];
52
+ }
53
+ let t1;
54
+ if ($[2] !== style || $[3] !== t0) {
55
+ t1 = react_2.default.createElement("div", { "data-testid": "row", ref: ref, style: style }, t0);
56
+ $[2] = style;
57
+ $[3] = t0;
58
+ $[4] = t1;
59
+ }
60
+ else {
61
+ t1 = $[4];
62
+ }
63
+ return t1;
44
64
  }
45
65
  function setup() {
46
66
  const onClick = jest.fn();
47
67
  const view = (0, react_1.render)(react_2.default.createElement(Row, { onClick: onClick }));
48
- return { onClick, row: react_1.screen.getByTestId("row"), tab: react_1.screen.getByRole("button"), view };
68
+ return {
69
+ onClick,
70
+ row: react_1.screen.getByTestId("row"),
71
+ tab: react_1.screen.getByRole("button"),
72
+ view
73
+ };
49
74
  }
50
75
  // jsdom does not lay anything out, so its `scrollLeft` stays 0 whatever the hook sets.
51
76
  function spyOnScrollLeft(element) {
52
77
  const setScrollLeft = jest.fn();
53
- Object.defineProperty(element, "scrollLeft", { configurable: true, get: () => 0, set: setScrollLeft });
78
+ Object.defineProperty(element, "scrollLeft", {
79
+ configurable: true,
80
+ get: () => 0,
81
+ set: setScrollLeft
82
+ });
54
83
  return setScrollLeft;
55
84
  }
56
85
  /**
@@ -58,16 +87,29 @@ function spyOnScrollLeft(element) {
58
87
  * as it does in the browser. Anything a person does later (pressing Enter, clicking again) comes after `later()`.
59
88
  */
60
89
  function press(target, x) {
61
- react_1.fireEvent.mouseDown(target, { button: 0, clientX: x, clientY: 0 });
90
+ react_1.fireEvent.mouseDown(target, {
91
+ button: 0,
92
+ clientX: x,
93
+ clientY: 0
94
+ });
62
95
  }
63
96
  function moveTo(x) {
64
- react_1.fireEvent.mouseMove(document, { clientX: x, clientY: 0 });
97
+ react_1.fireEvent.mouseMove(document, {
98
+ clientX: x,
99
+ clientY: 0
100
+ });
65
101
  }
66
102
  function release(x) {
67
- react_1.fireEvent.mouseUp(document, { clientX: x, clientY: 0 });
103
+ react_1.fireEvent.mouseUp(document, {
104
+ clientX: x,
105
+ clientY: 0
106
+ });
68
107
  }
69
108
  function click(target, x) {
70
- react_1.fireEvent.click(target, { clientX: x, detail: 1 });
109
+ react_1.fireEvent.click(target, {
110
+ clientX: x,
111
+ detail: 1
112
+ });
71
113
  }
72
114
  function later() {
73
115
  jest.runAllTimers();
@@ -131,7 +173,7 @@ describe("useMouseDragToScroll", () => {
131
173
  moveTo(40);
132
174
  release(40);
133
175
  later();
134
- tab.addEventListener("mousedown", (e) => e.stopPropagation());
176
+ tab.addEventListener("mousedown", e => e.stopPropagation());
135
177
  press(tab, 40);
136
178
  release(40);
137
179
  click(tab, 40);
@@ -139,7 +181,11 @@ describe("useMouseDragToScroll", () => {
139
181
  });
140
182
  it("does not drag with other than the primary button", () => {
141
183
  const { row, tab } = setup();
142
- react_1.fireEvent.mouseDown(tab, { button: 2, clientX: 100, clientY: 0 });
184
+ react_1.fireEvent.mouseDown(tab, {
185
+ button: 2,
186
+ clientX: 100,
187
+ clientY: 0
188
+ });
143
189
  expect(row.style.cursor).toBe("");
144
190
  });
145
191
  it("turns off the native drag of links and images", () => {
@@ -1,9 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useOnMount = useOnMount;
4
+ const compiler_runtime_1 = require("react/compiler-runtime");
4
5
  const react_1 = require("react");
5
6
  function useOnMount(effect) {
6
- (0, react_1.useEffect)(() => {
7
- return effect();
8
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
7
+ const $ = (0, compiler_runtime_1.c)(3);
8
+ let t0;
9
+ if ($[0] !== effect) {
10
+ t0 = () => effect();
11
+ $[0] = effect;
12
+ $[1] = t0;
13
+ }
14
+ else {
15
+ t0 = $[1];
16
+ }
17
+ let t1;
18
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
19
+ t1 = [];
20
+ $[2] = t1;
21
+ }
22
+ else {
23
+ t1 = $[2];
24
+ }
25
+ (0, react_1.useEffect)(t0, t1);
9
26
  }
@@ -1,11 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useOnUnmount = useOnUnmount;
4
+ const compiler_runtime_1 = require("react/compiler-runtime");
4
5
  const react_1 = require("react");
5
6
  /** Runs `effect` when the component unmounts, in the version from the latest render. */
6
7
  function useOnUnmount(effect) {
8
+ const $ = (0, compiler_runtime_1.c)(3);
7
9
  const onUnmount = (0, react_1.useEffectEvent)(effect);
8
- (0, react_1.useEffect)(() => () => {
9
- onUnmount();
10
- }, []);
10
+ let t0;
11
+ if ($[0] !== onUnmount) {
12
+ t0 = () => () => {
13
+ onUnmount();
14
+ };
15
+ $[0] = onUnmount;
16
+ $[1] = t0;
17
+ }
18
+ else {
19
+ t0 = $[1];
20
+ }
21
+ let t1;
22
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
23
+ t1 = [];
24
+ $[2] = t1;
25
+ }
26
+ else {
27
+ t1 = $[2];
28
+ }
29
+ (0, react_1.useEffect)(t0, t1);
11
30
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useOnUpdate = useOnUpdate;
4
+ const compiler_runtime_1 = require("react/compiler-runtime");
4
5
  const react_1 = require("react");
5
6
  function haveSameDeps(a, b) {
6
7
  return a.length === b.length && a.every((dep, index) => Object.is(dep, b.at(index)));
@@ -14,13 +15,24 @@ function haveSameDeps(a, b) {
14
15
  * cleanup has run. Work that must survive that, like a pending timer, belongs in a plain `useEffect`.
15
16
  */
16
17
  function useOnUpdate(effect, deps) {
18
+ const $ = (0, compiler_runtime_1.c)(3);
17
19
  const previousDeps = (0, react_1.useRef)(null);
18
- (0, react_1.useEffect)(() => {
19
- const previous = previousDeps.current;
20
- previousDeps.current = deps;
21
- if (previous === null || haveSameDeps(previous, deps)) {
22
- return;
23
- }
24
- return effect();
25
- }, deps); // eslint-disable-line react-hooks/exhaustive-deps
20
+ let t0;
21
+ if ($[0] !== deps || $[1] !== effect) {
22
+ t0 = () => {
23
+ const previous = previousDeps.current;
24
+ previousDeps.current = deps;
25
+ if (previous === null || haveSameDeps(previous, deps)) {
26
+ return;
27
+ }
28
+ return effect();
29
+ };
30
+ $[0] = deps;
31
+ $[1] = effect;
32
+ $[2] = t0;
33
+ }
34
+ else {
35
+ t0 = $[2];
36
+ }
37
+ (0, react_1.useEffect)(t0, deps);
26
38
  }