@skel-ui/react 0.1.0-alpha.9764c85
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 +0 -0
- package/dist/cjs/index.js +60 -0
- package/dist/cjs/tailwind.js +47 -0
- package/dist/esm/index.js +30 -0
- package/dist/esm/tailwind.js +17 -0
- package/dist/index.d.ts +23 -0
- package/dist/styles.css +21 -0
- package/dist/tailwind.d.ts +4 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Augustin Joseph
|
|
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
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
default: () => src_default,
|
|
32
|
+
generatePlaceholder: () => generatePlaceholder
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const IsLoadingContext = import_react.default.createContext(false);
|
|
37
|
+
function Root({ as, isLoading = true, children, ...rest }) {
|
|
38
|
+
const Component = as || "div";
|
|
39
|
+
return <IsLoadingContext.Provider value={isLoading}><Component {...rest} data-loading={isLoading}>{children}</Component></IsLoadingContext.Provider>;
|
|
40
|
+
}
|
|
41
|
+
function Item({ as, color, radius, children, ...rest }) {
|
|
42
|
+
const isLoading = import_react.default.useContext(IsLoadingContext);
|
|
43
|
+
const component = as || "p";
|
|
44
|
+
const Component = typeof component === "string" ? component : isLoading ? "div" : component;
|
|
45
|
+
return <Component
|
|
46
|
+
{...rest}
|
|
47
|
+
style={{
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
...rest.style,
|
|
50
|
+
"--skel-ui-color": color,
|
|
51
|
+
"--skel-ui-radius": radius
|
|
52
|
+
}}
|
|
53
|
+
data-loading={isLoading}
|
|
54
|
+
>{isLoading ? "\u200C" : typeof children === "function" ? children() : children}</Component>;
|
|
55
|
+
}
|
|
56
|
+
function generatePlaceholder(length, primary) {
|
|
57
|
+
return Array(length).fill(null).map((_, index) => ({ [primary]: `id-${index}` }));
|
|
58
|
+
}
|
|
59
|
+
const Skel = { Root, Item };
|
|
60
|
+
var src_default = Skel;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var tailwind_exports = {};
|
|
30
|
+
__export(tailwind_exports, {
|
|
31
|
+
default: () => tailwindcssPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(tailwind_exports);
|
|
34
|
+
var import_plugin = __toESM(require("tailwindcss/plugin"));
|
|
35
|
+
function tailwindcssPlugin() {
|
|
36
|
+
const variants = [
|
|
37
|
+
{ name: "loaded", value: false },
|
|
38
|
+
{ name: "loading", value: true }
|
|
39
|
+
];
|
|
40
|
+
return (0, import_plugin.default)(({ addVariant }) => {
|
|
41
|
+
variants.forEach(({ name, value }) => {
|
|
42
|
+
addVariant(name, `&[data-loading='${value}']`);
|
|
43
|
+
addVariant(`peer-${name}`, `:merge(.peer)[data-loading='${value}'] ~ &`);
|
|
44
|
+
addVariant(`group-${name}`, `:merge(.group)[data-loading='${value}'] &`);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
const IsLoadingContext = React.createContext(false);
|
|
3
|
+
function Root({ as, isLoading = true, children, ...rest }) {
|
|
4
|
+
const Component = as || "div";
|
|
5
|
+
return <IsLoadingContext.Provider value={isLoading}><Component {...rest} data-loading={isLoading}>{children}</Component></IsLoadingContext.Provider>;
|
|
6
|
+
}
|
|
7
|
+
function Item({ as, color, radius, children, ...rest }) {
|
|
8
|
+
const isLoading = React.useContext(IsLoadingContext);
|
|
9
|
+
const component = as || "p";
|
|
10
|
+
const Component = typeof component === "string" ? component : isLoading ? "div" : component;
|
|
11
|
+
return <Component
|
|
12
|
+
{...rest}
|
|
13
|
+
style={{
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
...rest.style,
|
|
16
|
+
"--skel-ui-color": color,
|
|
17
|
+
"--skel-ui-radius": radius
|
|
18
|
+
}}
|
|
19
|
+
data-loading={isLoading}
|
|
20
|
+
>{isLoading ? "\u200C" : typeof children === "function" ? children() : children}</Component>;
|
|
21
|
+
}
|
|
22
|
+
function generatePlaceholder(length, primary) {
|
|
23
|
+
return Array(length).fill(null).map((_, index) => ({ [primary]: `id-${index}` }));
|
|
24
|
+
}
|
|
25
|
+
const Skel = { Root, Item };
|
|
26
|
+
var src_default = Skel;
|
|
27
|
+
export {
|
|
28
|
+
src_default as default,
|
|
29
|
+
generatePlaceholder
|
|
30
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import plugin from "tailwindcss/plugin";
|
|
2
|
+
function tailwindcssPlugin() {
|
|
3
|
+
const variants = [
|
|
4
|
+
{ name: "loaded", value: false },
|
|
5
|
+
{ name: "loading", value: true }
|
|
6
|
+
];
|
|
7
|
+
return plugin(({ addVariant }) => {
|
|
8
|
+
variants.forEach(({ name, value }) => {
|
|
9
|
+
addVariant(name, `&[data-loading='${value}']`);
|
|
10
|
+
addVariant(`peer-${name}`, `:merge(.peer)[data-loading='${value}'] ~ &`);
|
|
11
|
+
addVariant(`group-${name}`, `:merge(.group)[data-loading='${value}'] &`);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
tailwindcssPlugin as default
|
|
17
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type HTMLProps<T extends React.ElementType> = Omit<React.ComponentPropsWithoutRef<T>, "children">;
|
|
3
|
+
type RootProps<T extends React.ElementType = "div"> = {
|
|
4
|
+
as?: T;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
} & HTMLProps<T>;
|
|
8
|
+
type ItemProps<T extends React.ElementType = "p"> = {
|
|
9
|
+
as?: T;
|
|
10
|
+
color?: string;
|
|
11
|
+
radius?: string;
|
|
12
|
+
children?: React.ReactNode | (() => React.ReactNode);
|
|
13
|
+
} & HTMLProps<T>;
|
|
14
|
+
declare function Root<T extends React.ElementType = "div">({ as, isLoading, children, ...rest }: RootProps<T>): React.JSX.Element;
|
|
15
|
+
declare function Item<T extends React.ElementType = "p">({ as, color, radius, children, ...rest }: ItemProps<T>): React.JSX.Element;
|
|
16
|
+
export declare function generatePlaceholder<T = {
|
|
17
|
+
[k: string]: unknown;
|
|
18
|
+
}>(length: number, primary: string): T[];
|
|
19
|
+
declare const Skel: {
|
|
20
|
+
Root: typeof Root;
|
|
21
|
+
Item: typeof Item;
|
|
22
|
+
};
|
|
23
|
+
export default Skel;
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--skel-ui-color: #cbd5e1;
|
|
3
|
+
--skel-ui-radius: 0.25rem;
|
|
4
|
+
}
|
|
5
|
+
[data-loading=true] {
|
|
6
|
+
border-radius: var(--skel-ui-radius);
|
|
7
|
+
background-color: var(--skel-ui-color) !important;
|
|
8
|
+
color: transparent !important;
|
|
9
|
+
cursor: default !important;
|
|
10
|
+
user-select: none !important;
|
|
11
|
+
pointer-events: none !important;
|
|
12
|
+
animation: skel-ui-pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite alternate-reverse !important;
|
|
13
|
+
}
|
|
14
|
+
@keyframes skel-ui-pulse {
|
|
15
|
+
0% {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
}
|
|
18
|
+
100% {
|
|
19
|
+
opacity: 0.5;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skel-ui/react",
|
|
3
|
+
"author": "https://github.com/sudoaugustin",
|
|
4
|
+
"version": "0.1.0-alpha.9764c85",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Next era of skeleton loading for react",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"main": "dist/cjs/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"module": "dist/esm/index.js",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react",
|
|
15
|
+
"skeleton",
|
|
16
|
+
"loading",
|
|
17
|
+
"placeholder"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./tailwind": {
|
|
26
|
+
"types": "./dist/tailwind.d.ts",
|
|
27
|
+
"import": "./dist/esm/tailwind.js",
|
|
28
|
+
"require": "./dist/cjs/tailwind.js"
|
|
29
|
+
},
|
|
30
|
+
"./styles.css": "./dist/styles.css"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/sudoaugustin/react-sleleto/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://skel-ui.augustin.zip",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/sudoaugustin/react-sleleto"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@chromatic-com/storybook": "^1.9.0",
|
|
42
|
+
"@storybook/addon-essentials": "^8.3.3",
|
|
43
|
+
"@storybook/addon-interactions": "^8.3.3",
|
|
44
|
+
"@storybook/addon-links": "^8.3.3",
|
|
45
|
+
"@storybook/addon-onboarding": "^8.3.3",
|
|
46
|
+
"@storybook/blocks": "^8.3.3",
|
|
47
|
+
"@storybook/react": "^8.3.3",
|
|
48
|
+
"@storybook/react-vite": "^8.3.3",
|
|
49
|
+
"@storybook/test": "^8.3.3",
|
|
50
|
+
"@types/react": "^18.3.9",
|
|
51
|
+
"@types/react-dom": "^18.0.10",
|
|
52
|
+
"esbuild": "^0.17.5",
|
|
53
|
+
"react": "^17.0.0",
|
|
54
|
+
"react-dom": "^17.0.0",
|
|
55
|
+
"storybook": "^8.3.3",
|
|
56
|
+
"swr": "^2.2.5",
|
|
57
|
+
"tailwindcss": "^3.4.13",
|
|
58
|
+
"typescript": "^5.6.2"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"react": "^17.0 || ^18.0",
|
|
62
|
+
"react-dom": "^17.0 || ^18.0"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"dev": "storybook dev -p 6006 --no-open",
|
|
66
|
+
"build": "rm -rf dist && pnpm build:dts && pnpm build:css && pnpm build:esm && pnpm build:cjs",
|
|
67
|
+
"build:dts": "tsc -p tsconfig.build.json --outDir dist",
|
|
68
|
+
"build:css": "esbuild src/styles.css --outdir=dist",
|
|
69
|
+
"build:esm": "esbuild src/*.ts* --format=esm --outdir=dist/esm",
|
|
70
|
+
"build:cjs": "esbuild src/*.ts* --format=cjs --outdir=dist/cjs"
|
|
71
|
+
}
|
|
72
|
+
}
|