Repository navigation
Release 0.14.0: a command palette, and empty values that stay empty - #18
Merged
Merged
Conversation
A command palette is a widget most modern applications carry and HeroUI's set lacks, so Command is ours in HeroUI's look, as Segment and TrendChip are: a search in a dialog that filters a menu of commands, made headless first of Kobalte's selection hooks, its look a stylesheet of its own. Setting a DatePicker's value to null after a date was typed left the date shown, and sent with a form. Kobalte and the headless parts read null as controlled and empty and undefined as no value given; the binding generator mapped TypeScript's `T | null` to Js.Nullable.t, which also holds undefined, and the hand-written components copied it. So the obvious conversion, Js.Nullable.fromOption, whose None is undefined, turned "empty" into "uncontrolled": the library did it in seven places, and every documented controlled example did it too. A value given to JavaScript as `T | null` is now Js.Null.t, which cannot hold undefined: Js.Null.fromOption None is null, and the wrong conversion no longer compiles. The generator tracks which way a value crosses, so what Kobalte gives back, an on_change's argument, stays Js.Nullable.t, as MELANGE.md asks of a value JavaScript may give as null. An abstract type of our own was weighed and dropped: Js.Null.t already says exactly this. Taking a plain option cannot work, since Melange writes None as undefined. The same audit found RadioGroup with no empty value at all, now `string Js.Null.t` as React's `string | null`; a NumberField that kept its number when set to NaN, Kobalte's, fixed in the headless module; and, compared with HeroUI's React components, a NumberField that told every key where React tells a committed value, and a DateRangePicker whose keys stopped at the edge of each end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A command palette is a widget most modern applications carry and HeroUI's set lacks, so
Commandis ours in HeroUI's look, made headless first of Kobalte's selection hooks, its look a stylesheet of its own.Setting a DatePicker's value to null after a date was typed left the date shown, and sent with a form (
0002-11-21). The binding generator mapped TypeScript'sT | nulltoJs.Nullable.t, which also holds theundefinedKobalte and the headless parts read as "no value given", and the hand-written components copied it. So the obvious conversion,Js.Nullable.fromOption, turned "empty" into "uncontrolled": the library did it in seven places, and every documented controlled example did it too. A value given to JavaScript asT | nullis nowJs.Null.t, which cannot holdundefined, so the wrong conversion no longer compiles; what Kobalte gives back staysJs.Nullable.t, as MELANGE.md asks. An abstract type of our own was weighed and dropped, sinceJs.Null.tsays exactly this; a plainoptioncannot work, since Melange writesNoneasundefined.Changes
Js.Null.t: Kobalte'sT | nullprops and arguments, and the value of the date, time, calendar and colour components, headless and HeroUI.Js.Nullable.fromOption→Js.Null.fromOption.Radio_group'svalueisstring Js.Null.t;nullcontrols it with none chosen, as React's.Command: a command palette in HeroUI's look,Solidtype_headless.Commandbeneath it.nullafter input are empty.nanis empty (Kobalte's, fixed headless), and tells typed text once Enter or leaving commits it, as React's.Verified
make test(1167 tests),make lint, andmake docswith no warnings, on the combined tree.Js.Nullable.fromOptionrefused intest/does_not_compile.t.