mtrl 0.2.5 → 0.2.7
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/index.ts +18 -0
- package/package.json +1 -1
- package/src/components/badge/_styles.scss +123 -115
- package/src/components/badge/api.ts +57 -59
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +65 -11
- package/src/components/badge/constants.ts +22 -12
- package/src/components/badge/features.ts +44 -40
- package/src/components/badge/types.ts +42 -30
- package/src/components/bottom-app-bar/_styles.scss +103 -0
- package/src/components/bottom-app-bar/bottom-app-bar.ts +196 -0
- package/src/components/bottom-app-bar/config.ts +73 -0
- package/src/components/bottom-app-bar/index.ts +11 -0
- package/src/components/bottom-app-bar/types.ts +108 -0
- package/src/components/button/_styles.scss +0 -66
- package/src/components/button/api.ts +5 -0
- package/src/components/button/button.ts +0 -2
- package/src/components/button/config.ts +5 -0
- package/src/components/button/constants.ts +0 -6
- package/src/components/button/index.ts +2 -2
- package/src/components/button/types.ts +7 -7
- package/src/components/card/_styles.scss +67 -25
- package/src/components/card/api.ts +54 -3
- package/src/components/card/card.ts +25 -6
- package/src/components/card/config.ts +189 -22
- package/src/components/card/constants.ts +20 -19
- package/src/components/card/content.ts +299 -2
- package/src/components/card/features.ts +158 -4
- package/src/components/card/index.ts +31 -9
- package/src/components/card/types.ts +166 -15
- package/src/components/checkbox/_styles.scss +0 -2
- package/src/components/chip/chip.ts +1 -9
- package/src/components/chip/constants.ts +0 -10
- package/src/components/chip/index.ts +1 -1
- package/src/components/chip/types.ts +1 -4
- package/src/components/datepicker/_styles.scss +358 -0
- package/src/components/datepicker/api.ts +272 -0
- package/src/components/datepicker/config.ts +144 -0
- package/src/components/datepicker/constants.ts +98 -0
- package/src/components/datepicker/datepicker.ts +346 -0
- package/src/components/datepicker/index.ts +9 -0
- package/src/components/datepicker/render.ts +452 -0
- package/src/components/datepicker/types.ts +268 -0
- package/src/components/datepicker/utils.ts +290 -0
- package/src/components/dialog/_styles.scss +174 -128
- package/src/components/dialog/api.ts +48 -13
- package/src/components/dialog/config.ts +9 -5
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +290 -130
- package/src/components/dialog/types.ts +7 -4
- package/src/components/divider/_styles.scss +57 -0
- package/src/components/divider/config.ts +81 -0
- package/src/components/divider/divider.ts +37 -0
- package/src/components/divider/features.ts +207 -0
- package/src/components/divider/index.ts +5 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/_styles.scss +267 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +108 -0
- package/src/components/extended-fab/constants.ts +36 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +4 -0
- package/src/components/extended-fab/types.ts +287 -0
- package/src/components/fab/_styles.scss +225 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +94 -0
- package/src/components/fab/constants.ts +41 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +4 -0
- package/src/components/fab/types.ts +234 -0
- package/src/components/navigation/_styles.scss +1 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/features/items.ts +280 -0
- package/src/components/navigation/nav-item.ts +72 -23
- package/src/components/navigation/navigation.ts +54 -2
- package/src/components/navigation/types.ts +210 -188
- package/src/components/progress/_styles.scss +0 -65
- package/src/components/progress/config.ts +1 -2
- package/src/components/progress/constants.ts +0 -14
- package/src/components/progress/index.ts +1 -1
- package/src/components/progress/progress.ts +1 -4
- package/src/components/progress/types.ts +1 -4
- package/src/components/radios/_styles.scss +0 -45
- package/src/components/radios/api.ts +85 -60
- package/src/components/radios/config.ts +1 -2
- package/src/components/radios/constants.ts +0 -9
- package/src/components/radios/index.ts +1 -1
- package/src/components/radios/radio.ts +34 -11
- package/src/components/radios/radios.ts +2 -1
- package/src/components/radios/types.ts +1 -7
- package/src/components/search/_styles.scss +306 -0
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +87 -0
- package/src/components/search/constants.ts +21 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +718 -0
- package/src/components/search/features/states.ts +165 -0
- package/src/components/search/features/structure.ts +198 -0
- package/src/components/search/index.ts +10 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +163 -0
- package/src/components/segmented-button/_styles.scss +117 -0
- package/src/components/segmented-button/config.ts +67 -0
- package/src/components/segmented-button/constants.ts +42 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +155 -0
- package/src/components/segmented-button/segmented-button.ts +250 -0
- package/src/components/segmented-button/types.ts +219 -0
- package/src/components/slider/_styles.scss +221 -168
- package/src/components/slider/accessibility.md +59 -0
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -49
- package/src/components/slider/features/handlers.ts +495 -0
- package/src/components/slider/features/index.ts +1 -2
- package/src/components/slider/features/slider.ts +66 -84
- package/src/components/slider/features/states.ts +195 -0
- package/src/components/slider/features/structure.ts +141 -184
- package/src/components/slider/features/ui.ts +150 -201
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +39 -24
- package/src/components/switch/_styles.scss +0 -2
- package/src/components/tabs/_styles.scss +346 -154
- package/src/components/tabs/api.ts +178 -400
- package/src/components/tabs/config.ts +46 -52
- package/src/components/tabs/constants.ts +85 -8
- package/src/components/tabs/features.ts +403 -0
- package/src/components/tabs/index.ts +60 -3
- package/src/components/tabs/indicator.ts +285 -0
- package/src/components/tabs/responsive.ts +144 -0
- package/src/components/tabs/scroll-indicators.ts +149 -0
- package/src/components/tabs/state.ts +186 -0
- package/src/components/tabs/tab-api.ts +258 -0
- package/src/components/tabs/tab.ts +255 -0
- package/src/components/tabs/tabs.ts +50 -31
- package/src/components/tabs/types.ts +332 -128
- package/src/components/tabs/utils.ts +107 -0
- package/src/components/textfield/_styles.scss +0 -98
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/constants.ts +0 -14
- package/src/components/textfield/index.ts +2 -2
- package/src/components/textfield/textfield.ts +0 -2
- package/src/components/textfield/types.ts +1 -4
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/_styles.scss +451 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +130 -0
- package/src/components/timepicker/constants.ts +138 -0
- package/src/components/timepicker/index.ts +8 -0
- package/src/components/timepicker/render.ts +613 -0
- package/src/components/timepicker/timepicker.ts +117 -0
- package/src/components/timepicker/types.ts +336 -0
- package/src/components/timepicker/utils.ts +241 -0
- package/src/components/top-app-bar/_styles.scss +225 -0
- package/src/components/top-app-bar/config.ts +83 -0
- package/src/components/top-app-bar/index.ts +11 -0
- package/src/components/top-app-bar/top-app-bar.ts +316 -0
- package/src/components/top-app-bar/types.ts +140 -0
- package/src/core/build/_ripple.scss +6 -6
- package/src/core/build/ripple.ts +72 -95
- package/src/core/compose/component.ts +1 -1
- package/src/core/compose/features/badge.ts +79 -0
- package/src/core/compose/features/icon.ts +3 -1
- package/src/core/compose/features/index.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +26 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +115 -3
- package/src/styles/themes/_autumn.scss +21 -0
- package/src/styles/themes/_base-theme.scss +61 -0
- package/src/styles/themes/_baseline.scss +58 -0
- package/src/styles/themes/_bluekhaki.scss +125 -0
- package/src/styles/themes/_brownbeige.scss +125 -0
- package/src/styles/themes/_browngreen.scss +125 -0
- package/src/styles/themes/_forest.scss +6 -0
- package/src/styles/themes/_greenbeige.scss +125 -0
- package/src/styles/themes/_material.scss +125 -0
- package/src/styles/themes/_ocean.scss +6 -0
- package/src/styles/themes/_sageivory.scss +125 -0
- package/src/styles/themes/_spring.scss +6 -0
- package/src/styles/themes/_summer.scss +5 -0
- package/src/styles/themes/_sunset.scss +5 -0
- package/src/styles/themes/_tealcaramel.scss +125 -0
- package/src/styles/themes/_winter.scss +6 -0
- package/src/components/card/actions.ts +0 -48
- package/src/components/card/header.ts +0 -88
- package/src/components/card/media.ts +0 -52
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -43
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -261
- package/src/components/slider/features/keyboard.ts +0 -112
- package/src/core/collection/adapters/mongodb.js +0 -232
|
@@ -1,48 +1,67 @@
|
|
|
1
1
|
// src/components/tabs/tabs.ts
|
|
2
|
-
import { PREFIX } from '../../core/config';
|
|
3
2
|
import { pipe } from '../../core/compose';
|
|
4
|
-
import { createBase
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
3
|
+
import { createBase } from '../../core/compose/component';
|
|
4
|
+
import { withEvents, withLifecycle } from '../../core/compose/features';
|
|
5
|
+
import { withAPI, getApiConfig } from './api';
|
|
6
|
+
import {
|
|
7
|
+
withTabsManagement,
|
|
8
|
+
withScrollable,
|
|
9
|
+
withDivider,
|
|
10
|
+
withIndicator
|
|
11
|
+
} from './features';
|
|
12
|
+
import { createTabsConfig, getTabsElementConfig } from './config';
|
|
13
|
+
import { TabsConfig, TabsComponent } from './types';
|
|
14
|
+
import { addTabStateStyles } from './state';
|
|
15
|
+
import { setupKeyboardNavigation } from './utils';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
* Creates a new Tabs component
|
|
18
|
+
* Creates a new Tabs component following MD3 guidelines
|
|
18
19
|
* @param {TabsConfig} config - Tabs configuration object
|
|
19
20
|
* @returns {TabsComponent} Tabs component instance
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Create basic tabs with three items
|
|
24
|
+
* const tabs = createTabs({
|
|
25
|
+
* tabs: [
|
|
26
|
+
* { text: 'Home', value: 'home', state: 'active' },
|
|
27
|
+
* { text: 'Products', value: 'products' },
|
|
28
|
+
* { text: 'About', value: 'about' }
|
|
29
|
+
* ]
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Add tabs to DOM
|
|
33
|
+
* document.body.appendChild(tabs.element);
|
|
34
|
+
*
|
|
35
|
+
* // Listen for tab changes
|
|
36
|
+
* tabs.on('change', (e) => {
|
|
37
|
+
* console.log(`Active tab: ${e.value}`);
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
20
40
|
*/
|
|
21
|
-
const createTabs = (config: TabsConfig = {}) => {
|
|
22
|
-
const baseConfig =
|
|
41
|
+
const createTabs = (config: TabsConfig = {}): TabsComponent => {
|
|
42
|
+
const baseConfig = createTabsConfig(config);
|
|
43
|
+
|
|
44
|
+
// Add ripple styles for state transitions
|
|
45
|
+
addTabStateStyles();
|
|
23
46
|
|
|
24
47
|
try {
|
|
25
|
-
|
|
48
|
+
// Build the tabs component with all features
|
|
49
|
+
const component = pipe(
|
|
26
50
|
createBase,
|
|
27
51
|
withEvents(),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
52
|
+
getTabsElementConfig(baseConfig),
|
|
53
|
+
withScrollable(baseConfig),
|
|
54
|
+
withTabsManagement(baseConfig),
|
|
55
|
+
withDivider(baseConfig),
|
|
56
|
+
withIndicator(baseConfig), // Add indicator feature
|
|
31
57
|
withLifecycle(),
|
|
32
58
|
comp => withAPI(getApiConfig(comp))(comp)
|
|
33
59
|
)(baseConfig);
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Set active tab if specified
|
|
41
|
-
if (baseConfig.activeIndex !== undefined) {
|
|
42
|
-
tabs.setActiveTab(baseConfig.activeIndex);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return tabs;
|
|
60
|
+
|
|
61
|
+
// Set up keyboard navigation
|
|
62
|
+
setupKeyboardNavigation(component);
|
|
63
|
+
|
|
64
|
+
return component;
|
|
46
65
|
} catch (error) {
|
|
47
66
|
console.error('Tabs creation error:', error);
|
|
48
67
|
throw new Error(`Failed to create tabs: ${(error as Error).message}`);
|
|
@@ -1,36 +1,148 @@
|
|
|
1
1
|
// src/components/tabs/types.ts
|
|
2
|
-
import { TABS_VARIANTS } from './constants';
|
|
2
|
+
import { TABS_VARIANTS, TAB_STATES, TAB_LAYOUT } from './constants';
|
|
3
|
+
import { BadgeComponent } from '../badge/types';
|
|
4
|
+
import { TabIndicator } from './indicator';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Configuration for the tab indicator
|
|
6
8
|
* @category Components
|
|
7
9
|
*/
|
|
8
|
-
export interface
|
|
10
|
+
export interface IndicatorConfig {
|
|
11
|
+
/** Height of the indicator in pixels */
|
|
12
|
+
height?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Width strategy for the indicator
|
|
15
|
+
* - 'fixed': Uses a fixed width defined by fixedWidth
|
|
16
|
+
* - 'dynamic': Uses half the tab width
|
|
17
|
+
* - 'content': Uses the text content width
|
|
18
|
+
* - 'auto': Adapts based on variant (primary: text width, secondary: full tab width)
|
|
19
|
+
*/
|
|
20
|
+
widthStrategy?: 'fixed' | 'dynamic' | 'content' | 'auto';
|
|
21
|
+
/** Fixed width in pixels (when using fixed strategy) */
|
|
22
|
+
fixedWidth?: number;
|
|
23
|
+
/** Animation duration in milliseconds */
|
|
24
|
+
animationDuration?: number;
|
|
25
|
+
/** Animation timing function */
|
|
26
|
+
animationTiming?: string;
|
|
27
|
+
/** Custom color for the indicator */
|
|
28
|
+
color?: string;
|
|
29
|
+
/** Tab variant (primary or secondary) */
|
|
30
|
+
variant?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Tab change event data interface
|
|
35
|
+
* @category Events
|
|
36
|
+
*/
|
|
37
|
+
export interface TabChangeEventData {
|
|
9
38
|
/**
|
|
10
|
-
*
|
|
39
|
+
* The tab component that was activated
|
|
11
40
|
*/
|
|
12
|
-
|
|
41
|
+
tab: TabComponent;
|
|
13
42
|
|
|
14
43
|
/**
|
|
15
|
-
*
|
|
44
|
+
* The value of the activated tab
|
|
16
45
|
*/
|
|
17
|
-
|
|
46
|
+
value: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Configuration interface for a single Tab
|
|
51
|
+
* @category Components
|
|
52
|
+
*/
|
|
53
|
+
export interface TabConfig {
|
|
54
|
+
/**
|
|
55
|
+
* Tab state that determines if it's the active destination
|
|
56
|
+
* @default 'inactive'
|
|
57
|
+
*/
|
|
58
|
+
state?: keyof typeof TAB_STATES | string;
|
|
18
59
|
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
60
|
+
/**
|
|
61
|
+
* Whether the tab is initially disabled
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Initial tab text content (label)
|
|
68
|
+
* @example 'Home'
|
|
69
|
+
*/
|
|
70
|
+
text?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Initial tab icon HTML content
|
|
74
|
+
* @example '<svg>...</svg>'
|
|
21
75
|
*/
|
|
22
76
|
icon?: string;
|
|
23
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Badge text or value to display (if applicable)
|
|
80
|
+
* @example '5'
|
|
81
|
+
*/
|
|
82
|
+
badge?: string | number;
|
|
83
|
+
|
|
24
84
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
85
|
+
* Badge configuration object
|
|
86
|
+
* Pass additional options for the badge component
|
|
27
87
|
*/
|
|
28
|
-
|
|
88
|
+
badgeConfig?: {
|
|
89
|
+
variant?: string;
|
|
90
|
+
color?: string;
|
|
91
|
+
size?: string;
|
|
92
|
+
position?: string;
|
|
93
|
+
max?: number;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Icon size in pixels or other CSS units
|
|
98
|
+
* @default '24px'
|
|
99
|
+
*/
|
|
100
|
+
iconSize?: string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Additional CSS classes to add to the tab
|
|
104
|
+
* @example 'home-tab main-navigation'
|
|
105
|
+
*/
|
|
106
|
+
class?: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Tab value attribute for identifying the selected tab
|
|
110
|
+
*/
|
|
111
|
+
value?: string;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Whether to enable ripple effect
|
|
115
|
+
* @default true
|
|
116
|
+
*/
|
|
117
|
+
ripple?: boolean;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Component prefix for class names
|
|
121
|
+
* @default 'mtrl'
|
|
122
|
+
*/
|
|
123
|
+
prefix?: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Component name used in class generation
|
|
127
|
+
*/
|
|
128
|
+
componentName?: string;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Ripple effect configuration
|
|
132
|
+
*/
|
|
133
|
+
rippleConfig?: {
|
|
134
|
+
/** Duration of the ripple animation in milliseconds */
|
|
135
|
+
duration?: number;
|
|
136
|
+
/** Timing function for the ripple animation */
|
|
137
|
+
timing?: string;
|
|
138
|
+
/** Opacity values for ripple start and end [start, end] */
|
|
139
|
+
opacity?: [string, string];
|
|
140
|
+
};
|
|
29
141
|
|
|
30
142
|
/**
|
|
31
|
-
*
|
|
143
|
+
* Variant of the tab
|
|
32
144
|
*/
|
|
33
|
-
|
|
145
|
+
variant?: string;
|
|
34
146
|
}
|
|
35
147
|
|
|
36
148
|
/**
|
|
@@ -39,209 +151,301 @@ export interface TabItem {
|
|
|
39
151
|
*/
|
|
40
152
|
export interface TabsConfig {
|
|
41
153
|
/**
|
|
42
|
-
* Tabs variant
|
|
154
|
+
* Tabs variant (primary or secondary)
|
|
43
155
|
* @default 'primary'
|
|
44
156
|
*/
|
|
45
157
|
variant?: keyof typeof TABS_VARIANTS | string;
|
|
46
158
|
|
|
47
159
|
/**
|
|
48
|
-
* Initial
|
|
160
|
+
* Initial tabs to create
|
|
49
161
|
*/
|
|
50
|
-
|
|
162
|
+
tabs?: TabConfig[];
|
|
51
163
|
|
|
52
164
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @default
|
|
165
|
+
* Whether to show the divider
|
|
166
|
+
* @default true
|
|
55
167
|
*/
|
|
56
|
-
|
|
168
|
+
showDivider?: boolean;
|
|
57
169
|
|
|
58
170
|
/**
|
|
59
|
-
* Whether
|
|
60
|
-
* @default
|
|
171
|
+
* Whether to enable horizontal scrolling
|
|
172
|
+
* @default true
|
|
61
173
|
*/
|
|
62
|
-
|
|
174
|
+
scrollable?: boolean;
|
|
63
175
|
|
|
64
176
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @default true
|
|
177
|
+
* Additional CSS classes for the container
|
|
67
178
|
*/
|
|
68
|
-
|
|
179
|
+
class?: string;
|
|
69
180
|
|
|
70
181
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @default
|
|
182
|
+
* Component prefix for class names
|
|
183
|
+
* @default 'mtrl'
|
|
73
184
|
*/
|
|
74
|
-
|
|
185
|
+
prefix?: string;
|
|
75
186
|
|
|
76
187
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @default true
|
|
188
|
+
* Event handlers configuration
|
|
79
189
|
*/
|
|
80
|
-
|
|
190
|
+
on?: {
|
|
191
|
+
/**
|
|
192
|
+
* Tab change event handler
|
|
193
|
+
*/
|
|
194
|
+
change?: (event: TabChangeEventData) => void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Event handlers for other events
|
|
198
|
+
*/
|
|
199
|
+
[key: string]: Function | undefined;
|
|
200
|
+
};
|
|
81
201
|
|
|
82
202
|
/**
|
|
83
|
-
*
|
|
203
|
+
* Tab indicator configuration
|
|
84
204
|
*/
|
|
85
|
-
|
|
205
|
+
indicator?: IndicatorConfig;
|
|
86
206
|
|
|
87
207
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
208
|
+
* Tab indicator height in pixels
|
|
209
|
+
* @deprecated Use indicator.height instead
|
|
90
210
|
*/
|
|
91
|
-
|
|
211
|
+
indicatorHeight?: number;
|
|
92
212
|
|
|
93
213
|
/**
|
|
94
|
-
*
|
|
214
|
+
* Tab indicator width strategy
|
|
215
|
+
* @deprecated Use indicator.widthStrategy instead
|
|
95
216
|
*/
|
|
96
|
-
|
|
217
|
+
indicatorWidthStrategy?: 'fixed' | 'dynamic' | 'content';
|
|
97
218
|
}
|
|
98
219
|
|
|
99
220
|
/**
|
|
100
|
-
*
|
|
221
|
+
* Icon API interface for managing tab icons
|
|
101
222
|
* @category Components
|
|
102
223
|
*/
|
|
103
|
-
export interface
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/** The tab indicator DOM element */
|
|
111
|
-
indicatorElement: HTMLElement;
|
|
112
|
-
|
|
113
|
-
/** API for managing disabled state */
|
|
114
|
-
disabled: {
|
|
115
|
-
/** Enables the tabs component */
|
|
116
|
-
enable: () => void;
|
|
117
|
-
/** Disables the tabs component */
|
|
118
|
-
disable: () => void;
|
|
119
|
-
/** Checks if the tabs component is disabled */
|
|
120
|
-
isDisabled: () => boolean;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/** API for managing component lifecycle */
|
|
124
|
-
lifecycle: {
|
|
125
|
-
/** Destroys the component and cleans up resources */
|
|
126
|
-
destroy: () => void;
|
|
127
|
-
};
|
|
224
|
+
export interface IconAPI {
|
|
225
|
+
/**
|
|
226
|
+
* Sets the icon HTML content
|
|
227
|
+
* @param html - HTML string for the icon
|
|
228
|
+
* @returns The icon API for chaining
|
|
229
|
+
*/
|
|
230
|
+
setIcon: (html: string) => IconAPI;
|
|
128
231
|
|
|
129
232
|
/**
|
|
130
|
-
* Gets
|
|
131
|
-
* @
|
|
132
|
-
* @returns Prefixed class name
|
|
233
|
+
* Gets the current icon HTML content
|
|
234
|
+
* @returns HTML string for the icon
|
|
133
235
|
*/
|
|
134
|
-
|
|
236
|
+
getIcon: () => string;
|
|
135
237
|
|
|
136
238
|
/**
|
|
137
|
-
*
|
|
138
|
-
* @returns The
|
|
239
|
+
* Gets the icon DOM element
|
|
240
|
+
* @returns The icon element or null if not present
|
|
139
241
|
*/
|
|
140
|
-
|
|
242
|
+
getElement: () => HTMLElement | null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Text API interface for managing tab text
|
|
247
|
+
* @category Components
|
|
248
|
+
*/
|
|
249
|
+
export interface TextAPI {
|
|
250
|
+
/**
|
|
251
|
+
* Sets the text content
|
|
252
|
+
* @param content - Text content
|
|
253
|
+
* @returns The text API for chaining
|
|
254
|
+
*/
|
|
255
|
+
setText: (content: string) => TextAPI;
|
|
141
256
|
|
|
142
257
|
/**
|
|
143
|
-
*
|
|
144
|
-
* @returns
|
|
258
|
+
* Gets the current text content
|
|
259
|
+
* @returns Tab text content
|
|
145
260
|
*/
|
|
146
|
-
|
|
261
|
+
getText: () => string;
|
|
147
262
|
|
|
148
263
|
/**
|
|
149
|
-
* Gets
|
|
150
|
-
* @returns
|
|
264
|
+
* Gets the text DOM element
|
|
265
|
+
* @returns The text element or null if not present
|
|
151
266
|
*/
|
|
152
|
-
|
|
267
|
+
getElement: () => HTMLElement | null;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Tab component interface
|
|
272
|
+
* @category Components
|
|
273
|
+
*/
|
|
274
|
+
export interface TabComponent {
|
|
275
|
+
/** The tab's DOM element */
|
|
276
|
+
element: HTMLElement;
|
|
277
|
+
|
|
278
|
+
/** The tab's badge component (if any) */
|
|
279
|
+
badge?: BadgeComponent;
|
|
280
|
+
|
|
281
|
+
/** Gets a class name with the component's prefix */
|
|
282
|
+
getClass: (name: string) => string;
|
|
283
|
+
|
|
284
|
+
/** Gets the tab's value attribute */
|
|
285
|
+
getValue: () => string;
|
|
286
|
+
|
|
287
|
+
/** Sets the tab's value attribute */
|
|
288
|
+
setValue: (value: string) => TabComponent;
|
|
289
|
+
|
|
290
|
+
/** Activates the tab (sets active state) */
|
|
291
|
+
activate: () => TabComponent;
|
|
292
|
+
|
|
293
|
+
/** Deactivates the tab (sets inactive state) */
|
|
294
|
+
deactivate: () => TabComponent;
|
|
295
|
+
|
|
296
|
+
/** Checks if the tab is active */
|
|
297
|
+
isActive: () => boolean;
|
|
298
|
+
|
|
299
|
+
/** Enables the tab (removes disabled attribute) */
|
|
300
|
+
enable: () => TabComponent;
|
|
301
|
+
|
|
302
|
+
/** Disables the tab (adds disabled attribute) */
|
|
303
|
+
disable: () => TabComponent;
|
|
304
|
+
|
|
305
|
+
/** Sets the tab's text content */
|
|
306
|
+
setText: (content: string) => TabComponent;
|
|
307
|
+
|
|
308
|
+
/** Gets the tab's text content */
|
|
309
|
+
getText: () => string;
|
|
310
|
+
|
|
311
|
+
/** Sets the tab's icon */
|
|
312
|
+
setIcon: (icon: string) => TabComponent;
|
|
313
|
+
|
|
314
|
+
/** Gets the tab's icon HTML content */
|
|
315
|
+
getIcon: () => string;
|
|
153
316
|
|
|
317
|
+
/** Sets the tab's badge */
|
|
318
|
+
setBadge: (content: string | number) => TabComponent;
|
|
319
|
+
|
|
320
|
+
/** Gets the tab's badge content */
|
|
321
|
+
getBadge: () => string;
|
|
322
|
+
|
|
323
|
+
/** Shows the tab's badge */
|
|
324
|
+
showBadge: () => TabComponent;
|
|
325
|
+
|
|
326
|
+
/** Hides the tab's badge */
|
|
327
|
+
hideBadge: () => TabComponent;
|
|
328
|
+
|
|
329
|
+
/** Gets the badge component instance */
|
|
330
|
+
getBadgeComponent: () => BadgeComponent | undefined;
|
|
331
|
+
|
|
332
|
+
/** Updates the tab's layout style based on content */
|
|
333
|
+
updateLayoutStyle: () => void;
|
|
334
|
+
|
|
335
|
+
/** Adds an event listener to the tab */
|
|
336
|
+
on: (event: string, handler: Function) => TabComponent;
|
|
337
|
+
|
|
338
|
+
/** Removes an event listener from the tab */
|
|
339
|
+
off: (event: string, handler: Function) => TabComponent;
|
|
340
|
+
|
|
341
|
+
/** Destroys the tab component and cleans up resources */
|
|
342
|
+
destroy: () => void;
|
|
343
|
+
|
|
344
|
+
/** API for managing disabled state */
|
|
345
|
+
disabled?: {
|
|
346
|
+
enable: () => void;
|
|
347
|
+
disable: () => void;
|
|
348
|
+
isDisabled: () => boolean;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/** API for managing component lifecycle */
|
|
352
|
+
lifecycle?: {
|
|
353
|
+
destroy: () => void;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Tabs component interface
|
|
359
|
+
* @category Components
|
|
360
|
+
*/
|
|
361
|
+
export interface TabsComponent {
|
|
154
362
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param items - Array of tab items
|
|
157
|
-
* @returns The tabs component for chaining
|
|
363
|
+
* Container element
|
|
158
364
|
*/
|
|
159
|
-
|
|
365
|
+
element: HTMLElement;
|
|
160
366
|
|
|
161
367
|
/**
|
|
162
|
-
*
|
|
163
|
-
* @param
|
|
164
|
-
* @
|
|
165
|
-
* @returns The tabs component for chaining
|
|
368
|
+
* Creates and adds a new tab to the tabs component
|
|
369
|
+
* @param config - Tab configuration
|
|
370
|
+
* @returns The created tab component
|
|
166
371
|
*/
|
|
167
|
-
addTab: (
|
|
372
|
+
addTab: (config: TabConfig) => TabComponent;
|
|
168
373
|
|
|
169
374
|
/**
|
|
170
|
-
*
|
|
171
|
-
* @param
|
|
172
|
-
* @returns
|
|
375
|
+
* Adds a pre-created tab to the tabs component
|
|
376
|
+
* @param tab - Tab component to add
|
|
377
|
+
* @returns Tabs component for chaining
|
|
173
378
|
*/
|
|
174
|
-
|
|
379
|
+
add: (tab: TabComponent) => TabsComponent;
|
|
175
380
|
|
|
176
381
|
/**
|
|
177
|
-
* Gets
|
|
178
|
-
* @returns
|
|
382
|
+
* Gets all tabs in the container
|
|
383
|
+
* @returns Array of tab components
|
|
179
384
|
*/
|
|
180
|
-
|
|
385
|
+
getTabs: () => TabComponent[];
|
|
181
386
|
|
|
182
387
|
/**
|
|
183
|
-
* Gets the
|
|
184
|
-
* @returns
|
|
388
|
+
* Gets the active tab
|
|
389
|
+
* @returns Active tab or null if none
|
|
185
390
|
*/
|
|
186
|
-
|
|
391
|
+
getActiveTab: () => TabComponent | null;
|
|
187
392
|
|
|
188
393
|
/**
|
|
189
|
-
*
|
|
190
|
-
* @
|
|
191
|
-
* @returns The tabs component for chaining
|
|
394
|
+
* Gets the indicator component
|
|
395
|
+
* @returns Tab indicator component
|
|
192
396
|
*/
|
|
193
|
-
|
|
397
|
+
getIndicator?: () => TabIndicator;
|
|
194
398
|
|
|
195
399
|
/**
|
|
196
|
-
* Sets
|
|
197
|
-
* @param
|
|
198
|
-
* @returns
|
|
400
|
+
* Sets a tab as active
|
|
401
|
+
* @param tabOrValue - Tab component or tab value
|
|
402
|
+
* @returns Tabs component for chaining
|
|
199
403
|
*/
|
|
200
|
-
|
|
404
|
+
setActiveTab: (tabOrValue: TabComponent | string) => TabsComponent;
|
|
201
405
|
|
|
202
406
|
/**
|
|
203
|
-
*
|
|
407
|
+
* Removes a tab from the container
|
|
408
|
+
* @param tabOrValue - Tab component or tab value
|
|
409
|
+
* @returns Tabs component for chaining
|
|
204
410
|
*/
|
|
205
|
-
|
|
411
|
+
removeTab: (tabOrValue: TabComponent | string) => TabsComponent;
|
|
206
412
|
|
|
207
413
|
/**
|
|
208
|
-
* Adds an event listener
|
|
209
|
-
* @param event - Event name
|
|
210
|
-
* @param handler - Event handler
|
|
211
|
-
* @returns
|
|
414
|
+
* Adds an event listener
|
|
415
|
+
* @param event - Event name
|
|
416
|
+
* @param handler - Event handler
|
|
417
|
+
* @returns Tabs component for chaining
|
|
212
418
|
*/
|
|
213
419
|
on: (event: string, handler: Function) => TabsComponent;
|
|
214
420
|
|
|
215
421
|
/**
|
|
216
|
-
* Removes an event listener
|
|
422
|
+
* Removes an event listener
|
|
217
423
|
* @param event - Event name
|
|
218
|
-
* @param handler - Event handler
|
|
219
|
-
* @returns
|
|
424
|
+
* @param handler - Event handler
|
|
425
|
+
* @returns Tabs component for chaining
|
|
220
426
|
*/
|
|
221
427
|
off: (event: string, handler: Function) => TabsComponent;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Event data for tab change events
|
|
226
|
-
*/
|
|
227
|
-
export interface TabChangeEventData {
|
|
428
|
+
|
|
228
429
|
/**
|
|
229
|
-
*
|
|
430
|
+
* Emit an event
|
|
431
|
+
* @param event - Event name
|
|
432
|
+
* @param data - Event data
|
|
433
|
+
* @returns Tabs component for chaining
|
|
230
434
|
*/
|
|
231
|
-
|
|
435
|
+
emit?: (event: string, data: any) => TabsComponent;
|
|
232
436
|
|
|
233
437
|
/**
|
|
234
|
-
*
|
|
438
|
+
* Destroys the tabs component and all tabs
|
|
235
439
|
*/
|
|
236
|
-
|
|
440
|
+
destroy: () => void;
|
|
237
441
|
|
|
238
442
|
/**
|
|
239
|
-
*
|
|
443
|
+
* Tab click event handler
|
|
240
444
|
*/
|
|
241
|
-
|
|
445
|
+
handleTabClick: (event: any, tab: TabComponent) => void;
|
|
242
446
|
|
|
243
447
|
/**
|
|
244
|
-
*
|
|
448
|
+
* Scroll container for scrollable tabs
|
|
245
449
|
*/
|
|
246
|
-
|
|
450
|
+
scrollContainer?: HTMLElement;
|
|
247
451
|
}
|