@astryxdesign/core 0.4.4 → 0.4.5-canary.1fdecb1

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 (275) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/BottomSheet/BottomSheet.d.ts +11 -2
  3. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  4. package/dist/BottomSheet/BottomSheet.js +4 -0
  5. package/dist/BottomSheet/BottomSheetPanel.d.ts +5 -2
  6. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  7. package/dist/BottomSheet/BottomSheetPanel.js +65 -15
  8. package/dist/BottomSheet/index.d.ts +1 -1
  9. package/dist/BottomSheet/index.d.ts.map +1 -1
  10. package/dist/BottomSheet/snapOffsets.d.ts +57 -20
  11. package/dist/BottomSheet/snapOffsets.d.ts.map +1 -1
  12. package/dist/BottomSheet/snapOffsets.js +106 -30
  13. package/dist/BottomSheet/useSheetGestures.d.ts +13 -8
  14. package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
  15. package/dist/BottomSheet/useSheetGestures.js +160 -64
  16. package/dist/Calendar/Calendar.d.ts +17 -0
  17. package/dist/Calendar/Calendar.d.ts.map +1 -1
  18. package/dist/Calendar/Calendar.js +34 -3
  19. package/dist/Calendar/getStandaloneShortWeekdayNames.d.ts +14 -0
  20. package/dist/Calendar/getStandaloneShortWeekdayNames.d.ts.map +1 -0
  21. package/dist/Calendar/getStandaloneShortWeekdayNames.js +26 -0
  22. package/dist/Calendar/hooks/useCalendarConstraints.d.ts +22 -1
  23. package/dist/Calendar/hooks/useCalendarConstraints.d.ts.map +1 -1
  24. package/dist/Calendar/hooks/useCalendarConstraints.js +26 -4
  25. package/dist/Calendar/hooks/useCalendarDays.d.ts.map +1 -1
  26. package/dist/Calendar/hooks/useCalendarDays.js +14 -10
  27. package/dist/Calendar/standaloneShortWeekdayNames.generated.d.ts +47 -0
  28. package/dist/Calendar/standaloneShortWeekdayNames.generated.d.ts.map +1 -0
  29. package/dist/Calendar/standaloneShortWeekdayNames.generated.js +40 -0
  30. package/dist/Center/Center.d.ts +23 -1
  31. package/dist/Center/Center.d.ts.map +1 -1
  32. package/dist/Center/Center.js +12 -6
  33. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  34. package/dist/CheckboxInput/CheckboxInput.js +9 -0
  35. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  36. package/dist/ComplexSelector/ComplexSelector.js +6 -1
  37. package/dist/DateInput/DateInput.d.ts.map +1 -1
  38. package/dist/DateInput/DateInput.js +6 -1
  39. package/dist/DateRangeInput/DateRangeInput.d.ts +23 -1
  40. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  41. package/dist/DateRangeInput/DateRangeInput.js +38 -3
  42. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  43. package/dist/DateTimeInput/DateTimeInput.js +7 -2
  44. package/dist/Dialog/Dialog.d.ts.map +1 -1
  45. package/dist/Dialog/Dialog.js +3 -3
  46. package/dist/Field/FieldLabel.d.ts +2 -1
  47. package/dist/Field/FieldLabel.d.ts.map +1 -1
  48. package/dist/Field/FieldLabel.js +21 -3
  49. package/dist/Field/InputClearButton.d.ts +2 -1
  50. package/dist/Field/InputClearButton.d.ts.map +1 -1
  51. package/dist/Field/InputClearButton.js +6 -1
  52. package/dist/FormLayout/FormLayout.d.ts +24 -2
  53. package/dist/FormLayout/FormLayout.d.ts.map +1 -1
  54. package/dist/FormLayout/FormLayout.js +7 -2
  55. package/dist/FormLayout/FormLayoutContext.d.ts +15 -2
  56. package/dist/FormLayout/FormLayoutContext.d.ts.map +1 -1
  57. package/dist/FormLayout/FormLayoutContext.js +19 -4
  58. package/dist/FormLayout/index.d.ts +1 -1
  59. package/dist/FormLayout/index.d.ts.map +1 -1
  60. package/dist/Item/Item.d.ts +9 -1
  61. package/dist/Item/Item.d.ts.map +1 -1
  62. package/dist/Item/Item.js +45 -7
  63. package/dist/Layer/useLayer.d.ts.map +1 -1
  64. package/dist/Layer/useLayer.js +3 -2
  65. package/dist/Layout/container.stylex.d.ts +4 -2
  66. package/dist/Layout/container.stylex.d.ts.map +1 -1
  67. package/dist/Layout/container.stylex.js +19 -11
  68. package/dist/Layout/index.d.ts +1 -0
  69. package/dist/Layout/index.d.ts.map +1 -1
  70. package/dist/Layout/index.js +4 -0
  71. package/dist/Layout/padding.stylex.d.ts +315 -12
  72. package/dist/Layout/padding.stylex.d.ts.map +1 -1
  73. package/dist/Layout/padding.stylex.js +389 -12
  74. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  75. package/dist/Lightbox/Lightbox.js +2 -1
  76. package/dist/Markdown/Markdown.d.ts +8 -0
  77. package/dist/Markdown/Markdown.d.ts.map +1 -1
  78. package/dist/Markdown/Markdown.js +31 -3
  79. package/dist/Markdown/parser.d.ts +14 -2
  80. package/dist/Markdown/parser.d.ts.map +1 -1
  81. package/dist/Markdown/parser.js +50 -2
  82. package/dist/MobileNav/MobileNav.d.ts +1 -0
  83. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  84. package/dist/MobileNav/MobileNav.js +24 -6
  85. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  86. package/dist/MultiSelector/MultiSelector.js +6 -1
  87. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  88. package/dist/NumberInput/NumberInput.js +36 -3
  89. package/dist/Outline/parseOutlineFromMarkdown.d.ts +2 -0
  90. package/dist/Outline/parseOutlineFromMarkdown.d.ts.map +1 -1
  91. package/dist/Outline/parseOutlineFromMarkdown.js +5 -31
  92. package/dist/RadioList/RadioList.d.ts.map +1 -1
  93. package/dist/RadioList/RadioList.js +12 -1
  94. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  95. package/dist/Resizable/ResizeHandle.js +3 -3
  96. package/dist/Section/Section.d.ts +36 -1
  97. package/dist/Section/Section.d.ts.map +1 -1
  98. package/dist/Section/Section.js +12 -2
  99. package/dist/Selector/Selector.d.ts +26 -1
  100. package/dist/Selector/Selector.d.ts.map +1 -1
  101. package/dist/Selector/Selector.js +93 -15
  102. package/dist/Selector/SelectorOption.d.ts +14 -1
  103. package/dist/Selector/SelectorOption.d.ts.map +1 -1
  104. package/dist/Selector/SelectorOption.js +6 -0
  105. package/dist/Selector/SelectorRowLayoutContext.d.ts +8 -0
  106. package/dist/Selector/SelectorRowLayoutContext.d.ts.map +1 -0
  107. package/dist/Selector/SelectorRowLayoutContext.js +27 -0
  108. package/dist/Selector/types.d.ts +1 -0
  109. package/dist/Selector/types.d.ts.map +1 -1
  110. package/dist/Slider/Slider.d.ts.map +1 -1
  111. package/dist/Slider/Slider.js +2 -2
  112. package/dist/Stack/Stack.d.ts +23 -1
  113. package/dist/Stack/Stack.d.ts.map +1 -1
  114. package/dist/Stack/Stack.js +12 -6
  115. package/dist/StatusDot/StatusDot.d.ts +43 -3
  116. package/dist/StatusDot/StatusDot.d.ts.map +1 -1
  117. package/dist/StatusDot/StatusDot.js +42 -5
  118. package/dist/Switch/Switch.d.ts.map +1 -1
  119. package/dist/Switch/Switch.js +9 -0
  120. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
  121. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +7 -2
  122. package/dist/TextArea/TextArea.d.ts.map +1 -1
  123. package/dist/TextArea/TextArea.js +6 -1
  124. package/dist/TextInput/TextInput.d.ts.map +1 -1
  125. package/dist/TextInput/TextInput.js +6 -1
  126. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  127. package/dist/TimeInput/TimeInput.js +6 -1
  128. package/dist/astryx.css +40 -21
  129. package/dist/hooks/scrollbarGutter.d.ts +28 -0
  130. package/dist/hooks/scrollbarGutter.d.ts.map +1 -0
  131. package/dist/hooks/scrollbarGutter.js +103 -0
  132. package/dist/hooks/useResolvedRequired.d.ts +19 -0
  133. package/dist/hooks/useResolvedRequired.d.ts.map +1 -0
  134. package/dist/hooks/useResolvedRequired.js +40 -0
  135. package/dist/hooks/useScrollLock.d.ts +4 -0
  136. package/dist/hooks/useScrollLock.d.ts.map +1 -1
  137. package/dist/hooks/useScrollLock.js +13 -1
  138. package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
  139. package/dist/theme/derivedVarRegistry.js +7 -0
  140. package/dist/theme/generateThemeRules.d.ts.map +1 -1
  141. package/dist/theme/generateThemeRules.js +37 -4
  142. package/dist/utils/plainDate.d.ts +6 -0
  143. package/dist/utils/plainDate.d.ts.map +1 -1
  144. package/dist/utils/plainDate.js +12 -0
  145. package/locales/af-ZA.json +958 -0
  146. package/locales/ar-SA.json +998 -0
  147. package/locales/ca-ES.json +974 -0
  148. package/locales/cs-CZ.json +990 -0
  149. package/locales/da-DK.json +966 -0
  150. package/locales/de-DE.json +966 -0
  151. package/locales/el-GR.json +990 -0
  152. package/locales/en.json +8 -0
  153. package/locales/es-ES.json +978 -0
  154. package/locales/fi-FI.json +990 -0
  155. package/locales/fr-FR.json +928 -0
  156. package/locales/he-IL.json +990 -0
  157. package/locales/hu-HU.json +990 -0
  158. package/locales/it-IT.json +978 -0
  159. package/locales/ja-JP.json +998 -0
  160. package/locales/ko-KR.json +990 -0
  161. package/locales/nl-NL.json +954 -0
  162. package/locales/no-NO.json +978 -0
  163. package/locales/pl-PL.json +982 -0
  164. package/locales/pseudo.json +6 -0
  165. package/locales/pt-BR.json +982 -0
  166. package/locales/pt-PT.json +982 -0
  167. package/locales/ro-RO.json +982 -0
  168. package/locales/ru-RU.json +990 -0
  169. package/locales/sr-SP.json +990 -0
  170. package/locales/sv-SE.json +986 -0
  171. package/locales/tr-TR.json +990 -0
  172. package/locales/uk-UA.json +990 -0
  173. package/locales/vi-VN.json +986 -0
  174. package/locales/zh-CN.json +998 -0
  175. package/locales/zh-TW.json +998 -0
  176. package/package.json +3 -3
  177. package/src/BottomSheet/BottomSheet.doc.mjs +36 -3
  178. package/src/BottomSheet/BottomSheet.test.tsx +177 -2
  179. package/src/BottomSheet/BottomSheet.tsx +16 -2
  180. package/src/BottomSheet/BottomSheetPanel.test.tsx +41 -0
  181. package/src/BottomSheet/BottomSheetPanel.tsx +95 -15
  182. package/src/BottomSheet/index.ts +5 -1
  183. package/src/BottomSheet/snapOffsets.test.ts +114 -47
  184. package/src/BottomSheet/snapOffsets.ts +119 -33
  185. package/src/BottomSheet/useSheetGestures.test.ts +113 -15
  186. package/src/BottomSheet/useSheetGestures.ts +196 -100
  187. package/src/Calendar/Calendar.doc.mjs +16 -0
  188. package/src/Calendar/Calendar.test.tsx +137 -0
  189. package/src/Calendar/Calendar.tsx +65 -2
  190. package/src/Calendar/getStandaloneShortWeekdayNames.test.ts +54 -0
  191. package/src/Calendar/getStandaloneShortWeekdayNames.ts +38 -0
  192. package/src/Calendar/hooks/useCalendarConstraints.ts +54 -3
  193. package/src/Calendar/hooks/useCalendarDays.ts +13 -10
  194. package/src/Calendar/standaloneShortWeekdayNames.generated.ts +50 -0
  195. package/src/Center/Center.doc.mjs +48 -0
  196. package/src/Center/Center.test.tsx +158 -0
  197. package/src/Center/Center.tsx +50 -9
  198. package/src/CheckboxInput/CheckboxInput.tsx +6 -0
  199. package/src/ComplexSelector/ComplexSelector.tsx +3 -1
  200. package/src/DateInput/DateInput.tsx +3 -1
  201. package/src/DateRangeInput/DateRangeInput.doc.mjs +16 -0
  202. package/src/DateRangeInput/DateRangeInput.test.tsx +81 -1
  203. package/src/DateRangeInput/DateRangeInput.tsx +72 -1
  204. package/src/DateTimeInput/DateTimeInput.tsx +4 -2
  205. package/src/Dialog/Dialog.test.tsx +24 -0
  206. package/src/Dialog/Dialog.tsx +3 -0
  207. package/src/Field/Field.doc.mjs +1 -0
  208. package/src/Field/FieldLabel.tsx +20 -4
  209. package/src/Field/InputClearButton.test.tsx +25 -0
  210. package/src/Field/InputClearButton.tsx +4 -1
  211. package/src/FormLayout/FormLayout.doc.mjs +13 -0
  212. package/src/FormLayout/FormLayout.test.tsx +181 -4
  213. package/src/FormLayout/FormLayout.tsx +33 -2
  214. package/src/FormLayout/FormLayoutContext.ts +22 -7
  215. package/src/FormLayout/index.ts +1 -1
  216. package/src/Item/Item.doc.mjs +1 -0
  217. package/src/Item/Item.test.tsx +50 -0
  218. package/src/Item/Item.tsx +40 -1
  219. package/src/Layer/useLayer.tsx +13 -2
  220. package/src/Layout/Layout.doc.mjs +18 -0
  221. package/src/Layout/container.stylex.ts +11 -3
  222. package/src/Layout/index.ts +4 -0
  223. package/src/Layout/overlayPaddingReset.test.tsx +222 -0
  224. package/src/Layout/padding.stylex.ts +192 -12
  225. package/src/Lightbox/Lightbox.tsx +2 -1
  226. package/src/Markdown/Markdown.doc.mjs +3 -0
  227. package/src/Markdown/Markdown.test.tsx +78 -0
  228. package/src/Markdown/Markdown.tsx +41 -1
  229. package/src/Markdown/parser.ts +60 -2
  230. package/src/MobileNav/MobileNav.tsx +61 -5
  231. package/src/MobileNav/MobileNavEntryAnimation.test.tsx +212 -0
  232. package/src/MobileNav/MobileNavScrollbarGutter.test.tsx +109 -0
  233. package/src/MultiSelector/MultiSelector.tsx +3 -1
  234. package/src/NumberInput/NumberInput.doc.mjs +24 -0
  235. package/src/NumberInput/NumberInput.test.tsx +138 -0
  236. package/src/NumberInput/NumberInput.tsx +43 -5
  237. package/src/Outline/Outline.doc.mjs +2 -0
  238. package/src/Outline/parseOutlineFromMarkdown.ts +10 -40
  239. package/src/RadioList/RadioList.tsx +9 -1
  240. package/src/Resizable/ResizeHandle.test.tsx +22 -0
  241. package/src/Resizable/ResizeHandle.tsx +9 -3
  242. package/src/Section/Section.doc.mjs +55 -0
  243. package/src/Section/Section.test.tsx +201 -4
  244. package/src/Section/Section.tsx +69 -0
  245. package/src/Selector/Selector.doc.mjs +16 -2
  246. package/src/Selector/Selector.test.tsx +524 -0
  247. package/src/Selector/Selector.tsx +161 -17
  248. package/src/Selector/SelectorOption.doc.mjs +7 -0
  249. package/src/Selector/SelectorOption.tsx +21 -0
  250. package/src/Selector/SelectorRowLayoutContext.ts +32 -0
  251. package/src/Selector/types.ts +4 -4
  252. package/src/Slider/Slider.tsx +10 -0
  253. package/src/Stack/Stack.doc.mjs +72 -0
  254. package/src/Stack/Stack.test.tsx +156 -0
  255. package/src/Stack/Stack.tsx +50 -8
  256. package/src/StatusDot/StatusDot.doc.mjs +13 -0
  257. package/src/StatusDot/StatusDot.test.tsx +115 -8
  258. package/src/StatusDot/StatusDot.tsx +74 -9
  259. package/src/Switch/Switch.tsx +6 -0
  260. package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +20 -2
  261. package/src/TextArea/TextArea.tsx +3 -1
  262. package/src/TextInput/TextInput.tsx +3 -1
  263. package/src/TimeInput/TimeInput.tsx +3 -1
  264. package/src/hooks/scrollbarGutter.test.ts +167 -0
  265. package/src/hooks/scrollbarGutter.ts +121 -0
  266. package/src/hooks/useResolvedRequired.ts +42 -0
  267. package/src/hooks/useScrollLock.doc.mjs +4 -4
  268. package/src/hooks/useScrollLock.test.ts +73 -0
  269. package/src/hooks/useScrollLock.ts +14 -0
  270. package/src/theme/derivedVarRegistry.test.ts +14 -3
  271. package/src/theme/derivedVarRegistry.ts +4 -0
  272. package/src/theme/generateThemeRules.test.ts +79 -0
  273. package/src/theme/generateThemeRules.ts +49 -4
  274. package/src/utils/plainDate.test.ts +50 -0
  275. package/src/utils/plainDate.ts +12 -0
