@design-edito/tools 0.3.10 → 0.3.12

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.
Files changed (133) hide show
  1. package/agnostic/colors/index.d.ts +2 -2
  2. package/agnostic/colors/index.js +2 -2
  3. package/agnostic/css/clss/index.d.ts +53 -1
  4. package/agnostic/css/clss/index.js +1 -1
  5. package/agnostic/css/index.d.ts +1 -1
  6. package/agnostic/css/index.js +1 -1
  7. package/agnostic/html/hyper-json/smart-tags/coalesced/index.d.ts +15 -15
  8. package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +15 -15
  9. package/agnostic/html/hyper-json/smart-tags/isolated/index.d.ts +6 -6
  10. package/agnostic/html/hyper-json/smart-tags/isolated/index.js +6 -6
  11. package/agnostic/index.d.ts +4 -4
  12. package/agnostic/index.js +4 -4
  13. package/agnostic/misc/assert/index.d.ts +3 -0
  14. package/agnostic/misc/index.d.ts +2 -2
  15. package/agnostic/misc/index.js +2 -2
  16. package/agnostic/misc/logs/index.d.ts +1 -1
  17. package/agnostic/misc/logs/index.js +1 -1
  18. package/agnostic/misc/logs/logger/index.d.ts +10 -0
  19. package/agnostic/misc/logs/logger/index.js +40 -10
  20. package/agnostic/misc/logs/styles/index.d.ts +1 -0
  21. package/agnostic/misc/logs/styles/index.js +27 -9
  22. package/agnostic/numbers/index.d.ts +2 -2
  23. package/agnostic/numbers/index.js +2 -2
  24. package/agnostic/objects/index.d.ts +2 -2
  25. package/agnostic/objects/index.js +2 -2
  26. package/agnostic/optim/index.d.ts +1 -1
  27. package/agnostic/optim/index.js +1 -1
  28. package/agnostic/random/index.d.ts +1 -1
  29. package/agnostic/random/index.js +1 -1
  30. package/agnostic/sanitization/index.d.ts +2 -2
  31. package/agnostic/sanitization/index.js +2 -2
  32. package/agnostic/strings/index.d.ts +1 -1
  33. package/agnostic/strings/index.js +1 -1
  34. package/agnostic/time/index.d.ts +1 -1
  35. package/agnostic/time/index.js +1 -1
  36. package/agnostic/time/transitions/index.d.ts +3 -3
  37. package/agnostic/time/transitions/index.js +4 -4
  38. package/components/BeforeAfter/index.controlled.d.ts +46 -0
  39. package/components/BeforeAfter/index.d.ts +55 -0
  40. package/components/BeforeAfter/index.js +40 -0
  41. package/components/BeforeAfter/utils.d.ts +4 -0
  42. package/components/Disclaimer/index.d.ts +45 -0
  43. package/components/Disclaimer/index.js +70 -0
  44. package/components/Disclaimer/styles.module.css +0 -0
  45. package/components/Drawer/index.d.ts +45 -0
  46. package/components/Drawer/index.js +82 -0
  47. package/components/Drawer/styles.module.css +0 -0
  48. package/components/EventListener/index.d.ts +20 -3
  49. package/components/EventListener/index.js +15 -22
  50. package/components/Gallery/index.d.ts +67 -0
  51. package/components/Gallery/index.js +173 -0
  52. package/components/Gallery/styles.module.css +33 -0
  53. package/components/Gallery/utils.d.ts +1 -0
  54. package/components/Image/index.d.ts +60 -0
  55. package/components/Image/index.js +99 -0
  56. package/components/Image/styles.module.css +0 -0
  57. package/components/IntersectionObserver/index.d.ts +48 -11
  58. package/components/IntersectionObserver/index.js +13 -22
  59. package/components/Paginator/index.d.ts +72 -0
  60. package/components/Paginator/index.js +116 -0
  61. package/components/Paginator/styles.module.css +9 -0
  62. package/components/ResizeObserver/index.d.ts +27 -0
  63. package/components/ResizeObserver/index.js +81 -0
  64. package/components/Scrllgngn/index.d.ts +123 -0
  65. package/components/Scrllgngn/index.js +175 -0
  66. package/components/Scrllgngn/styles.module.css +74 -0
  67. package/components/ScrollListener/index.d.ts +47 -0
  68. package/components/ScrollListener/index.js +110 -0
  69. package/components/ScrollListener/styles.module.css +0 -0
  70. package/components/ScrollListener/utils.d.ts +41 -0
  71. package/components/Sequencer/index.controlled.d.ts +78 -0
  72. package/components/Sequencer/index.d.ts +85 -0
  73. package/components/Sequencer/index.js +109 -0
  74. package/components/Sequencer/styles.module.css +0 -0
  75. package/components/ShadowRoot/index.d.ts +35 -0
  76. package/components/ShadowRoot/index.js +56 -0
  77. package/components/ShadowRoot/styles.module.css +0 -0
  78. package/components/Subtitles/index.d.ts +58 -0
  79. package/components/Subtitles/index.js +111 -0
  80. package/components/Subtitles/styles.module.css +0 -0
  81. package/components/Subtitles/types.d.ts +10 -0
  82. package/components/Subtitles/types.js +0 -0
  83. package/components/Subtitles/utils.d.ts +28 -0
  84. package/components/Theatre/index.d.ts +64 -0
  85. package/components/Theatre/index.js +97 -0
  86. package/components/Theatre/styles.module.css +0 -0
  87. package/components/UIModule/index.d.ts +85 -0
  88. package/components/UIModule/index.js +134 -0
  89. package/components/UIModule/styles.module.css +0 -0
  90. package/components/Video/index.d.ts +139 -0
  91. package/components/Video/index.js +385 -0
  92. package/components/Video/styles.module.css +0 -0
  93. package/components/Video/utils.d.ts +14 -0
  94. package/components/_WIP_AudioQuote/index.d.ts +1 -0
  95. package/components/_WIP_AudioQuote/index.js +0 -0
  96. package/components/_WIP_Icon/index.d.ts +1 -0
  97. package/components/_WIP_Icon/index.js +0 -0
  98. package/components/index.d.ts +18 -1
  99. package/components/index.js +18 -1
  100. package/components/public-classnames.d.ts +17 -3
  101. package/components/utils/index.d.ts +1 -0
  102. package/components/utils/index.js +12 -0
  103. package/components/utils/types.d.ts +3 -0
  104. package/components/utils/types.js +0 -0
  105. package/index.d.ts +1 -1
  106. package/index.js +1 -1
  107. package/node/@aws-s3/index.test.d.ts +1 -0
  108. package/node/@aws-s3/storage/file/index.d.ts +3 -3
  109. package/node/@aws-s3/storage/file/index.js +3 -3
  110. package/node/@google-cloud/storage/directory/index.d.ts +1 -1
  111. package/node/@google-cloud/storage/directory/index.js +1 -1
  112. package/node/@google-cloud/storage/file/index.d.ts +4 -4
  113. package/node/@google-cloud/storage/file/index.js +4 -4
  114. package/node/cloud-storage/operations/index.d.ts +1 -1
  115. package/node/cloud-storage/operations/index.js +1 -1
  116. package/node/ftps/directory/index.d.ts +1 -1
  117. package/node/ftps/directory/index.js +1 -1
  118. package/node/ftps/file/index.d.ts +1 -1
  119. package/node/ftps/file/index.js +1 -1
  120. package/node/images/index.d.ts +1 -1
  121. package/node/images/index.js +1 -1
  122. package/node/images/transform/operations/index.d.ts +4 -4
  123. package/node/images/transform/operations/index.js +4 -4
  124. package/node/index.d.ts +3 -3
  125. package/node/index.js +3 -3
  126. package/node/process/spawner/index.d.ts +61 -2
  127. package/node/process/spawner/index.js +6 -6
  128. package/node/sftp/file/index.d.ts +3 -3
  129. package/node/sftp/file/index.js +3 -3
  130. package/package.json +1051 -13
  131. package/components/Input/index.d.ts +0 -7
  132. package/components/Input/index.js +0 -29
  133. /package/components/{Input → BeforeAfter}/styles.module.css +0 -0
