mtrl 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.typedocignore +11 -0
  2. package/DOCS.md +153 -0
  3. package/index.ts +18 -3
  4. package/package.json +7 -2
  5. package/src/components/badge/_styles.scss +174 -0
  6. package/src/components/badge/api.ts +292 -0
  7. package/src/components/badge/badge.ts +52 -0
  8. package/src/components/badge/config.ts +68 -0
  9. package/src/components/badge/constants.ts +30 -0
  10. package/src/components/badge/features.ts +185 -0
  11. package/src/components/badge/index.ts +4 -0
  12. package/src/components/badge/types.ts +105 -0
  13. package/src/components/button/types.ts +174 -29
  14. package/src/components/carousel/_styles.scss +645 -0
  15. package/src/components/carousel/api.ts +147 -0
  16. package/src/components/carousel/carousel.ts +178 -0
  17. package/src/components/carousel/config.ts +91 -0
  18. package/src/components/carousel/constants.ts +95 -0
  19. package/src/components/carousel/features/drag.ts +388 -0
  20. package/src/components/carousel/features/index.ts +8 -0
  21. package/src/components/carousel/features/slides.ts +682 -0
  22. package/src/components/carousel/index.ts +38 -0
  23. package/src/components/carousel/types.ts +327 -0
  24. package/src/components/dialog/_styles.scss +213 -0
  25. package/src/components/dialog/api.ts +283 -0
  26. package/src/components/dialog/config.ts +113 -0
  27. package/src/components/dialog/constants.ts +32 -0
  28. package/src/components/dialog/dialog.ts +56 -0
  29. package/src/components/dialog/features.ts +713 -0
  30. package/src/components/dialog/index.ts +15 -0
  31. package/src/components/dialog/types.ts +221 -0
  32. package/src/components/progress/_styles.scss +13 -1
  33. package/src/components/progress/api.ts +2 -2
  34. package/src/components/progress/progress.ts +2 -2
  35. package/src/components/progress/types.ts +3 -0
  36. package/src/components/radios/_styles.scss +232 -0
  37. package/src/components/radios/api.ts +100 -0
  38. package/src/components/radios/config.ts +60 -0
  39. package/src/components/radios/constants.ts +28 -0
  40. package/src/components/radios/index.ts +4 -0
  41. package/src/components/radios/radio.ts +269 -0
  42. package/src/components/radios/radios.ts +42 -0
  43. package/src/components/radios/types.ts +232 -0
  44. package/src/components/sheet/_styles.scss +236 -0
  45. package/src/components/sheet/api.ts +96 -0
  46. package/src/components/sheet/config.ts +66 -0
  47. package/src/components/sheet/constants.ts +20 -0
  48. package/src/components/sheet/features/content.ts +51 -0
  49. package/src/components/sheet/features/gestures.ts +177 -0
  50. package/src/components/sheet/features/index.ts +6 -0
  51. package/src/components/sheet/features/position.ts +42 -0
  52. package/src/components/sheet/features/state.ts +116 -0
  53. package/src/components/sheet/features/title.ts +86 -0
  54. package/src/components/sheet/index.ts +4 -0
  55. package/src/components/sheet/sheet.ts +57 -0
  56. package/src/components/sheet/types.ts +266 -0
  57. package/src/components/slider/_styles.scss +518 -0
  58. package/src/components/slider/api.ts +336 -0
  59. package/src/components/slider/config.ts +145 -0
  60. package/src/components/slider/constants.ts +28 -0
  61. package/src/components/slider/features/appearance.ts +140 -0
  62. package/src/components/slider/features/disabled.ts +43 -0
  63. package/src/components/slider/features/events.ts +164 -0
  64. package/src/components/slider/features/index.ts +5 -0
  65. package/src/components/slider/features/interactions.ts +256 -0
  66. package/src/components/slider/features/keyboard.ts +114 -0
  67. package/src/components/slider/features/slider.ts +336 -0
  68. package/src/components/slider/features/structure.ts +264 -0
  69. package/src/components/slider/features/ui.ts +518 -0
  70. package/src/components/slider/index.ts +9 -0
  71. package/src/components/slider/slider.ts +58 -0
  72. package/src/components/slider/types.ts +166 -0
  73. package/src/components/tabs/_styles.scss +224 -0
  74. package/src/components/tabs/api.ts +443 -0
  75. package/src/components/tabs/config.ts +80 -0
  76. package/src/components/tabs/constants.ts +12 -0
  77. package/src/components/tabs/index.ts +4 -0
  78. package/src/components/tabs/tabs.ts +52 -0
  79. package/src/components/tabs/types.ts +247 -0
  80. package/src/components/textfield/_styles.scss +97 -4
  81. package/src/components/tooltip/_styles.scss +241 -0
  82. package/src/components/tooltip/api.ts +411 -0
  83. package/src/components/tooltip/config.ts +78 -0
  84. package/src/components/tooltip/constants.ts +27 -0
  85. package/src/components/tooltip/index.ts +4 -0
  86. package/src/components/tooltip/tooltip.ts +60 -0
  87. package/src/components/tooltip/types.ts +178 -0
  88. package/src/index.ts +9 -1
  89. package/src/styles/abstract/_variables.scss +24 -12
  90. package/tsconfig.json +22 -0
  91. package/typedoc.json +28 -0
  92. package/typedoc.simple.json +14 -0