@@ -71,7 +71,9 @@ import {
71
71
  } from './utils';
72
72
  import {useCombobox, useSelectedItemOffset} from './hooks';
73
73
  import {useTypeahead} from '../hooks/useTypeahead';
74
+ import {useResolvedRequired} from '../hooks/useResolvedRequired';
74
75
  import {SelectorOption} from './SelectorOption';
76
+ import {SelectorRowLayoutContext} from './SelectorRowLayoutContext';
75
77
  import {getInputARIA, isImeKeyEvent, mergeProps} from '../utils';
76
78
  import {useSize} from '../SizeContext/SizeContext';
77
79
  import type {BaseProps} from '../BaseProps';
@@ -100,7 +102,13 @@ const styles = stylex.create({
100
102
  default: typeScaleVars['--text-label-size'],
101
103
  '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
102
104
  },
103
- lineHeight: typeScaleVars['--text-label-leading'],
105
+ // A FIXED line box, not the ratio: the trigger's padding is derived from
106
+ // one line being `--spacing-5` tall, and a ratio makes the line box track
107
+ // the font — which the coarse-pointer bump above (and any theme that
108
+ // changes `--font-size-base`) then moves, taking the control off its size
109
+ // token. The glyphs still grow for touch; only the box they sit in is
110
+ // pinned. Item's own rows set their line heights and are unaffected.
111
+ lineHeight: spacingVars['--spacing-5'],
104
112
  color: colorVars['--color-text-primary'],
105
113
  cursor: 'pointer',
106
114
  },
