mtrl 0.6.1 → 0.6.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.
- package/README.md +39 -0
- package/dist/README.md +39 -0
- package/dist/components/badge/index.d.ts +2 -2
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/card/index.d.ts +0 -1
- package/dist/components/chips/index.d.ts +3 -4
- package/dist/components/datepicker/index.d.ts +3 -3
- package/dist/components/dialog/index.d.ts +2 -2
- package/dist/components/fab/index.d.ts +2 -2
- package/dist/components/index.d.ts +37 -45
- package/dist/components/progress/index.d.ts +2 -3
- package/dist/components/search/index.d.ts +0 -1
- package/dist/components/segmented-button/index.d.ts +3 -4
- package/dist/components/slider/index.d.ts +2 -3
- package/dist/components/snackbar/index.d.ts +2 -3
- package/dist/components/textfield/index.d.ts +0 -1
- package/dist/index.cjs +17 -17
- package/dist/index.cjs.map +41 -53
- package/dist/index.d.ts +0 -1
- package/dist/index.js +17 -17
- package/dist/index.js.map +41 -53
- package/dist/package.json +1 -1
- package/dist/styles.css +2 -2
- package/package.json +23 -2
- package/src/styles/components/_dialog.scss +10 -5
- package/src/styles/components/_tabs.scss +407 -381
- package/dist/constants.d.ts +0 -30
package/README.md
CHANGED
|
@@ -61,6 +61,45 @@ yarn add mtrl
|
|
|
61
61
|
bun add mtrl
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
## Tree-Shaking Optimized Imports
|
|
65
|
+
|
|
66
|
+
mtrl is optimized for tree-shaking. Constants are exported separately from component creators to minimize bundle size.
|
|
67
|
+
|
|
68
|
+
### Import Patterns
|
|
69
|
+
|
|
70
|
+
| Import Type | Path |
|
|
71
|
+
|-------------|------|
|
|
72
|
+
| Component creators | `import { createButton } from 'mtrl'` |
|
|
73
|
+
| Button constants | `import { BUTTON_VARIANTS } from 'mtrl/components/button/constants'` |
|
|
74
|
+
| Slider constants | `import { SLIDER_SIZES } from 'mtrl/components/slider/constants'` |
|
|
75
|
+
| Card constants | `import { CARD_VARIANTS } from 'mtrl/components/card/constants'` |
|
|
76
|
+
| Direct component import | `import createButton from 'mtrl/components/button'` |
|
|
77
|
+
| Core utilities | `import { addClass, removeClass } from 'mtrl/core/dom'` |
|
|
78
|
+
|
|
79
|
+
### Example
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// ✅ Optimal - only imports what you need
|
|
83
|
+
import { createButton } from 'mtrl';
|
|
84
|
+
import { BUTTON_VARIANTS, BUTTON_SIZES } from 'mtrl/components/button/constants';
|
|
85
|
+
|
|
86
|
+
const button = createButton({
|
|
87
|
+
text: 'Submit',
|
|
88
|
+
variant: BUTTON_VARIANTS.FILLED,
|
|
89
|
+
size: BUTTON_SIZES.LARGE
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ✅ Also optimal - direct component import
|
|
93
|
+
import createSlider from 'mtrl/components/slider';
|
|
94
|
+
import { SLIDER_COLORS } from 'mtrl/components/slider/constants';
|
|
95
|
+
|
|
96
|
+
const slider = createSlider({
|
|
97
|
+
color: SLIDER_COLORS.PRIMARY
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Note:** Constants are NOT exported from main entry points. Always import them from the component's constants file.
|
|
102
|
+
|
|
64
103
|
## Component Architecture
|
|
65
104
|
|
|
66
105
|
Let's look at how mtrl components are constructed:
|
package/dist/README.md
CHANGED
|
@@ -61,6 +61,45 @@ yarn add mtrl
|
|
|
61
61
|
bun add mtrl
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
## Tree-Shaking Optimized Imports
|
|
65
|
+
|
|
66
|
+
mtrl is optimized for tree-shaking. Constants are exported separately from component creators to minimize bundle size.
|
|
67
|
+
|
|
68
|
+
### Import Patterns
|
|
69
|
+
|
|
70
|
+
| Import Type | Path |
|
|
71
|
+
|-------------|------|
|
|
72
|
+
| Component creators | `import { createButton } from 'mtrl'` |
|
|
73
|
+
| Button constants | `import { BUTTON_VARIANTS } from 'mtrl/components/button/constants'` |
|
|
74
|
+
| Slider constants | `import { SLIDER_SIZES } from 'mtrl/components/slider/constants'` |
|
|
75
|
+
| Card constants | `import { CARD_VARIANTS } from 'mtrl/components/card/constants'` |
|
|
76
|
+
| Direct component import | `import createButton from 'mtrl/components/button'` |
|
|
77
|
+
| Core utilities | `import { addClass, removeClass } from 'mtrl/core/dom'` |
|
|
78
|
+
|
|
79
|
+
### Example
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// ✅ Optimal - only imports what you need
|
|
83
|
+
import { createButton } from 'mtrl';
|
|
84
|
+
import { BUTTON_VARIANTS, BUTTON_SIZES } from 'mtrl/components/button/constants';
|
|
85
|
+
|
|
86
|
+
const button = createButton({
|
|
87
|
+
text: 'Submit',
|
|
88
|
+
variant: BUTTON_VARIANTS.FILLED,
|
|
89
|
+
size: BUTTON_SIZES.LARGE
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ✅ Also optimal - direct component import
|
|
93
|
+
import createSlider from 'mtrl/components/slider';
|
|
94
|
+
import { SLIDER_COLORS } from 'mtrl/components/slider/constants';
|
|
95
|
+
|
|
96
|
+
const slider = createSlider({
|
|
97
|
+
color: SLIDER_COLORS.PRIMARY
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Note:** Constants are NOT exported from main entry points. Always import them from the component's constants file.
|
|
102
|
+
|
|
64
103
|
## Component Architecture
|
|
65
104
|
|
|
66
105
|
Let's look at how mtrl components are constructed:
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* @description A small element that communicates status, shows a count,
|
|
5
5
|
* or highlights an element requiring attention.
|
|
6
6
|
*/
|
|
7
|
-
export { default } from
|
|
8
|
-
export type { BadgeConfig, BadgeComponent, BadgeVariant, BadgeColor, BadgePosition } from
|
|
7
|
+
export { default } from "./badge";
|
|
8
|
+
export type { BadgeConfig, BadgeComponent, BadgeVariant, BadgeColor, BadgePosition, } from "./types";
|
|
@@ -69,4 +69,3 @@ export { CardVariant, CardElevationLevel, CardSchema, CardHeaderConfig, CardCont
|
|
|
69
69
|
export { createCardContent, createCardHeader, createCardActions, createCardMedia, } from "./content";
|
|
70
70
|
export { withAPI } from "./api";
|
|
71
71
|
export { withLoading, withExpandable, withSwipeable, withElevation, } from "./features";
|
|
72
|
-
export { CARD_VARIANTS, CARD_ELEVATIONS, CARD_WIDTHS, CARD_CORNER_RADIUS, CARD_ASPECT_RATIOS, CARD_ACTION_ALIGNMENT, CARD_MEDIA_POSITION, CARD_CLASSES, } from "./constants";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as createChip } from
|
|
2
|
-
export { default as createChips } from
|
|
3
|
-
export
|
|
4
|
-
export type { ChipConfig, ChipComponent, ChipVariant, ChipsConfig, ChipsComponent } from './types';
|
|
1
|
+
export { default as createChip } from "./chip";
|
|
2
|
+
export { default as createChips } from "./chips";
|
|
3
|
+
export type { ChipConfig, ChipComponent, ChipVariant, ChipsConfig, ChipsComponent, } from "./types";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export type { DatePickerConfig, DatePickerComponent, DatePickerVariant, DatePickerView, DatePickerSelectionMode } from
|
|
3
|
-
export { DEFAULT_DATE_FORMAT } from
|
|
1
|
+
export { default } from "./datepicker";
|
|
2
|
+
export type { DatePickerConfig, DatePickerComponent, DatePickerVariant, DatePickerView, DatePickerSelectionMode, } from "./types";
|
|
3
|
+
export { DEFAULT_DATE_FORMAT } from "./types";
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* @module components/dialog
|
|
11
11
|
* @category Components
|
|
12
12
|
*/
|
|
13
|
-
export { default } from
|
|
14
|
-
export { DialogConfig, DialogComponent, DialogButton, DialogEvent, DialogConfirmOptions, DialogSize, DialogAnimation, DialogFooterAlignment, DialogEventType } from
|
|
13
|
+
export { default } from "./dialog";
|
|
14
|
+
export { DialogConfig, DialogComponent, DialogButton, DialogEvent, DialogConfirmOptions, DialogSize, DialogAnimation, DialogFooterAlignment, DialogEventType, } from "./types";
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
*
|
|
32
32
|
* @category Components
|
|
33
33
|
*/
|
|
34
|
-
export { default, default as createFab } from
|
|
35
|
-
export { FabConfig, FabComponent, FabVariant, FabSize, FabPosition } from
|
|
34
|
+
export { default, default as createFab } from "./fab";
|
|
35
|
+
export { FabConfig, FabComponent, FabVariant, FabSize, FabPosition, } from "./types";
|
|
@@ -1,54 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component library exports
|
|
3
3
|
*
|
|
4
|
-
* This file
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* compatibility.
|
|
4
|
+
* This file exports all component creators and their types.
|
|
5
|
+
* Constants are NOT re-exported here to enable proper tree-shaking.
|
|
6
|
+
* Import constants directly from component paths if needed.
|
|
8
7
|
*
|
|
9
8
|
* @packageDocumentation
|
|
10
9
|
*/
|
|
11
|
-
export { LIST_DEFAULTS, LIST_TYPES, LIST_SELECTION_MODES, LIST_EVENTS, LIST_SCROLL_POSITIONS, LIST_CLASSES, } from "./list/constants";
|
|
12
|
-
export type { ListConfig, ListComponent, SelectEvent as ListSelectEvent, // Rename to avoid collision
|
|
13
|
-
LoadEvent, } from "./list/types";
|
|
14
|
-
export { BUTTON_GROUP_VARIANTS, BUTTON_GROUP_ORIENTATIONS, BUTTON_GROUP_DENSITY, BUTTON_GROUP_EVENTS, BUTTON_GROUP_DEFAULTS, BUTTON_GROUP_CLASSES, BUTTON_GROUP_HEIGHTS, BUTTON_GROUP_RADII, } from "./button-group/constants";
|
|
15
|
-
export type { ButtonGroupConfig, ButtonGroupComponent, ButtonGroupItemConfig, ButtonGroupEvent, ButtonGroupEventType, ButtonGroupVariant, ButtonGroupOrientation, ButtonGroupDensity, } from "./button-group/types";
|
|
16
|
-
export { SELECT_VARIANTS, SELECT_PLACEMENT, SELECT_INTERACTION, SELECT_EVENTS, SELECT_ICONS, SELECT_DEFAULTS, SELECT_CLASSES, } from "./select/constants";
|
|
17
|
-
export type { SelectConfig, SelectComponent, SelectOption, SelectEvent, // Keep the original name since select is more commonly used
|
|
18
|
-
SelectChangeEvent, } from "./select/types";
|
|
19
|
-
export * from "./badge";
|
|
20
|
-
export * from "./bottom-app-bar";
|
|
21
|
-
export * from "./button";
|
|
22
|
-
export * from "./button-group";
|
|
23
|
-
export * from "./card";
|
|
24
|
-
export * from "./carousel";
|
|
25
|
-
export * from "./checkbox";
|
|
26
|
-
export * from "./chips";
|
|
27
|
-
export * from "./datepicker";
|
|
28
|
-
export * from "./dialog";
|
|
29
|
-
export * from "./fab";
|
|
30
|
-
export * from "./extended-fab";
|
|
31
|
-
export * from "./icon-button";
|
|
32
|
-
export * from "./menu";
|
|
33
|
-
export * from "./navigation";
|
|
34
|
-
export { PROGRESS_VARIANTS, PROGRESS_SHAPES, PROGRESS_EVENTS, PROGRESS_DEFAULTS, PROGRESS_CLASSES, PROGRESS_MEASUREMENTS, PROGRESS_THICKNESS, } from "./progress/constants";
|
|
35
|
-
export type { ProgressConfig, ProgressComponent, ProgressShape, } from "./progress/types";
|
|
36
|
-
export * from "./radios";
|
|
37
|
-
export * from "./search";
|
|
38
|
-
export * from "./segmented-button";
|
|
39
|
-
export * from "./sheet";
|
|
40
|
-
export * from "./slider";
|
|
41
|
-
export * from "./snackbar";
|
|
42
|
-
export * from "./switch";
|
|
43
|
-
export * from "./tabs";
|
|
44
|
-
export * from "./textfield";
|
|
45
|
-
export * from "./timepicker";
|
|
46
|
-
export * from "./top-app-bar";
|
|
47
|
-
export * from "./tooltip";
|
|
48
|
-
export { createDivider } from "./divider";
|
|
49
|
-
export type { DividerConfig } from "./divider/config";
|
|
50
|
-
export type { DividerComponent } from "./divider/types";
|
|
51
|
-
export { createCardContent, createCardHeader, createCardActions, createCardMedia, } from "./card/content";
|
|
52
10
|
export { default as createBadge } from "./badge";
|
|
53
11
|
export { default as createBottomAppBar } from "./bottom-app-bar";
|
|
54
12
|
export { default as createButton } from "./button";
|
|
@@ -59,6 +17,7 @@ export { default as createCheckbox } from "./checkbox";
|
|
|
59
17
|
export { createChip, createChips } from "./chips";
|
|
60
18
|
export { default as createDatePicker } from "./datepicker";
|
|
61
19
|
export { default as createDialog } from "./dialog";
|
|
20
|
+
export { createDivider } from "./divider";
|
|
62
21
|
export { default as createFab } from "./fab";
|
|
63
22
|
export { default as createExtendedFab } from "./extended-fab";
|
|
64
23
|
export { default as createIconButton } from "./icon-button";
|
|
@@ -82,3 +41,36 @@ export { default as createTextfield } from "./textfield";
|
|
|
82
41
|
export { default as createTimePicker } from "./timepicker";
|
|
83
42
|
export { default as createTopAppBar } from "./top-app-bar";
|
|
84
43
|
export { default as createTooltip } from "./tooltip";
|
|
44
|
+
export { createCardContent, createCardHeader, createCardActions, createCardMedia, } from "./card/content";
|
|
45
|
+
export type { BadgeConfig, BadgeComponent } from "./badge/types";
|
|
46
|
+
export type { BottomAppBarConfig, BottomAppBar } from "./bottom-app-bar/types";
|
|
47
|
+
export type { ButtonConfig, ButtonComponent, ButtonVariant, } from "./button/types";
|
|
48
|
+
export type { ButtonGroupConfig, ButtonGroupComponent, ButtonGroupItemConfig, ButtonGroupEvent, ButtonGroupEventType, ButtonGroupVariant, ButtonGroupOrientation, ButtonGroupDensity, } from "./button-group/types";
|
|
49
|
+
export type { CardSchema } from "./card/types";
|
|
50
|
+
export type { CarouselConfig, CarouselComponent } from "./carousel/types";
|
|
51
|
+
export type { CheckboxConfig, CheckboxComponent } from "./checkbox/types";
|
|
52
|
+
export type { ChipConfig, ChipComponent, ChipVariant, ChipsConfig, ChipsComponent, } from "./chips/types";
|
|
53
|
+
export type { DatePickerConfig, DatePickerComponent } from "./datepicker/types";
|
|
54
|
+
export type { DialogConfig, DialogComponent } from "./dialog/types";
|
|
55
|
+
export type { DividerConfig } from "./divider/config";
|
|
56
|
+
export type { DividerComponent } from "./divider/types";
|
|
57
|
+
export type { FabConfig, FabComponent } from "./fab/types";
|
|
58
|
+
export type { ExtendedFabConfig, ExtendedFabComponent, } from "./extended-fab/types";
|
|
59
|
+
export type { IconButtonConfig, IconButtonComponent, } from "./icon-button/types";
|
|
60
|
+
export type { ListConfig, ListComponent, SelectEvent as ListSelectEvent, LoadEvent, } from "./list/types";
|
|
61
|
+
export type { MenuConfig, MenuComponent, MenuItem } from "./menu/types";
|
|
62
|
+
export type { NavigationConfig, NavigationComponent, NavItemConfig, } from "./navigation/types";
|
|
63
|
+
export type { ProgressConfig, ProgressComponent, ProgressShape, } from "./progress/types";
|
|
64
|
+
export type { RadiosConfig, RadiosComponent, RadioOptionConfig, } from "./radios/types";
|
|
65
|
+
export type { SearchConfig, SearchComponent } from "./search/types";
|
|
66
|
+
export type { SelectConfig, SelectComponent, SelectOption, SelectEvent, SelectChangeEvent, } from "./select/types";
|
|
67
|
+
export type { SegmentedButtonConfig, SegmentedButtonComponent, } from "./segmented-button/types";
|
|
68
|
+
export type { SheetConfig, SheetComponent } from "./sheet/types";
|
|
69
|
+
export type { SliderConfig, SliderComponent, SliderEvent, } from "./slider/types";
|
|
70
|
+
export type { SnackbarConfig, SnackbarComponent } from "./snackbar/types";
|
|
71
|
+
export type { SwitchConfig, SwitchComponent } from "./switch/types";
|
|
72
|
+
export type { TabsConfig, TabsComponent, TabConfig, TabComponent, } from "./tabs/types";
|
|
73
|
+
export type { TextfieldConfig, TextfieldComponent } from "./textfield/types";
|
|
74
|
+
export type { TimePickerConfig, TimePickerComponent } from "./timepicker/types";
|
|
75
|
+
export type { TopAppBarConfig, TopAppBar } from "./top-app-bar/types";
|
|
76
|
+
export type { TooltipConfig, TooltipComponent } from "./tooltip/types";
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export { ProgressConfig, ProgressComponent, ProgressShape } from
|
|
3
|
-
export { PROGRESS_VARIANTS, PROGRESS_SHAPES, PROGRESS_EVENTS, PROGRESS_DEFAULTS, PROGRESS_CLASSES, PROGRESS_MEASUREMENTS, PROGRESS_THICKNESS } from './constants';
|
|
1
|
+
export { default } from "./progress";
|
|
2
|
+
export { ProgressConfig, ProgressComponent, ProgressShape } from "./types";
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { default } from "./search";
|
|
2
2
|
export type { SearchConfig, SearchComponent, SearchEvent, SearchState, SearchViewMode, SearchEventType, SearchSuggestion, SearchTrailingItem, } from "./types";
|
|
3
|
-
export { SEARCH_STATES, SEARCH_VIEW_MODES, SEARCH_EVENTS, SEARCH_ICONS, SEARCH_DEFAULTS, SEARCH_CLASSES, SEARCH_MEASUREMENTS, SEARCH_KEYS, } from "./constants";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default, default as createSegmentedButton } from
|
|
2
|
-
export { SelectionMode, Density } from
|
|
3
|
-
export type { SegmentedButtonConfig, SegmentedButtonComponent, SegmentConfig, Segment } from
|
|
4
|
-
export { SEGMENTED_BUTTON_MODES, SEGMENTED_BUTTON_DENSITY, SEGMENTED_BUTTON_EVENTS, SEGMENTED_BUTTON_DEFAULTS, SEGMENTED_BUTTON_ICONS, SEGMENTED_BUTTON_CLASSES } from './constants';
|
|
1
|
+
export { default, default as createSegmentedButton } from "./segmented-button";
|
|
2
|
+
export { SelectionMode, Density } from "./types";
|
|
3
|
+
export type { SegmentedButtonConfig, SegmentedButtonComponent, SegmentConfig, Segment, } from "./types";
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export {
|
|
3
|
-
export { type SliderConfig, type SliderComponent, type SliderEvent } from './types';
|
|
1
|
+
export { default } from "./slider";
|
|
2
|
+
export { type SliderConfig, type SliderComponent, type SliderEvent, } from "./types";
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export {
|
|
3
|
-
export { SnackbarConfig, SnackbarComponent } from './types';
|
|
1
|
+
export { default } from "./snackbar";
|
|
2
|
+
export { SnackbarConfig, SnackbarComponent } from "./types";
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { default } from "./textfield";
|
|
2
|
-
export { TEXTFIELD_VARIANTS, TEXTFIELD_STATES, TEXTFIELD_TYPES, TEXTFIELD_EVENTS, TEXTFIELD_DEFAULTS, TEXTFIELD_CLASSES, TEXTFIELD_DENSITY, } from "./constants";
|
|
3
2
|
export { TextfieldConfig, TextfieldComponent, TextfieldDensity } from "./types";
|