@citrusworx/juiceui 0.9.1 → 0.9.3

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.
Files changed (51) hide show
  1. package/README.md +59 -6
  2. package/dist/components/accordion/accordion.d.ts +2 -1
  3. package/dist/index.css +2767 -328
  4. package/dist/index.d.ts +41 -19
  5. package/dist/index.js +3804 -1967
  6. package/dist/js/juice.d.ts +41 -19
  7. package/dist/js/src/accordion/accordion-runtime.d.ts +6 -0
  8. package/dist/js/src/avatar/avatar-runtime.d.ts +74 -0
  9. package/dist/js/src/banner/banner-runtime.d.ts +5 -0
  10. package/dist/js/src/breadcrumb/breadcrumb-runtime.d.ts +6 -0
  11. package/dist/js/src/checkbox/checkbox-runtime.d.ts +4 -0
  12. package/dist/js/src/combobox/combobox-runtime.d.ts +6 -0
  13. package/dist/js/src/disclosure/disclosure-runtime.d.ts +56 -0
  14. package/dist/js/src/drawer/drawer-runtime.d.ts +11 -0
  15. package/dist/js/src/field/field-runtime.d.ts +58 -0
  16. package/dist/js/src/icon-button/icon-button-runtime.d.ts +67 -0
  17. package/dist/js/src/input/input-runtime.d.ts +63 -0
  18. package/dist/js/src/menu/menu-runtime.d.ts +5 -0
  19. package/dist/js/src/modal/modal-runtime.d.ts +11 -0
  20. package/dist/js/src/nav/navigation.d.ts +5 -0
  21. package/dist/js/src/pagination/pagination-runtime.d.ts +6 -0
  22. package/dist/js/src/popover/popover-runtime.d.ts +10 -0
  23. package/dist/js/src/progress/progress-runtime.d.ts +5 -0
  24. package/dist/js/src/radio/radio-runtime.d.ts +7 -0
  25. package/dist/js/src/select/select-runtime.d.ts +61 -0
  26. package/dist/js/src/shared/change.d.ts +32 -0
  27. package/dist/js/src/shared/motion.d.ts +48 -0
  28. package/dist/js/src/slider/slider-runtime.d.ts +4 -0
  29. package/dist/js/src/spinner/spinner-runtime.d.ts +55 -0
  30. package/dist/js/src/switch/switch-runtime.d.ts +4 -0
  31. package/dist/js/src/table/table-runtime.d.ts +99 -0
  32. package/dist/js/src/tabs/tabs-runtime.d.ts +6 -0
  33. package/dist/js/src/textarea/textarea-runtime.d.ts +59 -0
  34. package/dist/js/src/toast/toast-runtime.d.ts +10 -0
  35. package/dist/js/src/tooltip/tooltip-runtime.d.ts +5 -0
  36. package/dist/js/src/wizard/wizard-runtime.d.ts +4 -0
  37. package/dist/themes/aquaflux.css +318 -0
  38. package/dist/themes/citrusmint.css +317 -0
  39. package/dist/themes/kiwipress.css +317 -0
  40. package/dist/themes/retro-afterburn.css +318 -0
  41. package/dist/themes/retro-arcade-glow.css +318 -0
  42. package/dist/themes/retro-boardwalk.css +585 -56
  43. package/dist/themes/retro-denim-dial.css +318 -0
  44. package/dist/themes/retro-forest-radio.css +318 -0
  45. package/dist/themes/retro-orchard-club.css +318 -0
  46. package/dist/themes/retro-poolside-pop.css +318 -0
  47. package/dist/themes/retro-signal-garden.css +318 -0
  48. package/dist/themes/retro-sunset-motel.css +318 -0
  49. package/dist/themes/retro-violet-parlor.css +318 -0
  50. package/dist/themes/tide.css +318 -0
  51. package/package.json +2 -2
@@ -1,38 +1,60 @@
1
1
  export { createNavigation, initNavigation, startNavigationRuntime, stopNavigationRuntime } from "./src/nav/navigation.js";