@@ -0,0 +1,247 @@
1
+ // src/components/tabs/types.ts
2
+ import { TABS_VARIANTS } from './constants';
3
+
4
+ /**
5
+ * Tab item configuration
6
+ * @category Components
7
+ */
8
+ export interface TabItem {
9
+ /**
10
+ * Unique identifier for the tab
11
+ */
12
+ id: string;
13
+
14
+ /**
15
+ * Display label for the tab
16
+ */
17
+ label: string;
18
+
19
+ /**
20
+ * Optional icon HTML content
21
+ */
22
+ icon?: string;
23
+
24
+ /**
25
+ * Whether the tab is disabled
26
+ * @default false
27
+ */
28
+ disabled?: boolean;
29
+
30
+ /**
31
+ * Additional data to associate with this tab
32
+ */
33
+ data?: any;
34
+ }
35
+
36
+ /**
37
+ * Configuration interface for the Tabs component
38
+ * @category Components
39
+ */
40
+ export interface TabsConfig {
41
+ /**
42
+ * Tabs variant that determines visual styling
43
+ * @default 'primary'
44
+ */
45
+ variant?: keyof typeof TABS_VARIANTS | string;
46
+
47
+ /**
48
+ * Initial tab items
49
+ */
50
+ items?: TabItem[];
51
+
52
+ /**
53
+ * Index of the initially active tab
54
+ * @default 0
55
+ */
56
+ activeIndex?: number;
57
+
58
+ /**
59
+ * Whether the tabs component is initially disabled
60
+ * @default false
61
+ */
62
+ disabled?: boolean;
63
+
64
+ /**
65
+ * Whether to show tab indicator
66
+ * @default true
67
+ */
68
+ showIndicator?: boolean;
69
+
70
+ /**
71
+ * Whether to enable animated transitions
72
+ * @default true
73
+ */
74
+ animated?: boolean;
75
+
76
+ /**
77
+ * Whether tabs should be scrollable when they overflow
78
+ * @default true
79
+ */
80
+ scrollable?: boolean;
81
+
82
+ /**
83
+ * Additional CSS classes to add to the tabs component
84
+ */
85
+ class?: string;
86
+
87
+ /**
88
+ * Component prefix for class names
89
+ * @default 'mtrl'
90
+ */
91
+ prefix?: string;
92
+
93
+ /**
94
+ * Component name used in class generation
95
+ */
96
+ componentName?: string;
97
+ }
98
+
99
+ /**
100
+ * Tabs component interface
101
+ * @category Components
102
+ */
103
+ export interface TabsComponent {
104
+ /** The tabs container DOM element */
105
+ element: HTMLElement;
106
+
107
+ /** The tabs list DOM element */
108
+ tabsListElement: HTMLElement;
109
+
110
+ /** The tab indicator DOM element */
111
+ indicatorElement: HTMLElement;
112
+
113
+ /** API for managing disabled state */
114
+ disabled: {
115
+ /** Enables the tabs component */
116
+ enable: () => void;
117
+ /** Disables the tabs component */
118
+ disable: () => void;
119
+ /** Checks if the tabs component is disabled */
120
+ isDisabled: () => boolean;
121
+ };
122
+
123
+ /** API for managing component lifecycle */
124
+ lifecycle: {
125
+ /** Destroys the component and cleans up resources */
126
+ destroy: () => void;
127
+ };
128
+
129
+ /**
130
+ * Gets a class name with the component's prefix
131
+ * @param name - Base class name
132
+ * @returns Prefixed class name
133
+ */
134
+ getClass: (name: string) => string;
135
+
136
+ /**
137
+ * Enables the tabs component
138
+ * @returns The tabs component for chaining
139
+ */
140
+ enable: () => TabsComponent;
141
+
142
+ /**
143
+ * Disables the tabs component
144
+ * @returns The tabs component for chaining
145
+ */
146
+ disable: () => TabsComponent;
147
+
148
+ /**
149
+ * Gets all tab items
150
+ * @returns Array of tab items
151
+ */
152
+ getItems: () => TabItem[];
153
+
154
+ /**
155
+ * Sets tab items, replacing any existing tabs
156
+ * @param items - Array of tab items
157
+ * @returns The tabs component for chaining
158
+ */
159
+ setItems: (items: TabItem[]) => TabsComponent;
160
+
161
+ /**
162
+ * Adds a new tab
163
+ * @param item - Tab item configuration
164
+ * @param index - Optional index to insert at (appends if omitted)
165
+ * @returns The tabs component for chaining
166
+ */
167
+ addTab: (item: TabItem, index?: number) => TabsComponent;
168
+
169
+ /**
170
+ * Removes a tab by ID or index
171
+ * @param idOrIndex - Tab ID or index
172
+ * @returns The tabs component for chaining
173
+ */
174
+ removeTab: (idOrIndex: string | number) => TabsComponent;
175
+
176
+ /**
177
+ * Gets the currently active tab
178
+ * @returns The active tab item or null if none active
179
+ */
180
+ getActiveTab: () => TabItem | null;
181
+
182
+ /**
183
+ * Gets the index of the currently active tab
184
+ * @returns The active tab index or -1 if none active
185
+ */
186
+ getActiveIndex: () => number;
187
+
188
+ /**
189
+ * Sets the active tab by index
190
+ * @param index - Index of the tab to activate
191
+ * @returns The tabs component for chaining
192
+ */
193
+ setActiveTab: (index: number) => TabsComponent;
194
+
195
+ /**
196
+ * Sets the active tab by ID
197
+ * @param id - ID of the tab to activate
198
+ * @returns The tabs component for chaining
199
+ */
200
+ setActiveTabById: (id: string) => TabsComponent;
201
+
202
+ /**
203
+ * Destroys the tabs component and cleans up resources
204
+ */
205
+ destroy: () => void;
206
+
207
+ /**
208
+ * Adds an event listener to the tabs component
209
+ * @param event - Event name ('change', 'click', etc.)
210
+ * @param handler - Event handler function
211
+ * @returns The tabs component for chaining
212
+ */
213
+ on: (event: string, handler: Function) => TabsComponent;
214
+
215
+ /**
216
+ * Removes an event listener from the tabs component
217
+ * @param event - Event name
218
+ * @param handler - Event handler function
219
+ * @returns The tabs component for chaining
220
+ */
221
+ off: (event: string, handler: Function) => TabsComponent;
222
+ }
223
+
224
+ /**
225
+ * Event data for tab change events
226
+ */
227
+ export interface TabChangeEventData {
228
+ /**
229
+ * Index of the newly activated tab
230
+ */
231
+ index: number;
232
+
233
+ /**
234
+ * The newly activated tab item
235
+ */
236
+ tab: TabItem;
237
+
238
+ /**
239
+ * Index of the previously active tab or -1
240
+ */
241
+ previousIndex: number;
242
+
243
+ /**
244
+ * The previously active tab item or null
245
+ */
246
+ previousTab: TabItem | null;
247
+ }
@@ -1,4 +1,4 @@
1
- // src/components/textfield/styles.scss
1
+ // src/components/textfield/_styles.scss
2
2
  @use '../../styles/abstract/base' as base;
