@spark-ui/components 10.8.2 → 10.9.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.9.0](https://github.com/leboncoin/spark-web/compare/v10.8.2...v10.9.0) (2025-07-01)
7
+
8
+ ### Features
9
+
10
+ - **components:** added fade scroll indicator on Drawer ([4bc8f20](https://github.com/leboncoin/spark-web/commit/4bc8f2008a4daa12c13060b91929b5dc73eaaf2c))
11
+ - **components:** fade scroll effect on Dialog ([4b5d171](https://github.com/leboncoin/spark-web/commit/4b5d171a20e6433a61bbd6ccf7b680aa1e74c0ed))
12
+
6
13
  ## [10.8.2](https://github.com/leboncoin/spark-web/compare/v10.8.1...v10.8.2) (2025-07-01)
7
14
 
8
15
  **Note:** Version bump only for package @spark-ui/components
@@ -1,8 +1,8 @@
1
1
  import { Dialog as Dialog$1 } from 'radix-ui';
2
2
  import { ReactElement, ReactNode, Ref } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
5
  import { VariantProps } from 'class-variance-authority';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface DialogProps {
8
8
  /**
@@ -25,25 +25,25 @@ interface DialogProps {
25
25
  * Specifies if the dialog is a modal.
26
26
  */
27
27
  modal?: Dialog$1.DialogProps['modal'];
28
+ /**
29
+ * Specifies if the dialog should have a fade animation on its body (in case it is scrollable).
30
+ */
31
+ withFade?: boolean;
28
32
  }
29
33
  declare const Dialog: {
30
- ({ children, ...rest }: DialogProps): ReactElement;
34
+ ({ children, withFade, ...rest }: DialogProps): ReactElement;
31
35
  displayName: string;
32
36
  };
33
37
 
34
- declare const dialogBodyStyles: (props?: ({
35
- inset?: boolean | null | undefined;
36
- } & class_variance_authority_types.ClassProp) | undefined) => string;
37
- type DialogBodyStylesProps = VariantProps<typeof dialogBodyStyles>;
38
-
39
- interface BodyProps extends DialogBodyStylesProps {
38
+ interface BodyProps {
40
39
  children: ReactNode;
41
40
  className?: string;
42
41
  tabIndex?: number;
43
42
  ref?: Ref<HTMLDivElement>;
43
+ inset?: boolean;
44
44
  }
45
45
  declare const Body: {
46
- ({ children, className, inset, ref, ...rest }: BodyProps): ReactElement;
46
+ ({ children, className, inset, ref: forwardedRef, ...rest }: BodyProps): ReactElement;
47
47
  displayName: string;
48
48
  };
49
49
 
@@ -1,8 +1,8 @@
1
1
  import { Dialog as Dialog$1 } from 'radix-ui';
2
2
  import { ReactElement, ReactNode, Ref } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
5
  import { VariantProps } from 'class-variance-authority';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface DialogProps {
8
8
  /**
@@ -25,25 +25,25 @@ interface DialogProps {
25
25
  * Specifies if the dialog is a modal.
26
26
  */
27
27
  modal?: Dialog$1.DialogProps['modal'];
28
+ /**
29
+ * Specifies if the dialog should have a fade animation on its body (in case it is scrollable).
30
+ */
31
+ withFade?: boolean;
28
32
  }
29
33
  declare const Dialog: {
30
- ({ children, ...rest }: DialogProps): ReactElement;
34
+ ({ children, withFade, ...rest }: DialogProps): ReactElement;
31
35
  displayName: string;
32
36
  };
33
37
 
34
- declare const dialogBodyStyles: (props?: ({
35
- inset?: boolean | null | undefined;
36
- } & class_variance_authority_types.ClassProp) | undefined) => string;
37
- type DialogBodyStylesProps = VariantProps<typeof dialogBodyStyles>;
38
-
39
- interface BodyProps extends DialogBodyStylesProps {
38
+ interface BodyProps {
40
39
  children: ReactNode;
41
40
  className?: string;
42
41
  tabIndex?: number;
43
42
  ref?: Ref<HTMLDivElement>;
43
+ inset?: boolean;
44
44
  }
45
45
  declare const Body: {
46
- ({ children, className, inset, ref, ...rest }: BodyProps): ReactElement;
46
+ ({ children, className, inset, ref: forwardedRef, ...rest }: BodyProps): ReactElement;
47
47
  displayName: string;
48
48
  };
49
49
 
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { e as DialogProps, C as CloseProps, h as BodyProps, f as ContentProps, n as DescriptionProps, i as FooterProps, g as HeaderProps, k as OverlayProps, l as PortalProps, m as TitleProps, j as TriggerProps } from '../DialogTrigger-5SI4dvpK.mjs';
2
+ import { e as DialogProps, C as CloseProps, h as BodyProps, f as ContentProps, n as DescriptionProps, i as FooterProps, g as HeaderProps, k as OverlayProps, l as PortalProps, m as TitleProps, j as TriggerProps } from '../DialogTrigger-woU7vsJi.mjs';
3
3
  import { Ref, MutableRefObject } from 'react';
4
4
  import 'radix-ui';
5
5
  import 'class-variance-authority/types';
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { e as DialogProps, C as CloseProps, h as BodyProps, f as ContentProps, n as DescriptionProps, i as FooterProps, g as HeaderProps, k as OverlayProps, l as PortalProps, m as TitleProps, j as TriggerProps } from '../DialogTrigger-5SI4dvpK.js';
2
+ import { e as DialogProps, C as CloseProps, h as BodyProps, f as ContentProps, n as DescriptionProps, i as FooterProps, g as HeaderProps, k as OverlayProps, l as PortalProps, m as TitleProps, j as TriggerProps } from '../DialogTrigger-woU7vsJi.js';
3
3
  import { Ref, MutableRefObject } from 'react';
4
4
  import 'radix-ui';
5
5
  import 'class-variance-authority/types';
@@ -33,14 +33,18 @@ var import_react2 = require("react");
33
33
  var import_react = require("react");
34
34
  var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var DialogContext = (0, import_react.createContext)(null);
36
- var DialogProvider = ({ children: childrenProp }) => {
36
+ var DialogProvider = ({
37
+ children: childrenProp,
38
+ withFade = false
39
+ }) => {
37
40
  const [isFullScreen, setIsFullScreen] = (0, import_react.useState)(false);
38
41
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
39
42
  DialogContext.Provider,
40
43
  {
41
44
  value: {
42
45
  isFullScreen,
43
- setIsFullScreen
46
+ setIsFullScreen,
47
+ withFade
44
48
  },
45
49
  children: childrenProp
46
50
  }
@@ -56,7 +60,7 @@ var useDialog = () => {
56
60
 
57
61
  // src/dialog/Dialog.tsx
58
62
  var import_jsx_runtime2 = require("react/jsx-runtime");
59
- var Dialog = ({ children, ...rest }) => {
63
+ var Dialog = ({ children, withFade = false, ...rest }) => {
60
64
  const open = rest.open;
61
65
  const activeElementRef = (0, import_react2.useRef)(null);
62
66
  function handleActiveElementFocus() {
@@ -71,42 +75,52 @@ var Dialog = ({ children, ...rest }) => {
71
75
  }
72
76
  }
73
77
  (0, import_react2.useEffect)(handleActiveElementFocus, [open]);
74
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DialogProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_radix_ui.Dialog.Root, { ...rest, children }) });
78
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DialogProvider, { withFade, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_radix_ui.Dialog.Root, { ...rest, children }) });
75
79
  };
76
80
  Dialog.displayName = "Dialog.Root";
77
81
 
78
- // src/dialog/DialogBody.styles.ts
79
- var import_class_variance_authority = require("class-variance-authority");
80
- var dialogBodyStyles = (0, import_class_variance_authority.cva)(
81
- ["grow", "overflow-y-auto", "outline-hidden", "focus-visible:u-outline"],
82
- {
83
- variants: {
84
- inset: {
85
- true: "",
86
- false: "px-xl py-lg"
87
- }
88
- }
89
- }
90
- );
91
-
92
82
  // src/dialog/DialogBody.tsx
83
+ var import_use_merge_refs = require("@spark-ui/hooks/use-merge-refs");
84
+ var import_use_scroll_overflow = require("@spark-ui/hooks/use-scroll-overflow");
85
+ var import_class_variance_authority = require("class-variance-authority");
86
+ var import_react3 = require("react");
93
87
  var import_jsx_runtime3 = require("react/jsx-runtime");
94
88
  var Body = ({
95
89
  children,
96
90
  className,
97
91
  inset = false,
98
- ref,
92
+ ref: forwardedRef,
99
93
  ...rest
100
- }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
101
- "div",
102
- {
103
- "data-spark-component": "dialog-body",
104
- ref,
105
- className: dialogBodyStyles({ inset, className }),
106
- ...rest,
107
- children
108
- }
109
- );
94
+ }) => {
95
+ const scrollAreaRef = (0, import_react3.useRef)(null);
96
+ const ref = (0, import_use_merge_refs.useMergeRefs)(forwardedRef, scrollAreaRef);
97
+ const { withFade } = useDialog();
98
+ const overflow = (0, import_use_scroll_overflow.useScrollOverflow)(scrollAreaRef);
99
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
100
+ "div",
101
+ {
102
+ "data-spark-component": "dialog-body",
103
+ ref,
104
+ className: (0, import_class_variance_authority.cx)(
105
+ "focus-visible:u-outline relative grow overflow-y-auto outline-hidden",
106
+ "transition-all duration-300",
107
+ {
108
+ ["px-xl py-lg"]: !inset
109
+ },
110
+ className
111
+ ),
112
+ style: {
113
+ ...withFade && {
114
+ maskImage: "linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))",
115
+ maskSize: `100% calc(100% + ${overflow.top ? "0px" : "44px"} + ${overflow.bottom ? "0px" : "44px"})`,
116
+ maskPosition: `0 ${overflow.top ? "0px" : "-44px"}`
117
+ }
118
+ },
119
+ ...rest,
120
+ children
121
+ }
122
+ );
123
+ };
110
124
  Body.displayName = "Dialog.Body";
111
125
 
112
126
  // src/dialog/DialogClose.tsx
@@ -120,11 +134,11 @@ var import_Close = require("@spark-ui/icons/Close");
120
134
  var import_class_variance_authority7 = require("class-variance-authority");
121
135
 
122
136
  // src/icon/Icon.tsx
123
- var import_react4 = require("react");
137
+ var import_react5 = require("react");
124
138
 
125
139
  // src/slot/Slot.tsx
126
140
  var import_radix_ui3 = require("radix-ui");
127
- var import_react3 = require("react");
141
+ var import_react4 = require("react");
128
142
  var import_jsx_runtime5 = require("react/jsx-runtime");
129
143
  var Slottable = import_radix_ui3.Slot.Slottable;
130
144
  var Slot = ({ ref, ...props }) => {
@@ -132,7 +146,7 @@ var Slot = ({ ref, ...props }) => {
132
146
  };
133
147
  var wrapPolymorphicSlot = (asChild, children, callback) => {
134
148
  if (!asChild) return callback(children);
135
- return (0, import_react3.isValidElement)(children) ? (0, import_react3.cloneElement)(
149
+ return (0, import_react4.isValidElement)(children) ? (0, import_react4.cloneElement)(
136
150
  children,
137
151
  void 0,
138
152
  callback(children.props.children)
@@ -210,9 +224,9 @@ var Icon = ({
210
224
  children,
211
225
  ...others
212
226
  }) => {
213
- const child = import_react4.Children.only(children);
227
+ const child = import_react5.Children.only(children);
214
228
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
215
- (0, import_react4.cloneElement)(child, {
229
+ (0, import_react5.cloneElement)(child, {
216
230
  className: iconStyles({ className, size, intent }),
217
231
  "data-spark-component": "icon",
218
232
  "aria-hidden": "true",
@@ -226,7 +240,7 @@ Icon.displayName = "Icon";
226
240
 
227
241
  // src/button/Button.tsx
228
242
  var import_class_variance_authority5 = require("class-variance-authority");
229
- var import_react5 = require("react");
243
+ var import_react6 = require("react");
230
244
 
231
245
  // src/spinner/Spinner.styles.tsx
232
246
  var import_internal_utils2 = require("@spark-ui/internal-utils");
@@ -978,7 +992,7 @@ var Button = ({
978
992
  }) => {
979
993
  const Component = asChild ? Slot : "button";
980
994
  const shouldNotInteract = !!disabled || isLoading;
981
- const disabledEventHandlers = (0, import_react5.useMemo)(() => {
995
+ const disabledEventHandlers = (0, import_react6.useMemo)(() => {
982
996
  const result = {};
983
997
  if (shouldNotInteract) {
984
998
  blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
@@ -1108,7 +1122,7 @@ Root.displayName = "Dialog.CloseButton";
1108
1122
 
1109
1123
  // src/dialog/DialogContent.tsx
1110
1124
  var import_radix_ui4 = require("radix-ui");
1111
- var import_react6 = require("react");
1125
+ var import_react7 = require("react");
1112
1126
 
1113
1127
  // src/dialog/DialogContent.styles.tsx
1114
1128
  var import_class_variance_authority8 = require("class-variance-authority");
@@ -1168,7 +1182,7 @@ var Content = ({
1168
1182
  ...rest
1169
1183
  }) => {
1170
1184
  const { setIsFullScreen } = useDialog();
1171
- (0, import_react6.useEffect)(() => {
1185
+ (0, import_react7.useEffect)(() => {
1172
1186
  if (size === "fullscreen") setIsFullScreen(true);
1173
1187
  return () => setIsFullScreen(false);
1174
1188
  }, [setIsFullScreen, size]);
@@ -1339,13 +1353,13 @@ var AlertDialogBody = (props) => {
1339
1353
  AlertDialogBody.displayName = "AlertDialog.Body";
1340
1354
 
1341
1355
  // src/alert-dialog/AlertDialogCancel.tsx
1342
- var import_use_merge_refs = require("@spark-ui/hooks/use-merge-refs");
1356
+ var import_use_merge_refs2 = require("@spark-ui/hooks/use-merge-refs");
1343
1357
 
1344
1358
  // src/alert-dialog/AlertDialogContext.ts
1345
- var import_react7 = require("react");
1346
- var AlertDialogContext = (0, import_react7.createContext)(null);
1359
+ var import_react8 = require("react");
1360
+ var AlertDialogContext = (0, import_react8.createContext)(null);
1347
1361
  var useAlertDialog = () => {
1348
- const context = (0, import_react7.useContext)(AlertDialogContext);
1362
+ const context = (0, import_react8.useContext)(AlertDialogContext);
1349
1363
  if (!context) {
1350
1364
  throw Error("useAlertDialog must be used within a RadioGroup provider");
1351
1365
  }
@@ -1356,7 +1370,7 @@ var useAlertDialog = () => {
1356
1370
  var import_jsx_runtime23 = require("react/jsx-runtime");
1357
1371
  var AlertDialogCancel = ({ ref: forwardedRef, ...props }) => {
1358
1372
  const { cancelRef } = useAlertDialog();
1359
- const ref = (0, import_use_merge_refs.useMergeRefs)(forwardedRef, cancelRef);
1373
+ const ref = (0, import_use_merge_refs2.useMergeRefs)(forwardedRef, cancelRef);
1360
1374
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Dialog2.Close, { ref, "data-spark-component": "alert-dialog-cancel", ...props });
1361
1375
  };
1362
1376
  AlertDialogCancel.displayName = "AlertDialog.Cancel";
@@ -1364,7 +1378,7 @@ AlertDialogCancel.displayName = "AlertDialog.Cancel";
1364
1378
  // src/alert-dialog/AlertDialogContent.tsx
1365
1379
  var import_class_variance_authority13 = require("class-variance-authority");
1366
1380
  var import_internal = require("radix-ui/internal");
1367
- var import_react8 = require("react");
1381
+ var import_react9 = require("react");
1368
1382
  var import_jsx_runtime24 = require("react/jsx-runtime");
1369
1383
  var AlertDialogContent = ({
1370
1384
  className,
@@ -1372,8 +1386,8 @@ var AlertDialogContent = ({
1372
1386
  ref,
1373
1387
  ...others
1374
1388
  }) => {
1375
- const cancelRef = (0, import_react8.useRef)(null);
1376
- const value = (0, import_react8.useMemo)(() => {
1389
+ const cancelRef = (0, import_react9.useRef)(null);
1390
+ const value = (0, import_react9.useMemo)(() => {
1377
1391
  return { cancelRef };
1378
1392
  }, []);
1379
1393
  const handleOpenAutoFocus = (event) => {