@planningcenter/tapestry 4.15.1-rc.0 → 4.15.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.
Files changed (46) hide show
  1. package/dist/components/combo-box/ComboBox.d.ts.map +1 -1
  2. package/dist/components/combo-box/ComboBox.js +4 -1
  3. package/dist/components/combo-box/ComboBox.js.map +1 -1
  4. package/dist/components/dropdown/Dropdown.d.ts +1 -1
  5. package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
  6. package/dist/components/dropdown/Dropdown.js +3 -1
  7. package/dist/components/dropdown/Dropdown.js.map +1 -1
  8. package/dist/components/tag/Tag.d.ts.map +1 -1
  9. package/dist/components/tag/Tag.js +12 -5
  10. package/dist/components/tag/Tag.js.map +1 -1
  11. package/dist/components/tag/TagContent.d.ts +5 -3
  12. package/dist/components/tag/TagContent.d.ts.map +1 -1
  13. package/dist/components/tag/TagContent.js +5 -4
  14. package/dist/components/tag/TagContent.js.map +1 -1
  15. package/dist/components/tag/TagListItem.d.ts +17 -0
  16. package/dist/components/tag/TagListItem.d.ts.map +1 -0
  17. package/dist/components/tag/TagListItem.js +17 -0
  18. package/dist/components/tag/TagListItem.js.map +1 -0
  19. package/dist/components/tag/useTagMenu.d.ts +24 -14
  20. package/dist/components/tag/useTagMenu.d.ts.map +1 -1
  21. package/dist/components/tag/useTagMenu.js +35 -18
  22. package/dist/components/tag/useTagMenu.js.map +1 -1
  23. package/dist/components/tag-group/TagGroup.d.ts +51 -0
  24. package/dist/components/tag-group/TagGroup.d.ts.map +1 -0
  25. package/dist/components/tag-group/TagGroup.js +49 -0
  26. package/dist/components/tag-group/TagGroup.js.map +1 -0
  27. package/dist/components/tag-group/index.d.ts +4 -0
  28. package/dist/components/tag-group/index.d.ts.map +1 -0
  29. package/dist/reactRender.css +1627 -1558
  30. package/dist/reactRender.css.map +1 -1
  31. package/dist/reactRenderLegacy.css +1627 -1558
  32. package/dist/reactRenderLegacy.css.map +1 -1
  33. package/dist/tapestryMount.css +1627 -1558
  34. package/dist/tapestryMount.css.map +1 -1
  35. package/dist/tapestryMountLegacy.css +1627 -1558
  36. package/dist/tapestryMountLegacy.css.map +1 -1
  37. package/dist/unstable.css +75 -6
  38. package/dist/unstable.css.map +1 -1
  39. package/dist/unstable.d.ts +2 -0
  40. package/dist/unstable.d.ts.map +1 -1
  41. package/dist/unstable.js +1 -0
  42. package/dist/unstable.js.map +1 -1
  43. package/docs/components/tag-group.md +48 -0
  44. package/docs/components/tag.md +6 -1
  45. package/docs/llms.txt +3 -0
  46. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/combo-box/ComboBox.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,oBAAoB,CAAA;AAC3B,OAAO,aAAa,CAAA;AASpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAIhF,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAyB,MAAM,OAAO,CAAA;AACpE,OAAO,EAIL,KAAK,aAAa,IAAI,iBAAiB,EAGvC,KAAK,GAAG,EAIR,KAAK,gBAAgB,EAErB,KAAK,YAAY,IAAI,gBAAgB,EAErC,KAAK,mBAAmB,EAGzB,MAAM,gCAAgC,CAAA;AAIvC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtC,MAAM,MAAM,oBAAoB,GAC5B,OAAO,GACP,WAAW,GACX,MAAM,GACN,SAAS,GACT,aAAa,GACb,SAAS,CAAA;AAEb,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,WAAW,CACnD,gBAAgB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAChC,CAAA;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACtD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,mC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SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,wBAAwB,CAAC,CAAC,CAAC,qBAQ7B;AAED,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,QAAQ,EAAE,SAAS,CAAA;IACnB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,KAAK,gCAAgC,GAAG,cAAc,CAAA;AAEtD,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAC/D,+BAA+B,CAC7B,mBAAmB,CAAC,CAAC,CAAC,EACtB,oBAAoB,EACpB,KAAK,EACL,gCAAgC,CACjC,CAAA;AAEH;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,EAChD,QAAQ,EACR,SAAS,EACT,KAAK,EACL,GAAG,SAAS,EACb,EAAE,2BAA2B,CAAC,CAAC,CAAC,qBAiBhC"}
@@ -137,8 +137,11 @@ function ComboBoxItem({ className, disabled, ...restProps }) {
137
137
  * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-combobox--docs | Storybook Documentation}
138
138
  */
139
139
  function ComboBoxSection({ children, className, title, ...restProps }) {
140
+ const hasTitle = typeof title === "string"
141
+ ? title.trim() !== ""
142
+ : Boolean(title) || title === 0;
140
143
  return (React__default.createElement(ListBoxSection, { ...restProps, className: classNames("tds-combo-box-list-section", className) },
141
- title && (React__default.createElement(Header, { className: "tds-combo-box-section-header" }, title)),
144
+ hasTitle && (React__default.createElement(Header, { className: "tds-combo-box-section-header" }, title)),
142
145
  children));
143
146
  }
