mtrl 0.3.0 → 0.3.1
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/CLAUDE.md +33 -0
- package/index.ts +0 -2
- package/package.json +3 -1
- package/src/components/navigation/index.ts +4 -1
- package/src/components/navigation/types.ts +33 -0
- package/src/components/snackbar/index.ts +7 -1
- package/src/components/snackbar/types.ts +25 -0
- package/src/components/switch/index.ts +5 -1
- package/src/components/switch/types.ts +13 -0
- package/src/components/textfield/index.ts +7 -1
- package/src/components/textfield/types.ts +36 -0
- package/test/components/badge.test.ts +545 -0
- package/test/components/bottom-app-bar.test.ts +303 -0
- package/test/components/button.test.ts +233 -0
- package/test/components/card.test.ts +560 -0
- package/test/components/carousel.test.ts +951 -0
- package/test/components/checkbox.test.ts +462 -0
- package/test/components/chip.test.ts +692 -0
- package/test/components/datepicker.test.ts +1124 -0
- package/test/components/dialog.test.ts +990 -0
- package/test/components/divider.test.ts +412 -0
- package/test/components/extended-fab.test.ts +672 -0
- package/test/components/fab.test.ts +561 -0
- package/test/components/list.test.ts +365 -0
- package/test/components/menu.test.ts +718 -0
- package/test/components/navigation.test.ts +186 -0
- package/test/components/progress.test.ts +567 -0
- package/test/components/radios.test.ts +699 -0
- package/test/components/search.test.ts +1135 -0
- package/test/components/segmented-button.test.ts +732 -0
- package/test/components/sheet.test.ts +641 -0
- package/test/components/slider.test.ts +1220 -0
- package/test/components/snackbar.test.ts +461 -0
- package/test/components/switch.test.ts +452 -0
- package/test/components/tabs.test.ts +1369 -0
- package/test/components/textfield.test.ts +400 -0
- package/test/components/timepicker.test.ts +592 -0
- package/test/components/tooltip.test.ts +630 -0
- package/test/components/top-app-bar.test.ts +566 -0
- package/test/core/dom.attributes.test.ts +148 -0
- package/test/core/dom.classes.test.ts +152 -0
- package/test/core/dom.events.test.ts +243 -0
- package/test/core/emitter.test.ts +141 -0
- package/test/core/ripple.test.ts +99 -0
- package/test/core/state.store.test.ts +189 -0
- package/test/core/utils.normalize.test.ts +61 -0
- package/test/core/utils.object.test.ts +120 -0
- package/test/setup.ts +451 -0
- package/tsconfig.json +2 -2
- package/src/components/snackbar/constants.ts +0 -26
- package/test/components/button.test.js +0 -170
- package/test/components/checkbox.test.js +0 -238
- package/test/components/list.test.js +0 -105
- package/test/components/menu.test.js +0 -385
- package/test/components/navigation.test.js +0 -227
- package/test/components/snackbar.test.js +0 -234
- package/test/components/switch.test.js +0 -186
- package/test/components/textfield.test.js +0 -314
- package/test/core/emitter.test.js +0 -141
- package/test/core/ripple.test.js +0 -66
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Build & Development Commands
|
|
6
|
+
- Build: `bun run build`
|
|
7
|
+
- Dev server: `bun run dev`
|
|
8
|
+
- Tests: `bun test`
|
|
9
|
+
- Single test: `bun test test/components/button.test.ts`
|
|
10
|
+
- Watch tests: `bun test --watch`
|
|
11
|
+
- Test with UI: `bun test --watch --ui`
|
|
12
|
+
- Test coverage: `bun test --coverage`
|
|
13
|
+
- Docs: `bun run docs` (uses TypeDoc)
|
|
14
|
+
|
|
15
|
+
## Code Conventions
|
|
16
|
+
- Factory pattern: Use `createComponent` naming for component creators
|
|
17
|
+
- Functional composition with pipe pattern
|
|
18
|
+
- Follow BEM-style CSS naming: `mtrl-component__element--modifier`
|
|
19
|
+
- Use TypeDoc-compatible comments for documentation
|
|
20
|
+
- Use TypeScript with strict typing where possible
|
|
21
|
+
- Error handling: Try/catch blocks for component creation
|
|
22
|
+
- Import order: core modules first, then utility functions, local imports last
|
|
23
|
+
- Components follow a standard structure in their directories (api.ts, config.ts, etc.)
|
|
24
|
+
- Use ES6+ features with full browser compatibility
|
|
25
|
+
|
|
26
|
+
## Test Conventions
|
|
27
|
+
- Tests live in `test/components/` with `.test.ts` extension
|
|
28
|
+
- Use JSDOM for DOM manipulation in tests
|
|
29
|
+
- Create mock implementations to avoid circular dependencies
|
|
30
|
+
- Test structure follows `describe/test` pattern
|
|
31
|
+
- Test component creation, options, events, and state changes
|
|
32
|
+
- Use `import type` to avoid circular dependencies in TypeScript tests
|
|
33
|
+
- Test directory structure mirrors src directory structure
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mtrl",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A functional TypeScript/JavaScript component library with composable architecture based on Material Design 3",
|
|
5
5
|
"author": "floor",
|
|
6
6
|
"license": "MIT License",
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
"url": "https://github.com/floor/mtrl.git"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
+
"@types/jsdom": "^21.1.7",
|
|
46
|
+
"jsdom": "^26.0.0",
|
|
45
47
|
"sass": "^1.85.1",
|
|
46
48
|
"typedoc": "^0.27.9"
|
|
47
49
|
}
|
|
@@ -6,18 +6,51 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export type NavVariant = 'rail' | 'drawer' | 'bar' | 'modal' | 'standard';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Navigation variants enum
|
|
11
|
+
* @category Components
|
|
12
|
+
*/
|
|
13
|
+
export const NAV_VARIANTS: Record<string, NavVariant> = {
|
|
14
|
+
RAIL: 'rail',
|
|
15
|
+
DRAWER: 'drawer',
|
|
16
|
+
BAR: 'bar',
|
|
17
|
+
MODAL: 'modal',
|
|
18
|
+
STANDARD: 'standard'
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
9
21
|
/**
|
|
10
22
|
* Navigation positions
|
|
11
23
|
* @category Components
|
|
12
24
|
*/
|
|
13
25
|
export type NavPosition = 'left' | 'right' | 'top' | 'bottom';
|
|
14
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Navigation positions enum
|
|
29
|
+
* @category Components
|
|
30
|
+
*/
|
|
31
|
+
export const NAV_POSITIONS: Record<string, NavPosition> = {
|
|
32
|
+
LEFT: 'left',
|
|
33
|
+
RIGHT: 'right',
|
|
34
|
+
TOP: 'top',
|
|
35
|
+
BOTTOM: 'bottom'
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
15
38
|
/**
|
|
16
39
|
* Navigation behaviors
|
|
17
40
|
* @category Components
|
|
18
41
|
*/
|
|
19
42
|
export type NavBehavior = 'fixed' | 'dismissible' | 'modal';
|
|
20
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Navigation behaviors enum
|
|
46
|
+
* @category Components
|
|
47
|
+
*/
|
|
48
|
+
export const NAV_BEHAVIORS: Record<string, NavBehavior> = {
|
|
49
|
+
FIXED: 'fixed',
|
|
50
|
+
DISMISSIBLE: 'dismissible',
|
|
51
|
+
MODAL: 'modal'
|
|
52
|
+
} as const;
|
|
53
|
+
|
|
21
54
|
/**
|
|
22
55
|
* Navigation item state
|
|
23
56
|
* @category Components
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
// src/components/snackbar/index.ts
|
|
2
2
|
export { default } from './snackbar'
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
SnackbarConfig,
|
|
5
|
+
SnackbarComponent,
|
|
6
|
+
SNACKBAR_VARIANTS,
|
|
7
|
+
SNACKBAR_POSITIONS,
|
|
8
|
+
SNACKBAR_STATES
|
|
9
|
+
} from './types'
|
|
@@ -5,16 +5,41 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type SnackbarVariant = 'basic' | 'action';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Snackbar visual variants
|
|
10
|
+
*/
|
|
11
|
+
export const SNACKBAR_VARIANTS = {
|
|
12
|
+
BASIC: 'basic',
|
|
13
|
+
ACTION: 'action' // With action button
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* Available snackbar positions
|
|
10
18
|
*/
|
|
11
19
|
export type SnackbarPosition = 'center' | 'start' | 'end';
|
|
12
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Snackbar display positions
|
|
23
|
+
*/
|
|
24
|
+
export const SNACKBAR_POSITIONS = {
|
|
25
|
+
CENTER: 'center',
|
|
26
|
+
START: 'start',
|
|
27
|
+
END: 'end'
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
13
30
|
/**
|
|
14
31
|
* Snackbar visibility states
|
|
15
32
|
*/
|
|
16
33
|
export type SnackbarState = 'visible' | 'hidden';
|
|
17
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Snackbar state classes
|
|
37
|
+
*/
|
|
38
|
+
export const SNACKBAR_STATES = {
|
|
39
|
+
VISIBLE: 'visible',
|
|
40
|
+
HIDDEN: 'hidden'
|
|
41
|
+
} as const;
|
|
42
|
+
|
|
18
43
|
/**
|
|
19
44
|
* Available snackbar event types
|
|
20
45
|
*/
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// src/components/switch/index.ts
|
|
2
2
|
export { default } from './switch'
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
SwitchConfig,
|
|
5
|
+
SwitchComponent,
|
|
6
|
+
SWITCH_LABEL_POSITION
|
|
7
|
+
} from './types'
|
|
4
8
|
export { withSupportingText, SupportingTextComponent } from './features'
|
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
export type SwitchPosition = 'center' | 'start' | 'end';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Switch label position types
|
|
7
|
+
*/
|
|
8
|
+
export type SwitchLabelPosition = 'start' | 'end';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Switch label positions
|
|
12
|
+
*/
|
|
13
|
+
export const SWITCH_LABEL_POSITION = {
|
|
14
|
+
START: 'start',
|
|
15
|
+
END: 'end'
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
5
18
|
/**
|
|
6
19
|
* Configuration interface for the Switch component
|
|
7
20
|
*/
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
// src/components/textfield/index.ts
|
|
2
2
|
export { default } from './textfield'
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
TextfieldConfig,
|
|
5
|
+
TextfieldComponent,
|
|
6
|
+
TEXTFIELD_VARIANTS,
|
|
7
|
+
TEXTFIELD_SIZES,
|
|
8
|
+
TEXTFIELD_TYPES
|
|
9
|
+
} from './types'
|
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type TextfieldVariant = 'filled' | 'outlined';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Textfield variant constants
|
|
10
|
+
*/
|
|
11
|
+
export const TEXTFIELD_VARIANTS = {
|
|
12
|
+
FILLED: 'filled',
|
|
13
|
+
OUTLINED: 'outlined'
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Available Textfield sizes
|
|
18
|
+
*/
|
|
19
|
+
export type TextfieldSize = 'small' | 'medium' | 'large';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Textfield size constants
|
|
23
|
+
*/
|
|
24
|
+
export const TEXTFIELD_SIZES = {
|
|
25
|
+
SMALL: 'small',
|
|
26
|
+
MEDIUM: 'medium',
|
|
27
|
+
LARGE: 'large'
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
8
30
|
/**
|
|
9
31
|
* Available Textfield states
|
|
10
32
|
*/
|
|
@@ -15,6 +37,20 @@ export type TextfieldStates = 'active' | 'inactive' | 'disabled';
|
|
|
15
37
|
*/
|
|
16
38
|
export type TextfieldTypes = 'text' | 'password' | 'email' | 'number' | 'tel' | 'url' | 'search' | 'multiline';
|
|
17
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Textfield type constants
|
|
42
|
+
*/
|
|
43
|
+
export const TEXTFIELD_TYPES = {
|
|
44
|
+
TEXT: 'text',
|
|
45
|
+
PASSWORD: 'password',
|
|
46
|
+
EMAIL: 'email',
|
|
47
|
+
NUMBER: 'number',
|
|
48
|
+
TEL: 'tel',
|
|
49
|
+
URL: 'url',
|
|
50
|
+
SEARCH: 'search',
|
|
51
|
+
MULTILINE: 'multiline'
|
|
52
|
+
} as const;
|
|
53
|
+
|
|
18
54
|
/**
|
|
19
55
|
* Configuration interface for the Textfield component
|
|
20
56
|
*/
|