@softize/opus 8.7.0 → 8.7.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softize/opus",
3
- "version": "8.7.0",
3
+ "version": "8.7.1",
4
4
  "description": "End-to-end action protocol for TypeScript. Single package with subpath exports (core + adapters).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -217,9 +217,24 @@ function CustomSelect(props: Exclude<SelectProps, SelectNativeProps>): React.Rea
217
217
  const inputRef = React.useRef<HTMLInputElement>(null)
218
218
  /** Fechando por Esc: o foco volta pro gatilho, e focar abre. Marca pra ignorar UM foco. */
219
219
  const closingRef = React.useRef(false)
220
+ const searchRef = React.useRef<HTMLInputElement>(null)
220
221
 
221
222
  const selectedOption = options.find((o) => o.value === singleValue)
222
223
 
224
+ /**
225
+ * Abrir com busca FOCA a caixa — abrir e já poder digitar é o ponto do padrão.
226
+ *
227
+ * Explícito e não pelo `autoFocus`: aqui dependeria de o Radix (que move o foco ao
228
+ * abrir o popover) e o cmdk concordarem sobre quem manda, e o resultado varia com a
229
+ * ordem de montagem. `requestAnimationFrame` porque o conteúdo do popover entra no DOM
230
+ * depois deste efeito.
231
+ */
232
+ React.useEffect(() => {
233
+ if (!open || !canSearch) return
234
+ const r = requestAnimationFrame(() => searchRef.current?.focus())
235
+ return () => cancelAnimationFrame(r)
236
+ }, [open, canSearch])
237
+
223
238
  /**
224
239
  * O termo de busca zera ao FECHAR.
225
240
  *
@@ -467,8 +482,8 @@ function CustomSelect(props: Exclude<SelectProps, SelectNativeProps>): React.Rea
467
482
  <div data-slot="select-search-row" className="flex items-center gap-2 border-b px-3">
468
483
  <SearchIcon className="size-4 shrink-0 opacity-50" aria-hidden="true" />
469
484
  <CommandPrimitive.Input
485
+ ref={searchRef}
470
486
  data-slot="select-search"
471
- autoFocus
472
487
  value={query}
473
488
  onValueChange={setQuery}
474
489
  placeholder={searchPlaceholder ?? 'Buscar…'}