mtrl 0.2.6 → 0.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/demo/build.ts +349 -0
- package/demo/index.html +110 -0
- package/demo/main.js +448 -0
- package/demo/styles.css +239 -0
- package/index.ts +18 -0
- package/package.json +14 -3
- package/server.ts +86 -0
- package/src/components/badge/api.ts +70 -63
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +66 -13
- package/src/components/badge/features.ts +51 -42
- package/src/components/badge/index.ts +27 -2
- package/src/components/badge/types.ts +62 -30
- package/src/components/bottom-app-bar/bottom-app-bar.ts +154 -0
- package/src/components/bottom-app-bar/config.ts +29 -0
- package/src/components/bottom-app-bar/index.ts +17 -0
- package/src/components/bottom-app-bar/types.ts +114 -0
- package/src/components/button/api.ts +5 -0
- package/src/components/button/button.ts +0 -1
- package/src/components/button/config.ts +6 -2
- package/src/components/button/index.ts +10 -2
- package/src/components/button/types.ts +20 -2
- package/src/components/card/card.ts +13 -25
- package/src/components/card/config.ts +83 -30
- package/src/components/card/content.ts +8 -10
- package/src/components/card/features.ts +4 -3
- package/src/components/card/index.ts +29 -2
- package/src/components/card/types.ts +33 -22
- package/src/components/checkbox/config.ts +3 -4
- package/src/components/checkbox/index.ts +1 -2
- package/src/components/checkbox/types.ts +12 -3
- package/src/components/chip/api.ts +170 -221
- package/src/components/chip/chip.ts +34 -302
- package/src/components/chip/config.ts +1 -2
- package/src/components/chip/index.ts +10 -2
- package/src/components/chip/types.ts +224 -35
- package/src/components/datepicker/api.ts +265 -0
- package/src/components/datepicker/config.ts +141 -0
- package/src/components/datepicker/datepicker.ts +341 -0
- package/src/components/datepicker/index.ts +12 -0
- package/src/components/datepicker/render.ts +450 -0
- package/src/components/datepicker/types.ts +397 -0
- package/src/components/datepicker/utils.ts +289 -0
- package/src/components/dialog/api.ts +55 -21
- package/src/components/dialog/config.ts +12 -9
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +345 -151
- package/src/components/dialog/index.ts +38 -8
- package/src/components/dialog/types.ts +40 -14
- 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 +9 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +112 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +9 -0
- package/src/components/extended-fab/types.ts +304 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +93 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +9 -0
- package/src/components/fab/types.ts +251 -0
- package/src/components/list/config.ts +4 -5
- package/src/components/list/features.ts +6 -7
- package/src/components/list/index.ts +7 -9
- package/src/components/list/list-item.ts +12 -13
- package/src/components/list/types.ts +50 -5
- package/src/components/list/utils.ts +30 -3
- package/src/components/menu/features/items-manager.ts +9 -9
- package/src/components/menu/features/positioning.ts +7 -7
- package/src/components/menu/features/visibility.ts +7 -7
- package/src/components/menu/index.ts +7 -9
- package/src/components/menu/menu-item.ts +6 -6
- package/src/components/menu/menu.ts +22 -0
- package/src/components/menu/types.ts +29 -10
- package/src/components/menu/utils.ts +67 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/config.ts +22 -10
- package/src/components/navigation/features/items.ts +284 -0
- package/src/components/navigation/index.ts +0 -6
- package/src/components/navigation/nav-item.ts +70 -33
- package/src/components/navigation/navigation.ts +53 -3
- package/src/components/navigation/types.ts +117 -70
- package/src/components/progress/api.ts +2 -3
- package/src/components/progress/config.ts +2 -3
- package/src/components/progress/index.ts +0 -1
- package/src/components/progress/progress.ts +1 -2
- package/src/components/progress/types.ts +186 -33
- package/src/components/radios/config.ts +1 -1
- package/src/components/radios/index.ts +0 -1
- package/src/components/radios/types.ts +0 -7
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +86 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +717 -0
- package/src/components/search/features/states.ts +169 -0
- package/src/components/search/features/structure.ts +197 -0
- package/src/components/search/index.ts +7 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +175 -0
- package/src/components/segmented-button/config.ts +80 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +154 -0
- package/src/components/segmented-button/segmented-button.ts +249 -0
- package/src/components/segmented-button/types.ts +254 -0
- package/src/components/slider/accessibility.md +5 -5
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -47
- 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 +136 -206
- package/src/components/slider/features/ui.ts +145 -206
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +67 -26
- package/src/components/snackbar/config.ts +2 -3
- package/src/components/snackbar/constants.ts +0 -32
- package/src/components/snackbar/index.ts +0 -1
- package/src/components/snackbar/position.ts +9 -1
- package/src/components/snackbar/types.ts +122 -46
- package/src/components/switch/config.ts +2 -3
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/types.ts +3 -2
- package/src/components/tabs/config.ts +3 -4
- package/src/components/tabs/features.ts +4 -2
- package/src/components/tabs/index.ts +0 -15
- package/src/components/tabs/indicator.ts +73 -13
- package/src/components/tabs/tab-api.ts +12 -4
- package/src/components/tabs/tab.ts +18 -6
- package/src/components/tabs/types.ts +23 -5
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/index.ts +0 -1
- package/src/components/textfield/types.ts +17 -3
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +228 -0
- package/src/components/timepicker/index.ts +3 -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/tooltip/api.ts +1 -1
- package/src/components/tooltip/config.ts +27 -6
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/types.ts +13 -3
- 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/features/icon.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +23 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +9 -1
- package/src/styles/components/_badge.scss +182 -0
- package/src/styles/components/_bottom-app-bar.scss +103 -0
- package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -10
- package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -2
- package/src/styles/components/_datepicker.scss +358 -0
- package/src/styles/components/_dialog.scss +259 -0
- package/src/styles/components/_divider.scss +57 -0
- package/src/styles/components/_extended-fab.scss +267 -0
- package/src/styles/components/_fab.scss +225 -0
- package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +1 -0
- package/src/styles/components/_search.scss +306 -0
- package/src/styles/components/_segmented-button.scss +117 -0
- package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +83 -24
- package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -2
- package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +95 -33
- package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
- package/src/styles/components/_timepicker.scss +451 -0
- package/src/styles/components/_top-app-bar.scss +225 -0
- package/src/styles/main.scss +98 -49
- 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/badge/_styles.scss +0 -174
- package/src/components/badge/constants.ts +0 -30
- package/src/components/button/constants.ts +0 -11
- package/src/components/card/constants.ts +0 -84
- package/src/components/dialog/_styles.scss +0 -213
- package/src/components/dialog/constants.ts +0 -32
- package/src/components/menu/constants.ts +0 -154
- package/src/components/navigation/constants.ts +0 -200
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/progress/constants.ts +0 -29
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -68
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -396
- package/src/components/slider/features/keyboard.ts +0 -233
- package/src/components/switch/constants.ts +0 -80
- package/src/components/tabs/constants.ts +0 -89
- package/src/core/collection/adapters/mongodb.js +0 -232
- /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
- /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
- /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
- /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
- /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
- /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
- /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
- /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
- /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
- /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
- /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
// src/components/button/index.ts
|
|
2
2
|
export { default } from './button'
|
|
3
|
-
export {
|
|
4
|
-
|
|
3
|
+
export { ButtonConfig, ButtonComponent, ButtonVariant } from './types'
|
|
4
|
+
|
|
5
|
+
// Export common button variants for convenience
|
|
6
|
+
export const BUTTON_VARIANTS = {
|
|
7
|
+
FILLED: 'filled',
|
|
8
|
+
TONAL: 'tonal',
|
|
9
|
+
OUTLINED: 'outlined',
|
|
10
|
+
ELEVATED: 'elevated',
|
|
11
|
+
TEXT: 'text'
|
|
12
|
+
} as const;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// src/components/button/types.ts
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Button variant types
|
|
5
|
+
* @category Components
|
|
6
|
+
*/
|
|
7
|
+
export type ButtonVariant = 'filled' | 'tonal' | 'outlined' | 'elevated' | 'text';
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* Configuration interface for the Button component
|
|
@@ -10,7 +15,7 @@ export interface ButtonConfig {
|
|
|
10
15
|
* Button variant that determines visual styling
|
|
11
16
|
* @default 'filled'
|
|
12
17
|
*/
|
|
13
|
-
variant?:
|
|
18
|
+
variant?: ButtonVariant | string;
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* Whether the button is initially disabled
|
|
@@ -81,6 +86,12 @@ export interface ButtonConfig {
|
|
|
81
86
|
/** Opacity values for ripple start and end [start, end] */
|
|
82
87
|
opacity?: [string, string];
|
|
83
88
|
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Accessible name for the button (aria-label)
|
|
92
|
+
* Required for icon-only buttons without text
|
|
93
|
+
*/
|
|
94
|
+
ariaLabel?: string;
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
/**
|
|
@@ -254,4 +265,11 @@ export interface ButtonComponent {
|
|
|
254
265
|
* @returns The button component for chaining
|
|
255
266
|
*/
|
|
256
267
|
addClass: (...classes: string[]) => ButtonComponent;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Sets the aria-label attribute for accessibility
|
|
271
|
+
* @param label - Aria label text
|
|
272
|
+
* @returns The button component for chaining
|
|
273
|
+
*/
|
|
274
|
+
setAriaLabel: (label: string) => ButtonComponent;
|
|
257
275
|
}
|
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
createBaseConfig,
|
|
14
14
|
getElementConfig,
|
|
15
15
|
getApiConfig,
|
|
16
|
-
withInteractiveBehavior
|
|
16
|
+
withInteractiveBehavior,
|
|
17
|
+
processInlineConfig,
|
|
18
|
+
applyInlineConfiguration
|
|
17
19
|
} from './config';
|
|
18
20
|
import { withElevation } from './features';
|
|
19
21
|
|
|
@@ -25,44 +27,30 @@ import { withElevation } from './features';
|
|
|
25
27
|
*
|
|
26
28
|
* @param {CardSchema} config - Card configuration object
|
|
27
29
|
* @returns {CardComponent} Card component instance
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* // Create a basic elevated card
|
|
32
|
-
* const card = createCard();
|
|
33
|
-
*
|
|
34
|
-
* // Create a filled card with content
|
|
35
|
-
* const filledCard = createCard({
|
|
36
|
-
* variant: CardVariant.FILLED,
|
|
37
|
-
* contentConfig: { text: 'Card content' }
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* // Create an interactive outlined card
|
|
41
|
-
* const interactiveCard = createCard({
|
|
42
|
-
* variant: CardVariant.OUTLINED,
|
|
43
|
-
* interactive: true,
|
|
44
|
-
* clickable: true,
|
|
45
|
-
* aria: { label: 'Click to view details' }
|
|
46
|
-
* });
|
|
47
|
-
* ```
|
|
48
30
|
*/
|
|
49
31
|
const createCard = (config: CardSchema = {}): CardComponent => {
|
|
50
|
-
|
|
32
|
+
// Process inline configuration (map shorthand properties)
|
|
33
|
+
const processedConfig = processInlineConfig(config);
|
|
34
|
+
const baseConfig = createBaseConfig(processedConfig);
|
|
51
35
|
|
|
52
36
|
try {
|
|
37
|
+
// Create the core card component
|
|
53
38
|
const card = pipe(
|
|
54
39
|
createBase,
|
|
55
40
|
withEvents(),
|
|
56
41
|
withElement(getElementConfig(baseConfig)),
|
|
57
42
|
withVariant(baseConfig),
|
|
58
|
-
|
|
43
|
+
baseConfig.clickable ? withRipple(baseConfig) : (c: BaseComponent) => c,
|
|
59
44
|
withLifecycle(),
|
|
60
45
|
withInteractiveBehavior,
|
|
61
46
|
withElevation,
|
|
62
47
|
comp => withAPI(getApiConfig(comp))(comp)
|
|
63
|
-
)(baseConfig);
|
|
48
|
+
)(baseConfig) as CardComponent;
|
|
49
|
+
|
|
50
|
+
// Apply any inline configuration
|
|
51
|
+
applyInlineConfiguration(card, processedConfig);
|
|
64
52
|
|
|
65
|
-
return card
|
|
53
|
+
return card;
|
|
66
54
|
} catch (error) {
|
|
67
55
|
console.error('Card creation error:', error instanceof Error ? error.message : String(error));
|
|
68
56
|
throw new Error(`Failed to create card: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -3,15 +3,20 @@ import {
|
|
|
3
3
|
createComponentConfig,
|
|
4
4
|
createElementConfig
|
|
5
5
|
} from '../../core/config/component-config';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
createCardHeader,
|
|
8
|
+
createCardContent,
|
|
9
|
+
createCardMedia,
|
|
10
|
+
createCardActions
|
|
11
|
+
} from './content';
|
|
12
|
+
import { CardComponent, CardSchema, ButtonConfig, BaseComponent } from './types';
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Default configuration for the Card component
|
|
11
16
|
* @const {CardSchema}
|
|
12
17
|
*/
|
|
13
18
|
export const defaultConfig: CardSchema = {
|
|
14
|
-
variant:
|
|
19
|
+
variant: 'elevated',
|
|
15
20
|
interactive: false,
|
|
16
21
|
fullWidth: false,
|
|
17
22
|
clickable: false,
|
|
@@ -19,57 +24,95 @@ export const defaultConfig: CardSchema = {
|
|
|
19
24
|
};
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Creates and adds all configured elements to the card in the following order:
|
|
25
|
-
* 1. Top media elements (position='top')
|
|
26
|
-
* 2. Header element
|
|
27
|
-
* 3. Content elements
|
|
28
|
-
* 4. Bottom media elements (position='bottom')
|
|
29
|
-
* 5. Actions elements
|
|
27
|
+
* Processes inline configuration options into standard config format
|
|
28
|
+
* Maps shorthand properties to their proper config counterparts
|
|
30
29
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
* @param {CardSchema} config - Raw card configuration
|
|
31
|
+
* @returns {CardSchema} Processed configuration
|
|
32
|
+
*/
|
|
33
|
+
export const processInlineConfig = (config: CardSchema): CardSchema => {
|
|
34
|
+
const processedConfig: CardSchema = { ...config };
|
|
35
|
+
|
|
36
|
+
// Map inline properties to their *Config counterparts
|
|
37
|
+
if (config.header) {
|
|
38
|
+
processedConfig.headerConfig = config.header;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (config.content) {
|
|
42
|
+
processedConfig.contentConfig = config.content;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (config.media) {
|
|
46
|
+
processedConfig.mediaConfig = config.media;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (config.actions) {
|
|
50
|
+
processedConfig.actionsConfig = config.actions;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return processedConfig;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Applies inline configuration to a card component
|
|
58
|
+
* Adds configured elements to the card in the correct order
|
|
33
59
|
*
|
|
34
|
-
* @param {CardComponent} card - Card component to
|
|
35
|
-
* @param {CardSchema} config -
|
|
36
|
-
* @returns {CardComponent} Initialized card component
|
|
37
|
-
* @internal This is an internal utility for the Card component
|
|
60
|
+
* @param {CardComponent} card - Card component to configure
|
|
61
|
+
* @param {CardSchema} config - Processed configuration
|
|
38
62
|
*/
|
|
39
|
-
export const
|
|
40
|
-
//
|
|
63
|
+
export const applyInlineConfiguration = (card: CardComponent, config: CardSchema): void => {
|
|
64
|
+
// Add media (top position) if configured
|
|
41
65
|
if (config.mediaConfig && (!config.mediaConfig.position || config.mediaConfig.position === 'top')) {
|
|
42
66
|
const { position, ...mediaConfigWithoutPosition } = config.mediaConfig;
|
|
43
67
|
const mediaElement = createCardMedia(mediaConfigWithoutPosition);
|
|
44
68
|
card.addMedia(mediaElement, 'top');
|
|
45
69
|
}
|
|
46
70
|
|
|
47
|
-
//
|
|
71
|
+
// Add header if configured
|
|
48
72
|
if (config.headerConfig) {
|
|
49
73
|
const headerElement = createCardHeader(config.headerConfig);
|
|
50
74
|
card.setHeader(headerElement);
|
|
51
75
|
}
|
|
52
76
|
|
|
53
|
-
//
|
|
77
|
+
// Add content if configured
|
|
54
78
|
if (config.contentConfig) {
|
|
55
79
|
const contentElement = createCardContent(config.contentConfig);
|
|
56
80
|
card.addContent(contentElement);
|
|
57
81
|
}
|
|
58
82
|
|
|
59
|
-
//
|
|
83
|
+
// Add media (bottom position) if configured
|
|
60
84
|
if (config.mediaConfig && config.mediaConfig.position === 'bottom') {
|
|
61
85
|
const { position, ...mediaConfigWithoutPosition } = config.mediaConfig;
|
|
62
86
|
const mediaElement = createCardMedia(mediaConfigWithoutPosition);
|
|
63
87
|
card.addMedia(mediaElement, 'bottom');
|
|
64
88
|
}
|
|
65
89
|
|
|
66
|
-
//
|
|
90
|
+
// Add actions if configured
|
|
67
91
|
if (config.actionsConfig) {
|
|
68
92
|
const actionsElement = createCardActions(config.actionsConfig);
|
|
69
93
|
card.setActions(actionsElement);
|
|
70
94
|
}
|
|
71
95
|
|
|
72
|
-
|
|
96
|
+
// Process buttons if provided (asynchronously)
|
|
97
|
+
if (Array.isArray(config.buttons) && config.buttons.length > 0) {
|
|
98
|
+
import('../button').then(({ default: createButton }) => {
|
|
99
|
+
// Create buttons from configuration
|
|
100
|
+
const actionButtons = config.buttons!.map(buttonConfig =>
|
|
101
|
+
createButton(buttonConfig).element
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Create actions container
|
|
105
|
+
const actionsElement = createCardActions({
|
|
106
|
+
actions: actionButtons,
|
|
107
|
+
align: config.actionsConfig?.align || 'end'
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Add the actions to the card
|
|
111
|
+
card.setActions(actionsElement);
|
|
112
|
+
}).catch(error => {
|
|
113
|
+
console.error('Error processing buttons:', error);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
73
116
|
};
|
|
74
117
|
|
|
75
118
|
/**
|
|
@@ -146,6 +189,16 @@ export const getApiConfig = (comp: any) => ({
|
|
|
146
189
|
}
|
|
147
190
|
});
|
|
148
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Card elevation levels
|
|
194
|
+
*/
|
|
195
|
+
export const CARD_ELEVATION_LEVELS = {
|
|
196
|
+
LEVEL0: 0,
|
|
197
|
+
LEVEL1: 1,
|
|
198
|
+
LEVEL2: 2,
|
|
199
|
+
LEVEL4: 4
|
|
200
|
+
};
|
|
201
|
+
|
|
149
202
|
/**
|
|
150
203
|
* Adds interactive behavior to card component
|
|
151
204
|
* Uses the MTRL elevation system for proper elevation levels
|
|
@@ -161,14 +214,14 @@ export const withInteractiveBehavior = (comp: BaseComponent): BaseComponent => {
|
|
|
161
214
|
if (isInteractive) {
|
|
162
215
|
// Mouse interactions
|
|
163
216
|
comp.element.addEventListener('mouseenter', () => {
|
|
164
|
-
if (config.variant ===
|
|
165
|
-
comp.element.style.setProperty('--card-elevation', String(
|
|
217
|
+
if (config.variant === 'elevated') {
|
|
218
|
+
comp.element.style.setProperty('--card-elevation', String(CARD_ELEVATION_LEVELS.LEVEL2));
|
|
166
219
|
}
|
|
167
220
|
});
|
|
168
221
|
|
|
169
222
|
comp.element.addEventListener('mouseleave', () => {
|
|
170
|
-
if (config.variant ===
|
|
171
|
-
comp.element.style.setProperty('--card-elevation', String(
|
|
223
|
+
if (config.variant === 'elevated') {
|
|
224
|
+
comp.element.style.setProperty('--card-elevation', String(CARD_ELEVATION_LEVELS.LEVEL1));
|
|
172
225
|
}
|
|
173
226
|
});
|
|
174
227
|
|
|
@@ -196,7 +249,7 @@ export const withInteractiveBehavior = (comp: BaseComponent): BaseComponent => {
|
|
|
196
249
|
comp.element.setAttribute('draggable', 'true');
|
|
197
250
|
|
|
198
251
|
comp.element.addEventListener('dragstart', (e: DragEvent) => {
|
|
199
|
-
comp.element.style.setProperty('--card-elevation', String(
|
|
252
|
+
comp.element.style.setProperty('--card-elevation', String(CARD_ELEVATION_LEVELS.LEVEL4));
|
|
200
253
|
comp.element.classList.add(`${comp.getClass('card')}--dragging`);
|
|
201
254
|
comp.emit?.('dragstart', { event: e });
|
|
202
255
|
|
|
@@ -209,7 +262,7 @@ export const withInteractiveBehavior = (comp: BaseComponent): BaseComponent => {
|
|
|
209
262
|
});
|
|
210
263
|
|
|
211
264
|
comp.element.addEventListener('dragend', (e: DragEvent) => {
|
|
212
|
-
comp.element.style.setProperty('--card-elevation', String(
|
|
265
|
+
comp.element.style.setProperty('--card-elevation', String(CARD_ELEVATION_LEVELS.LEVEL1));
|
|
213
266
|
comp.element.classList.remove(`${comp.getClass('card')}--dragging`);
|
|
214
267
|
comp.emit?.('dragend', { event: e });
|
|
215
268
|
});
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
import { PREFIX } from '../../core/config';
|
|
3
3
|
import { pipe } from '../../core/compose';
|
|
4
4
|
import { createBase, withElement } from '../../core/compose/component';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { createElement } from '../../core/dom/create';
|
|
6
|
+
import { CardContentConfig, CardHeaderConfig, CardMediaConfig, CardActionsConfig } from './types';
|
|
7
|
+
|
|
8
|
+
// Constants for content padding
|
|
9
|
+
export const CARD_CONTENT_PADDING = true;
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Creates a card content component
|
|
@@ -78,9 +81,6 @@ export const createCardContent = (config: CardContentConfig = {}): HTMLElement =
|
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
|
|
81
|
-
// src/components/card/header.ts
|
|
82
|
-
import { createElement } from '../../core/dom/create';
|
|
83
|
-
|
|
84
84
|
/**
|
|
85
85
|
* Creates a card header component
|
|
86
86
|
*
|
|
@@ -103,7 +103,7 @@ import { createElement } from '../../core/dom/create';
|
|
|
103
103
|
* });
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
|
-
export const createCardHeader = (config:
|
|
106
|
+
export const createCardHeader = (config: CardHeaderConfig = {}): HTMLElement => {
|
|
107
107
|
const baseConfig = {
|
|
108
108
|
...config,
|
|
109
109
|
componentName: 'card-header',
|
|
@@ -200,7 +200,6 @@ export const createCardHeader = (config: any = {}): HTMLElement => {
|
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
// src/components/card/actions.ts
|
|
204
203
|
/**
|
|
205
204
|
* Creates a card actions component
|
|
206
205
|
*
|
|
@@ -225,7 +224,7 @@ export const createCardHeader = (config: any = {}): HTMLElement => {
|
|
|
225
224
|
* });
|
|
226
225
|
* ```
|
|
227
226
|
*/
|
|
228
|
-
export const createCardActions = (config:
|
|
227
|
+
export const createCardActions = (config: CardActionsConfig = {}): HTMLElement => {
|
|
229
228
|
const baseConfig = {
|
|
230
229
|
...config,
|
|
231
230
|
componentName: 'card-actions',
|
|
@@ -273,7 +272,6 @@ export const createCardActions = (config: any = {}): HTMLElement => {
|
|
|
273
272
|
}
|
|
274
273
|
};
|
|
275
274
|
|
|
276
|
-
// src/components/card/media.ts
|
|
277
275
|
/**
|
|
278
276
|
* Creates a card media component
|
|
279
277
|
*
|
|
@@ -296,7 +294,7 @@ export const createCardActions = (config: any = {}): HTMLElement => {
|
|
|
296
294
|
* });
|
|
297
295
|
* ```
|
|
298
296
|
*/
|
|
299
|
-
export const createCardMedia = (config:
|
|
297
|
+
export const createCardMedia = (config: CardMediaConfig = {}): HTMLElement => {
|
|
300
298
|
const baseConfig = {
|
|
301
299
|
...config,
|
|
302
300
|
componentName: 'card-media',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { PREFIX } from '../../core/config';
|
|
3
3
|
import { createElement } from '../../core/dom/create';
|
|
4
4
|
import { BaseComponent, CardComponent, LoadingFeature, ExpandableFeature, SwipeableFeature } from './types';
|
|
5
|
+
import { CARD_ELEVATION_LEVELS } from './config';
|
|
5
6
|
|
|
6
7
|
interface LoadingConfig {
|
|
7
8
|
initialState?: boolean;
|
|
@@ -112,9 +113,9 @@ export const withElevation = (component: BaseComponent): BaseComponent => {
|
|
|
112
113
|
|
|
113
114
|
// Set initial elevation based on variant
|
|
114
115
|
if (config.variant === 'elevated') {
|
|
115
|
-
component.element.style.setProperty('--card-elevation',
|
|
116
|
+
component.element.style.setProperty('--card-elevation', String(CARD_ELEVATION_LEVELS.LEVEL1));
|
|
116
117
|
} else {
|
|
117
|
-
component.element.style.setProperty('--card-elevation',
|
|
118
|
+
component.element.style.setProperty('--card-elevation', String(CARD_ELEVATION_LEVELS.LEVEL0));
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
return component;
|
|
@@ -263,7 +264,7 @@ export const withExpandable = (config: ExpandableConfig = {}) => (component: Bas
|
|
|
263
264
|
* onSwipeLeft: (card) => console.log('Swiped left'),
|
|
264
265
|
* onSwipeRight: (card) => console.log('Swiped right')
|
|
265
266
|
* })
|
|
266
|
-
* )({ variant:
|
|
267
|
+
* )({ variant: 'elevated' });
|
|
267
268
|
* ```
|
|
268
269
|
*/
|
|
269
270
|
export const withSwipeable = (config: SwipeableConfig = {}) => (component: BaseComponent): BaseComponent & { swipeable: SwipeableFeature } => {
|
|
@@ -29,7 +29,7 @@ export {
|
|
|
29
29
|
|
|
30
30
|
export {
|
|
31
31
|
CardVariant,
|
|
32
|
-
|
|
32
|
+
CardElevationLevel,
|
|
33
33
|
CardSchema,
|
|
34
34
|
CardHeaderConfig,
|
|
35
35
|
CardContentConfig,
|
|
@@ -38,4 +38,31 @@ export {
|
|
|
38
38
|
CardAriaAttributes,
|
|
39
39
|
CardComponent
|
|
40
40
|
} from './types';
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
// Export card constants for backward compatibility
|
|
43
|
+
export const CARD_VARIANTS = {
|
|
44
|
+
ELEVATED: 'elevated',
|
|
45
|
+
FILLED: 'filled',
|
|
46
|
+
OUTLINED: 'outlined'
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
export const CARD_ELEVATIONS = {
|
|
50
|
+
LEVEL0: 0,
|
|
51
|
+
LEVEL1: 1,
|
|
52
|
+
LEVEL2: 2,
|
|
53
|
+
LEVEL4: 4
|
|
54
|
+
} as const;
|
|
55
|
+
|
|
56
|
+
// Additional constants
|
|
57
|
+
export const CARD_WIDTHS = {
|
|
58
|
+
SMALL: '344px',
|
|
59
|
+
MEDIUM: '480px',
|
|
60
|
+
LARGE: '624px',
|
|
61
|
+
FULL: '100%'
|
|
62
|
+
} as const;
|
|
63
|
+
|
|
64
|
+
export const CARD_CORNER_RADIUS = {
|
|
65
|
+
SMALL: '8px',
|
|
66
|
+
MEDIUM: '12px',
|
|
67
|
+
LARGE: '16px'
|
|
68
|
+
} as const;
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
// src/components/card/types.ts
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
|
-
* Card variant types
|
|
4
|
-
* @enum {string}
|
|
4
|
+
* Card variant types
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
OUTLINED = 'outlined'
|
|
13
|
-
}
|
|
6
|
+
export type CardVariant = 'elevated' | 'filled' | 'outlined';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Card elevation levels
|
|
10
|
+
*/
|
|
11
|
+
export type CardElevationLevel = 0 | 1 | 2 | 4;
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
14
|
+
* Button configuration interface for buttons shorthand
|
|
15
|
+
* @interface ButtonConfig
|
|
18
16
|
*/
|
|
19
|
-
export
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
17
|
+
export interface ButtonConfig {
|
|
18
|
+
/** Button text */
|
|
19
|
+
text?: string;
|
|
20
|
+
/** Button variant */
|
|
21
|
+
variant?: string;
|
|
22
|
+
/** Button icon */
|
|
23
|
+
icon?: string;
|
|
24
|
+
/** Additional button properties */
|
|
25
|
+
[key: string]: any;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
/**
|
|
@@ -33,7 +31,7 @@ export enum CardElevation {
|
|
|
33
31
|
*/
|
|
34
32
|
export interface CardSchema {
|
|
35
33
|
/** Card variant type (elevated, filled, outlined) */
|
|
36
|
-
variant?: CardVariant;
|
|
34
|
+
variant?: CardVariant | string;
|
|
37
35
|
/** Whether the card is interactive */
|
|
38
36
|
interactive?: boolean;
|
|
39
37
|
/** Whether the card should take full width */
|
|
@@ -54,6 +52,19 @@ export interface CardSchema {
|
|
|
54
52
|
mediaConfig?: CardMediaConfig;
|
|
55
53
|
/** ARIA attributes for accessibility */
|
|
56
54
|
aria?: CardAriaAttributes;
|
|
55
|
+
|
|
56
|
+
// New inline configuration options
|
|
57
|
+
/** Inline header configuration (alternative to headerConfig) */
|
|
58
|
+
header?: CardHeaderConfig;
|
|
59
|
+
/** Inline content configuration (alternative to contentConfig) */
|
|
60
|
+
content?: CardContentConfig;
|
|
61
|
+
/** Inline media configuration (alternative to mediaConfig) */
|
|
62
|
+
media?: CardMediaConfig;
|
|
63
|
+
/** Inline actions configuration (alternative to actionsConfig) */
|
|
64
|
+
actions?: CardActionsConfig;
|
|
65
|
+
/** Simple buttons array for actions (will be converted to actionsConfig) */
|
|
66
|
+
buttons?: ButtonConfig[];
|
|
67
|
+
|
|
57
68
|
/** Internal component name */
|
|
58
69
|
componentName?: string;
|
|
59
70
|
/** CSS class prefix */
|
|
@@ -5,14 +5,13 @@ import {
|
|
|
5
5
|
BaseComponentConfig
|
|
6
6
|
} from '../../core/config/component-config';
|
|
7
7
|
import { CheckboxConfig, BaseComponent, ApiOptions } from './types';
|
|
8
|
-
import { CHECKBOX_VARIANTS, CHECKBOX_LABEL_POSITION } from './constants';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Default configuration for the Checkbox component
|
|
12
11
|
*/
|
|
13
12
|
export const defaultConfig: CheckboxConfig = {
|
|
14
|
-
variant:
|
|
15
|
-
labelPosition:
|
|
13
|
+
variant: 'filled',
|
|
14
|
+
labelPosition: 'end'
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
/**
|
|
@@ -58,7 +57,7 @@ export const withCheckIcon = (config: CheckboxConfig) => (component: BaseCompone
|
|
|
58
57
|
* @param {CheckboxConfig} config - Component configuration
|
|
59
58
|
*/
|
|
60
59
|
export const withLabelPosition = (config: CheckboxConfig) => (component: BaseComponent): BaseComponent => {
|
|
61
|
-
const position = config.labelPosition ||
|
|
60
|
+
const position = config.labelPosition || 'end';
|
|
62
61
|
const positionClass = `${config.prefix}-checkbox--label-${position}`;
|
|
63
62
|
|
|
64
63
|
component.element.classList.add(positionClass);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
// src/components/checkbox/index.ts
|
|
2
2
|
export { default } from './checkbox';
|
|
3
|
-
export {
|
|
4
|
-
export { CheckboxConfig, CheckboxComponent } from './types';
|
|
3
|
+
export { CheckboxConfig, CheckboxComponent, CheckboxVariant, CheckboxLabelPosition } from './types';
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
// src/components/checkbox/types.ts
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checkbox variant types
|
|
5
|
+
*/
|
|
6
|
+
export type CheckboxVariant = 'filled' | 'outlined';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Checkbox label position types
|
|
10
|
+
*/
|
|
11
|
+
export type CheckboxLabelPosition = 'start' | 'end';
|
|
3
12
|
|
|
4
13
|
/**
|
|
5
14
|
* Configuration interface for the Checkbox component
|
|
@@ -27,10 +36,10 @@ export interface CheckboxConfig {
|
|
|
27
36
|
label?: string;
|
|
28
37
|
|
|
29
38
|
/** Label position (start/end) */
|
|
30
|
-
labelPosition?:
|
|
39
|
+
labelPosition?: CheckboxLabelPosition | string;
|
|
31
40
|
|
|
32
41
|
/** Visual variant */
|
|
33
|
-
variant?:
|
|
42
|
+
variant?: CheckboxVariant | string;
|
|
34
43
|
|
|
35
44
|
/** Additional CSS classes */
|
|
36
45
|
class?: string;
|