@ultraviolet/ui 3.24.0 → 3.24.2

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.
@@ -1,7 +1,8 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
2
  import { init_styles_css_ts_vanilla } from "../Drawer/styles.css.ts.vanilla.js";
3
- import { init_styles_css_ts_vanilla as init_styles_css_ts_vanilla$1 } from "../Tag/styles.css.ts.vanilla.js";
4
- import { init_styles_css_ts_vanilla as init_styles_css_ts_vanilla$2 } from "./styles.css.ts.vanilla.js";
3
+ import { init_styles_css_ts_vanilla as init_styles_css_ts_vanilla$1 } from "../TagList/styles.css.ts.vanilla.js";
4
+ import { init_styles_css_ts_vanilla as init_styles_css_ts_vanilla$2 } from "../Tag/styles.css.ts.vanilla.js";
5
+ import { init_styles_css_ts_vanilla as init_styles_css_ts_vanilla$3 } from "./styles.css.ts.vanilla.js";
5
6
  import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
6
7
 
7
8
  //#region src/components/Separator/styles.css.ts
@@ -11,6 +12,7 @@ function init_styles_css() {
11
12
  /* @__PURE__ */ init_styles_css_ts_vanilla();
12
13
  /* @__PURE__ */ init_styles_css_ts_vanilla$1();
13
14
  /* @__PURE__ */ init_styles_css_ts_vanilla$2();
15
+ /* @__PURE__ */ init_styles_css_ts_vanilla$3();
14
16
  thicknessSeparator = "var(--uv_bu43fb0)";
15
17
  separatorStyle = {
16
18
  thicknessSeparator: "var(--uv_bu43fb0)",
@@ -1 +1 @@
1
- {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/styles.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,YAAI,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAU,CAAA;AAuI9G,eAAO,MAAM,QAAQ;;;;;;wBAxGT,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwGmD,CAAA"}
1
+ {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/styles.css.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,YAAI,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAU,CAAA;AAgJ9G,eAAO,MAAM,QAAQ;;;;;;wBAxGT,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwGmD,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
- import { init_styles_css_ts_vanilla } from "./styles.css.ts.vanilla.js";
2
+ import { init_styles_css_ts_vanilla } from "../TagList/styles.css.ts.vanilla.js";
3
+ import { init_styles_css_ts_vanilla as init_styles_css_ts_vanilla$1 } from "./styles.css.ts.vanilla.js";
3
4
  import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
4
5
 
5
6
  //#region src/components/Tag/styles.css.ts
@@ -7,25 +8,26 @@ var tagStyle;
7
8
  function init_styles_css() {
8
9
  return (init_styles_css = __esmMin(() => {
9
10
  /* @__PURE__ */ init_styles_css_ts_vanilla();
11
+ /* @__PURE__ */ init_styles_css_ts_vanilla$1();
10
12
  tagStyle = {
11
13
  container: createRuntimeFn({
12
- defaultClassName: "uv_d6zknp5",
14
+ defaultClassName: "uv_d6zknp6",
13
15
  variantClassNames: {
14
- copiable: { true: "uv_d6zknp6" },
15
- disabled: { true: "uv_d6zknp7" },
16
- closable: { true: "uv_d6zknp8" },
16
+ copiable: { true: "uv_d6zknp7" },
17
+ disabled: { true: "uv_d6zknp8" },
18
+ closable: { true: "uv_d6zknp9" },
17
19
  sentiment: {
18
- danger: "uv_d6zknp9",
19
- info: "uv_d6zknpa",
20
- neutral: "uv_d6zknpb",
21
- primary: "uv_d6zknpc",
22
- secondary: "uv_d6zknpd",
23
- success: "uv_d6zknpe",
24
- warning: "uv_d6zknpf"
20
+ danger: "uv_d6zknpa",
21
+ info: "uv_d6zknpb",
22
+ neutral: "uv_d6zknpc",
23
+ primary: "uv_d6zknpd",
24
+ secondary: "uv_d6zknpe",
25
+ success: "uv_d6zknpf",
26
+ warning: "uv_d6zknpg"
25
27
  },
26
28
  isButton: {
27
- true: "uv_d6zknpg",
28
- false: "uv_d6zknph"
29
+ true: "uv_d6zknph",
30
+ false: "uv_d6zknpi"
29
31
  }
30
32
  },
31
33
  defaultVariants: {
@@ -40,111 +42,111 @@ function init_styles_css() {
40
42
  copiable: true,
41
43
  sentiment: "danger",
42
44
  disabled: false
43
- }, "uv_d6zknpi"],
45
+ }, "uv_d6zknpj"],
44
46
  [{
45
47
  copiable: true,
46
48
  sentiment: "info",
47
49
  disabled: false
48
- }, "uv_d6zknpj"],
50
+ }, "uv_d6zknpk"],
49
51
  [{
50
52
  copiable: true,
51
53
  sentiment: "neutral",
52
54
  disabled: false
53
- }, "uv_d6zknpk"],
55
+ }, "uv_d6zknpl"],
54
56
  [{
55
57
  copiable: true,
56
58
  sentiment: "primary",
57
59
  disabled: false
58
- }, "uv_d6zknpl"],
60
+ }, "uv_d6zknpm"],
59
61
  [{
60
62
  copiable: true,
61
63
  sentiment: "secondary",
62
64
  disabled: false
63
- }, "uv_d6zknpm"],
65
+ }, "uv_d6zknpn"],
64
66
  [{
65
67
  copiable: true,
66
68
  sentiment: "success",
67
69
  disabled: false
68
- }, "uv_d6zknpn"],
70
+ }, "uv_d6zknpo"],
69
71
  [{
70
72
  copiable: true,
71
73
  sentiment: "warning",
72
74
  disabled: false
73
- }, "uv_d6zknpo"],
75
+ }, "uv_d6zknpp"],
74
76
  [{
75
77
  disabled: true,
76
78
  sentiment: "danger"
77
- }, "uv_d6zknpp"],
79
+ }, "uv_d6zknpq"],
78
80
  [{
79
81
  disabled: true,
80
82
  sentiment: "info"
81
- }, "uv_d6zknpq"],
83
+ }, "uv_d6zknpr"],
82
84
  [{
83
85
  disabled: true,
84
86
  sentiment: "neutral"
85
- }, "uv_d6zknpr"],
87
+ }, "uv_d6zknps"],
86
88
  [{
87
89
  disabled: true,
88
90
  sentiment: "primary"
89
- }, "uv_d6zknps"],
91
+ }, "uv_d6zknpt"],
90
92
  [{
91
93
  disabled: true,
92
94
  sentiment: "secondary"
93
- }, "uv_d6zknpt"],
95
+ }, "uv_d6zknpu"],
94
96
  [{
95
97
  disabled: true,
96
98
  sentiment: "success"
97
- }, "uv_d6zknpu"],
99
+ }, "uv_d6zknpv"],
98
100
  [{
99
101
  disabled: true,
100
102
  sentiment: "warning"
101
- }, "uv_d6zknpv"],
103
+ }, "uv_d6zknpw"],
102
104
  [{
103
105
  isButton: true,
104
106
  sentiment: "danger",
105
107
  disabled: false
106
- }, "uv_d6zknpw"],
108
+ }, "uv_d6zknpx"],
107
109
  [{
108
110
  isButton: true,
109
111
  sentiment: "info",
110
112
  disabled: false
111
- }, "uv_d6zknpx"],
113
+ }, "uv_d6zknpy"],
112
114
  [{
113
115
  isButton: true,
114
116
  sentiment: "neutral",
115
117
  disabled: false
116
- }, "uv_d6zknpy"],
118
+ }, "uv_d6zknpz"],
117
119
  [{
118
120
  isButton: true,
119
121
  sentiment: "primary",
120
122
  disabled: false
121
- }, "uv_d6zknpz"],
123
+ }, "uv_d6zknp10"],
122
124
  [{
123
125
  isButton: true,
124
126
  sentiment: "secondary",
125
127
  disabled: false
126
- }, "uv_d6zknp10"],
128
+ }, "uv_d6zknp11"],
127
129
  [{
128
130
  isButton: true,
129
131
  sentiment: "success",
130
132
  disabled: false
131
- }, "uv_d6zknp11"],
133
+ }, "uv_d6zknp12"],
132
134
  [{
133
135
  isButton: true,
134
136
  sentiment: "warning",
135
137
  disabled: false
136
- }, "uv_d6zknp12"]
138
+ }, "uv_d6zknp13"]
137
139
  ]
