mtrl 0.3.0 → 0.3.2
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/.env +15 -0
- package/CONTRIBUTING.md +8 -8
- package/DOCS.md +3 -3
- package/README.md +43 -20
- package/TESTING.md +128 -18
- package/dist/index.js +14865 -0
- package/git-user-stats.js +545 -0
- package/index.ts +9 -69
- package/package.json +10 -3
- package/src/components/badge/api.ts +15 -1
- package/src/components/badge/badge.ts +43 -4
- package/src/components/badge/config.ts +40 -8
- package/src/components/badge/index.ts +64 -3
- package/src/components/badge/types.ts +175 -33
- package/src/components/button/api.ts +63 -1
- package/src/components/button/button.ts +39 -3
- package/src/components/button/config.ts +21 -4
- package/src/components/button/index.ts +26 -1
- package/src/components/button/types.ts +7 -1
- package/src/components/card/api.ts +78 -9
- package/src/components/card/card.ts +58 -3
- package/src/components/card/config.ts +41 -11
- package/src/components/card/features.ts +39 -12
- package/src/components/card/index.ts +84 -19
- package/src/components/card/types.ts +218 -29
- package/src/components/carousel/carousel.ts +92 -28
- package/src/components/carousel/constants.ts +107 -21
- package/src/components/carousel/index.ts +31 -13
- package/src/components/checkbox/checkbox.ts +83 -16
- package/src/components/checkbox/index.ts +43 -1
- package/src/components/checkbox/types.ts +219 -32
- package/src/components/chips/api.ts +194 -0
- package/src/components/{chip → chips/chip}/api.ts +42 -2
- package/src/components/chips/chip/chip.ts +131 -0
- package/src/components/{chip → chips/chip}/config.ts +3 -3
- package/src/components/chips/chip/index.ts +3 -0
- package/src/components/chips/chips.md +481 -0
- package/src/components/chips/chips.ts +75 -0
- package/src/components/chips/config.ts +109 -0
- package/src/components/chips/constants.ts +61 -0
- package/src/components/chips/features/chip-items.ts +33 -0
- package/src/components/chips/features/container.ts +77 -0
- package/src/components/chips/features/controller.ts +448 -0
- package/src/components/chips/features/index.ts +5 -0
- package/src/components/chips/features/label.ts +108 -0
- package/src/components/chips/index.ts +11 -0
- package/src/components/chips/schema.ts +61 -0
- package/src/components/{chip → chips}/types.ts +203 -92
- package/src/components/dialog/dialog.ts +99 -16
- package/src/components/dialog/index.ts +97 -1
- package/src/components/dialog/types.ts +375 -69
- package/src/components/divider/config.ts +90 -6
- package/src/components/divider/divider.ts +32 -2
- package/src/components/divider/features.ts +26 -0
- package/src/components/divider/index.ts +30 -0
- package/src/components/divider/types.ts +86 -9
- package/src/components/extended-fab/api.ts +53 -1
- package/src/components/extended-fab/config.ts +29 -1
- package/src/components/extended-fab/extended-fab.ts +28 -0
- package/src/components/extended-fab/index.ts +36 -0
- package/src/components/extended-fab/types.ts +458 -13
- package/src/components/fab/api.ts +42 -2
- package/src/components/fab/config.ts +29 -1
- package/src/components/fab/fab.ts +16 -2
- package/src/components/fab/index.ts +35 -0
- package/src/components/fab/types.ts +374 -10
- package/src/components/list/api.ts +12 -2
- package/src/components/list/config.ts +21 -0
- package/src/components/list/features.ts +6 -0
- package/src/components/list/index.ts +56 -1
- package/src/components/list/list-item.ts +46 -2
- package/src/components/list/list.ts +73 -2
- package/src/components/list/types.ts +172 -0
- package/src/components/list/utils.ts +26 -2
- package/src/components/menu/api.ts +217 -20
- package/src/components/menu/config.ts +27 -0
- package/src/components/menu/features/visibility.ts +55 -6
- package/src/components/menu/index.ts +64 -0
- package/src/components/menu/menu-item.ts +46 -3
- package/src/components/menu/menu.ts +77 -1
- package/src/components/menu/types.ts +404 -39
- package/src/components/navigation/index.ts +4 -1
- package/src/components/navigation/types.ts +33 -0
- package/src/components/sheet/config.ts +1 -2
- package/src/components/sheet/features/gestures.ts +1 -1
- package/src/components/sheet/features/position.ts +1 -2
- package/src/components/sheet/features/state.ts +1 -1
- package/src/components/sheet/index.ts +10 -2
- package/src/components/sheet/sheet.ts +1 -2
- package/src/components/sheet/types.ts +29 -1
- package/src/components/slider/api.ts +1 -1
- package/src/components/slider/config.ts +1 -1
- package/src/components/slider/features/controller.ts +1 -1
- package/src/components/slider/features/handlers.ts +1 -1
- package/src/components/slider/features/states.ts +1 -1
- package/src/components/slider/index.ts +12 -5
- package/src/components/slider/schema.ts +1 -1
- package/src/components/slider/types.ts +31 -0
- package/src/components/snackbar/index.ts +7 -1
- package/src/components/snackbar/types.ts +25 -0
- package/src/components/switch/index.ts +5 -1
- package/src/components/switch/types.ts +13 -0
- package/src/components/tabs/tab-api.ts +1 -1
- package/src/components/tabs/types.ts +1 -1
- package/src/components/textfield/index.ts +7 -1
- package/src/components/textfield/types.ts +36 -0
- package/src/components/tooltip/api.ts +6 -2
- package/src/components/tooltip/config.ts +9 -28
- package/src/components/tooltip/index.ts +10 -1
- package/src/components/tooltip/types.ts +38 -3
- package/src/index.ts +129 -31
- package/src/styles/abstract/_mixins.scss +23 -9
- package/src/styles/abstract/_variables.scss +14 -4
- package/src/styles/components/_card.scss +1 -1
- package/src/styles/components/_chip.scss +323 -113
- package/src/styles/components/_tabs.scss +1 -1
- package/src/components/checkbox/constants.ts +0 -37
- package/src/components/chip/chip-set.ts +0 -225
- package/src/components/chip/chip.ts +0 -118
- package/src/components/chip/constants.ts +0 -28
- package/src/components/chip/index.ts +0 -12
- package/src/components/list/constants.ts +0 -116
- package/src/components/sheet/constants.ts +0 -20
- package/src/components/slider/constants.ts +0 -32
- package/src/components/snackbar/constants.ts +0 -26
- package/src/components/tooltip/constants.ts +0 -27
- package/test/components/button.test.js +0 -170
- package/test/components/checkbox.test.js +0 -238
- package/test/components/list.test.js +0 -105
- package/test/components/menu.test.js +0 -385
- package/test/components/navigation.test.js +0 -227
- package/test/components/snackbar.test.js +0 -234
- package/test/components/switch.test.js +0 -186
- package/test/components/textfield.test.js +0 -314
- package/test/core/emitter.test.js +0 -141
- package/test/core/ripple.test.js +0 -66
- package/test/setup.js +0 -371
- package/tsconfig.json +0 -22
- package/typedoc.json +0 -28
- package/typedoc.simple.json +0 -14
|
@@ -1,12 +1,67 @@
|
|
|
1
1
|
// src/components/list/index.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module List
|
|
5
|
+
*
|
|
6
|
+
* List component following Material Design 3 guidelines.
|
|
7
|
+
* Lists are continuous, vertical indexes of text or images.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Multiple selection modes (single, multiple, none)
|
|
11
|
+
* - Horizontal and vertical layouts
|
|
12
|
+
* - Support for sections and dividers
|
|
13
|
+
* - Leading and trailing elements (icons, avatars, etc.)
|
|
14
|
+
* - Customizable item content (headline, supporting text, etc.)
|
|
15
|
+
* - Keyboard navigation and accessibility
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Create a simple list with items
|
|
20
|
+
* const userList = createList({
|
|
21
|
+
* type: 'single', // Single selection mode
|
|
22
|
+
* items: [
|
|
23
|
+
* {
|
|
24
|
+
* id: 'user1',
|
|
25
|
+
* headline: 'Jane Smith',
|
|
26
|
+
* supportingText: 'Software Engineer',
|
|
27
|
+
* leading: '<svg>...</svg>'
|
|
28
|
+
* },
|
|
29
|
+
* {
|
|
30
|
+
* id: 'user2',
|
|
31
|
+
* headline: 'John Doe',
|
|
32
|
+
* supportingText: 'Product Manager',
|
|
33
|
+
* leading: '<svg>...</svg>'
|
|
34
|
+
* }
|
|
35
|
+
* ]
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Attach to DOM and add selection handler
|
|
39
|
+
* container.appendChild(userList.element);
|
|
40
|
+
* userList.on('selectionChange', (event) => {
|
|
41
|
+
* console.log('Selected:', event.selected);
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @category Components
|
|
46
|
+
*/
|
|
47
|
+
|
|
2
48
|
export { default } from './list';
|
|
3
49
|
export { default as createListItem } from './list-item';
|
|
4
50
|
export {
|
|
51
|
+
// Types
|
|
5
52
|
ListConfig,
|
|
6
53
|
ListComponent,
|
|
7
54
|
ListItemConfig,
|
|
8
55
|
ListSectionConfig,
|
|
9
56
|
ListType,
|
|
10
57
|
ListLayout,
|
|
11
|
-
ListItemLayout
|
|
58
|
+
ListItemLayout,
|
|
59
|
+
|
|
60
|
+
// Constants
|
|
61
|
+
LIST_TYPES,
|
|
62
|
+
LIST_LAYOUTS,
|
|
63
|
+
LIST_ITEM_LAYOUTS,
|
|
64
|
+
LIST_CLASSES,
|
|
65
|
+
LIST_SCHEMA,
|
|
66
|
+
LIST_ITEM_STATES
|
|
12
67
|
} from './types';
|
|
@@ -8,9 +8,15 @@ import { createElement, getListClass } from './utils';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Creates list item content based on configuration
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
|
+
* Higher-order function that enhances a component with list item content structure
|
|
13
|
+
* according to Material Design 3 guidelines. Handles the creation and arrangement of
|
|
14
|
+
* item elements like headline text, supporting text, leading/trailing components, etc.
|
|
15
|
+
*
|
|
12
16
|
* @param {ListItemConfig} config - List item configuration
|
|
13
|
-
* @returns {
|
|
17
|
+
* @returns {Function} Function that enhances a component with list item content
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
14
20
|
*/
|
|
15
21
|
const withItemContent = (config: ListItemConfig) => (component: any): any => {
|
|
16
22
|
const { element } = component;
|
|
@@ -89,8 +95,46 @@ const withItemContent = (config: ListItemConfig) => (component: any): any => {
|
|
|
89
95
|
|
|
90
96
|
/**
|
|
91
97
|
* Creates a list item component
|
|
98
|
+
*
|
|
99
|
+
* Creates an individual list item with customizable content following Material Design 3
|
|
100
|
+
* list item patterns. List items can have different layouts, content structures, and
|
|
101
|
+
* visual states (selected, disabled, etc.).
|
|
102
|
+
*
|
|
92
103
|
* @param {ListItemConfig} config - List item configuration
|
|
93
104
|
* @returns {Object} List item component instance
|
|
105
|
+
*
|
|
106
|
+
* @category Components
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* // Create a standard list item
|
|
111
|
+
* const listItem = createListItem({
|
|
112
|
+
* id: 'user1',
|
|
113
|
+
* headline: 'Alex Johnson',
|
|
114
|
+
* supportingText: 'Software Engineer',
|
|
115
|
+
* leading: '<span class="material-icons">person</span>'
|
|
116
|
+
* });
|
|
117
|
+
*
|
|
118
|
+
* // Create a vertical layout list item with more content
|
|
119
|
+
* const detailedItem = createListItem({
|
|
120
|
+
* id: 'event1',
|
|
121
|
+
* layout: 'vertical',
|
|
122
|
+
* overline: 'UPCOMING EVENT',
|
|
123
|
+
* headline: 'Team Meeting',
|
|
124
|
+
* supportingText: 'Discussion of quarterly goals',
|
|
125
|
+
* meta: 'Tomorrow, 2:00 PM',
|
|
126
|
+
* leading: '<span class="material-icons">event</span>',
|
|
127
|
+
* trailing: '<span class="material-icons">more_vert</span>'
|
|
128
|
+
* });
|
|
129
|
+
*
|
|
130
|
+
* // Create a selected list item
|
|
131
|
+
* const selectedItem = createListItem({
|
|
132
|
+
* id: 'file1',
|
|
133
|
+
* headline: 'Project Proposal.pdf',
|
|
134
|
+
* supportingText: '2.4 MB',
|
|
135
|
+
* selected: true
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
94
138
|
*/
|
|
95
139
|
const createListItem = (config: ListItemConfig): any => {
|
|
96
140
|
const baseConfig = {
|
|
@@ -9,8 +9,79 @@ import { createBaseConfig, getElementConfig } from './config';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Creates a List component
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* Lists display a collection of items in a vertical arrangement. They can be configured
|
|
14
|
+
* with different selection modes, layouts, and content structures following Material
|
|
15
|
+
* Design 3 guidelines.
|
|
16
|
+
*
|
|
17
|
+
* @param {ListConfig} config - List configuration options
|
|
18
|
+
* @returns {ListComponent} List component instance with methods for managing items and selection
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} If list creation fails due to invalid configuration
|
|
21
|
+
*
|
|
22
|
+
* @category Components
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Create a simple list with single selection
|
|
27
|
+
* const contactList = createList({
|
|
28
|
+
* type: 'single',
|
|
29
|
+
* items: [
|
|
30
|
+
* {
|
|
31
|
+
* id: 'contact1',
|
|
32
|
+
* headline: 'Alex Johnson',
|
|
33
|
+
* supportingText: 'alex@example.com',
|
|
34
|
+
* leading: '<span class="material-icons">person</span>',
|
|
35
|
+
* trailing: '<span class="material-icons">chevron_right</span>'
|
|
36
|
+
* },
|
|
37
|
+
* {
|
|
38
|
+
* id: 'contact2',
|
|
39
|
+
* headline: 'Sam Taylor',
|
|
40
|
+
* supportingText: 'sam@example.com',
|
|
41
|
+
* leading: '<span class="material-icons">person</span>',
|
|
42
|
+
* trailing: '<span class="material-icons">chevron_right</span>'
|
|
43
|
+
* }
|
|
44
|
+
* ]
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* // Create a list with sections
|
|
48
|
+
* const categorizedList = createList({
|
|
49
|
+
* type: 'multi',
|
|
50
|
+
* sections: [
|
|
51
|
+
* {
|
|
52
|
+
* id: 'section1',
|
|
53
|
+
* title: 'Favorites',
|
|
54
|
+
* items: [
|
|
55
|
+
* { id: 'item1', headline: 'Item 1' },
|
|
56
|
+
* { id: 'item2', headline: 'Item 2' }
|
|
57
|
+
* ]
|
|
58
|
+
* },
|
|
59
|
+
* {
|
|
60
|
+
* id: 'section2',
|
|
61
|
+
* title: 'Recent',
|
|
62
|
+
* items: [
|
|
63
|
+
* { id: 'item3', headline: 'Item 3' },
|
|
64
|
+
* { id: 'item4', headline: 'Item 4' }
|
|
65
|
+
* ]
|
|
66
|
+
* }
|
|
67
|
+
* ]
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Handle selection change
|
|
71
|
+
* contactList.on('selectionChange', (event) => {
|
|
72
|
+
* console.log('Selected IDs:', event.selected);
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // Programmatically select items
|
|
76
|
+
* contactList.setSelected(['contact2']);
|
|
77
|
+
*
|
|
78
|
+
* // Add a new item
|
|
79
|
+
* contactList.addItem({
|
|
80
|
+
* id: 'contact3',
|
|
81
|
+
* headline: 'Jamie Smith',
|
|
82
|
+
* supportingText: 'jamie@example.com'
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
14
85
|
*/
|
|
15
86
|
const createList = (config: ListConfig = {}): any => {
|
|
16
87
|
const baseConfig = createBaseConfig(config);
|
|
@@ -1,5 +1,144 @@
|
|
|
1
1
|
// src/components/list/types.ts
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* List types/variants
|
|
5
|
+
*
|
|
6
|
+
* Different selection modes available for lists.
|
|
7
|
+
*
|
|
8
|
+
* @category Components
|
|
9
|
+
*/
|
|
10
|
+
export const LIST_TYPES = {
|
|
11
|
+
DEFAULT: 'default', // Standard list
|
|
12
|
+
SINGLE_SELECT: 'single', // Single selection list
|
|
13
|
+
MULTI_SELECT: 'multi', // Multiple selection list
|
|
14
|
+
RADIO: 'radio' // Radio button list
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* List layout variants
|
|
19
|
+
*
|
|
20
|
+
* Layout options for list items and content arrangement.
|
|
21
|
+
*
|
|
22
|
+
* @category Components
|
|
23
|
+
*/
|
|
24
|
+
export const LIST_LAYOUTS = {
|
|
25
|
+
HORIZONTAL: 'horizontal', // Default horizontal layout
|
|
26
|
+
VERTICAL: 'vertical' // Items with more content stacked vertically
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* List item layouts
|
|
31
|
+
*
|
|
32
|
+
* Individual item layout options controlling content arrangement.
|
|
33
|
+
*
|
|
34
|
+
* @category Components
|
|
35
|
+
*/
|
|
36
|
+
export const LIST_ITEM_LAYOUTS = {
|
|
37
|
+
HORIZONTAL: 'horizontal', // Default horizontal layout
|
|
38
|
+
VERTICAL: 'vertical' // Stacked layout with vertical alignment
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* List element class names
|
|
43
|
+
*
|
|
44
|
+
* CSS class names for the various elements that make up a list.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export const LIST_CLASSES = {
|
|
49
|
+
ROOT: 'list',
|
|
50
|
+
GROUP: 'list-group',
|
|
51
|
+
GROUP_TITLE: 'list-group-title',
|
|
52
|
+
DIVIDER: 'list-divider',
|
|
53
|
+
SECTION: 'list-section',
|
|
54
|
+
SECTION_TITLE: 'list-section-title',
|
|
55
|
+
ITEM: 'list-item',
|
|
56
|
+
ITEM_CONTENT: 'list-item-content',
|
|
57
|
+
ITEM_LEADING: 'list-item-leading',
|
|
58
|
+
ITEM_TEXT: 'list-item-text',
|
|
59
|
+
ITEM_OVERLINE: 'list-item-overline',
|
|
60
|
+
ITEM_HEADLINE: 'list-item-headline',
|
|
61
|
+
ITEM_SUPPORTING: 'list-item-supporting',
|
|
62
|
+
ITEM_META: 'list-item-meta',
|
|
63
|
+
ITEM_TRAILING: 'list-item-trailing'
|
|
64
|
+
} as const;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* List validation schema
|
|
68
|
+
*
|
|
69
|
+
* JSON Schema for validating list configuration options.
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export const LIST_SCHEMA = {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
type: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
enum: Object.values(LIST_TYPES),
|
|
79
|
+
default: LIST_TYPES.DEFAULT
|
|
80
|
+
},
|
|
81
|
+
layout: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
enum: Object.values(LIST_LAYOUTS),
|
|
84
|
+
default: LIST_LAYOUTS.HORIZONTAL
|
|
85
|
+
},
|
|
86
|
+
items: {
|
|
87
|
+
type: 'array',
|
|
88
|
+
items: {
|
|
89
|
+
type: 'object'
|
|
90
|
+
},
|
|
91
|
+
default: []
|
|
92
|
+
},
|
|
93
|
+
groups: {
|
|
94
|
+
type: 'array',
|
|
95
|
+
items: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
id: { type: 'string', required: true },
|
|
99
|
+
title: { type: 'string' },
|
|
100
|
+
items: { type: 'array' }
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
optional: true
|
|
104
|
+
},
|
|
105
|
+
sections: {
|
|
106
|
+
type: 'array',
|
|
107
|
+
items: {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
id: { type: 'string', required: true },
|
|
111
|
+
title: { type: 'string', required: true },
|
|
112
|
+
items: { type: 'array', required: true }
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
optional: true
|
|
116
|
+
},
|
|
117
|
+
disabled: {
|
|
118
|
+
type: 'boolean',
|
|
119
|
+
default: false
|
|
120
|
+
},
|
|
121
|
+
class: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
optional: true
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} as const;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* List item states
|
|
130
|
+
*
|
|
131
|
+
* Visual states that list items can have.
|
|
132
|
+
*
|
|
133
|
+
* @category Components
|
|
134
|
+
*/
|
|
135
|
+
export const LIST_ITEM_STATES = {
|
|
136
|
+
SELECTED: 'selected',
|
|
137
|
+
DISABLED: 'disabled',
|
|
138
|
+
FOCUSED: 'focused',
|
|
139
|
+
HOVERED: 'hovered'
|
|
140
|
+
} as const;
|
|
141
|
+
|
|
3
142
|
/**
|
|
4
143
|
* List type variants
|
|
5
144
|
* @category Components
|
|
@@ -48,6 +187,11 @@ export type ListItemState = 'selected' | 'disabled' | 'focused' | 'hovered';
|
|
|
48
187
|
|
|
49
188
|
/**
|
|
50
189
|
* List item configuration
|
|
190
|
+
*
|
|
191
|
+
* Configuration options for creating a list item with customizable content
|
|
192
|
+
* and appearance following Material Design 3 guidelines.
|
|
193
|
+
*
|
|
194
|
+
* @category Components
|
|
51
195
|
*/
|
|
52
196
|
export interface ListItemConfig {
|
|
53
197
|
/** Unique identifier for the item */
|
|
@@ -92,6 +236,11 @@ export interface ListItemConfig {
|
|
|
92
236
|
|
|
93
237
|
/**
|
|
94
238
|
* List section configuration
|
|
239
|
+
*
|
|
240
|
+
* Configuration for a list section, which groups items under a title.
|
|
241
|
+
* Sections help organize list content into logical groups.
|
|
242
|
+
*
|
|
243
|
+
* @category Components
|
|
95
244
|
*/
|
|
96
245
|
export interface ListSectionConfig {
|
|
97
246
|
/** Unique identifier for the section */
|
|
@@ -106,6 +255,11 @@ export interface ListSectionConfig {
|
|
|
106
255
|
|
|
107
256
|
/**
|
|
108
257
|
* Selection change event data
|
|
258
|
+
*
|
|
259
|
+
* Data structure provided with selectionChange events
|
|
260
|
+
* when list items are selected or deselected.
|
|
261
|
+
*
|
|
262
|
+
* @category Components
|
|
109
263
|
*/
|
|
110
264
|
export interface SelectionChangeEvent {
|
|
111
265
|
/** Array of selected item IDs */
|
|
@@ -120,6 +274,10 @@ export interface SelectionChangeEvent {
|
|
|
120
274
|
|
|
121
275
|
/**
|
|
122
276
|
* List item data
|
|
277
|
+
*
|
|
278
|
+
* Internal data structure for tracking list items and their state.
|
|
279
|
+
*
|
|
280
|
+
* @internal
|
|
123
281
|
*/
|
|
124
282
|
export interface ListItemData {
|
|
125
283
|
/** The item's DOM element */
|
|
@@ -134,6 +292,11 @@ export interface ListItemData {
|
|
|
134
292
|
|
|
135
293
|
/**
|
|
136
294
|
* Configuration interface for the List component
|
|
295
|
+
*
|
|
296
|
+
* Comprehensive options for creating and customizing a List
|
|
297
|
+
* according to Material Design 3 guidelines.
|
|
298
|
+
*
|
|
299
|
+
* @category Components
|
|
137
300
|
*/
|
|
138
301
|
export interface ListConfig {
|
|
139
302
|
/** List selection type */
|
|
@@ -163,6 +326,11 @@ export interface ListConfig {
|
|
|
163
326
|
|
|
164
327
|
/**
|
|
165
328
|
* List component interface
|
|
329
|
+
*
|
|
330
|
+
* Public API for the List component, providing methods for
|
|
331
|
+
* item management, selection handling, and event management.
|
|
332
|
+
*
|
|
333
|
+
* @category Components
|
|
166
334
|
*/
|
|
167
335
|
export interface ListComponent {
|
|
168
336
|
/** The root element of the list */
|
|
@@ -204,6 +372,10 @@ export interface ListComponent {
|
|
|
204
372
|
|
|
205
373
|
/**
|
|
206
374
|
* Base component interface
|
|
375
|
+
*
|
|
376
|
+
* Internal interface for component composition in the List component.
|
|
377
|
+
*
|
|
378
|
+
* @internal
|
|
207
379
|
*/
|
|
208
380
|
export interface BaseComponent {
|
|
209
381
|
element: HTMLElement;
|
|
@@ -20,9 +20,15 @@ const LIST_CLASS_NAMES = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Creates a divider element
|
|
23
|
+
* Creates a divider element for lists
|
|
24
|
+
*
|
|
25
|
+
* Creates a horizontal divider that can be used to separate list items
|
|
26
|
+
* following Material Design 3 guidelines.
|
|
27
|
+
*
|
|
24
28
|
* @param {string} prefix - CSS class prefix
|
|
25
29
|
* @returns {HTMLElement} Divider element
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
26
32
|
*/
|
|
27
33
|
export const createDivider = (prefix: string): HTMLElement => {
|
|
28
34
|
const divider = document.createElement('div');
|
|
@@ -32,10 +38,16 @@ export const createDivider = (prefix: string): HTMLElement => {
|
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
|
-
* Creates a section title element
|
|
41
|
+
* Creates a section title element for lists
|
|
42
|
+
*
|
|
43
|
+
* Creates a section header element used to group list items into logical sections
|
|
44
|
+
* following Material Design 3 guidelines for list organization.
|
|
45
|
+
*
|
|
36
46
|
* @param {string} title - Section title text
|
|
37
47
|
* @param {string} prefix - CSS class prefix
|
|
38
48
|
* @returns {HTMLElement} Section title element
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
39
51
|
*/
|
|
40
52
|
export const createSectionTitle = (title: string, prefix: string): HTMLElement => {
|
|
41
53
|
const titleEl = document.createElement('div');
|
|
@@ -46,10 +58,16 @@ export const createSectionTitle = (title: string, prefix: string): HTMLElement =
|
|
|
46
58
|
|
|
47
59
|
/**
|
|
48
60
|
* Creates a DOM element with optional class and content
|
|
61
|
+
*
|
|
62
|
+
* Utility function for creating DOM elements with proper class names and content
|
|
63
|
+
* for list items and their sub-elements.
|
|
64
|
+
*
|
|
49
65
|
* @param {string} tag - HTML tag name
|
|
50
66
|
* @param {string} className - CSS class name
|
|
51
67
|
* @param {string|HTMLElement} [content] - Element content or child element
|
|
52
68
|
* @returns {HTMLElement} Created element
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
53
71
|
*/
|
|
54
72
|
export const createElement = (tag: string, className: string, content?: string | HTMLElement): HTMLElement => {
|
|
55
73
|
const element = document.createElement(tag);
|
|
@@ -66,8 +84,14 @@ export const createElement = (tag: string, className: string, content?: string |
|
|
|
66
84
|
|
|
67
85
|
/**
|
|
68
86
|
* Gets the class name for a list element
|
|
87
|
+
*
|
|
88
|
+
* Retrieves the standard class name for list elements from a consistent
|
|
89
|
+
* centralized naming scheme.
|
|
90
|
+
*
|
|
69
91
|
* @param {string} element - Element name
|
|
70
92
|
* @returns {string} The class name string
|
|
93
|
+
*
|
|
94
|
+
* @internal
|
|
71
95
|
*/
|
|
72
96
|
export const getListClass = (element: keyof typeof LIST_CLASS_NAMES): string => {
|
|
73
97
|
return LIST_CLASS_NAMES[element];
|