@design-edito/tools 0.3.10 → 0.3.11

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 (129) hide show
  1. package/agnostic/arrays/index.d.ts +1 -1
  2. package/agnostic/arrays/index.js +1 -1
  3. package/agnostic/colors/index.d.ts +2 -2
  4. package/agnostic/colors/index.js +2 -2
  5. package/agnostic/css/clss/index.d.ts +53 -1
  6. package/agnostic/css/clss/index.js +1 -1
  7. package/agnostic/css/index.d.ts +2 -2
  8. package/agnostic/css/index.js +2 -2
  9. package/agnostic/errors/index.d.ts +1 -1
  10. package/agnostic/errors/index.js +1 -1
  11. package/agnostic/html/hyper-json/smart-tags/coalesced/index.d.ts +20 -20
  12. package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +20 -20
  13. package/agnostic/html/hyper-json/smart-tags/isolated/index.d.ts +4 -4
  14. package/agnostic/html/hyper-json/smart-tags/isolated/index.js +4 -4
  15. package/agnostic/index.d.ts +4 -4
  16. package/agnostic/index.js +4 -4
  17. package/agnostic/misc/assert/index.d.ts +3 -0
  18. package/agnostic/misc/crossenv/index.d.ts +1 -1
  19. package/agnostic/misc/crossenv/index.js +1 -1
  20. package/agnostic/misc/index.d.ts +5 -5
  21. package/agnostic/misc/index.js +5 -5
  22. package/agnostic/misc/logs/index.d.ts +1 -1
  23. package/agnostic/misc/logs/index.js +1 -1
  24. package/agnostic/misc/logs/logger/index.d.ts +10 -0
  25. package/agnostic/misc/logs/logger/index.js +40 -10
  26. package/agnostic/misc/logs/styles/index.d.ts +1 -0
  27. package/agnostic/misc/logs/styles/index.js +27 -9
  28. package/agnostic/numbers/index.d.ts +2 -2
  29. package/agnostic/numbers/index.js +2 -2
  30. package/agnostic/objects/index.d.ts +4 -4
  31. package/agnostic/objects/index.js +4 -4
  32. package/agnostic/sanitization/index.d.ts +1 -1
  33. package/agnostic/sanitization/index.js +1 -1
  34. package/agnostic/strings/index.d.ts +1 -1
  35. package/agnostic/strings/index.js +1 -1
  36. package/agnostic/time/index.d.ts +2 -2
  37. package/agnostic/time/index.js +2 -2
  38. package/agnostic/time/transitions/index.d.ts +3 -3
  39. package/agnostic/time/transitions/index.js +4 -4
  40. package/components/Disclaimer/index.d.ts +45 -0
  41. package/components/Disclaimer/index.js +70 -0
  42. package/components/Drawer/index.d.ts +45 -0
  43. package/components/Drawer/index.js +82 -0
  44. package/components/Drawer/styles.module.css +0 -0
  45. package/components/EventListener/index.d.ts +20 -3
  46. package/components/EventListener/index.js +15 -22
  47. package/components/Gallery/index.d.ts +67 -0
  48. package/components/Gallery/index.js +173 -0
  49. package/components/Gallery/styles.module.css +33 -0
  50. package/components/Gallery/utils.d.ts +1 -0
  51. package/components/Image/index.d.ts +60 -0
  52. package/components/Image/index.js +99 -0
  53. package/components/Image/styles.module.css +0 -0
  54. package/components/IntersectionObserver/index.d.ts +48 -11
  55. package/components/IntersectionObserver/index.js +13 -22
  56. package/components/Paginator/index.d.ts +72 -0
  57. package/components/Paginator/index.js +116 -0
  58. package/components/Paginator/styles.module.css +9 -0
  59. package/components/ResizeObserver/index.d.ts +27 -0
  60. package/components/ResizeObserver/index.js +81 -0
  61. package/components/Scrllgngn/index.d.ts +123 -0
  62. package/components/Scrllgngn/index.js +175 -0
  63. package/components/Scrllgngn/styles.module.css +74 -0
  64. package/components/Sequencer/index.controlled.d.ts +78 -0
  65. package/components/Sequencer/index.d.ts +85 -0
  66. package/components/Sequencer/index.js +109 -0
  67. package/components/Sequencer/styles.module.css +0 -0
  68. package/components/ShadowRoot/index.d.ts +35 -0
  69. package/components/ShadowRoot/index.js +56 -0
  70. package/components/ShadowRoot/styles.module.css +0 -0
  71. package/components/Subtitles/index.d.ts +58 -0
  72. package/components/Subtitles/index.js +111 -0
  73. package/components/Subtitles/styles.module.css +0 -0
  74. package/components/Subtitles/types.d.ts +10 -0
  75. package/components/Subtitles/types.js +0 -0
  76. package/components/Subtitles/utils.d.ts +28 -0
  77. package/components/Theatre/index.d.ts +64 -0
  78. package/components/Theatre/index.js +97 -0
  79. package/components/Theatre/styles.module.css +0 -0
  80. package/components/Video/index.d.ts +119 -0
  81. package/components/Video/index.js +358 -0
  82. package/components/Video/styles.module.css +0 -0
  83. package/components/Video/utils.d.ts +10 -0
  84. package/components/_WIP_AudioQuote/index.d.ts +1 -0
  85. package/components/_WIP_AudioQuote/index.js +0 -0
  86. package/components/_WIP_Icon/index.d.ts +1 -0
  87. package/components/_WIP_Icon/index.js +0 -0
  88. package/components/index.d.ts +15 -1
  89. package/components/index.js +15 -1
  90. package/components/public-classnames.d.ts +14 -3
  91. package/components/utils/index.d.ts +1 -0
  92. package/components/utils/index.js +12 -0
  93. package/components/utils/types.d.ts +3 -0
  94. package/components/utils/types.js +0 -0
  95. package/index.d.ts +1 -1
  96. package/index.js +1 -1
  97. package/node/@aws-s3/index.test.d.ts +1 -0
  98. package/node/@aws-s3/storage/directory/index.d.ts +1 -1
  99. package/node/@aws-s3/storage/directory/index.js +1 -1
  100. package/node/@aws-s3/storage/file/index.d.ts +3 -3
  101. package/node/@aws-s3/storage/file/index.js +3 -3
  102. package/node/@google-cloud/storage/directory/index.d.ts +2 -2
  103. package/node/@google-cloud/storage/directory/index.js +2 -2
  104. package/node/@google-cloud/storage/file/index.d.ts +4 -4
  105. package/node/@google-cloud/storage/file/index.js +4 -4
  106. package/node/cloud-storage/operations/index.d.ts +3 -3
  107. package/node/cloud-storage/operations/index.js +3 -3
  108. package/node/encryption/index.d.ts +1 -1
  109. package/node/encryption/index.js +1 -1
  110. package/node/files/index.d.ts +1 -1
  111. package/node/files/index.js +1 -1
  112. package/node/ftps/directory/index.d.ts +2 -2
  113. package/node/ftps/directory/index.js +2 -2
  114. package/node/ftps/file/index.d.ts +1 -1
  115. package/node/ftps/file/index.js +1 -1
  116. package/node/images/index.d.ts +3 -3
  117. package/node/images/index.js +3 -3
  118. package/node/images/transform/operations/index.d.ts +6 -6
  119. package/node/images/transform/operations/index.js +6 -6
  120. package/node/index.d.ts +4 -4
  121. package/node/index.js +4 -4
  122. package/node/process/spawner/index.d.ts +61 -2
  123. package/node/process/spawner/index.js +6 -6
  124. package/node/sftp/file/index.d.ts +3 -3
  125. package/node/sftp/file/index.js +3 -3
  126. package/package.json +1030 -13
  127. package/components/Input/index.d.ts +0 -7
  128. package/components/Input/index.js +0 -29
  129. /package/components/{Input → Disclaimer}/styles.module.css +0 -0
