@pallasoft/ps-core-components 2.12.0 → 2.13.1
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/components/ps-site-header.js +1 -1
- 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/components/ps-site-header.js +1 -1
- 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;
|
|
@@ -10,7 +10,7 @@ const logoLinkClassName = 'flex shrink-0 items-center gap-2.5';
|
|
|
10
10
|
const PsSiteHeader = ({ centerContent, className, homeHref, label, LinkComponent, logoAlt, logoClassName, logoSrc, logoSrcDark, logoSrcMobile, logoSrcMobileDark, navClassName, onBack, showLabel = false, trailing, }) => {
|
|
11
11
|
const headerRef = (0, use_ps_published_height_1.usePsPublishedHeight)(ps_site_header_config_1.PsSiteHeaderConfig.heightVariable);
|
|
12
12
|
const logoLabel = `${label} home`;
|
|
13
|
-
const renderLogo = (src, darkSrc, baseClassName) => darkSrc ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: ps_design_system_1.PallasoftClassNameService.merge(baseClassName, 'dark:hidden', logoClassName), src: src }), (0, jsx_runtime_1.jsx)("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: ps_design_system_1.PallasoftClassNameService.merge(baseClassName, 'hidden dark:block', logoClassName), src: darkSrc })] })) : ((0, jsx_runtime_1.jsx)("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: ps_design_system_1.PallasoftClassNameService.merge(baseClassName, logoClassName), src: src }));
|
|
13
|
+
const renderLogo = (src, darkSrc, baseClassName) => darkSrc ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: ps_design_system_1.PallasoftClassNameService.merge(baseClassName, 'dark:hidden', logoClassName), decoding: 'async', fetchPriority: 'high', src: src }), (0, jsx_runtime_1.jsx)("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: ps_design_system_1.PallasoftClassNameService.merge(baseClassName, 'hidden dark:block', logoClassName), decoding: 'async', fetchPriority: 'high', src: darkSrc })] })) : ((0, jsx_runtime_1.jsx)("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: ps_design_system_1.PallasoftClassNameService.merge(baseClassName, logoClassName), decoding: 'async', fetchPriority: 'high', src: src }));
|
|
14
14
|
const logoContent = logoSrcMobile ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: 'hidden sm:contents', children: renderLogo(logoSrc, logoSrcDark, 'h-8 w-auto') }), (0, jsx_runtime_1.jsx)("span", { className: 'contents sm:hidden', children: renderLogo(logoSrcMobile, logoSrcMobileDark, 'h-8 w-auto') }), showLabel ? (0, jsx_runtime_1.jsx)("span", { className: 'text-base font-bold text-ink', children: label }) : null] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [renderLogo(logoSrc, logoSrcDark, 'h-8 w-auto'), showLabel ? (0, jsx_runtime_1.jsx)("span", { className: 'text-base font-bold text-ink', children: label }) : null] }));
|
|
15
15
|
const logoLink = LinkComponent ? ((0, jsx_runtime_1.jsx)(LinkComponent, { "aria-label": logoLabel, className: logoLinkClassName, to: homeHref, children: logoContent })) : ((0, jsx_runtime_1.jsx)("a", { "aria-label": logoLabel, className: logoLinkClassName, href: homeHref, children: logoContent }));
|
|
16
16
|
return ((0, jsx_runtime_1.jsx)("header", { ref: headerRef, className: ps_design_system_1.PallasoftClassNameService.merge('fixed inset-x-0 top-0 z-header px-6 pt-4', className), children: (0, jsx_runtime_1.jsxs)("nav", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-glass mx-auto flex max-w-6xl items-center gap-3 rounded-ps-card px-5 py-3', navClassName), children: [onBack ? ((0, jsx_runtime_1.jsx)("button", { "aria-label": 'Back', className: 'ps-focus-ring flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-ink md:hidden', onClick: onBack, type: 'button', children: (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { iconKey: ps_icons_1.PsIconKey.ChevronRight, width: 20, height: 20, className: 'rotate-180' }) })) : null, (0, jsx_runtime_1.jsx)("div", { className: onBack ? 'hidden md:flex' : 'contents', children: logoLink }), (0, jsx_runtime_1.jsx)("div", { className: 'flex min-w-0 flex-1 items-center justify-center gap-3', children: centerContent }), trailing ? (0, jsx_runtime_1.jsx)("div", { className: 'flex shrink-0 items-center gap-2.5', children: trailing }) : null] }) }));
|
|
@@ -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
|
+
};
|
|
@@ -7,7 +7,7 @@ const logoLinkClassName = 'flex shrink-0 items-center gap-2.5';
|
|
|
7
7
|
export const PsSiteHeader = ({ centerContent, className, homeHref, label, LinkComponent, logoAlt, logoClassName, logoSrc, logoSrcDark, logoSrcMobile, logoSrcMobileDark, navClassName, onBack, showLabel = false, trailing, }) => {
|
|
8
8
|
const headerRef = usePsPublishedHeight(PsSiteHeaderConfig.heightVariable);
|
|
9
9
|
const logoLabel = `${label} home`;
|
|
10
|
-
const renderLogo = (src, darkSrc, baseClassName) => darkSrc ? (_jsxs(_Fragment, { children: [_jsx("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: PallasoftClassNameService.merge(baseClassName, 'dark:hidden', logoClassName), src: src }), _jsx("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: PallasoftClassNameService.merge(baseClassName, 'hidden dark:block', logoClassName), src: darkSrc })] })) : (_jsx("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: PallasoftClassNameService.merge(baseClassName, logoClassName), src: src }));
|
|
10
|
+
const renderLogo = (src, darkSrc, baseClassName) => darkSrc ? (_jsxs(_Fragment, { children: [_jsx("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: PallasoftClassNameService.merge(baseClassName, 'dark:hidden', logoClassName), decoding: 'async', fetchPriority: 'high', src: src }), _jsx("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: PallasoftClassNameService.merge(baseClassName, 'hidden dark:block', logoClassName), decoding: 'async', fetchPriority: 'high', src: darkSrc })] })) : (_jsx("img", { alt: logoAlt !== null && logoAlt !== undefined ? logoAlt : label, className: PallasoftClassNameService.merge(baseClassName, logoClassName), decoding: 'async', fetchPriority: 'high', src: src }));
|
|
11
11
|
const logoContent = logoSrcMobile ? (_jsxs(_Fragment, { children: [_jsx("span", { className: 'hidden sm:contents', children: renderLogo(logoSrc, logoSrcDark, 'h-8 w-auto') }), _jsx("span", { className: 'contents sm:hidden', children: renderLogo(logoSrcMobile, logoSrcMobileDark, 'h-8 w-auto') }), showLabel ? _jsx("span", { className: 'text-base font-bold text-ink', children: label }) : null] })) : (_jsxs(_Fragment, { children: [renderLogo(logoSrc, logoSrcDark, 'h-8 w-auto'), showLabel ? _jsx("span", { className: 'text-base font-bold text-ink', children: label }) : null] }));
|
|
12
12
|
const logoLink = LinkComponent ? (_jsx(LinkComponent, { "aria-label": logoLabel, className: logoLinkClassName, to: homeHref, children: logoContent })) : (_jsx("a", { "aria-label": logoLabel, className: logoLinkClassName, href: homeHref, children: logoContent }));
|
|
13
13
|
return (_jsx("header", { ref: headerRef, className: PallasoftClassNameService.merge('fixed inset-x-0 top-0 z-header px-6 pt-4', className), children: _jsxs("nav", { className: PallasoftClassNameService.merge('ps-glass mx-auto flex max-w-6xl items-center gap-3 rounded-ps-card px-5 py-3', navClassName), children: [onBack ? (_jsx("button", { "aria-label": 'Back', className: 'ps-focus-ring flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-ink md:hidden', onClick: onBack, type: 'button', children: _jsx(PsIcon, { iconKey: PsIconKey.ChevronRight, width: 20, height: 20, className: 'rotate-180' }) })) : null, _jsx("div", { className: onBack ? 'hidden md:flex' : 'contents', children: logoLink }), _jsx("div", { className: 'flex min-w-0 flex-1 items-center justify-center gap-3', children: centerContent }), trailing ? _jsx("div", { className: 'flex shrink-0 items-center gap-2.5', children: trailing }) : null] }) }));
|
|
@@ -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);
|