@@ -141,6 +149,43 @@ const styles = stylex.create({
141
149
  whiteSpace: 'nowrap',
142
150
  textAlign: 'start',
143
151
  },
152
+ // Inside an InputGroup the group's own height is the row, and the trigger
153
+ // takes it: `height: 100%` from `groupStyles.inGroup` can only govern if the
154
+ // trigger stops asserting a floor of its own — otherwise a control sized
155
+ // above its group (`<InputGroup size="md"><Selector size="lg">`) grows the
156
+ // row it was supposed to sit in. The padding goes with it: the row is
157
+ // already the size token, and the value box is centred in it.
158
+ triggerInGroup: {
159
+ minHeight: 0,
160
+ paddingBlock: 0,
161
+ },
162
+ // Wrapper for `renderValue` output. Takes the free width and clips
163
+ // horizontally so a long value ellipsizes rather than widening the trigger;
164
+ // vertically the content sizes the control, which the size styles below
165
+ // handle.
166
+ triggerValue: {
167
+ flexGrow: 1,
168
+ minWidth: 0,
169
+ overflow: 'hidden',
170
+ textAlign: 'start',
171
+ },
172
+ // Inside an InputGroup the row height is the group's, so the trigger clamps
173
+ // its own value box to that row rather than asking the value to fit it: any
174
+ // node is cut off at the row's edge instead of bleeding through the border
175
+ // over whatever sits above and below the group. The rows the system draws
176
+ // itself never reach the cut — the row-layout context folds them onto one
177
+ // line first (SelectorRowLayoutContext).
178
+ //
179
+ // The clamp is a percentage, not the size token, because a group can be a
180
+ // different size than the control inside it; the row is whatever the group
181
+ // made it. That needs a definite height to resolve against, which is what
182
+ // stretching the button provides.
183
+ triggerButtonInGroup: {
184
+ alignSelf: 'stretch',
185
+ },
186
+ triggerValueInGroup: {
187
+ maxHeight: '100%',
188
+ },
144
189
  // Only what Icon does not already provide: `size="sm"` gives the 16px box
145
190
  // and `color` the token, but the glyph still must not shrink inside the flex
146
191
  // trigger.
@@ -327,15 +372,31 @@ const styles = stylex.create({
327
372
  },
328
373
  });
