@pallasoft/ps-core-components 2.15.2 → 2.15.4
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/dist/components/ps-skeleton.js +3 -8
- package/dist/constants/ps-skeleton-config.d.ts +10 -0
- package/dist/constants/ps-skeleton-config.js +19 -0
- package/dist/esm/components/ps-skeleton.js +3 -8
- package/dist/esm/constants/ps-skeleton-config.js +19 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/models/ps-skeleton-size.js +1 -0
- package/dist/esm/services/ps-skeleton-class-service.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/models/ps-skeleton-size.d.ts +4 -0
- package/dist/models/ps-skeleton-size.js +2 -0
- package/dist/services/ps-skeleton-class-service.d.ts +5 -0
- package/dist/services/ps-skeleton-class-service.js +23 -0
- package/package.json +1 -2
|
@@ -5,12 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
6
6
|
const ps_skeleton_config_1 = require("../constants/ps-skeleton-config");
|
|
7
7
|
const ps_skeleton_shape_1 = require("../constants/ps-skeleton-shape");
|
|
8
|
-
const
|
|
9
|
-
[ps_skeleton_shape_1.PsSkeletonShape.Block]: 'h-11 w-full rounded-ps-control',
|
|
10
|
-
[ps_skeleton_shape_1.PsSkeletonShape.Circle]: 'h-9 w-9 shrink-0 rounded-full',
|
|
11
|
-
[ps_skeleton_shape_1.PsSkeletonShape.Line]: 'h-3 w-full rounded-full',
|
|
12
|
-
[ps_skeleton_shape_1.PsSkeletonShape.Text]: 'h-3 w-full rounded-full',
|
|
13
|
-
};
|
|
8
|
+
const ps_skeleton_class_service_1 = require("../services/ps-skeleton-class-service");
|
|
14
9
|
const sizeStyle = (props) => {
|
|
15
10
|
const style = {};
|
|
16
11
|
if (props.width !== undefined)
|
|
@@ -30,10 +25,10 @@ const PsSkeleton = ({ shape = ps_skeleton_shape_1.PsSkeletonShape.Line, ...props
|
|
|
30
25
|
const style = sizeStyle(props);
|
|
31
26
|
if (shape === ps_skeleton_shape_1.PsSkeletonShape.Text) {
|
|
32
27
|
const lines = props.lines !== undefined ? props.lines : ps_skeleton_config_1.PsSkeletonConfig.defaultTextLines;
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)("span", { className: ps_design_system_1.PallasoftClassNameService.merge('flex flex-col gap-2.5', props.className), children: Array.from({ length: lines }, (item, index) => ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": 'true', className:
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: ps_design_system_1.PallasoftClassNameService.merge('flex flex-col gap-2.5', props.className), children: Array.from({ length: lines }, (item, index) => ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": 'true', className: ps_skeleton_class_service_1.PsSkeletonClassService.resolve(ps_skeleton_shape_1.PsSkeletonShape.Line, index === lines - 1 && lines > 1
|
|
34
29
|
? ps_skeleton_config_1.PsSkeletonConfig.lastLineWidth
|
|
35
30
|
: ps_skeleton_config_1.PsSkeletonConfig.lineWidths[index % ps_skeleton_config_1.PsSkeletonConfig.lineWidths.length]), style: style }, index))) }));
|
|
36
31
|
}
|
|
37
|
-
return ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": 'true', className:
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": 'true', className: ps_skeleton_class_service_1.PsSkeletonClassService.resolve(shape, props.className), style: style }));
|
|
38
33
|
};
|
|
39
34
|
exports.PsSkeleton = PsSkeleton;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import type { PsSkeletonSize } from '../models/ps-skeleton-size';
|
|
2
|
+
import { PsSkeletonShape } from './ps-skeleton-shape';
|
|
1
3
|
export declare const PsSkeletonConfig: {
|
|
2
4
|
readonly defaultTextLines: 3;
|
|
3
5
|
readonly lastLineWidth: "w-2/3";
|
|
4
6
|
readonly lineWidths: readonly ["w-3/4", "w-1/2", "w-5/6", "w-2/3"];
|
|
7
|
+
readonly baseClassName: "ps-skeleton";
|
|
8
|
+
readonly classSeparator: RegExp;
|
|
9
|
+
readonly variantSeparator: ":";
|
|
10
|
+
readonly importantPrefix: "!";
|
|
11
|
+
readonly widthUtilityPattern: RegExp;
|
|
12
|
+
readonly heightUtilityPattern: RegExp;
|
|
13
|
+
readonly shapeClassNames: Record<PsSkeletonShape, string>;
|
|
14
|
+
readonly shapeSizes: Record<PsSkeletonShape, PsSkeletonSize>;
|
|
5
15
|
};
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PsSkeletonConfig = void 0;
|
|
4
|
+
const ps_skeleton_shape_1 = require("./ps-skeleton-shape");
|
|
4
5
|
exports.PsSkeletonConfig = {
|
|
5
6
|
defaultTextLines: 3,
|
|
6
7
|
lastLineWidth: 'w-2/3',
|
|
7
8
|
lineWidths: ['w-3/4', 'w-1/2', 'w-5/6', 'w-2/3'],
|
|
9
|
+
baseClassName: 'ps-skeleton',
|
|
10
|
+
classSeparator: /\s+/,
|
|
11
|
+
variantSeparator: ':',
|
|
12
|
+
importantPrefix: '!',
|
|
13
|
+
widthUtilityPattern: /^(w|size)-/,
|
|
14
|
+
heightUtilityPattern: /^(h|size)-/,
|
|
15
|
+
shapeClassNames: {
|
|
16
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Block]: 'rounded-ps-control',
|
|
17
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Circle]: 'shrink-0 rounded-full',
|
|
18
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Line]: 'rounded-full',
|
|
19
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Text]: 'rounded-full',
|
|
20
|
+
},
|
|
21
|
+
shapeSizes: {
|
|
22
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Block]: { height: 'h-11', width: 'w-full' },
|
|
23
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Circle]: { height: 'h-9', width: 'w-9' },
|
|
24
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Line]: { height: 'h-3', width: 'w-full' },
|
|
25
|
+
[ps_skeleton_shape_1.PsSkeletonShape.Text]: { height: 'h-3', width: 'w-full' },
|
|
26
|
+
},
|
|
8
27
|
};
|
|
@@ -2,12 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
|
|
3
3
|
import { PsSkeletonConfig } from '../constants/ps-skeleton-config';
|
|
4
4
|
import { PsSkeletonShape } from '../constants/ps-skeleton-shape';
|
|
5
|
-
|
|
6
|
-
[PsSkeletonShape.Block]: 'h-11 w-full rounded-ps-control',
|
|
7
|
-
[PsSkeletonShape.Circle]: 'h-9 w-9 shrink-0 rounded-full',
|
|
8
|
-
[PsSkeletonShape.Line]: 'h-3 w-full rounded-full',
|
|
9
|
-
[PsSkeletonShape.Text]: 'h-3 w-full rounded-full',
|
|
10
|
-
};
|
|
5
|
+
import { PsSkeletonClassService } from '../services/ps-skeleton-class-service';
|
|
11
6
|
const sizeStyle = (props) => {
|
|
12
7
|
const style = {};
|
|
13
8
|
if (props.width !== undefined)
|
|
@@ -27,9 +22,9 @@ export const PsSkeleton = ({ shape = PsSkeletonShape.Line, ...props }) => {
|
|
|
27
22
|
const style = sizeStyle(props);
|
|
28
23
|
if (shape === PsSkeletonShape.Text) {
|
|
29
24
|
const lines = props.lines !== undefined ? props.lines : PsSkeletonConfig.defaultTextLines;
|
|
30
|
-
return (_jsx("span", { className: PallasoftClassNameService.merge('flex flex-col gap-2.5', props.className), children: Array.from({ length: lines }, (item, index) => (_jsx("span", { "aria-hidden": 'true', className:
|
|
25
|
+
return (_jsx("span", { className: PallasoftClassNameService.merge('flex flex-col gap-2.5', props.className), children: Array.from({ length: lines }, (item, index) => (_jsx("span", { "aria-hidden": 'true', className: PsSkeletonClassService.resolve(PsSkeletonShape.Line, index === lines - 1 && lines > 1
|
|
31
26
|
? PsSkeletonConfig.lastLineWidth
|
|
32
27
|
: PsSkeletonConfig.lineWidths[index % PsSkeletonConfig.lineWidths.length]), style: style }, index))) }));
|
|
33
28
|
}
|
|
34
|
-
return (_jsx("span", { "aria-hidden": 'true', className:
|
|
29
|
+
return (_jsx("span", { "aria-hidden": 'true', className: PsSkeletonClassService.resolve(shape, props.className), style: style }));
|
|
35
30
|
};
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
import { PsSkeletonShape } from './ps-skeleton-shape';
|
|
1
2
|
export const PsSkeletonConfig = {
|
|
2
3
|
defaultTextLines: 3,
|
|
3
4
|
lastLineWidth: 'w-2/3',
|
|
4
5
|
lineWidths: ['w-3/4', 'w-1/2', 'w-5/6', 'w-2/3'],
|
|
6
|
+
baseClassName: 'ps-skeleton',
|
|
7
|
+
classSeparator: /\s+/,
|
|
8
|
+
variantSeparator: ':',
|
|
9
|
+
importantPrefix: '!',
|
|
10
|
+
widthUtilityPattern: /^(w|size)-/,
|
|
11
|
+
heightUtilityPattern: /^(h|size)-/,
|
|
12
|
+
shapeClassNames: {
|
|
13
|
+
[PsSkeletonShape.Block]: 'rounded-ps-control',
|
|
14
|
+
[PsSkeletonShape.Circle]: 'shrink-0 rounded-full',
|
|
15
|
+
[PsSkeletonShape.Line]: 'rounded-full',
|
|
16
|
+
[PsSkeletonShape.Text]: 'rounded-full',
|
|
17
|
+
},
|
|
18
|
+
shapeSizes: {
|
|
19
|
+
[PsSkeletonShape.Block]: { height: 'h-11', width: 'w-full' },
|
|
20
|
+
[PsSkeletonShape.Circle]: { height: 'h-9', width: 'w-9' },
|
|
21
|
+
[PsSkeletonShape.Line]: { height: 'h-3', width: 'w-full' },
|
|
22
|
+
[PsSkeletonShape.Text]: { height: 'h-3', width: 'w-full' },
|
|
23
|
+
},
|
|
5
24
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -24,6 +24,8 @@ export * from './hooks/use-ps-published-height';
|
|
|
24
24
|
export * from './constants/ps-scaled-preview-config';
|
|
25
25
|
export * from './constants/ps-site-header-config';
|
|
26
26
|
export * from './components/ps-skeleton';
|
|
27
|
+
export * from './services/ps-skeleton-class-service';
|
|
28
|
+
export * from './models/ps-skeleton-size';
|
|
27
29
|
export * from './constants/ps-skeleton-shape';
|
|
28
30
|
export * from './components/ps-skeleton-card';
|
|
29
31
|
export * from './components/ps-skeleton-group';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
|
|
2
|
+
import { PsSkeletonConfig } from '../constants/ps-skeleton-config';
|
|
3
|
+
export class PsSkeletonClassService {
|
|
4
|
+
static resolve(shape, className) {
|
|
5
|
+
const utilities = className
|
|
6
|
+
? className
|
|
7
|
+
.split(PsSkeletonConfig.classSeparator)
|
|
8
|
+
.filter((token) => !token.includes(PsSkeletonConfig.variantSeparator))
|
|
9
|
+
.map((token) => PsSkeletonClassService.withoutImportant(token))
|
|
10
|
+
: [];
|
|
11
|
+
const hasWidth = utilities.some((utility) => PsSkeletonConfig.widthUtilityPattern.test(utility));
|
|
12
|
+
const hasHeight = utilities.some((utility) => PsSkeletonConfig.heightUtilityPattern.test(utility));
|
|
13
|
+
const size = PsSkeletonConfig.shapeSizes[shape];
|
|
14
|
+
return PallasoftClassNameService.merge(PsSkeletonConfig.baseClassName, PsSkeletonConfig.shapeClassNames[shape], hasHeight ? null : size.height, hasWidth ? null : size.width, className);
|
|
15
|
+
}
|
|
16
|
+
static withoutImportant(token) {
|
|
17
|
+
return token.startsWith(PsSkeletonConfig.importantPrefix) ? token.slice(1) : token;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export * from './hooks/use-ps-published-height';
|
|
|
24
24
|
export * from './constants/ps-scaled-preview-config';
|
|
25
25
|
export * from './constants/ps-site-header-config';
|
|
26
26
|
export * from './components/ps-skeleton';
|
|
27
|
+
export * from './services/ps-skeleton-class-service';
|
|
28
|
+
export * from './models/ps-skeleton-size';
|
|
27
29
|
export * from './constants/ps-skeleton-shape';
|
|
28
30
|
export * from './components/ps-skeleton-card';
|
|
29
31
|
export * from './components/ps-skeleton-group';
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,8 @@ __exportStar(require("./hooks/use-ps-published-height"), exports);
|
|
|
40
40
|
__exportStar(require("./constants/ps-scaled-preview-config"), exports);
|
|
41
41
|
__exportStar(require("./constants/ps-site-header-config"), exports);
|
|
42
42
|
__exportStar(require("./components/ps-skeleton"), exports);
|
|
43
|
+
__exportStar(require("./services/ps-skeleton-class-service"), exports);
|
|
44
|
+
__exportStar(require("./models/ps-skeleton-size"), exports);
|
|
43
45
|
__exportStar(require("./constants/ps-skeleton-shape"), exports);
|
|
44
46
|
__exportStar(require("./components/ps-skeleton-card"), exports);
|
|
45
47
|
__exportStar(require("./components/ps-skeleton-group"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsSkeletonClassService = void 0;
|
|
4
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
5
|
+
const ps_skeleton_config_1 = require("../constants/ps-skeleton-config");
|
|
6
|
+
class PsSkeletonClassService {
|
|
7
|
+
static resolve(shape, className) {
|
|
8
|
+
const utilities = className
|
|
9
|
+
? className
|
|
10
|
+
.split(ps_skeleton_config_1.PsSkeletonConfig.classSeparator)
|
|
11
|
+
.filter((token) => !token.includes(ps_skeleton_config_1.PsSkeletonConfig.variantSeparator))
|
|
12
|
+
.map((token) => PsSkeletonClassService.withoutImportant(token))
|
|
13
|
+
: [];
|
|
14
|
+
const hasWidth = utilities.some((utility) => ps_skeleton_config_1.PsSkeletonConfig.widthUtilityPattern.test(utility));
|
|
15
|
+
const hasHeight = utilities.some((utility) => ps_skeleton_config_1.PsSkeletonConfig.heightUtilityPattern.test(utility));
|
|
16
|
+
const size = ps_skeleton_config_1.PsSkeletonConfig.shapeSizes[shape];
|
|
17
|
+
return ps_design_system_1.PallasoftClassNameService.merge(ps_skeleton_config_1.PsSkeletonConfig.baseClassName, ps_skeleton_config_1.PsSkeletonConfig.shapeClassNames[shape], hasHeight ? null : size.height, hasWidth ? null : size.width, className);
|
|
18
|
+
}
|
|
19
|
+
static withoutImportant(token) {
|
|
20
|
+
return token.startsWith(ps_skeleton_config_1.PsSkeletonConfig.importantPrefix) ? token.slice(1) : token;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.PsSkeletonClassService = PsSkeletonClassService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pallasoft/ps-core-components",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/esm/index.js",
|
|
13
12
|
"module": "./dist/esm/index.js",
|
|
14
13
|
"require": "./dist/index.js",
|
|
15
14
|
"default": "./dist/index.js"
|