@lobehub/ui 6.17.0 → 6.17.1
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.
|
@@ -41,7 +41,7 @@ declare const styleArrays: {
|
|
|
41
41
|
}> | Readonly<{
|
|
42
42
|
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "transparent">;
|
|
43
43
|
readonly cursor: stylex.StyleXClassNameFor<"cursor", "default">;
|
|
44
|
-
readonly display: stylex.StyleXClassNameFor<"display", "
|
|
44
|
+
readonly display: stylex.StyleXClassNameFor<"display", "none" | "flex">;
|
|
45
45
|
}>)[];
|
|
46
46
|
item: Readonly<{
|
|
47
47
|
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
@@ -19,7 +19,7 @@ const AvatarGroup = memo(({ items, max, gap, variant = "borderless", bordered, s
|
|
|
19
19
|
const avatars = max ? items.slice(0, max) : items;
|
|
20
20
|
const restAvatars = items.slice(max, items.length);
|
|
21
21
|
const gapValue = gap ?? Math.floor(-size / 4);
|
|
22
|
-
const hiddenNames = restAvatars.map((item) => item.
|
|
22
|
+
const hiddenNames = restAvatars.map((item) => item.title ?? item.label ?? item.alt).filter(Boolean).join(", ");
|
|
23
23
|
const avatarProps = {
|
|
24
24
|
animation,
|
|
25
25
|
background,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["Flexbox","clsx","Avatar"],"sources":["../../../src/Avatar/AvatarGroup/index.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { type KeyboardEvent, memo } from 'react';\n\nimport { Flexbox } from '@/Flex';\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { AvatarImpl as Avatar } from '../Avatar';\nimport { avatarGroupClasses } from '../stable';\nimport type { AvatarGroupProps } from '../type';\nimport { styles } from './style';\n\nconst pressOnKey = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n event.currentTarget.click();\n};\n\nconst AvatarGroup = memo<AvatarGroupProps>(\n ({\n items,\n max,\n gap,\n variant = 'borderless',\n bordered,\n shadow,\n size: sizeProp,\n background,\n animation,\n draggable,\n fallbackColors,\n fallbackVariant,\n classNames,\n shape,\n styles: customStyles,\n onClick,\n ref,\n zIndexReverse,\n className,\n ...rest\n }) => {\n const size = sizeProp ?? 48;\n const avatars = max ? items.slice(0, max) : items;\n const restAvatars = items.slice(max, items.length);\n const gapValue = gap ?? Math.floor(-size / 4);\n const hiddenNames = restAvatars\n .map((item) => item.
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Flexbox","clsx","Avatar"],"sources":["../../../src/Avatar/AvatarGroup/index.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { type KeyboardEvent, memo } from 'react';\n\nimport { Flexbox } from '@/Flex';\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { AvatarImpl as Avatar } from '../Avatar';\nimport { avatarGroupClasses } from '../stable';\nimport type { AvatarGroupProps } from '../type';\nimport { styles } from './style';\n\nconst pressOnKey = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n event.currentTarget.click();\n};\n\nconst AvatarGroup = memo<AvatarGroupProps>(\n ({\n items,\n max,\n gap,\n variant = 'borderless',\n bordered,\n shadow,\n size: sizeProp,\n background,\n animation,\n draggable,\n fallbackColors,\n fallbackVariant,\n classNames,\n shape,\n styles: customStyles,\n onClick,\n ref,\n zIndexReverse,\n className,\n ...rest\n }) => {\n const size = sizeProp ?? 48;\n const avatars = max ? items.slice(0, max) : items;\n const restAvatars = items.slice(max, items.length);\n const gapValue = gap ?? Math.floor(-size / 4);\n const hiddenNames = restAvatars\n .map((item) => item.title ?? item.label ?? item.alt)\n .filter(Boolean)\n .join(', ');\n\n const avatarProps = {\n animation,\n background,\n bordered,\n draggable,\n fallbackColors,\n fallbackVariant,\n shadow,\n shape,\n size: sizeProp,\n variant,\n };\n\n return (\n <Flexbox\n horizontal\n gap={gap}\n ref={ref}\n {...styleProps(styles.root, clsx(avatarGroupClasses(), className))}\n {...rest}\n >\n {avatars.map((avatar, index) => {\n const {\n key,\n style: avatarStyle,\n className: avatarClassName,\n ringColor,\n label,\n pressed,\n disabled,\n badge,\n onClick: itemClick,\n ...restAvatarProps\n } = avatar;\n const interactive = !disabled && (!!onClick || !!itemClick);\n const stacking = {\n marginLeft: index === 0 ? 0 : gapValue,\n zIndex: badge ? items.length + 1 : zIndexReverse ? items.length - index : index,\n };\n const node = (\n <Avatar\n aria-disabled={disabled || undefined}\n aria-label={label}\n aria-pressed={interactive ? !!pressed : undefined}\n className={clsx(avatarGroupClasses('avatar'), classNames?.avatar, avatarClassName)}\n key={badge ? undefined : key}\n nativeTitle={label}\n role={interactive ? 'button' : undefined}\n tabIndex={interactive ? 0 : undefined}\n xstyle={styles.avatar}\n style={{\n ...(!badge && stacking),\n ...(ringColor && { boxShadow: `0 0 0 2px ${ringColor}` }),\n ...customStyles?.avatar,\n ...avatarStyle,\n }}\n onKeyDown={interactive ? pressOnKey : undefined}\n onClick={\n interactive ? (itemClick ?? (() => onClick?.({ item: avatar, key }))) : undefined\n }\n {...avatarProps}\n {...restAvatarProps}\n />\n );\n if (!badge) return node;\n const item = styleProps(styles.item, avatarGroupClasses('item'));\n return (\n <span className={item.className} key={key} style={{ ...item.style, ...stacking }}>\n {node}\n <span {...styleProps(styles.badge, avatarGroupClasses('badge'))}>{badge}</span>\n </span>\n );\n })}\n {max && restAvatars.length > 0 && (\n <Avatar\n {...avatarProps}\n aria-label={hiddenNames || undefined}\n avatar={`+${restAvatars.length}`}\n background={cssVar.colorText}\n className={clsx(avatarGroupClasses('count'), classNames?.count)}\n contentXstyle={styles.count}\n fallbackVariant={'text'}\n nativeTitle={hiddenNames || undefined}\n sliceText={false}\n xstyle={styles.avatar}\n style={{\n marginLeft: gapValue,\n zIndex: zIndexReverse ? 0 : avatars.length,\n ...customStyles?.count,\n }}\n />\n )}\n </Flexbox>\n );\n },\n);\n\nAvatarGroup.displayName = 'AvatarGroup';\n\nexport default AvatarGroup;\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,cAAc,UAAyC;CAC3D,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;CAChD,MAAM,eAAe;CACrB,MAAM,cAAc,MAAM;AAC5B;AAEA,MAAM,cAAc,MACjB,EACC,OACA,KACA,KACA,UAAU,cACV,UACA,QACA,MAAM,UACN,YACA,WACA,WACA,gBACA,iBACA,YACA,OACA,QAAQ,cACR,SACA,KACA,eACA,WACA,GAAG,WACC;CACJ,MAAM,OAAO,YAAY;CACzB,MAAM,UAAU,MAAM,MAAM,MAAM,GAAG,GAAG,IAAI;CAC5C,MAAM,cAAc,MAAM,MAAM,KAAK,MAAM,MAAM;CACjD,MAAM,WAAW,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC;CAC5C,MAAM,cAAc,YACjB,KAAK,SAAS,KAAK,SAAS,KAAK,SAAS,KAAK,GAAG,CAAC,CACnD,OAAO,OAAO,CAAC,CACf,KAAK,IAAI;CAEZ,MAAM,cAAc;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;EACN;CACF;CAEA,OACE,qBAACA,mBAAD;EACE,YAAA;EACK;EACA;EACL,GAAI,WAAW,OAAO,MAAMC,OAAK,mBAAmB,GAAG,SAAS,CAAC;EACjE,GAAI;EALN,UAAA,CAOG,QAAQ,KAAK,QAAQ,UAAU;GAC9B,MAAM,EACJ,KACA,OAAO,aACP,WAAW,iBACX,WACA,OACA,SACA,UACA,OACA,SAAS,WACT,GAAG,oBACD;GACJ,MAAM,cAAc,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC;GACjD,MAAM,WAAW;IACf,YAAY,UAAU,IAAI,IAAI;IAC9B,QAAQ,QAAQ,MA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AI,QAAQ;IACpC,GAAG,cAAc;GACnB;EACD,CAAA,CAEI;;AAEb,CACF;AAEA,YAAY,cAAc"}
|
package/es/Avatar/type.d.mts
CHANGED
|
@@ -135,7 +135,7 @@ export interface AvatarGroupItemType extends Pick<AvatarProps, 'avatar' | 'title
|
|
|
135
135
|
disabled?: boolean;
|
|
136
136
|
key: string;
|
|
137
137
|
/**
|
|
138
|
-
* Accessible name and native tooltip of the avatar;
|
|
138
|
+
* Accessible name and native tooltip of the avatar; the `+N` count tooltip names hidden items by `title` first, then `label`
|
|
139
139
|
*/
|
|
140
140
|
label?: string;
|
|
141
141
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useAppElement } from "../ConfigProvider/AppElementContext.mjs";
|
|
2
3
|
import { Autocomplete } from "@base-ui/react/autocomplete";
|
|
3
4
|
import * as stylex from "@stylexjs/stylex";
|
|
4
5
|
import clsx$1 from "clsx";
|
|
5
|
-
import
|
|
6
|
+
import "../ConfigProvider/index.mjs";
|
|
6
7
|
import { menuClassNames, menuStyles } from "../DropdownMenu/style.mjs";
|
|
7
8
|
import { editorSlashMenuClasses } from "./stable.mjs";
|
|
8
9
|
import { styles } from "./style.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/EditorSlashMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Autocomplete } from '@base-ui/react/autocomplete';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport type React from 'react';\n\nimport { useAppElement } from '@/ConfigProvider';\nimport { menuClassNames, menuStyles } from '@/DropdownMenu/sharedStyle';\nimport { type styleProps } from '@/styles/stylex/props';\n\nimport { editorSlashMenuClasses } from './stable';\nimport { styles } from './style';\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\nconst sx = (styles: Parameters<typeof styleProps>[0]) => stylex.props(styles).className ?? '';\n\nexport const EditorSlashMenuRoot = Autocomplete.Root;\nexport const EditorSlashMenuList = ({\n ref,\n className,\n ...rest\n}: React.ComponentProps<typeof Autocomplete.List> & {\n ref?: React.RefObject<HTMLDivElement | null>;\n}) => {\n return (\n <Autocomplete.List\n {...rest}\n ref={ref}\n className={\n mergeStateClassName(\n clsx(sx(styles.list), editorSlashMenuClasses('list')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuList.displayName = 'EditorSlashMenuList';\n\nexport type EditorSlashMenuPortalProps = React.ComponentProps<typeof Autocomplete.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const EditorSlashMenuPortal = ({ container, ...rest }: EditorSlashMenuPortalProps) => {\n const appElement = useAppElement();\n return <Autocomplete.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\nEditorSlashMenuPortal.displayName = 'EditorSlashMenuPortal';\n\nexport type EditorSlashMenuPositionerProps = React.ComponentProps<typeof Autocomplete.Positioner>;\n\nexport const EditorSlashMenuPositioner = ({\n className,\n align,\n positionMethod,\n side,\n sideOffset,\n ...rest\n}: EditorSlashMenuPositionerProps) => {\n return (\n <Autocomplete.Positioner\n {...rest}\n align={align ?? 'start'}\n positionMethod={positionMethod ?? 'fixed'}\n side={side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n className={\n mergeStateClassName(\n clsx(\n sx(menuStyles.positioner),\n menuClassNames.positioner,\n editorSlashMenuClasses('positioner'),\n ),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPositioner.displayName = 'EditorSlashMenuPositioner';\n\nexport type EditorSlashMenuPopupProps = React.ComponentProps<typeof Autocomplete.Popup>;\n\nexport const EditorSlashMenuPopup = ({\n className,\n initialFocus = false,\n ...rest\n}: EditorSlashMenuPopupProps) => {\n return (\n <Autocomplete.Popup\n {...rest}\n initialFocus={initialFocus}\n className={\n mergeStateClassName(\n clsx(sx(menuStyles.popup), menuClassNames.popup, editorSlashMenuClasses()),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPopup.displayName = 'EditorSlashMenuPopup';\n\nexport type EditorSlashMenuItemProps = React.ComponentProps<typeof Autocomplete.Item> & {\n danger?: boolean;\n};\n\nexport const EditorSlashMenuItem = ({ className, danger, ...rest }: EditorSlashMenuItemProps) => {\n return (\n <Autocomplete.Item\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, danger && menuStyles.danger]),\n editorSlashMenuClasses('item'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuItem.displayName = 'EditorSlashMenuItem';\n\nexport type EditorSlashMenuGroupProps = React.ComponentProps<typeof Autocomplete.Group>;\nexport const EditorSlashMenuGroup = ({ className, ...rest }: EditorSlashMenuGroupProps) => (\n <Autocomplete.Group\n {...rest}\n className={mergeStateClassName(editorSlashMenuClasses('group'), className as any) as any}\n />\n);\nEditorSlashMenuGroup.displayName = 'EditorSlashMenuGroup';\n\nexport type EditorSlashMenuGroupLabelProps = React.ComponentProps<typeof Autocomplete.GroupLabel>;\n\nexport const EditorSlashMenuGroupLabel = ({\n className,\n ...rest\n}: EditorSlashMenuGroupLabelProps) => {\n return (\n <Autocomplete.GroupLabel\n {...rest}\n className={(state) =>\n clsx(\n sx(menuStyles.groupLabel),\n editorSlashMenuClasses('group-label'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuGroupLabel.displayName = 'EditorSlashMenuGroupLabel';\n\nexport type EditorSlashMenuEmptyProps = React.ComponentProps<typeof Autocomplete.Empty>;\n\nexport const EditorSlashMenuEmpty = ({ className, ...rest }: EditorSlashMenuEmptyProps) => {\n return (\n <Autocomplete.Empty\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, menuStyles.empty]),\n editorSlashMenuClasses('empty'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuEmpty.displayName = 'EditorSlashMenuEmpty';\n\nexport type EditorSlashMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\nexport const EditorSlashMenuItemContent = ({\n className,\n ...rest\n}: EditorSlashMenuItemContentProps) => {\n return (\n <div\n {...rest}\n className={clsx(\n sx(menuStyles.itemContent),\n editorSlashMenuClasses('item-content'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemContent.displayName = 'EditorSlashMenuItemContent';\n\nexport type EditorSlashMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemIcon = ({ className, ...rest }: EditorSlashMenuItemIconProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.icon),\n menuClassNames.icon,\n editorSlashMenuClasses('icon'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemIcon.displayName = 'EditorSlashMenuItemIcon';\n\nexport type EditorSlashMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemLabel = ({ className, ...rest }: EditorSlashMenuItemLabelProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.label),\n menuClassNames.label,\n editorSlashMenuClasses('label'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemLabel.displayName = 'EditorSlashMenuItemLabel';\n\nexport type EditorSlashMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemExtra = ({ className, ...rest }: EditorSlashMenuItemExtraProps) => {\n return (\n <span\n {...rest}\n className={clsx(sx(menuStyles.extra), editorSlashMenuClasses('extra'), className)}\n />\n );\n};\nEditorSlashMenuItemExtra.displayName = 'EditorSlashMenuItemExtra';\n\nexport type EditorSlashMenuHiddenInputProps = React.ComponentProps<typeof Autocomplete.Input>;\nexport const EditorSlashMenuHiddenInput = ({\n className,\n ...rest\n}: EditorSlashMenuHiddenInputProps) => {\n return (\n <Autocomplete.Input\n {...rest}\n className={\n mergeStateClassName(\n clsx(sx(styles.hiddenInput), editorSlashMenuClasses('input')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuHiddenInput.displayName = 'EditorSlashMenuHiddenInput';\n"],"mappings":";;;;;;;;;;AAWA,MAAM,uBAAgC,MAAc,cAA4E;CAC9H,IAAI,OAAO,cAAc,YAAY,QAAQ,UAAkBA,OAAK,MAAM,UAAU,KAAK,CAAC;CAC1F,OAAOA,OAAK,MAAM,SAAS;AAC7B;AACA,MAAM,MAAM,WAA6C,OAAO,MAAM,MAAM,CAAC,CAAC,aAAa;AAC3F,MAAa,sBAAsB,aAAa;AAChD,MAAa,uBAAuB,EAClC,KACA,WACA,GAAG,WAGC;CACJ,OAAO,oBAAC,aAAa,MAAd;EAAmB,GAAI;EAAW;EAAK,WAAW,oBAAoBA,OAAK,GAAG,OAAO,IAAI,GAAG,uBAAuB,MAAM,CAAC,GAAG,SAAgB;CAAW,CAAA;AACjK;AACA,oBAAoB,cAAc;AAOlC,MAAa,yBAAyB,EACpC,WACA,GAAG,WAC6B;CAChC,MAAM,aAAa,cAAc;CACjC,OAAO,oBAAC,aAAa,QAAd;EAAqB,WAAW,aAAa,cAAc,KAAA;EAAW,GAAI;CAAO,CAAA;AAC1F;AACA,sBAAsB,cAAc;AAEpC,MAAa,6BAA6B,EACxC,WACA,OACA,gBACA,MACA,YACA,GAAG,WACiC;CACpC,OAAO,oBAAC,aAAa,YAAd;EAAyB,GAAI;EAAM,OAAO,SAAS;EAAS,gBAAgB,kBAAkB;EAAS,MAAM,QAAQ;EAAU,YAAY,cAAc;EAAG,WAAW,oBAAoBA,OAAK,GAAG,WAAW,UAAU,GAAG,eAAe,YAAY,uBAAuB,YAAY,CAAC,GAAG,SAAgB;CAAW,CAAA;AACjU;AACA,0BAA0B,cAAc;AAExC,MAAa,wBAAwB,EACnC,WACA,eAAe,OACf,GAAG,WAC4B;CAC/B,OAAO,oBAAC,aAAa,OAAd;EAAoB,GAAI;EAAoB;EA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,2BAA2B,cAAc;AAEzC,MAAa,2BAA2B,EACtC,WACA,GAAG,WAC+B;CAClC,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAWA,OAAK,GAAG,WAAW,IAAI,GAAG,eAAe,MAAM,uBAAuB,MAAM,GAAG,SAAS;CAAI,CAAA;AAChI;AACA,wBAAwB,cAAc;AAEtC,MAAa,4BAA4B,EACvC,WACA,GAAG,WACgC;CACnC,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAWA,OAAK,GAAG,WAAW,KAAK,GAAG,eAAe,OAAO,uBAAuB,OAAO,GAAG,SAAS;CAAI,CAAA;AACnI;AACA,yBAAyB,cAAc;AAEvC,MAAa,4BAA4B,EACvC,WACA,GAAG,WACgC;CACnC,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAWA,OAAK,GAAG,WAAW,KAAK,GAAG,uBAAuB,OAAO,GAAG,SAAS;CAAI,CAAA;AAC7G;AACA,yBAAyB,cAAc;AAEvC,MAAa,8BAA8B,EACzC,WACA,GAAG,WACkC;CACrC,OAAO,oBAAC,aAAa,OAAd;EAAoB,GAAI;EAAM,WAAW,oBAAoBA,OAAK,GAAG,OAAO,WAAW,GAAG,uBAAuB,OAAO,CAAC,GAAG,SAAgB;CAAW,CAAA;AAChK;AACA,2BAA2B,cAAc"}
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/EditorSlashMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Autocomplete } from '@base-ui/react/autocomplete';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport type React from 'react';\n\nimport { useAppElement } from '@/ConfigProvider';\nimport { menuClassNames, menuStyles } from '@/DropdownMenu/sharedStyle';\nimport { type styleProps } from '@/styles/stylex/props';\n\nimport { editorSlashMenuClasses } from './stable';\nimport { styles } from './style';\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\nconst sx = (styles: Parameters<typeof styleProps>[0]) => stylex.props(styles).className ?? '';\n\nexport const EditorSlashMenuRoot = Autocomplete.Root;\nexport const EditorSlashMenuList = ({\n ref,\n className,\n ...rest\n}: React.ComponentProps<typeof Autocomplete.List> & {\n ref?: React.RefObject<HTMLDivElement | null>;\n}) => {\n return (\n <Autocomplete.List\n {...rest}\n ref={ref}\n className={\n mergeStateClassName(\n clsx(sx(styles.list), editorSlashMenuClasses('list')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuList.displayName = 'EditorSlashMenuList';\n\nexport type EditorSlashMenuPortalProps = React.ComponentProps<typeof Autocomplete.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const EditorSlashMenuPortal = ({ container, ...rest }: EditorSlashMenuPortalProps) => {\n const appElement = useAppElement();\n return <Autocomplete.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\nEditorSlashMenuPortal.displayName = 'EditorSlashMenuPortal';\n\nexport type EditorSlashMenuPositionerProps = React.ComponentProps<typeof Autocomplete.Positioner>;\n\nexport const EditorSlashMenuPositioner = ({\n className,\n align,\n positionMethod,\n side,\n sideOffset,\n ...rest\n}: EditorSlashMenuPositionerProps) => {\n return (\n <Autocomplete.Positioner\n {...rest}\n align={align ?? 'start'}\n positionMethod={positionMethod ?? 'fixed'}\n side={side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n className={\n mergeStateClassName(\n clsx(\n sx(menuStyles.positioner),\n menuClassNames.positioner,\n editorSlashMenuClasses('positioner'),\n ),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPositioner.displayName = 'EditorSlashMenuPositioner';\n\nexport type EditorSlashMenuPopupProps = React.ComponentProps<typeof Autocomplete.Popup>;\n\nexport const EditorSlashMenuPopup = ({\n className,\n initialFocus = false,\n ...rest\n}: EditorSlashMenuPopupProps) => {\n return (\n <Autocomplete.Popup\n {...rest}\n initialFocus={initialFocus}\n className={\n mergeStateClassName(\n clsx(sx(menuStyles.popup), menuClassNames.popup, editorSlashMenuClasses()),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPopup.displayName = 'EditorSlashMenuPopup';\n\nexport type EditorSlashMenuItemProps = React.ComponentProps<typeof Autocomplete.Item> & {\n danger?: boolean;\n};\n\nexport const EditorSlashMenuItem = ({ className, danger, ...rest }: EditorSlashMenuItemProps) => {\n return (\n <Autocomplete.Item\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, danger && menuStyles.danger]),\n editorSlashMenuClasses('item'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuItem.displayName = 'EditorSlashMenuItem';\n\nexport type EditorSlashMenuGroupProps = React.ComponentProps<typeof Autocomplete.Group>;\nexport const EditorSlashMenuGroup = ({ className, ...rest }: EditorSlashMenuGroupProps) => (\n <Autocomplete.Group\n {...rest}\n className={mergeStateClassName(editorSlashMenuClasses('group'), className as any) as any}\n />\n);\nEditorSlashMenuGroup.displayName = 'EditorSlashMenuGroup';\n\nexport type EditorSlashMenuGroupLabelProps = React.ComponentProps<typeof Autocomplete.GroupLabel>;\n\nexport const EditorSlashMenuGroupLabel = ({\n className,\n ...rest\n}: EditorSlashMenuGroupLabelProps) => {\n return (\n <Autocomplete.GroupLabel\n {...rest}\n className={(state) =>\n clsx(\n sx(menuStyles.groupLabel),\n editorSlashMenuClasses('group-label'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuGroupLabel.displayName = 'EditorSlashMenuGroupLabel';\n\nexport type EditorSlashMenuEmptyProps = React.ComponentProps<typeof Autocomplete.Empty>;\n\nexport const EditorSlashMenuEmpty = ({ className, ...rest }: EditorSlashMenuEmptyProps) => {\n return (\n <Autocomplete.Empty\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, menuStyles.empty]),\n editorSlashMenuClasses('empty'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuEmpty.displayName = 'EditorSlashMenuEmpty';\n\nexport type EditorSlashMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\nexport const EditorSlashMenuItemContent = ({\n className,\n ...rest\n}: EditorSlashMenuItemContentProps) => {\n return (\n <div\n {...rest}\n className={clsx(\n sx(menuStyles.itemContent),\n editorSlashMenuClasses('item-content'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemContent.displayName = 'EditorSlashMenuItemContent';\n\nexport type EditorSlashMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemIcon = ({ className, ...rest }: EditorSlashMenuItemIconProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.icon),\n menuClassNames.icon,\n editorSlashMenuClasses('icon'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemIcon.displayName = 'EditorSlashMenuItemIcon';\n\nexport type EditorSlashMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemLabel = ({ className, ...rest }: EditorSlashMenuItemLabelProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.label),\n menuClassNames.label,\n editorSlashMenuClasses('label'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemLabel.displayName = 'EditorSlashMenuItemLabel';\n\nexport type EditorSlashMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemExtra = ({ className, ...rest }: EditorSlashMenuItemExtraProps) => {\n return (\n <span\n {...rest}\n className={clsx(sx(menuStyles.extra), editorSlashMenuClasses('extra'), className)}\n />\n );\n};\nEditorSlashMenuItemExtra.displayName = 'EditorSlashMenuItemExtra';\n\nexport type EditorSlashMenuHiddenInputProps = React.ComponentProps<typeof Autocomplete.Input>;\nexport const EditorSlashMenuHiddenInput = ({\n className,\n ...rest\n}: EditorSlashMenuHiddenInputProps) => {\n return (\n <Autocomplete.Input\n {...rest}\n className={\n mergeStateClassName(\n clsx(sx(styles.hiddenInput), editorSlashMenuClasses('input')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuHiddenInput.displayName = 'EditorSlashMenuHiddenInput';\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,uBAAgC,MAAc,cAA4E;CAC9H,IAAI,OAAO,cAAc,YAAY,QAAQ,UAAkBA,OAAK,MAAM,UAAU,KAAK,CAAC;CAC1F,OAAOA,OAAK,MAAM,SAAS;AAC7B;AACA,MAAM,MAAM,WAA6C,OAAO,MAAM,MAAM,CAAC,CAAC,aAAa;AAC3F,MAAa,sBAAsB,aAAa;AAChD,MAAa,uBAAuB,EAClC,KACA,WACA,GAAG,WAGC;CACJ,OAAO,oBAAC,aAAa,MAAd;EAAmB,GAAI;EAAW;EAAK,WAAW,oBAAoBA,OAAK,GAAG,OAAO,IAAI,GAAG,uBAAuB,MAAM,CAAC,GAAG,SAAgB;CAAW,CAAA;AACjK;AACA,oBAAoB,cAAc;AAOlC,MAAa,yBAAyB,EACpC,WACA,GAAG,WAC6B;CAChC,MAAM,aAAa,cAAc;CACjC,OAAO,oBAAC,aAAa,QAAd;EAAqB,WAAW,aAAa,cAAc,KAAA;EAAW,GAAI;CAAO,CAAA;AAC1F;AACA,sBAAsB,cAAc;AAEpC,MAAa,6BAA6B,EACxC,WACA,OACA,gBACA,MACA,YACA,GAAG,WACiC;CACpC,OAAO,oBAAC,aAAa,YAAd;EAAyB,GAAI;EAAM,OAAO,SAAS;EAAS,gBAAgB,kBAAkB;EAAS,MAAM,QAAQ;EAAU,YAAY,cAAc;EAAG,WAAW,oBAAoBA,OAAK,GAAG,WAAW,UAAU,GAAG,eAAe,YAAY,uBAAuB,YAAY,CAAC,GAAG,SAAgB;CAAW,CAAA;AACjU;AACA,0BAA0B,cAAc;AAExC,MAAa,wBAAwB,EACnC,WACA,eAAe,OACf,GAAG,WAC4B;CAC/B,OAAO,oBA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