329
374
 
375
+ // The trigger is sized by PADDING, not by a fixed height, so it is the size
376
+ // token plus one text line for each extra line the value uses: 28/32/36 for
377
+ // one line, 48/52/56 for two. The token and a text line are both multiples of
378
+ // 4, so every trigger lands on the 4px rhythm and lines up with the Buttons
379
+ // and inputs beside it. No prop picks the height — the content does, and it
380
+ // can only land on the grid.
381
+ //
382
+ // `--spacing-5` is one line here because `triggerContainer` pins its
383
+ // line-height to exactly that; the two must stay in step, which is why both
384
+ // read the same token rather than one hardcoding 20px.
385
+ const linePad = (token: string) =>
386
+ `calc((${token} - ${spacingVars['--spacing-5']} - 2 * ${borderVars['--border-width']}) / 2)`;
387
+
330
388
  const sizeStyles = stylex.create({
331
389
  sm: {
332
- height: sizeVars['--size-element-sm'],
390
+ minHeight: sizeVars['--size-element-sm'],
391
+ paddingBlock: linePad(sizeVars['--size-element-sm']),
333
392
  },
334
393
  md: {
335
- height: sizeVars['--size-element-md'],
394
+ minHeight: sizeVars['--size-element-md'],
395
+ paddingBlock: linePad(sizeVars['--size-element-md']),
336
396
  },
337
397
  lg: {
338
- height: sizeVars['--size-element-lg'],
398
+ minHeight: sizeVars['--size-element-lg'],
399
+ paddingBlock: linePad(sizeVars['--size-element-lg']),
339
400
  },
340
401
  });
