@citrusworx/juiceui 0.8.0 → 0.9.1

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.
@@ -22,3 +22,17 @@ export { createBanner, initBanner, startBannerRuntime, stopBannerRuntime } from
22
22
  export type { BannerController, BannerOptions } from "./src/banner/banner-runtime.js";
23
23
  export { createMenu, initMenu, startMenuRuntime, stopMenuRuntime } from "./src/menu/menu-runtime.js";
24
24
  export type { MenuController, MenuOptions } from "./src/menu/menu-runtime.js";
25
+ export { createSwitch, initSwitch, startSwitchRuntime, stopSwitchRuntime } from "./src/switch/switch-runtime.js";
26
+ export type { SwitchController, SwitchOptions } from "./src/switch/switch-runtime.js";
27
+ export { createSlider, initSlider, startSliderRuntime, stopSliderRuntime } from "./src/slider/slider-runtime.js";
28
+ export type { SliderController, SliderOptions } from "./src/slider/slider-runtime.js";
29
+ export { createCheckbox, initCheckbox, startCheckboxRuntime, stopCheckboxRuntime } from "./src/checkbox/checkbox-runtime.js";
30
+ export type { CheckboxController, CheckboxOptions } from "./src/checkbox/checkbox-runtime.js";
31
+ export { createRadio, initRadio, startRadioRuntime, stopRadioRuntime } from "./src/radio/radio-runtime.js";
32
+ export type { RadioController, RadioOptions } from "./src/radio/radio-runtime.js";
33
+ export { createBreadcrumb, initBreadcrumb, startBreadcrumbRuntime, stopBreadcrumbRuntime } from "./src/breadcrumb/breadcrumb-runtime.js";
34
+ export type { BreadcrumbController, BreadcrumbOptions } from "./src/breadcrumb/breadcrumb-runtime.js";
35
+ export { createProgress, initProgress, startProgressRuntime, stopProgressRuntime } from "./src/progress/progress-runtime.js";
36
+ export type { ProgressController, ProgressOptions } from "./src/progress/progress-runtime.js";
37
+ export { createPagination, initPagination, startPaginationRuntime, stopPaginationRuntime } from "./src/pagination/pagination-runtime.js";
38
+ export type { PaginationController, PaginationOptions } from "./src/pagination/pagination-runtime.js";
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Light DOM-first breadcrumb runtime for Juice breadcrumb chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [breadcrumb] trail root. Authors use <nav breadcrumb> or
6
+ * <ol breadcrumb>.
7
+ * [breadcrumb-item] one crumb. Separator is CSS on every item
8
+ * except the last.
9
+ * [breadcrumb-link] optional. Anchors inside the trail are enough.
10
+ * [breadcrumb-separator]
11
+ * optional explicit separator. Authors own it.
12
+ *
13
+ * This is chrome, not a router. v1 does not listen to history, clicks,
14
+ * or the keyboard. It claims no events (no createEventClaim). There is
15
+ * no Escape handler, no focus trap, and no overlay.
16
+ *
17
+ * Sync (markup-driven):
18
+ * 1. Make the root a navigation landmark only when that is safe.
19
+ * - <nav> is already a landmark. Do not add a redundant
20
+ * role="navigation".
21
+ * - An element with no role that is not a list (ol / ul / menu)
22
+ * gets role="navigation". role="navigation" on a list would
23
+ * drop the list semantics, so <ol breadcrumb> is left alone.
24
+ * - An author role is never overwritten.
25
+ * - Ancestor <nav> elements are not relabeled. A parent nav may
26
+ * be a larger landmark than this trail.
27
+ * 2. Name that landmark only when it has no accessible name.
28
+ * APG's breadcrumb pattern puts the trail in a navigation
29
+ * landmark labeled "Breadcrumb" (aria-label or aria-labelledby).
30
+ * When the root is a navigation landmark and aria-label,
31
+ * aria-labelledby, and title are all missing or blank, sync sets
32
+ * aria-label="Breadcrumb". A non-empty author name is kept.
33
+ * Lists and other non-navigation roots are not given that label.
34
+ * 3. Keep a single aria-current="page" inside the trail.
35
+ * Crumbs are owned [breadcrumb-item] elements. When a trail has
36
+ * none, direct-child anchors and [breadcrumb-link] elements are
37
+ * the crumbs (the same flat markup the chrome styles).
38
+ * If the author already set aria-current="page", the first one
39
+ * in tree order stays and any others in this trail are removed.
40
+ * If none is set and the trail has crumbs, the last crumb is
41
+ * marked. A crumb that contains a link is marked on that link
42
+ * (the last owned anchor or [breadcrumb-link]); otherwise the
43
+ * crumb element itself is marked.
44
+ * 4. Do not rewrite the current crumb's href, click behavior, or
45
+ * disabled state. Authors own whether the current page is a link.
46
+ *
47
+ * setCurrent(item | index, trail?) moves that single current. An index
48
+ * applies to the given trail, or the first trail when trail is omitted.
49
+ * It is not a navigation.
50
+ */
51
+ export type BreadcrumbOptions = {
52
+ root?: ParentNode;
53
+ breadcrumbSelector?: string;
54
+ itemSelector?: string;
55
+ };
56
+ export type BreadcrumbController = {
57
+ destroy: () => void;
58
+ sync: () => void;
59
+ setCurrent: (itemOrIndex: HTMLElement | number, trail?: HTMLElement | null) => void;
60
+ };
61
+ export declare const createBreadcrumb: (options?: BreadcrumbOptions) => BreadcrumbController;
62
+ export declare const initBreadcrumb: (options?: BreadcrumbOptions) => BreadcrumbController;
63
+ export declare const startBreadcrumbRuntime: () => BreadcrumbController | null;
64
+ export declare const stopBreadcrumbRuntime: () => void;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * DOM-first APG Checkbox runtime for Juice checkbox chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [checkbox] on the control host. Primary host is
6
+ * <button type="button" checkbox>. Visible labels live beside the
7
+ * control (wrapping <label>, aria-label, or aria-labelledby) — the
8
+ * host *is* the box. The checkmark is a CSS pseudo-element; there
9
+ * is no [checkbox-box] child.
10
+ *
11
+ * Hosts this runtime enhances:
12
+ * - HTMLButtonElement (primary). Sync fills role="checkbox",
13
+ * aria-checked "true"|"false", and type="button" when type is
14
+ * missing (so a form does not submit).
15
+ * - HTMLInputElement type="checkbox" (secondary). Chrome already
16
+ * paints :checked. Sync fills role="checkbox" and keeps
17
+ * aria-checked in lockstep with the native checked property
18
+ * (change events, and a static aria-checked="true" on an
19
+ * unchecked box is promoted onto .checked so :checked paint
20
+ * matches). This is not a form-checkbox restyle as the only
21
+ * story, and it is not menuitemcheckbox or [switch].
22
+ *
23
+ * Other [checkbox] hosts (div, span, text inputs, radios) are ignored.
24
+ * Do not invent accessible names — authors must supply aria-label,
25
+ * aria-labelledby, or visible text.
26
+ *
27
+ * v1 is binary. aria-checked="mixed" and any other value coerce to
28
+ * "false". There is no tri-state, no focus trap, and no Escape
29
+ * handling (not a layered overlay).
30
+ *
31
+ * Click and Enter/Space toggle. Native disabled or aria-disabled="true"
32
+ * is ignored. Button click preventDefault stops accidental submit when
33
+ * type is still the default.
34
+ */
35
+ export type CheckboxOptions = {
36
+ root?: ParentNode;
37
+ checkboxSelector?: string;
38
+ };
39
+ export type CheckboxController = {
40
+ destroy: () => void;
41
+ sync: () => void;
42
+ toggle: (target?: HTMLElement | null) => void;
43
+ check: (target?: HTMLElement | null) => void;
44
+ uncheck: (target?: HTMLElement | null) => void;
45
+ setChecked: (checked: boolean, target?: HTMLElement | null) => void;
46
+ isChecked: (target?: HTMLElement | null) => boolean;
47
+ };
48
+ export declare const createCheckbox: (options?: CheckboxOptions) => CheckboxController;
49
+ export declare const initCheckbox: (options?: CheckboxOptions) => CheckboxController;
50
+ export declare const startCheckboxRuntime: () => CheckboxController | null;
51
+ export declare const stopCheckboxRuntime: () => void;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * DOM-first pagination runtime for Juice pagination chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [pagination] page-set root. Authors use <nav pagination> or
6
+ * <ol pagination>.
7
+ * [pagination-item] one cell. Layout only.
8
+ * [pagination-link] optional. Anchors and buttons inside the control
9
+ * are enough.
10
+ * [pagination-prev] / [pagination-next]
11
+ * previous and next controls. The attr may sit on
12
+ * the anchor or button, or on the item that wraps it.
13
+ * [pagination-ellipsis]
14
+ * optional gap marker. Not a page control.
15
+ * [pagination-status]
16
+ * optional "Page 2 of 12" text. Not a page control.
17
+ * Ends are not parsed from this text.
18
+ *
19
+ * This is chrome, not a router. It does not remove href, listen to
20
+ * history, trap focus, or handle Escape. It is not a layered overlay.
21
+ *
22
+ * Sync (markup-driven):
23
+ * 1. Make the root a navigation landmark only when that is safe.
24
+ * Same rules as breadcrumb:
25
+ * - <nav> is already a landmark. Do not add a redundant
26
+ * role="navigation".
27
+ * - An element with no role that is not a list (ol / ul / menu)
28
+ * gets role="navigation". role="navigation" on a list would
29
+ * drop the list semantics, so <ol pagination> is left alone.
30
+ * - An author role is never overwritten.
31
+ * - Ancestor <nav> elements are not relabeled.
32
+ * 2. Name that landmark only when it has no accessible name.
33
+ * When the root is a navigation landmark and aria-label,
34
+ * aria-labelledby, and title are all missing or blank, sync sets
35
+ * aria-label="Pagination". A non-empty author name is kept.
36
+ * Lists and other non-navigation roots are not given that label.
37
+ * 3. Keep exactly one aria-current="page" inside the root when the
38
+ * set has a page control.
39
+ * Page controls are owned cells and links that are not prev,
40
+ * next, ellipsis, or status. If the author already set
41
+ * aria-current="page", the first one in tree order stays and any
42
+ * others in this root are removed. If none is set, the first page
43
+ * control is marked (on its link when it has one). A set with no
44
+ * page control is left without a current page.
45
+ * 4. Sync prev/next disabled at the ends when that is inferable.
46
+ * Inference uses page controls plus optional ellipsis, not status
47
+ * text. Prev is disabled when the current page is the first page
48
+ * control and no ellipsis sits before it, or when that control's
49
+ * text is page 1. Next is disabled when the current page is the
50
+ * last page control and no ellipsis sits after it. Author-owned
51
+ * disabled (aria-disabled="true", native disabled, or [disabled]
52
+ * already present before this runtime wrote it) is never cleared.
53
+ * Runtime-owned disabled is aria-disabled="true", and disabled on
54
+ * buttons so they do not activate.
55
+ *
56
+ * Keyboard (conservative): ArrowLeft / ArrowUp and ArrowRight /
57
+ * ArrowDown move focus to the previous or next enabled control. Home /
58
+ * End move to the first or last enabled control. Disabled controls are
59
+ * skipped. Focus does not wrap. Enter and Space are left to the
60
+ * browser. A disabled link's click is cancelled so it does not navigate.
61
+ *
62
+ * setCurrent(item | index, pagination?) moves that single current. An
63
+ * index applies to page controls only (prev / next are not pages), on
64
+ * the given root, or the first root when omitted. It is not navigation.
65
+ */
66
+ export type PaginationOptions = {
67
+ root?: ParentNode;
68
+ paginationSelector?: string;
69
+ itemSelector?: string;
70
+ };
71
+ export type PaginationController = {
72
+ destroy: () => void;
73
+ sync: () => void;
74
+ setCurrent: (itemOrIndex: HTMLElement | number, pagination?: HTMLElement | null) => void;
75
+ };
76
+ export declare const createPagination: (options?: PaginationOptions) => PaginationController;
77
+ export declare const initPagination: (options?: PaginationOptions) => PaginationController;
78
+ export declare const startPaginationRuntime: () => PaginationController | null;
79
+ export declare const stopPaginationRuntime: () => void;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * DOM-first APG Progressbar runtime for Juice progress chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [progress] track host. Boolean (determinate) or
6
+ * progress="indeterminate". Any other value is
7
+ * determinate chrome; sync does not rewrite it.
8
+ * Authors write <div progress>, not <progress>.
9
+ * A native <progress> without the attribute is
10
+ * ignored. Native value / max are not the value hook.
11
+ * [progress-fill] filled portion. Optional for the runtime.
12
+ * [progress-label] optional visible value / status text. Authors own
13
+ * the accessible name. The label is not copied into
14
+ * aria-label, aria-labelledby, or aria-valuetext.
15
+ *
16
+ * Sync (markup-driven):
17
+ * 1. role="progressbar" on the host. An author role that is not
18
+ * progressbar is replaced. The host is not made focusable
19
+ * (no tabindex). There is no keyboard and no pointer handler.
20
+ * 2. Determinate: aria-valuemin (default 0), aria-valuemax (default
21
+ * 100), and aria-valuenow. A missing or non-numeric valuenow is
22
+ * min, which is an empty bar (ratio 0), not indeterminate.
23
+ * Values clamp to min/max. A max below min collapses to min.
24
+ * 3. The host inline custom property --juice-progress-ratio
25
+ * (unitless 0–1) stays in sync for every range, including ranges
26
+ * the 0–100 chrome selectors do not cover.
27
+ * 4. Indeterminate is progress="indeterminate" only. That flag wins.
28
+ * APG omits aria-valuenow while indeterminate; min/max stay.
29
+ * The last determinate value is remembered and restored when the
30
+ * flag clears. CSS owns the sliding fill.
31
+ * 5. aria-valuetext is never invented and never rewritten.
32
+ *
33
+ * Not a slider, not a spinner, and not a layered overlay: no focus
34
+ * trap, no Escape, no Sig Progress factory.
35
+ */
36
+ export type ProgressOptions = {
37
+ root?: ParentNode;
38
+ progressSelector?: string;
39
+ };
40
+ export type ProgressController = {
41
+ destroy: () => void;
42
+ sync: () => void;
43
+ setValue: (value: number, target?: HTMLElement | null) => void;
44
+ getValue: (target?: HTMLElement | null) => number;
45
+ setIndeterminate: (indeterminate: boolean, target?: HTMLElement | null) => void;
46
+ isIndeterminate: (target?: HTMLElement | null) => boolean;
47
+ };
48
+ export declare const createProgress: (options?: ProgressOptions) => ProgressController;
49
+ export declare const initProgress: (options?: ProgressOptions) => ProgressController;
50
+ export declare const startProgressRuntime: () => ProgressController | null;
51
+ export declare const stopProgressRuntime: () => void;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * DOM-first APG Radio Group runtime for Juice radio chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [radiogroup] is the group root (layout only — no group chrome).
6
+ * [radio] is one option. Primary host is
7
+ * <button type="button" radio> inside the group. Visible labels live
8
+ * beside the control (wrapping <label>, aria-label, or
9
+ * aria-labelledby) — the host *is* the disc. The dot is a CSS
10
+ * pseudo-element; there is no [radio-dot] child.
11
+ *
12
+ * Hosts this runtime enhances:
13
+ * - [radiogroup] roots. Sync fills role="radiogroup". Authors supply
14
+ * the group's accessible name. Radios outside a [radiogroup] are
15
+ * ignored (no solo exclusive group).
16
+ * - HTMLButtonElement [radio] descendants (primary). Sync fills
17
+ * role="radio", aria-checked "true"|"false", type="button" when
18
+ * type is missing, and a roving tabindex (one tab stop per group).
19
+ * - HTMLInputElement type="radio" (secondary). Chrome already paints
20
+ * :checked. Sync keeps aria-checked in lockstep with the native
21
+ * checked property. Exclusivity is the [radiogroup], not only the
22
+ * input name.
23
+ *
24
+ * Other [radio] hosts (div, span, text inputs, checkboxes) are ignored.
25
+ * A radio belongs to its nearest [radiogroup]. Do not invent accessible
26
+ * names.
27
+ *
28
+ * v1 is exclusive and binary. aria-checked="mixed" coerces to "false".
29
+ * When more than one radio is checked, sync keeps the first in document
30
+ * order. Zero checked is allowed until something is selected. There is
31
+ * no focus trap and no Escape handling (not a layered overlay).
32
+ *
33
+ * Click, Enter, and Space select the targeted radio. Arrow keys move
34
+ * the selection among enabled radios in the group and wrap, skipping
35
+ * disabled / aria-disabled radios. Native disabled or aria-disabled="true"
36
+ * is ignored.
37
+ */
38
+ export type RadioOptions = {
39
+ root?: ParentNode;
40
+ radiogroupSelector?: string;
41
+ radioSelector?: string;
42
+ };
43
+ export type RadioController = {
44
+ destroy: () => void;
45
+ sync: () => void;
46
+ select: (radio?: HTMLElement | null) => void;
47
+ getChecked: (group?: HTMLElement | null) => HTMLElement | null;
48
+ };
49
+ export declare const createRadio: (options?: RadioOptions) => RadioController;
50
+ export declare const initRadio: (options?: RadioOptions) => RadioController;
51
+ export declare const startRadioRuntime: () => RadioController | null;
52
+ export declare const stopRadioRuntime: () => void;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * DOM-first APG Slider runtime for Juice slider chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [slider] track host. Boolean or "horizontal".
6
+ * [slider="vertical"] is not painted and is not enhanced.
7
+ * [slider-fill] completed portion. Optional.
8
+ * [slider-thumb] real thumb. Required. Orphan thumbs are ignored.
9
+ * The first thumb whose nearest [slider] is the host
10
+ * is the control. Extra thumbs are not a multi-thumb
11
+ * slider in v1.
12
+ *
13
+ * Focus model: the thumb is the APG slider. Sync sets role="slider",
14
+ * tabindex="0" when the thumb is not natively focusable, type="button"
15
+ * when a button thumb omitted type, aria-valuemin (default 0),
16
+ * aria-valuemax (default 100), aria-valuenow, and
17
+ * aria-orientation="horizontal" on the thumb. The host stays the track.
18
+ * An author role="slider" on the host is removed so assistive tech sees
19
+ * one slider. Thumb aria-valuemin / aria-valuemax / aria-valuenow win
20
+ * over the same attributes on the host. A missing valuenow defaults to
21
+ * min. aria-valuetext is never invented and is never rewritten. Authors
22
+ * supply the accessible name.
23
+ *
24
+ * Paint: the host inline custom property --juice-slider-ratio (unitless
25
+ * 0–1) stays in sync for every range. Integer aria-valuenow 0–100 on the
26
+ * thumb also matches the chrome attribute selectors.
27
+ *
28
+ * Keyboard (thumb only): ArrowLeft / ArrowDown decrease, ArrowRight /
29
+ * ArrowUp increase, Home / End jump to min / max, PageUp / PageDown move
30
+ * by a larger step. Step is 1. Page step is 10. Values clamp to min/max.
31
+ * Pointer: primary pointerdown on the track, fill, or thumb jumps to that
32
+ * position and starts a drag; pointermove follows until pointerup or
33
+ * pointercancel. The thumb captures the pointer when the platform allows
34
+ * it. Disabled or aria-disabled="true" on the host or thumb is ignored.
35
+ *
36
+ * v1 is horizontal Juice markup only. There is no vertical orientation,
37
+ * no multi-thumb, no native <input type="range"> restyle, and no Escape
38
+ * handling (not a layered overlay).
39
+ */
40
+ export type SliderOptions = {
41
+ root?: ParentNode;
42
+ sliderSelector?: string;
43
+ };
44
+ export type SliderController = {
45
+ destroy: () => void;
46
+ sync: () => void;
47
+ setValue: (value: number, target?: HTMLElement | null) => void;
48
+ getValue: (target?: HTMLElement | null) => number;
49
+ increment: (target?: HTMLElement | null) => void;
50
+ decrement: (target?: HTMLElement | null) => void;
51
+ };
52
+ export declare const createSlider: (options?: SliderOptions) => SliderController;
53
+ export declare const initSlider: (options?: SliderOptions) => SliderController;
54
+ export declare const startSliderRuntime: () => SliderController | null;
55
+ export declare const stopSliderRuntime: () => void;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * DOM-first APG Switch runtime for Juice switch chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [switch] on the control host. Primary host is
6
+ * <button type="button" switch>. Visible labels live beside the
7
+ * control (wrapping <label>, aria-label, or aria-labelledby) — the
8
+ * host *is* the track. Track / thumb are CSS pseudo-elements; there
9
+ * are no [switch-track] / [switch-thumb] children.
10
+ *
11
+ * Hosts this runtime enhances:
12
+ * - HTMLButtonElement (primary). Sync fills role="switch",
13
+ * aria-checked "true"|"false", and type="button" when type is
14
+ * missing (so a form does not submit).
15
+ * - HTMLInputElement type="checkbox" (secondary). Chrome already
16
+ * paints :checked. Sync fills role="switch" and keeps aria-checked
17
+ * in lockstep with the native checked property (change events, and
18
+ * a static aria-checked="true" on an unchecked box is promoted onto
19
+ * .checked so :checked paint matches). This is not a form-checkbox
20
+ * restyle as the only story, and it is not menuitemcheckbox.
21
+ *
22
+ * Other [switch] hosts (div, span, text inputs, radios) are ignored.
23
+ * Do not invent accessible names — authors must supply aria-label,
24
+ * aria-labelledby, or visible text.
25
+ *
26
+ * v1 is binary. aria-checked="mixed" and any other value coerce to
27
+ * "false". There is no switch="on", no tri-state, no focus trap, and
28
+ * no Escape handling (not a layered overlay).
29
+ *
30
+ * Click and Enter/Space toggle. Native disabled or aria-disabled="true"
31
+ * is ignored. Button click preventDefault stops accidental submit when
32
+ * type is still the default.
33
+ */
34
+ export type SwitchOptions = {
35
+ root?: ParentNode;
36
+ switchSelector?: string;
37
+ };
38
+ export type SwitchController = {
39
+ destroy: () => void;
40
+ sync: () => void;
41
+ toggle: (target?: HTMLElement | null) => void;
42
+ check: (target?: HTMLElement | null) => void;
43
+ uncheck: (target?: HTMLElement | null) => void;
44
+ setChecked: (checked: boolean, target?: HTMLElement | null) => void;
45
+ isChecked: (target?: HTMLElement | null) => boolean;
46
+ };
47
+ export declare const createSwitch: (options?: SwitchOptions) => SwitchController;
48
+ export declare const initSwitch: (options?: SwitchOptions) => SwitchController;
49
+ export declare const startSwitchRuntime: () => SwitchController | null;
50
+ export declare const stopSwitchRuntime: () => void;