mithril-materialized 2.0.0-beta.1 → 2.0.0-beta.11
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 +287 -308
- package/dist/advanced.css +1888 -0
- package/dist/autocomplete.d.ts +3 -3
- package/dist/breadcrumb.d.ts +53 -0
- package/dist/button.d.ts +66 -21
- package/dist/carousel.d.ts +2 -2
- package/dist/chip.d.ts +2 -2
- package/dist/code-block.d.ts +2 -2
- package/dist/collapsible.d.ts +2 -2
- package/dist/collection.d.ts +2 -2
- package/dist/components.css +2310 -0
- package/dist/core.css +3402 -0
- package/dist/datatable.d.ts +291 -0
- package/dist/datepicker.d.ts +66 -0
- package/dist/dropdown.d.ts +2 -2
- package/dist/file-upload.d.ts +34 -0
- package/dist/floating-action-button.d.ts +2 -2
- package/dist/forms.css +2284 -0
- package/dist/index.css +1825 -184
- package/dist/index.d.ts +14 -1
- package/dist/index.esm.js +4752 -2143
- package/dist/index.js +4776 -2142
- package/dist/index.min.css +8 -0
- package/dist/index.umd.js +4776 -2142
- package/dist/input-options.d.ts +1 -1
- package/dist/input.d.ts +9 -10
- package/dist/label.d.ts +4 -2
- package/dist/material-box.d.ts +2 -2
- package/dist/modal.d.ts +2 -2
- package/dist/option.d.ts +4 -4
- package/dist/pagination.d.ts +2 -2
- package/dist/parallax.d.ts +2 -2
- package/dist/pickers.css +487 -0
- package/dist/pushpin.d.ts +32 -0
- package/dist/radio.d.ts +4 -4
- package/dist/search-select.d.ts +2 -2
- package/dist/select.d.ts +2 -2
- package/dist/sidenav.d.ts +76 -0
- package/dist/switch.d.ts +2 -2
- package/dist/tabs.d.ts +2 -4
- package/dist/theme-switcher.d.ts +49 -0
- package/dist/timepicker.d.ts +42 -0
- package/dist/toast.d.ts +45 -0
- package/dist/tooltip.d.ts +59 -0
- package/dist/types.d.ts +226 -0
- package/dist/utilities.css +3204 -0
- package/dist/wizard.d.ts +58 -0
- package/package.json +20 -9
- package/sass/components/_breadcrumb.scss +248 -0
- package/sass/components/_buttons.scss +3 -3
- package/sass/components/_cards.scss +10 -3
- package/sass/components/_chips.scss +8 -8
- package/sass/components/_collapsible.scss +8 -8
- package/sass/components/_datatable.scss +417 -0
- package/sass/components/_datepicker.scss +45 -14
- package/sass/components/_dropdown.scss +5 -5
- package/sass/components/_file-upload.scss +228 -0
- package/sass/components/_global.scss +13 -11
- package/sass/components/_modal.scss +5 -2
- package/sass/components/_navbar.scss +13 -5
- package/sass/components/_sidenav.scss +164 -7
- package/sass/components/_tabs.scss +5 -4
- package/sass/components/_theme-switcher.scss +120 -0
- package/sass/components/_theme-variables.scss +205 -0
- package/sass/components/_timepicker.scss +179 -87
- package/sass/components/_wizard.scss +416 -0
- package/sass/components/forms/_input-fields.scss +34 -12
- package/sass/components/forms/_radio-buttons.scss +10 -10
- package/sass/components/forms/_range.scss +5 -5
- package/sass/components/forms/_select.scss +9 -9
- package/sass/components/forms/_switches.scss +6 -6
- package/sass/materialize.scss +8 -0
- package/dist/pickers.d.ts +0 -130
package/dist/search-select.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface Option<T extends string | number> {
|
|
|
4
4
|
label?: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface SearchSelectAttrs<T extends string | number> extends Attributes {
|
|
8
8
|
/** Options to display in the select */
|
|
9
9
|
options?: Option<T>[];
|
|
10
10
|
/** Initial value */
|
|
@@ -37,5 +37,5 @@ interface SearchSelectState<T extends string | number> {
|
|
|
37
37
|
/**
|
|
38
38
|
* Mithril Factory Component for Multi-Select Dropdown with search
|
|
39
39
|
*/
|
|
40
|
-
export declare const SearchSelect: <T extends string | number>() => Component<
|
|
40
|
+
export declare const SearchSelect: <T extends string | number>() => Component<SearchSelectAttrs<T>, SearchSelectState<T>>;
|
|
41
41
|
export {};
|
package/dist/select.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Attributes, Component } from 'mithril';
|
|
2
2
|
import { InputOption } from './option';
|
|
3
|
-
export interface
|
|
3
|
+
export interface SelectAttrs<T extends string | number> extends Attributes {
|
|
4
4
|
/** Options to select from */
|
|
5
5
|
options: InputOption<T>[];
|
|
6
6
|
/** Called when the value is changed, either contains a single or all selected (checked) ids */
|
|
@@ -43,4 +43,4 @@ export interface SelectAttributes<T extends string | number> extends Attributes
|
|
|
43
43
|
showClearButton?: boolean;
|
|
44
44
|
}
|
|
45
45
|
/** Select component */
|
|
46
|
-
export declare const Select: <T extends string | number>() => Component<
|
|
46
|
+
export declare const Select: <T extends string | number>() => Component<SelectAttrs<T>>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { FactoryComponent, Attributes } from 'mithril';
|
|
2
|
+
export interface SidenavAttrs extends Attributes {
|
|
3
|
+
/** Unique ID for the sidenav */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Whether the sidenav is open */
|
|
6
|
+
isOpen?: boolean;
|
|
7
|
+
/** Callback when sidenav open state changes */
|
|
8
|
+
onToggle?: (isOpen: boolean) => void;
|
|
9
|
+
/** Position of the sidenav */
|
|
10
|
+
position?: 'left' | 'right';
|
|
11
|
+
/** Whether sidenav should overlay content or push it */
|
|
12
|
+
mode?: 'overlay' | 'push';
|
|
13
|
+
/** Width of the sidenav in pixels */
|
|
14
|
+
width?: number;
|
|
15
|
+
/** Custom class for the sidenav */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Whether to show backdrop overlay */
|
|
18
|
+
showBackdrop?: boolean;
|
|
19
|
+
/** Close sidenav when backdrop is clicked */
|
|
20
|
+
closeOnBackdropClick?: boolean;
|
|
21
|
+
/** Close sidenav when escape key is pressed */
|
|
22
|
+
closeOnEscape?: boolean;
|
|
23
|
+
/** Animation duration in milliseconds */
|
|
24
|
+
animationDuration?: number;
|
|
25
|
+
/** Fixed sidenav (always visible on larger screens) */
|
|
26
|
+
fixed?: boolean;
|
|
27
|
+
/** Breakpoint for responsive behavior (in pixels) */
|
|
28
|
+
breakpoint?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface SidenavItemAttrs {
|
|
31
|
+
/** Text content of the item */
|
|
32
|
+
text?: string;
|
|
33
|
+
/** Icon name (material icons) */
|
|
34
|
+
icon?: string;
|
|
35
|
+
/** Whether this item is active */
|
|
36
|
+
active?: boolean;
|
|
37
|
+
/** Whether this item is disabled */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Click handler */
|
|
40
|
+
onclick?: (e: Event) => void;
|
|
41
|
+
/** Href for link items */
|
|
42
|
+
href?: string;
|
|
43
|
+
/** Custom class */
|
|
44
|
+
className?: string;
|
|
45
|
+
/** Whether this is a divider */
|
|
46
|
+
divider?: boolean;
|
|
47
|
+
/** Whether this is a subheader */
|
|
48
|
+
subheader?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sidenav Component
|
|
52
|
+
* A responsive navigation drawer that slides in from the side
|
|
53
|
+
*/
|
|
54
|
+
export declare const Sidenav: FactoryComponent<SidenavAttrs>;
|
|
55
|
+
/**
|
|
56
|
+
* Sidenav Item Component
|
|
57
|
+
* Individual items for the sidenav menu
|
|
58
|
+
*/
|
|
59
|
+
export declare const SidenavItem: FactoryComponent<SidenavItemAttrs>;
|
|
60
|
+
/**
|
|
61
|
+
* Sidenav utilities for programmatic control
|
|
62
|
+
*/
|
|
63
|
+
export declare class SidenavManager {
|
|
64
|
+
/**
|
|
65
|
+
* Open a sidenav by ID
|
|
66
|
+
*/
|
|
67
|
+
static open(id: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Close a sidenav by ID
|
|
70
|
+
*/
|
|
71
|
+
static close(id: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* Toggle a sidenav by ID
|
|
74
|
+
*/
|
|
75
|
+
static toggle(id: string): void;
|
|
76
|
+
}
|
package/dist/switch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FactoryComponent } from 'mithril';
|
|
2
|
-
import {
|
|
3
|
-
export interface SwitchOptions extends Partial<
|
|
2
|
+
import { InputAttrs } from './input-options';
|
|
3
|
+
export interface SwitchOptions extends Partial<InputAttrs<boolean>> {
|
|
4
4
|
/** Left text label */
|
|
5
5
|
left?: string;
|
|
6
6
|
/** Right text label */
|
package/dist/tabs.d.ts
CHANGED
|
@@ -14,8 +14,6 @@ export interface TabItem {
|
|
|
14
14
|
vnode?: Vnode<any, any>;
|
|
15
15
|
/** ID of the tab element. Default the title in lowercase */
|
|
16
16
|
id?: string;
|
|
17
|
-
/** If the tab should be active */
|
|
18
|
-
active?: boolean;
|
|
19
17
|
/** If the tab should be disabled */
|
|
20
18
|
disabled?: boolean;
|
|
21
19
|
/** CSS class for the tab (li), default `.tab.col.s3` */
|
|
@@ -40,7 +38,7 @@ export interface TabsOptions {
|
|
|
40
38
|
/** Enable swiping between tabs on mobile */
|
|
41
39
|
swipeable?: boolean;
|
|
42
40
|
}
|
|
43
|
-
export interface
|
|
41
|
+
export interface TabsAttrs extends TabsOptions, Attributes {
|
|
44
42
|
/** Selected tab id, takes precedence over tab.active property */
|
|
45
43
|
selectedTabId?: string;
|
|
46
44
|
/**
|
|
@@ -54,4 +52,4 @@ export interface TabsAttributes extends TabsOptions, Attributes {
|
|
|
54
52
|
onTabChange?: (tabId: string) => void;
|
|
55
53
|
}
|
|
56
54
|
/** CSS-only Tabs component - no MaterializeCSS dependencies */
|
|
57
|
-
export declare const Tabs: FactoryComponent<
|
|
55
|
+
export declare const Tabs: FactoryComponent<TabsAttrs>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FactoryComponent } from 'mithril';
|
|
2
|
+
export type Theme = 'light' | 'dark' | 'auto';
|
|
3
|
+
export interface ThemeSwitcherAttrs {
|
|
4
|
+
/** Current theme selection */
|
|
5
|
+
theme?: Theme;
|
|
6
|
+
/** Callback when theme changes */
|
|
7
|
+
onThemeChange?: (theme: Theme) => void;
|
|
8
|
+
/** Show labels on the toggle buttons */
|
|
9
|
+
showLabels?: boolean;
|
|
10
|
+
/** Custom class for the container */
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Theme switching utilities and component
|
|
15
|
+
*/
|
|
16
|
+
export declare class ThemeManager {
|
|
17
|
+
private static currentTheme;
|
|
18
|
+
/**
|
|
19
|
+
* Set the theme for the entire application
|
|
20
|
+
*/
|
|
21
|
+
static setTheme(theme: Theme): void;
|
|
22
|
+
/**
|
|
23
|
+
* Get the current theme
|
|
24
|
+
*/
|
|
25
|
+
static getTheme(): Theme;
|
|
26
|
+
/**
|
|
27
|
+
* Get the effective theme (resolves 'auto' to actual theme)
|
|
28
|
+
*/
|
|
29
|
+
static getEffectiveTheme(): 'light' | 'dark';
|
|
30
|
+
/**
|
|
31
|
+
* Initialize theme from localStorage or system preference
|
|
32
|
+
*/
|
|
33
|
+
static initialize(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Toggle between light and dark themes
|
|
36
|
+
*/
|
|
37
|
+
static toggle(): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Theme Switcher Component
|
|
41
|
+
* Provides UI controls for changing themes
|
|
42
|
+
*/
|
|
43
|
+
export declare const ThemeSwitcher: FactoryComponent<ThemeSwitcherAttrs>;
|
|
44
|
+
/**
|
|
45
|
+
* Simple theme toggle button (just switches between light/dark)
|
|
46
|
+
*/
|
|
47
|
+
export declare const ThemeToggle: FactoryComponent<{
|
|
48
|
+
className?: string;
|
|
49
|
+
}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FactoryComponent } from 'mithril';
|
|
2
|
+
import { InputAttrs } from './input-options';
|
|
3
|
+
export interface TimepickerI18n {
|
|
4
|
+
cancel?: string;
|
|
5
|
+
clear?: string;
|
|
6
|
+
done?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TimepickerOptions {
|
|
9
|
+
dialRadius?: number;
|
|
10
|
+
outerRadius?: number;
|
|
11
|
+
innerRadius?: number;
|
|
12
|
+
tickRadius?: number;
|
|
13
|
+
duration?: number;
|
|
14
|
+
container?: string | null;
|
|
15
|
+
defaultTime?: string;
|
|
16
|
+
fromNow?: number;
|
|
17
|
+
showClearBtn?: boolean;
|
|
18
|
+
i18n?: TimepickerI18n;
|
|
19
|
+
autoClose?: boolean;
|
|
20
|
+
twelveHour?: boolean;
|
|
21
|
+
vibrate?: boolean;
|
|
22
|
+
onOpen?: () => void;
|
|
23
|
+
onOpenStart?: () => void;
|
|
24
|
+
onOpenEnd?: () => void;
|
|
25
|
+
onCloseStart?: () => void;
|
|
26
|
+
onCloseEnd?: () => void;
|
|
27
|
+
onSelect?: (hour: number, minute: number) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface TimePickerAttrs extends InputAttrs<string>, TimepickerOptions {
|
|
30
|
+
/** Use inline mode (HTML5 time input) instead of modal, default true */
|
|
31
|
+
useModal?: boolean;
|
|
32
|
+
/** Allow format toggle between 12h/24h (for inline mode) */
|
|
33
|
+
allowFormatToggle?: boolean;
|
|
34
|
+
/** Clear button label */
|
|
35
|
+
clearLabel?: string;
|
|
36
|
+
/** Close button label */
|
|
37
|
+
closeLabel?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* TimePicker component based on original Materialize CSS timepicker
|
|
41
|
+
*/
|
|
42
|
+
export declare const TimePicker: FactoryComponent<TimePickerAttrs>;
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FactoryComponent } from 'mithril';
|
|
2
|
+
export interface ToastOptions {
|
|
3
|
+
/** HTML content for the toast */
|
|
4
|
+
html?: string;
|
|
5
|
+
/** Display length in milliseconds */
|
|
6
|
+
displayLength?: number;
|
|
7
|
+
/** Animation in duration in milliseconds */
|
|
8
|
+
inDuration?: number;
|
|
9
|
+
/** Animation out duration in milliseconds */
|
|
10
|
+
outDuration?: number;
|
|
11
|
+
/** Additional CSS classes */
|
|
12
|
+
classes?: string;
|
|
13
|
+
/** Callback function called when toast is dismissed */
|
|
14
|
+
completeCallback?: () => void;
|
|
15
|
+
/** Activation percentage for swipe dismissal */
|
|
16
|
+
activationPercent?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare class Toast {
|
|
19
|
+
el: HTMLElement;
|
|
20
|
+
options: Required<ToastOptions>;
|
|
21
|
+
private state;
|
|
22
|
+
private static _toasts;
|
|
23
|
+
private static _container;
|
|
24
|
+
private static _draggedToast;
|
|
25
|
+
private static defaults;
|
|
26
|
+
constructor(options?: ToastOptions);
|
|
27
|
+
static getInstance(el: HTMLElement): Toast | undefined;
|
|
28
|
+
static _createContainer(): void;
|
|
29
|
+
static _removeContainer(): void;
|
|
30
|
+
static _onDragStart: (e: Event) => void;
|
|
31
|
+
static _onDragMove: (e: Event) => void;
|
|
32
|
+
static _onDragEnd: () => void;
|
|
33
|
+
static _xPos(e: Event): number;
|
|
34
|
+
static dismissAll(): void;
|
|
35
|
+
_createToast(): HTMLElement;
|
|
36
|
+
_animateIn(): void;
|
|
37
|
+
_setTimer(): void;
|
|
38
|
+
dismiss(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare const toast: (options: ToastOptions) => Toast;
|
|
41
|
+
export interface ToastComponentAttrs extends ToastOptions {
|
|
42
|
+
/** Whether to show the toast */
|
|
43
|
+
show?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare const ToastComponent: FactoryComponent<ToastComponentAttrs>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FactoryComponent, Attributes } from 'mithril';
|
|
2
|
+
export interface TooltipOptions {
|
|
3
|
+
/** Delay before tooltip appears on hover */
|
|
4
|
+
enterDelay?: number;
|
|
5
|
+
/** Delay before tooltip disappears after hover ends */
|
|
6
|
+
exitDelay?: number;
|
|
7
|
+
/** HTML content for the tooltip */
|
|
8
|
+
html?: string | null;
|
|
9
|
+
/** Margin from element */
|
|
10
|
+
margin?: number;
|
|
11
|
+
/** Animation in duration */
|
|
12
|
+
inDuration?: number;
|
|
13
|
+
/** Animation out duration */
|
|
14
|
+
outDuration?: number;
|
|
15
|
+
/** Position of tooltip */
|
|
16
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
17
|
+
/** Movement during transition */
|
|
18
|
+
transitionMovement?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class Tooltip {
|
|
21
|
+
el: HTMLElement;
|
|
22
|
+
tooltipEl: HTMLElement;
|
|
23
|
+
options: Required<TooltipOptions>;
|
|
24
|
+
private state;
|
|
25
|
+
private static defaults;
|
|
26
|
+
private _handleMouseEnterBound;
|
|
27
|
+
private _handleMouseLeaveBound;
|
|
28
|
+
private _handleFocusBound;
|
|
29
|
+
private _handleBlurBound;
|
|
30
|
+
constructor(el: HTMLElement, options?: TooltipOptions);
|
|
31
|
+
static getInstance(el: HTMLElement): Tooltip | undefined;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
_appendTooltipEl(): void;
|
|
34
|
+
_updateTooltipContent(): void;
|
|
35
|
+
_setupEventHandlers(): void;
|
|
36
|
+
_removeEventHandlers(): void;
|
|
37
|
+
open(isManual?: boolean): void;
|
|
38
|
+
close(): void;
|
|
39
|
+
_setExitDelayTimeout(): void;
|
|
40
|
+
_setEnterDelayTimeout(isManual: boolean): void;
|
|
41
|
+
_positionTooltip(): void;
|
|
42
|
+
_repositionWithinScreen(x: number, y: number, width: number, height: number): {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
};
|
|
46
|
+
_animateIn(): void;
|
|
47
|
+
_animateOut(): void;
|
|
48
|
+
_handleMouseEnter(): void;
|
|
49
|
+
_handleMouseLeave(): void;
|
|
50
|
+
_handleFocus(): void;
|
|
51
|
+
_handleBlur(): void;
|
|
52
|
+
_getAttributeOptions(): Partial<TooltipOptions>;
|
|
53
|
+
}
|
|
54
|
+
export interface TooltipComponentAttrs extends Attributes, TooltipOptions {
|
|
55
|
+
/** Element selector or reference to attach tooltip to */
|
|
56
|
+
targetSelector?: string;
|
|
57
|
+
}
|
|
58
|
+
export declare const TooltipComponent: FactoryComponent<TooltipComponentAttrs>;
|
|
59
|
+
export declare const initTooltips: (selector?: string, options?: TooltipOptions) => Tooltip[];
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Core TypeScript utility types for mithril-materialized library
|
|
3
|
+
* These types improve type safety and developer experience across all components
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Component size variants used throughout the library
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const buttonSize: ComponentSize = 'medium';
|
|
10
|
+
* const iconSize: ComponentSize = 'small';
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type ComponentSize = 'tiny' | 'small' | 'medium' | 'large';
|
|
14
|
+
/**
|
|
15
|
+
* Material Design positioning options
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const tooltipPosition: MaterialPosition = 'top';
|
|
19
|
+
* const dropdownPosition: MaterialPosition = 'bottom';
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export type MaterialPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
23
|
+
/**
|
|
24
|
+
* Extended positioning including corners and center
|
|
25
|
+
*/
|
|
26
|
+
export type ExtendedPosition = MaterialPosition | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
|
|
27
|
+
/**
|
|
28
|
+
* Validation result - either success (true/empty string) or error (false/error message)
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const validator = (value: string): ValidationResult => {
|
|
32
|
+
* return value.length >= 3 || 'Must be at least 3 characters';
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export type ValidationSuccess = true | '';
|
|
37
|
+
export type ValidationError = false | string;
|
|
38
|
+
export type ValidationResult = ValidationSuccess | ValidationError;
|
|
39
|
+
/**
|
|
40
|
+
* Generic event handler type with proper typing for value and optional event
|
|
41
|
+
* @template T - The type of the value being handled
|
|
42
|
+
*/
|
|
43
|
+
export interface EventHandler<T = any> {
|
|
44
|
+
(value: T, event?: Event): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Keyboard event handler with proper typing
|
|
48
|
+
* @template T - The type of the associated value
|
|
49
|
+
*/
|
|
50
|
+
export interface KeyboardEventHandler<T = string> {
|
|
51
|
+
(event: KeyboardEvent, value?: T): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Valid ID types for components - allows strings and numbers
|
|
55
|
+
*/
|
|
56
|
+
export type ValidId = string | number;
|
|
57
|
+
/**
|
|
58
|
+
* Component ID type - string branded for type safety
|
|
59
|
+
*/
|
|
60
|
+
export type ComponentId = string & {
|
|
61
|
+
readonly __componentId: unique symbol;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Conditional type to make ID required or optional
|
|
65
|
+
* @template T - The base type
|
|
66
|
+
* @template Required - Whether ID should be required
|
|
67
|
+
*/
|
|
68
|
+
export type WithId<T, Required extends boolean = false> = Required extends true ? T & {
|
|
69
|
+
id: ComponentId;
|
|
70
|
+
} : T & {
|
|
71
|
+
id?: ComponentId;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Validation function interface
|
|
75
|
+
* @template T - The type of value being validated
|
|
76
|
+
*/
|
|
77
|
+
export interface ValidatorFunction<T> {
|
|
78
|
+
/**
|
|
79
|
+
* Validates a value
|
|
80
|
+
* @param value - The value to validate
|
|
81
|
+
* @param element - Optional HTML element for context
|
|
82
|
+
* @returns True/empty string for success, false/error message for failure
|
|
83
|
+
*/
|
|
84
|
+
(value: T, element?: HTMLInputElement): ValidationResult;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Type guard to check if validation result indicates success
|
|
88
|
+
* @param result - The validation result to check
|
|
89
|
+
* @returns True if validation passed
|
|
90
|
+
*/
|
|
91
|
+
export declare const isValidationSuccess: (result: ValidationResult) => result is ValidationSuccess;
|
|
92
|
+
/**
|
|
93
|
+
* Type guard to check if validation result indicates an error
|
|
94
|
+
* @param result - The validation result to check
|
|
95
|
+
* @returns True if validation failed
|
|
96
|
+
*/
|
|
97
|
+
export declare const isValidationError: (result: ValidationResult) => result is ValidationError;
|
|
98
|
+
/**
|
|
99
|
+
* Button variant discriminated union for type-safe button configurations
|
|
100
|
+
*/
|
|
101
|
+
export type ButtonVariant = {
|
|
102
|
+
type: 'button';
|
|
103
|
+
submit?: never;
|
|
104
|
+
modalId?: never;
|
|
105
|
+
} | {
|
|
106
|
+
type: 'submit';
|
|
107
|
+
modalId?: never;
|
|
108
|
+
} | {
|
|
109
|
+
type: 'modal';
|
|
110
|
+
modalId: string;
|
|
111
|
+
submit?: never;
|
|
112
|
+
} | {
|
|
113
|
+
type: 'reset';
|
|
114
|
+
modalId?: never;
|
|
115
|
+
submit?: never;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Input type union with proper HTML input types
|
|
119
|
+
*/
|
|
120
|
+
export type InputType = 'text' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'number' | 'range' | 'date' | 'datetime-local' | 'month' | 'time' | 'week' | 'color' | 'file' | 'hidden';
|
|
121
|
+
/**
|
|
122
|
+
* Input value type based on input type
|
|
123
|
+
* @template T - The input type
|
|
124
|
+
*/
|
|
125
|
+
export type InputValue<T extends InputType> = T extends 'number' | 'range' ? number : T extends 'date' | 'datetime-local' | 'month' | 'time' | 'week' ? Date | string : T extends 'file' ? FileList | File[] : string;
|
|
126
|
+
/**
|
|
127
|
+
* Icon class using template literal types for better IntelliSense
|
|
128
|
+
*/
|
|
129
|
+
export type IconClass = ComponentSize | MaterialPosition | `${ComponentSize} ${MaterialPosition}`;
|
|
130
|
+
/**
|
|
131
|
+
* Modal type discriminated union
|
|
132
|
+
*/
|
|
133
|
+
export type ModalType = {
|
|
134
|
+
type: 'standard';
|
|
135
|
+
fixedFooter?: never;
|
|
136
|
+
bottomSheet?: never;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'fixed-footer';
|
|
139
|
+
fixedFooter: true;
|
|
140
|
+
bottomSheet?: never;
|
|
141
|
+
} | {
|
|
142
|
+
type: 'bottom-sheet';
|
|
143
|
+
bottomSheet: true;
|
|
144
|
+
fixedFooter?: never;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Selection mode for components that support item selection
|
|
148
|
+
*/
|
|
149
|
+
export type SelectionMode = 'none' | 'single' | 'multiple';
|
|
150
|
+
/**
|
|
151
|
+
* Sort direction for sortable components
|
|
152
|
+
*/
|
|
153
|
+
export type SortDirection = 'asc' | 'desc';
|
|
154
|
+
/**
|
|
155
|
+
* Theme variant for components that support theming
|
|
156
|
+
*/
|
|
157
|
+
export type ThemeVariant = 'light' | 'dark' | 'auto';
|
|
158
|
+
/**
|
|
159
|
+
* Color palette based on Material Design
|
|
160
|
+
*/
|
|
161
|
+
export type MaterialColor = 'red' | 'pink' | 'purple' | 'deep-purple' | 'indigo' | 'blue' | 'light-blue' | 'cyan' | 'teal' | 'green' | 'light-green' | 'lime' | 'yellow' | 'amber' | 'orange' | 'deep-orange' | 'brown' | 'grey' | 'blue-grey';
|
|
162
|
+
/**
|
|
163
|
+
* Color intensity levels
|
|
164
|
+
*/
|
|
165
|
+
export type ColorIntensity = 'lighten-5' | 'lighten-4' | 'lighten-3' | 'lighten-2' | 'lighten-1' | 'base' | 'darken-1' | 'darken-2' | 'darken-3' | 'darken-4' | 'accent-1' | 'accent-2' | 'accent-3' | 'accent-4';
|
|
166
|
+
/**
|
|
167
|
+
* Full color specification with intensity
|
|
168
|
+
*/
|
|
169
|
+
export type MaterialColorSpec = MaterialColor | `${MaterialColor} ${ColorIntensity}`;
|
|
170
|
+
/**
|
|
171
|
+
* Makes specified keys required while keeping others optional
|
|
172
|
+
* @template T - The base type
|
|
173
|
+
* @template K - Keys to make required
|
|
174
|
+
*/
|
|
175
|
+
export type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
176
|
+
/**
|
|
177
|
+
* Makes specified keys optional while keeping others as-is
|
|
178
|
+
* @template T - The base type
|
|
179
|
+
* @template K - Keys to make optional
|
|
180
|
+
*/
|
|
181
|
+
export type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
182
|
+
/**
|
|
183
|
+
* Extracts function parameter types
|
|
184
|
+
* @template T - The function type
|
|
185
|
+
*/
|
|
186
|
+
export type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
|
|
187
|
+
/**
|
|
188
|
+
* Creates a deep readonly version of a type
|
|
189
|
+
* @template T - The type to make readonly
|
|
190
|
+
*/
|
|
191
|
+
export type DeepReadonly<T> = {
|
|
192
|
+
readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Represents a component that can be focused
|
|
196
|
+
*/
|
|
197
|
+
export interface Focusable {
|
|
198
|
+
focus(): void;
|
|
199
|
+
blur(): void;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Represents a component that can be validated
|
|
203
|
+
*/
|
|
204
|
+
export interface Validatable<T = any> {
|
|
205
|
+
validate(): ValidationResult;
|
|
206
|
+
readonly isValid: boolean;
|
|
207
|
+
readonly value: T;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Configuration for components with validation
|
|
211
|
+
* @template T - The type of value being validated
|
|
212
|
+
*/
|
|
213
|
+
export interface ValidationConfig<T = any> {
|
|
214
|
+
/** Whether the field is required */
|
|
215
|
+
required?: boolean;
|
|
216
|
+
/** Minimum length for string values */
|
|
217
|
+
minLength?: number;
|
|
218
|
+
/** Maximum length for string values */
|
|
219
|
+
maxLength?: number;
|
|
220
|
+
/** Pattern to match for validation */
|
|
221
|
+
pattern?: RegExp;
|
|
222
|
+
/** Custom validation function */
|
|
223
|
+
validator?: ValidatorFunction<T>;
|
|
224
|
+
/** Whether to show validation messages inline */
|
|
225
|
+
showValidationMessage?: boolean;
|
|
226
|
+
}
|