@@ -1,9 +1,9 @@
1
+ export * as deepGetProperty from './deep-get-property/index.js'
1
2
  export * as enums from './enums/index.js'
2
- export * as flattenGetters from './flatten-getters/index.js'
3
- export * as isObject from './is-object/index.js'
4
3
  export * as isRecord from './is-record/index.js'
5
- export * as deepGetProperty from './deep-get-property/index.js'
4
+ export * as isObject from './is-object/index.js'
5
+ export * as recordFormat from './record-format/index.js'
6
+ export * as flattenGetters from './flatten-getters/index.js'
6
7
  export * as recordMap from './record-map/index.js'
7
8
  export * as sortKeys from './sort-keys/index.js'
8
- export * as recordFormat from './record-format/index.js'
9
9
  export * as validation from './validation/index.js'
@@ -1,9 +1,9 @@
1
+ export * as deepGetProperty from './deep-get-property/index.js'
1
2
  export * as enums from './enums/index.js'
2
- export * as flattenGetters from './flatten-getters/index.js'
3
- export * as isObject from './is-object/index.js'
4
3
  export * as isRecord from './is-record/index.js'
5
- export * as deepGetProperty from './deep-get-property/index.js'
4
+ export * as isObject from './is-object/index.js'
5
+ export * as recordFormat from './record-format/index.js'
6
+ export * as flattenGetters from './flatten-getters/index.js'
6
7
  export * as recordMap from './record-map/index.js'
