@sytechui/spinner 2.2.29
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 +21 -0
- package/README.md +24 -0
- package/dist/chunk-6KA2WGF7.mjs +42 -0
- package/dist/chunk-W4MA5USS.mjs +88 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +149 -0
- package/dist/index.mjs +11 -0
- package/dist/spinner.d.mts +12 -0
- package/dist/spinner.d.ts +12 -0
- package/dist/spinner.js +143 -0
- package/dist/spinner.mjs +8 -0
- package/dist/use-spinner.d.mts +130 -0
- package/dist/use-spinner.d.ts +130 -0
- package/dist/use-spinner.js +65 -0
- package/dist/use-spinner.mjs +7 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Next UI Inc.
|
|
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,24 @@
|
|
|
1
|
+
# @sytechui/loading
|
|
2
|
+
|
|
3
|
+
Spinner express an unspecified wait time or display the length of a process.
|
|
4
|
+
|
|
5
|
+
Please refer to the [documentation](https://heroui.com/docs/components/loading) for more information.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn add @sytechui/loading
|
|
11
|
+
# or
|
|
12
|
+
npm i @sytechui/loading
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Contribution
|
|
16
|
+
|
|
17
|
+
Yes please! See the
|
|
18
|
+
[contributing guidelines](https://github.com/heroui-inc/heroui/blob/master/CONTRIBUTING.md)
|
|
19
|
+
for details.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
This project is licensed under the terms of the
|
|
24
|
+
[MIT license](https://github.com/heroui-inc/heroui/blob/master/LICENSE).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/use-spinner.ts
|
|
4
|
+
import { mapPropsVariants } from "@sytechui/system-rsc";
|
|
5
|
+
import { spinner, cn } from "@sytechui/theme";
|
|
6
|
+
import { objectToDeps } from "@sytechui/shared-utils";
|
|
7
|
+
import { useMemo, useCallback } from "react";
|
|
8
|
+
import { useProviderContext } from "@sytechui/system";
|
|
9
|
+
function useSpinner(originalProps) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const [props, variantProps] = mapPropsVariants(originalProps, spinner.variantKeys);
|
|
12
|
+
const globalContext = useProviderContext();
|
|
13
|
+
const variant = (_b = (_a = originalProps == null ? void 0 : originalProps.variant) != null ? _a : globalContext == null ? void 0 : globalContext.spinnerVariant) != null ? _b : "default";
|
|
14
|
+
const { children, className, classNames, label: labelProp, ...otherProps } = props;
|
|
15
|
+
const slots = useMemo(
|
|
16
|
+
() => spinner({ ...variantProps, variant }),
|
|
17
|
+
[objectToDeps(variantProps), variant]
|
|
18
|
+
);
|
|
19
|
+
const baseStyles = cn(classNames == null ? void 0 : classNames.base, className);
|
|
20
|
+
const label = labelProp || children;
|
|
21
|
+
const ariaLabel = useMemo(() => {
|
|
22
|
+
if (label && typeof label === "string") {
|
|
23
|
+
return label;
|
|
24
|
+
}
|
|
25
|
+
return !otherProps["aria-label"] ? "Loading" : "";
|
|
26
|
+
}, [children, label, otherProps["aria-label"]]);
|
|
27
|
+
const getSpinnerProps = useCallback(
|
|
28
|
+
() => ({
|
|
29
|
+
"aria-label": ariaLabel,
|
|
30
|
+
className: slots.base({
|
|
31
|
+
class: baseStyles
|
|
32
|
+
}),
|
|
33
|
+
...otherProps
|
|
34
|
+
}),
|
|
35
|
+
[ariaLabel, slots, baseStyles, otherProps]
|
|
36
|
+
);
|
|
37
|
+
return { label, slots, classNames, variant, getSpinnerProps };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
useSpinner
|
|
42
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useSpinner
|
|
4
|
+
} from "./chunk-6KA2WGF7.mjs";
|
|
5
|
+
|
|
6
|
+
// src/spinner.tsx
|
|
7
|
+
import { forwardRef } from "@sytechui/system-rsc";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var Spinner = forwardRef((props, ref) => {
|
|
10
|
+
const { slots, classNames, label, variant, getSpinnerProps } = useSpinner({ ...props });
|
|
11
|
+
if (variant === "wave" || variant === "dots") {
|
|
12
|
+
return /* @__PURE__ */ jsxs("div", { ref, ...getSpinnerProps(), children: [
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [...new Array(3)].map((_, index) => /* @__PURE__ */ jsx(
|
|
14
|
+
"i",
|
|
15
|
+
{
|
|
16
|
+
className: slots.dots({ class: classNames == null ? void 0 : classNames.dots }),
|
|
17
|
+
style: {
|
|
18
|
+
"--dot-index": index
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
`dot-${index}`
|
|
22
|
+
)) }),
|
|
23
|
+
label && /* @__PURE__ */ jsx("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
if (variant === "simple") {
|
|
27
|
+
return /* @__PURE__ */ jsxs("div", { ref, ...getSpinnerProps(), children: [
|
|
28
|
+
/* @__PURE__ */ jsxs(
|
|
29
|
+
"svg",
|
|
30
|
+
{
|
|
31
|
+
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
|
|
32
|
+
fill: "none",
|
|
33
|
+
viewBox: "0 0 24 24",
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
"circle",
|
|
37
|
+
{
|
|
38
|
+
className: slots.circle1({ class: classNames == null ? void 0 : classNames.circle1 }),
|
|
39
|
+
cx: "12",
|
|
40
|
+
cy: "12",
|
|
41
|
+
r: "10",
|
|
42
|
+
stroke: "currentColor",
|
|
43
|
+
strokeWidth: "4"
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
"path",
|
|
48
|
+
{
|
|
49
|
+
className: slots.circle2({ class: classNames == null ? void 0 : classNames.circle2 }),
|
|
50
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",
|
|
51
|
+
fill: "currentColor"
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
label && /* @__PURE__ */ jsx("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
58
|
+
] });
|
|
59
|
+
}
|
|
60
|
+
if (variant === "spinner") {
|
|
61
|
+
return /* @__PURE__ */ jsxs("div", { ref, ...getSpinnerProps(), children: [
|
|
62
|
+
/* @__PURE__ */ jsx("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [...new Array(12)].map((_, index) => /* @__PURE__ */ jsx(
|
|
63
|
+
"i",
|
|
64
|
+
{
|
|
65
|
+
className: slots.spinnerBars({ class: classNames == null ? void 0 : classNames.spinnerBars }),
|
|
66
|
+
style: {
|
|
67
|
+
"--bar-index": index
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
`star-${index}`
|
|
71
|
+
)) }),
|
|
72
|
+
label && /* @__PURE__ */ jsx("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", { ref, ...getSpinnerProps(), children: [
|
|
76
|
+
/* @__PURE__ */ jsxs("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [
|
|
77
|
+
/* @__PURE__ */ jsx("i", { className: slots.circle1({ class: classNames == null ? void 0 : classNames.circle1 }) }),
|
|
78
|
+
/* @__PURE__ */ jsx("i", { className: slots.circle2({ class: classNames == null ? void 0 : classNames.circle2 }) })
|
|
79
|
+
] }),
|
|
80
|
+
label && /* @__PURE__ */ jsx("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
81
|
+
] });
|
|
82
|
+
});
|
|
83
|
+
Spinner.displayName = "HeroUI.Spinner";
|
|
84
|
+
var spinner_default = Spinner;
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
spinner_default
|
|
88
|
+
};
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
Spinner: () => spinner_default,
|
|
25
|
+
useSpinner: () => useSpinner
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/use-spinner.ts
|
|
30
|
+
var import_system_rsc = require("@sytechui/system-rsc");
|
|
31
|
+
var import_theme = require("@sytechui/theme");
|
|
32
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
var import_system = require("@sytechui/system");
|
|
35
|
+
function useSpinner(originalProps) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const [props, variantProps] = (0, import_system_rsc.mapPropsVariants)(originalProps, import_theme.spinner.variantKeys);
|
|
38
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
39
|
+
const variant = (_b = (_a = originalProps == null ? void 0 : originalProps.variant) != null ? _a : globalContext == null ? void 0 : globalContext.spinnerVariant) != null ? _b : "default";
|
|
40
|
+
const { children, className, classNames, label: labelProp, ...otherProps } = props;
|
|
41
|
+
const slots = (0, import_react.useMemo)(
|
|
42
|
+
() => (0, import_theme.spinner)({ ...variantProps, variant }),
|
|
43
|
+
[(0, import_shared_utils.objectToDeps)(variantProps), variant]
|
|
44
|
+
);
|
|
45
|
+
const baseStyles = (0, import_theme.cn)(classNames == null ? void 0 : classNames.base, className);
|
|
46
|
+
const label = labelProp || children;
|
|
47
|
+
const ariaLabel = (0, import_react.useMemo)(() => {
|
|
48
|
+
if (label && typeof label === "string") {
|
|
49
|
+
return label;
|
|
50
|
+
}
|
|
51
|
+
return !otherProps["aria-label"] ? "Loading" : "";
|
|
52
|
+
}, [children, label, otherProps["aria-label"]]);
|
|
53
|
+
const getSpinnerProps = (0, import_react.useCallback)(
|
|
54
|
+
() => ({
|
|
55
|
+
"aria-label": ariaLabel,
|
|
56
|
+
className: slots.base({
|
|
57
|
+
class: baseStyles
|
|
58
|
+
}),
|
|
59
|
+
...otherProps
|
|
60
|
+
}),
|
|
61
|
+
[ariaLabel, slots, baseStyles, otherProps]
|
|
62
|
+
);
|
|
63
|
+
return { label, slots, classNames, variant, getSpinnerProps };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/spinner.tsx
|
|
67
|
+
var import_system_rsc2 = require("@sytechui/system-rsc");
|
|
68
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
|
+
var Spinner = (0, import_system_rsc2.forwardRef)((props, ref) => {
|
|
70
|
+
const { slots, classNames, label, variant, getSpinnerProps } = useSpinner({ ...props });
|
|
71
|
+
if (variant === "wave" || variant === "dots") {
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [...new Array(3)].map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
"i",
|
|
75
|
+
{
|
|
76
|
+
className: slots.dots({ class: classNames == null ? void 0 : classNames.dots }),
|
|
77
|
+
style: {
|
|
78
|
+
"--dot-index": index
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
`dot-${index}`
|
|
82
|
+
)) }),
|
|
83
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
84
|
+
] });
|
|
85
|
+
}
|
|
86
|
+
if (variant === "simple") {
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
89
|
+
"svg",
|
|
90
|
+
{
|
|
91
|
+
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
|
|
92
|
+
fill: "none",
|
|
93
|
+
viewBox: "0 0 24 24",
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
+
"circle",
|
|
97
|
+
{
|
|
98
|
+
className: slots.circle1({ class: classNames == null ? void 0 : classNames.circle1 }),
|
|
99
|
+
cx: "12",
|
|
100
|
+
cy: "12",
|
|
101
|
+
r: "10",
|
|
102
|
+
stroke: "currentColor",
|
|
103
|
+
strokeWidth: "4"
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
107
|
+
"path",
|
|
108
|
+
{
|
|
109
|
+
className: slots.circle2({ class: classNames == null ? void 0 : classNames.circle2 }),
|
|
110
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",
|
|
111
|
+
fill: "currentColor"
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
if (variant === "spinner") {
|
|
121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [...new Array(12)].map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
123
|
+
"i",
|
|
124
|
+
{
|
|
125
|
+
className: slots.spinnerBars({ class: classNames == null ? void 0 : classNames.spinnerBars }),
|
|
126
|
+
style: {
|
|
127
|
+
"--bar-index": index
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
`star-${index}`
|
|
131
|
+
)) }),
|
|
132
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: slots.circle1({ class: classNames == null ? void 0 : classNames.circle1 }) }),
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: slots.circle2({ class: classNames == null ? void 0 : classNames.circle2 }) })
|
|
139
|
+
] }),
|
|
140
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
141
|
+
] });
|
|
142
|
+
});
|
|
143
|
+
Spinner.displayName = "HeroUI.Spinner";
|
|
144
|
+
var spinner_default = Spinner;
|
|
145
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
146
|
+
0 && (module.exports = {
|
|
147
|
+
Spinner,
|
|
148
|
+
useSpinner
|
|
149
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as _sytechui_system_rsc from '@sytechui/system-rsc';
|
|
2
|
+
import { UseSpinnerProps } from './use-spinner.mjs';
|
|
3
|
+
import '@sytechui/system/src/types';
|
|
4
|
+
import 'tailwind-variants';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@sytechui/theme';
|
|
7
|
+
|
|
8
|
+
interface SpinnerProps extends UseSpinnerProps {
|
|
9
|
+
}
|
|
10
|
+
declare const Spinner: _sytechui_system_rsc.InternalForwardRefRenderFunction<"div", SpinnerProps, never>;
|
|
11
|
+
|
|
12
|
+
export { type SpinnerProps, Spinner as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as _sytechui_system_rsc from '@sytechui/system-rsc';
|
|
2
|
+
import { UseSpinnerProps } from './use-spinner.js';
|
|
3
|
+
import '@sytechui/system/src/types';
|
|
4
|
+
import 'tailwind-variants';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@sytechui/theme';
|
|
7
|
+
|
|
8
|
+
interface SpinnerProps extends UseSpinnerProps {
|
|
9
|
+
}
|
|
10
|
+
declare const Spinner: _sytechui_system_rsc.InternalForwardRefRenderFunction<"div", SpinnerProps, never>;
|
|
11
|
+
|
|
12
|
+
export { type SpinnerProps, Spinner as default };
|
package/dist/spinner.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/spinner.tsx
|
|
22
|
+
var spinner_exports = {};
|
|
23
|
+
__export(spinner_exports, {
|
|
24
|
+
default: () => spinner_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(spinner_exports);
|
|
27
|
+
var import_system_rsc2 = require("@sytechui/system-rsc");
|
|
28
|
+
|
|
29
|
+
// src/use-spinner.ts
|
|
30
|
+
var import_system_rsc = require("@sytechui/system-rsc");
|
|
31
|
+
var import_theme = require("@sytechui/theme");
|
|
32
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
var import_system = require("@sytechui/system");
|
|
35
|
+
function useSpinner(originalProps) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const [props, variantProps] = (0, import_system_rsc.mapPropsVariants)(originalProps, import_theme.spinner.variantKeys);
|
|
38
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
39
|
+
const variant = (_b = (_a = originalProps == null ? void 0 : originalProps.variant) != null ? _a : globalContext == null ? void 0 : globalContext.spinnerVariant) != null ? _b : "default";
|
|
40
|
+
const { children, className, classNames, label: labelProp, ...otherProps } = props;
|
|
41
|
+
const slots = (0, import_react.useMemo)(
|
|
42
|
+
() => (0, import_theme.spinner)({ ...variantProps, variant }),
|
|
43
|
+
[(0, import_shared_utils.objectToDeps)(variantProps), variant]
|
|
44
|
+
);
|
|
45
|
+
const baseStyles = (0, import_theme.cn)(classNames == null ? void 0 : classNames.base, className);
|
|
46
|
+
const label = labelProp || children;
|
|
47
|
+
const ariaLabel = (0, import_react.useMemo)(() => {
|
|
48
|
+
if (label && typeof label === "string") {
|
|
49
|
+
return label;
|
|
50
|
+
}
|
|
51
|
+
return !otherProps["aria-label"] ? "Loading" : "";
|
|
52
|
+
}, [children, label, otherProps["aria-label"]]);
|
|
53
|
+
const getSpinnerProps = (0, import_react.useCallback)(
|
|
54
|
+
() => ({
|
|
55
|
+
"aria-label": ariaLabel,
|
|
56
|
+
className: slots.base({
|
|
57
|
+
class: baseStyles
|
|
58
|
+
}),
|
|
59
|
+
...otherProps
|
|
60
|
+
}),
|
|
61
|
+
[ariaLabel, slots, baseStyles, otherProps]
|
|
62
|
+
);
|
|
63
|
+
return { label, slots, classNames, variant, getSpinnerProps };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/spinner.tsx
|
|
67
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
68
|
+
var Spinner = (0, import_system_rsc2.forwardRef)((props, ref) => {
|
|
69
|
+
const { slots, classNames, label, variant, getSpinnerProps } = useSpinner({ ...props });
|
|
70
|
+
if (variant === "wave" || variant === "dots") {
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [...new Array(3)].map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
73
|
+
"i",
|
|
74
|
+
{
|
|
75
|
+
className: slots.dots({ class: classNames == null ? void 0 : classNames.dots }),
|
|
76
|
+
style: {
|
|
77
|
+
"--dot-index": index
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
`dot-${index}`
|
|
81
|
+
)) }),
|
|
82
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
if (variant === "simple") {
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
88
|
+
"svg",
|
|
89
|
+
{
|
|
90
|
+
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
|
|
91
|
+
fill: "none",
|
|
92
|
+
viewBox: "0 0 24 24",
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
95
|
+
"circle",
|
|
96
|
+
{
|
|
97
|
+
className: slots.circle1({ class: classNames == null ? void 0 : classNames.circle1 }),
|
|
98
|
+
cx: "12",
|
|
99
|
+
cy: "12",
|
|
100
|
+
r: "10",
|
|
101
|
+
stroke: "currentColor",
|
|
102
|
+
strokeWidth: "4"
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
"path",
|
|
107
|
+
{
|
|
108
|
+
className: slots.circle2({ class: classNames == null ? void 0 : classNames.circle2 }),
|
|
109
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",
|
|
110
|
+
fill: "currentColor"
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
117
|
+
] });
|
|
118
|
+
}
|
|
119
|
+
if (variant === "spinner") {
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [...new Array(12)].map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
+
"i",
|
|
123
|
+
{
|
|
124
|
+
className: slots.spinnerBars({ class: classNames == null ? void 0 : classNames.spinnerBars }),
|
|
125
|
+
style: {
|
|
126
|
+
"--bar-index": index
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
`star-${index}`
|
|
130
|
+
)) }),
|
|
131
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
132
|
+
] });
|
|
133
|
+
}
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref, ...getSpinnerProps(), children: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: slots.circle1({ class: classNames == null ? void 0 : classNames.circle1 }) }),
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: slots.circle2({ class: classNames == null ? void 0 : classNames.circle2 }) })
|
|
138
|
+
] }),
|
|
139
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label })
|
|
140
|
+
] });
|
|
141
|
+
});
|
|
142
|
+
Spinner.displayName = "HeroUI.Spinner";
|
|
143
|
+
var spinner_default = Spinner;
|
package/dist/spinner.mjs
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as _sytechui_system_src_types from '@sytechui/system/src/types';
|
|
2
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { Ref } from 'react';
|
|
5
|
+
import { SlotsToClasses, SpinnerSlots, SpinnerVariantProps } from '@sytechui/theme';
|
|
6
|
+
import { HTMLHeroUIProps, PropGetter } from '@sytechui/system-rsc';
|
|
7
|
+
|
|
8
|
+
interface Props extends HTMLHeroUIProps<"div"> {
|
|
9
|
+
/**
|
|
10
|
+
* Ref to the DOM node.
|
|
11
|
+
*/
|
|
12
|
+
ref?: Ref<HTMLElement | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Spinner label, in case you passed it will be used as `aria-label`.
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Classname or List of classes to change the classNames of the element.
|
|
19
|
+
* if `className` is passed, it will be added to the base slot.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* <Spinner classNames={{
|
|
24
|
+
* base:"base-classes",
|
|
25
|
+
* wrapper: "wrapper-classes",
|
|
26
|
+
* circle1: "circle1-classes",
|
|
27
|
+
* circle2: "circle2-classes",
|
|
28
|
+
* label: "label-classes"
|
|
29
|
+
* }} />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
classNames?: SlotsToClasses<SpinnerSlots>;
|
|
33
|
+
}
|
|
34
|
+
type UseSpinnerProps = Props & SpinnerVariantProps;
|
|
35
|
+
declare function useSpinner(originalProps: UseSpinnerProps): {
|
|
36
|
+
label: react.ReactNode;
|
|
37
|
+
slots: {
|
|
38
|
+
base: (slotProps?: ({
|
|
39
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
40
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
41
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
42
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
43
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
44
|
+
wrapper: (slotProps?: ({
|
|
45
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
46
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
47
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
48
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
49
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
50
|
+
label: (slotProps?: ({
|
|
51
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
52
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
53
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
54
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
55
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
56
|
+
circle1: (slotProps?: ({
|
|
57
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
58
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
59
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
60
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
61
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
62
|
+
circle2: (slotProps?: ({
|
|
63
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
64
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
65
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
66
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
67
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
68
|
+
dots: (slotProps?: ({
|
|
69
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
70
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
71
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
72
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
73
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
74
|
+
spinnerBars: (slotProps?: ({
|
|
75
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
76
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
77
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
78
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
79
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
80
|
+
} & {
|
|
81
|
+
base: (slotProps?: ({
|
|
82
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
83
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
84
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
85
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
86
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
87
|
+
wrapper: (slotProps?: ({
|
|
88
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
89
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
90
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
91
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
92
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
93
|
+
label: (slotProps?: ({
|
|
94
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
95
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
96
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
97
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
98
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
99
|
+
circle1: (slotProps?: ({
|
|
100
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
101
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
102
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
103
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
104
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
105
|
+
circle2: (slotProps?: ({
|
|
106
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
107
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
108
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
109
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
110
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
111
|
+
dots: (slotProps?: ({
|
|
112
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
113
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
114
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
115
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
116
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
117
|
+
spinnerBars: (slotProps?: ({
|
|
118
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
119
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
120
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
121
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
122
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
123
|
+
} & {};
|
|
124
|
+
classNames: SlotsToClasses<"base" | "wrapper" | "label" | "circle1" | "circle2" | "dots" | "spinnerBars"> | undefined;
|
|
125
|
+
variant: _sytechui_system_src_types.SpinnerVariants;
|
|
126
|
+
getSpinnerProps: PropGetter;
|
|
127
|
+
};
|
|
128
|
+
type UseSpinnerReturn = ReturnType<typeof useSpinner>;
|
|
129
|
+
|
|
130
|
+
export { type UseSpinnerProps, type UseSpinnerReturn, useSpinner };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as _sytechui_system_src_types from '@sytechui/system/src/types';
|
|
2
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { Ref } from 'react';
|
|
5
|
+
import { SlotsToClasses, SpinnerSlots, SpinnerVariantProps } from '@sytechui/theme';
|
|
6
|
+
import { HTMLHeroUIProps, PropGetter } from '@sytechui/system-rsc';
|
|
7
|
+
|
|
8
|
+
interface Props extends HTMLHeroUIProps<"div"> {
|
|
9
|
+
/**
|
|
10
|
+
* Ref to the DOM node.
|
|
11
|
+
*/
|
|
12
|
+
ref?: Ref<HTMLElement | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Spinner label, in case you passed it will be used as `aria-label`.
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Classname or List of classes to change the classNames of the element.
|
|
19
|
+
* if `className` is passed, it will be added to the base slot.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* <Spinner classNames={{
|
|
24
|
+
* base:"base-classes",
|
|
25
|
+
* wrapper: "wrapper-classes",
|
|
26
|
+
* circle1: "circle1-classes",
|
|
27
|
+
* circle2: "circle2-classes",
|
|
28
|
+
* label: "label-classes"
|
|
29
|
+
* }} />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
classNames?: SlotsToClasses<SpinnerSlots>;
|
|
33
|
+
}
|
|
34
|
+
type UseSpinnerProps = Props & SpinnerVariantProps;
|
|
35
|
+
declare function useSpinner(originalProps: UseSpinnerProps): {
|
|
36
|
+
label: react.ReactNode;
|
|
37
|
+
slots: {
|
|
38
|
+
base: (slotProps?: ({
|
|
39
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
40
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
41
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
42
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
43
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
44
|
+
wrapper: (slotProps?: ({
|
|
45
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
46
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
47
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
48
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
49
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
50
|
+
label: (slotProps?: ({
|
|
51
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
52
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
53
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
54
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
55
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
56
|
+
circle1: (slotProps?: ({
|
|
57
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
58
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
59
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
60
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
61
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
62
|
+
circle2: (slotProps?: ({
|
|
63
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
64
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
65
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
66
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
67
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
68
|
+
dots: (slotProps?: ({
|
|
69
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
70
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
71
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
72
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
73
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
74
|
+
spinnerBars: (slotProps?: ({
|
|
75
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
76
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
77
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
78
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
79
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
80
|
+
} & {
|
|
81
|
+
base: (slotProps?: ({
|
|
82
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
83
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
84
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
85
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
86
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
87
|
+
wrapper: (slotProps?: ({
|
|
88
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
89
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
90
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
91
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
92
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
93
|
+
label: (slotProps?: ({
|
|
94
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
95
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
96
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
97
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
98
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
99
|
+
circle1: (slotProps?: ({
|
|
100
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
101
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
102
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
103
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
104
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
105
|
+
circle2: (slotProps?: ({
|
|
106
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
107
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
108
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
109
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
110
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
111
|
+
dots: (slotProps?: ({
|
|
112
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
113
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
114
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
115
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
116
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
117
|
+
spinnerBars: (slotProps?: ({
|
|
118
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
119
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "current" | "white" | undefined;
|
|
120
|
+
variant?: "default" | "dots" | "gradient" | "wave" | "simple" | "spinner" | undefined;
|
|
121
|
+
labelColor?: "primary" | "secondary" | "success" | "warning" | "danger" | "foreground" | undefined;
|
|
122
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
123
|
+
} & {};
|
|
124
|
+
classNames: SlotsToClasses<"base" | "wrapper" | "label" | "circle1" | "circle2" | "dots" | "spinnerBars"> | undefined;
|
|
125
|
+
variant: _sytechui_system_src_types.SpinnerVariants;
|
|
126
|
+
getSpinnerProps: PropGetter;
|
|
127
|
+
};
|
|
128
|
+
type UseSpinnerReturn = ReturnType<typeof useSpinner>;
|
|
129
|
+
|
|
130
|
+
export { type UseSpinnerProps, type UseSpinnerReturn, useSpinner };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/use-spinner.ts
|
|
22
|
+
var use_spinner_exports = {};
|
|
23
|
+
__export(use_spinner_exports, {
|
|
24
|
+
useSpinner: () => useSpinner
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(use_spinner_exports);
|
|
27
|
+
var import_system_rsc = require("@sytechui/system-rsc");
|
|
28
|
+
var import_theme = require("@sytechui/theme");
|
|
29
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_system = require("@sytechui/system");
|
|
32
|
+
function useSpinner(originalProps) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const [props, variantProps] = (0, import_system_rsc.mapPropsVariants)(originalProps, import_theme.spinner.variantKeys);
|
|
35
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
36
|
+
const variant = (_b = (_a = originalProps == null ? void 0 : originalProps.variant) != null ? _a : globalContext == null ? void 0 : globalContext.spinnerVariant) != null ? _b : "default";
|
|
37
|
+
const { children, className, classNames, label: labelProp, ...otherProps } = props;
|
|
38
|
+
const slots = (0, import_react.useMemo)(
|
|
39
|
+
() => (0, import_theme.spinner)({ ...variantProps, variant }),
|
|
40
|
+
[(0, import_shared_utils.objectToDeps)(variantProps), variant]
|
|
41
|
+
);
|
|
42
|
+
const baseStyles = (0, import_theme.cn)(classNames == null ? void 0 : classNames.base, className);
|
|
43
|
+
const label = labelProp || children;
|
|
44
|
+
const ariaLabel = (0, import_react.useMemo)(() => {
|
|
45
|
+
if (label && typeof label === "string") {
|
|
46
|
+
return label;
|
|
47
|
+
}
|
|
48
|
+
return !otherProps["aria-label"] ? "Loading" : "";
|
|
49
|
+
}, [children, label, otherProps["aria-label"]]);
|
|
50
|
+
const getSpinnerProps = (0, import_react.useCallback)(
|
|
51
|
+
() => ({
|
|
52
|
+
"aria-label": ariaLabel,
|
|
53
|
+
className: slots.base({
|
|
54
|
+
class: baseStyles
|
|
55
|
+
}),
|
|
56
|
+
...otherProps
|
|
57
|
+
}),
|
|
58
|
+
[ariaLabel, slots, baseStyles, otherProps]
|
|
59
|
+
);
|
|
60
|
+
return { label, slots, classNames, variant, getSpinnerProps };
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
useSpinner
|
|
65
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sytechui/spinner",
|
|
3
|
+
"version": "2.2.29",
|
|
4
|
+
"description": "Loaders express an unspecified wait time or display the length of a process.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"loading",
|
|
7
|
+
"spinner",
|
|
8
|
+
"progress"
|
|
9
|
+
],
|
|
10
|
+
"author": "HeroUI <support@heroui.com>",
|
|
11
|
+
"homepage": "https://heroui.com",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/heroui-inc/heroui.git",
|
|
24
|
+
"directory": "packages/components/loading"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/heroui-inc/heroui/issues"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": ">=18 || >=19.0.0-rc.0",
|
|
31
|
+
"react-dom": ">=18 || >=19.0.0-rc.0",
|
|
32
|
+
"@sytechui/theme": ">=2.4.24"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@sytechui/system-rsc": "2.3.24",
|
|
36
|
+
"@sytechui/system": "2.4.28",
|
|
37
|
+
"@sytechui/shared-utils": "2.1.12"
|
|
38
|
+
},
|
|
39
|
+
"clean-package": "../../../clean-package.config.json",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.ts",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"import": "./dist/index.mjs",
|
|
46
|
+
"require": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup src --dts",
|
|
52
|
+
"dev": "pnpm build:fast --watch",
|
|
53
|
+
"clean": "rimraf dist .turbo",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"build:fast": "tsup src"
|
|
56
|
+
}
|
|
57
|
+
}
|