@pallasoft/ps-core-components 2.8.1 → 2.10.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.
@@ -4,12 +4,15 @@ exports.PsSiteHeader = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const ps_design_system_1 = require("@pallasoft/ps-design-system");
6
6
  const ps_icons_1 = require("@pallasoft/ps-icons");
7
+ const ps_site_header_config_1 = require("../constants/ps-site-header-config");
8
+ const use_ps_published_height_1 = require("../hooks/use-ps-published-height");
7
9
  const logoLinkClassName = 'flex shrink-0 items-center gap-2.5';
8
10
  const PsSiteHeader = ({ centerContent, className, homeHref, label, LinkComponent, logoAlt, logoClassName, logoSrc, logoSrcDark, logoSrcMobile, logoSrcMobileDark, navClassName, onBack, showLabel = false, trailing, }) => {
11
+ const headerRef = (0, use_ps_published_height_1.usePsPublishedHeight)(ps_site_header_config_1.PsSiteHeaderConfig.heightVariable);
9
12
  const logoLabel = `${label} home`;
10
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 }));
11
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] }));
12
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 }));
13
- return ((0, jsx_runtime_1.jsx)("header", { 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] }) }));
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] }) }));
14
17
  };
15
18
  exports.PsSiteHeader = PsSiteHeader;
@@ -0,0 +1,3 @@
1
+ export declare const PsSiteHeaderConfig: {
2
+ readonly heightVariable: "--ps-site-header-height";
3
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsSiteHeaderConfig = void 0;
4
+ exports.PsSiteHeaderConfig = {
5
+ heightVariable: '--ps-site-header-height',
6
+ };
@@ -1,11 +1,14 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
3
3
  import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
4
+ import { PsSiteHeaderConfig } from '../constants/ps-site-header-config';
5
+ import { usePsPublishedHeight } from '../hooks/use-ps-published-height';
4
6
  const logoLinkClassName = 'flex shrink-0 items-center gap-2.5';
5
7
  export const PsSiteHeader = ({ centerContent, className, homeHref, label, LinkComponent, logoAlt, logoClassName, logoSrc, logoSrcDark, logoSrcMobile, logoSrcMobileDark, navClassName, onBack, showLabel = false, trailing, }) => {
8
+ const headerRef = usePsPublishedHeight(PsSiteHeaderConfig.heightVariable);
6
9
  const logoLabel = `${label} home`;
7
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 }));
8
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] }));
9
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 }));
10
- return (_jsx("header", { 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] }) }));
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] }) }));
11
14
  };
@@ -0,0 +1,3 @@
1
+ export const PsSiteHeaderConfig = {
2
+ heightVariable: '--ps-site-header-height',
3
+ };
@@ -0,0 +1,11 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Client } from '@pallasoft/ps-utilities';
3
+ export const usePsDebouncedValue = (value, waitMs) => {
4
+ const [settled, setSettled] = useState(value);
5
+ useEffect(() => {
6
+ const debounced = Client.DebounceService.create((next) => setSettled(next), waitMs);
7
+ debounced.run(value);
8
+ return debounced.cancel;
9
+ }, [value, waitMs]);
10
+ return settled;
11
+ };
@@ -0,0 +1,15 @@
1
+ import { useEffect, useRef } from 'react';
2
+ export const usePsPublishedHeight = (variableName) => {
3
+ const elementRef = useRef(null);
4
+ useEffect(() => {
5
+ const element = elementRef.current;
6
+ if (element === null || typeof ResizeObserver === 'undefined')
7
+ return;
8
+ const publish = () => document.documentElement.style.setProperty(variableName, `${element.offsetHeight}px`);
9
+ publish();
10
+ const observer = new ResizeObserver(publish);
11
+ observer.observe(element);
12
+ return () => observer.disconnect();
13
+ }, [variableName]);
14
+ return elementRef;
15
+ };
package/dist/esm/index.js CHANGED
@@ -19,6 +19,8 @@ export * from './components/ps-navigation-progress';
19
19
  export * from './components/ps-step-progress';
20
20
  export * from './components/ps-section-header';
21
21
  export * from './components/ps-site-header';
22
+ export * from './hooks/use-ps-published-height';
23
+ export * from './constants/ps-site-header-config';
22
24
  export * from './components/ps-skeleton';
23
25
  export * from './constants/ps-skeleton-shape';
24
26
  export * from './components/ps-skeleton-card';
@@ -41,6 +43,7 @@ export * from './hooks/use-ps-viewport';
41
43
  export * from './interfaces/ps-component-props';
42
44
  export * from './models/ps-voice-orb';
43
45
  export * from './models/ps-navigation-progress';
46
+ export * from './hooks/use-ps-debounced-value';
44
47
  export * from './hooks/use-ps-navigation-progress';
45
48
  export * from './models/ps-draggable-grid';
