@economic/taco 1.12.1 → 1.12.2

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 (28) hide show
  1. package/dist/components/Button/Button.stories.d.ts +3 -3
  2. package/dist/components/Button/util.d.ts +2 -1
  3. package/dist/components/IconButton/IconButton.d.ts +30 -1
  4. package/dist/components/IconButton/IconButton.stories.d.ts +2 -2
  5. package/dist/components/Popover/Popover.d.ts +1 -1
  6. package/dist/esm/components/AlertDialog/AlertDialog.js +1 -1
  7. package/dist/esm/components/AlertDialog/AlertDialog.js.map +1 -1
  8. package/dist/esm/components/AlertDialog/components/Trigger.js +8 -4
  9. package/dist/esm/components/AlertDialog/components/Trigger.js.map +1 -1
  10. package/dist/esm/components/Button/Button.js +26 -8
  11. package/dist/esm/components/Button/Button.js.map +1 -1
  12. package/dist/esm/components/Button/util.js +22 -16
  13. package/dist/esm/components/Button/util.js.map +1 -1
  14. package/dist/esm/components/Dialog/components/Trigger.js +8 -4
  15. package/dist/esm/components/Dialog/components/Trigger.js.map +1 -1
  16. package/dist/esm/components/Hanger/Hanger.js +13 -6
  17. package/dist/esm/components/Hanger/Hanger.js.map +1 -1
  18. package/dist/esm/components/IconButton/IconButton.js +22 -4
  19. package/dist/esm/components/IconButton/IconButton.js.map +1 -1
  20. package/dist/esm/components/Popover/Popover.js +8 -4
  21. package/dist/esm/components/Popover/Popover.js.map +1 -1
  22. package/dist/esm/index.js +1 -1
  23. package/dist/taco.cjs.development.js +105 -43
  24. package/dist/taco.cjs.development.js.map +1 -1
  25. package/dist/taco.cjs.production.min.js +1 -1
  26. package/dist/taco.cjs.production.min.js.map +1 -1
  27. package/package.json +2 -2
  28. package/types.json +3 -3
