@economic/taco 0.0.11-alpha.0 → 0.0.12-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { IconName } from '../../Icon/Icon';
3
+ import { DialogProps } from '../../Dialog/Dialog';
3
4
  export declare const Icon: ({ name }: {
4
5
  name: any;
5
6
  }) => JSX.Element;
@@ -10,12 +11,14 @@ export declare const useItemStyling: ({ disabled, indented, className }: {
10
11
  }) => string;
11
12
  export declare const Shortcut: (props: any) => JSX.Element;
12
13
  export declare type MenuItemProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
14
+ dialog?: (props: Partial<DialogProps>) => JSX.Element;
13
15
  disabled?: boolean;
14
16
  icon?: IconName;
15
17
  onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
16
18
  shortcut?: string;
17
19
  };
18
20
  export declare const Item: React.ForwardRefExoticComponent<Pick<React.HTMLAttributes<HTMLDivElement>, "className" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "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" | "children" | "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" | "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"> & {
21
+ dialog?: ((props: Partial<DialogProps>) => JSX.Element) | undefined;
19
22
  disabled?: boolean | undefined;
20
23
  icon?: "account-preview" | "accounting-year-cancel" | "accounting-year" | "accounting" | "arrow-bottom" | "arrow-down" | "arrow-end" | "arrow-left" | "arrow-right" | "arrow-start" | "arrow-top" | "arrow-up" | "attach-auto" | "attach-cancel" | "attach" | "autotext-insert" | "autotext" | "basic-tabs" | "basic" | "bell-solid" | "book" | "booking" | "budget" | "calendar" | "cash-account" | "cash-reports" | "chat-solid" | "chat" | "chevron-down-double" | "chevron-down-solid" | "chevron-down" | "chevron-left-double" | "chevron-left" | "chevron-right-double" | "chevron-right" | "chevron-up-double" | "chevron-up-solid" | "chevron-up" | "clamp-open" | "clamp" | "close" | "connection-enable" | "connection-revoke" | "contacts" | "copy" | "courses" | "credit" | "delete-permanently" | "delete" | "depecriate" | "developer" | "distribution-template" | "document-approve" | "document-create-entry" | "document-cut" | "document-error" | "document-isolate-page" | "document-merge" | "document-move" | "document-preview" | "document-received" | "document-rejected-request" | "document-split" | "document-time" | "document" | "download" | "drag" | "e-copedia" | "e-signature" | "edit" | "ellipsis-horizontal" | "ellipsis-vertical" | "entries-on-account" | "entries-open" | "entries-warning" | "entry-type-customer-invoice" | "entry-type-customer-payment" | "entry-type-journal-entry" | "entry-type-manual-customer-invoice" | "entry-type-supplier-invoice" | "entry-type-supplier-payment" | "envelope-approved" | "envelope" | "expand-view" | "expenses" | "export-to-excel-copy" | "export-to-excel" | "export" | "filter-solid" | "filter" | "graph-solid" | "hash" | "home" | "images" | "import" | "inbox-smart" | "inbox" | "info" | "inventory-matrix" | "inventory" | "journal-pro" | "layout-both" | "layout-first" | "layout-last" | "layout-none" | "layout" | "ledger-card-customer-reminder" | "ledger-card-manual-customer-invoice" | "ledger-card-obsolete-stock" | "ledger-card-opening-entry" | "ledger-card-reserved-entry" | "ledger-card-shrinkage-pilferage" | "ledger-card-stock-adjustment" | "ledger-card-transferred-opening-entry" | "ledger-card" | "lightbulb" | "line" | "list-bulleted" | "list-search" | "list" | "lock-open" | "log" | "market" | "match-amount" | "match-entries" | "mileage" | "minus" | "modal-resize" | "modal-shrink" | "more-solid" | "more" | "move" | "navigation-list" | "note-follow-up" | "note-read" | "note" | "partner-api" | "period" | "person-change" | "person-minus" | "person-plus" | "person-tick" | "play" | "plus-circle" | "plus-minus" | "print" | "process-payment" | "product-ledger-card" | "project-cards" | "projects" | "quicklinks" | "rating-bankruptcy" | "rating-payment-problems" | "reconciled" | "refresh" | "report-solid" | "report" | "restore" | "rotate-left" | "rotate-right" | "sales" | "search-bold" | "search" | "secure-tick" | "secure" | "settings-solid" | "settings" | "shortcuts" | "show-all" | "show-less" | "show-more" | "show-template" | "sliders" | "smartpay" | "sort-by" | "spinner" | "star-solid" | "star" | "subscriptions" | "system-entries" | "tag" | "template-override" | "templates" | "thumb-both" | "thumb-down-solid" | "thumb-down" | "thumb-up-solid" | "thumb" | "tick-circle" | "tick" | "time" | "transfer-cancel" | "transfer-locked" | "transfer" | "undock" | "unreconciled" | "warning" | "webshop" | "website" | "workflow" | "zoom" | undefined;
21
24
  onClick?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
@@ -5,13 +5,13 @@ import { Icon as Icon$1 } from '../../Icon/Icon.js';
5
5
  import { useCurrentMenu } from '../Context.js';
6
6
  import { Item as Item$1 } from '@radix-ui/react-dropdown-menu';
7
7
 
8
- var _excluded = ["icon", "shortcut"];
8
+ var _excluded = ["dialog", "icon", "onClick", "shortcut"];
9
9
  var Icon = function Icon(_ref) {
10
10
  var name = _ref.name;
11
11
  return createElement("span", {
12
12
  className: "absolute left-0 ml-1"
13
13
  }, createElement(Icon$1, {
14
- className: "!h-5 !w-5 -ml-px -mt-px",
14
+ className: "-ml-px -mt-px !h-5 !w-5",
15
15
  name: name
16
16
  }));
17
17
  };
@@ -86,7 +86,11 @@ var Shortcut = function Shortcut(props) {
86
86
  }));
