@astryxdesign/core 0.4.0 → 0.4.1-canary.1ce0b4c

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 (271) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
  3. package/dist/AspectRatio/AspectRatio.js +1 -2
  4. package/dist/AspectRatio/index.d.ts.map +1 -1
  5. package/dist/AspectRatio/index.js +1 -2
  6. package/dist/Badge/Badge.d.ts.map +1 -1
  7. package/dist/Badge/Badge.js +1 -2
  8. package/dist/Badge/index.d.ts.map +1 -1
  9. package/dist/Badge/index.js +1 -2
  10. package/dist/Banner/Banner.d.ts +3 -0
  11. package/dist/Banner/Banner.d.ts.map +1 -1
  12. package/dist/Banner/Banner.js +17 -3
  13. package/dist/Blockquote/Blockquote.d.ts.map +1 -1
  14. package/dist/Blockquote/Blockquote.js +1 -2
  15. package/dist/Blockquote/index.d.ts.map +1 -1
  16. package/dist/Blockquote/index.js +1 -2
  17. package/dist/Button/Button.d.ts.map +1 -1
  18. package/dist/Button/Button.js +11 -9
  19. package/dist/Card/Card.d.ts.map +1 -1
  20. package/dist/Card/Card.js +1 -2
  21. package/dist/Card/index.d.ts.map +1 -1
  22. package/dist/Card/index.js +1 -2
  23. package/dist/Center/Center.d.ts.map +1 -1
  24. package/dist/Center/Center.js +1 -2
  25. package/dist/Center/index.d.ts.map +1 -1
  26. package/dist/Center/index.js +1 -2
  27. package/dist/Code/Code.d.ts.map +1 -1
  28. package/dist/Code/Code.js +1 -2
  29. package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
  30. package/dist/CommandPalette/CommandPalette.js +5 -0
  31. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  32. package/dist/ComplexSelector/ComplexSelector.js +7 -8
  33. package/dist/DateInput/DateInput.d.ts.map +1 -1
  34. package/dist/DateInput/DateInput.js +23 -10
  35. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  36. package/dist/DateRangeInput/DateRangeInput.js +44 -16
  37. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  38. package/dist/DateTimeInput/DateTimeInput.js +32 -13
  39. package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts +1 -1
  40. package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts.map +1 -1
  41. package/dist/DropdownMenu/DropdownMenuRadioGroup.js +10 -3
  42. package/dist/Field/PanelSearchInput.d.ts +81 -0
  43. package/dist/Field/PanelSearchInput.d.ts.map +1 -0
  44. package/dist/Field/PanelSearchInput.js +151 -0
  45. package/dist/FileInput/FileInput.d.ts.map +1 -1
  46. package/dist/FileInput/FileInput.js +21 -10
  47. package/dist/Grid/Grid.d.ts.map +1 -1
  48. package/dist/Grid/Grid.js +1 -2
  49. package/dist/Grid/index.d.ts.map +1 -1
  50. package/dist/Grid/index.js +1 -2
  51. package/dist/HoverCard/HoverCard.d.ts +1 -1
  52. package/dist/HoverCard/HoverCard.d.ts.map +1 -1
  53. package/dist/HoverCard/HoverCard.js +5 -13
  54. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  55. package/dist/HoverCard/useHoverCard.js +6 -5
  56. package/dist/Icon/globalIconRegistry.d.ts +5 -4
  57. package/dist/Icon/globalIconRegistry.d.ts.map +1 -1
  58. package/dist/Icon/globalIconRegistry.js +5 -4
  59. package/dist/Indicator/index.d.ts +1 -1
  60. package/dist/Indicator/index.d.ts.map +1 -1
  61. package/dist/Indicator/types.d.ts +10 -0
  62. package/dist/Indicator/types.d.ts.map +1 -1
  63. package/dist/InputGroup/groupStyles.d.ts.map +1 -1
  64. package/dist/InputGroup/groupStyles.js +7 -2
  65. package/dist/Layer/layerHost.d.ts +24 -0
  66. package/dist/Layer/layerHost.d.ts.map +1 -0
  67. package/dist/Layer/layerHost.js +79 -0
  68. package/dist/Layer/useLayer.d.ts +14 -6
  69. package/dist/Layer/useLayer.d.ts.map +1 -1
  70. package/dist/Layer/useLayer.js +155 -29
  71. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  72. package/dist/Lightbox/Lightbox.js +24 -50
  73. package/dist/MultiSelector/MultiSelector.d.ts +8 -1
  74. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  75. package/dist/MultiSelector/MultiSelector.js +134 -102
  76. package/dist/NavItem/navItemStyles.stylex.d.ts +17 -5
  77. package/dist/NavItem/navItemStyles.stylex.d.ts.map +1 -1
  78. package/dist/NavItem/navItemStyles.stylex.js +11 -5
  79. package/dist/Popover/usePopover.d.ts +15 -0
  80. package/dist/Popover/usePopover.d.ts.map +1 -1
  81. package/dist/Popover/usePopover.js +14 -2
  82. package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
  83. package/dist/ProgressBar/ProgressBar.js +2 -3
  84. package/dist/Section/Section.d.ts.map +1 -1
  85. package/dist/Section/Section.js +1 -2
  86. package/dist/Section/index.d.ts.map +1 -1
  87. package/dist/Section/index.js +1 -2
  88. package/dist/Selector/Selector.d.ts +10 -0
  89. package/dist/Selector/Selector.d.ts.map +1 -1
  90. package/dist/Selector/Selector.js +135 -95
  91. package/dist/SideNav/SideNav.d.ts +7 -9
  92. package/dist/SideNav/SideNav.d.ts.map +1 -1
  93. package/dist/SideNav/SideNav.js +32 -5
  94. package/dist/SideNav/SideNavCollapseButton.d.ts +25 -9
  95. package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
  96. package/dist/SideNav/SideNavCollapseButton.js +39 -15
  97. package/dist/SideNav/SideNavCollapseContext.d.ts +21 -0
  98. package/dist/SideNav/SideNavCollapseContext.d.ts.map +1 -1
  99. package/dist/SideNav/SideNavCollapseContext.js +16 -2
  100. package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
  101. package/dist/SideNav/SideNavHeading.js +70 -24
  102. package/dist/SideNav/SideNavItem.d.ts +7 -2
  103. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  104. package/dist/SideNav/SideNavItem.js +114 -75
  105. package/dist/SideNav/SideNavSection.d.ts.map +1 -1
  106. package/dist/SideNav/SideNavSection.js +7 -16
  107. package/dist/SideNav/index.d.ts +1 -1
  108. package/dist/SideNav/index.d.ts.map +1 -1
  109. package/dist/Skeleton/Skeleton.d.ts.map +1 -1
  110. package/dist/Skeleton/Skeleton.js +1 -2
  111. package/dist/Skeleton/index.d.ts.map +1 -1
  112. package/dist/Skeleton/index.js +1 -2
  113. package/dist/Slider/Slider.d.ts.map +1 -1
  114. package/dist/Slider/Slider.js +2 -6
  115. package/dist/Switch/Switch.d.ts.map +1 -1
  116. package/dist/Switch/Switch.js +3 -3
  117. package/dist/Table/TableRow.d.ts +1 -1
  118. package/dist/Table/TableRow.d.ts.map +1 -1
  119. package/dist/Table/TableRow.js +4 -2
  120. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  121. package/dist/TimeInput/TimeInput.js +7 -2
  122. package/dist/Timestamp/Timestamp.d.ts.map +1 -1
  123. package/dist/Timestamp/Timestamp.js +14 -3
  124. package/dist/Timestamp/formatInstant.d.ts +11 -1
  125. package/dist/Timestamp/formatInstant.d.ts.map +1 -1
  126. package/dist/Timestamp/formatInstant.js +3 -1
  127. package/dist/TopNav/TopNavMegaMenu.js +1 -1
  128. package/dist/TopNav/TopNavMegaMenuItem.js +1 -1
  129. package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
  130. package/dist/TopNav/TopNavMenu.js +2 -2
  131. package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
  132. package/dist/VisuallyHidden/VisuallyHidden.js +1 -2
  133. package/dist/VisuallyHidden/index.d.ts.map +1 -1
  134. package/dist/VisuallyHidden/index.js +1 -2
  135. package/dist/astryx.css +23 -24
  136. package/dist/astryx.umd.js +48 -48
  137. package/dist/astryx.umd.js.map +4 -4
  138. package/dist/hooks/index.d.ts +1 -1
  139. package/dist/hooks/index.d.ts.map +1 -1
  140. package/dist/hooks/index.js +1 -1
  141. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  142. package/dist/hooks/useFocusTrap.js +16 -2
  143. package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
  144. package/dist/hooks/useInputStatusIcon.js +17 -4
  145. package/dist/theme/defineTheme.d.ts +2 -2
  146. package/dist/theme/defineTheme.d.ts.map +1 -1
  147. package/dist/theme/defineTheme.js +2 -1
  148. package/dist/theme/index.d.ts +1 -1
  149. package/dist/theme/index.d.ts.map +1 -1
  150. package/dist/theme/index.js +1 -1
  151. package/dist/theme/tokens.stylex.d.ts +12 -0
  152. package/dist/theme/tokens.stylex.d.ts.map +1 -1
  153. package/dist/theme/tokens.stylex.js +23 -0
  154. package/dist/utils/focusOutline.stylex.d.ts +34 -19
  155. package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
  156. package/dist/utils/focusOutline.stylex.js +46 -33
  157. package/dist/utils/index.d.ts +1 -0
  158. package/dist/utils/index.d.ts.map +1 -1
  159. package/dist/utils/index.js +5 -1
  160. package/dist/utils/interactionModality.d.ts +34 -0
  161. package/dist/utils/interactionModality.d.ts.map +1 -0
  162. package/dist/utils/interactionModality.js +70 -0
  163. package/locales/en.json +44 -0
  164. package/locales/pseudo.json +33 -0
  165. package/package.json +3 -3
  166. package/src/AppShell/AppShell.doc.mjs +3 -0
  167. package/src/AspectRatio/AspectRatio.tsx +0 -2
  168. package/src/AspectRatio/index.ts +0 -2
  169. package/src/Badge/Badge.tsx +0 -2
  170. package/src/Badge/index.ts +0 -2
  171. package/src/Banner/Banner.test.tsx +58 -1
  172. package/src/Banner/Banner.tsx +24 -5
  173. package/src/Blockquote/Blockquote.tsx +0 -2
  174. package/src/Blockquote/index.ts +0 -2
  175. package/src/Button/Button.doc.mjs +2 -2
  176. package/src/Button/Button.tsx +10 -7
  177. package/src/ButtonGroup/ButtonGroup.test.tsx +7 -4
  178. package/src/Card/Card.tsx +0 -2
  179. package/src/Card/index.ts +0 -2
  180. package/src/Center/Center.tsx +0 -2
  181. package/src/Center/index.ts +0 -2
  182. package/src/CheckboxInput/CheckboxInput.test.tsx +8 -3
  183. package/src/Code/Code.tsx +0 -2
  184. package/src/CommandPalette/CommandPalette.test.tsx +54 -0
  185. package/src/CommandPalette/CommandPalette.tsx +5 -0
  186. package/src/ComplexSelector/ComplexSelector.test.tsx +15 -6
  187. package/src/ComplexSelector/ComplexSelector.tsx +6 -10
  188. package/src/DateInput/DateInput.test.tsx +19 -0
  189. package/src/DateInput/DateInput.tsx +3 -6
  190. package/src/DateRangeInput/DateRangeInput.tsx +3 -9
  191. package/src/DateTimeInput/DateTimeInput.test.tsx +79 -1
  192. package/src/DateTimeInput/DateTimeInput.tsx +23 -9
  193. package/src/DropdownMenu/DropdownMenuRadioGroup.tsx +2 -1
  194. package/src/Field/PanelSearchInput.tsx +271 -0
  195. package/src/FileInput/FileInput.tsx +21 -8
  196. package/src/Grid/Grid.tsx +0 -2
  197. package/src/Grid/index.ts +0 -2
  198. package/src/HoverCard/HoverCard.doc.mjs +3 -3
  199. package/src/HoverCard/HoverCard.test.tsx +283 -55
  200. package/src/HoverCard/HoverCard.tsx +5 -13
  201. package/src/HoverCard/useHoverCard.tsx +8 -11
  202. package/src/Icon/globalIconRegistry.tsx +5 -4
  203. package/src/Indicator/Indicator.doc.mjs +1 -1
  204. package/src/Indicator/index.ts +1 -0
  205. package/src/Indicator/types.ts +11 -0
  206. package/src/InputGroup/groupStyles.ts +7 -8
  207. package/src/Layer/layerHost.test.ts +99 -0
  208. package/src/Layer/layerHost.ts +141 -0
  209. package/src/Layer/useLayer.doc.mjs +14 -4
  210. package/src/Layer/useLayer.test.tsx +318 -7
  211. package/src/Layer/useLayer.tsx +229 -35
  212. package/src/Lightbox/Lightbox.tsx +2 -11
  213. package/src/MultiSelector/MultiSelector.doc.mjs +9 -0
  214. package/src/MultiSelector/MultiSelector.test.tsx +135 -5
  215. package/src/MultiSelector/MultiSelector.tsx +170 -127
  216. package/src/NavItem/navItemStyles.stylex.ts +31 -5
  217. package/src/Popover/Popover.doc.mjs +2 -0
  218. package/src/Popover/usePopover.tsx +37 -4
  219. package/src/ProgressBar/ProgressBar.tsx +2 -8
  220. package/src/Section/Section.tsx +0 -2
  221. package/src/Section/index.ts +0 -2
  222. package/src/Selector/Selector.doc.mjs +10 -0
  223. package/src/Selector/Selector.test.tsx +386 -2
  224. package/src/Selector/Selector.tsx +182 -122
  225. package/src/SideNav/SideNav.doc.mjs +13 -4
  226. package/src/SideNav/SideNav.test.tsx +771 -2
  227. package/src/SideNav/SideNav.tsx +37 -16
  228. package/src/SideNav/SideNavCollapseButton.doc.mjs +28 -6
  229. package/src/SideNav/SideNavCollapseButton.tsx +67 -15
  230. package/src/SideNav/SideNavCollapseContext.ts +29 -9
  231. package/src/SideNav/SideNavHeading.tsx +28 -10
  232. package/src/SideNav/SideNavItem.doc.mjs +13 -0
  233. package/src/SideNav/SideNavItem.tsx +92 -84
  234. package/src/SideNav/SideNavSection.tsx +6 -20
  235. package/src/SideNav/index.ts +2 -0
  236. package/src/Skeleton/Skeleton.tsx +0 -2
  237. package/src/Skeleton/index.ts +0 -2
  238. package/src/Slider/Slider.tsx +2 -11
  239. package/src/Switch/Switch.tsx +10 -2
  240. package/src/Table/Table.test.tsx +31 -0
  241. package/src/Table/TableRow.tsx +6 -0
  242. package/src/Text/Text.doc.mjs +1 -1
  243. package/src/TimeInput/TimeInput.test.tsx +54 -0
  244. package/src/TimeInput/TimeInput.tsx +17 -2
  245. package/src/Timestamp/Timestamp.test.tsx +125 -30
  246. package/src/Timestamp/Timestamp.tsx +14 -2
  247. package/src/Timestamp/formatInstant.ts +16 -1
  248. package/src/Toolbar/Toolbar.test.tsx +14 -14
  249. package/src/TopNav/TopNavMegaMenu.doc.mjs +5 -0
  250. package/src/TopNav/TopNavMegaMenu.test.tsx +43 -0
  251. package/src/TopNav/TopNavMegaMenu.tsx +4 -1
  252. package/src/TopNav/TopNavMegaMenuItem.tsx +1 -1
  253. package/src/TopNav/TopNavMenu.test.tsx +41 -0
  254. package/src/TopNav/TopNavMenu.tsx +8 -2
  255. package/src/TreeList/TreeList.test.tsx +3 -2
  256. package/src/VisuallyHidden/VisuallyHidden.tsx +0 -2
  257. package/src/VisuallyHidden/index.ts +0 -2
  258. package/src/hooks/index.ts +5 -1
  259. package/src/hooks/useFocusTrap.test.tsx +16 -0
  260. package/src/hooks/useFocusTrap.ts +20 -2
  261. package/src/hooks/useInputStatusIcon.tsx +8 -8
  262. package/src/serverSafeComponents.test.ts +665 -0
  263. package/src/theme/defineTheme.ts +3 -0
  264. package/src/theme/generateThemeRules.test.ts +17 -0
  265. package/src/theme/index.ts +2 -0
  266. package/src/theme/themingTargets.test.ts +152 -26
  267. package/src/theme/tokens.stylex.ts +18 -0
  268. package/src/theme/tokens.test.ts +37 -0
  269. package/src/utils/focusOutline.stylex.ts +37 -23
  270. package/src/utils/index.ts +4 -0
  271. package/src/utils/interactionModality.ts +74 -0