7
8
  export * as sortKeys from './sort-keys/index.js'
8
- export * as recordFormat from './record-format/index.js'
9
9
  export * as validation from './validation/index.js'
@@ -1,4 +1,4 @@
1
+ export * as fileName from './file-name/index.js'
1
2
  export * as path from './path/index.js'
2
3
  export * as html from './html/index.js'
3
- export * as fileName from './file-name/index.js'
4
4
  export * as userInput from './user-input/index.js'
@@ -1,4 +1,4 @@
1
+ export * as fileName from './file-name/index.js'
1
2
  export * as path from './path/index.js'
2
3
  export * as html from './html/index.js'
3
- export * as fileName from './file-name/index.js'
4
4
  export * as userInput from './user-input/index.js'
@@ -1,6 +1,6 @@
1
- export * as charCodes from './char-codes/index.js'
2
1
  export * as matches from './matches/index.js'
3
2
  export * as normalizeIndent from './normalize-indent/index.js'
3
+ export * as charCodes from './char-codes/index.js'
4
4
  export * as parseTable from './parse-table/index.js'
5
5
  export * as replaceAll from './replace-all/index.js'
6
6
  export * as toAlphanum from './to-alphanum/index.js'
@@ -1,6 +1,6 @@
1
- export * as charCodes from './char-codes/index.js'
2
1
  export * as matches from './matches/index.js'
3
2
  export * as normalizeIndent from './normalize-indent/index.js'
3
+ export * as charCodes from './char-codes/index.js'
4
4
  export * as parseTable from './parse-table/index.js'
5
5
  export * as replaceAll from './replace-all/index.js'
6
6
  export * as toAlphanum from './to-alphanum/index.js'
@@ -1,5 +1,5 @@
1
+ export * as duration from './duration/index.js'
1
2
  export * as dates from './dates/index.js'
3
+ export * as wait from './wait/index.js'
2
4
  export * as timeout from './timeout/index.js'
3
- export * as duration from './duration/index.js'
4
5
  export * as transitions from './transitions/index.js'
5
- export * as wait from './wait/index.js'
@@ -1,5 +1,5 @@
1
+ export * as duration from './duration/index.js'
1
2
  export * as dates from './dates/index.js'
3
+ export * as wait from './wait/index.js'
2
4
  export * as timeout from './timeout/index.js'
3
- export * as duration from './duration/index.js'
4
5
  export * as transitions from './transitions/index.js'
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,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
+ };
@@ -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>;