@fanvue/ui 3.52.0 → 3.54.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 (189) hide show
  1. package/dist/cjs/components/AudioPlayer/AudioPlayer.cjs +4 -2
  2. package/dist/cjs/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
  3. package/dist/cjs/components/Autocomplete/Autocomplete.cjs +34 -10
  4. package/dist/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
  5. package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs +13 -1
  6. package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs.map +1 -1
  7. package/dist/cjs/components/Badge/Badge.cjs +7 -6
  8. package/dist/cjs/components/Badge/Badge.cjs.map +1 -1
  9. package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs +2 -2
  10. package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs.map +1 -1
  11. package/dist/cjs/components/Button/Button.cjs +2 -1
  12. package/dist/cjs/components/Button/Button.cjs.map +1 -1
  13. package/dist/cjs/components/Card/Card.cjs +6 -3
  14. package/dist/cjs/components/Card/Card.cjs.map +1 -1
  15. package/dist/cjs/components/Chart/ChartCard.cjs +2 -1
  16. package/dist/cjs/components/Chart/ChartCard.cjs.map +1 -1
  17. package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs +1 -1
  18. package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs.map +1 -1
  19. package/dist/cjs/components/ChatInput/ChatInput.cjs +2 -2
  20. package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
  21. package/dist/cjs/components/ChatMessage/ChatMessage.cjs +4 -2
  22. package/dist/cjs/components/ChatMessage/ChatMessage.cjs.map +1 -1
  23. package/dist/cjs/components/Chip/Chip.cjs +10 -9
  24. package/dist/cjs/components/Chip/Chip.cjs.map +1 -1
  25. package/dist/cjs/components/CreatorCard/CreatorCard.cjs +3 -5
  26. package/dist/cjs/components/CreatorCard/CreatorCard.cjs.map +1 -1
  27. package/dist/cjs/components/CreatorCover/CreatorCover.cjs +11 -7
  28. package/dist/cjs/components/CreatorCover/CreatorCover.cjs.map +1 -1
  29. package/dist/cjs/components/DatePicker/DatePicker.cjs +37 -16
  30. package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
  31. package/dist/cjs/components/DatePicker/DateRangePanel.cjs +143 -0
  32. package/dist/cjs/components/DatePicker/DateRangePanel.cjs.map +1 -0
  33. package/dist/cjs/components/DatePicker/DateRangePicker.cjs +33 -0
  34. package/dist/cjs/components/DatePicker/DateRangePicker.cjs.map +1 -0
  35. package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +33 -10
  36. package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -1
  37. package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +2 -1
  38. package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -1
  39. package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +18 -13
  40. package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -1
  41. package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +56 -40
  42. package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -1
  43. package/dist/cjs/components/FilterMenu/FilterMenu.cjs +45 -0
  44. package/dist/cjs/components/FilterMenu/FilterMenu.cjs.map +1 -0
  45. package/dist/cjs/components/IconButton/IconButton.cjs +7 -3
  46. package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
  47. package/dist/cjs/components/Icons/MenuRowIcon.cjs +9 -2
  48. package/dist/cjs/components/Icons/MenuRowIcon.cjs.map +1 -1
  49. package/dist/cjs/components/Icons/ReorganiseIcon.cjs +65 -0
  50. package/dist/cjs/components/Icons/ReorganiseIcon.cjs.map +1 -0
  51. package/dist/cjs/components/Icons/VerifiedIcon.cjs +9 -15
  52. package/dist/cjs/components/Icons/VerifiedIcon.cjs.map +1 -1
  53. package/dist/cjs/components/Pagination/Pagination.cjs +3 -2
  54. package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
  55. package/dist/cjs/components/PhoneField/PhoneField.cjs +21 -17
  56. package/dist/cjs/components/PhoneField/PhoneField.cjs.map +1 -1
  57. package/dist/cjs/components/Popover/Popover.cjs +69 -0
  58. package/dist/cjs/components/Popover/Popover.cjs.map +1 -0
  59. package/dist/cjs/components/Select/Select.cjs +49 -12
  60. package/dist/cjs/components/Select/Select.cjs.map +1 -1
  61. package/dist/cjs/components/Slider/SliderThumb.cjs +3 -2
  62. package/dist/cjs/components/Slider/SliderThumb.cjs.map +1 -1
  63. package/dist/cjs/components/Snackbar/Snackbar.cjs +1 -1
  64. package/dist/cjs/components/Snackbar/Snackbar.cjs.map +1 -1
  65. package/dist/cjs/components/Switch/Switch.cjs +1 -1
  66. package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
  67. package/dist/cjs/components/Table/Table.cjs +104 -38
  68. package/dist/cjs/components/Table/Table.cjs.map +1 -1
  69. package/dist/cjs/components/Table/TableToolbarSearchFilters.cjs +152 -0
  70. package/dist/cjs/components/Table/TableToolbarSearchFilters.cjs.map +1 -0
  71. package/dist/cjs/components/Table/useFittingCount.cjs +51 -0
  72. package/dist/cjs/components/Table/useFittingCount.cjs.map +1 -0
  73. package/dist/cjs/components/Tag/Tag.cjs +99 -0
  74. package/dist/cjs/components/Tag/Tag.cjs.map +1 -0
  75. package/dist/cjs/components/TextArea/TextArea.cjs +5 -4
  76. package/dist/cjs/components/TextArea/TextArea.cjs.map +1 -1
  77. package/dist/cjs/components/TextField/TextField.cjs +30 -15
  78. package/dist/cjs/components/TextField/TextField.cjs.map +1 -1
  79. package/dist/cjs/date-picker.cjs +4 -0
  80. package/dist/cjs/date-picker.cjs.map +1 -1
  81. package/dist/cjs/index.cjs +12 -0
  82. package/dist/cjs/index.cjs.map +1 -1
  83. package/dist/cjs/utils/floatingContentSurface.cjs +8 -0
  84. package/dist/cjs/utils/floatingContentSurface.cjs.map +1 -0
  85. package/dist/cjs/utils/inputFieldClasses.cjs +8 -0
  86. package/dist/cjs/utils/inputFieldClasses.cjs.map +1 -0
  87. package/dist/cjs/utils/pointerCapture.cjs +20 -0
  88. package/dist/cjs/utils/pointerCapture.cjs.map +1 -0
  89. package/dist/cjs/utils/useDragToDismiss.cjs +3 -2
  90. package/dist/cjs/utils/useDragToDismiss.cjs.map +1 -1
  91. package/dist/cjs/utils/useSuppressClickAfterDrag.cjs +2 -1
  92. package/dist/cjs/utils/useSuppressClickAfterDrag.cjs.map +1 -1
  93. package/dist/components/AudioPlayer/AudioPlayer.mjs +4 -2
  94. package/dist/components/AudioPlayer/AudioPlayer.mjs.map +1 -1
  95. package/dist/components/Autocomplete/Autocomplete.mjs +34 -10
  96. package/dist/components/Autocomplete/Autocomplete.mjs.map +1 -1
  97. package/dist/components/Autocomplete/AutocompleteOptionItem.mjs +13 -1
  98. package/dist/components/Autocomplete/AutocompleteOptionItem.mjs.map +1 -1
  99. package/dist/components/Badge/Badge.mjs +7 -6
  100. package/dist/components/Badge/Badge.mjs.map +1 -1
  101. package/dist/components/BottomNavigation/BottomNavigation.mjs +2 -2
  102. package/dist/components/BottomNavigation/BottomNavigation.mjs.map +1 -1
  103. package/dist/components/Button/Button.mjs +2 -1
  104. package/dist/components/Button/Button.mjs.map +1 -1
  105. package/dist/components/Card/Card.mjs +6 -3
  106. package/dist/components/Card/Card.mjs.map +1 -1
  107. package/dist/components/Chart/ChartCard.mjs +2 -1
  108. package/dist/components/Chart/ChartCard.mjs.map +1 -1
  109. package/dist/components/Chart/ChartLoadingOverlay.mjs +1 -1
  110. package/dist/components/Chart/ChartLoadingOverlay.mjs.map +1 -1
  111. package/dist/components/ChatInput/ChatInput.mjs +2 -2
  112. package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
  113. package/dist/components/ChatMessage/ChatMessage.mjs +4 -2
  114. package/dist/components/ChatMessage/ChatMessage.mjs.map +1 -1
  115. package/dist/components/Chip/Chip.mjs +10 -9
  116. package/dist/components/Chip/Chip.mjs.map +1 -1
  117. package/dist/components/CreatorCard/CreatorCard.mjs +3 -5
  118. package/dist/components/CreatorCard/CreatorCard.mjs.map +1 -1
  119. package/dist/components/CreatorCover/CreatorCover.mjs +11 -7
  120. package/dist/components/CreatorCover/CreatorCover.mjs.map +1 -1
  121. package/dist/components/DatePicker/DatePicker.mjs +39 -18
  122. package/dist/components/DatePicker/DatePicker.mjs.map +1 -1
  123. package/dist/components/DatePicker/DateRangePanel.mjs +126 -0
  124. package/dist/components/DatePicker/DateRangePanel.mjs.map +1 -0
  125. package/dist/components/DatePicker/DateRangePicker.mjs +33 -0
  126. package/dist/components/DatePicker/DateRangePicker.mjs.map +1 -0
  127. package/dist/components/DropdownMenu/DropdownMenuItem.mjs +33 -10
  128. package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -1
  129. package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +2 -1
  130. package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -1
  131. package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +18 -13
  132. package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -1
  133. package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +56 -40
  134. package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -1
  135. package/dist/components/FilterMenu/FilterMenu.mjs +28 -0
  136. package/dist/components/FilterMenu/FilterMenu.mjs.map +1 -0
  137. package/dist/components/IconButton/IconButton.mjs +7 -3
  138. package/dist/components/IconButton/IconButton.mjs.map +1 -1
  139. package/dist/components/Icons/MenuRowIcon.mjs +9 -2
  140. package/dist/components/Icons/MenuRowIcon.mjs.map +1 -1
  141. package/dist/components/Icons/ReorganiseIcon.mjs +48 -0
  142. package/dist/components/Icons/ReorganiseIcon.mjs.map +1 -0
  143. package/dist/components/Icons/VerifiedIcon.mjs +9 -15
  144. package/dist/components/Icons/VerifiedIcon.mjs.map +1 -1
  145. package/dist/components/Pagination/Pagination.mjs +3 -2
  146. package/dist/components/Pagination/Pagination.mjs.map +1 -1
  147. package/dist/components/PhoneField/PhoneField.mjs +21 -17
  148. package/dist/components/PhoneField/PhoneField.mjs.map +1 -1
  149. package/dist/components/Popover/Popover.mjs +51 -0
  150. package/dist/components/Popover/Popover.mjs.map +1 -0
  151. package/dist/components/Select/Select.mjs +49 -12
  152. package/dist/components/Select/Select.mjs.map +1 -1
  153. package/dist/components/Slider/SliderThumb.mjs +3 -2
  154. package/dist/components/Slider/SliderThumb.mjs.map +1 -1
  155. package/dist/components/Snackbar/Snackbar.mjs +1 -1
  156. package/dist/components/Snackbar/Snackbar.mjs.map +1 -1
  157. package/dist/components/Switch/Switch.mjs +1 -1
  158. package/dist/components/Switch/Switch.mjs.map +1 -1
  159. package/dist/components/Table/Table.mjs +104 -38
  160. package/dist/components/Table/Table.mjs.map +1 -1
  161. package/dist/components/Table/TableToolbarSearchFilters.mjs +135 -0
  162. package/dist/components/Table/TableToolbarSearchFilters.mjs.map +1 -0
  163. package/dist/components/Table/useFittingCount.mjs +34 -0
  164. package/dist/components/Table/useFittingCount.mjs.map +1 -0
  165. package/dist/components/Tag/Tag.mjs +82 -0
  166. package/dist/components/Tag/Tag.mjs.map +1 -0
  167. package/dist/components/TextArea/TextArea.mjs +5 -4
  168. package/dist/components/TextArea/TextArea.mjs.map +1 -1
  169. package/dist/components/TextField/TextField.mjs +30 -15
  170. package/dist/components/TextField/TextField.mjs.map +1 -1
  171. package/dist/date-picker.d.ts +109 -0
  172. package/dist/date-picker.mjs +5 -1
  173. package/dist/date-picker.mjs.map +1 -1
  174. package/dist/index.d.ts +317 -20
  175. package/dist/index.mjs +12 -0
  176. package/dist/index.mjs.map +1 -1
  177. package/dist/styles/base.css +51 -4
  178. package/dist/styles/theme.css +1217 -1
  179. package/dist/utils/floatingContentSurface.mjs +8 -0
  180. package/dist/utils/floatingContentSurface.mjs.map +1 -0
  181. package/dist/utils/inputFieldClasses.mjs +8 -0
  182. package/dist/utils/inputFieldClasses.mjs.map +1 -0
  183. package/dist/utils/pointerCapture.mjs +20 -0
  184. package/dist/utils/pointerCapture.mjs.map +1 -0
  185. package/dist/utils/useDragToDismiss.mjs +3 -2
  186. package/dist/utils/useDragToDismiss.mjs.map +1 -1
  187. package/dist/utils/useSuppressClickAfterDrag.mjs +2 -1
  188. package/dist/utils/useSuppressClickAfterDrag.mjs.map +1 -1
  189. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../../utils/cn.mjs";
