mtrl 0.2.5 → 0.2.6

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 (70) hide show
  1. package/package.json +1 -1
  2. package/src/components/badge/_styles.scss +9 -9
  3. package/src/components/button/_styles.scss +0 -56
  4. package/src/components/button/button.ts +0 -2
  5. package/src/components/button/constants.ts +0 -6
  6. package/src/components/button/index.ts +2 -2
  7. package/src/components/button/types.ts +1 -7
  8. package/src/components/card/_styles.scss +67 -25
  9. package/src/components/card/api.ts +54 -3
  10. package/src/components/card/card.ts +33 -2
  11. package/src/components/card/config.ts +143 -21
  12. package/src/components/card/constants.ts +20 -19
  13. package/src/components/card/content.ts +299 -2
  14. package/src/components/card/features.ts +155 -4
  15. package/src/components/card/index.ts +31 -9
  16. package/src/components/card/types.ts +138 -15
  17. package/src/components/chip/chip.ts +1 -9
  18. package/src/components/chip/constants.ts +0 -10
  19. package/src/components/chip/index.ts +1 -1
  20. package/src/components/chip/types.ts +1 -4
  21. package/src/components/progress/_styles.scss +0 -65
  22. package/src/components/progress/config.ts +1 -2
  23. package/src/components/progress/constants.ts +0 -14
  24. package/src/components/progress/index.ts +1 -1
  25. package/src/components/progress/progress.ts +1 -4
  26. package/src/components/progress/types.ts +1 -4
  27. package/src/components/radios/_styles.scss +0 -45
  28. package/src/components/radios/api.ts +85 -60
  29. package/src/components/radios/config.ts +1 -2
  30. package/src/components/radios/constants.ts +0 -9
  31. package/src/components/radios/index.ts +1 -1
  32. package/src/components/radios/radio.ts +34 -11
  33. package/src/components/radios/radios.ts +2 -1
  34. package/src/components/radios/types.ts +1 -7
  35. package/src/components/slider/_styles.scss +149 -155
  36. package/src/components/slider/accessibility.md +59 -0
  37. package/src/components/slider/config.ts +4 -6
  38. package/src/components/slider/features/disabled.ts +41 -16
  39. package/src/components/slider/features/interactions.ts +153 -18
  40. package/src/components/slider/features/keyboard.ts +127 -6
  41. package/src/components/slider/features/structure.ts +32 -5
  42. package/src/components/slider/features/ui.ts +18 -8
  43. package/src/components/tabs/_styles.scss +285 -155
  44. package/src/components/tabs/api.ts +178 -400
  45. package/src/components/tabs/config.ts +46 -52
  46. package/src/components/tabs/constants.ts +85 -8
  47. package/src/components/tabs/features.ts +401 -0
  48. package/src/components/tabs/index.ts +60 -3
  49. package/src/components/tabs/indicator.ts +225 -0
  50. package/src/components/tabs/responsive.ts +144 -0
  51. package/src/components/tabs/scroll-indicators.ts +149 -0
  52. package/src/components/tabs/state.ts +186 -0
  53. package/src/components/tabs/tab-api.ts +258 -0
  54. package/src/components/tabs/tab.ts +255 -0
  55. package/src/components/tabs/tabs.ts +50 -31
  56. package/src/components/tabs/types.ts +324 -128
  57. package/src/components/tabs/utils.ts +107 -0
  58. package/src/components/textfield/_styles.scss +0 -98
  59. package/src/components/textfield/config.ts +2 -3
  60. package/src/components/textfield/constants.ts +0 -14
  61. package/src/components/textfield/index.ts +2 -2
  62. package/src/components/textfield/textfield.ts +0 -2
  63. package/src/components/textfield/types.ts +1 -4
  64. package/src/core/compose/component.ts +1 -1
  65. package/src/core/compose/features/badge.ts +79 -0
  66. package/src/core/compose/features/index.ts +3 -1
  67. package/src/styles/abstract/_theme.scss +106 -2
  68. package/src/components/card/actions.ts +0 -48
  69. package/src/components/card/header.ts +0 -88
  70. package/src/components/card/media.ts +0 -52
