@citrusworx/juiceui 0.9.4 → 0.9.5
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/README.md +61 -78
- package/dist/index.css +105 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +170 -2
- package/dist/js/juice.d.ts +2 -0
- package/dist/js/src/keyboard-avoider/keyboard-avoider-runtime.d.ts +96 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,9 +80,11 @@ Built files are `dist/index.css` (core) and `dist/themes/<id>.css`. Each theme i
|
|
|
80
80
|
|
|
81
81
|
## Components and runtimes
|
|
82
82
|
|
|
83
|
-
The top-level JS entry is
|
|
83
|
+
The top-level JS entry is small. Thirty-one runtimes stay Emerging.
|
|
84
84
|
|
|
85
|
-
Navigation through field (twenty-five
|
|
85
|
+
Navigation through field (twenty-five) shipped in `@citrusworx/juiceui@0.9.2`. Icon button, avatar, table, pressable, touchable row, and keyboard avoider are on master and are not in that release. Rows marked **master** are those six.
|
|
86
|
+
|
|
87
|
+
The full index, including how to choose between similar components, is [Runtime behavior](../../docs/juice/juice-runtime-behavior.md#components).
|
|
86
88
|
|
|
87
89
|
### Overlays
|
|
88
90
|
|
|
@@ -142,19 +144,23 @@ Navigation through field (twenty-five runtimes) are in the published `@citruswor
|
|
|
142
144
|
| Component | Markup | What it is | Docs |
|
|
143
145
|
| --- | --- | --- | --- |
|
|
144
146
|
| Avatar (**master**) | `[avatar]` | Initials or photo (`sync` / `getState`). Not a badge and not `[skeleton="circle"]`. The twenty-seventh Emerging runtime. Not in npm 0.9.2. | [Avatar](../../docs/juice/juice-avatar.md) |
|
|
145
|
-
| Table (**master**) | `<table table>` | Sortable grid
|
|
147
|
+
| Table (**master**) | `<table table>` | Sortable grid. The twenty-eighth runtime. Not in npm 0.9.2. | [Table](../../docs/juice/juice-table.md) |
|
|
146
148
|
|
|
147
|
-
###
|
|
149
|
+
### Page chrome
|
|
150
|
+
|
|
151
|
+
| Component | Markup | What it is | Docs |
|
|
152
|
+
| --- | --- | --- | --- |
|
|
153
|
+
| Keyboard avoider (**master**) | `[keyboard-avoider]` | Inset while the software keyboard is open. The thirty-first runtime. Not in npm 0.9.2. Not a `JuiceRuntimeName`. | [Keyboard avoider](../../docs/juice/juice-keyboard-avoider-runtime.md) |
|
|
148
154
|
|
|
149
|
-
|
|
155
|
+
### Auto-start
|
|
150
156
|
|
|
151
|
-
|
|
157
|
+
Importing `@citrusworx/juiceui` enhances the hooks in the tables above. Most apps need no `init` call.
|
|
152
158
|
|
|
153
159
|
The JS module is optional. Core CSS plus a theme is enough when the page does not use a runtime.
|
|
154
160
|
|
|
155
161
|
### Naming pattern
|
|
156
162
|
|
|
157
|
-
Every runtime exports the same four functions. `<Name>` is the stem
|
|
163
|
+
Every runtime exports the same four functions. `<Name>` is the component stem, such as `Modal` or `KeyboardAvoider`.
|
|
158
164
|
|
|
159
165
|
| Export | What it does |
|
|
160
166
|
| --- | --- |
|
|
@@ -163,7 +169,7 @@ Every runtime exports the same four functions. `<Name>` is the stem: Navigation,
|
|
|
163
169
|
| `start<Name>Runtime()` | Boots the document-level controller that enhances matching markup. A second call syncs and returns that controller. Returns `null` when there is no document. |
|
|
164
170
|
| `stop<Name>Runtime()` | Destroys that document-level controller. |
|
|
165
171
|
|
|
166
|
-
Modal shows the four export names. The other
|
|
172
|
+
Modal shows the four export names. The other thirty use the same `create` / `init` / `start` / `stop` names. Controller methods differ by runtime.
|
|
167
173
|
|
|
168
174
|
```ts
|
|
169
175
|
import {
|
|
@@ -184,13 +190,26 @@ stopModalRuntime();
|
|
|
184
190
|
|
|
185
191
|
`tokens` is the shared token object: color families and swatches, and the `adobe` and `google` font providers. `Accordion` is a Sig component that renders one `[accordion]` section (trigger plus panel). It is not the document runtime. The runtime is `createAccordion` / `startAccordionRuntime`.
|
|
186
192
|
|
|
187
|
-
Icon button, avatar, table, pressable,
|
|
193
|
+
Icon button, avatar, table, pressable, touchable row, and keyboard avoider export the same four names on master. Those twenty-four functions are not in `@citrusworx/juiceui@0.9.2`.
|
|
188
194
|
|
|
189
195
|
### `juice:change` and `getState`
|
|
190
196
|
|
|
191
|
-
Interactive runtimes dispatch a bubbling `juice:change`
|
|
197
|
+
Interactive runtimes dispatch a bubbling `juice:change` from the widget host when observable state changes. `detail` is `{ runtime, state }`. `getState()` reads that shape.
|
|
198
|
+
|
|
199
|
+
Select, input, and textarea publish through native `input` and `change`. They still expose `getState()`.
|
|
200
|
+
|
|
201
|
+
The contract covers all thirty-one runtimes. It is on master, unreleased after 0.9.2. `JUICE_CHANGE_EVENT` is not in the published 0.9.2 types.
|
|
202
|
+
|
|
203
|
+
`@citrusworx/sigjs/juice` `bind` names twenty-eight runtimes, through `table`, on master and in `@citrusworx/sigjs@0.7.2`.
|
|
204
|
+
|
|
205
|
+
- `icon-button`, `avatar`, and `table` are `JuiceRuntimeName` values.
|
|
206
|
+
- Pressable, touchable row, and keyboard avoider are not.
|
|
207
|
+
- `@citrusworx/sigjs@0.7.0` and `@citrusworx/sigjs@0.7.1` stop at twenty-five names, through `textarea`.
|
|
208
|
+
- Binding `icon-button`, `avatar`, or `table` against `@citrusworx/juiceui@0.9.2` throws. That cut does not export their start functions.
|
|
209
|
+
|
|
210
|
+
Juice works without Sig. The optional adapter is `@citrusworx/sigjs/juice` only.
|
|
192
211
|
|
|
193
|
-
|
|
212
|
+
See [`juice:change`](../../docs/juice/juice-runtime-behavior.md#juicechange) and [Sig.js + Juice](../../docs/sigjs/sig-juice-integration.md#runtime-binding).
|
|
194
213
|
|
|
195
214
|
### Markup examples
|
|
196
215
|
|
|
@@ -313,79 +332,26 @@ Interactive runtimes dispatch a bubbling `juice:change` event from the widget ho
|
|
|
313
332
|
|
|
314
333
|
### Notes
|
|
315
334
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
**Navigation.** A mobile nav toggle should expose an accessible name and control a sidebar with `aria-controls`. The runtime watches `nav[type="bar"]`, `nav[type="links"]`, `nav[type="mobile"]` (the toggle), and `nav[type="sidebar"]`.
|
|
319
|
-
|
|
320
|
-
**Accordion.** Triggers should use `aria-expanded` and `aria-controls`. Panels should be labeled regions when they contain meaningful content. Chrome colors come from `--juice-accordion-*` roles bound by the active theme. Every shipped theme binds them, including the retro family. Group FAQ stacks in a card or panel surface (`[aqua-card]` / `[aqua-panel]` under Aquaflux, `[tide-card]` / `[tide-panel]` under Tide) so the accordion wrapper stays structural. Open and closed panels use the native `hidden` attribute. Do not use `content="active"` or `content="hidden"` for accordion state. Those clash with layout `[content]`. Optional `[motion="accordion"]` is height easing, not required for show and hide.
|
|
321
|
-
|
|
322
|
-
**Tabs.** Tabs live under a `[tabs]` root with `[tabs-list]`, `[tab]` triggers, and `[tab-panel]` panels. Orphan triggers and panels are ignored. Selection dual-writes Juice `[active]` and `aria-selected`. The runtime also wires `role="tablist"` / `tab` / `tabpanel`, roving tabindex, and labeled panels. Chrome colors come from `--juice-tabs-*` roles bound by the active theme. Every shipped theme binds them, and generated themes bind `--jx-tabs-*` aliases. Visible and hidden panels use the native `hidden` attribute. Do not use `content="active"` or `content="hidden"` for panel state.
|
|
323
|
-
|
|
324
|
-
**Modal.** Chrome colors come from `--juice-modal-*` roles bound by the active theme. Hide `[modal-overlay]` with the native `hidden` attribute. Openers use `aria-controls` pointing at the overlay id. The dialog runtime auto-enhances that markup (open/close, Escape, focus trap, exclusive).
|
|
325
|
-
|
|
326
|
-
**Drawer.** Chrome colors come from `--juice-drawer-*` roles bound by the active theme. Hide `[drawer-overlay]` with the native `hidden` attribute. Openers use `aria-controls` pointing at the overlay id. The dialog runtime auto-enhances that markup (open/close, Escape, focus trap, exclusive). Edge is `[drawer]` / `[drawer="left"|"right"]`. Optional width is `[drawer-size="sm|lg"]`.
|
|
327
|
-
|
|
328
|
-
**Toast.** Chrome colors come from `--juice-toast-*` roles bound by the active theme. `[toast-region]` is a non-modal stack (default `top-right`). Hide an individual `[toast]` with the native `hidden` attribute. Status is `[toast="success|error|info|warning"]`. The runtime auto-enhances that markup (`show` / `dismiss`, `[toast-close]`, `toast-duration`, live-region ARIA). It is not a dialog: no focus trap, no `aria-modal`, and stacking is allowed.
|
|
329
|
-
|
|
330
|
-
**Popover.** Chrome colors come from `--juice-popover-*` roles bound by the active theme. Hide `[popover-root]` with the native `hidden` attribute. Openers use `aria-controls` pointing at the root id. The runtime auto-enhances that markup (open/close, Escape, outside click, Tab trap, exclusive, one-axis flip). The panel is a non-modal dialog (`role="dialog"`, no `aria-modal`). Never use a bare `popover` attribute. The surface is `[popover-panel]`. Placement is `[popover-root]` / `[popover-root="bottom"]` (default), `"top"`, `"left"`, `"right"`.
|
|
331
|
-
|
|
332
|
-
**Wizard.** Chrome colors come from `--juice-wizard-*` roles bound by the active theme. Scope is `[wizard-shell]`. The runtime paints `[step="pending"|"active"|"completed"]`, shows one `[step-page]` with native `hidden`, and wires `[wizard-prev]` / `[wizard-next]` (or unmarked buttons in `[step-nav]`). Default navigation jumps to completed plus current. `wizard-shell="linear"` is prev/next only. `wizard-shell="free"` jumps to any step. Do not use `content="active"` or `content="hidden"` for page state.
|
|
333
|
-
|
|
334
|
-
**Tooltip.** Chrome colors come from `--juice-tooltip-*` roles bound by the active theme. Hide `[tooltip-root]` with the native `hidden` attribute. Triggers prefer `aria-describedby` pointing at the root id (`aria-controls` is also accepted). The runtime auto-enhances that markup (show/hide, Escape, exclusive, one-axis flip). There is no focus trap. Focus never moves into the tip. Never use a bare `tooltip` attribute or native `title`. The surface is `[tooltip-panel]`. Placement is `[tooltip-root]` / `[tooltip-root="top"]` (default), `"bottom"`, `"left"`, `"right"`.
|
|
335
|
-
|
|
336
|
-
**Combobox.** Chrome colors come from `--juice-combobox-*` roles bound by the active theme. Hide `[combobox-list]` with the native `hidden` attribute. Scope is `[combobox]` with `[combobox-input]`, optional `[combobox-trigger]`, `[combobox-list]`, and `[combobox-option]`. The runtime auto-enhances that markup (`open` / `close` / `toggle` / `select`, case-insensitive substring filter, Arrow/Home/End/Enter/Escape/Tab). `aria-expanded` is written on the input and trigger. `aria-activedescendant` tracks the active option. Select writes option text or `data-value`. Distinct from native `<select>`. Placement is CSS-only (absolute under the field).
|
|
337
|
-
|
|
338
|
-
**Banner.** Chrome colors come from `--juice-banner-*` roles bound by the active theme. `[banner]` is an inline alert / callout, not a toast stack and not a dialog. Hide with the native `hidden` attribute. Layout is `[banner]` / `[banner="full"]`. Optional status is `[banner-tone="info|success|warning|error"]`. The runtime auto-enhances that markup (`show` / `dismiss`, `[banner-close]`, optional `banner-persist="session|local"` with `name` / `id`). It is not a dialog: no focus trap, no `aria-modal`, no Escape steal.
|
|
335
|
+
Open and closed state uses native `hidden`, not layout `content="active"` or `content="hidden"`.
|
|
339
336
|
|
|
340
|
-
|
|
337
|
+
Nav hooks are `nav[type="bar"]`, `nav[type="links"]`, `nav[type="mobile"]`, and `nav[type="sidebar"]`.
|
|
341
338
|
|
|
342
|
-
|
|
339
|
+
All 14 shipped themes bind `--juice-accordion-*` and `--juice-tabs-*`.
|
|
343
340
|
|
|
344
|
-
|
|
341
|
+
Attributes, keyboard behavior, and theme roles for each component are on the page linked from the tables above.
|
|
345
342
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
**Radio.** Chrome colors come from `--juice-radio-*` roles bound by the active theme. `[radio]` is an APG radio on a button host inside `[radiogroup]` (a native `<input type="radio" radio>` is allowed). `[radiogroup]` is layout only. The runtime auto-enhances exclusive selection (`select` / `getChecked`, roving tabindex, arrows plus Space/Enter/click). Orphans outside `[radiogroup]` are ignored. Authors supply the accessible name. It is not `[switch]`, not `[checkbox]`, and not a layered overlay: no focus trap and no Escape.
|
|
349
|
-
|
|
350
|
-
**Breadcrumb.** Chrome colors come from `--juice-breadcrumb-*` roles bound by the active theme. `[breadcrumb]` is an APG-inspired trail on `<nav>` or `<ol>`, with `[breadcrumb-item]` crumbs. Current page is `aria-current="page"` inside the trail. `surface` stays transparent unless crumbs sit on a bar. It is not site nav, `nav[type="breadcrumb"]`, tabs, a wizard step tracker, or pagination, and it is not a layered overlay. The light runtime auto-enhances `[breadcrumb]` (`sync` / `setCurrent`): an unlabeled navigation landmark is named `Breadcrumb`, and a single `aria-current="page"` is filled on the last crumb when none is set. It does not remove `href`, trap focus, steal Escape, or listen to history. `<ol breadcrumb>` stays a list. Not a router. No Sig Breadcrumb factory.
|
|
351
|
-
|
|
352
|
-
**Progress.** Chrome colors come from `--juice-progress-*` roles bound by the active theme. `[progress]` is an APG-inspired progressbar track on `<div progress>`, with `[progress-fill]` for the completed portion and optional `[progress-label]`. The runtime auto-enhances that markup (`setValue` / `getValue` / `setIndeterminate`, `role="progressbar"`, `aria-valuemin` / `aria-valuemax` / `aria-valuenow`, `--juice-progress-ratio`). `progress="indeterminate"` slides the fill and omits `aria-valuenow`. Authors supply the accessible name. `aria-valuetext` is kept when the author set it. It is not a slider, not a spinner, and not a native `<progress>` restyle. Authors do not style the HTML `<progress>` element alone. Inline status chrome: no overlay, no focus trap, no Escape. No Sig Progress factory.
|
|
353
|
-
|
|
354
|
-
**Pagination.** Chrome colors come from `--juice-pagination-*` roles bound by the active theme. `[pagination]` is an APG-inspired page set on `<nav pagination>` or `<ol pagination>`, with `[pagination-item]` cells, `[pagination-prev]` / `[pagination-next]`, and optional `[pagination-link]`, `[pagination-ellipsis]`, and `[pagination-status]`. Current page is `aria-current="page"` on the control. Disabled prev/next use `aria-disabled="true"`, native `disabled`, or `[disabled]`. The trail stays transparent. `surface` is the page control, not a bar. It is not site nav, `nav[type="pagination"]`, a breadcrumb, tabs, or a wizard step tracker, and it is not a layered overlay. The runtime auto-enhances `[pagination]` (`sync` / `setCurrent`): an unlabeled navigation landmark is named `Pagination`, a single `aria-current="page"` is kept (author current wins; otherwise the first page control), and prev/next are disabled at ends when page controls and optional ellipsis make that inferable. Author-owned disabled is kept. Arrow / Home / End move focus among enabled controls. It does not remove `href`, trap focus, steal Escape, or activate links on Enter/Space. `<ol pagination>` stays a list. Pagination is the nineteenth Emerging auto-enhance runtime. No Sig Pagination factory.
|
|
355
|
-
|
|
356
|
-
**Disclosure.** Chrome colors come from `--juice-disclosure-*` roles bound by the active theme. `[disclosure]` is a standalone APG disclosure: one `[disclosure-trigger]` and one `[disclosure-panel]`. Pair the panel with `aria-controls`, or place it as the next sibling of the trigger. Expanded state is `aria-expanded` on the trigger plus native `hidden` and `aria-hidden` on the panel. The runtime never writes layout `content=`. Orphans outside `[disclosure]` are ignored. Click toggles. Enter and Space toggle non-button triggers. Escape collapses the focused or last-opened disclosure and yields to an open modal, drawer, or popover. There is no exclusive group and no arrow roving. It is not an accordion (`[accordion]` / `[accordion-item]` stays multi-item and multi-open) and not a layered overlay. Disclosure is the twentieth Emerging auto-enhance runtime. Shipped in 0.9.2. No Sig Disclosure factory.
|
|
357
|
-
|
|
358
|
-
**Spinner.** Chrome colors come from `--juice-spinner-*` roles bound by the active theme. `[spinner]` is a standalone indeterminate busy indicator. The ring is `::before` on the host. Optional `[spinner-label]` is author text. CSS owns the spin (`juice-spinner-spin`). `prefers-reduced-motion` stops that animation and leaves the indicator. The runtime auto-enhances `[spinner]` (`sync` / `show` / `hide` / `isShown`): a shown host is `role="status"` and `aria-busy="true"`, and `hide` sets native `hidden` and clears both so a hidden spinner does not announce as busy. The runtime does not invent `aria-label` when there is no visible label, and it does not copy a label into a name. Authors supply the accessible name when there is no visible `[spinner-label]`. It is not a progress bar and not a disclosure. No value, no keyboard, no Escape, no focus trap, and no Sig Spinner factory. Inline status chrome: no overlay. Spinner is the twenty-first Emerging auto-enhance runtime. Shipped in 0.9.2.
|
|
359
|
-
|
|
360
|
-
**Select.** Chrome colors come from `--juice-select-*` roles bound by the active theme. `<select select>` is a styled native dropdown. Optional `[select-label]` is a visible label. The chevron is a `background-image`. `[multiple]` and `size` listboxes stay native selects. `[multiple]` and `size` other than `1` drop the chevron. The open list stays the platform popup. The runtime auto-enhances `<select select>` (`sync`): a visible associated label, wrapping label, or `[select-label]` names the control when the author has not set `aria-label` or `aria-labelledby`. A separate label is referenced with `aria-labelledby`. A wrapping label is copied into `aria-label` as its visible text excluding the select, so the selected option is not part of the name. Hidden or empty labels are skipped. No name is invented when nothing visible is there. Change events and the keyboard stay native. It is not a combobox. No keyboard rewrite, no Escape, no focus trap, and no Sig Select factory. Inline field chrome: no overlay, no listbox. Select is the twenty-second Emerging auto-enhance runtime. Shipped in 0.9.2.
|
|
361
|
-
|
|
362
|
-
**Input.** Chrome colors come from `--juice-input-*` roles bound by the active theme. `<input input>` is a styled native text field. Optional `[input-label]` is a visible label. Text-like controls only: missing type, empty type, text, email, password, search, tel, url, and number. Checkbox, radio, range, file, date, time, datetime-local, month, week, color, hidden, button, submit, reset, and image are ignored. The runtime auto-enhances `<input input>` (`sync`): a visible associated label, wrapping label, or `[input-label]` names the control when the author has not set `aria-label` or `aria-labelledby`. A separate label is referenced with `aria-labelledby`. A wrapping label is copied into `aria-label` as its visible text excluding the input's own value. Hidden or empty labels are skipped. No name is invented when nothing visible is there. Typing, change, and the keyboard stay native. It is not a combobox and not a select. Textarea and the field wrapper are not this runtime. No mask, no validation engine, no floating label, no keyboard rewrite, no Escape, no focus trap, and no Sig Input factory. Inline field chrome: no overlay. Input is the twenty-third Emerging auto-enhance runtime. Shipped in 0.9.2.
|
|
363
|
-
|
|
364
|
-
**Textarea.** Chrome colors come from `--juice-textarea-*` roles bound by the active theme. `<textarea textarea>` is a styled native multiline field. Optional `[textarea-label]` is a visible label. The runtime auto-enhances `<textarea textarea>` (`sync`): a visible associated label, wrapping label, or `[textarea-label]` names the control when the author has not set `aria-label` or `aria-labelledby`. A separate label is referenced with `aria-labelledby`. A wrapping label is copied into `aria-label` as its visible text excluding the textarea's own value. Hidden or empty labels are skipped. No name is invented when nothing visible is there. Typing, change, and the keyboard stay native. It is not an input, not a select, and not a combobox. The field wrapper is not this runtime. No auto-grow, no character count, no validation, no floating label, no keyboard rewrite, no Escape, no focus trap, and no Sig Textarea factory. Inline field chrome: no overlay. Textarea is the twenty-fourth Emerging auto-enhance runtime. Shipped in 0.9.2.
|
|
365
|
-
|
|
366
|
-
**Field.** Chrome colors come from `--juice-field-*` roles bound by the active theme. `[field]` is a wrapper around a control (`sync`). Optional `[field-label]`, `[field-help]`, and `[field-error]` are parts. `[invalid]` paints the wrapper border. The first input, textarea, or select inside the wrapper is described by visible `[field-help]` and `[field-error]` when the author has not set `aria-describedby`, and `[invalid]` sets `aria-invalid="true"` when the author has not set it. Hidden or empty help and error text are skipped, and missing ids are added only for parts the runtime references. Author `aria-describedby` and `aria-invalid` are kept. Clearing `[invalid]`, removing a part, or calling `destroy` removes only what the runtime wrote. `[field-label]` is chrome only. Naming stays with the input, textarea, and select runtimes. Typing, change, and the keyboard stay native. It is not a validation engine, not a floating label, and not a restyle of input, textarea, select, or combobox. No focus trap, no Escape, and no Sig Field factory. Inline wrapper chrome: no overlay. Field is the twenty-fifth Emerging auto-enhance runtime. Shipped in 0.9.2.
|
|
367
|
-
|
|
368
|
-
**Icon button.** Square `[icon-button]` on button chrome (`sync` / `toggle` / `getState`). `[toggle]` keeps `aria-pressed` and `[pressed]` in sync. Disabled hosts do not flip. A missing accessible name warns once in development. `title` does not count. No name is invented. It is not a switch and not a checkbox. No focus trap, no Escape, and no Sig IconButton factory. `bind` on current Sig accepts `icon-button`. The published npm 0.9.2 package does not export this runtime, so binding it there throws. Icon button is the twenty-sixth Emerging auto-enhance runtime and is on master, not in the published npm 0.9.2 release.
|
|
369
|
-
|
|
370
|
-
**Avatar.** Initials-or-photo mark (`[avatar]`, `sync` / `getState`). A broken, empty, or already-failed image sets `[fallback]` and hides the image. A later load clears both. An empty `src` with a real `srcset` waits. `getState()` is `{ loaded, fallback, hasImage }`. `destroy()` keeps the fallback. The runtime does not touch `alt`, labels, or initials. `[avatar-more]` stays plain text. It is not a badge and not `[skeleton="circle"]`. No keyboard, no Escape, and no Sig Avatar factory. `bind` on current Sig accepts `avatar`. The published npm 0.9.2 package does not export this runtime, so binding it there throws. Avatar is the twenty-seventh Emerging auto-enhance runtime and is on master, not in the published npm 0.9.2 release.
|
|
371
|
-
|
|
372
|
-
**Table.** Native `<table table>` grid (`createTable` / `sync` / `getState`). `th[sortable]` cycles ascending, descending, and none, sets `aria-sort`, and reorders each `tbody`. `column` is null when direction is none. A canceled `juice:sort` updates state without reordering. `cellIndex` is not a visual column. No Sig Table factory. `bind` on current Sig accepts `table`. The published npm 0.9.2 package does not export this runtime, so binding it there throws. Table is the twenty-eighth Emerging auto-enhance runtime and is on master, not in the published npm 0.9.2 release.
|
|
373
|
-
|
|
374
|
-
**Pressable.** Transient press on `[pressable]` (`createPressable` / `sync` / `getState`). Primary pointerdown sets `[pressed]` until pointerup, pointercancel, pointerleave, a move outside the host, lostpointercapture, or blur. Enter and Space do the same while held, including on a native button. Enter is not `preventDefault`'d, so a native click still fires. Space is `preventDefault`'d on a custom button-like host (`role="button"`, and `switch`, `checkbox`, `radio`, `menuitem`, `menuitemcheckbox`, `menuitemradio`, `option`, `tab`, `treeitem`) that is not a native control which already owns Space (`button`, any `input`, `textarea`, `select`, `summary`, or contenteditable). A move past the slop (default 10px, `[pressable-slop]` or `moveSlop`) or a scroll on the host or an ancestor cancels the press and the long-press timer. `[pressable-longpress]` arms `juice:longpress` (default 500ms, a numeric value or `longPressDelay`). If that event is not canceled, the following click is suppressed once. Disabled hosts (`:disabled`, `[disabled]`, `[aria-disabled="true"]`) do not press. `[icon-button][toggle]` and any host with `aria-pressed` keep their latched `[pressed]`; this runtime does not write that attribute there. `getState()` is `{ pressed, longPressed }`. It is not a toggle and not an icon button. Reduced motion stays in CSS. No Sig Pressable factory. `bind` does not name pressable or touchable-row yet. Pressable is the twenty-ninth Emerging auto-enhance runtime and is on master, not in the published npm 0.9.2 release. See [Pressable](../../docs/juice/juice-pressable.md).
|
|
375
|
-
|
|
376
|
-
**Touchable row.** 44px row on `[touchable-row]` (`createTouchableRow` / `sync` / `getState`). Hosts are `a`, `button`, `li`, and `div`. `dense` tightens padding and gap and keeps the 44px minimum. `chevron` draws the disclosure mark with `::after`. `undivided` drops the hairline on that boundary. `[touchable-row~="select"]` toggles `[selected]` plus `aria-selected`, or `aria-current` on a link or `role="link"`. Sibling rows stay selected. `[touchable-row~="activate"]` and `[pressable]` add `role="button"` and `tabindex="0"` on a non-native host when the author has not set them. Enter and Space on an `li` or `div` dispatch one click. Enter is not `preventDefault`'d. Space is, on those hosts, so the page does not scroll. Native `a` and `button` keep the platform click. A trailing button, switch, or icon button does not activate the row. A `[pressable-longpress]` that is not canceled suppresses the click, so the row does not select. Canceling `juice:longpress` still selects. `getState()` is `{ selected, disabled }`. Disabled hosts are ignored. There is no motion role. No Sig TouchableRow factory. `bind` does not name pressable or touchable-row yet. Touchable row is the thirtieth Emerging auto-enhance runtime and is on master, not in the published npm 0.9.2 release. See [Touchable row](../../docs/juice/juice-touchable-row.md).
|
|
343
|
+
[Choosing between similar components](../../docs/juice/juice-runtime-behavior.md#choosing-between-similar-components).
|
|
377
344
|
|
|
378
345
|
### CSS-only chrome
|
|
379
346
|
|
|
380
|
-
These
|
|
381
|
-
|
|
382
|
-
**Skeleton.** `[skeleton]` is a loading placeholder (boolean and `skeleton="rect"` are the rectangle, `skeleton="text"` is a line, `skeleton="circle"` is a circle). `[lines="1"` through `"8"]` or stacked element children supply the lines. A `width` on the last child shortens it. `[scale="sm"|"lg"]` steps the shape. `[static]` and `prefers-reduced-motion` remove the sheen and keep the base. Roles are `--juice-skeleton-*` on core. Color is restated on `[theme]` (inherited ink mixed into the muted surface). The highlight is a translucent white sheen. Tune `--juice-skeleton-highlight` on a pale surface. Shipped themes are not required to bind the roles. Copy stays in the accessibility tree and does not paint. Authors own `aria-busy` on the loading region. On master, not in the published npm 0.9.2 release. See [Skeleton](../../docs/juice/juice-skeleton.md).
|
|
347
|
+
These do not auto-enhance, do not dispatch `juice:change`, and are not part of the thirty-one runtimes.
|
|
383
348
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
349
|
+
| Chrome | Hook | Release | Docs |
|
|
350
|
+
| --- | --- | --- | --- |
|
|
351
|
+
| Skeleton | `[skeleton]` | On master, not in npm 0.9.2 | [Skeleton](../../docs/juice/juice-skeleton.md) |
|
|
352
|
+
| List | `[list]` | On master, not in npm 0.9.2 | [List](../../docs/juice/juice-list.md) |
|
|
353
|
+
| Badge | `[badge]` | Layout shipped in npm 0.9.2. `--juice-badge-*` roles are on master, not in that cut | [Badge](../../docs/juice/juice-badge.md) |
|
|
354
|
+
| Safe area | `[safe-area]` | On master, not in npm 0.9.2 | [Safe area](../../docs/juice/juice-safe-area.md) |
|
|
389
355
|
|
|
390
356
|
## Layout
|
|
391
357
|
|
|
@@ -397,7 +363,11 @@ Built-in breakpoints, `row` collapse, and scaled spacing are documented in [Resp
|
|
|
397
363
|
|
|
398
364
|
## Surfaces
|
|
399
365
|
|
|
400
|
-
Beta-stable: `surfaceTone="soft|strong|muted"`, `borderStrength="soft|bold"`, `blur="sm|md"`, `shadowTone="cool|warm"`, `overlay="frost|tint"`, and `variant="monochromatic|glass|tinted"`. Themes bind `--juice-surface-*`, `--juice-border-strength-*`, `--juice-shadow-tone-*`, and `--juice-overlay-*` roles.
|
|
366
|
+
Beta-stable: `surfaceTone="soft|strong|muted"`, `borderStrength="soft|bold"`, `blur="sm|md"`, `shadowTone="cool|warm"`, `overlay="frost|tint"`, and `variant="monochromatic|glass|tinted"`. Themes bind `--juice-surface-*`, `--juice-border-strength-*`, `--juice-shadow-tone-*`, and `--juice-overlay-*` roles.
|
|
367
|
+
|
|
368
|
+
Variant recipes compose those same roles. Standalone blur uses fixed `6px` / `16px` lengths.
|
|
369
|
+
|
|
370
|
+
See [Surfaces](../../docs/juice/juice-surfaces.md).
|
|
401
371
|
|
|
402
372
|
## Motion
|
|
403
373
|
|
|
@@ -419,7 +389,20 @@ The production package surface is intentionally small. The stable consumer-facin
|
|
|
419
389
|
If you are hosting Juice assets yourself, the main built files are:
|
|
420
390
|
|
|
421
391
|
- `dist/index.css` (core)
|
|
422
|
-
- `dist/themes/aquaflux.css
|
|
392
|
+
- `dist/themes/aquaflux.css`
|
|
393
|
+
- `dist/themes/kiwipress.css`
|
|
394
|
+
- `dist/themes/citrusmint.css`
|
|
395
|
+
- `dist/themes/tide.css`
|
|
396
|
+
- `dist/themes/retro-afterburn.css`
|
|
397
|
+
- `dist/themes/retro-arcade-glow.css`
|
|
398
|
+
- `dist/themes/retro-boardwalk.css`
|
|
399
|
+
- `dist/themes/retro-denim-dial.css`
|
|
400
|
+
- `dist/themes/retro-forest-radio.css`
|
|
401
|
+
- `dist/themes/retro-orchard-club.css`
|
|
402
|
+
- `dist/themes/retro-poolside-pop.css`
|
|
403
|
+
- `dist/themes/retro-signal-garden.css`
|
|
404
|
+
- `dist/themes/retro-sunset-motel.css`
|
|
405
|
+
- `dist/themes/retro-violet-parlor.css`
|
|
423
406
|
- `dist/index.js`
|
|
424
407
|
|
|
425
408
|
Load core plus at least one theme CSS file when using `theme="..."` on the root element.
|
package/dist/index.css
CHANGED
|
@@ -102486,6 +102486,111 @@ nav[sticky] > [container][safe-area=y],
|
|
|
102486
102486
|
box-sizing: border-box;
|
|
102487
102487
|
}
|
|
102488
102488
|
|
|
102489
|
+
@property --juice-keyboard-inset {
|
|
102490
|
+
syntax: "<length>";
|
|
102491
|
+
inherits: true;
|
|
102492
|
+
initial-value: 0px;
|
|
102493
|
+
}
|
|
102494
|
+
:root {
|
|
102495
|
+
--juice-keyboard-inset: 0px;
|
|
102496
|
+
--juice-keyboard-duration: var(--juice-motion-duration-base);
|
|
102497
|
+
--juice-keyboard-easing: var(--juice-motion-ease-enter);
|
|
102498
|
+
}
|
|
102499
|
+
|
|
102500
|
+
@supports (height: env(keyboard-inset-height)) {
|
|
102501
|
+
:root {
|
|
102502
|
+
--juice-keyboard-inset: env(keyboard-inset-height, 0px);
|
|
102503
|
+
}
|
|
102504
|
+
}
|
|
102505
|
+
[keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102506
|
+
[theme] [keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102507
|
+
nav[fixed] > [container][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102508
|
+
nav[sticky] > [container][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102509
|
+
[wizard-header] > [container][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]) {
|
|
102510
|
+
padding-bottom: var(--juice-keyboard-inset);
|
|
102511
|
+
box-sizing: border-box;
|
|
102512
|
+
}
|
|
102513
|
+
|
|
102514
|
+
[keyboard-avoider~=padding],
|
|
102515
|
+
[theme] [keyboard-avoider~=padding],
|
|
102516
|
+
nav[fixed] > [container][keyboard-avoider~=padding],
|
|
102517
|
+
nav[sticky] > [container][keyboard-avoider~=padding],
|
|
102518
|
+
[wizard-header] > [container][keyboard-avoider~=padding] {
|
|
102519
|
+
padding-bottom: var(--juice-keyboard-inset);
|
|
102520
|
+
box-sizing: border-box;
|
|
102521
|
+
}
|
|
102522
|
+
|
|
102523
|
+
[keyboard-avoider~=translate],
|
|
102524
|
+
[theme] [keyboard-avoider~=translate],
|
|
102525
|
+
nav[fixed] > [container][keyboard-avoider~=translate],
|
|
102526
|
+
nav[sticky] > [container][keyboard-avoider~=translate],
|
|
102527
|
+
[wizard-header] > [container][keyboard-avoider~=translate] {
|
|
102528
|
+
transform: translateY(calc(-1 * var(--juice-keyboard-inset)));
|
|
102529
|
+
transition: transform var(--juice-keyboard-duration) var(--juice-keyboard-easing);
|
|
102530
|
+
}
|
|
102531
|
+
|
|
102532
|
+
[keyboard-avoider~=footer],
|
|
102533
|
+
[theme] [keyboard-avoider~=footer],
|
|
102534
|
+
nav[fixed] > [container][keyboard-avoider~=footer],
|
|
102535
|
+
nav[sticky] > [container][keyboard-avoider~=footer],
|
|
102536
|
+
[wizard-header] > [container][keyboard-avoider~=footer] {
|
|
102537
|
+
position: sticky;
|
|
102538
|
+
bottom: var(--juice-keyboard-inset);
|
|
102539
|
+
}
|
|
102540
|
+
|
|
102541
|
+
nav[fixed][keyboard-avoider~=footer],
|
|
102542
|
+
[theme] nav[fixed][keyboard-avoider~=footer] {
|
|
102543
|
+
bottom: auto;
|
|
102544
|
+
}
|
|
102545
|
+
|
|
102546
|
+
[safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102547
|
+
[theme] [safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102548
|
+
nav[fixed] > [container][safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102549
|
+
nav[sticky] > [container][safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102550
|
+
[wizard-header] > [container][safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102551
|
+
[safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider~=padding],
|
|
102552
|
+
[theme] [safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider~=padding],
|
|
102553
|
+
nav[fixed] > [container][safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider~=padding],
|
|
102554
|
+
nav[sticky] > [container][safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider~=padding],
|
|
102555
|
+
[wizard-header] > [container][safe-area]:not([safe-area=top]):not([safe-area=bottom]):not([safe-area=x]):not([safe-area=y])[keyboard-avoider~=padding] {
|
|
102556
|
+
padding-bottom: max(var(--juice-safe-area-pad), env(safe-area-inset-bottom, 0px), var(--juice-keyboard-inset));
|
|
102557
|
+
}
|
|
102558
|
+
|
|
102559
|
+
[safe-area=bottom][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102560
|
+
[theme] [safe-area=bottom][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102561
|
+
nav[fixed] > [container][safe-area=bottom][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102562
|
+
nav[sticky] > [container][safe-area=bottom][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102563
|
+
[wizard-header] > [container][safe-area=bottom][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102564
|
+
[safe-area=bottom][keyboard-avoider~=padding],
|
|
102565
|
+
[theme] [safe-area=bottom][keyboard-avoider~=padding],
|
|
102566
|
+
nav[fixed] > [container][safe-area=bottom][keyboard-avoider~=padding],
|
|
102567
|
+
nav[sticky] > [container][safe-area=bottom][keyboard-avoider~=padding],
|
|
102568
|
+
[wizard-header] > [container][safe-area=bottom][keyboard-avoider~=padding] {
|
|
102569
|
+
padding-bottom: max(var(--juice-safe-area-pad), env(safe-area-inset-bottom, 0px), var(--juice-keyboard-inset));
|
|
102570
|
+
}
|
|
102571
|
+
|
|
102572
|
+
[safe-area=y][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102573
|
+
[theme] [safe-area=y][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102574
|
+
nav[fixed] > [container][safe-area=y][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102575
|
+
nav[sticky] > [container][safe-area=y][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102576
|
+
[wizard-header] > [container][safe-area=y][keyboard-avoider]:not([keyboard-avoider~=padding]):not([keyboard-avoider~=translate]):not([keyboard-avoider~=footer]),
|
|
102577
|
+
[safe-area=y][keyboard-avoider~=padding],
|
|
102578
|
+
[theme] [safe-area=y][keyboard-avoider~=padding],
|
|
102579
|
+
nav[fixed] > [container][safe-area=y][keyboard-avoider~=padding],
|
|
102580
|
+
nav[sticky] > [container][safe-area=y][keyboard-avoider~=padding],
|
|
102581
|
+
[wizard-header] > [container][safe-area=y][keyboard-avoider~=padding] {
|
|
102582
|
+
padding-bottom: max(var(--juice-safe-area-pad), env(safe-area-inset-bottom, 0px), var(--juice-keyboard-inset));
|
|
102583
|
+
}
|
|
102584
|
+
|
|
102585
|
+
@media (prefers-reduced-motion: reduce) {
|
|
102586
|
+
[keyboard-avoider~=translate],
|
|
102587
|
+
[theme] [keyboard-avoider~=translate],
|
|
102588
|
+
nav[fixed] > [container][keyboard-avoider~=translate],
|
|
102589
|
+
nav[sticky] > [container][keyboard-avoider~=translate],
|
|
102590
|
+
[wizard-header] > [container][keyboard-avoider~=translate] {
|
|
102591
|
+
transition: none;
|
|
102592
|
+
}
|
|
102593
|
+
}
|
|
102489
102594
|
[search-panel] {
|
|
102490
102595
|
max-width: 56rem;
|
|
102491
102596
|
margin: 0 auto;
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,8 @@ export { createPressable, initPressable, startPressableRuntime, stopPressableRun
|
|
|
59
59
|
export type { PressableController, PressableOptions, PressableState } from "./js/src/pressable/pressable-runtime.js";
|
|
60
60
|
export { createTouchableRow, initTouchableRow, startTouchableRowRuntime, stopTouchableRowRuntime } from "./js/src/touchable-row/touchable-row-runtime.js";
|
|
61
61
|
export type { TouchableRowController, TouchableRowOptions, TouchableRowState } from "./js/src/touchable-row/touchable-row-runtime.js";
|
|
62
|
+
export { createKeyboardAvoider, initKeyboardAvoider, startKeyboardAvoiderRuntime, stopKeyboardAvoiderRuntime } from "./js/src/keyboard-avoider/keyboard-avoider-runtime.js";
|
|
63
|
+
export type { KeyboardAvoiderController, KeyboardAvoiderOptions, KeyboardAvoiderState } from "./js/src/keyboard-avoider/keyboard-avoider-runtime.js";
|
|
62
64
|
export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./js/src/shared/motion.js";
|
|
63
65
|
export type { MotionCancelToken, MotionDirection, MotionPlayer, MotionResult, MotionState } from "./js/src/shared/motion.js";
|
|
64
66
|
export { JUICE_CHANGE_EVENT } from "./js/src/shared/change.js";
|
package/dist/index.js
CHANGED
|
@@ -6173,8 +6173,176 @@ typeof window < "u" && typeof document < "u" && (document.readyState === "loadin
|
|
|
6173
6173
|
_d = null, gd || yd();
|
|
6174
6174
|
}, document.addEventListener("DOMContentLoaded", _d)) : yd());
|
|
6175
6175
|
//#endregion
|
|
6176
|
+
//#region src/js/src/keyboard-avoider/keyboard-avoider-runtime.ts
|
|
6177
|
+
var xd = "--juice-keyboard-inset", Sd = "keyboard-open", Cd = 80, wd = {
|
|
6178
|
+
open: !1,
|
|
6179
|
+
inset: 0
|
|
6180
|
+
}, Td = new Set([
|
|
6181
|
+
"text",
|
|
6182
|
+
"email",
|
|
6183
|
+
"password",
|
|
6184
|
+
"search",
|
|
6185
|
+
"tel",
|
|
6186
|
+
"url",
|
|
6187
|
+
"number"
|
|
6188
|
+
]), Ed = {
|
|
6189
|
+
root: typeof document < "u" ? document : {},
|
|
6190
|
+
keyboardAvoiderSelector: "[keyboard-avoider]",
|
|
6191
|
+
threshold: Cd,
|
|
6192
|
+
scrollIntoView: !0
|
|
6193
|
+
}, Dd = (e) => Array.from(e), Od = (e) => typeof e != "number" || !Number.isFinite(e) || e < 0 ? Cd : e, kd = (e, t) => {
|
|
6194
|
+
let n = e.getAttribute("keyboard-avoider");
|
|
6195
|
+
return n ? n.split(/\s+/).includes(t) : !1;
|
|
6196
|
+
}, Ad = (e) => {
|
|
6197
|
+
if (!e.hasAttribute("type")) return !0;
|
|
6198
|
+
let t = e.getAttribute("type") ?? "";
|
|
6199
|
+
return t === "" ? !0 : Td.has(t.toLowerCase());
|
|
6200
|
+
}, jd = (e) => {
|
|
6201
|
+
if (e.isContentEditable) return !0;
|
|
6202
|
+
let t = e.getAttribute("contenteditable");
|
|
6203
|
+
if (t === null) return !1;
|
|
6204
|
+
let n = t.trim().toLowerCase();
|
|
6205
|
+
return n === "" || n === "true" || n === "plaintext-only";
|
|
6206
|
+
}, Md = (e) => e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? !0 : e instanceof HTMLInputElement ? Ad(e) : !1, Nd = (e) => {
|
|
6207
|
+
let t = e.visualViewport;
|
|
6208
|
+
return !t || typeof t.addEventListener != "function" ? null : t;
|
|
6209
|
+
}, Pd = (e) => {
|
|
6210
|
+
let t = e.visualViewport;
|
|
6211
|
+
if (!t) return 0;
|
|
6212
|
+
let n = e.innerHeight, r = t.height, i = t.offsetTop;
|
|
6213
|
+
return [
|
|
6214
|
+
n,
|
|
6215
|
+
r,
|
|
6216
|
+
i
|
|
6217
|
+
].every((e) => Number.isFinite(e)) ? Math.max(0, Math.round(n - (r + i))) : 0;
|
|
6218
|
+
}, Fd = (e) => {
|
|
6219
|
+
let t = e.visualViewport?.scale;
|
|
6220
|
+
return typeof t == "number" && t !== 1;
|
|
6221
|
+
}, Id = () => ({
|
|
6222
|
+
destroy: () => {},
|
|
6223
|
+
sync: () => {},
|
|
6224
|
+
getState: () => ({ ...wd })
|
|
6225
|
+
}), Ld = (e = {}) => {
|
|
6226
|
+
if (typeof window > "u" || typeof document > "u") return Id();
|
|
6227
|
+
let t = Nd(window);
|
|
6228
|
+
if (!t) return Id();
|
|
6229
|
+
let n = {
|
|
6230
|
+
...Ed,
|
|
6231
|
+
...e,
|
|
6232
|
+
threshold: Od(e.threshold),
|
|
6233
|
+
scrollIntoView: e.scrollIntoView !== !1
|
|
6234
|
+
}, r = n.root ?? document, i = r, a = T("keyboard-avoider"), o = /* @__PURE__ */ new Set(), s = !1, c = { ...wd }, l = null, u = 0, d = !1, f = 0, p = 0, m = !1, h = null, g = (e) => !(e instanceof HTMLElement) || !e.matches(n.keyboardAvoiderSelector) ? !1 : r instanceof Document ? !0 : r instanceof Node ? r === e || r.contains(e) : !1, _ = () => {
|
|
6235
|
+
let e = Dd(r.querySelectorAll(n.keyboardAvoiderSelector)).filter(g);
|
|
6236
|
+
return r instanceof HTMLElement && g(r) ? [r, ...e.filter((e) => e !== r)] : e;
|
|
6237
|
+
}, v = (e) => {
|
|
6238
|
+
if (e) {
|
|
6239
|
+
if (g(e)) return e;
|
|
6240
|
+
let t = e.closest(n.keyboardAvoiderSelector);
|
|
6241
|
+
return t instanceof HTMLElement && g(t) ? t : null;
|
|
6242
|
+
}
|
|
6243
|
+
return _()[0] ?? null;
|
|
6244
|
+
}, y = (e) => {
|
|
6245
|
+
if (!e) return null;
|
|
6246
|
+
let t = e.closest(n.keyboardAvoiderSelector);
|
|
6247
|
+
return !(t instanceof HTMLElement) || !g(t) ? null : t;
|
|
6248
|
+
}, b = () => {
|
|
6249
|
+
let e = document.activeElement;
|
|
6250
|
+
if (!(e instanceof HTMLElement)) return !1;
|
|
6251
|
+
let t = e;
|
|
6252
|
+
for (; t && t !== document.documentElement;) {
|
|
6253
|
+
if (Md(t) || jd(t)) return !0;
|
|
6254
|
+
t = t.parentElement;
|
|
6255
|
+
}
|
|
6256
|
+
return !1;
|
|
6257
|
+
}, x = () => {
|
|
6258
|
+
let e = Pd(window);
|
|
6259
|
+
return {
|
|
6260
|
+
inset: e,
|
|
6261
|
+
open: e > n.threshold && b()
|
|
6262
|
+
};
|
|
6263
|
+
}, S = (e) => {
|
|
6264
|
+
let t = document.documentElement.style;
|
|
6265
|
+
e.open ? t.setProperty(xd, `${e.inset}px`) : t.removeProperty(xd);
|
|
6266
|
+
}, C = (e) => {
|
|
6267
|
+
let t = document.documentElement;
|
|
6268
|
+
e ? t.setAttribute(Sd, "") : t.removeAttribute(Sd);
|
|
6269
|
+
let n = e ? _() : [], r = new Set(n);
|
|
6270
|
+
for (let e of o) r.has(e) || e.removeAttribute(Sd);
|
|
6271
|
+
o.clear();
|
|
6272
|
+
for (let e of n) e.setAttribute(Sd, ""), o.add(e);
|
|
6273
|
+
}, w = (e) => {
|
|
6274
|
+
let t = l, r = t !== null && t.open !== e.open, i = t !== null && t.open && e.open && e.inset !== t.inset && Math.abs(e.inset - t.inset) >= n.threshold, o = r || i;
|
|
6275
|
+
(t === null || o) && (l = { ...e });
|
|
6276
|
+
for (let t of _()) {
|
|
6277
|
+
if (!a.has(t)) {
|
|
6278
|
+
a.note(t, e);
|
|
6279
|
+
continue;
|
|
6280
|
+
}
|
|
6281
|
+
o && a.note(t, e);
|
|
6282
|
+
}
|
|
6283
|
+
}, E = () => {
|
|
6284
|
+
if (s || Fd(window)) return;
|
|
6285
|
+
let e = x();
|
|
6286
|
+
c = e, S(e), C(e.open), w(e);
|
|
6287
|
+
}, D = () => {
|
|
6288
|
+
m &&= (cancelAnimationFrame(f), cancelAnimationFrame(p), !1);
|
|
6289
|
+
}, O = () => {
|
|
6290
|
+
s || !h || (D(), m = !0, f = requestAnimationFrame(() => {
|
|
6291
|
+
if (s || !h) {
|
|
6292
|
+
m = !1;
|
|
6293
|
+
return;
|
|
6294
|
+
}
|
|
6295
|
+
p = requestAnimationFrame(() => {
|
|
6296
|
+
if (m = !1, s || !h || Fd(window)) return;
|
|
6297
|
+
let e = h;
|
|
6298
|
+
if (!e.isConnected || !N(e)) {
|
|
6299
|
+
h = null;
|
|
6300
|
+
return;
|
|
6301
|
+
}
|
|
6302
|
+
h = null;
|
|
6303
|
+
let t = y(e);
|
|
6304
|
+
!t || kd(t, "noscroll") || !n.scrollIntoView || e.scrollIntoView({
|
|
6305
|
+
block: "nearest",
|
|
6306
|
+
behavior: K() ? "auto" : "smooth"
|
|
6307
|
+
});
|
|
6308
|
+
});
|
|
6309
|
+
}));
|
|
6310
|
+
}, k = () => {
|
|
6311
|
+
s || d || (d = !0, u = requestAnimationFrame(() => {
|
|
6312
|
+
d = !1, E();
|
|
6313
|
+
}));
|
|
6314
|
+
}, A = () => {
|
|
6315
|
+
s || (k(), h && O());
|
|
6316
|
+
}, j = (e) => {
|
|
6317
|
+
if (s) return;
|
|
6318
|
+
let t = e.target instanceof HTMLElement ? e.target : null, r = t ? y(t) : null;
|
|
6319
|
+
t && n.scrollIntoView && r && !kd(r, "noscroll") ? (h = t, O()) : (h = null, D()), k();
|
|
6320
|
+
}, M = () => {
|
|
6321
|
+
s || k();
|
|
6322
|
+
}, N = (e) => {
|
|
6323
|
+
let t = document.activeElement;
|
|
6324
|
+
return t === e || t instanceof Node && e.contains(t);
|
|
6325
|
+
}, P = () => {
|
|
6326
|
+
s || E();
|
|
6327
|
+
};
|
|
6328
|
+
return t.addEventListener("resize", A), t.addEventListener("scroll", A), window.addEventListener("resize", A), window.addEventListener("orientationchange", A), i.addEventListener("focusin", j), i.addEventListener("focusout", M), P(), {
|
|
6329
|
+
destroy: () => {
|
|
6330
|
+
s || (s = !0, d &&= (cancelAnimationFrame(u), !1), h = null, D(), t.removeEventListener("resize", A), t.removeEventListener("scroll", A), window.removeEventListener("resize", A), window.removeEventListener("orientationchange", A), i.removeEventListener("focusin", j), i.removeEventListener("focusout", M), S(wd), C(!1));
|
|
6331
|
+
},
|
|
6332
|
+
sync: P,
|
|
6333
|
+
getState: (e) => s || !v(e) ? null : { ...c }
|
|
6334
|
+
};
|
|
6335
|
+
}, Rd = Ld, zd = null, Bd = !1, Vd = null, Hd = () => {
|
|
6336
|
+
!Vd || typeof document > "u" || (document.removeEventListener("DOMContentLoaded", Vd), Vd = null);
|
|
6337
|
+
}, Ud = () => typeof window > "u" || typeof document > "u" ? null : (Bd = !1, Hd(), zd ? (zd.sync(), zd) : (zd = Ld(), zd)), Wd = () => {
|
|
6338
|
+
Bd = !0, Hd(), zd?.destroy(), zd = null;
|
|
6339
|
+
};
|
|
6340
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (Vd = () => {
|
|
6341
|
+
Vd = null, Bd || Ud();
|
|
6342
|
+
}, document.addEventListener("DOMContentLoaded", Vd)) : Ud());
|
|
6343
|
+
//#endregion
|
|
6176
6344
|
//#region src/tokens/index.ts
|
|
6177
|
-
var
|
|
6345
|
+
var Gd = {
|
|
6178
6346
|
colors: {
|
|
6179
6347
|
families: [
|
|
6180
6348
|
"black",
|
|
@@ -6342,4 +6510,4 @@ var xd = {
|
|
|
6342
6510
|
themes: {}
|
|
6343
6511
|
};
|
|
6344
6512
|
//#endregion
|
|
6345
|
-
export { y as Accordion, b as JUICE_CHANGE_EVENT, ve as createAccordion, jl as createAvatar, $r as createBanner, po as createBreadcrumb, ja as createCheckbox, Fr as createCombobox, Ss as createDisclosure, xt as createDrawer, se as createElementMotion, Rc as createField, ll as createIconButton, cc as createInput, bi as createMenu, rt as createModal, te as createMotionCancelToken, M as createNavigation, ns as createPagination, vn as createPopover, Iu as createPressable, No as createProgress, Za as createRadio, qs as createSelect, pa as createSlider, Ps as createSpinner, Ri as createSwitch, lu as createTable, Pe as createTabs, xc as createTextarea, Ut as createToast, Wn as createTooltip, pd as createTouchableRow, dr as createWizard, ye as initAccordion, Ml as initAvatar, ei as initBanner, mo as initBreadcrumb, Ma as initCheckbox, Ir as initCombobox, Cs as initDisclosure, St as initDrawer, zc as initField, ul as initIconButton, lc as initInput, xi as initMenu, it as initModal, N as initNavigation, rs as initPagination, yn as initPopover, Lu as initPressable, Po as initProgress, Qa as initRadio, Js as initSelect, ma as initSlider, Fs as initSpinner, zi as initSwitch, uu as initTable, Fe as initTabs, Sc as initTextarea, Wt as initToast, Gn as initTooltip, md as initTouchableRow, fr as initWizard, K as prefersReducedMotion, oe as runMotion, we as startAccordionRuntime, Ll as startAvatarRuntime, ai as startBannerRuntime, yo as startBreadcrumbRuntime, La as startCheckboxRuntime, Vr as startComboboxRuntime, Os as startDisclosureRuntime, Dt as startDrawerRuntime, Wc as startFieldRuntime, hl as startIconButtonRuntime, mc as startInputRuntime, Ei as startMenuRuntime, lt as startModalRuntime, F as startNavigationRuntime, cs as startPaginationRuntime, wn as startPopoverRuntime, Hu as startPressableRuntime, zo as startProgressRuntime, ro as startRadioRuntime, $s as startSelectRuntime, ya as startSliderRuntime, Bs as startSpinnerRuntime, Wi as startSwitchRuntime, hu as startTableRuntime, Be as startTabsRuntime, Dc as startTextareaRuntime, Yt as startToastRuntime, Xn as startTooltipRuntime, yd as startTouchableRowRuntime, _r as startWizardRuntime, Te as stopAccordionRuntime, Rl as stopAvatarRuntime, oi as stopBannerRuntime, bo as stopBreadcrumbRuntime, Ra as stopCheckboxRuntime, Hr as stopComboboxRuntime, ks as stopDisclosureRuntime, Ot as stopDrawerRuntime, Gc as stopFieldRuntime, gl as stopIconButtonRuntime, hc as stopInputRuntime, Di as stopMenuRuntime, ut as stopModalRuntime, I as stopNavigationRuntime, ls as stopPaginationRuntime, Tn as stopPopoverRuntime, Uu as stopPressableRuntime, Bo as stopProgressRuntime, io as stopRadioRuntime, ec as stopSelectRuntime, ba as stopSliderRuntime, Vs as stopSpinnerRuntime, Gi as stopSwitchRuntime, gu as stopTableRuntime, Ve as stopTabsRuntime, Oc as stopTextareaRuntime, Xt as stopToastRuntime, Zn as stopTooltipRuntime, bd as stopTouchableRowRuntime, vr as stopWizardRuntime, ee as subscribeReducedMotion,
|
|
6513
|
+
export { y as Accordion, b as JUICE_CHANGE_EVENT, ve as createAccordion, jl as createAvatar, $r as createBanner, po as createBreadcrumb, ja as createCheckbox, Fr as createCombobox, Ss as createDisclosure, xt as createDrawer, se as createElementMotion, Rc as createField, ll as createIconButton, cc as createInput, Ld as createKeyboardAvoider, bi as createMenu, rt as createModal, te as createMotionCancelToken, M as createNavigation, ns as createPagination, vn as createPopover, Iu as createPressable, No as createProgress, Za as createRadio, qs as createSelect, pa as createSlider, Ps as createSpinner, Ri as createSwitch, lu as createTable, Pe as createTabs, xc as createTextarea, Ut as createToast, Wn as createTooltip, pd as createTouchableRow, dr as createWizard, ye as initAccordion, Ml as initAvatar, ei as initBanner, mo as initBreadcrumb, Ma as initCheckbox, Ir as initCombobox, Cs as initDisclosure, St as initDrawer, zc as initField, ul as initIconButton, lc as initInput, Rd as initKeyboardAvoider, xi as initMenu, it as initModal, N as initNavigation, rs as initPagination, yn as initPopover, Lu as initPressable, Po as initProgress, Qa as initRadio, Js as initSelect, ma as initSlider, Fs as initSpinner, zi as initSwitch, uu as initTable, Fe as initTabs, Sc as initTextarea, Wt as initToast, Gn as initTooltip, md as initTouchableRow, fr as initWizard, K as prefersReducedMotion, oe as runMotion, we as startAccordionRuntime, Ll as startAvatarRuntime, ai as startBannerRuntime, yo as startBreadcrumbRuntime, La as startCheckboxRuntime, Vr as startComboboxRuntime, Os as startDisclosureRuntime, Dt as startDrawerRuntime, Wc as startFieldRuntime, hl as startIconButtonRuntime, mc as startInputRuntime, Ud as startKeyboardAvoiderRuntime, Ei as startMenuRuntime, lt as startModalRuntime, F as startNavigationRuntime, cs as startPaginationRuntime, wn as startPopoverRuntime, Hu as startPressableRuntime, zo as startProgressRuntime, ro as startRadioRuntime, $s as startSelectRuntime, ya as startSliderRuntime, Bs as startSpinnerRuntime, Wi as startSwitchRuntime, hu as startTableRuntime, Be as startTabsRuntime, Dc as startTextareaRuntime, Yt as startToastRuntime, Xn as startTooltipRuntime, yd as startTouchableRowRuntime, _r as startWizardRuntime, Te as stopAccordionRuntime, Rl as stopAvatarRuntime, oi as stopBannerRuntime, bo as stopBreadcrumbRuntime, Ra as stopCheckboxRuntime, Hr as stopComboboxRuntime, ks as stopDisclosureRuntime, Ot as stopDrawerRuntime, Gc as stopFieldRuntime, gl as stopIconButtonRuntime, hc as stopInputRuntime, Wd as stopKeyboardAvoiderRuntime, Di as stopMenuRuntime, ut as stopModalRuntime, I as stopNavigationRuntime, ls as stopPaginationRuntime, Tn as stopPopoverRuntime, Uu as stopPressableRuntime, Bo as stopProgressRuntime, io as stopRadioRuntime, ec as stopSelectRuntime, ba as stopSliderRuntime, Vs as stopSpinnerRuntime, Gi as stopSwitchRuntime, gu as stopTableRuntime, Ve as stopTabsRuntime, Oc as stopTextareaRuntime, Xt as stopToastRuntime, Zn as stopTooltipRuntime, bd as stopTouchableRowRuntime, vr as stopWizardRuntime, ee as subscribeReducedMotion, Gd as tokens };
|
package/dist/js/juice.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export { createPressable, initPressable, startPressableRuntime, stopPressableRun
|
|
|
58
58
|
export type { PressableController, PressableOptions, PressableState } from "./src/pressable/pressable-runtime.js";
|
|
59
59
|
export { createTouchableRow, initTouchableRow, startTouchableRowRuntime, stopTouchableRowRuntime } from "./src/touchable-row/touchable-row-runtime.js";
|
|
60
60
|
export type { TouchableRowController, TouchableRowOptions, TouchableRowState } from "./src/touchable-row/touchable-row-runtime.js";
|
|
61
|
+
export { createKeyboardAvoider, initKeyboardAvoider, startKeyboardAvoiderRuntime, stopKeyboardAvoiderRuntime } from "./src/keyboard-avoider/keyboard-avoider-runtime.js";
|
|
62
|
+
export type { KeyboardAvoiderController, KeyboardAvoiderOptions, KeyboardAvoiderState } from "./src/keyboard-avoider/keyboard-avoider-runtime.js";
|
|
61
63
|
export { JUICE_CHANGE_EVENT } from "./src/shared/change.js";
|
|
62
64
|
export type { JuiceChangeDetail } from "./src/shared/change.js";
|
|
63
65
|
export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./src/shared/motion.js";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM-first runtime for Juice keyboard-avoider chrome.
|
|
3
|
+
*
|
|
4
|
+
* Markup contract (Slice A — do not rename attrs):
|
|
5
|
+
* [keyboard-avoider] host. Padding mode. Any unknown
|
|
6
|
+
* value is still a host. Words
|
|
7
|
+
* compose, same as the CSS.
|
|
8
|
+
* [keyboard-avoider="padding"] padding mode. Matches ~= .
|
|
9
|
+
* [keyboard-avoider~="translate"] translateY by the inset.
|
|
10
|
+
* [keyboard-avoider~="footer"] sticky; bottom is the inset.
|
|
11
|
+
* [keyboard-avoider~="noscroll"] this runtime does not
|
|
12
|
+
* scrollIntoView a focus inside
|
|
13
|
+
* that host. The word is behavior,
|
|
14
|
+
* not a layout mode. CSS ignores it.
|
|
15
|
+
* [keyboard-open] set on <html> and on each host
|
|
16
|
+
* while the keyboard is open.
|
|
17
|
+
* Slice A does not select it. The
|
|
18
|
+
* inset is the layout input.
|
|
19
|
+
*
|
|
20
|
+
* The overlap is the layout viewport minus the visual viewport:
|
|
21
|
+
*
|
|
22
|
+
* inset = max(0, round(innerHeight - (visualViewport.height + visualViewport.offsetTop)))
|
|
23
|
+
*
|
|
24
|
+
* iOS reports part of that overlap as offsetTop. Leaving it out
|
|
25
|
+
* counts the keyboard twice. Chrome Android with
|
|
26
|
+
* interactive-widget=resizes-content shrinks innerHeight with the
|
|
27
|
+
* keyboard, so the same formula is about 0 and this runtime does not
|
|
28
|
+
* pad on top of the layout viewport. Pinch zoom (visualViewport.scale
|
|
29
|
+
* other than 1) skips the update and leaves the previous inset.
|
|
30
|
+
*
|
|
31
|
+
* While open, the inset is written as `<n>px` on
|
|
32
|
+
* document.documentElement (the <html> element), not on each host.
|
|
33
|
+
* --juice-keyboard-inset inherits. When the keyboard is not open the
|
|
34
|
+
* inline property is removed. A closed keyboard must not leave an
|
|
35
|
+
* inline length behind: an inline value beats both the 0px role on
|
|
36
|
+
* :root and the @supports env(keyboard-inset-height) fallback. Clearing
|
|
37
|
+
* it is what lets that fallback show through. getState().inset is still
|
|
38
|
+
* the measured overlap. Only the custom property is cleared.
|
|
39
|
+
*
|
|
40
|
+
* open is inset > threshold (default 80) and an editable element has
|
|
41
|
+
* focus. Editable is a text-like input, the same set as the Input
|
|
42
|
+
* runtime (missing type, empty type, text, email, password, search,
|
|
43
|
+
* tel, url, number), plus a textarea, a select, or [contenteditable]
|
|
44
|
+
* (including a focused descendant). A hardware keyboard does not
|
|
45
|
+
* shrink the visual viewport, so a focused field stays closed. Every
|
|
46
|
+
* other input type is not editable: checkbox, radio, range, date,
|
|
47
|
+
* time, datetime-local, month, week, color, file, hidden, button,
|
|
48
|
+
* submit, reset, and image.
|
|
49
|
+
*
|
|
50
|
+
* Listeners: visualViewport resize and scroll, window resize and
|
|
51
|
+
* orientationchange, focusin and focusout on root. Updates are
|
|
52
|
+
* coalesced with requestAnimationFrame. This runtime does not set
|
|
53
|
+
* navigator.virtualKeyboard.overlaysContent.
|
|
54
|
+
*
|
|
55
|
+
* Scroll-into-view is on by default. focusin inside a host remembers
|
|
56
|
+
* the focused element. The scroll runs two frames after geometry
|
|
57
|
+
* events go quiet, so a resize burst settles before the element moves,
|
|
58
|
+
* and the inset written on the first of those frames is the one layout
|
|
59
|
+
* sees. A focus that never resizes still scrolls on that quiet window.
|
|
60
|
+
* The call is element.scrollIntoView({ block: 'nearest', behavior })
|
|
61
|
+
* with behavior 'auto' when prefersReducedMotion() is true and 'smooth'
|
|
62
|
+
* otherwise. [keyboard-avoider~="noscroll"] or scrollIntoView: false
|
|
63
|
+
* opts out. destroy cancels a pending scroll.
|
|
64
|
+
*
|
|
65
|
+
* State is { open, inset }. juice:change bubbles from each host with
|
|
66
|
+
* detail { runtime: 'keyboard-avoider', state }. The first observation
|
|
67
|
+
* is silent. Later events fire when open flips, or when the inset has
|
|
68
|
+
* moved by at least `threshold` pixels from the last published inset
|
|
69
|
+
* while open. Smaller steps still update the custom property and
|
|
70
|
+
* getState. They accumulate against the last published inset, so a
|
|
71
|
+
* slow drift still publishes once it is stale by `threshold`.
|
|
72
|
+
*
|
|
73
|
+
* No window, or no visualViewport, is a no-op (SSR and old browsers).
|
|
74
|
+
* getState then returns { open: false, inset: 0 }. No Sig
|
|
75
|
+
* KeyboardAvoider factory. Keyboard-avoider is the thirty-first
|
|
76
|
+
* Emerging auto-enhance runtime.
|
|
77
|
+
*/
|
|
78
|
+
export type KeyboardAvoiderOptions = {
|
|
79
|
+
root?: ParentNode;
|
|
80
|
+
keyboardAvoiderSelector?: string;
|
|
81
|
+
threshold?: number;
|
|
82
|
+
scrollIntoView?: boolean;
|
|
83
|
+
};
|
|
84
|
+
export type KeyboardAvoiderState = {
|
|
85
|
+
open: boolean;
|
|
86
|
+
inset: number;
|
|
87
|
+
};
|
|
88
|
+
export type KeyboardAvoiderController = {
|
|
89
|
+
destroy: () => void;
|
|
90
|
+
sync: () => void;
|
|
91
|
+
getState: (target?: HTMLElement | null) => KeyboardAvoiderState | null;
|
|
92
|
+
};
|
|
93
|
+
export declare const createKeyboardAvoider: (options?: KeyboardAvoiderOptions) => KeyboardAvoiderController;
|
|
94
|
+
export declare const initKeyboardAvoider: (options?: KeyboardAvoiderOptions) => KeyboardAvoiderController;
|
|
95
|
+
export declare const startKeyboardAvoiderRuntime: () => KeyboardAvoiderController | null;
|
|
96
|
+
export declare const stopKeyboardAvoiderRuntime: () => void;
|