@alepha/ui 0.36.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/dist/account/$pageAccount.d.ts +1 -1
  2. package/dist/account/$pageAccount.d.ts.map +1 -1
  3. package/dist/account/$pageAccount.js.map +1 -1
  4. package/dist/account/AccountDisplay.d.ts +13 -0
  5. package/dist/account/AccountDisplay.d.ts.map +1 -0
  6. package/dist/account/AccountDisplay.js +48 -0
  7. package/dist/account/AccountDisplay.js.map +1 -0
  8. package/dist/account/AccountProfile.d.ts.map +1 -1
  9. package/dist/account/AccountProfile.js +14 -10
  10. package/dist/account/AccountProfile.js.map +1 -1
  11. package/dist/account/AccountRouter.d.ts +6 -6
  12. package/dist/account/AccountRouter.d.ts.map +1 -1
  13. package/dist/account/index.d.ts +5 -0
  14. package/dist/account/index.d.ts.map +1 -1
  15. package/dist/account/index.js +2 -1
  16. package/dist/admin/$pageAdmin.d.ts +1 -1
  17. package/dist/admin/$pageAdmin.d.ts.map +1 -1
  18. package/dist/admin/$pageAdmin.js.map +1 -1
  19. package/dist/admin/AdminAudits.js.map +1 -1
  20. package/dist/admin/AdminJobDetail.js.map +1 -1
  21. package/dist/admin/AdminJobs.js.map +1 -1
  22. package/dist/admin/AdminNotifications.js.map +1 -1
  23. package/dist/admin/AdminRouter.d.ts +14 -14
  24. package/dist/admin/AdminRouter.d.ts.map +1 -1
  25. package/dist/admin/AdminUserDetail.js.map +1 -1
  26. package/dist/admin/AdminUsers.js.map +1 -1
  27. package/dist/admin/ParameterHistoryItem.js.map +1 -1
  28. package/dist/ai/AiChat.d.ts +26 -39
  29. package/dist/ai/AiChat.d.ts.map +1 -1
  30. package/dist/ai/AiChat.js +65 -123
  31. package/dist/ai/AiChat.js.map +1 -1
  32. package/dist/ai/AiChatDock.d.ts +23 -0
  33. package/dist/ai/AiChatDock.d.ts.map +1 -0
  34. package/dist/ai/AiChatDock.js +90 -0
  35. package/dist/ai/AiChatDock.js.map +1 -0
  36. package/dist/ai/AiChatDockSlot.d.ts +15 -0
  37. package/dist/ai/AiChatDockSlot.d.ts.map +1 -0
  38. package/dist/ai/AiChatDockSlot.js +20 -0
  39. package/dist/ai/AiChatDockSlot.js.map +1 -0
  40. package/dist/ai/AiChatLauncher.d.ts +17 -0
  41. package/dist/ai/AiChatLauncher.d.ts.map +1 -0
  42. package/dist/ai/AiChatLauncher.js +42 -0
  43. package/dist/ai/AiChatLauncher.js.map +1 -0
  44. package/dist/ai/AiChatMessage.d.ts +6 -0
  45. package/dist/ai/AiChatMessage.d.ts.map +1 -1
  46. package/dist/ai/AiChatMessage.js +20 -4
  47. package/dist/ai/AiChatMessage.js.map +1 -1
  48. package/dist/ai/AiChatPanel.d.ts +71 -0
  49. package/dist/ai/AiChatPanel.d.ts.map +1 -0
  50. package/dist/ai/AiChatPanel.js +143 -0
  51. package/dist/ai/AiChatPanel.js.map +1 -0
  52. package/dist/ai/index.d.ts +8 -4
  53. package/dist/ai/index.d.ts.map +1 -1
  54. package/dist/ai/index.js +5 -1
  55. package/dist/ai/useAiChat.d.ts +12 -0
  56. package/dist/ai/useAiChat.d.ts.map +1 -1
  57. package/dist/ai/useAiChat.js +32 -15
  58. package/dist/ai/useAiChat.js.map +1 -1
  59. package/dist/auth/AuthLogin.d.ts +9 -0
  60. package/dist/auth/AuthLogin.d.ts.map +1 -1
  61. package/dist/auth/AuthLogin.js +2 -2
  62. package/dist/auth/AuthLogin.js.map +1 -1
  63. package/dist/auth/AuthRegister.d.ts +4 -1
  64. package/dist/auth/AuthRegister.d.ts.map +1 -1
  65. package/dist/auth/AuthRegister.js +1 -1
  66. package/dist/auth/AuthRegister.js.map +1 -1
  67. package/dist/auth/AuthResetPassword.d.ts +8 -0
  68. package/dist/auth/AuthResetPassword.d.ts.map +1 -1
  69. package/dist/auth/AuthResetPassword.js +2 -2
  70. package/dist/auth/AuthResetPassword.js.map +1 -1
  71. package/dist/auth/AuthRouter.d.ts +4 -4
  72. package/dist/auth/AuthRouter.d.ts.map +1 -1
  73. package/dist/core/Badge.d.ts.map +1 -1
  74. package/dist/core/Badge.js +7 -3
  75. package/dist/core/Badge.js.map +1 -1
  76. package/dist/core/Collapsible.d.ts +50 -0
  77. package/dist/core/Collapsible.d.ts.map +1 -0
  78. package/dist/core/Collapsible.js +70 -0
  79. package/dist/core/Collapsible.js.map +1 -0
  80. package/dist/core/Combobox.d.ts +7 -1
  81. package/dist/core/Combobox.d.ts.map +1 -1
  82. package/dist/core/Combobox.js +2 -2
  83. package/dist/core/Combobox.js.map +1 -1
  84. package/dist/core/PaneRail.d.ts +24 -7
  85. package/dist/core/PaneRail.d.ts.map +1 -1
  86. package/dist/core/PaneRail.js +24 -19
  87. package/dist/core/PaneRail.js.map +1 -1
  88. package/dist/core/Stepper.d.ts +36 -0
  89. package/dist/core/Stepper.d.ts.map +1 -0
  90. package/dist/core/Stepper.js +54 -0
  91. package/dist/core/Stepper.js.map +1 -0
  92. package/dist/core/index.d.ts +2 -0
  93. package/dist/core/index.d.ts.map +1 -1
  94. package/dist/core/index.js +3 -1
  95. package/dist/core/useToast.js +13 -13
  96. package/dist/core/useToast.js.map +1 -1
  97. package/dist/form/AutoForm.d.ts.map +1 -1
  98. package/dist/form/AutoForm.js +29 -0
  99. package/dist/form/AutoForm.js.map +1 -1
  100. package/dist/form/AutoFormErrorPopover.js +13 -3
  101. package/dist/form/AutoFormErrorPopover.js.map +1 -1
  102. package/dist/form/Control.d.ts +14 -1
  103. package/dist/form/Control.d.ts.map +1 -1
  104. package/dist/form/Control.js +12 -2
  105. package/dist/form/Control.js.map +1 -1
  106. package/dist/form/ControlDate.d.ts.map +1 -1
  107. package/dist/form/ControlDate.js +3 -0
  108. package/dist/form/ControlDate.js.map +1 -1
  109. package/dist/form/ControlDateRange.d.ts +12 -1
  110. package/dist/form/ControlDateRange.d.ts.map +1 -1
  111. package/dist/form/ControlDateRange.js +11 -1
  112. package/dist/form/ControlDateRange.js.map +1 -1
  113. package/dist/form/ControlNumber.d.ts.map +1 -1
  114. package/dist/form/ControlNumber.js +2 -0
  115. package/dist/form/ControlNumber.js.map +1 -1
  116. package/dist/form/ControlObject.d.ts.map +1 -1
  117. package/dist/form/ControlObject.js +15 -1
  118. package/dist/form/ControlObject.js.map +1 -1
  119. package/dist/form/ControlPassword.d.ts +4 -0
  120. package/dist/form/ControlPassword.d.ts.map +1 -1
  121. package/dist/form/ControlPassword.js +1 -0
  122. package/dist/form/ControlPassword.js.map +1 -1
  123. package/dist/form/ControlSelect.d.ts +23 -1
  124. package/dist/form/ControlSelect.d.ts.map +1 -1
  125. package/dist/form/ControlSelect.js +5 -0
  126. package/dist/form/ControlSelect.js.map +1 -1
  127. package/dist/form/ControlSelectCombobox.d.ts +11 -1
  128. package/dist/form/ControlSelectCombobox.d.ts.map +1 -1
  129. package/dist/form/ControlSelectCombobox.js +9 -1
  130. package/dist/form/ControlSelectCombobox.js.map +1 -1
  131. package/dist/form/ControlUpload.d.ts.map +1 -1
  132. package/dist/form/ControlUpload.js +1 -0
  133. package/dist/form/ControlUpload.js.map +1 -1
  134. package/dist/form/FormField.d.ts +5 -0
  135. package/dist/form/FormField.d.ts.map +1 -1
  136. package/dist/form/FormField.js +7 -0
  137. package/dist/form/FormField.js.map +1 -1
  138. package/dist/i18n/fr/uiFr.d.ts.map +1 -1
  139. package/dist/i18n/fr/uiFr.js +14 -0
  140. package/dist/i18n/fr/uiFr.js.map +1 -1
  141. package/dist/shell/$pageNav.d.ts +2 -2
  142. package/dist/shell/$pageNav.d.ts.map +1 -1
  143. package/dist/shell/$pageNav.js.map +1 -1
  144. package/dist/shell/AppShell.d.ts +6 -0
  145. package/dist/shell/AppShell.d.ts.map +1 -1
  146. package/dist/shell/AppShell.js +31 -27
  147. package/dist/shell/AppShell.js.map +1 -1
  148. package/dist/shell/ButtonSettings.d.ts +6 -2
  149. package/dist/shell/ButtonSettings.d.ts.map +1 -1
  150. package/dist/shell/ButtonSettings.js +17 -3
  151. package/dist/shell/ButtonSettings.js.map +1 -1
  152. package/dist/shell/ButtonSettingsVisionMenuItem.d.ts +16 -0
  153. package/dist/shell/ButtonSettingsVisionMenuItem.d.ts.map +1 -0
  154. package/dist/shell/ButtonSettingsVisionMenuItem.js +24 -0
  155. package/dist/shell/ButtonSettingsVisionMenuItem.js.map +1 -0
  156. package/dist/shell/ButtonVision.d.ts +28 -0
  157. package/dist/shell/ButtonVision.d.ts.map +1 -0
  158. package/dist/shell/ButtonVision.js +46 -0
  159. package/dist/shell/ButtonVision.js.map +1 -0
  160. package/dist/shell/index.d.ts +6 -3
  161. package/dist/shell/index.d.ts.map +1 -1
  162. package/dist/shell/index.js +2 -1
  163. package/dist/styles.css +57 -0
  164. package/dist/table/DataTable.d.ts.map +1 -1
  165. package/dist/table/DataTable.js +29 -4
  166. package/dist/table/DataTable.js.map +1 -1
  167. package/dist/table/DataTableColumnPicker.d.ts.map +1 -1
  168. package/dist/table/DataTableColumnPicker.js +1 -0
  169. package/dist/table/DataTableColumnPicker.js.map +1 -1
  170. package/dist/table/DataTableFilterBar.d.ts +1 -1
  171. package/dist/table/DataTableFilterBar.d.ts.map +1 -1
  172. package/dist/table/DataTableFilterBar.js +5 -108
  173. package/dist/table/DataTableFilterBar.js.map +1 -1
  174. package/dist/table/DataTableHeaderFilter.d.ts +51 -0
  175. package/dist/table/DataTableHeaderFilter.d.ts.map +1 -0
  176. package/dist/table/DataTableHeaderFilter.js +113 -0
  177. package/dist/table/DataTableHeaderFilter.js.map +1 -0
  178. package/dist/table/DataTableHeaderRow.d.ts +7 -0
  179. package/dist/table/DataTableHeaderRow.d.ts.map +1 -1
  180. package/dist/table/DataTableHeaderRow.js +92 -74
  181. package/dist/table/DataTableHeaderRow.js.map +1 -1
  182. package/dist/table/DataTableTabs.d.ts +42 -0
  183. package/dist/table/DataTableTabs.d.ts.map +1 -0
  184. package/dist/table/DataTableTabs.js +55 -0
  185. package/dist/table/DataTableTabs.js.map +1 -0
  186. package/dist/table/dataTableBaseProps.d.ts +12 -0
  187. package/dist/table/dataTableBaseProps.d.ts.map +1 -1
  188. package/dist/table/dataTablePersistence.d.ts.map +1 -1
  189. package/dist/table/dataTablePersistence.js +4 -2
  190. package/dist/table/dataTablePersistence.js.map +1 -1
  191. package/dist/table/dataTableTypes.d.ts +18 -0
  192. package/dist/table/dataTableTypes.d.ts.map +1 -1
  193. package/dist/table/index.d.ts +5 -2
  194. package/dist/table/index.d.ts.map +1 -1
  195. package/dist/table/index.js +2 -1
  196. package/dist/table/useDataTableColumns.d.ts.map +1 -1
  197. package/dist/table/useDataTableColumns.js +1 -0
  198. package/dist/table/useDataTableColumns.js.map +1 -1
  199. package/dist/table/useDataTableFilterModel.d.ts +110 -0
  200. package/dist/table/useDataTableFilterModel.d.ts.map +1 -0
  201. package/dist/table/useDataTableFilterModel.js +154 -0
  202. package/dist/table/useDataTableFilterModel.js.map +1 -0
  203. package/docs/packages-alepha-ui-account.md +4 -0
  204. package/docs/packages-alepha-ui-ai.md +5 -5
  205. package/docs/packages-alepha-ui-shell.md +4 -3
  206. package/docs/packages-alepha-ui-table.md +4 -2
  207. package/package.json +8 -8
  208. package/src/account/$pageAccount.tsx +5 -4
  209. package/src/account/AccountDisplay.tsx +58 -0
  210. package/src/account/AccountProfile.tsx +30 -42
  211. package/src/account/__tests__/AccountProfile.browser.spec.tsx +141 -0
  212. package/src/account/__tests__/AccountRecoveryCodes.browser.spec.tsx +1 -1
  213. package/src/account/index.ts +5 -0
  214. package/src/admin/$pageAdmin.tsx +5 -4
  215. package/src/admin/AdminAudits.tsx +1 -1
  216. package/src/admin/AdminJobDetail.tsx +1 -1
  217. package/src/admin/AdminJobs.tsx +1 -1
  218. package/src/admin/AdminNotifications.tsx +1 -1
  219. package/src/admin/AdminUserDetail.tsx +1 -1
  220. package/src/admin/AdminUsers.tsx +1 -1
  221. package/src/admin/ParameterHistoryItem.tsx +1 -1
  222. package/src/admin/__tests__/AdminFilesUsageCard.browser.spec.tsx +17 -9
  223. package/src/ai/AiChat.tsx +94 -183
  224. package/src/ai/AiChatDock.tsx +129 -0
  225. package/src/ai/AiChatDockSlot.tsx +23 -0
  226. package/src/ai/AiChatLauncher.tsx +58 -0
  227. package/src/ai/AiChatMessage.tsx +36 -2
  228. package/src/ai/AiChatPanel.tsx +252 -0
  229. package/src/ai/__tests__/AiChat.browser.spec.tsx +187 -5
  230. package/src/ai/index.ts +8 -4
  231. package/src/ai/useAiChat.ts +63 -14
  232. package/src/auth/AuthLogin.tsx +19 -4
  233. package/src/auth/AuthRegister.tsx +6 -3
  234. package/src/auth/AuthResetPassword.tsx +18 -8
  235. package/src/auth/__tests__/AuthCancel.browser.spec.tsx +129 -0
  236. package/src/core/Badge.tsx +7 -3
  237. package/src/core/Collapsible.tsx +95 -0
  238. package/src/core/Combobox.tsx +11 -3
  239. package/src/core/PaneRail.tsx +36 -20
  240. package/src/core/Stepper.tsx +118 -0
  241. package/src/core/__tests__/Badge.browser.spec.tsx +5 -5
  242. package/src/core/__tests__/Collapsible.browser.spec.tsx +88 -0
  243. package/src/core/__tests__/PaneRail.browser.spec.tsx +48 -0
  244. package/src/core/__tests__/Stepper.browser.spec.tsx +39 -0
  245. package/src/core/__tests__/primitiveSlots.spec.ts +7 -0
  246. package/src/core/index.ts +15 -0
  247. package/src/form/AutoForm.tsx +32 -0
  248. package/src/form/AutoFormErrorPopover.tsx +27 -6
  249. package/src/form/Control.tsx +22 -0
  250. package/src/form/ControlDate.tsx +3 -0
  251. package/src/form/ControlDateRange.tsx +87 -58
  252. package/src/form/ControlNumber.tsx +2 -0
  253. package/src/form/ControlObject.tsx +20 -1
  254. package/src/form/ControlPassword.tsx +5 -0
  255. package/src/form/ControlSelect.tsx +32 -1
  256. package/src/form/ControlSelectCombobox.tsx +82 -56
  257. package/src/form/ControlUpload.tsx +1 -0
  258. package/src/form/FormField.tsx +23 -1
  259. package/src/form/__tests__/ControlFieldErrors.browser.spec.tsx +253 -0
  260. package/src/form/__tests__/ControlValidateMode.browser.spec.tsx +217 -0
  261. package/src/form/__tests__/ControlVariantErrors.browser.spec.tsx +133 -0
  262. package/src/i18n/fr/uiFr.ts +18 -1
  263. package/src/markdown/css.d.ts +11 -0
  264. package/src/shell/$pageNav.tsx +6 -4
  265. package/src/shell/AppShell.tsx +7 -0
  266. package/src/shell/ButtonSettings.tsx +20 -5
  267. package/src/shell/ButtonSettingsVisionMenuItem.tsx +40 -0
  268. package/src/shell/ButtonVision.tsx +73 -0
  269. package/src/shell/__tests__/ButtonSettings.browser.spec.tsx +42 -2
  270. package/src/shell/__tests__/ButtonVision.browser.spec.tsx +73 -0
  271. package/src/shell/__tests__/visionTokens.spec.ts +104 -0
  272. package/src/shell/index.ts +6 -3
  273. package/src/styles.css +57 -0
  274. package/src/table/DataTable.tsx +52 -4
  275. package/src/table/DataTableColumnPicker.tsx +3 -0
  276. package/src/table/DataTableFilterBar.tsx +18 -191
  277. package/src/table/DataTableHeaderFilter.tsx +156 -0
  278. package/src/table/DataTableHeaderRow.tsx +78 -40
  279. package/src/table/DataTableTabs.tsx +114 -0
  280. package/src/table/__tests__/DataTableHeaderFilter.browser.spec.tsx +174 -0
  281. package/src/table/__tests__/DataTableStaleColumns.browser.spec.tsx +80 -0
  282. package/src/table/__tests__/DataTableTabs.browser.spec.tsx +72 -0
  283. package/src/table/dataTableBaseProps.ts +12 -0
  284. package/src/table/dataTablePersistence.ts +11 -5
  285. package/src/table/dataTableTypes.ts +18 -0
  286. package/src/table/index.ts +9 -2
  287. package/src/table/useDataTableColumns.ts +1 -0
  288. package/src/table/useDataTableFilterModel.tsx +240 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ControlObject.js","names":[],"sources":["../../src/form/ControlObject.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { type ZObject, z } from \"alepha\";\nimport {\n type BaseInputField,\n type ObjectInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { ChevronDown, ChevronRight, Plus, Trash2 } from \"lucide-react\";\nimport { useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { Control, type ControlProps } from \"./Control.tsx\";\nimport { childI18nPrefix, resolveFieldI18n } from \"./fieldI18n.ts\";\nimport { spanClass, widthFor } from \"./grid.tsx\";\n\nexport interface ControlObjectProps {\n /**\n * Bound object `InputField` from `useForm`.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the group.\n */\n description?: string;\n /**\n * Number of grid columns. @default 1\n */\n columns?: 1 | 2 | 3 | 4;\n /**\n * \"fieldset\" wraps in a bordered container with legend. \"plain\" renders fields only.\n */\n variant?: \"fieldset\" | \"plain\";\n /**\n * Per-field control props override, keyed by field name.\n */\n controlProps?: Record<string, Partial<Omit<ControlProps, \"input\">>>;\n /**\n * Disable the group and all inner controls.\n */\n disabled?: boolean;\n /**\n * Default expanded state. @default true\n */\n defaultExpanded?: boolean;\n /**\n * Dictionary prefix for this object's children (see `resolveFieldI18n`).\n */\n i18nPrefix?: string;\n /**\n * Take the clear button away from an optional object.\n *\n * The schema decides by default: an optional or nullable object that has\n * been initialised offers the button, and `false` opts out - the same way\n * round as a text field's `clearable`, and for the same reason. Pass\n * `false` when clearing is not something the API can honour, so the button\n * does not promise an edit that silently does nothing.\n *\n * This used to be opt-IN, which made the button unreachable: `Control` is\n * the only thing that mounts this component and it never passed the prop,\n * so an initialised optional object could not be cleared from the UI at\n * all.\n */\n clearable?: boolean;\n}\n\nexport const ControlObject = (props: ControlObjectProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const [expanded, setExpanded] = useState(props.defaultExpanded ?? true);\n const { tr } = useI18n();\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n // The field schema may be wrapped (optional/nullable/default); peel to the\n // ZodObject before reading its shape.\n const schema = z.schema.unwrap(props.input.schema) as ZObject;\n if (!z.schema.isObject(schema)) return null;\n\n // ── Init / clear ────────────────────────────────────────────────\n const isInitialized = value != null && typeof value === \"object\";\n\n // `clearable !== false`, not `clearable === true`: the schema is the\n // answer, and a caller opts out. A required object has nothing to clear to.\n const showClear =\n isInitialized &&\n !meta.required &&\n !props.disabled &&\n props.clearable !== false;\n\n const fieldNames = Object.keys(z.schema.shape(schema));\n const nestedItems = (props.input as ObjectInputField<ZObject>).items as\n | Record<string, BaseInputField>\n | undefined;\n\n const grid = (\n <div className=\"grid grid-cols-12 gap-3\">\n {fieldNames.map((name) => {\n const field = nestedItems?.[name];\n if (!field) return null;\n const fieldProps = {\n ...props.controlProps?.[name],\n ...resolveFieldI18n(\n tr,\n props.i18nPrefix,\n name,\n props.controlProps?.[name] ?? {},\n ),\n i18nPrefix: childI18nPrefix(props.i18nPrefix, name),\n };\n const width = widthFor(field, fieldProps.width as number | undefined);\n return (\n <div key={name} className={spanClass(width)}>\n <Control input={field} disabled={props.disabled} {...fieldProps} />\n </div>\n );\n })}\n </div>\n );\n\n if (props.variant === \"plain\") return grid;\n\n return (\n <fieldset\n className={`rounded-md border p-3 ${\n meta.error ? \"border-danger\" : \"border-border\"\n }`}\n >\n <div className=\"flex items-start gap-3\">\n {!isInitialized && !props.disabled ? (\n <Button\n type=\"button\"\n variant=\"outlined\"\n size=\"icon\"\n className=\"size-8 shrink-0\"\n aria-label={tr(\"controlObject.initialize\", {\n default: \"Initialize\",\n })}\n onClick={() => setValue({})}\n >\n <Plus className=\"size-4\" />\n </Button>\n ) : showClear ? (\n <Button\n type=\"button\"\n variant=\"minimal\"\n size=\"icon\"\n className=\"size-8 shrink-0\"\n aria-label={tr(\"controlObject.clear\", { default: \"Clear\" })}\n onClick={() => setValue(undefined)}\n >\n <Trash2 className=\"size-4\" />\n </Button>\n ) : (\n <div className=\"size-8 shrink-0\" />\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n {meta.label && (\n <legend className=\"text-sm leading-tight font-medium\">\n {meta.label}\n {meta.required && (\n <span className=\"text-danger-text ml-0.5\">*</span>\n )}\n </legend>\n )}\n {meta.description && (\n <p className=\"text-muted-foreground text-xs leading-tight\">\n {meta.description}\n </p>\n )}\n {meta.error && (\n <p className=\"text-danger-text text-xs leading-tight\">\n {meta.error}\n </p>\n )}\n </div>\n {isInitialized && (\n <Button\n type=\"button\"\n variant=\"minimal\"\n size=\"icon\"\n className=\"size-8 shrink-0\"\n aria-label={\n expanded\n ? tr(\"controlObject.collapse\", { default: \"Collapse\" })\n : tr(\"controlObject.expand\", { default: \"Expand\" })\n }\n onClick={() => setExpanded((e) => !e)}\n >\n {expanded ? (\n <ChevronDown className=\"size-4\" />\n ) : (\n <ChevronRight className=\"size-4\" />\n )}\n </Button>\n )}\n </div>\n {expanded && isInitialized && <div className=\"mt-3\">{grid}</div>}\n </fieldset>\n );\n};\n"],"mappings":";;;;;;;;;;;AA2EA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM,mBAAmB,IAAI;CACtE,MAAM,EAAE,OAAO,QAAQ;CAEvB,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAID,MAAM,SAAS,EAAE,OAAO,OAAO,MAAM,MAAM,MAAM;CACjD,IAAI,CAAC,EAAE,OAAO,SAAS,MAAM,GAAG,OAAO;CAGvC,MAAM,gBAAgB,SAAS,QAAQ,OAAO,UAAU;CAIxD,MAAM,YACJ,iBACA,CAAC,KAAK,YACN,CAAC,MAAM,YACP,MAAM,cAAc;CAEtB,MAAM,aAAa,OAAO,KAAK,EAAE,OAAO,MAAM,MAAM,CAAC;CACrD,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,qBAAC,UAAD;OAAQ,WAAU;OAAlB,UAAA,CACG,KAAK,OACL,KAAK,YACJ,oBAAC,QAAD;QAAM,WAAU;QAA0B,UAAA;OAAO,CAAA,CAE7C;;MAET,KAAK,eACJ,oBAAC,KAAD;OAAG,WAAU;OACV,UAAA,KAAK;MACL,CAAA;MAEJ,KAAK,SACJ,oBAAC,KAAD;OAAG,WAAU;OACV,UAAA,KAAK;MACL,CAAA;KAEF;;IACJ,iBACC,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,MAAK;KACL,WAAU;KACV,cACE,WACI,GAAG,0BAA0B,EAAE,SAAS,WAAW,CAAC,IACpD,GAAG,wBAAwB,EAAE,SAAS,SAAS,CAAC;KAEtD,eAAe,aAAa,MAAM,CAAC,CAAC;KAEnC,UAAA,WACC,oBAAC,aAAD,EAAa,WAAU,SAAU,CAAA,IAEjC,oBAAC,cAAD,EAAc,WAAU,SAAU,CAAA;IAE9B,CAAA;GAEP;EACJ,CAAA,GAAA,YAAY,iBAAiB,oBAAC,OAAD;GAAK,WAAU;GAAQ,UAAA;EAAU,CAAA,CACvD;;AAEd"}