87
87
  };
88
88
  var Item = /*#__PURE__*/forwardRef(function MenuItem(props, ref) {
89
- var icon = props.icon,
89
+ var _props$disabled;
90
+
91
+ var dialog = props.dialog,
92
+ icon = props.icon,
93
+ onClick = props.onClick,
90
94
  shortcut = props.shortcut,
91
95
  otherProps = _objectWithoutPropertiesLoose(props, _excluded);
92
96
 
@@ -95,29 +99,42 @@ var Item = /*#__PURE__*/forwardRef(function MenuItem(props, ref) {
95
99
  indented: !!icon,
96
100
  className: props.className
97
101
  });
102
+ var disabled = (_props$disabled = props.disabled) !== null && _props$disabled !== void 0 ? _props$disabled : props['aria-disabled'];
98
103
  var handleClick; // radix has a bug that does not disable clicks when disabled is set on items
99
104
 
100
- if (!otherProps.disabled) {
101
- handleClick = props.onClick;
102
-
103
- if (props['aria-haspopup']) {
104
- handleClick = function handleClick(event) {
105
- if (props.onClick) {
106
- event.persist();
107
- props.onClick(event);
108
- event.preventDefault();
109
- }
110
- };
111
- }
105
+ if (disabled) {
106
+ handleClick = function handleClick(event) {
107
+ event.preventDefault();
108
+ event.stopPropagation();
109
+ };
112
110
  }
113
111
 
114
- return createElement(Item$1, Object.assign({}, otherProps, {
112
+ var handleSelect = function handleSelect(event) {
113
+ if (onClick) {
114
+ onClick(event);
115
+ }
116
+
117
+ if (props['aria-haspopup'] || typeof dialog === 'function') {
118
+ event.preventDefault();
119
+ }
120
+ };
121
+
122
+ var button = createElement(Item$1, Object.assign({}, otherProps, {
115
123
  className: className,
116
124
  onClick: handleClick,
125
+ onSelect: handleSelect,
117
126
  ref: ref
118
127
  }), icon && createElement(Icon, {
119
128
  name: icon
120
129
  }), props.children, shortcut && createElement(Shortcut, null, shortcut));
130
+
131
+ if (typeof dialog === 'function') {
132
+ button = dialog({
133
+ trigger: button
134
+ });
135
+ }
136
+
137
+ return button;
121
138
  });
122
139
 
123
140
  export { Icon, Item, Shortcut, useItemStyling };
@@ -1 +1 @@
1
- {"version":3,"file":"Item.js","sources":["../../../../../src/components/Menu/components/Item.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport cn from 'classnames';\nimport { IconName } from '../../Icon/Icon';\nimport { Icon as IconPrimitive } from '../../Icon/Icon';\nimport { useCurrentMenu } from '../Context';\nimport { Appearance } from '../../../types';\n\nexport const Icon = ({ name }) => (\n <span className=\"absolute left-0 ml-1\">\n <IconPrimitive className=\"!h-5 !w-5 -ml-px -mt-px\" name={name} />\n </span>\n);\n\nconst getAppearanceClasses = (appearance: Appearance | undefined) => {\n switch (appearance) {\n case 'primary':\n return 'wcag-blue aria-disabled:text-blue-dark focus:wcag-blue-light';\n\n case 'danger':\n return 'wcag-red aria-disabled:text-red-dark focus:wcag-red-light';\n\n case 'ghost':\n return 'text-blue aria-disabled:text-grey focus:wcag-blue';\n\n case 'discrete':\n return 'text-black aria-disabled:text-grey focus:wcag-blue-lightest';\n\n case 'default':\n default:\n return 'wcag-grey-light aria-disabled:text-grey-darker focus:wcag-grey-dark';\n }\n};\n\nexport const useItemStyling = ({ disabled, indented, className }) => {\n const menu = useCurrentMenu();\n\n React.useEffect(() => {\n if (indented && !menu?.indented) {\n menu?.registerIndentation();\n }\n }, [indented]);\n\n return cn(\n 'flex items-center justify-start h-7 pr-1.5 relative rounded w-full focus:outline-none group',\n getAppearanceClasses(menu?.appearance),\n {\n 'pl-7': menu?.indented,\n 'pl-1.5': !menu?.indented,\n 'cursor-pointer': !disabled,\n 'cursor-not-allowed': disabled,\n },\n className\n );\n};\n\nexport const Shortcut = props => {\n const menu = useCurrentMenu();\n let appearance;\n\n switch (menu?.appearance) {\n case 'primary':\n appearance = 'text-blue-lightest group-focus:text-black';\n break;\n\n case 'danger':\n appearance = 'text-red-lightest group-focus:text-white';\n break;\n\n case 'ghost':\n appearance = 'text-blue-light group-focus:text-blue-lightest';\n break;\n\n case 'discrete':\n appearance = 'text-grey-darker group-focus:text-blue-light';\n break;\n\n case 'default':\n default:\n appearance = 'text-grey-darkest';\n break;\n }\n\n const className = cn('ml-auto pl-3', appearance);\n\n return <span {...props} className={className} />;\n};\n\nexport type MenuItemProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\n disabled?: boolean;\n icon?: IconName;\n onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;\n shortcut?: string;\n};\n\nexport const Item = React.forwardRef(function MenuItem(props: MenuItemProps, ref: React.Ref<HTMLDivElement>) {\n const { icon, shortcut, ...otherProps } = props;\n const className = useItemStyling({\n disabled: props.disabled,\n indented: !!icon,\n className: props.className,\n });\n\n let handleClick;\n\n // radix has a bug that does not disable clicks when disabled is set on items\n if (!otherProps.disabled) {\n handleClick = props.onClick;\n\n if (props['aria-haspopup']) {\n handleClick = event => {\n if (props.onClick) {\n event.persist();\n props.onClick(event);\n event.preventDefault();\n }\n };\n }\n }\n\n return (\n <DropdownMenuPrimitive.Item {...otherProps} className={className} onClick={handleClick} ref={ref}>\n {icon && <Icon name={icon} />}\n {props.children}\n {shortcut && <Shortcut>{shortcut}</Shortcut>}\n </DropdownMenuPrimitive.Item>\n );\n});\n"],"names":["Icon","name","React","className","IconPrimitive","getAppearanceClasses","appearance","useItemStyling","disabled","indented","menu","useCurrentMenu","registerIndentation","cn","Shortcut","props","Item","MenuItem","ref","icon","shortcut","otherProps","handleClick","onClick","event","persist","preventDefault","DropdownMenuPrimitive","children"],"mappings":";;;;;;;;IAQaA,IAAI,GAAG,SAAPA,IAAO;AAAA,MAAGC,IAAH,QAAGA,IAAH;AAAA,SAChBC,aAAA,OAAA;AAAMC,IAAAA,SAAS,EAAC;GAAhB,EACID,aAAA,CAACE,MAAD;AAAeD,IAAAA,SAAS,EAAC;AAA0BF,IAAAA,IAAI,EAAEA;GAAzD,CADJ,CADgB;AAAA;;AAMpB,IAAMI,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,UAAD;AACzB,UAAQA,UAAR;AACI,SAAK,SAAL;AACI,aAAO,8DAAP;;AAEJ,SAAK,QAAL;AACI,aAAO,2DAAP;;AAEJ,SAAK,OAAL;AACI,aAAO,mDAAP;;AAEJ,SAAK,UAAL;AACI,aAAO,6DAAP;;AAEJ,SAAK,SAAL;AACA;AACI,aAAO,qEAAP;AAfR;AAiBH,CAlBD;;IAoBaC,cAAc,GAAG,SAAjBA,cAAiB;MAAGC,iBAAAA;MAAUC,iBAAAA;MAAUN,kBAAAA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B,SAASe,QAAT,CAAkBF,KAAlB,EAAwCG,GAAxC;AACjC,MAAQC,IAAR,GAA0CJ,KAA1C,CAAQI,IAAR;AAAA,MAAcC,QAAd,GAA0CL,KAA1C,CAAcK,QAAd;AAAA,MAA2BC,UAA3B,iCAA0CN,KAA1C;;AACA,MAAMZ,SAAS,GAAGI,cAAc,CAAC;AAC7BC,IAAAA,QAAQ,EAAEO,KAAK,CAACP,QADa;AAE7BC,IAAAA,QAAQ,EAAE,CAAC,CAACU,IAFiB;AAG7BhB,IAAAA,SAAS,EAAEY,KAAK,CAACZ;AAHY,GAAD,CAAhC;AAMA,MAAImB,WAAJ;;AAGA,MAAI,CAACD,UAAU,CAACb,QAAhB,EAA0B;AACtBc,IAAAA,WAAW,GAAGP,KAAK,CAACQ,OAApB;;AAEA,QAAIR,KAAK,CAAC,eAAD,CAAT,EAA4B;AACxBO,MAAAA,WAAW,GAAG,qBAAAE,KAAK;AACf,YAAIT,KAAK,CAACQ,OAAV,EAAmB;AACfC,UAAAA,KAAK,CAACC,OAAN;AACAV,UAAAA,KAAK,CAACQ,OAAN,CAAcC,KAAd;AACAA,UAAAA,KAAK,CAACE,cAAN;AACH;AACJ,OAND;AAOH;AACJ;;AAED,SACIxB,aAAA,CAACyB,MAAD,oBAAgCN;AAAYlB,IAAAA,SAAS,EAAEA;AAAWoB,IAAAA,OAAO,EAAED;AAAaJ,IAAAA,GAAG,EAAEA;IAA7F,EACKC,IAAI,IAAIjB,aAAA,CAACF,IAAD;AAAMC,IAAAA,IAAI,EAAEkB;GAAZ,CADb,EAEKJ,KAAK,CAACa,QAFX,EAGKR,QAAQ,IAAIlB,aAAA,CAACY,QAAD,MAAA,EAAWM,QAAX,CAHjB,CADJ;AAOH,CAhCmB;;;;"}
1
+ {"version":3,"file":"Item.js","sources":["../../../../../src/components/Menu/components/Item.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport cn from 'classnames';\nimport { IconName } from '../../Icon/Icon';\nimport { Icon as IconPrimitive } from '../../Icon/Icon';\nimport { useCurrentMenu } from '../Context';\nimport { Appearance } from '../../../types';\nimport { DialogProps } from '../../Dialog/Dialog';\n\nexport const Icon = ({ name }) => (\n <span className=\"absolute left-0 ml-1\">\n <IconPrimitive className=\"-ml-px -mt-px !h-5 !w-5\" name={name} />\n </span>\n);\n\nconst getAppearanceClasses = (appearance: Appearance | undefined) => {\n switch (appearance) {\n case 'primary':\n return 'wcag-blue aria-disabled:text-blue-dark focus:wcag-blue-light';\n\n case 'danger':\n return 'wcag-red aria-disabled:text-red-dark focus:wcag-red-light';\n\n case 'ghost':\n return 'text-blue aria-disabled:text-grey focus:wcag-blue';\n\n case 'discrete':\n return 'text-black aria-disabled:text-grey focus:wcag-blue-lightest';\n\n case 'default':\n default:\n return 'wcag-grey-light aria-disabled:text-grey-darker focus:wcag-grey-dark';\n }\n};\n\nexport const useItemStyling = ({ disabled, indented, className }) => {\n const menu = useCurrentMenu();\n\n React.useEffect(() => {\n if (indented && !menu?.indented) {\n menu?.registerIndentation();\n }\n }, [indented]);\n\n return cn(\n 'flex items-center justify-start h-7 pr-1.5 relative rounded w-full focus:outline-none group',\n getAppearanceClasses(menu?.appearance),\n {\n 'pl-7': menu?.indented,\n 'pl-1.5': !menu?.indented,\n 'cursor-pointer': !disabled,\n 'cursor-not-allowed': disabled,\n },\n className\n );\n};\n\nexport const Shortcut = props => {\n const menu = useCurrentMenu();\n let appearance;\n\n switch (menu?.appearance) {\n case 'primary':\n appearance = 'text-blue-lightest group-focus:text-black';\n break;\n\n case 'danger':\n appearance = 'text-red-lightest group-focus:text-white';\n break;\n\n case 'ghost':\n appearance = 'text-blue-light group-focus:text-blue-lightest';\n break;\n\n case 'discrete':\n appearance = 'text-grey-darker group-focus:text-blue-light';\n break;\n\n case 'default':\n default:\n appearance = 'text-grey-darkest';\n break;\n }\n\n const className = cn('ml-auto pl-3', appearance);\n\n return <span {...props} className={className} />;\n};\n\nexport type MenuItemProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n disabled?: boolean;\n icon?: IconName;\n onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;\n shortcut?: string;\n};\n\nexport const Item = React.forwardRef(function MenuItem(props: MenuItemProps, ref: React.Ref<HTMLDivElement>) {\n const { dialog, icon, onClick, shortcut, ...otherProps } = props;\n const className = useItemStyling({\n disabled: props.disabled,\n indented: !!icon,\n className: props.className,\n });\n\n let disabled = props.disabled ?? props['aria-disabled'];\n\n let handleClick;\n\n // radix has a bug that does not disable clicks when disabled is set on items\n if (disabled) {\n handleClick = event => {\n event.preventDefault();\n event.stopPropagation();\n };\n }\n\n let handleSelect = event => {\n if (onClick) {\n onClick(event);\n }\n\n if (props['aria-haspopup'] || typeof dialog === 'function') {\n event.preventDefault();\n }\n };\n\n let button = (\n <DropdownMenuPrimitive.Item {...otherProps} className={className} onClick={handleClick} onSelect={handleSelect} ref={ref}>\n {icon && <Icon name={icon} />}\n {props.children}\n {shortcut && <Shortcut>{shortcut}</Shortcut>}\n </DropdownMenuPrimitive.Item>\n );\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button });\n }\n\n return button;\n});\n"],"names":["Icon","name","React","className","IconPrimitive","getAppearanceClasses","appearance","useItemStyling","disabled","indented","menu","useCurrentMenu","registerIndentation","cn","Shortcut","props","Item","MenuItem","ref","dialog","icon","onClick","shortcut","otherProps","handleClick","event","preventDefault","stopPropagation","handleSelect","button","DropdownMenuPrimitive","onSelect","children","trigger"],"mappings":";;;;;;;;IASaA,IAAI,GAAG,SAAPA,IAAO;AAAA,MAAGC,IAAH,QAAGA,IAAH;AAAA,SAChBC,aAAA,OAAA;AAAMC,IAAAA,SAAS,EAAC;GAAhB,EACID,aAAA,CAACE,MAAD;AAAeD,IAAAA,SAAS,EAAC;AAA0BF,IAAAA,IAAI,EAAEA;GAAzD,CADJ,CADgB;AAAA;;A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P;AACH;;AAED,QAAIV,KAAK,CAAC,eAAD,CAAL,IAA0B,OAAOI,MAAP,KAAkB,UAAhD,EAA4D;AACxDM,MAAAA,KAAK,CAACC,cAAN;AACH;AACJ,GARD;;AAUA,MAAIG,MAAM,GACN3B,aAAA,CAAC4B,MAAD,oBAAgCP;AAAYpB,IAAAA,SAAS,EAAEA;AAAWkB,IAAAA,OAAO,EAAEG;AAAaO,IAAAA,QAAQ,EAAEH;AAAcV,IAAAA,GAAG,EAAEA;IAArH,EACKE,IAAI,IAAIlB,aAAA,CAACF,IAAD;AAAMC,IAAAA,IAAI,EAAEmB;GAAZ,CADb,EAEKL,KAAK,CAACiB,QAFX,EAGKV,QAAQ,IAAIpB,aAAA,CAACY,QAAD,MAAA,EAAWQ,QAAX,CAHjB,CADJ;;AAQA,MAAI,OAAOH,MAAP,KAAkB,UAAtB,EAAkC;AAC9BU,IAAAA,MAAM,GAAGV,MAAM,CAAC;AAAEc,MAAAA,OAAO,EAAEJ;AAAX,KAAD,CAAf;AACH;;AAED,SAAOA,MAAP;AACH,CA3CmB;;;;"}
@@ -6481,13 +6481,13 @@ var Content$4 = /*#__PURE__*/React.forwardRef(function (props, ref) {
6481
6481
  }), children);
6482
6482
  });
6483
6483
 
6484
- var _excluded$w = ["icon", "shortcut"];
6484
+ var _excluded$w = ["dialog", "icon", "onClick", "shortcut"];
6485
6485
  var Icon$1 = function Icon$1(_ref) {
6486
6486
  var name = _ref.name;
6487
6487
  return React.createElement("span", {
6488
6488
  className: "absolute left-0 ml-1"
6489
6489
  }, React.createElement(Icon, {
6490
- className: "!h-5 !w-5 -ml-px -mt-px",
6490
+ className: "-ml-px -mt-px !h-5 !w-5",
6491
6491
  name: name
6492
6492
  }));
6493
6493
  };
@@ -6562,7 +6562,11 @@ var Shortcut = function Shortcut(props) {
6562
6562
  }));
