@pallasoft/ps-core-components 2.11.3 → 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.
@@ -12,6 +12,6 @@ const PsReflectiveAppShell = ({ children, className, contentClassName, frameClas
12
12
  contentRef.current?.scrollTo({ top: 0, left: 0 });
13
13
  window.scrollTo({ top: 0, left: 0 });
14
14
  }, [scrollResetKey]);
15
- return ((0, jsx_runtime_1.jsx)("section", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-reflective-frame h-[100dvh] overflow-hidden text-ink lg:px-3 lg:py-3', className), children: (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-liquid-strong mx-auto grid h-full min-h-0 overflow-hidden border-line/70 bg-white/70 backdrop-blur-2xl transition-[grid-template-columns] duration-200 dark:border-white/10 dark:bg-surface/70 md:grid-cols-[var(--ps-sidebar-width)_minmax(0,1fr)] lg:max-w-[1720px] lg:rounded-[1.5rem] lg:border', frameClassName), style: { ['--ps-sidebar-width']: sidebarWidth }, children: [sidebar, (0, jsx_runtime_1.jsxs)("div", { className: 'flex min-h-0 min-w-0 flex-col bg-white/32 dark:bg-white/[0.02]', children: [topbar, (0, jsx_runtime_1.jsx)("main", { ref: contentRef, className: ps_design_system_1.PallasoftClassNameService.merge('ps-scrollbar min-h-0 flex-1 overflow-y-auto px-4 py-5 ps-page-enter sm:px-5 lg:px-6 xl:px-7', contentClassName), children: children })] })] }) }));
15
+ return ((0, jsx_runtime_1.jsx)("section", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-reflective-frame h-[100dvh] overflow-hidden text-ink', className), children: (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-liquid-strong grid h-full min-h-0 w-full overflow-hidden border-line/70 bg-white/70 backdrop-blur-2xl transition-[grid-template-columns] duration-200 dark:border-white/10 dark:bg-surface/70 md:grid-cols-[var(--ps-sidebar-width)_minmax(0,1fr)]', frameClassName), style: { ['--ps-sidebar-width']: sidebarWidth }, children: [sidebar, (0, jsx_runtime_1.jsxs)("div", { className: 'flex min-h-0 min-w-0 flex-col bg-white/32 dark:bg-white/[0.02]', children: [topbar, (0, jsx_runtime_1.jsx)("main", { ref: contentRef, className: ps_design_system_1.PallasoftClassNameService.merge('ps-scrollbar min-h-0 flex-1 overflow-y-auto px-4 py-5 ps-page-enter sm:px-5 lg:px-6 xl:px-7', contentClassName), children: children })] })] }) }));
16
16
  };
17
17
  exports.PsReflectiveAppShell = PsReflectiveAppShell;
@@ -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,4 @@
1
+ export declare const PsScaledPreviewConfig: {
2
+ readonly designWidth: 880;
3
+ readonly maxScale: 1;
4
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsScaledPreviewConfig = void 0;
4
+ exports.PsScaledPreviewConfig = {
5
+ designWidth: 880,
6
+ maxScale: 1,
7
+ };
@@ -9,5 +9,5 @@ export const PsReflectiveAppShell = ({ children, className, contentClassName, fr
9
9
  contentRef.current?.scrollTo({ top: 0, left: 0 });
10
10
  window.scrollTo({ top: 0, left: 0 });
11
11
  }, [scrollResetKey]);
12
- return (_jsx("section", { className: PallasoftClassNameService.merge('ps-reflective-frame h-[100dvh] overflow-hidden text-ink lg:px-3 lg:py-3', className), children: _jsxs("div", { className: PallasoftClassNameService.merge('ps-liquid-strong mx-auto grid h-full min-h-0 overflow-hidden border-line/70 bg-white/70 backdrop-blur-2xl transition-[grid-template-columns] duration-200 dark:border-white/10 dark:bg-surface/70 md:grid-cols-[var(--ps-sidebar-width)_minmax(0,1fr)] lg:max-w-[1720px] lg:rounded-[1.5rem] lg:border', frameClassName), style: { ['--ps-sidebar-width']: sidebarWidth }, children: [sidebar, _jsxs("div", { className: 'flex min-h-0 min-w-0 flex-col bg-white/32 dark:bg-white/[0.02]', children: [topbar, _jsx("main", { ref: contentRef, className: PallasoftClassNameService.merge('ps-scrollbar min-h-0 flex-1 overflow-y-auto px-4 py-5 ps-page-enter sm:px-5 lg:px-6 xl:px-7', contentClassName), children: children })] })] }) }));
12
+ return (_jsx("section", { className: PallasoftClassNameService.merge('ps-reflective-frame h-[100dvh] overflow-hidden text-ink', className), children: _jsxs("div", { className: PallasoftClassNameService.merge('ps-liquid-strong grid h-full min-h-0 w-full overflow-hidden border-line/70 bg-white/70 backdrop-blur-2xl transition-[grid-template-columns] duration-200 dark:border-white/10 dark:bg-surface/70 md:grid-cols-[var(--ps-sidebar-width)_minmax(0,1fr)]', frameClassName), style: { ['--ps-sidebar-width']: sidebarWidth }, children: [sidebar, _jsxs("div", { className: 'flex min-h-0 min-w-0 flex-col bg-white/32 dark:bg-white/[0.02]', children: [topbar, _jsx("main", { ref: contentRef, className: PallasoftClassNameService.merge('ps-scrollbar min-h-0 flex-1 overflow-y-auto px-4 py-5 ps-page-enter sm:px-5 lg:px-6 xl:px-7', contentClassName), children: children })] })] }) }));
13
13
  };
@@ -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,4 @@
1
+ export const PsScaledPreviewConfig = {
2
+ designWidth: 880,
3
+ maxScale: 1,
4
+ };
@@ -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,3 @@
1
+ import { type RefObject } from 'react';
2
+ import { PsElementSize } from '../models/ps-element-size';
3
+ export declare const usePsElementSize: <Element extends HTMLElement>() => [RefObject<Element>, PsElementSize];
@@ -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);
@@ -0,0 +1,4 @@
1
+ export interface PsElementSize {
2
+ height: number;
3
+ width: number;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-core-components",
3
- "version": "2.11.3",
3
+ "version": "2.13.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.js",