mtrl 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.typedocignore +11 -0
- package/DOCS.md +153 -0
- package/index.ts +18 -3
- package/package.json +7 -2
- package/src/components/badge/_styles.scss +174 -0
- package/src/components/badge/api.ts +292 -0
- package/src/components/badge/badge.ts +52 -0
- package/src/components/badge/config.ts +68 -0
- package/src/components/badge/constants.ts +30 -0
- package/src/components/badge/features.ts +185 -0
- package/src/components/badge/index.ts +4 -0
- package/src/components/badge/types.ts +105 -0
- package/src/components/button/types.ts +174 -29
- package/src/components/card/constants.ts +14 -0
- package/src/components/carousel/_styles.scss +645 -0
- package/src/components/carousel/api.ts +147 -0
- package/src/components/carousel/carousel.ts +178 -0
- package/src/components/carousel/config.ts +91 -0
- package/src/components/carousel/constants.ts +95 -0
- package/src/components/carousel/features/drag.ts +388 -0
- package/src/components/carousel/features/index.ts +8 -0
- package/src/components/carousel/features/slides.ts +682 -0
- package/src/components/carousel/index.ts +38 -0
- package/src/components/carousel/types.ts +327 -0
- package/src/components/chip/_styles.scss +83 -140
- package/src/components/chip/api.ts +231 -102
- package/src/components/chip/chip.ts +356 -44
- package/src/components/chip/constants.ts +3 -3
- package/src/components/chip/index.ts +3 -3
- package/src/components/dialog/_styles.scss +213 -0
- package/src/components/dialog/api.ts +283 -0
- package/src/components/dialog/config.ts +113 -0
- package/src/components/dialog/constants.ts +32 -0
- package/src/components/dialog/dialog.ts +56 -0
- package/src/components/dialog/features.ts +713 -0
- package/src/components/dialog/index.ts +15 -0
- package/src/components/dialog/types.ts +221 -0
- package/src/components/progress/_styles.scss +13 -1
- package/src/components/progress/api.ts +2 -2
- package/src/components/progress/progress.ts +2 -2
- package/src/components/progress/types.ts +3 -0
- package/src/components/radios/_styles.scss +232 -0
- package/src/components/radios/api.ts +100 -0
- package/src/components/radios/config.ts +60 -0
- package/src/components/radios/constants.ts +28 -0
- package/src/components/radios/index.ts +4 -0
- package/src/components/radios/radio.ts +269 -0
- package/src/components/radios/radios.ts +42 -0
- package/src/components/radios/types.ts +232 -0
- package/src/components/sheet/_styles.scss +236 -0
- package/src/components/sheet/api.ts +96 -0
- package/src/components/sheet/config.ts +66 -0
- package/src/components/sheet/constants.ts +20 -0
- package/src/components/sheet/features/content.ts +51 -0
- package/src/components/sheet/features/gestures.ts +177 -0
- package/src/components/sheet/features/index.ts +6 -0
- package/src/components/sheet/features/position.ts +42 -0
- package/src/components/sheet/features/state.ts +116 -0
- package/src/components/sheet/features/title.ts +86 -0
- package/src/components/sheet/index.ts +4 -0
- package/src/components/sheet/sheet.ts +57 -0
- package/src/components/sheet/types.ts +266 -0
- package/src/components/slider/_styles.scss +518 -0
- package/src/components/slider/api.ts +336 -0
- package/src/components/slider/config.ts +145 -0
- package/src/components/slider/constants.ts +28 -0
- package/src/components/slider/features/appearance.ts +140 -0
- package/src/components/slider/features/disabled.ts +43 -0
- package/src/components/slider/features/events.ts +164 -0
- package/src/components/slider/features/index.ts +5 -0
- package/src/components/slider/features/interactions.ts +256 -0
- package/src/components/slider/features/keyboard.ts +114 -0
- package/src/components/slider/features/slider.ts +336 -0
- package/src/components/slider/features/structure.ts +264 -0
- package/src/components/slider/features/ui.ts +518 -0
- package/src/components/slider/index.ts +9 -0
- package/src/components/slider/slider.ts +58 -0
- package/src/components/slider/types.ts +166 -0
- package/src/components/tabs/_styles.scss +224 -0
- package/src/components/tabs/api.ts +443 -0
- package/src/components/tabs/config.ts +80 -0
- package/src/components/tabs/constants.ts +12 -0
- package/src/components/tabs/index.ts +4 -0
- package/src/components/tabs/tabs.ts +52 -0
- package/src/components/tabs/types.ts +247 -0
- package/src/components/textfield/_styles.scss +97 -4
- package/src/components/tooltip/_styles.scss +241 -0
- package/src/components/tooltip/api.ts +411 -0
- package/src/components/tooltip/config.ts +78 -0
- package/src/components/tooltip/constants.ts +27 -0
- package/src/components/tooltip/index.ts +4 -0
- package/src/components/tooltip/tooltip.ts +60 -0
- package/src/components/tooltip/types.ts +178 -0
- package/src/index.ts +9 -1
- package/src/styles/abstract/_variables.scss +24 -0
- package/tsconfig.json +22 -0
- package/typedoc.json +28 -0
- package/typedoc.simple.json +14 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/components/badge/badge.ts
|
|
2
|
+
import { pipe } from '../../core/compose';
|
|
3
|
+
import { createBase, withElement } from '../../core/compose/component';
|
|
4
|
+
import {
|
|
5
|
+
withEvents,
|
|
6
|
+
withLifecycle
|
|
7
|
+
} from '../../core/compose/features';
|
|
8
|
+
import {
|
|
9
|
+
withVisibility,
|
|
10
|
+
withVariant,
|
|
11
|
+
withColor,
|
|
12
|
+
withSize,
|
|
13
|
+
withPosition,
|
|
14
|
+
withMax,
|
|
15
|
+
withAttachment
|
|
16
|
+
} from './features';
|
|
17
|
+
import { withAPI } from './api';
|
|
18
|
+
import { BadgeConfig, BadgeComponent } from './types';
|
|
19
|
+
import { createBaseConfig, getElementConfig, getApiConfig } from './config';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new Badge component
|
|
23
|
+
* @param {BadgeConfig} config - Badge configuration object
|
|
24
|
+
* @returns {BadgeComponent} Badge component instance
|
|
25
|
+
*/
|
|
26
|
+
const createBadge = (config: BadgeConfig = {}): BadgeComponent => {
|
|
27
|
+
const baseConfig = createBaseConfig(config);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const badge = pipe(
|
|
31
|
+
createBase,
|
|
32
|
+
withEvents(),
|
|
33
|
+
withElement(getElementConfig(baseConfig)),
|
|
34
|
+
withVariant(baseConfig),
|
|
35
|
+
withColor(baseConfig),
|
|
36
|
+
withSize(baseConfig),
|
|
37
|
+
withPosition(baseConfig),
|
|
38
|
+
withMax(baseConfig),
|
|
39
|
+
withVisibility(),
|
|
40
|
+
withAttachment(baseConfig),
|
|
41
|
+
withLifecycle(),
|
|
42
|
+
comp => withAPI(getApiConfig(comp))(comp)
|
|
43
|
+
)(baseConfig);
|
|
44
|
+
|
|
45
|
+
return badge;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Badge creation error:', error);
|
|
48
|
+
throw new Error(`Failed to create badge: ${(error as Error).message}`);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default createBadge;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/components/badge/config.ts
|
|
2
|
+
import {
|
|
3
|
+
createComponentConfig,
|
|
4
|
+
createElementConfig,
|
|
5
|
+
BaseComponentConfig
|
|
6
|
+
} from '../../core/config/component-config';
|
|
7
|
+
import { BadgeConfig } from './types';
|
|
8
|
+
import { BADGE_VARIANTS, BADGE_SIZES, BADGE_COLORS, BADGE_POSITIONS } from './constants';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Default configuration for the Badge component
|
|
12
|
+
*/
|
|
13
|
+
export const defaultConfig: BadgeConfig = {
|
|
14
|
+
variant: BADGE_VARIANTS.STANDARD,
|
|
15
|
+
size: BADGE_SIZES.MEDIUM,
|
|
16
|
+
color: BADGE_COLORS.ERROR,
|
|
17
|
+
position: BADGE_POSITIONS.TOP_RIGHT,
|
|
18
|
+
content: '',
|
|
19
|
+
visible: true,
|
|
20
|
+
standalone: false
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates the base configuration for Badge component
|
|
25
|
+
* @param {BadgeConfig} config - User provided configuration
|
|
26
|
+
* @returns {BadgeConfig} Complete configuration with defaults applied
|
|
27
|
+
*/
|
|
28
|
+
export const createBaseConfig = (config: BadgeConfig = {}): BadgeConfig =>
|
|
29
|
+
createComponentConfig(defaultConfig, config, 'badge') as BadgeConfig;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generates element configuration for the Badge component
|
|
33
|
+
* @param {BadgeConfig} config - Badge configuration
|
|
34
|
+
* @returns {Object} Element configuration object for withElement
|
|
35
|
+
*/
|
|
36
|
+
export const getElementConfig = (config: BadgeConfig) => {
|
|
37
|
+
// Create the attributes object
|
|
38
|
+
const attrs: Record<string, any> = {};
|
|
39
|
+
|
|
40
|
+
// Convert numeric content to string if needed
|
|
41
|
+
const content = config.content !== undefined ? String(config.content) : '';
|
|
42
|
+
|
|
43
|
+
return createElementConfig(config, {
|
|
44
|
+
tag: 'span',
|
|
45
|
+
attrs,
|
|
46
|
+
className: config.class,
|
|
47
|
+
content: config.variant === BADGE_VARIANTS.DOT ? '' : content
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Creates API configuration for the Badge component
|
|
53
|
+
* @param {Object} comp - Component with visibility and lifecycle features
|
|
54
|
+
* @returns {Object} API configuration object
|
|
55
|
+
*/
|
|
56
|
+
export const getApiConfig = (comp) => ({
|
|
57
|
+
visibility: {
|
|
58
|
+
show: () => comp.visibility.show(),
|
|
59
|
+
hide: () => comp.visibility.hide(),
|
|
60
|
+
toggle: (visible?: boolean) => comp.visibility.toggle(visible),
|
|
61
|
+
isVisible: () => comp.visibility.isVisible()
|
|
62
|
+
},
|
|
63
|
+
lifecycle: {
|
|
64
|
+
destroy: () => comp.lifecycle.destroy()
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export default defaultConfig;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/components/badge/constants.ts
|
|
2
|
+
|
|
3
|
+
export const BADGE_VARIANTS = {
|
|
4
|
+
STANDARD: 'standard',
|
|
5
|
+
DOT: 'dot',
|
|
6
|
+
OUTLINED: 'outlined'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const BADGE_SIZES = {
|
|
10
|
+
SMALL: 'small',
|
|
11
|
+
MEDIUM: 'medium',
|
|
12
|
+
LARGE: 'large'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const BADGE_COLORS = {
|
|
16
|
+
PRIMARY: 'primary',
|
|
17
|
+
SECONDARY: 'secondary',
|
|
18
|
+
TERTIARY: 'tertiary',
|
|
19
|
+
ERROR: 'error',
|
|
20
|
+
SUCCESS: 'success',
|
|
21
|
+
WARNING: 'warning',
|
|
22
|
+
INFO: 'info'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const BADGE_POSITIONS = {
|
|
26
|
+
TOP_RIGHT: 'top-right',
|
|
27
|
+
TOP_LEFT: 'top-left',
|
|
28
|
+
BOTTOM_RIGHT: 'bottom-right',
|
|
29
|
+
BOTTOM_LEFT: 'bottom-left'
|
|
30
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// src/components/badge/features.ts
|
|
2
|
+
import { BADGE_VARIANTS, BADGE_SIZES, BADGE_COLORS, BADGE_POSITIONS } from './constants';
|
|
3
|
+
import { BadgeConfig } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Higher-order function that adds visibility control features to a component
|
|
7
|
+
* @returns {Function} Component enhancer with visibility features
|
|
8
|
+
*/
|
|
9
|
+
export const withVisibility = () => component => {
|
|
10
|
+
// Get config values
|
|
11
|
+
const visible = component.config.visible !== false; // Default to true if not specified
|
|
12
|
+
|
|
13
|
+
// Initialize visibility state based on config
|
|
14
|
+
if (!visible) {
|
|
15
|
+
component.element.classList.add(`${component.getClass('badge')}--invisible`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
...component,
|
|
20
|
+
visibility: {
|
|
21
|
+
/**
|
|
22
|
+
* Shows the badge
|
|
23
|
+
*/
|
|
24
|
+
show() {
|
|
25
|
+
component.element.classList.remove(`${component.getClass('badge')}--invisible`);
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Hides the badge
|
|
30
|
+
*/
|
|
31
|
+
hide() {
|
|
32
|
+
component.element.classList.add(`${component.getClass('badge')}--invisible`);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Toggles badge visibility
|
|
37
|
+
* @param {boolean} [visible] - Optional flag to force visibility state
|
|
38
|
+
*/
|
|
39
|
+
toggle(visible?: boolean) {
|
|
40
|
+
if (visible === undefined) {
|
|
41
|
+
component.element.classList.toggle(`${component.getClass('badge')}--invisible`);
|
|
42
|
+
} else if (visible) {
|
|
43
|
+
this.show();
|
|
44
|
+
} else {
|
|
45
|
+
this.hide();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Checks if the badge is visible
|
|
51
|
+
* @returns {boolean} True if badge is visible
|
|
52
|
+
*/
|
|
53
|
+
isVisible() {
|
|
54
|
+
return !component.element.classList.contains(`${component.getClass('badge')}--invisible`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Higher-order function that adds variant features to a badge component
|
|
62
|
+
* @param {BadgeConfig} config - Badge configuration
|
|
63
|
+
* @returns {Function} Component enhancer with variant features
|
|
64
|
+
*/
|
|
65
|
+
export const withVariant = (config: BadgeConfig) => component => {
|
|
66
|
+
// Get variant from config with fallback to default
|
|
67
|
+
const variant = config.variant || BADGE_VARIANTS.STANDARD;
|
|
68
|
+
|
|
69
|
+
// Apply variant class if not standard variant
|
|
70
|
+
if (variant !== BADGE_VARIANTS.STANDARD) {
|
|
71
|
+
component.element.classList.add(`${component.getClass('badge')}--${variant}`);
|
|
72
|
+
|
|
73
|
+
// Clear content if dot variant
|
|
74
|
+
if (variant === BADGE_VARIANTS.DOT) {
|
|
75
|
+
component.element.textContent = '';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return component;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Higher-order function that adds color features to a badge component
|
|
84
|
+
* @param {BadgeConfig} config - Badge configuration
|
|
85
|
+
* @returns {Function} Component enhancer with color features
|
|
86
|
+
*/
|
|
87
|
+
export const withColor = (config: BadgeConfig) => component => {
|
|
88
|
+
// Get color from config with fallback to default
|
|
89
|
+
const color = config.color || BADGE_COLORS.ERROR;
|
|
90
|
+
|
|
91
|
+
// Apply color class
|
|
92
|
+
component.element.classList.add(`${component.getClass('badge')}--${color}`);
|
|
93
|
+
|
|
94
|
+
return component;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Higher-order function that adds size features to a badge component
|
|
99
|
+
* @param {BadgeConfig} config - Badge configuration
|
|
100
|
+
* @returns {Function} Component enhancer with size features
|
|
101
|
+
*/
|
|
102
|
+
export const withSize = (config: BadgeConfig) => component => {
|
|
103
|
+
// Get size from config with fallback to default
|
|
104
|
+
const size = config.size || BADGE_SIZES.MEDIUM;
|
|
105
|
+
|
|
106
|
+
// Apply size class if not medium (default)
|
|
107
|
+
if (size !== BADGE_SIZES.MEDIUM) {
|
|
108
|
+
component.element.classList.add(`${component.getClass('badge')}--${size}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return component;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Higher-order function that adds positioning features to a badge component
|
|
116
|
+
* @param {BadgeConfig} config - Badge configuration
|
|
117
|
+
* @returns {Function} Component enhancer with positioning features
|
|
118
|
+
*/
|
|
119
|
+
export const withPosition = (config: BadgeConfig) => component => {
|
|
120
|
+
// Skip for standalone badges
|
|
121
|
+
if (config.standalone) {
|
|
122
|
+
return component;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Get position from config with fallback to default
|
|
126
|
+
const position = config.position || BADGE_POSITIONS.TOP_RIGHT;
|
|
127
|
+
|
|
128
|
+
// Apply position class and positioned class
|
|
129
|
+
component.element.classList.add(`${component.getClass('badge')}--${position}`);
|
|
130
|
+
component.element.classList.add(`${component.getClass('badge')}--positioned`);
|
|
131
|
+
|
|
132
|
+
return component;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Higher-order function that adds max value features to a badge component
|
|
137
|
+
* @param {BadgeConfig} config - Badge configuration
|
|
138
|
+
* @returns {Function} Component enhancer with max value features
|
|
139
|
+
*/
|
|
140
|
+
export const withMax = (config: BadgeConfig) => component => {
|
|
141
|
+
// Skip if no max is defined
|
|
142
|
+
if (config.max === undefined) {
|
|
143
|
+
return component;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Store max value in config for later use
|
|
147
|
+
component.config.max = config.max;
|
|
148
|
+
|
|
149
|
+
// Apply max formatting if needed
|
|
150
|
+
if (typeof config.content === 'number' && config.content > config.max) {
|
|
151
|
+
component.element.textContent = String(config.max);
|
|
152
|
+
component.element.classList.add(`${component.getClass('badge')}--max`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return component;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Higher-order function that attaches badge to a target element
|
|
160
|
+
* @param {BadgeConfig} config - Badge configuration
|
|
161
|
+
* @returns {Function} Component enhancer with attachment features
|
|
162
|
+
*/
|
|
163
|
+
export const withAttachment = (config: BadgeConfig) => component => {
|
|
164
|
+
// Skip for standalone badges or if no target is provided
|
|
165
|
+
if (config.standalone || !config.target) {
|
|
166
|
+
return component;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Create wrapper to hold the target and badge
|
|
170
|
+
const wrapper = document.createElement('div');
|
|
171
|
+
wrapper.classList.add(component.getClass('badge-wrapper'));
|
|
172
|
+
|
|
173
|
+
// Replace the target with the wrapper
|
|
174
|
+
const parent = config.target.parentNode;
|
|
175
|
+
if (parent) {
|
|
176
|
+
parent.replaceChild(wrapper, config.target);
|
|
177
|
+
wrapper.appendChild(config.target);
|
|
178
|
+
wrapper.appendChild(component.element);
|
|
179
|
+
|
|
180
|
+
// Save the wrapper reference
|
|
181
|
+
component.wrapper = wrapper;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return component;
|
|
185
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/components/badge/types.ts
|
|
2
|
+
import { BADGE_VARIANTS, BADGE_SIZES, BADGE_COLORS, BADGE_POSITIONS } from './constants';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration interface for the Badge component
|
|
6
|
+
*/
|
|
7
|
+
export interface BadgeConfig {
|
|
8
|
+
/** Badge variant (standard, dot, outlined) */
|
|
9
|
+
variant?: keyof typeof BADGE_VARIANTS | BADGE_VARIANTS;
|
|
10
|
+
|
|
11
|
+
/** Badge size (small, medium, large) */
|
|
12
|
+
size?: keyof typeof BADGE_SIZES | BADGE_SIZES;
|
|
13
|
+
|
|
14
|
+
/** Badge color (primary, secondary, tertiary, error, success, warning, info) */
|
|
15
|
+
color?: keyof typeof BADGE_COLORS | BADGE_COLORS;
|
|
16
|
+
|
|
17
|
+
/** Badge position relative to its container (top-right, top-left, bottom-right, bottom-left) */
|
|
18
|
+
position?: keyof typeof BADGE_POSITIONS | BADGE_POSITIONS;
|
|
19
|
+
|
|
20
|
+
/** Text content inside the badge */
|
|
21
|
+
content?: string | number;
|
|
22
|
+
|
|
23
|
+
/** Maximum value to display (shows "{max}+" if content exceeds max) */
|
|
24
|
+
max?: number;
|
|
25
|
+
|
|
26
|
+
/** Whether the badge should be visible */
|
|
27
|
+
visible?: boolean;
|
|
28
|
+
|
|
29
|
+
/** Whether the badge should be standalone (not attached to another element) */
|
|
30
|
+
standalone?: boolean;
|
|
31
|
+
|
|
32
|
+
/** Target element to which badge will be attached */
|
|
33
|
+
target?: HTMLElement;
|
|
34
|
+
|
|
35
|
+
/** Additional CSS classes */
|
|
36
|
+
class?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Badge component interface
|
|
41
|
+
*/
|
|
42
|
+
export interface BadgeComponent {
|
|
43
|
+
/** Badge element */
|
|
44
|
+
element: HTMLElement;
|
|
45
|
+
|
|
46
|
+
/** Badge wrapper element (if badge is attached to target) */
|
|
47
|
+
wrapper?: HTMLElement;
|
|
48
|
+
|
|
49
|
+
/** Sets badge text content */
|
|
50
|
+
setContent: (content: string | number) => BadgeComponent;
|
|
51
|
+
|
|
52
|
+
/** Gets badge text content */
|
|
53
|
+
getContent: () => string;
|
|
54
|
+
|
|
55
|
+
/** Shows the badge */
|
|
56
|
+
show: () => BadgeComponent;
|
|
57
|
+
|
|
58
|
+
/** Hides the badge */
|
|
59
|
+
hide: () => BadgeComponent;
|
|
60
|
+
|
|
61
|
+
/** Toggles badge visibility */
|
|
62
|
+
toggle: (visible?: boolean) => BadgeComponent;
|
|
63
|
+
|
|
64
|
+
/** Checks if the badge is visible */
|
|
65
|
+
isVisible: () => boolean;
|
|
66
|
+
|
|
67
|
+
/** Sets maximum value (after which badge shows max+) */
|
|
68
|
+
setMax: (max: number) => BadgeComponent;
|
|
69
|
+
|
|
70
|
+
/** Sets badge color */
|
|
71
|
+
setColor: (color: keyof typeof BADGE_COLORS | BADGE_COLORS) => BadgeComponent;
|
|
72
|
+
|
|
73
|
+
/** Sets badge variant */
|
|
74
|
+
setVariant: (variant: keyof typeof BADGE_VARIANTS | BADGE_VARIANTS) => BadgeComponent;
|
|
75
|
+
|
|
76
|
+
/** Sets badge size */
|
|
77
|
+
setSize: (size: keyof typeof BADGE_SIZES | BADGE_SIZES) => BadgeComponent;
|
|
78
|
+
|
|
79
|
+
/** Sets badge position */
|
|
80
|
+
setPosition: (position: keyof typeof BADGE_POSITIONS | BADGE_POSITIONS) => BadgeComponent;
|
|
81
|
+
|
|
82
|
+
/** Attaches badge to a target element */
|
|
83
|
+
attachTo: (target: HTMLElement) => BadgeComponent;
|
|
84
|
+
|
|
85
|
+
/** Makes badge standalone (removes from wrapper) */
|
|
86
|
+
detach: () => BadgeComponent;
|
|
87
|
+
|
|
88
|
+
/** Destroys the badge component and cleans up resources */
|
|
89
|
+
destroy: () => void;
|
|
90
|
+
|
|
91
|
+
/** Gets the class with the specified name */
|
|
92
|
+
getClass: (name: string) => string;
|
|
93
|
+
|
|
94
|
+
/** Add CSS classes */
|
|
95
|
+
addClass: (...classes: string[]) => BadgeComponent;
|
|
96
|
+
|
|
97
|
+
/** Remove CSS classes */
|
|
98
|
+
removeClass: (...classes: string[]) => BadgeComponent;
|
|
99
|
+
|
|
100
|
+
/** Add event listener */
|
|
101
|
+
on: (event: string, handler: Function) => BadgeComponent;
|
|
102
|
+
|
|
103
|
+
/** Remove event listener */
|
|
104
|
+
off: (event: string, handler: Function) => BadgeComponent;
|
|
105
|
+
}
|