panelset 1.0.7 → 1.2.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.
- package/CHANGELOG.md +36 -0
- package/README.md +213 -0
- package/dist/panelset-core.js +1119 -0
- package/dist/panelset-core.js.map +1 -0
- package/dist/panelset.css +2 -1
- package/dist/panelset.esm.js +2 -0
- package/dist/panelset.js +1 -432
- package/dist/register.js +6 -0
- package/dist/register.js.map +1 -0
- package/dist/types/functions/config.d.ts +18 -0
- package/dist/types/functions/core.d.ts +11 -0
- package/dist/types/functions/focus.d.ts +16 -0
- package/dist/types/functions/persist.d.ts +7 -0
- package/dist/types/functions/pinning.d.ts +6 -0
- package/dist/types/functions/utils.d.ts +42 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.iife.d.ts +1 -0
- package/dist/types/panel.d.ts +56 -0
- package/dist/types/panel.element.d.ts +4 -0
- package/dist/types/panel.types.d.ts +28 -0
- package/dist/types/panelcontrol.d.ts +64 -0
- package/dist/types/panelcontrol.element.d.ts +9 -0
- package/dist/types/panelcontrol.types.d.ts +14 -0
- package/dist/types/panelset.d.ts +149 -0
- package/dist/types/panelset.element.d.ts +4 -0
- package/dist/types/panelset.esm.d.ts +6 -0
- package/dist/types/panelset.types.d.ts +89 -0
- package/dist/types/register.d.ts +1 -0
- package/package.json +30 -18
- package/dist/index.d.ts +0 -119
- package/dist/panelset.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PanelElement } from './panel.element.js';
|
|
2
|
+
import { PanelSetElement } from './panelset.element.js';
|
|
3
|
+
import { PanelControlElement, registerPanelControl } from './panelcontrol.element.js';
|
|
4
|
+
export { PanelSet } from './panelset.js';
|
|
5
|
+
export type { PanelSetConfig, ReadyEventDetail, BeforeActivateEventDetail, BeforeOpenEventDetail, ActivationEventDetail, ActivationAbortedEventDetail, HandlerOptions, ShowOptions, AsyncContentHandler, } from './panelset.types.js';
|
|
6
|
+
export { Panel } from './panel.js';
|
|
7
|
+
export type { PanelConfig, BeforeOpenEventDetail as PanelBeforeOpenEventDetail, PanelEventDetail, AsyncOpenHandler, } from './panel.types.js';
|
|
8
|
+
export { PanelControl } from './panelcontrol.js';
|
|
9
|
+
export type { PanelControlConfig } from './panelcontrol.types.js';
|
|
10
|
+
export { PanelElement, PanelSetElement, PanelControlElement, registerPanelControl };
|
|
11
|
+
export declare function register(prefix?: string): void;
|
|
12
|
+
export { PanelSet as default } from './panelset.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PanelConfig, AsyncOpenHandler } from './panel.types.js';
|
|
2
|
+
import { AttrMap } from './functions/config.js';
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElement {
|
|
5
|
+
panel?: Panel;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class Panel {
|
|
9
|
+
element: HTMLElement;
|
|
10
|
+
config: Required<PanelConfig>;
|
|
11
|
+
private _returnFocusTarget;
|
|
12
|
+
private _tempCloseGroup;
|
|
13
|
+
private _anim;
|
|
14
|
+
private _listenerController;
|
|
15
|
+
private _activating;
|
|
16
|
+
static defaults: Required<PanelConfig>;
|
|
17
|
+
static readonly attrs: AttrMap<PanelConfig>;
|
|
18
|
+
private static readonly _nativeInterpolateSize;
|
|
19
|
+
private static _autoIdCounter;
|
|
20
|
+
static init(selectorOrOptions?: string | PanelConfig, options?: PanelConfig): Panel[];
|
|
21
|
+
constructor(elementOrSelector: HTMLElement | string, options?: PanelConfig);
|
|
22
|
+
private _log;
|
|
23
|
+
private _parsePanelParam;
|
|
24
|
+
private _updatePanelParam;
|
|
25
|
+
private _resolveStateConfig;
|
|
26
|
+
private _persistState;
|
|
27
|
+
private _resolveInitialState;
|
|
28
|
+
private _cssProp;
|
|
29
|
+
private _wireImplicitTriggers;
|
|
30
|
+
private _bindTriggers;
|
|
31
|
+
private _setTriggerState;
|
|
32
|
+
private _cleanupTempClose;
|
|
33
|
+
private _closeGroupSiblings;
|
|
34
|
+
private _handleAutoFocus;
|
|
35
|
+
private _dispatch;
|
|
36
|
+
get isOpen(): boolean;
|
|
37
|
+
open(event?: Event): Promise<void>;
|
|
38
|
+
private _openAsync;
|
|
39
|
+
private _openSync;
|
|
40
|
+
/**
|
|
41
|
+
* Register a handler for async content loading before the panel opens.
|
|
42
|
+
* The handler receives the panel element and an AbortSignal.
|
|
43
|
+
* If it returns a Promise, the panel waits for it before animating open.
|
|
44
|
+
*/
|
|
45
|
+
onBeforeOpen(handler: AsyncOpenHandler, options?: {
|
|
46
|
+
once?: boolean;
|
|
47
|
+
}): void;
|
|
48
|
+
close(event?: Event): void;
|
|
49
|
+
toggle(event?: Event): void;
|
|
50
|
+
/**
|
|
51
|
+
* Tear down this instance. Removes listeners, resets element state, and
|
|
52
|
+
* clears element.panel so Panel.init() can re-bind it.
|
|
53
|
+
*/
|
|
54
|
+
destroy(): void;
|
|
55
|
+
}
|
|
56
|
+
export default Panel;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AutoFocusMode } from './functions/focus.js';
|
|
2
|
+
export interface PanelConfig {
|
|
3
|
+
axis?: 'vertical' | 'horizontal';
|
|
4
|
+
align?: 'start' | 'end' | 'center';
|
|
5
|
+
closeOnResize?: boolean;
|
|
6
|
+
transitions?: boolean;
|
|
7
|
+
autoFocus?: AutoFocusMode;
|
|
8
|
+
returnFocus?: boolean;
|
|
9
|
+
closeSiblings?: boolean;
|
|
10
|
+
loadingDelay?: number;
|
|
11
|
+
loadingHeight?: number;
|
|
12
|
+
interruptible?: boolean;
|
|
13
|
+
persist?: boolean;
|
|
14
|
+
deepLink?: boolean;
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface BeforeOpenEventDetail {
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
/** Underlying mechanism the open awaits; prefer waitUntil(). */
|
|
20
|
+
promise: Promise<unknown> | null;
|
|
21
|
+
/** Delay the open until p resolves. May be called more than once (awaits all). */
|
|
22
|
+
waitUntil(p: Promise<unknown>): void;
|
|
23
|
+
trigger: HTMLElement | null;
|
|
24
|
+
}
|
|
25
|
+
export interface PanelEventDetail {
|
|
26
|
+
trigger: HTMLElement | null;
|
|
27
|
+
}
|
|
28
|
+
export type AsyncOpenHandler = (element: HTMLElement, signal: AbortSignal) => Promise<void> | void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PanelControlConfig } from './panelcontrol.types.js';
|
|
2
|
+
import { ShowOptions } from './panelset.types.js';
|
|
3
|
+
import { AttrMap } from './functions/config.js';
|
|
4
|
+
declare global {
|
|
5
|
+
interface HTMLElement {
|
|
6
|
+
panelControl?: PanelControl;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare class PanelControl {
|
|
10
|
+
static defaults: Required<Omit<PanelControlConfig, 'selector'>>;
|
|
11
|
+
static readonly attrs: AttrMap<PanelControlConfig>;
|
|
12
|
+
element: HTMLElement;
|
|
13
|
+
config: Required<Omit<PanelControlConfig, 'selector'>>;
|
|
14
|
+
private _setEl;
|
|
15
|
+
private _controller;
|
|
16
|
+
private _isTablist;
|
|
17
|
+
private _activationWired;
|
|
18
|
+
/**
|
|
19
|
+
* Initialise all PanelControl containers matching the selector.
|
|
20
|
+
* @param selectorOrOptions - CSS selector string or config object.
|
|
21
|
+
* @param options - Config (used when the first argument is a selector).
|
|
22
|
+
*/
|
|
23
|
+
static init(selectorOrOptions?: string | PanelControlConfig, options?: PanelControlConfig): PanelControl[];
|
|
24
|
+
constructor(elementOrSelector: HTMLElement | string, options?: PanelControlConfig);
|
|
25
|
+
/**
|
|
26
|
+
* The PanelSet container this control drives. Resolved lazily on first access
|
|
27
|
+
* and then cached — so a PanelSet added to the DOM after init is still found.
|
|
28
|
+
*/
|
|
29
|
+
get panelSetElement(): HTMLElement | null;
|
|
30
|
+
/** The live PanelSet instance this control drives, if initialised. */
|
|
31
|
+
get panelSet(): import('./panelset.js').PanelSet | undefined;
|
|
32
|
+
/** Activate a tab's panel through the linked PanelSet. */
|
|
33
|
+
show(panelId: string, options?: ShowOptions): void;
|
|
34
|
+
/**
|
|
35
|
+
* Lock or unlock a tab. PanelControl only applies the state it is told to
|
|
36
|
+
* apply — it does not decide *when* a tab should be locked (that is the
|
|
37
|
+
* caller's concern, e.g. a flow controller). 'disabled' sets aria-disabled so
|
|
38
|
+
* keyboard nav skips the tab and clicks / Enter no longer activate it;
|
|
39
|
+
* 'enabled' clears it. A tab may carry data-pc-disabled-hint="hintId"; that
|
|
40
|
+
* hint is attached to aria-describedby only while the tab is disabled, so a
|
|
41
|
+
* focusable (aria-disabled) tab can explain why it is locked.
|
|
42
|
+
* @param panelId - aria-controls target id of the tab(s) to update.
|
|
43
|
+
* @param state - 'enabled' or 'disabled'.
|
|
44
|
+
*/
|
|
45
|
+
setTabState(panelId: string, state: 'enabled' | 'disabled'): void;
|
|
46
|
+
private _log;
|
|
47
|
+
private _reflectCloseable;
|
|
48
|
+
private _resolvePanelSet;
|
|
49
|
+
private _onElementResolved;
|
|
50
|
+
private _bindTriggers;
|
|
51
|
+
private _activate;
|
|
52
|
+
private _tabs;
|
|
53
|
+
private _enabled;
|
|
54
|
+
private _setRoving;
|
|
55
|
+
private _ensureRovingStop;
|
|
56
|
+
private _setupKeyboard;
|
|
57
|
+
private _onActivation;
|
|
58
|
+
private _onKeydown;
|
|
59
|
+
private _autoActivate;
|
|
60
|
+
private _autoFocusInPlay;
|
|
61
|
+
/** Remove all listeners and drop the reference from the element. */
|
|
62
|
+
destroy(): void;
|
|
63
|
+
}
|
|
64
|
+
export default PanelControl;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class PanelControlElement extends HTMLElement {
|
|
2
|
+
connectedCallback(): void;
|
|
3
|
+
disconnectedCallback(): void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Register the <ps-panelcontrol> custom element.
|
|
7
|
+
* @param prefix - Element name prefix. Defaults to 'ps' → <ps-panelcontrol>.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerPanelControl(prefix?: string): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PanelControlConfig {
|
|
2
|
+
/** CSS selector for init(). Defaults to '[data-panelcontrol]'. */
|
|
3
|
+
selector?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Keyboard activation for tablist controls.
|
|
6
|
+
* - 'manual' (default): arrow keys move focus; Enter/Space (or click) activates.
|
|
7
|
+
* - 'auto': arrow keys move focus AND activate — but auto self-downgrades to
|
|
8
|
+
* manual whenever the PanelSet uses autoFocus or async content, since
|
|
9
|
+
* activating on every arrow would fight focus or fire loads.
|
|
10
|
+
*/
|
|
11
|
+
activation?: 'manual' | 'auto';
|
|
12
|
+
/** Verbose console logging. */
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { PanelSetConfig, HandlerOptions, ShowOptions, AsyncContentHandler } from './panelset.types.js';
|
|
2
|
+
import { AttrMap } from './functions/config.js';
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElement {
|
|
5
|
+
panelSet?: PanelSet;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class PanelSet {
|
|
9
|
+
static defaults: Required<Omit<PanelSetConfig, 'selector'>>;
|
|
10
|
+
element: HTMLElement;
|
|
11
|
+
config: Required<Omit<PanelSetConfig, 'selector'>>;
|
|
12
|
+
panels: HTMLElement[];
|
|
13
|
+
activePanel: HTMLElement;
|
|
14
|
+
panelWrapper: HTMLElement;
|
|
15
|
+
pendingPanel: HTMLElement;
|
|
16
|
+
/** True once an async content handler has been registered via onBeforeOpen(). */
|
|
17
|
+
hasAsyncContent: boolean;
|
|
18
|
+
private _animShow;
|
|
19
|
+
private _animOpenClose;
|
|
20
|
+
private _isLoadingAsync;
|
|
21
|
+
private _activating;
|
|
22
|
+
private _switchDirection;
|
|
23
|
+
private _returnFocusTarget;
|
|
24
|
+
private _heightObserver;
|
|
25
|
+
private _verbController;
|
|
26
|
+
private static readonly _nativeInterpolateSize;
|
|
27
|
+
private static _verbDelegationInstalled;
|
|
28
|
+
static readonly attrs: AttrMap<PanelSetConfig>;
|
|
29
|
+
/**
|
|
30
|
+
* Initialize PanelSet instances
|
|
31
|
+
* @param selectorOrOptions - CSS selector string or config object
|
|
32
|
+
* @param options - Additional config options (when first param is selector)
|
|
33
|
+
* @returns Array of PanelSet instances
|
|
34
|
+
*/
|
|
35
|
+
static init(selectorOrOptions?: string | PanelSetConfig, options?: PanelSetConfig): PanelSet[];
|
|
36
|
+
constructor(elementOrSelector: HTMLElement | string, options?: PanelSetConfig);
|
|
37
|
+
private _observeTrackHeight;
|
|
38
|
+
private _log;
|
|
39
|
+
private get _isClosed();
|
|
40
|
+
private _parsePanelParam;
|
|
41
|
+
private _persistState;
|
|
42
|
+
private _updatePanelParam;
|
|
43
|
+
private _resolveInitialPanel;
|
|
44
|
+
private static _validateElement;
|
|
45
|
+
private _autoWrapPanels;
|
|
46
|
+
private _collectPanels;
|
|
47
|
+
private _internalInit;
|
|
48
|
+
private _dispatch;
|
|
49
|
+
private _getVerticalMetrics;
|
|
50
|
+
private _measureHeight;
|
|
51
|
+
private _updateHighestPanel;
|
|
52
|
+
private _updateTabTriggers;
|
|
53
|
+
private _reflectLabels;
|
|
54
|
+
private _uniqueId;
|
|
55
|
+
private _setTriggersActivating;
|
|
56
|
+
private _cleanupPanels;
|
|
57
|
+
private _resolveAutoFocus;
|
|
58
|
+
private _handleAutoFocus;
|
|
59
|
+
private _animateOpenClose;
|
|
60
|
+
/**
|
|
61
|
+
* Get the ID of the currently active panel
|
|
62
|
+
* @returns Panel ID or null if no panel is active
|
|
63
|
+
*/
|
|
64
|
+
getActive(): string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Re-scan the DOM for this set's panels and reconcile internal state — the
|
|
67
|
+
* active panel, trigger state, and the Prev/Next end-of-range disabling. Call
|
|
68
|
+
* after adding, removing, or reordering [role="tabpanel"] elements at runtime
|
|
69
|
+
* (e.g. lazy or windowed wizards). The active panel is preserved when it is
|
|
70
|
+
* still present; otherwise it falls back to the marked .active panel, then the
|
|
71
|
+
* first panel. Newly added panels are initialised to the hidden state.
|
|
72
|
+
* Call when idle (not mid-transition).
|
|
73
|
+
*/
|
|
74
|
+
refresh(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Insert a panel at runtime and refresh. The node is appended to the wrapper
|
|
77
|
+
* unless a position is given. Ensures the element carries role="tabpanel".
|
|
78
|
+
* @param panel - The [role="tabpanel"] element to add.
|
|
79
|
+
* @param position - { before } / { after } an existing panel id, or { index }.
|
|
80
|
+
* @returns The inserted panel.
|
|
81
|
+
*/
|
|
82
|
+
addPanel(panel: HTMLElement, position?: {
|
|
83
|
+
before?: string;
|
|
84
|
+
after?: string;
|
|
85
|
+
index?: number;
|
|
86
|
+
}): HTMLElement;
|
|
87
|
+
/**
|
|
88
|
+
* Remove a panel by id and refresh.
|
|
89
|
+
* @param panelId - ID of the panel to remove.
|
|
90
|
+
*/
|
|
91
|
+
removePanel(panelId: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* Destroy this instance
|
|
94
|
+
*/
|
|
95
|
+
destroy(): void;
|
|
96
|
+
private _edgeInfo;
|
|
97
|
+
private static _installVerbDelegation;
|
|
98
|
+
private static _resolveVerbSet;
|
|
99
|
+
private static _onVerbClick;
|
|
100
|
+
private _initVerbButtons;
|
|
101
|
+
private _reflectEnds;
|
|
102
|
+
private _onActivationEdge;
|
|
103
|
+
private _reflectVerbEndState;
|
|
104
|
+
private _applyVerbDisabled;
|
|
105
|
+
private _disableVerbNative;
|
|
106
|
+
private _verbFocusFallback;
|
|
107
|
+
private _verbButtonsFor;
|
|
108
|
+
/**
|
|
109
|
+
* Activate the next panel in DOM order. Stops at the last panel unless the
|
|
110
|
+
* `loop` option is set, in which case it wraps to the first.
|
|
111
|
+
* @param options - Configuration options for the activation
|
|
112
|
+
*/
|
|
113
|
+
next(options?: ShowOptions): void;
|
|
114
|
+
/**
|
|
115
|
+
* Activate the previous panel in DOM order. Stops at the first panel unless
|
|
116
|
+
* the `loop` option is set, in which case it wraps to the last.
|
|
117
|
+
* @param options - Configuration options for the activation
|
|
118
|
+
*/
|
|
119
|
+
prev(options?: ShowOptions): void;
|
|
120
|
+
private _step;
|
|
121
|
+
/**
|
|
122
|
+
* Open a closable panelset
|
|
123
|
+
* @param options - Configuration options
|
|
124
|
+
*/
|
|
125
|
+
open(options?: ShowOptions): void;
|
|
126
|
+
/**
|
|
127
|
+
* Close a closable panelset
|
|
128
|
+
* @param options - Configuration options
|
|
129
|
+
*/
|
|
130
|
+
close(options?: ShowOptions): void;
|
|
131
|
+
/**
|
|
132
|
+
* Toggle a closable panelset between open and closed
|
|
133
|
+
* @param options - Configuration options
|
|
134
|
+
*/
|
|
135
|
+
toggle(options?: ShowOptions): void;
|
|
136
|
+
/**
|
|
137
|
+
* Register a handler for async content loading
|
|
138
|
+
* @param handler - Async content handler function
|
|
139
|
+
* @param options - Handler options (once: whether to load only once)
|
|
140
|
+
*/
|
|
141
|
+
onBeforeOpen(handler: AsyncContentHandler, options?: HandlerOptions): void;
|
|
142
|
+
/**
|
|
143
|
+
* Show a panel by ID
|
|
144
|
+
* @param panelId - ID of the panel to show
|
|
145
|
+
* @param options - Configuration options for this activation
|
|
146
|
+
*/
|
|
147
|
+
show(panelId: string, options?: ShowOptions): Promise<void>;
|
|
148
|
+
}
|
|
149
|
+
export default PanelSet;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { AutoFocusMode } from './functions/focus.js';
|
|
2
|
+
export interface PanelSetConfig {
|
|
3
|
+
selector?: string;
|
|
4
|
+
align?: 'start' | 'end' | 'center';
|
|
5
|
+
transitions?: boolean | {
|
|
6
|
+
panels?: boolean;
|
|
7
|
+
height?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** Enable level-based slide direction. DOM order defines the level
|
|
10
|
+
* (later panel = higher). Adds .levelup / .leveldown to the panels so
|
|
11
|
+
* CSS can reverse the transform on backward navigation. Default false. */
|
|
12
|
+
levels?: boolean;
|
|
13
|
+
/** Make next() / prev() wrap around the ends (last → first, first → last).
|
|
14
|
+
* Default false: they stop at the first and last panel. */
|
|
15
|
+
loop?: boolean;
|
|
16
|
+
closable?: boolean;
|
|
17
|
+
closeOnTab?: boolean;
|
|
18
|
+
/** How PanelSet disables its own verb buttons (data-ps-next/prev/close) at the
|
|
19
|
+
* ends of the range. 'aria' (default) toggles aria-disabled and leaves the
|
|
20
|
+
* native disabled attribute to the author; 'native' toggles the native
|
|
21
|
+
* disabled attribute (PanelSet owns it) and leaves aria-disabled to the
|
|
22
|
+
* author. Tab-strip locking is PanelControl's concern and is always aria. */
|
|
23
|
+
disabledMode?: 'aria' | 'native';
|
|
24
|
+
loadingHeight?: number;
|
|
25
|
+
loadingDelay?: number;
|
|
26
|
+
returnFocus?: boolean;
|
|
27
|
+
autoFocus?: AutoFocusMode;
|
|
28
|
+
persist?: boolean;
|
|
29
|
+
deepLink?: boolean;
|
|
30
|
+
interruptible?: boolean;
|
|
31
|
+
manageTriggers?: boolean;
|
|
32
|
+
manageLabels?: boolean;
|
|
33
|
+
debug?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ReadyEventDetail {
|
|
36
|
+
container: HTMLElement;
|
|
37
|
+
instance: import('./panelset.js').PanelSet;
|
|
38
|
+
}
|
|
39
|
+
export interface BeforeActivateEventDetail {
|
|
40
|
+
/** ID of the panel about to be activated. */
|
|
41
|
+
panelId: string;
|
|
42
|
+
/** The panel about to be activated. */
|
|
43
|
+
targetPanel: HTMLElement;
|
|
44
|
+
/** The currently active panel, if any. */
|
|
45
|
+
outgoingPanel: HTMLElement | null;
|
|
46
|
+
/** The element that triggered the activation (button/tab), or null when
|
|
47
|
+
* called programmatically without an event. */
|
|
48
|
+
trigger: HTMLElement | null;
|
|
49
|
+
}
|
|
50
|
+
export interface BeforeOpenEventDetail {
|
|
51
|
+
panelId: string;
|
|
52
|
+
targetPanel: HTMLElement;
|
|
53
|
+
outgoingPanel: HTMLElement | null;
|
|
54
|
+
signal: AbortSignal;
|
|
55
|
+
/** Underlying mechanism the open awaits; prefer waitUntil(). */
|
|
56
|
+
promise: Promise<unknown> | null;
|
|
57
|
+
/** Delay the open until p resolves. May be called more than once (awaits all). */
|
|
58
|
+
waitUntil(p: Promise<unknown>): void;
|
|
59
|
+
}
|
|
60
|
+
export interface ActivationEventDetail {
|
|
61
|
+
panelId: string;
|
|
62
|
+
trigger: HTMLElement | null;
|
|
63
|
+
outgoingPanel: HTMLElement | null;
|
|
64
|
+
/** Zero-based index of the activated panel in DOM order. */
|
|
65
|
+
index: number;
|
|
66
|
+
/** Total number of panels in the set. */
|
|
67
|
+
total: number;
|
|
68
|
+
/** True when the activated panel is the first one. */
|
|
69
|
+
atStart: boolean;
|
|
70
|
+
/** True when the activated panel is the last one. */
|
|
71
|
+
atEnd: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface ActivationAbortedEventDetail {
|
|
74
|
+
panelId: string;
|
|
75
|
+
trigger: HTMLElement | null;
|
|
76
|
+
}
|
|
77
|
+
export interface HandlerOptions {
|
|
78
|
+
once?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface ShowOptions {
|
|
81
|
+
event?: Event;
|
|
82
|
+
transition?: boolean;
|
|
83
|
+
autoFocus?: AutoFocusMode;
|
|
84
|
+
/** Force the levels slide direction regardless of DOM order. next()/prev()
|
|
85
|
+
* set this so a loop wrap slides in the step's direction ('forward' = like
|
|
86
|
+
* Next, even when wrapping to an earlier panel). Only affects sets with levels. */
|
|
87
|
+
direction?: 'forward' | 'backward';
|
|
88
|
+
}
|
|
89
|
+
export type AsyncContentHandler = (targetPanel: HTMLElement, signal: AbortSignal) => Promise<void> | void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "panelset",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Flexible panel management with smooth transitions",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.css",
|
|
8
|
+
"**/*.scss"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/panelset.esm.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"unpkg": "./dist/panelset.js",
|
|
13
|
+
"jsdelivr": "./dist/panelset.js",
|
|
8
14
|
"exports": {
|
|
9
15
|
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/panelset.js"
|
|
16
|
+
"types": "./dist/types/index.d.ts",
|
|
17
|
+
"import": "./dist/panelset.esm.js"
|
|
18
|
+
},
|
|
19
|
+
"./register": {
|
|
20
|
+
"types": "./dist/types/register.d.ts",
|
|
21
|
+
"import": "./dist/register.js"
|
|
12
22
|
},
|
|
13
|
-
"./
|
|
23
|
+
"./style.css": "./dist/panelset.css"
|
|
14
24
|
},
|
|
15
25
|
"files": [
|
|
16
26
|
"dist",
|
|
@@ -18,15 +28,17 @@
|
|
|
18
28
|
"CHANGELOG.md"
|
|
19
29
|
],
|
|
20
30
|
"scripts": {
|
|
21
|
-
"start": "npm
|
|
22
|
-
"dev": "vite
|
|
23
|
-
"
|
|
31
|
+
"start": "cd docs && npm start",
|
|
32
|
+
"dev": "vite",
|
|
33
|
+
"docs": "cd docs && npm start",
|
|
34
|
+
"docs:build": "cd docs && npm run build",
|
|
35
|
+
"docs:preview": "npm run build && cd docs && rm -rf dist && npm run build && npm run preview",
|
|
36
|
+
"build": "npm run clean && npm run build:lib",
|
|
24
37
|
"build:lib": "vite build",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"clean": "rm -rf dist docs"
|
|
38
|
+
"size": "node scripts/size.mjs",
|
|
39
|
+
"prepack": "npm run build",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"setup": "cd docs && npm install"
|
|
30
42
|
},
|
|
31
43
|
"keywords": [
|
|
32
44
|
"panels",
|
|
@@ -38,13 +50,13 @@
|
|
|
38
50
|
"author": "Martijn De Jongh",
|
|
39
51
|
"license": "MIT",
|
|
40
52
|
"devDependencies": {
|
|
41
|
-
"@vituum/vite-plugin-pug": "^
|
|
53
|
+
"@vituum/vite-plugin-pug": "^2.0.1",
|
|
42
54
|
"fast-glob": "^3.3.3",
|
|
43
55
|
"sass": "^1.97.3",
|
|
44
56
|
"terser": "^5.46.0",
|
|
45
57
|
"typescript": "^5.9.3",
|
|
46
|
-
"vite": "^
|
|
47
|
-
"vite-plugin-dts": "
|
|
48
|
-
"vituum": "^
|
|
58
|
+
"vite": "^8.0.0",
|
|
59
|
+
"vite-plugin-dts": "5.0.0-beta.6",
|
|
60
|
+
"vituum": "^2.0.1"
|
|
49
61
|
}
|
|
50
62
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
export declare interface ActivationAbortedEventDetail {
|
|
2
|
-
panelId: string;
|
|
3
|
-
trigger: HTMLElement | null;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export declare interface ActivationEventDetail {
|
|
7
|
-
panelId: string;
|
|
8
|
-
trigger: HTMLElement | null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export declare type AsyncContentHandler = (targetPanel: HTMLElement, signal: AbortSignal) => Promise<void> | void;
|
|
12
|
-
|
|
13
|
-
export declare interface BeforeActivateEventDetail {
|
|
14
|
-
panelId: string;
|
|
15
|
-
targetPanel: HTMLElement;
|
|
16
|
-
outgoingPanel: HTMLElement | null;
|
|
17
|
-
signal: AbortSignal;
|
|
18
|
-
promise: Promise<void> | null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export declare interface HandlerOptions {
|
|
22
|
-
once?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
declare class PanelSet {
|
|
26
|
-
static defaults: Required<Omit<PanelSetConfig, 'selector'>>;
|
|
27
|
-
element: HTMLElement;
|
|
28
|
-
config: Required<Omit<PanelSetConfig, 'selector'>>;
|
|
29
|
-
panels: HTMLElement[];
|
|
30
|
-
activePanel: HTMLElement;
|
|
31
|
-
panelWrapper: HTMLElement;
|
|
32
|
-
pendingPanel: HTMLElement;
|
|
33
|
-
private _openCloseGeneration;
|
|
34
|
-
private _isLoadingAsync;
|
|
35
|
-
private _currentAbortController?;
|
|
36
|
-
static _getDataConfig(element: HTMLElement): Partial<PanelSetConfig>;
|
|
37
|
-
static _mergeConfig(defaults: Required<Omit<PanelSetConfig, 'selector'>>, dataConfig: Partial<PanelSetConfig>, options: Partial<PanelSetConfig>): Required<Omit<PanelSetConfig, 'selector'>>;
|
|
38
|
-
/**
|
|
39
|
-
* Initialize PanelSet instances
|
|
40
|
-
* @param selectorOrOptions - CSS selector string or config object
|
|
41
|
-
* @param options - Additional config options (when first param is selector)
|
|
42
|
-
* @returns Array of PanelSet instances
|
|
43
|
-
*/
|
|
44
|
-
static init(selectorOrOptions?: string | PanelSetConfig, options?: PanelSetConfig): PanelSet[];
|
|
45
|
-
constructor(elementOrSelector: HTMLElement | string, options?: PanelSetConfig);
|
|
46
|
-
private _log;
|
|
47
|
-
private static _validateElement;
|
|
48
|
-
private _autoWrapPanels;
|
|
49
|
-
private _internalInit;
|
|
50
|
-
private _dispatch;
|
|
51
|
-
private _getVerticalMetrics;
|
|
52
|
-
private _measureHeight;
|
|
53
|
-
private _updateHighestPanel;
|
|
54
|
-
private _cleanupPanels;
|
|
55
|
-
private _waitForTransition;
|
|
56
|
-
private _handleAutoFocus;
|
|
57
|
-
private _syncAriaWithActivePanel;
|
|
58
|
-
private _animateOpenClose;
|
|
59
|
-
/**
|
|
60
|
-
* Get the ID of the currently active panel
|
|
61
|
-
* @returns Panel ID or null if no panel is active
|
|
62
|
-
*/
|
|
63
|
-
getActive(): string | null;
|
|
64
|
-
/**
|
|
65
|
-
* Open a closable panelset
|
|
66
|
-
* @param options - Configuration options
|
|
67
|
-
*/
|
|
68
|
-
open(options?: ShowOptions): void;
|
|
69
|
-
/**
|
|
70
|
-
* Close a closable panelset
|
|
71
|
-
* @param options - Configuration options
|
|
72
|
-
*/
|
|
73
|
-
close(options?: ShowOptions): void;
|
|
74
|
-
/**
|
|
75
|
-
* Toggle a closable panelset between open and closed
|
|
76
|
-
* @param options - Configuration options
|
|
77
|
-
*/
|
|
78
|
-
toggle(options?: ShowOptions): void;
|
|
79
|
-
/**
|
|
80
|
-
* Register a handler for async content loading
|
|
81
|
-
* @param handler - Async content handler function
|
|
82
|
-
* @param options - Handler options (once: whether to load only once)
|
|
83
|
-
*/
|
|
84
|
-
onBeforeActivate(handler: AsyncContentHandler, options?: HandlerOptions): void;
|
|
85
|
-
/**
|
|
86
|
-
* Show a panel by ID
|
|
87
|
-
* @param panelId - ID of the panel to show
|
|
88
|
-
* @param options - Configuration options for this activation
|
|
89
|
-
*/
|
|
90
|
-
show(panelId: string, options?: ShowOptions): Promise<void>;
|
|
91
|
-
}
|
|
92
|
-
export { PanelSet }
|
|
93
|
-
export default PanelSet;
|
|
94
|
-
|
|
95
|
-
export declare interface PanelSetConfig {
|
|
96
|
-
selector?: string;
|
|
97
|
-
transitions?: boolean | {
|
|
98
|
-
panels?: boolean;
|
|
99
|
-
height?: boolean;
|
|
100
|
-
};
|
|
101
|
-
closable?: boolean;
|
|
102
|
-
emptyPanelHeight?: number;
|
|
103
|
-
loadingDelay?: number;
|
|
104
|
-
autoFocus?: boolean | 'heading' | 'first' | 'input';
|
|
105
|
-
debug?: boolean;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export declare interface ReadyEventDetail {
|
|
109
|
-
container: HTMLElement;
|
|
110
|
-
instance: PanelSet;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export declare interface ShowOptions {
|
|
114
|
-
event?: Event;
|
|
115
|
-
transition?: boolean;
|
|
116
|
-
autoFocus?: boolean | 'heading' | 'first' | 'input' | ((panel: HTMLElement) => void);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export { }
|