mtrl 0.1.3 → 0.2.0

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.
Files changed (224) hide show
  1. package/README.md +70 -22
  2. package/index.ts +33 -0
  3. package/package.json +14 -5
  4. package/src/components/button/{styles.scss → _styles.scss} +2 -2
  5. package/src/components/button/api.ts +89 -0
  6. package/src/components/button/button.ts +50 -0
  7. package/src/components/button/config.ts +75 -0
  8. package/src/components/button/constants.ts +17 -0
  9. package/src/components/button/index.ts +4 -0
  10. package/src/components/button/types.ts +118 -0
  11. package/src/components/card/{styles.scss → _styles.scss} +79 -7
  12. package/src/components/card/{actions.js → actions.ts} +15 -18
  13. package/src/components/card/{api.js → api.ts} +33 -33
  14. package/src/components/card/card.ts +41 -0
  15. package/src/components/card/config.ts +99 -0
  16. package/src/components/card/{constants.js → constants.ts} +11 -10
  17. package/src/components/card/{content.js → content.ts} +15 -18
  18. package/src/components/card/{features.js → features.ts} +104 -94
  19. package/src/components/card/{header.js → header.ts} +21 -25
  20. package/src/components/card/index.ts +19 -0
  21. package/src/components/card/media.ts +52 -0
  22. package/src/components/card/types.ts +174 -0
  23. package/src/components/checkbox/api.ts +82 -0
  24. package/src/components/checkbox/checkbox.ts +75 -0
  25. package/src/components/checkbox/config.ts +90 -0
  26. package/src/components/checkbox/index.ts +4 -0
  27. package/src/components/checkbox/types.ts +146 -0
  28. package/src/components/chip/_styles.scss +372 -0
  29. package/src/components/chip/api.ts +115 -0
  30. package/src/components/chip/chip-set.ts +225 -0
  31. package/src/components/chip/chip.ts +82 -0
  32. package/src/components/chip/config.ts +92 -0
  33. package/src/components/chip/constants.ts +38 -0
  34. package/src/components/chip/index.ts +4 -0
  35. package/src/components/chip/types.ts +172 -0
  36. package/src/components/list/api.ts +72 -0
  37. package/src/components/list/config.ts +43 -0
  38. package/src/components/list/{constants.js → constants.ts} +34 -7
  39. package/src/components/list/features.ts +224 -0
  40. package/src/components/list/index.ts +14 -0
  41. package/src/components/list/list-item.ts +120 -0
  42. package/src/components/list/list.ts +37 -0
  43. package/src/components/list/types.ts +179 -0
  44. package/src/components/list/utils.ts +47 -0
  45. package/src/components/menu/api.ts +119 -0
  46. package/src/components/menu/config.ts +54 -0
  47. package/src/components/menu/constants.ts +154 -0
  48. package/src/components/menu/features/items-manager.ts +457 -0
  49. package/src/components/menu/features/keyboard-navigation.ts +133 -0
  50. package/src/components/menu/features/positioning.ts +127 -0
  51. package/src/components/menu/features/{visibility.js → visibility.ts} +66 -64
  52. package/src/components/menu/index.ts +14 -0
  53. package/src/components/menu/menu-item.ts +43 -0
  54. package/src/components/menu/menu.ts +53 -0
  55. package/src/components/menu/types.ts +178 -0
  56. package/src/components/navigation/api.ts +79 -0
  57. package/src/components/navigation/config.ts +61 -0
  58. package/src/components/navigation/{constants.js → constants.ts} +10 -10
  59. package/src/components/navigation/index.ts +14 -0
  60. package/src/components/navigation/nav-item.ts +148 -0
  61. package/src/components/navigation/navigation.ts +50 -0
  62. package/src/components/navigation/types.ts +212 -0
  63. package/src/components/progress/_styles.scss +204 -0
  64. package/src/components/progress/api.ts +179 -0
  65. package/src/components/progress/config.ts +124 -0
  66. package/src/components/progress/constants.ts +43 -0
  67. package/src/components/progress/index.ts +5 -0
  68. package/src/components/progress/progress.ts +163 -0
  69. package/src/components/progress/types.ts +102 -0
  70. package/src/components/snackbar/api.ts +162 -0
  71. package/src/components/snackbar/config.ts +62 -0
  72. package/src/components/snackbar/{constants.js → constants.ts} +21 -4
  73. package/src/components/snackbar/features.ts +76 -0
  74. package/src/components/snackbar/index.ts +4 -0
  75. package/src/components/snackbar/position.ts +71 -0
  76. package/src/components/snackbar/queue.ts +76 -0
  77. package/src/components/snackbar/snackbar.ts +60 -0
  78. package/src/components/snackbar/types.ts +58 -0
  79. package/src/components/switch/api.ts +77 -0
  80. package/src/components/switch/config.ts +74 -0
  81. package/src/components/switch/index.ts +4 -0
  82. package/src/components/switch/switch.ts +52 -0
  83. package/src/components/switch/types.ts +142 -0
  84. package/src/components/textfield/api.ts +72 -0
  85. package/src/components/textfield/config.ts +54 -0
  86. package/src/components/textfield/{constants.js → constants.ts} +38 -5
  87. package/src/components/textfield/index.ts +4 -0
  88. package/src/components/textfield/textfield.ts +50 -0
  89. package/src/components/textfield/types.ts +139 -0
  90. package/src/core/compose/base.ts +43 -0
  91. package/src/core/compose/component.ts +247 -0
  92. package/src/core/compose/features/checkable.ts +155 -0
  93. package/src/core/compose/features/disabled.ts +116 -0
  94. package/src/core/compose/features/events.ts +65 -0
  95. package/src/core/compose/features/icon.ts +67 -0
  96. package/src/core/compose/features/index.ts +35 -0
  97. package/src/core/compose/features/input.ts +174 -0
  98. package/src/core/compose/features/lifecycle.ts +139 -0
  99. package/src/core/compose/features/position.ts +94 -0
  100. package/src/core/compose/features/ripple.ts +55 -0
  101. package/src/core/compose/features/size.ts +29 -0
  102. package/src/core/compose/features/style.ts +31 -0
  103. package/src/core/compose/features/text.ts +44 -0
  104. package/src/core/compose/features/textinput.ts +225 -0
  105. package/src/core/compose/features/textlabel.ts +92 -0
  106. package/src/core/compose/features/track.ts +84 -0
  107. package/src/core/compose/features/variant.ts +29 -0
  108. package/src/core/compose/features/withEvents.ts +137 -0
  109. package/src/core/compose/index.ts +54 -0
  110. package/src/core/compose/{pipe.js → pipe.ts} +16 -11
  111. package/src/core/config/component-config.ts +136 -0
  112. package/src/core/config.ts +211 -0
  113. package/src/core/dom/{attributes.js → attributes.ts} +11 -11
  114. package/src/core/dom/classes.ts +60 -0
  115. package/src/core/dom/create.ts +188 -0
  116. package/src/core/dom/events.ts +209 -0
  117. package/src/core/dom/index.ts +10 -0
  118. package/src/core/dom/utils.ts +97 -0
  119. package/src/core/index.ts +111 -0
  120. package/src/core/state/disabled.ts +81 -0
  121. package/src/core/state/emitter.ts +94 -0
  122. package/src/core/state/events.ts +88 -0
  123. package/src/core/state/index.ts +16 -0
  124. package/src/core/state/lifecycle.ts +131 -0
  125. package/src/core/state/store.ts +197 -0
  126. package/src/core/utils/index.ts +45 -0
  127. package/src/core/utils/{mobile.js → mobile.ts} +48 -24
  128. package/src/core/utils/object.ts +41 -0
  129. package/src/core/utils/validate.ts +234 -0
  130. package/src/{index.js → index.ts} +3 -2
  131. package/index.js +0 -11
  132. package/src/components/button/api.js +0 -54
  133. package/src/components/button/button.js +0 -81
  134. package/src/components/button/config.js +0 -10
  135. package/src/components/button/constants.js +0 -63
  136. package/src/components/button/index.js +0 -2
  137. package/src/components/card/card.js +0 -102
  138. package/src/components/card/config.js +0 -16
  139. package/src/components/card/index.js +0 -7
  140. package/src/components/card/media.js +0 -56
  141. package/src/components/checkbox/api.js +0 -45
  142. package/src/components/checkbox/checkbox.js +0 -96
  143. package/src/components/checkbox/index.js +0 -2
  144. package/src/components/container/api.js +0 -42
  145. package/src/components/container/container.js +0 -45
  146. package/src/components/container/index.js +0 -2
  147. package/src/components/container/styles.scss +0 -66
  148. package/src/components/list/index.js +0 -2
  149. package/src/components/list/list-item.js +0 -147
  150. package/src/components/list/list.js +0 -267
  151. package/src/components/menu/api.js +0 -117
  152. package/src/components/menu/constants.js +0 -42
  153. package/src/components/menu/features/items-manager.js +0 -375
  154. package/src/components/menu/features/keyboard-navigation.js +0 -129
  155. package/src/components/menu/features/positioning.js +0 -125
  156. package/src/components/menu/index.js +0 -2
  157. package/src/components/menu/menu-item.js +0 -41
  158. package/src/components/menu/menu.js +0 -54
  159. package/src/components/navigation/api.js +0 -43
  160. package/src/components/navigation/index.js +0 -2
  161. package/src/components/navigation/nav-item.js +0 -137
  162. package/src/components/navigation/navigation.js +0 -55
  163. package/src/components/snackbar/api.js +0 -125
  164. package/src/components/snackbar/features.js +0 -69
  165. package/src/components/snackbar/index.js +0 -2
  166. package/src/components/snackbar/position.js +0 -63
  167. package/src/components/snackbar/queue.js +0 -74
  168. package/src/components/snackbar/snackbar.js +0 -70
  169. package/src/components/switch/api.js +0 -44
  170. package/src/components/switch/index.js +0 -2
  171. package/src/components/switch/switch.js +0 -71
  172. package/src/components/textfield/api.js +0 -49
  173. package/src/components/textfield/index.js +0 -2
  174. package/src/components/textfield/textfield.js +0 -68
  175. package/src/core/build/_ripple.scss +0 -79
  176. package/src/core/build/constants.js +0 -51
  177. package/src/core/build/icon.js +0 -78
  178. package/src/core/build/ripple.js +0 -159
  179. package/src/core/build/text.js +0 -54
  180. package/src/core/compose/base.js +0 -8
  181. package/src/core/compose/component.js +0 -225
  182. package/src/core/compose/features/checkable.js +0 -114
  183. package/src/core/compose/features/disabled.js +0 -64
  184. package/src/core/compose/features/events.js +0 -48
  185. package/src/core/compose/features/icon.js +0 -33
  186. package/src/core/compose/features/index.js +0 -20
  187. package/src/core/compose/features/input.js +0 -100
  188. package/src/core/compose/features/lifecycle.js +0 -69
  189. package/src/core/compose/features/position.js +0 -60
  190. package/src/core/compose/features/ripple.js +0 -32
  191. package/src/core/compose/features/size.js +0 -9
  192. package/src/core/compose/features/style.js +0 -12
  193. package/src/core/compose/features/text.js +0 -17
  194. package/src/core/compose/features/textinput.js +0 -114
  195. package/src/core/compose/features/textlabel.js +0 -28
  196. package/src/core/compose/features/track.js +0 -49
  197. package/src/core/compose/features/variant.js +0 -9
  198. package/src/core/compose/features/withEvents.js +0 -67
  199. package/src/core/compose/index.js +0 -16
  200. package/src/core/config.js +0 -140
  201. package/src/core/dom/classes.js +0 -70
  202. package/src/core/dom/create.js +0 -132
  203. package/src/core/dom/events.js +0 -175
  204. package/src/core/dom/index.js +0 -5
  205. package/src/core/dom/utils.js +0 -22
  206. package/src/core/index.js +0 -23
  207. package/src/core/state/disabled.js +0 -51
  208. package/src/core/state/emitter.js +0 -63
  209. package/src/core/state/events.js +0 -29
  210. package/src/core/state/index.js +0 -6
  211. package/src/core/state/lifecycle.js +0 -64
  212. package/src/core/state/store.js +0 -112
  213. package/src/core/utils/index.js +0 -39
  214. package/src/core/utils/object.js +0 -22
  215. package/src/core/utils/validate.js +0 -37
  216. /package/src/components/checkbox/{styles.scss → _styles.scss} +0 -0
  217. /package/src/components/checkbox/{constants.js → constants.ts} +0 -0
  218. /package/src/components/list/{styles.scss → _styles.scss} +0 -0
  219. /package/src/components/menu/{styles.scss → _styles.scss} +0 -0
  220. /package/src/components/navigation/{styles.scss → _styles.scss} +0 -0
  221. /package/src/components/snackbar/{styles.scss → _styles.scss} +0 -0
  222. /package/src/components/switch/{styles.scss → _styles.scss} +0 -0
  223. /package/src/components/switch/{constants.js → constants.ts} +0 -0
  224. /package/src/components/textfield/{styles.scss → _styles.scss} +0 -0
