remix 3.0.0-rc.4 → 3.0.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.
- package/INDEX.md +6 -21
- package/README.md +1 -1
- package/dist/component/dev/refresh.d.ts +2 -0
- package/dist/component/dev/refresh.d.ts.map +1 -0
- package/dist/{ui → component}/dev/refresh.js +1 -1
- package/dist/component/jsx-dev-runtime.d.ts +2 -0
- package/dist/component/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/{ui → component}/jsx-dev-runtime.js +1 -1
- package/dist/component/jsx-runtime.d.ts +2 -0
- package/dist/component/jsx-runtime.d.ts.map +1 -0
- package/dist/{ui → component}/jsx-runtime.js +1 -1
- package/dist/component/server.d.ts +2 -0
- package/dist/component/server.d.ts.map +1 -0
- package/dist/{ui → component}/server.js +1 -1
- package/dist/component/test.d.ts +2 -0
- package/dist/component/test.d.ts.map +1 -0
- package/dist/{ui → component}/test.js +1 -1
- package/dist/component-hmr/assets.d.ts +2 -0
- package/dist/component-hmr/assets.d.ts.map +1 -0
- package/dist/{ui-hmr.js → component-hmr/assets.js} +1 -1
- package/dist/component-hmr/node.d.ts +3 -0
- package/dist/component-hmr/node.d.ts.map +1 -0
- package/dist/{ui-hmr → component-hmr}/node.js +1 -1
- package/dist/component-hmr/runtime/browser.d.ts +2 -0
- package/dist/component-hmr/runtime/browser.d.ts.map +1 -0
- package/dist/{ui-hmr → component-hmr}/runtime/browser.js +1 -1
- package/dist/component-hmr/runtime/server.d.ts +2 -0
- package/dist/component-hmr/runtime/server.d.ts.map +1 -0
- package/dist/{ui-hmr → component-hmr}/runtime/server.js +1 -1
- package/dist/component-hmr.d.ts +2 -0
- package/dist/component-hmr.d.ts.map +1 -0
- package/dist/{ui-hmr/assets.js → component-hmr.js} +1 -1
- package/dist/component.d.ts +2 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/{ui/anchor.js → component.js} +1 -1
- package/guides/01-start-here.md +20 -20
- package/guides/02-routing-and-controllers.md +1 -1
- package/guides/03-request-handling.md +1 -1
- package/guides/04-rendering-ui.md +41 -307
- package/guides/05-interactivity.md +42 -37
- package/guides/06-streaming-ui-with-frames.md +28 -70
- package/guides/07-animation.md +41 -35
- package/guides/08-data-and-validation.md +423 -27
- package/guides/09-forms-and-mutations.md +250 -25
- package/guides/13-testing.md +10 -10
- package/guides/14-cli-and-tooling.md +2 -2
- package/package.json +96 -180
- package/src/assets/README.md +12 -12
- package/src/cli/README.md +3 -3
- package/src/{ui → component}/README.md +31 -75
- package/src/{ui → component}/dev/refresh.ts +1 -1
- package/src/{ui → component}/jsx-dev-runtime.ts +1 -1
- package/src/{ui → component}/jsx-runtime.ts +1 -1
- package/src/{ui → component}/server/README.md +8 -8
- package/src/{ui → component}/server.ts +1 -1
- package/src/{ui → component}/test/README.md +6 -6
- package/src/{ui → component}/test.ts +1 -1
- package/src/{ui-hmr → component-hmr}/README.md +13 -13
- package/src/{ui-hmr → component-hmr}/assets.ts +1 -1
- package/src/{ui-hmr → component-hmr}/node.ts +1 -1
- package/src/{ui-hmr → component-hmr}/runtime/browser.ts +1 -1
- package/src/{ui-hmr → component-hmr}/runtime/server.ts +1 -1
- package/{dist/ui/accordion.js → src/component-hmr.ts} +1 -1
- package/{dist/ui/tabs.js → src/component.ts} +1 -1
- package/src/data-table/README.md +2 -1
- package/src/multiple-import-maps-polyfill/README.md +3 -3
- package/src/node-hmr/README.md +6 -6
- package/src/render-middleware/README.md +5 -5
- package/src/spa/README.md +4 -4
- package/src/test/README.md +4 -4
- package/dist/ui/accordion/primitives.d.ts +0 -2
- package/dist/ui/accordion/primitives.d.ts.map +0 -1
- package/dist/ui/accordion/primitives.js +0 -2
- package/dist/ui/accordion.d.ts +0 -2
- package/dist/ui/accordion.d.ts.map +0 -1
- package/dist/ui/anchor.d.ts +0 -2
- package/dist/ui/anchor.d.ts.map +0 -1
- package/dist/ui/animation.d.ts +0 -2
- package/dist/ui/animation.d.ts.map +0 -1
- package/dist/ui/animation.js +0 -2
- package/dist/ui/breadcrumbs.d.ts +0 -2
- package/dist/ui/breadcrumbs.d.ts.map +0 -1
- package/dist/ui/breadcrumbs.js +0 -2
- package/dist/ui/button.d.ts +0 -3
- package/dist/ui/button.d.ts.map +0 -1
- package/dist/ui/button.js +0 -3
- package/dist/ui/checkbox.d.ts +0 -3
- package/dist/ui/checkbox.d.ts.map +0 -1
- package/dist/ui/checkbox.js +0 -3
- package/dist/ui/combobox/primitives.d.ts +0 -2
- package/dist/ui/combobox/primitives.d.ts.map +0 -1
- package/dist/ui/combobox/primitives.js +0 -2
- package/dist/ui/combobox.d.ts +0 -2
- package/dist/ui/combobox.d.ts.map +0 -1
- package/dist/ui/combobox.js +0 -2
- package/dist/ui/dev/refresh.d.ts +0 -2
- package/dist/ui/dev/refresh.d.ts.map +0 -1
- package/dist/ui/input.d.ts +0 -3
- package/dist/ui/input.d.ts.map +0 -1
- package/dist/ui/input.js +0 -3
- package/dist/ui/jsx-dev-runtime.d.ts +0 -2
- package/dist/ui/jsx-dev-runtime.d.ts.map +0 -1
- package/dist/ui/jsx-runtime.d.ts +0 -2
- package/dist/ui/jsx-runtime.d.ts.map +0 -1
- package/dist/ui/listbox.d.ts +0 -2
- package/dist/ui/listbox.d.ts.map +0 -1
- package/dist/ui/listbox.js +0 -2
- package/dist/ui/menu/primitives.d.ts +0 -2
- package/dist/ui/menu/primitives.d.ts.map +0 -1
- package/dist/ui/menu/primitives.js +0 -2
- package/dist/ui/menu.d.ts +0 -2
- package/dist/ui/menu.d.ts.map +0 -1
- package/dist/ui/menu.js +0 -2
- package/dist/ui/popover.d.ts +0 -2
- package/dist/ui/popover.d.ts.map +0 -1
- package/dist/ui/popover.js +0 -2
- package/dist/ui/radio.d.ts +0 -3
- package/dist/ui/radio.d.ts.map +0 -1
- package/dist/ui/radio.js +0 -3
- package/dist/ui/select/primitives.d.ts +0 -2
- package/dist/ui/select/primitives.d.ts.map +0 -1
- package/dist/ui/select/primitives.js +0 -2
- package/dist/ui/select.d.ts +0 -2
- package/dist/ui/select.d.ts.map +0 -1
- package/dist/ui/select.js +0 -2
- package/dist/ui/server.d.ts +0 -2
- package/dist/ui/server.d.ts.map +0 -1
- package/dist/ui/tabs/primitives.d.ts +0 -2
- package/dist/ui/tabs/primitives.d.ts.map +0 -1
- package/dist/ui/tabs/primitives.js +0 -2
- package/dist/ui/tabs.d.ts +0 -2
- package/dist/ui/tabs.d.ts.map +0 -1
- package/dist/ui/test.d.ts +0 -2
- package/dist/ui/test.d.ts.map +0 -1
- package/dist/ui/toggle/primitives.d.ts +0 -2
- package/dist/ui/toggle/primitives.d.ts.map +0 -1
- package/dist/ui/toggle/primitives.js +0 -2
- package/dist/ui/toggle.d.ts +0 -3
- package/dist/ui/toggle.d.ts.map +0 -1
- package/dist/ui/toggle.js +0 -3
- package/dist/ui-hmr/assets.d.ts +0 -2
- package/dist/ui-hmr/assets.d.ts.map +0 -1
- package/dist/ui-hmr/node.d.ts +0 -3
- package/dist/ui-hmr/node.d.ts.map +0 -1
- package/dist/ui-hmr/runtime/browser.d.ts +0 -2
- package/dist/ui-hmr/runtime/browser.d.ts.map +0 -1
- package/dist/ui-hmr/runtime/server.d.ts +0 -2
- package/dist/ui-hmr/runtime/server.d.ts.map +0 -1
- package/dist/ui-hmr.d.ts +0 -2
- package/dist/ui-hmr.d.ts.map +0 -1
- package/dist/ui.d.ts +0 -2
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js +0 -2
- package/src/ui/accordion/README.md +0 -202
- package/src/ui/accordion/primitives.ts +0 -2
- package/src/ui/accordion.ts +0 -2
- package/src/ui/anchor/README.md +0 -196
- package/src/ui/anchor.ts +0 -2
- package/src/ui/animation/README.md +0 -318
- package/src/ui/animation.ts +0 -2
- package/src/ui/breadcrumbs/README.md +0 -55
- package/src/ui/breadcrumbs.ts +0 -2
- package/src/ui/button/README.md +0 -44
- package/src/ui/button.ts +0 -3
- package/src/ui/checkbox/README.md +0 -59
- package/src/ui/checkbox.ts +0 -3
- package/src/ui/combobox/README.md +0 -194
- package/src/ui/combobox/primitives.ts +0 -2
- package/src/ui/combobox.ts +0 -2
- package/src/ui/input/README.md +0 -52
- package/src/ui/input.ts +0 -3
- package/src/ui/listbox/README.md +0 -83
- package/src/ui/listbox.ts +0 -2
- package/src/ui/menu/README.md +0 -161
- package/src/ui/menu/primitives.ts +0 -2
- package/src/ui/menu.ts +0 -2
- package/src/ui/popover/README.md +0 -103
- package/src/ui/popover.ts +0 -2
- package/src/ui/radio/README.md +0 -53
- package/src/ui/radio.ts +0 -3
- package/src/ui/select/README.md +0 -117
- package/src/ui/select/primitives.ts +0 -2
- package/src/ui/select.ts +0 -2
- package/src/ui/tabs/README.md +0 -141
- package/src/ui/tabs/primitives.ts +0 -2
- package/src/ui/tabs.ts +0 -2
- package/src/ui/toggle/README.md +0 -56
- package/src/ui/toggle/primitives.ts +0 -2
- package/src/ui/toggle.ts +0 -3
- package/src/ui-hmr.ts +0 -2
- package/src/ui.ts +0 -2
package/src/ui/input/README.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# input
|
|
2
|
-
|
|
3
|
-
`input` is a style mixin for text inputs. Use `input()` directly on standalone native inputs, or compose `input.root()` with `input.field()` when the input needs inline icons or controls.
|
|
4
|
-
|
|
5
|
-
## Primitive Usage
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
import input from 'remix/ui/input'
|
|
9
|
-
|
|
10
|
-
function ProductFilters() {
|
|
11
|
-
return () => (
|
|
12
|
-
<div>
|
|
13
|
-
<input mix={input()} placeholder="Limit" />
|
|
14
|
-
|
|
15
|
-
<div mix={input.root()}>
|
|
16
|
-
<SearchIcon />
|
|
17
|
-
<input mix={input.field()} placeholder="Search and filter products" />
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Compose app-owned styles when a field needs local layout or adornments:
|
|
25
|
-
|
|
26
|
-
```tsx
|
|
27
|
-
import input from 'remix/ui/input'
|
|
28
|
-
import { filterFieldStyle, filterRootStyle } from './filters.styles'
|
|
29
|
-
|
|
30
|
-
function SearchFilter() {
|
|
31
|
-
return () => (
|
|
32
|
-
<div mix={[filterRootStyle, input.root()]}>
|
|
33
|
-
<SearchIcon />
|
|
34
|
-
<input mix={[filterFieldStyle, input.field()]} placeholder="Search" />
|
|
35
|
-
</div>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## `remix/ui/input`
|
|
41
|
-
|
|
42
|
-
- `input(options)`: styles a standalone native input. `size` may be `'md'` or `'lg'` and defaults to `'md'`.
|
|
43
|
-
- `input.root(options)`: styles a flex input frame for inline icons, buttons, and a child input.
|
|
44
|
-
- `input.field()`: styles the child native input inside `input.root()`.
|
|
45
|
-
- `InputOptions`: accepts `size`.
|
|
46
|
-
- `InputSize`: `'md'` or `'lg'`.
|
|
47
|
-
|
|
48
|
-
## Behavior Notes
|
|
49
|
-
|
|
50
|
-
- `input.root()` uses child selectors to size direct SVG children as presentational icons.
|
|
51
|
-
- Put the icon before or after the field to control its visual position.
|
|
52
|
-
- Focus and disabled states work through the native input; the root mirrors them with `:focus-within` and `:has(input:disabled)`.
|
package/src/ui/input.ts
DELETED
package/src/ui/listbox/README.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# listbox
|
|
2
|
-
|
|
3
|
-
`listbox` is a headless option-list primitive for controlled selection and highlighting. Use it under components like select and combobox, or directly when you need custom listbox markup.
|
|
4
|
-
|
|
5
|
-
## Primitive Usage
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
import type { Handle } from 'remix/ui'
|
|
9
|
-
import * as listbox from 'remix/ui/listbox'
|
|
10
|
-
import type { ListboxValue } from 'remix/ui/listbox'
|
|
11
|
-
import { listStyle, optionStyle } from './listbox.styles'
|
|
12
|
-
|
|
13
|
-
function FrameworkListbox(handle: Handle) {
|
|
14
|
-
let value: ListboxValue = 'remix'
|
|
15
|
-
let activeValue: ListboxValue = 'remix'
|
|
16
|
-
|
|
17
|
-
return () => (
|
|
18
|
-
<listbox.Context
|
|
19
|
-
value={value}
|
|
20
|
-
activeValue={activeValue}
|
|
21
|
-
onSelect={(nextValue) => {
|
|
22
|
-
value = nextValue
|
|
23
|
-
void handle.update()
|
|
24
|
-
}}
|
|
25
|
-
onHighlight={(nextValue) => {
|
|
26
|
-
activeValue = nextValue
|
|
27
|
-
void handle.update()
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
<div aria-label="Frameworks" tabIndex={0} mix={[listStyle, listbox.list()]}>
|
|
31
|
-
{frameworks.map((option) => (
|
|
32
|
-
<div key={option.value} mix={[optionStyle, listbox.option(option)]}>
|
|
33
|
-
{option.label}
|
|
34
|
-
</div>
|
|
35
|
-
))}
|
|
36
|
-
</div>
|
|
37
|
-
</listbox.Context>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let frameworks = [
|
|
42
|
-
{ label: 'Remix', value: 'remix' },
|
|
43
|
-
{ disabled: true, label: 'React Router', value: 'react-router' },
|
|
44
|
-
{ label: 'React', value: 'react' },
|
|
45
|
-
{ label: 'Preact', value: 'preact' },
|
|
46
|
-
]
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Use `textValue` when the visible label is not the best string for typeahead search.
|
|
50
|
-
|
|
51
|
-
```tsx
|
|
52
|
-
<div
|
|
53
|
-
mix={[
|
|
54
|
-
optionStyle,
|
|
55
|
-
listbox.option({
|
|
56
|
-
label: 'Staging',
|
|
57
|
-
textValue: 'beta',
|
|
58
|
-
value: 'staging',
|
|
59
|
-
}),
|
|
60
|
-
]}
|
|
61
|
-
>
|
|
62
|
-
Staging
|
|
63
|
-
</div>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## `remix/ui/listbox`
|
|
67
|
-
|
|
68
|
-
- `listbox.Context`: provider for controlled `value` and `activeValue`, option registration, selection, highlighting, optional ref access, `flashSelection`, `selectionFlashAttribute`, and `onSelectSettled`.
|
|
69
|
-
- `listbox.list()`: mixin that wires `role="listbox"`, default `tabIndex={-1}`, keyboard navigation, focus scrolling, and typeahead highlighting.
|
|
70
|
-
- `listbox.option(options)`: mixin that registers an option with required `label` and `value`, optional `disabled` and `textValue`, and wires `role="option"`, id, selected, disabled, highlighted, mouse, and click behavior.
|
|
71
|
-
- `ListboxValue`: selected or active value, represented as `string | null`.
|
|
72
|
-
- `ListboxContext` and `ListboxProviderProps`: provider context and prop types for controlled listboxes.
|
|
73
|
-
- `ListboxOption`: option input shape with `label`, `value`, optional `disabled`, and optional `textValue`.
|
|
74
|
-
- `ListboxRegisteredOption`: registered option metadata passed to callbacks and refs.
|
|
75
|
-
- `ListboxRef`: live ref object exposing active/selected options, option navigation, search matching, scrolling, and selection helpers.
|
|
76
|
-
|
|
77
|
-
## Behavior Notes
|
|
78
|
-
|
|
79
|
-
- Selection and highlighting are controlled. `onSelect` and `onHighlight` notify the parent, but DOM state updates after the parent rerenders with new values.
|
|
80
|
-
- Disabled options are skipped by keyboard navigation, typeahead, mouse movement, and click selection.
|
|
81
|
-
- Arrow keys wrap through enabled options. `Home` and `End` move to enabled boundaries. `Enter` and Space select the active option.
|
|
82
|
-
- Typeahead highlights the next matching enabled option without selecting it and supports `textValue`.
|
|
83
|
-
- `flashSelection` applies `selectionFlashAttribute` for 60ms, delays `onSelectSettled`, and ignores new highlight/select interactions until the flash completes.
|
package/src/ui/listbox.ts
DELETED
package/src/ui/menu/README.md
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
# menu
|
|
2
|
-
|
|
3
|
-
`Menu` renders a button-triggered menu with keyboard navigation, checked items, selection events, and nested submenus. Use it for action menus and command groups.
|
|
4
|
-
|
|
5
|
-
## Component Usage
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
import type { Handle } from 'remix/ui'
|
|
9
|
-
import { css } from 'remix/ui'
|
|
10
|
-
import { Menu, MenuItem, Submenu } from 'remix/ui/menu'
|
|
11
|
-
import { onMenuSelect } from 'remix/ui/menu/primitives'
|
|
12
|
-
|
|
13
|
-
export function ViewMenu(handle: Handle) {
|
|
14
|
-
let wordWrap = false
|
|
15
|
-
let density = 'comfortable'
|
|
16
|
-
|
|
17
|
-
return () => (
|
|
18
|
-
<Menu
|
|
19
|
-
label="View"
|
|
20
|
-
mix={onMenuSelect((event) => {
|
|
21
|
-
if (event.item.name === 'wordWrap') {
|
|
22
|
-
wordWrap = event.item.checked ?? false
|
|
23
|
-
} else if (event.item.name === 'density' && event.item.value) {
|
|
24
|
-
density = event.item.value
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
void handle.update()
|
|
28
|
-
})}
|
|
29
|
-
>
|
|
30
|
-
<MenuItem checked={wordWrap} name="wordWrap" type="checkbox">
|
|
31
|
-
Word wrap
|
|
32
|
-
</MenuItem>
|
|
33
|
-
<MenuItem disabled name="minimap">
|
|
34
|
-
Minimap
|
|
35
|
-
</MenuItem>
|
|
36
|
-
<hr mix={separatorStyle} />
|
|
37
|
-
<MenuItem checked={density === 'compact'} name="density" type="radio" value="compact">
|
|
38
|
-
Compact
|
|
39
|
-
</MenuItem>
|
|
40
|
-
<MenuItem checked={density === 'comfortable'} name="density" type="radio" value="comfortable">
|
|
41
|
-
Comfortable
|
|
42
|
-
</MenuItem>
|
|
43
|
-
<Submenu label="Zoom">
|
|
44
|
-
<MenuItem name="zoomIn" value="zoom-in">
|
|
45
|
-
Zoom in
|
|
46
|
-
</MenuItem>
|
|
47
|
-
<MenuItem name="zoomOut" value="zoom-out">
|
|
48
|
-
Zoom out
|
|
49
|
-
</MenuItem>
|
|
50
|
-
</Submenu>
|
|
51
|
-
</Menu>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let separatorStyle = css({
|
|
56
|
-
border: 0,
|
|
57
|
-
borderBlockStart: '1px solid #e5e7eb',
|
|
58
|
-
marginBlock: '4px',
|
|
59
|
-
})
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Use `label` or `searchValue` when the rendered item content is not the text that should be used for event labels or typeahead.
|
|
63
|
-
|
|
64
|
-
```tsx
|
|
65
|
-
<MenuItem label="Open command palette" name="commandPalette" searchValue="palette">
|
|
66
|
-
Command palette
|
|
67
|
-
</MenuItem>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Use `menuLabel` when the menu surface needs a different accessible label from the visible trigger.
|
|
71
|
-
|
|
72
|
-
```tsx
|
|
73
|
-
<Menu label="..." menuLabel="Project actions">
|
|
74
|
-
<MenuItem name="rename">Rename project</MenuItem>
|
|
75
|
-
</Menu>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Use `menu.contextTrigger()` with `menu.Context` and `MenuList` when a menu should open at the right-click location of an element.
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
81
|
-
import { MenuItem, MenuList } from 'remix/ui/menu'
|
|
82
|
-
import * as menu from 'remix/ui/menu/primitives'
|
|
83
|
-
|
|
84
|
-
export function FileContextMenu(handle: Handle) {
|
|
85
|
-
return () => (
|
|
86
|
-
<menu.Context label="File actions">
|
|
87
|
-
<div mix={menu.contextTrigger()} tabIndex={0}>
|
|
88
|
-
File.txt
|
|
89
|
-
</div>
|
|
90
|
-
<MenuList>
|
|
91
|
-
<MenuItem name="rename">Rename</MenuItem>
|
|
92
|
-
<MenuItem name="delete">Delete</MenuItem>
|
|
93
|
-
</MenuList>
|
|
94
|
-
</menu.Context>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Attach `onMenuSelect(...)` from `remix/ui/menu/primitives` to `MenuList` or a shared ancestor when using lower-level context menu composition.
|
|
100
|
-
|
|
101
|
-
## Primitive Usage
|
|
102
|
-
|
|
103
|
-
Use only the lower-level primitives when app code owns the trigger, surface, and item markup:
|
|
104
|
-
|
|
105
|
-
```tsx
|
|
106
|
-
import * as menu from 'remix/ui/menu/primitives'
|
|
107
|
-
import { itemStyle, listStyle, popoverStyle, triggerStyle } from './menu.styles'
|
|
108
|
-
|
|
109
|
-
export function PrimitiveMenu() {
|
|
110
|
-
return (
|
|
111
|
-
<menu.Context label="Project actions">
|
|
112
|
-
<button mix={[triggerStyle, menu.trigger()]} type="button">
|
|
113
|
-
Actions
|
|
114
|
-
</button>
|
|
115
|
-
<div mix={[popoverStyle, menu.popover()]}>
|
|
116
|
-
<div mix={[listStyle, menu.list()]}>
|
|
117
|
-
<div mix={[itemStyle, menu.item({ name: 'rename' })]}>Rename</div>
|
|
118
|
-
<div mix={[itemStyle, menu.item({ disabled: true, name: 'archive' })]}>Archive</div>
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
</menu.Context>
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## `remix/ui/menu`
|
|
127
|
-
|
|
128
|
-
- `Menu`: composed trigger, popover, and list component for the common menu case.
|
|
129
|
-
- `MenuItem`: menu item component. Supports regular, checkbox, and radio item roles through `type`, `checked`, `name`, `value`, `label`, `disabled`, and `searchValue`.
|
|
130
|
-
- `Submenu`: nested menu component with its own trigger and child menu surface.
|
|
131
|
-
- `MenuList`: lower-level styled list component for custom composition inside `menu.Context`.
|
|
132
|
-
- `buttonStyle`, `popoverStyle`, `listStyle`, `itemStyle`, `itemSlotStyle`, `itemLabelStyle`, `itemIndicatorStyle`, and `triggerIndicatorStyle`: flat style mixins used by the component markup.
|
|
133
|
-
- `MenuProps`, `MenuItemProps`, `MenuListProps`, and `SubmenuProps`: public TypeScript props for the composed APIs.
|
|
134
|
-
|
|
135
|
-
## `remix/ui/menu/primitives`
|
|
136
|
-
|
|
137
|
-
- `Context`: lower-level provider for custom menu composition.
|
|
138
|
-
- `trigger()`: wires a button-style trigger to open the root menu.
|
|
139
|
-
- `contextTrigger()`: opens the root menu from a `contextmenu` event at pointer coordinates, or from keyboard context-menu shortcuts.
|
|
140
|
-
- `popover()`: wires the menu popover surface.
|
|
141
|
-
- `list()`: wires the menu list root, focus handling, keyboard navigation, and typeahead.
|
|
142
|
-
- `item(...)`: registers one menu item. Supports regular, checkbox, and radio roles through `type`, `checked`, `name`, `value`, `label`, `disabled`, and `searchValue`.
|
|
143
|
-
- `submenuTrigger(...)`: registers a menu item that opens a child menu.
|
|
144
|
-
- `onMenuSelect(...)`: event mixin for the bubbling `MenuSelectEvent`.
|
|
145
|
-
- `MenuSelectEvent`: bubbling event whose `item` describes the selected item.
|
|
146
|
-
- `MenuSelectItem`, `MenuProviderProps`, `MenuTriggerOptions`, `MenuContextTriggerOptions`, `MenuItemOptions`, and `SubmenuTriggerOptions`: public TypeScript event, prop, and option types for the primitives.
|
|
147
|
-
|
|
148
|
-
## Behavior Notes
|
|
149
|
-
|
|
150
|
-
- Click opens the root menu and focuses the list; clicking the trigger again closes it and restores focus.
|
|
151
|
-
- `menu.contextTrigger()` opens the root menu from a `contextmenu` event at the pointer coordinates and supports keyboard opening with the Context Menu key or Shift+F10.
|
|
152
|
-
- `ArrowDown` opens from the trigger at the first enabled item. `ArrowUp` opens at the last enabled item. Enter and Space open the menu with focus on the list.
|
|
153
|
-
- Keyboard navigation skips disabled items and does not wrap past the first or last enabled item.
|
|
154
|
-
- `Home` and `End` move to the first and last enabled item. Enter and Space activate the highlighted item.
|
|
155
|
-
- Printable keys use typeahead. Typeahead matches `searchValue` when provided and otherwise uses the item label.
|
|
156
|
-
- Submenus open with `ArrowRight`, close with `ArrowLeft`, and are anchored to the submenu trigger with `right-start` placement.
|
|
157
|
-
- Pointer movement highlights enabled items. Submenus open after a short focus/pointer delay and use hover aim so they stay open while moving toward the child surface.
|
|
158
|
-
- Selecting a regular item flashes that item. Selecting a checkbox or radio item flashes the committed checked state.
|
|
159
|
-
- Selection dispatches one bubbled `MenuSelectEvent`, closes the full menu tree, and restores focus to the root trigger.
|
|
160
|
-
- The composed `Menu` re-dispatches selection from its trigger so handlers on the `Menu` button and shared ancestors see the event once.
|
|
161
|
-
- `menuLabel`, `Submenu.menuLabel`, and `Submenu.listProps` let composed menus label and customize menu surfaces separately from trigger content.
|
package/src/ui/menu.ts
DELETED
package/src/ui/popover/README.md
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# popover
|
|
2
|
-
|
|
3
|
-
`popover` is a low-level primitive for anchored, dismissible floating panels.
|
|
4
|
-
|
|
5
|
-
Use it for custom surfaces like filters, inspectors, and view options. Higher-level widgets like menu, select, and combobox should build on top of it instead of exposing raw `popover.*` mixins directly.
|
|
6
|
-
|
|
7
|
-
## Primitive Usage
|
|
8
|
-
|
|
9
|
-
```tsx
|
|
10
|
-
import { on, type Handle } from 'remix/ui'
|
|
11
|
-
import * as popover from 'remix/ui/popover'
|
|
12
|
-
import { panelStyle } from './popover.styles'
|
|
13
|
-
|
|
14
|
-
export function ViewOptions(handle: Handle) {
|
|
15
|
-
let open = false
|
|
16
|
-
|
|
17
|
-
function openPopover() {
|
|
18
|
-
open = true
|
|
19
|
-
void handle.update()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function closePopover() {
|
|
23
|
-
open = false
|
|
24
|
-
void handle.update()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return () => (
|
|
28
|
-
<popover.Context>
|
|
29
|
-
<button
|
|
30
|
-
mix={[
|
|
31
|
-
popover.anchor({ placement: 'bottom-end' }),
|
|
32
|
-
popover.focusOnHide(),
|
|
33
|
-
on('click', openPopover),
|
|
34
|
-
]}
|
|
35
|
-
type="button"
|
|
36
|
-
>
|
|
37
|
-
View options
|
|
38
|
-
</button>
|
|
39
|
-
|
|
40
|
-
<div
|
|
41
|
-
mix={[
|
|
42
|
-
panelStyle,
|
|
43
|
-
popover.surface({
|
|
44
|
-
open,
|
|
45
|
-
onHide() {
|
|
46
|
-
closePopover()
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
]}
|
|
50
|
-
>
|
|
51
|
-
<button mix={[popover.focusOnShow(), on('click', closePopover)]} type="button">
|
|
52
|
-
Close
|
|
53
|
-
</button>
|
|
54
|
-
<div>Panel content</div>
|
|
55
|
-
</div>
|
|
56
|
-
</popover.Context>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## `remix/ui/popover`
|
|
62
|
-
|
|
63
|
-
### `popover.Context`
|
|
64
|
-
|
|
65
|
-
Provides shared coordination for one popover instance. Render the anchor, any focus targets, and the surface inside the same context.
|
|
66
|
-
|
|
67
|
-
### `popover.anchor(options)`
|
|
68
|
-
|
|
69
|
-
Registers the host element as the anchor for the current popover surface.
|
|
70
|
-
|
|
71
|
-
### `popover.surface({ open, onHide, ... })`
|
|
72
|
-
|
|
73
|
-
Turns the host into the controlled popover surface.
|
|
74
|
-
|
|
75
|
-
- Wires `popover="manual"` and native `showPopover()` / `hidePopover()` behavior.
|
|
76
|
-
- Calls `onHide` for `Escape` and outside clicks with a `PopoverHideRequest`.
|
|
77
|
-
- Restores focus to the registered hide target unless `restoreFocusOnHide: false`.
|
|
78
|
-
- Accepts `closeOnAnchorClick: false` when the anchor must stay interactive while open.
|
|
79
|
-
|
|
80
|
-
Apply this to the actual floating root, not a nested child.
|
|
81
|
-
|
|
82
|
-
### `popover.focusOnShow()`
|
|
83
|
-
|
|
84
|
-
Registers the element that should receive focus when the popover opens.
|
|
85
|
-
|
|
86
|
-
### `popover.focusOnHide()`
|
|
87
|
-
|
|
88
|
-
Registers the element that should receive focus again when the popover closes.
|
|
89
|
-
|
|
90
|
-
### Primitive Types
|
|
91
|
-
|
|
92
|
-
- `PopoverContext`: context object exposed by `popover.Context`.
|
|
93
|
-
- `PopoverProps`: provider props for one popover instance.
|
|
94
|
-
- `PopoverSurfaceOptions`: options accepted by `popover.surface(...)`.
|
|
95
|
-
- `PopoverHideRequest`: hide request passed to `onHide`.
|
|
96
|
-
|
|
97
|
-
## Behavior Notes
|
|
98
|
-
|
|
99
|
-
- Opening anchors the surface to the registered anchor and locks page scrolling until close.
|
|
100
|
-
- `onHide` receives `{ reason: 'escape-key' | 'outside-click', target? }`.
|
|
101
|
-
- `popover.focusOnShow()` wins on open when present.
|
|
102
|
-
- `popover.focusOnHide()` is used on close by default when focus restoration is enabled.
|
|
103
|
-
- `closeOnAnchorClick: false` keeps anchor clicks inside the current session, which is useful for input-driven popovers like comboboxes.
|
package/src/ui/popover.ts
DELETED
package/src/ui/radio/README.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# radio
|
|
2
|
-
|
|
3
|
-
`radio` is a style mixin for native radio inputs. It only owns radio visuals and the default `type="radio"` behavior for native `<input>` hosts.
|
|
4
|
-
|
|
5
|
-
## Primitive Usage
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
import radio from 'remix/ui/radio'
|
|
9
|
-
|
|
10
|
-
function ShippingSpeed() {
|
|
11
|
-
return () => (
|
|
12
|
-
<fieldset>
|
|
13
|
-
<label>
|
|
14
|
-
<input defaultChecked mix={radio()} name="shipping-speed" value="standard" />
|
|
15
|
-
Standard
|
|
16
|
-
</label>
|
|
17
|
-
<label>
|
|
18
|
-
<input mix={radio({ size: 'lg' })} name="shipping-speed" value="express" />
|
|
19
|
-
Express
|
|
20
|
-
</label>
|
|
21
|
-
</fieldset>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Compose app-owned styles around the primitive when a radio option needs local layout:
|
|
27
|
-
|
|
28
|
-
```tsx
|
|
29
|
-
import radio from 'remix/ui/radio'
|
|
30
|
-
import { optionStyle } from './shipping.styles'
|
|
31
|
-
|
|
32
|
-
function ShippingOption() {
|
|
33
|
-
return () => (
|
|
34
|
-
<label mix={optionStyle}>
|
|
35
|
-
<input mix={radio()} name="shipping-speed" value="overnight" />
|
|
36
|
-
Overnight
|
|
37
|
-
</label>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## `remix/ui/radio`
|
|
43
|
-
|
|
44
|
-
- `radio(options)`: style mixin for native radio inputs or radio-like hosts.
|
|
45
|
-
- `RadioOptions`: accepts `size`.
|
|
46
|
-
- `RadioSize`: `'md'` or `'lg'`. Defaults to `'md'`.
|
|
47
|
-
|
|
48
|
-
## Behavior Notes
|
|
49
|
-
|
|
50
|
-
- `radio()` returns a mixin descriptor, so it composes with other mixins in the host element's `mix` prop.
|
|
51
|
-
- Native `<input>` hosts receive `type="radio"` unless an explicit `type` is provided.
|
|
52
|
-
- Radio state is native browser behavior. The mixin also styles `aria-checked="true"` and `data-state="checked"` for custom hosts.
|
|
53
|
-
- Disabled hosts use the shared disabled treatment through `disabled` or `aria-disabled="true"`.
|
package/src/ui/radio.ts
DELETED
package/src/ui/select/README.md
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# select
|
|
2
|
-
|
|
3
|
-
`Select` is a button-triggered popup value picker backed by `listbox` and `popover`. Use it when the user should choose one stable string value from a finite set.
|
|
4
|
-
|
|
5
|
-
## Component Usage
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
import { Option, Select } from 'remix/ui/select'
|
|
9
|
-
import { onSelectChange } from 'remix/ui/select/primitives'
|
|
10
|
-
|
|
11
|
-
export function FrameworkSelect() {
|
|
12
|
-
return (
|
|
13
|
-
<Select
|
|
14
|
-
defaultLabel="Select a framework"
|
|
15
|
-
defaultValue="remix"
|
|
16
|
-
name="framework"
|
|
17
|
-
mix={onSelectChange((event) => {
|
|
18
|
-
console.log(event.value, event.label, event.optionId)
|
|
19
|
-
})}
|
|
20
|
-
>
|
|
21
|
-
<Option label="Remix framework" value="remix">
|
|
22
|
-
Remix
|
|
23
|
-
</Option>
|
|
24
|
-
<Option disabled label="React Router framework" value="react-router">
|
|
25
|
-
React Router
|
|
26
|
-
</Option>
|
|
27
|
-
<Option label="React framework" value="react">
|
|
28
|
-
React
|
|
29
|
-
</Option>
|
|
30
|
-
</Select>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Use `textValue` when closed-trigger typeahead should match a different string from the visible label.
|
|
36
|
-
|
|
37
|
-
```tsx
|
|
38
|
-
<Select defaultLabel="Select an environment">
|
|
39
|
-
<Option label="Production environment" value="production">
|
|
40
|
-
Production
|
|
41
|
-
</Option>
|
|
42
|
-
<Option label="Staging environment" textValue="beta" value="staging">
|
|
43
|
-
Staging
|
|
44
|
-
</Option>
|
|
45
|
-
</Select>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Primitive Usage
|
|
49
|
-
|
|
50
|
-
Use the lower-level primitives when the trigger or popup structure needs to be owned by another component. Keep the same provider, trigger, popover, list, option, and hidden-input relationship.
|
|
51
|
-
|
|
52
|
-
```tsx
|
|
53
|
-
import type { Handle } from 'remix/ui'
|
|
54
|
-
import * as popover from 'remix/ui/popover'
|
|
55
|
-
import { triggerStyle } from 'remix/ui/select'
|
|
56
|
-
import * as select from 'remix/ui/select/primitives'
|
|
57
|
-
import { listStyle, optionStyle, surfaceStyle } from './select.styles'
|
|
58
|
-
|
|
59
|
-
function SelectValue(handle: Handle) {
|
|
60
|
-
let context = handle.context.get(select.Context)
|
|
61
|
-
|
|
62
|
-
return () => <span>{context.displayedLabel}</span>
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function IssueTypeSelect() {
|
|
66
|
-
return () => (
|
|
67
|
-
<select.Context defaultLabel="Select a type" labelSwapDelayMs={100} name="issueType">
|
|
68
|
-
<button type="button" mix={[triggerStyle, select.trigger()]}>
|
|
69
|
-
<SelectValue />
|
|
70
|
-
</button>
|
|
71
|
-
<popover.Context>
|
|
72
|
-
<div mix={[surfaceStyle, select.popover()]}>
|
|
73
|
-
<div mix={[listStyle, select.list()]}>
|
|
74
|
-
<div mix={[optionStyle, select.option({ label: 'Bug', value: 'bug' })]}>Bug</div>
|
|
75
|
-
<div mix={[optionStyle, select.option({ label: 'Feature', value: 'feature' })]}>
|
|
76
|
-
Feature
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</popover.Context>
|
|
81
|
-
<input mix={select.hiddenInput()} />
|
|
82
|
-
</select.Context>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## `remix/ui/select`
|
|
88
|
-
|
|
89
|
-
- `Select`: composed trigger, popover, listbox, option list, and optional hidden input for form participation. Accepts `defaultLabel`, `defaultValue`, `disabled`, `name`, and button props.
|
|
90
|
-
- `Option`: option component that renders the standard check indicator and label slot. Accepts `label`, `value`, optional `disabled`, and optional `textValue`.
|
|
91
|
-
- `triggerStyle`: standard select trigger style for custom trigger composition.
|
|
92
|
-
- `SelectProps` and `SelectOptionProps`: public TypeScript props for the composed APIs.
|
|
93
|
-
|
|
94
|
-
## `remix/ui/select/primitives`
|
|
95
|
-
|
|
96
|
-
- `Context`: lower-level provider for custom composition. Accepts `defaultLabel`, `defaultValue`, `disabled`, `name`, and primitive-only `labelSwapDelayMs`; the label-swap delay defaults to `75` milliseconds.
|
|
97
|
-
- `trigger()`: wires the trigger button, open behavior, closed-trigger typeahead, and trigger ARIA attributes.
|
|
98
|
-
- `popover()`: wires the popover surface and keeps its min-width synced to the trigger before open.
|
|
99
|
-
- `list()`: wires the listbox root used inside the popover.
|
|
100
|
-
- `option(...)`: registers one selectable option. Accepts `label`, `value`, optional `disabled`, and optional `textValue`.
|
|
101
|
-
- `hiddenInput()`: mirrors the selected value into a hidden input for form participation.
|
|
102
|
-
- `onSelectChange(...)`: event mixin for the bubbling `SelectChangeEvent`.
|
|
103
|
-
- `SelectChangeEvent`: event with `value`, `label`, and `optionId`.
|
|
104
|
-
- `SelectContextProps`, `SelectProps`, and `SelectOptionProps`: primitive prop types for custom composition.
|
|
105
|
-
|
|
106
|
-
## Behavior Notes
|
|
107
|
-
|
|
108
|
-
- `defaultLabel` is displayed before selection settles. `defaultValue` selects the matching option without replacing the trigger label until a new selection commits.
|
|
109
|
-
- `Option.label` is the committed display label and event label. `children` are the rendered option contents.
|
|
110
|
-
- Click, `ArrowDown`, and `ArrowUp` open the popup. Focus moves into the list and Escape restores focus to the trigger through popover behavior.
|
|
111
|
-
- Reopening highlights the current selected value.
|
|
112
|
-
- The popup min-width syncs to the trigger width before opening.
|
|
113
|
-
- Closed-trigger typeahead selects a matching option immediately and supports option `textValue`.
|
|
114
|
-
- Selecting an option flashes it with `data-select-flash`, waits for the close transition and label delay, updates the displayed label, and dispatches `SelectChangeEvent`.
|
|
115
|
-
- Selecting the already-selected value updates state but does not dispatch a change event.
|
|
116
|
-
- `SelectChangeEvent` bubbles from the trigger when a trigger exists. It includes `value`, `label`, and `optionId`.
|
|
117
|
-
- Passing `name` renders a hidden input so the selected value participates in `FormData`; disabled selects disable the trigger and hidden input.
|
package/src/ui/select.ts
DELETED