144
147
 
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.js","sources":["../../../src/components/combo-box/ComboBox.tsx"],"sourcesContent":["import \"../button/btn.css\"\nimport \"../field/index.css\"\nimport \"./index.css\"\n\nimport { IconButton } from \"@components/button\"\nimport {\n LOADING_ANNOUNCEMENT_DELAY_MS,\n LoadingAnnouncement,\n} from \"@components/internal/LoadingAnnouncement\"\nimport LoadingSpinner from \"@components/internal/LoadingSpinner\"\nimport Icon from \"@utilities/Icon\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useAnnounce } from \"@utilities/useAnnounce\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, { type ReactNode, useContext, useEffect } from \"react\"\nimport {\n Button,\n Collection,\n ComboBox as AriaComboBox,\n type ComboBoxProps as AriaComboBoxProps,\n ComboBoxStateContext,\n Input,\n type Key,\n Label,\n ListBox,\n ListBoxItem,\n type ListBoxItemProps,\n ListBoxLoadMoreItem,\n type ListBoxProps as AriaListBoxProps,\n ListBoxSection,\n type ListBoxSectionProps,\n Popover,\n Text,\n} from \"react-aria-components/ComboBox\"\nimport { Group } from \"react-aria-components/Group\"\nimport { Header } from \"react-aria-components/Header\"\n\nexport type ComboBoxSize = \"md\" | \"lg\"\n\nexport type ComboBoxLoadingState =\n | \"error\"\n | \"filtering\"\n | \"idle\"\n | \"loading\"\n | \"loadingMore\"\n | \"sorting\"\n\ntype ComboBoxChildren<T extends object> = NonNullable<\n AriaListBoxProps<T>[\"children\"]\n>\n\nexport interface ComboBoxProps<T extends object = object> {\n /**\n * If `true`, keeps typed text that does not match an option. Turn it on when\n * ComboBox is a standalone search and the suggestions are shortcuts. Leave it\n * off in forms, where the value needs to match one of the options.\n */\n allowsCustomValue?: boolean\n /** The contents of the listbox. */\n children: ComboBoxChildren<T>\n /** Helper text displayed below the component. Styled as error text when `invalid` is `true`. */\n description?: ReactNode\n /** Disables the field and trigger button. */\n disabled?: boolean\n /** Custom filter function for determining if an item should appear in the list. */\n filter?: (textValue: string, inputValue: string) => boolean\n /** If `true`, the `label` text is rendered as an `aria-label` instead of a visible label element. */\n hideLabel?: boolean\n /** Whether the input is in an invalid state. */\n invalid?: boolean\n /** Accessible label for the field. */\n label: string\n /**\n * Async loading state for the listbox.\n * - `\"loading\"`: while the collection is empty, replaces the empty state with a spinner.\n * - `\"loadingMore\"`: shows an inline spinner at the bottom of the listbox (use with `onLoadMore`).\n * - `\"filtering\"`: renders as `\"idle\"`, but tells screen reader users \"Loading\" when results are slow to arrive after typing stops.\n * - `\"error\"`: renders as `\"idle\"`, but reads the empty state (`renderEmptyState`) to screen reader users while the collection is empty.\n * - Other values render as `\"idle\"`.\n */\n loadingState?: ComboBoxLoadingState\n /**\n * The interaction that opens the popover.\n * - `\"input\"`: opens when the user enters text in the input.\n * - `\"focus\"`: opens when the user focuses (via click or keyboard) into the input.\n * - `\"manual\"`: opens only via the trigger button or arrow keys.\n * @default \"focus\"\n */\n menuTrigger?: \"focus\" | \"input\" | \"manual\"\n /**\n * Called when the selected value(s) change.\n * Receives `Key[]` when `selectionMode` is `\"multiple\"`, otherwise `Key | null`.\n */\n onChange?: ((value: Key | null) => void) | ((value: Key[]) => void)\n /** Called when the user scrolls near the bottom of the listbox. Pair with `loadingState` for infinite scroll. */\n onLoadMore?: () => void\n /** Placeholder text for the input. */\n placeholder?: string\n /** If `true`, allows the value to be read but not changed. */\n readOnly?: boolean\n /** Content to display when there are no items in the list. Defaults to \"No results\". */\n renderEmptyState?: ReactNode | (() => ReactNode)\n /** If `true`, appends an asterisk at the end of the label text. */\n required?: boolean\n /**\n * If `true`, renders a button after the input that clears its text. Only\n * applies when `menuTrigger` is `\"focus\"`, where no trigger button is rendered.\n */\n showClearButton?: boolean\n /** If `true`, renders a search icon before the input. */\n showSearchIcon?: boolean\n /** The size of the combo box. */\n size?: ComboBoxSize\n}\n\ntype AriaComboBoxPropsToOmit = \"slot\"\n\ntype AriaComboBoxPropsToInclude =\n | \"allowsEmptyCollection\"\n | \"defaultItems\"\n | \"defaultValue\"\n | \"disabledKeys\"\n | \"inputValue\"\n | \"items\"\n | \"name\"\n | \"onInputChange\"\n | \"selectionMode\"\n | \"value\"\n\nexport type ComboBoxElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n AriaComboBoxProps<T, \"single\" | \"multiple\">,\n ComboBoxProps<T>,\n AriaComboBoxPropsToOmit,\n AriaComboBoxPropsToInclude\n >\n\nfunction resolveEmptyState(value: ReactNode | (() => ReactNode)): ReactNode {\n return typeof value === \"function\" ? value() : value\n}\n\nfunction ClearButton() {\n const state = useContext(ComboBoxStateContext)\n\n return (\n <IconButton\n aria-label=\"Clear\"\n className=\"tds-combo-box-clear-button\"\n data-input-empty={!state?.inputValue ? true : undefined}\n icon={\n <Icon\n aria-hidden\n className=\"tds-combo-box-clear-icon\"\n symbol=\"general#x\"\n />\n }\n kind=\"neutral-inline\"\n onClick={() => state?.setInputValue(\"\")}\n onMouseDown={(event) => event.preventDefault()}\n tabIndex={-1}\n />\n )\n}\n\n/**\n * In multiple selection mode, Tab closes the list without changing the\n * selection. React Aria would otherwise toggle the focused option, which\n * removes a value when the list opened with a selected option focused.\n */\nfunction ComboBoxInput(props: React.ComponentProps<typeof Input>) {\n const state = useContext(ComboBoxStateContext)\n\n return (\n <Input\n {...props}\n onKeyDownCapture={(event) => {\n if (\n event.key === \"Tab\" &&\n state?.isOpen &&\n state.selectionManager.selectionMode === \"multiple\"\n ) {\n state.selectionManager.setFocusedKey(null)\n }\n }}\n />\n )\n}\n\nfunction ErrorAnnouncement({ labelledBy }: { labelledBy: string }) {\n const announce = useAnnounce()\n const inputValue = useContext(ComboBoxStateContext)?.inputValue\n\n useEffect(() => {\n const timeout = setTimeout(\n () => announce({ \"aria-labelledby\": labelledBy }),\n LOADING_ANNOUNCEMENT_DELAY_MS\n )\n return () => clearTimeout(timeout)\n }, [announce, inputValue, labelledBy])\n\n return null\n}\n\nfunction FilteringAnnouncement() {\n const state = useContext(ComboBoxStateContext)\n if (!state?.isOpen) return null\n\n return <LoadingAnnouncement key={state.inputValue} message=\"Loading\" />\n}\n\n/**\n * A combo box combines a text input with a filterable popover\n * listbox, allowing users to type to search and select from a list of options.\n *\n * It supports both single and multiple selection (`selectionMode`), custom filtering,\n * and asynchronous data loading with infinite scroll capabilities (`loadingState` and `onLoadMore`).\n * Collections can be either static or dynamic, managed via the `children`, `items`,\n * or `defaultItems` props. To construct the dropdown list, compose this component\n * with `ComboBoxItem` for individual options and `ComboBoxSection` for grouping.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-combobox--docs | Storybook Documentation}\n */\nexport function ComboBox<T extends object>({\n allowsEmptyCollection = true,\n children,\n className,\n description,\n disabled,\n filter,\n hideLabel,\n invalid,\n label,\n loadingState,\n menuTrigger = \"focus\",\n onChange,\n onLoadMore,\n placeholder,\n readOnly,\n renderEmptyState = \"No results\",\n required,\n showClearButton,\n showSearchIcon,\n size = \"md\",\n ...restProps\n}: ComboBoxElementProps<T>) {\n const emptyStateId = `tds-combo-box-empty-state-${useId()}`\n const combinedClassName = classNames(\n \"tds-field tds-combo-box\",\n {\n \"tds-combo-box--lg\": size === \"lg\",\n \"tds-field--lg\": size === \"lg\",\n },\n className\n )\n\n const loadMoreItem = onLoadMore && (\n <ListBoxLoadMoreItem\n className=\"tds-combo-box-load-more\"\n isLoading={loadingState === \"loadingMore\"}\n onLoadMore={onLoadMore}\n >\n <span className=\"tds-combo-box-loading-label--hidden\">Loading more</span>\n <LoadingSpinner />\n <LoadingAnnouncement message=\"Loading more\" />\n </ListBoxLoadMoreItem>\n )\n\n const renderChildren = () => {\n if (typeof children === \"function\") {\n return (\n <Collection items={restProps.items ?? restProps.defaultItems}>\n {children}\n </Collection>\n )\n }\n return children\n }\n\n return (\n // React Aria's ComboBox is generic over selection mode (M). We instantiate\n // it with the union \"single\" | \"multiple\" so value/defaultValue/selectionMode\n // accept both shapes. onChange still needs a cast because our type is a union\n // of function types (to allow narrower handlers like\n // `setValue: (Key|null) => void`), which isn't assignable to RAC's\n // single-function signature.\n <AriaComboBox<T, \"single\" | \"multiple\">\n {...restProps}\n allowsEmptyCollection={allowsEmptyCollection}\n aria-label={hideLabel ? label : undefined}\n className={combinedClassName}\n defaultFilter={filter}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isRequired={required}\n menuTrigger={menuTrigger}\n onChange={onChange as (value: Key | Key[] | null) => void}\n >\n {!hideLabel && <Label className=\"tds-field-label\">{label}</Label>}\n <Group className=\"tds-field-control tds-combo-box-field\">\n {showSearchIcon && (\n <Icon\n aria-hidden\n className=\"tds-combo-box-search-icon\"\n symbol=\"general#search\"\n />\n )}\n <ComboBoxInput\n aria-invalid={invalid || undefined}\n className=\"tds-combo-box-input\"\n placeholder={placeholder}\n />\n {menuTrigger !== \"focus\" && !readOnly && (\n <Button className=\"tds-combo-box-button tds-btn tds-btn--infield\">\n <Icon aria-hidden symbol=\"general#down-caret\" />\n </Button>\n )}\n {showClearButton &&\n menuTrigger === \"focus\" &&\n !readOnly &&\n !disabled && <ClearButton />}\n </Group>\n <Popover className=\"tds-combo-box-popover\">\n <ListBox\n className=\"tds-combo-box-list\"\n renderEmptyState={\n allowsEmptyCollection\n ? () => (\n <div className=\"tds-combo-box-empty-state\" id={emptyStateId}>\n {loadingState === \"error\" && (\n <ErrorAnnouncement labelledBy={emptyStateId} />\n )}\n {loadingState === \"loading\" ? (\n <>\n <span className=\"tds-combo-box-loading-label--hidden\">\n Loading\n </span>\n <LoadingSpinner />\n <LoadingAnnouncement message=\"Loading\" />\n </>\n ) : (\n resolveEmptyState(renderEmptyState)\n )}\n </div>\n )\n : undefined\n }\n >\n {renderChildren()}\n {loadMoreItem}\n </ListBox>\n {loadingState === \"filtering\" && <FilteringAnnouncement />}\n </Popover>\n {description && (\n <Text className=\"tds-field-description\" slot=\"description\">\n <Icon\n aria-hidden\n className=\"tds-field-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {description}\n </Text>\n )}\n </AriaComboBox>\n )\n}\n\nexport interface ComboBoxItemProps {\n /** Disables the item. */\n disabled?: boolean\n}\n\ntype AriaListBoxItemPropsToOmit = \"isDisabled\"\n\ntype AriaListBoxItemPropsToInclude = \"onAction\" | \"textValue\" | \"value\"\n\nexport type ComboBoxItemElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n ListBoxItemProps<T>,\n ComboBoxItemProps,\n AriaListBoxItemPropsToOmit,\n AriaListBoxItemPropsToInclude\n >\n\n/**\n * A selectable option within a {@link ComboBox}. Renders as a listbox item.\n *\n * Provide an `id` (or `key` when rendering from a collection) to identify the\n * option, and `textValue` when the visible children are not plain text so\n * type-ahead and screen readers have a stable label to use.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-combobox--docs | Storybook Documentation}\n */\nexport function ComboBoxItem<T extends object>({\n className,\n disabled,\n ...restProps\n}: ComboBoxItemElementProps<T>) {\n return (\n <ListBoxItem\n {...restProps}\n className={classNames(\"tds-combo-box-list-item\", className)}\n isDisabled={disabled}\n />\n )\n}\n\nexport interface ComboBoxSectionProps {\n /** The items rendered within the section. */\n children: ReactNode\n /** Optional heading text rendered above the section's items. */\n title?: string\n}\n\ntype AriaListBoxSectionPropsToInclude = \"dependencies\"\n\nexport type ComboBoxSectionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n ListBoxSectionProps<T>,\n ComboBoxSectionProps,\n never,\n AriaListBoxSectionPropsToInclude\n >\n\n/**\n * A group of related {@link ComboBoxItem}s within a {@link ComboBox}. Renders\n * an optional `title` heading above its items.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-combobox--docs | Storybook Documentation}\n */\nexport function ComboBoxSection<T extends object>({\n children,\n className,\n title,\n ...restProps\n}: ComboBoxSectionElementProps<T>) {\n return (\n <ListBoxSection\n {...restProps}\n className={classNames(\"tds-combo-box-list-section\", className)}\n >\n {title && (\n <Header className=\"tds-combo-box-section-header\">{title}</Header>\n )}\n {children}\n </ListBoxSection>\n )\n}\n"],"names":["React","AriaComboBox"],"mappings":";;;;;;;;;;;;;;;;;;AA0IA,SAAS,iBAAiB,CAAC,KAAoC,EAAA;AAC7D,IAAA,OAAO,OAAO,KAAK,KAAK,UAAU,GAAG,KAAK,EAAE,GAAG,KAAK;AACtD;AAEA,SAAS,WAAW,GAAA;A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CACG;AAEV,sBAAE,SAAS,EAAA;AAGd,gBAAA,cAAc,EAAE;AAChB,gBAAA,YAAY,CACL;AACT,YAAA,YAAY,KAAK,WAAW,IAAIA,cAAA,CAAA,aAAA,CAAC,qBAAqB,OAAG,CAClD;QACT,WAAW,KACVA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,uBAAuB,EAAC,IAAI,EAAC,aAAa,EAAA;YACxDA,cAAA,CAAA,aAAA,CAAC,IAAI,yBAEH,SAAS,EAAC,oCAAoC,EAC9C,MAAM,EAAC,8BAA8B,EAAA,CACrC;AACD,YAAA,WAAW,CACP,CACR,CACY;AAEnB;AAmBA;;;;;;;;;AASG;AACG,SAAU,YAAY,CAAmB,EAC7C,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACgB,EAAA;IAC5B,QACEA,6BAAC,WAAW,EAAA,EAAA,GACN,SAAS,EACb,SAAS,EAAE,UAAU,CAAC,yBAAyB,EAAE,SAAS,CAAC,EAC3D,UAAU,EAAE,QAAQ,EAAA,CACpB;AAEN;AAmBA;;;;;;AAMG;AACG,SAAU,eAAe,CAAmB,EAChD,QAAQ,EACR,SAAS,EACT,KAAK,EACL,GAAG,SAAS,EACmB,EAAA;AAC/B,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,cAAc,EAAA,EAAA,GACT,SAAS,EACb,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,SAAS,CAAC,EAAA;QAE7D,KAAK,KACJA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,8BAA8B,EAAA,EAAE,KAAK,CAAU,CAClE;QACA,QAAQ,CACM;AAErB;;;;"}
1
+ {"version":3,"file":"ComboBox.js","sources":["../../../src/components/combo-box/ComboBox.tsx"],"sourcesContent":["import \"../button/btn.css\"\nimport \"../field/index.css\"\nimport \"./index.css\"\n\nimport { IconButton } from \"@components/button\"\nimport {\n LOADING_ANNOUNCEMENT_DELAY_MS,\n LoadingAnnouncement,\n} from \"@components/internal/LoadingAnnouncement\"\nimport LoadingSpinner from \"@components/internal/LoadingSpinner\"\nimport Icon from \"@utilities/Icon\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useAnnounce } from \"@utilities/useAnnounce\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, { type ReactNode, useContext, useEffect } from \"react\"\nimport {\n Button,\n Collection,\n ComboBox as AriaComboBox,\n type ComboBoxProps as AriaComboBoxProps,\n ComboBoxStateContext,\n Input,\n type Key,\n Label,\n ListBox,\n ListBoxItem,\n type ListBoxItemProps,\n ListBoxLoadMoreItem,\n type ListBoxProps as AriaListBoxProps,\n ListBoxSection,\n type ListBoxSectionProps,\n Popover,\n Text,\n} from \"react-aria-components/ComboBox\"\nimport { Group } from \"react-aria-components/Group\"\nimport { Header } from \"react-aria-components/Header\"\n\nexport type ComboBoxSize = \"md\" | \"lg\"\n\nexport type ComboBoxLoadingState =\n | \"error\"\n | \"filtering\"\n | \"idle\"\n | \"loading\"\n | \"loadingMore\"\n | \"sorting\"\n\ntype ComboBoxChildren<T extends object> = NonNullable<\n AriaListBoxProps<T>[\"children\"]\n>\n\nexport interface ComboBoxProps<T extends object = object> {\n /**\n * If `true`, keeps typed text that does not match an option. Turn it on when\n * ComboBox is a standalone search and the suggestions are shortcuts. Leave it\n * off in forms, where the value needs to match one of the options.\n */\n allowsCustomValue?: boolean\n /** The contents of the listbox. */\n children: ComboBoxChildren<T>\n /** Helper text displayed below the component. Styled as error text when `invalid` is `true`. */\n description?: ReactNode\n /** Disables the field and trigger button. */\n disabled?: boolean\n /** Custom filter function for determining if an item should appear in the list. */\n filter?: (textValue: string, inputValue: string) => boolean\n /** If `true`, the `label` text is rendered as an `aria-label` instead of a visible label element. */\n hideLabel?: boolean\n /** Whether the input is in an invalid state. */\n invalid?: boolean\n /** Accessible label for the field. */\n label: string\n /**\n * Async loading state for the listbox.\n * - `\"loading\"`: while the collection is empty, replaces the empty state with a spinner.\n * - `\"loadingMore\"`: shows an inline spinner at the bottom of the listbox (use with `onLoadMore`).\n * - `\"filtering\"`: renders as `\"idle\"`, but tells screen reader users \"Loading\" when results are slow to arrive after typing stops.\n * - `\"error\"`: renders as `\"idle\"`, but reads the empty state (`renderEmptyState`) to screen reader users while the collection is empty.\n * - Other values render as `\"idle\"`.\n */\n loadingState?: ComboBoxLoadingState\n /**\n * The interaction that opens the popover.\n * - `\"input\"`: opens when the user enters text in the input.\n * - `\"focus\"`: opens when the user focuses (via click or keyboard) into the input.\n * - `\"manual\"`: opens only via the trigger button or arrow keys.\n * @default \"focus\"\n */\n menuTrigger?: \"focus\" | \"input\" | \"manual\"\n /**\n * Called when the selected value(s) change.\n * Receives `Key[]` when `selectionMode` is `\"multiple\"`, otherwise `Key | null`.\n */\n onChange?: ((value: Key | null) => void) | ((value: Key[]) => void)\n /** Called when the user scrolls near the bottom of the listbox. Pair with `loadingState` for infinite scroll. */\n onLoadMore?: () => void\n /** Placeholder text for the input. */\n placeholder?: string\n /** If `true`, allows the value to be read but not changed. */\n readOnly?: boolean\n /** Content to display when there are no items in the list. Defaults to \"No results\". */\n renderEmptyState?: ReactNode | (() => ReactNode)\n /** If `true`, appends an asterisk at the end of the label text. */\n required?: boolean\n /**\n * If `true`, renders a button after the input that clears its text. Only\n * applies when `menuTrigger` is `\"focus\"`, where no trigger button is rendered.\n */\n showClearButton?: boolean\n /** If `true`, renders a search icon before the input. */\n showSearchIcon?: boolean\n /** The size of the combo box. */\n size?: ComboBoxSize\n}\n\ntype AriaComboBoxPropsToOmit = \"slot\"\n\ntype AriaComboBoxPropsToInclude =\n | \"allowsEmptyCollection\"\n | \"defaultItems\"\n | \"defaultValue\"\n | \"disabledKeys\"\n | \"inputValue\"\n | \"items\"\n | \"name\"\n | \"onInputChange\"\n | \"selectionMode\"\n | \"value\"\n\nexport type ComboBoxElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n AriaComboBoxProps<T, \"single\" | \"multiple\">,\n ComboBoxProps<T>,\n AriaComboBoxPropsToOmit,\n AriaComboBoxPropsToInclude\n >\n\nfunction resolveEmptyState(value: ReactNode | (() => ReactNode)): ReactNode {\n return typeof value === \"function\" ? value() : value\n}\n\nfunction ClearButton() {\n const state = useContext(ComboBoxStateContext)\n\n return (\n <IconButton\n aria-label=\"Clear\"\n className=\"tds-combo-box-clear-button\"\n data-input-empty={!state?.inputValue ? true : undefined}\n icon={\n <Icon\n aria-hidden\n className=\"tds-combo-box-clear-icon\"\n symbol=\"general#x\"\n />\n }\n kind=\"neutral-inline\"\n onClick={() => state?.setInputValue(\"\")}\n onMouseDown={(event) => event.preventDefault()}\n tabIndex={-1}\n />\n )\n}\n\n/**\n * In multiple selection mode, Tab closes the list without changing the\n * selection. React Aria would otherwise toggle the focused option, which\n * removes a value when the list opened with a selected option focused.\n */\nfunction ComboBoxInput(props: React.ComponentProps<typeof Input>) {\n const state = useContext(ComboBoxStateContext)\n\n return (\n <Input\n {...props}\n onKeyDownCapture={(event) => {\n if (\n event.key === \"Tab\" &&\n state?.isOpen &&\n state.selectionManager.selectionMode === \"multiple\"\n ) {\n state.selectionManager.setFocusedKey(null)\n }\n }}\n />\n )\n}\n\nfunction ErrorAnnouncement({ labelledBy }: { labelledBy: string }) {\n const announce = useAnnounce()\n const inputValue = useContext(ComboBoxStateContext)?.inputValue\n\n useEffect(() => {\n const timeout = setTimeout(\n () => announce({ \"aria-labelledby\": labelledBy }),\n LOADING_ANNOUNCEMENT_DELAY_MS\n )\n return () => clearTimeout(timeout)\n }, [announce, inputValue, labelledBy])\n\n return null\n}\n\nfunction FilteringAnnouncement() {\n const state = useContext(ComboBoxStateContext)\n if (!state?.isOpen) return null\n\n return <LoadingAnnouncement key={state.inputValue} message=\"Loading\" />\n}\n\n/**\n * A combo box combines a text input with a filterable popover\n * listbox, allowing users to type to search and select from a list of options.\n *\n * It supports both single and multiple selection (`selectionMode`), custom filtering,\n * and asynchronous data loading with infinite scroll capabilities (`loadingState` and `onLoadMore`).\n * Collections can be either static or dynamic, managed via the `children`, `items`,\n * or `defaultItems` props. To construct the dropdown list, compose this component\n * with `ComboBoxItem` for individual options and `ComboBoxSection` for grouping.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-combobox--docs | Storybook Documentation}\n */\nexport function ComboBox<T extends object>({\n allowsEmptyCollection = true,\n children,\n className,\n description,\n disabled,\n filter,\n hideLabel,\n invalid,\n label,\n loadingState,\n menuTrigger = \"focus\",\n onChange,\n onLoadMore,\n placeholder,\n readOnly,\n renderEmptyState = \"No results\",\n required,\n showClearButton,\n showSearchIcon,\n size = \"md\",\n ...restProps\n}: ComboBoxElementProps<T>) {\n const emptyStateId = `tds-combo-box-empty-state-${useId()}`\n const combinedClassName = classNames(\n \"tds-field tds-combo-box\",\n {\n \"tds-combo-box--lg\": size === \"lg\",\n \"tds-field--lg\": size === \"lg\",\n },\n className\n )\n\n const loadMoreItem = onLoadMore && (\n <ListBoxLoadMoreItem\n className=\"tds-combo-box-load-more\"\n isLoading={loadingState === \"loadingMore\"}\n onLoadMore={onLoadMore}\n >\n <span className=\"tds-combo-box-loading-label--hidden\">Loading more</span>\n <LoadingSpinner />\n <LoadingAnnouncement message=\"Loading more\" />\n </ListBoxLoadMoreItem>\n )\n\n const renderChildren = () => {\n if (typeof children === \"function\") {\n return (\n <Collection items={restProps.items ?? restProps.defaultItems}>\n {children}\n </Collection>\n )\n }\n return children\n }\n\n return (\n // React Aria's ComboBox is generic over selection mode (M). We instantiate\n // it with the union \"single\" | \"multiple\" so value/defaultValue/selectionMode\n // accept both shapes. onChange still needs a cast because our type is a union\n // of function types (to allow narrower handlers like\n // `setValue: (Key|null) => void`), which isn't assignable to RAC's\n // single-function signature.\n <AriaComboBox<T, \"single\" | \"multiple\">\n {...restProps}\n allowsEmptyCollection={allowsEmptyCollection}\n aria-label={hideLabel ? label : undefined}\n className={combinedClassName}\n defaultFilter={filter}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isRequired={required}\n menuTrigger={menuTrigger}\n onChange={onChange as (value: Key | Key[] | null) => void}\n >\n {!hideLabel && <Label className=\"tds-field-label\">{label}</Label>}\n <Group className=\"tds-field-control tds-combo-box-field\">\n {showSearchIcon && (\n <Icon\n aria-hidden\n className=\"tds-combo-box-search-icon\"\n symbol=\"general#search\"\n />\n )}\n <ComboBoxInput\n aria-invalid={invalid || undefined}\n className=\"tds-combo-box-input\"\n placeholder={placeholder}\n />\n {menuTrigger !== \"focus\" && !readOnly && (\n <Button className=\"tds-combo-box-button tds-btn tds-btn--infield\">\n <Icon aria-hidden symbol=\"general#down-caret\" />\n </Button>\n )}\n {showClearButton &&\n menuTrigger === \"focus\" &&\n !readOnly &&\n !disabled && <ClearButton />}\n </Group>\n <Popover className=\"tds-combo-box-popover\">\n <ListBox\n className=\"tds-combo-box-list\"\n renderEmptyState={\n allowsEmptyCollection\n ? () => (\n <div className=\"tds-combo-box-empty-state\" id={emptyStateId}>\n {loadingState === \"error\" && (\n <ErrorAnnouncement labelledBy={emptyStateId} />\n )}\n {loadingState === \"loading\" ? (\n <>\n <span className=\"tds-combo-box-loading-label--hidden\">\n Loading\n </span>\n <LoadingSpinner />\n <LoadingAnnouncement message=\"Loading\" />\n </>\n ) : (\n resolveEmptyState(renderEmptyState)\n )}\n </div>\n )\n : undefined\n }\n >\n {renderChildren()}\n {loadMoreItem}\n </ListBox>\n {loadingState === \"filtering\" && <FilteringAnnouncement />}\n </Popover>\n {description && (\n <Text className=\"tds-field-description\" slot=\"description\">\n <Icon\n aria-hidden\n className=\"tds-field-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {description}\n </Text>\n )}\n </AriaComboBox>\n )\n}\n\nexport interface ComboBoxItemProps {\n /** Disables the item. */\n disabled?: boolean\n}\n\ntype AriaListBoxItemPropsToOmit = \"isDisabled\"\n\ntype AriaListBoxItemPropsToInclude = \"onAction\" | \"textValue\" | \"value\"\n\nexport type ComboBoxItemElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n ListBoxItemProps<T>,\n ComboBoxItemProps,\n AriaListBoxItemPropsToOmit,\n AriaListBoxItemPropsToInclude\n >\n\n/**\n * A selectable option within a {@link ComboBox}. Renders as a listbox item.\n *\n * Provide an `id` (or `key` when rendering from a collection) to identify the\n * option, and `textValue` when the visible children are not plain text so\n * type-ahead and screen readers have a stable label to use.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-combobox--docs | Storybook Documentation}\n */\nexport function ComboBoxItem<T extends object>({\n className,\n disabled,\n ...restProps\n}: ComboBoxItemElementProps<T>) {\n return (\n <ListBoxItem\n {...restProps}\n className={classNames(\"tds-combo-box-list-item\", className)}\n isDisabled={disabled}\n />\n )\n}\n\nexport interface ComboBoxSectionProps {\n /** The items rendered within the section. */\n children: ReactNode\n /** Optional heading text rendered above the section's items. */\n title?: string\n}\n\ntype AriaListBoxSectionPropsToInclude = \"dependencies\"\n\nexport type ComboBoxSectionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n ListBoxSectionProps<T>,\n ComboBoxSectionProps,\n never,\n AriaListBoxSectionPropsToInclude\n >\n\n/**\n * A group of related {@link ComboBoxItem}s within a {@link ComboBox}. Renders\n * an optional `title` heading above its items.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-combobox--docs | Storybook Documentation}\n */\nexport function ComboBoxSection<T extends object>({\n children,\n className,\n title,\n ...restProps\n}: ComboBoxSectionElementProps<T>) {\n const hasTitle =\n typeof title === \"string\"\n ? title.trim() !== \"\"\n : Boolean(title) || title === 0\n\n return (\n <ListBoxSection\n {...restProps}\n className={classNames(\"tds-combo-box-list-section\", className)}\n >\n {hasTitle && (\n <Header className=\"tds-combo-box-section-header\">{title}</Header>\n )}\n {children}\n </ListBoxSection>\n )\n}\n"],"names":["React","AriaComboBox"],"mappings":";;;;;;;;;;;;;;;;;;AA0IA,SAAS,iBAAiB,CAAC,KAAoC,EAAA;A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B,EAAA,EAAE,KAAK,CAAU,CAClE;QACA,QAAQ,CACM;AAErB;;;;"}
@@ -150,7 +150,7 @@ export type DropdownLinkElementProps<T extends object = object> = CombineAriaPro
150
150
  *