@@ -1,4 +1,4 @@
1
- export * as path from './path/index.js'
2
- export * as html from './html/index.js'
3
1
  export * as fileName from './file-name/index.js'
2
+ export * as html from './html/index.js'
3
+ export * as path from './path/index.js'
4
4
  export * as userInput from './user-input/index.js'
@@ -1,7 +1,7 @@
1
1
  export * as charCodes from './char-codes/index.js'
2
2
  export * as matches from './matches/index.js'
3
3
  export * as normalizeIndent from './normalize-indent/index.js'
4
- export * as parseTable from './parse-table/index.js'
5
4
  export * as replaceAll from './replace-all/index.js'
6
5
  export * as toAlphanum from './to-alphanum/index.js'
7
6
  export * as trim from './trim/index.js'
7
+ export * as parseTable from './parse-table/index.js'
@@ -1,7 +1,7 @@
1
1
  export * as charCodes from './char-codes/index.js'
2
2
  export * as matches from './matches/index.js'
3
3
  export * as normalizeIndent from './normalize-indent/index.js'
4
- export * as parseTable from './parse-table/index.js'
5
4
  export * as replaceAll from './replace-all/index.js'
6
5
  export * as toAlphanum from './to-alphanum/index.js'
7
6
  export * as trim from './trim/index.js'
7
+ export * as parseTable from './parse-table/index.js'
@@ -1,5 +1,5 @@
1
1
  export * as dates from './dates/index.js'
2
- export * as timeout from './timeout/index.js'
3
2
  export * as duration from './duration/index.js'
