@dodlhuat/basix 1.2.7 → 1.2.8

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/js/modal.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ type ModalType = 'default' | 'success' | 'error' | 'warning' | 'info';
2
+ interface ModalOptions {
3
+ content: string;
4
+ header?: string;
5
+ footer?: string;
6
+ closeable?: boolean;
7
+ type?: ModalType;
8
+ }
9
+ declare class Modal {
10
+ private content;
11
+ private readonly header?;
12
+ private readonly footer?;
13
+ private readonly closeable;
14
+ private readonly type;
15
+ private template;
16
+ private modalWrapper;
17
+ constructor(options: ModalOptions);
18
+ constructor(content: string, header?: string, footer?: string, closeable?: boolean, type?: ModalType);
19
+ show(): void;
20
+ hide(): void;
21
+ private handleEscape;
22
+ private handleBackgroundClick;
23
+ private buildTemplate;
24
+ updateContent(content: string): void;
25
+ isVisible(): boolean;
26
+ destroy(): void;
27
+ }
28
+ export { Modal, type ModalOptions, type ModalType };
@@ -0,0 +1,46 @@
1
+ import type { Placement } from './position.js';
2
+ type PopoverPlacement = Placement | 'auto';
3
+ type PopoverAlign = 'start' | 'center' | 'end';
4
+ type PopoverTrigger = 'click' | 'hover';
5
+ interface PopoverOptions {
6
+ content: string;
7
+ placement?: PopoverPlacement;
8
+ align?: PopoverAlign;
9
+ offset?: number;
10
+ arrow?: boolean;
11
+ triggerMode?: PopoverTrigger;
12
+ closeOnOutsideClick?: boolean;
13
+ closeOnEscape?: boolean;
14
+ className?: string;
15
+ onOpen?: () => void;
16
+ onClose?: () => void;
17
+ }
18
+ declare class Popover {
19
+ private static openPopovers;
20
+ private static idCounter;
21
+ private readonly trigger;
22
+ private readonly opts;
23
+ private popoverEl;
24
+ private _isOpen;
25
+ private hoverTimer;
26
+ constructor(triggerEl: HTMLElement | string, options: PopoverOptions);
27
+ get isOpen(): boolean;
28
+ open(): void;
29
+ close(): void;
30
+ toggle(): void;
31
+ destroy(): void;
32
+ static closeAll(): void;
33
+ /** Declarative init — reads [data-popover="#selector"] attributes */
34
+ static initAll(): void;
35
+ private buildEl;
36
+ private reposition;
37
+ private onClick;
38
+ private onMouseEnter;
39
+ private onMouseLeave;
40
+ private onOutsideClick;
41
+ private onEscape;
42
+ private attachTrigger;
43
+ private detachTrigger;
44
+ }
45
+ export { Popover };
46
+ export type { PopoverOptions, PopoverPlacement, PopoverAlign, PopoverTrigger };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared floating-element positioning utility.
3
+ * Used by Tooltip and Popover.
4
+ */
5
+ type Placement = 'top' | 'bottom' | 'left' | 'right';
6
+ type Align = 'start' | 'center' | 'end';
7
+ interface PositionOptions {
8
+ placement: Placement | 'auto';
9
+ align?: Align;
10
+ offset?: number;
11
+ margin?: number;
12
+ arrowSize?: number;
13
+ }
14
+ interface PositionResult {
15
+ left: number;
16
+ top: number;
17
+ placement: Placement;
18
+ arrowOffset?: number;
19
+ }
20
+ /** Pick the placement with the most available space, preferring bottom > top > right > left. */
21
+ declare function bestPlacement(trigger: DOMRect, floating: DOMRect, offset: number): Placement;
22
+ /** Flip to opposite side if preferred placement doesn't fit. */
23
+ declare function maybeFlip(placement: Placement, trigger: DOMRect, floating: DOMRect, offset: number): Placement;
24
+ /**
25
+ * Compute `left` / `top` for a `position: fixed` floating element anchored to a trigger.
26
+ * Handles placement resolution (auto + flip), cross-axis alignment, viewport clamping,
27
+ * and optional arrow offset calculation.
28
+ */
29
+ declare function computePosition(trigger: DOMRect, floating: DOMRect, opts: PositionOptions): PositionResult;
30
+ export { computePosition, bestPlacement, maybeFlip };
31
+ export type { Placement, Align, PositionOptions, PositionResult };
@@ -0,0 +1,31 @@
1
+ interface PushMenuElements {
2
+ navigation: HTMLElement | null;
3
+ content: HTMLElement | null;
4
+ menu: HTMLElement | null;
5
+ header: HTMLElement | null;
6
+ controlIcon: HTMLElement | null;
7
+ backdrop: HTMLElement | null;
8
+ }
9
+ declare class PushMenu {
10
+ private static elements;
11
+ private static initialized;
12
+ private static panelStack;
13
+ private static boundHandleNavigationChange;
14
+ static init(): void;
15
+ private static buildPanels;
16
+ private static extractSubPanels;
17
+ static openPanel(panel: HTMLElement): void;
18
+ static goBack(): void;
19
+ private static resetPanels;
20
+ private static handleNavigationChange;
21
+ static pushToggle(): void;
22
+ private static toggleClass;
23
+ private static clickNav;
24
+ private static handleBackdropClick;
25
+ static open(): void;
26
+ static close(): void;
27
+ static isOpen(): boolean;
28
+ static destroy(): void;
29
+ static refresh(): void;
30
+ }
31
+ export { PushMenu, type PushMenuElements };
@@ -0,0 +1,9 @@
1
+ declare class RangeSlider {
2
+ private readonly input;
3
+ constructor(input: HTMLInputElement);
4
+ static initAll(selector?: string): void;
5
+ private update;
6
+ private handleInput;
7
+ destroy(): void;
8
+ }
9
+ export { RangeSlider };
package/js/scroll.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ interface ScrollOptions {
2
+ behavior?: ScrollBehavior;
3
+ offset?: number;
4
+ block?: ScrollLogicalPosition;
5
+ }
6
+ declare class Scroll {
7
+ static to(target: string | Element, options?: ScrollOptions): void;
8
+ }
9
+ declare global {
10
+ interface Window {
11
+ Scroll: typeof Scroll;
12
+ }
13
+ }
14
+ export { Scroll };
15
+ export type { ScrollOptions };
@@ -0,0 +1,48 @@
1
+ interface ScrollbarElements {
2
+ viewport: HTMLElement;
3
+ content: HTMLElement;
4
+ track: HTMLElement;
5
+ thumb: HTMLElement;
6
+ }
7
+ declare class Scrollbar {
8
+ private static readonly instances;
9
+ private static activeInstance;
10
+ private static globalListenersInstalled;
11
+ private static instanceCount;
12
+ private static globalListenerAbortController;
13
+ private readonly container;
14
+ private readonly viewport;
15
+ private readonly content;
16
+ private readonly track;
17
+ private readonly thumb;
18
+ private readonly MIN_THUMB_HEIGHT;
19
+ private readonly ro;
20
+ private dragging;
21
+ private activePointerId;
22
+ private startPointerY;
23
+ private startThumbTop;
24
+ private readonly boundPointerMove;
25
+ private readonly boundPointerUp;
26
+ private readonly boundThumbPointerDown;
27
+ private readonly boundTrackClick;
28
+ private readonly boundViewportScroll;
29
+ private readonly boundUpdateThumb;
30
+ private readonly boundContainerWheel;
31
+ private constructor();
32
+ private getRequiredElements;
33
+ private getMinThumbHeight;
34
+ private static installGlobalListeners;
35
+ private attachEventListeners;
36
+ private updateThumb;
37
+ private handleThumbPointerDown;
38
+ private handlePointerMove;
39
+ private handlePointerUp;
40
+ private handleTrackClick;
41
+ private handleContainerWheel;
42
+ destroy(): void;
43
+ static create(elementOrSelector: string | HTMLElement): Scrollbar;
44
+ static initAll(selector: string): Scrollbar[];
45
+ static initOne(elementOrSelector: string | HTMLElement): Scrollbar;
46
+ static getInstance(container: HTMLElement): Scrollbar | undefined;
47
+ }
48
+ export { Scrollbar, ScrollbarElements };
package/js/select.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ declare class Select {
2
+ private readonly element;
3
+ private readonly isMultiselect;
4
+ private readonly dropdown;
5
+ private readonly documentClickHandler;
6
+ constructor(elementOrSelector: string | HTMLSelectElement);
7
+ destroy(): void;
8
+ value(): string | string[] | undefined;
9
+ static init(elementOrSelector: string | HTMLSelectElement): boolean | null;
10
+ private static initElement;
11
+ private static closeAllDropdowns;
12
+ private static handleMultiSelect;
13
+ private static handleSingleSelect;
14
+ private static transformSelect;
15
+ }
16
+ export { Select };
@@ -0,0 +1,22 @@
1
+ interface SidebarNavOptions {
2
+ /** Selector for the toggle button. Default: '.sidebar-toggle' */
3
+ toggleSelector?: string;
4
+ /** Breakpoint (px) above which the sidebar is always visible. Default: 768 */
5
+ breakpoint?: number;
6
+ }
7
+ declare class SidebarNav {
8
+ private nav;
9
+ private backdrop;
10
+ private toggleBtn;
11
+ private opts;
12
+ private _onToggle;
13
+ private _onBackdrop;
14
+ private _onResize;
15
+ constructor(containerOrSelector: string | HTMLElement, options?: SidebarNavOptions);
16
+ open(): void;
17
+ close(): void;
18
+ toggle(): void;
19
+ isOpen(): boolean;
20
+ destroy(): void;
21
+ }
22
+ export { SidebarNav, SidebarNavOptions };
@@ -0,0 +1,26 @@
1
+ interface StepperOptions {
2
+ defaultStep?: number;
3
+ clickable?: boolean;
4
+ onChange?: (current: number, previous: number) => void;
5
+ }
6
+ declare class Stepper {
7
+ private container;
8
+ private steps;
9
+ private connectors;
10
+ private current;
11
+ private readonly onChange?;
12
+ private abortController;
13
+ constructor(elementOrSelector: string | HTMLElement, options?: StepperOptions);
14
+ private render;
15
+ next(): void;
16
+ prev(): void;
17
+ goTo(index: number): void;
18
+ setError(index: number): void;
19
+ clearError(index: number): void;
20
+ getStep(): number;
21
+ getStepCount(): number;
22
+ isFirst(): boolean;
23
+ isLast(): boolean;
24
+ destroy(): void;
25
+ }
26
+ export { Stepper, type StepperOptions };
package/js/table.d.ts ADDED
@@ -0,0 +1,98 @@
1
+ interface TableColumn {
2
+ key: string;
3
+ label: string;
4
+ sortable?: boolean;
5
+ }
6
+ interface TableRow {
7
+ [key: string]: string | number | boolean;
8
+ }
9
+ interface TableOptions {
10
+ data?: TableRow[];
11
+ columns?: TableColumn[];
12
+ pageSize?: number;
13
+ }
14
+ declare class Table {
15
+ private container;
16
+ private data;
17
+ private columns;
18
+ private pageSize;
19
+ private currentPage;
20
+ private sortColumn;
21
+ private sortDirection;
22
+ private filterText;
23
+ private tableBody;
24
+ private tableHeader;
25
+ private paginationContainer;
26
+ private abortController;
27
+ constructor(elementOrSelector: string | HTMLElement, options?: TableOptions);
28
+ /**
29
+ * Parses an existing HTML table in the DOM to extract data and columns
30
+ */
31
+ private parseTableFromDOM;
32
+ /**
33
+ * Initializes the table by rendering controls, structure, and content
34
+ */
35
+ private init;
36
+ /**
37
+ * Renders the search and page size controls
38
+ */
39
+ private renderControls;
40
+ /**
41
+ * Creates the table structure (table, thead, tbody, pagination container)
42
+ */
43
+ private renderTableStructure;
44
+ /**
45
+ * Returns filtered and sorted data based on current state
46
+ */
47
+ private getFilteredAndSortedData;
48
+ /**
49
+ * Renders the table body, pagination, and header sort indicators
50
+ */
51
+ private render;
52
+ /**
53
+ * Renders the table body rows
54
+ */
55
+ private renderBody;
56
+ /**
57
+ * Updates the sort direction indicators in table headers
58
+ */
59
+ private updateHeaderSortIcons;
60
+ /**
61
+ * Renders pagination controls and info
62
+ */
63
+ private renderPagination;
64
+ /**
65
+ * Handles search input changes
66
+ */
67
+ private handleSearch;
68
+ /**
69
+ * Handles column header clicks for sorting
70
+ */
71
+ private handleSort;
72
+ /**
73
+ * Handles page size changes
74
+ */
75
+ private handlePageSizeChange;
76
+ /**
77
+ * Sets the current page and re-renders
78
+ */
79
+ private setPage;
80
+ /**
81
+ * Assigns a unique ID to an element, incrementing if necessary
82
+ */
83
+ private assignUniqueId;
84
+ /**
85
+ * Public API: Updates the table data and re-renders
86
+ */
87
+ setData(data: TableRow[]): void;
88
+ /**
89
+ * Public API: Updates the columns and re-renders
90
+ */
91
+ setColumns(columns: TableColumn[]): void;
92
+ /**
93
+ * Public API: Gets the current filtered and sorted data
94
+ */
95
+ getData(): TableRow[];
96
+ destroy(): void;
97
+ }
98
+ export { Table, TableRow, TableColumn, TableOptions };
package/js/tabs.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ type TabLayout = 'horizontal' | 'vertical';
2
+ type MenuPosition = 'top' | 'bottom' | 'left' | 'right';
3
+ interface TabsOptions {
4
+ layout?: TabLayout;
5
+ defaultTab?: number;
6
+ menuPos?: MenuPosition;
7
+ onChange?: (index: number) => void;
8
+ }
9
+ declare class Tabs {
10
+ private container;
11
+ private options;
12
+ private tabItems;
13
+ private tabPanels;
14
+ private currentTab;
15
+ constructor(elementOrSelector: string | HTMLElement, options?: TabsOptions);
16
+ /**
17
+ * Initializes the tabs component
18
+ */
19
+ private init;
20
+ /**
21
+ * Binds click events to tab items
22
+ */
23
+ private bindEvents;
24
+ /**
25
+ * Handles keyboard navigation (Arrow keys, Home, End)
26
+ */
27
+ private handleKeyboardNavigation;
28
+ /**
29
+ * Activates a tab by index
30
+ */
31
+ private activateTab;
32
+ /**
33
+ * Public API: Programmatically activate a tab
34
+ */
35
+ goToTab(index: number): void;
36
+ /**
37
+ * Public API: Get the currently active tab index
38
+ */
39
+ getCurrentTab(): number;
40
+ /**
41
+ * Public API: Get the total number of tabs
42
+ */
43
+ getTabCount(): number;
44
+ /**
45
+ * Public API: Enable a tab
46
+ */
47
+ enableTab(index: number): void;
48
+ /**
49
+ * Public API: Disable a tab
50
+ */
51
+ disableTab(index: number): void;
52
+ /**
53
+ * Public API: Destroy the tabs instance and clean up
54
+ */
55
+ destroy(): void;
56
+ }
57
+ export { Tabs };
package/js/theme.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ type ThemeMode = 'light' | 'dark';
2
+ declare class Theme {
3
+ private static readonly STORAGE_KEY;
4
+ private static root;
5
+ private static elements;
6
+ private static mediaQuery;
7
+ /**
8
+ * Initializes the theme system with toggle functionality and system preference detection
9
+ */
10
+ static init(): void;
11
+ /**
12
+ * Safely retrieves the saved theme from localStorage
13
+ */
14
+ private static getSavedTheme;
15
+ /**
16
+ * Safely saves the theme to localStorage
17
+ */
18
+ private static saveTheme;
19
+ /**
20
+ * Gets the system-preferred theme
21
+ */
22
+ private static getSystemTheme;
23
+ /**
24
+ * Gets the current active theme
25
+ */
26
+ private static getCurrentTheme;
27
+ /**
28
+ * Applies a theme to the document
29
+ */
30
+ private static applyTheme;
31
+ /**
32
+ * Toggles between light and dark theme
33
+ */
34
+ private static toggleTheme;
35
+ /**
36
+ * Binds click event to toggle button
37
+ */
38
+ private static bindToggleClick;
39
+ /**
40
+ * Binds keyboard shortcut (Ctrl/Cmd+J) for theme toggle
41
+ */
42
+ private static bindKeyboardShortcut;
43
+ /**
44
+ * Binds listener for system theme changes
45
+ * Only applies if user hasn't explicitly saved a preference
46
+ */
47
+ private static bindSystemThemeChange;
48
+ /**
49
+ * Public API: Get the current theme
50
+ */
51
+ static getTheme(): ThemeMode;
52
+ /**
53
+ * Public API: Set the theme programmatically
54
+ */
55
+ static setTheme(theme: ThemeMode): void;
56
+ /**
57
+ * Public API: Reset to system preference
58
+ */
59
+ static resetToSystem(): void;
60
+ /**
61
+ * Public API: Check if user has a saved preference
62
+ */
63
+ static hasSavedPreference(): boolean;
64
+ }
65
+ export { Theme };
@@ -0,0 +1,37 @@
1
+ interface TimeSpan {
2
+ start: string;
3
+ end: string;
4
+ }
5
+ interface TimeSpanPickerOptions {
6
+ onChange?: (start: string, end: string) => void;
7
+ defaultStart?: string;
8
+ defaultEnd?: string;
9
+ fromString?: string;
10
+ toString?: string;
11
+ }
12
+ declare class TimeSpanPicker {
13
+ private container;
14
+ private startTimeInput;
15
+ private endTimeInput;
16
+ private onChange?;
17
+ private readonly uid;
18
+ private fromString;
19
+ private toString;
20
+ constructor(elementOrSelector: string | HTMLElement, options?: TimeSpanPickerOptions);
21
+ private queryInput;
22
+ private render;
23
+ private readonly handleStartChange;
24
+ private readonly handleEndChange;
25
+ private attachEventListeners;
26
+ private toMinutes;
27
+ private formatDuration;
28
+ private updateUI;
29
+ private handleChange;
30
+ getValue(): TimeSpan;
31
+ setValue(start: string, end: string): void;
32
+ reset(): void;
33
+ isValid(): boolean;
34
+ destroy(): void;
35
+ }
36
+ export { TimeSpanPicker };
37
+ export type { TimeSpan, TimeSpanPickerOptions };
package/js/toast.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ type ToastType = 'success' | 'error' | 'warning' | 'info';
2
+ interface ToastOptions {
3
+ content: string;
4
+ header?: string;
5
+ type?: ToastType;
6
+ closeable?: boolean;
7
+ }
8
+ declare class Toast {
9
+ private readonly content;
10
+ private readonly header;
11
+ private readonly type?;
12
+ private readonly closeable;
13
+ private readonly closureIcon;
14
+ private readonly template;
15
+ private toastElement;
16
+ private timerId;
17
+ constructor(options: ToastOptions);
18
+ constructor(content: string, header?: string, type?: ToastType, closeable?: boolean);
19
+ show(ms?: number): void;
20
+ hide: () => void;
21
+ private handleClose;
22
+ private startTimer;
23
+ private buildTemplate;
24
+ }
25
+ export { Toast };
26
+ export type { ToastOptions, ToastType };
@@ -0,0 +1,34 @@
1
+ interface TooltipOptions {
2
+ position?: 'top' | 'bottom' | 'left' | 'right' | 'auto';
3
+ offset?: number;
4
+ delay?: number;
5
+ className?: string;
6
+ /** Set to true when content is trusted HTML (e.g. from data-tooltip-id).
7
+ * Defaults to false — content is treated as plain text and escaped. */
8
+ isHtml?: boolean;
9
+ }
10
+ declare class Tooltip {
11
+ private static activeTooltip;
12
+ private static idCounter;
13
+ private readonly trigger;
14
+ private readonly content;
15
+ private readonly options;
16
+ private tooltipElement;
17
+ private showTimeout;
18
+ private isVisible;
19
+ constructor(trigger: HTMLElement, content: string, options?: TooltipOptions);
20
+ static initializeAll(): void;
21
+ show(): void;
22
+ hide(): void;
23
+ private static hideActive;
24
+ private createTooltip;
25
+ private position;
26
+ private attachEvents;
27
+ private handleMouseEnter;
28
+ private handleMouseLeave;
29
+ private handleFocus;
30
+ private handleBlur;
31
+ destroy(): void;
32
+ }
33
+ export { Tooltip };
34
+ export type { TooltipOptions };
package/js/tree.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ type NodeType = 'file' | 'folder';
2
+ interface TreeOptions {
3
+ onSelect?: (node: TreeNode) => void;
4
+ }
5
+ declare class TreeNode {
6
+ label: string;
7
+ type: NodeType;
8
+ children: TreeNode[];
9
+ expanded: boolean;
10
+ selected: boolean;
11
+ element: HTMLDivElement | null;
12
+ childrenContainer: HTMLUListElement | null;
13
+ constructor(label: string, type?: NodeType, children?: TreeNode[]);
14
+ }
15
+ declare class TreeComponent {
16
+ private container;
17
+ private data;
18
+ private selectedNode;
19
+ private readonly options;
20
+ constructor(elementOrSelector: string | HTMLElement, data: TreeNode[], options?: TreeOptions);
21
+ private init;
22
+ render(): void;
23
+ private renderNode;
24
+ private createIconElement;
25
+ private createLabelElement;
26
+ private createChildrenContainer;
27
+ private toggleNode;
28
+ private expandChildren;
29
+ private collapseChildren;
30
+ selectNode(node: TreeNode): void;
31
+ expandAll(): void;
32
+ collapseAll(): void;
33
+ private traverseNodes;
34
+ destroy(): void;
35
+ getSelectedNode(): TreeNode | null;
36
+ findNodeByLabel(label: string): TreeNode | null;
37
+ private findNode;
38
+ }
39
+ export { TreeComponent, TreeNode };
40
+ export type { NodeType, TreeOptions };
package/js/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "outDir": ".",
6
6
  "rootDir": ".",
7
7
  "strict": true,
8
+ "declaration": true,
8
9
  "types": [],
9
10
  },
10
11
  "include": [
package/js/utils.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Utility functions for DOM manipulation and element handling
3
+ */
4
+ interface Utils {
5
+ ready(fn: () => void): void;
6
+ value(element: HTMLElement): string;
7
+ text(element: HTMLElement): string;
8
+ attribute(element: HTMLElement, attribute: string): string | undefined;
9
+ isList(element: HTMLElement | NodeList): boolean;
10
+ isHidden(element: HTMLElement): boolean;
11
+ }
12
+ declare const utils: Utils;
13
+ /**
14
+ * Escape a plain-text string so it is safe to inject into innerHTML.
15
+ * Use this whenever inserting user-controlled strings into HTML templates.
16
+ */
17
+ declare function escapeHtml(text: string): string;
18
+ /**
19
+ * Sanitize an HTML string by removing dangerous elements and attributes
20
+ * (script, iframe, on* handlers, javascript: hrefs) while preserving safe markup.
21
+ * Use this when a component intentionally accepts rich HTML from callers.
22
+ */
23
+ declare function sanitizeHtml(html: string): string;
24
+ export { utils, escapeHtml, sanitizeHtml };