138
140
  }),
139
- text: "uv_d6zknp13",
140
- separator: "uv_d6zknp2",
141
+ text: "uv_d6zknp14",
142
+ separator: "uv_d6zknp3",
141
143
  wrapper: {
142
- copiable: "uv_d6zknp0",
143
- notCopiable: "uv_d6zknp1"
144
+ copiable: "uv_d6zknp1 uv_d6zknp0",
145
+ notCopiable: "uv_d6zknp2 uv_d6zknp0"
144
146
  },
145
147
  content: {
146
- copiable: "uv_d6zknp3",
147
- notCopiable: "uv_d6zknp4"
148
+ copiable: "uv_d6zknp4",
149
+ notCopiable: "uv_d6zknp5"
148
150
  }
149
151
  };
150
152
  }))();
@@ -1,4 +1,4 @@
1
- export declare const TAGS_GAP: string;
1
+ export declare const TAGS_GAP_PX = 4;
2
2
  export declare const DEFAULT_POPOVER_MAX_HEIGHT = "16rem";
3
- export declare const MIN_TAG_WIDTH = 32;
3
+ export declare const MIN_TAG_WIDTH_PX = 32;
4
4
  //# sourceMappingURL=constant.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/components/TagList/constant.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,QAA+B,CAAA;AAEpD,eAAO,MAAM,0BAA0B,UAAU,CAAA;AACjD,eAAO,MAAM,aAAa,KAAK,CAAA"}
1
+ {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/components/TagList/constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,IAAI,CAAA;AAE5B,eAAO,MAAM,0BAA0B,UAAU,CAAA;AACjD,eAAO,MAAM,gBAAgB,KAAK,CAAA"}
@@ -1,15 +1,13 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
- import { consoleLightTheme } from "@ultraviolet/themes";
3
2
 
4
3
  //#region src/components/TagList/constant.ts
5
- var TAGS_GAP, DEFAULT_POPOVER_MAX_HEIGHT;
4
+ var DEFAULT_POPOVER_MAX_HEIGHT;
6
5
  function init_constant() {
7
6
  return (init_constant = __esmMin(() => {
8
- TAGS_GAP = consoleLightTheme.space["1"];
9
7
  DEFAULT_POPOVER_MAX_HEIGHT = "16rem";
10
8
  }))();
11
9
  }
12
10
 
13
11
  //#endregion
14
12
  init_constant();
15
- export { DEFAULT_POPOVER_MAX_HEIGHT, TAGS_GAP, init_constant };
13
+ export { DEFAULT_POPOVER_MAX_HEIGHT, init_constant };
@@ -12,21 +12,20 @@ type TagIcon = {
12
12
  export type TagType = string | TagKeyValue | TagIcon;
13
13
  type TagListProps = {
14
14
  /**
15
- * This property define maximum characters length of all tags until it hide tags into tooltip.
15
+ * Maximum character length of all tags before hiding them into a popover.
16
16
  */
17
17
  maxLength?: number;
18
18
  tags?: TagType[];
19
19
  /**
20
- * This property define maximum characters length of all tags until it hide tags into tooltip.
21
- * NB: this will be overridden if the parent width is smaller and cannot show all the tags
20
+ * Maximum number of tags to display before hiding them in a popover.
22
21
  */
23
22
  threshold?: number;
24
23
  /**
25
- * This property define maximum width of each tag. This doesn't apply for tags in tooltip.
24
+ * Wrap the tags on multiple lines instead of containing them on the first one.
26
25
  */
27
26
  multiline?: boolean;
28
27
  /**
29
- * This property define the title of the Popover, when some tags are hidden because of the threshold.
28
+ * Title of the Popover added when some tags are hidden because of the `threshold` or `maxLength` properties.
30
29
  */
31
30
  popoverTitle: string;
32
31
  /**
@@ -35,7 +34,8 @@ type TagListProps = {
35
34
  */
36
35
  popoverPlacement?: ComponentProps<typeof Popover>['placement'];
37
36
  /**
38
- * The popover maxHeight, defaults to 12.5rem
37
+ * The popover maxHeight
38
+ * @default 12.5rem
39
39
  */
40
40
  popoverMaxHeight?: ComponentProps<typeof Popover>['maxHeight'];
41
41
  className?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TagList/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ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AC7C,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAqB,EACrB,OAAmB,EACnB,SAAS,EACT,aAAa,EAAE,UAAU,EACzB,KAAK,GACN,EAAE,YAAY"}
@@ -1,13 +1,12 @@
1
1
  'use client';
2
2
  import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
3
  import _objectSpread2, { init_objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.146.0/helpers/esm/objectSpread2.js";
4
- import { init_styles_css, popoverTriggerWidthVar, tagListStyle } from "./styles.css.js";
4
+ import { init_styles_css, tagListStyle } from "./styles.css.js";
5
5
  import { Tag, init_Tag } from "../Tag/index.js";
6
6
  import { Popover, init_Popover } from "../Popover/index.js";
7
- import { DEFAULT_POPOVER_MAX_HEIGHT, TAGS_GAP, init_constant } from "./constant.js";
8
- import { useEffect, useMemo, useRef, useState } from "react";
7
+ import { DEFAULT_POPOVER_MAX_HEIGHT, init_constant } from "./constant.js";
8
+ import { createElement, useEffect, useMemo, useRef, useState } from "react";
9
9
  import { cn } from "@ultraviolet/utils";
10
- import { assignInlineVars } from "@vanilla-extract/dynamic";
11
10
  import { jsx, jsxs } from "react/jsx-runtime";
12
11
 
13
12
  //#region src/components/TagList/index.tsx
@@ -28,142 +27,93 @@ function init_TagList() {
28
27
  return tag;
29
28
  };
30
29
  TagList = ({ maxLength = 600, tags = DEFAULT_TAGS, threshold = 1, multiline = false, popoverTitle, popoverPlacement, popoverMaxHeight = DEFAULT_POPOVER_MAX_HEIGHT, copiable, copyText, copiedText, sentiment = "neutral", variant = "default", className, "data-testid": dataTestId, style }) => {
31
- var _containerRef$current3;
32
- var _containerRef$current6;
33
30
  const containerRef = useRef(null);
34
31
  const measureRef = useRef(null);
35
32
  const popoverTriggerRef = useRef(null);
36
- const [isReady, setIsReady] = useState(false);
37
33
  const [isPopoverVisible, setIsPopoverVisible] = useState(false);
38
- const [popoverTriggerWidth, setPopoverTriggerWidth] = useState(0);
39
- const [visibleTags, setVisibleTags] = useState([]);
34
+ const [visibleTags, setVisibleTags] = useState(tags[0] ? [tags[0]] : []);
40
35
  const [hiddenTags, setHiddenTags] = useState([]);
41
- const { tmpThreshold, potentiallyVisibleTags, surelyHiddenTags } = useMemo(() => {
42
- let tmpThreshold = threshold;
43
- while (tmpThreshold > 1 && tags.length > 0 && tags.slice(0, tmpThreshold).reduce((acc, tag) => acc + getTagLabel(tag), "").length > maxLength) tmpThreshold -= 1;
44
- const potentiallyVisibleTagsLength = Math.max(1, tags.length > tmpThreshold ? tmpThreshold : tags.length);
45
- return {
46
- potentiallyVisibleTags: tags.slice(0, potentiallyVisibleTagsLength),
47
- surelyHiddenTags: tags.slice(potentiallyVisibleTagsLength),
48
- tmpThreshold
49
- };
36
+ const [potentiallyVisibleTags, surelyHiddenTags] = useMemo(() => {
37
+ if (tags.length === 0) return [[], []];
38
+ const limit = Math.min(threshold, tags.length);
39
+ let visibleCount = 0;
40
+ let currentLength = 0;
41
+ for (let i = 0; i < limit; i++) {
42
+ currentLength += getTagLabel(tags[i]).length;
43
+ if (currentLength > maxLength) break;
44
+ visibleCount++;
45
+ }
46
+ visibleCount = Math.max(visibleCount, 1);
47
+ return [tags.slice(0, visibleCount), tags.slice(visibleCount)];
50
48
  }, [
51
49
  maxLength,
52
50
  tags,
53
51
  threshold
54
52
  ]);
55
53
  useEffect(() => {
56
- var _containerRef$current;
57
- var _containerRef$current2;
58
54
  if (tags.length === 0 || !containerRef.current || !measureRef.current) return;
59
- if (multiline) {
55
+ if (multiline || typeof ResizeObserver === "undefined") {
60
56
  setVisibleTags(potentiallyVisibleTags);
61
57
  setHiddenTags(surelyHiddenTags);
62
- setIsReady(true);
63
58
  return;
64
59
  }
65
- const parentWidth = ((_containerRef$current = (_containerRef$current2 = containerRef.current.parentElement) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.offsetWidth) !== null && _containerRef$current !== void 0 ? _containerRef$current : 0) - 32;
66
- const { measuredVisibleTags, measuredHiddenTags } = [...measureRef.current.children[0].children].reduce((accumulator, currentValue, index) => {
67
- const tagWidth = currentValue.offsetWidth;
68
- const gap = index > 0 ? Number.parseInt(TAGS_GAP, 10) : 0;
69
- const newAccumulatedWidth = accumulator.accumulatedWidth + tagWidth + gap;
70
- if (accumulator.accumulatedWidth + 32 + gap <= parentWidth) return {
71
- accumulatedWidth: newAccumulatedWidth,
72
- measuredHiddenTags: accumulator.measuredHiddenTags,
73
- measuredVisibleTags: [...accumulator.measuredVisibleTags, tags[index]]
74
- };
75
- return {
76
- accumulatedWidth: accumulator.accumulatedWidth,
77
- measuredHiddenTags: [...accumulator.measuredHiddenTags, tags[index]],
78
- measuredVisibleTags: accumulator.measuredVisibleTags
79
- };
80
- }, {
81
- accumulatedWidth: 0,
82
- measuredHiddenTags: [],
83
- measuredVisibleTags: []
84
- });
85
- const finalHiddenTags = [...measuredHiddenTags, ...surelyHiddenTags];
86
- setVisibleTags(measuredVisibleTags);
87
- setHiddenTags(finalHiddenTags);
88
- if (finalHiddenTags.length === 0) setIsReady(true);
60
+ const handleResize = (entries) => {
61
+ if (!containerRef.current || !measureRef.current || !popoverTriggerRef.current) return;
62
+ const totalAvailableWidth = entries[0].contentBoxSize[0].inlineSize;
63
+ if (measureRef.current.offsetWidth < totalAvailableWidth) {
64
+ setVisibleTags(potentiallyVisibleTags);
65
+ setHiddenTags(surelyHiddenTags);
66
+ return;
67
+ }
68
+ const elementsToMeasure = [...measureRef.current.children[0].children];
69
+ const counterWidth = popoverTriggerRef.current.offsetWidth;
70
+ let visibleTagsCount = 0;
71
+ let visibleTagsWidth = 0;
72
+ for (let i = 0; i < potentiallyVisibleTags.length; i++) {
73
+ if (i > 0) visibleTagsWidth += 4;
74
+ visibleTagsWidth += elementsToMeasure[i].offsetWidth;
75
+ const availableWidth = i < tags.length - 1 ? totalAvailableWidth - counterWidth : totalAvailableWidth;
76
+ if (visibleTagsWidth > availableWidth) break;
77
+ visibleTagsCount++;
78
+ }
79
+ if (visibleTagsCount === 0) visibleTagsCount = 1;
80
+ setVisibleTags(tags.slice(0, visibleTagsCount));
81
+ setHiddenTags(tags.slice(visibleTagsCount));
82
+ };
83
+ const resizeObserver = new ResizeObserver(handleResize);
84
+ resizeObserver.observe(containerRef.current);
85
+ return () => {
86
+ resizeObserver.disconnect();
87
+ };
89
88
  }, [
90
89
  multiline,
91
90
  potentiallyVisibleTags,
92
91
  surelyHiddenTags,
93
- tags,
94
- threshold,
95
- tmpThreshold,
96
- (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 || (_containerRef$current3 = _containerRef$current3.parentElement) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.offsetWidth
92
+ tags
97
93
  ]);
98
- useEffect(() => {
99
- var _popoverTriggerRef$cu;
100
- if ((_popoverTriggerRef$cu = popoverTriggerRef.current) === null || _popoverTriggerRef$cu === void 0 ? void 0 : _popoverTriggerRef$cu.offsetWidth) {
101
- var _containerRef$current4;
102
- var _containerRef$current5;
103
- var _tagsContainer$parent;
104
- var _tagsContainer$parent2;
105
- const newPopoverTriggerWidth = popoverTriggerRef.current.offsetWidth;
106
- setPopoverTriggerWidth(newPopoverTriggerWidth);
107
- const tagsContainer = containerRef.current;
108
- const tagsContainerWidth = (_containerRef$current4 = (_containerRef$current5 = containerRef.current) === null || _containerRef$current5 === void 0 ? void 0 : _containerRef$current5.offsetWidth) !== null && _containerRef$current4 !== void 0 ? _containerRef$current4 : 0;
109
- const parentWidth = (_tagsContainer$parent = tagsContainer === null || tagsContainer === void 0 || (_tagsContainer$parent2 = tagsContainer.parentElement) === null || _tagsContainer$parent2 === void 0 ? void 0 : _tagsContainer$parent2.offsetWidth) !== null && _tagsContainer$parent !== void 0 ? _tagsContainer$parent : 0;
110
- if (visibleTags.length > 1 && hiddenTags.length > 0 && tagsContainerWidth + newPopoverTriggerWidth > parentWidth) {
111
- var _visibleTags$at;
112
- const visibleTagsCopy = visibleTags.filter((_, index) => index < visibleTags.length - 1);
113
- const tagToMove = (_visibleTags$at = visibleTags.at(-1)) !== null && _visibleTags$at !== void 0 ? _visibleTags$at : "";
114
- setVisibleTags(visibleTagsCopy);
115
- setHiddenTags([tagToMove, ...hiddenTags]);
116
- }
117
- setIsReady(true);
118
- }
119
- }, [
120
- hiddenTags,
121
- threshold,
122
- visibleTags,
123
- visibleTags.length,
124
- (_containerRef$current6 = containerRef.current) === null || _containerRef$current6 === void 0 || (_containerRef$current6 = _containerRef$current6.parentElement) === null || _containerRef$current6 === void 0 ? void 0 : _containerRef$current6.offsetWidth
125
- ]);
126
- const renderTag = (tag, index, isEllipsis = false, hidden) => {
94
+ const renderTag = (tag, index, hidden) => {
95
+ const tagLabel = getTagLabel(tag);
127
96
  const commonProps = {
128
- className: cn(isEllipsis ? "ellipsed" : "", tagListStyle.ellipsisChild),
97
+ className: tagListStyle.tag,
129
98
  copiable,
130
99
  copiedText,
131
100
  copyText,
132
- key: `${getTagLabel(tag)}-${index}`,
133
- "data-testid": hidden ? "" : getTagLabel(tag),
101
+ "data-testid": hidden ? "" : tagLabel,
134
102
  variant,
135
103
  sentiment
136
104
  };
137
- if (isKeyValueTag(tag)) return /* @__PURE__ */ jsx(Tag, _objectSpread2({ keyValue: tag }, commonProps));
138
- return /* @__PURE__ */ jsxs(Tag, _objectSpread2(_objectSpread2({}, commonProps), {}, { children: [isLabelIconTag(tag) ? tag.icon : void 0, getTagLabel(tag)] }));
105
+ if (isKeyValueTag(tag)) return /* @__PURE__ */ createElement(Tag, _objectSpread2(_objectSpread2({ keyValue: tag }, commonProps), {}, { key: `${tagLabel}-${index}` }));
106
+ return /* @__PURE__ */ createElement(Tag, _objectSpread2(_objectSpread2({}, commonProps), {}, { key: `${tagLabel}-${index}` }), isLabelIconTag(tag) ? tag.icon : void 0, tagLabel);
139
107
  };
140
108
  return /* @__PURE__ */ jsxs("div", {
141
109
  className: cn(className, tagListStyle.container),
142
110
  "data-testid": dataTestId,
143
- style: _objectSpread2({ visibility: isReady ? "visible" : "hidden" }, style),
144
- children: [
145
- /* @__PURE__ */ jsx("div", {
146
- className: cn(tagListStyle.tagContainer({ multiline }), visibleTags.length === 1 && hiddenTags.length === 0 || popoverTriggerWidth ? tagListStyle.ellipsisContainer : ""),
147
- "data-testid": `${dataTestId !== null && dataTestId !== void 0 ? dataTestId : "taglist"}-container`,
148
- ref: containerRef,
149
- style: assignInlineVars({ [popoverTriggerWidthVar]: `${popoverTriggerWidth || 0}px` }),
150
- children: visibleTags.map((tag, index) => renderTag(tag, index, index === visibleTags.length - 1, true))
151
- }),
152
- /* @__PURE__ */ jsx("div", {
153
- ref: measureRef,
154
- style: {
155
- position: "absolute",
156
- visibility: "hidden",
157
- whiteSpace: "nowrap",
158
- pointerEvents: "none"
159
- },
160
- children: /* @__PURE__ */ jsx("div", {
161
- className: tagListStyle.tagContainer({ multiline }),
162
- "data-testid": `${dataTestId !== null && dataTestId !== void 0 ? dataTestId : "taglist"}-measure-container`,
163
- children: potentiallyVisibleTags.map((tag, index) => renderTag(tag, index))
164
- })
165
- }),
166
- hiddenTags.length > 0 && /* @__PURE__ */ jsx(Popover, {
111
+ ref: containerRef,
112
+ style,
113
+ children: [/* @__PURE__ */ jsxs("div", {
114
+ className: cn(tagListStyle.tagContainer({ multiline })),
115
+ "data-testid": `${dataTestId !== null && dataTestId !== void 0 ? dataTestId : "taglist"}-container`,
116
+ children: [visibleTags.map((tag, index) => renderTag(tag, index, true)), hiddenTags.length > 0 && /* @__PURE__ */ jsx(Popover, {
167
117
  content: /* @__PURE__ */ jsx("div", {
168
118
  className: tagListStyle.tagContainer({ multiline: true }),
169
119
  children: hiddenTags.map((tag, index) => renderTag(tag, index))
@@ -174,19 +124,31 @@ function init_TagList() {
174
124
  size: "small",
175
125
  title: popoverTitle,
176
126
  visible: isPopoverVisible,
177
- children: /* @__PURE__ */ jsxs("span", {
178
- className: tagListStyle.tagsWrapper,
127
+ children: /* @__PURE__ */ jsxs("button", {
128
+ type: "button",
129
+ className: tagListStyle.counter,
179
130
  "data-testid": `${dataTestId !== null && dataTestId !== void 0 ? dataTestId : "taglist"}-open`,
180
131
  onClick: () => setIsPopoverVisible(true),
181
132
  onKeyDown: (event) => {
182
133
  if ([" ", "Enter"].includes(event.key)) setIsPopoverVisible(true);
183
134
  },
184
- ref: popoverTriggerRef,
185
- tabIndex: 0,
186
135
  children: ["+", hiddenTags.length]
187
136
  })
188
- })
189
- ]
137
+ })]
138
+ }), /* @__PURE__ */ jsxs("div", {
139
+ "aria-hidden": "true",
140
+ ref: measureRef,
141
+ className: tagListStyle.measurementContainer,
142
+ children: [/* @__PURE__ */ jsx("div", {
143
+ className: tagListStyle.tagContainer({ multiline }),
144
+ children: potentiallyVisibleTags.map((tag, index) => renderTag(tag, index))
145
+ }), /* @__PURE__ */ jsxs("button", {
146
+ type: "button",
147
+ className: tagListStyle.counter,
148
+ ref: popoverTriggerRef,
149
+ children: ["+", surelyHiddenTags.length]
150
+ })]
151
+ })]
190
152
  });
191
153
  };
192
154
  TagList.displayName = "TagList";
@@ -8,8 +8,8 @@ export declare const tagListStyle: {
8
8
  };
9
9
  };
10
10
  }>;
11
- ellipsisChild: string;
12
- ellipsisContainer: string;
13
- tagsWrapper: string;
11
+ tag: string;
12
+ counter: string;
13
+ measurementContainer: string;
14
14
  };
15
15
  //# sourceMappingURL=styles.css.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/TagList/styles.css.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sBAAsB,oBAAc,CAAA;AA4DjD,eAAO,MAAM,YAAY;;;;;;;;;;;;CAMxB,CAAA"}
1
+ {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/TagList/styles.css.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sBAAsB,oBAAc,CAAA;AAuDjD,eAAO,MAAM,YAAY;;;;;;;;;;;;CAMxB,CAAA"}
@@ -3,26 +3,25 @@ import { init_styles_css_ts_vanilla } from "./styles.css.ts.vanilla.js";
3
3
  import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
4
4
 
5
5
  //#region src/components/TagList/styles.css.ts
6
- var popoverTriggerWidthVar, tagListStyle;
6
+ var tagListStyle;
7
7
  function init_styles_css() {
8
8
  return (init_styles_css = __esmMin(() => {
9
9
  /* @__PURE__ */ init_styles_css_ts_vanilla();
10
- popoverTriggerWidthVar = "var(--uv_1f9zr5y0)";
11
10
  tagListStyle = {
12
11
  container: "uv_1f9zr5y1",
13
12
  tagContainer: createRuntimeFn({
14
- defaultClassName: "uv_1f9zr5y2",
15
- variantClassNames: { multiline: { true: "uv_1f9zr5y3" } },
13
+ defaultClassName: "uv_1f9zr5y3",
14
+ variantClassNames: { multiline: { true: "uv_1f9zr5y4" } },
16
15
  defaultVariants: {},
17
16
  compoundVariants: []
18
17
  }),
19
- ellipsisChild: "uv_1f9zr5y5",
20
- ellipsisContainer: "uv_1f9zr5y4",
21
- tagsWrapper: "uv_1f9zr5y6"
18
+ tag: "uv_1f9zr5y5",
19
+ counter: "uv_1f9zr5y6",
20
+ measurementContainer: "uv_1f9zr5y2"
22
21
  };
23
22
  }))();
24
23
  }
25
24
 
26
25
  //#endregion
27
26
  init_styles_css();
28
- export { init_styles_css, popoverTriggerWidthVar, tagListStyle };
27
+ export { init_styles_css, tagListStyle };
@@ -1 +1 @@
1
- {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/styles.css.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,IAAI,CAAA;AAE3B,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAsErC,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;CAMxB,CAAA"}
1
+ {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/styles.css.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,IAAI,CAAA;AAE3B,eAAO,MAAM,kBAAkB,MAAM,CAAA;AA2ErC,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;CAMxB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
2
  import { init_animationsVanillaExtract_css_ts_vanilla } from "../../utils/animations/animationsVanillaExtract.css.ts.vanilla.js";
3
+ import { init_style_css_ts_vanilla } from "../Text/style.css.ts.vanilla.js";
3
4
  import { init_styles_css_ts_vanilla } from "./styles.css.ts.vanilla.js";
4
5
  import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
5
6
 
@@ -8,6 +9,7 @@ var tooltipStyle;
8
9
  function init_styles_css() {
9
10
  return (init_styles_css = __esmMin(() => {
10
11
  /* @__PURE__ */ init_animationsVanillaExtract_css_ts_vanilla();
12
+ /* @__PURE__ */ init_style_css_ts_vanilla();
11
13
  /* @__PURE__ */ init_styles_css_ts_vanilla();
12
14
  tooltipStyle = {
13
15
  animation: {