@@ -1,45 +0,0 @@
1
- // src/components/checkbox/api.js
2
-
3
- /**
4
- * Enhances checkbox component with API methods
5
- * @param {Object} options - API configuration
6
- * @param {Object} options.disabled - Disabled state handlers
7
- * @param {Object} options.lifecycle - Lifecycle handlers
8
- * @param {Object} options.checkable - Checked state handlers
9
- */
10
- export const withAPI = ({ disabled, lifecycle, checkable }) => (component) => ({
11
- ...component,
12
- element: component.element,
13
-
14
- // Value management
15
- getValue: component.getValue,
16
- setValue (value) {
17
- component.setValue(value)
18
- return this
19
- },
20
-
21
- // State management
22
- check: checkable.check,
23
- uncheck: checkable.uncheck,
24
- toggle: checkable.toggle,
25
- isChecked: checkable.isChecked,
26
- setIndeterminate: component.setIndeterminate,
27
-
28
- // Label management
29
- setLabel (text) {
30
- component.text?.setText(text)
31
- return this
32
- },
33
- getLabel () {
34
- return component.text?.getText() || ''
35
- },
36
-
37
- // Event handling
38
- on: component.on,
39
- off: component.off,
40
-
41
- // State management
42
- enable: disabled.enable,
43
- disable: disabled.disable,
44
- destroy: lifecycle.destroy
45
- })
@@ -1,96 +0,0 @@
1
- // src/components/checkbox/checkbox.js
2
-
3
- import { PREFIX } from '../../core/config'
4
- import { pipe } from '../../core/compose'
5
- import { createBase, withElement } from '../../core/compose/component'
6
- import {
7
- withEvents,
8
- withTextLabel,
9
- withDisabled,
10
- withLifecycle,
11
- withInput,
12
- withCheckable
13
- } from '../../core/compose/features'
14
- import { withAPI } from './api'
15
- import { CHECKBOX_VARIANTS } from './constants'
16
-
17
- /**
18
- * Adds check icon to checkbox
19
- * @param {Object} config - Component configuration
20
- */
21
- const withCheckIcon = (config) => (component) => {
22
- const icon = document.createElement('span')
23
- icon.className = `${config.prefix}-checkbox-icon`
24
- icon.innerHTML = `
25
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
26
- <path d="M9.55 14.6L6.35 11.4l-1.9 1.9L9.55 18.4l10.9-10.9-1.9-1.9z"/>
27
- </svg>
28
- `
29
-
30
- component.element.appendChild(icon)
31
- return component
32
- }
33
-
34
- /**
35
- * Creates a new Checkbox component
36
- * @param {Object} config - Checkbox configuration
37
- * @param {string} [config.name] - Input name attribute
38
- * @param {boolean} [config.checked] - Initial checked state
39
- * @param {boolean} [config.indeterminate] - Initial indeterminate state
40
- * @param {boolean} [config.required] - Whether input is required
41
- * @param {boolean} [config.disabled] - Whether checkbox is disabled
42
- * @param {string} [config.value] - Input value attribute
43
- * @param {string} [config.label] - Label text
44
- * @param {string} [config.labelPosition='end'] - Label position (start/end)
45
- * @param {string} [config.variant='filled'] - Visual variant
46
- * @param {string} [config.class] - Additional CSS classes
47
- */
48
- const createCheckbox = (config = {}) => {
49
- const baseConfig = {
50
- ...config,
51
- componentName: 'checkbox',
52
- prefix: PREFIX,
53
- variant: config.variant || CHECKBOX_VARIANTS.FILLED
54
- }
55
-
56
- const enhancedWithCheckable = (component) => {
57
- const enhanced = withCheckable(baseConfig)(component)
58
-
59
- // Add indeterminate state handling
60
- if (config.indeterminate) {
61
- enhanced.input.indeterminate = true
62
- }
63
-
64
- enhanced.setIndeterminate = (state) => {
65
- enhanced.input.indeterminate = state
66
- enhanced.element.classList.toggle(`${PREFIX}-checkbox--indeterminate`, state)
67
- return enhanced
68
- }
69
-
70
- return enhanced
71
- }
72
-
73
- return pipe(
74
- createBase,
75
- withEvents(),
76
- withElement({
77
- tag: 'div',
78
- componentName: 'checkbox',
79
- className: config.class,
80
- interactive: true
81
- }),
82
- withInput(baseConfig),
83
- withCheckIcon(baseConfig),
84
- withTextLabel(baseConfig),
85
- enhancedWithCheckable,
86
- withDisabled(baseConfig), // Pass the baseConfig to withDisabled
87
- withLifecycle(),
88
- comp => withAPI({
89
- disabled: comp.disabled,
90
- lifecycle: comp.lifecycle,
91
- checkable: comp.checkable
92
- })(comp)
93
- )(baseConfig)
94
- }
95
-
96
- export default createCheckbox
@@ -1,2 +0,0 @@
1
- // src/components/checkbox/index.js
2
- export { default } from './checkbox.js'
@@ -1,42 +0,0 @@
1
- // src/components/container/api.js
2
-
3
- /**
4
- * Enhances container component with API methods
5
- * @param {Object} options - API configuration
6
- * @param {Object} options.lifecycle - Lifecycle handlers
7
- */
8
- export const withAPI = ({ lifecycle }) => (component) => ({
9
- ...component,
10
- element: component.element,
11
-
12
- // Attribute management
13
- get (prop) {
14
- return component.element.getAttribute(prop)
15
- },
16
- set (prop, value) {
17
- value === null
18
- ? component.element.removeAttribute(prop)
19
- : component.element.setAttribute(prop, value)
20
- return this
21
- },
22
-
23
- // Content management
24
- setContent (content) {
25
- if (content instanceof Node) {
26
- component.element.appendChild(content)
27
- } else {
28
- component.element.innerHTML = content
29
- }
30
- return this
31
- },
32
- getContent () {
33
- return component.element.innerHTML
34
- },
35
-
36
- // Event handling
37
- on: component.on,
38
- off: component.off,
39
-
40
- // Lifecycle
41
- destroy: lifecycle.destroy
42
- })
@@ -1,45 +0,0 @@
1
- // src/components/container/container.js
2
- import { PREFIX } from '../../core/config'
3
- import { pipe } from '../../core/compose'
4
- import { createBase, withElement } from '../../core/compose/component'
5
- import { withEvents, withLifecycle } from '../../core/compose/features'
6
- import { withAPI } from './api'
7
-
8
- /**
9
- * Creates a new Container component
10
- * @param {Object} config - Container configuration
11
- * @param {string} [config.variant] - Visual variant
12
- * @param {number} [config.elevation] - Elevation level
13
- * @param {string} [config.class] - Additional CSS classes
14
- */
15
- const createContainer = (config = {}) => {
16
- const baseConfig = {
17
- ...config,
18
- componentName: 'container',
19
- prefix: PREFIX
20
- }
21
-
22
- try {
23
- return pipe(
24
- createBase,
25
- withElement({
26
- tag: 'div',
27
- componentName: 'container',
28
- className: [
29
- config.variant && `${PREFIX}-container--${config.variant}`,
30
- config.elevation && `${PREFIX}-container--elevation-${config.elevation}`,
31
- config.class
32
- ]
33
- }),
34
- withEvents(),
35
- withLifecycle(),
36
- comp => withAPI({
37
- lifecycle: comp.lifecycle
38
- })(comp)
39
- )(baseConfig)
40
- } catch (error) {
41
- throw new Error(`Failed to create container: ${error.message}`)
42
- }
43
- }
44
-
45
- export default createContainer
@@ -1,2 +0,0 @@
1
- // src/components/container/index.js
2
- export { default } from './container.js'
@@ -1,66 +0,0 @@
1
- // src/components/container/_container.scss
2
- @use '../../styles/abstract/base' as base;
3
- @use '../../styles/abstract/variables' as v;
4
- @use '../../styles/abstract/functions' as f;
5
- @use '../../styles/abstract/mixins' as m;
6
- @use '../../styles/abstract/theme' as t;
7
-
8
- $component: '#{base.$prefix}-container';
9
-
10
- .#{$component} {
11
- @include m.shape('medium');
12
- @include m.motion-transition(
13
- background-color,
14
- box-shadow
15
- );
16
-
17
- padding: 16px;
18
- background-color: t.color('surface-container');
19
-
20
- // Surface container variants
21
- &--low {
22
- background-color: t.color('surface-container-low');
23
- }
24
-
25
- &--lowest {
26
- background-color: t.color('surface-container-lowest');
27
- }
28
-
29
- &--high {
30
- background-color: t.color('surface-container-high');
31
- }
32
-
33
- &--highest {
34
- background-color: t.color('surface-container-highest');
35
- }
36
-
37
- // Elevation variants
38
- &--elevation-0 {
39
- @include m.elevation(0);
40
- }
41
-
42
- &--elevation-1 {
43
- @include m.elevation(1);
44
- }
45
-
46
- &--elevation-2 {
47
- @include m.elevation(2);
48
- }
49
-
50
- &--elevation-3 {
51
- @include m.elevation(3);
52
- }
53
-
54
- &--elevation-4 {
55
- @include m.elevation(4);
56
- }
57
-
58
- // Accessibility
59
- @include m.reduced-motion {
60
- transition: none;
61
- }
62
-
63
- @include m.high-contrast {
64
- border: 1px solid currentColor;
65
- }
66
- }
@@ -1,2 +0,0 @@
1
- // src/components/list/index.js
2
- export { default } from './list.js'
@@ -1,147 +0,0 @@
1
- // src/components/list/list-item.js
2
-
3
- import { PREFIX } from '../../core/config'
4
- import { pipe } from '../../core/compose'
5
- import { createBase, withElement } from '../../core/compose/component'
6
- import { withEvents, withDisabled } from '../../core/compose/features'
7
-
8
- /**
9
- * Supported list item layouts
10
- */
11
- export const LIST_ITEM_LAYOUTS = {
12
- HORIZONTAL: 'horizontal', // Default horizontal layout
13
- VERTICAL: 'vertical' // Stacked layout with vertical alignment
14
- }
15
-
16
- /**
17
- * Creates a DOM element with optional class and content
18
- * @param {string} tag - HTML tag name
19
- * @param {string} className - CSS class name
20
- * @param {string|HTMLElement} [content] - Element content or child element
21
- * @returns {HTMLElement} Created element
22
- */
23
- const createElement = (tag, className, content) => {
24
- const element = document.createElement(tag)
25
- element.className = className
26
- if (content) {
27
- if (typeof content === 'string') {
28
- element.textContent = content
29
- } else {
30
- element.appendChild(content)
31
- }
32
- }
33
- return element
34
- }
35
-
36
- /**
37
- * Creates a list item component
38
- * @param {Object} config - List item configuration
39
- * @param {string} [config.layout='horizontal'] - Item layout (horizontal/vertical)
40
- * @param {string|HTMLElement} [config.leading] - Leading content (icon/avatar)
41
- * @param {string} [config.headline] - Primary text
42
- * @param {string} [config.supportingText] - Secondary text
43
- * @param {string|HTMLElement} [config.trailing] - Trailing content (icon/meta)
44
- * @param {string} [config.overline] - Text above headline (vertical only)
45
- * @param {string|HTMLElement} [config.meta] - Meta information (vertical only)
46
- * @param {boolean} [config.disabled] - Disabled state
47
- * @param {boolean} [config.selected] - Selected state
48
- * @param {string} [config.class] - Additional CSS classes
49
- * @param {string} [config.role='listitem'] - ARIA role
50
- */
51
- const createListItem = (config = {}) => {
52
- const baseConfig = {
53
- ...config,
54
- componentName: 'list-item',
55
- prefix: PREFIX
56
- }
57
-
58
- const createContent = (component) => {
59
- const { element } = component
60
- const { prefix } = baseConfig
61
- const isVertical = config.layout === LIST_ITEM_LAYOUTS.VERTICAL
62
-
63
- // Create content container
64
- const content = createElement('div', `${prefix}-list-item-content`)
65
-
66
- // Add leading content (icon/avatar)
67
- if (config.leading) {
68
- const leading = createElement('div', `${prefix}-list-item-leading`)
69
- if (typeof config.leading === 'string') {
70
- leading.innerHTML = config.leading
71
- } else {
72
- leading.appendChild(config.leading)
73
- }
74
- element.appendChild(leading)
75
- }
76
-
77
- // Text wrapper for proper alignment
78
- const textWrapper = createElement('div', `${prefix}-list-item-text`)
79
-
80
- // Add overline text (vertical only)
81
- if (isVertical && config.overline) {
82
- const overline = createElement('div', `${prefix}-list-item-overline`, config.overline)
83
- textWrapper.appendChild(overline)
84
- }
85
-
86
- // Add headline (primary text)
87
- if (config.headline) {
88
- const headline = createElement('div', `${prefix}-list-item-headline`, config.headline)
89
- textWrapper.appendChild(headline)
90
- }
91
-
92
- // Add supporting text (secondary text)
93
- if (config.supportingText) {
94
- const supporting = createElement('div', `${prefix}-list-item-supporting`, config.supportingText)
95
- textWrapper.appendChild(supporting)
96
- }
97
-
98
- content.appendChild(textWrapper)
99
-
100
- // Add meta information (vertical only)
101
- if (isVertical && config.meta) {
102
- const meta = createElement('div', `${prefix}-list-item-meta`)
103
- if (typeof config.meta === 'string') {
104
- meta.textContent = config.meta
105
- } else {
106
- meta.appendChild(config.meta)
107
- }
108
- content.appendChild(meta)
109
- }
110
-
111
- element.appendChild(content)
112
-
113
- // Add trailing content (icon/meta)
114
- if (config.trailing) {
115
- const trailing = createElement('div', `${prefix}-list-item-trailing`)
116
- if (typeof config.trailing === 'string') {
117
- trailing.innerHTML = config.trailing
118
- } else {
119
- trailing.appendChild(config.trailing)
120
- }
121
- element.appendChild(trailing)
122
- }
123
-
124
- // Handle selected state
125
- if (config.selected) {
126
- element.setAttribute('aria-selected', 'true')
127
- element.classList.add(`${prefix}-list-item--selected`)
128
- }
129
-
130
- return component
131
- }
132
-
133
- return pipe(
134
- createBase,
135
- withEvents(),
136
- withElement({
137
- tag: 'div',
138
- role: config.role || 'listitem',
139
- componentName: 'list-item',
140
- className: `${config.layout === LIST_ITEM_LAYOUTS.VERTICAL ? 'vertical' : ''} ${config.class || ''}`
141
- }),
142
- withDisabled(),
143
- createContent
144
- )(baseConfig)
145
- }
146
-
147
- export default createListItem