@fusion.dev/helix-docs 0.142.1 → 0.143.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.
@@ -65,9 +65,10 @@ it.
65
65
  ## Register the elements
66
66
 
67
67
  ```ts
68
- import '@fusion.dev/helix'
68
+ import '@fusion.dev/helix/button'
69
+ import '@fusion.dev/helix/dialog'
69
70
  ```
70
71
 
71
- Import it once, anywhere that runs in the browser. The stylesheets are the same
72
+ Import each family you use once, anywhere that runs in the browser. The stylesheets are the same
72
73
  in every framework, and they are the part most often left out. See
73
74
  [Installation](./installation) for the stylesheets.
@@ -70,13 +70,27 @@ checks focus by walking through the shadow roots.
70
70
  Nested overlays work because lifecycle events do not bubble.
71
71
  `helix-before-open` and `helix-before-close` do not bubble and are not composed,
72
72
  so a menu that closes inside a dialog does not close the dialog. `Escape` closes
73
- the innermost overlay and leaves the others open.
73
+ the innermost overlay and leaves the others open. The overlay that closes
74
+ cancels the key press, so a `Dialog` or `Drawer` around it stays open until you
75
+ press `Escape` again.
74
76
 
75
77
  ## Where focus goes
76
78
 
77
79
  A modal overlay keeps `Tab` inside itself while it is open, and it returns focus
78
- to the element that opened it. `Dialog` and `Drawer` always do this. `Popover`
79
- does it only in its modal mode.
80
+ to the element that opened it. `Dialog` does this, and so does `Drawer` unless
81
+ you set `modal="false"`. The page behind a modal `Dialog` or `Drawer` does not
82
+ scroll while it is open.
83
+
84
+ `Popover` does not trap focus. When focus moves out of its trigger and its
85
+ panel, the popover closes.
86
+
87
+ The fields with a panel behave the same way:
88
+
89
+ - `Select` and `Combobox` close their list when `Tab` moves focus out.
90
+ - `Date Input`, `Time Input`, and `Color Input` close their panel when focus
91
+ leaves the field, and `Escape` returns focus to the field.
92
+ - Opening one of those panels from its trigger, or with `ArrowDown`, moves
93
+ focus into the panel.
80
94
 
81
95
  **A tooltip never takes focus.** A tooltip only describes a control, so it
82
96
  cannot contain a button. For something with a button in it, use a `Popover`.
package/content/react.mdx CHANGED
@@ -131,7 +131,9 @@ See [State and control](./state-and-control) for the full model.
131
131
 
132
132
  ```tsx
133
133
  'use client'
134
- import '@fusion.dev/helix'
134
+ // One line per family you use.
135
+ import '@fusion.dev/helix/button'
136
+ import '@fusion.dev/helix/dialog'
135
137
 
136
138
  export const HelixElements = () => null
137
139
  ```
@@ -41,20 +41,84 @@ without tracking which element sent each event. A pane named `html` sets the
41
41
  preview's markup, and a pane named `css` sets its stylesheet. The sandbox
42
42
  ignores a pane with any other name, so that pane only displays its contents.
43
43
 
44
+ A pane's text goes in its `value`. The pane renders no children. The sandbox
45
+ also hands each pane's `value` to the preview when it starts, so you write the
46
+ text once, in the pane. A preview given its own `source` keeps it until the
47
+ first edit.
48
+
44
49
  ```html
45
50
  <helix-sandbox>
46
51
  <helix-sandbox-source
47
52
  name="html"
48
53
  slot="source"
49
- >…</helix-sandbox-source>
54
+ value="<p>Hello</p>"
55
+ ></helix-sandbox-source>
50
56
  <helix-sandbox-source
51
57
  name="css"
52
58
  slot="source"
53
- >…</helix-sandbox-source>
54
- <helix-sandbox-preview slot="preview"></helix-sandbox-preview>
59
+ value="p { color: teal }"
60
+ ></helix-sandbox-source>
61
+ <helix-sandbox-preview
62
+ slot="preview"
63
+ src="/frame.html"
64
+ ></helix-sandbox-preview>
55
65
  </helix-sandbox>
56
66
  ```
