mtrl 0.0.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 (121) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +251 -0
  3. package/index.js +10 -0
  4. package/package.json +17 -0
  5. package/src/components/button/api.js +54 -0
  6. package/src/components/button/button.js +81 -0
  7. package/src/components/button/config.js +8 -0
  8. package/src/components/button/constants.js +63 -0
  9. package/src/components/button/index.js +2 -0
  10. package/src/components/button/styles.scss +231 -0
  11. package/src/components/checkbox/api.js +45 -0
  12. package/src/components/checkbox/checkbox.js +95 -0
  13. package/src/components/checkbox/constants.js +88 -0
  14. package/src/components/checkbox/index.js +2 -0
  15. package/src/components/checkbox/styles.scss +183 -0
  16. package/src/components/container/api.js +42 -0
  17. package/src/components/container/container.js +45 -0
  18. package/src/components/container/index.js +2 -0
  19. package/src/components/container/styles.scss +59 -0
  20. package/src/components/list/constants.js +89 -0
  21. package/src/components/list/index.js +2 -0
  22. package/src/components/list/list-item.js +147 -0
  23. package/src/components/list/list.js +267 -0
  24. package/src/components/list/styles/_list-item.scss +142 -0
  25. package/src/components/list/styles/_list.scss +89 -0
  26. package/src/components/list/styles/_variables.scss +13 -0
  27. package/src/components/list/styles.scss +19 -0
  28. package/src/components/navigation/api.js +43 -0
  29. package/src/components/navigation/constants.js +235 -0
  30. package/src/components/navigation/features/items.js +192 -0
  31. package/src/components/navigation/index.js +2 -0
  32. package/src/components/navigation/nav-item.js +137 -0
  33. package/src/components/navigation/navigation.js +55 -0
  34. package/src/components/navigation/styles/_bar.scss +51 -0
  35. package/src/components/navigation/styles/_base.scss +129 -0
  36. package/src/components/navigation/styles/_drawer.scss +169 -0
  37. package/src/components/navigation/styles/_rail.scss +65 -0
  38. package/src/components/navigation/styles.scss +6 -0
  39. package/src/components/snackbar/api.js +125 -0
  40. package/src/components/snackbar/constants.js +41 -0
  41. package/src/components/snackbar/features.js +69 -0
  42. package/src/components/snackbar/index.js +2 -0
  43. package/src/components/snackbar/position.js +63 -0
  44. package/src/components/snackbar/queue.js +74 -0
  45. package/src/components/snackbar/snackbar.js +70 -0
  46. package/src/components/snackbar/styles.scss +182 -0
  47. package/src/components/switch/api.js +44 -0
  48. package/src/components/switch/constants.js +80 -0
  49. package/src/components/switch/index.js +2 -0
  50. package/src/components/switch/styles.scss +172 -0
  51. package/src/components/switch/switch.js +71 -0
  52. package/src/components/textfield/api.js +49 -0
  53. package/src/components/textfield/constants.js +81 -0
  54. package/src/components/textfield/index.js +2 -0
  55. package/src/components/textfield/styles/base.scss +107 -0
  56. package/src/components/textfield/styles/filled.scss +58 -0
  57. package/src/components/textfield/styles/outlined.scss +66 -0
  58. package/src/components/textfield/styles.scss +6 -0
  59. package/src/components/textfield/textfield.js +68 -0
  60. package/src/core/build/constants.js +51 -0
  61. package/src/core/build/icon.js +78 -0
  62. package/src/core/build/ripple.js +92 -0
  63. package/src/core/build/text.js +54 -0
  64. package/src/core/collection/adapters/base.js +26 -0
  65. package/src/core/collection/adapters/mongodb.js +232 -0
  66. package/src/core/collection/adapters/route.js +201 -0
  67. package/src/core/collection/collection.js +259 -0
  68. package/src/core/collection/list-manager.js +157 -0
  69. package/src/core/compose/base.js +8 -0
  70. package/src/core/compose/component.js +225 -0
  71. package/src/core/compose/features/checkable.js +114 -0
  72. package/src/core/compose/features/disabled.js +25 -0
  73. package/src/core/compose/features/events.js +48 -0
  74. package/src/core/compose/features/icon.js +33 -0
  75. package/src/core/compose/features/index.js +20 -0
  76. package/src/core/compose/features/input.js +92 -0
  77. package/src/core/compose/features/lifecycle.js +69 -0
  78. package/src/core/compose/features/position.js +60 -0
  79. package/src/core/compose/features/ripple.js +32 -0
  80. package/src/core/compose/features/size.js +9 -0
  81. package/src/core/compose/features/style.js +12 -0
  82. package/src/core/compose/features/text.js +17 -0
  83. package/src/core/compose/features/textinput.js +118 -0
  84. package/src/core/compose/features/textlabel.js +28 -0
  85. package/src/core/compose/features/track.js +49 -0
  86. package/src/core/compose/features/variant.js +9 -0
  87. package/src/core/compose/features/withEvents.js +67 -0
  88. package/src/core/compose/index.js +16 -0
  89. package/src/core/compose/pipe.js +69 -0
  90. package/src/core/config.js +140 -0
  91. package/src/core/dom/attributes.js +33 -0
  92. package/src/core/dom/classes.js +70 -0
  93. package/src/core/dom/create.js +133 -0
  94. package/src/core/dom/events.js +175 -0
  95. package/src/core/dom/index.js +5 -0
  96. package/src/core/dom/utils.js +22 -0
  97. package/src/core/index.js +23 -0
  98. package/src/core/layout/index.js +93 -0
  99. package/src/core/state/disabled.js +14 -0
  100. package/src/core/state/emitter.js +63 -0
  101. package/src/core/state/events.js +29 -0
  102. package/src/core/state/index.js +6 -0
  103. package/src/core/state/lifecycle.js +64 -0
  104. package/src/core/state/store.js +112 -0
  105. package/src/core/utils/index.js +39 -0
  106. package/src/core/utils/mobile.js +74 -0
  107. package/src/core/utils/object.js +22 -0
  108. package/src/core/utils/validate.js +37 -0
  109. package/src/index.js +11 -0
  110. package/src/styles/abstract/_base.scss +2 -0
  111. package/src/styles/abstract/_config.scss +28 -0
  112. package/src/styles/abstract/_functions.scss +124 -0
  113. package/src/styles/abstract/_mixins.scss +261 -0
  114. package/src/styles/abstract/_variables.scss +158 -0
  115. package/src/styles/main.scss +78 -0
  116. package/src/styles/themes/_base-theme.scss +49 -0
  117. package/src/styles/themes/_baseline.scss +90 -0
  118. package/src/styles/themes/_forest.scss +71 -0
  119. package/src/styles/themes/_index.scss +6 -0
  120. package/src/styles/themes/_ocean.scss +71 -0
  121. package/src/styles/themes/_sunset.scss +55 -0
