@dust-tt/sparkle 0.2.93 → 0.2.94-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.
@@ -56,6 +56,8 @@ import Spinner from "./components/Spinner";
56
56
  export { Spinner };
57
57
  import { Modal } from "./components/Modal";
58
58
  export { Modal };
59
+ import { ElementModal } from "./components/ElementModal";
60
+ export { ElementModal };
59
61
  import { Dialog } from "./components/Dialog";
60
62
  export { Dialog };
61
63
  import { Input } from "./components/Input";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { ModalProps } from "./Modal";
3
+ type ElementModalProps<T> = Omit<ModalProps, "isOpen" | "onSave"> & {
4
+ openOnElement: T | null;
5
+ onSave?: (closeModalFn: () => void) => void;
6
+ };
7
+ export declare function ElementModal<T>({ openOnElement, onClose, onSave, ...props }: ElementModalProps<T>): React.JSX.Element;
8
+ export {};
@@ -5,7 +5,7 @@ export declare enum ModalType {
5
5
  FullScreen = "full-screen",
6
6
  Side = "side"
7
7
  }
8
- type ModalProps = {
8
+ export type ModalProps = {
9
9
  isOpen: boolean;
10
10
  onClose: () => void;
11
11
  action?: ButtonProps;
@@ -19,4 +19,3 @@ type ModalProps = {
19
19
  variant?: "full-screen" | "side-sm" | "side-md" | "dialogue";
20
20
  };
21
21
  export declare function Modal({ isOpen, onClose, action, children, hasChanged, onSave, saveLabel, isSaving, savingLabel, title, variant, }: ModalProps): React.JSX.Element;
22
- export {};
package/dist/cjs/index.js CHANGED
@@ -33613,6 +33613,19 @@ function Modal(_a) {
33613
33613
  React.createElement("div", { className: classNames("s-pb-6 s-pt-16", innerContainerClasses) }, children)))))));
33614
33614
  }
33615
33615
 
33616
+ function ElementModal(_a) {
33617
+ var openOnElement = _a.openOnElement, onClose = _a.onClose, onSave = _a.onSave, props = __rest(_a, ["openOnElement", "onClose", "onSave"]);
33618
+ var _b = __read(React.useState(false), 2), isClosingTransition = _b[0], setIsClosingTransition = _b[1];
33619
+ var transitionOnClose = React.useCallback(function () {
33620
+ setIsClosingTransition(true);
33621
+ setTimeout(function () {
33622
+ onClose();
33623
+ setIsClosingTransition(false);
33624
+ }, 200);
33625
+ }, [onClose]);
33626
+ return (React.createElement(Modal, __assign({ isOpen: openOnElement !== null && !isClosingTransition, onClose: transitionOnClose, onSave: onSave ? function () { return onSave(transitionOnClose); } : undefined }, props)));
33627
+ }
33628
+
33616
33629
  function Dialog(_a) {
33617
33630
  var isOpen = _a.isOpen, children = _a.children, onCancel = _a.onCancel, onValidate = _a.onValidate, _b = _a.cancelLabel, cancelLabel = _b === void 0 ? "Cancel" : _b, _c = _a.validateLabel, validateLabel = _c === void 0 ? "Ok" : _c, _d = _a.validateVariant, validateVariant = _d === void 0 ? "primary" : _d, title = _a.title;
33618
33631
  return (React.createElement(tt, { show: isOpen, as: React.Fragment, appear: true },
@@ -33868,6 +33881,7 @@ exports.DriveLogo = SvgDrive;
33868
33881
  exports.DropdownMenu = DropdownMenu;
33869
33882
  exports.DustIcon = SvgDust$1;
33870
33883
  exports.DustStrokeIcon = SvgDust;
33884
+ exports.ElementModal = ElementModal;
33871
33885
  exports.EmotionLaughIcon = SvgEmotionLaugh$1;
33872
33886
  exports.EmotionLaughStrokeIcon = SvgEmotionLaugh;
33873
33887
  exports.EqualizerIcon = SvgEqualizer$1;