@yamada-ui/progress 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/progress
2
+
3
+ ## Installation
4
+
5
+ ```sh
6
+ $ pnpm add @yamada-ui/progress
7
+ ```
8
+
9
+ or
10
+
11
+ ```sh
12
+ $ yarn add @yamada-ui/progress
13
+ ```
14
+
15
+ or
16
+
17
+ ```sh
18
+ $ npm install @yamada-ui/progress
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,119 @@
1
+ // src/circle-progress.tsx
2
+ import { ui, forwardRef } from "@yamada-ui/core";
3
+ import { useAnimation } from "@yamada-ui/use-animation";
4
+ import { useToken } from "@yamada-ui/use-token";
5
+ import { useValue } from "@yamada-ui/use-value";
6
+ import { cx, valueToPercent } from "@yamada-ui/utils";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ var CircleProgress = forwardRef(
9
+ ({
10
+ className,
11
+ children,
12
+ size = "6rem",
13
+ thickness = "0.625rem",
14
+ color = "primary",
15
+ trackColor = "border",
16
+ value = 0,
17
+ min = 0,
18
+ max = 100,
19
+ isAnimation = false,
20
+ isRounded,
21
+ speed = ["1.4s", "2s"],
22
+ ...rest
23
+ }, ref) => {
24
+ var _a, _b;
25
+ size = (_a = useToken("sizes", useValue(size))) != null ? _a : size;
26
+ thickness = (_b = useToken("sizes", useValue(thickness))) != null ? _b : thickness;
27
+ const isTransparent = value === 0 && !isAnimation;
28
+ const percent = valueToPercent(value, min, max);
29
+ const interval = !isAnimation ? percent * 2.64 : void 0;
30
+ const animation = useAnimation({
31
+ keyframes: {
32
+ "0%": {
33
+ strokeDasharray: "1, 400",
34
+ strokeDashoffset: "0"
35
+ },
36
+ "50%": {
37
+ strokeDasharray: "400, 400",
38
+ strokeDashoffset: "-100"
39
+ },
40
+ "100%": {
41
+ strokeDasharray: "400, 400",
42
+ strokeDashoffset: "-260"
43
+ }
44
+ },
45
+ duration: typeof speed[0] === "string" ? speed[0] : `${speed[0]}s`,
46
+ iterationCount: "infinite",
47
+ timingFunction: "linear"
48
+ });
49
+ const css = {
50
+ display: "inline-block",
51
+ position: "relative",
52
+ verticalAlign: "middle",
53
+ fontSize: size
54
+ };
55
+ const props = isAnimation ? {
56
+ animation
57
+ } : {
58
+ strokeDashoffset: 66,
59
+ strokeDasharray: interval == null ? void 0 : `${interval} ${264 - interval}`,
60
+ transitionProperty: "stroke-dasharray, stroke",
61
+ transitionDuration: "0.6s",
62
+ transitionTimingFunction: "ease"
63
+ };
64
+ return /* @__PURE__ */ jsxs(ui.div, { ref, className: cx("ui-circle-progress", className), __css: css, ...rest, children: [
65
+ /* @__PURE__ */ jsxs(Shape, { size, isAnimation, speed, children: [
66
+ /* @__PURE__ */ jsx(Circle, { stroke: trackColor, strokeWidth: thickness }),
67
+ /* @__PURE__ */ jsx(
68
+ Circle,
69
+ {
70
+ stroke: color,
71
+ strokeWidth: thickness,
72
+ strokeLinecap: isRounded ? "round" : void 0,
73
+ opacity: isTransparent ? 0 : void 0,
74
+ ...props
75
+ }
76
+ )
77
+ ] }),
78
+ children
79
+ ] });
80
+ }
81
+ );
82
+ var Circle = (rest) => /* @__PURE__ */ jsx(ui.circle, { cx: 50, cy: 50, r: 42, fill: "transparent", ...rest });
83
+ var Shape = ({ size, isAnimation, speed, ...rest }) => {
84
+ const animation = useAnimation({
85
+ keyframes: {
86
+ "0%": {
87
+ transform: "rotate(0deg)"
88
+ },
89
+ "100%": {
90
+ transform: "rotate(360deg)"
91
+ }
92
+ },
93
+ duration: typeof speed[1] === "string" ? speed[1] : `${speed[1]}s`,
94
+ iterationCount: "infinite",
95
+ timingFunction: "linear"
96
+ });
97
+ const css = {
98
+ display: "block",
99
+ boxSize: size,
100
+ ...isAnimation ? { animation } : {}
101
+ };
102
+ return /* @__PURE__ */ jsx(ui.svg, { viewBox: "0 0 100 100", __css: css, ...rest });
103
+ };
104
+ var CircleProgressLabel = ui("span", {
105
+ baseStyle: {
106
+ position: "absolute",
107
+ top: "50%",
108
+ left: "50%",
109
+ transform: "translate(-50%, -50%)",
110
+ width: "100%",
111
+ fontSize: "0.25em",
112
+ textAlign: "center"
113
+ }
114
+ });
115
+
116
+ export {
117
+ CircleProgress,
118
+ CircleProgressLabel
119
+ };
@@ -0,0 +1,118 @@
1
+ // src/progress.tsx
2
+ import {
3
+ ui,
4
+ forwardRef,
5
+ useMultiComponentStyle,
6
+ omitThemeProps
7
+ } from "@yamada-ui/core";
8
+ import { useAnimation } from "@yamada-ui/use-animation";
9
+ import { createContext, cx, valueToPercent } from "@yamada-ui/utils";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ var [ProgressProvider, useProgress] = createContext({
12
+ name: `ProgressStylesContext`,
13
+ errorMessage: `useProgress returned is 'undefined'. Seems you forgot to wrap the components in "<Progress />" `
14
+ });
15
+ var Progress = forwardRef((props, ref) => {
16
+ var _a;
17
+ const [styles, mergedProps] = useMultiComponentStyle("Progress", props);
18
+ const {
19
+ className,
20
+ children,
21
+ value,
22
+ min,
23
+ max,
24
+ hasStripe,
25
+ isStripeAnimation,
26
+ isAnimation,
27
+ speed,
28
+ borderRadius: _borderRadius,
29
+ rounded,
30
+ ...rest
31
+ } = omitThemeProps(mergedProps);
32
+ const borderRadius = (_a = _borderRadius != null ? _borderRadius : rounded) != null ? _a : styles.track.borderRadius;
33
+ const css = {
34
+ w: "100%",
35
+ overflow: "hidden",
36
+ pos: "relative",
37
+ ...styles.track
38
+ };
39
+ return /* @__PURE__ */ jsx(ProgressProvider, { value: styles, children: /* @__PURE__ */ jsxs(
40
+ ui.div,
41
+ {
42
+ ref,
43
+ className: cx("ui-progress", className),
44
+ __css: css,
45
+ borderRadius,
46
+ ...rest,
47
+ children: [
48
+ /* @__PURE__ */ jsx(
49
+ ProgressFilledTrack,
50
+ {
51
+ min,
52
+ max,
53
+ value,
54
+ hasStripe,
55
+ isStripeAnimation,
56
+ isAnimation,
57
+ speed,
58
+ borderRadius
59
+ }
60
+ ),
61
+ children
62
+ ]
63
+ }
64
+ ) });
65
+ });
66
+ var ProgressFilledTrack = ({
67
+ value = 0,
68
+ min = 0,
69
+ max = 100,
70
+ hasStripe,
71
+ isStripeAnimation,
72
+ isAnimation,
73
+ speed = "1.4s",
74
+ ...rest
75
+ }) => {
76
+ const percent = valueToPercent(value, min, max);
77
+ const styles = useProgress();
78
+ const stripeAnimation = useAnimation({
79
+ keyframes: {
80
+ "0%": { bgPosition: "1rem 0" },
81
+ "100%": { bgPosition: "0 0" }
82
+ },
83
+ duration: typeof speed === "string" ? speed : `${speed}s`,
84
+ iterationCount: "infinite",
85
+ timingFunction: "linear"
86
+ });
87
+ const interpolationAnimation = useAnimation({
88
+ keyframes: {
89
+ "0%": { left: "-40%" },
90
+ "100%": { left: "100%" }
91
+ },
92
+ duration: typeof speed === "string" ? speed : `${speed}s`,
93
+ iterationCount: "infinite",
94
+ timingFunction: "ease"
95
+ });
96
+ isStripeAnimation = !isAnimation && hasStripe && isStripeAnimation;
97
+ const css = {
98
+ ...isStripeAnimation ? {
99
+ animation: stripeAnimation
100
+ } : {},
101
+ ...isAnimation ? {
102
+ position: "absolute",
103
+ willChange: "left",
104
+ minWidth: "50%",
105
+ animation: interpolationAnimation
106
+ } : {}
107
+ };
108
+ const __css = {
109
+ w: `${percent}%`,
110
+ h: "100%",
111
+ ...styles.filledTrack
112
+ };
113
+ return /* @__PURE__ */ jsx(ui.div, { css, __css, ...rest });
114
+ };
115
+
116
+ export {
117
+ Progress
118
+ };
@@ -0,0 +1,20 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, CSSUIProps } from '@yamada-ui/core';
3
+
4
+ type CircleProgressOptions = {
5
+ size?: CSSUIProps['boxSize'];
6
+ thickness?: CSSUIProps['width'];
7
+ color?: CSSUIProps['color'];
8
+ trackColor?: CSSUIProps['color'];
9
+ value?: number;
10
+ min?: number;
11
+ max?: number;
12
+ isRounded?: boolean;
13
+ isAnimation?: boolean;
14
+ speed?: [string | number, string | number];
15
+ };
16
+ type CircleProgressProps = Omit<HTMLUIProps<'div'>, 'color'> & CircleProgressOptions;
17
+ declare const CircleProgress: _yamada_ui_core.Component<"div", CircleProgressProps>;
18
+ declare const CircleProgressLabel: _yamada_ui_core.UIComponent<"span", {}>;
19
+
20
+ export { CircleProgress, CircleProgressLabel, CircleProgressProps };
@@ -0,0 +1,144 @@
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/circle-progress.tsx
21
+ var circle_progress_exports = {};
22
+ __export(circle_progress_exports, {
23
+ CircleProgress: () => CircleProgress,
24
+ CircleProgressLabel: () => CircleProgressLabel
25
+ });
26
+ module.exports = __toCommonJS(circle_progress_exports);
27
+ var import_core = require("@yamada-ui/core");
28
+ var import_use_animation = require("@yamada-ui/use-animation");
29
+ var import_use_token = require("@yamada-ui/use-token");
30
+ var import_use_value = require("@yamada-ui/use-value");
31
+ var import_utils = require("@yamada-ui/utils");
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var CircleProgress = (0, import_core.forwardRef)(
34
+ ({
35
+ className,
36
+ children,
37
+ size = "6rem",
38
+ thickness = "0.625rem",
39
+ color = "primary",
40
+ trackColor = "border",
41
+ value = 0,
42
+ min = 0,
43
+ max = 100,
44
+ isAnimation = false,
45
+ isRounded,
46
+ speed = ["1.4s", "2s"],
47
+ ...rest
48
+ }, ref) => {
49
+ var _a, _b;
50
+ size = (_a = (0, import_use_token.useToken)("sizes", (0, import_use_value.useValue)(size))) != null ? _a : size;
51
+ thickness = (_b = (0, import_use_token.useToken)("sizes", (0, import_use_value.useValue)(thickness))) != null ? _b : thickness;
52
+ const isTransparent = value === 0 && !isAnimation;
53
+ const percent = (0, import_utils.valueToPercent)(value, min, max);
54
+ const interval = !isAnimation ? percent * 2.64 : void 0;
55
+ const animation = (0, import_use_animation.useAnimation)({
56
+ keyframes: {
57
+ "0%": {
58
+ strokeDasharray: "1, 400",
59
+ strokeDashoffset: "0"
60
+ },
61
+ "50%": {
62
+ strokeDasharray: "400, 400",
63
+ strokeDashoffset: "-100"
64
+ },
65
+ "100%": {
66
+ strokeDasharray: "400, 400",
67
+ strokeDashoffset: "-260"
68
+ }
69
+ },
70
+ duration: typeof speed[0] === "string" ? speed[0] : `${speed[0]}s`,
71
+ iterationCount: "infinite",
72
+ timingFunction: "linear"
73
+ });
74
+ const css = {
75
+ display: "inline-block",
76
+ position: "relative",
77
+ verticalAlign: "middle",
78
+ fontSize: size
79
+ };
80
+ const props = isAnimation ? {
81
+ animation
82
+ } : {
83
+ strokeDashoffset: 66,
84
+ strokeDasharray: interval == null ? void 0 : `${interval} ${264 - interval}`,
85
+ transitionProperty: "stroke-dasharray, stroke",
86
+ transitionDuration: "0.6s",
87
+ transitionTimingFunction: "ease"
88
+ };
89
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-circle-progress", className), __css: css, ...rest, children: [
90
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Shape, { size, isAnimation, speed, children: [
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Circle, { stroke: trackColor, strokeWidth: thickness }),
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
+ Circle,
94
+ {
95
+ stroke: color,
96
+ strokeWidth: thickness,
97
+ strokeLinecap: isRounded ? "round" : void 0,
98
+ opacity: isTransparent ? 0 : void 0,
99
+ ...props
100
+ }
101
+ )
102
+ ] }),
103
+ children
104
+ ] });
105
+ }
106
+ );
107
+ var Circle = (rest) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.circle, { cx: 50, cy: 50, r: 42, fill: "transparent", ...rest });
108
+ var Shape = ({ size, isAnimation, speed, ...rest }) => {
109
+ const animation = (0, import_use_animation.useAnimation)({
110
+ keyframes: {
111
+ "0%": {
112
+ transform: "rotate(0deg)"
113
+ },
114
+ "100%": {
115
+ transform: "rotate(360deg)"
116
+ }
117
+ },
118
+ duration: typeof speed[1] === "string" ? speed[1] : `${speed[1]}s`,
119
+ iterationCount: "infinite",
120
+ timingFunction: "linear"
121
+ });
122
+ const css = {
123
+ display: "block",
124
+ boxSize: size,
125
+ ...isAnimation ? { animation } : {}
126
+ };
127
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.svg, { viewBox: "0 0 100 100", __css: css, ...rest });
128
+ };
129
+ var CircleProgressLabel = (0, import_core.ui)("span", {
130
+ baseStyle: {
131
+ position: "absolute",
132
+ top: "50%",
133
+ left: "50%",
134
+ transform: "translate(-50%, -50%)",
135
+ width: "100%",
136
+ fontSize: "0.25em",
137
+ textAlign: "center"
138
+ }
139
+ });
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ CircleProgress,
143
+ CircleProgressLabel
144
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ CircleProgress,
3
+ CircleProgressLabel
4
+ } from "./chunk-ENCTHIX3.mjs";
5
+ export {
6
+ CircleProgress,
7
+ CircleProgressLabel
8
+ };
@@ -0,0 +1,3 @@
1
+ export { Progress, ProgressProps } from './progress.js';
2
+ export { CircleProgress, CircleProgressLabel, CircleProgressProps } from './circle-progress.js';
3
+ import '@yamada-ui/core';
package/dist/index.js ADDED
@@ -0,0 +1,258 @@
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
+ CircleProgress: () => CircleProgress,
24
+ CircleProgressLabel: () => CircleProgressLabel,
25
+ Progress: () => Progress
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/progress.tsx
30
+ var import_core = require("@yamada-ui/core");
31
+ var import_use_animation = require("@yamada-ui/use-animation");
32
+ var import_utils = require("@yamada-ui/utils");
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var [ProgressProvider, useProgress] = (0, import_utils.createContext)({
35
+ name: `ProgressStylesContext`,
36
+ errorMessage: `useProgress returned is 'undefined'. Seems you forgot to wrap the components in "<Progress />" `
37
+ });
38
+ var Progress = (0, import_core.forwardRef)((props, ref) => {
39
+ var _a;
40
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Progress", props);
41
+ const {
42
+ className,
43
+ children,
44
+ value,
45
+ min,
46
+ max,
47
+ hasStripe,
48
+ isStripeAnimation,
49
+ isAnimation,
50
+ speed,
51
+ borderRadius: _borderRadius,
52
+ rounded,
53
+ ...rest
54
+ } = (0, import_core.omitThemeProps)(mergedProps);
55
+ const borderRadius = (_a = _borderRadius != null ? _borderRadius : rounded) != null ? _a : styles.track.borderRadius;
56
+ const css = {
57
+ w: "100%",
58
+ overflow: "hidden",
59
+ pos: "relative",
60
+ ...styles.track
61
+ };
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
63
+ import_core.ui.div,
64
+ {
65
+ ref,
66
+ className: (0, import_utils.cx)("ui-progress", className),
67
+ __css: css,
68
+ borderRadius,
69
+ ...rest,
70
+ children: [
71
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
72
+ ProgressFilledTrack,
73
+ {
74
+ min,
75
+ max,
76
+ value,
77
+ hasStripe,
78
+ isStripeAnimation,
79
+ isAnimation,
80
+ speed,
81
+ borderRadius
82
+ }
83
+ ),
84
+ children
85
+ ]
86
+ }
87
+ ) });
88
+ });
89
+ var ProgressFilledTrack = ({
90
+ value = 0,
91
+ min = 0,
92
+ max = 100,
93
+ hasStripe,
94
+ isStripeAnimation,
95
+ isAnimation,
96
+ speed = "1.4s",
97
+ ...rest
98
+ }) => {
99
+ const percent = (0, import_utils.valueToPercent)(value, min, max);
100
+ const styles = useProgress();
101
+ const stripeAnimation = (0, import_use_animation.useAnimation)({
102
+ keyframes: {
103
+ "0%": { bgPosition: "1rem 0" },
104
+ "100%": { bgPosition: "0 0" }
105
+ },
106
+ duration: typeof speed === "string" ? speed : `${speed}s`,
107
+ iterationCount: "infinite",
108
+ timingFunction: "linear"
109
+ });
110
+ const interpolationAnimation = (0, import_use_animation.useAnimation)({
111
+ keyframes: {
112
+ "0%": { left: "-40%" },
113
+ "100%": { left: "100%" }
114
+ },
115
+ duration: typeof speed === "string" ? speed : `${speed}s`,
116
+ iterationCount: "infinite",
117
+ timingFunction: "ease"
118
+ });
119
+ isStripeAnimation = !isAnimation && hasStripe && isStripeAnimation;
120
+ const css = {
121
+ ...isStripeAnimation ? {
122
+ animation: stripeAnimation
123
+ } : {},
124
+ ...isAnimation ? {
125
+ position: "absolute",
126
+ willChange: "left",
127
+ minWidth: "50%",
128
+ animation: interpolationAnimation
129
+ } : {}
130
+ };
131
+ const __css = {
132
+ w: `${percent}%`,
133
+ h: "100%",
134
+ ...styles.filledTrack
135
+ };
136
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { css, __css, ...rest });
137
+ };
138
+
139
+ // src/circle-progress.tsx
140
+ var import_core2 = require("@yamada-ui/core");
141
+ var import_use_animation2 = require("@yamada-ui/use-animation");
142
+ var import_use_token = require("@yamada-ui/use-token");
143
+ var import_use_value = require("@yamada-ui/use-value");
144
+ var import_utils2 = require("@yamada-ui/utils");
145
+ var import_jsx_runtime2 = require("react/jsx-runtime");
146
+ var CircleProgress = (0, import_core2.forwardRef)(
147
+ ({
148
+ className,
149
+ children,
150
+ size = "6rem",
151
+ thickness = "0.625rem",
152
+ color = "primary",
153
+ trackColor = "border",
154
+ value = 0,
155
+ min = 0,
156
+ max = 100,
157
+ isAnimation = false,
158
+ isRounded,
159
+ speed = ["1.4s", "2s"],
160
+ ...rest
161
+ }, ref) => {
162
+ var _a, _b;
163
+ size = (_a = (0, import_use_token.useToken)("sizes", (0, import_use_value.useValue)(size))) != null ? _a : size;
164
+ thickness = (_b = (0, import_use_token.useToken)("sizes", (0, import_use_value.useValue)(thickness))) != null ? _b : thickness;
165
+ const isTransparent = value === 0 && !isAnimation;
166
+ const percent = (0, import_utils2.valueToPercent)(value, min, max);
167
+ const interval = !isAnimation ? percent * 2.64 : void 0;
168
+ const animation = (0, import_use_animation2.useAnimation)({
169
+ keyframes: {
170
+ "0%": {
171
+ strokeDasharray: "1, 400",
172
+ strokeDashoffset: "0"
173
+ },
174
+ "50%": {
175
+ strokeDasharray: "400, 400",
176
+ strokeDashoffset: "-100"
177
+ },
178
+ "100%": {
179
+ strokeDasharray: "400, 400",
180
+ strokeDashoffset: "-260"
181
+ }
182
+ },
183
+ duration: typeof speed[0] === "string" ? speed[0] : `${speed[0]}s`,
184
+ iterationCount: "infinite",
185
+ timingFunction: "linear"
186
+ });
187
+ const css = {
188
+ display: "inline-block",
189
+ position: "relative",
190
+ verticalAlign: "middle",
191
+ fontSize: size
192
+ };
193
+ const props = isAnimation ? {
194
+ animation
195
+ } : {
196
+ strokeDashoffset: 66,
197
+ strokeDasharray: interval == null ? void 0 : `${interval} ${264 - interval}`,
198
+ transitionProperty: "stroke-dasharray, stroke",
199
+ transitionDuration: "0.6s",
200
+ transitionTimingFunction: "ease"
201
+ };
202
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-circle-progress", className), __css: css, ...rest, children: [
203
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Shape, { size, isAnimation, speed, children: [
204
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Circle, { stroke: trackColor, strokeWidth: thickness }),
205
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
206
+ Circle,
207
+ {
208
+ stroke: color,
209
+ strokeWidth: thickness,
210
+ strokeLinecap: isRounded ? "round" : void 0,
211
+ opacity: isTransparent ? 0 : void 0,
212
+ ...props
213
+ }
214
+ )
215
+ ] }),
216
+ children
217
+ ] });
218
+ }
219
+ );
220
+ var Circle = (rest) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.circle, { cx: 50, cy: 50, r: 42, fill: "transparent", ...rest });
221
+ var Shape = ({ size, isAnimation, speed, ...rest }) => {
222
+ const animation = (0, import_use_animation2.useAnimation)({
223
+ keyframes: {
224
+ "0%": {
225
+ transform: "rotate(0deg)"
226
+ },
227
+ "100%": {
228
+ transform: "rotate(360deg)"
229
+ }
230
+ },
231
+ duration: typeof speed[1] === "string" ? speed[1] : `${speed[1]}s`,
232
+ iterationCount: "infinite",
233
+ timingFunction: "linear"
234
+ });
235
+ const css = {
236
+ display: "block",
237
+ boxSize: size,
238
+ ...isAnimation ? { animation } : {}
239
+ };
240
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.svg, { viewBox: "0 0 100 100", __css: css, ...rest });
241
+ };
242
+ var CircleProgressLabel = (0, import_core2.ui)("span", {
243
+ baseStyle: {
244
+ position: "absolute",
245
+ top: "50%",
246
+ left: "50%",
247
+ transform: "translate(-50%, -50%)",
248
+ width: "100%",
249
+ fontSize: "0.25em",
250
+ textAlign: "center"
251
+ }
252
+ });
253
+ // Annotate the CommonJS export names for ESM import in node:
254
+ 0 && (module.exports = {
255
+ CircleProgress,
256
+ CircleProgressLabel,
257
+ Progress
258
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ import {
2
+ CircleProgress,
3
+ CircleProgressLabel
4
+ } from "./chunk-ENCTHIX3.mjs";
5
+ import {
6
+ Progress
7
+ } from "./chunk-RBJMSLYD.mjs";
8
+ export {
9
+ CircleProgress,
10
+ CircleProgressLabel,
11
+ Progress
12
+ };
@@ -0,0 +1,16 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, ThemeProps } from '@yamada-ui/core';
3
+
4
+ type ProgressOptions = {
5
+ value?: number;
6
+ min?: number;
7
+ max?: number;
8
+ hasStripe?: boolean;
9
+ isStripeAnimation?: boolean;
10
+ isAnimation?: boolean;
11
+ speed?: string | number;
12
+ };
13
+ type ProgressProps = HTMLUIProps<'div'> & ThemeProps<'Progress'> & ProgressOptions;
14
+ declare const Progress: _yamada_ui_core.Component<"div", ProgressProps>;
15
+
16
+ export { Progress, ProgressProps };
@@ -0,0 +1,137 @@
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/progress.tsx
21
+ var progress_exports = {};
22
+ __export(progress_exports, {
23
+ Progress: () => Progress
24
+ });
25
+ module.exports = __toCommonJS(progress_exports);
26
+ var import_core = require("@yamada-ui/core");
27
+ var import_use_animation = require("@yamada-ui/use-animation");
28
+ var import_utils = require("@yamada-ui/utils");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var [ProgressProvider, useProgress] = (0, import_utils.createContext)({
31
+ name: `ProgressStylesContext`,
32
+ errorMessage: `useProgress returned is 'undefined'. Seems you forgot to wrap the components in "<Progress />" `
33
+ });
34
+ var Progress = (0, import_core.forwardRef)((props, ref) => {
35
+ var _a;
36
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Progress", props);
37
+ const {
38
+ className,
39
+ children,
40
+ value,
41
+ min,
42
+ max,
43
+ hasStripe,
44
+ isStripeAnimation,
45
+ isAnimation,
46
+ speed,
47
+ borderRadius: _borderRadius,
48
+ rounded,
49
+ ...rest
50
+ } = (0, import_core.omitThemeProps)(mergedProps);
51
+ const borderRadius = (_a = _borderRadius != null ? _borderRadius : rounded) != null ? _a : styles.track.borderRadius;
52
+ const css = {
53
+ w: "100%",
54
+ overflow: "hidden",
55
+ pos: "relative",
56
+ ...styles.track
57
+ };
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
59
+ import_core.ui.div,
60
+ {
61
+ ref,
62
+ className: (0, import_utils.cx)("ui-progress", className),
63
+ __css: css,
64
+ borderRadius,
65
+ ...rest,
66
+ children: [
67
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
+ ProgressFilledTrack,
69
+ {
70
+ min,
71
+ max,
72
+ value,
73
+ hasStripe,
74
+ isStripeAnimation,
75
+ isAnimation,
76
+ speed,
77
+ borderRadius
78
+ }
79
+ ),
80
+ children
81
+ ]
82
+ }
83
+ ) });
84
+ });
85
+ var ProgressFilledTrack = ({
86
+ value = 0,
87
+ min = 0,
88
+ max = 100,
89
+ hasStripe,
90
+ isStripeAnimation,
91
+ isAnimation,
92
+ speed = "1.4s",
93
+ ...rest
94
+ }) => {
95
+ const percent = (0, import_utils.valueToPercent)(value, min, max);
96
+ const styles = useProgress();
97
+ const stripeAnimation = (0, import_use_animation.useAnimation)({
98
+ keyframes: {
99
+ "0%": { bgPosition: "1rem 0" },
100
+ "100%": { bgPosition: "0 0" }
101
+ },
102
+ duration: typeof speed === "string" ? speed : `${speed}s`,
103
+ iterationCount: "infinite",
104
+ timingFunction: "linear"
105
+ });
106
+ const interpolationAnimation = (0, import_use_animation.useAnimation)({
107
+ keyframes: {
108
+ "0%": { left: "-40%" },
109
+ "100%": { left: "100%" }
110
+ },
111
+ duration: typeof speed === "string" ? speed : `${speed}s`,
112
+ iterationCount: "infinite",
113
+ timingFunction: "ease"
114
+ });
115
+ isStripeAnimation = !isAnimation && hasStripe && isStripeAnimation;
116
+ const css = {
117
+ ...isStripeAnimation ? {
118
+ animation: stripeAnimation
119
+ } : {},
120
+ ...isAnimation ? {
121
+ position: "absolute",
122
+ willChange: "left",
123
+ minWidth: "50%",
124
+ animation: interpolationAnimation
125
+ } : {}
126
+ };
127
+ const __css = {
128
+ w: `${percent}%`,
129
+ h: "100%",
130
+ ...styles.filledTrack
131
+ };
132
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { css, __css, ...rest });
133
+ };
134
+ // Annotate the CommonJS export names for ESM import in node:
135
+ 0 && (module.exports = {
136
+ Progress
137
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ Progress
3
+ } from "./chunk-RBJMSLYD.mjs";
4
+ export {
5
+ Progress
6
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@yamada-ui/progress",
3
+ "version": "0.0.0-dev-20230603042803",
4
+ "description": "Yamada UI progress components",
5
+ "keywords": [
6
+ "yamada",
7
+ "yamada ui",
8
+ "react",
9
+ "emotion",
10
+ "component",
11
+ "progress",
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/progress"
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/utils": "0.1.0",
40
+ "@yamada-ui/use-value": "0.0.0-dev-20230603042803",
41
+ "@yamada-ui/use-token": "0.0.0-dev-20230603042803",
42
+ "@yamada-ui/use-animation": "0.0.0-dev-20230603042803"
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
+ }