@pallasoft/ps-core-components 2.12.0 → 2.13.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.
- package/dist/components/ps-scaled-preview.d.ts +8 -0
- package/dist/components/ps-scaled-preview.js +14 -0
- package/dist/constants/ps-scaled-preview-config.d.ts +4 -0
- package/dist/constants/ps-scaled-preview-config.js +7 -0
- package/dist/esm/components/ps-scaled-preview.js +10 -0
- package/dist/esm/constants/ps-scaled-preview-config.js +4 -0
- package/dist/esm/hooks/use-ps-element-size.js +14 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/models/ps-element-size.js +1 -0
- package/dist/hooks/use-ps-element-size.d.ts +3 -0
- package/dist/hooks/use-ps-element-size.js +18 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/models/ps-element-size.d.ts +4 -0
- package/dist/models/ps-element-size.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface PsScaledPreviewProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
designWidth?: number;
|
|
6
|
+
isDecorative?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const PsScaledPreview: ({ children, className, designWidth, isDecorative, }: PsScaledPreviewProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsScaledPreview = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
6
|
+
const ps_scaled_preview_config_1 = require("../constants/ps-scaled-preview-config");
|
|
7
|
+
const use_ps_element_size_1 = require("../hooks/use-ps-element-size");
|
|
8
|
+
const PsScaledPreview = ({ children, className, designWidth = ps_scaled_preview_config_1.PsScaledPreviewConfig.designWidth, isDecorative = true, }) => {
|
|
9
|
+
const [frameRef, frame] = (0, use_ps_element_size_1.usePsElementSize)();
|
|
10
|
+
const [contentRef, content] = (0, use_ps_element_size_1.usePsElementSize)();
|
|
11
|
+
const scale = frame.width === 0 ? 0 : Math.min(ps_scaled_preview_config_1.PsScaledPreviewConfig.maxScale, frame.width / designWidth);
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": isDecorative ? 'true' : undefined, className: ps_design_system_1.PallasoftClassNameService.merge('relative w-full overflow-hidden', isDecorative ? 'pointer-events-none select-none' : '', className), ref: frameRef, style: { height: content.height * scale }, children: (0, jsx_runtime_1.jsx)("div", { className: 'absolute top-0 left-0 origin-top-left', ref: contentRef, style: { transform: `scale(${scale})`, width: designWidth }, children: children }) }));
|
|
13
|
+
};
|
|
14
|
+
exports.PsScaledPreview = PsScaledPreview;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
|
|
3
|
+
import { PsScaledPreviewConfig } from '../constants/ps-scaled-preview-config';
|
|
4
|
+
import { usePsElementSize } from '../hooks/use-ps-element-size';
|
|
5
|
+
export const PsScaledPreview = ({ children, className, designWidth = PsScaledPreviewConfig.designWidth, isDecorative = true, }) => {
|
|
6
|
+
const [frameRef, frame] = usePsElementSize();
|
|
7
|
+
const [contentRef, content] = usePsElementSize();
|
|
8
|
+
const scale = frame.width === 0 ? 0 : Math.min(PsScaledPreviewConfig.maxScale, frame.width / designWidth);
|
|
9
|
+
return (_jsx("div", { "aria-hidden": isDecorative ? 'true' : undefined, className: PallasoftClassNameService.merge('relative w-full overflow-hidden', isDecorative ? 'pointer-events-none select-none' : '', className), ref: frameRef, style: { height: content.height * scale }, children: _jsx("div", { className: 'absolute top-0 left-0 origin-top-left', ref: contentRef, style: { transform: `scale(${scale})`, width: designWidth }, children: children }) }));
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
export const usePsElementSize = () => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
const [size, setSize] = useState({ height: 0, width: 0 });
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const node = ref.current;
|
|
7
|
+
if (node === null)
|
|
8
|
+
return;
|
|
9
|
+
const observer = new ResizeObserver(([entry]) => setSize({ height: entry.contentRect.height, width: entry.contentRect.width }));
|
|
10
|
+
observer.observe(node);
|
|
11
|
+
return () => observer.disconnect();
|
|
12
|
+
}, []);
|
|
13
|
+
return [ref, size];
|
|
14
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -15,11 +15,13 @@ export * from './components/ps-metric-card';
|
|
|
15
15
|
export * from './components/ps-pill';
|
|
16
16
|
export * from './components/ps-portable-text';
|
|
17
17
|
export * from './components/ps-reflective-app-shell';
|
|
18
|
+
export * from './components/ps-scaled-preview';
|
|
18
19
|
export * from './components/ps-navigation-progress';
|
|
19
20
|
export * from './components/ps-step-progress';
|
|
20
21
|
export * from './components/ps-section-header';
|
|
21
22
|
export * from './components/ps-site-header';
|
|
22
23
|
export * from './hooks/use-ps-published-height';
|
|
24
|
+
export * from './constants/ps-scaled-preview-config';
|
|
23
25
|
export * from './constants/ps-site-header-config';
|
|
24
26
|
export * from './components/ps-skeleton';
|
|
25
27
|
export * from './constants/ps-skeleton-shape';
|
|
@@ -39,8 +41,10 @@ export * from './hooks/use-ps-invisible-recaptcha';
|
|
|
39
41
|
export * from './contexts/ps-layer-context';
|
|
40
42
|
export * from './hooks/use-ps-layer-z-index';
|
|
41
43
|
export * from './hooks/use-ps-route-loader-data';
|
|
44
|
+
export * from './hooks/use-ps-element-size';
|
|
42
45
|
export * from './hooks/use-ps-viewport';
|
|
43
46
|
export * from './interfaces/ps-component-props';
|
|
47
|
+
export * from './models/ps-element-size';
|
|
44
48
|
export * from './models/ps-voice-orb';
|
|
45
49
|
export * from './models/ps-navigation-progress';
|
|
46
50
|
export * from './hooks/use-ps-debounced-value';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsElementSize = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const usePsElementSize = () => {
|
|
6
|
+
const ref = (0, react_1.useRef)(null);
|
|
7
|
+
const [size, setSize] = (0, react_1.useState)({ height: 0, width: 0 });
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
const node = ref.current;
|
|
10
|
+
if (node === null)
|
|
11
|
+
return;
|
|
12
|
+
const observer = new ResizeObserver(([entry]) => setSize({ height: entry.contentRect.height, width: entry.contentRect.width }));
|
|
13
|
+
observer.observe(node);
|
|
14
|
+
return () => observer.disconnect();
|
|
15
|
+
}, []);
|
|
16
|
+
return [ref, size];
|
|
17
|
+
};
|
|
18
|
+
exports.usePsElementSize = usePsElementSize;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,11 +15,13 @@ export * from './components/ps-metric-card';
|
|
|
15
15
|
export * from './components/ps-pill';
|
|
16
16
|
export * from './components/ps-portable-text';
|
|
17
17
|
export * from './components/ps-reflective-app-shell';
|
|
18
|
+
export * from './components/ps-scaled-preview';
|
|
18
19
|
export * from './components/ps-navigation-progress';
|
|
19
20
|
export * from './components/ps-step-progress';
|
|
20
21
|
export * from './components/ps-section-header';
|
|
21
22
|
export * from './components/ps-site-header';
|
|
22
23
|
export * from './hooks/use-ps-published-height';
|
|
24
|
+
export * from './constants/ps-scaled-preview-config';
|
|
23
25
|
export * from './constants/ps-site-header-config';
|
|
24
26
|
export * from './components/ps-skeleton';
|
|
25
27
|
export * from './constants/ps-skeleton-shape';
|
|
@@ -39,8 +41,10 @@ export * from './hooks/use-ps-invisible-recaptcha';
|
|
|
39
41
|
export * from './contexts/ps-layer-context';
|
|
40
42
|
export * from './hooks/use-ps-layer-z-index';
|
|
41
43
|
export * from './hooks/use-ps-route-loader-data';
|
|
44
|
+
export * from './hooks/use-ps-element-size';
|
|
42
45
|
export * from './hooks/use-ps-viewport';
|
|
43
46
|
export * from './interfaces/ps-component-props';
|
|
47
|
+
export * from './models/ps-element-size';
|
|
44
48
|
export * from './models/ps-voice-orb';
|
|
45
49
|
export * from './models/ps-navigation-progress';
|
|
46
50
|
export * from './hooks/use-ps-debounced-value';
|
package/dist/index.js
CHANGED
|
@@ -31,11 +31,13 @@ __exportStar(require("./components/ps-metric-card"), exports);
|
|
|
31
31
|
__exportStar(require("./components/ps-pill"), exports);
|
|
32
32
|
__exportStar(require("./components/ps-portable-text"), exports);
|
|
33
33
|
__exportStar(require("./components/ps-reflective-app-shell"), exports);
|
|
34
|
+
__exportStar(require("./components/ps-scaled-preview"), exports);
|
|
34
35
|
__exportStar(require("./components/ps-navigation-progress"), exports);
|
|
35
36
|
__exportStar(require("./components/ps-step-progress"), exports);
|
|
36
37
|
__exportStar(require("./components/ps-section-header"), exports);
|
|
37
38
|
__exportStar(require("./components/ps-site-header"), exports);
|
|
38
39
|
__exportStar(require("./hooks/use-ps-published-height"), exports);
|
|
40
|
+
__exportStar(require("./constants/ps-scaled-preview-config"), exports);
|
|
39
41
|
__exportStar(require("./constants/ps-site-header-config"), exports);
|
|
40
42
|
__exportStar(require("./components/ps-skeleton"), exports);
|
|
41
43
|
__exportStar(require("./constants/ps-skeleton-shape"), exports);
|
|
@@ -55,8 +57,10 @@ __exportStar(require("./hooks/use-ps-invisible-recaptcha"), exports);
|
|
|
55
57
|
__exportStar(require("./contexts/ps-layer-context"), exports);
|
|
56
58
|
__exportStar(require("./hooks/use-ps-layer-z-index"), exports);
|
|
57
59
|
__exportStar(require("./hooks/use-ps-route-loader-data"), exports);
|
|
60
|
+
__exportStar(require("./hooks/use-ps-element-size"), exports);
|
|
58
61
|
__exportStar(require("./hooks/use-ps-viewport"), exports);
|
|
59
62
|
__exportStar(require("./interfaces/ps-component-props"), exports);
|
|
63
|
+
__exportStar(require("./models/ps-element-size"), exports);
|
|
60
64
|
__exportStar(require("./models/ps-voice-orb"), exports);
|
|
61
65
|
__exportStar(require("./models/ps-navigation-progress"), exports);
|
|
62
66
|
__exportStar(require("./hooks/use-ps-debounced-value"), exports);
|