2
- export type { NavigationController, NavigationOptions } from "./src/nav/navigation.js";
2
+ export type { NavigationController, NavigationOptions, NavigationState } from "./src/nav/navigation.js";
3
3
  export { createAccordion, initAccordion, startAccordionRuntime, stopAccordionRuntime } from "./src/accordion/accordion-runtime.js";
4
- export type { AccordionController, AccordionOptions } from "./src/accordion/accordion-runtime.js";
4
+ export type { AccordionController, AccordionOptions, AccordionState } from "./src/accordion/accordion-runtime.js";
5
5
  export { createTabs, initTabs, startTabsRuntime, stopTabsRuntime } from "./src/tabs/tabs-runtime.js";
6
- export type { TabsController, TabsOptions } from "./src/tabs/tabs-runtime.js";
6
+ export type { TabsController, TabsOptions, TabsState } from "./src/tabs/tabs-runtime.js";
7
7
  export { createModal, initModal, startModalRuntime, stopModalRuntime } from "./src/modal/modal-runtime.js";
8
- export type { ModalController, ModalOptions } from "./src/modal/modal-runtime.js";
8
+ export type { ModalController, ModalOptions, ModalState } from "./src/modal/modal-runtime.js";
9
9
  export { createDrawer, initDrawer, startDrawerRuntime, stopDrawerRuntime } from "./src/drawer/drawer-runtime.js";
10
- export type { DrawerController, DrawerOptions } from "./src/drawer/drawer-runtime.js";
10
+ export type { DrawerController, DrawerOptions, DrawerState } from "./src/drawer/drawer-runtime.js";
11
11
  export { createToast, initToast, startToastRuntime, stopToastRuntime } from "./src/toast/toast-runtime.js";
12
- export type { ToastController, ToastOptions } from "./src/toast/toast-runtime.js";
12
+ export type { ToastController, ToastOptions, ToastState } from "./src/toast/toast-runtime.js";
13
13
  export { createPopover, initPopover, startPopoverRuntime, stopPopoverRuntime } from "./src/popover/popover-runtime.js";
14
- export type { PopoverController, PopoverOptions, PopoverPlacement } from "./src/popover/popover-runtime.js";
14
+ export type { PopoverController, PopoverOptions, PopoverPlacement, PopoverState } from "./src/popover/popover-runtime.js";
15
15
  export { createTooltip, initTooltip, startTooltipRuntime, stopTooltipRuntime } from "./src/tooltip/tooltip-runtime.js";
16
- export type { TooltipController, TooltipOptions, TooltipPlacement } from "./src/tooltip/tooltip-runtime.js";
16
+ export type { TooltipController, TooltipOptions, TooltipPlacement, TooltipState } from "./src/tooltip/tooltip-runtime.js";
17
17
  export { createWizard, initWizard, startWizardRuntime, stopWizardRuntime } from "./src/wizard/wizard-runtime.js";
18
- export type { WizardController, WizardOptions } from "./src/wizard/wizard-runtime.js";
18
+ export type { WizardController, WizardOptions, WizardState } from "./src/wizard/wizard-runtime.js";
19
19
  export { createCombobox, initCombobox, startComboboxRuntime, stopComboboxRuntime } from "./src/combobox/combobox-runtime.js";
20
- export type { ComboboxController, ComboboxOptions } from "./src/combobox/combobox-runtime.js";
20
+ export type { ComboboxController, ComboboxOptions, ComboboxState } from "./src/combobox/combobox-runtime.js";
21
21
  export { createBanner, initBanner, startBannerRuntime, stopBannerRuntime } from "./src/banner/banner-runtime.js";
22
- export type { BannerController, BannerOptions } from "./src/banner/banner-runtime.js";
22
+ export type { BannerController, BannerOptions, BannerState } from "./src/banner/banner-runtime.js";
23
23
  export { createMenu, initMenu, startMenuRuntime, stopMenuRuntime } from "./src/menu/menu-runtime.js";
24
- export type { MenuController, MenuOptions } from "./src/menu/menu-runtime.js";
24
+ export type { MenuController, MenuOptions, MenuState } from "./src/menu/menu-runtime.js";
25
25
  export { createSwitch, initSwitch, startSwitchRuntime, stopSwitchRuntime } from "./src/switch/switch-runtime.js";