3
3
  @use '../../styles/abstract/variables' as v;
4
4
  @use '../../styles/abstract/functions' as f;
@@ -14,17 +14,102 @@ $component: '#{base.$prefix}-textfield';
14
14
  display: inline-flex;
15
15
  flex-direction: column;
16
16
  min-width: 210px;
17
-
17
+
18
18
  // Size variants
19
19
  &--small {
20
20
  .#{$component}-input {
21
- height: 48px;
21
+ height: 40px;
22
+ font-size: 14px;
23
+ }
24
+
25
+ .#{$component}-label {
26
+ font-size: 14px;
27
+ }
28
+
29
+ .#{$component}-helper {
30
+ font-size: 11px;
31
+ margin-top: 2px;
32
+ }
33
+
34
+ &.#{$component}--filled {
35
+ .#{$component}-input {
36
+ padding: 16px 12px 6px;
37
+
38
+ &:focus {
39
+ padding-bottom: 5px;
40
+ }
41
+ }
42
+
43
+ &:not(.#{$component}--empty) .#{$component}-label,
44
+ &.#{$component}--focused .#{$component}-label {
45
+ transform: translateY(-85%) scale(0.75);
46
+ }
47
+ }
48
+
49
+ &.#{$component}--outlined {
50
+ .#{$component}-input {
51
+ padding: 10px 12px 11px;
52
+ }
53
+
54
+ &:not(.#{$component}--empty) .#{$component}-label,
55
+ &.#{$component}--focused .#{$component}-label {
56
+ transform: translateY(-130%) scale(0.75);
57
+ }
58
+
59
+ &.#{$component}--focused .#{$component}-input {
60
+ height: 38px;
61
+ padding: 9px 11px 10px;
62
+ }
22
63
  }
