@pallasoft/ps-core-components 2.44.0 → 2.44.2

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,8 +4,10 @@ exports.PsDragOverlay = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const core_1 = require("@dnd-kit/core");
7
+ const ps_design_system_1 = require("@pallasoft/ps-design-system");
7
8
  const react_dom_1 = require("react-dom");
8
9
  const ps_drag_config_1 = require("../constants/ps-drag-config");
10
+ const use_ps_layer_z_index_1 = require("../hooks/use-ps-layer-z-index");
9
11
  const use_ps_reduced_motion_1 = require("../hooks/use-ps-reduced-motion");
10
12
  const dropAnimation = {
11
13
  duration: ps_drag_config_1.PsDragConfig.dropDuration,
@@ -17,6 +19,7 @@ const dropAnimation = {
17
19
  const PsDragOverlay = ({ children, className, frames, isDropAnimated, }) => {
18
20
  const [isMounted, setIsMounted] = (0, react_1.useState)(false);
19
21
  const isReduced = (0, use_ps_reduced_motion_1.usePsReducedMotion)();
22
+ const zIndex = (0, use_ps_layer_z_index_1.usePsLayerZIndex)(ps_design_system_1.PallasoftZIndex.Popover);
20
23
  (0, react_1.useEffect)(() => setIsMounted(true), []);
21
24
  if (!isMounted)
22
25
  return null;
@@ -29,6 +32,6 @@ const PsDragOverlay = ({ children, className, frames, isDropAnimated, }) => {
29
32
  fill: 'forwards',
30
33
  });
31
34
  };
32
- return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, children: children === null ? null : ((0, jsx_runtime_1.jsx)("div", { className: className, ref: lift, children: children })) }), document.body);
35
+ return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, zIndex: zIndex, children: children === null ? null : ((0, jsx_runtime_1.jsx)("div", { className: className, ref: lift, children: children })) }), document.body);
33
36
  };
34
37
  exports.PsDragOverlay = PsDragOverlay;
@@ -9,15 +9,15 @@ exports.PsButtonSizeClassNames = {
9
9
  };
10
10
  exports.PsButtonVariantClassNames = {
11
11
  danger: 'border-danger bg-danger text-white enabled:hover:opacity-90',
12
- ghost: 'ps-liquid ps-liquid-control bg-white/72 text-ink enabled:hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
12
+ ghost: 'ps-control-surface text-ink enabled:hover:border-primary/40',
13
13
  primary: 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)] enabled:hover:border-primary-dark enabled:hover:bg-primary-dark',
14
- secondary: 'ps-liquid ps-liquid-control bg-white/72 text-ink enabled:hover:border-primary/30 enabled:hover:text-primary dark:border-white/16 dark:bg-white/12 dark:enabled:hover:text-white',
15
- surface: 'ps-liquid ps-liquid-control bg-white/72 text-ink enabled:hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
14
+ secondary: 'ps-control-surface text-ink enabled:hover:border-primary/40 enabled:hover:text-primary dark:enabled:hover:text-white',
15
+ surface: 'ps-control-surface text-ink enabled:hover:border-primary/40',
16
16
  };
17
17
  exports.PsLinkButtonVariantClassNames = {
18
18
  danger: 'border-danger bg-danger text-white hover:opacity-90',
19
- ghost: 'ps-liquid ps-liquid-control bg-white/72 text-ink hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
19
+ ghost: 'ps-control-surface text-ink hover:border-primary/40',
20
20
  primary: 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)] hover:border-primary-dark hover:bg-primary-dark',
21
- secondary: 'ps-liquid ps-liquid-control bg-white/72 text-ink hover:border-primary/30 hover:text-primary dark:border-white/16 dark:bg-white/12 dark:hover:text-white',
22
- surface: 'ps-liquid ps-liquid-control bg-white/72 text-ink hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
21
+ secondary: 'ps-control-surface text-ink hover:border-primary/40 hover:text-primary dark:hover:text-white',
22
+ surface: 'ps-control-surface text-ink hover:border-primary/40',
23
23
  };
@@ -1,8 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { DragOverlay, defaultDropAnimationSideEffects } from '@dnd-kit/core';
4
+ import { PallasoftZIndex } from '@pallasoft/ps-design-system';
4
5
  import { createPortal } from 'react-dom';
5
6
  import { PsDragConfig } from '../constants/ps-drag-config.js';
7
+ import { usePsLayerZIndex } from '../hooks/use-ps-layer-z-index.js';
6
8
  import { usePsReducedMotion } from '../hooks/use-ps-reduced-motion.js';
