@react-spectrum/tag 3.2.4 → 3.2.5

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 (63) hide show
  1. package/dist/Tag.main.js +92 -0
  2. package/dist/Tag.main.js.map +1 -0
  3. package/dist/Tag.mjs +87 -0
  4. package/dist/Tag.module.js +87 -0
  5. package/dist/Tag.module.js.map +1 -0
  6. package/dist/TagGroup.main.js +270 -0
  7. package/dist/TagGroup.main.js.map +1 -0
  8. package/dist/TagGroup.mjs +265 -0
  9. package/dist/TagGroup.module.js +265 -0
  10. package/dist/TagGroup.module.js.map +1 -0
  11. package/dist/ar-AE.mjs +1 -1
  12. package/dist/bg-BG.mjs +1 -1
  13. package/dist/cs-CZ.mjs +1 -1
  14. package/dist/da-DK.mjs +1 -1
  15. package/dist/de-DE.mjs +1 -1
  16. package/dist/el-GR.mjs +1 -1
  17. package/dist/en-US.mjs +1 -1
  18. package/dist/es-ES.mjs +1 -1
  19. package/dist/et-EE.mjs +1 -1
  20. package/dist/fi-FI.mjs +1 -1
  21. package/dist/fr-FR.mjs +1 -1
  22. package/dist/he-IL.mjs +1 -1
  23. package/dist/hr-HR.mjs +1 -1
  24. package/dist/hu-HU.mjs +1 -1
  25. package/dist/import.mjs +1 -520
  26. package/dist/intlStrings.main.js +108 -0
  27. package/dist/intlStrings.main.js.map +1 -0
  28. package/dist/intlStrings.mjs +110 -0
  29. package/dist/intlStrings.module.js +110 -0
  30. package/dist/intlStrings.module.js.map +1 -0
  31. package/dist/it-IT.mjs +1 -1
  32. package/dist/ja-JP.mjs +1 -1
  33. package/dist/ko-KR.mjs +1 -1
  34. package/dist/lt-LT.mjs +1 -1
  35. package/dist/lv-LV.mjs +1 -1
  36. package/dist/main.js +2 -517
  37. package/dist/main.js.map +1 -1
  38. package/dist/module.js +1 -520
  39. package/dist/module.js.map +1 -1
  40. package/dist/nb-NO.mjs +1 -1
  41. package/dist/nl-NL.mjs +1 -1
  42. package/dist/pl-PL.mjs +1 -1
  43. package/dist/pt-BR.mjs +1 -1
  44. package/dist/pt-PT.mjs +1 -1
  45. package/dist/ro-RO.mjs +1 -1
  46. package/dist/ru-RU.mjs +1 -1
  47. package/dist/sk-SK.mjs +1 -1
  48. package/dist/sl-SI.mjs +1 -1
  49. package/dist/sr-SP.mjs +1 -1
  50. package/dist/sv-SE.mjs +1 -1
  51. package/dist/tags_vars_css.main.js +86 -0
  52. package/dist/tags_vars_css.main.js.map +1 -0
  53. package/dist/tags_vars_css.mjs +88 -0
  54. package/dist/tags_vars_css.module.js +88 -0
  55. package/dist/tags_vars_css.module.js.map +1 -0
  56. package/dist/tr-TR.mjs +1 -1
  57. package/dist/uk-UA.mjs +1 -1
  58. package/dist/{main.css → vars.0a7fe83c.css} +14 -24
  59. package/dist/vars.0a7fe83c.css.map +1 -0
  60. package/dist/zh-CN.mjs +1 -1
  61. package/dist/zh-TW.mjs +1 -1
  62. package/package.json +16 -16
  63. package/dist/main.css.map +0 -1