26
- export type { SwitchController, SwitchOptions } from "./src/switch/switch-runtime.js";
26
+ export type { SwitchController, SwitchOptions, SwitchState } from "./src/switch/switch-runtime.js";
27
27
  export { createSlider, initSlider, startSliderRuntime, stopSliderRuntime } from "./src/slider/slider-runtime.js";
28
- export type { SliderController, SliderOptions } from "./src/slider/slider-runtime.js";
28
+ export type { SliderController, SliderOptions, SliderState } from "./src/slider/slider-runtime.js";
29
29
  export { createCheckbox, initCheckbox, startCheckboxRuntime, stopCheckboxRuntime } from "./src/checkbox/checkbox-runtime.js";
30
- export type { CheckboxController, CheckboxOptions } from "./src/checkbox/checkbox-runtime.js";
30
+ export type { CheckboxController, CheckboxOptions, CheckboxState } from "./src/checkbox/checkbox-runtime.js";
31
31
  export { createRadio, initRadio, startRadioRuntime, stopRadioRuntime } from "./src/radio/radio-runtime.js";
32
- export type { RadioController, RadioOptions } from "./src/radio/radio-runtime.js";
32
+ export type { RadioController, RadioOptions, RadioState } from "./src/radio/radio-runtime.js";
33
33
  export { createBreadcrumb, initBreadcrumb, startBreadcrumbRuntime, stopBreadcrumbRuntime } from "./src/breadcrumb/breadcrumb-runtime.js";
34
- export type { BreadcrumbController, BreadcrumbOptions } from "./src/breadcrumb/breadcrumb-runtime.js";
34
+ export type { BreadcrumbController, BreadcrumbOptions, BreadcrumbState } from "./src/breadcrumb/breadcrumb-runtime.js";
35
35
  export { createProgress, initProgress, startProgressRuntime, stopProgressRuntime } from "./src/progress/progress-runtime.js";
36
- export type { ProgressController, ProgressOptions } from "./src/progress/progress-runtime.js";
36
+ export type { ProgressController, ProgressOptions, ProgressState } from "./src/progress/progress-runtime.js";
37
37
  export { createPagination, initPagination, startPaginationRuntime, stopPaginationRuntime } from "./src/pagination/pagination-runtime.js";
38
- export type { PaginationController, PaginationOptions } from "./src/pagination/pagination-runtime.js";
38
+ export type { PaginationController, PaginationOptions, PaginationState } from "./src/pagination/pagination-runtime.js";
39
+ export { createDisclosure, initDisclosure, startDisclosureRuntime, stopDisclosureRuntime } from "./src/disclosure/disclosure-runtime.js";
40
+ export type { DisclosureController, DisclosureOptions, DisclosureState } from "./src/disclosure/disclosure-runtime.js";
41
+ export { createSpinner, initSpinner, startSpinnerRuntime, stopSpinnerRuntime } from "./src/spinner/spinner-runtime.js";
42
+ export type { SpinnerController, SpinnerOptions, SpinnerState } from "./src/spinner/spinner-runtime.js";
43
+ export { createSelect, initSelect, startSelectRuntime, stopSelectRuntime } from "./src/select/select-runtime.js";
44
+ export type { SelectController, SelectOptions, SelectState } from "./src/select/select-runtime.js";
45
+ export { createInput, initInput, startInputRuntime, stopInputRuntime } from "./src/input/input-runtime.js";
46
+ export type { InputController, InputOptions, InputState } from "./src/input/input-runtime.js";
47
+ export { createTextarea, initTextarea, startTextareaRuntime, stopTextareaRuntime } from "./src/textarea/textarea-runtime.js";
48
+ export type { TextareaController, TextareaOptions, TextareaState } from "./src/textarea/textarea-runtime.js";
49
+ export { createField, initField, startFieldRuntime, stopFieldRuntime } from "./src/field/field-runtime.js";
50
+ export type { FieldController, FieldOptions, FieldState } from "./src/field/field-runtime.js";
51
+ export { createIconButton, initIconButton, startIconButtonRuntime, stopIconButtonRuntime } from "./src/icon-button/icon-button-runtime.js";
52
+ export type { IconButtonController, IconButtonOptions, IconButtonState } from "./src/icon-button/icon-button-runtime.js";
53
+ export { createAvatar, initAvatar, startAvatarRuntime, stopAvatarRuntime } from "./src/avatar/avatar-runtime.js";
54
+ export type { AvatarController, AvatarOptions, AvatarState } from "./src/avatar/avatar-runtime.js";
55
+ export { createTable, initTable, startTableRuntime, stopTableRuntime } from "./src/table/table-runtime.js";
56
+ export type { TableController, TableOptions, TableSortDirection, TableState } from "./src/table/table-runtime.js";
57
+ export { JUICE_CHANGE_EVENT } from "./src/shared/change.js";
58
+ export type { JuiceChangeDetail } from "./src/shared/change.js";
59
+ export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./src/shared/motion.js";
60
+ export type { MotionCancelToken, MotionDirection, MotionPlayer, MotionResult, MotionState } from "./src/shared/motion.js";
@@ -3,12 +3,18 @@ export type AccordionOptions = {
3
3
  accordionSelector?: string;
4
4
  triggerSelector?: string;
5
5
  };