7
9
  const dropAnimation = {
8
10
  duration: PsDragConfig.dropDuration,
@@ -14,6 +16,7 @@ const dropAnimation = {
14
16
  export const PsDragOverlay = ({ children, className, frames, isDropAnimated, }) => {
15
17
  const [isMounted, setIsMounted] = useState(false);
16
18
  const isReduced = usePsReducedMotion();
19
+ const zIndex = usePsLayerZIndex(PallasoftZIndex.Popover);
17
20
  useEffect(() => setIsMounted(true), []);
18
21
  if (!isMounted)
19
22
  return null;
@@ -26,5 +29,5 @@ export const PsDragOverlay = ({ children, className, frames, isDropAnimated, })
26
29
  fill: 'forwards',
27
30
  });
28
31
  };
29
- return createPortal(_jsx(DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, children: children === null ? null : (_jsx("div", { className: className, ref: lift, children: children })) }), document.body);
32
+ return createPortal(_jsx(DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, zIndex: zIndex, children: children === null ? null : (_jsx("div", { className: className, ref: lift, children: children })) }), document.body);
30
33
  };
@@ -6,15 +6,15 @@ export const PsButtonSizeClassNames = {
6
6
  };
7
7
  export const PsButtonVariantClassNames = {
8
8
  danger: 'border-danger bg-danger text-white enabled:hover:opacity-90',
9
- ghost: 'ps-liquid ps-liquid-control bg-white/72 text-ink enabled:hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
9
+ ghost: 'ps-control-surface text-ink enabled:hover:border-primary/40',
10
10
  primary: 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)] enabled:hover:border-primary-dark enabled:hover:bg-primary-dark',
11
- secondary: 'ps-liquid ps-liquid-control bg-white/72 text-ink enabled:hover:border-primary/30 enabled:hover:text-primary dark:border-white/16 dark:bg-white/12 dark:enabled:hover:text-white',
12
- surface: 'ps-liquid ps-liquid-control bg-white/72 text-ink enabled:hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
11
+ secondary: 'ps-control-surface text-ink enabled:hover:border-primary/40 enabled:hover:text-primary dark:enabled:hover:text-white',
12
+ surface: 'ps-control-surface text-ink enabled:hover:border-primary/40',
13
13
  };
14
14
  export const PsLinkButtonVariantClassNames = {
15
15
  danger: 'border-danger bg-danger text-white hover:opacity-90',
16
- ghost: 'ps-liquid ps-liquid-control bg-white/72 text-ink hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
16
+ ghost: 'ps-control-surface text-ink hover:border-primary/40',
17
17
  primary: 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)] hover:border-primary-dark hover:bg-primary-dark',
18
- secondary: 'ps-liquid ps-liquid-control bg-white/72 text-ink hover:border-primary/30 hover:text-primary dark:border-white/16 dark:bg-white/12 dark:hover:text-white',
19
- surface: 'ps-liquid ps-liquid-control bg-white/72 text-ink hover:border-primary/30 dark:border-white/16 dark:bg-white/12',
18
+ secondary: 'ps-control-surface text-ink hover:border-primary/40 hover:text-primary dark:hover:text-white',
19
+ surface: 'ps-control-surface text-ink hover:border-primary/40',
20
20
  };
@@ -0,0 +1,17 @@
1
+ import { useCallback, useId, useRef, useState } from 'react';
2
+ import { PsListKeyService } from '../services/ps-list-key-service.js';
3
+ export const usePsListKeys = (count) => {
4
+ const prefix = useId();
5
+ const created = useRef(0);
6
+ const create = useCallback(() => {
7
+ created.current += 1;
8
+ return `${prefix}-${created.current}`;
9
+ }, [prefix]);
10
+ const [keys, setKeys] = useState(() => PsListKeyService.fit([], count, create));
11
+ const fitted = PsListKeyService.fit(keys, count, create);
12
+ if (fitted !== keys)
13
+ setKeys(fitted);
14
+ const move = useCallback((from, to) => setKeys((current) => PsListKeyService.move(current, from, to)), []);
15
+ const remove = useCallback((index) => setKeys((current) => PsListKeyService.remove(current, index)), []);
16
+ return { keys: fitted, move, remove };
17
+ };
package/dist/esm/index.js CHANGED
@@ -188,6 +188,9 @@ export * from './models/ps-summary-item.js';
188
188
  export * from './components/ps-drag-grip.js';
189
189
  export * from './components/ps-drag-overlay.js';
190
190
  export * from './hooks/use-ps-drag-sensors.js';
191
+ export * from './hooks/use-ps-list-keys.js';
192
+ export * from './interfaces/ps-list-keys-result.js';
193
+ export * from './services/ps-list-key-service.js';
191
194
  export * from './hooks/use-ps-reduced-motion.js';
192
195
  export * from './components/ps-divider.js';
193
196
  export * from './models/ps-divider-orientation.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ export class PsListKeyService {