341
402
 
@@ -516,7 +577,8 @@ interface SelectorPropsBase<
516
577
  labelTooltip?: string;
517
578
 
518
579
  /**
519
- * Icon displayed at the start of the selector trigger.
580
+ * Icon displayed at the start of the selector trigger. Takes precedence over
581
+ * the selected option's own `icon`, which the trigger otherwise renders.
520
582
  */
521
583
  startIcon?: ReactNode | IconType;
522
584
 
@@ -526,6 +588,31 @@ interface SelectorPropsBase<
526
588
  */
527
589
  renderOption?: (option: SelectorOptionData) => ReactNode;
528
590
 
591
+ /**
592
+ * Custom render function for the selected option inside the closed trigger.
593
+ * Only called when something is selected; the placeholder is unaffected.
594
+ *
595
+ * Passing this does not change the trigger's height — what it draws does. A
596
+ * one-line value measures exactly the `size` token, so the control still
597
+ * lines up with the Buttons and inputs beside it; each further line of
598
+ * content adds one text line. Inside an `InputGroup` the group owns the row
599
+ * height: the trigger clamps its value box to that row, so a `SelectorOption`
600
+ * folds onto one line and ellipsizes, and anything taller than the row is cut
601
+ * off at it rather than bleeding over the rows above and below.
602
+ *
603
+ * @example
604
+ * ```
605
+ * renderValue={option => (
606
+ * <SelectorOption
607
+ * icon={option.icon}
608
+ * label={option.label}
609
+ * description={option.description}
610
+ * />
611
+ * )}
612
+ * ```
613
+ */
614
+ renderValue?: (option: SelectorOptionData) => ReactNode;
615
+
529
616
  /**
530
617
  * Which edge of the option row carries the selected mark. `start` reserves a
531
618
  * mark column ahead of every label so they stay aligned, the way a native
@@ -613,7 +700,11 @@ export type SelectorProps<T extends SelectorOptionType = SelectorOptionType> =
613
700
  */
614
701
  function DefaultOption({option}: {option: SelectorOptionData}) {
615
702
  return (
616
- <SelectorOption icon={option.icon} label={option.label ?? option.value} />
703
+ <SelectorOption
704
+ icon={option.icon}
705
+ label={option.label ?? option.value}
706
+ description={option.description}
707
+ />
617
708
  );
618
709
  }
619
710
 
