@react-spectrum/tag 3.1.3 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +85 -85
- package/dist/main.css +1 -1
- package/dist/main.js +85 -85
- package/dist/main.js.map +1 -1
- package/dist/module.js +85 -85
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/Tag.tsx +1 -1
- package/src/TagGroup.tsx +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/tag",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
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.
|
|
41
|
-
"@react-aria/interactions": "^3.
|
|
42
|
-
"@react-aria/selection": "^3.17.
|
|
43
|
-
"@react-aria/tag": "^3.
|
|
44
|
-
"@react-aria/utils": "^3.
|
|
45
|
-
"@react-spectrum/button": "^3.
|
|
46
|
-
"@react-spectrum/form": "^3.
|
|
47
|
-
"@react-spectrum/label": "^3.
|
|
48
|
-
"@react-spectrum/text": "^3.
|
|
49
|
-
"@react-spectrum/utils": "^3.11.
|
|
50
|
-
"@react-stately/collections": "^3.10.
|
|
51
|
-
"@react-stately/list": "^3.10.
|
|
52
|
-
"@react-types/shared": "^3.
|
|
39
|
+
"@react-aria/focus": "^3.15.0",
|
|
40
|
+
"@react-aria/i18n": "^3.9.0",
|
|
41
|
+
"@react-aria/interactions": "^3.20.0",
|
|
42
|
+
"@react-aria/selection": "^3.17.2",
|
|
43
|
+
"@react-aria/tag": "^3.3.0",
|
|
44
|
+
"@react-aria/utils": "^3.22.0",
|
|
45
|
+
"@react-spectrum/button": "^3.15.0",
|
|
46
|
+
"@react-spectrum/form": "^3.7.0",
|
|
47
|
+
"@react-spectrum/label": "^3.16.0",
|
|
48
|
+
"@react-spectrum/text": "^3.5.0",
|
|
49
|
+
"@react-spectrum/utils": "^3.11.2",
|
|
50
|
+
"@react-stately/collections": "^3.10.3",
|
|
51
|
+
"@react-stately/list": "^3.10.1",
|
|
52
|
+
"@react-types/shared": "^3.22.0",
|
|
53
53
|
"@swc/helpers": "^0.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "9ce2f674eab2cc8912800d3162dcf00a1ce94274"
|
|
67
67
|
}
|
package/src/Tag.tsx
CHANGED
|
@@ -36,7 +36,7 @@ export function Tag<T>(props: SpectrumTagProps<T>) {
|
|
|
36
36
|
let {styleProps} = useStyleProps(otherProps);
|
|
37
37
|
let {hoverProps, isHovered} = useHover({});
|
|
38
38
|
let {isFocused, isFocusVisible, focusProps} = useFocusRing({within: true});
|
|
39
|
-
let ref = useRef();
|
|
39
|
+
let ref = useRef(null);
|
|
40
40
|
let {removeButtonProps, gridCellProps, rowProps, allowsRemoving} = useTag({
|
|
41
41
|
...props,
|
|
42
42
|
item
|
package/src/TagGroup.tsx
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import {ActionButton} from '@react-spectrum/button';
|
|
14
14
|
import {AriaTagGroupProps, useTagGroup} from '@react-aria/tag';
|
|
15
15
|
import {classNames, useDOMRef} from '@react-spectrum/utils';
|
|
16
|
-
import {DOMRef, SpectrumLabelableProps, StyleProps, Validation} from '@react-types/shared';
|
|
16
|
+
import {Collection, DOMRef, Node, SpectrumLabelableProps, StyleProps, Validation} from '@react-types/shared';
|
|
17
17
|
import {Field} from '@react-spectrum/label';
|
|
18
18
|
import {FocusRing, FocusScope} from '@react-aria/focus';
|
|
19
19
|
// @ts-ignore
|
|
@@ -39,13 +39,13 @@ const TAG_STYLES = {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
export interface SpectrumTagGroupProps<T> extends Omit<AriaTagGroupProps<T>, 'selectionMode' | 'disallowEmptySelection' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionBehavior' | 'disabledKeys'>, StyleProps, Omit<SpectrumLabelableProps, 'isRequired' | 'necessityIndicator'>,
|
|
42
|
+
export interface SpectrumTagGroupProps<T> extends Omit<AriaTagGroupProps<T>, 'selectionMode' | 'disallowEmptySelection' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionBehavior' | 'disabledKeys'>, StyleProps, Omit<SpectrumLabelableProps, 'isRequired' | 'necessityIndicator'>, Pick<Validation<any>, 'isInvalid' | 'validationState'> {
|
|
43
43
|
/** The label to display on the action button. */
|
|
44
44
|
actionLabel?: string,
|
|
45
45
|
/** Handler that is called when the action button is pressed. */
|
|
46
46
|
onAction?: () => void,
|
|
47
47
|
/** Sets what the TagGroup should render when there are no tags to display. */
|
|
48
|
-
renderEmptyState?: () => JSX.Element,
|
|
48
|
+
renderEmptyState?: () => React.JSX.Element,
|
|
49
49
|
/** Limit the number of rows initially shown. This will render a button that allows the user to expand to show all tags. */
|
|
50
50
|
maxRows?: number
|
|
51
51
|
}
|
|
@@ -63,7 +63,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
63
63
|
} = props;
|
|
64
64
|
let domRef = useDOMRef(ref);
|
|
65
65
|
let containerRef = useRef(null);
|
|
66
|
-
let tagsRef = useRef(null);
|
|
66
|
+
let tagsRef = useRef<HTMLDivElement | null>(null);
|
|
67
67
|
let {direction} = useLocale();
|
|
68
68
|
let {scale} = useProvider();
|
|
69
69
|
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
@@ -71,9 +71,9 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
71
71
|
let state = useListState(props);
|
|
72
72
|
let [tagState, setTagState] = useValueEffect({visibleTagCount: state.collection.size, showCollapseButton: false});
|
|
73
73
|
let keyboardDelegate = useMemo(() => {
|
|
74
|
-
let collection = isCollapsed
|
|
74
|
+
let collection = (isCollapsed
|
|
75
75
|
? new ListCollection([...state.collection].slice(0, tagState.visibleTagCount))
|
|
76
|
-
: new ListCollection([...state.collection])
|
|
76
|
+
: new ListCollection([...state.collection])) as Collection<Node<T>>;
|
|
77
77
|
return new ListKeyboardDelegate({
|
|
78
78
|
collection,
|
|
79
79
|
ref: domRef,
|
|
@@ -88,7 +88,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
88
88
|
let actionsRef = useRef(null);
|
|
89
89
|
|
|
90
90
|
let updateVisibleTagCount = useCallback(() => {
|
|
91
|
-
if (maxRows > 0) {
|
|
91
|
+
if (maxRows && maxRows > 0) {
|
|
92
92
|
let computeVisibleTagCount = () => {
|
|
93
93
|
// Refs can be null at runtime.
|
|
94
94
|
let currContainerRef: HTMLDivElement | null = containerRef.current;
|
|
@@ -115,7 +115,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
|
|
|
115
115
|
rowCount++;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
if (rowCount > maxRows) {
|
|
118
|
+
if (maxRows && rowCount > maxRows) {
|
|
119
119
|
break;
|
|
120
120
|
}
|
|
121
121
|
tagWidths.push(width);
|
|
@@ -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 (buttons.length > 0 && rowCount >= maxRows) {
|
|
127
|
+
if (maxRows && buttons.length > 0 && rowCount >= maxRows) {
|
|
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';
|