151
151
  * @component
152
152
  */
153
- export declare function DropdownLink<T extends object>({ asChild, children, className, destructive, external, staffOnly, ...restProps }: DropdownLinkElementProps<T>): React.JSX.Element;
153
+ export declare function DropdownLink<T extends object>({ asChild, children, className, destructive, external, staffOnly, ...restProps }: DropdownLinkElementProps<T>): React.JSX.Element | null;
154
154
  export interface DropdownSectionProps {
155
155
  /** The items rendered within the section. */
156
156
  children: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,KAAK,EAAE,EAEZ,KAAK,YAAY,EACjB,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EACV,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,YAAY,EACb,MAAM,uBAAuB,CAAA;AAgB9B,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;AAEtE,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAA;AAEhD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,oBAAoB,qBAO3E;AAED,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,C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C,CAAC,SAAS,MAAM,EAAE,EAC7C,OAAe,EACf,QAAQ,EACR,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,GAAG,SAAS,EACb,EAAE,wBAAwB,CAAC,CAAC,CAAC,4BA+B7B;AAED,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,QAAQ,EAAE,SAAS,CAAA;IACnB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAC/D,+BAA+B,CAC7B,gBAAgB,CAAC,CAAC,CAAC,EACnB,oBAAoB,EACpB,OAAO,EACP,KAAK,CACN,CAAA;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,EAChD,QAAQ,EACR,SAAS,EACT,KAAK,EACL,GAAG,SAAS,EACb,EAAE,2BAA2B,CAAC,CAAC,CAAC,qBAUhC;AAED,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEjE;;;;;GAKG;AACH,wBAAgB,iBAAiB,sBAEhC"}
@@ -1,6 +1,6 @@
1
1
  import { Slot } from '@radix-ui/react-slot';
2
2
  import classNames from 'classnames';
3
- import React__default, { useRef, useContext, useState, useEffect } from 'react';
3
+ import React__default, { isValidElement, useRef, useContext, useState, useEffect } from 'react';
4
4
  import { useInteractOutside, usePreventScroll, FocusScope } from 'react-aria';
5
5
  import { MenuTrigger, MenuItem, RootMenuTriggerStateContext, Popover, Menu, MenuSection, Header, Separator, Pressable } from 'react-aria-components/Menu';
6
6
  import { PopoverContext } from 'react-aria-components/Popover';
@@ -117,6 +117,8 @@ function omitUndefinedValues(props) {
117
117
  * @component
118
118
  */
119
119
  function DropdownLink({ asChild = false, children, className, destructive, external, staffOnly, ...restProps }) {
120
+ if (asChild && !isValidElement(children))
121
+ return null;
120
122
  const externalProps = external
121
123
  ? { rel: "noreferrer noopener", target: "_blank" }
122
124
  : null;
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sources":["../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { Slot } from \"@radix-ui/react-slot\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport classNames from \"classnames\"\nimport React, {\n type ComponentProps,\n type ReactElement,\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport { FocusScope, useInteractOutside, usePreventScroll } from \"react-aria\"\nimport type {\n Key,\n MenuItemProps,\n MenuSectionProps,\n PopoverProps,\n} from \"react-aria-components\"\nimport {\n Header,\n Menu,\n MenuItem,\n MenuSection,\n MenuTrigger,\n Popover,\n Pressable,\n RootMenuTriggerStateContext,\n Separator,\n} from \"react-aria-components/Menu\"\nimport { PopoverContext } from \"react-aria-components/Popover\"\n\nimport { DropdownTriggerContext } from \"./DropdownTriggerContext\"\n\nexport type DropdownPlacement = NonNullable<PopoverProps[\"placement\"]>\n\nexport interface DropdownProps {\n /**\n * A `<DropdownTrigger>` followed by a `<DropdownMenu>` containing the items.\n */\n children: ReactNode\n /** Fires when the menu closes. */\n onClose?: () => void\n /** Fires when the menu opens. Useful for analytics or lazy data prep. */\n onOpen?: () => void\n}\n\nexport type DropdownElementProps = DropdownProps\n\n/**\n * An action menu — a button that, when activated, reveals a list of actions or\n * navigation links. Composed of a `<DropdownTrigger>` wrapping a Tapestry\n * dropdown-trigger button (`DropdownButton`, `DropdownIconButton`, or\n * `PageHeaderActionsDropdownButton`) and a `<DropdownMenu>` containing\n * `<DropdownAction>`, `<DropdownLink>`, `<DropdownSection>`, and\n * `<DropdownSeparator>` items.\n *\n * Built on React Aria's `MenuTrigger` primitive; popover positioning and menu\n * identity live on `<DropdownMenu>`.\n *\n * @component\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/menu/ | W3C APG Menu Pattern}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function Dropdown({ children, onClose, onOpen }: DropdownElementProps) {\n const handleOpenChange = (isOpen: boolean) => {\n if (isOpen) onOpen?.()\n else onClose?.()\n }\n\n return <MenuTrigger onOpenChange={handleOpenChange}>{children}</MenuTrigger>\n}\n\nexport interface DropdownMenuProps {\n /** Arbitrary `data-*` attributes are forwarded to the menu element. */\n [key: `data-${string}`]: boolean | number | string | undefined\n /**\n * `<DropdownAction>` / `<DropdownLink>` / `<DropdownSection>` /\n * `<DropdownSeparator>` elements.\n */\n children: ReactNode\n /** Override for the underlying `<Menu>` element id. */\n id?: string\n /**\n * Popover position relative to the trigger. Uses React Aria's\n * space-separated format (e.g., `\"bottom start\"`, `\"top end\"`,\n * `\"left top\"`). Defaults to `\"bottom start\"`.\n */\n placement?: DropdownPlacement\n}\n\nexport type DropdownMenuElementProps = DropdownMenuProps\n\nfunction useMenuTriggerRef() {\n const popoverContext = useContext(PopoverContext)\n return popoverContext && \"triggerRef\" in popoverContext\n ? popoverContext.triggerRef\n : undefined\n}\n\nfunction isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType,\n}: {\n event: PointerEvent\n menuTriggerRef: RefObject<Element | null> | undefined\n pointerType: string | null\n}) {\n const isTouch = pointerType === \"touch\"\n const isOnMenuTrigger =\n event.target instanceof Node &&\n Boolean(menuTriggerRef?.current?.contains(event.target))\n return isTouch && isOnMenuTrigger\n}\n\n/**\n * The popover surface for a `<Dropdown>`. Wraps React Aria's `<Popover>` and\n * `<Menu>` and contains the menu items.\n *\n * @component\n */\nexport function DropdownMenu({\n children,\n id,\n placement = \"bottom start\",\n ...dataAttributes\n}: DropdownMenuElementProps) {\n const popoverRef = useRef<HTMLElement>(null)\n const state = useContext(RootMenuTriggerStateContext)\n const menuTriggerRef = useMenuTriggerRef()\n const lastPointerType = useRef<string | null>(null)\n // Release focus containment once a press starts outside the menu, so focus\n // can land on whatever was pressed instead of being pulled back into the menu.\n const [isPointerDownOutside, setIsPointerDownOutside] = useState(false)\n\n useEffect(() => {\n if (!state?.isOpen) setIsPointerDownOutside(false)\n }, [state?.isOpen])\n\n useInteractOutside({\n isDisabled: !state?.isOpen,\n onInteractOutside: (event) => {\n const triggerWillToggleClosed = isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType: lastPointerType.current,\n })\n if (triggerWillToggleClosed) return\n\n state?.close()\n },\n onInteractOutsideStart: (event) => {\n lastPointerType.current = event.pointerType\n setIsPointerDownOutside(true)\n },\n ref: popoverRef,\n })\n usePreventScroll({ isDisabled: !state?.isOpen })\n\n return (\n <Popover\n className=\"tds-dropdown-popover\"\n isNonModal\n placement={placement}\n ref={popoverRef}\n shouldCloseOnInteractOutside={() => false}\n >\n <FocusScope contain={!isPointerDownOutside}>\n <Menu {...dataAttributes} id={id}>\n {children}\n </Menu>\n </FocusScope>\n </Popover>\n )\n}\n\nexport interface DropdownTriggerProps {\n /**\n * A single Tapestry dropdown-trigger button element (`DropdownButton`,\n * `DropdownIconButton`, or `PageHeaderActionsDropdownButton`).\n */\n children: ReactElement\n /**\n * Whether the trigger is disabled. This is the single source of truth for the\n * trigger's disabled state — a `disabled` set directly on the child button\n * does not win.\n */\n disabled?: boolean\n}\n\n/**\n * Wraps a single Tapestry dropdown-trigger button and bridges it to React\n * Aria's `MenuTrigger` via `<Pressable>`.\n * Uses context to pass `disabled` to the trigger button.\n *\n * @component\n */\ntype PressableChild = ComponentProps<typeof Pressable>[\"children\"]\n\nexport function DropdownTrigger({ children, disabled }: DropdownTriggerProps) {\n return (\n <DropdownTriggerContext.Provider value={{ disabled }}>\n <Pressable isDisabled={disabled}>{children as PressableChild}</Pressable>\n </DropdownTriggerContext.Provider>\n )\n}\n\nexport interface DropdownItemBaseProps {\n /** Applies destructive styling. */\n destructive?: boolean\n /** Applies staff-only visual treatment. */\n staffOnly?: boolean\n}\n\nexport interface DropdownActionProps extends DropdownItemBaseProps {\n /**\n * Disables the item. Renamed to React Aria's `isDisabled` inside the\n * wrapper. Disabled items are skipped by keyboard traversal and won't fire\n * `onAction`.\n */\n disabled?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n /**\n * Callback fired when the item is activated.\n *\n * React Aria closes the menu and returns focus to the trigger after this\n * runs, which can override a focus change made here — e.g. focusing a\n * nearby input. If `onAction` needs to move focus elsewhere, wrap that\n * part in `queueMicrotask` to defer it until after React Aria's\n * focus-restore has finished: `queueMicrotask(() => inputRef.current?.focus())`.\n */\n onAction: () => void\n /** Whether activating the item closes the menu. Defaults to `true`. */\n shouldCloseOnSelect?: boolean\n}\n\ntype AriaActionPropsToOmit =\n | \"href\"\n | \"isDisabled\"\n | \"rel\"\n | \"routerOptions\"\n | \"target\"\n | \"value\"\ntype AriaActionPropsToInclude = \"textValue\"\n\nexport type DropdownActionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownActionProps,\n AriaActionPropsToOmit,\n AriaActionPropsToInclude\n >\n\n/**\n * A `<Dropdown>` item that fires a callback when activated. Renders an RA\n * `<MenuItem>` (`role=\"menuitem\"`). Children are passed through and can use\n * the slot convention (`slot=\"label\" | \"prefix\" | \"suffix\" | \"description\"`)\n * for structured content.\n *\n * @component\n */\nexport function DropdownAction<T extends object>({\n className,\n destructive,\n disabled,\n staffOnly,\n ...restProps\n}: DropdownActionElementProps<T>) {\n return (\n <MenuItem\n {...restProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n isDisabled={disabled}\n />\n )\n}\n\nexport interface DropdownLinkBaseProps extends DropdownItemBaseProps {\n /** If `true`, sets `target=\"_blank\"` and `rel=\"noreferrer noopener\"`. */\n external?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n}\n\nexport interface DropdownLinkAsChildProps extends DropdownLinkBaseProps {\n /**\n * Merge menu item behavior onto a single child element (e.g. a router\n * `Link`) instead of rendering an `<a>`. When true, `href` must not be set.\n * **Not supported in Rails.**\n */\n asChild: true\n href?: never\n}\n\nexport interface DropdownLinkHrefProps extends DropdownLinkBaseProps {\n asChild?: false\n /** Destination URL. */\n href: string\n}\n\nexport type DropdownLinkProps = DropdownLinkAsChildProps | DropdownLinkHrefProps\n\ntype AriaLinkPropsToOmit =\n | \"isDisabled\"\n | \"onAction\"\n | \"rel\"\n | \"render\"\n | \"target\"\n | \"value\"\ntype AriaLinkPropsToInclude = \"routerOptions\" | \"textValue\"\n\nexport type DropdownLinkElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownLinkProps,\n AriaLinkPropsToOmit,\n AriaLinkPropsToInclude\n >\n\n/** Strips RAC-injected `undefined` values (e.g. `href`) that would otherwise clobber a child's own prop of the same name via `Slot`. */\nfunction omitUndefinedValues<T extends object>(props: T): Partial<T> {\n return Object.fromEntries(\n Object.entries(props).filter(([, value]) => value !== undefined)\n ) as Partial<T>\n}\n\n/**\n * A `<Dropdown>` item that navigates to a URL. Renders an RA `<MenuItem>` as\n * an anchor (`<a role=\"menuitem\" href=\"…\">`). Pass `external` to open in a\n * new tab with `rel=\"noreferrer noopener\"`.\n *\n * `disabled` is intentionally not accepted — HTML has no native disabled state\n * for anchors, and a \"disabled link\" has no accessible analog. If a link\n * shouldn't be activatable, omit it.\n *\n * @component\n */\nexport function DropdownLink<T extends object>({\n asChild = false,\n children,\n className,\n destructive,\n external,\n staffOnly,\n ...restProps\n}: DropdownLinkElementProps<T>) {\n const externalProps = external\n ? { rel: \"noreferrer noopener\", target: \"_blank\" as const }\n : null\n return (\n <MenuItem\n {...restProps}\n {...externalProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n render={\n asChild\n ? (props) => (\n <Slot {...omitUndefinedValues(props)}>\n {children as ReactElement}\n </Slot>\n )\n : undefined\n }\n >\n {asChild ? undefined : children}\n </MenuItem>\n )\n}\n\nexport interface DropdownSectionProps {\n /** The items rendered within the section. */\n children: ReactNode\n /**\n * Heading rendered above the section's items. Required — RA renders the\n * section as `role=\"group\"` and the heading provides the group's\n * accessible name via `aria-labelledby`.\n */\n title: string\n}\n\nexport type DropdownSectionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuSectionProps<T>,\n DropdownSectionProps,\n \"value\",\n never\n >\n\n/**\n * A grouped section within a `<Dropdown>`. Renders an RA `<MenuSection>`\n * (`role=\"group\"`) with an optional `<Header>` heading when `title` is set.\n *\n * @component\n */\nexport function DropdownSection<T extends object>({\n children,\n className,\n title,\n ...restProps\n}: DropdownSectionElementProps<T>) {\n return (\n <MenuSection\n {...restProps}\n className={classNames(\"tds-dropdown-section\", className)}\n >\n <Header className=\"tds-dropdown-section-label\">{title}</Header>\n {children}\n </MenuSection>\n )\n}\n\nexport type DropdownSeparatorElementProps = Record<string, never>\n\n/**\n * A divider between items in a `<Dropdown>`. Renders an RA `<Separator>`\n * (`role=\"separator\"`).\n *\n * @component\n */\nexport function DropdownSeparator() {\n return <Separator className=\"tds-dropdown-separator\" />\n}\n"],"names":["React"],"mappings":";;;;;;;;AAoDA;;;;;;;;;;;;;;AAcG;AACG,SAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAwB,EAAA;AAC1E,IAAA,MAAM,gBAAgB,GAAG,CAAC,MAAe,KAAI;AAC3C,QAAA,IAAI,MAAM;YAAE,MAAM,IAAI;;YACjB,OAAO,IAAI;AAClB,IAAA,CAAC;IAED,OAAOA,cAAA,CAAA,aAAA,CAAC,WAAW,EAAA,EAAC,YAAY,EAAE,gBAAgB,EAAA,EAAG,QAAQ,CAAe;AAC9E;AAsBA,SAAS,iBAAiB,GAAA;AACxB,IAAA,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;A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QAAAA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,4BAA4B,EAAA,EAAE,KAAK,CAAU;QAC9D,QAAQ,CACG;AAElB;AAIA;;;;;AAKG;SACa,iBAAiB,GAAA;AAC/B,IAAA,OAAOA,6BAAC,SAAS,EAAA,EAAC,SAAS,EAAC,wBAAwB,GAAG;AACzD;;;;"}
1
+ {"version":3,"file":"Dropdown.js","sources":["../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { Slot } from \"@radix-ui/react-slot\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport classNames from \"classnames\"\nimport React, {\n type ComponentProps,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport { FocusScope, useInteractOutside, usePreventScroll } from \"react-aria\"\nimport type {\n Key,\n MenuItemProps,\n MenuSectionProps,\n PopoverProps,\n} from \"react-aria-components\"\nimport {\n Header,\n Menu,\n MenuItem,\n MenuSection,\n MenuTrigger,\n Popover,\n Pressable,\n RootMenuTriggerStateContext,\n Separator,\n} from \"react-aria-components/Menu\"\nimport { PopoverContext } from \"react-aria-components/Popover\"\n\nimport { DropdownTriggerContext } from \"./DropdownTriggerContext\"\n\nexport type DropdownPlacement = NonNullable<PopoverProps[\"placement\"]>\n\nexport interface DropdownProps {\n /**\n * A `<DropdownTrigger>` followed by a `<DropdownMenu>` containing the items.\n */\n children: ReactNode\n /** Fires when the menu closes. */\n onClose?: () => void\n /** Fires when the menu opens. Useful for analytics or lazy data prep. */\n onOpen?: () => void\n}\n\nexport type DropdownElementProps = DropdownProps\n\n/**\n * An action menu — a button that, when activated, reveals a list of actions or\n * navigation links. Composed of a `<DropdownTrigger>` wrapping a Tapestry\n * dropdown-trigger button (`DropdownButton`, `DropdownIconButton`, or\n * `PageHeaderActionsDropdownButton`) and a `<DropdownMenu>` containing\n * `<DropdownAction>`, `<DropdownLink>`, `<DropdownSection>`, and\n * `<DropdownSeparator>` items.\n *\n * Built on React Aria's `MenuTrigger` primitive; popover positioning and menu\n * identity live on `<DropdownMenu>`.\n *\n * @component\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/menu/ | W3C APG Menu Pattern}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function Dropdown({ children, onClose, onOpen }: DropdownElementProps) {\n const handleOpenChange = (isOpen: boolean) => {\n if (isOpen) onOpen?.()\n else onClose?.()\n }\n\n return <MenuTrigger onOpenChange={handleOpenChange}>{children}</MenuTrigger>\n}\n\nexport interface DropdownMenuProps {\n /** Arbitrary `data-*` attributes are forwarded to the menu element. */\n [key: `data-${string}`]: boolean | number | string | undefined\n /**\n * `<DropdownAction>` / `<DropdownLink>` / `<DropdownSection>` /\n * `<DropdownSeparator>` elements.\n */\n children: ReactNode\n /** Override for the underlying `<Menu>` element id. */\n id?: string\n /**\n * Popover position relative to the trigger. Uses React Aria's\n * space-separated format (e.g., `\"bottom start\"`, `\"top end\"`,\n * `\"left top\"`). Defaults to `\"bottom start\"`.\n */\n placement?: DropdownPlacement\n}\n\nexport type DropdownMenuElementProps = DropdownMenuProps\n\nfunction useMenuTriggerRef() {\n const popoverContext = useContext(PopoverContext)\n return popoverContext && \"triggerRef\" in popoverContext\n ? popoverContext.triggerRef\n : undefined\n}\n\nfunction isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType,\n}: {\n event: PointerEvent\n menuTriggerRef: RefObject<Element | null> | undefined\n pointerType: string | null\n}) {\n const isTouch = pointerType === \"touch\"\n const isOnMenuTrigger =\n event.target instanceof Node &&\n Boolean(menuTriggerRef?.current?.contains(event.target))\n return isTouch && isOnMenuTrigger\n}\n\n/**\n * The popover surface for a `<Dropdown>`. Wraps React Aria's `<Popover>` and\n * `<Menu>` and contains the menu items.\n *\n * @component\n */\nexport function DropdownMenu({\n children,\n id,\n placement = \"bottom start\",\n ...dataAttributes\n}: DropdownMenuElementProps) {\n const popoverRef = useRef<HTMLElement>(null)\n const state = useContext(RootMenuTriggerStateContext)\n const menuTriggerRef = useMenuTriggerRef()\n const lastPointerType = useRef<string | null>(null)\n // Release focus containment once a press starts outside the menu, so focus\n // can land on whatever was pressed instead of being pulled back into the menu.\n const [isPointerDownOutside, setIsPointerDownOutside] = useState(false)\n\n useEffect(() => {\n if (!state?.isOpen) setIsPointerDownOutside(false)\n }, [state?.isOpen])\n\n useInteractOutside({\n isDisabled: !state?.isOpen,\n onInteractOutside: (event) => {\n const triggerWillToggleClosed = isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType: lastPointerType.current,\n })\n if (triggerWillToggleClosed) return\n\n state?.close()\n },\n onInteractOutsideStart: (event) => {\n lastPointerType.current = event.pointerType\n setIsPointerDownOutside(true)\n },\n ref: popoverRef,\n })\n usePreventScroll({ isDisabled: !state?.isOpen })\n\n return (\n <Popover\n className=\"tds-dropdown-popover\"\n isNonModal\n placement={placement}\n ref={popoverRef}\n shouldCloseOnInteractOutside={() => false}\n >\n <FocusScope contain={!isPointerDownOutside}>\n <Menu {...dataAttributes} id={id}>\n {children}\n </Menu>\n </FocusScope>\n </Popover>\n )\n}\n\nexport interface DropdownTriggerProps {\n /**\n * A single Tapestry dropdown-trigger button element (`DropdownButton`,\n * `DropdownIconButton`, or `PageHeaderActionsDropdownButton`).\n */\n children: ReactElement\n /**\n * Whether the trigger is disabled. This is the single source of truth for the\n * trigger's disabled state — a `disabled` set directly on the child button\n * does not win.\n */\n disabled?: boolean\n}\n\n/**\n * Wraps a single Tapestry dropdown-trigger button and bridges it to React\n * Aria's `MenuTrigger` via `<Pressable>`.\n * Uses context to pass `disabled` to the trigger button.\n *\n * @component\n */\ntype PressableChild = ComponentProps<typeof Pressable>[\"children\"]\n\nexport function DropdownTrigger({ children, disabled }: DropdownTriggerProps) {\n return (\n <DropdownTriggerContext.Provider value={{ disabled }}>\n <Pressable isDisabled={disabled}>{children as PressableChild}</Pressable>\n </DropdownTriggerContext.Provider>\n )\n}\n\nexport interface DropdownItemBaseProps {\n /** Applies destructive styling. */\n destructive?: boolean\n /** Applies staff-only visual treatment. */\n staffOnly?: boolean\n}\n\nexport interface DropdownActionProps extends DropdownItemBaseProps {\n /**\n * Disables the item. Renamed to React Aria's `isDisabled` inside the\n * wrapper. Disabled items are skipped by keyboard traversal and won't fire\n * `onAction`.\n */\n disabled?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n /**\n * Callback fired when the item is activated.\n *\n * React Aria closes the menu and returns focus to the trigger after this\n * runs, which can override a focus change made here — e.g. focusing a\n * nearby input. If `onAction` needs to move focus elsewhere, wrap that\n * part in `queueMicrotask` to defer it until after React Aria's\n * focus-restore has finished: `queueMicrotask(() => inputRef.current?.focus())`.\n */\n onAction: () => void\n /** Whether activating the item closes the menu. Defaults to `true`. */\n shouldCloseOnSelect?: boolean\n}\n\ntype AriaActionPropsToOmit =\n | \"href\"\n | \"isDisabled\"\n | \"rel\"\n | \"routerOptions\"\n | \"target\"\n | \"value\"\ntype AriaActionPropsToInclude = \"textValue\"\n\nexport type DropdownActionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownActionProps,\n AriaActionPropsToOmit,\n AriaActionPropsToInclude\n >\n\n/**\n * A `<Dropdown>` item that fires a callback when activated. Renders an RA\n * `<MenuItem>` (`role=\"menuitem\"`). Children are passed through and can use\n * the slot convention (`slot=\"label\" | \"prefix\" | \"suffix\" | \"description\"`)\n * for structured content.\n *\n * @component\n */\nexport function DropdownAction<T extends object>({\n className,\n destructive,\n disabled,\n staffOnly,\n ...restProps\n}: DropdownActionElementProps<T>) {\n return (\n <MenuItem\n {...restProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n isDisabled={disabled}\n />\n )\n}\n\nexport interface DropdownLinkBaseProps extends DropdownItemBaseProps {\n /** If `true`, sets `target=\"_blank\"` and `rel=\"noreferrer noopener\"`. */\n external?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n}\n\nexport interface DropdownLinkAsChildProps extends DropdownLinkBaseProps {\n /**\n * Merge menu item behavior onto a single child element (e.g. a router\n * `Link`) instead of rendering an `<a>`. When true, `href` must not be set.\n * **Not supported in Rails.**\n */\n asChild: true\n href?: never\n}\n\nexport interface DropdownLinkHrefProps extends DropdownLinkBaseProps {\n asChild?: false\n /** Destination URL. */\n href: string\n}\n\nexport type DropdownLinkProps = DropdownLinkAsChildProps | DropdownLinkHrefProps\n\ntype AriaLinkPropsToOmit =\n | \"isDisabled\"\n | \"onAction\"\n | \"rel\"\n | \"render\"\n | \"target\"\n | \"value\"\ntype AriaLinkPropsToInclude = \"routerOptions\" | \"textValue\"\n\nexport type DropdownLinkElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownLinkProps,\n AriaLinkPropsToOmit,\n AriaLinkPropsToInclude\n >\n\n/** Strips RAC-injected `undefined` values (e.g. `href`) that would otherwise clobber a child's own prop of the same name via `Slot`. */\nfunction omitUndefinedValues<T extends object>(props: T): Partial<T> {\n return Object.fromEntries(\n Object.entries(props).filter(([, value]) => value !== undefined)\n ) as Partial<T>\n}\n\n/**\n * A `<Dropdown>` item that navigates to a URL. Renders an RA `<MenuItem>` as\n * an anchor (`<a role=\"menuitem\" href=\"…\">`). Pass `external` to open in a\n * new tab with `rel=\"noreferrer noopener\"`.\n *\n * `disabled` is intentionally not accepted — HTML has no native disabled state\n * for anchors, and a \"disabled link\" has no accessible analog. If a link\n * shouldn't be activatable, omit it.\n *\n * @component\n */\nexport function DropdownLink<T extends object>({\n asChild = false,\n children,\n className,\n destructive,\n external,\n staffOnly,\n ...restProps\n}: DropdownLinkElementProps<T>) {\n if (asChild && !isValidElement(children)) return null\n\n const externalProps = external\n ? { rel: \"noreferrer noopener\", target: \"_blank\" as const }\n : null\n return (\n <MenuItem\n {...restProps}\n {...externalProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n render={\n asChild\n ? (props) => (\n <Slot {...omitUndefinedValues(props)}>\n {children as ReactElement}\n </Slot>\n )\n : undefined\n }\n >\n {asChild ? undefined : children}\n </MenuItem>\n )\n}\n\nexport interface DropdownSectionProps {\n /** The items rendered within the section. */\n children: ReactNode\n /**\n * Heading rendered above the section's items. Required — RA renders the\n * section as `role=\"group\"` and the heading provides the group's\n * accessible name via `aria-labelledby`.\n */\n title: string\n}\n\nexport type DropdownSectionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuSectionProps<T>,\n DropdownSectionProps,\n \"value\",\n never\n >\n\n/**\n * A grouped section within a `<Dropdown>`. Renders an RA `<MenuSection>`\n * (`role=\"group\"`) with an optional `<Header>` heading when `title` is set.\n *\n * @component\n */\nexport function DropdownSection<T extends object>({\n children,\n className,\n title,\n ...restProps\n}: DropdownSectionElementProps<T>) {\n return (\n <MenuSection\n {...restProps}\n className={classNames(\"tds-dropdown-section\", className)}\n >\n <Header className=\"tds-dropdown-section-label\">{title}</Header>\n {children}\n </MenuSection>\n )\n}\n\nexport type DropdownSeparatorElementProps = Record<string, never>\n\n/**\n * A divider between items in a `<Dropdown>`. Renders an RA `<Separator>`\n * (`role=\"separator\"`).\n *\n * @component\n */\nexport function DropdownSeparator() {\n return <Separator className=\"tds-dropdown-separator\" />\n}\n"],"names":["React"],"mappings":";;;;;;;;AAqDA;;;;;;;;;;;;;;AAcG;AACG,SAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAwB,EAAA;AAC1E,IAAA,MAAM,gBAAgB,GAAG,CAAC,MAAe,KAAI;AAC3C,QAAA,IAAI,MAAM;YAAE,MAAM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;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,GACjC,CAAC,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC,CAAA;AAEjD,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,cAAc,CAAC,cAAc,CAAC,EAC9B,MAAM,QAAQ,GAAG,UAAU,CAC5B,GACC,QAAQ,CAAA;AAEV;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,EAClB,SAAS,EACT,KAAiB,EACjB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAkB,EAClB,GAAG,SAAS,EACb,EAAE,eAAe,qBAwDjB"}
@@ -1,6 +1,7 @@
1
1
  import Icon from '../../utilities/Icon.js';
2
2
  import classNames from 'classnames';
3
3
  import React__default from 'react';
4
+ import { Button } from 'react-aria-components/Button';
4
5
  import { TagContent, tagText } from './TagContent.js';
5
6
  import { useTagMenu } from './useTagMenu.js';
6
7
 
@@ -14,16 +15,22 @@ import { useTagMenu } from './useTagMenu.js';
14
15
  function Tag({ className, color = "neutral", icon, label, name, onChange, onDismiss, options, variant = "subtle", ...restProps }) {
15
16
  const text = tagText(label, name);
16
17
  const hasMenu = !!options?.length;
18
+ const selected = options?.find((option) => option.name === name);
17
19
  const menu = useTagMenu({
18
- buttonLabel: `Change ${text}`,
19
- menuLabel: label ?? name,
20
- onChange: (option) => onChange?.(option),
20
+ label: label ?? name,
21
+ onSelectionChange: ([key]) => {
22
+ const option = options?.find((o) => o.id === key);
23
+ if (option)
24
+ onChange?.(option);
25
+ },
21
26
  options: options ?? [],
22
- selectedName: name,
27
+ selectedKeys: selected ? [selected.id] : [],
28
+ selectionMode: "single",
23
29
  });
24
30
  return (React__default.createElement("div", { ...restProps, className: classNames("tds-tag", `tds-tag--${color}`, `tds-tag--${variant}`, className) },
25
31
  React__default.createElement(TagContent, { dismissButton: onDismiss && (React__default.createElement("button", { "aria-label": `Remove ${text}`, className: "tds-tag-dismiss", onClick: onDismiss, type: "button" },
26
- React__default.createElement(Icon, { "aria-hidden": true, symbol: "general#x" }))), icon: icon, label: label, menuButton: hasMenu && menu.button, name: name }),
32
+ React__default.createElement(Icon, { "aria-hidden": true, symbol: "general#x" }))), icon: icon, label: label, menuButton: hasMenu && (React__default.createElement(Button, { ...menu.triggerProps, "aria-label": `Change ${text}`, className: "tds-tag-menu-button" },
33
+ React__default.createElement(Icon, { "aria-hidden": true, symbol: "general#down-caret" }))), name: name }),
27
34
  hasMenu && menu.popover));