@@ -7,7 +7,7 @@ declare const _default: {
7
7
  href?: string | undefined;
8
8
  target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
9
9
  } & {
10
- appearance?: "default" | "primary" | "danger" | "ghost" | "discrete" | undefined;
10
+ appearance?: "primary" | "default" | "danger" | "ghost" | "discrete" | undefined;
11
11
  dialog?: ((props: Partial<import("../..").DialogProps>) => JSX.Element) | undefined;
12
12
  fluid?: boolean | undefined;
13
13
  hanger?: ((props: Partial<React.PropsWithChildren<{
@@ -54,11 +54,11 @@ export declare const WithHanger: {
54
54
  (args: ButtonProps): JSX.Element;
55
55
  storyName: string;
56
56
  };
57
- export declare const WithDialog: {
57
+ export declare const WithAlertDialog: {
58
58
  (args: ButtonProps): JSX.Element;
59
59
  storyName: string;
60
60
  };
61
- export declare const WithAlertDialog: {
61
+ export declare const WithDialog: {
62
62
  (args: ButtonProps): JSX.Element;
63
63
  storyName: string;
64
64
  };
@@ -2,4 +2,5 @@ import React from 'react';
2
2
  import { Appearance } from '../../types';
3
3
  export declare const getButtonClasses: () => string;
4
4
  export declare const getAppearanceClasses: (value: Appearance | undefined, icon?: boolean) => string;
5
- export declare const createButton: (props: any, className: string, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) => JSX.Element;
5
+ export declare const createButtonWithTooltip: (props: any, className: string, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) => JSX.Element;
6
+ export declare const createButtonWithOverlays: (props: any, buttonBase: JSX.Element) => JSX.Element;
@@ -32,6 +32,35 @@ export declare type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'childre
32
32
  /** A tooltip to show when hovering over the button */
33
33
  tooltip?: string;
34
34
  };
35
+ export declare const Base: React.ForwardRefExoticComponent<Pick<ButtonPrimitive.ButtonProps, "autoFocus" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "href" | "target"> & {
36
+ /** Appearance will change the style of the button */
37
+ appearance?: "default" | "primary" | "danger" | "ghost" | "discrete" | undefined;
38
+ /**
39
+ * Dialog component associated with the button, clicking the button will open the dialog.
40
+ * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of
41
+ * the button should be only to open the associated dialog when clicked.
42
+ */
43
+ dialog?: ((props: Partial<DialogProps>) => JSX.Element) | undefined;
44
+ /** Hanger component associated with the button. */
45
+ hanger?: ((props: Partial<HangerProps>) => JSX.Element) | undefined;
46
+ /** Set which icon should be rendered within button */
47
+ icon: IconName;
48
+ /** Menu component associated with the button. */
49
+ menu?: ((props: Partial<MenuProps>) => JSX.Element) | undefined;
50
+ /**
51
+ * Popover component associated with the button, clicking the button will open the popover.
52
+ * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of
53
+ * the button should be only to open the associated popover when clicked.
54
+ */
55
+ popover?: ((props: Partial<PopoverProps>) => JSX.Element) | undefined;
56
+ /**
57
+ * Set whether the button is rounded.
58
+ * Default value is `false`
59
+ */
60
+ rounded?: boolean | undefined;
61
+ /** A tooltip to show when hovering over the button */
62
+ tooltip?: string | undefined;
63
+ } & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
35
64
  export declare const IconButton: React.ForwardRefExoticComponent<Pick<ButtonPrimitive.ButtonProps, "autoFocus" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "href" | "target"> & {
36
65
  /** Appearance will change the style of the button */
37
66
  appearance?: "default" | "primary" | "danger" | "ghost" | "discrete" | undefined;
@@ -60,4 +89,4 @@ export declare const IconButton: React.ForwardRefExoticComponent<Pick<ButtonPrim
60
89
  rounded?: boolean | undefined;
61
90
  /** A tooltip to show when hovering over the button */
62
91
  tooltip?: string | undefined;
63
- } & React.RefAttributes<HTMLButtonElement>>;
92
+ } & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  component: React.ForwardRefExoticComponent<Pick<import("../../primitives/Button").ButtonProps, "draggable" | "name" | "form" | "className" | "color" | "id" | "lang" | "style" | "target" | "type" | "role" | "tabIndex" | "href" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "slot" | "title" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value"> & {
5
- appearance?: "default" | "primary" | "danger" | "ghost" | "discrete" | undefined;
5
+ appearance?: "primary" | "default" | "danger" | "ghost" | "discrete" | undefined;
6
6
  dialog?: ((props: Partial<import("../..").DialogProps>) => JSX.Element) | undefined;
7
7
  hanger?: ((props: Partial<React.PropsWithChildren<{
8
8
  anchor?: JSX.Element | undefined;
@@ -16,7 +16,7 @@ declare const _default: {
16
16
  }>>) => JSX.Element) | undefined;
17
17
  rounded?: boolean | undefined;
18
18
  tooltip?: string | undefined;
19
- } & React.RefAttributes<HTMLButtonElement>>;
19
+ } & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
20
20
  };
21
21
  export default _default;
22
22
  export declare const Default: () => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Placement } from '../..';
3
- export declare type PopoverTriggerProps = React.HTMLAttributes<HTMLButtonElement>;
3
+ export declare type PopoverTriggerProps = React.HTMLAttributes<HTMLElement>;
4
4
  export declare type PopoverContentRenderProps = {
5
5
  close: () => void;
6
6
  };
@@ -17,9 +17,9 @@ const AlertDialog = /*#__PURE__*/forwardRef(function AlertDialog(props, ref) {
17
17
  ...otherProps
18
18
  } = props;
19
19
  const context = useMemo(() => ({
20
- ref,
21
20
  draggable,
22
21
  props: otherProps,
22
+ ref,
23
23
  size,
24
24
  trigger
25
25
  }), [draggable, open, otherProps]);
@@ -1 +1 @@
1
- {"version":3,"file":"AlertDialog.js","sources":["../../../../src/components/AlertDialog/AlertDialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport { AlertDialogContext } from './Context';\nimport { Trigger, AlertDialogTriggerProps } from './components/Trigger';\nimport {\n Cancel,\n Action,\n Footer,\n AlertDialogCancelProps,\n AlertDialogActionProps,\n AlertDialogFooterProps,\n} from './components/Footer';\nimport { Title, Content, AlertDialogContentProps, AlertDialogTitleProps } from './components/Content';\nimport { DialogSize } from '../Dialog/types';\n\nexport type AlertDialogProps = {\n children: React.ReactNode | React.ReactNode[];\n /** Set whether the alert dialog is open by default or not, use when not providing a trigger */\n defaultOpen?: boolean;\n /** Allows dragging the alert dialog around the screen (window constrained) */\n draggable?: boolean;\n /** Called when the alert dialog opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean) => void;\n /** Control the open state of the dialog from outside the component */\n open?: boolean;\n /** Size of the alert dialog. This is the recommended way to set a size for alert dialog component. */\n size?: DialogSize;\n /** A trigger to be used for the alert dialog, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n};\n\nexport type ForwardedAlertDialogWithStatics = React.ForwardRefExoticComponent<\n AlertDialogProps & React.RefAttributes<HTMLElement>\n> & {\n Trigger: React.ForwardRefExoticComponent<AlertDialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<AlertDialogContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<AlertDialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<AlertDialogFooterProps & React.RefAttributes<HTMLDivElement>>;\n Action: React.ForwardRefExoticComponent<AlertDialogActionProps & React.RefAttributes<HTMLButtonElement>>;\n Cancel: React.ForwardRefExoticComponent<AlertDialogCancelProps & React.RefAttributes<HTMLButtonElement>>;\n};\n\nexport const AlertDialog = React.forwardRef(function AlertDialog(props: AlertDialogProps, ref: React.Ref<HTMLElement>) {\n const {\n children: initialChildren,\n defaultOpen,\n draggable = false,\n size = 'dialog',\n onChange,\n open,\n trigger,\n ...otherProps\n } = props;\n\n const context = React.useMemo(\n () => ({\n ref,\n draggable,\n props: otherProps,\n size,\n trigger,\n }),\n [draggable, open, otherProps]\n );\n\n return (\n <AlertDialogContext.Provider value={context}>\n <AlertDialogPrimitive.Root {...props} defaultOpen={defaultOpen} open={open} onOpenChange={onChange}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {props.children}\n </AlertDialogPrimitive.Root>\n </AlertDialogContext.Provider>\n );\n}) as ForwardedAlertDialogWithStatics;\n\nAlertDialog.Trigger = Trigger;\nAlertDialog.Content = Content;\nAlertDialog.Title = Title;\nAlertDialog.Cancel = Cancel;\nAlertDialog.Action = Action;\nAlertDialog.Footer = Footer;\n"],"names":["AlertDialog","React","props","ref","children","initialChildren","defaultOpen","draggable","size","onChange","open","trigger","otherProps","context","AlertDialogContext","Provider","value","AlertDialogPrimitive","onOpenChange","Trigger","Content","Title","Cancel","Action","Footer"],"mappings":";;;;;;;MA0CaA,WAAW,gBAAGC,UAAA,CAAiB,SAASD,WAAT,CAAqBE,KAArB,EAA8CC,GAA9C;EACxC,MAAM;IACFC,QAAQ,EAAEC,eADR;IAEFC,WAFE;IAGFC,SAAS,GAAG,KAHV;IAIFC,IAAI,GAAG,QAJL;IAKFC,QALE;IAMFC,IANE;IAOFC,OAPE;IAQF,GAAGC;MACHV,KATJ;EAWA,MAAMW,OAAO,GAAGZ,OAAA,CACZ,OAAO;IACHE,GADG;IAEHI,SAFG;IAGHL,KAAK,EAAEU,UAHJ;IAIHJ,IAJG;IAKHG;GALJ,CADY,EAQZ,CAACJ,SAAD,EAAYG,IAAZ,EAAkBE,UAAlB,CARY,CAAhB;EAWA,oBACIX,aAAA,CAACa,kBAAkB,CAACC,QAApB;IAA6BC,KAAK,EAAEH;GAApC,eACIZ,aAAA,CAACgB,IAAD,oBAA+Bf;IAAOI,WAAW,EAAEA;IAAaI,IAAI,EAAEA;IAAMQ,YAAY,EAAET;IAA1F,EACKE,OAAO,iBAAIV,aAAA,CAACkB,OAAD,MAAA,EAAUR,OAAV,CADhB,EAEKT,KAAK,CAACE,QAFX,CADJ,CADJ;AAQH,CA/B0B;AAiC3BJ,WAAW,CAACmB,OAAZ,GAAsBA,OAAtB;AACAnB,WAAW,CAACoB,OAAZ,GAAsBA,OAAtB;AACApB,WAAW,CAACqB,KAAZ,GAAoBA,KAApB;AACArB,WAAW,CAACsB,MAAZ,GAAqBA,MAArB;AACAtB,WAAW,CAACuB,MAAZ,GAAqBA,MAArB;AACAvB,WAAW,CAACwB,MAAZ,GAAqBA,MAArB;;;;"}
1
+ {"version":3,"file":"AlertDialog.js","sources":["../../../../src/components/AlertDialog/AlertDialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport { AlertDialogContext } from './Context';\nimport { Trigger, AlertDialogTriggerProps } from './components/Trigger';\nimport {\n Cancel,\n Action,\n Footer,\n AlertDialogCancelProps,\n AlertDialogActionProps,\n AlertDialogFooterProps,\n} from './components/Footer';\nimport { Title, Content, AlertDialogContentProps, AlertDialogTitleProps } from './components/Content';\nimport { DialogSize } from '../Dialog/types';\n\nexport type AlertDialogProps = {\n children: React.ReactNode | React.ReactNode[];\n /** Set whether the alert dialog is open by default or not, use when not providing a trigger */\n defaultOpen?: boolean;\n /** Allows dragging the alert dialog around the screen (window constrained) */\n draggable?: boolean;\n /** Called when the alert dialog opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean) => void;\n /** Control the open state of the dialog from outside the component */\n open?: boolean;\n /** Size of the alert dialog. This is the recommended way to set a size for alert dialog component. */\n size?: DialogSize;\n /** A trigger to be used for the alert dialog, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n};\n\nexport type ForwardedAlertDialogWithStatics = React.ForwardRefExoticComponent<\n AlertDialogProps & React.RefAttributes<HTMLElement>\n> & {\n Trigger: React.ForwardRefExoticComponent<AlertDialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<AlertDialogContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<AlertDialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<AlertDialogFooterProps & React.RefAttributes<HTMLDivElement>>;\n Action: React.ForwardRefExoticComponent<AlertDialogActionProps & React.RefAttributes<HTMLButtonElement>>;\n Cancel: React.ForwardRefExoticComponent<AlertDialogCancelProps & React.RefAttributes<HTMLButtonElement>>;\n};\n\nexport const AlertDialog = React.forwardRef(function AlertDialog(props: AlertDialogProps, ref: React.Ref<HTMLElement>) {\n const {\n children: initialChildren,\n defaultOpen,\n draggable = false,\n size = 'dialog',\n onChange,\n open,\n trigger,\n ...otherProps\n } = props;\n\n const context = React.useMemo(\n () => ({\n draggable,\n props: otherProps,\n ref,\n size,\n trigger,\n }),\n [draggable, open, otherProps]\n );\n\n return (\n <AlertDialogContext.Provider value={context}>\n <AlertDialogPrimitive.Root {...props} defaultOpen={defaultOpen} open={open} onOpenChange={onChange}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {props.children}\n </AlertDialogPrimitive.Root>\n </AlertDialogContext.Provider>\n );\n}) as ForwardedAlertDialogWithStatics;\n\nAlertDialog.Trigger = Trigger;\nAlertDialog.Content = Content;\nAlertDialog.Title = Title;\nAlertDialog.Cancel = Cancel;\nAlertDialog.Action = Action;\nAlertDialog.Footer = Footer;\n"],"names":["AlertDialog","React","props","ref","children","initialChildren","defaultOpen","draggable","size","onChange","open","trigger","otherProps","context","AlertDialogContext","Provider","value","AlertDialogPrimitive","onOpenChange","Trigger","Content","Title","Cancel","Action","Footer"],"mappings":";;;;;;;MA0CaA,WAAW,gBAAGC,UAAA,CAAiB,SAASD,WAAT,CAAqBE,KAArB,EAA8CC,GAA9C;EACxC,MAAM;IACFC,QAAQ,EAAEC,eADR;IAEFC,WAFE;IAGFC,SAAS,GAAG,KAHV;IAIFC,IAAI,GAAG,QAJL;IAKFC,QALE;IAMFC,IANE;IAOFC,OAPE;IAQF,GAAGC;MACHV,KATJ;EAWA,MAAMW,OAAO,GAAGZ,OAAA,CACZ,OAAO;IACHM,SADG;IAEHL,KAAK,EAAEU,UAFJ;IAGHT,GAHG;IAIHK,IAJG;IAKHG;GALJ,CADY,EAQZ,CAACJ,SAAD,EAAYG,IAAZ,EAAkBE,UAAlB,CARY,CAAhB;EAWA,oBACIX,aAAA,CAACa,kBAAkB,CAACC,QAApB;IAA6BC,KAAK,EAAEH;GAApC,eACIZ,aAAA,CAACgB,IAAD,oBAA+Bf;IAAOI,WAAW,EAAEA;IAAaI,IAAI,EAAEA;IAAMQ,YAAY,EAAET;IAA1F,EACKE,OAAO,iBAAIV,aAAA,CAACkB,OAAD,MAAA,EAAUR,OAAV,CADhB,EAEKT,KAAK,CAACE,QAFX,CADJ,CADJ;AAQH,CA/B0B;AAiC3BJ,WAAW,CAACmB,OAAZ,GAAsBA,OAAtB;AACAnB,WAAW,CAACoB,OAAZ,GAAsBA,OAAtB;AACApB,WAAW,CAACqB,KAAZ,GAAoBA,KAApB;AACArB,WAAW,CAACsB,MAAZ,GAAqBA,MAArB;AACAtB,WAAW,CAACuB,MAAZ,GAAqBA,MAArB;AACAvB,WAAW,CAACwB,MAAZ,GAAqBA,MAArB;;;;"}
@@ -3,10 +3,14 @@ import { Trigger as Trigger$1 } from '@radix-ui/react-alert-dialog';
3
3
  import { useCurrentAlertDialog } from '../Context.js';
4
4
  import { mergeRefs } from '../../../utils/mergeRefs.js';
5
5
 
6
- const Trigger = /*#__PURE__*/forwardRef(function AlertDialogTrigger(props, ref) {
7
- const dialog = useCurrentAlertDialog();
8
- return /*#__PURE__*/createElement(Trigger$1, Object.assign({}, props, {
9
- ref: mergeRefs([dialog.ref, ref]),
6
+ const Trigger = /*#__PURE__*/forwardRef(function AlertDialogTrigger(props, externalRef) {
7
+ const {
8
+ ref: parentRef,
9
+ props: parentProps
10
+ } = useCurrentAlertDialog();
11
+ const refCallback = mergeRefs([parentRef, externalRef]);
12
+ return /*#__PURE__*/createElement(Trigger$1, Object.assign({}, parentProps, props, {
13
+ ref: refCallback,
10
14
  asChild: true
11
15
  }));
12
16
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Trigger.js","sources":["../../../../../src/components/AlertDialog/components/Trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport { useCurrentAlertDialog } from '../Context';\nimport { mergeRefs } from '../../../utils/mergeRefs';\n\nexport type AlertDialogTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\nexport const Trigger = React.forwardRef(function AlertDialogTrigger(\n props: AlertDialogTriggerProps,\n ref: React.Ref<HTMLButtonElement>\n) {\n const dialog = useCurrentAlertDialog();\n return <AlertDialogPrimitive.Trigger {...props} ref={mergeRefs([dialog.ref, ref])} asChild />;\n});\n"],"names":["Trigger","React","AlertDialogTrigger","props","ref","dialog","useCurrentAlertDialog","AlertDialogPrimitive","mergeRefs","asChild"],"mappings":";;;;;MAMaA,OAAO,gBAAGC,UAAA,CAAiB,SAASC,kBAAT,CACpCC,KADoC,EAEpCC,GAFoC;EAIpC,MAAMC,MAAM,GAAGC,qBAAqB,EAApC;EACA,oBAAOL,aAAA,CAACM,SAAD,oBAAkCJ;IAAOC,GAAG,EAAEI,SAAS,CAAC,CAACH,MAAM,CAACD,GAAR,EAAaA,GAAb,CAAD;IAAqBK,OAAO;IAAnF,CAAP;AACH,CANsB;;;;"}
1
+ {"version":3,"file":"Trigger.js","sources":["../../../../../src/components/AlertDialog/components/Trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport { useCurrentAlertDialog } from '../Context';\nimport { mergeRefs } from '../../../utils/mergeRefs';\n\nexport type AlertDialogTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\n\nexport const Trigger = React.forwardRef(function AlertDialogTrigger(\n props: AlertDialogTriggerProps,\n externalRef: React.Ref<HTMLButtonElement>\n) {\n const { ref: parentRef, props: parentProps } = useCurrentAlertDialog();\n const refCallback = mergeRefs([parentRef, externalRef]);\n\n return <AlertDialogPrimitive.Trigger {...parentProps} {...props} ref={refCallback} asChild />;\n});\n"],"names":["Trigger","React","AlertDialogTrigger","props","externalRef","ref","parentRef","parentProps","useCurrentAlertDialog","refCallback","mergeRefs","AlertDialogPrimitive","asChild"],"mappings":";;;;;MAOaA,OAAO,gBAAGC,UAAA,CAAiB,SAASC,kBAAT,CACpCC,KADoC,EAEpCC,WAFoC;EAIpC,MAAM;IAAEC,GAAG,EAAEC,SAAP;IAAkBH,KAAK,EAAEI;MAAgBC,qBAAqB,EAApE;EACA,MAAMC,WAAW,GAAGC,SAAS,CAAC,CAACJ,SAAD,EAAYF,WAAZ,CAAD,CAA7B;EAEA,oBAAOH,aAAA,CAACU,SAAD,oBAAkCJ,aAAiBJ;IAAOE,GAAG,EAAEI;IAAaG,OAAO;IAAnF,CAAP;AACH,CARsB;;;;"}
@@ -1,9 +1,9 @@
1
1
  import { forwardRef, createElement } from 'react';
2
2
  import cn from 'classnames';
3
3
  import { Icon } from '../Icon/Icon.js';
4
- import { getButtonClasses, getAppearanceClasses, createButton } from './util.js';
4
+ import { createButtonWithOverlays, getButtonClasses, getAppearanceClasses, createButtonWithTooltip } from './util.js';
5
5
 
6
- const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
6
+ const Base = /*#__PURE__*/forwardRef(function ButtonBase(props, ref) {
7
7
  const {
8
8
  fluid,
9
9
  ...otherProps
@@ -13,9 +13,21 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
13
13
  'focus:yt-focus active:focus:yt-focus': !props.disabled,
14
14
  'w-full': fluid
15
15
  }, props.className);
16
- let children = otherProps.children; // add a chevron icon to menu buttons
16
+ return createButtonWithTooltip({ ...otherProps,
17
+ 'data-taco': 'button'
18
+ }, className, ref);
19
+ });
20
+ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
21
+ const {
22
+ dialog,
23
+ hanger,
24
+ menu,
25
+ popover,
26
+ ...buttonProps
27
+ } = props;
28
+ let children = buttonProps.children; // add a chevron icon to menu buttons
17
29
 
18
- if (typeof otherProps.menu === 'function') {
30
+ if (typeof menu === 'function') {
19
31
  children = Array.isArray(children) ? [...children, /*#__PURE__*/createElement(Icon, {
20
32
  key: "chevron-down",
21
33
  name: "chevron-down"
@@ -25,10 +37,16 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
25
37
  })];
26
38
  }
27
39
 
28
- return createButton({ ...otherProps,
29
- children,
30
- 'data-taco': 'button'
31
- }, className, ref);
40
+ const button = /*#__PURE__*/createElement(Base, Object.assign({}, buttonProps, {
41
+ children: children,
42
+ ref: ref
43
+ }));
44
+ return createButtonWithOverlays({
45
+ dialog,
46
+ hanger,
47
+ menu,
48
+ popover
49
+ }, button);
32
50
  });
33
51
 
34
52
  export { Button };
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { getAppearanceClasses, getButtonClasses, createButton } from './util';\nimport { HangerProps } from '../Hanger/Hanger';\nimport { MenuProps } from '../Menu/Menu';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { PopoverProps } from '../Popover/Popover';\nimport './Button.css';\nimport { Icon } from '../Icon/Icon';\n\nexport type ButtonProps = ButtonPrimitive.ButtonProps & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** If fluid, button expands to the width of it's container */\n fluid?: boolean;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const Button = React.forwardRef(function Button(\n props: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { fluid, ...otherProps } = props;\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance),\n 'rounded px-3',\n {\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n 'w-full': fluid,\n },\n props.className\n );\n\n let children = otherProps.children;\n\n // add a chevron icon to menu buttons\n if (typeof otherProps.menu === 'function') {\n children = Array.isArray(children)\n ? [...children, <Icon key=\"chevron-down\" name=\"chevron-down\" />]\n : [children, <Icon key=\"chevron-down\" name=\"chevron-down\" />];\n }\n\n return createButton({ ...otherProps, children, 'data-taco': 'button' }, className, ref);\n});\n"],"names":["Button","React","props","ref","fluid","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","children","menu","Array","isArray","Icon","key","name","createButton"],"mappings":";;;;;MAqCaA,MAAM,gBAAGC,UAAA,CAAiB,SAASD,MAAT,CACnCE,KADmC,EAEnCC,GAFmC;EAInC,MAAM;IAAEC,KAAF;IAAS,GAAGC;MAAeH,KAAjC;EACA,MAAMI,SAAS,GAAGC,EAAE,CAChBC,gBAAgB,EADA,EAEhBC,oBAAoB,CAACJ,UAAU,CAACK,UAAZ,CAFJ,EAGhB,cAHgB,EAIhB;IACI,iCAAiCR,KAAK,CAACS,QAD3C;IAEI,wCAAwC,CAACT,KAAK,CAACS,QAFnD;IAGI,UAAUP;GAPE,EAShBF,KAAK,CAACI,SATU,CAApB;EAYA,IAAIM,QAAQ,GAAGP,UAAU,CAACO,QAA1B;;EAGA,IAAI,OAAOP,UAAU,CAACQ,IAAlB,KAA2B,UAA/B,EAA2C;IACvCD,QAAQ,GAAGE,KAAK,CAACC,OAAN,CAAcH,QAAd,IACL,CAAC,GAAGA,QAAJ,eAAcX,aAAA,CAACe,IAAD;MAAMC,GAAG,EAAC;MAAeC,IAAI,EAAC;KAA9B,CAAd,CADK,GAEL,CAACN,QAAD,eAAWX,aAAA,CAACe,IAAD;MAAMC,GAAG,EAAC;MAAeC,IAAI,EAAC;KAA9B,CAAX,CAFN;;;EAKJ,OAAOC,YAAY,CAAC,EAAE,GAAGd,UAAL;IAAiBO,QAAjB;IAA2B,aAAa;GAAzC,EAAqDN,SAArD,EAAgEH,GAAhE,CAAnB;AACH,CA3BqB;;;;"}
1
+ {"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { getAppearanceClasses, getButtonClasses, createButtonWithTooltip, createButtonWithOverlays } from './util';\nimport { HangerProps } from '../Hanger/Hanger';\nimport { MenuProps } from '../Menu/Menu';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { PopoverProps } from '../Popover/Popover';\nimport './Button.css';\nimport { Icon } from '../Icon/Icon';\n\nexport type ButtonProps = ButtonPrimitive.ButtonProps & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** If fluid, button expands to the width of it's container */\n fluid?: boolean;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nconst Base = React.forwardRef(function ButtonBase(props: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) {\n const { fluid, ...otherProps } = props;\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance),\n 'rounded px-3',\n {\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n 'w-full': fluid,\n },\n props.className\n );\n\n return createButtonWithTooltip({ ...otherProps, 'data-taco': 'button' }, className, ref);\n});\n\nexport const Button = React.forwardRef(function Button(\n props: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { dialog, hanger, menu, popover, ...buttonProps } = props;\n\n let children = buttonProps.children;\n\n // add a chevron icon to menu buttons\n if (typeof menu === 'function') {\n children = Array.isArray(children)\n ? [...children, <Icon key=\"chevron-down\" name=\"chevron-down\" />]\n : [children, <Icon key=\"chevron-down\" name=\"chevron-down\" />];\n }\n\n const button = <Base {...buttonProps} children={children} ref={ref} />;\n\n return createButtonWithOverlays({ dialog, hanger, menu, popover }, button);\n});\n"],"names":["Base","React","ButtonBase","props","ref","fluid","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButtonWithTooltip","Button","dialog","hanger","menu","popover","buttonProps","children","Array","isArray","Icon","key","name","button","createButtonWithOverlays"],"mappings":";;;;;AAqCA,MAAMA,IAAI,gBAAGC,UAAA,CAAiB,SAASC,UAAT,CAAoBC,KAApB,EAAwCC,GAAxC;EAC1B,MAAM;IAAEC,KAAF;IAAS,GAAGC;MAAeH,KAAjC;EACA,MAAMI,SAAS,GAAGC,EAAE,CAChBC,gBAAgB,EADA,EAEhBC,oBAAoB,CAACJ,UAAU,CAACK,UAAZ,CAFJ,EAGhB,cAHgB,EAIhB;IACI,iCAAiCR,KAAK,CAACS,QAD3C;IAEI,wCAAwC,CAACT,KAAK,CAACS,QAFnD;IAGI,UAAUP;GAPE,EAShBF,KAAK,CAACI,SATU,CAApB;EAYA,OAAOM,uBAAuB,CAAC,EAAE,GAAGP,UAAL;IAAiB,aAAa;GAA/B,EAA2CC,SAA3C,EAAsDH,GAAtD,CAA9B;AACH,CAfY,CAAb;MAiBaU,MAAM,gBAAGb,UAAA,CAAiB,SAASa,MAAT,CACnCX,KADmC,EAEnCC,GAFmC;EAInC,MAAM;IAAEW,MAAF;IAAUC,MAAV;IAAkBC,IAAlB;IAAwBC,OAAxB;IAAiC,GAAGC;MAAgBhB,KAA1D;EAEA,IAAIiB,QAAQ,GAAGD,WAAW,CAACC,QAA3B;;EAGA,IAAI,OAAOH,IAAP,KAAgB,UAApB,EAAgC;IAC5BG,QAAQ,GAAGC,KAAK,CAACC,OAAN,CAAcF,QAAd,IACL,CAAC,GAAGA,QAAJ,eAAcnB,aAAA,CAACsB,IAAD;MAAMC,GAAG,EAAC;MAAeC,IAAI,EAAC;KAA9B,CAAd,CADK,GAEL,CAACL,QAAD,eAAWnB,aAAA,CAACsB,IAAD;MAAMC,GAAG,EAAC;MAAeC,IAAI,EAAC;KAA9B,CAAX,CAFN;;;EAKJ,MAAMC,MAAM,gBAAGzB,aAAA,CAACD,IAAD,oBAAUmB;IAAaC,QAAQ,EAAEA;IAAUhB,GAAG,EAAEA;IAAhD,CAAf;EAEA,OAAOuB,wBAAwB,CAAC;IAAEZ,MAAF;IAAUC,MAAV;IAAkBC,IAAlB;IAAwBC;GAAzB,EAAoCQ,MAApC,CAA/B;AACH,CAlBqB;;;;"}
@@ -29,28 +29,40 @@ const getAppearanceClasses = (value, icon = false) => {
29
29
  return `yt-grey-solid focus:bg-grey focus:yt-focus active:bg-grey-dark active:text-black hover:bg-grey-light hover:text-grey-darkest hover:focus:bg-grey-light hover:focus:text-grey-darkest disabled:hover:yt-grey-solid`;
30
30
  }
31
31
  };
32
- const createButton = (props, className, ref) => {
32
+ const createButtonWithTooltip = (props, className, ref) => {
33
33
  const {
34
- dialog,
35
- hanger,
36
- menu,
37
- popover,
38
34
  tooltip,
39
- ...otherProps
35
+ ...buttonProps
40
36
  } = props;
41
- let button = /*#__PURE__*/React__default.createElement(Button, Object.assign({}, otherProps, {
37
+ const button = /*#__PURE__*/React__default.createElement(Button, Object.assign({}, buttonProps, {
42
38
  className: className,
43
39
  ref: ref
44
40
  }));
45
41
 
42
+ if (tooltip) {
43
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
44
+ title: tooltip
45
+ }, button);
46
+ }
47
+
48
+ return button;
49
+ };
50
+ const createButtonWithOverlays = (props, buttonBase) => {
51
+ const {
52
+ dialog,
53
+ hanger,
54
+ menu,
55
+ popover
56
+ } = props;
57
+ let button = buttonBase;
58
+
46
59
  if (typeof dialog === 'function') {
47
60
  button = dialog({
48
61
  trigger: button
49
62
  });
50
63
  } else if (typeof menu === 'function') {
51
64
  button = menu({
52
- trigger: button,
53
- appearance: otherProps.appearance
65
+ trigger: button
54
66
  });
55
67
  } else if (typeof popover === 'function') {
56
68
  button = popover({
@@ -64,14 +76,8 @@ const createButton = (props, className, ref) => {
64
76
  });
65
77
  }
66
78
 
67
- if (tooltip) {
68
- button = /*#__PURE__*/React__default.createElement(Tooltip, {
69
- title: tooltip
70
- }, button);
71
- }
72
-
73
79
  return button;
74
80
  };
75
81
 
76
- export { createButton, getAppearanceClasses, getButtonClasses };
82
+ export { createButtonWithOverlays, createButtonWithTooltip, getAppearanceClasses, getButtonClasses };
77
83
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sources":["../../../../src/components/Button/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport const getButtonClasses = () => {\n return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center';\n};\n\nexport const getAppearanceClasses = (value: Appearance | undefined, icon = false): string => {\n switch (value) {\n case 'primary':\n return `yt-blue-solid focus:bg-blue focus:text-white focus:yt-focus active:bg-blue-dark active:text-white hover:bg-blue-light hover:text-white hover:focus:bg-blue-light hover:focus:border-blue-light hover:focus:text-white disabled:hover:yt-blue-solid disabled:hover:hover:border-blue`;\n\n case 'danger':\n return `yt-red-solid focus:bg-red focus:text-white focus:yt-focus-red active:bg-red-dark active:text-white hover:bg-red-light hover:text-white hover:focus:bg-red-light hover:focus:text-white disabled:hover:yt-red-solid`;\n\n case 'ghost':\n return `bg-white shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT)] text-blue focus:bg-transparent focus:text-blue active:bg-blue-lightest focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT),0_0_0_2px_rgba(0,99,255,0.25)] active:text-blue-dark hover:bg-blue-lightest hover:shadow-[inset_0_0_0_1px_theme(colors.blue.light)] hover:text-blue-light hover:focus:bg-blue-lightest hover:focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.light),0_0_0_2px_rgba(0,99,255,0.25)] hover:focus:text-blue-light`;\n\n case 'discrete': {\n if (icon) {\n return `bg-transparent text-black border-transparent focus:text-black focus:yt-focus active:text-black hover:text-grey-darkest hover:focus:text-grey-darkest disabled:hover:text-black `;\n }\n\n return `yt-transparent focus:text-blue focus:yt-focus active:text-blue-dark hover:text-blue-light hover:focus:text-blue-light disabled:hover:yt-transparent`;\n }\n\n default:\n return `yt-grey-solid focus:bg-grey focus:yt-focus active:bg-grey-dark active:text-black hover:bg-grey-light hover:text-grey-darkest hover:focus:bg-grey-light hover:focus:text-grey-darkest disabled:hover:yt-grey-solid`;\n }\n};\n\nexport const createButton = (\n props: any,\n className: string,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n): JSX.Element => {\n const { dialog, hanger, menu, popover, tooltip, ...otherProps } = props;\n\n let button = <ButtonPrimitive.Button {...otherProps} className={className} ref={ref} />;\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button });\n } else if (typeof menu === 'function') {\n button = menu({ trigger: button, appearance: otherProps.appearance });\n } else if (typeof popover === 'function') {\n button = popover({ trigger: button });\n }\n\n if (typeof hanger === 'function') {\n button = hanger({ anchor: button });\n }\n\n if (tooltip) {\n button = <Tooltip title={tooltip}>{button}</Tooltip>;\n }\n\n return button;\n};\n"],"names":["getButtonClasses","getAppearanceClasses","value","icon","createButton","props","className","ref","dialog","hanger","menu","popover","tooltip","otherProps","button","React","ButtonPrimitive","trigger","appearance","anchor","Tooltip","title"],"mappings":";;;;MAKaA,gBAAgB,GAAG;EAC5B,OAAO,iHAAP;AACH;MAEYC,oBAAoB,GAAG,CAACC,KAAD,EAAgCC,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/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport const getButtonClasses = () => {\n return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center';\n};\n\nexport const getAppearanceClasses = (value: Appearance | undefined, icon = false): string => {\n switch (value) {\n case 'primary':\n return `yt-blue-solid focus:bg-blue focus:text-white focus:yt-focus active:bg-blue-dark active:text-white hover:bg-blue-light hover:text-white hover:focus:bg-blue-light hover:focus:border-blue-light hover:focus:text-white disabled:hover:yt-blue-solid disabled:hover:hover:border-blue`;\n\n case 'danger':\n return `yt-red-solid focus:bg-red focus:text-white focus:yt-focus-red active:bg-red-dark active:text-white hover:bg-red-light hover:text-white hover:focus:bg-red-light hover:focus:text-white disabled:hover:yt-red-solid`;\n\n case 'ghost':\n return `bg-white shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT)] text-blue focus:bg-transparent focus:text-blue active:bg-blue-lightest focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT),0_0_0_2px_rgba(0,99,255,0.25)] active:text-blue-dark hover:bg-blue-lightest hover:shadow-[inset_0_0_0_1px_theme(colors.blue.light)] hover:text-blue-light hover:focus:bg-blue-lightest hover:focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.light),0_0_0_2px_rgba(0,99,255,0.25)] hover:focus:text-blue-light`;\n\n case 'discrete': {\n if (icon) {\n return `bg-transparent text-black border-transparent focus:text-black focus:yt-focus active:text-black hover:text-grey-darkest hover:focus:text-grey-darkest disabled:hover:text-black `;\n }\n\n return `yt-transparent focus:text-blue focus:yt-focus active:text-blue-dark hover:text-blue-light hover:focus:text-blue-light disabled:hover:yt-transparent`;\n }\n\n default:\n return `yt-grey-solid focus:bg-grey focus:yt-focus active:bg-grey-dark active:text-black hover:bg-grey-light hover:text-grey-darkest hover:focus:bg-grey-light hover:focus:text-grey-darkest disabled:hover:yt-grey-solid`;\n }\n};\n\nexport const createButtonWithTooltip = (\n props: any,\n className: string,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n): JSX.Element => {\n const { tooltip, ...buttonProps } = props;\n const button = <ButtonPrimitive.Button {...buttonProps} className={className} ref={ref} />;\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{button}</Tooltip>;\n }\n\n return button;\n};\n\nexport const createButtonWithOverlays = (props: any, buttonBase: JSX.Element) => {\n const { dialog, hanger, menu, popover } = props;\n let button = buttonBase;\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button });\n } else if (typeof menu === 'function') {\n button = menu({ trigger: button });\n } else if (typeof popover === 'function') {\n button = popover({ trigger: button });\n }\n\n if (typeof hanger === 'function') {\n button = hanger({ anchor: button });\n }\n\n return button;\n};\n"],"names":["getButtonClasses","getAppearanceClasses","value","icon","createButtonWithTooltip","props","className","ref","tooltip","buttonProps","button","React","ButtonPrimitive","Tooltip","title","createButtonWithOverlays","buttonBase","dialog","hanger","menu","popover","trigger","anchor"],"mappings":";;;;MAKaA,gBAAgB,GAAG;EAC5B,OAAO,iHAAP;AACH;MAEYC,oBAAoB,GAAG,CAACC,KAAD,EAAgCC,IAAI,GAAG,KAAvC;EAChC,QAAQD,KAAR;IACI,KAAK,SAAL;MACI,4RAAA;;IAEJ,KAAK,QAAL;MACI,2NAAA;;IAEJ,KAAK,OAAL;MACI,sfAAA;;IAEJ,KAAK,UAAL;MAAiB;QACb,IAAIC,IAAJ,EAAU;UACN,wLAAA;;;QAGJ,4JAAA;;;IAGJ;MACI,0NAAA;;AAEX;MAEYC,uBAAuB,GAAG,CACnCC,KADmC,EAEnCC,SAFmC,EAGnCC,GAHmC;EAKnC,MAAM;IAAEC,OAAF;IAAW,GAAGC;MAAgBJ,KAApC;EACA,MAAMK,MAAM,gBAAGC,4BAAA,CAACC,MAAD,oBAA4BH;IAAaH,SAAS,EAAEA;IAAWC,GAAG,EAAEA;IAApE,CAAf;;EAEA,IAAIC,OAAJ,EAAa;IACT,oBAAOG,4BAAA,CAACE,OAAD;MAASC,KAAK,EAAEN;KAAhB,EAA0BE,MAA1B,CAAP;;;EAGJ,OAAOA,MAAP;AACH;MAEYK,wBAAwB,GAAG,CAACV,KAAD,EAAaW,UAAb;EACpC,MAAM;IAAEC,MAAF;IAAUC,MAAV;IAAkBC,IAAlB;IAAwBC;MAAYf,KAA1C;EACA,IAAIK,MAAM,GAAGM,UAAb;;EAEA,IAAI,OAAOC,MAAP,KAAkB,UAAtB,EAAkC;IAC9BP,MAAM,GAAGO,MAAM,CAAC;MAAEI,OAAO,EAAEX;KAAZ,CAAf;GADJ,MAEO,IAAI,OAAOS,IAAP,KAAgB,UAApB,EAAgC;IACnCT,MAAM,GAAGS,IAAI,CAAC;MAAEE,OAAO,EAAEX;KAAZ,CAAb;GADG,MAEA,IAAI,OAAOU,OAAP,KAAmB,UAAvB,EAAmC;IACtCV,MAAM,GAAGU,OAAO,CAAC;MAAEC,OAAO,EAAEX;KAAZ,CAAhB;;;EAGJ,IAAI,OAAOQ,MAAP,KAAkB,UAAtB,EAAkC;IAC9BR,MAAM,GAAGQ,MAAM,CAAC;MAAEI,MAAM,EAAEZ;KAAX,CAAf;;;EAGJ,OAAOA,MAAP;AACH;;;;"}
@@ -3,10 +3,14 @@ import { mergeRefs } from '../../../utils/mergeRefs.js';
3
3
  import { Trigger as Trigger$1 } from '@radix-ui/react-dialog';
4
4
  import { useCurrentDialog } from '../Context.js';
5
5
 
6
- const Trigger = /*#__PURE__*/forwardRef(function DialogTrigger(props, ref) {
7
- const dialog = useCurrentDialog();
8
- return /*#__PURE__*/createElement(Trigger$1, Object.assign({}, dialog.props, props, {
9
- ref: mergeRefs([dialog.ref, ref]),
6
+ const Trigger = /*#__PURE__*/forwardRef(function DialogTrigger(props, externalRef) {
7
+ const {
8
+ ref: parentRef,
9
+ props: parentProps
10
+ } = useCurrentDialog();
11
+ const refCallback = mergeRefs([parentRef, externalRef]);
12
+ return /*#__PURE__*/createElement(Trigger$1, Object.assign({}, parentProps, props, {
13
+ ref: refCallback,
10
14
  asChild: true
11
15
  }));
12
16
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Trigger.js","sources":["../../../../../src/components/Dialog/components/Trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { useCurrentDialog } from '../Context';\nimport { mergeRefs } from '../../../utils/mergeRefs';\n\nexport type DialogTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\n\nexport const Trigger = React.forwardRef(function DialogTrigger(props: DialogTriggerProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n return <DialogPrimitive.Trigger {...dialog.props} {...props} ref={mergeRefs([dialog.ref, ref])} asChild />;\n});\n"],"names":["Trigger","React","DialogTrigger","props","ref","dialog","useCurrentDialog","DialogPrimitive","mergeRefs","asChild"],"mappings":";;;;;MAOaA,OAAO,gBAAGC,UAAA,CAAiB,SAASC,aAAT,CAAuBC,KAAvB,EAAkDC,GAAlD;EACpC,MAAMC,MAAM,GAAGC,gBAAgB,EAA/B;EACA,oBAAOL,aAAA,CAACM,SAAD,oBAA6BF,MAAM,CAACF,OAAWA;IAAOC,GAAG,EAAEI,SAAS,CAAC,CAACH,MAAM,CAACD,GAAR,EAAaA,GAAb,CAAD;IAAqBK,OAAO;IAAhG,CAAP;AACH,CAHsB;;;;"}
1
+ {"version":3,"file":"Trigger.js","sources":["../../../../../src/components/Dialog/components/Trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { useCurrentDialog } from '../Context';\nimport { mergeRefs } from '../../../utils/mergeRefs';\n\nexport type DialogTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\n\nexport const Trigger = React.forwardRef(function DialogTrigger(\n props: DialogTriggerProps,\n externalRef: React.Ref<HTMLButtonElement>\n) {\n const { ref: parentRef, props: parentProps } = useCurrentDialog();\n const refCallback = mergeRefs([parentRef, externalRef]);\n\n return <DialogPrimitive.Trigger {...parentProps} {...props} ref={refCallback} asChild />;\n});\n"],"names":["Trigger","React","DialogTrigger","props","externalRef","ref","parentRef","parentProps","useCurrentDialog","refCallback","mergeRefs","DialogPrimitive","asChild"],"mappings":";;;;;MAOaA,OAAO,gBAAGC,UAAA,CAAiB,SAASC,aAAT,CACpCC,KADoC,EAEpCC,WAFoC;EAIpC,MAAM;IAAEC,GAAG,EAAEC,SAAP;IAAkBH,KAAK,EAAEI;MAAgBC,gBAAgB,EAA/D;EACA,MAAMC,WAAW,GAAGC,SAAS,CAAC,CAACJ,SAAD,EAAYF,WAAZ,CAAD,CAA7B;EAEA,oBAAOH,aAAA,CAACU,SAAD,oBAA6BJ,aAAiBJ;IAAOE,GAAG,EAAEI;IAAaG,OAAO;IAA9E,CAAP;AACH,CARsB;;;;"}
@@ -7,13 +7,18 @@ import { Root, Anchor as Anchor$1, Close } from '@radix-ui/react-popover';
7
7
  import { UnstyledContent, UnstyledArrow } from '../Popover/Primitives.js';
8
8
 
9
9
  const HangerContext = /*#__PURE__*/createContext({
10
+ onClose: undefined,
10
11
  props: {},
11
12
  ref: null
12
13
  });
13
- const Anchor = /*#__PURE__*/forwardRef(function HangerAnchor(props, ref) {
14
+ const Anchor = /*#__PURE__*/forwardRef(function HangerAnchor(props, externalRef) {
14
15
  var _props$children;
15
16
 
16
- const context = useContext(HangerContext);
17
+ const {
18
+ ref: parentRef,
19
+ props: parentProps
20
+ } = useContext(HangerContext);
21
+ const refCallback = mergeRefs([parentRef, externalRef]);
17
22
  let children = props.children;
18
23
 
19
24
  if ( /*#__PURE__*/isValidElement(props.children) && typeof ((_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.type) === 'function') {
@@ -21,9 +26,9 @@ const Anchor = /*#__PURE__*/forwardRef(function HangerAnchor(props, ref) {
21
26
  children = /*#__PURE__*/createElement("span", null, props.children);
22
27
  }
23
28
 
24
- return /*#__PURE__*/createElement(Anchor$1, Object.assign({}, context.props, props, {
29
+ return /*#__PURE__*/createElement(Anchor$1, Object.assign({}, parentProps, props, {
25
30
  children: children,
26
- ref: mergeRefs([context.ref, ref]),
31
+ ref: refCallback,
27
32
  asChild: true
28
33
  }));
29
34
  });
@@ -60,7 +65,7 @@ const Content = /*#__PURE__*/forwardRef(function HangerContent(props, ref) {
60
65
  "aria-label": texts.hanger.close,
61
66
  className: "absolute top-0 right-0 ml-2 mr-2 mt-2 text-white",
62
67
  icon: "close",
63
- onClick: context.props.onClose
68
+ onClick: context.onClose
64
69
  })));
65
70
  });
66
71
  const Hanger = /*#__PURE__*/forwardRef(function Hanger(props, ref) {
@@ -68,12 +73,14 @@ const Hanger = /*#__PURE__*/forwardRef(function Hanger(props, ref) {
68
73
  anchor,
69
74
  children,
70
75
  defaultOpen = true,
76
+ onClose,
71
77
  ...otherProps
72
78
  } = props;
73
79
  const context = useMemo(() => ({
80
+ onClose,
74
81
  props: otherProps,
75
82
  ref
76
- }), [otherProps]); // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal
83
+ }), [onClose, otherProps]); // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal
77
84
 
78
85
  const [open, setOpen] = useState(false);
79
86
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Hanger.js","sources":["../../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow, UnstyledContent } from '../Popover/Primitives';\nimport { useLocalization } from '../Provider/Provider';\nimport './Hanger.css';\nimport { mergeRefs } from '../../utils/mergeRefs';\n\ntype HangerContextValue = {\n props: any;\n ref: React.Ref<HTMLElement>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n props: {},\n ref: null,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\nconst Anchor = React.forwardRef(function HangerAnchor(props: HangerAnchorProps, ref: React.Ref<HTMLDivElement>) {\n const context = React.useContext(HangerContext);\n let children = props.children;\n\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\n console.warn(\n `Hanger.Anchor requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`\n );\n children = <span>{props.children}</span>;\n }\n\n return (\n <PopoverPrimitive.Anchor {...context.props} {...props} children={children} ref={mergeRefs([context.ref, ref])} asChild />\n );\n});\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm',\n props.className\n );\n const handleInteractOutside = (event: CustomEvent): void => {\n event.preventDefault();\n };\n\n return (\n <UnstyledContent\n className={className}\n data-taco=\"hanger\"\n onInteractOutside={handleInteractOutside}\n placement={props.placement}\n ref={ref}>\n {props.children}\n <UnstyledArrow className=\"text-blue\" />\n <PopoverPrimitive.Close asChild>\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute top-0 right-0 ml-2 mr-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.props.onClose}\n />\n </PopoverPrimitive.Close>\n </UnstyledContent>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef(function Hanger(props: HangerProps, ref: React.Ref<HTMLElement>) {\n const { anchor, children, defaultOpen = true, ...otherProps } = props;\n const context = React.useMemo(() => ({ props: otherProps, ref }), [otherProps]);\n\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n if (defaultOpen) {\n setOpen(defaultOpen);\n }\n }, []);\n\n return (\n <HangerContext.Provider value={context}>\n <PopoverPrimitive.Root key={String(open)} defaultOpen={open}>\n {anchor && <Anchor>{anchor}</Anchor>}\n {children}\n </PopoverPrimitive.Root>\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\nHanger.Title = Title;\n"],"names":["HangerContext","React","props","ref","Anchor","HangerAnchor","context","children","type","console","warn","name","PopoverPrimitive","mergeRefs","asChild","Title","DialogTitle","className","cn","Content","HangerContent","texts","useLocalization","handleInteractOutside","event","preventDefault","UnstyledContent","onInteractOutside","placement","UnstyledArrow","IconButton","appearance","hanger","close","icon","onClick","onClose","Hanger","anchor","defaultOpen","otherProps","open","setOpen","Provider","value","key","String"],"mappings":";;;;;;;;AAcA,MAAMA,aAAa,gBAAGC,aAAA,CAAwC;EAC1DC,KAAK,EAAE,EADmD;EAE1DC,GAAG,EAAE;AAFqD,CAAxC,CAAt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H,MAAM,iBAAIrC,aAAA,CAACG,MAAD,MAAA,EAASkC,MAAT,CADf,EAEK/B,QAFL,CADJ,CADJ;AAQH,CApBqB;AAqBtB8B,MAAM,CAACjC,MAAP,GAAgBA,MAAhB;AACAiC,MAAM,CAAClB,OAAP,GAAiBA,OAAjB;AACAkB,MAAM,CAACtB,KAAP,GAAeA,KAAf;;;;"}
1
+ {"version":3,"file":"Hanger.js","sources":["../../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow, UnstyledContent } from '../Popover/Primitives';\nimport { useLocalization } from '../Provider/Provider';\nimport './Hanger.css';\nimport { mergeRefs } from '../../utils/mergeRefs';\n\ntype HangerContextValue = {\n /** Handler called when hanger closes by user interaction */\n onClose?: () => void;\n props: any;\n ref: React.Ref<HTMLElement>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n onClose: undefined,\n props: {},\n ref: null,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\nconst Anchor = React.forwardRef(function HangerAnchor(props: HangerAnchorProps, externalRef: React.Ref<HTMLDivElement>) {\n const { ref: parentRef, props: parentProps } = React.useContext(HangerContext);\n const refCallback = mergeRefs([parentRef, externalRef]);\n\n let children = props.children;\n\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\n console.warn(\n `Hanger.Anchor requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`\n );\n children = <span>{props.children}</span>;\n }\n\n return <PopoverPrimitive.Anchor {...parentProps} {...props} children={children} ref={refCallback} asChild />;\n});\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm',\n props.className\n );\n const handleInteractOutside = (event: CustomEvent): void => {\n event.preventDefault();\n };\n\n return (\n <UnstyledContent\n className={className}\n data-taco=\"hanger\"\n onInteractOutside={handleInteractOutside}\n placement={props.placement}\n ref={ref}>\n {props.children}\n <UnstyledArrow className=\"text-blue\" />\n <PopoverPrimitive.Close asChild>\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute top-0 right-0 ml-2 mr-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.onClose}\n />\n </PopoverPrimitive.Close>\n </UnstyledContent>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef<HTMLElement, HangerProps>(function Hanger(props, ref) {\n const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;\n const context = React.useMemo(() => ({ onClose, props: otherProps, ref }), [onClose, otherProps]);\n\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n if (defaultOpen) {\n setOpen(defaultOpen);\n }\n }, []);\n\n return (\n <HangerContext.Provider value={context}>\n <PopoverPrimitive.Root key={String(open)} defaultOpen={open}>\n {anchor && <Anchor>{anchor}</Anchor>}\n {children}\n </PopoverPrimitive.Root>\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\nHanger.Title = Title;\n"],"names":["HangerContext","React","onClose","undefined","props","ref","Anchor","HangerAnchor","externalRef","parentRef","parentProps","refCallback","mergeRefs","children","type","console","warn","name","PopoverPrimitive","asChild","Title","DialogTitle","className","cn","Content","HangerContent","context","texts","useLocalization","handleInteractOutside","event","preventDefault","UnstyledContent","onInteractOutside","placement","UnstyledArrow","IconButton","appearance","hanger","close","icon","onClick","Hanger","anchor","defaultOpen","otherProps","open","setOpen","Provider","value","key","String"],"mappings":";;;;;;;;AAgBA,MAAMA,aAAa,gBAAGC,aAAA,CAAwC;EAC1DC,OAAO,EAAEC,SADiD;EAE1DC,KAAK,EAAE,EAFmD;EAG1DC,GAAG,EAAE;AAHqD,CAAxC,CAAtB;AAYA,MAAMC,MAAM,gBAAGL,UAAA,CAAiB,SAASM,YAAT,CAAsBH,KAAtB,EAAgDI,WAAhD;;;EAC5B,MAAM;IAAEH,GAAG,EAAEI,SAAP;IAAkBL,KAAK,EAAEM;MAAgBT,UAAA,CAAiBD,aAAjB,CAA/C;EACA,MAAMW,WAAW,GAAGC,SAAS,CAAC,CAACH,SAAD,EAAYD,WAAZ,CAAD,CAA7B;EAEA,IAAIK,QAAQ,GAAGT,KAAK,CAACS,QAArB;;EAEA,kBAAIZ,cAAA,CAAqBG,KAAK,CAACS,QAA3B,KAAwC,2BAAOT,KAAK,CAACS,QAAb,oDAA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cn from 'classnames';
3
3
  import { Icon } from '../Icon/Icon.js';
4
- import { getButtonClasses, getAppearanceClasses, createButton } from '../Button/util.js';
4
+ import { getButtonClasses, getAppearanceClasses, createButtonWithTooltip, createButtonWithOverlays } from '../Button/util.js';
5
5
 
6
- const IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
6
+ const Base = /*#__PURE__*/forwardRef(function IconButtonBase(props, ref) {
7
7
  const {
8
8
  icon,
9
9
  rounded = false,
@@ -20,7 +20,7 @@ const IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
20
20
  return null;
21
21
  }
22
22
 
23
- return createButton({ ...otherProps,
23
+ return createButtonWithTooltip({ ...otherProps,
24
24
  children: /*#__PURE__*/createElement(Icon, {
25
25
  name: icon,
26
26
  className: "m-0 p-0"
@@ -28,6 +28,24 @@ const IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
28
28
  'data-taco': 'icon-button'
29
29
  }, className, ref);
30
30
  });
31
+ const IconButton = /*#__PURE__*/forwardRef(function Button(props, ref) {
32
+ const {
33
+ dialog,
34
+ hanger,
35
+ menu,
36
+ popover,
37
+ ...buttonProps
38
+ } = props;
39
+ const button = /*#__PURE__*/createElement(Base, Object.assign({}, buttonProps, {
40
+ ref: ref
41
+ }));
42
+ return createButtonWithOverlays({
43
+ dialog,
44
+ hanger,
45
+ menu,
46
+ popover
47
+ }, button);
48
+ });
31
49
 
32
- export { IconButton };
50
+ export { Base, IconButton };
33
51
  //# sourceMappingURL=IconButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","sources":["../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses, createButton } from '../Button/util';\nimport { Appearance } from '../../types';\nimport { DialogProps, HangerProps, MenuProps, PopoverProps } from '../..';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const IconButton = React.forwardRef(function IconButton(props: IconButtonProps, ref: React.Ref<HTMLButtonElement>) {\n const { icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n 'w-8',\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return createButton(\n { ...otherProps, children: <Icon name={icon} className=\"m-0 p-0\" />, 'data-taco': 'icon-button' },\n className,\n ref\n );\n});\n"],"names":["IconButton","React","props","ref","icon","rounded","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButton","children","Icon","name"],"mappings":";;;;;MAsCaA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;EACvC,MAAM;IAAEC,IAAF;IAAQC,OAAO,GAAG,KAAlB;IAAyB,GAAGC;MAAeJ,KAAjD;EAEA,MAAMK,SAAS,GAAGC,EAAE,CAChB,KADgB,EAEhBC,gBAAgB,EAFA,EAGhBC,oBAAoB,CAACJ,UAAU,CAACK,UAAZ,EAAwB,IAAxB,CAHJ,EAIhB;IACI,gBAAgBN,OADpB;IAEIA,OAAO,EAAE,CAACA,OAFd;IAGI,iCAAiCH,KAAK,CAACU,QAH3C;IAII,wCAAwC,CAACV,KAAK,CAACU;GARnC,EAUhBV,KAAK,CAACK,SAVU,CAApB;;EAaA,IAAI,CAACH,IAAL,EAAW;IACP,OAAO,IAAP;;;EAGJ,OAAOS,YAAY,CACf,EAAE,GAAGP,UAAL;IAAiBQ,QAAQ,eAAEb,aAAA,CAACc,IAAD;MAAMC,IAAI,EAAEZ;MAAMG,SAAS,EAAC;KAA5B,CAA3B;IAAqE,aAAa;GADnE,EAEfA,SAFe,EAGfJ,GAHe,CAAnB;AAKH,CAzByB;;;;"}
1
+ {"version":3,"file":"IconButton.js","sources":["../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses, createButtonWithTooltip, createButtonWithOverlays } from '../Button/util';\nimport { Appearance } from '../../types';\nimport { DialogProps, HangerProps, MenuProps, PopoverProps } from '../..';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const Base = React.forwardRef(function IconButtonBase(\n props: IconButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n 'w-8',\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return createButtonWithTooltip(\n { ...otherProps, children: <Icon name={icon} className=\"m-0 p-0\" />, 'data-taco': 'icon-button' },\n className,\n ref\n );\n});\n\nexport const IconButton = React.forwardRef(function Button(\n props: IconButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { dialog, hanger, menu, popover, ...buttonProps } = props;\n const button = <Base {...buttonProps} ref={ref} />;\n\n return createButtonWithOverlays({ dialog, hanger, menu, popover }, button);\n});\n"],"names":["Base","React","IconButtonBase","props","ref","icon","rounded","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButtonWithTooltip","children","Icon","name","IconButton","Button","dialog","hanger","menu","popover","buttonProps","button","createButtonWithOverlays"],"mappings":";;;;;MAsCaA,IAAI,gBAAGC,UAAA,CAAiB,SAASC,cAAT,CACjCC,KADiC,EAEjCC,GAFiC;EAIjC,MAAM;IAAEC,IAAF;IAAQC,OAAO,GAAG,KAAlB;IAAyB,GAAGC;MAAeJ,KAAjD;EAEA,MAAMK,SAAS,GAAGC,EAAE,CAChB,KADgB,EAEhBC,gBAAgB,EAFA,EAGhBC,oBAAoB,CAACJ,UAAU,CAACK,UAAZ,EAAwB,IAAxB,CAHJ,EAIhB;IACI,gBAAgBN,OADpB;IAEIA,OAAO,EAAE,CAACA,OAFd;IAGI,iCAAiCH,KAAK,CAACU,QAH3C;IAII,wCAAwC,CAACV,KAAK,CAACU;GARnC,EAUhBV,KAAK,CAACK,SAVU,CAApB;;EAaA,IAAI,CAACH,IAAL,EAAW;IACP,OAAO,IAAP;;;EAGJ,OAAOS,uBAAuB,CAC1B,EAAE,GAAGP,UAAL;IAAiBQ,QAAQ,eAAEd,aAAA,CAACe,IAAD;MAAMC,IAAI,EAAEZ;MAAMG,SAAS,EAAC;KAA5B,CAA3B;IAAqE,aAAa;GADxD,EAE1BA,SAF0B,EAG1BJ,GAH0B,CAA9B;AAKH,CA5BmB;MA8BPc,UAAU,gBAAGjB,UAAA,CAAiB,SAASkB,MAAT,CACvChB,KADuC,EAEvCC,GAFuC;EAIvC,MAAM;IAAEgB,MAAF;IAAUC,MAAV;IAAkBC,IAAlB;IAAwBC,OAAxB;IAAiC,GAAGC;MAAgBrB,KAA1D;EACA,MAAMsB,MAAM,gBAAGxB,aAAA,CAACD,IAAD,oBAAUwB;IAAapB,GAAG,EAAEA;IAA5B,CAAf;EAEA,OAAOsB,wBAAwB,CAAC;IAAEN,MAAF;IAAUC,MAAV;IAAkBC,IAAlB;IAAwBC;GAAzB,EAAoCE,MAApC,CAA/B;AACH,CARyB;;;;"}