@@ -0,0 +1,271 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file PanelSearchInput.tsx
7
+ * @input Uses React, StyleX, Icon, InputClearButton, theme tokens
8
+ * @output Exports PanelSearchInput — the search row that sits at the top of a
9
+ * dropdown panel
10
+ * @position Shared internal primitive; used by Selector and MultiSelector
11
+ *
12
+ * A dropdown panel is already a bordered, elevated surface. Nesting a bordered
13
+ * TextInput inside it draws a second box within that box, so the field reads as
14
+ * a control dropped into the menu rather than part of it. This row is the
15
+ * seamless alternative — magnifier, borderless input, clear button — separated
16
+ * from the options by a divider the panel owns.
17
+ *
18
+ * The field is shaped like the option rows under it rather than like a form
19
+ * input: same inset from the panel edge, same `--radius-element` corners, same
20
+ * height. The focus ring is drawn on that rounded box, so focus reads as "this
21
+ * row of the panel" — the same visual language as an item's highlight — instead
22
+ * of ringing the whole panel header. It appears for keyboard focus only; see
23
+ * `fieldKeyboardFocus` for why `:focus-visible` alone does not mean that.
24
+ *
25
+ * ┌─ panel ──────────────────┐
26
+ * │ ┌──────────────────────┐ │ ← field: rounded, inset, item-sized
27
+ * │ │ ⌕ Search… ✕ │ │
28
+ * │ └──────────────────────┘ │
29
+ * ├──────────────────────────┤ ← divider (full-bleed)
30
+ * │ ┌──────────────────────┐ │
31
+ * │ │ Apple │ │ ← option row: same box
32
+ *
33
+ * The clear button is the shared `InputClearButton`, so the affordance and its
34
+ * ghost-button behavior match every other input's clear. It renders AFTER the
35
+ * input in DOM order: the selector components' Tab handling depends on that
36
+ * order to keep the popup open while focus moves onto it.
37
+ *
38
+ * Not exported from the package: it is an implementation detail of the panels
39
+ * that use it, not public API.
40
+ */
41
+
42
+ import {useCallback, useEffect, useState, type Ref} from 'react';
43
+ import * as stylex from '@stylexjs/stylex';
44
+ import {Icon} from '../Icon';
45
+ import {InputClearButton} from './InputClearButton';
46
+ import {mergeProps} from '../utils';
47
+ import {
48
+ getInteractionModality,
49
+ trackInteractionModality,
50
+ } from '../utils/interactionModality';
51
+ import {
52
+ colorVars,
53
+ durationVars,
54
+ easeVars,
55
+ radiusVars,
56
+ spacingVars,
57
+ typeScaleVars,
58
+ typographyVars,
59
+ } from '../theme/tokens.stylex';
60
+ import type {BaseProps} from '../BaseProps';
61
+
62
+ const styles = stylex.create({
63
+ // Gutter only. Matches the option list's own padding so the field below
64
+ // lines up with the option rows rather than with the panel edge.
65
+ wrapper: {
66
+ paddingBlock: spacingVars['--spacing-1'],
67
+ paddingInline: spacingVars['--spacing-1'],
68
+ },
69
+ // The field proper — the same box an option row draws: `--radius-element`
70
+ // corners and, at md, a 6/8 padding pair that lands it on the option row's
71
+ // 32px height. Focus rings THIS, not the full-width row.
72
+ field: {
73
+ boxSizing: 'border-box',
74
+ display: 'flex',
75
+ alignItems: 'center',
76
+ gap: spacingVars['--spacing-2'],
77
+ width: '100%',
78
+ paddingBlock: spacingVars['--spacing-1-5'],
79
+ paddingInline: spacingVars['--spacing-2'],
80
+ borderRadius: radiusVars['--radius-element'],
81
+ transitionProperty: 'box-shadow',
82
+ transitionDuration: {
83
+ default: durationVars['--duration-fast'],
84
+ '@media (prefers-reduced-motion: reduce)': '0s',
85
+ },
86
+ transitionTimingFunction: easeVars['--ease-standard'],
87
+ },
88
+ // The focus ring, applied only while focus was taken by keyboard (see
89
+ // `isKeyboardFocus`). `:has(input:focus-visible)` stays the CSS condition —
90
+ // the browser's heuristic still decides, this only narrows it — and rings
91
+ // the field rather than the bare <input> so the magnifier and the clear
92
+ // button sit inside it, and so tabbing ONTO the clear button does not
93
+ // re-ring the field.
94
+ //
95
+ // Inset, not the shared 3px-offset outline: the field is inset 4-5px from
96
+ // the panel edge, so an outline at that offset would land on the panel's own
97
+ // border and the divider. Measured, not guessed.
98
+ fieldKeyboardFocus: {
99
+ boxShadow: {
100
+ default: 'none',
101
+ ':has(input:focus-visible)': `inset 0 0 0 2px ${colorVars['--color-accent']}`,
102
+ },
103
+ },
104
+ // The icon span needs explicit flex centering to avoid a line-height offset.
105
+ icon: {
106
+ display: 'flex',
107
+ alignItems: 'center',
108
+ flexShrink: 0,
109
+ },
110
+ input: {
111
+ flexGrow: 1,
112
+ flexShrink: 1,
113
+ minWidth: 0,
114
+ padding: 0,
115
+ margin: 0,
116
+ borderWidth: 0,
117
+ borderStyle: 'none',
118
+ backgroundColor: 'transparent',
119
+ color: colorVars['--color-text-primary'],
120
+ fontFamily: typographyVars['--font-family-body'],
121
+ // Matches the option rows below it, so the query reads as the first line of
122
+ // the list. The coarse-pointer floor keeps iOS from zooming on focus.
123
+ fontSize: {
124
+ default: typeScaleVars['--text-label-size'],
125
+ '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
126
+ },
127
+ lineHeight: typeScaleVars['--text-label-leading'],
128
+ // The field draws the focus ring (see `field`), so the bare input must not
129
+ // draw a second one inside it.
130
+ outline: 'none',
131
+ '::placeholder': {
132
+ color: colorVars['--color-text-secondary'],
133
+ },
134
+ },
135
+ });
136
+
137
+ export interface PanelSearchInputProps extends Omit<
138
+ BaseProps<HTMLInputElement>,
139
+ 'onChange'
140
+ > {
141
+ /** Ref forwarded to the input element (for focus management). */
142
+ ref?: Ref<HTMLInputElement>;
143
+
144
+ /**
145
+ * Accessible name for the input. Rendered as `aria-label`: the panel has no
146
+ * visible label for the field, and a placeholder is not a reliable name.
147
+ */
148
+ label: string;
149
+
150
+ /** Accessible name for the clear (✕) button, e.g. `Clear Search options`. */
151
+ clearLabel: string;
152
+
153
+ /** Placeholder text shown while the query is empty. */
154
+ placeholder?: string;
155
+
156
+ /** The current query. */
157
+ value: string;
158
+
159
+ /** Called with the next query on every keystroke and on clear. */
160
+ onValueChange: (value: string) => void;
161
+
162
+ /** Key handler for the input itself. */
163
+ onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
164
+
165
+ /** Focus handler for the input; runs after the ring's own bookkeeping. */
166
+ onFocus?: React.FocusEventHandler<HTMLInputElement>;
167
+
168
+ /** Blur handler for the input; runs after the ring's own bookkeeping. */
169
+ onBlur?: React.FocusEventHandler<HTMLInputElement>;
170
+
171
+ /**
172
+ * Key handler for the row. Events from the input are handled by `onKeyDown`;
173
+ * this one exists for keys pressed on the clear button, which has no other
174
+ * handler of its own.
175
+ */
176
+ onContainerKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
177
+ }
178
+
179
+ /**
180
+ * Search row for the top of a dropdown panel: magnifier, borderless input, and
181
+ * a clear button once a query is typed, in a rounded box shaped like the
182
+ * option rows beneath it.
183
+ *
184
+ * `className`/`style`/`xstyle` apply to the outer row (use them to match the
185
+ * option list's inline padding); every other prop (`role`, `aria-*`, `id`, …)
186
+ * passes through to the `<input>`, so the caller owns the combobox wiring.
187
+ */
188
+ export function PanelSearchInput({
189
+ ref,
190
+ label,
191
+ clearLabel,
192
+ placeholder,
193
+ value,
194
+ onValueChange,
195
+ onKeyDown,
196
+ onFocus,
197
+ onBlur,
198
+ onContainerKeyDown,
199
+ xstyle,
200
+ className,
201
+ style,
202
+ ...props
203
+ }: PanelSearchInputProps) {
204
+ // `:focus-visible` matches a text input focused by POINTER as well (CSS
205
+ // Selectors 4, verified in Chromium), so it cannot express "keyboard focus"
206
+ // by itself. Gate it on how the user last interacted; the CSS condition
207
+ // stays `:focus-visible`, this only narrows it.
208
+ const [isKeyboardFocus, setIsKeyboardFocus] = useState(false);
209
+
210
+ useEffect(() => {
211
+ trackInteractionModality();
212
+ }, []);
213
+
214
+ const handleFocus = useCallback(
215
+ (e: React.FocusEvent<HTMLInputElement>) => {
216
+ setIsKeyboardFocus(getInteractionModality() === 'keyboard');
217
+ onFocus?.(e);
218
+ },
219
+ [onFocus],
220
+ );
221
+
222
+ const handleBlur = useCallback(
223
+ (e: React.FocusEvent<HTMLInputElement>) => {
224
+ setIsKeyboardFocus(false);
225
+ onBlur?.(e);
226
+ },
227
+ [onBlur],
228
+ );
229
+
230
+ const handleClear = useCallback(() => {
231
+ onValueChange('');
232
+ // Clearing puts the caret back where the user was typing, matching
233
+ // TextInput's built-in clear.
234
+ if (typeof ref === 'object' && ref?.current) {
235
+ ref.current.focus();
236
+ }
237
+ }, [onValueChange, ref]);
238
+
239
+ return (
240
+ <div
241
+ onKeyDown={onContainerKeyDown}
242
+ {...mergeProps(stylex.props(styles.wrapper, xstyle), className, style)}>
243
+ <div
244
+ data-keyboard-focus={isKeyboardFocus ? 'true' : undefined}
245
+ {...stylex.props(
246
+ styles.field,
247
+ isKeyboardFocus && styles.fieldKeyboardFocus,
248
+ )}>
249
+ <Icon icon="search" size="sm" color="secondary" xstyle={styles.icon} />
250
+ <input
251
+ ref={ref}
252
+ type="text"
253
+ aria-label={label}
254
+ placeholder={placeholder}
255
+ value={value}
256
+ onChange={e => onValueChange(e.target.value)}
257
+ onKeyDown={onKeyDown}
258
+ onFocus={handleFocus}
259
+ onBlur={handleBlur}
260
+ {...stylex.props(styles.input)}
261
+ {...props}
262
+ />
263
+ {value !== '' && (
264
+ <InputClearButton label={clearLabel} onClick={handleClear} />
265
+ )}
266
+ </div>
267
+ </div>
268
+ );
269
+ }
270
+
271
+ PanelSearchInput.displayName = 'PanelSearchInput';
@@ -59,6 +59,7 @@ import type {BaseProps} from '../BaseProps';
59
59
  import type {SizeValue} from '../utils/types';