2
+ static fit(keys, count, create) {
3
+ if (keys.length === count)
4
+ return keys;
5
+ if (keys.length > count)
6
+ return keys.slice(0, count);
7
+ return [...keys, ...Array.from({ length: count - keys.length }, create)];
8
+ }
9
+ static move(keys, from, to) {
10
+ if (from === to || from < 0 || to < 0 || from >= keys.length || to >= keys.length)
11
+ return keys;
12
+ const next = [...keys];
13
+ const [moved] = next.splice(from, 1);
14
+ next.splice(to, 0, moved);
15
+ return next;
16
+ }
17
+ static remove(keys, index) {
18
+ return index < 0 || index >= keys.length ? keys : keys.filter((_key, at) => at !== index);
19
+ }
20
+ }
@@ -0,0 +1,2 @@
1
+ import type { PsListKeysResult } from '../interfaces/ps-list-keys-result';
2
+ export declare const usePsListKeys: (count: number) => PsListKeysResult;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePsListKeys = void 0;
4
+ const react_1 = require("react");
5
+ const ps_list_key_service_1 = require("../services/ps-list-key-service");
6
+ const usePsListKeys = (count) => {
7
+ const prefix = (0, react_1.useId)();
8
+ const created = (0, react_1.useRef)(0);
9
+ const create = (0, react_1.useCallback)(() => {
10
+ created.current += 1;
11
+ return `${prefix}-${created.current}`;
12
+ }, [prefix]);
13
+ const [keys, setKeys] = (0, react_1.useState)(() => ps_list_key_service_1.PsListKeyService.fit([], count, create));
14
+ const fitted = ps_list_key_service_1.PsListKeyService.fit(keys, count, create);
15
+ if (fitted !== keys)
16
+ setKeys(fitted);
17
+ const move = (0, react_1.useCallback)((from, to) => setKeys((current) => ps_list_key_service_1.PsListKeyService.move(current, from, to)), []);
18
+ const remove = (0, react_1.useCallback)((index) => setKeys((current) => ps_list_key_service_1.PsListKeyService.remove(current, index)), []);
19
+ return { keys: fitted, move, remove };
20
+ };
21
+ exports.usePsListKeys = usePsListKeys;
package/dist/index.d.ts CHANGED
@@ -188,6 +188,9 @@ export * from './models/ps-summary-item';
188
188
  export * from './components/ps-drag-grip';
189
189
  export * from './components/ps-drag-overlay';
190
190
  export * from './hooks/use-ps-drag-sensors';
191
+ export * from './hooks/use-ps-list-keys';
192
+ export * from './interfaces/ps-list-keys-result';
193
+ export * from './services/ps-list-key-service';
191
194
  export * from './hooks/use-ps-reduced-motion';
192
195
  export * from './components/ps-divider';
193
196
  export * from './models/ps-divider-orientation';
package/dist/index.js CHANGED
@@ -204,6 +204,9 @@ __exportStar(require("./models/ps-summary-item"), exports);
204
204
  __exportStar(require("./components/ps-drag-grip"), exports);
205
205
  __exportStar(require("./components/ps-drag-overlay"), exports);
206
206
  __exportStar(require("./hooks/use-ps-drag-sensors"), exports);
207
+ __exportStar(require("./hooks/use-ps-list-keys"), exports);
208
+ __exportStar(require("./interfaces/ps-list-keys-result"), exports);
209
+ __exportStar(require("./services/ps-list-key-service"), exports);
207
210
  __exportStar(require("./hooks/use-ps-reduced-motion"), exports);
208
211
  __exportStar(require("./components/ps-divider"), exports);
209
212
  __exportStar(require("./models/ps-divider-orientation"), exports);
@@ -0,0 +1,5 @@
1
+ export interface PsListKeysResult {
2
+ keys: string[];
3
+ move: (from: number, to: number) => void;
4
+ remove: (index: number) => void;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export declare class PsListKeyService {
2
+ static fit(keys: string[], count: number, create: () => string): string[];
3
+ static move(keys: string[], from: number, to: number): string[];
4
+ static remove(keys: string[], index: number): string[];
5
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsListKeyService = void 0;
4
+ class PsListKeyService {
5
+ static fit(keys, count, create) {
6
+ if (keys.length === count)
7
+ return keys;
8
+ if (keys.length > count)
9
+ return keys.slice(0, count);
10
+ return [...keys, ...Array.from({ length: count - keys.length }, create)];
11
+ }
12
+ static move(keys, from, to) {
13
+ if (from === to || from < 0 || to < 0 || from >= keys.length || to >= keys.length)
14
+ return keys;
15
+ const next = [...keys];
16
+ const [moved] = next.splice(from, 1);
17
+ next.splice(to, 0, moved);
18
+ return next;
19
+ }
20
+ static remove(keys, index) {
21
+ return index < 0 || index >= keys.length ? keys : keys.filter((_key, at) => at !== index);
22
+ }
23
+ }
24
+ exports.PsListKeyService = PsListKeyService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-core-components",
3
- "version": "2.44.0",
3
+ "version": "2.44.2",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.js",