@skel-ui/react-native 1.0.0-alpha.444268b

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 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
@@ -0,0 +1,71 @@
1
+ # Getting Started
2
+
3
+ Skel UI resolves the challenges of implementing skeletons by eliminating the need to create dedicated loading screens and providing an easier way to manage skeleton states using react-context.
4
+
5
+ ## Installation
6
+
7
+ Install the package into your project via command line.
8
+
9
+ ```bash
10
+ npm install @skel-ui/react
11
+ ```
12
+
13
+ ## Importing CSS
14
+
15
+ Import the CSS file into the root of your application.
16
+
17
+ ```js
18
+ import "@skel-ui/react/styles.css";
19
+ ```
20
+
21
+ ## Start crafting UI
22
+
23
+ Now it's time for you to craft your user interface to life!
24
+
25
+ ```jsx
26
+ import * as Skel from "@skel-ui/react";
27
+ import Image from "next/image";
28
+
29
+ function Profile() {
30
+ const { user, isLoading } = useProfile();
31
+
32
+ return (
33
+ <Skel.Root isLoading={isLoading}>
34
+ <Skel.Item className="user-avatar">
35
+ <Image src={user.profile} />
36
+ </Skel.Item>
37
+ <Skel.Item as="h1" className="user-email">
38
+ {user.email}
39
+ </Skel.Item>
40
+ </Skel.Root>
41
+ );
42
+ }
43
+ ```
44
+
45
+ Now, not only have you designed the skeleton, but you have also done the actual UI. Additionally, the skeleton state for the entire UI is handled in a single place at the `<Skel.Root>` .
46
+
47
+ ## Customization
48
+
49
+ Customize the default color and border-radius of skeleton using css variables.
50
+
51
+ ```css title="global.css"
52
+ :root {
53
+ --skel-ui-color1: #a1a1aa;
54
+ --skel-ui-color2: #e4e4e7;
55
+ --skel-ui-radius: 0.25rem;
56
+ }
57
+ ```
58
+
59
+ Each `Skel.Item` will have a `data-loading` attribute that is set to `"true"` when the item is in a loading state, and `"false"` otherwise. You can use this attribute in your CSS to create styles based on the loading state.
60
+
61
+ ```css
62
+ /* This style will be applied during loading. */
63
+ .user-email[data-loading="true"] {
64
+ width: 5rem;
65
+ }
66
+
67
+ /* This style will be applied after loading is done. */
68
+ .user-email[data-loading="false"]:hover {
69
+ background: #f97316;
70
+ }
71
+ ```
@@ -0,0 +1,23 @@
1
+ import { SkelComponentProps } from "@skel-ui/core";
2
+ import { ReactNode } from "react";
3
+ import { View } from "react-native";
4
+ import { EasingFunction, EasingFunctionFactory } from "react-native-reanimated";
5
+ import { TStyle } from "./funcs";
6
+ type UIOptions = {
7
+ radius?: number;
8
+ colors?: [string, string];
9
+ animation?: {
10
+ easing?: EasingFunction | EasingFunctionFactory;
11
+ duration?: number;
12
+ } | {
13
+ component: ReactNode;
14
+ };
15
+ skelUIPulse?: boolean;
16
+ };
17
+ type AnimationProps = Pick<SkelComponentProps<typeof View>, "sw" | "sh" | "sr"> & {
18
+ style?: TStyle;
19
+ numberOfLines?: number;
20
+ };
21
+ export declare const UIOptionsContext: import("react").Context<UIOptions>;
22
+ export declare function Animation({ sw, sh, sr, style, numberOfLines }: AnimationProps): import("react/jsx-runtime").JSX.Element;
23
+ export {};
@@ -0,0 +1,98 @@
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 Animation_exports = {};
30
+ __export(Animation_exports, {
31
+ Animation: () => Animation,
32
+ UIOptionsContext: () => UIOptionsContext
33
+ });
34
+ module.exports = __toCommonJS(Animation_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_expo_linear_gradient = require("expo-linear-gradient");
37
+ var import_react = require("react");
38
+ var import_react_native = require("react-native");
39
+ var import_react_native_reanimated = __toESM(require("react-native-reanimated"));
40
+ var import_funcs = require("./funcs");
41
+ const UIOptionsContext = (0, import_react.createContext)({});
42
+ function Pluse({ colors, animation }) {
43
+ const opacity = (0, import_react_native_reanimated.useSharedValue)(0.5);
44
+ (0, import_react_native_reanimated.useFrameCallback)(() => {
45
+ if (opacity.value === 1) opacity.value = (0, import_react_native_reanimated.withTiming)(0.5, animation);
46
+ if (opacity.value === 0.5) opacity.value = (0, import_react_native_reanimated.withTiming)(1, animation);
47
+ });
48
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { style: { width: "100%", height: "100%", opacity, backgroundColor: colors[0] }, "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { children: " \u200C " }) });
49
+ }
50
+ function Gradient({ colors, animation }) {
51
+ const translateX = (0, import_react_native_reanimated.useSharedValue)("-100%");
52
+ (0, import_react.useEffect)(() => {
53
+ translateX.value = (0, import_react_native_reanimated.withRepeat)((0, import_react_native_reanimated.withTiming)("100%", animation), -1, false);
54
+ }, []);
55
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: { backgroundColor: colors[0] }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ import_react_native_reanimated.default.View,
57
+ {
58
+ style: { width: "100%", height: "100%", transform: [{ translateX }] },
59
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
+ import_expo_linear_gradient.LinearGradient,
61
+ {
62
+ start: { x: 0, y: 0 },
63
+ end: { x: 1, y: 0 },
64
+ style: { width: "100%", height: "100%" },
65
+ colors: [...colors, colors[0]]
66
+ }
67
+ )
68
+ }
69
+ ) });
70
+ }
71
+ function Animation({ sw, sh, sr, style = {}, numberOfLines = 1 }) {
72
+ const text = (0, import_react.useMemo)(() => new Array(numberOfLines).fill(" \u200C ").join("\n"), [numberOfLines]);
73
+ const { viewStyle, textStyle } = (0, import_funcs.filterStyle)(style);
74
+ const { colors = ["#cbd5e1", "#f1f0f0"], radius = 4, animation = {}, skelUIPulse } = (0, import_react.useContext)(UIOptionsContext);
75
+ const isCustomAnimation = "component" in animation;
76
+ const animationItemProps = {
77
+ colors,
78
+ animation: { duration: skelUIPulse ? 1e3 : 2e3, easing: import_react_native_reanimated.Easing.bezier(0.4, 0, 0.6, 1), ...animation }
79
+ };
80
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
81
+ import_react_native.View,
82
+ {
83
+ style: {
84
+ ...style,
85
+ width: sw || viewStyle.width,
86
+ height: sh || viewStyle.height,
87
+ borderRadius: sr || viewStyle.borderRadius || radius,
88
+ overflow: "hidden",
89
+ position: "relative",
90
+ backgroundColor: void 0
91
+ },
92
+ children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: textStyle, children: text }),
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: { inset: 0, position: "absolute" }, children: isCustomAnimation ? animation.component : skelUIPulse ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pluse, { ...animationItemProps }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Gradient, { ...animationItemProps }) })
95
+ ]
96
+ }
97
+ );
98
+ }
@@ -0,0 +1,87 @@
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
+ var funcs_exports = {};
20
+ __export(funcs_exports, {
21
+ filterStyle: () => filterStyle
22
+ });
23
+ module.exports = __toCommonJS(funcs_exports);
24
+ const viewWhitelistStyles = [
25
+ "aspectRatio",
26
+ "bottom",
27
+ "display",
28
+ "flex",
29
+ "flexBasis",
30
+ "flexGrow",
31
+ "flexShrink",
32
+ "left",
33
+ "margin",
34
+ "marginBottom",
35
+ "marginEnd",
36
+ "marginHorizontal",
37
+ "marginLeft",
38
+ "marginRight",
39
+ "marginStart",
40
+ "marginTop",
41
+ "marginVertical",
42
+ "maxHeight",
43
+ "maxWidth",
44
+ "minHeight",
45
+ "minWidth",
46
+ "padding",
47
+ "paddingBottom",
48
+ "paddingEnd",
49
+ "paddingHorizontal",
50
+ "paddingLeft",
51
+ "paddingRight",
52
+ "paddingStart",
53
+ "paddingTop",
54
+ "paddingVertical",
55
+ "position",
56
+ "right",
57
+ "top",
58
+ "zIndex",
59
+ "width",
60
+ "height",
61
+ "borderRadius",
62
+ "borderBottomEndRadius",
63
+ "borderBottomLeftRadius",
64
+ "borderBottomRightRadius",
65
+ "borderBottomStartRadius",
66
+ "borderStartEndRadius",
67
+ "borderStartStartRadius",
68
+ "borderEndEndRadius",
69
+ "borderEndStartRadius",
70
+ "borderTopEndRadius",
71
+ "borderTopLeftRadius",
72
+ "borderTopRightRadius",
73
+ "borderTopStartRadius"
74
+ ];
75
+ const textWhitelistStyles = ["fontFamily", "fontSize", "fontStyle", "fontWeight", "lineHeight"];
76
+ const filterStyle = (style) => {
77
+ const viewStyle = {};
78
+ const textStyle = {};
79
+ Object.entries(style).forEach(([name, value]) => {
80
+ if (viewWhitelistStyles.includes(name)) {
81
+ viewStyle[name] = value;
82
+ } else if (textWhitelistStyles.includes(name)) {
83
+ textStyle[name] = value;
84
+ }
85
+ });
86
+ return { viewStyle, textStyle };
87
+ };
@@ -0,0 +1,86 @@
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
+ Custom: () => Custom,
32
+ Image: () => Image,
33
+ Pressable: () => Pressable,
34
+ Provider: () => Provider,
35
+ Root: () => Root,
36
+ SkelProvider: () => SkelProvider,
37
+ Text: () => Text,
38
+ View: () => View
39
+ });
40
+ module.exports = __toCommonJS(src_exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_core = require("@skel-ui/core");
43
+ var import_react = __toESM(require("react"));
44
+ var ReactNative = __toESM(require("react-native"));
45
+ var import_Animation = require("./Animation");
46
+ function createSkelComponent(type) {
47
+ return ({ sw, sh, sr, children, ...props }) => {
48
+ const isLoading = import_react.default.useContext(import_core.IsLoadingContext);
49
+ return isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
50
+ import_Animation.Animation,
51
+ {
52
+ sw,
53
+ sh,
54
+ sr,
55
+ style: { width: props.width, height: props.height, ...props.style },
56
+ numberOfLines: props.numberOfLines
57
+ }
58
+ ) : import_react.default.createElement(type, props, children);
59
+ };
60
+ }
61
+ function SkelProvider({
62
+ colors,
63
+ radius,
64
+ children,
65
+ animation,
66
+ skelUIPulse
67
+ }) {
68
+ const value = import_react.default.useMemo(
69
+ () => ({ colors, radius, animation, skelUIPulse }),
70
+ [colors, radius, animation, skelUIPulse]
71
+ );
72
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Animation.UIOptionsContext.Provider, { value, children });
73
+ }
74
+ function SkelCustom({
75
+ component,
76
+ ...rest
77
+ }) {
78
+ return createSkelComponent(component)(rest);
79
+ }
80
+ const Root = import_core.SkelRoot;
81
+ const Custom = SkelCustom;
82
+ const Provider = SkelProvider;
83
+ const View = createSkelComponent(ReactNative.View);
84
+ const Text = createSkelComponent(ReactNative.Text);
85
+ const Image = createSkelComponent(ReactNative.Image);
86
+ const Pressable = createSkelComponent(ReactNative.Pressable);
@@ -0,0 +1,24 @@
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
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ generatePlaceholder: () => import_core.generatePlaceholder
22
+ });
23
+ module.exports = __toCommonJS(utils_exports);
24
+ var import_core = require("@skel-ui/core");
@@ -0,0 +1,74 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { LinearGradient } from "expo-linear-gradient";
3
+ import { createContext, useContext, useEffect, useMemo } from "react";
4
+ import { Text, View } from "react-native";
5
+ import Animated, {
6
+ Easing,
7
+ useFrameCallback,
8
+ useSharedValue,
9
+ withRepeat,
10
+ withTiming
11
+ } from "react-native-reanimated";
12
+ import { filterStyle } from "./funcs";
13
+ const UIOptionsContext = createContext({});
14
+ function Pluse({ colors, animation }) {
15
+ const opacity = useSharedValue(0.5);
16
+ useFrameCallback(() => {
17
+ if (opacity.value === 1) opacity.value = withTiming(0.5, animation);
18
+ if (opacity.value === 0.5) opacity.value = withTiming(1, animation);
19
+ });
20
+ return /* @__PURE__ */ jsx(Animated.View, { style: { width: "100%", height: "100%", opacity, backgroundColor: colors[0] }, "aria-hidden": true, children: /* @__PURE__ */ jsx(Text, { children: " \u200C " }) });
21
+ }
22
+ function Gradient({ colors, animation }) {
23
+ const translateX = useSharedValue("-100%");
24
+ useEffect(() => {
25
+ translateX.value = withRepeat(withTiming("100%", animation), -1, false);
26
+ }, []);
27
+ return /* @__PURE__ */ jsx(View, { style: { backgroundColor: colors[0] }, children: /* @__PURE__ */ jsx(
28
+ Animated.View,
29
+ {
30
+ style: { width: "100%", height: "100%", transform: [{ translateX }] },
31
+ children: /* @__PURE__ */ jsx(
32
+ LinearGradient,
33
+ {
34
+ start: { x: 0, y: 0 },
35
+ end: { x: 1, y: 0 },
36
+ style: { width: "100%", height: "100%" },
37
+ colors: [...colors, colors[0]]
38
+ }
39
+ )
40
+ }
41
+ ) });
42
+ }
43
+ function Animation({ sw, sh, sr, style = {}, numberOfLines = 1 }) {
44
+ const text = useMemo(() => new Array(numberOfLines).fill(" \u200C ").join("\n"), [numberOfLines]);
45
+ const { viewStyle, textStyle } = filterStyle(style);
46
+ const { colors = ["#cbd5e1", "#f1f0f0"], radius = 4, animation = {}, skelUIPulse } = useContext(UIOptionsContext);
47
+ const isCustomAnimation = "component" in animation;
48
+ const animationItemProps = {
49
+ colors,
50
+ animation: { duration: skelUIPulse ? 1e3 : 2e3, easing: Easing.bezier(0.4, 0, 0.6, 1), ...animation }
51
+ };
52
+ return /* @__PURE__ */ jsxs(
53
+ View,
54
+ {
55
+ style: {
56
+ ...style,
57
+ width: sw || viewStyle.width,
58
+ height: sh || viewStyle.height,
59
+ borderRadius: sr || viewStyle.borderRadius || radius,
60
+ overflow: "hidden",
61
+ position: "relative",
62
+ backgroundColor: void 0
63
+ },
64
+ children: [
65
+ /* @__PURE__ */ jsx(Text, { style: textStyle, children: text }),
66
+ /* @__PURE__ */ jsx(View, { style: { inset: 0, position: "absolute" }, children: isCustomAnimation ? animation.component : skelUIPulse ? /* @__PURE__ */ jsx(Pluse, { ...animationItemProps }) : /* @__PURE__ */ jsx(Gradient, { ...animationItemProps }) })
67
+ ]
68
+ }
69
+ );
70
+ }
71
+ export {
72
+ Animation,
73
+ UIOptionsContext
74
+ };
@@ -0,0 +1,67 @@
1
+ const viewWhitelistStyles = [
2
+ "aspectRatio",
3
+ "bottom",
4
+ "display",
5
+ "flex",
6
+ "flexBasis",
7
+ "flexGrow",
8
+ "flexShrink",
9
+ "left",
10
+ "margin",
11
+ "marginBottom",
12
+ "marginEnd",
13
+ "marginHorizontal",
14
+ "marginLeft",
15
+ "marginRight",
16
+ "marginStart",
17
+ "marginTop",
18
+ "marginVertical",
19
+ "maxHeight",
20
+ "maxWidth",
21
+ "minHeight",
22
+ "minWidth",
23
+ "padding",
24
+ "paddingBottom",
25
+ "paddingEnd",
26
+ "paddingHorizontal",
27
+ "paddingLeft",
28
+ "paddingRight",
29
+ "paddingStart",
30
+ "paddingTop",
31
+ "paddingVertical",
32
+ "position",
33
+ "right",
34
+ "top",
35
+ "zIndex",
36
+ "width",
37
+ "height",
38
+ "borderRadius",
39
+ "borderBottomEndRadius",
40
+ "borderBottomLeftRadius",
41
+ "borderBottomRightRadius",
42
+ "borderBottomStartRadius",
43
+ "borderStartEndRadius",
44
+ "borderStartStartRadius",
45
+ "borderEndEndRadius",
46
+ "borderEndStartRadius",
47
+ "borderTopEndRadius",
48
+ "borderTopLeftRadius",
49
+ "borderTopRightRadius",
50
+ "borderTopStartRadius"
51
+ ];
52
+ const textWhitelistStyles = ["fontFamily", "fontSize", "fontStyle", "fontWeight", "lineHeight"];
53
+ const filterStyle = (style) => {
54
+ const viewStyle = {};
55
+ const textStyle = {};
56
+ Object.entries(style).forEach(([name, value]) => {
57
+ if (viewWhitelistStyles.includes(name)) {
58
+ viewStyle[name] = value;
59
+ } else if (textWhitelistStyles.includes(name)) {
60
+ textStyle[name] = value;
61
+ }
62
+ });
63
+ return { viewStyle, textStyle };
64
+ };
65
+ export {
66
+ filterStyle
67
+ };
@@ -0,0 +1,56 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { IsLoadingContext, SkelRoot } from "@skel-ui/core";
3
+ import React from "react";
4
+ import * as ReactNative from "react-native";
5
+ import { Animation, UIOptionsContext } from "./Animation";
6
+ function createSkelComponent(type) {
7
+ return ({ sw, sh, sr, children, ...props }) => {
8
+ const isLoading = React.useContext(IsLoadingContext);
9
+ return isLoading ? /* @__PURE__ */ jsx(
10
+ Animation,
11
+ {
12
+ sw,
13
+ sh,
14
+ sr,
15
+ style: { width: props.width, height: props.height, ...props.style },
16
+ numberOfLines: props.numberOfLines
17
+ }
18
+ ) : React.createElement(type, props, children);
19
+ };
20
+ }
21
+ function SkelProvider({
22
+ colors,
23
+ radius,
24
+ children,
25
+ animation,
26
+ skelUIPulse
27
+ }) {
28
+ const value = React.useMemo(
29
+ () => ({ colors, radius, animation, skelUIPulse }),
30
+ [colors, radius, animation, skelUIPulse]
31
+ );
32
+ return /* @__PURE__ */ jsx(UIOptionsContext.Provider, { value, children });
33
+ }
34
+ function SkelCustom({
35
+ component,
36
+ ...rest
37
+ }) {
38
+ return createSkelComponent(component)(rest);
39
+ }
40
+ const Root = SkelRoot;
41
+ const Custom = SkelCustom;
42
+ const Provider = SkelProvider;
43
+ const View = createSkelComponent(ReactNative.View);
44
+ const Text = createSkelComponent(ReactNative.Text);
45
+ const Image = createSkelComponent(ReactNative.Image);
46
+ const Pressable = createSkelComponent(ReactNative.Pressable);
47
+ export {
48
+ Custom,
49
+ Image,
50
+ Pressable,
51
+ Provider,
52
+ Root,
53
+ SkelProvider,
54
+ Text,
55
+ View
56
+ };
@@ -0,0 +1,4 @@
1
+ import { generatePlaceholder } from "@skel-ui/core";
2
+ export {
3
+ generatePlaceholder
4
+ };
@@ -0,0 +1,7 @@
1
+ export type TStyle = {
2
+ [k: string]: unknown;
3
+ };
4
+ export declare const filterStyle: (style: TStyle) => {
5
+ viewStyle: TStyle;
6
+ textStyle: TStyle;
7
+ };
@@ -0,0 +1,19 @@
1
+ import { SkelComponentProps, SkelRoot } from "@skel-ui/core";
2
+ import type { ComponentProps, ComponentType, ContextType, ReactNode } from "react";
3
+ import React from "react";
4
+ import * as ReactNative from "react-native";
5
+ import { UIOptionsContext } from "./Animation";
6
+ export declare function SkelProvider({ colors, radius, children, animation, skelUIPulse, }: ContextType<typeof UIOptionsContext> & {
7
+ children: ReactNode;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ declare function SkelCustom<T extends ComponentType<ComponentProps<T>>>({ component, ...rest }: {
10
+ component: T;
11
+ } & ComponentProps<T> & Pick<SkelComponentProps<T>, "sw" | "sh" | "sr">): import("react/jsx-runtime").JSX.Element;
12
+ export declare const Root: typeof SkelRoot;
13
+ export declare const Custom: typeof SkelCustom;
14
+ export declare const Provider: typeof SkelProvider;
15
+ export declare const View: ({ sw, sh, sr, children, ...props }: SkelComponentProps<typeof ReactNative.View>) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const Text: ({ sw, sh, sr, children, ...props }: SkelComponentProps<typeof ReactNative.Text>) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const Image: ({ sw, sh, sr, children, ...props }: SkelComponentProps<typeof ReactNative.Image>) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const Pressable: ({ sw, sh, sr, children, ...props }: SkelComponentProps<React.ForwardRefExoticComponent<ReactNative.PressableProps & React.RefAttributes<ReactNative.View>>>) => import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,2 @@
1
+ import { generatePlaceholder } from "@skel-ui/core";
2
+ export { generatePlaceholder };
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@skel-ui/react-native",
3
+ "author": "https://github.com/sudoaugustin",
4
+ "version": "1.0.0-alpha.444268b",
5
+ "license": "MIT",
6
+ "description": "Next era of skeleton loading for React Native",
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
+ "native",
16
+ "skeleton",
17
+ "loading",
18
+ "placeholder"
19
+ ],
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/esm/index.js",
24
+ "require": "./dist/cjs/index.js"
25
+ },
26
+ "./utils": {
27
+ "types": "./dist/utils.d.ts",
28
+ "import": "./dist/esm/utils.js",
29
+ "require": "./dist/cjs/utils.js"
30
+ }
31
+ },
32
+ "typesVersions": {
33
+ "*": {
34
+ "utils": [
35
+ "./dist/utils.d.ts"
36
+ ]
37
+ }
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/sudoaugustin/skel-ui/issues"
41
+ },
42
+ "homepage": "https://skel-ui.augustin.zip",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/sudoaugustin/skel-ui"
46
+ },
47
+ "dependencies": {
48
+ "@skel-ui/core": "1.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/react": "^18.3.12",
52
+ "esbuild": "^0.24.0",
53
+ "expo-linear-gradient": "^14.0",
54
+ "react": "^18.3.1",
55
+ "react-native": "0.76.3",
56
+ "typescript": "^5.7.2",
57
+ "react-native-reanimated": "^3.0",
58
+ "@skel-ui/core": "1.0.0",
59
+ "commons-tsconfig": "0.0.1"
60
+ },
61
+ "peerDependencies": {
62
+ "expo-linear-gradient": "^14.0.",
63
+ "react": "^17.0 || ^18.0",
64
+ "react-native": "*",
65
+ "react-native-reanimated": "^3.0"
66
+ },
67
+ "scripts": {
68
+ "build": "rm -rf dist && pnpm build:dts && pnpm build:esm && pnpm build:cjs",
69
+ "build:dts": "tsc -p tsconfig.json --outDir dist --emitDeclarationOnly",
70
+ "build:css": "esbuild src/styles.css --outdir=dist",
71
+ "build:esm": "esbuild src/*.ts* --format=esm --outdir=dist/esm",
72
+ "build:cjs": "esbuild src/*.ts* --format=cjs --outdir=dist/cjs"
73
+ }
74
+ }