28
35
  }
29
36
 
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.js","sources":["../../../src/components/tag/Tag.tsx"],"sourcesContent":["import Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React, { type HTMLAttributes, type ReactNode } from \"react\"\n\nimport { TagContent, tagText } from \"./TagContent\"\nimport { type TagOption, useTagMenu } from \"./useTagMenu\"\n\nexport type { TagOption } from \"./useTagMenu\"\n\nexport type TagColor =\n | \"aqua\"\n | \"blue\"\n | \"green\"\n | \"indigo\"\n | \"magenta\"\n | \"neutral\"\n | \"orange\"\n | \"pink\"\n | \"purple\"\n | \"teal\"\n | \"yellow\"\n\nexport type TagVariant = \"bold\" | \"subtle\"\n\ninterface TagBaseProps {\n className?: string\n /** The hue. Defaults to `neutral`. */\n color?: TagColor\n /** Text before the name, on a darker fill. */\n label?: string\n /**\n * The text of the tag. With `options`, the name of the current option.\n */\n name: string\n /** Defaults to `subtle`. */\n variant?: TagVariant\n}\n\ninterface TagIconProps {\n /** Leading icon. Cannot be used with `onDismiss` or `options`. */\n icon?: ReactNode\n onChange?: never\n onDismiss?: never\n options?: never\n}\n\ninterface TagDismissProps {\n icon?: never\n onChange?: never\n /** Shows the ✕ when set. Called when the ✕ is pressed. */\n onDismiss?: () => void\n options?: never\n}\n\ninterface TagMenuProps {\n icon?: never\n /** Called with the picked option. */\n onChange: (option: TagOption) => void\n onDismiss?: () => void\n /**\n * The values the tag can change to. Shows a menu button after the name.\n * The menu marks the option whose `name` matches.\n */\n options: TagOption[]\n}\n\n/**\n * A tag has a leading icon, or its ✕ and menu buttons, not both, so the\n * icons do not compete.\n */\nexport type TagProps = TagBaseProps &\n (TagDismissProps | TagIconProps | TagMenuProps)\n\n/** `TagProps`, plus any other attribute of the root `div`, such as `id`. */\nexport type TagElementProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n keyof TagProps | \"children\"\n> &\n TagProps\n\n/**\n * A small, colored label for a value, such as a status or a category. A tag\n * can show a label before its name, a ✕ to remove it, and a menu that\n * changes its value.\n *\n * @component\n */\nexport function Tag({\n className,\n color = \"neutral\",\n icon,\n label,\n name,\n onChange,\n onDismiss,\n options,\n variant = \"subtle\",\n ...restProps\n}: TagElementProps) {\n const text = tagText(label, name)\n const hasMenu = !!options?.length\n const menu = useTagMenu({\n buttonLabel: `Change ${text}`,\n menuLabel: label ?? name,\n onChange: (option) => onChange?.(option),\n options: options ?? [],\n selectedName: name,\n })\n\n return (\n <div\n {...restProps}\n className={classNames(\n \"tds-tag\",\n `tds-tag--${color}`,\n `tds-tag--${variant}`,\n className\n )}\n >\n <TagContent\n dismissButton={\n onDismiss && (\n <button\n aria-label={`Remove ${text}`}\n className=\"tds-tag-dismiss\"\n onClick={onDismiss}\n type=\"button\"\n >\n <Icon aria-hidden symbol=\"general#x\" />\n </button>\n )\n }\n icon={icon}\n label={label}\n menuButton={hasMenu && menu.button}\n name={name}\n />\n {hasMenu && menu.popover}\n </div>\n )\n}\n"],"names":["React"],"mappings":";;;;;;AAgFA;;;;;;AAMG;AACG,SAAU,GAAG,CAAC,EAClB,SAAS,EACT,KAAK,GAAG,SAAS,EACjB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,GAAG,QAAQ,EAClB,GAAG,SAAS,EACI,EAAA;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;AACjC,IAAA,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM;IACjC,MAAM,IAAI,GAAG,UAAU,CAAC;QACtB,WAAW,EAAE,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE;QAC7B,SAAS,EAAE,KAAK,IAAI,IAAI;QACxB,QAAQ,EAAE,CAAC,MAAM,KAAK,QAAQ,GAAG,MAAM,CAAC;QACxC,OAAO,EAAE,OAAO,IAAI,EAAE;AACtB,QAAA,YAAY,EAAE,IAAI;AACnB,KAAA,CAAC;AAEF,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GACM,SAAS,EACb,SAAS,EAAE,UAAU,CACnB,SAAS,EACT,CAAA,SAAA,EAAY,KAAK,EAAE,EACnB,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,EACrB,SAAS,CACV,EAAA;QAEDA,cAAA,CAAA,aAAA,CAAC,UAAU,IACT,aAAa,EACX,SAAS,KACPA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,YAAA,EACc,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE,EAC5B,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,SAAS,EAClB,IAAI,EAAC,QAAQ,EAAA;AAEb,gBAAAA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAA,aAAA,EAAA,IAAA,EAAa,MAAM,EAAC,WAAW,EAAA,CAAG,CAChC,CACV,EAEH,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,OAAO,IAAI,IAAI,CAAC,MAAM,EAClC,IAAI,EAAE,IAAI,EAAA,CACV;AACD,QAAA,OAAO,IAAI,IAAI,CAAC,OAAO,CACpB;AAEV;;;;"}
1
+ {"version":3,"file":"Tag.js","sources":["../../../src/components/tag/Tag.tsx"],"sourcesContent":["import Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React, { type HTMLAttributes, type ReactNode } from \"react\"\nimport { Button as AriaButton } from \"react-aria-components/Button\"\n\nimport { TagContent, tagText } from \"./TagContent\"\nimport { type TagOption, useTagMenu } from \"./useTagMenu\"\n\nexport type { TagOption } from \"./useTagMenu\"\n\nexport type TagColor =\n | \"aqua\"\n | \"blue\"\n | \"green\"\n | \"indigo\"\n | \"magenta\"\n | \"neutral\"\n | \"orange\"\n | \"pink\"\n | \"purple\"\n | \"teal\"\n | \"yellow\"\n\nexport type TagVariant = \"bold\" | \"subtle\"\n\ninterface TagBaseProps {\n className?: string\n /** The hue. Defaults to `neutral`. */\n color?: TagColor\n /** Text before the name, on a darker fill. */\n label?: string\n /**\n * The text of the tag. With `options`, the name of the current option.\n */\n name: string\n /** Defaults to `subtle`. */\n variant?: TagVariant\n}\n\ninterface TagIconProps {\n /** Leading icon. Cannot be used with `onDismiss` or `options`. */\n icon?: ReactNode\n onChange?: never\n onDismiss?: never\n options?: never\n}\n\ninterface TagDismissProps {\n icon?: never\n onChange?: never\n /** Shows the ✕ when set. Called when the ✕ is pressed. */\n onDismiss?: () => void\n options?: never\n}\n\ninterface TagMenuProps {\n icon?: never\n /** Called with the picked option. */\n onChange: (option: TagOption) => void\n onDismiss?: () => void\n /**\n * The values the tag can change to. Shows a menu button after the name.\n * The menu marks the option whose `name` matches.\n */\n options: TagOption[]\n}\n\n/**\n * A tag has a leading icon, or its ✕ and menu buttons, not both, so the\n * icons do not compete.\n */\nexport type TagProps = TagBaseProps &\n (TagDismissProps | TagIconProps | TagMenuProps)\n\n/** `TagProps`, plus any other attribute of the root `div`, such as `id`. */\nexport type TagElementProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n keyof TagProps | \"children\"\n> &\n TagProps\n\n/**\n * A small, colored label for a value, such as a status or a category. A tag\n * can show a label before its name, a ✕ to remove it, and a menu that\n * changes its value.\n *\n * @component\n */\nexport function Tag({\n className,\n color = \"neutral\",\n icon,\n label,\n name,\n onChange,\n onDismiss,\n options,\n variant = \"subtle\",\n ...restProps\n}: TagElementProps) {\n const text = tagText(label, name)\n const hasMenu = !!options?.length\n const selected = options?.find((option) => option.name === name)\n const menu = useTagMenu({\n label: label ?? name,\n onSelectionChange: ([key]) => {\n const option = options?.find((o) => o.id === key)\n if (option) onChange?.(option)\n },\n options: options ?? [],\n selectedKeys: selected ? [selected.id] : [],\n selectionMode: \"single\",\n })\n\n return (\n <div\n {...restProps}\n className={classNames(\n \"tds-tag\",\n `tds-tag--${color}`,\n `tds-tag--${variant}`,\n className\n )}\n >\n <TagContent\n dismissButton={\n onDismiss && (\n <button\n aria-label={`Remove ${text}`}\n className=\"tds-tag-dismiss\"\n onClick={onDismiss}\n type=\"button\"\n >\n <Icon aria-hidden symbol=\"general#x\" />\n </button>\n )\n }\n icon={icon}\n label={label}\n menuButton={\n hasMenu && (\n <AriaButton\n {...menu.triggerProps}\n aria-label={`Change ${text}`}\n className=\"tds-tag-menu-button\"\n >\n <Icon aria-hidden symbol=\"general#down-caret\" />\n </AriaButton>\n )\n }\n name={name}\n />\n {hasMenu && menu.popover}\n </div>\n )\n}\n"],"names":["React","AriaButton"],"mappings":";;;;;;;AAiFA;;;;;;AAMG;AACG,SAAU,GAAG,CAAC,EAClB,SAAS,EACT,KAAK,GAAG,SAAS,EACjB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,GAAG,QAAQ,EAClB,GAAG,SAAS,EACI,EAAA;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;AACjC,IAAA,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM;AACjC,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;IAChE,MAAM,IAAI,GAAG,UAAU,CAAC;QACtB,KAAK,EAAE,KAAK,IAAI,IAAI;AACpB,QAAA,iBAAiB,EAAE,CAAC,CAAC,GAAG,CAAC,KAAI;AAC3B,YAAA,MAAM,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AAI,EAAE,IAAI,EAAA,CACV;AACD,QAAA,OAAO,IAAI,IAAI,CAAC,OAAO,CACpB;AAEV;;;;"}
@@ -1,10 +1,12 @@
1
1
  import React, { type ReactNode } from "react";
