@snack-uikit/skeleton 0.3.5 → 0.3.6-preview-1f246c4a.0

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.
Files changed (43) hide show
  1. package/dist/cjs/components/Skeleton/Skeleton.js +48 -0
  2. package/dist/cjs/components/Skeleton/index.js +25 -0
  3. package/dist/cjs/components/SkeletonText/SkeletonText.js +61 -0
  4. package/dist/cjs/components/SkeletonText/index.js +25 -0
  5. package/dist/cjs/components/WithSkeleton/WithSkeleton.js +26 -0
  6. package/dist/cjs/components/WithSkeleton/index.js +25 -0
  7. package/dist/cjs/components/index.js +27 -0
  8. package/dist/cjs/context/index.js +20 -0
  9. package/dist/cjs/hooks.js +12 -0
  10. package/dist/cjs/index.js +26 -0
  11. package/dist/esm/components/Skeleton/Skeleton.d.ts +14 -0
  12. package/dist/esm/components/Skeleton/index.js +1 -0
  13. package/dist/esm/components/SkeletonText/SkeletonText.d.ts +11 -0
  14. package/dist/esm/components/SkeletonText/index.js +1 -0
  15. package/dist/esm/components/WithSkeleton/WithSkeleton.d.ts +9 -0
  16. package/dist/esm/components/WithSkeleton/index.js +1 -0
  17. package/dist/esm/components/index.js +3 -0
  18. package/dist/esm/context/index.d.ts +7 -0
  19. package/dist/esm/hooks.d.ts +1 -0
  20. package/dist/esm/index.js +2 -0
  21. package/package.json +8 -6
  22. package/dist/components/Skeleton/styles.module.css +0 -12
  23. package/dist/components/SkeletonText/styles.module.css +0 -19
  24. /package/dist/{components → cjs/components}/Skeleton/Skeleton.d.ts +0 -0
  25. /package/dist/{components → cjs/components}/Skeleton/index.d.ts +0 -0
  26. /package/dist/{components → cjs/components}/SkeletonText/SkeletonText.d.ts +0 -0
  27. /package/dist/{components → cjs/components}/SkeletonText/index.d.ts +0 -0
  28. /package/dist/{components → cjs/components}/WithSkeleton/WithSkeleton.d.ts +0 -0
  29. /package/dist/{components → cjs/components}/WithSkeleton/index.d.ts +0 -0
  30. /package/dist/{components → cjs/components}/index.d.ts +0 -0
  31. /package/dist/{context → cjs/context}/index.d.ts +0 -0
  32. /package/dist/{hooks.d.ts → cjs/hooks.d.ts} +0 -0
  33. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  34. /package/dist/{components → esm/components}/Skeleton/Skeleton.js +0 -0
  35. /package/dist/{components/Skeleton/index.js → esm/components/Skeleton/index.d.ts} +0 -0
  36. /package/dist/{components → esm/components}/SkeletonText/SkeletonText.js +0 -0
  37. /package/dist/{components/SkeletonText/index.js → esm/components/SkeletonText/index.d.ts} +0 -0
  38. /package/dist/{components → esm/components}/WithSkeleton/WithSkeleton.js +0 -0
  39. /package/dist/{components/WithSkeleton/index.js → esm/components/WithSkeleton/index.d.ts} +0 -0
  40. /package/dist/{components/index.js → esm/components/index.d.ts} +0 -0
  41. /package/dist/{context → esm/context}/index.js +0 -0
  42. /package/dist/{hooks.js → esm/hooks.js} +0 -0
  43. /package/dist/{index.js → esm/index.d.ts} +0 -0
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
+ }
9
+ return t;
10
+ };
11
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
+ return mod && mod.__esModule ? mod : {
13
+ "default": mod
14
+ };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ exports.Skeleton = Skeleton;
20
+ const jsx_runtime_1 = require("react/jsx-runtime");
21
+ const classnames_1 = __importDefault(require("classnames"));
22
+ const hooks_1 = require("../../hooks");
23
+ const styles_module_scss_1 = __importDefault({});
24
+ function Skeleton(_a) {
25
+ var {
26
+ width,
27
+ height,
28
+ className,
29
+ borderRadius,
30
+ loading,
31
+ children
32
+ } = _a,
33
+ restProps = __rest(_a, ["width", "height", "className", "borderRadius", "loading", "children"]);
34
+ const isLoading = (0, hooks_1.useIsLoadingValue)(loading);
35
+ if (isLoading) {
36
+ return (0, jsx_runtime_1.jsx)("div", Object.assign({}, restProps, {
37
+ style: {
38
+ width,
39
+ height,
40
+ borderRadius
41
+ },
42
+ className: (0, classnames_1.default)(styles_module_scss_1.default.skeleton, className)
43
+ }));
44
+ }
45
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {
46
+ children: children
47
+ });
48
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./Skeleton"), exports);
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
+ }
9
+ return t;
10
+ };
11
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
+ return mod && mod.__esModule ? mod : {
13
+ "default": mod
14
+ };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ exports.SkeletonText = SkeletonText;
20
+ const jsx_runtime_1 = require("react/jsx-runtime");
21
+ const classnames_1 = __importDefault(require("classnames"));
22
+ const react_1 = require("react");
23
+ const hooks_1 = require("../../hooks");
24
+ const Skeleton_1 = require("../Skeleton");
25
+ const styles_module_scss_1 = __importDefault({});
26
+ function SkeletonText(_a) {
27
+ var {
28
+ width,
29
+ className,
30
+ rowClassName,
31
+ lineClassName,
32
+ children,
33
+ loading,
34
+ lines = 3,
35
+ borderRadius = '0.4em'
36
+ } = _a,
37
+ restProps = __rest(_a, ["width", "className", "rowClassName", "lineClassName", "children", "loading", "lines", "borderRadius"]);
38
+ const lineTestId = restProps['data-test-id'] ? `${restProps['data-test-id']}_line` : undefined;
39
+ const rows = (0, react_1.useMemo)(() => Array(lines).fill(true).map((_, index) => (0, jsx_runtime_1.jsx)("div", {
40
+ className: (0, classnames_1.default)(styles_module_scss_1.default.skeletonTextRow, rowClassName),
41
+ children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, {
42
+ "data-test-id": lineTestId,
43
+ loading: true,
44
+ borderRadius: borderRadius,
45
+ className: (0, classnames_1.default)(styles_module_scss_1.default.skeletonTextLine, lineClassName)
46
+ })
47
+ }, index)), [lines, borderRadius, rowClassName, lineClassName, lineTestId]);
48
+ const isLoading = (0, hooks_1.useIsLoadingValue)(loading);
49
+ if (isLoading) {
50
+ return (0, jsx_runtime_1.jsx)("div", Object.assign({}, restProps, {
51
+ style: {
52
+ width
53
+ },
54
+ className: (0, classnames_1.default)(className, styles_module_scss_1.default.skeletonText),
55
+ children: rows
56
+ }));
57
+ }
58
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {
59
+ children: children
60
+ });
61
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./SkeletonText"), exports);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WithSkeleton = WithSkeleton;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const context_1 = require("../../context");
9
+ const hooks_1 = require("../../hooks");
10
+ function WithSkeleton(_ref) {
11
+ let {
12
+ children,
13
+ skeleton,
14
+ loading
15
+ } = _ref;
16
+ const isLoading = (0, hooks_1.useIsLoadingValue)(loading);
17
+ if (isLoading) {
18
+ return (0, jsx_runtime_1.jsx)(context_1.SkeletonContextProvider, {
19
+ loading: true,
20
+ children: skeleton
21
+ });
22
+ }
23
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {
24
+ children: children
25
+ });
26
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./WithSkeleton"), exports);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./Skeleton"), exports);
26
+ __exportStar(require("./SkeletonText"), exports);
27
+ __exportStar(require("./WithSkeleton"), exports);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SkeletonContext = void 0;
7
+ exports.SkeletonContextProvider = SkeletonContextProvider;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ exports.SkeletonContext = (0, react_1.createContext)(false);
11
+ function SkeletonContextProvider(_ref) {
12
+ let {
13
+ loading,
14
+ children
15
+ } = _ref;
16
+ return (0, jsx_runtime_1.jsx)(exports.SkeletonContext.Provider, {
17
+ value: loading,
18
+ children: children
19
+ });
20
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsLoadingValue = useIsLoadingValue;
7
+ const react_1 = require("react");
8
+ const context_1 = require("./context");
9
+ function useIsLoadingValue(loadingByProp) {
10
+ const loadingByContext = (0, react_1.useContext)(context_1.SkeletonContext);
11
+ return loadingByContext || loadingByProp;
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./components"), exports);
26
+ __exportStar(require("./context"), exports);
@@ -0,0 +1,14 @@
1
+ import { CSSProperties, PropsWithChildren } from 'react';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ export type SkeletonProps = WithSupportProps<PropsWithChildren<{
4
+ /** Флаг состояния загрузки. Если значение true, будет отрисован блок скелетона, если false - children. */
5
+ loading?: boolean;
6
+ /** Ширина блока. Можно указать значение допустимое для CSSProperty.width (пример `'60%'`, `'400px'` и т.д) */
7
+ width?: CSSProperties['width'];
8
+ /** Высота блока. Можно указать значение допустимое для CSSProperty.height (пример `'60%'`, `'400px'` и т.д) */
9
+ height?: CSSProperties['height'];
10
+ /** Радиус скругления. Можно указать значение допустимое для CSSProperty.borderRadius (пример `'10px'`, `'50%'` и т.д) */
11
+ borderRadius?: CSSProperties['borderRadius'];
12
+ className?: string;
13
+ }>>;
14
+ export declare function Skeleton({ width, height, className, borderRadius, loading, children, ...restProps }: SkeletonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './Skeleton';
@@ -0,0 +1,11 @@
1
+ import { WithSupportProps } from '@snack-uikit/utils';
2
+ import { SkeletonProps } from '../Skeleton';
3
+ export type SkeletonTextProps = WithSupportProps<Omit<SkeletonProps, 'height'> & {
4
+ /** Количество строк. */
5
+ lines?: number;
6
+ /** CSS-класс строки */
7
+ rowClassName?: string;
8
+ /** CSS-класс линии */
9
+ lineClassName?: string;
10
+ }>;
11
+ export declare function SkeletonText({ width, className, rowClassName, lineClassName, children, loading, lines, borderRadius, ...restProps }: SkeletonTextProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './SkeletonText';
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ type WithSkeletonProps = PropsWithChildren<{
3
+ /** JSX скелетон */
4
+ skeleton: ReactNode;
5
+ /** Флаг состояния загрузки. Если значение true, будет отрисован блок скелетона, если false - children. */
6
+ loading?: boolean;
7
+ }>;
8
+ export declare function WithSkeleton({ children, skeleton, loading }: WithSkeletonProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1 @@
1
+ export * from './WithSkeleton';
@@ -0,0 +1,3 @@
1
+ export * from './Skeleton';
2
+ export * from './SkeletonText';
3
+ export * from './WithSkeleton';
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare const SkeletonContext: import("react").Context<boolean>;
3
+ export type SkeletonContextProviderProps = PropsWithChildren<{
4
+ /** Флаг состояния загрузки. Если значение true, будут отрисованы блоки скелетона. */
5
+ loading: boolean;
6
+ }>;
7
+ export declare function SkeletonContextProvider({ loading, children }: SkeletonContextProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function useIsLoadingValue(loadingByProp?: boolean): boolean | undefined;
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './context';
package/package.json CHANGED
@@ -4,15 +4,16 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Skeleton",
7
- "version": "0.3.5",
7
+ "version": "0.3.6-preview-1f246c4a.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
11
11
  "*.woff2"
12
12
  ],
13
13
  "description": "",
14
- "main": "./dist/index.js",
15
- "module": "./dist/index.js",
14
+ "types": "./dist/esm/index.d.ts",
15
+ "main": "./dist/cjs/index.js",
16
+ "module": "./dist/esm/index.js",
16
17
  "homepage": "https://github.com/cloud-ru-tech/snack-uikit/tree/master/packages/skeleton",
17
18
  "repository": {
18
19
  "type": "git",
@@ -24,7 +25,8 @@
24
25
  "Сергей Хлупин <svhlupin@cloud.ru>"
25
26
  ],
26
27
  "files": [
27
- "dist",
28
+ "dist/cjs",
29
+ "dist/esm",
28
30
  "src",
29
31
  "./CHANGELOG.md",
30
32
  "./LICENSE"
@@ -32,8 +34,8 @@
32
34
  "license": "Apache-2.0",
33
35
  "scripts": {},
34
36
  "dependencies": {
35
- "@snack-uikit/utils": "3.4.0",
37
+ "@snack-uikit/utils": "3.4.1-preview-1f246c4a.0",
36
38
  "classnames": "2.3.2"
37
39
  },
38
- "gitHead": "f9212fe04b0dbba9bedea1bb3a034ab612287841"
40
+ "gitHead": "a185a55c0722b19f70dd168cf299e6f53a0fd93f"
39
41
  }
@@ -1,12 +0,0 @@
1
- .skeleton{
2
- box-sizing:border-box;
3
- width:100%;
4
- height:1em;
5
- background:var(--gradient-skeleton, linear-gradient(115deg, rgba(36, 36, 48, 0.0784313725) 40%, rgba(36, 36, 48, 0) 50%, rgba(36, 36, 48, 0.0784313725) 60%)) 0 0/200% 100% repeat fixed;
6
- animation:loading 2s infinite linear;
7
- }
8
- @keyframes loading{
9
- to{
10
- background-position:-200% 0;
11
- }
12
- }
@@ -1,19 +0,0 @@
1
- .skeletonText{
2
- position:relative;
3
- }
4
-
5
- .skeletonTextLine{
6
- display:inline-block;
7
- height:0.8em;
8
- margin-top:0;
9
- margin-bottom:0;
10
- vertical-align:middle;
11
- }
12
-
13
- .skeletonTextRow{
14
- display:inline;
15
- }
16
-
17
- .skeletonTextRow + .skeletonTextRow:last-child .skeletonTextLine{
18
- width:65%;
19
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes