@astral/ui 4.36.1 → 4.37.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.
Files changed (86) hide show
  1. package/components/Autocomplete/Autocomplete.d.ts +1 -1
  2. package/components/Autocomplete/Autocomplete.js +53 -15
  3. package/components/Autocomplete/constants.d.ts +6 -0
  4. package/components/Autocomplete/constants.js +7 -0
  5. package/components/Autocomplete/styles.js +15 -1
  6. package/components/Autocomplete/useLogic/useLogic.d.ts +2 -1
  7. package/components/Autocomplete/useLogic/useLogic.js +11 -2
  8. package/components/TagsList/Tag/Tag.d.ts +1 -1
  9. package/components/TagsList/Tag/constants.d.ts +1 -0
  10. package/components/TagsList/Tag/constants.js +1 -0
  11. package/components/TagsList/Tag/index.d.ts +1 -0
  12. package/components/TagsList/Tag/index.js +1 -0
  13. package/components/TagsList/Tag/styles.js +2 -0
  14. package/components/TagsList/TagsList.js +6 -6
  15. package/components/TagsList/constants.d.ts +2 -0
  16. package/components/TagsList/constants.js +2 -0
  17. package/components/TagsList/styles.js +5 -1
  18. package/components/TagsList/types.d.ts +14 -5
  19. package/components/TagsList/useLogic/useLogic.d.ts +5 -5
  20. package/components/TagsList/useLogic/useLogic.js +70 -110
  21. package/components/TagsList/utils/calculateVisibleTagsCount/calculateVisibleTagsCount.d.ts +6 -0
  22. package/components/TagsList/utils/calculateVisibleTagsCount/calculateVisibleTagsCount.js +35 -0
  23. package/components/TagsList/utils/calculateVisibleTagsCount/index.d.ts +1 -0
  24. package/components/TagsList/utils/calculateVisibleTagsCount/index.js +1 -0
  25. package/components/TagsList/utils/getAvailableWidth/getAvailableWidth.d.ts +1 -0
  26. package/components/TagsList/utils/getAvailableWidth/getAvailableWidth.js +7 -0
  27. package/components/TagsList/utils/getAvailableWidth/index.d.ts +1 -0
  28. package/components/TagsList/utils/getAvailableWidth/index.js +1 -0
  29. package/components/TagsList/utils/getKey/getKey.d.ts +1 -1
  30. package/components/TagsList/utils/getKey/getKey.js +6 -3
  31. package/components/TagsList/utils/getTagWidth/getTagWidth.d.ts +2 -0
  32. package/components/TagsList/utils/getTagWidth/getTagWidth.js +21 -0
  33. package/components/TagsList/utils/getTagWidth/index.d.ts +1 -0
  34. package/components/TagsList/utils/getTagWidth/index.js +1 -0
  35. package/components/TagsList/utils/index.d.ts +3 -0
  36. package/components/TagsList/utils/index.js +3 -0
  37. package/components/TextField/TextField.js +6 -5
  38. package/components/TextField/constants.d.ts +1 -0
  39. package/components/TextField/constants.js +1 -0
  40. package/components/TextField/styles.js +4 -0
  41. package/components/TreeLikeAsyncAutocomplete/Input/Input.js +1 -1
  42. package/node/components/Autocomplete/Autocomplete.d.ts +1 -1
  43. package/node/components/Autocomplete/Autocomplete.js +51 -13
  44. package/node/components/Autocomplete/constants.d.ts +6 -0
  45. package/node/components/Autocomplete/constants.js +8 -1
  46. package/node/components/Autocomplete/styles.js +15 -1
  47. package/node/components/Autocomplete/useLogic/useLogic.d.ts +2 -1
  48. package/node/components/Autocomplete/useLogic/useLogic.js +10 -1
  49. package/node/components/TagsList/Tag/Tag.d.ts +1 -1
  50. package/node/components/TagsList/Tag/constants.d.ts +1 -0
  51. package/node/components/TagsList/Tag/constants.js +4 -0
  52. package/node/components/TagsList/Tag/index.d.ts +1 -0
  53. package/node/components/TagsList/Tag/index.js +1 -0
  54. package/node/components/TagsList/Tag/styles.js +2 -0
  55. package/node/components/TagsList/TagsList.js +6 -6
  56. package/node/components/TagsList/constants.d.ts +2 -0
  57. package/node/components/TagsList/constants.js +5 -0
  58. package/node/components/TagsList/styles.js +5 -1
  59. package/node/components/TagsList/types.d.ts +14 -5
  60. package/node/components/TagsList/useLogic/useLogic.d.ts +5 -5
  61. package/node/components/TagsList/useLogic/useLogic.js +70 -110
  62. package/node/components/TagsList/utils/calculateVisibleTagsCount/calculateVisibleTagsCount.d.ts +6 -0
  63. package/node/components/TagsList/utils/calculateVisibleTagsCount/calculateVisibleTagsCount.js +39 -0
  64. package/node/components/TagsList/utils/calculateVisibleTagsCount/index.d.ts +1 -0
  65. package/node/components/TagsList/utils/calculateVisibleTagsCount/index.js +5 -0
  66. package/node/components/TagsList/utils/getAvailableWidth/getAvailableWidth.d.ts +1 -0
  67. package/node/components/TagsList/utils/getAvailableWidth/getAvailableWidth.js +11 -0
  68. package/node/components/TagsList/utils/getAvailableWidth/index.d.ts +1 -0
  69. package/node/components/TagsList/utils/getAvailableWidth/index.js +5 -0
  70. package/node/components/TagsList/utils/getKey/getKey.d.ts +1 -1
  71. package/node/components/TagsList/utils/getKey/getKey.js +6 -3
  72. package/node/components/TagsList/utils/getTagWidth/getTagWidth.d.ts +2 -0
  73. package/node/components/TagsList/utils/getTagWidth/getTagWidth.js +25 -0
  74. package/node/components/TagsList/utils/getTagWidth/index.d.ts +1 -0
  75. package/node/components/TagsList/{public.js → utils/getTagWidth/index.js} +1 -2
  76. package/node/components/TagsList/utils/index.d.ts +3 -0
  77. package/node/components/TagsList/utils/index.js +7 -1
  78. package/node/components/TextField/TextField.js +6 -5
  79. package/node/components/TextField/constants.d.ts +1 -0
  80. package/node/components/TextField/constants.js +1 -0
  81. package/node/components/TextField/styles.js +4 -0
  82. package/node/components/TreeLikeAsyncAutocomplete/Input/Input.js +1 -1
  83. package/package.json +1 -1
  84. package/components/TagsList/public.d.ts +0 -2
  85. package/components/TagsList/public.js +0 -2
  86. package/node/components/TagsList/public.d.ts +0 -2
@@ -3,146 +3,106 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
5
  const useTheme_1 = require("../../theme/hooks/useTheme");
6
- const useLogic = ({ data = [], keyId, getOptionLabel, onChange, }) => {
7
- // Сколько тегов можно отобразить в инпуте
8
- const [maxItems, setMaxItems] = (0, react_1.useState)(1);
9
- const ignoreResizeRef = (0, react_1.useRef)(false);
6
+ const constants_1 = require("../constants");
7
+ const utils_1 = require("../utils");
8
+ const useLogic = ({ data = [], keyId, getOptionLabel, onChange, inputContainerRef, reservedWidth = 0, }) => {
9
+ const [visibleOptions, setVisibleOptions] = (0, react_1.useState)([]);
10
+ const [hiddenCount, setHiddenCount] = (0, react_1.useState)(0);
10
11
  const tagsContainerRef = (0, react_1.useRef)(null);
12
+ const availableWidthRef = (0, react_1.useRef)(0);
11
13
  const theme = (0, useTheme_1.useTheme)();
12
14
  /**
13
- * Определяет, сколько тегов можно отобразить в строке,
14
- * учитывая ширину контейнера и промежутки (gap) между тегами.
15
- *
16
- * @param container - DOM-элемент контейнера с тегами
17
- * @param gap - расстояние между тегами (например, 4px)
18
- * @param padding - отступ внутри тега
19
- * @returns количество тегов, которые помещаются без переполнения
15
+ * Обновляет доступную ширину для расчета количества отображаемых тегов
20
16
  */
21
- const getTagsCountToAdd = (container, gap, padding) => {
22
- const tags = Array.from(container.children);
23
- // Если нет ни одного тега, сразу возвращаем 0
24
- if (tags.length === 0) {
25
- return 0;
17
+ const updateAvailableWidth = () => {
18
+ const target = inputContainerRef?.current ?? tagsContainerRef.current;
19
+ if (target) {
20
+ availableWidthRef.current = (0, utils_1.getAvailableWidth)(target, reservedWidth);
26
21
  }
27
- // Преобразуем значение из темы в число
28
- const gapValue = parseInt(gap, 10);
29
- const paddingValue = parseInt(padding, 10);
30
- let totalWidth = 0; // Накопленная ширина всех тегов + gap
31
- let lastFittingIndex = tags.length; // Индекс, до которого теги помещаются
32
- for (let i = 0; i < tags.length; i++) {
33
- const tag = tags[i];
34
- const contentEl = tag.firstElementChild;
35
- // Полная ширина элемента (включая margin/padding/border)
36
- const tagWidth = tag.clientWidth;
37
- // gap учитывается, начиная со второго тега
38
- const currentGap = i > 0 ? gapValue : 0;
39
- // Проверяем, переполнен ли текст внутри тега (например, обрезался)
40
- const isContentOverflowing = contentEl?.scrollWidth > contentEl?.clientWidth;
41
- // Если добавление текущего тега превышает ширину контейнера
42
- // или если сам контент внутри тега не помещается
43
- if (totalWidth + currentGap + tagWidth > container.clientWidth ||
44
- isContentOverflowing) {
45
- lastFittingIndex = i;
46
- break;
47
- }
48
- // Увеличиваем суммарную ширину
49
- totalWidth += currentGap + tagWidth + paddingValue;
50
- }
51
- // Если даже первый тег не влезает, всё равно показываем один тег
52
- if (lastFittingIndex === 0 && tags.length > 0) {
53
- return 1;
54
- }
55
- return lastFittingIndex;
56
22
  };
57
- /**
58
- * Пересчитывает максимальное количество тегов (maxItems),
59
- * которые помещаются в строку контейнера без переполнения.
60
- */
61
23
  const recomputeMaxItems = () => {
62
- const containerEl = tagsContainerRef.current;
63
- // Если контейнер или данные не заданы — прекращаем
64
- if (!containerEl || !data?.length) {
24
+ if (data.length === 0) {
25
+ setVisibleOptions([]);
26
+ setHiddenCount(0);
65
27
  return;
66
28
  }
67
- // Берём первый тег как шаблон (для клонирования)
68
- const tagTemplate = containerEl.children[0];
69
- if (!tagTemplate) {
29
+ const hasNoInputContainer = !inputContainerRef?.current;
30
+ const isZeroWidth = availableWidthRef.current === 0;
31
+ const isSmallWidth = availableWidthRef.current < constants_1.MIN_AVAILABLE_WIDTH;
32
+ // Если нет inputContainerRef и доступная ширина слишком мала или не вычислена - показываем первый тег и счетчик(если есть)
33
+ if (hasNoInputContainer && (isZeroWidth || isSmallWidth)) {
34
+ setVisibleOptions(data.slice(0, 1));
35
+ setHiddenCount(data.length - 1);
70
36
  return;
71
37
  }
72
- // Создаём скрытый клон-контейнер, чтобы измерить ширину вне DOM-окружения
73
- const clone = document.createElement('div');
74
- // Задаем стили для клон-контейнера
75
- clone.style.cssText = `
76
- visibility: hidden;
77
- position: absolute;
78
- width: ${containerEl.clientWidth}px;
79
- white-space: nowrap;
80
- `;
81
- // На основе шаблона создаём копии тегов для всех элементов data
82
- data.forEach((option) => {
83
- const tagClone = tagTemplate.cloneNode(true);
84
- const contentEl = tagClone.firstElementChild;
85
- if (contentEl) {
86
- // Подставляем текст соответствующего option
87
- contentEl.textContent = getOptionLabel(option).toString();
88
- // Включаем горизонтальный скролл, чтобы можно было определить overflow
89
- contentEl.style.overflowX = 'auto';
90
- }
91
- clone.appendChild(tagClone);
92
- });
93
- // Добавляем клон-контейнер в DOM, чтобы получить размеры
94
- document.body.appendChild(clone);
95
- // Вычисляем, сколько тегов влезает с учётом gap и padding
96
- const visibleCount = getTagsCountToAdd(clone, theme.spacing(1), theme.spacing(2));
97
- // Сохраняем результат в стейт
98
- setMaxItems(visibleCount);
99
- // Удаляем клон из DOM
100
- document.body.removeChild(clone);
101
- };
102
- (0, react_1.useLayoutEffect)(() => {
103
- if (typeof window === 'undefined' || !data || !data.length) {
38
+ // Если нет inputContainerRef и данных всего 1, показываем его даже при малой ширине (fallback)
39
+ if (hasNoInputContainer && data.length === 1) {
40
+ setVisibleOptions(data.slice(0, 1));
41
+ setHiddenCount(0);
42
+ return;
43
+ }
44
+ if (isSmallWidth) {
45
+ setVisibleOptions([]);
46
+ setHiddenCount(data.length);
47
+ }
48
+ // Расчет количества отображаемых тегов
49
+ const labels = data.map((item) => getOptionLabel(item).toString());
50
+ const visibleCount = (0, utils_1.calculateVisibleTagsCount)(labels, availableWidthRef.current, theme);
51
+ const finalCount = Math.min(visibleCount, data.length);
52
+ if (finalCount === 0 && hasNoInputContainer) {
53
+ setVisibleOptions(data.slice(0, 1));
54
+ setHiddenCount(data.length - 1);
104
55
  return;
105
56
  }
57
+ setVisibleOptions(data.slice(0, finalCount));
58
+ setHiddenCount(data.length - finalCount);
59
+ };
60
+ (0, react_1.useEffect)(() => {
61
+ updateAvailableWidth();
62
+ }, [reservedWidth]);
63
+ (0, react_1.useLayoutEffect)(() => {
106
64
  recomputeMaxItems();
107
- // Не пересчитываем ширину контейнера, так как сами ее модифицировали
108
- ignoreResizeRef.current = true;
109
- }, [data]);
65
+ }, []);
110
66
  (0, react_1.useEffect)(() => {
111
- if (typeof window === 'undefined' || !data || !data.length) {
67
+ if (!data.length) {
68
+ setVisibleOptions([]);
69
+ setHiddenCount(0);
112
70
  return;
113
71
  }
114
- if (!tagsContainerRef.current) {
115
- throw new Error('Tags container ref is not set');
116
- }
117
- // Пересчитываем maxItems при ресайзе контейнера
118
- const observer = new ResizeObserver(() => {
119
- if (ignoreResizeRef.current) {
120
- ignoreResizeRef.current = false;
121
- return;
122
- }
72
+ const resizeObserver = new ResizeObserver(() => {
73
+ updateAvailableWidth();
123
74
  recomputeMaxItems();
124
75
  });
125
- observer.observe(tagsContainerRef.current);
126
- return () => observer.disconnect();
76
+ const target = inputContainerRef?.current ?? tagsContainerRef.current;
77
+ if (!target) {
78
+ return;
79
+ }
80
+ resizeObserver.observe(target);
81
+ return () => {
82
+ resizeObserver.disconnect();
83
+ };
127
84
  }, [data]);
128
- const getTagProps = (option, index) => {
85
+ const getTagProps = (option) => {
129
86
  const label = getOptionLabel(option);
130
- const shrinks = index === maxItems - 1 && maxItems <= data.length;
131
87
  const onDelete = () => {
132
- const newValue = data?.filter((value) => {
88
+ const newValue = data.filter((value) => {
133
89
  if (typeof value === 'string') {
134
90
  return value !== option;
135
91
  }
136
- return value[keyId] !== option[keyId];
92
+ if (keyId) {
93
+ return value[keyId] !== option[keyId];
94
+ }
95
+ return getOptionLabel(value) !== getOptionLabel(option);
137
96
  });
138
- onChange(newValue?.length ? newValue : []);
97
+ onChange(newValue.length ? newValue : []);
139
98
  };
140
- return { label, shrinks, onDelete };
99
+ return { label, shrinks: false, onDelete };
141
100
  };
142
- const visibleOptions = data?.slice(0, maxItems);
101
+ const showCounter = hiddenCount > 0;
143
102
  return {
144
- maxItems,
145
103
  visibleOptions,
104
+ hiddenCount,
105
+ showCounter,
146
106
  tagsContainerRef,
147
107
  getTagProps,
148
108
  };
@@ -0,0 +1,6 @@
1
+ import type { Theme } from '../../../theme/types';
2
+ /**
3
+ * Вычисляет количество тегов, которые могут поместиться в доступную ширину
4
+ * с учетом пробелов между тегами и счетчика оставшихся элементов
5
+ */
6
+ export declare const calculateVisibleTagsCount: (tagLabels: string[], availableWidth: number, theme: Theme) => number;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateVisibleTagsCount = void 0;
4
+ const constants_1 = require("../../constants");
5
+ const getTagWidth_1 = require("../getTagWidth");
6
+ /**
7
+ * Вычисляет количество тегов, которые могут поместиться в доступную ширину
8
+ * с учетом пробелов между тегами и счетчика оставшихся элементов
9
+ */
10
+ const calculateVisibleTagsCount = (tagLabels, availableWidth, theme) => {
11
+ if (!tagLabels.length || availableWidth <= 0) {
12
+ return 0;
13
+ }
14
+ const tagWidths = tagLabels.map((label) => (0, getTagWidth_1.getTagWidth)(label, theme));
15
+ const canFitTagAtIndex = (tagIndex, accumulatedWidth) => {
16
+ const isFirstTag = tagIndex === 0;
17
+ const gapWidth = isFirstTag ? 0 : constants_1.GAP_BETWEEN_TAGS;
18
+ const tagsAfterCurrent = tagLabels.length - (tagIndex + 1);
19
+ const counterTagWidth = tagsAfterCurrent > 0
20
+ ? (0, getTagWidth_1.getTagWidth)(`+${tagsAfterCurrent}`, theme, true) + constants_1.GAP_BETWEEN_TAGS
21
+ : 0;
22
+ const totalWidthWithTag = accumulatedWidth + gapWidth + tagWidths[tagIndex];
23
+ return totalWidthWithTag + counterTagWidth <= availableWidth;
24
+ };
25
+ const fittingTagIndex = tagWidths.findIndex((_, index) => {
26
+ const widthBeforeCurrentTag = tagWidths
27
+ .slice(0, index)
28
+ .reduce((sum, width, i) => sum + width + (i > 0 ? constants_1.GAP_BETWEEN_TAGS : 0), 0);
29
+ return !canFitTagAtIndex(index, widthBeforeCurrentTag);
30
+ });
31
+ const visibleTagsCount = fittingTagIndex === -1 ? tagLabels.length : fittingTagIndex;
32
+ if (visibleTagsCount === 0) {
33
+ const counterWidthAlone = (0, getTagWidth_1.getTagWidth)(`+${tagLabels.length}`, theme);
34
+ const remainingAfterCounter = availableWidth - counterWidthAlone;
35
+ return remainingAfterCounter < constants_1.MIN_AVAILABLE_WIDTH ? 0 : 1;
36
+ }
37
+ return visibleTagsCount;
38
+ };
39
+ exports.calculateVisibleTagsCount = calculateVisibleTagsCount;
@@ -0,0 +1 @@
1
+ export { calculateVisibleTagsCount } from './calculateVisibleTagsCount';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateVisibleTagsCount = void 0;
4
+ var calculateVisibleTagsCount_1 = require("./calculateVisibleTagsCount");
5
+ Object.defineProperty(exports, "calculateVisibleTagsCount", { enumerable: true, get: function () { return calculateVisibleTagsCount_1.calculateVisibleTagsCount; } });
@@ -0,0 +1 @@
1
+ export declare const getAvailableWidth: (containerEl: HTMLElement, reservedWidth?: number) => number;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableWidth = void 0;
4
+ const getAvailableWidth = (containerEl, reservedWidth = 0) => {
5
+ const containerWidth = containerEl.clientWidth;
6
+ const paddingLeft = parseFloat(getComputedStyle(containerEl).paddingLeft);
7
+ const paddingRight = parseFloat(getComputedStyle(containerEl).paddingRight);
8
+ const availableWidth = containerWidth - paddingLeft - paddingRight - reservedWidth;
9
+ return availableWidth;
10
+ };
11
+ exports.getAvailableWidth = getAvailableWidth;
@@ -0,0 +1 @@
1
+ export { getAvailableWidth } from './getAvailableWidth';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableWidth = void 0;
4
+ var getAvailableWidth_1 = require("./getAvailableWidth");
5
+ Object.defineProperty(exports, "getAvailableWidth", { enumerable: true, get: function () { return getAvailableWidth_1.getAvailableWidth; } });
@@ -1,2 +1,2 @@
1
1
  import type { TagValue } from '../../types';
2
- export declare const getKey: (option: TagValue, keyId: string) => string;
2
+ export declare const getKey: <TData extends TagValue>(option: TData, keyId: string | undefined, getOptionLabel: (tagOption: TData) => string | number) => string;
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getKey = void 0;
4
- const getKey = (option, keyId) => {
4
+ const getKey = (option, keyId, getOptionLabel) => {
5
5
  if (typeof option === 'string') {
6
6
  return option;
7
7
  }
8
- const key = option[keyId];
9
- return typeof key === 'number' ? key.toString() : key;
8
+ if (keyId) {
9
+ const key = option[keyId];
10
+ return typeof key === 'number' ? key.toString() : key;
11
+ }
12
+ return getOptionLabel(option).toString();
10
13
  };
11
14
  exports.getKey = getKey;
@@ -0,0 +1,2 @@
1
+ import { type Theme } from '../../../theme/types';
2
+ export declare const getTagWidth: (label: string | number, theme: Theme, isCounter?: boolean) => number;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTagWidth = void 0;
4
+ const Tag_1 = require("../../Tag");
5
+ const getTagWidth = (label, theme, isCounter = false) => {
6
+ /** 16px иконка и 2px padding */
7
+ const DELETE_ICON_WIDTH = 18;
8
+ const el = document.createElement('div');
9
+ el.textContent = label.toString();
10
+ el.style.visibility = 'hidden';
11
+ el.style.position = 'absolute';
12
+ el.style.display = 'inline-flex';
13
+ el.style.whiteSpace = 'nowrap';
14
+ el.style.padding = theme.spacing(0, 2);
15
+ el.style.paddingLeft = theme.spacing(2);
16
+ el.style.paddingRight = isCounter ? theme.spacing(2) : theme.microSpacing(1);
17
+ el.style.boxSizing = 'border-box';
18
+ document.body.appendChild(el);
19
+ const width = isCounter
20
+ ? el.getBoundingClientRect().width
21
+ : el.getBoundingClientRect().width + DELETE_ICON_WIDTH;
22
+ document.body.removeChild(el);
23
+ return Math.ceil(Math.min(width, parseInt(Tag_1.MAX_TAG_WIDTH, 10)));
24
+ };
25
+ exports.getTagWidth = getTagWidth;
@@ -0,0 +1 @@
1
+ export * from './getTagWidth';
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./TagsList"), exports);
18
- __exportStar(require("./types"), exports);
17
+ __exportStar(require("./getTagWidth"), exports);
@@ -1,2 +1,5 @@
1
1
  export { getElementByText } from './getElementByText';
2
2
  export { getKey } from './getKey';
3
+ export { getTagWidth } from './getTagWidth';
4
+ export { getAvailableWidth } from './getAvailableWidth';
5
+ export { calculateVisibleTagsCount } from './calculateVisibleTagsCount';
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getKey = exports.getElementByText = void 0;
3
+ exports.calculateVisibleTagsCount = exports.getAvailableWidth = exports.getTagWidth = exports.getKey = exports.getElementByText = void 0;
4
4
  var getElementByText_1 = require("./getElementByText");
5
5
  Object.defineProperty(exports, "getElementByText", { enumerable: true, get: function () { return getElementByText_1.getElementByText; } });
6
6
  var getKey_1 = require("./getKey");
7
7
  Object.defineProperty(exports, "getKey", { enumerable: true, get: function () { return getKey_1.getKey; } });
8
+ var getTagWidth_1 = require("./getTagWidth");
9
+ Object.defineProperty(exports, "getTagWidth", { enumerable: true, get: function () { return getTagWidth_1.getTagWidth; } });
10
+ var getAvailableWidth_1 = require("./getAvailableWidth");
11
+ Object.defineProperty(exports, "getAvailableWidth", { enumerable: true, get: function () { return getAvailableWidth_1.getAvailableWidth; } });
12
+ var calculateVisibleTagsCount_1 = require("./calculateVisibleTagsCount");
13
+ Object.defineProperty(exports, "calculateVisibleTagsCount", { enumerable: true, get: function () { return calculateVisibleTagsCount_1.calculateVisibleTagsCount; } });
@@ -7,7 +7,7 @@ const FormHelperText_1 = require("../FormHelperText");
7
7
  const classNames_1 = require("../utils/classNames");
8
8
  const constants_1 = require("./constants");
9
9
  const styles_1 = require("./styles");
10
- exports.TextField = (0, react_1.forwardRef)(({ success, error, helperText: helperTextProp, fullWidth = false, startAdornment, endAdornment, inputProps, InputProps, maxLength, trimmed = true, onBlur, hideHelperText = false, className, ...props }, ref) => {
10
+ exports.TextField = (0, react_1.forwardRef)(({ success, error, helperText: helperTextProp, fullWidth = false, startAdornment, endAdornment, inputProps, InputProps, maxLength, trimmed = true, onBlur, hideHelperText = false, className, disabled, ...props }, ref) => {
11
11
  const color = (0, react_1.useMemo)(() => {
12
12
  if (success) {
13
13
  return 'success';
@@ -40,9 +40,10 @@ exports.TextField = (0, react_1.forwardRef)(({ success, error, helperText: helpe
40
40
  }
41
41
  onBlur?.(event);
42
42
  };
43
- const classes = (0, react_1.useMemo)(() => {
44
- return (0, classNames_1.classNames)(className, hideHelperText ? constants_1.textFieldClassnames.hideHelperText : '');
45
- }, [className, hideHelperText]);
43
+ const classnames = (0, react_1.useMemo)(() => (0, classNames_1.classNames)(className, {
44
+ [constants_1.textFieldClassnames.hideHelperText]: hideHelperText,
45
+ [constants_1.textFieldClassnames.disabled]: disabled,
46
+ }), [className, hideHelperText, disabled]);
46
47
  return ((0, jsx_runtime_1.jsx)(styles_1.StyledTextField, { ref: ref, variant: "outlined", fullWidth: fullWidth, error: error, color: color, helperText: helperText, InputProps: {
47
48
  startAdornment,
48
49
  endAdornment,
@@ -50,5 +51,5 @@ exports.TextField = (0, react_1.forwardRef)(({ success, error, helperText: helpe
50
51
  }, inputProps: {
51
52
  maxLength,
52
53
  ...inputProps,
53
- }, onBlur: handleBlur, className: classes, ...props }));
54
+ }, onBlur: handleBlur, className: classnames, disabled: disabled, ...props }));
54
55
  });
@@ -1,3 +1,4 @@
1
1
  export declare const textFieldClassnames: {
2
2
  hideHelperText: string;
3
+ disabled: string;
3
4
  };
@@ -4,4 +4,5 @@ exports.textFieldClassnames = void 0;
4
4
  const createUIKitClassname_1 = require("../utils/createUIKitClassname");
5
5
  exports.textFieldClassnames = {
6
6
  hideHelperText: (0, createUIKitClassname_1.createUIKitClassname)('text-field__helper-text_hidden'),
7
+ disabled: (0, createUIKitClassname_1.createUIKitClassname)('text-field_disabled'),
7
8
  };
@@ -20,4 +20,8 @@ exports.StyledTextField = (0, styled_1.styled)(TextField_1.default) `
20
20
  }
21
21
  }
22
22
  }
23
+
24
+ &.${constants_1.textFieldClassnames.disabled} {
25
+ pointer-events: none;
26
+ }
23
27
  `;
@@ -12,7 +12,7 @@ const styles_1 = require("./styles");
12
12
  const useLogic_1 = require("./useLogic");
13
13
  const ClearButton = ({ disabled, onClick }) => ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", color: "grey", disabled: disabled, onClick: onClick, title: constants_1.CLEAR_TEXT, "aria-label": constants_1.CLEAR_TEXT, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) }));
14
14
  exports.Input = (0, react_1.forwardRef)(({ disabled, onChange: propsOnChange, value, inputRef, hideHelperText = false, onClick, isLoading, ...restProps }, forwardedRef) => {
15
- const { isVisibleClearButton, onChange, isVisibleTagsList, textFieldProps, onClearAll, } = (0, useLogic_1.useLogic)({
15
+ const { isVisibleClearButton, isVisibleTagsList, onChange, textFieldProps, onClearAll, } = (0, useLogic_1.useLogic)({
16
16
  inputRef,
17
17
  value,
18
18
  onChange: propsOnChange,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.36.1",
3
+ "version": "4.37.0",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {
@@ -1,2 +0,0 @@
1
- export * from './TagsList';
2
- export * from './types';
@@ -1,2 +0,0 @@
1
- export * from './TagsList';
2
- export * from './types';
@@ -1,2 +0,0 @@
1
- export * from './TagsList';
2
- export * from './types';