2
2
  interface TagContentProps {
3
- /** The ✕ button. Always after the name. */
3
+ /** The ✕ button. Always last. */
4
4
  dismissButton?: ReactNode;
5
+ /** Hides the name from screen readers, for a tag that its list row names. */
6
+ hideName?: boolean;
5
7
  icon?: ReactNode;
6
8
  label?: string;
7
- /** The menu button. After the name and the ✕. */
9
+ /** The menu button. After the name. */
8
10
  menuButton?: ReactNode;
9
11
  name: string;
10
12
  }
@@ -14,6 +16,6 @@ export declare function tagText(label: string | undefined, name: string): string
14
16
  * The markup inside a tag. With a label, screen readers read one hidden
15
17
  * "label: name" text, so the two parts are not read as separate items.
16
18
  */
17
- export declare function TagContent({ dismissButton, icon, label, menuButton, name, }: TagContentProps): React.JSX.Element;
19
+ export declare function TagContent({ dismissButton, hideName, icon, label, menuButton, name, }: TagContentProps): React.JSX.Element;
18
20
  export {};
19
21
  //# sourceMappingURL=TagContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TagContent.d.ts","sourceRoot":"","sources":["../../../src/components/tag/TagContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE7C,UAAU,eAAe;IACvB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,UAE9D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,aAAa,EACb,IAAI,EACJ,KAAK,EACL,UAAU,EACV,IAAI,GACL,EAAE,eAAe,qBA0BjB"}