6
+ /** `expanded` is one flag per trigger, in DOM order. */
7
+ export type AccordionState = {
8
+ expanded: boolean[];
9
+ };
6
10
  export type AccordionController = {
7
11
  destroy: () => void;
8
12
  sync: () => void;
9
13
  expand: (trigger?: HTMLElement | null) => void;
10
14
  collapse: (trigger?: HTMLElement | null) => void;
11
15
  toggle: (trigger?: HTMLElement | null) => void;
16
+ isExpanded: (trigger?: HTMLElement | null) => boolean;
17
+ getState: (target?: HTMLElement | null) => AccordionState | null;
12
18
  };
13
19
  export declare const createAccordion: (options?: AccordionOptions) => AccordionController;
14
20
  export declare const initAccordion: (options?: AccordionOptions) => AccordionController;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * DOM-first runtime for Juice avatar chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [avatar] host. Any value, including "square" and
6
+ * "round", is still an avatar. Sync does not
7
+ * rewrite the attribute. [scale] and [status]
8
+ * stay CSS. There is no <avatar> element.
9
+ * [avatar-more] overflow chip. Slice A does not stack an
10
+ * <img> inside it (only [avatar] img is
11
+ * positioned), so this runtime does not manage
12
+ * [avatar-more]. A "+N" chip stays text.
13
+ * [avatar-group] overlapping row. Not a host. Each [avatar]
14
+ * inside it is evaluated on its own image.
15
+ * child <img> optional photo, stacked above initials by
16
+ * CSS. Authors own the accessible name. This
17
+ * runtime does not read or write alt,
18
+ * aria-label, aria-labelledby, title, or the
19
+ * initials text, and it does not invent initials.
20
+ *
21
+ * Sync (markup-driven):
22
+ * 1. No <img> in the avatar: initials. State is loaded false,
23
+ * fallback false, hasImage false. A stale [fallback] is removed
24
+ * so the attribute matches that state.
25
+ * 2. An <img> with no src and no srcset, or with a blank one, cannot
26
+ * load. Set [fallback] on the avatar and hide that img.
27
+ * 3. An <img> that has already finished (img.complete) with
28
+ * naturalWidth === 0 is broken, including one that errored before
29
+ * this runtime started. Same fallback. naturalWidth > 0 is loaded:
30
+ * clear [fallback] and unhide an img this runtime hid.
31
+ * 4. Otherwise the image is still loading. Leave it visible, leave
32
+ * [fallback] off, and wait for load or error. hasImage is true so
33
+ * a pending photo is not the same state as initials.
34
+ * 5. load clears fallback for that image. error sets it. src and
35
+ * srcset changes drop the previous verdict and are classified
36
+ * again. Images added or removed later are picked up by a
37
+ * MutationObserver. Several images: a broken one stays hidden,
38
+ * and the avatar is in fallback only when none is loaded and
39
+ * none is still loading.
40
+ *
41
+ * The img is hidden with the hidden attribute (not a CSS rule). Avatar
42
+ * CSS does not set display on the photo, and the UA stylesheet hides
43
+ * [hidden] with !important. hidden is removed only when this runtime
44
+ * set it, so an author-hidden photo is left alone.
45
+ *
46
+ * State is { loaded, fallback, hasImage }. The first observation is
47
+ * recorded and does not dispatch. Later changes dispatch a bubbling
48
+ * juice:change CustomEvent with detail { runtime: "avatar", state }.
49
+ *
50
+ * destroy drops listeners and the observer. It does not remove
51
+ * [fallback] or unhide the img. Clearing those would paint a broken
52
+ * photo over the initials again. The last visual decision stays; this
53
+ * runtime simply stops updating it.
54
+ *
55
+ * No Sig Avatar factory.
56
+ */
57
+ export type AvatarOptions = {
58
+ root?: ParentNode;
59
+ avatarSelector?: string;
60
+ };
61
+ export type AvatarState = {
62
+ loaded: boolean;
63
+ fallback: boolean;
64
+ hasImage: boolean;
65
+ };
66
+ export type AvatarController = {
67
+ destroy: () => void;
68
+ sync: () => void;
69
+ getState: (target?: HTMLElement | null) => AvatarState | null;
70
+ };
71
+ export declare const createAvatar: (options?: AvatarOptions) => AvatarController;
72
+ export declare const initAvatar: (options?: AvatarOptions) => AvatarController;
73
+ export declare const startAvatarRuntime: () => AvatarController | null;
74
+ export declare const stopAvatarRuntime: () => void;
@@ -28,11 +28,16 @@ export type BannerOptions = {
28
28
  bannerSelector?: string;
29
29
  closeSelector?: string;
30
30
  };