3
+ export * as timeout from './timeout/index.js'
4
4
  export * as transitions from './transitions/index.js'
5
5
  export * as wait from './wait/index.js'
@@ -1,5 +1,5 @@
1
1
  export * as dates from './dates/index.js'
2
- export * as timeout from './timeout/index.js'
3
2
  export * as duration from './duration/index.js'
3
+ export * as timeout from './timeout/index.js'
4
4
  export * as transitions from './transitions/index.js'
5
5
  export * as wait from './wait/index.js'
@@ -54,16 +54,16 @@ export type EasingFunction = (progress: number) => number;
54
54
  */
55
55
  export type EasingDictionary = Record<string, EasingFunction>;
56
56
  /**
57
- * Performs a numeric transition from 0 to `to` over `durationMs` milliseconds.
57
+ * Performs a numeric transition from 0 to `steps` over `durationMs` milliseconds.
58
58
  * Invokes a callback at each step with the eased value and timestamp.
59
59
  *
60
- * @param to - The number of steps or increments for the transition.
60
+ * @param steps - The number of steps or increments for the transition.
61
61
  * @param durationMs - Total duration of the transition in milliseconds.
62
62
  * @param callbackOrEase - Either a callback function for each step or a predefined easing name.
63
63
  * @param callback - Optional callback if `callbackOrEase` is an easing name.
64
64
  * @returns A promise that resolves when the transition is complete.
65
65
  */
66
- export declare function transition(to: number, durationMs: number, callbackOrEase: Ease | Callback, callback?: Callback): Promise<void>;
66
+ export declare function transition(steps: number, durationMs: number, callbackOrEase: Ease | Callback, callback?: Callback): Promise<void>;
67
67
  /**
68
68
  * Predefined easing functions used internally by transitions.
69
69
  */
@@ -34,18 +34,18 @@ var Ease = /* @__PURE__ */ ((Ease2) => {
34
34
  Ease2["EASE_IN_OUT_BOUNCE"] = "ease-in-out-bounce";
35
35
  return Ease2;
36
36
  })(Ease || {});
