@react-spectrum/tag 3.2.10 → 3.2.11
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.
- package/dist/TagGroup.main.js +1 -1
- package/dist/TagGroup.main.js.map +1 -1
- package/dist/TagGroup.mjs +1 -1
- package/dist/TagGroup.module.js +1 -1
- package/dist/TagGroup.module.js.map +1 -1
- package/dist/tags_vars_css.main.js.map +1 -1
- package/dist/tags_vars_css.module.js.map +1 -1
- package/package.json +18 -18
- package/src/TagGroup.tsx +4 -4
package/dist/TagGroup.main.js
CHANGED
|
@@ -136,7 +136,7 @@ function $e7b72d8874e98cd4$var$TagGroup(props, ref) {
|
|
|
136
136
|
let buttons = [
|
|
137
137
|
...currActionsRef.children
|
|
138
138
|
];
|
|
139
|
-
if (maxRows && buttons.length > 0 && rowCount >= maxRows) {
|
|
139
|
+
if (maxRows && buttons.length > 0 && rowCount >= maxRows && currContainerRef.parentElement) {
|
|
140
140
|
var _tags_;
|
|
141
141
|
let buttonsWidth = buttons.reduce((acc, curr)=>acc += curr.getBoundingClientRect().width, 0);
|
|
142
142
|
buttonsWidth += $e7b72d8874e98cd4$var$TAG_STYLES[scale].margin * 2 * buttons.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAoBD,MAAM,mCAAa;IACjB,QAAQ;QACN,QAAQ;QACR,QAAQ;IACV;IACA,OAAO;QACL,QAAQ;QACR,QAAQ;IACV;AACF;AAaA,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,qCAAW,EAAE;IACrB,IAAI,WACF,OAAO,YACP,QAAQ,eACR,WAAW,YACX,QAAQ,iBACR,aAAa,oBACb,mBAAmB,IAAM,gBAAgB,MAAM,CAAC,WACjD,GAAG;IACJ,IAAI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AU,CAAC;QAC/C,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OAC7B,SAAS,kBAAkB,kBAC1B,0DAAC,CAAA,GAAA,uCAAW;QACV,SAAA;QACA,SAAS;QACT,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACpC,cACC,gBAAgB,MAAM,CAAC,sBAAsB;QAAC,UAAU,MAAM,UAAU,CAAC,IAAI;IAAA,KAC7E,gBAAgB,MAAM,CAAC,qBAI5B,eAAe,0BACd,0DAAC,CAAA,GAAA,uCAAW;QACV,SAAA;QACA,SAAS,IAAM,qBAAA,+BAAA;QACf,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACpC;AAUrB;AAEA,4IAA4I,GAC5I,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tag/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2020 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} from '@react-spectrum/button';\nimport {AriaTagGroupProps, useTagGroup} from '@react-aria/tag';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {Collection, DOMRef, Node, SpectrumLabelableProps, StyleProps, Validation} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {FocusRing, FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListCollection, useListState} from '@react-stately/list';\nimport {ListKeyboardDelegate} from '@react-aria/selection';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {JSX, ReactElement, useCallback, useEffect, useMemo, useRef, useState} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/tags/vars.css';\nimport {Tag} from './Tag';\nimport {useFormProps} from '@react-spectrum/form';\nimport {useId, useLayoutEffect, useResizeObserver, useValueEffect} from '@react-aria/utils';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\n\nconst TAG_STYLES = {\n medium: {\n height: 24,\n margin: 4\n },\n large: {\n height: 30,\n margin: 5\n }\n};\n\nexport interface SpectrumTagGroupProps<T> extends Omit<AriaTagGroupProps<T>, 'selectionMode' | 'disallowEmptySelection' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionBehavior' | 'disabledKeys'>, StyleProps, Omit<SpectrumLabelableProps, 'isRequired' | 'necessityIndicator'>, Pick<Validation<any>, 'isInvalid' | 'validationState'> {\n /** The label to display on the action button. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Sets what the TagGroup should render when there are no tags to display. */\n renderEmptyState?: () => JSX.Element,\n /** Limit the number of rows initially shown. This will render a button that allows the user to expand to show all tags. */\n maxRows?: number\n}\n\nfunction TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n maxRows,\n children,\n actionLabel,\n onAction,\n labelPosition,\n renderEmptyState = () => stringFormatter.format('noTags')\n } = props;\n let domRef = useDOMRef(ref);\n let containerRef = useRef(null);\n let tagsRef = useRef<HTMLDivElement | null>(null);\n let {direction} = useLocale();\n let {scale} = useProvider();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/tag');\n let [isCollapsed, setIsCollapsed] = useState(maxRows != null);\n let state = useListState(props);\n let [tagState, setTagState] = useValueEffect({visibleTagCount: state.collection.size, showCollapseButton: false});\n let keyboardDelegate = useMemo(() => {\n let collection = (isCollapsed\n ? new ListCollection([...state.collection].slice(0, tagState.visibleTagCount))\n : new ListCollection([...state.collection])) as Collection<Node<T>>;\n return new ListKeyboardDelegate({\n collection,\n ref: domRef,\n direction,\n orientation: 'horizontal'\n });\n }, [direction, isCollapsed, state.collection, tagState.visibleTagCount, domRef]) as ListKeyboardDelegate<T>;\n // Remove onAction from props so it doesn't make it into useGridList.\n delete props.onAction;\n let {gridProps, labelProps, descriptionProps, errorMessageProps} = useTagGroup({...props, keyboardDelegate}, state, tagsRef);\n let actionsId = useId();\n let actionsRef = useRef(null);\n\n let updateVisibleTagCount = useCallback(() => {\n if (maxRows && maxRows > 0) {\n let computeVisibleTagCount = () => {\n // Refs can be null at runtime.\n let currContainerRef: HTMLDivElement | null = containerRef.current;\n let currTagsRef: HTMLDivElement | null = tagsRef.current;\n let currActionsRef: HTMLDivElement | null = actionsRef.current;\n if (!currContainerRef || !currTagsRef || !currActionsRef || state.collection.size === 0) {\n return {\n visibleTagCount: 0,\n showCollapseButton: false\n };\n }\n\n // Count rows and show tags until we hit the maxRows.\n let tags = [...currTagsRef.children];\n let currY = -Infinity;\n let rowCount = 0;\n let index = 0;\n let tagWidths: number[] = [];\n for (let tag of tags) {\n let {width, y} = tag.getBoundingClientRect();\n\n if (y !== currY) {\n currY = y;\n rowCount++;\n }\n\n if (maxRows && rowCount > maxRows) {\n break;\n }\n tagWidths.push(width);\n index++;\n }\n\n // Remove tags until there is space for the collapse button and action button (if present) on the last row.\n let buttons = [...currActionsRef.children];\n if (maxRows && buttons.length > 0 && rowCount >= maxRows) {\n let buttonsWidth = buttons.reduce((acc, curr) => acc += curr.getBoundingClientRect().width, 0);\n buttonsWidth += TAG_STYLES[scale].margin * 2 * buttons.length;\n let end = direction === 'ltr' ? 'right' : 'left';\n let containerEnd = currContainerRef.parentElement.getBoundingClientRect()[end];\n let lastTagEnd = tags[index - 1]?.getBoundingClientRect()[end];\n lastTagEnd += TAG_STYLES[scale].margin;\n let availableWidth = containerEnd - lastTagEnd;\n\n while (availableWidth < buttonsWidth && index > 0) {\n availableWidth += tagWidths.pop();\n index--;\n }\n }\n\n return {\n visibleTagCount: Math.max(index, 1),\n showCollapseButton: index < state.collection.size\n };\n };\n\n setTagState(function *() {\n // Update to show all items.\n yield {visibleTagCount: state.collection.size, showCollapseButton: true};\n\n // Measure, and update to show the items until maxRows is reached.\n yield computeVisibleTagCount();\n });\n }\n }, [maxRows, setTagState, direction, scale, state.collection.size]);\n\n useResizeObserver({ref: containerRef, onResize: updateVisibleTagCount});\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateVisibleTagCount, [children]);\n\n useEffect(() => {\n // Recalculate visible tags when fonts are loaded.\n document.fonts?.ready.then(() => updateVisibleTagCount());\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let visibleTags = useMemo(() =>\n [...state.collection].slice(0, isCollapsed ? tagState.visibleTagCount : state.collection.size),\n [isCollapsed, state.collection, tagState.visibleTagCount]\n );\n\n let handlePressCollapse = () => {\n // Prevents button from losing focus if focusedKey got collapsed.\n state.selectionManager.setFocusedKey(null);\n setIsCollapsed(prevCollapsed => !prevCollapsed);\n };\n\n let showActions = tagState.showCollapseButton || (actionLabel && onAction);\n let isEmpty = state.collection.size === 0;\n\n let containerStyle = useMemo(() => {\n if (maxRows == null || !isCollapsed || isEmpty) {\n return undefined;\n }\n let maxHeight = (TAG_STYLES[scale].height + (TAG_STYLES[scale].margin * 2)) * maxRows;\n return {maxHeight, overflow: 'hidden'};\n }, [isCollapsed, maxRows, isEmpty, scale]);\n\n return (\n <FocusScope>\n <Field\n {...props}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n showErrorIcon\n ref={domRef}\n elementType=\"span\"\n wrapperClassName={\n classNames(\n styles,\n 'spectrum-Tags-fieldWrapper',\n {\n 'spectrum-Tags-fieldWrapper--positionSide': labelPosition === 'side'\n }\n )\n }>\n <div\n ref={containerRef}\n style={containerStyle}\n className={\n classNames(\n styles,\n 'spectrum-Tags-container',\n {\n 'spectrum-Tags-container--empty': isEmpty\n }\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n <div\n ref={tagsRef}\n {...gridProps}\n className={classNames(styles, 'spectrum-Tags')}>\n {visibleTags.map(item => (\n <Tag\n {...item.props}\n key={item.key}\n item={item}\n state={state}>\n {item.rendered}\n </Tag>\n ))}\n {isEmpty && (\n <div className={classNames(styles, 'spectrum-Tags-empty-state')}>\n {renderEmptyState()}\n </div>\n )}\n </div>\n </FocusRing>\n {showActions && !isEmpty &&\n <Provider isDisabled={false}>\n <div\n role=\"group\"\n ref={actionsRef}\n id={actionsId}\n aria-label={stringFormatter.format('actions')}\n aria-labelledby={`${gridProps.id} ${actionsId}`}\n className={classNames(styles, 'spectrum-Tags-actions')}>\n {tagState.showCollapseButton &&\n <ActionButton\n isQuiet\n onPress={handlePressCollapse}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {isCollapsed ?\n stringFormatter.format('showAllButtonLabel', {tagCount: state.collection.size}) :\n stringFormatter.format('hideButtonLabel')\n }\n </ActionButton>\n }\n {actionLabel && onAction &&\n <ActionButton\n isQuiet\n onPress={() => onAction?.()}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {actionLabel}\n </ActionButton>\n }\n </div>\n </Provider>\n }\n </div>\n </Field>\n </FocusScope>\n );\n}\n\n/** Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request. */\nconst _TagGroup = React.forwardRef(TagGroup) as <T>(props: SpectrumTagGroupProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_TagGroup as TagGroup};\n"],"names":[],"version":3,"file":"TagGroup.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAoBD,MAAM,mCAAa;IACjB,QAAQ;QACN,QAAQ;QACR,QAAQ;IACV;IACA,OAA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O;WACN,KAAK,QAAQ,IAGjB,yBACC,0DAAC;QAAI,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OAChC,uBAKR,eAAe,CAAC,yBACf,0DAAC,CAAA,GAAA,qCAAO;QAAE,YAAY;qBACpB,0DAAC;QACC,MAAK;QACL,KAAK;QACL,IAAI;QACJ,cAAY,gBAAgB,MAAM,CAAC;QACnC,mBAAiB,GAAG,UAAU,EAAE,CAAC,CAAC,EAAE,WAAW;QAC/C,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OAC7B,SAAS,kBAAkB,kBAC1B,0DAAC,CAAA,GAAA,uCAAW;QACV,SAAA;QACA,SAAS;QACT,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACpC,cACC,gBAAgB,MAAM,CAAC,sBAAsB;QAAC,UAAU,MAAM,UAAU,CAAC,IAAI;IAAA,KAC7E,gBAAgB,MAAM,CAAC,qBAI5B,eAAe,0BACd,0DAAC,CAAA,GAAA,uCAAW;QACV,SAAA;QACA,SAAS,IAAM,qBAAA,+BAAA;QACf,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACpC;AAUrB;AAEA,4IAA4I,GAC5I,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tag/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2020 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} from '@react-spectrum/button';\nimport {AriaTagGroupProps, useTagGroup} from '@react-aria/tag';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {Collection, DOMRef, Node, SpectrumLabelableProps, StyleProps, Validation} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {FocusRing, FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListCollection, useListState} from '@react-stately/list';\nimport {ListKeyboardDelegate} from '@react-aria/selection';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {JSX, ReactElement, useCallback, useEffect, useMemo, useRef, useState} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/tags/vars.css';\nimport {Tag} from './Tag';\nimport {useFormProps} from '@react-spectrum/form';\nimport {useId, useLayoutEffect, useResizeObserver, useValueEffect} from '@react-aria/utils';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\n\nconst TAG_STYLES = {\n medium: {\n height: 24,\n margin: 4\n },\n large: {\n height: 30,\n margin: 5\n }\n};\n\nexport interface SpectrumTagGroupProps<T> extends Omit<AriaTagGroupProps<T>, 'selectionMode' | 'disallowEmptySelection' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionBehavior' | 'disabledKeys'>, StyleProps, Omit<SpectrumLabelableProps, 'isRequired' | 'necessityIndicator'>, Pick<Validation<any>, 'isInvalid' | 'validationState'> {\n /** The label to display on the action button. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Sets what the TagGroup should render when there are no tags to display. */\n renderEmptyState?: () => JSX.Element,\n /** Limit the number of rows initially shown. This will render a button that allows the user to expand to show all tags. */\n maxRows?: number\n}\n\nfunction TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n maxRows,\n children,\n actionLabel,\n onAction,\n labelPosition,\n renderEmptyState = () => stringFormatter.format('noTags')\n } = props;\n let domRef = useDOMRef(ref);\n let containerRef = useRef<HTMLDivElement>(null);\n let tagsRef = useRef<HTMLDivElement | null>(null);\n let {direction} = useLocale();\n let {scale} = useProvider();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/tag');\n let [isCollapsed, setIsCollapsed] = useState(maxRows != null);\n let state = useListState(props);\n let [tagState, setTagState] = useValueEffect({visibleTagCount: state.collection.size, showCollapseButton: false});\n let keyboardDelegate = useMemo(() => {\n let collection = (isCollapsed\n ? new ListCollection([...state.collection].slice(0, tagState.visibleTagCount))\n : new ListCollection([...state.collection])) as Collection<Node<T>>;\n return new ListKeyboardDelegate({\n collection,\n ref: domRef,\n direction,\n orientation: 'horizontal'\n });\n }, [direction, isCollapsed, state.collection, tagState.visibleTagCount, domRef]) as ListKeyboardDelegate<T>;\n // Remove onAction from props so it doesn't make it into useGridList.\n delete props.onAction;\n let {gridProps, labelProps, descriptionProps, errorMessageProps} = useTagGroup({...props, keyboardDelegate}, state, tagsRef);\n let actionsId = useId();\n let actionsRef = useRef<HTMLDivElement>(null);\n\n let updateVisibleTagCount = useCallback(() => {\n if (maxRows && maxRows > 0) {\n let computeVisibleTagCount = () => {\n // Refs can be null at runtime.\n let currContainerRef: HTMLDivElement | null = containerRef.current;\n let currTagsRef: HTMLDivElement | null = tagsRef.current;\n let currActionsRef: HTMLDivElement | null = actionsRef.current;\n if (!currContainerRef || !currTagsRef || !currActionsRef || state.collection.size === 0) {\n return {\n visibleTagCount: 0,\n showCollapseButton: false\n };\n }\n\n // Count rows and show tags until we hit the maxRows.\n let tags = [...currTagsRef.children];\n let currY = -Infinity;\n let rowCount = 0;\n let index = 0;\n let tagWidths: number[] = [];\n for (let tag of tags) {\n let {width, y} = tag.getBoundingClientRect();\n\n if (y !== currY) {\n currY = y;\n rowCount++;\n }\n\n if (maxRows && rowCount > maxRows) {\n break;\n }\n tagWidths.push(width);\n index++;\n }\n\n // Remove tags until there is space for the collapse button and action button (if present) on the last row.\n let buttons = [...currActionsRef.children];\n if (maxRows && buttons.length > 0 && rowCount >= maxRows && currContainerRef.parentElement) {\n let buttonsWidth = buttons.reduce((acc, curr) => acc += curr.getBoundingClientRect().width, 0);\n buttonsWidth += TAG_STYLES[scale].margin * 2 * buttons.length;\n let end = direction === 'ltr' ? 'right' : 'left';\n let containerEnd = currContainerRef.parentElement.getBoundingClientRect()[end];\n let lastTagEnd = tags[index - 1]?.getBoundingClientRect()[end];\n lastTagEnd += TAG_STYLES[scale].margin;\n let availableWidth = containerEnd - lastTagEnd;\n\n while (availableWidth < buttonsWidth && index > 0) {\n availableWidth += tagWidths.pop()!;\n index--;\n }\n }\n\n return {\n visibleTagCount: Math.max(index, 1),\n showCollapseButton: index < state.collection.size\n };\n };\n\n setTagState(function *() {\n // Update to show all items.\n yield {visibleTagCount: state.collection.size, showCollapseButton: true};\n\n // Measure, and update to show the items until maxRows is reached.\n yield computeVisibleTagCount();\n });\n }\n }, [maxRows, setTagState, direction, scale, state.collection.size]);\n\n useResizeObserver({ref: containerRef, onResize: updateVisibleTagCount});\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateVisibleTagCount, [children]);\n\n useEffect(() => {\n // Recalculate visible tags when fonts are loaded.\n document.fonts?.ready.then(() => updateVisibleTagCount());\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let visibleTags = useMemo(() =>\n [...state.collection].slice(0, isCollapsed ? tagState.visibleTagCount : state.collection.size),\n [isCollapsed, state.collection, tagState.visibleTagCount]\n );\n\n let handlePressCollapse = () => {\n // Prevents button from losing focus if focusedKey got collapsed.\n state.selectionManager.setFocusedKey(null);\n setIsCollapsed(prevCollapsed => !prevCollapsed);\n };\n\n let showActions = tagState.showCollapseButton || (actionLabel && onAction);\n let isEmpty = state.collection.size === 0;\n\n let containerStyle = useMemo(() => {\n if (maxRows == null || !isCollapsed || isEmpty) {\n return undefined;\n }\n let maxHeight = (TAG_STYLES[scale].height + (TAG_STYLES[scale].margin * 2)) * maxRows;\n return {maxHeight, overflow: 'hidden'};\n }, [isCollapsed, maxRows, isEmpty, scale]);\n\n return (\n <FocusScope>\n <Field\n {...props}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n showErrorIcon\n ref={domRef}\n elementType=\"span\"\n wrapperClassName={\n classNames(\n styles,\n 'spectrum-Tags-fieldWrapper',\n {\n 'spectrum-Tags-fieldWrapper--positionSide': labelPosition === 'side'\n }\n )\n }>\n <div\n ref={containerRef}\n style={containerStyle}\n className={\n classNames(\n styles,\n 'spectrum-Tags-container',\n {\n 'spectrum-Tags-container--empty': isEmpty\n }\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n <div\n ref={tagsRef}\n {...gridProps}\n className={classNames(styles, 'spectrum-Tags')}>\n {visibleTags.map(item => (\n <Tag\n {...item.props}\n key={item.key}\n item={item}\n state={state}>\n {item.rendered}\n </Tag>\n ))}\n {isEmpty && (\n <div className={classNames(styles, 'spectrum-Tags-empty-state')}>\n {renderEmptyState()}\n </div>\n )}\n </div>\n </FocusRing>\n {showActions && !isEmpty &&\n <Provider isDisabled={false}>\n <div\n role=\"group\"\n ref={actionsRef}\n id={actionsId}\n aria-label={stringFormatter.format('actions')}\n aria-labelledby={`${gridProps.id} ${actionsId}`}\n className={classNames(styles, 'spectrum-Tags-actions')}>\n {tagState.showCollapseButton &&\n <ActionButton\n isQuiet\n onPress={handlePressCollapse}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {isCollapsed ?\n stringFormatter.format('showAllButtonLabel', {tagCount: state.collection.size}) :\n stringFormatter.format('hideButtonLabel')\n }\n </ActionButton>\n }\n {actionLabel && onAction &&\n <ActionButton\n isQuiet\n onPress={() => onAction?.()}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {actionLabel}\n </ActionButton>\n }\n </div>\n </Provider>\n }\n </div>\n </Field>\n </FocusScope>\n );\n}\n\n/** Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request. */\nconst _TagGroup = React.forwardRef(TagGroup) as <T>(props: SpectrumTagGroupProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_TagGroup as TagGroup};\n"],"names":[],"version":3,"file":"TagGroup.main.js.map"}
|
package/dist/TagGroup.mjs
CHANGED
|
@@ -130,7 +130,7 @@ function $880d112c7a588209$var$TagGroup(props, ref) {
|
|
|
130
130
|
let buttons = [
|
|
131
131
|
...currActionsRef.children
|
|
132
132
|
];
|
|
133
|
-
if (maxRows && buttons.length > 0 && rowCount >= maxRows) {
|
|
133
|
+
if (maxRows && buttons.length > 0 && rowCount >= maxRows && currContainerRef.parentElement) {
|
|
134
134
|
var _tags_;
|
|
135
135
|
let buttonsWidth = buttons.reduce((acc, curr)=>acc += curr.getBoundingClientRect().width, 0);
|
|
136
136
|
buttonsWidth += $880d112c7a588209$var$TAG_STYLES[scale].margin * 2 * buttons.length;
|
package/dist/TagGroup.module.js
CHANGED
|
@@ -130,7 +130,7 @@ function $880d112c7a588209$var$TagGroup(props, ref) {
|
|
|
130
130
|
let buttons = [
|
|
131
131
|
...currActionsRef.children
|
|
132
132
|
];
|
|
133
|
-
if (maxRows && buttons.length > 0 && rowCount >= maxRows) {
|
|
133
|
+
if (maxRows && buttons.length > 0 && rowCount >= maxRows && currContainerRef.parentElement) {
|
|
134
134
|
var _tags_;
|
|
135
135
|
let buttonsWidth = buttons.reduce((acc, curr)=>acc += curr.getBoundingClientRect().width, 0);
|
|
136
136
|
buttonsWidth += $880d112c7a588209$var$TAG_STYLES[scale].margin * 2 * buttons.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAoBD,MAAM,mCAAa;IACjB,QAAQ;QACN,QAAQ;QACR,QAAQ;IACV;IACA,OAAO;QACL,QAAQ;QACR,QAAQ;IACV;AACF;AAaA,SAAS,+BAA2B,KA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AAK,GAAG;OAChC,uBAKR,eAAe,CAAC,yBACf,gCAAC,CAAA,GAAA,eAAO;QAAE,YAAY;qBACpB,gCAAC;QACC,MAAK;QACL,KAAK;QACL,IAAI;QACJ,cAAY,gBAAgB,MAAM,CAAC;QACnC,mBAAiB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC;QAC/C,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OAC7B,SAAS,kBAAkB,kBAC1B,gCAAC,CAAA,GAAA,mBAAW;QACV,SAAA;QACA,SAAS;QACT,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OACpC,cACC,gBAAgB,MAAM,CAAC,sBAAsB;QAAC,UAAU,MAAM,UAAU,CAAC,IAAI;IAAA,KAC7E,gBAAgB,MAAM,CAAC,qBAI5B,eAAe,0BACd,gCAAC,CAAA,GAAA,mBAAW;QACV,SAAA;QACA,SAAS,IAAM,qBAAA,+BAAA;QACf,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OACpC;AAUrB;AAEA,4IAA4I,GAC5I,MAAM,0DAAY,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tag/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2020 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} from '@react-spectrum/button';\nimport {AriaTagGroupProps, useTagGroup} from '@react-aria/tag';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {Collection, DOMRef, Node, SpectrumLabelableProps, StyleProps, Validation} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {FocusRing, FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListCollection, useListState} from '@react-stately/list';\nimport {ListKeyboardDelegate} from '@react-aria/selection';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {JSX, ReactElement, useCallback, useEffect, useMemo, useRef, useState} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/tags/vars.css';\nimport {Tag} from './Tag';\nimport {useFormProps} from '@react-spectrum/form';\nimport {useId, useLayoutEffect, useResizeObserver, useValueEffect} from '@react-aria/utils';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\n\nconst TAG_STYLES = {\n medium: {\n height: 24,\n margin: 4\n },\n large: {\n height: 30,\n margin: 5\n }\n};\n\nexport interface SpectrumTagGroupProps<T> extends Omit<AriaTagGroupProps<T>, 'selectionMode' | 'disallowEmptySelection' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionBehavior' | 'disabledKeys'>, StyleProps, Omit<SpectrumLabelableProps, 'isRequired' | 'necessityIndicator'>, Pick<Validation<any>, 'isInvalid' | 'validationState'> {\n /** The label to display on the action button. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Sets what the TagGroup should render when there are no tags to display. */\n renderEmptyState?: () => JSX.Element,\n /** Limit the number of rows initially shown. This will render a button that allows the user to expand to show all tags. */\n maxRows?: number\n}\n\nfunction TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n maxRows,\n children,\n actionLabel,\n onAction,\n labelPosition,\n renderEmptyState = () => stringFormatter.format('noTags')\n } = props;\n let domRef = useDOMRef(ref);\n let containerRef = useRef(null);\n let tagsRef = useRef<HTMLDivElement | null>(null);\n let {direction} = useLocale();\n let {scale} = useProvider();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/tag');\n let [isCollapsed, setIsCollapsed] = useState(maxRows != null);\n let state = useListState(props);\n let [tagState, setTagState] = useValueEffect({visibleTagCount: state.collection.size, showCollapseButton: false});\n let keyboardDelegate = useMemo(() => {\n let collection = (isCollapsed\n ? new ListCollection([...state.collection].slice(0, tagState.visibleTagCount))\n : new ListCollection([...state.collection])) as Collection<Node<T>>;\n return new ListKeyboardDelegate({\n collection,\n ref: domRef,\n direction,\n orientation: 'horizontal'\n });\n }, [direction, isCollapsed, state.collection, tagState.visibleTagCount, domRef]) as ListKeyboardDelegate<T>;\n // Remove onAction from props so it doesn't make it into useGridList.\n delete props.onAction;\n let {gridProps, labelProps, descriptionProps, errorMessageProps} = useTagGroup({...props, keyboardDelegate}, state, tagsRef);\n let actionsId = useId();\n let actionsRef = useRef(null);\n\n let updateVisibleTagCount = useCallback(() => {\n if (maxRows && maxRows > 0) {\n let computeVisibleTagCount = () => {\n // Refs can be null at runtime.\n let currContainerRef: HTMLDivElement | null = containerRef.current;\n let currTagsRef: HTMLDivElement | null = tagsRef.current;\n let currActionsRef: HTMLDivElement | null = actionsRef.current;\n if (!currContainerRef || !currTagsRef || !currActionsRef || state.collection.size === 0) {\n return {\n visibleTagCount: 0,\n showCollapseButton: false\n };\n }\n\n // Count rows and show tags until we hit the maxRows.\n let tags = [...currTagsRef.children];\n let currY = -Infinity;\n let rowCount = 0;\n let index = 0;\n let tagWidths: number[] = [];\n for (let tag of tags) {\n let {width, y} = tag.getBoundingClientRect();\n\n if (y !== currY) {\n currY = y;\n rowCount++;\n }\n\n if (maxRows && rowCount > maxRows) {\n break;\n }\n tagWidths.push(width);\n index++;\n }\n\n // Remove tags until there is space for the collapse button and action button (if present) on the last row.\n let buttons = [...currActionsRef.children];\n if (maxRows && buttons.length > 0 && rowCount >= maxRows) {\n let buttonsWidth = buttons.reduce((acc, curr) => acc += curr.getBoundingClientRect().width, 0);\n buttonsWidth += TAG_STYLES[scale].margin * 2 * buttons.length;\n let end = direction === 'ltr' ? 'right' : 'left';\n let containerEnd = currContainerRef.parentElement.getBoundingClientRect()[end];\n let lastTagEnd = tags[index - 1]?.getBoundingClientRect()[end];\n lastTagEnd += TAG_STYLES[scale].margin;\n let availableWidth = containerEnd - lastTagEnd;\n\n while (availableWidth < buttonsWidth && index > 0) {\n availableWidth += tagWidths.pop();\n index--;\n }\n }\n\n return {\n visibleTagCount: Math.max(index, 1),\n showCollapseButton: index < state.collection.size\n };\n };\n\n setTagState(function *() {\n // Update to show all items.\n yield {visibleTagCount: state.collection.size, showCollapseButton: true};\n\n // Measure, and update to show the items until maxRows is reached.\n yield computeVisibleTagCount();\n });\n }\n }, [maxRows, setTagState, direction, scale, state.collection.size]);\n\n useResizeObserver({ref: containerRef, onResize: updateVisibleTagCount});\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateVisibleTagCount, [children]);\n\n useEffect(() => {\n // Recalculate visible tags when fonts are loaded.\n document.fonts?.ready.then(() => updateVisibleTagCount());\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let visibleTags = useMemo(() =>\n [...state.collection].slice(0, isCollapsed ? tagState.visibleTagCount : state.collection.size),\n [isCollapsed, state.collection, tagState.visibleTagCount]\n );\n\n let handlePressCollapse = () => {\n // Prevents button from losing focus if focusedKey got collapsed.\n state.selectionManager.setFocusedKey(null);\n setIsCollapsed(prevCollapsed => !prevCollapsed);\n };\n\n let showActions = tagState.showCollapseButton || (actionLabel && onAction);\n let isEmpty = state.collection.size === 0;\n\n let containerStyle = useMemo(() => {\n if (maxRows == null || !isCollapsed || isEmpty) {\n return undefined;\n }\n let maxHeight = (TAG_STYLES[scale].height + (TAG_STYLES[scale].margin * 2)) * maxRows;\n return {maxHeight, overflow: 'hidden'};\n }, [isCollapsed, maxRows, isEmpty, scale]);\n\n return (\n <FocusScope>\n <Field\n {...props}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n showErrorIcon\n ref={domRef}\n elementType=\"span\"\n wrapperClassName={\n classNames(\n styles,\n 'spectrum-Tags-fieldWrapper',\n {\n 'spectrum-Tags-fieldWrapper--positionSide': labelPosition === 'side'\n }\n )\n }>\n <div\n ref={containerRef}\n style={containerStyle}\n className={\n classNames(\n styles,\n 'spectrum-Tags-container',\n {\n 'spectrum-Tags-container--empty': isEmpty\n }\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n <div\n ref={tagsRef}\n {...gridProps}\n className={classNames(styles, 'spectrum-Tags')}>\n {visibleTags.map(item => (\n <Tag\n {...item.props}\n key={item.key}\n item={item}\n state={state}>\n {item.rendered}\n </Tag>\n ))}\n {isEmpty && (\n <div className={classNames(styles, 'spectrum-Tags-empty-state')}>\n {renderEmptyState()}\n </div>\n )}\n </div>\n </FocusRing>\n {showActions && !isEmpty &&\n <Provider isDisabled={false}>\n <div\n role=\"group\"\n ref={actionsRef}\n id={actionsId}\n aria-label={stringFormatter.format('actions')}\n aria-labelledby={`${gridProps.id} ${actionsId}`}\n className={classNames(styles, 'spectrum-Tags-actions')}>\n {tagState.showCollapseButton &&\n <ActionButton\n isQuiet\n onPress={handlePressCollapse}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {isCollapsed ?\n stringFormatter.format('showAllButtonLabel', {tagCount: state.collection.size}) :\n stringFormatter.format('hideButtonLabel')\n }\n </ActionButton>\n }\n {actionLabel && onAction &&\n <ActionButton\n isQuiet\n onPress={() => onAction?.()}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {actionLabel}\n </ActionButton>\n }\n </div>\n </Provider>\n }\n </div>\n </Field>\n </FocusScope>\n );\n}\n\n/** Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request. */\nconst _TagGroup = React.forwardRef(TagGroup) as <T>(props: SpectrumTagGroupProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {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G,SAAS;QACb,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OAC7B,YAAY,GAAG,CAAC,CAAA,qBACf,gCAAC,CAAA,GAAA,yCAAE;YACA,GAAG,KAAK,KAAK;YACd,KAAK,KAAK,GAAG;YACb,MAAM;YACN,OAAO;WACN,KAAK,QAAQ,IAGjB,yBACC,gCAAC;QAAI,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OAChC,uBAKR,eAAe,CAAC,yBACf,gCAAC,CAAA,GAAA,eAAO;QAAE,YAAY;qBACpB,gCAAC;QACC,MAAK;QACL,KAAK;QACL,IAAI;QACJ,cAAY,gBAAgB,MAAM,CAAC;QACnC,mBAAiB,GAAG,UAAU,EAAE,CAAC,CAAC,EAAE,WAAW;QAC/C,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OAC7B,SAAS,kBAAkB,kBAC1B,gCAAC,CAAA,GAAA,mBAAW;QACV,SAAA;QACA,SAAS;QACT,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OACpC,cACC,gBAAgB,MAAM,CAAC,sBAAsB;QAAC,UAAU,MAAM,UAAU,CAAC,IAAI;IAAA,KAC7E,gBAAgB,MAAM,CAAC,qBAI5B,eAAe,0BACd,gCAAC,CAAA,GAAA,mBAAW;QACV,SAAA;QACA,SAAS,IAAM,qBAAA,+BAAA;QACf,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OACpC;AAUrB;AAEA,4IAA4I,GAC5I,MAAM,0DAAY,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tag/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2020 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} from '@react-spectrum/button';\nimport {AriaTagGroupProps, useTagGroup} from '@react-aria/tag';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {Collection, DOMRef, Node, SpectrumLabelableProps, StyleProps, Validation} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {FocusRing, FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListCollection, useListState} from '@react-stately/list';\nimport {ListKeyboardDelegate} from '@react-aria/selection';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {JSX, ReactElement, useCallback, useEffect, useMemo, useRef, useState} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/tags/vars.css';\nimport {Tag} from './Tag';\nimport {useFormProps} from '@react-spectrum/form';\nimport {useId, useLayoutEffect, useResizeObserver, useValueEffect} from '@react-aria/utils';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\n\nconst TAG_STYLES = {\n medium: {\n height: 24,\n margin: 4\n },\n large: {\n height: 30,\n margin: 5\n }\n};\n\nexport interface SpectrumTagGroupProps<T> extends Omit<AriaTagGroupProps<T>, 'selectionMode' | 'disallowEmptySelection' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionBehavior' | 'disabledKeys'>, StyleProps, Omit<SpectrumLabelableProps, 'isRequired' | 'necessityIndicator'>, Pick<Validation<any>, 'isInvalid' | 'validationState'> {\n /** The label to display on the action button. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Sets what the TagGroup should render when there are no tags to display. */\n renderEmptyState?: () => JSX.Element,\n /** Limit the number of rows initially shown. This will render a button that allows the user to expand to show all tags. */\n maxRows?: number\n}\n\nfunction TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n maxRows,\n children,\n actionLabel,\n onAction,\n labelPosition,\n renderEmptyState = () => stringFormatter.format('noTags')\n } = props;\n let domRef = useDOMRef(ref);\n let containerRef = useRef<HTMLDivElement>(null);\n let tagsRef = useRef<HTMLDivElement | null>(null);\n let {direction} = useLocale();\n let {scale} = useProvider();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/tag');\n let [isCollapsed, setIsCollapsed] = useState(maxRows != null);\n let state = useListState(props);\n let [tagState, setTagState] = useValueEffect({visibleTagCount: state.collection.size, showCollapseButton: false});\n let keyboardDelegate = useMemo(() => {\n let collection = (isCollapsed\n ? new ListCollection([...state.collection].slice(0, tagState.visibleTagCount))\n : new ListCollection([...state.collection])) as Collection<Node<T>>;\n return new ListKeyboardDelegate({\n collection,\n ref: domRef,\n direction,\n orientation: 'horizontal'\n });\n }, [direction, isCollapsed, state.collection, tagState.visibleTagCount, domRef]) as ListKeyboardDelegate<T>;\n // Remove onAction from props so it doesn't make it into useGridList.\n delete props.onAction;\n let {gridProps, labelProps, descriptionProps, errorMessageProps} = useTagGroup({...props, keyboardDelegate}, state, tagsRef);\n let actionsId = useId();\n let actionsRef = useRef<HTMLDivElement>(null);\n\n let updateVisibleTagCount = useCallback(() => {\n if (maxRows && maxRows > 0) {\n let computeVisibleTagCount = () => {\n // Refs can be null at runtime.\n let currContainerRef: HTMLDivElement | null = containerRef.current;\n let currTagsRef: HTMLDivElement | null = tagsRef.current;\n let currActionsRef: HTMLDivElement | null = actionsRef.current;\n if (!currContainerRef || !currTagsRef || !currActionsRef || state.collection.size === 0) {\n return {\n visibleTagCount: 0,\n showCollapseButton: false\n };\n }\n\n // Count rows and show tags until we hit the maxRows.\n let tags = [...currTagsRef.children];\n let currY = -Infinity;\n let rowCount = 0;\n let index = 0;\n let tagWidths: number[] = [];\n for (let tag of tags) {\n let {width, y} = tag.getBoundingClientRect();\n\n if (y !== currY) {\n currY = y;\n rowCount++;\n }\n\n if (maxRows && rowCount > maxRows) {\n break;\n }\n tagWidths.push(width);\n index++;\n }\n\n // Remove tags until there is space for the collapse button and action button (if present) on the last row.\n let buttons = [...currActionsRef.children];\n if (maxRows && buttons.length > 0 && rowCount >= maxRows && currContainerRef.parentElement) {\n let buttonsWidth = buttons.reduce((acc, curr) => acc += curr.getBoundingClientRect().width, 0);\n buttonsWidth += TAG_STYLES[scale].margin * 2 * buttons.length;\n let end = direction === 'ltr' ? 'right' : 'left';\n let containerEnd = currContainerRef.parentElement.getBoundingClientRect()[end];\n let lastTagEnd = tags[index - 1]?.getBoundingClientRect()[end];\n lastTagEnd += TAG_STYLES[scale].margin;\n let availableWidth = containerEnd - lastTagEnd;\n\n while (availableWidth < buttonsWidth && index > 0) {\n availableWidth += tagWidths.pop()!;\n index--;\n }\n }\n\n return {\n visibleTagCount: Math.max(index, 1),\n showCollapseButton: index < state.collection.size\n };\n };\n\n setTagState(function *() {\n // Update to show all items.\n yield {visibleTagCount: state.collection.size, showCollapseButton: true};\n\n // Measure, and update to show the items until maxRows is reached.\n yield computeVisibleTagCount();\n });\n }\n }, [maxRows, setTagState, direction, scale, state.collection.size]);\n\n useResizeObserver({ref: containerRef, onResize: updateVisibleTagCount});\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateVisibleTagCount, [children]);\n\n useEffect(() => {\n // Recalculate visible tags when fonts are loaded.\n document.fonts?.ready.then(() => updateVisibleTagCount());\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let visibleTags = useMemo(() =>\n [...state.collection].slice(0, isCollapsed ? tagState.visibleTagCount : state.collection.size),\n [isCollapsed, state.collection, tagState.visibleTagCount]\n );\n\n let handlePressCollapse = () => {\n // Prevents button from losing focus if focusedKey got collapsed.\n state.selectionManager.setFocusedKey(null);\n setIsCollapsed(prevCollapsed => !prevCollapsed);\n };\n\n let showActions = tagState.showCollapseButton || (actionLabel && onAction);\n let isEmpty = state.collection.size === 0;\n\n let containerStyle = useMemo(() => {\n if (maxRows == null || !isCollapsed || isEmpty) {\n return undefined;\n }\n let maxHeight = (TAG_STYLES[scale].height + (TAG_STYLES[scale].margin * 2)) * maxRows;\n return {maxHeight, overflow: 'hidden'};\n }, [isCollapsed, maxRows, isEmpty, scale]);\n\n return (\n <FocusScope>\n <Field\n {...props}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n showErrorIcon\n ref={domRef}\n elementType=\"span\"\n wrapperClassName={\n classNames(\n styles,\n 'spectrum-Tags-fieldWrapper',\n {\n 'spectrum-Tags-fieldWrapper--positionSide': labelPosition === 'side'\n }\n )\n }>\n <div\n ref={containerRef}\n style={containerStyle}\n className={\n classNames(\n styles,\n 'spectrum-Tags-container',\n {\n 'spectrum-Tags-container--empty': isEmpty\n }\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n <div\n ref={tagsRef}\n {...gridProps}\n className={classNames(styles, 'spectrum-Tags')}>\n {visibleTags.map(item => (\n <Tag\n {...item.props}\n key={item.key}\n item={item}\n state={state}>\n {item.rendered}\n </Tag>\n ))}\n {isEmpty && (\n <div className={classNames(styles, 'spectrum-Tags-empty-state')}>\n {renderEmptyState()}\n </div>\n )}\n </div>\n </FocusRing>\n {showActions && !isEmpty &&\n <Provider isDisabled={false}>\n <div\n role=\"group\"\n ref={actionsRef}\n id={actionsId}\n aria-label={stringFormatter.format('actions')}\n aria-labelledby={`${gridProps.id} ${actionsId}`}\n className={classNames(styles, 'spectrum-Tags-actions')}>\n {tagState.showCollapseButton &&\n <ActionButton\n isQuiet\n onPress={handlePressCollapse}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {isCollapsed ?\n stringFormatter.format('showAllButtonLabel', {tagCount: state.collection.size}) :\n stringFormatter.format('hideButtonLabel')\n }\n </ActionButton>\n }\n {actionLabel && onAction &&\n <ActionButton\n isQuiet\n onPress={() => onAction?.()}\n UNSAFE_className={classNames(styles, 'spectrum-Tags-actionButton')}>\n {actionLabel}\n </ActionButton>\n }\n </div>\n </Provider>\n }\n </div>\n </Field>\n </FocusScope>\n );\n}\n\n/** Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request. */\nconst _TagGroup = React.forwardRef(TagGroup) as <T>(props: SpectrumTagGroupProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_TagGroup as TagGroup};\n"],"names":[],"version":3,"file":"TagGroup.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAzBA,4CAA2B,CAAC,cAAc,CAAC;AAC3C,4CAA4B,CAAC,eAAe,CAAC;AAC7C,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAAmC,CAAC,sBAAsB,CAAC;AAC3D,4CAAgC,CAAC,mBAAmB,CAAC;AACrD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAuC,CAAC,2BAA2B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAzBA,4CAA2B,CAAC,cAAc,CAAC;AAC3C,4CAA4B,CAAC,eAAe,CAAC;AAC7C,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAAmC,CAAC,sBAAsB,CAAC;AAC3D,4CAAgC,CAAC,mBAAmB,CAAC;AACrD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAuC,CAAC,2BAA2B,EAAE,2CAA2C;AAChH,4CAA8C,CAAC,iCAAiC,CAAC;AACjF,4CAAiC,CAAC,qBAAqB,EAAE,2CAAsC;AAC/F,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAwC,CAAC,2BAA2B,CAAC;AACrE,4CAAsC,CAAC,yBAAyB,CAAC;AACjE,4CAAyC,CAAC,4BAA4B,CAAC;AACvE,4CAAsC,CAAC,yBAAyB,CAAC;AACjE,2CAA8C,CAAC,iCAAiC,CAAC;AACjF,4CAAkC,CAAC,qBAAqB,CAAC;AACzD,4CAA+C,CAAC,kCAAkC,CAAC;AACnF,4CAA0C,CAAC,6BAA6B,CAAC;AACzE,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAmD,CAAC,sCAAsC,CAAC;AAC3F,2CAA8C,CAAC,iCAAiC,CAAC;AACjF,4CAA+C,CAAC,kCAAkC,CAAC;AACnF,4CAA6D,CAAC,gDAAgD,CAAC","sources":["packages/@adobe/spectrum-css-temp/components/tags/vars.css"],"sourcesContent":["/*\n * Copyright 2020 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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"tags_vars_css.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAzBA,4CAA2B,CAAC,cAAc,CAAC;AAC3C,4CAA4B,CAAC,eAAe,CAAC;AAC7C,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAAmC,CAAC,sBAAsB,CAAC;AAC3D,4CAAgC,CAAC,mBAAmB,CAAC;AACrD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAuC,CAAC,2BAA2B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAzBA,4CAA2B,CAAC,cAAc,CAAC;AAC3C,4CAA4B,CAAC,eAAe,CAAC;AAC7C,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAAmC,CAAC,sBAAsB,CAAC;AAC3D,4CAAgC,CAAC,mBAAmB,CAAC;AACrD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAuC,CAAC,2BAA2B,EAAE,2CAA2C;AAChH,4CAA8C,CAAC,iCAAiC,CAAC;AACjF,4CAAiC,CAAC,qBAAqB,EAAE,2CAAsC;AAC/F,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAwC,CAAC,2BAA2B,CAAC;AACrE,4CAAsC,CAAC,yBAAyB,CAAC;AACjE,4CAAyC,CAAC,4BAA4B,CAAC;AACvE,4CAAsC,CAAC,yBAAyB,CAAC;AACjE,2CAA8C,CAAC,iCAAiC,CAAC;AACjF,4CAAkC,CAAC,qBAAqB,CAAC;AACzD,4CAA+C,CAAC,kCAAkC,CAAC;AACnF,4CAA0C,CAAC,6BAA6B,CAAC;AACzE,4CAA4C,CAAC,+BAA+B,CAAC;AAC7E,4CAAmD,CAAC,sCAAsC,CAAC;AAC3F,2CAA8C,CAAC,iCAAiC,CAAC;AACjF,4CAA+C,CAAC,kCAAkC,CAAC;AACnF,4CAA6D,CAAC,gDAAgD,CAAC","sources":["packages/@adobe/spectrum-css-temp/components/tags/vars.css"],"sourcesContent":["/*\n * Copyright 2020 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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"tags_vars_css.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/tag",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.11",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/focus": "^3.
|
|
40
|
-
"@react-aria/i18n": "^3.12.
|
|
41
|
-
"@react-aria/interactions": "^3.22.
|
|
42
|
-
"@react-aria/selection": "^3.
|
|
43
|
-
"@react-aria/tag": "^3.4.
|
|
44
|
-
"@react-aria/utils": "^3.
|
|
45
|
-
"@react-spectrum/button": "^3.16.
|
|
46
|
-
"@react-spectrum/form": "^3.7.
|
|
47
|
-
"@react-spectrum/label": "^3.16.
|
|
48
|
-
"@react-spectrum/text": "^3.5.
|
|
49
|
-
"@react-spectrum/utils": "^3.
|
|
50
|
-
"@react-stately/collections": "^3.
|
|
51
|
-
"@react-stately/list": "^3.11.
|
|
52
|
-
"@react-types/shared": "^3.
|
|
39
|
+
"@react-aria/focus": "^3.19.0",
|
|
40
|
+
"@react-aria/i18n": "^3.12.4",
|
|
41
|
+
"@react-aria/interactions": "^3.22.5",
|
|
42
|
+
"@react-aria/selection": "^3.21.0",
|
|
43
|
+
"@react-aria/tag": "^3.4.8",
|
|
44
|
+
"@react-aria/utils": "^3.26.0",
|
|
45
|
+
"@react-spectrum/button": "^3.16.9",
|
|
46
|
+
"@react-spectrum/form": "^3.7.10",
|
|
47
|
+
"@react-spectrum/label": "^3.16.10",
|
|
48
|
+
"@react-spectrum/text": "^3.5.10",
|
|
49
|
+
"@react-spectrum/utils": "^3.12.0",
|
|
50
|
+
"@react-stately/collections": "^3.12.0",
|
|
51
|
+
"@react-stately/list": "^3.11.1",
|
|
52
|
+
"@react-types/shared": "^3.26.0",
|
|
53
53
|
"@swc/helpers": "^0.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@react-spectrum/provider": "^3.0.0",
|
|
60
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
61
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
60
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
61
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
67
67
|
}
|
package/src/TagGroup.tsx
CHANGED
|
@@ -62,7 +62,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
62
62
|
renderEmptyState = () => stringFormatter.format('noTags')
|
|
63
63
|
} = props;
|
|
64
64
|
let domRef = useDOMRef(ref);
|
|
65
|
-
let containerRef = useRef(null);
|
|
65
|
+
let containerRef = useRef<HTMLDivElement>(null);
|
|
66
66
|
let tagsRef = useRef<HTMLDivElement | null>(null);
|
|
67
67
|
let {direction} = useLocale();
|
|
68
68
|
let {scale} = useProvider();
|
|
@@ -85,7 +85,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
85
85
|
delete props.onAction;
|
|
86
86
|
let {gridProps, labelProps, descriptionProps, errorMessageProps} = useTagGroup({...props, keyboardDelegate}, state, tagsRef);
|
|
87
87
|
let actionsId = useId();
|
|
88
|
-
let actionsRef = useRef(null);
|
|
88
|
+
let actionsRef = useRef<HTMLDivElement>(null);
|
|
89
89
|
|
|
90
90
|
let updateVisibleTagCount = useCallback(() => {
|
|
91
91
|
if (maxRows && maxRows > 0) {
|
|
@@ -124,7 +124,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
124
124
|
|
|
125
125
|
// Remove tags until there is space for the collapse button and action button (if present) on the last row.
|
|
126
126
|
let buttons = [...currActionsRef.children];
|
|
127
|
-
if (maxRows && buttons.length > 0 && rowCount >= maxRows) {
|
|
127
|
+
if (maxRows && buttons.length > 0 && rowCount >= maxRows && currContainerRef.parentElement) {
|
|
128
128
|
let buttonsWidth = buttons.reduce((acc, curr) => acc += curr.getBoundingClientRect().width, 0);
|
|
129
129
|
buttonsWidth += TAG_STYLES[scale].margin * 2 * buttons.length;
|
|
130
130
|
let end = direction === 'ltr' ? 'right' : 'left';
|
|
@@ -134,7 +134,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
134
134
|
let availableWidth = containerEnd - lastTagEnd;
|
|
135
135
|
|
|
136
136
|
while (availableWidth < buttonsWidth && index > 0) {
|
|
137
|
-
availableWidth += tagWidths.pop()
|
|
137
|
+
availableWidth += tagWidths.pop()!;
|
|
138
138
|
index--;
|
|
139
139
|
}
|
|
140
140
|
}
|