57
67
 
68
+ Cancel `helix-before-edit` to refuse an edit. The pane keeps its text, and the
69
+ preview does not receive the refused one.
70
+
71
+ In a source pane, Tab inserts two spaces. Shift+Tab moves focus back, and
72
+ Escape then Tab moves it forward. The field's description says this to a
73
+ screen reader.
74
+
75
+ ## The frame document
76
+
77
+ `helix-sandbox-preview` loads `src` into a sandboxed frame. You provide that
78
+ document. It loads the styles and the elements your examples use, and it talks
79
+ to the preview through `postMessage`:
80
+
81
+ | Message | Sent by | What it carries |
82
+ |---|---|---|
83
+ | `helix-preview-console` | The frame | One console call: `level` (`log`, `info`, `warn` or `error`) and `text` |
84
+ | `helix-preview-press` | The frame | Nothing. Send it on `pointerdown`, so menus outside the frame close |
85
+ | `helix-preview-ready` | The frame | Nothing. Send it once the listener for renders is in place |
86
+ | `helix-preview-render` | The preview | `source`, `styles`, `layout`, `direction` and an optional `colorMode` |
87
+ | `helix-preview-size` | The frame | `size`, the height of the content in CSS pixels |
88
+
89
+ Each message is an object with a `type` naming it. The preview sends
90
+ `helix-preview-render` once the frame posts `helix-preview-ready` or fires
91
+ `load`, and again after each edit settles. The frame writes `source` into its
92
+ body and `styles` into a stylesheet. The preview accepts a message only from
93
+ its own frame, and only from an opaque origin, so the frame keeps the sandbox
94
+ it was given. The types are exported from `@fusion.dev/helix/sandbox` as
95
+ `PreviewMessage` and its members.
96
+
97
+ A minimal frame follows. `/helix.css` is the stylesheet from
98
+ `@fusion.dev/helix-styles`, and `/elements.js` is a classic script that
99
+ registers your elements, for the reason under "How the preview is isolated".
100
+
101
+ ```html
102
+ <!doctype html>
103
+ <link
104
+ href="/helix.css"
105
+ rel="stylesheet"
106
+ >
107
+ <script
108
+ defer
109
+ src="/elements.js"
110
+ ></script>
111
+ <style id="example-styles"></style>
112
+ <script defer>
113
+ addEventListener('message', ({ data }) => {
114
+ if (data?.type !== 'helix-preview-render') return
115
+ document.getElementById('example-styles').textContent = data.styles
116
+ document.body.innerHTML = data.source
117
+ })
118
+ parent.postMessage({ type: 'helix-preview-ready' }, '*')
119
+ </script>
120
+ ```
121
+
58
122
  ## Console output from the example
59
123
 
60
124
  Logs from the example appear in the console panel. Logs from the page around it
@@ -52,7 +52,7 @@ browser. Load Lit's hydration support before the components:
52
52
 
53
53
  ```ts
54
54
  import '@lit-labs/ssr-client/lit-element-hydrate-support.js'
55
- import '@fusion.dev/helix'
55
+ import '@fusion.dev/helix/button'
56
56
  ```
57
57
 
58
58
  Hydration assumes the markup already matches the client's first render. If a
@@ -106,6 +106,12 @@ current value. The pair comes from the platform. A native input reflects its
106
106
  `value` *content attribute* to `defaultValue`, and it keeps a dirty flag. Once a
107
107
  user has typed, the flag stops the attribute from changing the value.
108
108
 
109
+ **A form reset clears a `value` or `checked` you wrote in markup.** A native
110
+ `<input value="Ada">` resets to `Ada`, and `<helix-input value="Ada">` resets to
111
+ empty, because a Helix control resets to `default-value` and `default-checked`.
112
+ Write the starting value of a form control as `default-value`, or
113
+ `default-checked` for a checkbox or a switch.
114
+
109
115
  ## State is published as a custom state
