@yamada-ui/skeleton 0.0.0-dev-20230603042803

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Hirotomo Yamada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @yamada-ui/skeleton
2
+
3
+ ## Installation
4
+
5
+ ```sh
6
+ $ pnpm add @yamada-ui/skeleton
7
+ ```
8
+
9
+ or
10
+
11
+ ```sh
12
+ $ yarn add @yamada-ui/skeleton
13
+ ```
14
+
15
+ or
16
+
17
+ ```sh
18
+ $ npm install @yamada-ui/skeleton
19
+ ```
20
+
21
+ ## Contribution
22
+
23
+ Wouldn't you like to contribute? That's amazing! We have prepared a [contribution guide](https://github.com/hirotomoyamada/yamada-ui/blob/main/CONTRIBUTING.md) to assist you.
24
+
25
+ ## Licence
26
+
27
+ This package is licensed under the terms of the
28
+ [MIT license](https://github.com/hirotomoyamada/yamada-ui/blob/main/LICENSE).
@@ -0,0 +1,73 @@
1
+ import {
2
+ Skeleton
3
+ } from "./chunk-LK7WNBJJ.mjs";
4
+
5
+ // src/skeleton-circle.tsx
6
+ import { forwardRef as forwardRef2 } from "@yamada-ui/core";
7
+ import { cx as cx2 } from "@yamada-ui/utils";
8
+
9
+ // src/skeleton-text.tsx
10
+ import { ui, forwardRef } from "@yamada-ui/core";
11
+ import { useValue } from "@yamada-ui/use-value";
12
+ import { cx } from "@yamada-ui/utils";
13
+ import { jsx } from "react/jsx-runtime";
14
+ var SkeletonText = forwardRef(
15
+ ({
16
+ className,
17
+ noOfLines = 3,
18
+ startColor,
19
+ endColor,
20
+ fadeDuration,
21
+ speed,
22
+ isLoaded,
23
+ gap = "2",
24
+ textHeight = "2",
25
+ children,
26
+ ...rest
27
+ }, ref) => {
28
+ const computedNoOfLines = useValue(noOfLines);
29
+ const css = {
30
+ w: "full"
31
+ };
32
+ return /* @__PURE__ */ jsx(ui.div, { ref, className: cx("ui-skeleton-text", className), __css: css, ...rest, children: Array(computedNoOfLines).fill(0).map((_, index) => {
33
+ if (isLoaded && index > 0)
34
+ return null;
35
+ const isLast = index + 1 === computedNoOfLines;
36
+ const props = !isLoaded ? {
37
+ mb: !isLast ? gap : void 0,
38
+ w: computedNoOfLines > 1 ? !isLast ? "100%" : "80%" : "100%",
39
+ h: textHeight
40
+ } : {};
41
+ return /* @__PURE__ */ jsx(
42
+ Skeleton,
43
+ {
44
+ ...{ startColor, endColor, fadeDuration, speed, isLoaded, ...props },
45
+ children: index === 0 ? children : void 0
46
+ },
47
+ index
48
+ );
49
+ }) });
50
+ }
51
+ );
52
+
53
+ // src/skeleton-circle.tsx
54
+ import { jsx as jsx2 } from "react/jsx-runtime";
55
+ var SkeletonCircle = forwardRef2(
56
+ ({ className, boxSize = "12", ...rest }, ref) => {
57
+ return /* @__PURE__ */ jsx2(
58
+ Skeleton,
59
+ {
60
+ ref,
61
+ className: cx2("ui-skeleton-circle", className),
62
+ rounded: "full",
63
+ boxSize,
64
+ ...rest
65
+ }
66
+ );
67
+ }
68
+ );
69
+
70
+ export {
71
+ SkeletonCircle,
72
+ SkeletonText
73
+ };
@@ -0,0 +1,88 @@
1
+ // src/skeleton.tsx
2
+ import {
3
+ ui,
4
+ forwardRef,
5
+ omitThemeProps,
6
+ useComponentStyle
7
+ } from "@yamada-ui/core";
8
+ import { useAnimation } from "@yamada-ui/use-animation";
9
+ import { usePrevious } from "@yamada-ui/use-previous";
10
+ import { useValue } from "@yamada-ui/use-value";
11
+ import { cx, useIsMounted } from "@yamada-ui/utils";
12
+ import { jsx } from "react/jsx-runtime";
13
+ var Skeleton = forwardRef((props, ref) => {
14
+ let [styles, mergedProps] = useComponentStyle("Skeleton", props);
15
+ const {
16
+ className,
17
+ startColor,
18
+ endColor,
19
+ fadeDuration = 0.4,
20
+ speed = 0.8,
21
+ isLoaded,
22
+ ...rest
23
+ } = omitThemeProps(mergedProps);
24
+ const isMounted = useIsMounted();
25
+ const prevIsLoaded = usePrevious(isLoaded);
26
+ const computedStartColor = useValue(startColor);
27
+ const computedEndColor = useValue(endColor);
28
+ const fadeIn = useAnimation({
29
+ keyframes: {
30
+ "0%": {
31
+ opacity: 0
32
+ },
33
+ "100%": {
34
+ opacity: 1
35
+ }
36
+ },
37
+ duration: typeof fadeDuration === "string" ? fadeDuration : `${fadeDuration}s`
38
+ });
39
+ const animation = useAnimation({
40
+ keyframes: {
41
+ "0%": {
42
+ borderColor: computedStartColor,
43
+ background: computedStartColor
44
+ },
45
+ "100%": {
46
+ borderColor: computedEndColor,
47
+ background: computedEndColor
48
+ }
49
+ },
50
+ duration: typeof speed === "string" ? speed : `${speed}s`,
51
+ iterationCount: "infinite",
52
+ direction: "alternate",
53
+ timingFunction: "linear"
54
+ });
55
+ const css = {
56
+ w: "full",
57
+ h: "4",
58
+ boxShadow: "none",
59
+ backgroundClip: "padding-box",
60
+ cursor: "default",
61
+ color: "transparent",
62
+ pointerEvents: "none",
63
+ userSelect: "none",
64
+ "&::before, &::after, *": {
65
+ visibility: "hidden"
66
+ },
67
+ ...styles
68
+ };
69
+ if (isLoaded) {
70
+ const animation2 = !isMounted.current || prevIsLoaded ? "none" : fadeIn;
71
+ return /* @__PURE__ */ jsx(ui.div, { ref, className: cx("ui-skeleton", className), ...rest, animation: animation2 });
72
+ } else {
73
+ return /* @__PURE__ */ jsx(
74
+ ui.div,
75
+ {
76
+ ref,
77
+ className: cx("ui-skeleton", className),
78
+ __css: css,
79
+ ...rest,
80
+ animation
81
+ }
82
+ );
83
+ }
84
+ });
85
+
86
+ export {
87
+ Skeleton
88
+ };
@@ -0,0 +1,4 @@
1
+ export { Skeleton, SkeletonProps } from './skeleton.js';
2
+ export { SkeletonCircle, SkeletonCircleProps } from './skeleton-circle.js';
3
+ export { SkeletonText, SkeletonTextProps } from './skeleton-text.js';
4
+ import '@yamada-ui/core';
package/dist/index.js ADDED
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Skeleton: () => Skeleton,
24
+ SkeletonCircle: () => SkeletonCircle,
25
+ SkeletonText: () => SkeletonText
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/skeleton.tsx
30
+ var import_core = require("@yamada-ui/core");
31
+ var import_use_animation = require("@yamada-ui/use-animation");
32
+ var import_use_previous = require("@yamada-ui/use-previous");
33
+ var import_use_value = require("@yamada-ui/use-value");
34
+ var import_utils = require("@yamada-ui/utils");
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var Skeleton = (0, import_core.forwardRef)((props, ref) => {
37
+ let [styles, mergedProps] = (0, import_core.useComponentStyle)("Skeleton", props);
38
+ const {
39
+ className,
40
+ startColor,
41
+ endColor,
42
+ fadeDuration = 0.4,
43
+ speed = 0.8,
44
+ isLoaded,
45
+ ...rest
46
+ } = (0, import_core.omitThemeProps)(mergedProps);
47
+ const isMounted = (0, import_utils.useIsMounted)();
48
+ const prevIsLoaded = (0, import_use_previous.usePrevious)(isLoaded);
49
+ const computedStartColor = (0, import_use_value.useValue)(startColor);
50
+ const computedEndColor = (0, import_use_value.useValue)(endColor);
51
+ const fadeIn = (0, import_use_animation.useAnimation)({
52
+ keyframes: {
53
+ "0%": {
54
+ opacity: 0
55
+ },
56
+ "100%": {
57
+ opacity: 1
58
+ }
59
+ },
60
+ duration: typeof fadeDuration === "string" ? fadeDuration : `${fadeDuration}s`
61
+ });
62
+ const animation = (0, import_use_animation.useAnimation)({
63
+ keyframes: {
64
+ "0%": {
65
+ borderColor: computedStartColor,
66
+ background: computedStartColor
67
+ },
68
+ "100%": {
69
+ borderColor: computedEndColor,
70
+ background: computedEndColor
71
+ }
72
+ },
73
+ duration: typeof speed === "string" ? speed : `${speed}s`,
74
+ iterationCount: "infinite",
75
+ direction: "alternate",
76
+ timingFunction: "linear"
77
+ });
78
+ const css = {
79
+ w: "full",
80
+ h: "4",
81
+ boxShadow: "none",
82
+ backgroundClip: "padding-box",
83
+ cursor: "default",
84
+ color: "transparent",
85
+ pointerEvents: "none",
86
+ userSelect: "none",
87
+ "&::before, &::after, *": {
88
+ visibility: "hidden"
89
+ },
90
+ ...styles
91
+ };
92
+ if (isLoaded) {
93
+ const animation2 = !isMounted.current || prevIsLoaded ? "none" : fadeIn;
94
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-skeleton", className), ...rest, animation: animation2 });
95
+ } else {
96
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
+ import_core.ui.div,
98
+ {
99
+ ref,
100
+ className: (0, import_utils.cx)("ui-skeleton", className),
101
+ __css: css,
102
+ ...rest,
103
+ animation
104
+ }
105
+ );
106
+ }
107
+ });
108
+
109
+ // src/skeleton-circle.tsx
110
+ var import_core2 = require("@yamada-ui/core");
111
+ var import_utils2 = require("@yamada-ui/utils");
112
+ var import_jsx_runtime2 = require("react/jsx-runtime");
113
+ var SkeletonCircle = (0, import_core2.forwardRef)(
114
+ ({ className, boxSize = "12", ...rest }, ref) => {
115
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
116
+ Skeleton,
117
+ {
118
+ ref,
119
+ className: (0, import_utils2.cx)("ui-skeleton-circle", className),
120
+ rounded: "full",
121
+ boxSize,
122
+ ...rest
123
+ }
124
+ );
125
+ }
126
+ );
127
+
128
+ // src/skeleton-text.tsx
129
+ var import_core3 = require("@yamada-ui/core");
130
+ var import_use_value2 = require("@yamada-ui/use-value");
131
+ var import_utils3 = require("@yamada-ui/utils");
132
+ var import_jsx_runtime3 = require("react/jsx-runtime");
133
+ var SkeletonText = (0, import_core3.forwardRef)(
134
+ ({
135
+ className,
136
+ noOfLines = 3,
137
+ startColor,
138
+ endColor,
139
+ fadeDuration,
140
+ speed,
141
+ isLoaded,
142
+ gap = "2",
143
+ textHeight = "2",
144
+ children,
145
+ ...rest
146
+ }, ref) => {
147
+ const computedNoOfLines = (0, import_use_value2.useValue)(noOfLines);
148
+ const css = {
149
+ w: "full"
150
+ };
151
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.div, { ref, className: (0, import_utils3.cx)("ui-skeleton-text", className), __css: css, ...rest, children: Array(computedNoOfLines).fill(0).map((_, index) => {
152
+ if (isLoaded && index > 0)
153
+ return null;
154
+ const isLast = index + 1 === computedNoOfLines;
155
+ const props = !isLoaded ? {
156
+ mb: !isLast ? gap : void 0,
157
+ w: computedNoOfLines > 1 ? !isLast ? "100%" : "80%" : "100%",
158
+ h: textHeight
159
+ } : {};
160
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
161
+ Skeleton,
162
+ {
163
+ ...{ startColor, endColor, fadeDuration, speed, isLoaded, ...props },
164
+ children: index === 0 ? children : void 0
165
+ },
166
+ index
167
+ );
168
+ }) });
169
+ }
170
+ );
171
+ // Annotate the CommonJS export names for ESM import in node:
172
+ 0 && (module.exports = {
173
+ Skeleton,
174
+ SkeletonCircle,
175
+ SkeletonText
176
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ import {
2
+ SkeletonCircle,
3
+ SkeletonText
4
+ } from "./chunk-I64RKGOG.mjs";
5
+ import {
6
+ Skeleton
7
+ } from "./chunk-LK7WNBJJ.mjs";
8
+ export {
9
+ Skeleton,
10
+ SkeletonCircle,
11
+ SkeletonText
12
+ };
@@ -0,0 +1,7 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { SkeletonProps } from './skeleton.js';
3
+
4
+ type SkeletonCircleProps = SkeletonProps;
5
+ declare const SkeletonCircle: _yamada_ui_core.Component<"div", SkeletonProps>;
6
+
7
+ export { SkeletonCircle, SkeletonCircleProps };
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/skeleton-circle.tsx
21
+ var skeleton_circle_exports = {};
22
+ __export(skeleton_circle_exports, {
23
+ SkeletonCircle: () => SkeletonCircle
24
+ });
25
+ module.exports = __toCommonJS(skeleton_circle_exports);
26
+ var import_core2 = require("@yamada-ui/core");
27
+ var import_utils2 = require("@yamada-ui/utils");
28
+
29
+ // src/skeleton.tsx
30
+ var import_core = require("@yamada-ui/core");
31
+ var import_use_animation = require("@yamada-ui/use-animation");
32
+ var import_use_previous = require("@yamada-ui/use-previous");
33
+ var import_use_value = require("@yamada-ui/use-value");
34
+ var import_utils = require("@yamada-ui/utils");
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var Skeleton = (0, import_core.forwardRef)((props, ref) => {
37
+ let [styles, mergedProps] = (0, import_core.useComponentStyle)("Skeleton", props);
38
+ const {
39
+ className,
40
+ startColor,
41
+ endColor,
42
+ fadeDuration = 0.4,
43
+ speed = 0.8,
44
+ isLoaded,
45
+ ...rest
46
+ } = (0, import_core.omitThemeProps)(mergedProps);
47
+ const isMounted = (0, import_utils.useIsMounted)();
48
+ const prevIsLoaded = (0, import_use_previous.usePrevious)(isLoaded);
49
+ const computedStartColor = (0, import_use_value.useValue)(startColor);
50
+ const computedEndColor = (0, import_use_value.useValue)(endColor);
51
+ const fadeIn = (0, import_use_animation.useAnimation)({
52
+ keyframes: {
53
+ "0%": {
54
+ opacity: 0
55
+ },
56
+ "100%": {
57
+ opacity: 1
58
+ }
59
+ },
60
+ duration: typeof fadeDuration === "string" ? fadeDuration : `${fadeDuration}s`
61
+ });
62
+ const animation = (0, import_use_animation.useAnimation)({
63
+ keyframes: {
64
+ "0%": {
65
+ borderColor: computedStartColor,
66
+ background: computedStartColor
67
+ },
68
+ "100%": {
69
+ borderColor: computedEndColor,
70
+ background: computedEndColor
71
+ }
72
+ },
73
+ duration: typeof speed === "string" ? speed : `${speed}s`,
74
+ iterationCount: "infinite",
75
+ direction: "alternate",
76
+ timingFunction: "linear"
77
+ });
78
+ const css = {
79
+ w: "full",
80
+ h: "4",
81
+ boxShadow: "none",
82
+ backgroundClip: "padding-box",
83
+ cursor: "default",
84
+ color: "transparent",
85
+ pointerEvents: "none",
86
+ userSelect: "none",
87
+ "&::before, &::after, *": {
88
+ visibility: "hidden"
89
+ },
90
+ ...styles
91
+ };
92
+ if (isLoaded) {
93
+ const animation2 = !isMounted.current || prevIsLoaded ? "none" : fadeIn;
94
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-skeleton", className), ...rest, animation: animation2 });
95
+ } else {
96
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
+ import_core.ui.div,
98
+ {
99
+ ref,
100
+ className: (0, import_utils.cx)("ui-skeleton", className),
101
+ __css: css,
102
+ ...rest,
103
+ animation
104
+ }
105
+ );
106
+ }
107
+ });
108
+
109
+ // src/skeleton-circle.tsx
110
+ var import_jsx_runtime2 = require("react/jsx-runtime");
111
+ var SkeletonCircle = (0, import_core2.forwardRef)(
112
+ ({ className, boxSize = "12", ...rest }, ref) => {
113
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
114
+ Skeleton,
115
+ {
116
+ ref,
117
+ className: (0, import_utils2.cx)("ui-skeleton-circle", className),
118
+ rounded: "full",
119
+ boxSize,
120
+ ...rest
121
+ }
122
+ );
123
+ }
124
+ );
125
+ // Annotate the CommonJS export names for ESM import in node:
126
+ 0 && (module.exports = {
127
+ SkeletonCircle
128
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ SkeletonCircle
3
+ } from "./chunk-I64RKGOG.mjs";
4
+ import "./chunk-LK7WNBJJ.mjs";
5
+ export {
6
+ SkeletonCircle
7
+ };
@@ -0,0 +1,12 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { UIProps } from '@yamada-ui/core';
3
+ import { SkeletonProps } from './skeleton.js';
4
+
5
+ type SkeletonTextOptions = {
6
+ gap?: UIProps['gap'];
7
+ textHeight?: UIProps['height'];
8
+ };
9
+ type SkeletonTextProps = SkeletonProps & SkeletonTextOptions;
10
+ declare const SkeletonText: _yamada_ui_core.Component<"div", SkeletonTextProps>;
11
+
12
+ export { SkeletonText, SkeletonTextProps };
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/skeleton-text.tsx
21
+ var skeleton_text_exports = {};
22
+ __export(skeleton_text_exports, {
23
+ SkeletonText: () => SkeletonText
24
+ });
25
+ module.exports = __toCommonJS(skeleton_text_exports);
26
+ var import_core2 = require("@yamada-ui/core");
27
+ var import_use_value2 = require("@yamada-ui/use-value");
28
+ var import_utils2 = require("@yamada-ui/utils");
29
+
30
+ // src/skeleton.tsx
31
+ var import_core = require("@yamada-ui/core");
32
+ var import_use_animation = require("@yamada-ui/use-animation");
33
+ var import_use_previous = require("@yamada-ui/use-previous");
34
+ var import_use_value = require("@yamada-ui/use-value");
35
+ var import_utils = require("@yamada-ui/utils");
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var Skeleton = (0, import_core.forwardRef)((props, ref) => {
38
+ let [styles, mergedProps] = (0, import_core.useComponentStyle)("Skeleton", props);
39
+ const {
40
+ className,
41
+ startColor,
42
+ endColor,
43
+ fadeDuration = 0.4,
44
+ speed = 0.8,
45
+ isLoaded,
46
+ ...rest
47
+ } = (0, import_core.omitThemeProps)(mergedProps);
48
+ const isMounted = (0, import_utils.useIsMounted)();
49
+ const prevIsLoaded = (0, import_use_previous.usePrevious)(isLoaded);
50
+ const computedStartColor = (0, import_use_value.useValue)(startColor);
51
+ const computedEndColor = (0, import_use_value.useValue)(endColor);
52
+ const fadeIn = (0, import_use_animation.useAnimation)({
53
+ keyframes: {
54
+ "0%": {
55
+ opacity: 0
56
+ },
57
+ "100%": {
58
+ opacity: 1
59
+ }
60
+ },
61
+ duration: typeof fadeDuration === "string" ? fadeDuration : `${fadeDuration}s`
62
+ });
63
+ const animation = (0, import_use_animation.useAnimation)({
64
+ keyframes: {
65
+ "0%": {
66
+ borderColor: computedStartColor,
67
+ background: computedStartColor
68
+ },
69
+ "100%": {
70
+ borderColor: computedEndColor,
71
+ background: computedEndColor
72
+ }
73
+ },
74
+ duration: typeof speed === "string" ? speed : `${speed}s`,
75
+ iterationCount: "infinite",
76
+ direction: "alternate",
77
+ timingFunction: "linear"
78
+ });
79
+ const css = {
80
+ w: "full",
81
+ h: "4",
82
+ boxShadow: "none",
83
+ backgroundClip: "padding-box",
84
+ cursor: "default",
85
+ color: "transparent",
86
+ pointerEvents: "none",
87
+ userSelect: "none",
88
+ "&::before, &::after, *": {
89
+ visibility: "hidden"
90
+ },
91
+ ...styles
92
+ };
93
+ if (isLoaded) {
94
+ const animation2 = !isMounted.current || prevIsLoaded ? "none" : fadeIn;
95
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-skeleton", className), ...rest, animation: animation2 });
96
+ } else {
97
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
+ import_core.ui.div,
99
+ {
100
+ ref,
101
+ className: (0, import_utils.cx)("ui-skeleton", className),
102
+ __css: css,
103
+ ...rest,
104
+ animation
105
+ }
106
+ );
107
+ }
108
+ });
109
+
110
+ // src/skeleton-text.tsx
111
+ var import_jsx_runtime2 = require("react/jsx-runtime");
112
+ var SkeletonText = (0, import_core2.forwardRef)(
113
+ ({
114
+ className,
115
+ noOfLines = 3,
116
+ startColor,
117
+ endColor,
118
+ fadeDuration,
119
+ speed,
120
+ isLoaded,
121
+ gap = "2",
122
+ textHeight = "2",
123
+ children,
124
+ ...rest
125
+ }, ref) => {
126
+ const computedNoOfLines = (0, import_use_value2.useValue)(noOfLines);
127
+ const css = {
128
+ w: "full"
129
+ };
130
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-skeleton-text", className), __css: css, ...rest, children: Array(computedNoOfLines).fill(0).map((_, index) => {
131
+ if (isLoaded && index > 0)
132
+ return null;
133
+ const isLast = index + 1 === computedNoOfLines;
134
+ const props = !isLoaded ? {
135
+ mb: !isLast ? gap : void 0,
136
+ w: computedNoOfLines > 1 ? !isLast ? "100%" : "80%" : "100%",
137
+ h: textHeight
138
+ } : {};
139
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
140
+ Skeleton,
141
+ {
142
+ ...{ startColor, endColor, fadeDuration, speed, isLoaded, ...props },
143
+ children: index === 0 ? children : void 0
144
+ },
145
+ index
146
+ );
147
+ }) });
148
+ }
149
+ );
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ SkeletonText
153
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ SkeletonText
3
+ } from "./chunk-I64RKGOG.mjs";
4
+ import "./chunk-LK7WNBJJ.mjs";
5
+ export {
6
+ SkeletonText
7
+ };
@@ -0,0 +1,14 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, ThemeProps, CSSUIProps } from '@yamada-ui/core';
3
+
4
+ type SkeletonOptions = {
5
+ startColor?: CSSUIProps['color'];
6
+ endColor?: CSSUIProps['color'];
7
+ isLoaded?: boolean;
8
+ speed?: string | number;
9
+ fadeDuration?: string | number;
10
+ };
11
+ type SkeletonProps = HTMLUIProps<'div'> & ThemeProps<'Skeleton'> & SkeletonOptions;
12
+ declare const Skeleton: _yamada_ui_core.Component<"div", SkeletonProps>;
13
+
14
+ export { Skeleton, SkeletonProps };
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/skeleton.tsx
21
+ var skeleton_exports = {};
22
+ __export(skeleton_exports, {
23
+ Skeleton: () => Skeleton
24
+ });
25
+ module.exports = __toCommonJS(skeleton_exports);
26
+ var import_core = require("@yamada-ui/core");
27
+ var import_use_animation = require("@yamada-ui/use-animation");
28
+ var import_use_previous = require("@yamada-ui/use-previous");
29
+ var import_use_value = require("@yamada-ui/use-value");
30
+ var import_utils = require("@yamada-ui/utils");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ var Skeleton = (0, import_core.forwardRef)((props, ref) => {
33
+ let [styles, mergedProps] = (0, import_core.useComponentStyle)("Skeleton", props);
34
+ const {
35
+ className,
36
+ startColor,
37
+ endColor,
38
+ fadeDuration = 0.4,
39
+ speed = 0.8,
40
+ isLoaded,
41
+ ...rest
42
+ } = (0, import_core.omitThemeProps)(mergedProps);
43
+ const isMounted = (0, import_utils.useIsMounted)();
44
+ const prevIsLoaded = (0, import_use_previous.usePrevious)(isLoaded);
45
+ const computedStartColor = (0, import_use_value.useValue)(startColor);
46
+ const computedEndColor = (0, import_use_value.useValue)(endColor);
47
+ const fadeIn = (0, import_use_animation.useAnimation)({
48
+ keyframes: {
49
+ "0%": {
50
+ opacity: 0
51
+ },
52
+ "100%": {
53
+ opacity: 1
54
+ }
55
+ },
56
+ duration: typeof fadeDuration === "string" ? fadeDuration : `${fadeDuration}s`
57
+ });
58
+ const animation = (0, import_use_animation.useAnimation)({
59
+ keyframes: {
60
+ "0%": {
61
+ borderColor: computedStartColor,
62
+ background: computedStartColor
63
+ },
64
+ "100%": {
65
+ borderColor: computedEndColor,
66
+ background: computedEndColor
67
+ }
68
+ },
69
+ duration: typeof speed === "string" ? speed : `${speed}s`,
70
+ iterationCount: "infinite",
71
+ direction: "alternate",
72
+ timingFunction: "linear"
73
+ });
74
+ const css = {
75
+ w: "full",
76
+ h: "4",
77
+ boxShadow: "none",
78
+ backgroundClip: "padding-box",
79
+ cursor: "default",
80
+ color: "transparent",
81
+ pointerEvents: "none",
82
+ userSelect: "none",
83
+ "&::before, &::after, *": {
84
+ visibility: "hidden"
85
+ },
86
+ ...styles
87
+ };
88
+ if (isLoaded) {
89
+ const animation2 = !isMounted.current || prevIsLoaded ? "none" : fadeIn;
90
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-skeleton", className), ...rest, animation: animation2 });
91
+ } else {
92
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
+ import_core.ui.div,
94
+ {
95
+ ref,
96
+ className: (0, import_utils.cx)("ui-skeleton", className),
97
+ __css: css,
98
+ ...rest,
99
+ animation
100
+ }
101
+ );
102
+ }
103
+ });
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ Skeleton
107
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ Skeleton
3
+ } from "./chunk-LK7WNBJJ.mjs";
4
+ export {
5
+ Skeleton
6
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@yamada-ui/skeleton",
3
+ "version": "0.0.0-dev-20230603042803",
4
+ "description": "Yamada UI skeleton component",
5
+ "keywords": [
6
+ "yamada",
7
+ "yamada ui",
8
+ "react",
9
+ "emotion",
10
+ "component",
11
+ "skeleton",
12
+ "ui",
13
+ "uikit",
14
+ "styled",
15
+ "style-props",
16
+ "styled-component",
17
+ "css-in-js"
18
+ ],
19
+ "author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
20
+ "license": "MIT",
21
+ "main": "dist/index.js",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "sideEffects": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/hirotomoyamada/yamada-ui",
32
+ "directory": "packages/components/skeleton"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
36
+ },
37
+ "dependencies": {
38
+ "@yamada-ui/core": "0.0.0-dev-20230603042803",
39
+ "@yamada-ui/use-animation": "0.0.0-dev-20230603042803",
40
+ "@yamada-ui/use-value": "0.0.0-dev-20230603042803",
41
+ "@yamada-ui/use-previous": "0.1.0",
42
+ "@yamada-ui/utils": "0.1.0"
43
+ },
44
+ "devDependencies": {
45
+ "react": "^18.0.0",
46
+ "clean-package": "2.2.0"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=18"
50
+ },
51
+ "clean-package": "../../../clean-package.config.json",
52
+ "tsup": {
53
+ "clean": true,
54
+ "target": "es2019",
55
+ "format": [
56
+ "cjs",
57
+ "esm"
58
+ ]
59
+ },
60
+ "module": "dist/index.mjs",
61
+ "types": "dist/index.d.ts",
62
+ "exports": {
63
+ ".": {
64
+ "types": "./dist/index.d.ts",
65
+ "import": "./dist/index.mjs",
66
+ "require": "./dist/index.js"
67
+ },
68
+ "./package.json": "./package.json"
69
+ },
70
+ "scripts": {
71
+ "dev": "pnpm build:fast -- --watch",
72
+ "build": "tsup src --dts",
73
+ "build:fast": "tsup src",
74
+ "clean": "rimraf dist .turbo",
75
+ "typecheck": "tsc --noEmit",
76
+ "gen:docs": "tsx ../../../scripts/generate-docs"
77
+ }
78
+ }