5
+ import { Popover, PopoverTrigger, PopoverContent } from "../Popover/Popover.mjs";
6
+ import { Tag } from "../Tag/Tag.mjs";
7
+ import { useFittingCount } from "./useFittingCount.mjs";
8
+ function SearchFilter({
9
+ filter,
10
+ className
11
+ }) {
12
+ return /* @__PURE__ */ jsxs(
13
+ Tag,
14
+ {
15
+ className: cn("shrink-0", className),
16
+ onRemove: filter.onRemove,
17
+ removeLabel: filter.removeLabel,
18
+ children: [
19
+ /* @__PURE__ */ jsx("span", { className: "text-content-secondary", children: filter.name }),
20
+ " ",
21
+ filter.value
22
+ ]
23
+ }
24
+ );
25
+ }
26
+ function SearchFilters({
27
+ filters,
28
+ formatHiddenFilters,
29
+ children
30
+ }) {
31
+ if (!filters) return children;
32
+ return /* @__PURE__ */ jsx(SearchFiltersSlot, { filters, formatHiddenFilters, children });
33
+ }
34
+ function SearchFiltersSlot({ filters, formatHiddenFilters, children }) {
35
+ const wrapperRef = React.useRef(null);
36
+ const rulerRef = React.useRef(null);
37
+ const refocusInput = React.useRef(false);
38
+ const fittingCount = useFittingCount(rulerRef, filters.length);
39
+ const visibleCount = Math.min(fittingCount ?? filters.length, filters.length);
40
+ const hiddenCount = filters.length - visibleCount;
41
+ React.useEffect(() => {
42
+ if (hiddenCount === 0 && refocusInput.current) {
43
+ refocusInput.current = false;
44
+ wrapperRef.current?.querySelector("input")?.focus();
45
+ }
46
+ }, [hiddenCount]);
47
+ return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: "relative flex min-w-0 flex-1 items-center gap-2", children: [
48
+ /* @__PURE__ */ jsx(
49
+ "div",
50
+ {
51
+ ref: rulerRef,
52
+ "aria-hidden": true,
53
+ inert: true,
54
+ className: "pointer-events-none invisible absolute top-0 right-26 left-0 hidden h-0 overflow-hidden md:block",
55
+ children: /* @__PURE__ */ jsxs("div", { className: "flex w-max items-center gap-2", children: [
56
+ filters.map((filter) => /* @__PURE__ */ jsx(SearchFilter, { filter }, filter.id)),
57
+ /* @__PURE__ */ jsx(Tag, { children: `+${Math.max(filters.length - 1, 1)}` })
58
+ ] })
59
+ }
60
+ ),
61
+ filters.length > 0 && /* @__PURE__ */ jsxs("div", { className: "hidden min-w-0 items-center gap-2 md:flex", children: [
62
+ filters.slice(0, visibleCount).map((filter) => /* @__PURE__ */ jsx(SearchFilter, { filter }, filter.id)),
63
+ hiddenCount > 0 && /* @__PURE__ */ jsx(
64
+ HiddenFilters,
65
+ {
66
+ filters: filters.slice(visibleCount),
67
+ label: formatHiddenFilters?.(hiddenCount),
68
+ refocusInput
69
+ }
70
+ )
71
+ ] }),
72
+ children
73
+ ] });
74
+ }
75
+ function HiddenFilters({
76
+ filters,
77
+ label,
78
+ refocusInput
79
+ }) {
80
+ return /* @__PURE__ */ jsxs(
81
+ Popover,
82
+ {
83
+ onOpenChange: (open) => {
84
+ if (!open) refocusInput.current = false;
85
+ },
86
+ children: [
87
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
88
+ "button",
89
+ {
90
+ type: "button",
91
+ "aria-label": label,
92
+ className: "relative isolate inline-flex shrink-0 cursor-pointer rounded-2xs border-none bg-transparent p-0 outline-hidden before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:bg-tag-hover-overlay before:opacity-0 hover:before:opacity-100 focus-visible:shadow-focus-ring",
93
+ children: /* @__PURE__ */ jsx(Tag, { "aria-hidden": label ? true : void 0, children: `+${filters.length}` })
94
+ }
95
+ ) }),
96
+ /* @__PURE__ */ jsx(
97
+ PopoverContent,
98
+ {
99
+ "aria-label": label ?? `+${filters.length}`,
100
+ className: "flex flex-col items-start gap-2",
101
+ children: filters.map((filter) => /* @__PURE__ */ jsx(
102
+ SearchFilter,
103
+ {
104
+ filter: {
105
+ ...filter,
106
+ onRemove: () => {
107
+ refocusInput.current = true;
108
+ filter.onRemove();
109
+ }
110
+ }
111
+ },
112
+ filter.id
113
+ ))
114
+ }
115
+ )
116
+ ]
117
+ }
118
+ );
119
+ }
120
+ function ClearSearchFilters({ label, onClick }) {
121
+ return /* @__PURE__ */ jsx(
122
+ "button",
123
+ {
124
+ type: "button",
125
+ onClick,
126
+ className: "typography-description-12px-regular hidden h-6 shrink-0 cursor-pointer items-center whitespace-nowrap rounded-xs border-none bg-transparent p-0 text-content-secondary outline-none hover:text-content-primary focus-visible:shadow-focus-ring md:inline-flex",
127
+ children: label
128
+ }
129
+ );
130
+ }
131
+ export {
132
+ ClearSearchFilters,
133
+ SearchFilters
134
+ };
135
+ //# sourceMappingURL=TableToolbarSearchFilters.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableToolbarSearchFilters.mjs","sources":["../../../src/components/Table/TableToolbarSearchFilters.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../Popover/Popover\";\nimport { Tag } from \"../Tag/Tag\";\nimport { useFittingCount } from \"./useFittingCount\";\n\n/** An applied filter shown inside a `TableToolbarSearch`, e.g. \"Platform is Instagram\". */\nexport interface TableToolbarSearchFilter {\n /** Stable key for the filter. */\n id: string;\n /** Secondary text, e.g. \"Platform is\". */\n name: string;\n /** Primary text, e.g. \"Instagram, YouTube\". */\n value: string;\n /** Called when the filter's × button is pressed. */\n onRemove: () => void;\n /** Accessible name of the × button, as one translated string such as \"Remove Platform filter\". */\n removeLabel: string;\n}\n\nfunction SearchFilter({\n filter,\n className,\n}: {\n filter: TableToolbarSearchFilter;\n className?: string;\n}) {\n return (\n <Tag\n className={cn(\"shrink-0\", className)}\n onRemove={filter.onRemove}\n removeLabel={filter.removeLabel}\n >\n <span className=\"text-content-secondary\">{filter.name}</span> {filter.value}\n </Tag>\n );\n}\n\n/**\n * Wraps the search input of a `TableToolbarSearch` and puts the applied filters before it. Without\n * `filters` it renders the input alone.\n */\nexport function SearchFilters({\n filters,\n formatHiddenFilters,\n children,\n}: {\n filters?: readonly TableToolbarSearchFilter[];\n formatHiddenFilters?: (count: number) => string;\n children: React.ReactNode;\n}) {\n if (!filters) return children;\n return (\n <SearchFiltersSlot filters={filters} formatHiddenFilters={formatHiddenFilters}>\n {children}\n </SearchFiltersSlot>\n );\n}\n\ninterface SearchFiltersSlotProps {\n filters: readonly TableToolbarSearchFilter[];\n formatHiddenFilters?: (count: number) => string;\n children: React.ReactNode;\n}\n\n/**\n * The input keeps at least 96px. A filter is shown whole or counted in the \"+N\" tag, never cut, so\n * when none fits only \"+N\" shows. \"+N\" opens a popover listing the hidden filters. The ruler's `right-26` is the input's `min-w-24`, set in\n * `TableToolbarSearch`, plus the wrapper's `gap-2`: change them together.\n */\nfunction SearchFiltersSlot({ filters, formatHiddenFilters, children }: SearchFiltersSlotProps) {\n const wrapperRef = React.useRef<HTMLDivElement>(null);\n const rulerRef = React.useRef<HTMLDivElement>(null);\n const refocusInput = React.useRef(false);\n const fittingCount = useFittingCount(rulerRef, filters.length);\n const visibleCount = Math.min(fittingCount ?? filters.length, filters.length);\n const hiddenCount = filters.length - visibleCount;\n\n React.useEffect(() => {\n if (hiddenCount === 0 && refocusInput.current) {\n refocusInput.current = false;\n wrapperRef.current?.querySelector(\"input\")?.focus();\n }\n }, [hiddenCount]);\n\n return (\n <div ref={wrapperRef} className=\"relative flex min-w-0 flex-1 items-center gap-2\">\n <div\n ref={rulerRef}\n aria-hidden\n inert\n className=\"pointer-events-none invisible absolute top-0 right-26 left-0 hidden h-0 overflow-hidden md:block\"\n >\n <div className=\"flex w-max items-center gap-2\">\n {filters.map((filter) => (\n <SearchFilter key={filter.id} filter={filter} />\n ))}\n <Tag>{`+${Math.max(filters.length - 1, 1)}`}</Tag>\n </div>\n </div>\n {filters.length > 0 && (\n <div className=\"hidden min-w-0 items-center gap-2 md:flex\">\n {filters.slice(0, visibleCount).map((filter) => (\n <SearchFilter key={filter.id} filter={filter} />\n ))}\n {hiddenCount > 0 && (\n <HiddenFilters\n filters={filters.slice(visibleCount)}\n label={formatHiddenFilters?.(hiddenCount)}\n refocusInput={refocusInput}\n />\n )}\n </div>\n )}\n {children}\n </div>\n );\n}\n\nfunction HiddenFilters({\n filters,\n label,\n refocusInput,\n}: {\n filters: readonly TableToolbarSearchFilter[];\n label?: string;\n refocusInput: React.MutableRefObject<boolean>;\n}) {\n return (\n <Popover\n onOpenChange={(open) => {\n if (!open) refocusInput.current = false;\n }}\n >\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-label={label}\n className=\"relative isolate inline-flex shrink-0 cursor-pointer rounded-2xs border-none bg-transparent p-0 outline-hidden before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:bg-tag-hover-overlay before:opacity-0 hover:before:opacity-100 focus-visible:shadow-focus-ring\"\n >\n <Tag aria-hidden={label ? true : undefined}>{`+${filters.length}`}</Tag>\n </button>\n </PopoverTrigger>\n <PopoverContent\n aria-label={label ?? `+${filters.length}`}\n className=\"flex flex-col items-start gap-2\"\n >\n {filters.map((filter) => (\n <SearchFilter\n key={filter.id}\n filter={{\n ...filter,\n onRemove: () => {\n refocusInput.current = true;\n filter.onRemove();\n },\n }}\n />\n ))}\n </PopoverContent>\n </Popover>\n );\n}\n\n/** The \"Clear all\" text action after the search input, hidden below `md` like the filters. */\nexport function ClearSearchFilters({ label, onClick }: { label: string; onClick: () => void }) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className=\"typography-description-12px-regular hidden h-6 shrink-0 cursor-pointer items-center whitespace-nowrap rounded-xs border-none bg-transparent p-0 text-content-secondary outline-none hover:text-content-primary focus-visible:shadow-focus-ring md:inline-flex\"\n >\n {label}\n </button>\n );\n}\n"],"names":[],"mappings":";;;;;;;AAoBA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AACF,GAGG;AACD,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,GAAG,YAAY,SAAS;AAAA,MACnC,UAAU,OAAO;AAAA,MACjB,aAAa,OAAO;AAAA,MAEpB,UAAA;AAAA,QAAA,oBAAC,QAAA,EAAK,WAAU,0BAA0B,UAAA,OAAO,MAAK;AAAA,QAAO;AAAA,QAAE,OAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG5E;AAMO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,MAAI,CAAC,QAAS,QAAO;AACrB,SACE,oBAAC,mBAAA,EAAkB,SAAkB,qBAClC,SAAA,CACH;AAEJ;AAaA,SAAS,kBAAkB,EAAE,SAAS,qBAAqB,YAAoC;AAC7F,QAAM,aAAa,MAAM,OAAuB,IAAI;AACpD,QAAM,WAAW,MAAM,OAAuB,IAAI;AAClD,QAAM,eAAe,MAAM,OAAO,KAAK;AACvC,QAAM,eAAe,gBAAgB,UAAU,QAAQ,MAAM;AAC7D,QAAM,eAAe,KAAK,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,MAAM;AAC5E,QAAM,cAAc,QAAQ,SAAS;AAErC,QAAM,UAAU,MAAM;AACpB,QAAI,gBAAgB,KAAK,aAAa,SAAS;AAC7C,mBAAa,UAAU;AACvB,iBAAW,SAAS,cAAc,OAAO,GAAG,MAAA;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,SACE,qBAAC,OAAA,EAAI,KAAK,YAAY,WAAU,mDAC9B,UAAA;AAAA,IAAA;AAAA,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UAAA;AAAA,YACC,cAAY,SAAS,IAAI,QAAQ,MAAM;AAAA,YACvC,WAAU;AAAA,YAET,UAAA,QAAQ,IAAI,CAAC,WACZ;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,QAAQ;AAAA,kBACN,GAAG;AAAA,kBACH,UAAU,MAAM;AACd,iCAAa,UAAU;AACvB,2BAAO,SAAA;AAAA,kBACT;AAAA,gBAAA;AAAA,cACF;AAAA,cAPK,OAAO;AAAA,YAAA,CASf;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAGN;AAGO,SAAS,mBAAmB,EAAE,OAAO,WAAmD;AAC7F,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL;AAAA,MACA,WAAU;AAAA,MAET,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ function countFitting(available, items, indicator) {
4
+ const last = items.at(-1);
5
+ if (available.width <= 0 || !last || !indicator) return null;
6
+ if (last.right - available.left <= available.width) return items.length;
7
+ const reserved = indicator.left - last.right + indicator.width;
8
+ return items.findIndex((item) => item.right - available.left + reserved > available.width);
9
+ }
10
+ function useFittingCount(rulerRef, itemCount) {
11
+ const [count, setCount] = React.useState(null);
12
+ const evaluate = React.useCallback(() => {
13
+ const ruler = rulerRef.current;
14
+ const replica = ruler?.firstElementChild;
15
+ if (!ruler || !replica) return;
16
+ const rects = Array.from(replica.children, (child) => child.getBoundingClientRect());
17
+ setCount(countFitting(ruler.getBoundingClientRect(), rects.slice(0, itemCount), rects.at(-1)));
18
+ }, [rulerRef, itemCount]);
19
+ React.useLayoutEffect(evaluate);
20
+ React.useEffect(() => {
21
+ const ruler = rulerRef.current;
22
+ const replica = ruler?.firstElementChild;
23
+ if (!ruler || !replica) return;
24
+ const observer = new ResizeObserver(evaluate);
25
+ observer.observe(ruler);
26
+ observer.observe(replica);
27
+ return () => observer.disconnect();
28
+ }, [rulerRef, evaluate]);
29
+ return count;
30
+ }
31
+ export {
32
+ useFittingCount
33
+ };
34
+ //# sourceMappingURL=useFittingCount.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFittingCount.mjs","sources":["../../../src/components/Table/useFittingCount.ts"],"sourcesContent":["import * as React from \"react\";\n\nfunction countFitting(available: DOMRect, items: DOMRect[], indicator?: DOMRect): number | null {\n const last = items.at(-1);\n if (available.width <= 0 || !last || !indicator) return null;\n if (last.right - available.left <= available.width) return items.length;\n const reserved = indicator.left - last.right + indicator.width;\n return items.findIndex((item) => item.right - available.left + reserved > available.width);\n}\n\n/**\n * Returns how many leading items fit in a row, or `null` while the row cannot be measured (SSR,\n * jsdom, `display: none`), in which case the caller shows them all.\n *\n * `rulerRef` is an invisible element as wide as the space the items may take. Its only child is a\n * replica row holding every item at its natural width, followed by the widest overflow indicator\n * (\"+N\"). Because the replica always holds every item, the count it yields never changes the\n * widths that decided it, so showing or hiding the indicator cannot cause another update. The\n * indicator's width is reserved unless every item fits. The count is 0 when not even the first\n * item fits beside the indicator.\n */\nexport function useFittingCount(\n rulerRef: React.RefObject<HTMLElement | null>,\n itemCount: number,\n): number | null {\n const [count, setCount] = React.useState<number | null>(null);\n\n const evaluate = React.useCallback(() => {\n const ruler = rulerRef.current;\n const replica = ruler?.firstElementChild;\n if (!ruler || !replica) return;\n const rects = Array.from(replica.children, (child) => child.getBoundingClientRect());\n setCount(countFitting(ruler.getBoundingClientRect(), rects.slice(0, itemCount), rects.at(-1)));\n }, [rulerRef, itemCount]);\n\n React.useLayoutEffect(evaluate);\n\n React.useEffect(() => {\n const ruler = rulerRef.current;\n const replica = ruler?.firstElementChild;\n if (!ruler || !replica) return;\n const observer = new ResizeObserver(evaluate);\n observer.observe(ruler);\n observer.observe(replica);\n return () => observer.disconnect();\n }, [rulerRef, evaluate]);\n\n return count;\n}\n"],"names":[],"mappings":";;AAEA,SAAS,aAAa,WAAoB,OAAkB,WAAoC;AAC9F,QAAM,OAAO,MAAM,GAAG,EAAE;AACxB,MAAI,UAAU,SAAS,KAAK,CAAC,QAAQ,CAAC,UAAW,QAAO;AACxD,MAAI,KAAK,QAAQ,UAAU,QAAQ,UAAU,cAAc,MAAM;AACjE,QAAM,WAAW,UAAU,OAAO,KAAK,QAAQ,UAAU;AACzD,SAAO,MAAM,UAAU,CAAC,SAAS,KAAK,QAAQ,UAAU,OAAO,WAAW,UAAU,KAAK;AAC3F;AAaO,SAAS,gBACd,UACA,WACe;AACf,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAwB,IAAI;AAE5D,QAAM,WAAW,MAAM,YAAY,MAAM;AACvC,UAAM,QAAQ,SAAS;AACvB,UAAM,UAAU,OAAO;AACvB,QAAI,CAAC,SAAS,CAAC,QAAS;AACxB,UAAM,QAAQ,MAAM,KAAK,QAAQ,UAAU,CAAC,UAAU,MAAM,uBAAuB;AACnF,aAAS,aAAa,MAAM,sBAAA,GAAyB,MAAM,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,EAC/F,GAAG,CAAC,UAAU,SAAS,CAAC;AAExB,QAAM,gBAAgB,QAAQ;AAE9B,QAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,SAAS;AACvB,UAAM,UAAU,OAAO;AACvB,QAAI,CAAC,SAAS,CAAC,QAAS;AACxB,UAAM,WAAW,IAAI,eAAe,QAAQ;AAC5C,aAAS,QAAQ,KAAK;AACtB,aAAS,QAAQ,OAAO;AACxB,WAAO,MAAM,SAAS,WAAA;AAAA,EACxB,GAAG,CAAC,UAAU,QAAQ,CAAC;AAEvB,SAAO;AACT;"}
@@ -0,0 +1,82 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../../utils/cn.mjs";
5
+ import { CrossIcon } from "../Icons/CrossIcon.mjs";
6
+ const variantClass = {
7
+ gray: "bg-tag-gray-surface text-tag-gray-content",
8
+ blue: "bg-tag-blue-surface text-tag-blue-content",
9
+ teal: "bg-tag-teal-surface text-tag-teal-content",
10
+ green: "bg-tag-green-surface text-tag-green-content",
11
+ amber: "bg-tag-amber-surface text-tag-amber-content",
12
+ red: "bg-tag-red-surface text-tag-red-content",
13
+ pink: "bg-tag-pink-surface text-tag-pink-content",
14
+ purple: "bg-tag-purple-surface text-tag-purple-content"
15
+ };
16
+ const Tag = React.forwardRef(
17
+ ({
18
+ className,
19
+ variant = "gray",
20
+ size = "20",
21
+ leadingIcon,
22
+ children,
23
+ onRemove,
24
+ removeLabel,
25
+ removeVisibility = "always",
26
+ ...props
27
+ }, ref) => {
28
+ const isEmoji = typeof leadingIcon === "string";
29
+ return /* @__PURE__ */ jsxs(
30
+ "span",
31
+ {
32
+ ref,
33
+ "data-testid": "tag",
34
+ className: cn(
35
+ "group/tag relative isolate inline-flex min-w-0 max-w-full items-center gap-0.5 whitespace-nowrap rounded-2xs",
36
+ size === "16" && "typography-tag-16px h-4 px-1",
37
+ size === "20" && "typography-tag-20px h-5 px-1.5",
38
+ variantClass[variant],
39
+ onRemove && "before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:bg-tag-hover-overlay before:opacity-0 hover:before:opacity-100",
40
+ className
41
+ ),
42
+ ...props,
43
+ children: [
44
+ leadingIcon && !isEmoji && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-center", "aria-hidden": "true", children: leadingIcon }),
45
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1 px-0.5", children: [
46
+ isEmoji && /* @__PURE__ */ jsx(
47
+ "span",
48
+ {
49
+ className: "typography-description-12px-regular flex w-3 shrink-0 justify-center",
50
+ "aria-hidden": "true",
51
+ children: leadingIcon
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children })
55
+ ] }),
56
+ onRemove && /* @__PURE__ */ jsx(
57
+ "button",
58
+ {
59
+ type: "button",
60
+ "aria-label": removeLabel,
61
+ onClick: onRemove,
62
+ className: cn(
63
+ "relative flex shrink-0 cursor-pointer items-center justify-center rounded-3xs after:absolute focus-visible:opacity-100 focus-visible:shadow-focus-ring focus-visible:outline-hidden",
64
+ size === "16" && "size-3 after:-inset-1.5",
65
+ size === "20" && "size-3.5 after:-inset-1.25",
66
+ removeVisibility === "hover" && "group-focus-within/tag:pointer-events-auto group-focus-within/tag:ml-0 group-focus-within/tag:opacity-100 group-hover/tag:pointer-events-auto group-hover/tag:ml-0 group-hover/tag:opacity-100 [@media(hover:hover)]:pointer-events-none [@media(hover:hover)]:-ml-0.5 [@media(hover:hover)]:w-0 [@media(hover:hover)]:opacity-0",
67
+ removeVisibility === "hover" && size === "16" && "group-focus-within/tag:w-3 group-hover/tag:w-3",
68
+ removeVisibility === "hover" && size === "20" && "group-focus-within/tag:w-3.5 group-hover/tag:w-3.5"
69
+ ),
70
+ children: /* @__PURE__ */ jsx(CrossIcon, { className: size === "16" ? "size-3" : "size-3.5" })
71
+ }
72
+ )
73
+ ]
74
+ }
75
+ );
76
+ }
77
+ );
78
+ Tag.displayName = "Tag";
79
+ export {
80
+ Tag
81
+ };
82
+ //# sourceMappingURL=Tag.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tag.mjs","sources":["../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CrossIcon } from \"../Icons/CrossIcon\";\n\n/** Colour of the tag, from the V2 Tags palette. */\nexport type TagVariant = \"gray\" | \"blue\" | \"teal\" | \"green\" | \"amber\" | \"red\" | \"pink\" | \"purple\";\n\n/** Height of the tag in pixels. */\nexport type TagSize = \"16\" | \"20\";\n\n/** When the remove button is shown. */\nexport type TagRemoveVisibility = \"always\" | \"hover\";\n\ninterface TagBaseProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** Colour from the V2 Tags palette. @default \"gray\" */\n variant?: TagVariant;\n /** Height in pixels: 16 for dense rows, 20 for panels, pickers and filter tags. @default \"20\" */\n size?: TagSize;\n /**\n * Emoji (a string) or icon (an element) displayed before the label. Decorative, so it is hidden\n * from assistive technology. Size an icon yourself: 14px on a 20px tag (`className=\"size-3.5\"`)\n * and 12px on a 16px tag (`className=\"size-3\"`).\n */\n leadingIcon?: React.ReactNode;\n /** The visible label. */\n children: React.ReactNode;\n}\n\ninterface TagRemovableProps {\n /**\n * Renders a remove (×) button when set. Receives the click, so a caller can stop it bubbling.\n * Pass `undefined` to hide the button conditionally while keeping `removeLabel`.\n */\n onRemove?: ((event: React.MouseEvent<HTMLButtonElement>) => void) | undefined;\n /** Accessible name of the remove button, as one translated string such as \"Remove Whale\". */\n removeLabel: string;\n /**\n * `\"always\"` keeps the × visible (lists, filter tags). `\"hover\"` reveals it on hover or\n * keyboard focus, and keeps it visible on devices that cannot hover.\n * In `\"hover\"` mode the tag is narrower at rest and widens when the × appears; its height never changes.\n * @default \"always\"\n */\n removeVisibility?: TagRemoveVisibility;\n}\n\ninterface TagStaticProps {\n /** Leave unset for a tag with no remove button. */\n onRemove?: undefined;\n /** Only used with `onRemove`. */\n removeLabel?: undefined;\n /** Only used with `onRemove`. */\n removeVisibility?: undefined;\n}\n\nexport type TagProps = TagBaseProps & (TagRemovableProps | TagStaticProps);\n\nconst variantClass: Record<TagVariant, string> = {\n gray: \"bg-tag-gray-surface text-tag-gray-content\",\n blue: \"bg-tag-blue-surface text-tag-blue-content\",\n teal: \"bg-tag-teal-surface text-tag-teal-content\",\n green: \"bg-tag-green-surface text-tag-green-content\",\n amber: \"bg-tag-amber-surface text-tag-amber-content\",\n red: \"bg-tag-red-surface text-tag-red-content\",\n pink: \"bg-tag-pink-surface text-tag-pink-content\",\n purple: \"bg-tag-purple-surface text-tag-purple-content\",\n};\n\n/**\n * A small label for something the user applied, such as a fan tag, a list or an active filter.\n * Status labels belong in {@link Pill} or {@link Badge}.\n *\n * Pass `onRemove` to add a × button. The label is plain text, and the × is a real button named by\n * `removeLabel`, so nothing interactive is nested inside the tag except the ×.\n *\n * @example\n * ```tsx\n * <Tag\n * variant=\"blue\"\n * leadingIcon=\"🐳\"\n * onRemove={() => removeTag(\"whale\")}\n * removeLabel={t(\"tags.remove\", { name: \"Whale\" })}\n * >\n * Whale\n * </Tag>\n * ```\n */\nexport const Tag = React.forwardRef<HTMLSpanElement, TagProps>(\n (\n {\n className,\n variant = \"gray\",\n size = \"20\",\n leadingIcon,\n children,\n onRemove,\n removeLabel,\n removeVisibility = \"always\",\n ...props\n },\n ref,\n ) => {\n const isEmoji = typeof leadingIcon === \"string\";\n return (\n <span\n ref={ref}\n data-testid=\"tag\"\n className={cn(\n \"group/tag relative isolate inline-flex min-w-0 max-w-full items-center gap-0.5 whitespace-nowrap rounded-2xs\",\n size === \"16\" && \"typography-tag-16px h-4 px-1\",\n size === \"20\" && \"typography-tag-20px h-5 px-1.5\",\n variantClass[variant],\n onRemove &&\n \"before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:bg-tag-hover-overlay before:opacity-0 hover:before:opacity-100\",\n className,\n )}\n {...props}\n >\n {leadingIcon && !isEmoji && (\n <span className=\"flex shrink-0 items-center\" aria-hidden=\"true\">\n {leadingIcon}\n </span>\n )}\n <span className=\"flex min-w-0 items-center gap-1 px-0.5\">\n {isEmoji && (\n <span\n className=\"typography-description-12px-regular flex w-3 shrink-0 justify-center\"\n aria-hidden=\"true\"\n >\n {leadingIcon}\n </span>\n )}\n <span className=\"min-w-0 truncate\">{children}</span>\n </span>\n {onRemove && (\n <button\n type=\"button\"\n aria-label={removeLabel}\n onClick={onRemove}\n className={cn(\n \"relative flex shrink-0 cursor-pointer items-center justify-center rounded-3xs after:absolute focus-visible:opacity-100 focus-visible:shadow-focus-ring focus-visible:outline-hidden\",\n size === \"16\" && \"size-3 after:-inset-1.5\",\n size === \"20\" && \"size-3.5 after:-inset-1.25\",\n removeVisibility === \"hover\" &&\n \"group-focus-within/tag:pointer-events-auto group-focus-within/tag:ml-0 group-focus-within/tag:opacity-100 group-hover/tag:pointer-events-auto group-hover/tag:ml-0 group-hover/tag:opacity-100 [@media(hover:hover)]:pointer-events-none [@media(hover:hover)]:-ml-0.5 [@media(hover:hover)]:w-0 [@media(hover:hover)]:opacity-0\",\n removeVisibility === \"hover\" &&\n size === \"16\" &&\n \"group-focus-within/tag:w-3 group-hover/tag:w-3\",\n removeVisibility === \"hover\" &&\n size === \"20\" &&\n \"group-focus-within/tag:w-3.5 group-hover/tag:w-3.5\",\n )}\n >\n <CrossIcon className={size === \"16\" ? \"size-3\" : \"size-3.5\"} />\n </button>\n )}\n </span>\n );\n },\n);\n\nTag.displayName = \"Tag\";\n"],"names":[],"mappings":";;;;;AAwDA,MAAM,eAA2C;AAAA,EAC/C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AACV;AAqBO,MAAM,MAAM,MAAM;AAAA,EACvB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,UAAU,OAAO,gBAAgB;AACvC,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,eAAY;AAAA,QACZ,WAAW;AAAA,UACT;AAAA,UACA,SAAS,QAAQ;AAAA,UACjB,SAAS,QAAQ;AAAA,UACjB,aAAa,OAAO;AAAA,UACpB,YACE;AAAA,UACF;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,eAAe,CAAC,WACf,oBAAC,QAAA,EAAK,WAAU,8BAA6B,eAAY,QACtD,UAAA,YAAA,CACH;AAAA,UAEF,qBAAC,QAAA,EAAK,WAAU,0CACb,UAAA;AAAA,YAAA,WACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,eAAY;AAAA,gBAEX,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,YAGL,oBAAC,QAAA,EAAK,WAAU,oBAAoB,SAAA,CAAS;AAAA,UAAA,GAC/C;AAAA,UACC,YACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,cAAY;AAAA,cACZ,SAAS;AAAA,cACT,WAAW;AAAA,gBACT;AAAA,gBACA,SAAS,QAAQ;AAAA,gBACjB,SAAS,QAAQ;AAAA,gBACjB,qBAAqB,WACnB;AAAA,gBACF,qBAAqB,WACnB,SAAS,QACT;AAAA,gBACF,qBAAqB,WACnB,SAAS,QACT;AAAA,cAAA;AAAA,cAGJ,8BAAC,WAAA,EAAU,WAAW,SAAS,OAAO,WAAW,WAAA,CAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QAC/D;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,IAAI,cAAc;"}
@@ -2,6 +2,7 @@
2
2
  import { jsxs, jsx } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { cn } from "../../utils/cn.mjs";
