@citrusworx/juiceui 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,3 +12,13 @@ export { createToast, initToast, startToastRuntime, stopToastRuntime } from "./s
12
12
  export type { ToastController, ToastOptions } from "./src/toast/toast-runtime.js";
13
13
  export { createPopover, initPopover, startPopoverRuntime, stopPopoverRuntime } from "./src/popover/popover-runtime.js";
14
14
  export type { PopoverController, PopoverOptions, PopoverPlacement } from "./src/popover/popover-runtime.js";
15
+ export { createTooltip, initTooltip, startTooltipRuntime, stopTooltipRuntime } from "./src/tooltip/tooltip-runtime.js";
16
+ export type { TooltipController, TooltipOptions, TooltipPlacement } from "./src/tooltip/tooltip-runtime.js";
17
+ export { createWizard, initWizard, startWizardRuntime, stopWizardRuntime } from "./src/wizard/wizard-runtime.js";
18
+ export type { WizardController, WizardOptions } from "./src/wizard/wizard-runtime.js";
19
+ export { createCombobox, initCombobox, startComboboxRuntime, stopComboboxRuntime } from "./src/combobox/combobox-runtime.js";
20
+ export type { ComboboxController, ComboboxOptions } from "./src/combobox/combobox-runtime.js";
21
+ export { createBanner, initBanner, startBannerRuntime, stopBannerRuntime } from "./src/banner/banner-runtime.js";
22
+ export type { BannerController, BannerOptions } from "./src/banner/banner-runtime.js";
23
+ export { createMenu, initMenu, startMenuRuntime, stopMenuRuntime } from "./src/menu/menu-runtime.js";
24
+ export type { MenuController, MenuOptions } from "./src/menu/menu-runtime.js";
@@ -0,0 +1,40 @@
1
+ /**
2
+ * DOM-first banner dismiss runtime for Juice banner chrome.
3
+ *
4
+ * Markup contract (authors place the callout — this is not a portal):
5
+ * [banner] / [banner="full"] + [banner-body]? + [banner-close]?
6
+ * Optional status: [banner-tone="info|success|warning|error"]
7
+ * Closed banners use native `hidden`. The node stays in the DOM.
8
+ *
9
+ * Banner is NOT a dialog and NOT a toast stack:
10
+ * - no focus trap, no aria-modal, no overlay, no [banner-region]
11
+ * - no auto-dismiss timer; the banner stays until dismiss
12
+ * - show() never hides siblings
13
+ * - do not move focus into the banner on show
14
+ *
15
+ * Escape is left to modal / drawer / popover / toast. Banner is inline
16
+ * and not a dialog; v1 does not steal Escape for focused banners.
17
+ *
18
+ * Persist (lean): optional banner-persist="session|local" plus a `name`
19
+ * or `id` key remembers dismiss in sessionStorage / localStorage.
20
+ * Without persist, or without a name/id, dismiss is in-memory only.
21
+ *
22
+ * Live role: sync fills role="status" for info / success / neutral, and
23
+ * role="alert" for error / warning. Empty close controls get
24
+ * aria-label="Dismiss".
25
+ */
26
+ export type BannerOptions = {
27
+ root?: ParentNode;
28
+ bannerSelector?: string;
29
+ closeSelector?: string;
30
+ };
31
+ export type BannerController = {
32
+ destroy: () => void;
33
+ sync: () => void;
34
+ show: (target?: HTMLElement | null) => void;
35
+ dismiss: (target?: HTMLElement | null) => void;
36
+ };
37
+ export declare const createBanner: (options?: BannerOptions) => BannerController;
38
+ export declare const initBanner: (options?: BannerOptions) => BannerController;
39
+ export declare const startBannerRuntime: () => BannerController | null;
40
+ export declare const stopBannerRuntime: () => void;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * DOM-first combobox runtime for Juice combobox chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [combobox] > [combobox-input] + [combobox-trigger]? +
6
+ * [combobox-list] > [combobox-option]+
7
+ * Closed vs open is the native `hidden` attribute on [combobox-list].
8
+ *
9
+ * This is an editable combobox with a listbox popup (APG list
10
+ * autocomplete, manual selection). It is not a native <select>
11
+ * polyfill, not a popover, not a tooltip, and not a dialog overlay.
12
+ * Single-select only. No async/remote fetch, no creatable options,
13
+ * no multi-select, no Floating UI.
14
+ *
15
+ * Accessibility (honest v1):
16
+ * [combobox-input] role="combobox" aria-autocomplete="list"
17
+ * aria-expanded aria-controls aria-activedescendant
18
+ * [combobox-list] role="listbox"
19
+ * [combobox-option] role="option" + guaranteed id on sync
20
+ * Focus stays on the input. Visual focus on options is
21
+ * `aria-activedescendant` plus `combobox-option="active"` paint.
22
+ * Committed choice is `aria-selected="true"`.
23
+ *
24
+ * Open on input focus, typing, or trigger click. Close on Escape
25
+ * (yields when an open [modal-overlay], [drawer-overlay],
26
+ * [popover-root], or [menu] exists — those surfaces own Escape first;
27
+ * menu sits with popover in the dialog-adjacent band),
28
+ * outside click, blur (option mousedown preventDefault so the input
29
+ * keeps focus through click-to-select), or after select.
30
+ *
31
+ * Filter: case-insensitive substring against option text and, when
32
+ * present, `data-value`. Non-matches get `hidden` on the option.
33
+ * An empty match set stays open with no visible options.
34
+ *
35
+ * Keyboard (list autocomplete, manual selection):
36
+ * ArrowDown / ArrowUp open if needed; move active among visible
37
+ * options (no wrap)
38
+ * Home / End first / last visible option while open
39
+ * (closed: native input cursor)
40
+ * Enter select the active option
41
+ * Escape close (yields to open dialog / popover / menu)
42
+ * Tab close without committing the active option
43
+ * (APG manual selection). Focus moves on.
44
+ *
45
+ * Select: input value becomes option text, or `data-value` when that
46
+ * attribute is present. Chosen option gets `aria-selected="true"`;
47
+ * others are cleared. Closing (including after select, Tab, or
48
+ * Escape) clears `combobox-option="active"` and aria-activedescendant
49
+ * so a later Enter cannot commit a stale option.
50
+ *
51
+ * Trigger toggles the list. `aria-expanded` is written on the input
52
+ * and, when present, the trigger. Opening one managed combobox closes
53
+ * the others. Placement stays CSS (`[combobox-list]` is absolute
54
+ * under the field at z-index 1050).
55
+ */
56
+ export type ComboboxOptions = {
57
+ root?: ParentNode;
58
+ rootSelector?: string;
59
+ inputSelector?: string;
60
+ triggerSelector?: string;
61
+ listSelector?: string;
62
+ optionSelector?: string;
63
+ };
64
+ export type ComboboxController = {
65
+ destroy: () => void;
66
+ sync: () => void;
67
+ open: (target?: HTMLElement | null) => void;
68
+ close: (target?: HTMLElement | null) => void;
69
+ toggle: (target?: HTMLElement | null) => void;
70
+ select: (target?: HTMLElement | null) => void;
71
+ };
72
+ export declare const createCombobox: (options?: ComboboxOptions) => ComboboxController;
73
+ export declare const initCombobox: (options?: ComboboxOptions) => ComboboxController;
74
+ export declare const startComboboxRuntime: () => ComboboxController | null;
75
+ export declare const stopComboboxRuntime: () => void;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * DOM-first APG Menu Button runtime for Juice menu chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [menu-root] > opener + [menu][hidden] > [menuitem]+ /
6
+ * [menu-separator]? / [menu-label]?
7
+ * Closed vs open is the native `hidden` attribute on `[menu]`, not on
8
+ * `[menu-root]` (hiding the root would hide the opener).
9
+ *
10
+ * Opener: prefer `[menu-button]` inside the root. Authors may omit that
11
+ * attr for CTA styling and use a plain button/control inside the root.
12
+ * Pairing: `aria-haspopup="menu"` + `aria-controls` → the `[menu]` id
13
+ * (runtime fills missing).
14
+ *
15
+ * This is an APG **Menu Button** (opener toggles a menu of menuitems).
16
+ * It is not a popover, not a combobox, not a native <select> restyle,
17
+ * not a menubar, and not a context menu. No submenus or typeahead in v1.
18
+ * Placement stays CSS-absolute on `[menu-root]` (`top|bottom|left|right`,
19
+ * default bottom). No Floating UI. No `aria-modal`.
20
+ *
21
+ * Keyboard focus (honest v1): **roving tabindex** on `[menuitem]`.
22
+ * Combobox keeps focus on the input and uses `aria-activedescendant`
23
+ * because the text field must remain the active element. APG Menu Button
24
+ * moves focus onto the menuitem itself (ArrowUp/Down, Home/End move
25
+ * `tabindex="0"` plus `menuitem="active"` paint). This runtime follows
26
+ * that pattern. Separators and labels are skipped. Disabled items
27
+ * (`aria-disabled="true"` or native `disabled`) are skipped.
28
+ *
29
+ * Open on opener click / Enter / Space (native buttons use click).
30
+ * ArrowDown on a closed opener opens and focuses the first enabled item
31
+ * (or the previously active item). ArrowUp opens onto the last enabled
32
+ * item. Close on Escape (yields when an open [modal-overlay] or
33
+ * [drawer-overlay] exists — menu sits with popover in the dialog-adjacent
34
+ * band), outside click, Tab (closes without activating; focus returns
35
+ * to the opener so Tab's default can move to the next/previous control),
36
+ * or after activating an item. Activating an item clicks it and restores
37
+ * focus to the opener. Disabled items are intercepted on capture so
38
+ * author click handlers never run. Opening one managed menu closes the
39
+ * others. Modal / drawer / popover are not auto-closed. ArrowUp/Down on
40
+ * a closed menu apply only to the opener. A controller claims opener
41
+ * clicks only when it can resolve a panel (custom `menuSelector` can
42
+ * coexist with the auto singleton).
43
+ */
44
+ export type MenuOptions = {
45
+ root?: ParentNode;
46
+ rootSelector?: string;
47
+ buttonSelector?: string;
48
+ menuSelector?: string;
49
+ itemSelector?: string;
50
+ separatorSelector?: string;
51
+ labelSelector?: string;
52
+ };
53
+ export type MenuController = {
54
+ destroy: () => void;
55
+ sync: () => void;
56
+ open: (target?: HTMLElement | null) => void;
57
+ close: (target?: HTMLElement | null) => void;
58
+ toggle: (target?: HTMLElement | null) => void;
59
+ select: (target?: HTMLElement | null) => void;
60
+ };
61
+ export declare const createMenu: (options?: MenuOptions) => MenuController;
62
+ export declare const initMenu: (options?: MenuOptions) => MenuController;
63
+ export declare const startMenuRuntime: () => MenuController | null;
64
+ export declare const stopMenuRuntime: () => void;
@@ -31,9 +31,11 @@
31
31
  *
32
32
  * Escape closes the open popover on bubble (after modal/drawer capture),
33
33
  * and also yields when an open [modal-overlay] or [drawer-overlay] exists
34
- * or the event is already defaultPrevented (same courtesy as toast).
35
- * Opening one managed popover closes the others. Modal / drawer are not
36
- * auto-closed.
34
+ * or the event is already defaultPrevented (those dialogs own Escape).
35
+ * Menu sits in the same dialog-adjacent band as popover (peers do not
36
+ * yield to each other). Combobox / toast / tooltip yield to an open
37
+ * popover or menu. Opening one managed popover closes the others. Modal
38
+ * / drawer / menu are not auto-closed.
37
39
  */
38
40
  export type PopoverPlacement = 'top' | 'bottom' | 'left' | 'right';
39
41
  export type PopoverOptions = {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal per-runtime event claim. Not a public export.
3
+ *
4
+ * Call once at module scope so custom-root and auto-enhance instances
5
+ * of the same runtime share one WeakSet and do not double-handle.
6
+ */
7
+ export declare const createEventClaim: () => (event: Event) => boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal focus-trap helpers for modal, drawer, and popover. Not a public export.
3
+ */
4
+ export declare const isFocusableCandidate: (element: HTMLElement) => boolean;
5
+ export declare const getFocusable: (container: HTMLElement) => HTMLElement[];
6
+ export declare const moveFocusInto: (container: HTMLElement) => void;
7
+ export declare const wrapTabFocus: (event: KeyboardEvent, container: HTMLElement) => boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal Juice runtime id helpers. Not a public export.
3
+ */
4
+ export declare const escapeId: (value: string) => string;
5
+ export declare const tokenIds: (value: string | null | undefined) => string[];
6
+ export declare const controlIds: (element: HTMLElement) => string[];
7
+ export declare const resolveElementById: (id: string, root: ParentNode) => HTMLElement | null;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Internal open-surface queries for Escape yield. Not a public export.
3
+ * Selectors match the polish A/B overlay contract.
4
+ *
5
+ * Yield order (highest owns Escape first):
6
+ * modal/drawer overlay → popover ≈ menu (same band) → combobox →
7
+ * toast / tooltip. Menu closed vs open is native `hidden` on `[menu]`,
8
+ * not on `[menu-root]`.
9
+ */
10
+ export declare const hasOpenDialogOverlay: () => boolean;
11
+ export declare const hasOpenPopover: () => boolean;
12
+ export declare const hasOpenMenu: () => boolean;
13
+ export declare const hasOpenComboboxList: () => boolean;
14
+ export declare const hasOpenTooltip: () => boolean;
@@ -19,7 +19,10 @@
19
19
  * Auto-dismiss pauses while pointer or focus is inside the toast, then resumes.
20
20
  *
21
21
  * Escape dismisses the most recently shown visible toast, but only when no
22
- * open [modal-overlay] or [drawer-overlay] exists (those dialogs own Escape).
22
+ * open [modal-overlay], [drawer-overlay], [popover-root], [menu],
23
+ * [combobox-list], or [tooltip-root] exists (those surfaces own Escape
24
+ * first; menu sits with popover). An open tip hides while toasts remain
25
+ * — toast does not steal Escape from tooltip.
23
26
  *
24
27
  * Live region: sync fills missing aria-live="polite" and
25
28
  * aria-relevant="additions" on [toast-region]. Opt into assertive with
@@ -0,0 +1,60 @@
1
+ /**
2
+ * DOM-first tooltip runtime for Juice tooltip chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [tooltip-root][hidden] > [tooltip-panel role="tooltip"]
6
+ * Closed vs open is the native `hidden` attribute on [tooltip-root].
7
+ *
8
+ * Never use a bare `tooltip` attribute. Juice chrome is not the native
9
+ * HTML `title` attribute — do not restyle or replace `title`.
10
+ *
11
+ * Tooltip is a thin cousin of popover: hover/focus only, no interactive
12
+ * content, no close button, no focus trap, no status variants. Do not
13
+ * move focus into the tip. It is not a popover, not a modal, not a
14
+ * drawer, and not a toast stack.
15
+ *
16
+ * Pairing: prefer `aria-describedby` pointing at the tooltip-root id
17
+ * (APG). `aria-controls` is also accepted for consistency with other
18
+ * Juice runtimes. Sync fills a missing root id and ensures the trigger
19
+ * `aria-describedby` token list includes that id.
20
+ *
21
+ * Show on pointer enter / focus of the trigger; hide on pointer leave /
22
+ * blur after a short grace (default 150ms) so a brief leave does not
23
+ * flicker. The tip has `pointer-events: none` in chrome, so the delay
24
+ * is not a bridge onto the tip. Touch / first-tap is later — v1 is
25
+ * hover and keyboard focus only.
26
+ *
27
+ * Placement (honest v1, no Floating UI): read `tooltip-root` (`top` /
28
+ * `bottom` / `left` / `right`, default `top`), position `fixed` near
29
+ * the trigger from getBoundingClientRect, with a small gap. If a
30
+ * transformed / filtered ancestor is the fixed containing block,
31
+ * subtract that origin. If the preferred side overflows the viewport,
32
+ * flip once to the opposite side. Repositions on open, window resize,
33
+ * and capture scroll (rAF-throttled).
34
+ *
35
+ * Escape hides the open tip on bubble, but yields when an open
36
+ * [modal-overlay], [drawer-overlay], [popover-root], [menu], or
37
+ * [combobox-list] exists, or the event is already defaultPrevented
38
+ * (same courtesy as toast / popover). Menu sits with popover in the
39
+ * dialog-adjacent band. Toast does not block tooltip Escape — the tip
40
+ * can hide while toasts remain. Opening one managed tooltip closes the
41
+ * others.
42
+ */
43
+ export type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right';
44
+ export type TooltipOptions = {
45
+ root?: ParentNode;
46
+ rootSelector?: string;
47
+ panelSelector?: string;
48
+ gap?: number;
49
+ hideDelay?: number;
50
+ };
51
+ export type TooltipController = {
52
+ destroy: () => void;
53
+ sync: () => void;
54
+ show: (target?: HTMLElement | null) => void;
55
+ hide: (target?: HTMLElement | null) => void;
56
+ };
57
+ export declare const createTooltip: (options?: TooltipOptions) => TooltipController;
58
+ export declare const initTooltip: (options?: TooltipOptions) => TooltipController;
59
+ export declare const startTooltipRuntime: () => TooltipController | null;
60
+ export declare const stopTooltipRuntime: () => void;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * DOM-first multi-step wizard runtime for Juice wizard chrome.
3
+ *
4
+ * Markup contract (authors place the shell — this is not a form engine):
5
+ * [wizard-shell] > [step-tracker] [steps] > [step]
6
+ * > [wizard-content] > [step-page] + [step-nav]
7
+ *
8
+ * Pairing (first match wins, then document order):
9
+ * aria-controls → page id
10
+ * data-step / name / [step-page="…"] / id
11
+ *
12
+ * KiwiPress templates in this repo do not ship live wizard HTML. The pairing
13
+ * tokens follow wizard.scss: named pages (`[step-page="welcome"]`) and
14
+ * `[wizard-content][data-step="…"]`. Tracker items typically use the same
15
+ * `data-step` / `name` token, or rely on index order.
16
+ *
17
+ * Navigation (honest default — documented here, not a second API):
18
+ * bare [wizard-shell] jump to completed + current; no skip ahead
19
+ * wizard-shell="linear" prev/next only; tracker clicks do nothing
20
+ * wizard-shell="free" jump to any step
21
+ * Programmatic next / prev / goTo always work. Linear / default only
22
+ * constrain tracker clicks. Form validation and provisioning stay in the app.
23
+ *
24
+ * Visible vs hidden pages use native `hidden`. Do not write layout `content=`.
25
+ * Step paint uses [step="pending"|"active"|"completed"] (slice A chrome).
26
+ *
27
+ * A11y is a step indicator + one visible region, not APG Tabs:
28
+ * aria-current="step" on the active tracker item
29
+ * [step-page] as role="region" labelled by its step when unlabeled
30
+ */
31
+ export type WizardOptions = {
32
+ root?: ParentNode;
33
+ shellSelector?: string;
34
+ trackerSelector?: string;
35
+ stepsSelector?: string;
36
+ stepSelector?: string;
37
+ pageSelector?: string;
38
+ navSelector?: string;
39
+ nextSelector?: string;
40
+ prevSelector?: string;
41
+ completeSelector?: string;
42
+ };
43
+ export type WizardController = {
44
+ destroy: () => void;
45
+ sync: () => void;
46
+ next: (target?: HTMLElement | null) => void;
47
+ prev: (target?: HTMLElement | null) => void;
48
+ goTo: (step: number | string, target?: HTMLElement | null) => void;
49
+ current: (target?: HTMLElement | null) => number;
50
+ };
51
+ export declare const createWizard: (options?: WizardOptions) => WizardController;
52
+ export declare const initWizard: (options?: WizardOptions) => WizardController;
53
+ export declare const startWizardRuntime: () => WizardController | null;
54
+ export declare const stopWizardRuntime: () => void;