31
+ export type BannerState = {
32
+ shown: boolean;
33
+ };
31
34
  export type BannerController = {
32
35
  destroy: () => void;
33
36
  sync: () => void;
34
37
  show: (target?: HTMLElement | null) => void;
35
38
  dismiss: (target?: HTMLElement | null) => void;
39
+ isShown: (target?: HTMLElement | null) => boolean;
40
+ getState: (target?: HTMLElement | null) => BannerState | null;
36
41
  };
37
42
  export declare const createBanner: (options?: BannerOptions) => BannerController;
38
43
  export declare const initBanner: (options?: BannerOptions) => BannerController;
@@ -53,10 +53,16 @@ export type BreadcrumbOptions = {
53
53
  breadcrumbSelector?: string;
54
54
  itemSelector?: string;
55
55
  };
56
+ /** `current` is the 0-based crumb index. `-1` when no crumb is current. */
57
+ export type BreadcrumbState = {
58
+ current: number;
59
+ };
56
60
  export type BreadcrumbController = {
57
61
  destroy: () => void;
58
62
  sync: () => void;
59
63
  setCurrent: (itemOrIndex: HTMLElement | number, trail?: HTMLElement | null) => void;
64
+ getCurrent: (target?: HTMLElement | null) => number;
65
+ getState: (target?: HTMLElement | null) => BreadcrumbState | null;
60
66
  };
61
67
  export declare const createBreadcrumb: (options?: BreadcrumbOptions) => BreadcrumbController;
62
68
  export declare const initBreadcrumb: (options?: BreadcrumbOptions) => BreadcrumbController;
@@ -36,6 +36,9 @@ export type CheckboxOptions = {
36
36
  root?: ParentNode;
37
37
  checkboxSelector?: string;
38
38
  };