6563
6563
  };
6564
6564
  var Item$1 = /*#__PURE__*/React.forwardRef(function MenuItem(props, ref) {
6565
- var icon = props.icon,
6565
+ var _props$disabled;
6566
+
6567
+ var dialog = props.dialog,
6568
+ icon = props.icon,
6569
+ onClick = props.onClick,
6566
6570
  shortcut = props.shortcut,
6567
6571
  otherProps = _objectWithoutPropertiesLoose(props, _excluded$w);
6568
6572
 
@@ -6571,29 +6575,42 @@ var Item$1 = /*#__PURE__*/React.forwardRef(function MenuItem(props, ref) {
6571
6575
  indented: !!icon,
6572
6576
  className: props.className
6573
6577
  });
6578
+ var disabled = (_props$disabled = props.disabled) !== null && _props$disabled !== void 0 ? _props$disabled : props['aria-disabled'];
6574
6579
  var handleClick; // radix has a bug that does not disable clicks when disabled is set on items
6575
6580
 
6576
- if (!otherProps.disabled) {
6577
- handleClick = props.onClick;
6581
+ if (disabled) {
6582
+ handleClick = function handleClick(event) {
6583
+ event.preventDefault();
6584
+ event.stopPropagation();
6585
+ };
6586
+ }
6578
6587
 
6579
- if (props['aria-haspopup']) {
6580
- handleClick = function handleClick(event) {
6581
- if (props.onClick) {
6582
- event.persist();
6583
- props.onClick(event);
6584
- event.preventDefault();
6585
- }
6586
- };
6588
+ var handleSelect = function handleSelect(event) {
6589
+ if (onClick) {
6590
+ onClick(event);
6587
6591
  }
6588
- }
6589
6592
 
6590
- return React.createElement(DropdownMenuPrimitive.Item, Object.assign({}, otherProps, {
6593
+ if (props['aria-haspopup'] || typeof dialog === 'function') {
6594
+ event.preventDefault();
6595
+ }
6596
+ };
6597
+
6598
+ var button = React.createElement(DropdownMenuPrimitive.Item, Object.assign({}, otherProps, {
6591
6599
  className: className,
6592
6600
  onClick: handleClick,
6601
+ onSelect: handleSelect,
6593
6602
  ref: ref
6594
6603
  }), icon && React.createElement(Icon$1, {
6595
6604
  name: icon
6596
6605
  }), props.children, shortcut && React.createElement(Shortcut, null, shortcut));
6606
+
6607
+ if (typeof dialog === 'function') {
6608
+ button = dialog({
6609
+ trigger: button
6610
+ });
6611
+ }
6612
+
6613
+ return button;
6597
6614
  });
6598
6615
 
6599
6616
  var _excluded$x = ["href", "icon"];