@@ -0,0 +1,92 @@
1
+ require("./vars.0a7fe83c.css");
2
+ var $ed889f8f1f091fc8$exports = require("./tags_vars_css.main.js");
3
+ var $hZPqg$reactariatag = require("@react-aria/tag");
4
+ var $hZPqg$reactspectrumutils = require("@react-spectrum/utils");
5
+ var $hZPqg$reactspectrumbutton = require("@react-spectrum/button");
6
+ var $hZPqg$reactariautils = require("@react-aria/utils");
7
+ var $hZPqg$react = require("react");
8
+ var $hZPqg$reactspectrumtext = require("@react-spectrum/text");
9
+ var $hZPqg$reactariafocus = require("@react-aria/focus");
10
+ var $hZPqg$reactariainteractions = require("@react-aria/interactions");
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+
17
+ function $parcel$export(e, n, v, s) {
18
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
+ }
20
+
21
+ $parcel$export(module.exports, "Tag", () => $dd2c5d00108c1840$export$3288d34c523a1192);
22
+ /*
23
+ * Copyright 2020 Adobe. All rights reserved.
24
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License. You may obtain a copy
26
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software distributed under
29
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
+ * OF ANY KIND, either express or implied. See the License for the specific language
31
+ * governing permissions and limitations under the License.
32
+ */
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+ function $dd2c5d00108c1840$export$3288d34c523a1192(props) {
42
+ const { item: item, state: state, ...otherProps } = props;
43
+ // @ts-ignore
44
+ let { styleProps: styleProps } = (0, $hZPqg$reactspectrumutils.useStyleProps)(otherProps);
45
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $hZPqg$reactariainteractions.useHover)({});
46
+ let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $hZPqg$reactariafocus.useFocusRing)({
47
+ within: true
48
+ });
49
+ let ref = (0, $hZPqg$react.useRef)(null);
50
+ let { removeButtonProps: removeButtonProps, gridCellProps: gridCellProps, rowProps: rowProps, allowsRemoving: allowsRemoving } = (0, $hZPqg$reactariatag.useTag)({
51
+ ...props,
52
+ item: item
53
+ }, state, ref);
54
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement("div", {
55
+ ...(0, $hZPqg$reactariautils.mergeProps)(rowProps, hoverProps, focusProps),
56
+ className: (0, $hZPqg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tag", {
57
+ "focus-ring": isFocusVisible,
58
+ "is-focused": isFocused,
59
+ "is-hovered": isHovered,
60
+ "spectrum-Tag--removable": allowsRemoving
61
+ }, styleProps.className),
62
+ ref: ref
63
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement("div", {
64
+ className: (0, $hZPqg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tag-cell"),
65
+ ...gridCellProps
66
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement((0, $hZPqg$reactspectrumutils.SlotProvider), {
67
+ slots: {
68
+ icon: {
69
+ UNSAFE_className: (0, $hZPqg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tag-icon"),
70
+ size: "XS"
71
+ },
72
+ text: {
73
+ UNSAFE_className: (0, $hZPqg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tag-content")
74
+ },
75
+ avatar: {
76
+ UNSAFE_className: (0, $hZPqg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tag-avatar"),
77
+ size: "avatar-size-50"
78
+ }
79
+ }
80
+ }, typeof item.rendered === "string" ? /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement((0, $hZPqg$reactspectrumtext.Text), null, item.rendered) : item.rendered, /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement((0, $hZPqg$reactspectrumutils.ClearSlots), null, allowsRemoving && /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement($dd2c5d00108c1840$var$TagRemoveButton, {
81
+ item: item,
82
+ ...removeButtonProps,
83
+ UNSAFE_className: (0, $hZPqg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tag-removeButton")
84
+ })))));
85
+ }
86
+ function $dd2c5d00108c1840$var$TagRemoveButton(props) {
87
+ let { styleProps: styleProps } = (0, $hZPqg$reactspectrumutils.useStyleProps)(props);
88
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement("span", styleProps, /*#__PURE__*/ (0, ($parcel$interopDefault($hZPqg$react))).createElement((0, $hZPqg$reactspectrumb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,QAAQ;gBAAC,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;gBAAwB,MAAM;YAAgB;QAC9F;OACC,OAAO,KAAK,QAAQ,KAAK,yBAAW,0DAAC,CAAA,GAAA,6BAAG,SAAG,KAAK,QAAQ,IAAW,KAAK,QAAQ,gBACjF,0DAAC,CAAA,GAAA,oCAAS,SACP,gCAAkB,0DAAC;QAAgB,MAAM;QAAO,GAAG,iBAAiB;QAAE,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;;AAMxH;AAEA,SAAS,sCAAgB,KAAK;IAC5B,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IAEjC,qBACE,0DAAC,QAAS,0BACR,0DAAC,CAAA,GAAA,sCAAU,GAAM;AAGvB","sources":["packages/@react-spectrum/tag/src/Tag.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 {AriaTagProps, useTag} from '@react-aria/tag';\nimport {classNames, ClearSlots, SlotProvider, useStyleProps} from '@react-spectrum/utils';\nimport {ClearButton} from '@react-spectrum/button';\nimport type {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/tags/vars.css';\nimport {Text} from '@react-spectrum/text';\nimport {useFocusRing} from '@react-aria/focus';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface SpectrumTagProps<T> extends AriaTagProps<T> {\n state: ListState<T>\n}\n\nexport function Tag<T>(props: SpectrumTagProps<T>) {\n const {\n item,\n state,\n ...otherProps\n } = props;\n\n // @ts-ignore\n let {styleProps} = useStyleProps(otherProps);\n let {hoverProps, isHovered} = useHover({});\n let {isFocused, isFocusVisible, focusProps} = useFocusRing({within: true});\n let ref = useRef(null);\n let {removeButtonProps, gridCellProps, rowProps, allowsRemoving} = useTag({\n ...props,\n item\n }, state, ref);\n\n return (\n <div\n {...mergeProps(rowProps, hoverProps, focusProps)}\n className={classNames(\n styles,\n 'spectrum-Tag',\n {\n 'focus-ring': isFocusVisible,\n 'is-focused': isFocused,\n 'is-hovered': isHovered,\n 'spectrum-Tag--removable': allowsRemoving\n },\n styleProps.className\n )}\n ref={ref}>\n <div\n className={classNames(styles, 'spectrum-Tag-cell')}\n {...gridCellProps}>\n <SlotProvider\n slots={{\n icon: {UNSAFE_className: classNames(styles, 'spectrum-Tag-icon'), size: 'XS'},\n text: {UNSAFE_className: classNames(styles, 'spectrum-Tag-content')},\n avatar: {UNSAFE_className: classNames(styles, 'spectrum-Tag-avatar'), size: 'avatar-size-50'}\n }}>\n {typeof item.rendered === 'string' ? <Text>{item.rendered}</Text> : item.rendered}\n <ClearSlots>\n {allowsRemoving && <TagRemoveButton item={item} {...removeButtonProps} UNSAFE_className={classNames(styles, 'spectrum-Tag-removeButton')} />}\n </ClearSlots>\n </SlotProvider>\n </div>\n </div>\n );\n}\n\nfunction TagRemoveButton(props) {\n let {styleProps} = useStyleProps(props);\n\n return (\n <span {...styleProps}>\n <ClearButton {...props} />\n </span>\n );\n}\n"],"names":[],"version":3,"file":"Tag.main.js.map"}
package/dist/Tag.mjs ADDED
@@ -0,0 +1,87 @@
1
+ import "./vars.0a7fe83c.css";
2
+ import $X1F04$tags_vars_cssmodulejs from "./tags_vars_css.mjs";
3
+ import {useTag as $X1F04$useTag} from "@react-aria/tag";
4
+ import {useStyleProps as $X1F04$useStyleProps, classNames as $X1F04$classNames, SlotProvider as $X1F04$SlotProvider, ClearSlots as $X1F04$ClearSlots} from "@react-spectrum/utils";
5
+ import {ClearButton as $X1F04$ClearButton} from "@react-spectrum/button";
6
+ import {mergeProps as $X1F04$mergeProps} from "@react-aria/utils";
7
+ import $X1F04$react, {useRef as $X1F04$useRef} from "react";
8
+ import {Text as $X1F04$Text} from "@react-spectrum/text";
9
+ import {useFocusRing as $X1F04$useFocusRing} from "@react-aria/focus";
10
+ import {useHover as $X1F04$useHover} from "@react-aria/interactions";
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ function $b5f5ee35d3b6b95c$export$3288d34c523a1192(props) {
36
+ const { item: item, state: state, ...otherProps } = props;
37
+ // @ts-ignore
38
+ let { styleProps: styleProps } = (0, $X1F04$useStyleProps)(otherProps);
39
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $X1F04$useHover)({});
40
+ let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $X1F04$useFocusRing)({
41
+ within: true
42
+ });
43
+ let ref = (0, $X1F04$useRef)(null);
44
+ let { removeButtonProps: removeButtonProps, gridCellProps: gridCellProps, rowProps: rowProps, allowsRemoving: allowsRemoving } = (0, $X1F04$useTag)({
45
+ ...props,
46
+ item: item
47
+ }, state, ref);
48
+ return /*#__PURE__*/ (0, $X1F04$react).createElement("div", {
49
+ ...(0, $X1F04$mergeProps)(rowProps, hoverProps, focusProps),
50
+ className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag", {
51
+ "focus-ring": isFocusVisible,
52
+ "is-focused": isFocused,
53
+ "is-hovered": isHovered,
54
+ "spectrum-Tag--removable": allowsRemoving
55
+ }, styleProps.className),
56
+ ref: ref
57
+ }, /*#__PURE__*/ (0, $X1F04$react).createElement("div", {
58
+ className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-cell"),
59
+ ...gridCellProps
60
+ }, /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$SlotProvider), {
61
+ slots: {
62
+ icon: {
63
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-icon"),
64
+ size: "XS"
65
+ },
66
+ text: {
67
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-content")
68
+ },
69
+ avatar: {
70
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-avatar"),
71
+ size: "avatar-size-50"
72
+ }
73
+ }
74
+ }, typeof item.rendered === "string" ? /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$Text), null, item.rendered) : item.rendered, /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$ClearSlots), null, allowsRemoving && /*#__PURE__*/ (0, $X1F04$react).createElement($b5f5ee35d3b6b95c$var$TagRemoveButton, {
75
+ item: item,
76
+ ...removeButtonProps,
77
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-removeButton")
78
+ })))));
79
+ }
80
+ function $b5f5ee35d3b6b95c$var$TagRemoveButton(props) {
81
+ let { styleProps: styleProps } = (0, $X1F04$useStyleProps)(props);
82
+ return /*#__PURE__*/ (0, $X1F04$react).createElement("span", styleProps, /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$ClearButton), props));
83
+ }
84
+
85
+
86
+ export {$b5f5ee35d3b6b95c$export$3288d34c523a1192 as Tag};
87
+ //# sourceMappingURL=Tag.mjs.map
@@ -0,0 +1,87 @@
1
+ import "./vars.0a7fe83c.css";
2
+ import $X1F04$tags_vars_cssmodulejs from "./tags_vars_css.module.js";
3
+ import {useTag as $X1F04$useTag} from "@react-aria/tag";
4
+ import {useStyleProps as $X1F04$useStyleProps, classNames as $X1F04$classNames, SlotProvider as $X1F04$SlotProvider, ClearSlots as $X1F04$ClearSlots} from "@react-spectrum/utils";
5
+ import {ClearButton as $X1F04$ClearButton} from "@react-spectrum/button";
6
+ import {mergeProps as $X1F04$mergeProps} from "@react-aria/utils";
7
+ import $X1F04$react, {useRef as $X1F04$useRef} from "react";
8
+ import {Text as $X1F04$Text} from "@react-spectrum/text";
9
+ import {useFocusRing as $X1F04$useFocusRing} from "@react-aria/focus";
10
+ import {useHover as $X1F04$useHover} from "@react-aria/interactions";
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ function $b5f5ee35d3b6b95c$export$3288d34c523a1192(props) {
36
+ const { item: item, state: state, ...otherProps } = props;
37
+ // @ts-ignore
38
+ let { styleProps: styleProps } = (0, $X1F04$useStyleProps)(otherProps);
39
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $X1F04$useHover)({});
40
+ let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $X1F04$useFocusRing)({
41
+ within: true
42
+ });
43
+ let ref = (0, $X1F04$useRef)(null);
44
+ let { removeButtonProps: removeButtonProps, gridCellProps: gridCellProps, rowProps: rowProps, allowsRemoving: allowsRemoving } = (0, $X1F04$useTag)({
45
+ ...props,
46
+ item: item
47
+ }, state, ref);
48
+ return /*#__PURE__*/ (0, $X1F04$react).createElement("div", {
49
+ ...(0, $X1F04$mergeProps)(rowProps, hoverProps, focusProps),
50
+ className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag", {
51
+ "focus-ring": isFocusVisible,
52
+ "is-focused": isFocused,
53
+ "is-hovered": isHovered,
54
+ "spectrum-Tag--removable": allowsRemoving
55
+ }, styleProps.className),
56
+ ref: ref
57
+ }, /*#__PURE__*/ (0, $X1F04$react).createElement("div", {
58
+ className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-cell"),
59
+ ...gridCellProps
60
+ }, /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$SlotProvider), {
61
+ slots: {
62
+ icon: {
63
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-icon"),
64
+ size: "XS"
65
+ },
66
+ text: {
67
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-content")
68
+ },
69
+ avatar: {
70
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-avatar"),
71
+ size: "avatar-size-50"
72
+ }
73
+ }
74
+ }, typeof item.rendered === "string" ? /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$Text), null, item.rendered) : item.rendered, /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$ClearSlots), null, allowsRemoving && /*#__PURE__*/ (0, $X1F04$react).createElement($b5f5ee35d3b6b95c$var$TagRemoveButton, {
75
+ item: item,
76
+ ...removeButtonProps,
77
+ UNSAFE_className: (0, $X1F04$classNames)((0, ($parcel$interopDefault($X1F04$tags_vars_cssmodulejs))), "spectrum-Tag-removeButton")
78
+ })))));
79
+ }
80
+ function $b5f5ee35d3b6b95c$var$TagRemoveButton(props) {
81
+ let { styleProps: styleProps } = (0, $X1F04$useStyleProps)(props);
82
+ return /*#__PURE__*/ (0, $X1F04$react).createElement("span", styleProps, /*#__PURE__*/ (0, $X1F04$react).createElement((0, $X1F04$ClearButton), props));
83
+ }
84
+
85
+
86
+ export {$b5f5ee35d3b6b95c$export$3288d34c523a1192 as Tag};
87
+ //# sourceMappingURL=Tag.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAiBM,SAAS,0CAAO,KAA0B;IAC/C,MAAM,QACJ,IAAI,SACJ,KAAK,EACL,GAAG,YACJ,GAAG;IAEJ,aAAa;IACb,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE,CAAC;IACxC,IAAI,aAAC,SAAS,kBAAE,cAAc,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE;QAAC,QAAQ;IAAI;IACxE,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE;IACjB,IAAI,qBAAC,iBAAiB,iBAAE,aAAa,YAAE,QAAQ,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,aAAK,EAAE;QACxE,GAAG,KAAK;cACR;IACF,GAAG,OAAO;IAEV,qBACE,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,WAAW;QAChD,WAAW,CAAA,GAAA,iBAAS,EAChB,CAAA,GAAA,sDAAK,GACL,gBACF;YACE,cAAc;YACd,cAAc;YACd,cAAc;YACd,2BAA2B;QAC7B,GACE,WAAW,SAAS;QAExB,KAAK;qBACL,gCAAC;QACC,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;QAC7B,GAAG,aAAa;qBACjB,gCAAC,CAAA,GAAA,mBAAW;QACV,OAAO;YACL,MAAM;gBAAC,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;gBAAsB,MAAM;YAAI;YAC5E,MAAM;gBAAC,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;YAAuB;YACnE,QAAQ;gBAAC,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;gBAAwB,MAAM;YAAgB;QAC9F;OACC,OAAO,KAAK,QAAQ,KAAK,yBAAW,gCAAC,CAAA,GAAA,WAAG,SAAG,KAAK,QAAQ,IAAW,KAAK,QAAQ,gBACjF,gCAAC,CAAA,GAAA,iBAAS,SACP,gCAAkB,gCAAC;QAAgB,MAAM;QAAO,GAAG,iBAAiB;QAAE,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;;AAMxH;AAEA,SAAS,sCAAgB,KAAK;IAC5B,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IAEjC,qBACE,gCAAC,QAAS,0BACR,gCAAC,CAAA,GAAA,kBAAU,GAAM;AAGvB","sources":["packages/@react-spectrum/tag/src/Tag.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 {AriaTagProps, useTag} from '@react-aria/tag';\nimport {classNames, ClearSlots, SlotProvider, useStyleProps} from '@react-spectrum/utils';\nimport {ClearButton} from '@react-spectrum/button';\nimport type {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/tags/vars.css';\nimport {Text} from '@react-spectrum/text';\nimport {useFocusRing} from '@react-aria/focus';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface SpectrumTagProps<T> extends AriaTagProps<T> {\n state: ListState<T>\n}\n\nexport function Tag<T>(props: SpectrumTagProps<T>) {\n const {\n item,\n state,\n ...otherProps\n } = props;\n\n // @ts-ignore\n let {styleProps} = useStyleProps(otherProps);\n let {hoverProps, isHovered} = useHover({});\n let {isFocused, isFocusVisible, focusProps} = useFocusRing({within: true});\n let ref = useRef(null);\n let {removeButtonProps, gridCellProps, rowProps, allowsRemoving} = useTag({\n ...props,\n item\n }, state, ref);\n\n return (\n <div\n {...mergeProps(rowProps, hoverProps, focusProps)}\n className={classNames(\n styles,\n 'spectrum-Tag',\n {\n 'focus-ring': isFocusVisible,\n 'is-focused': isFocused,\n 'is-hovered': isHovered,\n 'spectrum-Tag--removable': allowsRemoving\n },\n styleProps.className\n )}\n ref={ref}>\n <div\n className={classNames(styles, 'spectrum-Tag-cell')}\n {...gridCellProps}>\n <SlotProvider\n slots={{\n icon: {UNSAFE_className: classNames(styles, 'spectrum-Tag-icon'), size: 'XS'},\n text: {UNSAFE_className: classNames(styles, 'spectrum-Tag-content')},\n avatar: {UNSAFE_className: classNames(styles, 'spectrum-Tag-avatar'), size: 'avatar-size-50'}\n }}>\n {typeof item.rendered === 'string' ? <Text>{item.rendered}</Text> : item.rendered}\n <ClearSlots>\n {allowsRemoving && <TagRemoveButton item={item} {...removeButtonProps} UNSAFE_className={classNames(styles, 'spectrum-Tag-removeButton')} />}\n </ClearSlots>\n </SlotProvider>\n </div>\n </div>\n );\n}\n\nfunction TagRemoveButton(props) {\n let {styleProps} = useStyleProps(props);\n\n return (\n <span {...styleProps}>\n <ClearButton {...props} />\n </span>\n );\n}\n"],"names":[],"version":3,"file":"Tag.module.js.map"}
@@ -0,0 +1,270 @@
1
+ var $a85da3418799ba7d$exports = require("./intlStrings.main.js");
2
+ require("./vars.0a7fe83c.css");
3
+ var $ed889f8f1f091fc8$exports = require("./tags_vars_css.main.js");
4
+ var $dd2c5d00108c1840$exports = require("./Tag.main.js");
5
+ var $gBwi7$reactspectrumbutton = require("@react-spectrum/button");
6
+ var $gBwi7$reactariatag = require("@react-aria/tag");
7
+ var $gBwi7$reactspectrumutils = require("@react-spectrum/utils");
8
+ var $gBwi7$reactspectrumlabel = require("@react-spectrum/label");
9
+ var $gBwi7$reactariafocus = require("@react-aria/focus");
10
+ var $gBwi7$reactstatelylist = require("@react-stately/list");
11
+ var $gBwi7$reactariaselection = require("@react-aria/selection");
12
+ var $gBwi7$reactspectrumprovider = require("@react-spectrum/provider");
13
+ var $gBwi7$react = require("react");
14
+ var $gBwi7$reactspectrumform = require("@react-spectrum/form");
15
+ var $gBwi7$reactariautils = require("@react-aria/utils");
16
+ var $gBwi7$reactariai18n = require("@react-aria/i18n");
17
+
18
+
19
+ function $parcel$interopDefault(a) {
20
+ return a && a.__esModule ? a.default : a;
21
+ }
22
+
23
+ function $parcel$export(e, n, v, s) {
24
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
25
+ }
26
+
27
+ $parcel$export(module.exports, "TagGroup", () => $e7b72d8874e98cd4$export$67ea30858aaf75e3);
28
+ /*
29
+ * Copyright 2020 Adobe. All rights reserved.
30
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
31
+ * you may not use this file except in compliance with the License. You may obtain a copy
32
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
33
+ *
34
+ * Unless required by applicable law or agreed to in writing, software distributed under
35
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
36
+ * OF ANY KIND, either express or implied. See the License for the specific language
37
+ * governing permissions and limitations under the License.
38
+ */
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+ const $e7b72d8874e98cd4$var$TAG_STYLES = {
54
+ medium: {
55
+ height: 24,
56
+ margin: 4
57
+ },
58
+ large: {
59
+ height: 30,
60
+ margin: 5
61
+ }
62
+ };
63
+ function $e7b72d8874e98cd4$var$TagGroup(props, ref) {
64
+ props = (0, $gBwi7$reactspectrumprovider.useProviderProps)(props);
65
+ props = (0, $gBwi7$reactspectrumform.useFormProps)(props);
66
+ let { maxRows: maxRows, children: children, actionLabel: actionLabel, onAction: onAction, labelPosition: labelPosition, renderEmptyState: renderEmptyState = ()=>stringFormatter.format("noTags") } = props;
67
+ let domRef = (0, $gBwi7$reactspectrumutils.useDOMRef)(ref);
68
+ let containerRef = (0, $gBwi7$react.useRef)(null);
69
+ let tagsRef = (0, $gBwi7$react.useRef)(null);
70
+ let { direction: direction } = (0, $gBwi7$reactariai18n.useLocale)();
71
+ let { scale: scale } = (0, $gBwi7$reactspectrumprovider.useProvider)();
72
+ let stringFormatter = (0, $gBwi7$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($a85da3418799ba7d$exports))), "@react-spectrum/tag");
73
+ let [isCollapsed, setIsCollapsed] = (0, $gBwi7$react.useState)(maxRows != null);
74
+ let state = (0, $gBwi7$reactstatelylist.useListState)(props);
75
+ let [tagState, setTagState] = (0, $gBwi7$reactariautils.useValueEffect)({
76
+ visibleTagCount: state.collection.size,
77
+ showCollapseButton: false
78
+ });
79
+ let keyboardDelegate = (0, $gBwi7$react.useMemo)(()=>{
80
+ let collection = isCollapsed ? new (0, $gBwi7$reactstatelylist.ListCollection)([
81
+ ...state.collection
82
+ ].slice(0, tagState.visibleTagCount)) : new (0, $gBwi7$reactstatelylist.ListCollection)([
83
+ ...state.collection
84
+ ]);
85
+ return new (0, $gBwi7$reactariaselection.ListKeyboardDelegate)({
86
+ collection: collection,
87
+ ref: domRef,
88
+ direction: direction,
89
+ orientation: "horizontal"
90
+ });
91
+ }, [
92
+ direction,
93
+ isCollapsed,
94
+ state.collection,
95
+ tagState.visibleTagCount,
96
+ domRef
97
+ ]);
98
+ // Remove onAction from props so it doesn't make it into useGridList.
99
+ delete props.onAction;
100
+ let { gridProps: gridProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $gBwi7$reactariatag.useTagGroup)({
101
+ ...props,
102
+ keyboardDelegate: keyboardDelegate
103
+ }, state, tagsRef);
104
+ let actionsId = (0, $gBwi7$reactariautils.useId)();
105
+ let actionsRef = (0, $gBwi7$react.useRef)(null);
106
+ let updateVisibleTagCount = (0, $gBwi7$react.useCallback)(()=>{
107
+ if (maxRows && maxRows > 0) {
108
+ let computeVisibleTagCount = ()=>{
109
+ // Refs can be null at runtime.
110
+ let currContainerRef = containerRef.current;
111
+ let currTagsRef = tagsRef.current;
112
+ let currActionsRef = actionsRef.current;
113
+ if (!currContainerRef || !currTagsRef || !currActionsRef || state.collection.size === 0) return {
114
+ visibleTagCount: 0,
115
+ showCollapseButton: false
116
+ };
117
+ // Count rows and show tags until we hit the maxRows.
118
+ let tags = [
119
+ ...currTagsRef.children
120
+ ];
121
+ let currY = -Infinity;
122
+ let rowCount = 0;
123
+ let index = 0;
124
+ let tagWidths = [];
125
+ for (let tag of tags){
126
+ let { width: width, y: y } = tag.getBoundingClientRect();
127
+ if (y !== currY) {
128
+ currY = y;
129
+ rowCount++;
130
+ }
131
+ if (maxRows && rowCount > maxRows) break;
132
+ tagWidths.push(width);
133
+ index++;
134
+ }
135
+ // Remove tags until there is space for the collapse button and action button (if present) on the last row.
136
+ let buttons = [
137
+ ...currActionsRef.children
138
+ ];
139
+ if (maxRows && buttons.length > 0 && rowCount >= maxRows) {
140
+ var _tags_;
141
+ let buttonsWidth = buttons.reduce((acc, curr)=>acc += curr.getBoundingClientRect().width, 0);
142
+ buttonsWidth += $e7b72d8874e98cd4$var$TAG_STYLES[scale].margin * 2 * buttons.length;
143
+ let end = direction === "ltr" ? "right" : "left";
144
+ let containerEnd = currContainerRef.parentElement.getBoundingClientRect()[end];
145
+ let lastTagEnd = (_tags_ = tags[index - 1]) === null || _tags_ === void 0 ? void 0 : _tags_.getBoundingClientRect()[end];
146
+ lastTagEnd += $e7b72d8874e98cd4$var$TAG_STYLES[scale].margin;
147
+ let availableWidth = containerEnd - lastTagEnd;
148
+ while(availableWidth < buttonsWidth && index > 0){
149
+ availableWidth += tagWidths.pop();
150
+ index--;
151
+ }
152
+ }
153
+ return {
154
+ visibleTagCount: Math.max(index, 1),
155
+ showCollapseButton: index < state.collection.size
156
+ };
157
+ };
158
+ setTagState(function*() {
159
+ // Update to show all items.
160
+ yield {
161
+ visibleTagCount: state.collection.size,
162
+ showCollapseButton: true
163
+ };
164
+ // Measure, and update to show the items until maxRows is reached.
165
+ yield computeVisibleTagCount();
166
+ });
167
+ }
168
+ }, [
169
+ maxRows,
170
+ setTagState,
171
+ direction,
172
+ scale,
173
+ state.collection.size
174
+ ]);
175
+ (0, $gBwi7$reactariautils.useResizeObserver)({
176
+ ref: containerRef,
177
+ onResize: updateVisibleTagCount
178
+ });
179
+ // eslint-disable-next-line react-hooks/exhaustive-deps
180
+ (0, $gBwi7$reactariautils.useLayoutEffect)(updateVisibleTagCount, [
181
+ children
182
+ ]);
183
+ (0, $gBwi7$react.useEffect)(()=>{
184
+ var // Recalculate visible tags when fonts are loaded.
185
+ _document_fonts;
186
+ (_document_fonts = document.fonts) === null || _document_fonts === void 0 ? void 0 : _document_fonts.ready.then(()=>updateVisibleTagCount());
187
+ // eslint-disable-next-line react-hooks/exhaustive-deps
188
+ }, []);
189
+ let visibleTags = (0, $gBwi7$react.useMemo)(()=>[
190
+ ...state.collection
191
+ ].slice(0, isCollapsed ? tagState.visibleTagCount : state.collection.size), [
192
+ isCollapsed,
193
+ state.collection,
194
+ tagState.visibleTagCount
195
+ ]);
196
+ let handlePressCollapse = ()=>{
197
+ // Prevents button from losing focus if focusedKey got collapsed.
198
+ state.selectionManager.setFocusedKey(null);
199
+ setIsCollapsed((prevCollapsed)=>!prevCollapsed);
200
+ };
201
+ let showActions = tagState.showCollapseButton || actionLabel && onAction;
202
+ let isEmpty = state.collection.size === 0;
203
+ let containerStyle = (0, $gBwi7$react.useMemo)(()=>{
204
+ if (maxRows == null || !isCollapsed || isEmpty) return undefined;
205
+ let maxHeight = ($e7b72d8874e98cd4$var$TAG_STYLES[scale].height + $e7b72d8874e98cd4$var$TAG_STYLES[scale].margin * 2) * maxRows;
206
+ return {
207
+ maxHeight: maxHeight,
208
+ overflow: "hidden"
209
+ };
210
+ }, [
211
+ isCollapsed,
212
+ maxRows,
213
+ isEmpty,
214
+ scale
215
+ ]);
216
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement((0, $gBwi7$reactariafocus.FocusScope), null, /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement((0, $gBwi7$reactspectrumlabel.Field), {
217
+ ...props,
218
+ labelProps: labelProps,
219
+ descriptionProps: descriptionProps,
220
+ errorMessageProps: errorMessageProps,
221
+ showErrorIcon: true,
222
+ ref: domRef,
223
+ elementType: "span",
224
+ wrapperClassName: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tags-fieldWrapper", {
225
+ "spectrum-Tags-fieldWrapper--positionSide": labelPosition === "side"
226
+ })
227
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement("div", {
228
+ ref: containerRef,
229
+ style: containerStyle,
230
+ className: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tags-container", {
231
+ "spectrum-Tags-container--empty": isEmpty
232
+ })
233
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement((0, $gBwi7$reactariafocus.FocusRing), {
234
+ focusRingClass: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "focus-ring")
235
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement("div", {
236
+ ref: tagsRef,
237
+ ...gridProps,
238
+ className: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tags")
239
+ }, visibleTags.map((item)=>/*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement((0, $dd2c5d00108c1840$exports.Tag), {
240
+ ...item.props,
241
+ key: item.key,
242
+ item: item,
243
+ state: state
244
+ }, item.rendered)), isEmpty && /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement("div", {
245
+ className: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tags-empty-state")
246
+ }, renderEmptyState()))), showActions && !isEmpty && /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement((0, $gBwi7$reactspectrumprovider.Provider), {
247
+ isDisabled: false
248
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement("div", {
249
+ role: "group",
250
+ ref: actionsRef,
251
+ id: actionsId,
252
+ "aria-label": stringFormatter.format("actions"),
253
+ "aria-labelledby": `${gridProps.id} ${actionsId}`,
254
+ className: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tags-actions")
255
+ }, tagState.showCollapseButton && /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement((0, $gBwi7$reactspectrumbutton.ActionButton), {
256
+ isQuiet: true,
257
+ onPress: handlePressCollapse,
258
+ UNSAFE_className: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tags-actionButton")
259
+ }, isCollapsed ? stringFormatter.format("showAllButtonLabel", {
260
+ tagCount: state.collection.size
261
+ }) : stringFormatter.format("hideButtonLabel")), actionLabel && onAction && /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).createElement((0, $gBwi7$reactspectrumbutton.ActionButton), {
262
+ isQuiet: true,
263
+ onPress: ()=>onAction === null || onAction === void 0 ? void 0 : onAction(),
264
+ UNSAFE_className: (0, $gBwi7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ed889f8f1f091fc8$exports))), "spectrum-Tags-actionButton")
265
+ }, actionLabel))))));
266
+ }
267
+ /** Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request. */ const $e7b72d8874e98cd4$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, ($parcel$interopDefault($gBwi7$react))).forwardRef($e7b72d8874e98cd4$var$TagGroup);
268
+
269
+
270
+ //# sourceMappingURL=TagGroup.main.js.map
@@ -0,0 +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,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE;IAC1B,IAAI,UAAU,CA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C1B,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"}