60
60
  import {themeProps} from '../utils/themeProps';
61
61
  import {useTranslator} from '../i18n';
62
+ import type {TranslatorFn} from '../i18n';
62
63
 
63
64
  function formatFileSize(bytes: number): string {
64
65
  if (bytes < 1024) {
@@ -76,12 +77,13 @@ function validateFiles(
76
77
  maxSize: number | undefined,
77
78
  maxFiles: number | undefined,
78
79
  isMultiple: boolean,
80
+ t: TranslatorFn,
79
81
  ): {valid: File[]; errors: string[]} {
80
82
  const errors: string[] = [];
81
83
  let valid = files;
82
84
 
83
85
  if (accept) {
84
- const acceptedTypes = accept.split(',').map(t => t.trim().toLowerCase());
86
+ const acceptedTypes = accept.split(',').map(s => s.trim().toLowerCase());
85
87
  valid = valid.filter(file => {
86
88
  const matches = acceptedTypes.some(type => {
87
89
  if (type.startsWith('.')) {
@@ -93,7 +95,9 @@ function validateFiles(
93
95
  return file.type.toLowerCase() === type;
94
96
  });
95
97
  if (!matches) {
96
- errors.push(`"${file.name}" is not an accepted file type`);
98
+ errors.push(
99
+ t('@astryx.fileInput.errorInvalidType', {fileName: file.name}),
100
+ );
97
101
  }
98
102
  return matches;
99
103
  });
@@ -102,7 +106,12 @@ function validateFiles(
102
106
  if (maxSize != null) {
103
107
  valid = valid.filter(file => {
104
108
  if (file.size > maxSize) {
105
- errors.push(`"${file.name}" exceeds ${formatFileSize(maxSize)} limit`);
109
+ errors.push(
110
+ t('@astryx.fileInput.errorMaxSize', {
111
+ fileName: file.name,
112
+ maxSize: formatFileSize(maxSize),
113
+ }),
114
+ );
106
115
  return false;
107
116
  }
108
117
  return true;
@@ -110,7 +119,7 @@ function validateFiles(
110
119
  }
111
120
 
112
121
  if (isMultiple && maxFiles != null && valid.length > maxFiles) {
113
- errors.push(`Maximum ${maxFiles} files allowed`);
122
+ errors.push(t('@astryx.fileInput.errorMaxFiles', {maxFiles}));
114
123
  valid = valid.slice(0, maxFiles);
115
124
  }
116
125
 
@@ -488,7 +497,9 @@ export function FileInput({
488
497
  .filter(Boolean)
489
498
  .join(' ') || undefined;
490
499
 
491
- const defaultPlaceholder = isMultiple ? 'Choose files' : 'Choose file';
500
+ const defaultPlaceholder = isMultiple
501
+ ? t('@astryx.fileInput.placeholderMultiple')
502
+ : t('@astryx.fileInput.placeholder');
492
503
  const displayPlaceholder = placeholder ?? defaultPlaceholder;
493
504
 
494
505
  const handleFiles = useCallback(
@@ -503,6 +514,7 @@ export function FileInput({
503
514
  maxSize,
504
515
  maxFiles,
505
516
  isMultiple,
517
+ t,
506
518
  );
507
519
 
508
520
  if (errors.length > 0) {
@@ -526,8 +538,8 @@ export function FileInput({
526
538
  if (errors.length === 0) {
527
539
  announce(
528
540
  valid.length === 1
529
- ? `1 file selected: ${valid[0].name}`
530
- : `${valid.length} files selected`,
541
+ ? t('@astryx.fileInput.fileSelected', {fileName: valid[0].name})
542
+ : t('@astryx.fileInput.filesSelected', {count: valid.length}),
531
543
  );
532
544
  }
533
545
 
@@ -547,6 +559,7 @@ export function FileInput({
547
559
  changeAction,
548
560
  startTransition,
549
561
  announce,
562
+ t,
550
563
  ],
551
564
  );
552
565
 
@@ -679,7 +692,7 @@ export function FileInput({
679
692
  <>
680
693
  <Icon icon="arrowUp" size="md" color="secondary" />
681
694
  <span {...stylex.props(styles.placeholderText)}>
682
- {isDragOver ? 'Drop files here' : displayPlaceholder}
695
+ {isDragOver ? t('@astryx.fileInput.dropHint') : displayPlaceholder}
683
696
  </span>
684
697
  </>
685
698
  );
package/src/Grid/Grid.tsx CHANGED
@@ -1,7 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
- 'use client';
4
-
5
3
  /**
6
4
  * @file Grid.tsx
7
5
  * @input Uses React, stylex, spacing tokens
package/src/Grid/index.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
- 'use client';
4
-
5
3
  /**
6
4
  * @file index.ts
7
5
  * @input Imports from Grid.tsx and GridSpan.tsx
@@ -114,7 +114,7 @@ export const docs = {
114
114
  { guidance: false, description: 'Place critical actions or required information inside a hover card; users may miss content that only appears on hover.' },
115
115
  { guidance: false, description: 'Use a hover card when a simple Tooltip or Popover would suffice.' },
116
116
  { guidance: false, description: 'Use a HoverCard for content the user must interact with; it disappears when the cursor leaves.' },
117
- { guidance: false, description: 'Nest a HoverCard whose content has block elements directly inside phrasing-only contexts such as a <p>, <label>, or heading. The card renders inline, so block content there is invalid HTML the browser reparents. Wrap the surrounding text in a block element (e.g. a <div>) instead.' },
117
+ { guidance: true, description: 'Prefer placing HoverCard in a block context rather than directly in a <p>, heading, or link. Those placements are supported when necessary through a corrective portal, but the DOM and tab order may differ.' },
118
118
  ],
119
119
  anatomy: [
120
120
  {name: 'Trigger', required: true, description: 'The element that opens the hover card on hover or focus: a button, link, or inline text.'},
@@ -229,7 +229,7 @@ export const docsZh = {
229
229
  { guidance: false, description: 'Place critical actions or required information inside a hover card; users may miss content that only appears on hover.' },
230
230
  { guidance: false, description: 'Use a hover card when a simple Tooltip or Popover would suffice.' },
231
231
  { guidance: false, description: 'Use a HoverCard for content the user must interact with; it disappears when the cursor leaves.' },
232
- { guidance: false, description: 'Nest a HoverCard whose content has block elements directly inside phrasing-only contexts such as a <p>, <label>, or heading. The card renders inline, so block content there is invalid HTML the browser reparents. Wrap the surrounding text in a block element (e.g. a <div>) instead.' },
232
+ { guidance: true, description: 'Prefer placing HoverCard in a block context rather than directly in a <p>, heading, or link. Those placements are supported when necessary through a corrective portal, but the DOM and tab order may differ.' },
233
233
  ],
234
234
  },
235
235
  };
@@ -247,7 +247,7 @@ export const docsDense = {
247
247
  { guidance: false, description: 'Place critical actions or required information inside a hover card; users may miss content that only appears on hover.' },
248
248
  { guidance: false, description: 'Use a hover card when a simple Tooltip or Popover would suffice.' },
249
249
  { guidance: false, description: 'Use a HoverCard for content the user must interact with; it disappears when the cursor leaves.' },
250
- { guidance: false, description: 'Nest a block-content HoverCard directly inside phrasing-only contexts (<p>, <label>, heading); it renders inline so block content is invalid HTML there. Wrap surrounding text in a block element instead.' },
250
+ { guidance: true, description: 'Prefer a block context over a direct <p>, heading, or link placement. Those placements work when necessary through a corrective portal, but DOM/tab order may differ.' },
251
251
  ],
252
252
  },
253
253
  components: [