@k8o/arte-odyssey 0.1.0 → 1.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.
- package/dist/components/accordion/index.d.ts +7 -7
- package/dist/components/breadcrumb/breadcrumb.d.ts +1 -1
- package/dist/components/dialog/dialog.d.ts +1 -1
- package/dist/components/dropdown-menu/hooks.d.ts +2 -2
- package/dist/components/list-box/hooks.d.ts +2 -2
- package/dist/components/modal/modal.js +2 -1
- package/dist/components/popover/hooks.d.ts +2 -2
- package/dist/components/providers/arte-odyssey-provider.d.ts +2 -0
- package/dist/components/providers/{component-provider.js → arte-odyssey-provider.js} +2 -2
- package/dist/components/providers/index.d.ts +1 -1
- package/dist/components/providers/index.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/hooks/click-away/index.test.js +6 -11
- package/dist/hooks/clipboard/index.test.js +3 -7
- package/dist/hooks/hash/index.test.js +7 -8
- package/dist/hooks/interval/index.test.js +1 -1
- package/dist/hooks/local-storage/index.test.js +14 -6
- package/dist/hooks/scroll-direction/index.test.js +14 -14
- package/dist/hooks/step/index.test.js +18 -12
- package/dist/hooks/timeout/index.test.js +1 -1
- package/dist/hooks/window-size/index.test.js +2 -2
- package/package.json +20 -21
- package/dist/components/providers/component-provider.d.ts +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export declare const Accordion: {
|
|
2
|
-
readonly Root:
|
|
3
|
-
children?:
|
|
2
|
+
readonly Root: import("react").FC<{
|
|
3
|
+
children?: import("react").ReactNode | undefined;
|
|
4
4
|
}>;
|
|
5
|
-
readonly Button:
|
|
6
|
-
children?:
|
|
5
|
+
readonly Button: import("react").FC<{
|
|
6
|
+
children?: import("react").ReactNode | undefined;
|
|
7
7
|
}>;
|
|
8
|
-
readonly Item:
|
|
8
|
+
readonly Item: import("react").FC<import("react").PropsWithChildren<{
|
|
9
9
|
defaultOpen?: boolean;
|
|
10
10
|
}>>;
|
|
11
|
-
readonly Panel:
|
|
12
|
-
children?:
|
|
11
|
+
readonly Panel: import("react").FC<{
|
|
12
|
+
children?: import("react").ReactNode | undefined;
|
|
13
13
|
}>;
|
|
14
14
|
};
|
|
@@ -4,7 +4,7 @@ export declare const Breadcrumb: {
|
|
|
4
4
|
size?: "sm" | "md" | "lg";
|
|
5
5
|
}>>;
|
|
6
6
|
readonly Item: FC<{
|
|
7
|
-
children?:
|
|
7
|
+
children?: import("react").ReactNode | undefined;
|
|
8
8
|
}>;
|
|
9
9
|
readonly Separator: FC;
|
|
10
10
|
readonly Link: <T extends string>({ href, current, children, component, }: PropsWithChildren<{
|
|
@@ -6,8 +6,8 @@ type MenuContext = {
|
|
|
6
6
|
getContentProps: (userProps?: HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
7
7
|
getItemProps: (userProps?: Omit<HTMLProps<HTMLButtonElement>, 'selected' | 'active'>) => Record<string, unknown>;
|
|
8
8
|
};
|
|
9
|
-
declare const MenuContext:
|
|
10
|
-
export declare const MenuContextProvider:
|
|
9
|
+
declare const MenuContext: import("react").Context<MenuContext | null>;
|
|
10
|
+
export declare const MenuContextProvider: import("react").Context<MenuContext | null>;
|
|
11
11
|
export declare const useMenuContent: () => {
|
|
12
12
|
contentProps: Record<string, unknown>;
|
|
13
13
|
itemElementsRef: RefObject<(HTMLElement | null)[]>;
|
|
@@ -13,8 +13,8 @@ type MenuContext = {
|
|
|
13
13
|
getContentProps: (userProps?: HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
14
14
|
getItemProps: (userProps?: Omit<HTMLProps<HTMLElement>, 'selected' | 'active'>) => Record<string, unknown>;
|
|
15
15
|
};
|
|
16
|
-
declare const MenuContext:
|
|
17
|
-
export declare const MenuContextProvider:
|
|
16
|
+
declare const MenuContext: import("react").Context<MenuContext | null>;
|
|
17
|
+
export declare const MenuContextProvider: import("react").Context<MenuContext | null>;
|
|
18
18
|
export declare const useMenuContent: () => {
|
|
19
19
|
options: Option[];
|
|
20
20
|
selectedIndex: number | null;
|
|
@@ -87,7 +87,8 @@ const Modal = ({ ref, type = "center", defaultOpen, isOpen, onClose, children })
|
|
|
87
87
|
realDialogOpen,
|
|
88
88
|
realRef.current?.close,
|
|
89
89
|
realRef.current?.open,
|
|
90
|
-
realRef.current?.showModal
|
|
90
|
+
realRef.current?.showModal,
|
|
91
|
+
realRef.current
|
|
91
92
|
]);
|
|
92
93
|
return /* @__PURE__ */ jsx(
|
|
93
94
|
motion.dialog,
|
|
@@ -14,8 +14,8 @@ type PopoverContext = {
|
|
|
14
14
|
setContentRef: (node: HTMLElement | null) => void;
|
|
15
15
|
contentStyles: CSSProperties;
|
|
16
16
|
};
|
|
17
|
-
declare const PopoverContext:
|
|
18
|
-
export declare const PopoverProvider:
|
|
17
|
+
declare const PopoverContext: import("react").Context<PopoverContext | null>;
|
|
18
|
+
export declare const PopoverProvider: import("react").Context<PopoverContext | null>;
|
|
19
19
|
export declare const useFloatingUIContext: () => FloatingContext;
|
|
20
20
|
export declare const usePlacement: () => Placement;
|
|
21
21
|
export declare const useOpenContext: () => {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { MotionConfig } from "motion/react";
|
|
4
4
|
import { ToastProvider } from "../toast";
|
|
5
|
-
const
|
|
5
|
+
const ArteOdysseyProvider = ({ children }) => {
|
|
6
6
|
return /* @__PURE__ */ jsx(MotionConfig, { reducedMotion: "user", children: /* @__PURE__ */ jsx(ToastProvider, { children }) });
|
|
7
7
|
};
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
ArteOdysseyProvider
|
|
10
10
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './arte-odyssey-provider';
|
|
2
2
|
export * from './portal-root';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./arte-odyssey-provider";
|
|
2
2
|
export * from "./portal-root";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { userEvent } from "@vitest/browser/context";
|
|
3
|
+
import { render } from "vitest-browser-react";
|
|
3
4
|
import { useClickAway } from ".";
|
|
4
5
|
const OutsideClicker = ({ callback }) => {
|
|
5
6
|
const ref = useClickAway(callback);
|
|
@@ -9,23 +10,17 @@ const OutsideClicker = ({ callback }) => {
|
|
|
9
10
|
] });
|
|
10
11
|
};
|
|
11
12
|
describe("useClickAway", () => {
|
|
12
|
-
it("\u9818\u57DF\u5916\u3092\u89E6\u308B\u3068callback\u304C\u547C\u3073\u51FA\u3055\u308C\u308B", () => {
|
|
13
|
+
it("\u9818\u57DF\u5916\u3092\u89E6\u308B\u3068callback\u304C\u547C\u3073\u51FA\u3055\u308C\u308B", async () => {
|
|
13
14
|
const fn = vi.fn();
|
|
14
15
|
const { getByText } = render(/* @__PURE__ */ jsx(OutsideClicker, { callback: fn }));
|
|
15
16
|
const element = getByText("Element");
|
|
16
17
|
const outsideElement = getByText("Outside");
|
|
17
|
-
const click = (el) => {
|
|
18
|
-
fireEvent.mouseDown(el);
|
|
19
|
-
fireEvent.mouseUp(el);
|
|
20
|
-
};
|
|
21
18
|
expect(fn).not.toHaveBeenCalled();
|
|
22
|
-
click(element);
|
|
19
|
+
await userEvent.click(element);
|
|
23
20
|
expect(fn).not.toHaveBeenCalled();
|
|
24
|
-
click(outsideElement);
|
|
21
|
+
await userEvent.click(outsideElement);
|
|
25
22
|
expect(fn).toHaveBeenCalledOnce();
|
|
26
|
-
click(document.body);
|
|
23
|
+
await userEvent.click(document.body);
|
|
27
24
|
expect(fn).toHaveBeenCalledTimes(2);
|
|
28
|
-
click(document);
|
|
29
|
-
expect(fn).toHaveBeenCalledTimes(3);
|
|
30
25
|
});
|
|
31
26
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderHook } from "vitest-browser-react";
|
|
2
2
|
import { useClipboard } from ".";
|
|
3
3
|
describe("useClipboard", () => {
|
|
4
4
|
afterEach(() => {
|
|
@@ -13,9 +13,7 @@ describe("useClipboard", () => {
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
const { result } = renderHook(() => useClipboard());
|
|
16
|
-
await
|
|
17
|
-
await result.current.writeClipboard(writeText);
|
|
18
|
-
});
|
|
16
|
+
await result.current.writeClipboard(writeText);
|
|
19
17
|
expect(writeTextMockFn).toBeCalledWith(writeText);
|
|
20
18
|
expect(navigator.clipboard.writeText).toHaveBeenCalledOnce();
|
|
21
19
|
});
|
|
@@ -27,9 +25,7 @@ describe("useClipboard", () => {
|
|
|
27
25
|
}
|
|
28
26
|
});
|
|
29
27
|
const { result } = renderHook(() => useClipboard());
|
|
30
|
-
await
|
|
31
|
-
await result.current.readClipboard();
|
|
32
|
-
});
|
|
28
|
+
await result.current.readClipboard();
|
|
33
29
|
expect(readTextMockFn).toHaveBeenCalledOnce();
|
|
34
30
|
});
|
|
35
31
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { renderHook
|
|
2
|
-
import { act } from "react";
|
|
1
|
+
import { renderHook } from "vitest-browser-react";
|
|
3
2
|
import { useHash } from ".";
|
|
4
3
|
vi.mock("../client", () => ({
|
|
5
4
|
useClient: () => true
|
|
@@ -18,28 +17,28 @@ describe("useHash", () => {
|
|
|
18
17
|
expect(result.current).toBe("test");
|
|
19
18
|
});
|
|
20
19
|
it("hash\u5024\u304C\u5909\u66F4\u3055\u308C\u305F\u3068\u304D\u306B\u66F4\u65B0\u3055\u308C\u308B", () => {
|
|
21
|
-
const { result } = renderHook(() => useHash());
|
|
22
|
-
window.location.hash = "#changed";
|
|
20
|
+
const { result, act } = renderHook(() => useHash());
|
|
23
21
|
act(() => {
|
|
22
|
+
window.location.hash = "#changed";
|
|
24
23
|
window.dispatchEvent(new Event("hashchange"));
|
|
25
24
|
});
|
|
26
25
|
expect(result.current).toBe("changed");
|
|
27
26
|
});
|
|
28
27
|
it("pushState\u3067hash\u5024\u304C\u5909\u66F4\u3055\u308C\u305F\u3068\u304D\u306B\u66F4\u65B0\u3055\u308C\u308B", async () => {
|
|
29
|
-
const { result } = renderHook(() => useHash());
|
|
28
|
+
const { result, act } = renderHook(() => useHash());
|
|
30
29
|
act(() => {
|
|
31
30
|
window.history.pushState({}, "", "/#pushed");
|
|
32
31
|
});
|
|
33
|
-
await waitFor(() => {
|
|
32
|
+
await vi.waitFor(() => {
|
|
34
33
|
expect(result.current).toBe("pushed");
|
|
35
34
|
});
|
|
36
35
|
});
|
|
37
36
|
it("replaceState\u3067hash\u5024\u304C\u5909\u66F4\u3055\u308C\u305F\u3068\u304D\u306B\u66F4\u65B0\u3055\u308C\u308B", async () => {
|
|
38
|
-
const { result } = renderHook(() => useHash());
|
|
37
|
+
const { result, act } = renderHook(() => useHash());
|
|
39
38
|
act(() => {
|
|
40
39
|
window.history.replaceState({}, "", "/#replaced");
|
|
41
40
|
});
|
|
42
|
-
await waitFor(() => {
|
|
41
|
+
await vi.waitFor(() => {
|
|
43
42
|
expect(result.current).toBe("replaced");
|
|
44
43
|
});
|
|
45
44
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderHook } from "vitest-browser-react";
|
|
2
2
|
import { useLocalStorage } from "./index";
|
|
3
3
|
const consoleErrorMock = vi.spyOn(console, "error").mockImplementation(() => void 0);
|
|
4
4
|
describe("useLocalStorage", () => {
|
|
@@ -19,7 +19,9 @@ describe("useLocalStorage", () => {
|
|
|
19
19
|
expect(result.current[0]).toBe("storedValue");
|
|
20
20
|
});
|
|
21
21
|
it("\u66F4\u65B0\u51E6\u7406\u3067\u306FlocalStorage\u3068state\u306E\u4E21\u65B9\u3092\u66F4\u65B0\u3059\u308B", () => {
|
|
22
|
-
const { result } = renderHook(
|
|
22
|
+
const { result, act } = renderHook(
|
|
23
|
+
() => useLocalStorage(key, "defaultValue")
|
|
24
|
+
);
|
|
23
25
|
act(() => {
|
|
24
26
|
result.current[1]("newValue");
|
|
25
27
|
});
|
|
@@ -28,7 +30,9 @@ describe("useLocalStorage", () => {
|
|
|
28
30
|
});
|
|
29
31
|
it("\u524A\u9664\u51E6\u7406\u3067\u306FlocalStorage\u306F\u5024\u3092\u524A\u9664\u3055\u308C\u3001state\u306F\u521D\u671F\u5024\u306B\u306A\u308B", () => {
|
|
30
32
|
localStorage.setItem(key, JSON.stringify("storedValue"));
|
|
31
|
-
const { result } = renderHook(
|
|
33
|
+
const { result, act } = renderHook(
|
|
34
|
+
() => useLocalStorage(key, "defaultValue")
|
|
35
|
+
);
|
|
32
36
|
act(() => {
|
|
33
37
|
result.current[2]();
|
|
34
38
|
});
|
|
@@ -36,7 +40,7 @@ describe("useLocalStorage", () => {
|
|
|
36
40
|
expect(result.current[0]).toBe("defaultValue");
|
|
37
41
|
});
|
|
38
42
|
it("null\u3067\u66F4\u65B0\u3057\u305F\u5834\u5408\u306Fremove\u3068\u540C\u3058\u7D50\u679C\u306B\u306A\u308B", () => {
|
|
39
|
-
const { result } = renderHook(
|
|
43
|
+
const { result, act } = renderHook(
|
|
40
44
|
() => useLocalStorage(key, {
|
|
41
45
|
lang: ["ja", "en"]
|
|
42
46
|
})
|
|
@@ -48,7 +52,9 @@ describe("useLocalStorage", () => {
|
|
|
48
52
|
expect(result.current[0]).toEqual({ lang: ["ja", "en"] });
|
|
49
53
|
});
|
|
50
54
|
it("storage\u30A4\u30D9\u30F3\u30C8\u306E\u767A\u706B\u306B\u5FDC\u3058\u3066\u72B6state\u304C\u66F4\u65B0\u3055\u308C\u308B", () => {
|
|
51
|
-
const { result } = renderHook(
|
|
55
|
+
const { result, act } = renderHook(
|
|
56
|
+
() => useLocalStorage(key, "defaultValue")
|
|
57
|
+
);
|
|
52
58
|
act(() => {
|
|
53
59
|
localStorage.setItem(key, JSON.stringify("updatedValue"));
|
|
54
60
|
window.dispatchEvent(
|
|
@@ -61,7 +67,9 @@ describe("useLocalStorage", () => {
|
|
|
61
67
|
expect(result.current[0]).toBe("updatedValue");
|
|
62
68
|
});
|
|
63
69
|
it("\u7570\u306A\u308B\u30AD\u30FC\u306Estorage\u30A4\u30D9\u30F3\u30C8\u306Fstate\u3092\u66F4\u65B0\u3057\u306A\u3044", () => {
|
|
64
|
-
const { result } = renderHook(
|
|
70
|
+
const { result, act } = renderHook(
|
|
71
|
+
() => useLocalStorage(key, "defaultValue")
|
|
72
|
+
);
|
|
65
73
|
act(() => {
|
|
66
74
|
localStorage.setItem("otherKey", JSON.stringify("otherValue"));
|
|
67
75
|
window.dispatchEvent(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderHook } from "vitest-browser-react";
|
|
2
2
|
import { useScrollDirection } from ".";
|
|
3
3
|
describe("useScrollDirection", () => {
|
|
4
4
|
beforeEach(() => {
|
|
@@ -17,7 +17,7 @@ describe("useScrollDirection", () => {
|
|
|
17
17
|
});
|
|
18
18
|
describe("Vertical scroll", () => {
|
|
19
19
|
it("100px\u4EE5\u4E0A\u4E0B\u306B\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B\u3068y: down\u3092\u8FD4\u3059", () => {
|
|
20
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
20
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
21
21
|
act(() => {
|
|
22
22
|
Object.defineProperty(window, "scrollY", { value: 150 });
|
|
23
23
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -25,7 +25,7 @@ describe("useScrollDirection", () => {
|
|
|
25
25
|
expect(result.current.y).toBe("down");
|
|
26
26
|
});
|
|
27
27
|
it("100px\u672A\u6E80\u306E\u30B9\u30AF\u30ED\u30FC\u30EB\u3067\u306Fy: up\u306E\u307E\u307E", () => {
|
|
28
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
28
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
29
29
|
act(() => {
|
|
30
30
|
Object.defineProperty(window, "scrollY", { value: 50 });
|
|
31
31
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -33,7 +33,7 @@ describe("useScrollDirection", () => {
|
|
|
33
33
|
expect(result.current.y).toBe("up");
|
|
34
34
|
});
|
|
35
35
|
it("\u4E0A\u306B\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B\u3068y: up\u3092\u8FD4\u3059", () => {
|
|
36
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
36
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
37
37
|
act(() => {
|
|
38
38
|
Object.defineProperty(window, "scrollY", { value: 200 });
|
|
39
39
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -48,7 +48,7 @@ describe("useScrollDirection", () => {
|
|
|
48
48
|
});
|
|
49
49
|
describe("Horizontal scroll", () => {
|
|
50
50
|
it("100px\u4EE5\u4E0A\u53F3\u306B\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B\u3068x: right\u3092\u8FD4\u3059", () => {
|
|
51
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
51
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
52
52
|
act(() => {
|
|
53
53
|
Object.defineProperty(window, "scrollX", { value: 150 });
|
|
54
54
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -56,7 +56,7 @@ describe("useScrollDirection", () => {
|
|
|
56
56
|
expect(result.current.x).toBe("right");
|
|
57
57
|
});
|
|
58
58
|
it("100px\u672A\u6E80\u306E\u30B9\u30AF\u30ED\u30FC\u30EB\u3067\u306Fx: right\u306E\u307E\u307E", () => {
|
|
59
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
59
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
60
60
|
act(() => {
|
|
61
61
|
Object.defineProperty(window, "scrollX", { value: 50 });
|
|
62
62
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -64,7 +64,7 @@ describe("useScrollDirection", () => {
|
|
|
64
64
|
expect(result.current.x).toBe("right");
|
|
65
65
|
});
|
|
66
66
|
it("\u5DE6\u306B\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B\u3068x: left\u3092\u8FD4\u3059", () => {
|
|
67
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
67
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
68
68
|
act(() => {
|
|
69
69
|
Object.defineProperty(window, "scrollX", { value: 200 });
|
|
70
70
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -79,7 +79,7 @@ describe("useScrollDirection", () => {
|
|
|
79
79
|
});
|
|
80
80
|
describe("Combined scroll", () => {
|
|
81
81
|
it("\u7E26\u6A2A\u540C\u6642\u306B\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u305F\u5834\u5408\u3001\u4E21\u65B9\u5411\u3092\u6B63\u3057\u304F\u691C\u77E5\u3059\u308B", () => {
|
|
82
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
82
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
83
83
|
act(() => {
|
|
84
84
|
Object.defineProperty(window, "scrollY", { value: 150 });
|
|
85
85
|
Object.defineProperty(window, "scrollX", { value: 150 });
|
|
@@ -108,7 +108,7 @@ describe("useScrollDirection", () => {
|
|
|
108
108
|
});
|
|
109
109
|
describe("Threshold parameter", () => {
|
|
110
110
|
it("threshold\u304C100\u306E\u5834\u5408\u3001100px\u4EE5\u4E0B\u306E\u30B9\u30AF\u30ED\u30FC\u30EB\u3067\u306F\u65B9\u5411\u304C\u5909\u308F\u3089\u306A\u3044", () => {
|
|
111
|
-
const { result } = renderHook(() => useScrollDirection(100));
|
|
111
|
+
const { result, act } = renderHook(() => useScrollDirection(100));
|
|
112
112
|
act(() => {
|
|
113
113
|
Object.defineProperty(window, "scrollY", { value: 100 });
|
|
114
114
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -121,7 +121,7 @@ describe("useScrollDirection", () => {
|
|
|
121
121
|
expect(result.current.x).toBe("right");
|
|
122
122
|
});
|
|
123
123
|
it("threshold\u304C100\u306E\u5834\u5408\u3001101px\u4EE5\u4E0A\u306E\u30B9\u30AF\u30ED\u30FC\u30EB\u3067\u65B9\u5411\u304C\u5909\u308F\u308B", () => {
|
|
124
|
-
const { result } = renderHook(() => useScrollDirection(100));
|
|
124
|
+
const { result, act } = renderHook(() => useScrollDirection(100));
|
|
125
125
|
act(() => {
|
|
126
126
|
Object.defineProperty(window, "scrollY", { value: 101 });
|
|
127
127
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -134,7 +134,7 @@ describe("useScrollDirection", () => {
|
|
|
134
134
|
expect(result.current.x).toBe("right");
|
|
135
135
|
});
|
|
136
136
|
it("threshold\u304C10\u306E\u5834\u5408\u300110px\u4EE5\u4E0B\u306E\u30B9\u30AF\u30ED\u30FC\u30EB\u3067\u306F\u65B9\u5411\u304C\u5909\u308F\u3089\u306A\u3044", () => {
|
|
137
|
-
const { result } = renderHook(() => useScrollDirection(10));
|
|
137
|
+
const { result, act } = renderHook(() => useScrollDirection(10));
|
|
138
138
|
act(() => {
|
|
139
139
|
Object.defineProperty(window, "scrollY", { value: 10 });
|
|
140
140
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -142,7 +142,7 @@ describe("useScrollDirection", () => {
|
|
|
142
142
|
expect(result.current.y).toBe("up");
|
|
143
143
|
});
|
|
144
144
|
it("threshold\u304C10\u306E\u5834\u5408\u300111px\u4EE5\u4E0A\u306E\u30B9\u30AF\u30ED\u30FC\u30EB\u3067\u65B9\u5411\u304C\u5909\u308F\u308B", () => {
|
|
145
|
-
const { result } = renderHook(() => useScrollDirection(10));
|
|
145
|
+
const { result, act } = renderHook(() => useScrollDirection(10));
|
|
146
146
|
act(() => {
|
|
147
147
|
Object.defineProperty(window, "scrollY", { value: 11 });
|
|
148
148
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -150,7 +150,7 @@ describe("useScrollDirection", () => {
|
|
|
150
150
|
expect(result.current.y).toBe("down");
|
|
151
151
|
});
|
|
152
152
|
it("threshold\u304C0\u306E\u5834\u5408\u30011px\u4EE5\u4E0A\u306E\u30B9\u30AF\u30ED\u30FC\u30EB\u3067\u65B9\u5411\u304C\u5909\u308F\u308B", () => {
|
|
153
|
-
const { result } = renderHook(() => useScrollDirection(0));
|
|
153
|
+
const { result, act } = renderHook(() => useScrollDirection(0));
|
|
154
154
|
act(() => {
|
|
155
155
|
Object.defineProperty(window, "scrollY", { value: 1 });
|
|
156
156
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -158,7 +158,7 @@ describe("useScrollDirection", () => {
|
|
|
158
158
|
expect(result.current.y).toBe("down");
|
|
159
159
|
});
|
|
160
160
|
it("\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\uFF08threshold\u672A\u6307\u5B9A\uFF09\u3067\u306F50px\u306E\u95BE\u5024\u304C\u9069\u7528\u3055\u308C\u308B", () => {
|
|
161
|
-
const { result } = renderHook(() => useScrollDirection());
|
|
161
|
+
const { result, act } = renderHook(() => useScrollDirection());
|
|
162
162
|
act(() => {
|
|
163
163
|
Object.defineProperty(window, "scrollY", { value: 50 });
|
|
164
164
|
window.dispatchEvent(new Event("scroll"));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { act, renderHook } from "@testing-library/react";
|
|
2
1
|
import { userEvent } from "@vitest/browser/context";
|
|
2
|
+
import { renderHook } from "vitest-browser-react";
|
|
3
3
|
import { useStep } from ".";
|
|
4
4
|
describe("useStep", () => {
|
|
5
5
|
it("\u521D\u671F\u72B6\u614B", () => {
|
|
@@ -13,7 +13,9 @@ describe("useStep", () => {
|
|
|
13
13
|
it("next\u3067initialCount\u304B\u30891\u9032\u3080", () => {
|
|
14
14
|
const initialCount = 1;
|
|
15
15
|
const maxCount = 10;
|
|
16
|
-
const { result } = renderHook(
|
|
16
|
+
const { result, act } = renderHook(
|
|
17
|
+
() => useStep({ initialCount, maxCount })
|
|
18
|
+
);
|
|
17
19
|
act(() => {
|
|
18
20
|
result.current.next();
|
|
19
21
|
});
|
|
@@ -24,7 +26,9 @@ describe("useStep", () => {
|
|
|
24
26
|
it("initialCount\u304B\u3089\u306Fback\u3067\u304D\u306A\u3044", () => {
|
|
25
27
|
const initialCount = 1;
|
|
26
28
|
const maxCount = 10;
|
|
27
|
-
const { result } = renderHook(
|
|
29
|
+
const { result, act } = renderHook(
|
|
30
|
+
() => useStep({ initialCount, maxCount })
|
|
31
|
+
);
|
|
28
32
|
act(() => {
|
|
29
33
|
result.current.back();
|
|
30
34
|
});
|
|
@@ -35,7 +39,9 @@ describe("useStep", () => {
|
|
|
35
39
|
it("maxCount\u307E\u3067\u9032\u3080", () => {
|
|
36
40
|
const initialCount = 1;
|
|
37
41
|
const maxCount = 3;
|
|
38
|
-
const { result } = renderHook(
|
|
42
|
+
const { result, act } = renderHook(
|
|
43
|
+
() => useStep({ initialCount, maxCount })
|
|
44
|
+
);
|
|
39
45
|
act(() => {
|
|
40
46
|
result.current.next();
|
|
41
47
|
result.current.next();
|
|
@@ -47,7 +53,9 @@ describe("useStep", () => {
|
|
|
47
53
|
it("maxCount\u4EE5\u4E0A\u306F\u9032\u3081\u306A\u3044", () => {
|
|
48
54
|
const initialCount = 1;
|
|
49
55
|
const maxCount = 3;
|
|
50
|
-
const { result } = renderHook(
|
|
56
|
+
const { result, act } = renderHook(
|
|
57
|
+
() => useStep({ initialCount, maxCount })
|
|
58
|
+
);
|
|
51
59
|
act(() => {
|
|
52
60
|
result.current.next();
|
|
53
61
|
result.current.next();
|
|
@@ -60,7 +68,9 @@ describe("useStep", () => {
|
|
|
60
68
|
it("next\u3068back\u3092\u7D44\u307F\u5408\u308F\u305B\u3066\u5229\u7528\u3067\u304D\u308B", () => {
|
|
61
69
|
const initialCount = 1;
|
|
62
70
|
const maxCount = 3;
|
|
63
|
-
const { result } = renderHook(
|
|
71
|
+
const { result, act } = renderHook(
|
|
72
|
+
() => useStep({ initialCount, maxCount })
|
|
73
|
+
);
|
|
64
74
|
act(() => {
|
|
65
75
|
result.current.next();
|
|
66
76
|
result.current.back();
|
|
@@ -73,13 +83,9 @@ describe("useStep", () => {
|
|
|
73
83
|
const initialCount = 1;
|
|
74
84
|
const maxCount = 3;
|
|
75
85
|
const { result } = renderHook(() => useStep({ initialCount, maxCount }));
|
|
76
|
-
await
|
|
77
|
-
await userEvent.keyboard("{arrowright}");
|
|
78
|
-
});
|
|
86
|
+
await userEvent.keyboard("{arrowright}");
|
|
79
87
|
expect(result.current.count).toBe(initialCount + 1);
|
|
80
|
-
await
|
|
81
|
-
await userEvent.keyboard("{arrowleft}");
|
|
82
|
-
});
|
|
88
|
+
await userEvent.keyboard("{arrowleft}");
|
|
83
89
|
expect(result.current.count).toBe(initialCount);
|
|
84
90
|
});
|
|
85
91
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderHook } from "vitest-browser-react";
|
|
2
2
|
import { useWindowSize } from ".";
|
|
3
3
|
describe("useWindowSize", () => {
|
|
4
4
|
it("window\u30B5\u30A4\u30BA\u306E\u5909\u66F4\u306B\u5408\u308F\u305B\u3066\u73FE\u5728\u306Ewindow\u30B5\u30A4\u30BA\u3092\u53D6\u5F97\u3059\u308B", () => {
|
|
@@ -6,7 +6,7 @@ describe("useWindowSize", () => {
|
|
|
6
6
|
const resizedWindowSize = { width: 1e3, height: 1e3 };
|
|
7
7
|
window.innerWidth = initWindowSize.width;
|
|
8
8
|
window.innerHeight = initWindowSize.height;
|
|
9
|
-
const { result } = renderHook(() => useWindowSize());
|
|
9
|
+
const { result, act } = renderHook(() => useWindowSize());
|
|
10
10
|
expect(result.current).toEqual(initWindowSize);
|
|
11
11
|
window.innerWidth = resizedWindowSize.width;
|
|
12
12
|
window.innerHeight = resizedWindowSize.height;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k8o/arte-odyssey",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "k8o's react ui library",
|
|
5
5
|
"author": "k8o <kosakanoki@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -55,34 +55,33 @@
|
|
|
55
55
|
"@floating-ui/react": "0.27.16",
|
|
56
56
|
"baseline-status": "1.0.11",
|
|
57
57
|
"clsx": "2.1.1",
|
|
58
|
-
"esbuild": "0.25.
|
|
59
|
-
"lucide-react": "0.
|
|
60
|
-
"motion": "12.23.
|
|
58
|
+
"esbuild": "0.25.10",
|
|
59
|
+
"lucide-react": "0.545.0",
|
|
60
|
+
"motion": "12.23.24",
|
|
61
61
|
"react-error-boundary": "6.0.0",
|
|
62
62
|
"tailwind-merge": "3.3.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@chromatic-com/storybook": "4.1.1",
|
|
66
|
-
"@storybook/addon-a11y": "9.1.
|
|
67
|
-
"@storybook/addon-docs": "9.1.
|
|
68
|
-
"@storybook/addon-vitest": "9.1.
|
|
69
|
-
"@storybook/react-vite": "9.1.
|
|
70
|
-
"@tailwindcss/postcss": "4.1.
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"@
|
|
74
|
-
"@types/react-dom": "19.1.9",
|
|
75
|
-
"@vitejs/plugin-react-swc": "4.0.1",
|
|
66
|
+
"@storybook/addon-a11y": "9.1.10",
|
|
67
|
+
"@storybook/addon-docs": "9.1.10",
|
|
68
|
+
"@storybook/addon-vitest": "9.1.10",
|
|
69
|
+
"@storybook/react-vite": "9.1.10",
|
|
70
|
+
"@tailwindcss/postcss": "4.1.14",
|
|
71
|
+
"@types/react": "19.2.2",
|
|
72
|
+
"@types/react-dom": "19.2.2",
|
|
73
|
+
"@vitejs/plugin-react-swc": "4.1.0",
|
|
76
74
|
"@vitest/browser": "3.2.4",
|
|
77
75
|
"@vitest/ui": "3.2.4",
|
|
78
76
|
"postcss": "8.5.6",
|
|
79
|
-
"react": "19.
|
|
80
|
-
"react-dom": "19.
|
|
81
|
-
"storybook": "9.1.
|
|
82
|
-
"storybook-addon-mock-date": "1.0.
|
|
83
|
-
"tailwindcss": "4.1.
|
|
84
|
-
"vite": "7.1.
|
|
85
|
-
"vitest": "3.2.4"
|
|
77
|
+
"react": "19.2.0",
|
|
78
|
+
"react-dom": "19.2.0",
|
|
79
|
+
"storybook": "9.1.10",
|
|
80
|
+
"storybook-addon-mock-date": "1.0.2",
|
|
81
|
+
"tailwindcss": "4.1.14",
|
|
82
|
+
"vite": "7.1.9",
|
|
83
|
+
"vitest": "3.2.4",
|
|
84
|
+
"vitest-browser-react": "1.0.1"
|
|
86
85
|
},
|
|
87
86
|
"peerDependencies": {
|
|
88
87
|
"@types/react": ">=19.0.0",
|