1
+ {"version":3,"file":"TagContent.d.ts","sourceRoot":"","sources":["../../../src/components/tag/TagContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE7C,UAAU,eAAe;IACvB,iCAAiC;IACjC,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,UAE9D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,UAAU,EACV,IAAI,GACL,EAAE,eAAe,qBA6BjB"}
@@ -8,7 +8,7 @@ function tagText(label, name) {
8
8
  * The markup inside a tag. With a label, screen readers read one hidden
9
9
  * "label: name" text, so the two parts are not read as separate items.
10
10
  */
11
- function TagContent({ dismissButton, icon, label, menuButton, name, }) {
11
+ function TagContent({ dismissButton, hideName, icon, label, menuButton, name, }) {
12
12
  const iconNode = icon && (React__default.createElement("span", { "aria-hidden": true, className: "tds-tag-icon" }, icon));
13
13
  return (React__default.createElement(React__default.Fragment, null,
14
14
  label && (React__default.createElement("span", { className: "tds-tag-text--hidden" }, tagText(label, name))),
@@ -17,9 +17,10 @@ function TagContent({ dismissButton, icon, label, menuButton, name, }) {
17
17
  label)),
18
18
  React__default.createElement("span", { className: "tds-tag-value" },
19
19
  !label && iconNode,
20
- React__default.createElement("span", { "aria-hidden": label ? true : undefined }, name),
21
- dismissButton,
22
- menuButton)));
20
+ React__default.createElement("span", { "aria-hidden": label || hideName ? true : undefined }, name),
21
+ menuButton,
22
+ menuButton && dismissButton && (React__default.createElement("span", { "aria-hidden": true, className: "tds-tag-divider" })),
23
+ dismissButton)));
23
24
  }
