@seed-design/react 1.2.15 → 1.2.17

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Avatar.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Avatar.test.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/Avatar.test.tsx"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/react",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -47,14 +47,14 @@
47
47
  "@seed-design/react-dialog": "1.0.3",
48
48
  "@seed-design/react-drawer": "1.0.11",
49
49
  "@seed-design/react-field": "1.0.1",
50
- "@seed-design/react-image": "0.1.1",
51
- "@seed-design/react-fieldset": "0.1.0",
52
50
  "@seed-design/react-field-button": "1.0.2",
51
+ "@seed-design/react-fieldset": "0.1.0",
52
+ "@seed-design/react-image": "1.1.0",
53
53
  "@seed-design/react-popover": "1.0.4",
54
54
  "@seed-design/react-portal": "1.0.0",
55
55
  "@seed-design/react-primitive": "1.0.0",
56
56
  "@seed-design/react-progress": "1.0.0",
57
- "@seed-design/react-pull-to-refresh": "1.0.1",
57
+ "@seed-design/react-pull-to-refresh": "1.0.2",
58
58
  "@seed-design/react-radio-group": "1.1.0",
59
59
  "@seed-design/react-segmented-control": "1.0.1",
60
60
  "@seed-design/react-slider": "1.0.2",
@@ -67,7 +67,7 @@
67
67
  "unicode-segmenter": "^0.14.4"
68
68
  },
69
69
  "peerDependencies": {
70
- "@seed-design/css": ">=1.1.17",
70
+ "@seed-design/css": ">=1.2.19",
71
71
  "react": ">=18.0.0",
72
72
  "react-dom": ">=18.0.0"
73
73
  },
@@ -0,0 +1,21 @@
1
+ import { fireEvent, render } from "@testing-library/react";
2
+ import { describe, expect, it } from "bun:test";
3
+ import { AvatarFallback, AvatarImage, AvatarRoot } from "./Avatar";
4
+
5
+ describe("Avatar.Image", () => {
6
+ it("forwards a srcSet-only lazy source to the shared image primitive", () => {
7
+ const { getByAltText, getByText } = render(
8
+ <AvatarRoot>
9
+ <AvatarImage srcSet="avatar.png 1x" loading="lazy" alt="Profile" />
10
+ <AvatarFallback>AB</AvatarFallback>
11
+ </AvatarRoot>,
12
+ );
13
+ const image = getByAltText("Profile");
14
+ expect(image).toHaveAttribute("srcset", "avatar.png 1x");
15
+ expect(image).toHaveAttribute("data-loading-state", "loading");
16
+ expect(image).not.toHaveAttribute("hidden");
17
+ fireEvent.load(image);
18
+ expect(image).toHaveAttribute("data-loading-state", "loaded");
19
+ expect(getByText("AB")).toHaveAttribute("hidden");
20
+ });
21
+ });
@@ -1,9 +1,10 @@
1
1
  import { imageFrameReactionButton } from "@seed-design/css/recipes/image-frame-reaction-button";
2
- import { render } from "@testing-library/react";
2
+ import { fireEvent, render } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
  import { describe, expect, it } from "bun:test";
5
5
  import type { ReactElement } from "react";
6
- import { ImageFrameReactionButton } from "./ImageFrame";
6
+ import { renderToString } from "react-dom/server";
7
+ import { ImageFrame, ImageFrameReactionButton } from "./ImageFrame";
7
8
 
8
9
  function setUp(jsx: ReactElement) {
9
10
  return {
@@ -13,12 +14,55 @@ function setUp(jsx: ReactElement) {
13
14
  }
14
15
 
15
16
  describe("ImageFrame", () => {
17
+ it.each([
18
+ "eager",
19
+ "lazy",
20
+ ] as const)("keeps a server-rendered %s image available before hydration", (loading) => {
21
+ const container = document.createElement("div");
22
+ container.innerHTML = renderToString(
23
+ <ImageFrame src="image.png" alt="Preview" loading={loading} fallback="Loading" />,
24
+ );
25
+ const image = container.querySelector("img");
26
+ expect(image).not.toHaveAttribute("hidden");
27
+ expect(image).not.toHaveAttribute("aria-hidden");
28
+ expect(image).toHaveAttribute("data-loading-state", "loading");
29
+ });
30
+
31
+ it("hides an image without a source even when loading is lazy", () => {
32
+ const { getByAltText } = setUp(<ImageFrame src="" alt="Preview" loading="lazy" />);
33
+ expect(getByAltText("Preview")).toHaveAttribute("data-loading-state", "error");
34
+ expect(getByAltText("Preview")).toHaveAttribute("hidden");
35
+ });
36
+
37
+ it("keeps a lazy image in layout while loading and hides the fallback on load", () => {
38
+ const { getByAltText, getByText } = setUp(
39
+ <ImageFrame src="image.png" alt="Preview" loading="lazy" fallback="Loading" />,
40
+ );
41
+ const image = getByAltText("Preview");
42
+ expect(image).toHaveAttribute("loading", "lazy");
43
+ expect(image).not.toHaveAttribute("hidden");
44
+ fireEvent.load(image);
45
+ expect(image).toHaveAttribute("data-loading-state", "loaded");
46
+ expect(getByText("Loading")).toHaveAttribute("hidden");
47
+ });
48
+
49
+ it("uses srcSet when src is empty and hides the image on error", () => {
50
+ const { getByAltText, getByText } = setUp(
51
+ <ImageFrame src="" srcSet="image.png 1x" alt="Preview" fallback="Unavailable" />,
52
+ );
53
+ const image = getByAltText("Preview");
54
+ expect(image).toHaveAttribute("data-loading-state", "loading");
55
+ expect(image).toHaveAttribute("srcset", "image.png 1x");
56
+ expect(image).not.toHaveAttribute("hidden");
57
+ fireEvent.error(image);
58
+ expect(image).toHaveAttribute("hidden");
59
+ expect(getByText("Unavailable")).not.toHaveAttribute("hidden");
60
+ });
61
+
16
62
  describe("ImageFrameReactionButton", () => {
17
63
  it("renders the unselected icon by default", () => {
18
64
  const classNames = imageFrameReactionButton();
19
- const { getByRole, container } = setUp(
20
- <ImageFrameReactionButton aria-label="Like image" />,
21
- );
65
+ const { getByRole, container } = setUp(<ImageFrameReactionButton aria-label="Like image" />);
22
66
 
23
67
  const button = getByRole("button", { name: "Like image" });
24
68
  const lineIcon = container.querySelector(`.${classNames.lineIcon}`);