110
116
 
111
117
  ```css
@@ -120,7 +126,8 @@ A reflected `value` would carry the password past every session-replay masker
120
126
  that masks `.value` and `input[value]`.
121
127
 
122
128
  Helix publishes the resolved boolean as a custom state, and the attribute keeps
123
- the value you wrote. There are four custom states:
129
+ the value you wrote. These are the most common, and each component's reference
130
+ page lists the states it publishes:
124
131
 
125
132
  - `:state(open)`
126
133
  - `:state(checked)`
@@ -30,7 +30,7 @@ and you do not need a compiler flag.
30
30
  Svelte passes objects and arrays as properties on its own:
31
31
 
32
32
  ```svelte
33
- <helix-tabs items={tabs} />
33
+ <helix-data-table label="People" rows={people} />
34
34
  ```
35
35
 
36
36
  Svelte's own attributes are typed on every Helix tag as well, so `onclick`,
@@ -158,7 +158,11 @@ Mark the section so the stylesheet derives its own colors there from the
158
158
  section's seeds, in the section's mode, and paint it with its page color:
159
159
 
160
160
  ```html
161
- <section data-band data-color-mode="dark" data-helix-theme>…</section>
161
+ <section
162
+ data-band
163
+ data-color-mode="dark"
164
+ data-helix-theme
165
+ >…</section>
162
166
  ```
163
167
 
164
168
  ```css
@@ -120,7 +120,7 @@ looks enabled while it does not accept input.
120
120
 
121
121
  ```ts
122
122
  import '@fusion.dev/helix-styles/helix.css'
123
- import '@fusion.dev/helix'
123
+ import '@fusion.dev/helix/button'
124
124
  ```
125
125
 
126
126
  `helix.css` combines four files in the order they must load:
@@ -90,10 +90,12 @@ button.
90
90
  ## Import `elements.css` beside the base layer
91
91
 
92
92
  ```ts
93
- import '@fusion.dev/helix-styles/base.css'
94
93
  import '@fusion.dev/helix-styles/helix.css'
95
94
  ```
96
95
 
96
+ `helix.css` imports `elements.css` after the primitives, the tokens, and the
97
+ base layer. If you import the layers one at a time, import `elements.css` last.
98
+
97
99
  `elements.css` hides each tag with `:not(:defined)` until the element upgrades.
98
100
  It uses `visibility`, so the page does not reflow. Without it, a card appears as
99
101
  unstyled text and then jumps into its card layout.
@@ -112,6 +114,24 @@ import '@fusion.dev/helix' // ❌ the barrel
112
114
  Import one component family per module, so you do not ship the whole library to
113
115
  use a button.
114
116
 
117
+ ## Turn off an attribute that is on by default
118
+
119
+ A boolean attribute is off until you write it, with four exceptions. These are
120
+ on until you write the string `"false"`:
121
+
122
+ - `modal` on Drawer
123
+ - `playsinline` on Video
124
+ - `default-pinned` on Chat
125
+ - `tab-indents` on Sandbox Source
126
+
127
+ ```html
128
+ <helix-drawer modal="false"></helix-drawer>
129
+ ```
130
+
131
+ In JSX, `modal={false}` sets the property and does the same. Other features
132
+ that are on by default turn off with an attribute named `no-`, such as
133
+ `no-copy`.
134
+
115
135
  ## Declarative shadow DOM is opt-in
116
136
 
117
137
  The site ships no declarative shadow DOM (DSD). The shadow styles load with the
package/content/vue.mdx CHANGED
@@ -42,7 +42,8 @@ That works for every Helix element. A string goes through either path, and an
42
42
  array or an object goes through the property.
43
43
 
44
44
  ```vue
45
- <helix-tabs :items="items" @helix-before-activate="onActivate" />
45
+ <helix-data-table label="People" :rows="people" />
46
+ <helix-tabs @helix-before-activate="onActivate" />
46
47
  ```
47
48
 
48
49
  `@helix-before-activate` binds with `addEventListener`, so use the event's own