5
+ import { INPUT_FIELD_DISABLED_CLASSES, INPUT_FIELD_V2_FOCUS_CLASSES } from "../../utils/inputFieldClasses.mjs";
5
6
  import { IconButton } from "../IconButton/IconButton.mjs";
6
7
  import { CheckOutlineIcon } from "../Icons/CheckOutlineIcon.mjs";
7
8
  import { CloseIcon } from "../Icons/CloseIcon.mjs";
@@ -33,15 +34,15 @@ const CLEAR_BUTTON_RIGHT = {
33
34
  function getContainerClassName(size, error, disabled) {
34
35
  return cn(
35
36
  "relative rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors",
36
- error ? "border-error-content" : "border-border-primary",
37
- !disabled && !error && "hover:border-neutral-alphas-400",
37
+ error ? "border-error-content" : ["border-border-input", INPUT_FIELD_V2_FOCUS_CLASSES],
38
+ !disabled && !error && "hover:border-border-input-hover",
38
39
  CONTAINER_MIN_HEIGHT[size],
39
- disabled && "opacity-50"
40
+ disabled && INPUT_FIELD_DISABLED_CLASSES
40
41
  );
41
42
  }
42
43
  function getTextareaClassName(size, hasClearButton, hasMinRows, resizable) {
43
44
  return cn(
44
- "h-full w-full bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed",
45
+ "h-full w-full bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed theme-v2:disabled:text-content-disabled theme-v2:disabled:placeholder:text-content-disabled",
45
46
  resizable ? "resize-y" : "resize-none",
46
47
  !hasMinRows && "min-h-[80px]",
47
48
  TEXTAREA_SIZE_CLASSES[size],
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.mjs","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CheckOutlineIcon } from \"../Icons/CheckOutlineIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** Text area height in pixels. */\nexport type TextAreaSize = \"48\" | \"40\" | \"32\";\n\nexport interface TextAreaProps\n extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, \"size\"> {\n /** Label text displayed above the textarea. Also used as the accessible name. */\n label?: string;\n /** Helper text displayed below the textarea. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Minimum height of the text area in pixels. @default \"48\" */\n size?: TextAreaSize;\n /** Whether the text area is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the textarea. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Whether the text area is validated. @default false */\n validated?: boolean;\n /** Whether the text area stretches to fill its container width. @default false */\n fullWidth?: boolean;\n /** Whether to show a clear button when text is present. @default false */\n showClearButton?: boolean;\n /** Callback fired when the clear button is clicked. Note: `onChange` is also called with an empty value when clearing. */\n onClear?: () => void;\n /** Minimum number of rows (lines) for the textarea. */\n minRows?: number;\n /** Maximum number of rows (lines) for the textarea. */\n maxRows?: number;\n /** Whether the textarea can be resized by the user. @default true */\n resizable?: boolean;\n}\n\nconst CONTAINER_MIN_HEIGHT: Record<TextAreaSize, string> = {\n \"48\": \"min-h-12\",\n \"40\": \"min-h-10\",\n \"32\": \"min-h-8\",\n};\n\nconst TEXTAREA_SIZE_CLASSES: Record<TextAreaSize, string> = {\n \"48\": \"py-3 typography-body-default-16px-regular autofill-body-lg\",\n \"40\": \"py-2 typography-body-default-16px-regular autofill-body-lg\",\n \"32\": \"py-2 typography-body-small-14px-regular autofill-body-md\",\n};\n\nconst PADDING_HORIZONTAL: Record<TextAreaSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst PADDING_RIGHT_WITH_CLEAR: Record<TextAreaSize, string> = {\n \"48\": \"pr-11\",\n \"40\": \"pr-11\",\n \"32\": \"pr-10\",\n};\n\nconst CLEAR_BUTTON_RIGHT: Record<TextAreaSize, string> = {\n \"48\": \"right-4 top-3\",\n \"40\": \"right-4 top-2\",\n \"32\": \"right-3 top-2\",\n};\n\nfunction getContainerClassName(size: TextAreaSize, error: boolean, disabled?: boolean) {\n return cn(\n \"relative rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors\",\n error ? \"border-error-content\" : \"border-border-primary\",\n !disabled && !error && \"hover:border-neutral-alphas-400\",\n CONTAINER_MIN_HEIGHT[size],\n disabled && \"opacity-50\",\n );\n}\n\nfunction getTextareaClassName(\n size: TextAreaSize,\n hasClearButton: boolean,\n hasMinRows: boolean,\n resizable: boolean,\n) {\n return cn(\n \"h-full w-full bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed\",\n resizable ? \"resize-y\" : \"resize-none\",\n !hasMinRows && \"min-h-[80px]\",\n TEXTAREA_SIZE_CLASSES[size],\n PADDING_HORIZONTAL[size],\n hasClearButton ? PADDING_RIGHT_WITH_CLEAR[size] : \"\",\n );\n}\n\nfunction TextAreaHelperText({\n id,\n error,\n children,\n}: {\n id: string;\n error: boolean;\n children: React.ReactNode;\n}) {\n return (\n <p\n id={id}\n className={cn(\n \"typography-description-12px-regular pt-2\",\n error ? \"text-error-content\" : \"text-content-tertiary\",\n )}\n >\n {children}\n </p>\n );\n}\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"TextArea: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\nfunction calculateMaxHeight(size: TextAreaSize, maxRows?: number): string | undefined {\n if (!maxRows) return undefined;\n\n // Line height is 24px for body-1 (sizes 48 and 40) and 20px for body-2 (size 32)\n const lineHeight = size === \"32\" ? 20 : 24;\n // py-2 = 8px, py-3 = 12px\n const verticalPadding = size === \"32\" ? 8 : size === \"40\" ? 8 : 12;\n\n return `${lineHeight * maxRows + verticalPadding * 2}px`;\n}\n\nfunction useTextAreaValue(\n value: React.TextareaHTMLAttributes<HTMLTextAreaElement>[\"value\"],\n defaultValue: React.TextareaHTMLAttributes<HTMLTextAreaElement>[\"defaultValue\"],\n showClearButton: boolean,\n onChange?: React.ChangeEventHandler<HTMLTextAreaElement>,\n onClear?: () => void,\n textareaRef?: React.RefObject<HTMLTextAreaElement | null>,\n) {\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? \"\");\n const resolvedValue = value !== undefined ? value : internalValue;\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInternalValue(e.target.value);\n onChange?.(e);\n };\n\n const handleClear = () => {\n setInternalValue(\"\");\n\n if (onChange && textareaRef?.current) {\n const syntheticEvent = {\n target: { ...textareaRef.current, value: \"\" },\n currentTarget: { ...textareaRef.current, value: \"\" },\n } as React.ChangeEvent<HTMLTextAreaElement>;\n onChange(syntheticEvent);\n }\n\n onClear?.();\n };\n\n return {\n resolvedValue,\n displayValue: showClearButton ? resolvedValue : value,\n resolvedDefaultValue: showClearButton ? undefined : defaultValue,\n handleChange,\n handleClear,\n };\n}\n\n/**\n * A multi-line text input with optional label, helper/error text, and clear button.\n *\n * Provide at least one of `label`, `aria-label`, or `aria-labelledby` for\n * accessibility — a console warning is emitted in development if none are set.\n *\n * @example\n * ```tsx\n * <TextArea\n * label=\"Description\"\n * placeholder=\"Enter your description...\"\n * showClearButton\n * error={!!descError}\n * errorMessage={descError}\n * />\n * ```\n */\nexport const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n validated = false,\n className,\n id,\n disabled,\n fullWidth = false,\n showClearButton = false,\n onClear,\n value,\n defaultValue,\n onChange,\n minRows,\n maxRows,\n resizable = false,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const helperTextId = `${inputId}-helper`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n const maxHeight = calculateMaxHeight(size, maxRows);\n\n const internalRef = React.useRef<HTMLTextAreaElement>(null);\n\n const { resolvedValue, displayValue, resolvedDefaultValue, handleChange, handleClear } =\n useTextAreaValue(value, defaultValue, showClearButton, onChange, onClear, internalRef);\n\n const mergedRef = (node: HTMLTextAreaElement | null) => {\n internalRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n };\n\n const showClear = showClearButton && resolvedValue !== \"\" && !disabled;\n const showValidated = validated && !showClear;\n const ariaDescribedBy = bottomText ? helperTextId : undefined;\n const textareaStyle = maxHeight ? { maxHeight } : undefined;\n\n warnMissingAccessibleName(label, props[\"aria-label\"], props[\"aria-labelledby\"]);\n\n return (\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={inputId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n <div className={getContainerClassName(size, error, disabled)}>\n <textarea\n ref={mergedRef}\n id={inputId}\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n aria-invalid={error || undefined}\n className={getTextareaClassName(size, showClear, !!minRows, resizable)}\n value={displayValue}\n defaultValue={resolvedDefaultValue}\n onChange={handleChange}\n rows={minRows}\n style={textareaStyle}\n {...props}\n />\n\n {showClear && (\n <IconButton\n variant=\"tertiary\"\n size=\"24\"\n icon={<CloseIcon />}\n aria-label=\"Clear text\"\n onClick={handleClear}\n className={cn(\n \"absolute flex size-5 items-center justify-center self-end\",\n CLEAR_BUTTON_RIGHT[size],\n )}\n />\n )}\n {showValidated && (\n <div\n className={cn(\n \"pointer-events-none absolute flex size-5 items-center justify-center\",\n CLEAR_BUTTON_RIGHT[size],\n )}\n >\n <CheckOutlineIcon className=\"text-success-content\" />\n </div>\n )}\n </div>\n\n {bottomText && (\n <TextAreaHelperText id={helperTextId} error={error}>\n {bottomText}\n </TextAreaHelperText>\n )}\n </div>\n );\n },\n);\n\nTextArea.displayName = \"TextArea\";\n"],"names":[],"mappings":";;;;;;;AAqCA,MAAM,uBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,wBAAsD;AAAA,EAC1D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAmD;AAAA,EACvD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,2BAAyD;AAAA,EAC7D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,q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,YAGH,iBACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAW;AAAA,kBACT;AAAA,kBACA,mBAAmB,IAAI;AAAA,gBAAA;AAAA,gBAGzB,UAAA,oBAAC,kBAAA,EAAiB,WAAU,uBAAA,CAAuB;AAAA,cAAA;AAAA,YAAA;AAAA,UACrD,GAEJ;AAAA,UAEC,cACC,oBAAC,oBAAA,EAAmB,IAAI,cAAc,OACnC,UAAA,WAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,SAAS,cAAc;"}
1
+ {"version":3,"file":"TextArea.mjs","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport {\n INPUT_FIELD_DISABLED_CLASSES,\n INPUT_FIELD_V2_FOCUS_CLASSES,\n} from \"../../utils/inputFieldClasses\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CheckOutlineIcon } from \"../Icons/CheckOutlineIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** Text area height in pixels. */\nexport type TextAreaSize = \"48\" | \"40\" | \"32\";\n\nexport interface TextAreaProps\n extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, \"size\"> {\n /** Label text displayed above the textarea. Also used as the accessible name. */\n label?: string;\n /** Helper text displayed below the textarea. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Minimum height of the text area in pixels. @default \"48\" */\n size?: TextAreaSize;\n /** Whether the text area is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the textarea. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Whether the text area is validated. @default false */\n validated?: boolean;\n /** Whether the text area stretches to fill its container width. @default false */\n fullWidth?: boolean;\n /** Whether to show a clear button when text is present. @default false */\n showClearButton?: boolean;\n /** Callback fired when the clear button is clicked. Note: `onChange` is also called with an empty value when clearing. */\n onClear?: () => void;\n /** Minimum number of rows (lines) for the textarea. */\n minRows?: number;\n /** Maximum number of rows (lines) for the textarea. */\n maxRows?: number;\n /** Whether the textarea can be resized by the user. @default true */\n resizable?: boolean;\n}\n\nconst CONTAINER_MIN_HEIGHT: Record<TextAreaSize, string> = {\n \"48\": \"min-h-12\",\n \"40\": \"min-h-10\",\n \"32\": \"min-h-8\",\n};\n\nconst TEXTAREA_SIZE_CLASSES: Record<TextAreaSize, string> = {\n \"48\": \"py-3 typography-body-default-16px-regular autofill-body-lg\",\n \"40\": \"py-2 typography-body-default-16px-regular autofill-body-lg\",\n \"32\": \"py-2 typography-body-small-14px-regular autofill-body-md\",\n};\n\nconst PADDING_HORIZONTAL: Record<TextAreaSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst PADDING_RIGHT_WITH_CLEAR: Record<TextAreaSize, string> = {\n \"48\": \"pr-11\",\n \"40\": \"pr-11\",\n \"32\": \"pr-10\",\n};\n\nconst CLEAR_BUTTON_RIGHT: Record<TextAreaSize, string> = {\n \"48\": \"right-4 top-3\",\n \"40\": \"right-4 top-2\",\n \"32\": \"right-3 top-2\",\n};\n\nfunction getContainerClassName(size: TextAreaSize, error: boolean, disabled?: boolean) {\n return cn(\n \"relative rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors\",\n error ? \"border-error-content\" : [\"border-border-input\", INPUT_FIELD_V2_FOCUS_CLASSES],\n !disabled && !error && \"hover:border-border-input-hover\",\n CONTAINER_MIN_HEIGHT[size],\n disabled && INPUT_FIELD_DISABLED_CLASSES,\n );\n}\n\nfunction getTextareaClassName(\n size: TextAreaSize,\n hasClearButton: boolean,\n hasMinRows: boolean,\n resizable: boolean,\n) {\n return cn(\n \"h-full w-full bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed theme-v2:disabled:text-content-disabled theme-v2:disabled:placeholder:text-content-disabled\",\n resizable ? \"resize-y\" : \"resize-none\",\n !hasMinRows && \"min-h-[80px]\",\n TEXTAREA_SIZE_CLASSES[size],\n PADDING_HORIZONTAL[size],\n hasClearButton ? PADDING_RIGHT_WITH_CLEAR[size] : \"\",\n );\n}\n\nfunction TextAreaHelperText({\n id,\n error,\n children,\n}: {\n id: string;\n error: boolean;\n children: React.ReactNode;\n}) {\n return (\n <p\n id={id}\n className={cn(\n \"typography-description-12px-regular pt-2\",\n error ? \"text-error-content\" : \"text-content-tertiary\",\n )}\n >\n {children}\n </p>\n );\n}\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"TextArea: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\nfunction calculateMaxHeight(size: TextAreaSize, maxRows?: number): string | undefined {\n if (!maxRows) return undefined;\n\n // Line height is 24px for body-1 (sizes 48 and 40) and 20px for body-2 (size 32)\n const lineHeight = size === \"32\" ? 20 : 24;\n // py-2 = 8px, py-3 = 12px\n const verticalPadding = size === \"32\" ? 8 : size === \"40\" ? 8 : 12;\n\n return `${lineHeight * maxRows + verticalPadding * 2}px`;\n}\n\nfunction useTextAreaValue(\n value: React.TextareaHTMLAttributes<HTMLTextAreaElement>[\"value\"],\n defaultValue: React.TextareaHTMLAttributes<HTMLTextAreaElement>[\"defaultValue\"],\n showClearButton: boolean,\n onChange?: React.ChangeEventHandler<HTMLTextAreaElement>,\n onClear?: () => void,\n textareaRef?: React.RefObject<HTMLTextAreaElement | null>,\n) {\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? \"\");\n const resolvedValue = value !== undefined ? value : internalValue;\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInternalValue(e.target.value);\n onChange?.(e);\n };\n\n const handleClear = () => {\n setInternalValue(\"\");\n\n if (onChange && textareaRef?.current) {\n const syntheticEvent = {\n target: { ...textareaRef.current, value: \"\" },\n currentTarget: { ...textareaRef.current, value: \"\" },\n } as React.ChangeEvent<HTMLTextAreaElement>;\n onChange(syntheticEvent);\n }\n\n onClear?.();\n };\n\n return {\n resolvedValue,\n displayValue: showClearButton ? resolvedValue : value,\n resolvedDefaultValue: showClearButton ? undefined : defaultValue,\n handleChange,\n handleClear,\n };\n}\n\n/**\n * A multi-line text input with optional label, helper/error text, and clear button.\n *\n * Provide at least one of `label`, `aria-label`, or `aria-labelledby` for\n * accessibility — a console warning is emitted in development if none are set.\n *\n * @example\n * ```tsx\n * <TextArea\n * label=\"Description\"\n * placeholder=\"Enter your description...\"\n * showClearButton\n * error={!!descError}\n * errorMessage={descError}\n * />\n * ```\n */\nexport const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n validated = false,\n className,\n id,\n disabled,\n fullWidth = false,\n showClearButton = false,\n onClear,\n value,\n defaultValue,\n onChange,\n minRows,\n maxRows,\n resizable = false,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const helperTextId = `${inputId}-helper`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n const maxHeight = calculateMaxHeight(size, maxRows);\n\n const internalRef = React.useRef<HTMLTextAreaElement>(null);\n\n const { resolvedValue, displayValue, resolvedDefaultValue, handleChange, handleClear } =\n useTextAreaValue(value, defaultValue, showClearButton, onChange, onClear, internalRef);\n\n const mergedRef = (node: HTMLTextAreaElement | null) => {\n internalRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n };\n\n const showClear = showClearButton && resolvedValue !== \"\" && !disabled;\n const showValidated = validated && !showClear;\n const ariaDescribedBy = bottomText ? helperTextId : undefined;\n const textareaStyle = maxHeight ? { maxHeight } : undefined;\n\n warnMissingAccessibleName(label, props[\"aria-label\"], props[\"aria-labelledby\"]);\n\n return (\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={inputId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n <div className={getContainerClassName(size, error, disabled)}>\n <textarea\n ref={mergedRef}\n id={inputId}\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n aria-invalid={error || undefined}\n className={getTextareaClassName(size, showClear, !!minRows, resizable)}\n value={displayValue}\n defaultValue={resolvedDefaultValue}\n onChange={handleChange}\n rows={minRows}\n style={textareaStyle}\n {...props}\n />\n\n {showClear && (\n <IconButton\n variant=\"tertiary\"\n size=\"24\"\n icon={<CloseIcon />}\n aria-label=\"Clear text\"\n onClick={handleClear}\n className={cn(\n \"absolute flex size-5 items-center justify-center self-end\",\n CLEAR_BUTTON_RIGHT[size],\n )}\n />\n )}\n {showValidated && (\n <div\n className={cn(\n \"pointer-events-none absolute flex size-5 items-center justify-center\",\n CLEAR_BUTTON_RIGHT[size],\n )}\n >\n <CheckOutlineIcon className=\"text-success-content\" />\n </div>\n )}\n </div>\n\n {bottomText && (\n <TextAreaHelperText id={helperTextId} error={error}>\n {bottomText}\n </TextAreaHelperText>\n )}\n </div>\n );\n },\n);\n\nTextArea.displayName = \"TextArea\";\n"],"names":[],"mappings":";;;;;;;;AAyCA,MAAM,uBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,wBAAsD;AAAA,EAC1D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAmD;AAAA,EACvD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,2BAAyD;AAAA,EAC7D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,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AAI;AAAA,gBAAA;AAAA,cACzB;AAAA,YAAA;AAAA,YAGH,iBACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAW;AAAA,kBACT;AAAA,kBACA,mBAAmB,IAAI;AAAA,gBAAA;AAAA,gBAGzB,UAAA,oBAAC,kBAAA,EAAiB,WAAU,uBAAA,CAAuB;AAAA,cAAA;AAAA,YAAA;AAAA,UACrD,GAEJ;AAAA,UAEC,cACC,oBAAC,oBAAA,EAAmB,IAAI,cAAc,OACnC,UAAA,WAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,SAAS,cAAc;"}
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import "@radix-ui/react-slot";
5
5
  import { CheckOutlineIcon } from "../Icons/CheckOutlineIcon.mjs";
6
6
  import { cn } from "../../utils/cn.mjs";
7
+ import { INPUT_FIELD_DISABLED_CLASSES, INPUT_FIELD_V2_FOCUS_CLASSES } from "../../utils/inputFieldClasses.mjs";
7
8
  const CONTAINER_HEIGHT = {
8
9
  "48": "h-12",
9
10
  "40": "h-10",
@@ -39,14 +40,15 @@ function getContainerClassName(size, error, disabled, hasAction) {
39
40
  "relative flex items-center overflow-hidden rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors",
40
41
  hasAction ? CONTAINER_PADDING_X_WITH_ACTION[size] : CONTAINER_PADDING_X[size],
41
42
  CONTAINER_GAP[size],
42
- error ? "border-error-content" : "border-border-primary",
43
- !disabled && !error && "hover:border-neutral-alphas-400",
43
+ error ? "border-error-content" : ["border-border-input", INPUT_FIELD_V2_FOCUS_CLASSES],
44
+ !disabled && !error && "hover:border-border-input-hover",
44
45
  CONTAINER_HEIGHT[size],
45
- disabled && "opacity-50"
46
+ disabled && INPUT_FIELD_DISABLED_CLASSES
46
47
  );
47
48
  }
48
49
  function LeadingIcon({
49
50
  size = "16",
51
+ disabled,
50
52
  children
51
53
  }) {
52
54
  if (!children) return null;
@@ -55,7 +57,8 @@ function LeadingIcon({
55
57
  {
56
58
  className: cn(
57
59
  "pointer-events-none flex shrink-0 items-center justify-center text-content-secondary",
58
- size === "24" ? "size-6" : "size-4"
60
+ size === "24" ? "size-6" : "size-4",
61
+ disabled && "theme-v2:text-icons-disabled"
59
62
  ),
60
63
  children
61
64
  }
@@ -65,6 +68,7 @@ function SideLabel({
65
68
  id,
66
69
  size,
67
70
  align,
71
+ disabled,
68
72
  children
69
73
  }) {
70
74
  if (!children) return null;
@@ -75,7 +79,8 @@ function SideLabel({
75
79
  className: cn(
76
80
  "shrink-0 select-none whitespace-nowrap text-content-tertiary",
77
81
  align === "right" && "text-right",
78
- SIDE_LABEL_TYPOGRAPHY[size]
82
+ SIDE_LABEL_TYPOGRAPHY[size],
83
+ disabled && "theme-v2:text-content-disabled"
79
84
  ),
80
85
  children
81
86
  }
@@ -83,13 +88,23 @@ function SideLabel({
83
88
  }
84
89
  function TrailingAdornment({
85
90
  rightIcon,
86
- validated
91
+ validated,
92
+ disabled
87
93
  }) {
88
94
  if (!rightIcon && !validated) return null;
89
- return /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-2 text-content-secondary", children: [
90
- rightIcon && /* @__PURE__ */ jsx("span", { "data-tf-interactive": "", className: "flex size-4 shrink-0 items-center justify-center", children: rightIcon }),
91
- validated && /* @__PURE__ */ jsx("span", { className: "pointer-events-none flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx(CheckOutlineIcon, { className: "text-success-content" }) })
92
- ] });
95
+ return /* @__PURE__ */ jsxs(
96
+ "span",
97
+ {
98
+ className: cn(
99
+ "flex shrink-0 items-center gap-2 text-content-secondary",
100
+ disabled && "theme-v2:text-icons-disabled"
101
+ ),
102
+ children: [
103
+ rightIcon && /* @__PURE__ */ jsx("span", { "data-tf-interactive": "", className: "flex size-4 shrink-0 items-center justify-center", children: rightIcon }),
104
+ validated && /* @__PURE__ */ jsx("span", { className: "pointer-events-none flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx(CheckOutlineIcon, { className: "text-success-content" }) })
105
+ ]
106
+ }
107
+ );
93
108
  }
94
109
  function TextFieldHelperText({
95
110
  id,
@@ -187,8 +202,8 @@ const TextField = React.forwardRef(
187
202
  className: getContainerClassName(size, error, disabled, action != null),
188
203
  onMouseDown: handleContainerMouseDown,
189
204
  children: [
190
- /* @__PURE__ */ jsx(LeadingIcon, { size: leftIconSize, children: leftIcon }),
191
- /* @__PURE__ */ jsx(SideLabel, { id: leftLabelId, size, align: "left", children: leftLabel }),
205
+ /* @__PURE__ */ jsx(LeadingIcon, { size: leftIconSize, disabled, children: leftIcon }),
206
+ /* @__PURE__ */ jsx(SideLabel, { id: leftLabelId, size, align: "left", disabled, children: leftLabel }),
192
207
  /* @__PURE__ */ jsx(
193
208
  "input",
194
209
  {
@@ -198,15 +213,15 @@ const TextField = React.forwardRef(
198
213
  "aria-describedby": describedBy,
199
214
  "aria-invalid": error || void 0,
200
215
  className: cn(
201
- "h-full min-w-0 flex-1 bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed",
216
+ "h-full min-w-0 flex-1 bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed theme-v2:disabled:text-content-disabled theme-v2:disabled:placeholder:text-content-disabled",
202
217
  INPUT_TYPOGRAPHY[size],
203
218
  "[&[type='search']::-webkit-search-cancel-button]:hidden [&[type='search']::-webkit-search-cancel-button]:appearance-none"
204
219
  ),
205
220
  ...props
206
221
  }
207
222
  ),
208
- /* @__PURE__ */ jsx(SideLabel, { id: rightLabelId, size, align: "right", children: rightLabel }),
209
- /* @__PURE__ */ jsx(TrailingAdornment, { rightIcon, validated }),
223
+ /* @__PURE__ */ jsx(SideLabel, { id: rightLabelId, size, align: "right", disabled, children: rightLabel }),
224
+ /* @__PURE__ */ jsx(TrailingAdornment, { rightIcon, validated, disabled }),
210
225
  action != null && /* @__PURE__ */ jsx("span", { "data-tf-interactive": "", className: "flex shrink-0 items-center", children: action })
211
226
  ]
212
227
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.mjs","sources":["../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckOutlineIcon } from \"@/index\";\nimport { cn } from \"../../utils/cn\";\n\n/** Text field height in pixels. */\nexport type TextFieldSize = \"48\" | \"40\" | \"32\";\n\nexport interface TextFieldProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n /** Label text displayed above the input. Also used as the accessible name. */\n label?: string;\n /** Helper text displayed below the input. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the text field in pixels. @default \"48\" */\n size?: TextFieldSize;\n /** Whether the text field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the input. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Whether the text field is validated. @default false */\n validated?: boolean;\n /** Icon element displayed at the left side of the input. */\n leftIcon?: React.ReactNode;\n /** Size in pixels of the slot that holds `leftIcon`. @default \"16\" */\n leftIconSize?: \"16\" | \"24\";\n /** Icon element displayed at the right side of the input. */\n rightIcon?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the left edge of the field — for a prefix such as a currency symbol or country code. */\n leftLabel?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the right edge of the field — for a unit or suffix such as a currency code or domain. */\n rightLabel?: React.ReactNode;\n /**\n * Trailing interactive element pinned to the right edge — typically a `Chip`\n * or `Button` (the \"with button\" field type). Reduces the right padding so the\n * control sits flush, and clicks on it do not steal focus from the input.\n */\n action?: React.ReactNode;\n /** Whether the text field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n}\n\nconst CONTAINER_HEIGHT: Record<TextFieldSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst CONTAINER_PADDING_X: Record<TextFieldSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst CONTAINER_PADDING_X_WITH_ACTION: Record<TextFieldSize, string> = {\n \"48\": \"pl-4 pr-2\",\n \"40\": \"pl-4 pr-2\",\n \"32\": \"pl-3 pr-2\",\n};\n\nconst CONTAINER_GAP: Record<TextFieldSize, string> = {\n \"48\": \"gap-2.5\",\n \"40\": \"gap-2.5\",\n \"32\": \"gap-2\",\n};\n\nconst INPUT_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"40\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"32\": \"typography-body-small-14px-regular autofill-body-md\",\n};\n\nconst SIDE_LABEL_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nfunction getContainerClassName(\n size: TextFieldSize,\n error: boolean,\n disabled?: boolean,\n hasAction?: boolean,\n) {\n return cn(\n \"relative flex items-center overflow-hidden rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors\",\n hasAction ? CONTAINER_PADDING_X_WITH_ACTION[size] : CONTAINER_PADDING_X[size],\n CONTAINER_GAP[size],\n error ? \"border-error-content\" : \"border-border-primary\",\n !disabled && !error && \"hover:border-neutral-alphas-400\",\n CONTAINER_HEIGHT[size],\n disabled && \"opacity-50\",\n );\n}\n\nfunction LeadingIcon({\n size = \"16\",\n children,\n}: {\n size?: \"16\" | \"24\";\n children?: React.ReactNode;\n}) {\n if (!children) return null;\n return (\n <span\n className={cn(\n \"pointer-events-none flex shrink-0 items-center justify-center text-content-secondary\",\n size === \"24\" ? \"size-6\" : \"size-4\",\n )}\n >\n {children}\n </span>\n );\n}\n\nfunction SideLabel({\n id,\n size,\n align,\n children,\n}: {\n id?: string;\n size: TextFieldSize;\n align: \"left\" | \"right\";\n children?: React.ReactNode;\n}) {\n if (!children) return null;\n return (\n <span\n id={id}\n className={cn(\n \"shrink-0 select-none whitespace-nowrap text-content-tertiary\",\n align === \"right\" && \"text-right\",\n SIDE_LABEL_TYPOGRAPHY[size],\n )}\n >\n {children}\n </span>\n );\n}\n\nfunction TrailingAdornment({\n rightIcon,\n validated,\n}: {\n rightIcon?: React.ReactNode;\n validated: boolean;\n}) {\n if (!rightIcon && !validated) return null;\n return (\n <span className=\"flex shrink-0 items-center gap-2 text-content-secondary\">\n {rightIcon && (\n <span data-tf-interactive=\"\" className=\"flex size-4 shrink-0 items-center justify-center\">\n {rightIcon}\n </span>\n )}\n {validated && (\n <span className=\"pointer-events-none flex size-4 shrink-0 items-center justify-center\">\n <CheckOutlineIcon className=\"text-success-content\" />\n </span>\n )}\n </span>\n );\n}\n\nfunction TextFieldHelperText({\n id,\n error,\n children,\n}: {\n id: string;\n error: boolean;\n children: React.ReactNode;\n}) {\n return (\n <p\n id={id}\n className={cn(\n \"typography-description-12px-regular pt-2\",\n error ? \"text-error-content\" : \"text-content-tertiary\",\n )}\n >\n {children}\n </p>\n );\n}\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"TextField: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\n/**\n * A text input field with optional label, helper/error text, icon slots, and side labels.\n *\n * Use `leftLabel` / `rightLabel` for fixed unit or prefix affordances (currency symbol,\n * country code, domain suffix). Provide at least one of `label`, `aria-label`, or\n * `aria-labelledby` for accessibility — a console warning is emitted in development if none are set.\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Email\"\n * placeholder=\"you@example.com\"\n * error={!!emailError}\n * errorMessage={emailError}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <TextField label=\"Price\" leftLabel=\"$\" rightLabel=\"USD\" placeholder=\"0.00\" />\n * ```\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Promo code\"\n * placeholder=\"Enter code\"\n * action={<Chip size=\"32\" onClick={apply}>Apply</Chip>}\n * />\n * ```\n */\nexport const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n validated = false,\n leftIcon,\n leftIconSize,\n rightIcon,\n leftLabel,\n rightLabel,\n action,\n className,\n id,\n disabled,\n fullWidth = false,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const helperTextId = `${inputId}-helper`;\n const leftLabelId = `${inputId}-left-label`;\n const rightLabelId = `${inputId}-right-label`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n const describedBy =\n [\n leftLabel != null ? leftLabelId : null,\n rightLabel != null ? rightLabelId : null,\n bottomText ? helperTextId : null,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n const innerRef = React.useRef<HTMLInputElement>(null);\n const setRefs = React.useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n },\n [ref],\n );\n\n // Keep clicks on the non-interactive adornments (icons, side labels, padding)\n // focusing the input, matching the old absolute/pointer-events-none layout.\n const handleContainerMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {\n if (disabled) return;\n const target = event.target as HTMLElement;\n if (target === innerRef.current) return;\n if (target.closest(\"[data-tf-interactive]\")) return;\n event.preventDefault();\n innerRef.current?.focus();\n };\n\n warnMissingAccessibleName(label, props[\"aria-label\"], props[\"aria-labelledby\"]);\n\n return (\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={inputId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n {/* biome-ignore lint/a11y/noStaticElementInteractions: focus bridge delegates pointer clicks on adornments to the input */}\n <div\n className={getContainerClassName(size, error, disabled, action != null)}\n onMouseDown={handleContainerMouseDown}\n >\n <LeadingIcon size={leftIconSize}>{leftIcon}</LeadingIcon>\n <SideLabel id={leftLabelId} size={size} align=\"left\">\n {leftLabel}\n </SideLabel>\n\n <input\n ref={setRefs}\n id={inputId}\n disabled={disabled}\n aria-describedby={describedBy}\n aria-invalid={error || undefined}\n className={cn(\n \"h-full min-w-0 flex-1 bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed\",\n INPUT_TYPOGRAPHY[size],\n \"[&[type='search']::-webkit-search-cancel-button]:hidden [&[type='search']::-webkit-search-cancel-button]:appearance-none\",\n )}\n {...props}\n />\n\n <SideLabel id={rightLabelId} size={size} align=\"right\">\n {rightLabel}\n </SideLabel>\n <TrailingAdornment rightIcon={rightIcon} validated={validated} />\n {action != null && (\n <span data-tf-interactive=\"\" className=\"flex shrink-0 items-center\">\n {action}\n </span>\n )}\n </div>\n\n {bottomText && (\n <TextFieldHelperText id={helperTextId} error={error}>\n {bottomText}\n </TextFieldHelperText>\n )}\n </div>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n"],"names":[],"mappings":";;;;;;AAyCA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,sBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,kCAAiE;AAAA,EACrE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,gBAA+C;AAAA,EACnD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,mBAAkD;AAAA,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sB;AAAA,gBAC9D,UAAU,QACT,oBAAC,QAAA,EAAK,uBAAoB,IAAG,WAAU,8BACpC,UAAA,OAAA,CACH;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAIH,cACC,oBAAC,qBAAA,EAAoB,IAAI,cAAc,OACpC,UAAA,WAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;"}
1
+ {"version":3,"file":"TextField.mjs","sources":["../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckOutlineIcon } from \"@/index\";\nimport { cn } from \"../../utils/cn\";\nimport {\n INPUT_FIELD_DISABLED_CLASSES,\n INPUT_FIELD_V2_FOCUS_CLASSES,\n} from \"../../utils/inputFieldClasses\";\n\n/** Text field height in pixels. */\nexport type TextFieldSize = \"48\" | \"40\" | \"32\";\n\nexport interface TextFieldProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n /** Label text displayed above the input. Also used as the accessible name. */\n label?: string;\n /** Helper text displayed below the input. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the text field in pixels. @default \"48\" */\n size?: TextFieldSize;\n /** Whether the text field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the input. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Whether the text field is validated. @default false */\n validated?: boolean;\n /** Icon element displayed at the left side of the input. */\n leftIcon?: React.ReactNode;\n /** Size in pixels of the slot that holds `leftIcon`. @default \"16\" */\n leftIconSize?: \"16\" | \"24\";\n /** Icon element displayed at the right side of the input. */\n rightIcon?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the left edge of the field — for a prefix such as a currency symbol or country code. */\n leftLabel?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the right edge of the field — for a unit or suffix such as a currency code or domain. */\n rightLabel?: React.ReactNode;\n /**\n * Trailing interactive element pinned to the right edge — typically a `Chip`\n * or `Button` (the \"with button\" field type). Reduces the right padding so the\n * control sits flush, and clicks on it do not steal focus from the input.\n */\n action?: React.ReactNode;\n /** Whether the text field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n}\n\nconst CONTAINER_HEIGHT: Record<TextFieldSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst CONTAINER_PADDING_X: Record<TextFieldSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst CONTAINER_PADDING_X_WITH_ACTION: Record<TextFieldSize, string> = {\n \"48\": \"pl-4 pr-2\",\n \"40\": \"pl-4 pr-2\",\n \"32\": \"pl-3 pr-2\",\n};\n\nconst CONTAINER_GAP: Record<TextFieldSize, string> = {\n \"48\": \"gap-2.5\",\n \"40\": \"gap-2.5\",\n \"32\": \"gap-2\",\n};\n\nconst INPUT_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"40\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"32\": \"typography-body-small-14px-regular autofill-body-md\",\n};\n\nconst SIDE_LABEL_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nfunction getContainerClassName(\n size: TextFieldSize,\n error: boolean,\n disabled?: boolean,\n hasAction?: boolean,\n) {\n return cn(\n \"relative flex items-center overflow-hidden rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors\",\n hasAction ? CONTAINER_PADDING_X_WITH_ACTION[size] : CONTAINER_PADDING_X[size],\n CONTAINER_GAP[size],\n error ? \"border-error-content\" : [\"border-border-input\", INPUT_FIELD_V2_FOCUS_CLASSES],\n !disabled && !error && \"hover:border-border-input-hover\",\n CONTAINER_HEIGHT[size],\n disabled && INPUT_FIELD_DISABLED_CLASSES,\n );\n}\n\nfunction LeadingIcon({\n size = \"16\",\n disabled,\n children,\n}: {\n size?: \"16\" | \"24\";\n disabled?: boolean;\n children?: React.ReactNode;\n}) {\n if (!children) return null;\n return (\n <span\n className={cn(\n \"pointer-events-none flex shrink-0 items-center justify-center text-content-secondary\",\n size === \"24\" ? \"size-6\" : \"size-4\",\n disabled && \"theme-v2:text-icons-disabled\",\n )}\n >\n {children}\n </span>\n );\n}\n\nfunction SideLabel({\n id,\n size,\n align,\n disabled,\n children,\n}: {\n id?: string;\n size: TextFieldSize;\n align: \"left\" | \"right\";\n disabled?: boolean;\n children?: React.ReactNode;\n}) {\n if (!children) return null;\n return (\n <span\n id={id}\n className={cn(\n \"shrink-0 select-none whitespace-nowrap text-content-tertiary\",\n align === \"right\" && \"text-right\",\n SIDE_LABEL_TYPOGRAPHY[size],\n disabled && \"theme-v2:text-content-disabled\",\n )}\n >\n {children}\n </span>\n );\n}\n\nfunction TrailingAdornment({\n rightIcon,\n validated,\n disabled,\n}: {\n rightIcon?: React.ReactNode;\n validated: boolean;\n disabled?: boolean;\n}) {\n if (!rightIcon && !validated) return null;\n return (\n <span\n className={cn(\n \"flex shrink-0 items-center gap-2 text-content-secondary\",\n disabled && \"theme-v2:text-icons-disabled\",\n )}\n >\n {rightIcon && (\n <span data-tf-interactive=\"\" className=\"flex size-4 shrink-0 items-center justify-center\">\n {rightIcon}\n </span>\n )}\n {validated && (\n <span className=\"pointer-events-none flex size-4 shrink-0 items-center justify-center\">\n <CheckOutlineIcon className=\"text-success-content\" />\n </span>\n )}\n </span>\n );\n}\n\nfunction TextFieldHelperText({\n id,\n error,\n children,\n}: {\n id: string;\n error: boolean;\n children: React.ReactNode;\n}) {\n return (\n <p\n id={id}\n className={cn(\n \"typography-description-12px-regular pt-2\",\n error ? \"text-error-content\" : \"text-content-tertiary\",\n )}\n >\n {children}\n </p>\n );\n}\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"TextField: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\n/**\n * A text input field with optional label, helper/error text, icon slots, and side labels.\n *\n * Use `leftLabel` / `rightLabel` for fixed unit or prefix affordances (currency symbol,\n * country code, domain suffix). Provide at least one of `label`, `aria-label`, or\n * `aria-labelledby` for accessibility — a console warning is emitted in development if none are set.\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Email\"\n * placeholder=\"you@example.com\"\n * error={!!emailError}\n * errorMessage={emailError}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <TextField label=\"Price\" leftLabel=\"$\" rightLabel=\"USD\" placeholder=\"0.00\" />\n * ```\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Promo code\"\n * placeholder=\"Enter code\"\n * action={<Chip size=\"32\" onClick={apply}>Apply</Chip>}\n * />\n * ```\n */\nexport const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n validated = false,\n leftIcon,\n leftIconSize,\n rightIcon,\n leftLabel,\n rightLabel,\n action,\n className,\n id,\n disabled,\n fullWidth = false,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const helperTextId = `${inputId}-helper`;\n const leftLabelId = `${inputId}-left-label`;\n const rightLabelId = `${inputId}-right-label`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n const describedBy =\n [\n leftLabel != null ? leftLabelId : null,\n rightLabel != null ? rightLabelId : null,\n bottomText ? helperTextId : null,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n const innerRef = React.useRef<HTMLInputElement>(null);\n const setRefs = React.useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n },\n [ref],\n );\n\n // Keep clicks on the non-interactive adornments (icons, side labels, padding)\n // focusing the input, matching the old absolute/pointer-events-none layout.\n const handleContainerMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {\n if (disabled) return;\n const target = event.target as HTMLElement;\n if (target === innerRef.current) return;\n if (target.closest(\"[data-tf-interactive]\")) return;\n event.preventDefault();\n innerRef.current?.focus();\n };\n\n warnMissingAccessibleName(label, props[\"aria-label\"], props[\"aria-labelledby\"]);\n\n return (\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={inputId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n {/* biome-ignore lint/a11y/noStaticElementInteractions: focus bridge delegates pointer clicks on adornments to the input */}\n <div\n className={getContainerClassName(size, error, disabled, action != null)}\n onMouseDown={handleContainerMouseDown}\n >\n <LeadingIcon size={leftIconSize} disabled={disabled}>\n {leftIcon}\n </LeadingIcon>\n <SideLabel id={leftLabelId} size={size} align=\"left\" disabled={disabled}>\n {leftLabel}\n </SideLabel>\n\n <input\n ref={setRefs}\n id={inputId}\n disabled={disabled}\n aria-describedby={describedBy}\n aria-invalid={error || undefined}\n className={cn(\n \"h-full min-w-0 flex-1 bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed theme-v2:disabled:text-content-disabled theme-v2:disabled:placeholder:text-content-disabled\",\n INPUT_TYPOGRAPHY[size],\n \"[&[type='search']::-webkit-search-cancel-button]:hidden [&[type='search']::-webkit-search-cancel-button]:appearance-none\",\n )}\n {...props}\n />\n\n <SideLabel id={rightLabelId} size={size} align=\"right\" disabled={disabled}>\n {rightLabel}\n </SideLabel>\n <TrailingAdornment rightIcon={rightIcon} validated={validated} disabled={disabled} />\n {action != null && (\n <span data-tf-interactive=\"\" className=\"flex shrink-0 items-center\">\n {action}\n </span>\n )}\n </div>\n\n {bottomText && (\n <TextFieldHelperText id={helperTextId} error={error}>\n {bottomText}\n </TextFieldHelperText>\n )}\n </div>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n"],"names":[],"mappings":";;;;;;;AA6CA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,sBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,kCAAiE;AAAA,EACrE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,gBAA+C;AAAA,EACnD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,wBAAuD;AAAA,EAC3D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,SAAS,sBACP,MACA,OACA,UACA,WACA;AACA,SAAO;AAAA,IACL;AAAA,IACA,YAAY,gCAAgC,IAAI,IAAI,oBAAoB,IAAI;AAAA,IAC5E,cAAc,IAAI;AAAA,IAClB,QAAQ,yBAAyB,CAAC,uBAAuB,4BAA4B;AAAA,IACrF,CAAC,YAAY,CAAC,SAAS;AAAA,IACvB,iBAAiB,IAAI;AAAA,IACrB,YAAY;AAAA,EAAA;AAEhB;AAEA,SAAS,YAAY;AAAA,EACnB,OAAO;AAAA,EACP;AAAA,EACA;AACF,GAIG;AACD,MAAI,CAAC,SAAU,QAAO;AACtB,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,SAAS,OAAO,WAAW;AAAA,QAC3B,YAAY;AAAA,MAAA;AAAA,MAGb;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,SAAS,UAAU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