@@ -0,0 +1,142 @@
1
+ // src/components/list/styles/_list-item.scss
2
+
3
+ @use '../../../styles/abstract/config' as c;
4
+ @use 'variables' as v;
5
+
6
+ .#{c.$prefix}-list-item {
7
+ display: flex;
8
+ align-items: center;
9
+ min-height: v.$list-item-height;
10
+ padding: v.$list-padding v.$list-item-padding;
11
+ position: relative;
12
+ gap: 16px;
13
+ cursor: pointer;
14
+ color: var(--mtrl-sys-color-on-surface);
15
+ @include c.motion-transition(background-color);
16
+
17
+ &:hover {
18
+ @include c.state-layer(v.$list-hover-state-layer-color, 'hover');
19
+ }
20
+
21
+ &:focus-visible {
22
+ @include c.state-layer(v.$list-hover-state-layer-color, 'focus');
23
+ outline: none;
24
+ }
25
+
26
+ &:active {
27
+ @include c.state-layer(v.$list-hover-state-layer-color, 'pressed');
28
+ }
29
+
30
+ // Content layout
31
+ &-content {
32
+ flex: 1;
33
+ min-width: 0; // Enable text truncation
34
+ display: flex;
35
+ flex-direction: column;
36
+ justify-content: center;
37
+ }
38
+
39
+ // Text elements
40
+ &-text {
41
+ display: flex;
42
+ flex-direction: column;
43
+ gap: 4px;
44
+ }
45
+
46
+ &-overline {
47
+ @include c.typography('label-small');
48
+ color: var(--mtrl-sys-color-on-surface-variant);
49
+ }
50
+
51
+ &-headline {
52
+ @include c.typography('body-large');
53
+ color: var(--mtrl-sys-color-on-surface);
54
+ }
55
+
56
+ &-supporting {
57
+ @include c.typography('body-medium');
58
+ color: var(--mtrl-sys-color-on-surface-variant);
59
+ }
60
+
61
+ &-meta {
62
+ @include c.typography('label-small');
63
+ color: var(--mtrl-sys-color-on-surface-variant);
64
+ margin-top: 4px;
65
+ }
66
+
67
+ // Leading/trailing elements
68
+ &-leading,
69
+ &-trailing {
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ flex-shrink: 0;
74
+ }
75
+
76
+ &-leading {
77
+ width: 24px;
78
+ height: 24px;
79
+ color: var(--mtrl-sys-color-on-surface-variant);
80
+
81
+ svg {
82
+ width: 100%;
83
+ height: 100%;
84
+ }
85
+ }
86
+
87
+ &-trailing {
88
+ color: var(--mtrl-sys-color-on-surface-variant);
89
+ }
90
+
91
+ // Vertical layout variant
92
+ &.vertical {
93
+ min-height: 72px;
94
+ padding: 12px v.$list-item-padding;
95
+
96
+ .#{c.$prefix}-list-item {
97
+ &-content {
98
+ flex-direction: column;
99
+ gap: 4px;
100
+ }
101
+
102
+ &-meta {
103
+ margin-top: v.$list-padding;
104
+ }
105
+ }
106
+ }
107
+
108
+ // States
109
+ &--selected {
110
+ background-color: var(--mtrl-sys-color-secondary-container);
111
+ color: var(--mtrl-sys-color-on-secondary-container);
112
+
113
+ .#{c.$prefix}-list-item {
114
+ &-leading,
115
+ &-trailing {
116
+ color: var(--mtrl-sys-color-on-secondary-container);
117
+ }
118
+ }
119
+ }
120
+
121
+ &--disabled {
122
+ opacity: 0.38;
123
+ pointer-events: none;
124
+ }
125
+
126
+ // RTL Support
127
+ @include c.rtl {
128
+ .#{c.$prefix}-list-item {
129
+ &-text {
130
+ text-align: right;
131
+ }
132
+ }
133
+ }
134
+
135
+ // High contrast mode
136
+ @include c.high-contrast {
137
+ &--selected {
138
+ outline: 2px solid currentColor;
139
+ outline-offset: -2px;
140
+ }
141
+ }
142
+ }
@@ -0,0 +1,89 @@
1
+ // src/components/list/styles/_list.scss
2
+
3
+ @use '../../../styles/abstract/config' as c;
4
+ @use 'variables' as v;
5
+
6
+ .#{c.$prefix}-list {
7
+ display: flex;
8
+ flex-direction: column;
9
+ padding: v.$list-padding 0;
10
+ min-width: 200px;
11
+ background-color: var(--mtrl-sys-color-surface);
12
+
13
+ // Sections
14
+ &-section {
15
+ display: flex;
16
+ flex-direction: column;
17
+ width: 100%;
18
+
19
+ &:not(:last-child) {
20
+ margin-bottom: v.$list-padding;
21
+ }
22
+ }
23
+
24
+ &-section-title {
25
+ @include c.typography('label-large');
26
+ color: v.$list-section-title-color;
27
+ padding: v.$list-section-padding v.$list-item-padding 8px;
28
+ }
29
+
30
+ // Dividers
31
+ &-divider {
32
+ height: 1px;
33
+ margin: v.$list-padding 0;
34
+ background-color: v.$list-divider-color;
35
+ }
36
+
37
+ // Selection states
38
+ &[data-type="single"],
39
+ &[data-type="multi"],
40
+ &[data-type="radio"] {
41
+ .#{c.$prefix}-list-item {
42
+ cursor: pointer;
43
+
44
+ &--selected {
45
+ background-color: var(--mtrl-sys-color-secondary-container);
46
+ color: var(--mtrl-sys-color-on-secondary-container);
47
+
48
+ &:hover {
49
+ background-color: var(--mtrl-sys-color-secondary-container);
50
+ @include c.state-layer(var(--mtrl-sys-color-on-secondary-container), 'hover');
51
+ }
52
+
53
+ .#{c.$prefix}-list-item-supporting {
54
+ color: var(--mtrl-sys-color-on-secondary-container);
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ // Dense variant
61
+ &--dense {
62
+ .#{c.$prefix}-list-item {
63
+ min-height: v.$list-item-dense-height;
64
+ }
65
+ }
66
+
67
+ // Disabled state
68
+ &--disabled {
69
+ pointer-events: none;
70
+ opacity: 0.38;
71
+ }
72
+
73
+ // RTL Support
74
+ @include c.rtl {
75
+ .#{c.$prefix}-list-section-title {
76
+ text-align: right;
77
+ }
78
+ }
79
+
80
+ // High contrast mode
81
+ @include c.high-contrast {
82
+ border: 1px solid currentColor;
83
+
84
+ &-divider {
85
+ border-top: 1px solid currentColor;
86
+ background: none;
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,13 @@
1
+ // src/components/list/styles/_variables.scss
2
+
3
+ // Component variables
4
+ $list-item-height: 48px !default;
5
+ $list-item-dense-height: 40px !default;
6
+ $list-padding: 8px !default;
7
+ $list-item-padding: 16px !default;
8
+ $list-section-padding: 16px !default;
9
+
10
+ // Color variables - can be overridden
11
+ $list-divider-color: var(--mtrl-sys-color-outline-variant) !default;
12
+ $list-section-title-color: var(--mtrl-sys-color-primary) !default;
13
+ $list-hover-state-layer-color: var(--mtrl-sys-color-on-surface) !default;
@@ -0,0 +1,19 @@
1
+ // src/components/list/styles.scss
2
+
3
+ // Import core configuration and utilities
4
+ @use '../../styles/abstract/config' as c;
5
+ @use '../../styles/abstract/mixins' as m;
6
+ @use './styles/variables' as v;
7
+ @use './styles/list';
8
+ @use './styles/list-item';
9
+
10
+ // Component-specific mixins
11
+ @mixin list-item-hover {
12
+ @include c.state-layer(v.$list-hover-state-layer-color, 'hover');
13
+ }
14
+
15
+ @mixin list-section-title {
16
+ @include c.typography('label-large');
17
+ color: v.$list-section-title-color;
18
+ padding: v.$list-section-padding v.$list-item-padding 8px;
19
+ }
@@ -0,0 +1,43 @@
1
+ // src/components/navigation/api.js
2
+
3
+ /**
4
+ * Enhances navigation 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
+ */
9
+ export const withAPI = ({ disabled, lifecycle }) => (component) => ({
10
+ ...component,
11
+ element: component.element,
12
+
13
+ // Item management
14
+ addItem (config) {
15
+ component.addItem?.(config)
16
+ return this
17
+ },
18
+ removeItem (id) {
19
+ component.removeItem?.(id)
20
+ return this
21
+ },
22
+ getItem (id) {
23
+ return component.getItem?.(id)
24
+ },
25
+
26
+ // Active state management
27
+ setActive (id) {
28
+ component.setActive?.(id)
29
+ return this
30
+ },
31
+ getActive () {
32
+ return component.getActive?.()
33
+ },
34
+
35
+ // Event handling
36
+ on: component.on,
37
+ off: component.off,
38
+
39
+ // State management
40
+ enable: disabled.enable,
41
+ disable: disabled.disable,
42
+ destroy: lifecycle.destroy
43
+ })
@@ -0,0 +1,235 @@
1
+ // src/components/navigation/constants.js
2
+
3
+ /**
4
+ * Navigation variants following Material Design 3
5
+ */
6
+ export const NAV_VARIANTS = {
7
+ RAIL: 'rail', // Vertical slim navigation
8
+ DRAWER: 'drawer', // Expandable side navigation
9
+ BAR: 'bar', // Bottom or top navigation bar
10
+ DRAWER_MODAL: 'modal', // Modal drawer overlay
11
+ DRAWER_STANDARD: 'standard' // Standard permanent drawer
12
+ }
13
+
14
+ /**
15
+ * Navigation positions
16
+ */
17
+ export const NAV_POSITIONS = {
18
+ LEFT: 'left',
19
+ RIGHT: 'right',
20
+ TOP: 'top',
21
+ BOTTOM: 'bottom'
22
+ }
23
+
24
+ /**
25
+ * Navigation behaviors
26
+ */
27
+ export const NAV_BEHAVIORS = {
28
+ FIXED: 'fixed', // Always visible
29
+ DISMISSIBLE: 'dismissible', // Can be dismissed/hidden
30
+ MODAL: 'modal' // Overlays content with scrim
31
+ }
32
+
33
+ /**
34
+ * Navigation state classes
35
+ */
36
+ export const NAV_STATES = {
37
+ ACTIVE: 'active', // Currently selected item
38
+ DISABLED: 'disabled', // Disabled state
39
+ EXPANDED: 'expanded', // Drawer expanded state
40
+ COLLAPSED: 'collapsed', // Drawer collapsed state
41
+ HOVERED: 'hovered', // Hover state
42
+ FOCUSED: 'focused', // Keyboard focus state
43
+ PRESSED: 'pressed' // Press/click state
44
+ }
45
+
46
+ /**
47
+ * Navigation element classes
48
+ */
49
+ export const NAV_CLASSES = {
50
+ ROOT: 'nav',
51
+ ITEM: 'nav-item',
52
+ ITEM_CONTAINER: 'nav-item-container',
53
+ ICON: 'nav-item-icon',
54
+ LABEL: 'nav-item-label',
55
+ BADGE: 'nav-item-badge',
56
+ DIVIDER: 'nav-divider',
57
+ SCRIM: 'nav-scrim',
58
+ GROUP: 'nav-group',
59
+ GROUP_TITLE: 'nav-group-title',
60
+ SUBTITLE: 'nav-subtitle',
61
+ NESTED_CONTAINER: 'nav-nested-container',
62
+ NESTED_ITEM: 'nav-nested-item',
63
+ EXPAND_ICON: 'nav-expand-icon'
64
+ }
65
+
66
+ /**
67
+ * Validation schema for navigation configuration
68
+ */
69
+ export const NAV_SCHEMA = {
70
+ type: 'object',
71
+ properties: {
72
+ variant: {
73
+ type: 'string',
74
+ enum: Object.values(NAV_VARIANTS),
75
+ optional: true,
76
+ default: NAV_VARIANTS.RAIL
77
+ },
78
+ position: {
79
+ type: 'string',
80
+ enum: Object.values(NAV_POSITIONS),
81
+ optional: true,
82
+ default: NAV_POSITIONS.LEFT
83
+ },
84
+ behavior: {
85
+ type: 'string',
86
+ enum: Object.values(NAV_BEHAVIORS),
87
+ optional: true,
88
+ default: NAV_BEHAVIORS.FIXED
89
+ },
90
+ items: {
91
+ type: 'array',
92
+ optional: true,
93
+ default: []
94
+ },
95
+ groups: {
96
+ type: 'array',
97
+ optional: true
98
+ },
99
+ disabled: {
100
+ type: 'boolean',
101
+ optional: true
102
+ },
103
+ expanded: {
104
+ type: 'boolean',
105
+ optional: true
106
+ },
107
+ showLabels: {
108
+ type: 'boolean',
109
+ optional: true,
110
+ default: true
111
+ },
112
+ scrimEnabled: {
113
+ type: 'boolean',
114
+ optional: true,
115
+ default: false
116
+ },
117
+ class: {
118
+ type: 'string',
119
+ optional: true
120
+ }
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Navigation item schema
126
+ */
127
+ export const NAV_ITEM_SCHEMA = {
128
+ type: 'object',
129
+ properties: {
130
+ id: {
131
+ type: 'string',
132
+ required: true
133
+ },
134
+ icon: {
135
+ type: 'string',
136
+ required: true
137
+ },
138
+ label: {
139
+ type: 'string',
140
+ required: true
141
+ },
142
+ badge: {
143
+ type: 'string',
144
+ optional: true
145
+ },
146
+ disabled: {
147
+ type: 'boolean',
148
+ optional: true
149
+ },
150
+ subtitle: {
151
+ type: 'string',
152
+ optional: true
153
+ },
154
+ groupId: {
155
+ type: 'string',
156
+ optional: true
157
+ }
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Navigation group schema
163
+ */
164
+ export const NAV_GROUP_SCHEMA = {
165
+ type: 'object',
166
+ properties: {
167
+ id: {
168
+ type: 'string',
169
+ required: true
170
+ },
171
+ title: {
172
+ type: 'string',
173
+ required: true
174
+ },
175
+ expanded: {
176
+ type: 'boolean',
177
+ optional: true,
178
+ default: true
179
+ }
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Navigation item states
185
+ */
186
+ export const NAV_ITEM_STATES = {
187
+ EXPANDED: 'expanded',
188
+ COLLAPSED: 'collapsed'
189
+ }
190
+
191
+
192
+ // Update NAV_ITEM_SCHEMA to support nested items
193
+ export const NAV_ITEM_SCHEMA = {
194
+ type: 'object',
195
+ properties: {
196
+ id: {
197
+ type: 'string',
198
+ required: true
199
+ },
200
+ icon: {
201
+ type: 'string',
202
+ required: true
203
+ },
204
+ label: {
205
+ type: 'string',
206
+ required: true
207
+ },
208
+ badge: {
209
+ type: 'string',
210
+ optional: true
211
+ },
212
+ disabled: {
213
+ type: 'boolean',
214
+ optional: true
215
+ },
216
+ subtitle: {
217
+ type: 'string',
218
+ optional: true
219
+ },
220
+ groupId: {
221
+ type: 'string',
222
+ optional: true
223
+ },
224
+ items: {
225
+ type: 'array',
226
+ optional: true,
227
+ description: 'Nested navigation items'
228
+ },
229
+ expanded: {
230
+ type: 'boolean',
231
+ optional: true,
232
+ default: false
233
+ }
234
+ }
235
+ }