24
25
 
25
26
  export { TagContent, tagText };
@@ -1 +1 @@
1
- {"version":3,"file":"TagContent.js","sources":["../../../src/components/tag/TagContent.tsx"],"sourcesContent":["import React, { type ReactNode } from \"react\"\n\ninterface TagContentProps {\n /** The ✕ button. Always after the name. */\n dismissButton?: ReactNode\n icon?: ReactNode\n label?: string\n /** The menu button. After the name and the ✕. */\n menuButton?: ReactNode\n name: string\n}\n\n/** The text screen readers read for a tag: \"label: name\", or the name. */\nexport function tagText(label: string | undefined, name: string) {\n return label ? `${label}: ${name}` : name\n}\n\n/**\n * The markup inside a tag. With a label, screen readers read one hidden\n * \"label: name\" text, so the two parts are not read as separate items.\n */\nexport function TagContent({\n dismissButton,\n icon,\n label,\n menuButton,\n name,\n}: TagContentProps) {\n const iconNode = icon && (\n <span aria-hidden className=\"tds-tag-icon\">\n {icon}\n </span>\n )\n\n return (\n <>\n {label && (\n <span className=\"tds-tag-text--hidden\">{tagText(label, name)}</span>\n )}\n {label && (\n <span aria-hidden className=\"tds-tag-label\">\n {iconNode}\n {label}\n </span>\n )}\n <span className=\"tds-tag-value\">\n {!label && iconNode}\n <span aria-hidden={label ? true : undefined}>{name}</span>\n {dismissButton}\n {menuButton}\n </span>\n </>\n )\n}\n"],"names":["React"],"mappings":";;AAYA;AACM,SAAU,OAAO,CAAC,KAAyB,EAAE,IAAY,EAAA;AAC7D,IAAA,OAAO,KAAK,GAAG,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,GAAG,IAAI;AAC3C;AAEA;;;AAGG;AACG,SAAU,UAAU,CAAC,EACzB,aAAa,EACb,IAAI,EACJ,KAAK,EACL,UAAU,EACV,IAAI,GACY,EAAA;AAChB,IAAA,MAAM,QAAQ,GAAG,IAAI,KACnBA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAkB,SAAS,EAAC,cAAc,EAAA,EACvC,IAAI,CACA,CACR;AAED,IAAA,QACEA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA;AACG,QAAA,KAAK,KACJA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,sBAAsB,EAAA,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAQ,CACrE;AACA,QAAA,KAAK,KACJA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAkB,SAAS,EAAC,eAAe,EAAA;YACxC,QAAQ;AACR,YAAA,KAAK,CACD,CACR;QACDA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,eAAe,EAAA;YAC5B,CAAC,KAAK,IAAI,QAAQ;YACnBA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAmB,KAAK,GAAG,IAAI,GAAG,SAAS,EAAA,EAAG,IAAI,CAAQ;YACzD,aAAa;YACb,UAAU,CACN,CACN;AAEP;;;;"}
1
+ {"version":3,"file":"TagContent.js","sources":["../../../src/components/tag/TagContent.tsx"],"sourcesContent":["import React, { type ReactNode } from \"react\"\n\ninterface TagContentProps {\n /** The ✕ button. Always last. */\n dismissButton?: ReactNode\n /** Hides the name from screen readers, for a tag that its list row names. */\n hideName?: boolean\n icon?: ReactNode\n label?: string\n /** The menu button. After the name. */\n menuButton?: ReactNode\n name: string\n}\n\n/** The text screen readers read for a tag: \"label: name\", or the name. */\nexport function tagText(label: string | undefined, name: string) {\n return label ? `${label}: ${name}` : name\n}\n\n/**\n * The markup inside a tag. With a label, screen readers read one hidden\n * \"label: name\" text, so the two parts are not read as separate items.\n */\nexport function TagContent({\n dismissButton,\n hideName,\n icon,\n label,\n menuButton,\n name,\n}: TagContentProps) {\n const iconNode = icon && (\n <span aria-hidden className=\"tds-tag-icon\">\n {icon}\n </span>\n )\n\n return (\n <>\n {label && (\n <span className=\"tds-tag-text--hidden\">{tagText(label, name)}</span>\n )}\n {label && (\n <span aria-hidden className=\"tds-tag-label\">\n {iconNode}\n {label}\n </span>\n )}\n <span className=\"tds-tag-value\">\n {!label && iconNode}\n <span aria-hidden={label || hideName ? true : undefined}>{name}</span>\n {menuButton}\n {menuButton && dismissButton && (\n <span aria-hidden className=\"tds-tag-divider\" />\n )}\n {dismissButton}\n </span>\n </>\n )\n}\n"],"names":["React"],"mappings":";;AAcA;AACM,SAAU,OAAO,CAAC,KAAyB,EAAE,IAAY,EAAA;AAC7D,IAAA,OAAO,KAAK,GAAG,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,GAAG,IAAI;AAC3C;AAEA;;;AAGG;AACG,SAAU,UAAU,CAAC,EACzB,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,UAAU,EACV,IAAI,GACY,EAAA;AAChB,IAAA,MAAM,QAAQ,GAAG,IAAI,KACnBA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAkB,SAAS,EAAC,cAAc,EAAA,EACvC,IAAI,CACA,CACR;AAED,IAAA,QACEA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA;AACG,QAAA,KAAK,KACJA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,sBAAsB,EAAA,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAQ,CACrE;AACA,QAAA,KAAK,KACJA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAkB,SAAS,EAAC,eAAe,EAAA;YACxC,QAAQ;AACR,YAAA,KAAK,CACD,CACR;QACDA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,eAAe,EAAA;YAC5B,CAAC,KAAK,IAAI,QAAQ;AACnB,YAAAA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAmB,KAAK,IAAI,QAAQ,GAAG,IAAI,GAAG,SAAS,EAAA,EAAG,IAAI,CAAQ;YACrE,UAAU;YACV,UAAU,IAAI,aAAa,KAC1BA,4DAAkB,SAAS,EAAC,iBAAiB,EAAA,CAAG,CACjD;YACA,aAAa,CACT,CACN;AAEP;;;;"}
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import type { Key } from "react-aria-components";
3
+ import type { TagColor, TagVariant } from "./Tag";
4
+ interface TagListItemProps {
5
+ color?: TagColor;
6
+ /** The list's name. Screen readers read the tag as "groupLabel: name". */
7
+ groupLabel: string;
8
+ id: Key;
9
+ name: string;
10
+ variant?: TagVariant;
11
+ }
12
+ /**
13
+ * A tag inside a React Aria tag list. Internal to TagGroup and TagInput.
14
+ */
15
+ export declare function TagListItem({ color, groupLabel, id, name, variant, }: TagListItemProps): React.JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=TagListItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagListItem.d.ts","sourceRoot":"","sources":["../../../src/components/tag/TagListItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAIhD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGjD,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,GAAG,CAAA;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAiB,EACjB,UAAU,EACV,EAAE,EACF,IAAI,EACJ,OAAkB,GACnB,EAAE,gBAAgB,qBA8BlB"}
@@ -0,0 +1,17 @@
1
+ import Icon from '../../utilities/Icon.js';
2
+ import classNames from 'classnames';
3
+ import React__default from 'react';
4
+ import { Button } from 'react-aria-components/Button';
5
+ import { Tag } from 'react-aria-components/TagGroup';
6
+ import { tagText, TagContent } from './TagContent.js';
7
+
8
+ /**
9
+ * A tag inside a React Aria tag list. Internal to TagGroup and TagInput.
10
+ */
11
+ function TagListItem({ color = "neutral", groupLabel, id, name, variant = "subtle", }) {
12
+ return (React__default.createElement(Tag, { className: classNames("tds-tag", `tds-tag--${color}`, `tds-tag--${variant}`), id: id, textValue: tagText(groupLabel, name) }, ({ allowsRemoving }) => (React__default.createElement(TagContent, { dismissButton: allowsRemoving && (React__default.createElement(Button, { className: "tds-tag-dismiss", excludeFromTabOrder: true, slot: "remove" },
13
+ React__default.createElement(Icon, { "aria-hidden": true, symbol: "general#x" }))), hideName: true, name: name }))));
14
+ }
15
+
16
+ export { TagListItem };
17
+ //# sourceMappingURL=TagListItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagListItem.js","sources":["../../../src/components/tag/TagListItem.tsx"],"sourcesContent":["import Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React from \"react\"\nimport type { Key } from \"react-aria-components\"\nimport { Button as AriaButton } from \"react-aria-components/Button\"\nimport { Tag as AriaTag } from \"react-aria-components/TagGroup\"\n\nimport type { TagColor, TagVariant } from \"./Tag\"\nimport { TagContent, tagText } from \"./TagContent\"\n\ninterface TagListItemProps {\n color?: TagColor\n /** The list's name. Screen readers read the tag as \"groupLabel: name\". */\n groupLabel: string\n id: Key\n name: string\n variant?: TagVariant\n}\n\n/**\n * A tag inside a React Aria tag list. Internal to TagGroup and TagInput.\n */\nexport function TagListItem({\n color = \"neutral\",\n groupLabel,\n id,\n name,\n variant = \"subtle\",\n}: TagListItemProps) {\n return (\n <AriaTag\n className={classNames(\n \"tds-tag\",\n `tds-tag--${color}`,\n `tds-tag--${variant}`\n )}\n id={id}\n textValue={tagText(groupLabel, name)}\n >\n {({ allowsRemoving }) => (\n <TagContent\n dismissButton={\n allowsRemoving && (\n <AriaButton\n className=\"tds-tag-dismiss\"\n excludeFromTabOrder\n slot=\"remove\"\n >\n <Icon aria-hidden symbol=\"general#x\" />\n </AriaButton>\n )\n }\n hideName\n name={name}\n />\n )}\n </AriaTag>\n )\n}\n"],"names":["React","AriaTag","AriaButton"],"mappings":";;;;;;;AAmBA;;AAEG;SACa,WAAW,CAAC,EAC1B,KAAK,GAAG,SAAS,EACjB,UAAU,EACV,EAAE,EACF,IAAI,EACJ,OAAO,GAAG,QAAQ,GACD,EAAA;IACjB,QACEA,cAAA,CAAA,aAAA,CAACC,GAAO,EAAA,EACN,SAAS,EAAE,UAAU,CACnB,SAAS,EACT,CAAA,SAAA,EAAY,KAAK,CAAA,CAAE,EACnB,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CACtB,EACD,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,EAAA,EAEnC,CAAC,EAAE,cAAc,EAAE,MAClBD,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EACT,aAAa,EACX,cAAc,KACZA,cAAA,CAAA,aAAA,CAACE,MAAU,EAAA,EACT,SAAS,EAAC,iBAAiB,EAC3B,mBAAmB,EAAA,IAAA,EACnB,IAAI,EAAC,QAAQ,EAAA;AAEb,YAAAF,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAA,aAAA,EAAA,IAAA,EAAa,MAAM,EAAC,WAAW,EAAA,CAAG,CAC5B,CACd,EAEH,QAAQ,EAAA,IAAA,EACR,IAAI,EAAE,IAAI,GACV,CACH,CACO;AAEd;;;;"}
@@ -1,31 +1,41 @@
1
1
  import "../dropdown/index.css";