23
64
  }
24
-
65
+
66
+ &--medium {
67
+ // Default size, styles already defined in base
68
+ }
69
+
25
70
  &--large {
26
71
  .#{$component}-input {
27
72
  height: 64px;
73
+ font-size: 16px;
74
+ }
75
+
76
+ .#{$component}-label {
77
+ font-size: 16px;
78
+ }
79
+
80
+ .#{$component}-helper {
81
+ font-size: 13px;
82
+ margin-top: 6px;
83
+ }
84
+
85
+ &.#{$component}--filled {
86
+ .#{$component}-input {
87
+ padding: 26px 20px 8px;
88
+
89
+ &:focus {
90
+ padding-bottom: 7px;
91
+ }
92
+ }
93
+
94
+ &:not(.#{$component}--empty) .#{$component}-label,
95
+ &.#{$component}--focused .#{$component}-label {
96
+ transform: translateY(-110%) scale(0.75);
97
+ }
98
+ }
99
+
100
+ &.#{$component}--outlined {
101
+ .#{$component}-input {
102
+ padding: 16px 20px 17px;
103
+ }
104
+
105
+ &:not(.#{$component}--empty) .#{$component}-label,
106
+ &.#{$component}--focused .#{$component}-label {
107
+ transform: translateY(-170%) scale(0.75);
108
+ }
109
+
110
+ &.#{$component}--focused .#{$component}-input {
111
+ padding: 15px 19px 16px;
112
+ }
28
113
  }
29
114
  }
30
115
 
