@dust-tt/sparkle 0.2.134 → 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
@@ -777,8 +777,9 @@ function Tooltip(_a) {
777
777
  React.useEffect(function () {
778
778
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
779
779
  return function () {
780
- if (timerId)
780
+ if (timerId) {
781
781
  window.clearTimeout(timerId);
782
+ }
782
783
  };
783
784
  }, [timerId]);
784
785
  if (isTouchDevice) {
@@ -32328,8 +32329,9 @@ ContextItem.List = function (_a) {
32328
32329
  var children = _a.children, className = _a.className, hasBorder = _a.hasBorder;
32329
32330
  // Ensure all children are of type ContextItem or ContextItem.SectionHeader
32330
32331
  React.Children.forEach(children, function (child) {
32331
- if (child === null || child === undefined)
32332
+ if (child === null || child === undefined) {
32332
32333
  return;
32334
+ }
32333
32335
  if (!React.isValidElement(child) ||
32334
32336
  (child.type !== ContextItem &&
32335
32337
  child.type !== ContextItem.SectionHeader &&
@@ -55167,6 +55169,19 @@ function Dialog(_a) {
55167
55169
  React.createElement(ConfettiBackground, { variant: backgroundType, referentSize: referentRef }))))))))));
55168
55170
  }
55169
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
+
55170
55185
  var sizeInputClasses = {
55171
55186
  sm: "s-text-base s-rounded-md s-py-1.5 s-pl-4 s-pr-8",
55172
55187
  md: "s-text-lg s-rounded-lg s-py-2 s-pl-4 s-pr-10",
@@ -76944,6 +76959,7 @@ exports.DriveLogo = SvgDrive;
76944
76959
  exports.DropdownMenu = DropdownMenu;
76945
76960
  exports.DustIcon = SvgDust$1;
76946
76961
  exports.DustStrokeIcon = SvgDust;
76962
+ exports.ElementDialog = ElementDialog;
76947
76963
  exports.ElementModal = ElementModal;
76948
76964
  exports.EmotionLaughIcon = SvgEmotionLaugh$1;
76949
76965
  exports.EmotionLaughStrokeIcon = SvgEmotionLaugh;