@@ -120,71 +120,6 @@ $component: '#{base.$prefix}-progress';
120
120
  }
121
121
  }
122
122
 
123
- // Size variants
124
- &--small {
125
- &.#{$component}--linear {
126
- height: 2px;
127
- }
128
-
129
- &.#{$component}--circular {
130
- width: 24px;
131
- height: 24px;
132
-
133
- .#{$component}-track,
134
- .#{$component}-indicator {
135
- stroke-width: 3;
136
- border-radius: 1px;
137
- linecap: round
138
- }
139
- }
140
- }
141
-
142
- &--medium {
143
- &.#{$component}--linear {
144
- height: 4px;
145
- }
146
-
147
- &.#{$component}--circular {
148
- width: 48px;
149
- height: 48px;
150
-
151
- .#{$component}-track,
152
- .#{$component}-indicator {
153
- stroke-width: 4;
154
- }
155
- }
156
- }
157
-
158
- &--large {
159
- &.#{$component}--linear {
160
- height: 8px;
161
-
162
- .#{$component}-track,
163
- .#{$component}-indicator {
164
- border-radius: 4px;
165
- }
166
-
167
- .#{$component}-label {
168
- font-size: 14px;
169
- top: 12px;
170
- }
171
- }
172
-
173
- &.#{$component}--circular {
174
- width: 64px;
175
- height: 64px;
176
-
177
- .#{$component}-track,
178
- .#{$component}-indicator {
179
- stroke-width: 6;
180
- }
181
-
182
- .#{$component}-label {
183
- font-size: 14px;
184
- }
185
- }
186
- }
187
-
188
123
  // Disabled state
