@react-spectrum/s2
Version:
Spectrum 2 UI components in React
1 lines • 4.37 kB
Source Map (JSON)
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAwBM,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAqF;AAK3H,MAAM,4CAA0B,AAAb,WAAW,GAAG,CAAA,GAAA,uBAAS,EAAqB,SAAS,WAA6B,KAAyB,EAAE,GAAoC;IACzK,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,iDAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,cAAc,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACxD,IAAI,WAAW,CAAC,aAAa,KAAK,WAChC,WAAW,CAAC,aAAa,GAAG,gBAAgB,MAAM,CAAC;IAGrD,qBACE,iCAAC,CAAA,GAAA,qCAAU;QACT,QAAQ,MAAM,MAAM;QACpB,aAAa,MAAM,WAAW;QAC9B,cAAc,MAAM,YAAY;QAChC,OAAO,MAAM,KAAK;QAClB,WAAW,MAAM,SAAS;QAC1B,YAAY,MAAM,UAAU;;0BAC5B,gCAAC,CAAA,GAAA,sCAAW;gBACV,KAAK;gBACL,MAAM,MAAM,IAAI;gBAChB,YAAY,MAAM,UAAU;gBAC5B,WAAW,MAAM,SAAS;gBAC1B,SAAS,MAAM,OAAO;gBACtB,QAAQ,MAAM,MAAM;gBACnB,GAAG,WAAW;0BACf,cAAA,gCAAC,CAAA,GAAA,iCAAO;;0BAEV,gCAAC,CAAA,GAAA,8BAAG;gBACF,OAAO,MAAM,KAAK;gBAClB,cAAc,MAAM,YAAY;gBAChC,UAAU,MAAM,QAAQ;gBACxB,MAAM,MAAM,QAAQ;0BACnB,MAAM,QAAQ;;;;AAIvB","sources":["packages/@react-spectrum/s2/src/ActionMenu.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ActionButton, ActionButtonProps} from './ActionButton';\nimport {AriaLabelingProps, DOMProps, FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {ContextValue} from 'react-aria-components';\nimport {createContext, forwardRef} from 'react';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {forwardRefType} from './types';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {Menu, MenuProps, MenuTrigger, MenuTriggerProps} from './Menu';\nimport MoreIcon from '../s2wf-icons/S2_Icon_More_20_N.svg';\nimport {StyleProps} from './style-utils' with { type: 'macro' };\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ActionMenuProps<T> extends\n Pick<MenuTriggerProps, 'isOpen' | 'defaultOpen' | 'onOpenChange' | 'align' | 'direction' | 'shouldFlip'>,\n Pick<MenuProps<T>, 'children' | 'items' | 'disabledKeys' | 'onAction'>,\n Pick<ActionButtonProps, 'isDisabled' | 'isQuiet' | 'autoFocus' | 'size'>,\n StyleProps, DOMProps, AriaLabelingProps {\n menuSize?: 'S' | 'M' | 'L' | 'XL'\n}\n\nexport const ActionMenuContext = createContext<ContextValue<Partial<ActionMenuProps<any>>, FocusableRefValue<HTMLButtonElement>>>(null);\n\n/**\n * ActionMenu combines an ActionButton with a Menu for simple \"more actions\" use cases.\n */\nexport const ActionMenu = /*#__PURE__*/(forwardRef as forwardRefType)(function ActionMenu<T extends object>(props: ActionMenuProps<T>, ref: FocusableRef<HTMLButtonElement>) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n [props, ref] = useSpectrumContextProps(props, ref, ActionMenuContext);\n let buttonProps = filterDOMProps(props, {labelable: true});\n if (buttonProps['aria-label'] === undefined) {\n buttonProps['aria-label'] = stringFormatter.format('menu.moreActions');\n }\n\n return (\n <MenuTrigger\n isOpen={props.isOpen}\n defaultOpen={props.defaultOpen}\n onOpenChange={props.onOpenChange}\n align={props.align}\n direction={props.direction}\n shouldFlip={props.shouldFlip}>\n <ActionButton\n ref={ref}\n size={props.size}\n isDisabled={props.isDisabled}\n autoFocus={props.autoFocus}\n isQuiet={props.isQuiet}\n styles={props.styles}\n {...buttonProps}>\n <MoreIcon />\n </ActionButton>\n <Menu\n items={props.items}\n disabledKeys={props.disabledKeys}\n onAction={props.onAction}\n size={props.menuSize}>\n {props.children}\n </Menu>\n </MenuTrigger>\n );\n});\n"],"names":[],"version":3,"file":"ActionMenu.cjs.map"}