@mittwald/flow-react-components 1.1.18 → 1.1.20

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/AGENTS.md CHANGED
@@ -342,6 +342,19 @@ Easy-to-miss conventions not spelled out above. Full details and examples in
342
342
  must affect layout.
343
343
  - **Controllers coexist with declarative props** — overlay-like APIs support
344
344
  controlled/uncontrolled props _and_ a controller object, not one or the other.
345
+ - **A component without `value` and without `defaultValue` still has to render
346
+ as controlled** — react-aria's `useControlledState` reads only `undefined` as
347
+ uncontrolled. A component that mirrors the value in its own state therefore
348
+ hands react-aria `undefined` on the first render and a real value after the
349
+ first change: the value changes owner mid-flight, and React and react-aria
350
+ warn `A component changed from uncontrolled to controlled`. Pass a sentinel
351
+ instead of `undefined` — `null` where "nothing selected yet" is representable
352
+ (`Tabs`' `selectedKey`), otherwise the type's empty value (`""` for text,
353
+ `NaN` for a number, `null` for a date range — `useControlledHostValueProps`'
354
+ `emptyValue`). Mind `??` once the sentinel is `null`: a caller-supplied `null`
355
+ must not fall through to `defaultValue`. Nothing breaks visibly, and a
356
+ component holding its own document state (`CodeEditor`) does not even warn —
357
+ it changes owner silently.
345
358
  - **Complex behavior is split by vocabulary** — `components/` for render,
346
359
  `hooks/` for behavior, `lib/` for pure transforms, `models/` for durable
347
360
  state.
package/MIGRATION.md CHANGED
@@ -28,6 +28,68 @@ The CLI's own output does detect it and prints the right form.
28
28
 
29
29
  ---
30
30
 
31
+ <a id="option-value-inferred-from-mixed-children"></a>
32
+
33
+ ## Option: value is inferred from mixed children
34
+
35
+ **Since `1.1.12`** · migration · no code change needed · also applies to
36
+ `@mittwald/flow-remote-react-components`
37
+
38
+ An `Option` used to infer its `textValue` — and, through it, its `value` — only
39
+ when its children were exactly one text node. Text next to any element left both
40
+ undefined, so react-aria assigned the option a key off a render-order counter:
41
+
42
+ ```tsx
43
+ <Select>
44
+ <Option>
45
+ Millennium Falcon <Badge>Latest</Badge>
46
+ </Option>
47
+ <Option>X-Wing</Option>
48
+ </Select>
49
+ ```
50
+
51
+ | Option | key before | key now |
52
+ | ----------------------------- | -------------- | ------------------- |
53
+ | `Millennium Falcon` + `Badge` | `react-aria-1` | `Millennium Falcon` |
54
+ | `X-Wing` | `X-Wing` | `X-Wing` |
55
+
56
+ The key is what the field reports as its selected value and what `defaultValue`
57
+ has to match, so the old key made the field submit a meaningless string, could
58
+ not be preselected, and shifted when unrelated markup around it changed.
59
+
60
+ Only text that is a child itself contributes — text inside an element child does
61
+ not, so the option above is `"Millennium Falcon"` and not
62
+ `"Millennium Falcon Latest"`.
63
+
64
+ An `Option` with no text among its children at all still has no key to infer,
65
+ and now says so on the console instead of failing silently:
66
+
67
+ ```tsx
68
+ // logs: An <Option> has no 'value' and none could be inferred from its children…
69
+ <Option>
70
+ <Text>Millennium Falcon</Text>
71
+ </Option>
72
+ ```
73
+
74
+ Give those options a `value`:
75
+
76
+ ```diff
77
+ - <Option>
78
+ + <Option value="millennium-falcon">
79
+ <Text>Millennium Falcon</Text>
80
+ </Option>
81
+ ```
82
+
83
+ **Apply:** No code change required for the option itself. An `Option` whose
84
+ children are text plus an element — text and a `Badge`, text and an icon — now
85
+ carries that text as its key, where it previously fell back to react-aria's
86
+ generated `react-aria-N`. Check anywhere such a key was read back: a stored or
87
+ server-side selection, a `defaultValue`/`value` matched against it, or a test
88
+ asserting on it. Pass an explicit `value` to pin the key to something other than
89
+ the display text.
90
+
91
+ ---
92
+
31
93
  <a id="use-design-tokens-build-metadata-removed"></a>
32
94
 
33
95
  ## useDesignTokens(): no longer returns style-dictionary build metadata