46
49
  export * from './constants/ps-draggable-grid';
@@ -0,0 +1 @@
1
+ export declare const usePsDebouncedValue: <T>(value: T, waitMs: number) => T;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePsDebouncedValue = void 0;
4
+ const react_1 = require("react");
5
+ const ps_utilities_1 = require("@pallasoft/ps-utilities");
6
+ const usePsDebouncedValue = (value, waitMs) => {
7
+ const [settled, setSettled] = (0, react_1.useState)(value);
8
+ (0, react_1.useEffect)(() => {
9
+ const debounced = ps_utilities_1.Client.DebounceService.create((next) => setSettled(next), waitMs);
10
+ debounced.run(value);
11
+ return debounced.cancel;
12
+ }, [value, waitMs]);
13
+ return settled;
14
+ };
15
+ exports.usePsDebouncedValue = usePsDebouncedValue;
@@ -0,0 +1 @@
1
+ export declare const usePsPublishedHeight: <T extends HTMLElement>(variableName: string) => import("react").MutableRefObject<T | null>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePsPublishedHeight = void 0;
4
+ const react_1 = require("react");
5
+ const usePsPublishedHeight = (variableName) => {
6
+ const elementRef = (0, react_1.useRef)(null);
7
+ (0, react_1.useEffect)(() => {
8
+ const element = elementRef.current;
9
+ if (element === null || typeof ResizeObserver === 'undefined')
10
+ return;
11
+ const publish = () => document.documentElement.style.setProperty(variableName, `${element.offsetHeight}px`);
12
+ publish();
13
+ const observer = new ResizeObserver(publish);
14
+ observer.observe(element);
15
+ return () => observer.disconnect();
16
+ }, [variableName]);
17
+ return elementRef;
18
+ };
19
+ exports.usePsPublishedHeight = usePsPublishedHeight;
package/dist/index.d.ts CHANGED
@@ -19,6 +19,8 @@ export * from './components/ps-navigation-progress';
19
19
  export * from './components/ps-step-progress';
20
20
  export * from './components/ps-section-header';
21
21
  export * from './components/ps-site-header';
22
+ export * from './hooks/use-ps-published-height';
23
+ export * from './constants/ps-site-header-config';
22
24
  export * from './components/ps-skeleton';
23
25
  export * from './constants/ps-skeleton-shape';
24
26
  export * from './components/ps-skeleton-card';
@@ -41,6 +43,7 @@ export * from './hooks/use-ps-viewport';
41
43
  export * from './interfaces/ps-component-props';
42
44
  export * from './models/ps-voice-orb';
43
45
  export * from './models/ps-navigation-progress';
46
+ export * from './hooks/use-ps-debounced-value';
44
47
  export * from './hooks/use-ps-navigation-progress';
45
48
  export * from './models/ps-draggable-grid';
46
49
  export * from './constants/ps-draggable-grid';
package/dist/index.js CHANGED
@@ -35,6 +35,8 @@ __exportStar(require("./components/ps-navigation-progress"), exports);
35
35
  __exportStar(require("./components/ps-step-progress"), exports);
36
36
  __exportStar(require("./components/ps-section-header"), exports);
37
37
  __exportStar(require("./components/ps-site-header"), exports);
38
+ __exportStar(require("./hooks/use-ps-published-height"), exports);
39
+ __exportStar(require("./constants/ps-site-header-config"), exports);
38
40
  __exportStar(require("./components/ps-skeleton"), exports);
39
41
  __exportStar(require("./constants/ps-skeleton-shape"), exports);
40
42
  __exportStar(require("./components/ps-skeleton-card"), exports);
@@ -57,6 +59,7 @@ __exportStar(require("./hooks/use-ps-viewport"), exports);
57
59
  __exportStar(require("./interfaces/ps-component-props"), exports);
58
60
  __exportStar(require("./models/ps-voice-orb"), exports);
59
61
  __exportStar(require("./models/ps-navigation-progress"), exports);
62
+ __exportStar(require("./hooks/use-ps-debounced-value"), exports);
60
63
  __exportStar(require("./hooks/use-ps-navigation-progress"), exports);
61
64
  __exportStar(require("./models/ps-draggable-grid"), exports);
62
65
  __exportStar(require("./constants/ps-draggable-grid"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-core-components",
3
- "version": "2.8.1",
3
+ "version": "2.10.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -36,6 +36,7 @@
36
36
  "@dnd-kit/utilities": "^3.2.2",
37
37
  "@pallasoft/ps-design-system": "^1.3.0",
38
38
  "@pallasoft/ps-icons": "^1.1.0",
39
+ "@pallasoft/ps-utilities": "^2.2.0",
39
40
  "@portabletext/react": "^3.2.4",
40
41
  "@portabletext/types": "^2.0.13",
41
42
  "@radix-ui/react-accordion": "^1.2.12",