1
+ {"version":3,"file":"ControlObject.js","names":[],"sources":["../../src/form/ControlObject.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { type ZObject, z } from \"alepha\";\nimport { useAlepha } from \"alepha/react\";\nimport {\n type BaseInputField,\n type ObjectInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { ChevronDown, ChevronRight, Plus, Trash2 } from \"lucide-react\";\nimport { useEffect, useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { Control, type ControlProps } from \"./Control.tsx\";\nimport { childI18nPrefix, resolveFieldI18n } from \"./fieldI18n.ts\";\nimport { spanClass, widthFor } from \"./grid.tsx\";\n\nexport interface ControlObjectProps {\n /**\n * Bound object `InputField` from `useForm`.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the group.\n */\n description?: string;\n /**\n * Number of grid columns. @default 1\n */\n columns?: 1 | 2 | 3 | 4;\n /**\n * \"fieldset\" wraps in a bordered container with legend. \"plain\" renders fields only.\n */\n variant?: \"fieldset\" | \"plain\";\n /**\n * Per-field control props override, keyed by field name.\n */\n controlProps?: Record<string, Partial<Omit<ControlProps, \"input\">>>;\n /**\n * Disable the group and all inner controls.\n */\n disabled?: boolean;\n /**\n * Default expanded state. @default true\n */\n defaultExpanded?: boolean;\n /**\n * Dictionary prefix for this object's children (see `resolveFieldI18n`).\n */\n i18nPrefix?: string;\n /**\n * Take the clear button away from an optional object.\n *\n * The schema decides by default: an optional or nullable object that has\n * been initialised offers the button, and `false` opts out - the same way\n * round as a text field's `clearable`, and for the same reason. Pass\n * `false` when clearing is not something the API can honour, so the button\n * does not promise an edit that silently does nothing.\n *\n * This used to be opt-IN, which made the button unreachable: `Control` is\n * the only thing that mounts this component and it never passed the prop,\n * so an initialised optional object could not be cleared from the UI at\n * all.\n */\n clearable?: boolean;\n}\n\nexport const ControlObject = (props: ControlObjectProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const [expanded, setExpanded] = useState(props.defaultExpanded ?? true);\n const { tr } = useI18n();\n const alepha = useAlepha();\n\n // An error under a collapsed object must be reachable: open it the moment\n // one lands on a field inside, so the field mounts and shows it (and\n // `AutoForm` can bring it into view).\n const formId = props.input?.form?.id;\n const path = props.input?.path;\n useEffect(() => {\n if (!formId || !path) return;\n return alepha.events.on(\"form:errors:changed\", (event) => {\n if (\n event.id === formId &&\n Object.keys(event.errors).some((key) => key.startsWith(`${path}/`))\n ) {\n setExpanded(true);\n }\n });\n }, [alepha, formId, path]);\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n // The field schema may be wrapped (optional/nullable/default); peel to the\n // ZodObject before reading its shape.\n const schema = z.schema.unwrap(props.input.schema) as ZObject;\n if (!z.schema.isObject(schema)) return null;\n\n // ── Init / clear ────────────────────────────────────────────────\n const isInitialized = value != null && typeof value === \"object\";\n\n // `clearable !== false`, not `clearable === true`: the schema is the\n // answer, and a caller opts out. A required object has nothing to clear to.\n const showClear =\n isInitialized &&\n !meta.required &&\n !props.disabled &&\n props.clearable !== false;\n\n const fieldNames = Object.keys(z.schema.shape(schema));\n const nestedItems = (props.input as ObjectInputField<ZObject>).items as\n | Record<string, BaseInputField>\n | undefined;\n\n const grid = (\n <div className=\"grid grid-cols-12 gap-3\">\n {fieldNames.map((name) => {\n const field = nestedItems?.[name];\n if (!field) return null;\n const fieldProps = {\n ...props.controlProps?.[name],\n ...resolveFieldI18n(\n tr,\n props.i18nPrefix,\n name,\n props.controlProps?.[name] ?? {},\n ),\n i18nPrefix: childI18nPrefix(props.i18nPrefix, name),\n };\n const width = widthFor(field, fieldProps.width as number | undefined);\n return (\n <div key={name} className={spanClass(width)}>\n <Control input={field} disabled={props.disabled} {...fieldProps} />\n </div>\n );\n })}\n </div>\n );\n\n if (props.variant === \"plain\") return grid;\n\n return (\n <fieldset\n className={`rounded-md border p-3 ${\n meta.error ? \"border-danger\" : \"border-border\"\n }`}\n >\n <div className=\"flex items-start gap-3\">\n {!isInitialized && !props.disabled ? (\n <Button\n type=\"button\"\n variant=\"outlined\"\n size=\"icon\"\n className=\"size-8 shrink-0\"\n aria-label={tr(\"controlObject.initialize\", {\n default: \"Initialize\",\n })}\n onClick={() => setValue({})}\n >\n <Plus className=\"size-4\" />\n </Button>\n ) : showClear ? (\n <Button\n type=\"button\"\n variant=\"minimal\"\n size=\"icon\"\n className=\"size-8 shrink-0\"\n aria-label={tr(\"controlObject.clear\", { default: \"Clear\" })}\n onClick={() => setValue(undefined)}\n >\n <Trash2 className=\"size-4\" />\n </Button>\n ) : (\n <div className=\"size-8 shrink-0\" />\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n {meta.label && (\n <legend className=\"text-sm leading-tight font-medium\">\n {meta.label}\n {meta.required && (\n <span className=\"text-danger-text ml-0.5\">*</span>\n )}\n </legend>\n )}\n {meta.description && (\n <p className=\"text-muted-foreground text-xs leading-tight\">\n {meta.description}\n </p>\n )}\n {meta.error && (\n <p className=\"text-danger-text text-xs leading-tight\">\n {meta.error}\n </p>\n )}\n </div>\n {isInitialized && (\n <Button\n type=\"button\"\n variant=\"minimal\"\n size=\"icon\"\n className=\"size-8 shrink-0\"\n aria-label={\n expanded\n ? tr(\"controlObject.collapse\", { default: \"Collapse\" })\n : tr(\"controlObject.expand\", { default: \"Expand\" })\n }\n onClick={() => setExpanded((e) => !e)}\n >\n {expanded ? (\n <ChevronDown className=\"size-4\" />\n ) : (\n <ChevronRight className=\"size-4\" />\n )}\n </Button>\n )}\n </div>\n {expanded && isInitialized && <div className=\"mt-3\">{grid}</div>}\n </fieldset>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA4EA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM,mBAAmB,IAAI;CACtE,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,SAAS,UAAU;CAKzB,MAAM,SAAS,MAAM,OAAO,MAAM;CAClC,MAAM,OAAO,MAAM,OAAO;CAC1B,gBAAgB;EACd,IAAI,CAAC,UAAU,CAAC,MAAM;EACtB,OAAO,OAAO,OAAO,GAAG,wBAAwB,UAAU;GACxD,IACE,MAAM,OAAO,UACb,OAAO,KAAK,MAAM,MAAM,CAAC,CAAC,MAAM,QAAQ,IAAI,WAAW,GAAG,KAAK,EAAE,CAAC,GAElE,YAAY,IAAI;EAEpB,CAAC;CACH,GAAG;EAAC;EAAQ;EAAQ;CAAI,CAAC;CAEzB,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAE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AC,CAAC;KAE1B,UAAA,oBAAC,MAAD,EAAM,WAAU,SAAU,CAAA;IACpB,CAAA,IACN,YACF,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,MAAK;KACL,WAAU;KACV,cAAY,GAAG,uBAAuB,EAAE,SAAS,QAAQ,CAAC;KAC1D,eAAe,SAAS,KAAA,CAAS;KAEjC,UAAA,oBAAC,QAAD,EAAQ,WAAU,SAAU,CAAA;IACtB,CAAA,IAER,oBAAC,OAAD,EAAK,WAAU,kBAAmB,CAAA;IAEpC,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA;MACG,KAAK,SACJ,qBAAC,UAAD;OAAQ,WAAU;OAAlB,UAAA,CACG,KAAK,OACL,KAAK,YACJ,oBAAC,QAAD;QAAM,WAAU;QAA0B,UAAA;OAAO,CAAA,CAE7C;;MAET,KAAK,eACJ,oBAAC,KAAD;OAAG,WAAU;OACV,UAAA,KAAK;MACL,CAAA;MAEJ,KAAK,SACJ,oBAAC,KAAD;OAAG,WAAU;OACV,UAAA,KAAK;MACL,CAAA;KAEF;;IACJ,iBACC,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,MAAK;KACL,WAAU;KACV,cACE,WACI,GAAG,0BAA0B,EAAE,SAAS,WAAW,CAAC,IACpD,GAAG,wBAAwB,EAAE,SAAS,SAAS,CAAC;KAEtD,eAAe,aAAa,MAAM,CAAC,CAAC;KAEnC,UAAA,WACC,oBAAC,aAAD,EAAa,WAAU,SAAU,CAAA,IAEjC,oBAAC,cAAD,EAAc,WAAU,SAAU,CAAA;IAE9B,CAAA;GAEP;EACJ,CAAA,GAAA,YAAY,iBAAiB,oBAAC,OAAD;GAAK,WAAU;GAAQ,UAAA;EAAU,CAAA,CACvD;;AAEd"}
@@ -16,6 +16,10 @@ export interface ControlPasswordProps {
16
16
  icon?: IconComponent;
17
17
  value: string;
18
18
  onChange: (v: string) => void;
19
+ /**
20
+ * Called when focus leaves the field.
21
+ */
22
+ onBlur?: () => void;
19
23
  }
20
24
  /**
21
25
  * Masked password field with a reveal toggle.
@@ -1 +1 @@
1
- {"version":3,"file":"ControlPassword.d.ts","sourceRoot":"","sources":["../../src/form/ControlPassword.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AAKtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAAW,oBAAoB,gCA0D1D,CAAC"}
1
+ {"version":3,"file":"ControlPassword.d.ts","sourceRoot":"","sources":["../../src/form/ControlPassword.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AAKtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAAW,oBAAoB,gCA2D1D,CAAC"}
@@ -16,6 +16,7 @@ const ControlPassword = (props) => {
16
16
  const [reveal, setReveal] = useState(false);
17
17
  const Icon = props.icon;
18
18
  return /* @__PURE__ */ jsx(FormField, {
19
+ onBlur: props.onBlur,
19
20
  id: props.id,
20
21
  label: props.label,
21
22
  description: props.description,
@@ -1 +1 @@
1
- {"version":3,"file":"ControlPassword.js","names":[],"sources":["../../src/form/ControlPassword.tsx"],"sourcesContent":["import { Eye, EyeOff } from \"lucide-react\";\nimport { type HTMLAttributes, useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { Input } from \"../core/Input.tsx\";\nimport { FormField, formFieldAriaProps } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlPasswordProps {\n id?: string;\n name?: string;\n label?: string;\n description?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n autoComplete?: string;\n autoFocus?: boolean;\n minLength?: number;\n maxLength?: number;\n inputProps?: HTMLAttributes<HTMLElement>;\n icon?: IconComponent;\n value: string;\n onChange: (v: string) => void;\n}\n\n/**\n * Masked password field with a reveal toggle.\n *\n * Lives outside `Control` so a hand-built form — a dialog that is not driven by\n * a schema — gets the same field the schema path renders, rather than pairing a\n * bare `<Input type=\"password\">` with no way to check what was typed.\n */\nexport const ControlPassword = (props: ControlPasswordProps) => {\n const [reveal, setReveal] = useState(false);\n const Icon = props.icon;\n return (\n <FormField\n id={props.id}\n label={props.label}\n description={props.description}\n error={props.error}\n required={props.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n {...props.inputProps}\n {...formFieldAriaProps({\n id: props.id,\n error: props.error,\n description: props.description,\n })}\n id={props.id}\n name={props.name}\n type={reveal ? \"text\" : \"password\"}\n autoComplete={props.autoComplete ?? \"current-password\"}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- a caller-requested autofocus, see `autoFocus` in form/Control.tsx\n autoFocus={props.autoFocus}\n disabled={props.disabled}\n required={props.required}\n minLength={props.minLength}\n maxLength={props.maxLength}\n value={props.value}\n onChange={(e) => props.onChange(e.target.value)}\n className={[props.inputProps?.className, Icon ? \"pr-9 pl-9\" : \"pr-9\"]\n .filter(Boolean)\n .join(\" \")}\n />\n {/*\n * Centred with `inset-y-0 my-auto`, never `top-1/2 -translate-y-1/2`:\n * Button's press nudge (`active:translate-y-px`) writes the same\n * `--tw-translate-y`, so while pressed `-50%` became `1px` and the\n * button slid down by half its height (#Q2219).\n */}\n <Button\n type=\"button\"\n variant=\"minimal\"\n size=\"icon\"\n disabled={props.disabled}\n onClick={() => setReveal((r) => !r)}\n aria-label={reveal ? \"Hide password\" : \"Show password\"}\n className=\"text-muted-foreground hover:text-foreground absolute inset-y-0 right-1 my-auto size-7\"\n >\n {reveal ? <EyeOff className=\"size-4\" /> : <Eye className=\"size-4\" />}\n </Button>\n </div>\n </FormField>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAiCA,MAAa,mBAAmB,UAAgC;CAC9D,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,OAAO,MAAM;CACnB,OACE,oBAAC,WAAD;EACE,IAAI,MAAM;EACV,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,MAAM;EACb,UAAU,MAAM;EAEhB,UAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG,QACC,oBAAC,MAAD,EAAM,WAAU,4FAA6F,CAAA;IAE/G,oBAAC,OAAD;KACE,GAAI,MAAM;KACV,GAAI,mBAAmB;MACrB,IAAI,MAAM;MACV,OAAO,MAAM;MACb,aAAa,MAAM;KACrB,CAAC;KACD,IAAI,MAAM;KACV,MAAM,MAAM;KACZ,MAAM,SAAS,SAAS;KACxB,cAAc,MAAM,gBAAgB;KAEpC,WAAW,MAAM;KACjB,UAAU,MAAM;KAChB,UAAU,MAAM;KAChB,WAAW,MAAM;KACjB,WAAW,MAAM;KACjB,OAAO,MAAM;KACb,WAAW,MAAM,MAAM,SAAS,EAAE,OAAO,KAAK;KAC9C,WAAW,CAAC,MAAM,YAAY,WAAW,OAAO,cAAc,MAAM,CAAC,CAClE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;IACZ,CAAA;IAOD,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,MAAK;KACL,UAAU,MAAM;KAChB,eAAe,WAAW,MAAM,CAAC,CAAC;KAClC,cAAY,SAAS,kBAAkB;KACvC,WAAU;KAET,UAAA,SAAS,oBAAC,QAAD,EAAQ,WAAU,SAAU,CAAA,IAAI,oBAAC,KAAD,EAAK,WAAU,SAAU,CAAA;IAC7D,CAAA;GACL;;CACI,CAAA;AAEf"}
1
+ {"version":3,"file":"ControlPassword.js","names":[],"sources":["../../src/form/ControlPassword.tsx"],"sourcesContent":["import { Eye, EyeOff } from \"lucide-react\";\nimport { type HTMLAttributes, useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { Input } from \"../core/Input.tsx\";\nimport { FormField, formFieldAriaProps } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlPasswordProps {\n id?: string;\n name?: string;\n label?: string;\n description?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n autoComplete?: string;\n autoFocus?: boolean;\n minLength?: number;\n maxLength?: number;\n inputProps?: HTMLAttributes<HTMLElement>;\n icon?: IconComponent;\n value: string;\n onChange: (v: string) => void;\n /**\n * Called when focus leaves the field.\n */\n onBlur?: () => void;\n}\n\n/**\n * Masked password field with a reveal toggle.\n *\n * Lives outside `Control` so a hand-built form — a dialog that is not driven by\n * a schema — gets the same field the schema path renders, rather than pairing a\n * bare `<Input type=\"password\">` with no way to check what was typed.\n */\nexport const ControlPassword = (props: ControlPasswordProps) => {\n const [reveal, setReveal] = useState(false);\n const Icon = props.icon;\n return (\n <FormField\n onBlur={props.onBlur}\n id={props.id}\n label={props.label}\n description={props.description}\n error={props.error}\n required={props.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n {...props.inputProps}\n {...formFieldAriaProps({\n id: props.id,\n error: props.error,\n description: props.description,\n })}\n id={props.id}\n name={props.name}\n type={reveal ? \"text\" : \"password\"}\n autoComplete={props.autoComplete ?? \"current-password\"}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- a caller-requested autofocus, see `autoFocus` in form/Control.tsx\n autoFocus={props.autoFocus}\n disabled={props.disabled}\n required={props.required}\n minLength={props.minLength}\n maxLength={props.maxLength}\n value={props.value}\n onChange={(e) => props.onChange(e.target.value)}\n className={[props.inputProps?.className, Icon ? \"pr-9 pl-9\" : \"pr-9\"]\n .filter(Boolean)\n .join(\" \")}\n />\n {/*\n * Centred with `inset-y-0 my-auto`, never `top-1/2 -translate-y-1/2`:\n * Button's press nudge (`active:translate-y-px`) writes the same\n * `--tw-translate-y`, so while pressed `-50%` became `1px` and the\n * button slid down by half its height (#Q2219).\n */}\n <Button\n type=\"button\"\n variant=\"minimal\"\n size=\"icon\"\n disabled={props.disabled}\n onClick={() => setReveal((r) => !r)}\n aria-label={reveal ? \"Hide password\" : \"Show password\"}\n className=\"text-muted-foreground hover:text-foreground absolute inset-y-0 right-1 my-auto size-7\"\n >\n {reveal ? <EyeOff className=\"size-4\" /> : <Eye className=\"size-4\" />}\n </Button>\n </div>\n </FormField>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAa,mBAAmB,UAAgC;CAC9D,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,OAAO,MAAM;CACnB,OACE,oBAAC,WAAD;EACE,QAAQ,MAAM;EACd,IAAI,MAAM;EACV,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,MAAM;EACb,UAAU,MAAM;EAEhB,UAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG,QACC,oBAAC,MAAD,EAAM,WAAU,4FAA6F,CAAA;IAE/G,oBAAC,OAAD;KACE,GAAI,MAAM;KACV,GAAI,mBAAmB;MACrB,IAAI,MAAM;MACV,OAAO,MAAM;MACb,aAAa,MAAM;KACrB,CAAC;KACD,IAAI,MAAM;KACV,MAAM,MAAM;KACZ,MAAM,SAAS,SAAS;KACxB,cAAc,MAAM,gBAAgB;KAEpC,WAAW,MAAM;KACjB,UAAU,MAAM;KAChB,UAAU,MAAM;KAChB,WAAW,MAAM;KACjB,WAAW,MAAM;KACjB,OAAO,MAAM;KACb,WAAW,MAAM,MAAM,SAAS,EAAE,OAAO,KAAK;KAC9C,WAAW,CAAC,MAAM,YAAY,WAAW,OAAO,cAAc,MAAM,CAAC,CAClE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;IACZ,CAAA;IAOD,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,MAAK;KACL,UAAU,MAAM;KAChB,eAAe,WAAW,MAAM,CAAC,CAAC;KAClC,cAAY,SAAS,kBAAkB;KACvC,WAAU;KAET,UAAA,SAAS,oBAAC,QAAD,EAAQ,WAAU,SAAU,CAAA,IAAI,oBAAC,KAAD,EAAK,WAAU,SAAU,CAAA;IAC7D,CAAA;GACL;;CACI,CAAA;AAEf"}
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import type { Async } from "alepha";
3
3
  import { type BaseInputField } from "alepha/react/form";
4
4
  import type { HTMLAttributes } from "react";
5
- import { type ReactNode } from "react";
5
+ import { type ReactElement, type ReactNode } from "react";
6
6
  import type { ControlTriggerSize } from "./fieldTrigger.tsx";
7
7
  import type { IconComponent } from "./iconHint.tsx";
8
8
  export interface ControlSelectProps {
@@ -185,6 +185,28 @@ export interface ControlSelectProps {
185
185
  * floor (`w-max min-w-48`) sizes it from its own content instead.
186
186
  */
187
187
  popupClassName?: string;
188
+ /**
189
+ * An element drawn INSTEAD of the field: it becomes the button that opens
190
+ * the popup, rendered as written, with none of the field's own icon,
191
+ * label, caret or clear button. For a list opened from somewhere that is
192
+ * not a form, such as the funnel in a table column's header.
193
+ *
194
+ * Pass a `<button>`. Its children are kept; its click and its ARIA state
195
+ * are the popup's. The popup is anchored to it, so give `popupClassName`
196
+ * a width (`w-max min-w-48`): it would otherwise be as narrow as an icon.
197
+ *
198
+ * ⚠️ Only the combobox shape has a popup, so a segmented or checkbox
199
+ * rendering of the same field ignores it.
200
+ */
201
+ trigger?: ReactElement<{
202
+ children?: ReactNode;
203
+ }>;
204
+ /**
205
+ * The popup opened or closed. For a caller that acts on the reader's
206
+ * choice once they are done with the list, such as a table header that
207
+ * takes an emptied filter off the bar. The combobox shape only.
208
+ */
209
+ onPopupOpenChange?: (open: boolean) => void;
188
210
  }
189
211
  export declare const ControlSelect: (props: ControlSelectProps) => React.JSX.Element | null;
190
212
  export type SelectOption = string | {
@@ -1 +1 @@
1
- {"version":3,"file":"ControlSelect.d.ts","sourceRoot":"","sources":["../../src/form/ControlSelect.tsx"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,MAAM,aAAa,UAAW,kBAAkB,6BA4QtD,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,MAAM,GACN;IACE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAIN;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC"}
@@ -67,6 +67,7 @@ const ControlSelect = (props) => {
67
67
  return raw;
68
68
  };
69
69
  if (props.segmented) return /* @__PURE__ */ jsx(FormField, {
70
+ onBlur: () => props.input.form?.blur(props.input.path),
70
71
  id: meta.id,
71
72
  label: meta.label,
72
73
  description: meta.description,
@@ -86,6 +87,7 @@ const ControlSelect = (props) => {
86
87
  if (props.checkboxes && isArray) {
87
88
  const ticked = Array.isArray(value) ? value.map(String) : [];
88
89
  return /* @__PURE__ */ jsx(FormField, {
90
+ onBlur: () => props.input.form?.blur(props.input.path),
89
91
  id: meta.id,
90
92
  label: meta.label,
91
93
  description: meta.description,
@@ -122,6 +124,7 @@ const ControlSelect = (props) => {
122
124
  const clearLabel = props.clearLabel ?? tr("controlSelect.none", { default: "None" });
123
125
  const searchable = props.searchable ?? (props.combobox || mode === "long" || Boolean(props.createNewEntry) || data.length > SEARCH_THRESHOLD);
124
126
  return /* @__PURE__ */ jsx(FormField, {
127
+ onBlur: () => props.input.form?.blur(props.input.path),
125
128
  id: meta.id,
126
129
  label: meta.label,
127
130
  description: meta.description,
@@ -151,6 +154,8 @@ const ControlSelect = (props) => {
151
154
  popupHeader: props.popupHeader,
152
155
  triggerPrefix: props.triggerPrefix,
153
156
  popupClassName: props.popupClassName,
157
+ trigger: props.trigger,
158
+ onPopupOpenChange: props.onPopupOpenChange,
154
159
  deselectable: props.clearable || !meta.required,
155
160
  placeholder: props.placeholder ?? (props.clearable || isArray ? clearLabel : void 0)
156
161
  })
@@ -1 +1 @@
1
- {"version":3,"file":"ControlSelect.js","names":[],"sources":["../../src/form/ControlSelect.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { Async } from \"alepha\";\nimport { useAction } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport type { HTMLAttributes } from \"react\";\nimport { type ReactNode, useMemo, useRef, useState } from \"react\";\n\nimport { Checkbox } from \"../core/Checkbox.tsx\";\nimport { Segmented } from \"../core/Segmented.tsx\";\nimport { ControlSelectCombobox } from \"./ControlSelectCombobox.tsx\";\nimport { optValue } from \"./controlSelectOptions.ts\";\nimport type { ControlTriggerSize } from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectProps {\n /**\n * Bound `InputField` from `useForm`. Single or multi value depending on schema.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a `<Segmented>` control (best for 2–4 options).\n */\n segmented?: boolean;\n /**\n * Render a multi-choice field (an array schema) as a group of checkboxes,\n * every option visible: for a handful of fixed choices (days of the week,\n * device types), where a select would hide what is ticked. Each checkbox\n * is named by its option's label and carries `data-value`.\n */\n checkboxes?: boolean;\n /**\n * Force the search input on. Kept as the historical name for\n * `searchable: true` — every select is a combobox now, the flag only\n * decides whether it carries a search field.\n */\n combobox?: boolean;\n /**\n * Whether the dropdown carries a search input. Defaults to \"auto\": on for a\n * long-mode `loader` (the rows are not all here), when `createNewEntry` is\n * set (typing IS how an entry is made), and for lists longer than\n * `SEARCH_THRESHOLD`. Set explicitly to search a short list or to drop the\n * search field from a long one.\n *\n * Multi-select obeys the same rule as everything else; it used to force the\n * field on because its chips box doubled as the search input.\n */\n searchable?: boolean;\n /**\n * Async option loader. Triggers long-mode (server-side search) above `loaderThreshold` options.\n */\n loader?: (search: string, resolve?: string[]) => Async<SelectOption[]>;\n /**\n * Option count above which `loader` is invoked on every search instead of once. Defaults to 100.\n */\n loaderThreshold?: number;\n /**\n * Debounce in ms applied to search queries when calling `loader` in long mode.\n */\n loaderDebounce?: number;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Inline option list (overrides schema `enum`). Accepts either a static\n * array or an async function `(query) => SelectOption[]`. The async form\n * is mapped to a long-mode loader.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Allow the user to add a new option by typing. When `true`, the typed\n * query becomes the value (and label) of a freshly created entry. When a\n * function, the function builds the option from the query.\n *\n * - For multi-select fields: each entry is appended to the value array.\n * - For single fields: behaves like a regular text input with a dropdown\n * suggesting existing options.\n */\n createNewEntry?: boolean | ((query: string) => Exclude<SelectOption, string>);\n /**\n * When true, the dropdown gets a synthetic \"none\" row at the top that\n * resets the field to `undefined`. Useful for optional filter chips\n * (e.g. an admin-table status filter) where the user needs an explicit\n * \"no filter\" option — Base UI's `Select` reserves empty-string values\n * as its internal no-selection sentinel, so a regular `<SelectItem\n * value=\"\">` can't be picked. With `clearable`, ControlSelect uses an\n * internal sentinel and translates it to `undefined` in `onChange`.\n *\n * Currently honored by the static-short `Select` and the searchable\n * Combobox render paths. Ignored by `segmented` (use a real segment\n * for \"all\" there).\n */\n clearable?: boolean;\n /**\n * Label rendered for the \"clear\" row injected by `clearable`. Also\n * used as the trigger placeholder when the field is empty. Defaults to\n * `\"None\"`. Localize at the call site (e.g. `\"All types\"`,\n * `\"All status\"`).\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * The longest joined text, in characters, a multi-select trigger names its\n * selection with (\"Draft, Ready\") before it collapses to `countLabel`.\n * Defaults to 20, which suits a filter chip; a full-width form field has\n * room for more.\n */\n maxTriggerLength?: number;\n /**\n * Trigger text when nothing is selected, e.g. \"Pick an epic…\". Defaults to\n * the `clearLabel` on a `clearable` or multi field (where empty IS a\n * meaningful state to name), and to \"Select…\" otherwise.\n *\n * Set it when the empty trigger has a job to do - a picker whose whole\n * purpose is the choice it prompts for reads as a dead \"Select…\" without\n * it, which is why the surfaces that needed one stayed on the raw `Select`.\n */\n placeholder?: string;\n /**\n * Extra className applied to the visible trigger: the combobox button or\n * the segmented control, whichever this field renders. Useful for sizing\n * filter chips (`\"w-40\"`, `\"w-72\"`, etc.) without wrapping the whole\n * `FormField` in an extra div.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n /**\n * Extra attributes for whichever trigger this field renders, forwarded from\n * `Control`'s `inputProps`.\n *\n * The accessible name usually lives here, because a filter is routinely\n * rendered with `label=\"\"` next to its own heading: with no `<label>` to\n * borrow a name from, a `role=combobox` button or a radiogroup has no name\n * at all. That is both an a11y hole and unaddressable from a\n * test, and it was silent, since `Control` accepted `inputProps` and then\n * dropped it on every select-shaped branch.\n */\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Leading icon rendered on the left of the trigger, matching the\n * text-input controls. Resolved by the parent `Control` from its `icon`\n * prop, falling back to the list glyph like a text input falls back to\n * its schema hint; `icon={null}` on the `Control` removes it, and a\n * `minimal` trigger gets none by default.\n */\n icon?: IconComponent;\n /**\n * Drawn at the top of the popup, above the options - for a setting that\n * changes what the choice MEANS rather than what is chosen, such as a\n * filter's \"is / is not\".\n *\n * ⚠️ Only the combobox shape has a popup, so a segmented or radio rendering\n * of the same field draws nothing for it.\n */\n popupHeader?: ReactNode;\n /**\n * Drawn on the trigger just before the selected label, after the icon: the\n * short word that keeps a qualified value from reading as a plain one\n * (\"not Active\"). Absent while nothing is selected, because a qualifier on\n * a placeholder has nothing to qualify.\n */\n triggerPrefix?: ReactNode;\n /**\n * Extra className on the popup, merged over its own.\n *\n * The popup is sized from its trigger by default (`--anchor-width`), and it\n * keeps following that width while open. A trigger whose text changes as\n * the reader picks - a `triggerPrefix` appearing, \"2 values\" replacing a\n * name - therefore resizes the popup under their cursor. `w-max` with a\n * floor (`w-max min-w-48`) sizes it from its own content instead.\n */\n popupClassName?: string;\n}\n\nexport const ControlSelect = (props: ControlSelectProps) => {\n const { tr } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isArray = meta.isArray;\n const isNumeric = meta.type === \"number\" || meta.type === \"integer\";\n const isBoolean = meta.type === \"boolean\";\n\n // Normalize items prop: array → static; function → loader\n const itemsArray = Array.isArray(props.items)\n ? (props.items as SelectOption[])\n : undefined;\n const itemsLoader =\n typeof props.items === \"function\"\n ? (props.items as (q: string) => Async<SelectOption[]>)\n : undefined;\n\n const enumValues =\n itemsArray ?? (meta.enum as SelectOption[] | undefined) ?? [];\n\n const effectiveLoader = props.loader ?? itemsLoader;\n\n const {\n data: asyncData,\n loading,\n mode,\n search,\n } = useAsyncLoader(\n effectiveLoader,\n props.loaderThreshold ?? 100,\n props.loaderDebounce ?? 300,\n props.input.initialValue,\n );\n\n // Labels and `disabled` flags are part of the identity: keying on the\n // joined values alone collided (`[\"ab\",\"c\"]` vs `[\"a\",\"bc\"]`) and kept a\n // stale list when only the labels changed.\n //\n // ⚠️ `icon` is EXCLUDED, and it has to be. It is a `ReactNode`, and a\n // rendered element holds a fiber that points back at its DOM node, so\n // `JSON.stringify` on the raw option threw \"Converting circular structure\n // to JSON\" - a documented prop that crashed the component the first time\n // anyone used it (#Q2049). Two lists that differ only by icon share a key,\n // which is right: the key exists to notice a changed VALUE or LABEL.\n const enumKey = JSON.stringify(\n enumValues.map((option) =>\n typeof option === \"string\"\n ? option\n : {\n value: option.value,\n label: option.label,\n description: option.description,\n tag: option.tag,\n disabled: option.disabled,\n },\n ),\n );\n const min = meta.constraints.minimum;\n const max = meta.constraints.maximum;\n // Derived, not stored: this is a pure function of the schema. As state\n // filled in by an effect, the first paint of every boolean or ranged select\n // was an EMPTY list, corrected one render later.\n const staticData = useMemo<SelectOption[]>(() => {\n if (effectiveLoader) return [];\n if (isBoolean && enumValues.length === 0) {\n return [\n { value: \"true\", label: tr(\"controlSelect.yes\", { default: \"Yes\" }) },\n { value: \"false\", label: tr(\"controlSelect.no\", { default: \"No\" }) },\n ];\n }\n if (\n isNumeric &&\n enumValues.length === 0 &&\n typeof min === \"number\" &&\n typeof max === \"number\" &&\n max - min <= 20\n ) {\n const range: SelectOption[] = [];\n for (let i = min; i <= max; i++) range.push(String(i));\n return range;\n }\n return enumValues;\n }, [effectiveLoader, enumKey, isBoolean, isNumeric, min, max, tr]);\n\n const data = effectiveLoader ? asyncData : staticData;\n\n if (!props.input?.props) return null;\n\n const coerce = (raw: string): unknown => {\n if (isNumeric) return Number(raw);\n if (isBoolean) return raw === \"true\";\n return raw;\n };\n\n if (props.segmented) {\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n {/* `triggerProps` is deliberately NOT spread here. `Segmented`\n redeclares two attributes that `HTMLAttributes` also has, with\n narrower types (`defaultValue` is string-only, `onChange` takes a\n value rather than an event), so a blanket spread neither typechecks\n nor is safe. A segmented field also renders every option as visible\n text, so it is the one branch that is not nameless without a label.\n Name it with `label` if it needs one. */}\n <Segmented\n value={value != null ? String(value) : undefined}\n onChange={(v) => setValue(coerce(v))}\n disabled={props.disabled}\n options={data.slice(0, 10).map((o) => ({\n value: optValue(o),\n label: segmentedLabel(o),\n }))}\n fullWidth\n />\n </FormField>\n );\n }\n\n if (props.checkboxes && isArray) {\n const ticked = Array.isArray(value) ? (value as unknown[]).map(String) : [];\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div\n role=\"group\"\n aria-label={meta.label || undefined}\n {...props.triggerProps}\n id={meta.id}\n className=\"flex flex-wrap gap-x-4 gap-y-2 py-1\"\n >\n {data.map((o) => {\n const optionValue = optValue(o);\n const optionId = `${meta.id}-${optionValue}`;\n return (\n <label\n key={optionValue}\n htmlFor={optionId}\n className=\"flex items-center gap-2 text-sm\"\n >\n <Checkbox\n // An explicit id: Base UI would mint one with `useId`.\n id={optionId}\n data-value={optionValue}\n disabled={\n props.disabled || (typeof o !== \"string\" && o.disabled)\n }\n checked={ticked.includes(optionValue)}\n onCheckedChange={(checked) => {\n const next = checked\n ? [...ticked, optionValue]\n : ticked.filter((it) => it !== optionValue);\n // In the options' order, whatever order they were ticked.\n const ordered = data\n .map(optValue)\n .filter((it) => next.includes(it));\n setValue(ordered.map(coerce));\n }}\n />\n {segmentedLabel(o)}\n </label>\n );\n })}\n </div>\n </FormField>\n );\n }\n\n const clearLabel =\n props.clearLabel ?? tr(\"controlSelect.none\", { default: \"None\" });\n\n // One control for every list. The option count decides whether the popup\n // carries a search field — it no longer decides which primitive renders.\n // The native `Select` path this replaced silently dropped `description`,\n // `tag`, per-option `disabled` and `deselectable`, and styled its trigger\n // differently, purely because a list happened to be short.\n // A search field is offered only when scanning the list by eye stops being\n // realistic: a server-driven list (whose rows are not all here), one past\n // `SEARCH_THRESHOLD`, or one where typing is how a new entry is made.\n //\n // Multi-select used to force it on unconditionally, because the chips box\n // WAS the search input and there was no other way to open the popup. The\n // trigger is a button now, so multi obeys the same rule as everything else\n // and a four-row status filter no longer opens onto a search field.\n const searchable =\n props.searchable ??\n (props.combobox ||\n mode === \"long\" ||\n Boolean(props.createNewEntry) ||\n data.length > SEARCH_THRESHOLD);\n\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlSelectCombobox\n id={meta.id}\n data={data}\n loading={loading}\n multi={isArray}\n searchable={searchable}\n disabled={props.disabled}\n value={value}\n onChange={(v) => setValue(v)}\n coerce={coerce}\n onSearch={mode === \"long\" ? (text) => search.run(text) : undefined}\n createNewEntry={props.createNewEntry}\n icon={props.icon}\n // Used to be dropped on this path, so a filter chip sized `w-40` lost\n // its width as soon as its list crossed the threshold.\n triggerClassName={props.triggerClassName}\n triggerProps={props.triggerProps}\n size={props.size}\n minimal={props.minimal}\n // `clearable` used to reach this path as a placeholder and nothing\n // else, so a filter chip that had switched to the combobox (>20\n // options) could be set but never put back to \"All …\".\n clearable={props.clearable}\n clearLabel={clearLabel}\n countLabel={props.countLabel}\n maxTriggerLength={props.maxTriggerLength}\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={props.popupClassName}\n // An optional field must also be able to go back to empty without a\n // dedicated row: Base UI never emits `null`, so re-pressing the\n // selected row deselects (see `handleSingle` in\n // `ControlSelectCombobox.tsx`). A required field keeps its value —\n // clearing it would only produce a validation error the user cannot\n // see yet.\n deselectable={props.clearable || !meta.required}\n // Multi shows this muted when nothing is picked, so it reaches the\n // trigger whether or not the field is `clearable` — a multi-select\n // has no clear ROW (it clears by deselecting), and without this its\n // empty trigger fell back to a bare \"Select…\".\n placeholder={\n props.placeholder ??\n (props.clearable || isArray ? clearLabel : undefined)\n }\n />\n </FormField>\n );\n};\n\nexport type SelectOption =\n | string\n | {\n value: string;\n label: string;\n /**\n * Optional secondary line shown under the label in the dropdown.\n */\n description?: string;\n /**\n * Optional small badge rendered next to the label.\n */\n tag?: string;\n /**\n * Optional icon/element rendered before the label, in both the\n * dropdown row and (for single-select) the trigger when selected.\n */\n icon?: ReactNode;\n /**\n * When true, the row is non-interactive — can't be selected if\n * not selected, can't be deselected if selected. Useful for\n * default/mandatory entries (e.g. the base \"user\" role).\n */\n disabled?: boolean;\n };\n\ntype LoaderMode = \"static\" | \"short\" | \"long\";\n\n/**\n * How tall and how loud a select trigger is.\n *\n * The kit's own scale, kept under this name because `Control` and a long tail\n * of callers already spell it `size=\"xs\"` on a select. The table behind it,\n * and the trigger box it sizes, are `control-base/field-trigger`'s - shared\n * with the two calendar controls, which used to draw a button instead.\n */\nexport type ControlSelectSize = ControlTriggerSize;\n\n/**\n * Static option count above which the dropdown grows a search input. Below it\n * the very same combobox renders without one — the threshold decides whether\n * you can type, never which control you get.\n */\n// Past this many rows, scanning by eye stops being realistic and the popup\n// grows a search field. Raised 20 -> 50 with the multi-select rework: the old\n// value put a search box on lists a reader takes in at a glance.\nconst SEARCH_THRESHOLD = 50;\n\n/**\n * Friendly label for plain string options: \"optional\" → \"Optional\",\n * \"in_progress\" → \"In Progress\". Custom `{ value, label }` items pass through\n * untouched.\n */\nconst titlecase = (s: string) =>\n s.replace(/[_-]+/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase());\n/**\n * What one segment shows.\n *\n * ⚠️ The option's `icon` is rendered HERE rather than dropped, which is what\n * this path did until #Q2049. `SegmentedOption.label` is a `ReactNode`, so\n * there was never a reason for it: an option list carrying icons for the\n * dropdown carried them for the segments too, and dropping them silently\n * made a caller choose between two shapes for one list.\n */\nconst segmentedLabel = (o: SelectOption): ReactNode => {\n if (typeof o === \"string\") {\n return titlecase(o);\n }\n if (!o.icon) {\n return o.label;\n }\n return (\n <span className=\"inline-flex items-center gap-1.5\">\n {o.icon}\n {o.label}\n </span>\n );\n};\n\nconst useAsyncLoader = (\n loader: ControlSelectProps[\"loader\"],\n threshold: number,\n debounceMs: number,\n defaultValue: unknown,\n) => {\n const [data, setData] = useState<SelectOption[]>([]);\n const [loading, setLoading] = useState(false);\n const [mode, setMode] = useState<LoaderMode>(\"static\");\n const cache = useRef(new Map<string, SelectOption[]>());\n\n useAction(\n {\n // `id`, not `name`: `id` is what useAction threads into its\n // react:action:* events. `name` was accepted and never read, so this\n // identifier reached nothing.\n id: \"select:loader:init\",\n runOnInit: true,\n handler: async () => {\n if (!loader) {\n setMode(\"static\");\n return;\n }\n setLoading(true);\n try {\n const result = await loader(\"\");\n const isShort = result.length <= threshold;\n setMode(isShort ? \"short\" : \"long\");\n cache.current.set(\"\", result);\n setData(result);\n\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n if (!isShort && defaultValue != null && String(defaultValue) !== \"\") {\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n const resolved = await loader(\"\", [String(defaultValue)]);\n if (resolved.length > 0) {\n setData((prev) => {\n const existing = new Set(prev.map(optValue));\n const fresh = resolved.filter(\n (r) => !existing.has(optValue(r)),\n );\n return [...prev, ...fresh];\n });\n }\n }\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, threshold],\n );\n\n const search = useAction<[string]>(\n {\n debounce: debounceMs,\n handler: async (_ctx, text) => {\n if (!loader || mode !== \"long\") return;\n if (cache.current.has(text)) {\n setData(cache.current.get(text)!);\n return;\n }\n setLoading(true);\n try {\n const result = await loader(text);\n cache.current.set(text, result);\n setData(result);\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, mode, debounceMs],\n );\n\n return { data, loading, mode, search };\n};\n"],"mappings":";;;;;;;;;;;AAgNA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAEnD,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,UAAU,KAAK;CACrB,MAAM,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SAAS,QAAQ;IAChC,IAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;KAC3B,QAAQ,MAAM,QAAQ,IAAI,IAAI,CAAE;KAChC;IACF;IACA,WAAW,IAAI;IACf,IAAI;KACF,MAAM,SAAS,MAAM,OAAO,IAAI;KAChC,MAAM,QAAQ,IAAI,MAAM,MAAM;KAC9B,QAAQ,MAAM;IAChB,UAAU;KACR,WAAW,KAAK;IAClB;GACF;EACF,GACA;GAAC;GAAQ;GAAM;EAAU,CAGQ;CAAE;AACvC"}
1
+ {"version":3,"file":"ControlSelect.js","names":[],"sources":["../../src/form/ControlSelect.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { Async } from \"alepha\";\nimport { useAction } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport type { HTMLAttributes } from \"react\";\nimport {\n type ReactElement,\n type ReactNode,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { Checkbox } from \"../core/Checkbox.tsx\";\nimport { Segmented } from \"../core/Segmented.tsx\";\nimport { ControlSelectCombobox } from \"./ControlSelectCombobox.tsx\";\nimport { optValue } from \"./controlSelectOptions.ts\";\nimport type { ControlTriggerSize } from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectProps {\n /**\n * Bound `InputField` from `useForm`. Single or multi value depending on schema.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a `<Segmented>` control (best for 2–4 options).\n */\n segmented?: boolean;\n /**\n * Render a multi-choice field (an array schema) as a group of checkboxes,\n * every option visible: for a handful of fixed choices (days of the week,\n * device types), where a select would hide what is ticked. Each checkbox\n * is named by its option's label and carries `data-value`.\n */\n checkboxes?: boolean;\n /**\n * Force the search input on. Kept as the historical name for\n * `searchable: true` — every select is a combobox now, the flag only\n * decides whether it carries a search field.\n */\n combobox?: boolean;\n /**\n * Whether the dropdown carries a search input. Defaults to \"auto\": on for a\n * long-mode `loader` (the rows are not all here), when `createNewEntry` is\n * set (typing IS how an entry is made), and for lists longer than\n * `SEARCH_THRESHOLD`. Set explicitly to search a short list or to drop the\n * search field from a long one.\n *\n * Multi-select obeys the same rule as everything else; it used to force the\n * field on because its chips box doubled as the search input.\n */\n searchable?: boolean;\n /**\n * Async option loader. Triggers long-mode (server-side search) above `loaderThreshold` options.\n */\n loader?: (search: string, resolve?: string[]) => Async<SelectOption[]>;\n /**\n * Option count above which `loader` is invoked on every search instead of once. Defaults to 100.\n */\n loaderThreshold?: number;\n /**\n * Debounce in ms applied to search queries when calling `loader` in long mode.\n */\n loaderDebounce?: number;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Inline option list (overrides schema `enum`). Accepts either a static\n * array or an async function `(query) => SelectOption[]`. The async form\n * is mapped to a long-mode loader.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Allow the user to add a new option by typing. When `true`, the typed\n * query becomes the value (and label) of a freshly created entry. When a\n * function, the function builds the option from the query.\n *\n * - For multi-select fields: each entry is appended to the value array.\n * - For single fields: behaves like a regular text input with a dropdown\n * suggesting existing options.\n */\n createNewEntry?: boolean | ((query: string) => Exclude<SelectOption, string>);\n /**\n * When true, the dropdown gets a synthetic \"none\" row at the top that\n * resets the field to `undefined`. Useful for optional filter chips\n * (e.g. an admin-table status filter) where the user needs an explicit\n * \"no filter\" option — Base UI's `Select` reserves empty-string values\n * as its internal no-selection sentinel, so a regular `<SelectItem\n * value=\"\">` can't be picked. With `clearable`, ControlSelect uses an\n * internal sentinel and translates it to `undefined` in `onChange`.\n *\n * Currently honored by the static-short `Select` and the searchable\n * Combobox render paths. Ignored by `segmented` (use a real segment\n * for \"all\" there).\n */\n clearable?: boolean;\n /**\n * Label rendered for the \"clear\" row injected by `clearable`. Also\n * used as the trigger placeholder when the field is empty. Defaults to\n * `\"None\"`. Localize at the call site (e.g. `\"All types\"`,\n * `\"All status\"`).\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * The longest joined text, in characters, a multi-select trigger names its\n * selection with (\"Draft, Ready\") before it collapses to `countLabel`.\n * Defaults to 20, which suits a filter chip; a full-width form field has\n * room for more.\n */\n maxTriggerLength?: number;\n /**\n * Trigger text when nothing is selected, e.g. \"Pick an epic…\". Defaults to\n * the `clearLabel` on a `clearable` or multi field (where empty IS a\n * meaningful state to name), and to \"Select…\" otherwise.\n *\n * Set it when the empty trigger has a job to do - a picker whose whole\n * purpose is the choice it prompts for reads as a dead \"Select…\" without\n * it, which is why the surfaces that needed one stayed on the raw `Select`.\n */\n placeholder?: string;\n /**\n * Extra className applied to the visible trigger: the combobox button or\n * the segmented control, whichever this field renders. Useful for sizing\n * filter chips (`\"w-40\"`, `\"w-72\"`, etc.) without wrapping the whole\n * `FormField` in an extra div.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n /**\n * Extra attributes for whichever trigger this field renders, forwarded from\n * `Control`'s `inputProps`.\n *\n * The accessible name usually lives here, because a filter is routinely\n * rendered with `label=\"\"` next to its own heading: with no `<label>` to\n * borrow a name from, a `role=combobox` button or a radiogroup has no name\n * at all. That is both an a11y hole and unaddressable from a\n * test, and it was silent, since `Control` accepted `inputProps` and then\n * dropped it on every select-shaped branch.\n */\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Leading icon rendered on the left of the trigger, matching the\n * text-input controls. Resolved by the parent `Control` from its `icon`\n * prop, falling back to the list glyph like a text input falls back to\n * its schema hint; `icon={null}` on the `Control` removes it, and a\n * `minimal` trigger gets none by default.\n */\n icon?: IconComponent;\n /**\n * Drawn at the top of the popup, above the options - for a setting that\n * changes what the choice MEANS rather than what is chosen, such as a\n * filter's \"is / is not\".\n *\n * ⚠️ Only the combobox shape has a popup, so a segmented or radio rendering\n * of the same field draws nothing for it.\n */\n popupHeader?: ReactNode;\n /**\n * Drawn on the trigger just before the selected label, after the icon: the\n * short word that keeps a qualified value from reading as a plain one\n * (\"not Active\"). Absent while nothing is selected, because a qualifier on\n * a placeholder has nothing to qualify.\n */\n triggerPrefix?: ReactNode;\n /**\n * Extra className on the popup, merged over its own.\n *\n * The popup is sized from its trigger by default (`--anchor-width`), and it\n * keeps following that width while open. A trigger whose text changes as\n * the reader picks - a `triggerPrefix` appearing, \"2 values\" replacing a\n * name - therefore resizes the popup under their cursor. `w-max` with a\n * floor (`w-max min-w-48`) sizes it from its own content instead.\n */\n popupClassName?: string;\n /**\n * An element drawn INSTEAD of the field: it becomes the button that opens\n * the popup, rendered as written, with none of the field's own icon,\n * label, caret or clear button. For a list opened from somewhere that is\n * not a form, such as the funnel in a table column's header.\n *\n * Pass a `<button>`. Its children are kept; its click and its ARIA state\n * are the popup's. The popup is anchored to it, so give `popupClassName`\n * a width (`w-max min-w-48`): it would otherwise be as narrow as an icon.\n *\n * ⚠️ Only the combobox shape has a popup, so a segmented or checkbox\n * rendering of the same field ignores it.\n */\n trigger?: ReactElement<{ children?: ReactNode }>;\n /**\n * The popup opened or closed. For a caller that acts on the reader's\n * choice once they are done with the list, such as a table header that\n * takes an emptied filter off the bar. The combobox shape only.\n */\n onPopupOpenChange?: (open: boolean) => void;\n}\n\nexport const ControlSelect = (props: ControlSelectProps) => {\n const { tr } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isArray = meta.isArray;\n const isNumeric = meta.type === \"number\" || meta.type === \"integer\";\n const isBoolean = meta.type === \"boolean\";\n\n // Normalize items prop: array → static; function → loader\n const itemsArray = Array.isArray(props.items)\n ? (props.items as SelectOption[])\n : undefined;\n const itemsLoader =\n typeof props.items === \"function\"\n ? (props.items as (q: string) => Async<SelectOption[]>)\n : undefined;\n\n const enumValues =\n itemsArray ?? (meta.enum as SelectOption[] | undefined) ?? [];\n\n const effectiveLoader = props.loader ?? itemsLoader;\n\n const {\n data: asyncData,\n loading,\n mode,\n search,\n } = useAsyncLoader(\n effectiveLoader,\n props.loaderThreshold ?? 100,\n props.loaderDebounce ?? 300,\n props.input.initialValue,\n );\n\n // Labels and `disabled` flags are part of the identity: keying on the\n // joined values alone collided (`[\"ab\",\"c\"]` vs `[\"a\",\"bc\"]`) and kept a\n // stale list when only the labels changed.\n //\n // ⚠️ `icon` is EXCLUDED, and it has to be. It is a `ReactNode`, and a\n // rendered element holds a fiber that points back at its DOM node, so\n // `JSON.stringify` on the raw option threw \"Converting circular structure\n // to JSON\" - a documented prop that crashed the component the first time\n // anyone used it (#Q2049). Two lists that differ only by icon share a key,\n // which is right: the key exists to notice a changed VALUE or LABEL.\n const enumKey = JSON.stringify(\n enumValues.map((option) =>\n typeof option === \"string\"\n ? option\n : {\n value: option.value,\n label: option.label,\n description: option.description,\n tag: option.tag,\n disabled: option.disabled,\n },\n ),\n );\n const min = meta.constraints.minimum;\n const max = meta.constraints.maximum;\n // Derived, not stored: this is a pure function of the schema. As state\n // filled in by an effect, the first paint of every boolean or ranged select\n // was an EMPTY list, corrected one render later.\n const staticData = useMemo<SelectOption[]>(() => {\n if (effectiveLoader) return [];\n if (isBoolean && enumValues.length === 0) {\n return [\n { value: \"true\", label: tr(\"controlSelect.yes\", { default: \"Yes\" }) },\n { value: \"false\", label: tr(\"controlSelect.no\", { default: \"No\" }) },\n ];\n }\n if (\n isNumeric &&\n enumValues.length === 0 &&\n typeof min === \"number\" &&\n typeof max === \"number\" &&\n max - min <= 20\n ) {\n const range: SelectOption[] = [];\n for (let i = min; i <= max; i++) range.push(String(i));\n return range;\n }\n return enumValues;\n }, [effectiveLoader, enumKey, isBoolean, isNumeric, min, max, tr]);\n\n const data = effectiveLoader ? asyncData : staticData;\n\n if (!props.input?.props) return null;\n\n const coerce = (raw: string): unknown => {\n if (isNumeric) return Number(raw);\n if (isBoolean) return raw === \"true\";\n return raw;\n };\n\n if (props.segmented) {\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n {/* `triggerProps` is deliberately NOT spread here. `Segmented`\n redeclares two attributes that `HTMLAttributes` also has, with\n narrower types (`defaultValue` is string-only, `onChange` takes a\n value rather than an event), so a blanket spread neither typechecks\n nor is safe. A segmented field also renders every option as visible\n text, so it is the one branch that is not nameless without a label.\n Name it with `label` if it needs one. */}\n <Segmented\n value={value != null ? String(value) : undefined}\n onChange={(v) => setValue(coerce(v))}\n disabled={props.disabled}\n options={data.slice(0, 10).map((o) => ({\n value: optValue(o),\n label: segmentedLabel(o),\n }))}\n fullWidth\n />\n </FormField>\n );\n }\n\n if (props.checkboxes && isArray) {\n const ticked = Array.isArray(value) ? (value as unknown[]).map(String) : [];\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div\n role=\"group\"\n aria-label={meta.label || undefined}\n {...props.triggerProps}\n id={meta.id}\n className=\"flex flex-wrap gap-x-4 gap-y-2 py-1\"\n >\n {data.map((o) => {\n const optionValue = optValue(o);\n const optionId = `${meta.id}-${optionValue}`;\n return (\n <label\n key={optionValue}\n htmlFor={optionId}\n className=\"flex items-center gap-2 text-sm\"\n >\n <Checkbox\n // An explicit id: Base UI would mint one with `useId`.\n id={optionId}\n data-value={optionValue}\n disabled={\n props.disabled || (typeof o !== \"string\" && o.disabled)\n }\n checked={ticked.includes(optionValue)}\n onCheckedChange={(checked) => {\n const next = checked\n ? [...ticked, optionValue]\n : ticked.filter((it) => it !== optionValue);\n // In the options' order, whatever order they were ticked.\n const ordered = data\n .map(optValue)\n .filter((it) => next.includes(it));\n setValue(ordered.map(coerce));\n }}\n />\n {segmentedLabel(o)}\n </label>\n );\n })}\n </div>\n </FormField>\n );\n }\n\n const clearLabel =\n props.clearLabel ?? tr(\"controlSelect.none\", { default: \"None\" });\n\n // One control for every list. The option count decides whether the popup\n // carries a search field — it no longer decides which primitive renders.\n // The native `Select` path this replaced silently dropped `description`,\n // `tag`, per-option `disabled` and `deselectable`, and styled its trigger\n // differently, purely because a list happened to be short.\n // A search field is offered only when scanning the list by eye stops being\n // realistic: a server-driven list (whose rows are not all here), one past\n // `SEARCH_THRESHOLD`, or one where typing is how a new entry is made.\n //\n // Multi-select used to force it on unconditionally, because the chips box\n // WAS the search input and there was no other way to open the popup. The\n // trigger is a button now, so multi obeys the same rule as everything else\n // and a four-row status filter no longer opens onto a search field.\n const searchable =\n props.searchable ??\n (props.combobox ||\n mode === \"long\" ||\n Boolean(props.createNewEntry) ||\n data.length > SEARCH_THRESHOLD);\n\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlSelectCombobox\n id={meta.id}\n data={data}\n loading={loading}\n multi={isArray}\n searchable={searchable}\n disabled={props.disabled}\n value={value}\n onChange={(v) => setValue(v)}\n coerce={coerce}\n onSearch={mode === \"long\" ? (text) => search.run(text) : undefined}\n createNewEntry={props.createNewEntry}\n icon={props.icon}\n // Used to be dropped on this path, so a filter chip sized `w-40` lost\n // its width as soon as its list crossed the threshold.\n triggerClassName={props.triggerClassName}\n triggerProps={props.triggerProps}\n size={props.size}\n minimal={props.minimal}\n // `clearable` used to reach this path as a placeholder and nothing\n // else, so a filter chip that had switched to the combobox (>20\n // options) could be set but never put back to \"All …\".\n clearable={props.clearable}\n clearLabel={clearLabel}\n countLabel={props.countLabel}\n maxTriggerLength={props.maxTriggerLength}\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={props.popupClassName}\n trigger={props.trigger}\n onPopupOpenChange={props.onPopupOpenChange}\n // An optional field must also be able to go back to empty without a\n // dedicated row: Base UI never emits `null`, so re-pressing the\n // selected row deselects (see `handleSingle` in\n // `ControlSelectCombobox.tsx`). A required field keeps its value —\n // clearing it would only produce a validation error the user cannot\n // see yet.\n deselectable={props.clearable || !meta.required}\n // Multi shows this muted when nothing is picked, so it reaches the\n // trigger whether or not the field is `clearable` — a multi-select\n // has no clear ROW (it clears by deselecting), and without this its\n // empty trigger fell back to a bare \"Select…\".\n placeholder={\n props.placeholder ??\n (props.clearable || isArray ? clearLabel : undefined)\n }\n />\n </FormField>\n );\n};\n\nexport type SelectOption =\n | string\n | {\n value: string;\n label: string;\n /**\n * Optional secondary line shown under the label in the dropdown.\n */\n description?: string;\n /**\n * Optional small badge rendered next to the label.\n */\n tag?: string;\n /**\n * Optional icon/element rendered before the label, in both the\n * dropdown row and (for single-select) the trigger when selected.\n */\n icon?: ReactNode;\n /**\n * When true, the row is non-interactive — can't be selected if\n * not selected, can't be deselected if selected. Useful for\n * default/mandatory entries (e.g. the base \"user\" role).\n */\n disabled?: boolean;\n };\n\ntype LoaderMode = \"static\" | \"short\" | \"long\";\n\n/**\n * How tall and how loud a select trigger is.\n *\n * The kit's own scale, kept under this name because `Control` and a long tail\n * of callers already spell it `size=\"xs\"` on a select. The table behind it,\n * and the trigger box it sizes, are `control-base/field-trigger`'s - shared\n * with the two calendar controls, which used to draw a button instead.\n */\nexport type ControlSelectSize = ControlTriggerSize;\n\n/**\n * Static option count above which the dropdown grows a search input. Below it\n * the very same combobox renders without one — the threshold decides whether\n * you can type, never which control you get.\n */\n// Past this many rows, scanning by eye stops being realistic and the popup\n// grows a search field. Raised 20 -> 50 with the multi-select rework: the old\n// value put a search box on lists a reader takes in at a glance.\nconst SEARCH_THRESHOLD = 50;\n\n/**\n * Friendly label for plain string options: \"optional\" → \"Optional\",\n * \"in_progress\" → \"In Progress\". Custom `{ value, label }` items pass through\n * untouched.\n */\nconst titlecase = (s: string) =>\n s.replace(/[_-]+/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase());\n/**\n * What one segment shows.\n *\n * ⚠️ The option's `icon` is rendered HERE rather than dropped, which is what\n * this path did until #Q2049. `SegmentedOption.label` is a `ReactNode`, so\n * there was never a reason for it: an option list carrying icons for the\n * dropdown carried them for the segments too, and dropping them silently\n * made a caller choose between two shapes for one list.\n */\nconst segmentedLabel = (o: SelectOption): ReactNode => {\n if (typeof o === \"string\") {\n return titlecase(o);\n }\n if (!o.icon) {\n return o.label;\n }\n return (\n <span className=\"inline-flex items-center gap-1.5\">\n {o.icon}\n {o.label}\n </span>\n );\n};\n\nconst useAsyncLoader = (\n loader: ControlSelectProps[\"loader\"],\n threshold: number,\n debounceMs: number,\n defaultValue: unknown,\n) => {\n const [data, setData] = useState<SelectOption[]>([]);\n const [loading, setLoading] = useState(false);\n const [mode, setMode] = useState<LoaderMode>(\"static\");\n const cache = useRef(new Map<string, SelectOption[]>());\n\n useAction(\n {\n // `id`, not `name`: `id` is what useAction threads into its\n // react:action:* events. `name` was accepted and never read, so this\n // identifier reached nothing.\n id: \"select:loader:init\",\n runOnInit: true,\n handler: async () => {\n if (!loader) {\n setMode(\"static\");\n return;\n }\n setLoading(true);\n try {\n const result = await loader(\"\");\n const isShort = result.length <= threshold;\n setMode(isShort ? \"short\" : \"long\");\n cache.current.set(\"\", result);\n setData(result);\n\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n if (!isShort && defaultValue != null && String(defaultValue) !== \"\") {\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n const resolved = await loader(\"\", [String(defaultValue)]);\n if (resolved.length > 0) {\n setData((prev) => {\n const existing = new Set(prev.map(optValue));\n const fresh = resolved.filter(\n (r) => !existing.has(optValue(r)),\n );\n return [...prev, ...fresh];\n });\n }\n }\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, threshold],\n );\n\n const search = useAction<[string]>(\n {\n debounce: debounceMs,\n handler: async (_ctx, text) => {\n if (!loader || mode !== \"long\") return;\n if (cache.current.has(text)) {\n setData(cache.current.get(text)!);\n return;\n }\n setLoading(true);\n try {\n const result = await loader(text);\n cache.current.set(text, result);\n setData(result);\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, mode, debounceMs],\n );\n\n return { data, loading, mode, search };\n};\n"],"mappings":";;;;;;;;;;;AA0OA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAEnD,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,UAAU,KAAK;CACrB,MAAM,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS;CAC1D,MAAM,YAAY,KAAK,SAAS;CAGhC,MAAM,aAAa,MAAM,QAAQ,MAAM,KAAK,IACvC,MAAM,QACP,KAAA;CACJ,MAAM,cACJ,OAAO,MAAM,UAAU,aAClB,MAAM,QACP,KAAA;CAEN,MAAM,aACJ,cAAe,KAAK,QAAuC,CAAC;CAE9D,MAAM,kBAAkB,MAAM,UAAU;CAExC,MAAM,EACJ,MAAM,WACN,SACA,MACA,WACE,eACF,iBACA,MAAM,mBAAmB,KACzB,MAAM,kBAAkB,KACxB,MAAM,MAAM,YACd;CAYA,MAAM,UAAU,KAAK,UACnB,WAA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9B,QAAQ,MAAM;IAChB,UAAU;KACR,WAAW,KAAK;IAClB;GACF;EACF,GACA;GAAC;GAAQ;GAAM;EAAU,CAGQ;CAAE;AACvC"}
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import type { HTMLAttributes } from "react";
3
- import { type ReactNode } from "react";
3
+ import { type ReactElement, type ReactNode } from "react";
4
4
  import type { ControlSelectProps, ControlSelectSize, SelectOption } from "./ControlSelect.tsx";
5
5
  import type { IconComponent } from "./iconHint.tsx";
6
6
  export interface ControlSelectComboboxProps {
@@ -79,6 +79,16 @@ export interface ControlSelectComboboxProps {
79
79
  * See `ControlSelectProps.popupClassName` in `ControlSelect.tsx`.
80
80
  */
81
81
  popupClassName?: string;
82
+ /**
83
+ * See `ControlSelectProps.trigger` in `ControlSelect.tsx`.
84
+ */
85
+ trigger?: ReactElement<{
86
+ children?: ReactNode;
87
+ }>;
88
+ /**
89
+ * See `ControlSelectProps.onPopupOpenChange` in `ControlSelect.tsx`.
90
+ */
91
+ onPopupOpenChange?: (open: boolean) => void;
82
92
  }
83
93
  /**
84
94
  * Searchable single/multi select built on the Base UI `Combobox` primitive.
@@ -1 +1 @@
1
- {"version":3,"file":"ControlSelectCombobox.d.ts","sourceRoot":"","sources":["../../src/form/ControlSelectCombobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AAYzD,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAY7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,0BAA0B;IACzC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,OAAO,EAAE,O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;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACjD;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,UAAW,0BAA0B,sBA+XtE,CAAC"}
@@ -200,12 +200,20 @@ const ControlSelectCombobox = (props) => {
200
200
  onValueChange: props.multi ? (v) => handleMulti(v) : (v) => handleSingle(v),
201
201
  isItemEqualToValue: ((a, b) => a.value === b.value),
202
202
  filter: null,
203
+ onOpenChange: (open) => props.onPopupOpenChange?.(open),
203
204
  autoHighlight: true,
204
205
  onInputValueChange: (v) => {
205
206
  setQuery(v);
206
207
  props.onSearch?.(v);
207
208
  },
208
- children: [/* @__PURE__ */ jsxs("div", {
209
+ children: [props.trigger ? /* @__PURE__ */ jsx(ComboboxTrigger, {
210
+ id: props.id,
211
+ disabled: props.disabled,
212
+ ...props.triggerProps,
213
+ chevron: false,
214
+ render: props.trigger,
215
+ children: props.trigger.props.children
216
+ }) : /* @__PURE__ */ jsxs("div", {
209
217
  className: TRIGGER_WRAPPER_CLASSES,
210
218
  children: [/* @__PURE__ */ jsx(ComboboxTrigger, {
211
219
  id: props.id,
@@ -1 +1 @@
1
- {"version":3,"file":"ControlSelectCombobox.js","names":["ComboboxRoot"],"sources":["../../src/form/ControlSelectCombobox.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useI18n } from \"alepha/react/i18n\";\nimport { ListChecks, Loader2 } from \"lucide-react\";\nimport type { HTMLAttributes } from \"react\";\nimport { type ReactNode, useRef, useState } from \"react\";\n\nimport {\n ComboboxContent,\n ComboboxEmpty,\n ComboboxInput,\n ComboboxItem,\n ComboboxList,\n Combobox as ComboboxRoot,\n ComboboxTrigger,\n} from \"../core/Combobox.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type {\n ControlSelectProps,\n ControlSelectSize,\n SelectOption,\n} from \"./ControlSelect.tsx\";\nimport {\n type ComboOption,\n resolveComboboxItems,\n} from \"./controlSelectOptions.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_MINIMAL_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectComboboxProps {\n id?: string;\n data: SelectOption[];\n loading: boolean;\n multi: boolean;\n /**\n * Render the search input. When false the popup is the list alone — the\n * shape a short static list gets. Multi-select ignores it: its input is the\n * chips box itself, and it is the only way to open and type.\n */\n searchable: boolean;\n disabled?: boolean;\n value: unknown;\n onChange: (v: unknown) => void;\n coerce: (v: string) => unknown;\n onSearch?: (q: string) => void;\n createNewEntry?: ControlSelectProps[\"createNewEntry\"];\n icon?: IconComponent;\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Trigger text when nothing is selected. Mirrors the native-Select path,\n * where a `clearable` field shows its `clearLabel` (e.g. \"All zones\") as the\n * empty placeholder. Defaults to \"Select…\".\n */\n placeholder?: string;\n /**\n * Empty is a meaningful choice for this field, so say so and offer it: the\n * trigger shows {@link clearLabel} while nothing is selected, and carries\n * an `x` to get back there once something is.\n *\n * ⚠️ It used to PREPEND A ROW saying the same thing, which is why the two\n * names still read that way at some call sites. That row was drawn as a\n * pickable option with a check mark, so \"All states\" looked like a third\n * state rather than the absence of a filter (feedback #2098).\n */\n clearable?: boolean;\n /**\n * What empty is called on this field (e.g. \"All zones\"), shown as the\n * trigger's placeholder.\n */\n clearLabel?: string;\n /**\n * See `ControlSelectProps.countLabel` in `ControlSelect.tsx`.\n */\n countLabel?: (count: number) => string;\n /**\n * See `ControlSelectProps.maxTriggerLength` in `ControlSelect.tsx`.\n */\n maxTriggerLength?: number;\n /**\n * Allow the single-select value to be unset by pressing the row that is\n * already selected. Set for optional (and `clearable`) fields only.\n */\n deselectable?: boolean;\n /**\n * See `ControlSelectProps.popupHeader` in `ControlSelect.tsx`.\n */\n popupHeader?: ReactNode;\n /**\n * See `ControlSelectProps.triggerPrefix` in `ControlSelect.tsx`.\n */\n triggerPrefix?: ReactNode;\n /**\n * See `ControlSelectProps.popupClassName` in `ControlSelect.tsx`.\n */\n popupClassName?: string;\n}\n\n/**\n * Searchable single/multi select built on the Base UI `Combobox` primitive.\n *\n * Composed in the \"select-like\" shape: a button trigger that shows the current\n * value, with the search `<input>` living inside the popup. We disable Base\n * UI's internal filtering (`filter={null}`) and filter in JS so the same code\n * path serves static lists, server-driven (`onSearch`) lists, and the\n * `createNewEntry` affordance.\n */\nexport const ControlSelectCombobox = (props: ControlSelectComboboxProps) => {\n const { tr } = useI18n();\n const sizeClasses = TRIGGER_SIZES[props.size ?? \"default\"];\n const [query, setQuery] = useState(\"\");\n // Remembers labels for values the user has picked, so the trigger/chips keep\n // a human label even after the source option drops out of a server-filtered\n // `data` set — or for freshly created entries that never existed in `data`.\n const labelCache = useRef(new Map<string, string>());\n\n const { selected, labelFor, options, unselectedMatches, items } =\n resolveComboboxItems(props, query, labelCache, tr);\n\n // Reconstruct option objects for the controlled value. Base UI matches them\n // back to list items via `isItemEqualToValue` (by `value`), so identity\n // across renders doesn't matter.\n const toValueObject = (val: string): ComboOption =>\n options.find((o) => o.value === val) ?? {\n value: val,\n label: labelFor(val),\n };\n\n const cbValue = props.multi\n ? selected.map(toValueObject)\n : selected[0]\n ? toValueObject(selected[0])\n : // Empty is EMPTY. It used to resolve to the clear row so that row\n // carried a check mark; with no such row, nothing is selected and the\n // trigger shows `clearLabel` as its placeholder.\n null;\n\n const remember = (o: ComboOption) => {\n if (o.create) labelCache.current.set(o.value, o.query ?? o.value);\n else labelCache.current.set(o.value, o.label);\n };\n\n const handleSingle = (o: ComboOption | null) => {\n // `null` still arrives from Base UI's own clearing paths (Escape on an\n // open popup, a controlled reset). There is no longer a synthetic clear\n // ROW that could arrive here as an option - the label lives on the\n // trigger and nowhere else since feedback #2098.\n if (!o) {\n props.onChange(undefined);\n setQuery(\"\");\n return;\n }\n // Base UI's single-select `Combobox` re-selects on every item press — its\n // `handleSelection` calls `setSelectedValue(itemValue)` unconditionally and\n // never emits `null` — so pressing the checked row was a no-op and an\n // optional field had no way back to empty. Toggle it off here, the way the\n // multi path already does via its chips.\n if (props.deselectable && !o.create && selected[0] === o.value) {\n props.onChange(undefined);\n setQuery(\"\");\n return;\n }\n remember(o);\n props.onChange(props.coerce(o.value));\n setQuery(\"\");\n };\n\n const handleMulti = (list: ComboOption[]) => {\n // The \"select every match\" row arrives here as one more selected item.\n // Swap it for the values it stands for, so the sentinel never leaves this\n // component and the chips show the real areas rather than a prefix.\n const expanded = list.flatMap((o) =>\n o.selectAll ? unselectedMatches : [o],\n );\n // Base UI can hand the same option back twice when the expansion overlaps\n // something already selected.\n const seen = new Set<string>();\n const unique = expanded.filter((o) =>\n seen.has(o.value) ? false : (seen.add(o.value), true),\n );\n for (const o of unique) remember(o);\n props.onChange(unique.map((o) => props.coerce(o.value)));\n setQuery(\"\");\n };\n\n const emptyLabel =\n props.placeholder ?? tr(\"controlSelect.select\", { default: \"Select…\" });\n\n /**\n * The selection's names, in the list's order, joined.\n *\n * The list's order and not the picking order, so the same selection always\n * reads the same, and a pick never reshuffles the names already shown.\n * Every selected value has a row in `options` (an orphan is injected for\n * one `data` lacks), so the index is always found.\n */\n const names = selected\n .map((value) => ({\n value,\n at: options.findIndex((o) => o.value === value),\n }))\n .sort((a, b) => a.at - b.at)\n .map((entry) => labelFor(entry.value))\n .join(\", \");\n\n /**\n * Names while they are short, then a count.\n *\n * One selection names itself however long it is: \"1 value\" is never better.\n * Two or more are named while the joined text fits `maxTriggerLength`\n * characters (20 by default), and collapse to a count past it.\n *\n * A budget of characters rather than of items: \"Draft, Ready\" says what a\n * filter holds where \"2 values\" makes the reader open it, while\n * \"lore/quests, alepha/orm\" would only truncate into a list that looks\n * shorter than it is. The chips box this replaced did exactly that, growing\n * with every pick and then truncating. The budget caps the trigger's width\n * instead, and needs no measuring, so the server renders the same text.\n *\n * ⚠️ Characters are not pixels, so the cap is approximate, and a pick that\n * crosses it shrinks the trigger from names to a count.\n */\n const maxTriggerLength = props.maxTriggerLength ?? 20;\n const triggerLabel = props.multi\n ? selected.length === 0\n ? emptyLabel\n : selected.length === 1 || names.length <= maxTriggerLength\n ? names\n : (props.countLabel?.(selected.length) ??\n tr(\"controlSelect.count\", {\n default: `${selected.length} values`,\n args: [String(selected.length)],\n }))\n : selected[0]\n ? labelFor(selected[0])\n : emptyLabel;\n\n /**\n * The `x` that puts a `clearable` field back to empty in one click.\n *\n * ⚠️ This is the affordance the injected clear ROW used to be, moved to\n * where it belongs (feedback #2098). Deleting the row made the empty state\n * a placeholder rather than a third pickable value, which is what the\n * report asked for.\n *\n * ## Why the `x` and not the row, stated properly\n *\n * An earlier version of this comment said the `x` had to exist because\n * `epics.spec.ts` went red when the row was deleted. **That was circular\n * and is corrected here.** The spec went red because its SELECTOR named a\n * node that no longer existed; the fix could equally have been one line\n * re-clicking the selected release. A broken locator is not a usability\n * finding.\n *\n * The real reasons, none of which that argument gave:\n *\n * - **Re-click-to-deselect is counter-conventional, not merely quiet.** In\n * a native `select`, and in almost every combobox people use daily,\n * clicking the chosen option confirms and closes. No learned model says\n * it removes the value, so it is neither discovered by accident nor\n * retained after being shown once.\n * - **\"Reset filters\" is not a fallback.** It is all or nothing. With\n * status, area and release all set, dropping just the release is a\n * different intent, and `DataTable`'s menu has no per-filter escape.\n * - **It costs nothing at rest**, since `showClear` needs a selection.\n *\n * ## No row comes back, at any size\n *\n * Feedback #2113 proposed a `None` row for `minimal`/`xs`, and the owner\n * dropped it the same day: this control had already been changed twice in\n * opposite directions, and keeping the row out leaves that sweep intact.\n *\n * ## And no `x` at `xs`\n *\n * At `xs` the trigger is 24px tall and the `x` a 12px glyph wedged between\n * the value and the chevron: too small a target to hit, and it crowds the\n * value it would clear. The owner took it out there. A `clearable` field is\n * always `deselectable`, so clicking the selected option again still puts\n * it back to empty, and the trigger still names the empty state with\n * `clearLabel`.\n *\n * ## `clearable`, not `deselectable`\n *\n * `deselectable` is `clearable || !meta.required`, so a large set of\n * optional fields accept re-click-to-clear and show no `x`: the component\n * holds both positions at once, that re-click suffices there and not here.\n *\n * That is a judgment call rather than a principle, and it is deliberate:\n * `clearable` is the caller saying empty is a meaningful state worth\n * ADVERTISING, so an ordinary optional field in a form keeps the trigger it\n * has today rather than growing a control for a state nobody is looking\n * for. Written down because it was previously undocumented, and an\n * undocumented asymmetry reads as an oversight to whoever finds it next.\n */\n const showClear =\n Boolean(props.clearable) &&\n selected.length > 0 &&\n !props.disabled &&\n props.size !== \"xs\";\n\n // The list (loading / empty / items) is identical for single and multi, and\n // so is the trigger now, so render it once.\n const popupBody = props.loading ? (\n <div className=\"text-muted-foreground flex items-center justify-center gap-2 p-4 text-sm\">\n <Loader2 className=\"size-4 animate-spin\" />{\" \"}\n {tr(\"controlSelect.loading\", { default: \"Loading…\" })}\n </div>\n ) : (\n <>\n <ComboboxEmpty>\n {props.createNewEntry\n ? \"\"\n : tr(\"controlSelect.noResults\", { default: \"No results.\" })}\n </ComboboxEmpty>\n <ComboboxList>\n {(opt: ComboOption) =>\n opt.selectAll ? (\n <ComboboxItem key=\"__select_all__\" value={opt}>\n <ListChecks className=\"mr-2 size-4 shrink-0\" />\n <span className=\"truncate font-medium\">{opt.label}</span>\n </ComboboxItem>\n ) : opt.create ? (\n <ComboboxItem key={`__create__${opt.value}`} value={opt}>\n <span className=\"mr-2\">+</span>\n {tr(\"controlSelect.create\", {\n default: `Create \"${opt.query}\"`,\n args: [String(opt.query ?? \"\")],\n })}\n </ComboboxItem>\n ) : (\n <ComboboxItem key={opt.value} value={opt} disabled={opt.disabled}>\n {opt.icon && (\n <span className=\"mr-2 flex shrink-0 items-center\">\n {opt.icon}\n </span>\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <div className=\"flex items-center gap-1.5\">\n {opt.tag && (\n <span className=\"bg-muted text-muted-foreground rounded px-1 text-[10px] tracking-wide uppercase\">\n {opt.tag}\n </span>\n )}\n <span className=\"truncate\">{opt.label}</span>\n </div>\n {opt.description && (\n <span className=\"text-muted-foreground truncate text-xs\">\n {opt.description}\n </span>\n )}\n </div>\n </ComboboxItem>\n )\n }\n </ComboboxList>\n </>\n );\n\n return (\n <ComboboxRoot\n items={items as never}\n multiple={props.multi}\n disabled={props.disabled}\n value={cbValue as never}\n onValueChange={\n (props.multi\n ? (v: ComboOption[]) => handleMulti(v)\n : (v: ComboOption | null) => handleSingle(v)) as never\n }\n isItemEqualToValue={\n ((a: ComboOption, b: ComboOption) => a.value === b.value) as never\n }\n filter={null}\n // Base UI leaves `autoHighlight` off by default, so nothing is\n // highlighted while typing and Enter has no target — the user has to\n // click a row (including the `createNewEntry` one). Highlighting the\n // first match makes Enter pick it, which is what a search field is\n // expected to do. It only engages while the query is non-empty, so\n // opening the popup still starts with no preselection.\n autoHighlight\n onInputValueChange={(v) => {\n setQuery(v);\n props.onSearch?.(v);\n }}\n >\n {/* One trigger for single AND multi. Multi used to render a bordered\n chips box instead, which made it a different-looking control for the\n same job, grew with every pick, and forced a search field on because\n the chips input was the only way to open the popup.\n\n Wrapped so the clear button below can sit ON the trigger without\n being INSIDE it: a button nested in a button is invalid, and Base\n UI renders this trigger as a real `<button>`. */}\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <ComboboxTrigger\n id={props.id}\n disabled={props.disabled}\n {...props.triggerProps}\n // Read by the hover-border rule in `styles.css`, which leaves a\n // minimal trigger borderless on hover too: its hover is the tint.\n data-minimal={props.minimal ? \"\" : undefined}\n className={cn(\n TRIGGER_CLASSES,\n sizeClasses.trigger,\n sizeClasses.chevron,\n props.minimal && TRIGGER_MINIMAL_CLASSES,\n // Muted means \"nothing chosen yet\", and now that is simply\n // \"nothing selected\" for every shape.\n //\n // It used to carve out `clearable` singles, because for those empty\n // WAS a selected value - the injected clear row - and muting it made\n // one filter look unset while its neighbour looked set for the same\n // meaning. That row is gone (see `items` in\n // `controlSelectOptions.ts`), so empty is empty and reads as a\n // placeholder everywhere.\n selected.length === 0 && \"text-muted-foreground\",\n props.triggerClassName,\n )}\n >\n {/* The room for the clear button, per size - see `clearGap` in\n TRIGGER_SIZES for why it is a margin here and not padding on the\n trigger. `trigger-label` lets a container that hides the button\n (`DataTableFilterControl`) take the room back. */}\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && sizeClasses.clearGap,\n )}\n >\n {props.icon && (\n <props.icon\n className={cn(\n \"text-muted-foreground shrink-0\",\n sizeClasses.icon,\n )}\n />\n )}\n {/*\n The prefix rides in the SAME text run as the label, separated by\n an ordinary space. As a flex sibling it was spaced by the row's\n `gap-2`, 8px, while the words inside it were a font space apart,\n so \"Status not Active\" read \"Status not Active\". One run makes\n every gap the same space, and truncation eats from the end of\n the value rather than squeezing the two apart.\n */}\n <span className=\"truncate\">\n {props.triggerPrefix && selected.length > 0 && (\n <span className=\"text-muted-foreground\">\n {props.triggerPrefix}{\" \"}\n </span>\n )}\n {triggerLabel}\n </span>\n </span>\n </ComboboxTrigger>\n {showClear && (\n <ControlClearButton\n size={props.size}\n onClick={() => props.onChange(props.multi ? [] : undefined)}\n />\n )}\n </div>\n <ComboboxContent className={props.popupClassName}>\n {props.popupHeader}\n {props.searchable && (\n <ComboboxInput showTrigger={false} placeholder=\"Search…\" />\n )}\n {popupBody}\n </ComboboxContent>\n </ComboboxRoot>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4HA,MAAa,yBAAyB,UAAsC;CAC1E,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,cAAc,cAAc,MAAM,QAAQ;CAChD,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CAIrC,MAAM,aAAa,uBAAO,IAAI,IAAoB,CAAC;CAEnD,MAAM,EAAE,UAAU,UAAU,SAAS,mBAAmB,UACtD,qBAAqB,OAAO,OAAO,YAAY,EAAE;CAKnD,MAAM,iBAAiB,QACrB,QAAQ,MAAM,MAAM,EAAE,UAAU,GAAG,KAAK;EACtC,OAAO;EACP,OAAO,SAAS,GAAG;CACrB;CAEF,MAAM,UAAU,MAAM,QAClB,SAAS,IAAI,aAAa,IAC1B,SAAS,KACP,cAAc,SAAS,EAAE,IAIzB;CAEN,MAAM,YAAY,MAAmB;EACnC,IAAI,EAAE,QAAQ,WAAW,QAAQ,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK;OAC3D,WAAW,QAAQ,IAAI,EAAE,OAAO,EAAE,KAAK;CAC9C;CAEA,MAAM,gBAAgB,MAA0B;EAK9C,IAAI,CAAC,GAAG;GACN,MAAM,SAAS,KAAA,CAAS;GACxB,SAAS,EAAE;GACX;EACF;EAMA,IAAI,MAAM,gBAAgB,CAAC,EAAE,UAAU,SAAS,OAAO,EAAE,OAAO;GAC9D,MAAM,SAAS,KAAA,CAAS;GACxB,SAAS,EAAE;GACX;EACF;EACA,SAAS,CAAC;EACV,MAAM,SAAS,MAAM,OAAO,EAAE,KAAK,CAAC;EACpC,SAAS,EAAE;CACb;CAEA,MAAM,eAA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obox.js","names":["ComboboxRoot"],"sources":["../../src/form/ControlSelectCombobox.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useI18n } from \"alepha/react/i18n\";\nimport { ListChecks, Loader2 } from \"lucide-react\";\nimport type { HTMLAttributes } from \"react\";\nimport { type ReactElement, type ReactNode, useRef, useState } from \"react\";\n\nimport {\n ComboboxContent,\n ComboboxEmpty,\n ComboboxInput,\n ComboboxItem,\n ComboboxList,\n Combobox as ComboboxRoot,\n ComboboxTrigger,\n} from \"../core/Combobox.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type {\n ControlSelectProps,\n ControlSelectSize,\n SelectOption,\n} from \"./ControlSelect.tsx\";\nimport {\n type ComboOption,\n resolveComboboxItems,\n} from \"./controlSelectOptions.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_MINIMAL_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectComboboxProps {\n id?: string;\n data: SelectOption[];\n loading: boolean;\n multi: boolean;\n /**\n * Render the search input. When false the popup is the list alone — the\n * shape a short static list gets. Multi-select ignores it: its input is the\n * chips box itself, and it is the only way to open and type.\n */\n searchable: boolean;\n disabled?: boolean;\n value: unknown;\n onChange: (v: unknown) => void;\n coerce: (v: string) => unknown;\n onSearch?: (q: string) => void;\n createNewEntry?: ControlSelectProps[\"createNewEntry\"];\n icon?: IconComponent;\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Trigger text when nothing is selected. Mirrors the native-Select path,\n * where a `clearable` field shows its `clearLabel` (e.g. \"All zones\") as the\n * empty placeholder. Defaults to \"Select…\".\n */\n placeholder?: string;\n /**\n * Empty is a meaningful choice for this field, so say so and offer it: the\n * trigger shows {@link clearLabel} while nothing is selected, and carries\n * an `x` to get back there once something is.\n *\n * ⚠️ It used to PREPEND A ROW saying the same thing, which is why the two\n * names still read that way at some call sites. That row was drawn as a\n * pickable option with a check mark, so \"All states\" looked like a third\n * state rather than the absence of a filter (feedback #2098).\n */\n clearable?: boolean;\n /**\n * What empty is called on this field (e.g. \"All zones\"), shown as the\n * trigger's placeholder.\n */\n clearLabel?: string;\n /**\n * See `ControlSelectProps.countLabel` in `ControlSelect.tsx`.\n */\n countLabel?: (count: number) => string;\n /**\n * See `ControlSelectProps.maxTriggerLength` in `ControlSelect.tsx`.\n */\n maxTriggerLength?: number;\n /**\n * Allow the single-select value to be unset by pressing the row that is\n * already selected. Set for optional (and `clearable`) fields only.\n */\n deselectable?: boolean;\n /**\n * See `ControlSelectProps.popupHeader` in `ControlSelect.tsx`.\n */\n popupHeader?: ReactNode;\n /**\n * See `ControlSelectProps.triggerPrefix` in `ControlSelect.tsx`.\n */\n triggerPrefix?: ReactNode;\n /**\n * See `ControlSelectProps.popupClassName` in `ControlSelect.tsx`.\n */\n popupClassName?: string;\n /**\n * See `ControlSelectProps.trigger` in `ControlSelect.tsx`.\n */\n trigger?: ReactElement<{ children?: ReactNode }>;\n /**\n * See `ControlSelectProps.onPopupOpenChange` in `ControlSelect.tsx`.\n */\n onPopupOpenChange?: (open: boolean) => void;\n}\n\n/**\n * Searchable single/multi select built on the Base UI `Combobox` primitive.\n *\n * Composed in the \"select-like\" shape: a button trigger that shows the current\n * value, with the search `<input>` living inside the popup. We disable Base\n * UI's internal filtering (`filter={null}`) and filter in JS so the same code\n * path serves static lists, server-driven (`onSearch`) lists, and the\n * `createNewEntry` affordance.\n */\nexport const ControlSelectCombobox = (props: ControlSelectComboboxProps) => {\n const { tr } = useI18n();\n const sizeClasses = TRIGGER_SIZES[props.size ?? \"default\"];\n const [query, setQuery] = useState(\"\");\n // Remembers labels for values the user has picked, so the trigger/chips keep\n // a human label even after the source option drops out of a server-filtered\n // `data` set — or for freshly created entries that never existed in `data`.\n const labelCache = useRef(new Map<string, string>());\n\n const { selected, labelFor, options, unselectedMatches, items } =\n resolveComboboxItems(props, query, labelCache, tr);\n\n // Reconstruct option objects for the controlled value. Base UI matches them\n // back to list items via `isItemEqualToValue` (by `value`), so identity\n // across renders doesn't matter.\n const toValueObject = (val: string): ComboOption =>\n options.find((o) => o.value === val) ?? {\n value: val,\n label: labelFor(val),\n };\n\n const cbValue = props.multi\n ? selected.map(toValueObject)\n : selected[0]\n ? toValueObject(selected[0])\n : // Empty is EMPTY. It used to resolve to the clear row so that row\n // carried a check mark; with no such row, nothing is selected and the\n // trigger shows `clearLabel` as its placeholder.\n null;\n\n const remember = (o: ComboOption) => {\n if (o.create) labelCache.current.set(o.value, o.query ?? o.value);\n else labelCache.current.set(o.value, o.label);\n };\n\n const handleSingle = (o: ComboOption | null) => {\n // `null` still arrives from Base UI's own clearing paths (Escape on an\n // open popup, a controlled reset). There is no longer a synthetic clear\n // ROW that could arrive here as an option - the label lives on the\n // trigger and nowhere else since feedback #2098.\n if (!o) {\n props.onChange(undefined);\n setQuery(\"\");\n return;\n }\n // Base UI's single-select `Combobox` re-selects on every item press — its\n // `handleSelection` calls `setSelectedValue(itemValue)` unconditionally and\n // never emits `null` — so pressing the checked row was a no-op and an\n // optional field had no way back to empty. Toggle it off here, the way the\n // multi path already does via its chips.\n if (props.deselectable && !o.create && selected[0] === o.value) {\n props.onChange(undefined);\n setQuery(\"\");\n return;\n }\n remember(o);\n props.onChange(props.coerce(o.value));\n setQuery(\"\");\n };\n\n const handleMulti = (list: ComboOption[]) => {\n // The \"select every match\" row arrives here as one more selected item.\n // Swap it for the values it stands for, so the sentinel never leaves this\n // component and the chips show the real areas rather than a prefix.\n const expanded = list.flatMap((o) =>\n o.selectAll ? unselectedMatches : [o],\n );\n // Base UI can hand the same option back twice when the expansion overlaps\n // something already selected.\n const seen = new Set<string>();\n const unique = expanded.filter((o) =>\n seen.has(o.value) ? false : (seen.add(o.value), true),\n );\n for (const o of unique) remember(o);\n props.onChange(unique.map((o) => props.coerce(o.value)));\n setQuery(\"\");\n };\n\n const emptyLabel =\n props.placeholder ?? tr(\"controlSelect.select\", { default: \"Select…\" });\n\n /**\n * The selection's names, in the list's order, joined.\n *\n * The list's order and not the picking order, so the same selection always\n * reads the same, and a pick never reshuffles the names already shown.\n * Every selected value has a row in `options` (an orphan is injected for\n * one `data` lacks), so the index is always found.\n */\n const names = selected\n .map((value) => ({\n value,\n at: options.findIndex((o) => o.value === value),\n }))\n .sort((a, b) => a.at - b.at)\n .map((entry) => labelFor(entry.value))\n .join(\", \");\n\n /**\n * Names while they are short, then a count.\n *\n * One selection names itself however long it is: \"1 value\" is never better.\n * Two or more are named while the joined text fits `maxTriggerLength`\n * characters (20 by default), and collapse to a count past it.\n *\n * A budget of characters rather than of items: \"Draft, Ready\" says what a\n * filter holds where \"2 values\" makes the reader open it, while\n * \"lore/quests, alepha/orm\" would only truncate into a list that looks\n * shorter than it is. The chips box this replaced did exactly that, growing\n * with every pick and then truncating. The budget caps the trigger's width\n * instead, and needs no measuring, so the server renders the same text.\n *\n * ⚠️ Characters are not pixels, so the cap is approximate, and a pick that\n * crosses it shrinks the trigger from names to a count.\n */\n const maxTriggerLength = props.maxTriggerLength ?? 20;\n const triggerLabel = props.multi\n ? selected.length === 0\n ? emptyLabel\n : selected.length === 1 || names.length <= maxTriggerLength\n ? names\n : (props.countLabel?.(selected.length) ??\n tr(\"controlSelect.count\", {\n default: `${selected.length} values`,\n args: [String(selected.length)],\n }))\n : selected[0]\n ? labelFor(selected[0])\n : emptyLabel;\n\n /**\n * The `x` that puts a `clearable` field back to empty in one click.\n *\n * ⚠️ This is the affordance the injected clear ROW used to be, moved to\n * where it belongs (feedback #2098). Deleting the row made the empty state\n * a placeholder rather than a third pickable value, which is what the\n * report asked for.\n *\n * ## Why the `x` and not the row, stated properly\n *\n * An earlier version of this comment said the `x` had to exist because\n * `epics.spec.ts` went red when the row was deleted. **That was circular\n * and is corrected here.** The spec went red because its SELECTOR named a\n * node that no longer existed; the fix could equally have been one line\n * re-clicking the selected release. A broken locator is not a usability\n * finding.\n *\n * The real reasons, none of which that argument gave:\n *\n * - **Re-click-to-deselect is counter-conventional, not merely quiet.** In\n * a native `select`, and in almost every combobox people use daily,\n * clicking the chosen option confirms and closes. No learned model says\n * it removes the value, so it is neither discovered by accident nor\n * retained after being shown once.\n * - **\"Reset filters\" is not a fallback.** It is all or nothing. With\n * status, area and release all set, dropping just the release is a\n * different intent, and `DataTable`'s menu has no per-filter escape.\n * - **It costs nothing at rest**, since `showClear` needs a selection.\n *\n * ## No row comes back, at any size\n *\n * Feedback #2113 proposed a `None` row for `minimal`/`xs`, and the owner\n * dropped it the same day: this control had already been changed twice in\n * opposite directions, and keeping the row out leaves that sweep intact.\n *\n * ## And no `x` at `xs`\n *\n * At `xs` the trigger is 24px tall and the `x` a 12px glyph wedged between\n * the value and the chevron: too small a target to hit, and it crowds the\n * value it would clear. The owner took it out there. A `clearable` field is\n * always `deselectable`, so clicking the selected option again still puts\n * it back to empty, and the trigger still names the empty state with\n * `clearLabel`.\n *\n * ## `clearable`, not `deselectable`\n *\n * `deselectable` is `clearable || !meta.required`, so a large set of\n * optional fields accept re-click-to-clear and show no `x`: the component\n * holds both positions at once, that re-click suffices there and not here.\n *\n * That is a judgment call rather than a principle, and it is deliberate:\n * `clearable` is the caller saying empty is a meaningful state worth\n * ADVERTISING, so an ordinary optional field in a form keeps the trigger it\n * has today rather than growing a control for a state nobody is looking\n * for. Written down because it was previously undocumented, and an\n * undocumented asymmetry reads as an oversight to whoever finds it next.\n */\n const showClear =\n Boolean(props.clearable) &&\n selected.length > 0 &&\n !props.disabled &&\n props.size !== \"xs\";\n\n // The list (loading / empty / items) is identical for single and multi, and\n // so is the trigger now, so render it once.\n const popupBody = props.loading ? (\n <div className=\"text-muted-foreground flex items-center justify-center gap-2 p-4 text-sm\">\n <Loader2 className=\"size-4 animate-spin\" />{\" \"}\n {tr(\"controlSelect.loading\", { default: \"Loading…\" })}\n </div>\n ) : (\n <>\n <ComboboxEmpty>\n {props.createNewEntry\n ? \"\"\n : tr(\"controlSelect.noResults\", { default: \"No results.\" })}\n </ComboboxEmpty>\n <ComboboxList>\n {(opt: ComboOption) =>\n opt.selectAll ? (\n <ComboboxItem key=\"__select_all__\" value={opt}>\n <ListChecks className=\"mr-2 size-4 shrink-0\" />\n <span className=\"truncate font-medium\">{opt.label}</span>\n </ComboboxItem>\n ) : opt.create ? (\n <ComboboxItem key={`__create__${opt.value}`} value={opt}>\n <span className=\"mr-2\">+</span>\n {tr(\"controlSelect.create\", {\n default: `Create \"${opt.query}\"`,\n args: [String(opt.query ?? \"\")],\n })}\n </ComboboxItem>\n ) : (\n <ComboboxItem key={opt.value} value={opt} disabled={opt.disabled}>\n {opt.icon && (\n <span className=\"mr-2 flex shrink-0 items-center\">\n {opt.icon}\n </span>\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <div className=\"flex items-center gap-1.5\">\n {opt.tag && (\n <span className=\"bg-muted text-muted-foreground rounded px-1 text-[10px] tracking-wide uppercase\">\n {opt.tag}\n </span>\n )}\n <span className=\"truncate\">{opt.label}</span>\n </div>\n {opt.description && (\n <span className=\"text-muted-foreground truncate text-xs\">\n {opt.description}\n </span>\n )}\n </div>\n </ComboboxItem>\n )\n }\n </ComboboxList>\n </>\n );\n\n return (\n <ComboboxRoot\n items={items as never}\n multiple={props.multi}\n disabled={props.disabled}\n value={cbValue as never}\n onValueChange={\n (props.multi\n ? (v: ComboOption[]) => handleMulti(v)\n : (v: ComboOption | null) => handleSingle(v)) as never\n }\n isItemEqualToValue={\n ((a: ComboOption, b: ComboOption) => a.value === b.value) as never\n }\n filter={null}\n onOpenChange={(open) => props.onPopupOpenChange?.(open)}\n // Base UI leaves `autoHighlight` off by default, so nothing is\n // highlighted while typing and Enter has no target — the user has to\n // click a row (including the `createNewEntry` one). Highlighting the\n // first match makes Enter pick it, which is what a search field is\n // expected to do. It only engages while the query is non-empty, so\n // opening the popup still starts with no preselection.\n autoHighlight\n onInputValueChange={(v) => {\n setQuery(v);\n props.onSearch?.(v);\n }}\n >\n {/* One trigger for single AND multi. Multi used to render a bordered\n chips box instead, which made it a different-looking control for the\n same job, grew with every pick, and forced a search field on because\n the chips input was the only way to open the popup.\n\n Wrapped so the clear button below can sit ON the trigger without\n being INSIDE it: a button nested in a button is invalid, and Base\n UI renders this trigger as a real `<button>`.\n\n A caller's own `trigger` replaces all of it: the element is the\n button, as it was drawn, and opens the same popup. Its children are\n handed over explicitly, because the trigger's own children would\n otherwise replace them. */}\n {props.trigger ? (\n <ComboboxTrigger\n id={props.id}\n disabled={props.disabled}\n {...props.triggerProps}\n chevron={false}\n render={props.trigger}\n >\n {props.trigger.props.children}\n </ComboboxTrigger>\n ) : (\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <ComboboxTrigger\n id={props.id}\n disabled={props.disabled}\n {...props.triggerProps}\n // Read by the hover-border rule in `styles.css`, which leaves a\n // minimal trigger borderless on hover too: its hover is the tint.\n data-minimal={props.minimal ? \"\" : undefined}\n className={cn(\n TRIGGER_CLASSES,\n sizeClasses.trigger,\n sizeClasses.chevron,\n props.minimal && TRIGGER_MINIMAL_CLASSES,\n // Muted means \"nothing chosen yet\", and now that is simply\n // \"nothing selected\" for every shape.\n //\n // It used to carve out `clearable` singles, because for those empty\n // WAS a selected value - the injected clear row - and muting it made\n // one filter look unset while its neighbour looked set for the same\n // meaning. That row is gone (see `items` in\n // `controlSelectOptions.ts`), so empty is empty and reads as a\n // placeholder everywhere.\n selected.length === 0 && \"text-muted-foreground\",\n props.triggerClassName,\n )}\n >\n {/* The room for the clear button, per size - see `clearGap` in\n TRIGGER_SIZES for why it is a margin here and not padding on the\n trigger. `trigger-label` lets a container that hides the button\n (`DataTableFilterControl`) take the room back. */}\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && sizeClasses.clearGap,\n )}\n >\n {props.icon && (\n <props.icon\n className={cn(\n \"text-muted-foreground shrink-0\",\n sizeClasses.icon,\n )}\n />\n )}\n {/*\n The prefix rides in the SAME text run as the label, separated by\n an ordinary space. As a flex sibling it was spaced by the row's\n `gap-2`, 8px, while the words inside it were a font space apart,\n so \"Status not Active\" read \"Status not Active\". One run makes\n every gap the same space, and truncation eats from the end of\n the value rather than squeezing the two apart.\n */}\n <span className=\"truncate\">\n {props.triggerPrefix && selected.length > 0 && (\n <span className=\"text-muted-foreground\">\n {props.triggerPrefix}{\" \"}\n </span>\n )}\n {triggerLabel}\n </span>\n </span>\n </ComboboxTrigger>\n {showClear && (\n <ControlClearButton\n size={props.size}\n onClick={() => props.onChange(props.multi ? [] : undefined)}\n />\n )}\n </div>\n )}\n <ComboboxContent className={props.popupClassName}>\n {props.popupHeader}\n {props.searchable && (\n <ComboboxInput showTrigger={false} placeholder=\"Search…\" />\n )}\n {popupBody}\n </ComboboxContent>\n </ComboboxRoot>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoIA,MAAa,yBAAyB,UAAsC;CAC1E,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,cAAc,cAAc,MAAM,QAAQ;CAChD,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CAIrC,MAAM,aAAa,uBAAO,IAAI,IAAoB,CAAC;CAEnD,MAAM,EAAE,UAAU,UAAU,SAAS,mBAAmB,UACtD,qBAAqB,OAAO,OAAO,YAAY,EAAE;CAKnD,MAAM,iBAAiB,QACrB,QAAQ,MAAM,MAAM,EAAE,UAAU,GAAG,KAAK;EACtC,OAAO;EACP,OAAO,SAAS,GAAG;CACrB;CAEF,MAAM,UAAU,MAAM,QAClB,SAAS,IAAI,aAAa,IAC1B,SAAS,KACP,cAAc,SAAS,EAAE,IAIzB;CAEN,MAAM,YAAY,MAAmB;EACnC,IAAI,EAAE,QAAQ,WAAW,QAAQ,IAAI,EAAE,OAAO,EA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AEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,UAAW,kBAAkB,6BAwWtD,CAAC"}
1
+ {"version":3,"file":"ControlUpload.d.ts","sourceRoot":"","sources":["../../src/form/ControlUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,mBAAmB,CAAC;AAyB3B,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,kBAAkB,CAAC;AAExE,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,UAAW,kBAAkB,6BAyWtD,CAAC"}
@@ -195,6 +195,7 @@ const ControlUpload = (props) => {
195
195
  children: uploading ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Loader2, { className: "mr-1 size-4 animate-spin" }), tr("controlUpload.uploading", { default: "Uploading…" })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Upload, { className: "mr-1 size-4" }), props.multi ? tr("controlUpload.chooseFiles", { default: "Choose files" }) : tr("controlUpload.chooseFile", { default: "Choose a file" })] })
196
196
  }), /* @__PURE__ */ jsx(TooltipContent, { children: dragDropHint })] });
197
197
  return /* @__PURE__ */ jsxs(FormField, {
198
+ onBlur: () => props.input.form?.blur(props.input.path),
198
199
  id: inputId,
199
200
  label: fieldMeta.label,
200
201
  description: fieldMeta.description,