@@ -50,6 +135,7 @@ $component: '#{base.$prefix}-textfield';
50
135
  @include m.shape('extra-small');
51
136
  padding: 13px 16px;
52
137
  width: 100%;
138
+ height: 56px;
53
139
  color: t.color('on-surface');
54
140
  border: 0;
55
141
  appearance: none;
@@ -187,6 +273,12 @@ $component: '#{base.$prefix}-textfield';
187
273
  color: t.color('primary');
188
274
  }
189
275
 
276
+ .#{$component}-input {
277
+ height: 55px;
278
+ padding: 20px 16px 6px;
279
+ }
280
+
281
+
190
282
  &:hover {
191
283
  border-bottom: 2px solid t.color('primary');
192
284
  }
@@ -290,6 +382,7 @@ $component: '#{base.$prefix}-textfield';
290
382
  }
291
383
 
292
384
  .#{$component}-input {
385
+ height: 54px;
293
386
  padding: 12px 15px 13px;
294
387
  }
295
388
 
@@ -0,0 +1,241 @@
1
+ // src/components/tooltip/_styles.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}-tooltip';
9
+ $arrow-size: 8px;
10
+
11
+ .#{$component} {
12
+ // Base styles
13
+ position: fixed;
14
+ top: 0;
15
+ left: 0;
16
+ z-index: 1000;
17
+ max-width: 200px;
18
+ padding: 4px 8px;
19
+ border-radius: 4px;
20
+ background-color: t.color('inverse-surface');
21
+ color: t.color('inverse-on-surface');
22
+ font-size: 12px;
23
+ line-height: 16px;
24
+ text-align: center;
25
+ pointer-events: none;
26
+ opacity: 0;
27
+ transform: scale(0.9);
28
+ transform-origin: center;
29
+ box-sizing: border-box;
30
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
31
+
32
+ // Typography
33
+ @include m.typography('body-small');
34
+ font-weight: 500;
35
+
36
+ // Transition
37
+ transition:
38
+ opacity 150ms cubic-bezier(0, 0, 0.2, 1),
39
+ transform 150ms cubic-bezier(0, 0, 0.2, 1);
40
+
41
+ // States
42
+ &--visible {
43
+ opacity: 0.9;
44
+ transform: scale(1);
45
+ }
46
+
47
+ // Variants
48
+
49
+ // Default variant
50
+ &--default {
51
+ // Default styles already applied in base
52
+ }
53
+
54
+ // Rich variant (for rich content)
55
+ &--rich {
56
+ text-align: left;
57
+ padding: 8px 12px;
58
+ }
59
+
60
+ // Plain variant (flat, no shadow)
61
+ &--plain {
62
+ background-color: t.color('surface-container-high');
63
+ color: t.color('on-surface');
64
+ box-shadow: none;
65
+ border: 1px solid t.color('outline');
66
+ }
67
+
68
+ // Arrow styles
69
+ &__arrow {
70
+ position: absolute;
71
+ width: 0;
72
+ height: 0;
73
+ border: $arrow-size solid transparent;
74
+ pointer-events: none;
75
+
76
+ // Top position (arrow points up)
77
+ &--top {
78
+ bottom: 100%;
79
+ left: 50%;
80
+ transform: translateX(-50%);
81
+ border-bottom-color: t.color('inverse-surface');
82
+ border-top-width: 0;
83
+
84
+ .#{$component}--plain & {
85
+ border-bottom-color: t.color('surface-container-high');
86
+ }
87
+ }
88
+
89
+ // Top-start position
90
+ &--top-start {
91
+ bottom: 100%;
92
+ left: $arrow-size;
93
+ border-bottom-color: t.color('inverse-surface');
94
+ border-top-width: 0;
95
+
96
+ .#{$component}--plain & {
97
+ border-bottom-color: t.color('surface-container-high');
98
+ }
99
+ }
100
+
101
+ // Top-end position
102
+ &--top-end {
103
+ bottom: 100%;
104
+ right: $arrow-size;
105
+ border-bottom-color: t.color('inverse-surface');
106
+ border-top-width: 0;
107
+
108
+ .#{$component}--plain & {
109
+ border-bottom-color: t.color('surface-container-high');
110
+ }
111
+ }
112
+
113
+ // Bottom position (arrow points down)
114
+ &--bottom {
115
+ top: 100%;
116
+ left: 50%;
117
+ transform: translateX(-50%);
118
+ border-top-color: t.color('inverse-surface');
119
+ border-bottom-width: 0;
120
+
121
+ .#{$component}--plain & {
122
+ border-top-color: t.color('surface-container-high');
123
+ }
124
+ }
125
+
126
+ // Bottom-start position
127
+ &--bottom-start {
128
+ top: 100%;
129
+ left: $arrow-size;
130
+ border-top-color: t.color('inverse-surface');
131
+ border-bottom-width: 0;
132
+
133
+ .#{$component}--plain & {
134
+ border-top-color: t.color('surface-container-high');
135
+ }
136
+ }
137
+
138
+ // Bottom-end position
139
+ &--bottom-end {
140
+ top: 100%;
141
+ right: $arrow-size;
142
+ border-top-color: t.color('inverse-surface');
143
+ border-bottom-width: 0;
144
+
145
+ .#{$component}--plain & {
146
+ border-top-color: t.color('surface-container-high');
147
+ }
148
+ }
149
+
150
+ // Left position (arrow points left)
151
+ &--left {
152
+ right: 100%;
153
+ top: 50%;
154
+ transform: translateY(-50%);
155
+ border-right-color: t.color('inverse-surface');
156
+ border-left-width: 0;
157
+
158
+ .#{$component}--plain & {
159
+ border-right-color: t.color('surface-container-high');
160
+ }
161
+ }
162
+
163
+ // Left-start position
164
+ &--left-start {
165
+ right: 100%;
166
+ top: $arrow-size;
167
+ border-right-color: t.color('inverse-surface');
168
+ border-left-width: 0;
169
+
170
+ .#{$component}--plain & {
171
+ border-right-color: t.color('surface-container-high');
172
+ }
173
+ }
174
+
175
+ // Left-end position
176
+ &--left-end {
177
+ right: 100%;
178
+ bottom: $arrow-size;
179
+ border-right-color: t.color('inverse-surface');
180
+ border-left-width: 0;
181
+
182
+ .#{$component}--plain & {
183
+ border-right-color: t.color('surface-container-high');
184
+ }
185
+ }
186
+
187
+ // Right position (arrow points right)
188
+ &--right {
189
+ left: 100%;
190
+ top: 50%;
191
+ transform: translateY(-50%);
192
+ border-left-color: t.color('inverse-surface');
193
+ border-right-width: 0;
194
+
195
+ .#{$component}--plain & {
196
+ border-left-color: t.color('surface-container-high');
197
+ }
198
+ }
199
+
200
+ // Right-start position
201
+ &--right-start {
202
+ left: 100%;
203
+ top: $arrow-size;
204
+ border-left-color: t.color('inverse-surface');
205
+ border-right-width: 0;
206
+
207
+ .#{$component}--plain & {
208
+ border-left-color: t.color('surface-container-high');
209
+ }
210
+ }
211
+
212
+ // Right-end position
213
+ &--right-end {
214
+ left: 100%;
215
+ bottom: $arrow-size;
216
+ border-left-color: t.color('inverse-surface');
217
+ border-right-width: 0;
218
+
219
+ .#{$component}--plain & {
220
+ border-left-color: t.color('surface-container-high');
221
+ }
222
+ }
223
+ }
224
+
225
+ // Positioning classes
226
+ &--top {
227
+ margin-bottom: $arrow-size;
228
+ }
229
+
230
+ &--bottom {
231
+ margin-top: $arrow-size;
232
+ }
233
+
234
+ &--left {
235
+ margin-right: $arrow-size;
236
+ }
237
+
238
+ &--right {
239
+ margin-left: $arrow-size;
240
+ }
241
+ }