@citrusworx/juiceui 0.9.1 → 0.9.2

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.
@@ -36,3 +36,17 @@ export { createProgress, initProgress, startProgressRuntime, stopProgressRuntime
36
36
  export type { ProgressController, ProgressOptions } from "./src/progress/progress-runtime.js";
37
37
  export { createPagination, initPagination, startPaginationRuntime, stopPaginationRuntime } from "./src/pagination/pagination-runtime.js";
38
38
  export type { PaginationController, PaginationOptions } from "./src/pagination/pagination-runtime.js";
39
+ export { createDisclosure, initDisclosure, startDisclosureRuntime, stopDisclosureRuntime } from "./src/disclosure/disclosure-runtime.js";
40
+ export type { DisclosureController, DisclosureOptions } from "./src/disclosure/disclosure-runtime.js";
41
+ export { createSpinner, initSpinner, startSpinnerRuntime, stopSpinnerRuntime } from "./src/spinner/spinner-runtime.js";
42
+ export type { SpinnerController, SpinnerOptions } from "./src/spinner/spinner-runtime.js";
43
+ export { createSelect, initSelect, startSelectRuntime, stopSelectRuntime } from "./src/select/select-runtime.js";
44
+ export type { SelectController, SelectOptions } from "./src/select/select-runtime.js";
45
+ export { createInput, initInput, startInputRuntime, stopInputRuntime } from "./src/input/input-runtime.js";
46
+ export type { InputController, InputOptions } from "./src/input/input-runtime.js";
47
+ export { createTextarea, initTextarea, startTextareaRuntime, stopTextareaRuntime } from "./src/textarea/textarea-runtime.js";
48
+ export type { TextareaController, TextareaOptions } from "./src/textarea/textarea-runtime.js";
49
+ export { createField, initField, startFieldRuntime, stopFieldRuntime } from "./src/field/field-runtime.js";
50
+ export type { FieldController, FieldOptions } from "./src/field/field-runtime.js";
51
+ export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./src/shared/motion.js";
52
+ export type { MotionCancelToken, MotionDirection, MotionPlayer, MotionResult, MotionState } from "./src/shared/motion.js";
@@ -0,0 +1,51 @@
1
+ /**
2
+ * DOM-first disclosure runtime for Juice disclosure chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [disclosure] standalone root. One trigger, one panel.
6
+ * Not an accordion and not a stack.
7
+ * [disclosure-trigger] the button. Expanded state is aria-expanded.
8
+ * [disclosure-panel] the controlled region.
9
+ *
10
+ * Pairing: aria-controls inside the root, otherwise the next sibling
11
+ * [disclosure-panel] or the next panel sibling. Orphans outside
12
+ * [disclosure] are ignored. There is no exclusive group and no Sig
13
+ * factory. Accordion markup is not enhanced here.
14
+ *
15
+ * Open/closed state is aria-expanded on the trigger plus native hidden
16
+ * and aria-hidden on the panel. This runtime never writes layout
17
+ * content="active" or content="hidden".
18
+ *
19
+ * A panel with `[motion="accordion"]` animates height from its measured
20
+ * `scrollHeight`. `aria-expanded` updates immediately. `hidden` is removed
21
+ * before the expand and applied only after the collapse transition, because
22
+ * native `hidden` cannot interpolate to `auto`. Reduced motion stays instant.
23
+ * The attribute has to sit on the panel: that is the element ease.scss
24
+ * transitions.
25
+ *
26
+ * Keyboard: click toggles. Enter and Space activate non-button triggers.
27
+ * Escape collapses the focused open disclosure, or the last opened one,
28
+ * and returns focus to that trigger. It yields to an open modal, drawer,
29
+ * or popover (and to an already-handled Escape). There is no global
30
+ * disclosure Escape and no arrow-key roving tabindex.
31
+ *
32
+ * Limitations: exclusive groups, arrow-key roving tabindex, and a Sig
33
+ * Disclosure factory are out of scope. See
34
+ * docs/juice/juice-disclosure-runtime.md.
35
+ */
36
+ export type DisclosureOptions = {
37
+ root?: ParentNode;
38
+ disclosureSelector?: string;
39
+ triggerSelector?: string;
40
+ };
41
+ export type DisclosureController = {
42
+ destroy: () => void;
43
+ sync: () => void;
44
+ expand: (trigger?: HTMLElement | null) => void;
45
+ collapse: (trigger?: HTMLElement | null) => void;
46
+ toggle: (trigger?: HTMLElement | null) => void;
47
+ };
48
+ export declare const createDisclosure: (options?: DisclosureOptions) => DisclosureController;
49
+ export declare const initDisclosure: (options?: DisclosureOptions) => DisclosureController;
50
+ export declare const startDisclosureRuntime: () => DisclosureController | null;
51
+ export declare const stopDisclosureRuntime: () => void;
@@ -4,6 +4,12 @@
4
4
  * Markup contract:
5
5
  * [drawer-overlay][hidden] > [drawer role="dialog"] + [drawer-close]
6
6
  * Closed vs open is the native `hidden` attribute on the overlay.
7
+ * Enter removes `hidden`, then plays. Exit plays first; `hidden` is set
8
+ * only after it finishes. Focus moves in when `hidden` is removed and
9
+ * restores when `hidden` is set. Reduced motion (or a zero computed
10
+ * duration) does both in the same turn. An in-flight exit stays the open
11
+ * dialog for Escape and the focus trap until that commit, and a new open
12
+ * cancels it.
7
13
  *
8
14
  * Openers: any element whose `aria-controls` token list includes a
9
15
  * `[drawer-overlay]` id. `[drawer-close]` closes the containing overlay.
@@ -0,0 +1,53 @@
1
+ /**
2
+ * DOM-first runtime for Juice field wrappers.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [field] host wrapper around a control. Any attribute value
6
+ * is still a field. Sync does not rewrite the attribute.
7
+ * [field-label] chrome only. This runtime does not name the control.
8
+ * Naming stays with the input, textarea, and select
9
+ * runtimes.
10
+ * [field-help] optional help text.
11
+ * [field-error] optional error text.
12
+ * [field][invalid] wrapper invalid state. Paints in CSS. This runtime
13
+ * mirrors it onto the control when the author has not
14
+ * set aria-invalid.
15
+ *
16
+ * Sync (markup-driven):
17
+ * 1. Find the control: the first input, textarea, or select inside
18
+ * the field that is not inside a nested field. A button, a nested
19
+ * field's control, and a field with no control are skipped.
20
+ * 2. When the author has not set aria-describedby, point it at the
21
+ * visible [field-help] and [field-error] in that field, in
22
+ * document order. Nested fields keep their own parts. Give a part
23
+ * an id only when it lacks one. Hidden parts and empty text are
24
+ * skipped. An author aria-describedby is kept. A blank value is
25
+ * not a description.
26
+ * 3. [field][invalid] sets aria-invalid="true" on the control when
27
+ * the author has not set aria-invalid. A blank value is not set.
28
+ * Clearing [invalid] removes only an aria-invalid this runtime
29
+ * wrote.
30
+ * 4. Anything this runtime wrote (aria-describedby, aria-invalid, or
31
+ * an id on a help or error part) is removed when its source goes
32
+ * away, or on destroy. An author value is left in place.
33
+ *
34
+ * Typing, change, and keys stay on the native control. There is no
35
+ * validation engine, no floating label, no keyboard handler, no
36
+ * Escape handler, no focus trap, and no Sig Field factory.
37
+ *
38
+ * Limitations: validation, a floating label, keyboard handling,
39
+ * Escape, a focus trap, naming, and a Sig Field factory are out of
40
+ * scope. [field-label] is chrome only.
41
+ */
42
+ export type FieldOptions = {
43
+ root?: ParentNode;
44
+ fieldSelector?: string;
45
+ };
46
+ export type FieldController = {
47
+ destroy: () => void;
48
+ sync: () => void;
49
+ };
50
+ export declare const createField: (options?: FieldOptions) => FieldController;
51
+ export declare const initField: (options?: FieldOptions) => FieldController;
52
+ export declare const startFieldRuntime: () => FieldController | null;
53
+ export declare const stopFieldRuntime: () => void;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * DOM-first runtime for Juice native text-input chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [input] host, on the native element: <input input>.
6
+ * Text-like types only: missing type, empty type,
7
+ * text, email, password, search, tel, url, and
8
+ * number. Any attribute value is still an input.
9
+ * Sync does not rewrite the attribute. A node that
10
+ * is not an <input> is ignored. An <input> without
11
+ * [input] is ignored. Checkbox, radio, range, file,
12
+ * date, time, datetime-local, month, week, color,
13
+ * hidden, button, submit, reset, and image are
14
+ * ignored. An input inside [combobox], including
15
+ * [combobox-input], is ignored.
16
+ * [input-label] optional visible label. Pair it with the control
17
+ * (wrapping element, or for/id).
18
+ *
19
+ * Sync (markup-driven):
20
+ * 1. Name the control from a visible label when the author has not
21
+ * set an accessible name. Sources, in order: an associated
22
+ * <label for>, a wrapping <label>, then [input-label] (for/id,
23
+ * a wrapping element, or the nearest preceding sibling).
24
+ * 2. An author aria-label or aria-labelledby is kept. A blank value
25
+ * is not a name. title is left untouched and does not block a
26
+ * visible label.
27
+ * 3. A label that does not contain the control is referenced with
28
+ * aria-labelledby (an id is added only when that label has none).
29
+ * A wrapping label is copied into aria-label as its visible text,
30
+ * excluding the control, so the input's own value is not part of
31
+ * the name. Hidden labels and empty text are skipped.
32
+ * 4. When no visible label exists, sync does not invent a name.
33
+ * A name this runtime wrote is removed if that label goes away
34
+ * or the host stops being a text-like [input].
35
+ *
36
+ * Typing, change, and keys stay on the native control. There is no
37
+ * mask, no validation engine, no floating label, no keyboard handler,
38
+ * no Escape handler, no focus trap, and no Sig Input factory.
39
+ *
40
+ * Limitations: a mask, validation, a floating label, keyboard
41
+ * handling, Escape, a focus trap, and a Sig Input factory are out of
42
+ * scope. See docs/juice/juice-input-runtime.md.
43
+ */
44
+ export type InputOptions = {
45
+ root?: ParentNode;
46
+ inputSelector?: string;
47
+ };
48
+ export type InputController = {
49
+ destroy: () => void;
50
+ sync: () => void;
51
+ };
52
+ export declare const createInput: (options?: InputOptions) => InputController;
53
+ export declare const initInput: (options?: InputOptions) => InputController;
54
+ export declare const startInputRuntime: () => InputController | null;
55
+ export declare const stopInputRuntime: () => void;
@@ -4,6 +4,12 @@
4
4
  * Markup contract:
5
5
  * [modal-overlay][hidden] > [modal role="dialog"] + [modal-close]
6
6
  * Closed vs open is the native `hidden` attribute on the overlay.
7
+ * Enter removes `hidden`, then plays. Exit plays first; `hidden` is set
8
+ * only after it finishes. Focus moves in when `hidden` is removed and
9
+ * restores when `hidden` is set. Reduced motion (or a zero computed
10
+ * duration) does both in the same turn. An in-flight exit stays the open
11
+ * dialog for Escape and the focus trap until that commit, and a new open
12
+ * cancels it.
7
13
  *
8
14
  * Openers: any element whose `aria-controls` token list includes a
9
15
  * `[modal-overlay]` id. `[modal-close]` closes the containing overlay.
@@ -5,6 +5,11 @@
5
5
  * [popover-root][hidden] > [popover-panel] + [popover-header]? +
6
6
  * [popover-body]? + [popover-close]?
7
7
  * Closed vs open is the native `hidden` attribute on [popover-root].
8
+ * Enter removes `hidden`, places the panel, moves focus, then plays.
9
+ * Exit plays first; `hidden`, placement cleanup, and focus restore run
10
+ * only after it finishes. Reduced motion (or a zero computed duration)
11
+ * does both in the same turn. An in-flight exit stays the open popover
12
+ * for Escape and the focus trap until that commit, and a new open cancels it.
8
13
  *
9
14
  * Never use a bare `popover` attribute. HTML `popover=""` / `popover="manual"`
10
15
  * activates the platform Popover API. The floating surface is [popover-panel].
@@ -0,0 +1,52 @@
1
+ /**
2
+ * DOM-first runtime for Juice native select chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [select] host, on the native element: <select select>.
6
+ * Any attribute value is still a select. Sync does
7
+ * not rewrite the attribute. A node that is not a
8
+ * <select>, including [combobox], is ignored. A
9
+ * <select> without [select] is ignored.
10
+ * [select-label] optional visible label. Pair it with the control
11
+ * (wrapping element, or for/id).
12
+ *
13
+ * The open list stays the platform popup. There is no [select-list]
14
+ * and no [select-option]. [multiple] and size listboxes stay native
15
+ * <select> elements. Sync does not set role, aria-expanded,
16
+ * aria-multiselectable, or tabindex, and it does not build a listbox.
17
+ *
18
+ * Sync (markup-driven):
19
+ * 1. Name the control from a visible label when the author has not
20
+ * set an accessible name. Sources, in order: an associated
21
+ * <label for>, a wrapping <label>, then [select-label] (for/id,
22
+ * a wrapping element, or the nearest preceding sibling).
23
+ * 2. An author aria-label or aria-labelledby is kept. A blank value
24
+ * is not a name. title is left untouched and does not block a
25
+ * visible label.
26
+ * 3. A label that does not contain the control is referenced with
27
+ * aria-labelledby (an id is added only when that label has none).
28
+ * A wrapping label is copied into aria-label as its visible text,
29
+ * excluding the control, so the selected option is not part of
30
+ * the name. Hidden labels and empty text are skipped.
31
+ * 4. When no visible label exists, sync does not invent a name.
32
+ * A name this runtime wrote is removed if that label goes away.
33
+ *
34
+ * Change and keys stay on the native control. There is no keyboard
35
+ * handler, no Escape handler, no focus trap, and no Sig Select factory.
36
+ *
37
+ * Limitations: a custom listbox, keyboard handling, Escape, a focus
38
+ * trap, and a Sig Select factory are out of scope. See
39
+ * docs/juice/juice-select-runtime.md.
40
+ */
41
+ export type SelectOptions = {
42
+ root?: ParentNode;
43
+ selectSelector?: string;
44
+ };
45
+ export type SelectController = {
46
+ destroy: () => void;
47
+ sync: () => void;
48
+ };
49
+ export declare const createSelect: (options?: SelectOptions) => SelectController;
50
+ export declare const initSelect: (options?: SelectOptions) => SelectController;
51
+ export declare const startSelectRuntime: () => SelectController | null;
52
+ export declare const stopSelectRuntime: () => void;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Shared enter/exit motion for Juice runtimes.
3
+ *
4
+ * `prefersReducedMotion` reads `matchMedia('(prefers-reduced-motion: reduce)')`.
5
+ * It returns false when `matchMedia` is missing (SSR, jsdom) or throws.
6
+ * `subscribeReducedMotion` reports later changes and returns an unsubscribe
7
+ * function. The unsubscribe is a no-op in those same environments.
8
+ *
9
+ * `runMotion` drives one element:
10
+ * enter → data-motion-state="entering", then "entered"
11
+ * exit → data-motion-state="exiting", then "exited"
12
+ * It resolves on `transitionend` or `animationend` whose target is that
13
+ * element. Events that bubble from children are ignored. If the event never
14
+ * arrives, a timeout fires after the computed transition and animation
15
+ * duration plus delay (the longer of the two). Duration 0, or reduced
16
+ * motion, finishes in the same turn (`immediate: true`) so callers can set
17
+ * `hidden` or restore focus before they return. A resolved promise alone
18
+ * would wait a microtask and miss that contract.
19
+ *
20
+ * Pass a `MotionCancelToken` to abandon an in-flight enter or exit. Cancelling
21
+ * does not apply the terminal state. `createElementMotion` keeps one token
22
+ * per element so a later enter or exit replaces the previous one.
23
+ */
24
+ export type MotionState = 'entering' | 'entered' | 'exiting' | 'exited';
25
+ export type MotionDirection = 'enter' | 'exit';
26
+ export type MotionCancelToken = {
27
+ readonly cancelled: boolean;
28
+ cancel: () => void;
29
+ };
30
+ export type MotionResult = {
31
+ /** True when the terminal state was applied before `runMotion` returned. */
32
+ immediate: boolean;
33
+ /** Resolves when the motion finishes or is cancelled. */
34
+ finished: Promise<{
35
+ completed: boolean;
36
+ }>;
37
+ };
38
+ export type MotionPlayer = {
39
+ enter: (element: HTMLElement, onComplete?: () => void, afterStart?: () => void) => void;
40
+ exit: (element: HTMLElement, onComplete?: () => void, afterStart?: () => void) => void;
41
+ cancel: (element: HTMLElement) => void;
42
+ destroy: () => void;
43
+ };
44
+ export declare const prefersReducedMotion: () => boolean;
45
+ export declare const subscribeReducedMotion: (listener: (reduced: boolean) => void) => (() => void);
46
+ export declare const createMotionCancelToken: () => MotionCancelToken;
47
+ export declare const runMotion: (element: HTMLElement, direction: MotionDirection, token?: MotionCancelToken) => MotionResult;
48
+ export declare const createElementMotion: () => MotionPlayer;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * DOM-first indeterminate busy-indicator runtime for Juice spinner chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [spinner] host. The ring is ::before. CSS owns the spin
6
+ * (juice-spinner-spin). prefers-reduced-motion already
7
+ * stops that animation. Any attribute value, including
8
+ * spinner="busy", is still a spinner. Sync does not
9
+ * rewrite the attribute. There is no <spinner> element.
10
+ * A node without [spinner] is ignored.
11
+ * [spinner-label] optional visible text, usually inside the host.
12
+ * Authors own the accessible name. The label is not
13
+ * copied into aria-label or aria-labelledby.
14
+ *
15
+ * Sync (markup-driven):
16
+ * 1. Shown means the host does not have the native hidden attribute.
17
+ * While shown, role="status" and aria-busy="true". An author role
18
+ * that is not status is replaced. The host is not made focusable
19
+ * (no tabindex). There is no keyboard and no pointer handler.
20
+ * 2. Hidden means native hidden. hide() sets that attribute and clears
21
+ * role="status" and aria-busy so the spinner does not announce as
22
+ * busy. show() removes hidden and restores the shown state.
23
+ * Siblings are left alone.
24
+ * 3. When there is no visible [spinner-label], authors supply the
25
+ * accessible name (aria-label or aria-labelledby). This runtime
26
+ * does not invent label text, and it does not rewrite a name the
27
+ * author already set.
28
+ *
29
+ * Not a progress bar: no value, no aria-valuenow, no
30
+ * --juice-progress-ratio. Not a layered overlay: no focus trap, no
31
+ * Escape, no Sig Spinner factory.
32
+ *
33
+ * Limitations: a value, keyboard handling, Escape, a focus trap, and a
34
+ * Sig Spinner factory are out of scope. See
35
+ * docs/juice/juice-spinner-runtime.md.
36
+ */
37
+ export type SpinnerOptions = {
38
+ root?: ParentNode;
39
+ spinnerSelector?: string;
40
+ };
41
+ export type SpinnerController = {
42
+ destroy: () => void;
43
+ sync: () => void;
44
+ show: (target?: HTMLElement | null) => void;
45
+ hide: (target?: HTMLElement | null) => void;
46
+ isShown: (target?: HTMLElement | null) => boolean;
47
+ };
48
+ export declare const createSpinner: (options?: SpinnerOptions) => SpinnerController;
49
+ export declare const initSpinner: (options?: SpinnerOptions) => SpinnerController;
50
+ export declare const startSpinnerRuntime: () => SpinnerController | null;
51
+ export declare const stopSpinnerRuntime: () => void;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * DOM-first runtime for Juice native textarea chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [textarea] host, on the native element: <textarea textarea>.
6
+ * Any attribute value is still a textarea. Sync does
7
+ * not rewrite the attribute. A node that is not a
8
+ * <textarea> is ignored. A <textarea> without
9
+ * [textarea] is ignored. A textarea inside [combobox],
10
+ * including [combobox-input], is ignored.
11
+ * [textarea-label] optional visible label. Pair it with the control
12
+ * (wrapping element, or for/id).
13
+ *
14
+ * Sync (markup-driven):
15
+ * 1. Name the control from a visible label when the author has not
16
+ * set an accessible name. Sources, in order: an associated
17
+ * <label for>, a wrapping <label>, then [textarea-label] (for/id,
18
+ * a wrapping element, or the nearest preceding sibling).
19
+ * 2. An author aria-label or aria-labelledby is kept. A blank value
20
+ * is not a name. title is left untouched and does not block a
21
+ * visible label.
22
+ * 3. A label that does not contain the control is referenced with
23
+ * aria-labelledby (an id is added only when that label has none).
24
+ * A wrapping label is copied into aria-label as its visible text,
25
+ * excluding the control, so the textarea's own value is not part
26
+ * of the name. Hidden labels and empty text are skipped.
27
+ * 4. When no visible label exists, sync does not invent a name.
28
+ * A name this runtime wrote is removed if that label goes away
29
+ * or the host stops being a [textarea] textarea.
30
+ *
31
+ * Typing, change, and keys stay on the native control. There is no
32
+ * auto-grow, no character count, no validation engine, no floating
33
+ * label, no keyboard handler, no Escape handler, no focus trap, and
34
+ * no Sig Textarea factory.
35
+ *
36
+ * Limitations: auto-grow, a character count, validation, a floating
37
+ * label, keyboard handling, Escape, a focus trap, and a Sig Textarea
38
+ * factory are out of scope. See docs/juice/juice-textarea-runtime.md.
39
+ */
40
+ export type TextareaOptions = {
41
+ root?: ParentNode;
42
+ textareaSelector?: string;
43
+ };
44
+ export type TextareaController = {
45
+ destroy: () => void;
46
+ sync: () => void;
47
+ };
48
+ export declare const createTextarea: (options?: TextareaOptions) => TextareaController;
49
+ export declare const initTextarea: (options?: TextareaOptions) => TextareaController;
50
+ export declare const startTextareaRuntime: () => TextareaController | null;
51
+ export declare const stopTextareaRuntime: () => void;
@@ -4,6 +4,11 @@
4
4
  * Markup contract (authors place the region — this is not a portal):
5
5
  * [toast-region] > [toast] + [toast-title]? + [toast-body]? + [toast-close]?
6
6
  * Individual toasts use native `hidden` when dismissed. The region stays in the DOM.
7
+ * Enter removes `hidden`, then plays. Exit plays first; `hidden` is set
8
+ * only after it finishes. Reduced motion (or a zero computed duration)
9
+ * does both in the same turn. Showing a toast that is exiting cancels
10
+ * the exit and leaves it open. Auto-dismiss duration is reading time,
11
+ * not motion: reduced motion does not shorten `toast-duration`.
7
12
  *
8
13
  * Toast is NOT a dialog:
9
14
  * - no focus trap, no aria-modal, no exclusive "one toast only"