37
- async function transition(to, durationMs, callbackOrEase, callback) {
37
+ async function transition(steps, durationMs, callbackOrEase, callback) {
38
38
  const ease = typeof callbackOrEase === "string" ? callbackOrEase : "linear" /* LINEAR */;
39
39
  const easing = easings[ease];
40
40
  if (easing === void 0) return;
41
41
  const actualCallback = callback ?? (typeof callbackOrEase === "function" ? callbackOrEase : void 0);
42
42
  if (actualCallback === void 0) return;
43
43
  const start = Date.now();
44
- const timeTable = new Array(to).fill(null).map((_, step) => {
45
- const progression = (step + 1) / to;
44
+ const timeTable = new Array(steps).fill(null).map((_, step) => {
45
+ const progression = (step + 1) / steps;
46
46
  const eased = easing(progression);
47
47
  const time = start + eased * durationMs;
48
- return { time, step: eased * to };
48
+ return { time, step: eased * steps };
49
49
  });
50
50
  for (const { time, step } of timeTable) {
51
51
  const now = Date.now();
@@ -0,0 +1,46 @@
1
+ import React, { type FunctionComponent, type HTMLAttributes } from 'react';
2
+ import type { WithClassName } from '../utils/types.js';
3
+ export type Props = WithClassName<{
4
+ content?: React.ReactNode;
5
+ beforeContent?: React.ReactNode;
6
+ afterContent?: React.ReactNode;
7
+ ratio?: number;
8
+ actionHandlers?: {
9
+ pointer?: (e: PointerEvent, targetHRatio: number, targetVRatio: number, ratio: number | null, element: HTMLDivElement) => void;
10
+ };
11
+ _modifiers?: {
12
+ horizontal?: boolean;
13
+ vertical?: boolean;
14
+ };
15
+ }> & HTMLAttributes<HTMLDivElement>;
16
+ /**
17
+ * Props for the {@link BeforeAfterControlled} component.
18
+ *
19
+ * @property beforeContent - Content shown first.
20
+ * @property afterContent - Content shown second.
21
+ * @property ratio - Split ratio (0 to 1). Controlled by parent.
22
+ * @property actionHandlers - Optional pointer (drag) callbacks:
23
+ * - `pointer` — called on pointer events with ratio and element info.
24
+ * @property _modifiers - Orientation modifiers: `horizontal` or `vertical`.
25
+ * @property className - Custom CSS class.
26
+ *
27
+ * @see {@link BeforeAfter}
28
+ */
29
+ /**
30
+ * Controlled before/after slider component. Renders two contents separated by a slider,
31
+ * whose ratio is managed by the parent component. Handles pointer interactions (mouse/touch/pen)
32
+ * to update the ratio via callbacks.
33
+ *
34
+ * ### Forwarded CSS custom properties
35
+ * - `--before-after-ratio` — the current ratio value (0 to 1, fixed to 8 decimals).
36
+ * - `--before-after-ratio-percent` — the current ratio as a percentage (0 to 100).
37
+ *
38
+ * ### Forwarded data attributes
39
+ * - `data-ratio` — the current ratio value.
40
+ *
41
+ * @param props - Component properties.
42
+ * @see {@link Props}
43
+ * @see {@link BeforeAfter}
44
+ * @returns A div containing used to render "before/after" content, with pointer event handling for ratio updates.
45
+ */
46
+ export declare const BeforeAfterControlled: FunctionComponent<Props>;
@@ -0,0 +1,55 @@
1
+ import { type FunctionComponent } from 'react';
2
+ import { type Props as ControlledProps } from './index.controlled.js';
3
+ /**
4
+ * Props for the {@link BeforeAfter} component.
5
+ *
6
+ * Extends {@link ControlledProps} (minus `_modifiers`, which are derived
7
+ * internally) with uncontrolled ratio and direction management.
8
+ *
9
+ * @property defaultRatio - Initial ratio value (0 to 1). Used if `ratio` is not provided. Defaults to `0`.
10
+ * @property direction - Slider orientation: `'horizontal'` (default) or `'vertical'`.
11
+ * @property stateHandlers - Optional callbacks invoked when derived state changes:
12
+ * - `ratio` — called with the new ratio whenever it changes.
13
+ */
14
+ export type Props = ControlledProps & {
15
+ defaultRatio?: number;
16
+ direction?: 'horizontal' | 'vertical';
17
+ stateHandlers?: {
18
+ ratio?: (ratio: number) => void;
19
+ };
20
+ };
21
+ /**
22
+ * Props for the {@link BeforeAfter} component.
23
+ *
24
+ * Extends {@link ControlledProps} with uncontrolled ratio and direction management.
25
+ *
26
+ * @property defaultRatio - Initial ratio value (0 to 1). Used if `ratio` is not provided. Defaults to `0`.
27
+ * @property direction - Slider orientation: `'horizontal'` (default) or `'vertical'`. If horizontal, the ratio is calced as the horizontal pointer position over the element width. If vertical, it's the vertical pointer position over the element height.
28
+ * @property stateHandlers - Optional callbacks invoked when derived state changes:
29
+ * - `ratio` — called with the new ratio whenever it changes.
30
+ *
31
+ * @see {@link ControlledProps}
32
+ */
33
+ /**
34
+ * Uncontrolled, self-updating before/after slider component. Drives a
35
+ * {@link BeforeAfterControlled} instance with internal ratio state and direction,
36
+ * supporting both controlled and uncontrolled usage.
37
+ *
38
+ * Supports mixed controlled/uncontrolled usage: passing `ratio` disables internal ratio state,
39
+ * but still allows direction and stateHandlers to be used. Passing `defaultRatio` sets the initial ratio.
40
+ *
41
+ * ### Forwarded modifiers to {@link BeforeAfterControlled}
42
+ * The following `_modifiers` are computed and injected automatically:
43
+ * - `horizontal` — `true`.
44
+ * - `vertical` — `true`.
45
+ *
46
+ * ### Forwarded CSS custom properties to {@link BeforeAfterControlled}
47
+ * - `--before-after-ratio` — the current ratio value (0 to 1, fixed to 8 decimals).
48
+ * - `--before-after-ratio-percent` — the current ratio as a percentage (0 to 100).
49
+ *
50
+ * @param props - Component properties.
51
+ * @see {@link Props}
52
+ * @see {@link BeforeAfterControlled}
53
+ * @returns A {@link BeforeAfterControlled} with computed ratio and orientation modifiers applied.
54
+ */
55
+ export declare const BeforeAfter: FunctionComponent<Props>;
@@ -0,0 +1,40 @@
1
+ // src/components/BeforeAfter/index.tsx
2
+ import {
3
+ useState,
4
+ useCallback,
5
+ useEffect
6
+ } from "react";
7
+ import { BeforeAfterControlled } from "./index.controlled.js";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var BeforeAfter = ({
10
+ direction,
11
+ defaultRatio,
12
+ stateHandlers,
13
+ ...controlledProps
14
+ }) => {
15
+ const { actionHandlers, ratio } = controlledProps;
16
+ const [internalRatio, setInternalRatio] = useState(ratio ?? defaultRatio ?? 0);
17
+ const handlePointer = useCallback((e, targetHRatio, targetVRatio, ratio2, element) => {
18
+ if (direction === "vertical") setInternalRatio(targetVRatio);
19
+ else setInternalRatio(targetHRatio);
20
+ actionHandlers?.pointer?.(e, targetHRatio, targetVRatio, ratio2, element);
21
+ }, [direction, actionHandlers?.pointer]);
22
+ useEffect(() => {
23
+ stateHandlers?.ratio?.(internalRatio);
24
+ }, [internalRatio, stateHandlers?.ratio]);
25
+ return /* @__PURE__ */ jsx(
26
+ BeforeAfterControlled,
27
+ {
28
+ ...controlledProps,
29
+ _modifiers: {
30
+ horizontal: direction !== "vertical",
31
+ vertical: direction === "vertical"
32
+ },
33
+ ratio: ratio ?? internalRatio,
34
+ actionHandlers: { pointer: handlePointer }
35
+ }
36
+ );
37
+ };
38
+ export {
39
+ BeforeAfter
40
+ };
@@ -0,0 +1,4 @@
1
+ export declare function getRelativePointerCoordinates(event: PointerEvent, element: HTMLDivElement | null): {
2
+ x: number;
3
+ y: number;
4
+ };
@@ -0,0 +1,45 @@
1
+ import { type ReactNode, type PropsWithChildren, type FunctionComponent } from 'react';
2
+ import type { WithClassName } from '../utils/types.js';
3
+ /**
4
+ * Props for the Disclaimer component.
5
+ *
6
+ * @property content - Content displayed inside the disclaimer panel.
7
+ * @property togglerContent - Content rendered inside the dismiss toggler.
8
+ * If not provided, the toggler is not rendered.
9
+ * @property isOn - Controls the visibility state. When defined, the component
10
+ * behaves as a controlled component.
11
+ * @property defaultIsOn - Default visibility state for uncontrolled mode.
12
+ * @property stateHandlers - Callbacks invoked after state changes.
13
+ * @property stateHandlers.toggled - Callback invoked after the disclaimer state changes.
14
+ * @property actionHandlers - Callbacks invoked before actions are committed.
15
+ * @property actionHandlers.dismissClick - Callback invoked before the disclaimer is dismissed.
16
+ * @property className - Optional additional class name(s) applied to the root element.
17
+ * @property children - Additional content rendered below the disclaimer panel.
18
+ */
19
+ export type Props = PropsWithChildren<WithClassName<{
20
+ content?: ReactNode;
21
+ togglerContent?: ReactNode;
22
+ isOn?: boolean;
23
+ defaultIsOn?: boolean;
24
+ stateHandlers?: {
25
+ toggled?: (isOn: boolean) => void;
26
+ };
27
+ actionHandlers?: {
28
+ dismissClick?: (prevIsOn: boolean) => void;
29
+ };
30
+ }>>;
31
+ /**
32
+ * Component that displays a dismissible disclaimer panel.
33
+ *
34
+ * Supports both controlled (`isOn` provided) and uncontrolled modes.
35
+ *
36
+ * @param props - Component properties.
37
+ * @see {@link Props}
38
+ *
39
+ * @remarks
40
+ * - In controlled mode, visibility is driven by `isOn` and internal state
41
+ * does not toggle automatically.
42
+ * - In uncontrolled mode, the component manages its own visibility state.
43
+ * - Applies `on` and `off` modifier classes depending on visibility state.
44
+ */
45
+ export declare const Disclaimer: FunctionComponent<Props>;
@@ -0,0 +1,70 @@
1
+ // src/components/Disclaimer/index.tsx
2
+ import {
3
+ useState,
4
+ useEffect,
5
+ useRef
6
+ } from "react";
7
+ import { clss } from "../../agnostic/css/clss/index.js";
8
+ import { mergeClassNames } from "../utils/index.js";
9
+ import { disclaimer as publicClassName } from "../public-classnames.js";
10
+ import cssModule from "./styles.module.css";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ var Disclaimer = ({
13
+ content,
14
+ togglerContent,
15
+ isOn: isOnProp,
16
+ defaultIsOn: defaultIsOnProp,
17
+ stateHandlers,
18
+ actionHandlers,
19
+ children,
20
+ className
21
+ }) => {
22
+ const [internalIsOn, setInternalIsOn] = useState(isOnProp ?? defaultIsOnProp ?? true);
23
+ const isOn = isOnProp ?? internalIsOn;
24
+ const pIsOn = useRef(isOn);
25
+ useEffect(() => {
26
+ if (pIsOn.current === isOn) return;
27
+ stateHandlers?.toggled?.(isOn);
28
+ pIsOn.current = isOn;
29
+ }, [isOn]);
30
+ const handleDismissClick = () => {
31
+ actionHandlers?.dismissClick?.(isOn);
32
+ if (isOnProp !== void 0) return;
33
+ setInternalIsOn(false);
34
+ };
35
+ const c = clss(publicClassName, { cssModule });
36
+ const rootClss = mergeClassNames(
37
+ c(null, {
38
+ on: isOn,
39
+ off: !isOn
40
+ }),
41
+ className
42
+ );
43
+ const panelClss = c("panel");
44
+ const contentClss = c("content");
45
+ const btnClss = c("toggler");
46
+ const sensitiveClss = c("sensitive");
47
+ return /* @__PURE__ */ jsxs("div", { className: rootClss, children: [
48
+ /* @__PURE__ */ jsxs("div", { className: panelClss, children: [
49
+ content !== void 0 && /* @__PURE__ */ jsx(
50
+ "div",
51
+ {
52
+ className: contentClss,
53
+ children: content
54
+ }
55
+ ),
56
+ togglerContent !== void 0 && /* @__PURE__ */ jsx(
57
+ "div",
58
+ {
59
+ className: btnClss,
60
+ onClick: handleDismissClick,
61
+ children: togglerContent
62
+ }
63
+ )
64
+ ] }),
65
+ /* @__PURE__ */ jsx("div", { className: sensitiveClss, children })
66
+ ] });
67
+ };
68
+ export {
69
+ Disclaimer
70
+ };
File without changes
@@ -0,0 +1,45 @@
1
+ import { type PropsWithChildren, type FunctionComponent, type ReactNode } from 'react';
2
+ import type { WithClassName } from '../utils/types.js';
3
+ /**
4
+ * Props for the Drawer component.
5
+ *
6
+ * @property openerContent - Content rendered inside the opener control.
7
+ * @property closerContent - Content rendered inside the closer control.
8
+ * @property initialIsOpened - Initial open state in uncontrolled mode.
9
+ * Ignored when `isOpened` is provided.
10
+ * @property isOpened - Controlled open state. When defined, the component
11
+ * behaves as a controlled component and internal state is ignored.
12
+ * @property stateHandlers - Callbacks invoked after the state changes
13
+ * @property stateHandlers.toggled - Callbacks invoked after the isOpened state has changed
14
+ * @property className - Additional class name(s) applied to the root element.
15
+ * @property children - Drawer content.
16
+ */
17
+ export type Props = PropsWithChildren<WithClassName<{
18
+ openerContent?: ReactNode;
19
+ closerContent?: ReactNode;
20
+ initialIsOpened?: boolean;
21
+ isOpened?: boolean;
22
+ stateHandlers?: {
23
+ toggled?: (isOpen: boolean) => void;
24
+ };
25
+ }>>;
26
+ /**
27
+ * Drawer component with optional controlled and uncontrolled behavior.
28
+ *
29
+ * @remarks
30
+ * - In controlled mode (`isOpened` defined), visibility is fully driven by the prop.
31
+ * - In uncontrolled mode, internal state is initialized from `initialIsOpened`.
32
+ * - The component measures its content using `ResizeObserverComponent`
33
+ * and exposes the dimensions:
34
+ * - As CSS custom properties:
35
+ * --{prefix}-content-height
36
+ * --{prefix}-content-height-px
37
+ * --{prefix}-content-width
38
+ * --{prefix}-content-width-px
39
+ * - As `data-content-width` and `data-content-height` attributes.
40
+ *
41
+ * CSS modifier classes:
42
+ * - `opened` when open
43
+ * - `closed` when closed
44
+ */
45
+ export declare const Drawer: FunctionComponent<Props>;
@@ -0,0 +1,82 @@
1
+ // src/components/Drawer/index.tsx
2
+ import {
3
+ useState,
4
+ useRef,
5
+ useEffect
6
+ } from "react";
7
+ import { clss } from "../../agnostic/css/clss/index.js";
8
+ import { mergeClassNames } from "../utils/index.js";
9
+ import { drawer as publicClassName } from "../public-classnames.js";
10
+ import cssModule from "./styles.module.css";
11
+ import {
12
+ ResizeObserverComponent
13
+ } from "../ResizeObserver/index.js";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var Drawer = ({
16
+ openerContent,
17
+ closerContent,
18
+ initialIsOpened = false,
19
+ isOpened: isOpenedProp,
20
+ stateHandlers,
21
+ className,
22
+ children
23
+ }) => {
24
+ const [internalIsOpened, setInternalIsOpened] = useState(isOpenedProp ?? initialIsOpened);
25
+ const isOpened = isOpenedProp ?? internalIsOpened;
26
+ const pIsOpened = useRef(isOpened);
27
+ const [{ width, height }, setContentDimensions] = useState({});
28
+ useEffect(() => {
29
+ if (pIsOpened.current === isOpened) return;
30
+ pIsOpened.current = isOpened;
31
+ stateHandlers?.toggled?.(isOpened);
32
+ }, [isOpened]);
33
+ const handleOpenerClick = () => {
34
+ if (isOpenedProp !== void 0) return;
35
+ setInternalIsOpened(true);
36
+ };
37
+ const handleCloserClick = () => {
38
+ if (isOpenedProp !== void 0) return;
39
+ setInternalIsOpened(false);
40
+ };
41
+ const handleROCompResize = ({ entry }) => {
42
+ const { width: width2, height: height2 } = entry?.contentRect ?? {};
43
+ setContentDimensions({ width: width2, height: height2 });
44
+ };
45
+ const c = clss(publicClassName, { cssModule });
46
+ const rootClss = mergeClassNames(c(null, {
47
+ "opened": isOpened,
48
+ "closed": !isOpened
49
+ }), className);
50
+ const openerClss = c("opener");
51
+ const closerClss = c("closer");
52
+ const contentClss = c("content");
53
+ const dimensions = { width, height };
54
+ const customCssProps = Object.entries(dimensions).reduce((acc, [key, val]) => {
55
+ if (val === void 0) return acc;
56
+ return {
57
+ ...acc,
58
+ [`--${publicClassName}-content-${key}`]: `${val}`,
59
+ [`--${publicClassName}-content-${key}-px`]: `${val}px`
60
+ };
61
+ }, {});
62
+ const dataAttributes = Object.entries(dimensions).reduce((acc, [key, val]) => {
63
+ if (val === void 0) return acc;
64
+ return { ...acc, [`data-content-${key}`]: `${val}` };
65
+ }, {});
66
+ return /* @__PURE__ */ jsxs(
67
+ "div",
68
+ {
69
+ className: rootClss,
70
+ ...dataAttributes,
71
+ style: { ...customCssProps },
72
+ children: [
73
+ /* @__PURE__ */ jsx("div", { className: openerClss, onClick: handleOpenerClick, children: openerContent }),
74
+ /* @__PURE__ */ jsx("div", { className: closerClss, onClick: handleCloserClick, children: closerContent }),
75
+ /* @__PURE__ */ jsx("div", { className: contentClss, children: /* @__PURE__ */ jsx(ResizeObserverComponent, { onResized: handleROCompResize, children }) })
76
+ ]
77
+ }
78
+ );
79
+ };
80
+ export {
81
+ Drawer
82
+ };
File without changes
@@ -1,10 +1,27 @@
1
- import { type ReactNode, type JSX } from 'react';
1
+ import { type ReactNode, type FunctionComponent } from 'react';
2
+ /**
3
+ * Props for the EventListenerComponent.
4
+ *
5
+ * @property className - Optional additional class name(s) applied to the root element.
6
+ * @property type - Event type or list of event types to listen to (e.g. "click", ["mouseenter", "focus"]).
7
+ * @property targetSelector - Optional CSS selector used to match descendant elements
8
+ * within the root element. If omitted, the listener is attached to the root element itself.
9
+ * @property onEvent - Callback invoked when one of the specified events is triggered.
10
+ * Receives the native DOM Event object.
11
+ * @property children - React children rendered inside the root element.
12
+ */
2
13
  export type Props = {
3
14
  className?: string;
4
15
  type?: string | string[];
5
16
  targetSelector?: string;
6
17
  onEvent?: (e: Event) => void;
7
- content?: ReactNode;
8
18
  children?: ReactNode;
9
19
  };
10
- export declare const EventListenerComponent: ({ className, type, targetSelector, onEvent, content, children }: Props) => JSX.Element;
20
+ /**
21
+ * Component that attaches one or multiple DOM event listeners to its root element
22
+ * or to matching descendants.
23
+ * @param props - Component properties
24
+ * @see {@link Props}
25
+ * @returns A span element wrapping `children`, with configured event listeners.
26
+ */
27
+ export declare const EventListenerComponent: FunctionComponent<Props>;
@@ -4,16 +4,15 @@ import {
4
4
  useEffect
5
5
  } from "react";
6
6
  import { clss } from "../../agnostic/css/clss/index.js";
7
- import { isNotFalsy } from "../../agnostic/booleans/is-falsy/index.js";
8
- import { eventListener } from "../public-classnames.js";
7
+ import { mergeClassNames } from "../utils/index.js";
8
+ import { eventListener as publicClassName } from "../public-classnames.js";
9
9
  import cssModule from "./styles.module.css";
10
- import { jsxs } from "react/jsx-runtime";
10
+ import { jsx } from "react/jsx-runtime";
11
11
  var EventListenerComponent = ({
12
12
  className,
13
13
  type,
14
14
  targetSelector,
15
15
  onEvent,
16
- content,
17
16
  children
18
17
  }) => {
19
18
  const rootRef = useRef(null);
@@ -22,25 +21,19 @@ var EventListenerComponent = ({
22
21
  if (onEvent === void 0 || type === void 0 || root === null) return;
23
22
  const typeArr = Array.isArray(type) ? type : [type];
24
23
  const elements = Array.from(targetSelector === void 0 ? [root] : root.querySelectorAll(targetSelector));
25
- elements.forEach((elt) => {
26
- typeArr.forEach((type2) => {
27
- elt.addEventListener(type2, onEvent);
28
- });
29
- });
30
- return () => {
31
- elements.forEach((elt) => {
32
- typeArr.forEach((type2) => {
33
- elt.removeEventListener(type2, onEvent);
34
- });
35
- });
36
- };
24
+ elements.forEach((e) => typeArr.forEach((t) => e.addEventListener(t, onEvent)));
25
+ return () => elements.forEach((e) => typeArr.forEach((t) => e.removeEventListener(t, onEvent)));
37
26
  }, [targetSelector, type, onEvent]);
38
- const c = clss(eventListener, { cssModule });
39
- const wrapperClassName = [c(null), className].filter(isNotFalsy).join(" ");
40
- return /* @__PURE__ */ jsxs("span", { className: wrapperClassName, ref: rootRef, children: [
41
- children,
42
- content
43
- ] });
27
+ const c = clss(publicClassName, { cssModule });
28
+ const rootClss = mergeClassNames(c(), className);
29
+ return /* @__PURE__ */ jsx(
30
+ "div",
31
+ {
32
+ className: rootClss,
33
+ ref: rootRef,
34
+ children
35
+ }
36
+ );
44
37
  };
45
38
  export {
46
39
  EventListenerComponent
@@ -0,0 +1,67 @@
1
+ import { type FunctionComponent, type PropsWithChildren, type ReactNode } from 'react';
2
+ import type { WithClassName } from '../utils/types.js';
3
+ /**
4
+ * Props for the Gallery component.
5
+ *
6
+ * @property paddingLeft - Left padding applied to the first slot. Accepts a number (pixels) or any valid CSS length value.
7
+ * If not provided, falls back to `padding` or `0px`.
8
+ * @property paddingRight - Right padding applied to the last slot. Accepts a number (pixels) or any valid CSS length value.
9
+ * If not provided, falls back to `padding` or `0px`.
10
+ * @property padding - Shorthand horizontal padding applied to both ends when `paddingLeft` and/or `paddingRight`
11
+ * are not explicitly defined. Accepts a number (pixels) or any valid CSS length value.
12
+ * @property prevButtonContent - Content rendered inside the "previous" navigation control.
13
+ * Defaults to the string `"prev"` when not provided.
14
+ * @property nextButtonContent - Content rendered inside the "next" navigation control.
15
+ * Defaults to the string `"next"` when not provided.
16
+ * @property paginationContent - Content rendered inside each pagination item.
17
+ * Can be:
18
+ * - A ReactNode used for all pages,
19
+ * - A function receiving the page index and returning a ReactNode,
20
+ * - Undefined, in which case the page index is displayed.
21
+ * @property initActive - Optional. When uncontrolled mode, sets the default active slot at mount
22
+ * @property active - Optional controlled index. When provided, the active slot is driven by this
23
+ * value instead of internal scroll-derived state. When omitted, the component manages its own
24
+ * active index based on scroll position.
25
+ * @property noSnap - Optional, defines if scroll is free in side the scroller or not (defaults to false)
26
+ * @property stateHandlers - Callbacks called after the state changed
27
+ * @property stateHandlers.slotChanged - Called when the active slot changes due to scrolling. Receives the new active index.
28
+ * @property actionHandlers - Callbacks called after a user interaction
29
+ * @property actionHandlers.prevClick - Called when the "previous" control is clicked. Receives the current active index before navigation occurs.
30
+ * @property actionHandlers.nextClick - Called when the "next" control is clicked. Receives the current active index before navigation occurs.
31
+ * @property actionHandlers.paginationClick - Called when a pagination item is clicked. Receives the current active index and the target index.
32
+ * @property className - Optional additional class name(s) applied to the root element.
33
+ * @property children - Elements rendered as gallery slots. Each child is wrapped in a slot container.
34
+ */
35
+ export type Props = PropsWithChildren<WithClassName<{
36
+ paddingLeft?: string | number;
37
+ paddingRight?: string | number;
38
+ padding?: string | number;
39
+ prevButtonContent?: ReactNode;
40
+ nextButtonContent?: ReactNode;
41
+ paginationContent?: ReactNode | ((page: number) => ReactNode);
42
+ initActive?: number;
43
+ active?: number;
44
+ noSnap?: boolean;
45
+ stateHandlers?: {
46
+ slotChanged?: (activePos: number) => void;
47
+ };
48
+ actionHandlers?: {
49
+ prevClick?: (activePos: number) => void;
50
+ nextClick?: (activePos: number) => void;
51
+ paginationClick?: (activePos: number, targetPos: number) => void;
52
+ };
53
+ }>>;
54
+ /**
55
+ * Horizontally scrollable gallery component with navigation controls and pagination.
56
+ *
57
+ * Tracks the active slot based on scroll position and exposes state through CSS class names
58
+ * and a `data-active` attribute on the root element.
59
+ *
60
+ * @param props - Component properties.
61
+ * @see {@link Props}
62
+ * @returns A container element wrapping:
63
+ * - A scrollable area containing each child in a slot wrapper,
64
+ * - Previous/next navigation controls,
65
+ * - Pagination controls allowing direct slot activation.
66
+ */
67
+ export declare const Gallery: FunctionComponent<Props>;