39
+ export type CheckboxState = {
40
+ checked: boolean;
41
+ };
39
42
  export type CheckboxController = {
40
43
  destroy: () => void;
41
44
  sync: () => void;
@@ -44,6 +47,7 @@ export type CheckboxController = {
44
47
  uncheck: (target?: HTMLElement | null) => void;
45
48
  setChecked: (checked: boolean, target?: HTMLElement | null) => void;
46
49
  isChecked: (target?: HTMLElement | null) => boolean;
50
+ getState: (target?: HTMLElement | null) => CheckboxState | null;
47
51
  };
48
52
  export declare const createCheckbox: (options?: CheckboxOptions) => CheckboxController;
49
53
  export declare const initCheckbox: (options?: CheckboxOptions) => CheckboxController;
@@ -61,6 +61,10 @@ export type ComboboxOptions = {
61
61
  listSelector?: string;
62
62
  optionSelector?: string;
63
63
  };
64
+ export type ComboboxState = {
65
+ open: boolean;
66
+ value: string;
67
+ };
64
68
  export type ComboboxController = {
65
69
  destroy: () => void;
66
70
  sync: () => void;
@@ -68,6 +72,8 @@ export type ComboboxController = {
68
72
  close: (target?: HTMLElement | null) => void;
69
73
  toggle: (target?: HTMLElement | null) => void;
70
74
  select: (target?: HTMLElement | null) => void;
75
+ isOpen: (target?: HTMLElement | null) => boolean;
76
+ getState: (target?: HTMLElement | null) => ComboboxState | null;
71
77
  };
72
78
  export declare const createCombobox: (options?: ComboboxOptions) => ComboboxController;
73
79
  export declare const initCombobox: (options?: ComboboxOptions) => ComboboxController;
@@ -0,0 +1,56 @@
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 DisclosureState = {
42
+ expanded: boolean;
43
+ };
44
+ export type DisclosureController = {
45
+ destroy: () => void;
46
+ sync: () => void;
47
+ expand: (trigger?: HTMLElement | null) => void;
48
+ collapse: (trigger?: HTMLElement | null) => void;
49
+ toggle: (trigger?: HTMLElement | null) => void;
50
+ isExpanded: (trigger?: HTMLElement | null) => boolean;
51
+ getState: (target?: HTMLElement | null) => DisclosureState | null;
52
+ };
53
+ export declare const createDisclosure: (options?: DisclosureOptions) => DisclosureController;
54
+ export declare const initDisclosure: (options?: DisclosureOptions) => DisclosureController;
55
+ export declare const startDisclosureRuntime: () => DisclosureController | null;
56
+ 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.
@@ -17,12 +23,17 @@ export type DrawerOptions = {
17
23
  closeSelector?: string;
18
24
  closeOnBackdrop?: boolean;
19
25
  };
26
+ export type DrawerState = {
27
+ open: boolean;
28
+ };
20
29
  export type DrawerController = {
21
30
  destroy: () => void;
22
31
  sync: () => void;
23
32
  open: (target?: HTMLElement | null) => void;
24
33
  close: (target?: HTMLElement | null) => void;
25
34
  toggle: (target?: HTMLElement | null) => void;
35
+ isOpen: (target?: HTMLElement | null) => boolean;
36
+ getState: (target?: HTMLElement | null) => DrawerState | null;
26
37
  };
27
38
  export declare const createDrawer: (options?: DrawerOptions) => DrawerController;
28
39
  export declare const initDrawer: (options?: DrawerOptions) => DrawerController;
@@ -0,0 +1,58 @@
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 FieldState = {
47
+ invalid: boolean;
48
+ };
49
+ export type FieldController = {
50
+ destroy: () => void;
51
+ sync: () => void;
52
+ isInvalid: (target?: HTMLElement | null) => boolean;
53
+ getState: (target?: HTMLElement | null) => FieldState | null;
54
+ };
55
+ export declare const createField: (options?: FieldOptions) => FieldController;
56
+ export declare const initField: (options?: FieldOptions) => FieldController;
57
+ export declare const startFieldRuntime: () => FieldController | null;
58
+ export declare const stopFieldRuntime: () => void;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * DOM-first runtime for Juice icon-button chrome.
3
+ *
4
+ * Markup contract (Slice A — do not rename attrs):
5
+ * [icon-button] host. Square control on the existing button
6
+ * chrome. Any value, including "round", is still
7
+ * an icon button. Sync does not rewrite the
8
+ * attribute. [icon-button][round] is the same
9
+ * circle option. [scale="sm"|"lg"] stays CSS.
10
+ * [toggle] on the host, this control is a pressed toggle.
11
+ * Click flips it. Enter and Space flip it only
12
+ * when the host is not a native button (and not
13
+ * an <a href>, matching the other runtimes'
14
+ * native-interactive check). A native <button>
15
+ * already turns those keys into a click.
16
+ * [pressed] kept in sync with aria-pressed on toggles.
17
+ * An initial [pressed] or aria-pressed="true"
18
+ * starts pressed. Anything else starts
19
+ * aria-pressed="false". Non-toggles are not
20
+ * given aria-pressed.
21
+ *
22
+ * Sync (markup-driven):
23
+ * 1. Name check. An accessible name is a non-empty aria-label, an
24
+ * aria-labelledby that resolves to visible text, or visible text
25
+ * on the host. Blank values are not names. title is left
26
+ * untouched and is not a name (same convention as input and
27
+ * select). SVG subtrees and icon-only content contribute no
28
+ * text. Hidden and aria-hidden subtrees are skipped. This
29
+ * runtime does not invent a label.
30
+ * 2. In development (NODE_ENV === "development"), an unnamed host
31
+ * warns once per element via console.warn. Production and test
32
+ * stay silent. A name added later does not warn again.
33
+ * 3. Toggles write aria-pressed "true"|"false" and mirror [pressed].
34
+ * Disabled hosts ([disabled] or aria-disabled="true", including
35
+ * a native disabled button) still receive the initial value and
36
+ * do not flip.
37
+ * 4. A non-button toggle gets role="button" and tabindex="0" when
38
+ * those are missing, so Enter and Space can reach it. An author
39
+ * role or tabindex is kept. Native buttons and links are left
40
+ * alone, including type.
41
+ *
42
+ * State is { pressed, disabled, named }. The first observation is
43
+ * recorded and does not dispatch. Later changes dispatch a bubbling
44
+ * juice:change CustomEvent with detail { runtime: "icon-button", state }.
45
+ *
46
+ * Not a switch and not a checkbox. No focus trap, no Escape handler,
47
+ * and no Sig IconButton factory.
48
+ */
49
+ export type IconButtonOptions = {
50
+ root?: ParentNode;
51
+ iconButtonSelector?: string;
52
+ };
53
+ export type IconButtonState = {
54
+ pressed: boolean;
55
+ disabled: boolean;
56
+ named: boolean;
57
+ };
58
+ export type IconButtonController = {
59
+ destroy: () => void;
60
+ sync: () => void;
61
+ toggle: (target?: HTMLElement | null) => void;
62
+ getState: (target?: HTMLElement | null) => IconButtonState | null;
63
+ };
64
+ export declare const createIconButton: (options?: IconButtonOptions) => IconButtonController;
65
+ export declare const initIconButton: (options?: IconButtonOptions) => IconButtonController;
66
+ export declare const startIconButtonRuntime: () => IconButtonController | null;
67
+ export declare const stopIconButtonRuntime: () => void;
@@ -0,0 +1,63 @@
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
+ /**
49
+ * Value changes stay on the native `input` and `change` events.
50
+ * This runtime does not dispatch `juice:change`.
51
+ */
52
+ export type InputState = {
53
+ value: string;
54
+ };
55
+ export type InputController = {
56
+ destroy: () => void;
57
+ sync: () => void;
58
+ getState: (target?: HTMLElement | null) => InputState | null;
59
+ };
60
+ export declare const createInput: (options?: InputOptions) => InputController;
61
+ export declare const initInput: (options?: InputOptions) => InputController;
62
+ export declare const startInputRuntime: () => InputController | null;
63
+ export declare const stopInputRuntime: () => void;
@@ -50,6 +50,9 @@ export type MenuOptions = {
50
50
  separatorSelector?: string;
51
51
  labelSelector?: string;
52
52
  };
53
+ export type MenuState = {
54
+ open: boolean;
55
+ };
53
56
  export type MenuController = {
54
57
  destroy: () => void;
55
58
  sync: () => void;
@@ -57,6 +60,8 @@ export type MenuController = {
57
60
  close: (target?: HTMLElement | null) => void;
58
61
  toggle: (target?: HTMLElement | null) => void;
59
62
  select: (target?: HTMLElement | null) => void;
63
+ isOpen: (target?: HTMLElement | null) => boolean;
64
+ getState: (target?: HTMLElement | null) => MenuState | null;
60
65
  };
61
66
  export declare const createMenu: (options?: MenuOptions) => MenuController;
62
67
  export declare const initMenu: (options?: MenuOptions) => MenuController;
@@ -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.
@@ -17,12 +23,17 @@ export type ModalOptions = {
17
23
  closeSelector?: string;
18
24
  closeOnBackdrop?: boolean;
19
25
  };
26
+ export type ModalState = {
27
+ open: boolean;
28
+ };
20
29
  export type ModalController = {
21
30
  destroy: () => void;
22
31
  sync: () => void;
23
32
  open: (target?: HTMLElement | null) => void;
24
33
  close: (target?: HTMLElement | null) => void;
25
34
  toggle: (target?: HTMLElement | null) => void;
35
+ isOpen: (target?: HTMLElement | null) => boolean;
36
+ getState: (target?: HTMLElement | null) => ModalState | null;
26
37
  };
27
38
  export declare const createModal: (options?: ModalOptions) => ModalController;
28
39
  export declare const initModal: (options?: ModalOptions) => ModalController;
@@ -5,6 +5,9 @@ export type NavigationOptions = {
5
5
  toggleSelector?: string;
6
6
  mobileBreakpoint?: number;
7
7
  };
8
+ export type NavigationState = {
9
+ open: boolean;
10
+ };
8
11
  export type NavigationController = {
9
12
  destroy: () => void;
10
13
  openSidebar: (toggle?: HTMLElement | null) => void;
@@ -12,6 +15,8 @@ export type NavigationController = {
12
15
  toggleSidebar: (toggle?: HTMLElement | null) => void;
13
16
  sync: () => void;
14
17
  isMobile: () => boolean;
18
+ isOpen: (target?: HTMLElement | null) => boolean;
19
+ getState: (target?: HTMLElement | null) => NavigationState | null;
15
20
  };
16
21
  export declare const createNavigation: (options?: NavigationOptions) => NavigationController;
17
22
  export declare const initNavigation: (options?: NavigationOptions) => NavigationController;
@@ -68,10 +68,16 @@ export type PaginationOptions = {
68
68
  paginationSelector?: string;
69
69
  itemSelector?: string;
70
70
  };
71
+ /** `current` is the 0-based page index. `-1` when no page is current. */
72
+ export type PaginationState = {
73
+ current: number;
74
+ };
71
75
  export type PaginationController = {
72
76
  destroy: () => void;
73
77
  sync: () => void;
74
78
  setCurrent: (itemOrIndex: HTMLElement | number, pagination?: HTMLElement | null) => void;
79
+ getCurrent: (target?: HTMLElement | null) => number;
80
+ getState: (target?: HTMLElement | null) => PaginationState | null;
75
81
  };
76
82
  export declare const createPagination: (options?: PaginationOptions) => PaginationController;
77
83
  export declare const initPagination: (options?: PaginationOptions) => PaginationController;
@@ -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].
@@ -45,12 +50,17 @@ export type PopoverOptions = {
45
50
  closeSelector?: string;
46
51
  gap?: number;
47
52
  };
53
+ export type PopoverState = {
54
+ open: boolean;
55
+ };
48
56
  export type PopoverController = {
49
57
  destroy: () => void;
50
58
  sync: () => void;
51
59
  open: (target?: HTMLElement | null) => void;
52
60
  close: (target?: HTMLElement | null) => void;
53
61
  toggle: (target?: HTMLElement | null) => void;
62
+ isOpen: (target?: HTMLElement | null) => boolean;
63
+ getState: (target?: HTMLElement | null) => PopoverState | null;
54
64
  };
55
65
  export declare const createPopover: (options?: PopoverOptions) => PopoverController;
56
66
  export declare const initPopover: (options?: PopoverOptions) => PopoverController;