2
- import { type ReactNode } from "react";
3
- import type { Key } from "react-aria-components";
2
+ import { type ReactNode, type RefObject } from "react";
3
+ import type { ButtonProps, Key, PopoverProps } from "react-aria-components";
4
4
  export interface TagOption {
5
5
  id: Key;
6
6
  name: string;
7
7
  }
8
8
  interface UseTagMenuOptions {
9
- /** Accessible name of the menu button. */
10
- buttonLabel: string;
11
9
  /** Accessible name of the menu. */
12
- menuLabel: string;
13
- onChange: (option: TagOption) => void;
10
+ label: string;
11
+ onSelectionChange: (keys: Key[]) => void;
14
12
  options: TagOption[];
15
- /** The name of the current option. The menu marks the option with this name. */
16
- selectedName: string;
13
+ /** Where the menu opens. Defaults to `"bottom"`. */
14
+ placement?: PopoverProps["placement"];
15
+ selectedKeys: Key[];
16
+ /** `"single"` closes the menu after a pick. `"multiple"` keeps it open. */
17
+ selectionMode: "multiple" | "single";
18
+ }
19
+ interface TagMenuTriggerProps {
20
+ "aria-expanded": boolean;
21
+ "aria-haspopup": "menu";
22
+ onKeyDown: NonNullable<ButtonProps["onKeyDown"]>;
23
+ onPress: () => void;
24
+ ref: RefObject<HTMLButtonElement>;
17
25
  }
18
26
  interface TagMenu {
19
- /** The menu button. Place it inside the tag, after the name. */
20
- button: ReactNode;
27
+ isOpen: boolean;
21
28
  /** The menu. */
22
29
  popover: ReactNode;
30
+ /** Spread these on the React Aria `Button` that opens the menu. */
31
+ triggerProps: TagMenuTriggerProps;
23
32
  }
24
33
  /**
25
- * The menu button and single-select menu that change a tag's value.
26
- * Internal to Tag. The menu is non-modal, like Dropdown's, so one click on
27
- * another Tag's menu button closes this menu and opens that one.
34
+ * The menu that changes the values of a tag or a tag group. Internal to Tag
35
+ * and TagGroup. The menu is non-modal, like Dropdown's, so one click on
36
+ * another menu button closes this menu and opens that one. Like Dropdown,
37
+ * the down and up arrows on the button open the menu.
28
38
  */
29
- export declare function useTagMenu({ buttonLabel, menuLabel, onChange, options, selectedName, }: UseTagMenuOptions): TagMenu;
39
+ export declare function useTagMenu({ label, onSelectionChange, options, placement, selectedKeys, selectionMode, }: UseTagMenuOptions): TagMenu;
30
40
  export {};
31
41
  //# sourceMappingURL=useTagMenu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTagMenu.d.ts","sourceRoot":"","sources":["../../../src/components/tag/useTagMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAG9B,OAAc,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAA;AAE1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAKhD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,GAAG,CAAA;IACP,IAAI,EAAE,MAAM,CAAA;CACb;AAED,UAAU,iBAAiB;IACzB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAA;IACnB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAA;IACrC,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,UAAU,OAAO;IACf,gEAAgE;IAChE,MAAM,EAAE,SAAS,CAAA;IACjB,gBAAgB;IAChB,OAAO,EAAE,SAAS,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAuF7B"}
1
+ {"version":3,"file":"useTagMenu.d.ts","sourceRoot":"","sources":["../../../src/components/tag/useTagMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAG9B,OAAc,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,EAIf,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAI3E,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,GAAG,CAAA;IACP,IAAI,EAAE,MAAM,CAA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