@citrusworx/juiceui 0.9.2 → 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.
- package/README.md +34 -11
- package/dist/components/accordion/accordion.d.ts +2 -1
- package/dist/index.css +1499 -89
- package/dist/index.d.ts +33 -25
- package/dist/index.js +3035 -2253
- package/dist/js/juice.d.ts +33 -25
- package/dist/js/src/accordion/accordion-runtime.d.ts +6 -0
- package/dist/js/src/avatar/avatar-runtime.d.ts +74 -0
- package/dist/js/src/banner/banner-runtime.d.ts +5 -0
- package/dist/js/src/breadcrumb/breadcrumb-runtime.d.ts +6 -0
- package/dist/js/src/checkbox/checkbox-runtime.d.ts +4 -0
- package/dist/js/src/combobox/combobox-runtime.d.ts +6 -0
- package/dist/js/src/disclosure/disclosure-runtime.d.ts +5 -0
- package/dist/js/src/drawer/drawer-runtime.d.ts +5 -0
- package/dist/js/src/field/field-runtime.d.ts +5 -0
- package/dist/js/src/icon-button/icon-button-runtime.d.ts +67 -0
- package/dist/js/src/input/input-runtime.d.ts +8 -0
- package/dist/js/src/menu/menu-runtime.d.ts +5 -0
- package/dist/js/src/modal/modal-runtime.d.ts +5 -0
- package/dist/js/src/nav/navigation.d.ts +5 -0
- package/dist/js/src/pagination/pagination-runtime.d.ts +6 -0
- package/dist/js/src/popover/popover-runtime.d.ts +5 -0
- package/dist/js/src/progress/progress-runtime.d.ts +5 -0
- package/dist/js/src/radio/radio-runtime.d.ts +7 -0
- package/dist/js/src/select/select-runtime.d.ts +9 -0
- package/dist/js/src/shared/change.d.ts +32 -0
- package/dist/js/src/slider/slider-runtime.d.ts +4 -0
- package/dist/js/src/spinner/spinner-runtime.d.ts +4 -0
- package/dist/js/src/switch/switch-runtime.d.ts +4 -0
- package/dist/js/src/table/table-runtime.d.ts +99 -0
- package/dist/js/src/tabs/tabs-runtime.d.ts +6 -0
- package/dist/js/src/textarea/textarea-runtime.d.ts +8 -0
- package/dist/js/src/toast/toast-runtime.d.ts +5 -0
- package/dist/js/src/tooltip/tooltip-runtime.d.ts +5 -0
- package/dist/js/src/wizard/wizard-runtime.d.ts +4 -0
- package/dist/themes/tide.css +7 -0
- package/package.json +2 -2
package/dist/js/juice.d.ts
CHANGED
|
@@ -1,52 +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
39
|
export { createDisclosure, initDisclosure, startDisclosureRuntime, stopDisclosureRuntime } from "./src/disclosure/disclosure-runtime.js";
|
|
40
|
-
export type { DisclosureController, DisclosureOptions } from "./src/disclosure/disclosure-runtime.js";
|
|
40
|
+
export type { DisclosureController, DisclosureOptions, DisclosureState } from "./src/disclosure/disclosure-runtime.js";
|
|
41
41
|
export { createSpinner, initSpinner, startSpinnerRuntime, stopSpinnerRuntime } from "./src/spinner/spinner-runtime.js";
|
|
42
|
-
export type { SpinnerController, SpinnerOptions } from "./src/spinner/spinner-runtime.js";
|
|
42
|
+
export type { SpinnerController, SpinnerOptions, SpinnerState } from "./src/spinner/spinner-runtime.js";
|
|
43
43
|
export { createSelect, initSelect, startSelectRuntime, stopSelectRuntime } from "./src/select/select-runtime.js";
|
|
44
|
-
export type { SelectController, SelectOptions } from "./src/select/select-runtime.js";
|
|
44
|
+
export type { SelectController, SelectOptions, SelectState } from "./src/select/select-runtime.js";
|
|
45
45
|
export { createInput, initInput, startInputRuntime, stopInputRuntime } from "./src/input/input-runtime.js";
|
|
46
|
-
export type { InputController, InputOptions } from "./src/input/input-runtime.js";
|
|
46
|
+
export type { InputController, InputOptions, InputState } from "./src/input/input-runtime.js";
|
|
47
47
|
export { createTextarea, initTextarea, startTextareaRuntime, stopTextareaRuntime } from "./src/textarea/textarea-runtime.js";
|
|
48
|
-
export type { TextareaController, TextareaOptions } from "./src/textarea/textarea-runtime.js";
|
|
48
|
+
export type { TextareaController, TextareaOptions, TextareaState } from "./src/textarea/textarea-runtime.js";
|
|
49
49
|
export { createField, initField, startFieldRuntime, stopFieldRuntime } from "./src/field/field-runtime.js";
|
|
50
|
-
export type { FieldController, FieldOptions } 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";
|
|
51
59
|
export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./src/shared/motion.js";
|
|
52
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;
|
|
@@ -38,12 +38,17 @@ export type DisclosureOptions = {
|
|
|
38
38
|
disclosureSelector?: string;
|
|
39
39
|
triggerSelector?: string;
|
|
40
40
|
};
|
|
41
|
+
export type DisclosureState = {
|
|
42
|
+
expanded: boolean;
|
|
43
|
+
};
|
|
41
44
|
export type DisclosureController = {
|
|
42
45
|
destroy: () => void;
|
|
43
46
|
sync: () => void;
|
|
44
47
|
expand: (trigger?: HTMLElement | null) => void;
|
|
45
48
|
collapse: (trigger?: HTMLElement | null) => void;
|
|
46
49
|
toggle: (trigger?: HTMLElement | null) => void;
|
|
50
|
+
isExpanded: (trigger?: HTMLElement | null) => boolean;
|
|
51
|
+
getState: (target?: HTMLElement | null) => DisclosureState | null;
|
|
47
52
|
};
|
|
48
53
|
export declare const createDisclosure: (options?: DisclosureOptions) => DisclosureController;
|
|
49
54
|
export declare const initDisclosure: (options?: DisclosureOptions) => DisclosureController;
|
|
@@ -23,12 +23,17 @@ export type DrawerOptions = {
|
|
|
23
23
|
closeSelector?: string;
|
|
24
24
|
closeOnBackdrop?: boolean;
|
|
25
25
|
};
|
|
26
|
+
export type DrawerState = {
|
|
27
|
+
open: boolean;
|
|
28
|
+
};
|
|
26
29
|
export type DrawerController = {
|
|
27
30
|
destroy: () => void;
|
|
28
31
|
sync: () => void;
|
|
29
32
|
open: (target?: HTMLElement | null) => void;
|
|
30
33
|
close: (target?: HTMLElement | null) => void;
|
|
31
34
|
toggle: (target?: HTMLElement | null) => void;
|
|
35
|
+
isOpen: (target?: HTMLElement | null) => boolean;
|
|
36
|
+
getState: (target?: HTMLElement | null) => DrawerState | null;
|
|
32
37
|
};
|
|
33
38
|
export declare const createDrawer: (options?: DrawerOptions) => DrawerController;
|
|
34
39
|
export declare const initDrawer: (options?: DrawerOptions) => DrawerController;
|
|
@@ -43,9 +43,14 @@ export type FieldOptions = {
|
|
|
43
43
|
root?: ParentNode;
|
|
44
44
|
fieldSelector?: string;
|
|
45
45
|
};
|
|
46
|
+
export type FieldState = {
|
|
47
|
+
invalid: boolean;
|
|
48
|
+
};
|
|
46
49
|
export type FieldController = {
|
|
47
50
|
destroy: () => void;
|
|
48
51
|
sync: () => void;
|
|
52
|
+
isInvalid: (target?: HTMLElement | null) => boolean;
|
|
53
|
+
getState: (target?: HTMLElement | null) => FieldState | null;
|
|
49
54
|
};
|
|
50
55
|
export declare const createField: (options?: FieldOptions) => FieldController;
|
|
51
56
|
export declare const initField: (options?: FieldOptions) => FieldController;
|
|
@@ -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;
|
|
@@ -45,9 +45,17 @@ export type InputOptions = {
|
|
|
45
45
|
root?: ParentNode;
|
|
46
46
|
inputSelector?: string;
|
|
47
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
|
+
};
|
|
48
55
|
export type InputController = {
|
|
49
56
|
destroy: () => void;
|
|
50
57
|
sync: () => void;
|
|
58
|
+
getState: (target?: HTMLElement | null) => InputState | null;
|
|
51
59
|
};
|
|
52
60
|
export declare const createInput: (options?: InputOptions) => InputController;
|
|
53
61
|
export declare const initInput: (options?: InputOptions) => InputController;
|
|
@@ -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;
|
|
@@ -23,12 +23,17 @@ export type ModalOptions = {
|
|
|
23
23
|
closeSelector?: string;
|
|
24
24
|
closeOnBackdrop?: boolean;
|
|
25
25
|
};
|
|
26
|
+
export type ModalState = {
|
|
27
|
+
open: boolean;
|
|
28
|
+
};
|
|
26
29
|
export type ModalController = {
|
|
27
30
|
destroy: () => void;
|
|
28
31
|
sync: () => void;
|
|
29
32
|
open: (target?: HTMLElement | null) => void;
|
|
30
33
|
close: (target?: HTMLElement | null) => void;
|
|
31
34
|
toggle: (target?: HTMLElement | null) => void;
|
|
35
|
+
isOpen: (target?: HTMLElement | null) => boolean;
|
|
36
|
+
getState: (target?: HTMLElement | null) => ModalState | null;
|
|
32
37
|
};
|
|
33
38
|
export declare const createModal: (options?: ModalOptions) => ModalController;
|
|
34
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;
|
|
@@ -50,12 +50,17 @@ export type PopoverOptions = {
|
|
|
50
50
|
closeSelector?: string;
|
|
51
51
|
gap?: number;
|
|
52
52
|
};
|
|
53
|
+
export type PopoverState = {
|
|
54
|
+
open: boolean;
|
|
55
|
+
};
|
|
53
56
|
export type PopoverController = {
|
|
54
57
|
destroy: () => void;
|
|
55
58
|
sync: () => void;
|
|
56
59
|
open: (target?: HTMLElement | null) => void;
|
|
57
60
|
close: (target?: HTMLElement | null) => void;
|
|
58
61
|
toggle: (target?: HTMLElement | null) => void;
|
|
62
|
+
isOpen: (target?: HTMLElement | null) => boolean;
|
|
63
|
+
getState: (target?: HTMLElement | null) => PopoverState | null;
|
|
59
64
|
};
|
|
60
65
|
export declare const createPopover: (options?: PopoverOptions) => PopoverController;
|
|
61
66
|
export declare const initPopover: (options?: PopoverOptions) => PopoverController;
|
|
@@ -37,6 +37,10 @@ export type ProgressOptions = {
|
|
|
37
37
|
root?: ParentNode;
|
|
38
38
|
progressSelector?: string;
|
|
39
39
|
};
|
|
40
|
+
export type ProgressState = {
|
|
41
|
+
value: number;
|
|
42
|
+
indeterminate: boolean;
|
|
43
|
+
};
|
|
40
44
|
export type ProgressController = {
|
|
41
45
|
destroy: () => void;
|
|
42
46
|
sync: () => void;
|
|
@@ -44,6 +48,7 @@ export type ProgressController = {
|
|
|
44
48
|
getValue: (target?: HTMLElement | null) => number;
|
|
45
49
|
setIndeterminate: (indeterminate: boolean, target?: HTMLElement | null) => void;
|
|
46
50
|
isIndeterminate: (target?: HTMLElement | null) => boolean;
|
|
51
|
+
getState: (target?: HTMLElement | null) => ProgressState | null;
|
|
47
52
|
};
|
|
48
53
|
export declare const createProgress: (options?: ProgressOptions) => ProgressController;
|
|
49
54
|
export declare const initProgress: (options?: ProgressOptions) => ProgressController;
|
|
@@ -40,11 +40,18 @@ export type RadioOptions = {
|
|
|
40
40
|
radiogroupSelector?: string;
|
|
41
41
|
radioSelector?: string;
|
|
42
42
|
};
|
|
43
|
+
export type RadioState = {
|
|
44
|
+
/** `value` attribute of the checked radio, or the native value. */
|
|
45
|
+
value: string | null;
|
|
46
|
+
/** Index of the checked radio in the group. `-1` when none are checked. */
|
|
47
|
+
index: number;
|
|
48
|
+
};
|
|
43
49
|
export type RadioController = {
|
|
44
50
|
destroy: () => void;
|
|
45
51
|
sync: () => void;
|
|
46
52
|
select: (radio?: HTMLElement | null) => void;
|
|
47
53
|
getChecked: (group?: HTMLElement | null) => HTMLElement | null;
|
|
54
|
+
getState: (target?: HTMLElement | null) => RadioState | null;
|
|
48
55
|
};
|
|
49
56
|
export declare const createRadio: (options?: RadioOptions) => RadioController;
|
|
50
57
|
export declare const initRadio: (options?: RadioOptions) => RadioController;
|
|
@@ -42,9 +42,18 @@ export type SelectOptions = {
|
|
|
42
42
|
root?: ParentNode;
|
|
43
43
|
selectSelector?: string;
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Value changes stay on the native `input` and `change` events.
|
|
47
|
+
* This runtime does not dispatch `juice:change`.
|
|
48
|
+
* `value` is `HTMLSelectElement.value` (the first selected option).
|
|
49
|
+
*/
|
|
50
|
+
export type SelectState = {
|
|
51
|
+
value: string;
|
|
52
|
+
};
|
|
45
53
|
export type SelectController = {
|
|
46
54
|
destroy: () => void;
|
|
47
55
|
sync: () => void;
|
|
56
|
+
getState: (target?: HTMLElement | null) => SelectState | null;
|
|
48
57
|
};
|
|
49
58
|
export declare const createSelect: (options?: SelectOptions) => SelectController;
|
|
50
59
|
export declare const initSelect: (options?: SelectOptions) => SelectController;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observable state for Juice runtimes.
|
|
3
|
+
*
|
|
4
|
+
* A runtime dispatches `juice:change` from the widget host when its
|
|
5
|
+
* observable state actually changes. The event bubbles. Detail is
|
|
6
|
+
* `{ runtime, state }`. The first observation of a host is recorded
|
|
7
|
+
* and does not dispatch, so init can normalize ARIA without looking
|
|
8
|
+
* like a change. Pass `baseline` when this note is the first look and
|
|
9
|
+
* it follows a real mutation.
|
|
10
|
+
*
|
|
11
|
+
* Select, input, and textarea do not use this event. Their value
|
|
12
|
+
* changes stay on the native `input` and `change` events.
|
|
13
|
+
*/
|
|
14
|
+
export declare const JUICE_CHANGE_EVENT = "juice:change";
|
|
15
|
+
export type JuiceChangeDetail<TState> = {
|
|
16
|
+
runtime: string;
|
|
17
|
+
state: TState;
|
|
18
|
+
};
|
|
19
|
+
export declare const juiceStatesEqual: (left: unknown, right: unknown) => boolean;
|
|
20
|
+
export declare const dispatchJuiceChange: <TState>(host: EventTarget, runtime: string, state: TState) => void;
|
|
21
|
+
export type JuiceChangeNoteOptions<TState> = {
|
|
22
|
+
/**
|
|
23
|
+
* State from before this mutation. Used only when the host has not
|
|
24
|
+
* been observed yet, so the first real change still dispatches.
|
|
25
|
+
*/
|
|
26
|
+
baseline?: TState;
|
|
27
|
+
};
|
|
28
|
+
export declare const createJuiceChanges: <TState>(runtime: string) => {
|
|
29
|
+
has: (host: EventTarget) => boolean;
|
|
30
|
+
prime: (host: EventTarget, state: TState) => void;
|
|
31
|
+
note: (host: EventTarget, state: TState, options?: JuiceChangeNoteOptions<TState>) => void;
|
|
32
|
+
};
|
|
@@ -41,6 +41,9 @@ export type SliderOptions = {
|
|
|
41
41
|
root?: ParentNode;
|
|
42
42
|
sliderSelector?: string;
|
|
43
43
|
};
|
|
44
|
+
export type SliderState = {
|
|
45
|
+
value: number;
|
|
46
|
+
};
|
|
44
47
|
export type SliderController = {
|
|
45
48
|
destroy: () => void;
|
|
46
49
|
sync: () => void;
|
|
@@ -48,6 +51,7 @@ export type SliderController = {
|
|
|
48
51
|
getValue: (target?: HTMLElement | null) => number;
|
|
49
52
|
increment: (target?: HTMLElement | null) => void;
|
|
50
53
|
decrement: (target?: HTMLElement | null) => void;
|
|
54
|
+
getState: (target?: HTMLElement | null) => SliderState | null;
|
|
51
55
|
};
|
|
52
56
|
export declare const createSlider: (options?: SliderOptions) => SliderController;
|
|
53
57
|
export declare const initSlider: (options?: SliderOptions) => SliderController;
|
|
@@ -38,12 +38,16 @@ export type SpinnerOptions = {
|
|
|
38
38
|
root?: ParentNode;
|
|
39
39
|
spinnerSelector?: string;
|
|
40
40
|
};
|
|
41
|
+
export type SpinnerState = {
|
|
42
|
+
shown: boolean;
|
|
43
|
+
};
|
|
41
44
|
export type SpinnerController = {
|
|
42
45
|
destroy: () => void;
|
|
43
46
|
sync: () => void;
|
|
44
47
|
show: (target?: HTMLElement | null) => void;
|
|
45
48
|
hide: (target?: HTMLElement | null) => void;
|
|
46
49
|
isShown: (target?: HTMLElement | null) => boolean;
|
|
50
|
+
getState: (target?: HTMLElement | null) => SpinnerState | null;
|
|
47
51
|
};
|
|
48
52
|
export declare const createSpinner: (options?: SpinnerOptions) => SpinnerController;
|
|
49
53
|
export declare const initSpinner: (options?: SpinnerOptions) => SpinnerController;
|
|
@@ -35,6 +35,9 @@ export type SwitchOptions = {
|
|
|
35
35
|
root?: ParentNode;
|
|
36
36
|
switchSelector?: string;
|
|
37
37
|
};
|
|
38
|
+
export type SwitchState = {
|
|
39
|
+
checked: boolean;
|
|
40
|
+
};
|
|
38
41
|
export type SwitchController = {
|
|
39
42
|
destroy: () => void;
|
|
40
43
|
sync: () => void;
|
|
@@ -43,6 +46,7 @@ export type SwitchController = {
|
|
|
43
46
|
uncheck: (target?: HTMLElement | null) => void;
|
|
44
47
|
setChecked: (checked: boolean, target?: HTMLElement | null) => void;
|
|
45
48
|
isChecked: (target?: HTMLElement | null) => boolean;
|
|
49
|
+
getState: (target?: HTMLElement | null) => SwitchState | null;
|
|
46
50
|
};
|
|
47
51
|
export declare const createSwitch: (options?: SwitchOptions) => SwitchController;
|
|
48
52
|
export declare const initSwitch: (options?: SwitchOptions) => SwitchController;
|