@dust-tt/sparkle 0.2.135 → 0.2.136-pr

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.
@@ -68,6 +68,8 @@ import { ElementModal } from "./components/ElementModal";
68
68
  export { ElementModal };
69
69
  import { Dialog } from "./components/Dialog";
70
70
  export { Dialog };
71
+ import { ElementDialog } from "./components/ElementDialog";
72
+ export { ElementDialog };
71
73
  import { Input } from "./components/Input";
72
74
  export { Input };
73
75
  import { Searchbar } from "./components/Searchbar";
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- type ModalProps = {
2
+ export type ModalProps = {
3
3
  title: string;
4
4
  children: React.ReactNode;
5
5
  isOpen: boolean;
@@ -12,4 +12,3 @@ type ModalProps = {
12
12
  backgroundType?: "confetti" | "snow" | "none";
13
13
  };
14
14
  export declare function Dialog({ isOpen, children, onCancel, onValidate, cancelLabel, validateLabel, validateVariant, title, isSaving, backgroundType, }: ModalProps): React.JSX.Element;
15
- export {};
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { ModalProps } from "./Dialog";
3
+ type ElementDialogProps<T> = Omit<ModalProps, "isOpen" | "onValidate" | "onCancel"> & {
4
+ openOnElement: T | null;
5
+ onValidate: (closeDialogFn: () => void) => void;
6
+ closeDialogFn: () => void;
7
+ };
8
+ export declare function ElementDialog<T>({ openOnElement, closeDialogFn, onValidate, ...props }: ElementDialogProps<T>): React.JSX.Element;
9
+ export {};
package/dist/cjs/index.js CHANGED
@@ -55169,6 +55169,19 @@ function Dialog(_a) {
55169
55169
  React.createElement(ConfettiBackground, { variant: backgroundType, referentSize: referentRef }))))))))));
55170
55170
  }
55171
55171
 
55172
+ function ElementDialog(_a) {
55173
+ var openOnElement = _a.openOnElement, closeDialogFn = _a.closeDialogFn, onValidate = _a.onValidate, props = __rest(_a, ["openOnElement", "closeDialogFn", "onValidate"]);
55174
+ var _b = __read(React.useState(false), 2), isClosingTransition = _b[0], setIsClosingTransition = _b[1];
55175
+ var transitionOnClose = React.useCallback(function () {
55176
+ setIsClosingTransition(true);
55177
+ setTimeout(function () {
55178
+ closeDialogFn();
55179
+ setIsClosingTransition(false);
55180
+ }, 200);
55181
+ }, [closeDialogFn]);
55182
+ return (React.createElement(Dialog, __assign({ isOpen: openOnElement !== null && !isClosingTransition, onCancel: transitionOnClose, onValidate: function () { return onValidate(transitionOnClose); } }, props)));
55183
+ }
55184
+
55172
55185
  var sizeInputClasses = {
55173
55186
  sm: "s-text-base s-rounded-md s-py-1.5 s-pl-4 s-pr-8",
55174
55187
  md: "s-text-lg s-rounded-lg s-py-2 s-pl-4 s-pr-10",
@@ -76946,6 +76959,7 @@ exports.DriveLogo = SvgDrive;
76946
76959
  exports.DropdownMenu = DropdownMenu;
76947
76960
  exports.DustIcon = SvgDust$1;
76948
76961
  exports.DustStrokeIcon = SvgDust;
76962
+ exports.ElementDialog = ElementDialog;
76949
76963
  exports.ElementModal = ElementModal;
76950
76964
  exports.EmotionLaughIcon = SvgEmotionLaugh$1;
76951
76965
  exports.EmotionLaughStrokeIcon = SvgEmotionLaugh;