189
124
  &--disabled {
190
125
  opacity: 0.38;
@@ -5,14 +5,13 @@ import {
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
7
  import { ProgressConfig } from './types';
8
- import { PROGRESS_VARIANTS, PROGRESS_SIZES } from './constants';
8
+ import { PROGRESS_VARIANTS } from './constants';
9
9
 
10
10
  /**
11
11
  * Default configuration for the Progress component
12
12
  */
13
13
  export const defaultConfig: ProgressConfig = {
14
14
  variant: PROGRESS_VARIANTS.LINEAR,
15
- size: PROGRESS_SIZES.MEDIUM,
16
15
  value: 0,
17
16
  max: 100,
18
17
  buffer: 0,
@@ -17,20 +17,6 @@ export const PROGRESS_VARIANTS = {
17
17
  INDETERMINATE: 'indeterminate'
18
18
  } as const;
19
19
 
20
- /**
21
- * Progress component sizes
22
- */
23
- export const PROGRESS_SIZES = {
24
- /** Small progress indicator (2px height for linear, 16px diameter for circular) */
25
- SMALL: 'small',
26
-
27
- /** Medium progress indicator (4px height for linear, 24px diameter for circular) */
28
- MEDIUM: 'medium',
29
-
30
- /** Large progress indicator (8px height for linear, 48px diameter for circular) */
31
- LARGE: 'large'
32
- } as const;
33
-
34
20
  /**
35
21
  * Progress component events
36
22
  */
@@ -1,5 +1,5 @@
1
1
  // src/components/progress/index.ts
2
2
 
3
3
  export { default } from './progress';
4
- export { PROGRESS_VARIANTS, PROGRESS_SIZES, PROGRESS_EVENTS } from './constants';
4
+ export { PROGRESS_VARIANTS, PROGRESS_EVENTS } from './constants';
5
5
  export { ProgressConfig, ProgressComponent } from './types';
@@ -6,13 +6,12 @@ import { createBase, withElement } from '../../core/compose/component';
6
6
  import {
7
7
  withEvents,
8
8
  withVariant,
9
- withSize,
10
9
  withDisabled,
11
10
  withLifecycle
12
11
  } from '../../core/compose/features';
13
12
  import { withAPI } from './api';
14
13
  import { ProgressConfig, ProgressComponent } from './types';
15
- import { PROGRESS_VARIANTS, PROGRESS_SIZES, PROGRESS_EVENTS } from './constants';
14
+ import { PROGRESS_VARIANTS, PROGRESS_EVENTS } from './constants';
16
15
  import { createBaseConfig, getElementConfig, getApiConfig } from './config';
17
16
 
18
17
  // Helper functions
@@ -72,7 +71,6 @@ const createCircularProgressDOM = (baseClass: string) => {
72
71
  * // Create an indeterminate circular progress
73
72
  * const loader = createProgress({
74
73
  * variant: 'circular',
75
- * size: 'large',
76
74
  * indeterminate: true
77
75
  * });
78
76
  * ```
@@ -101,7 +99,6 @@ const createProgress = (config: ProgressConfig = {}): ProgressComponent => {
101
99
  withEvents(),
102
100
  withElement(getElementConfig(baseConfig)),
103
101
  withVariant(baseConfig),
104
- withSize(baseConfig),
105
102
  withDisabled(baseConfig),
106
103
  withLifecycle(),
107
104
  // Add DOM structure based on variant
@@ -1,5 +1,5 @@
1
1
  // src/components/progress/types.ts
2
- import { PROGRESS_VARIANTS, PROGRESS_SIZES } from './constants';
2
+ import { PROGRESS_VARIANTS } from './constants';
3
3
 
4
4
  /**
5
5
  * Configuration interface for the Progress component
@@ -8,9 +8,6 @@ export interface ProgressConfig {
8
8
  /** Progress variant (linear, circular) */
9
9
  variant?: keyof typeof PROGRESS_VARIANTS | string;
10
10
 
11
- /** Progress size (small, medium, large) */
12
- size?: keyof typeof PROGRESS_SIZES | string;
13
-
14
11
  /** Initial progress value (0-100) */
15
12
  value?: number;
16
13
 
@@ -184,49 +184,4 @@ $component: '#{base.$prefix}-radios';
184
184
  margin-left: 8px;
185
185
  line-height: 1.2;
186
186
  }
187
-
188
- // Size variants
189
- &--small {
190
- .#{$component}-control {
191
- width: 36px;
192
- height: 36px;
193
- }
194
-
195
- .#{$component}-circle {
196
- width: 18px;
197
- height: 18px;
198
-
199
- &:after {
200
- width: 10px;
201
- height: 10px;
202
- }
203
- }
204
-
205
- .#{$component}-label {
206
- font-size: 13px;
207
- height: 36px;
208
- }
209
- }
210
-
211
- &--large {
212
- .#{$component}-control {
213
- width: 48px;
214
- height: 48px;
215
- }
216
-
217
- .#{$component}-circle {
218
- width: 24px;
219
- height: 24px;
220
-
221
- &:after {
222
- width: 14px;
223
- height: 14px;
224
- }
225
- }
226
-
227
- .#{$component}-label {
228
- font-size: 16px;
229
- height: 48px;
230
- }
231
- }
232
187
  }
@@ -27,6 +27,7 @@ interface ComponentWithRadio {
27
27
  events: {
28
28
  on: (event: string, handler: Function) => void;
29
29
  off: (event: string, handler: Function) => void;
30
+ emit?: (event: string, data: any) => void;
30
31
  };
31
32
  }
32
33
 
@@ -37,64 +38,88 @@ interface ComponentWithRadio {
37
38
  * @internal This is an internal utility for the Radios component
38
39
  */
39
40
  export const withAPI = ({ disabled, lifecycle }: ApiOptions) =>
40
- (component: ComponentWithRadio): RadiosComponent => ({
41
- ...component as any,
42
- element: component.element,
43
- radios: component.radios,
44
-
45
- getValue: () => component.getValue(),
46
-
47
- setValue(value: string) {
48
- component.setValue(value);
49
- return this;
50
- },
51
-
52
- getSelected: () => component.getSelected(),
53
-
54
- addOption(option) {
55
- component.addOption(option);
56
- return this;
57
- },
58
-
59
- removeOption(value: string) {
60
- component.removeOption(value);
61
- return this;
62
- },
63
-
64
- enable() {
65
- disabled.enable();
66
- return this;
67
- },
68
-
69
- disable() {
70
- disabled.disable();
71
- return this;
72
- },
73
-
74
- enableOption(value: string) {
75
- component.enableOption(value);
76
- return this;
77
- },
78
-
79
- disableOption(value: string) {
80
- component.disableOption(value);
81
- return this;
82
- },
83
-
84
- on(event: string, handler: Function) {
85
- component.events.on(event, handler);
86
- return this;
87
- },
88
-
89
- off(event: string, handler: Function) {
90
- component.events.off(event, handler);
91
- return this;
92
- },
93
-
94
- destroy() {
95
- // First destroy all radio items
96
- component.radios.forEach(radio => radio.destroy());
97
- // Then destroy the component
98
- lifecycle.destroy();
41
+ (component: ComponentWithRadio): RadiosComponent => {
42
+ // Ensure component has events
43
+ if (!component.events) {
44
+ component.events = {
45
+ on: (event, handler) => {
46
+ component.element.addEventListener(event, (e) => handler(e.detail));
47
+ },
48
+ off: (event, handler) => {
49
+ component.element.removeEventListener(event, handler);
50
+ },
51
+ emit: (event, data) => {
52
+ const customEvent = new CustomEvent(event, { detail: data });
53
+ component.element.dispatchEvent(customEvent);
54
+ }
55
+ };
56
+ } else if (!component.events.emit) {
57
+ // Add emit method if not present
58
+ component.events.emit = (event, data) => {
59
+ const customEvent = new CustomEvent(event, { detail: data });
60
+ component.element.dispatchEvent(customEvent);
61
+ };
99
62
  }
100
- });
63
+
64
+ return {
65
+ ...component as any,
66
+ element: component.element,
67
+ radios: component.radios,
68
+
69
+ getValue: () => component.getValue(),
70
+
71
+ setValue(value: string) {
72
+ component.setValue(value);
73
+ return this;
74
+ },
75
+
76
+ getSelected: () => component.getSelected(),
77
+
78
+ addOption(option) {
79
+ component.addOption(option);
80
+ return this;
81
+ },
82
+
83
+ removeOption(value: string) {
84
+ component.removeOption(value);
85
+ return this;
86
+ },
87
+
88
+ enable() {
89
+ disabled.enable();
90
+ return this;
91
+ },
92
+
93
+ disable() {
94
+ disabled.disable();
95
+ return this;
96
+ },
97
+
98
+ enableOption(value: string) {
99
+ component.enableOption(value);
100
+ return this;
101
+ },
102
+
103
+ disableOption(value: string) {
104
+ component.disableOption(value);
105
+ return this;
106
+ },
107
+
108
+ on(event: string, handler: Function) {
109
+ component.events.on(event, handler);
110
+ return this;
111
+ },
112
+
113
+ off(event: string, handler: Function) {
114
+ component.events.off(event, handler);
115
+ return this;
116
+ },
117
+
118
+ destroy() {
119
+ // First destroy all radio items
120
+ component.radios.forEach(radio => radio.destroy());
121
+ // Then destroy the component
122
+ lifecycle.destroy();
123
+ }
124
+ };
125
+ };
@@ -5,7 +5,7 @@ import {
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
7
  import { RadiosConfig } from './types';
8
- import { RADIO_DIRECTIONS, RADIO_SIZES } from './constants';
8
+ import { RADIO_DIRECTIONS } from './constants';
9
9
 
10
10
  /**
11
11
  * Default configuration for the Radios component
@@ -13,7 +13,6 @@ import { RADIO_DIRECTIONS, RADIO_SIZES } from './constants';
13
13
  export const defaultConfig: RadiosConfig = {
14
14
  name: '',
15
15
  direction: RADIO_DIRECTIONS.VERTICAL,
16
- size: RADIO_SIZES.MEDIUM,
17
16
  disabled: false,
18
17
  ripple: true,
19
18
  options: []
@@ -10,15 +10,6 @@ export const RADIO_STATES = {
10
10
  FOCUSED: 'focused'
11
11
  };
12
12
 
13
- /**
14
- * Radio sizes
15
- */
16
- export const RADIO_SIZES = {
17
- SMALL: 'small',
18
- MEDIUM: 'medium',
19
- LARGE: 'large'
20
- };
21
-
22
13
  /**
23
14
  * Radio layout directions
24
15
  */
@@ -1,4 +1,4 @@
1
1
  // src/components/radios/index.ts
2
2
  export { default } from './radios';
3
- export { RADIO_STATES, RADIO_SIZES, RADIO_DIRECTIONS } from './constants';
3
+ export { RADIO_STATES, RADIO_DIRECTIONS } from './constants';
4
4
  export { RadiosConfig, RadiosComponent, RadioOptionConfig } from './types';
@@ -16,11 +16,6 @@ export const withRadio = (config: RadiosConfig) => (component) => {
16
16
  `${radiosClass}--${config.direction || 'vertical'}`
17
17
  );
18
18
 
19
- // Add size class
20
- component.element.classList.add(
21
- `${radiosClass}--${config.size || 'medium'}`
22
- );
23
-
24
19
  // Setup disabled state if needed
25
20
  if (config.disabled) {
26
21
  component.element.classList.add(`${radiosClass}--disabled`);
@@ -112,12 +107,24 @@ export const withRadio = (config: RadiosConfig) => (component) => {
112
107
  }
113
108
  });
114
109
 
115
- // Emit change event
116
- component.events.emit('change', {
117
- value: option.value,
118
- originalEvent: e,
119
- option
120
- });
110
+ // Safely emit change event if events exist
111
+ if (component.events && typeof component.events.emit === 'function') {
112
+ component.events.emit('change', {
113
+ value: option.value,
114
+ originalEvent: e,
115
+ option
116
+ });
117
+ } else if (typeof component.on === 'function') {
118
+ // Fallback to trigger handlers directly if they were registered with on()
119
+ const changeEvent = new CustomEvent('change', {
120
+ detail: {
121
+ value: option.value,
122
+ originalEvent: e,
123
+ option
124
+ }
125
+ });
126
+ component.element.dispatchEvent(changeEvent);
127
+ }
121
128
  }
122
129
  };
123
130
 
@@ -188,6 +195,22 @@ export const withRadio = (config: RadiosConfig) => (component) => {
188
195
  config.options.forEach(option => addOption(option));
189
196
  }
190
197
 
198
+ // Create events object if it doesn't exist
199
+ if (!component.events) {
200
+ component.events = {
201
+ on: (event, handler) => {
202
+ component.element.addEventListener(event, (e) => handler(e.detail));
203
+ },
204
+ off: (event, handler) => {
205
+ component.element.removeEventListener(event, handler);
206
+ },
207
+ emit: (event, data) => {
208
+ const customEvent = new CustomEvent(event, { detail: data });
209
+ component.element.dispatchEvent(customEvent);
210
+ }
211
+ };
212
+ }
213
+
191
214
  // Return enhanced component
192
215
  return {
193
216
  ...component,
@@ -22,9 +22,10 @@ const createRadios = (config: RadiosConfig): RadiosComponent => {
22
22
  const baseConfig = createBaseConfig(config);
23
23
 
24
24
  try {
25
+ // First add events support before radio functionality
25
26
  const radios = pipe(
26
27
  createBase,
27
- withEvents(),
28
+ withEvents(), // Make sure this runs first to provide events
28
29
  withElement(getElementConfig(baseConfig)),
29
30
  withRadio(baseConfig),
30
31
  withDisabled(baseConfig),
@@ -1,5 +1,5 @@
1
1
  // src/components/radios/types.ts
2
- import { RADIO_SIZES, RADIO_DIRECTIONS } from './constants';
2
+ import { RADIO_DIRECTIONS } from './constants';
3
3
 
4
4
  /**
5
5
  * Configuration for a radio option in the Radios component
@@ -64,12 +64,6 @@ export interface RadiosConfig {
64
64
  */
65
65
  direction?: keyof typeof RADIO_DIRECTIONS | string;
66
66
 
67
- /**
68
- * Radio size
69
- * @default 'medium'
70
- */
71
- size?: keyof typeof RADIO_SIZES | string;
72
-
73
67
  /**
74
68
  * Whether to enable ripple effect
75
69
  * @default true