@@ -686,6 +777,7 @@ export function Selector<T extends SelectorOptionType>(
686
777
  startIcon,
687
778
  htmlName,
688
779
  renderOption,
780
+ renderValue,
689
781
  indicatorPosition = 'end',
690
782
  hasSearch = false,
691
783
  searchPlaceholder: searchPlaceholderFromProps,
@@ -699,6 +791,7 @@ export function Selector<T extends SelectorOptionType>(
699
791
  hasClear: hasClearProp,
700
792
  ...rest
701
793
  } = props as SelectorPropsClearable<T>;
794
+ const isEffectivelyRequired = useResolvedRequired({isRequired, isOptional});
702
795
  const placeholder = placeholderFromProps ?? t('@astryx.selector.placeholder');
703
796
  const searchPlaceholder =
704
797
  searchPlaceholderFromProps ?? t('@astryx.selector.searchPlaceholder');
@@ -1164,12 +1257,27 @@ export function Selector<T extends SelectorOptionType>(
1164
1257
  aria-disabled={item.disabled}
1165
1258
  onClick={() => onItemSelect(item)}
1166
1259
  onMouseEnter={() => onItemMouseEnter(item, flatIndex)}
1167
- {...stylex.props(
1168
- styles.item,
1169
- itemSizeStyles[size],
1170
- isHighlighted && styles.itemHighlighted,
1171
- isSelected && styles.itemSelected,
1172
- item.disabled && styles.itemDisabled,
1260
+ {...mergeProps(
1261
+ // Stable theme target on the option row itself, mirroring
1262
+ // `multi-selector-option`: it carries the row's size and runtime
1263
+ // state so a theme can express "selected option at large" or
1264
+ // restyle a given row density without structural selectors. The
1265
+ // row's padding is split across a base and a per-size override (the
1266
+ // default `md` trims the block axis), so `size` is what a theme
1267
+ // needs to reach it. Named `-option-row` because `selector-option`
1268
+ // is the public SelectorOption content primitive, not this row.
1269
+ themeProps('selector-option-row', {
1270
+ size,
1271
+ selected: isSelected ? 'selected' : null,
1272
+ disabled: item.disabled ? 'disabled' : null,
1273
+ }),
1274
+ stylex.props(
1275
+ styles.item,
1276
+ itemSizeStyles[size],
1277
+ isHighlighted && styles.itemHighlighted,
1278
+ isSelected && styles.itemSelected,
1279
+ item.disabled && styles.itemDisabled,
1280
+ ),
1173
1281
  )}>
1174
1282
  {content}
1175
1283
  </div>
@@ -1279,6 +1387,40 @@ export function Selector<T extends SelectorOptionType>(
1279
1387
  const showStatusTooltip =
1280
1388
  status != null && effectiveStatusVariant === 'tooltip' && !!status.message;
1281
1389
 
1390
+ // Two lines cannot fit inside an InputGroup: the group pins the row height,
1391
+ // and the trigger clamps its value box to one line so nothing bleeds through
1392
+ // its border (styles.triggerValueInGroup). The clamp holds for any node; the
1393
+ // context is what lets the rows the system draws itself reflow into that one
1394
+ // line — label and description side by side — instead of being cut off at
1395
+ // it. Outside a group the caller's own row decides, and the trigger's
1396
+ // padding sizes it to whatever that draws.
1397
+ const rowLayout = inputGroup ? 'inline' : 'stacked';
1398
+
1399
+ // What the closed trigger shows for the current selection: the option's icon
1400
+ // and label. `startIcon` wins over the option's own icon so a caller who
1401
+ // pins a field icon does not get two.
1402
+ const valueContent =
1403
+ selectedItem && renderValue ? (
1404
+ <SelectorRowLayoutContext value={rowLayout}>
1405
+ <span
1406
+ {...stylex.props(
1407
+ styles.triggerValue,
1408
+ inputGroup && styles.triggerValueInGroup,
1409
+ )}>
1410
+ {renderValue(selectedItem)}
1411
+ </span>
1412
+ </SelectorRowLayoutContext>
1413
+ ) : (
1414
+ <>
1415
+ {!startIcon &&
1416
+ selectedItem?.icon != null &&
1417
+ renderIconSlot(selectedItem.icon, {size: 'sm', color: 'secondary'})}
1418
+ <span {...stylex.props(styles.triggerLabel)}>
1419
+ {selectedItem?.label ?? placeholder}
1420
+ </span>
1421
+ </>
1422
+ );
1423
+
1282
1424
  const selectorContent = (
1283
1425
  <>
1284
1426
  <div
@@ -1316,6 +1458,7 @@ export function Selector<T extends SelectorOptionType>(
1316
1458
  !isDisabled &&
1317
1459
  inputStatusHoverShadowStyles[status.type],
1318
1460
  variant !== 'ghost' && inputGroup && groupStyles.inGroup,
1461
+ inputGroup && styles.triggerInGroup,
1319
1462
  xstyle,
1320
1463
  ),
1321
1464
  className,
@@ -1345,7 +1488,7 @@ export function Selector<T extends SelectorOptionType>(
1345
1488
  }
1346
1489
  aria-describedby={ariaDescribedBy}
1347
1490
  aria-labelledby={ariaLabelledBy}
1348
- aria-required={isRequired ? 'true' : undefined}
1491
+ aria-required={isEffectivelyRequired ? 'true' : undefined}
1349
1492
  aria-invalid={status?.type === 'error' ? 'true' : undefined}
1350
1493
  aria-busy={isBusy || undefined}
1351
1494
  // With a disabledMessage the trigger keeps focusability via
@@ -1355,10 +1498,11 @@ export function Selector<T extends SelectorOptionType>(
1355
1498
  aria-disabled={showsDisabledMessage ? 'true' : undefined}
1356
1499
  onKeyDown={handleTriggerKeyDown}
1357
1500
  tabIndex={isDisabled && !showsDisabledMessage ? -1 : 0}
1358
- {...stylex.props(styles.trigger)}>
1359
- <span {...stylex.props(styles.triggerLabel)}>
1360
- {selectedItem?.label ?? placeholder}
1361
- </span>
1501
+ {...stylex.props(
1502
+ styles.trigger,
1503
+ inputGroup && styles.triggerButtonInGroup,
1504
+ )}>
1505
+ {valueContent}
1362
1506
  </button>
1363
1507
  {htmlName != null && (
1364
1508
  <input
@@ -27,6 +27,13 @@ export const docs = {
27
27
  type: 'ReactNode',
28
28
  description: 'Secondary description text displayed below the label.',
29
29
  },
30
+ {
31
+ name: 'layout',
32
+ type: "'stacked' | 'inline'",
33
+ description:
34
+ "How the label and description sit together. 'stacked' puts the description on its own line; 'inline' keeps both on one line so the row fits a fixed-height host. Inside a Selector trigger the trigger's padding sizes itself to whichever layout you pick, so both land on the 4px rhythm; an InputGroup pins the row height and forces 'inline'.",
35
+ default: "'stacked'",
36
+ },
30
37
  {
31
38
  name: 'endContent',
32
39
  type: 'ReactNode',
@@ -13,6 +13,7 @@ import * as stylex from '@stylexjs/stylex';
13
13
  import type {StyleXStyles} from '@stylexjs/stylex';
14
14
  import {renderIconSlot, type IconType} from '../Icon';
15
15
  import {Item} from '../Item';
16
+ import {useSelectorRowLayout} from './SelectorRowLayoutContext';
16
17
  import {mergeProps} from '../utils';
17
18
  import {themeProps} from '../utils/themeProps';
18
19
 
@@ -40,6 +41,20 @@ export interface SelectorOptionProps {
40
41
  */
41
42
  description?: ReactNode;
42
43
 
44
+ /**
45
+ * How the label and description sit together. `stacked` puts the
46
+ * description on its own line below the label; `inline` keeps both on one
47
+ * line, with the description ellipsizing first.
48
+ *
49
+ * In a Selector trigger this is the caller's choice and the trigger sizes
50
+ * itself to it — one line at the size token, two lines exactly one text line
51
+ * taller. Inside an `InputGroup` the row height is pinned by the group, so
52
+ * `inline` is forced.
53
+ *
54
+ * @default 'stacked'
55
+ */
56
+ layout?: 'stacked' | 'inline';
57
+
43
58
  /**
44
59
  * Additional content to render after the label/description.
45
60
  */
@@ -95,11 +110,16 @@ export function SelectorOption({
95
110
  icon,
96
111
  label,
97
112
  description,
113
+ layout,
98
114
  endContent,
99
115
  xstyle,
100
116
  className,
101
117
  style,
102
118
  }: SelectorOptionProps) {
119
+ // A height-pinned host (the trigger inside an InputGroup) overrides the
120
+ // caller's choice: the row physically cannot be two lines there.
121
+ const enforcedLayout = useSelectorRowLayout();
122
+
103
123
  return (
104
124
  <Item
105
125
  startContent={
@@ -109,6 +129,7 @@ export function SelectorOption({
109
129
  }
110
130
  label={label}
111
131
  description={description}
132
+ layout={enforcedLayout === 'inline' ? 'inline' : layout}
112
133
  endContent={endContent}
113
134
  xstyle={[embeddedStyles.root, xstyle]}
114
135
  {...mergeProps(themeProps('selector-option'), {className, style})}
@@ -0,0 +1,32 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file SelectorRowLayoutContext.ts
7
+ * @input React createContext/use
8
+ * @output Exports the row-layout context and useSelectorRowLayout hook
9
+ * @position Internal to the Selector module; read by SelectorOption
10
+ *
11
+ * The trigger inside an InputGroup is height-pinned by the group, so its value
12
+ * box is clamped to one line and anything taller is cut off at the fold. This
13
+ * context is how the rows the system draws itself avoid being cut: they reflow
14
+ * label and description onto that one line instead. The geometry does not
15
+ * depend on it — a node that ignores this context still cannot grow the row.
16
+ */
17
+
18
+ import {createContext, use} from 'react';
19
+
20
+ export type SelectorRowLayout = 'stacked' | 'inline';
21
+
22
+ export const SelectorRowLayoutContext =
23
+ createContext<SelectorRowLayout>('stacked');
24
+ SelectorRowLayoutContext.displayName = 'SelectorRowLayoutContext';
25
+
26
+ /**
27
+ * The row layout a host imposes on the options it renders. `stacked` outside
28
+ * any height-pinned host.
29
+ */
30
+ export function useSelectorRowLayout(): SelectorRowLayout {
31
+ return use(SelectorRowLayoutContext);
32
+ }
@@ -14,7 +14,10 @@ import type {IconType} from '../Icon';
14
14
  */
15
15
  export type SelectorOptionData = {
16
16
  value: string;
17
+ // Kept a string, not ReactNode: search filtering and type-ahead both
18
+ // lowercase this to match keystrokes.
17
19
  label?: string;
20
+ description?: ReactNode;
18
21
  disabled?: boolean;
19
22
  icon?: ReactNode | IconType;
20
23
  };
@@ -40,7 +43,4 @@ export type SelectorSection = {
40
43
  * Can be a plain string, option data object, divider, or section.
41
44
  */
42
45
  export type SelectorOptionType =
43
- | string
44
- | SelectorOptionData
45
- | SelectorDivider
46
- | SelectorSection;
46
+ string | SelectorOptionData | SelectorDivider | SelectorSection;
@@ -189,6 +189,16 @@ const styles = stylex.create({
189
189
  trackContainerVertical: {
190
190
  width: THUMB_SIZE,
191
191
  height: 160,
192
+ // Same tap target, rotated: the vertical track is the thing you press, and
193
+ // it is only THUMB_SIZE (20px) wide. `minBlockSize` above floors the
194
+ // horizontal track's short axis; here the short axis is the inline one
195
+ // (the block size is already 160px), so floor that instead. The rail,
196
+ // fill, marks and thumb all center on the inline 50%, so they stay put;
197
+ // only the invisible tappable area grows. Desktop is unchanged.
198
+ minInlineSize: {
199
+ default: null,
200
+ '@media (pointer: coarse)': '24px',
201
+ },
192
202
  flexDirection: 'column',
193
203
  justifyContent: 'center',
194
204
  cursor: 'pointer',
@@ -46,12 +46,36 @@ export const docs = {
46
46
  description:
47
47
  'Inline (horizontal) padding. Overrides padding on the inline axis when both are set.',
48
48
  },
49
+ {
50
+ name: 'paddingInlineStart',
51
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
52
+ description:
53
+ 'Inline-start padding, using the spacing scale (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',
54
+ },
55
+ {
56
+ name: 'paddingInlineEnd',
57
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
58
+ description:
59
+ 'Inline-end padding, using the spacing scale (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',
60
+ },
49
61
  {
50
62
  name: 'paddingBlock',
51
63
  type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
52
64
  description:
53
65
  'Block (vertical) padding. Overrides padding on the block axis when both are set.',
54
66
  },
67
+ {
68
+ name: 'paddingBlockStart',
69
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
70
+ description:
71
+ 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',
72
+ },
73
+ {
74
+ name: 'paddingBlockEnd',
75
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
76
+ description:
77
+ 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',
78
+ },
55
79
  {
56
80
  name: 'isScrollable',
57
81
  type: 'boolean',
@@ -150,12 +174,36 @@ export const docs = {
150
174
  description:
151
175
  'Inline (horizontal) padding, using the spacing scale. Overrides padding on the inline axis when both are set.',
152
176
  },
177
+ {
178
+ name: 'paddingInlineStart',
179
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
180
+ description:
181
+ 'Inline-start padding, using the spacing scale (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',
182
+ },
183
+ {
184
+ name: 'paddingInlineEnd',
185
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
186
+ description:
187
+ 'Inline-end padding, using the spacing scale (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',
188
+ },
153
189
  {
154
190
  name: 'paddingBlock',
155
191
  type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
156
192
  description:
157
193
  'Block (vertical) padding, using the spacing scale. Overrides padding on the block axis when both are set.',
158
194
  },
195
+ {
196
+ name: 'paddingBlockStart',
197
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
198
+ description:
199
+ 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',
200
+ },
201
+ {
202
+ name: 'paddingBlockEnd',
203
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
204
+ description:
205
+ 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',
206
+ },
159
207
  {
160
208
  name: 'isScrollable',
161
209
  type: 'boolean',
@@ -253,12 +301,36 @@ export const docs = {
253
301
  description:
254
302
  'Inline (horizontal) padding, using the spacing scale. Overrides padding on the inline axis when both are set.',
255
303
  },
304
+ {
305
+ name: 'paddingInlineStart',
306
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
307
+ description:
308
+ 'Inline-start padding, using the spacing scale (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',
309
+ },
310
+ {
311
+ name: 'paddingInlineEnd',
312
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
313
+ description:
314
+ 'Inline-end padding, using the spacing scale (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',
315
+ },
256
316
  {
257
317
  name: 'paddingBlock',
258
318
  type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
259
319
  description:
260
320
  'Block (vertical) padding, using the spacing scale. Overrides padding on the block axis when both are set.',
261
321
  },
322
+ {
323
+ name: 'paddingBlockStart',
324
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
325
+ description:
326
+ 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',
327
+ },
328
+ {
329
+ name: 'paddingBlockEnd',
330
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
331
+ description:
332
+ 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',
333
+ },
262
334
  {
263
335
  name: 'isScrollable',
264
336
  type: 'boolean',