@shortfuse/materialdesignweb 0.7.6 → 0.8.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.
- package/README.md +57 -68
- package/components/Badge.js +2 -2
- package/components/BottomAppBar.js +3 -5
- package/components/Box.js +33 -3
- package/components/Button.js +48 -21
- package/components/Button.md +9 -9
- package/components/Card.js +9 -16
- package/components/Checkbox.js +45 -36
- package/components/CheckboxIcon.js +2 -2
- package/components/Chip.js +1 -1
- package/components/Dialog.js +228 -359
- package/components/DialogActions.js +2 -2
- package/components/Divider.js +3 -3
- package/components/ExtendedFab.js +4 -8
- package/components/Fab.js +1 -2
- package/components/FilterChip.js +4 -4
- package/components/Headline.js +1 -1
- package/components/Icon.js +8 -8
- package/components/IconButton.js +9 -14
- package/components/Input.js +273 -1
- package/components/Layout.js +485 -16
- package/components/List.js +6 -4
- package/components/ListItem.js +12 -12
- package/components/ListOption.js +21 -5
- package/components/Listbox.js +239 -0
- package/components/Menu.js +77 -526
- package/components/MenuItem.js +12 -14
- package/components/Nav.js +0 -2
- package/components/NavBar.js +8 -79
- package/components/NavDrawer.js +12 -11
- package/components/NavDrawerItem.js +2 -1
- package/components/NavItem.js +18 -8
- package/components/NavRail.js +15 -7
- package/components/NavRailItem.js +3 -1
- package/components/Popup.js +20 -0
- package/components/Progress.js +24 -23
- package/components/Radio.js +42 -35
- package/components/RadioIcon.js +3 -3
- package/components/Ripple.js +2 -3
- package/components/Search.js +85 -0
- package/components/SegmentedButton.js +1 -10
- package/components/SegmentedButtonGroup.js +16 -10
- package/components/Select.js +4 -4
- package/components/Shape.js +1 -1
- package/components/Slider.js +43 -50
- package/components/Snackbar.js +4 -5
- package/components/Surface.js +3 -3
- package/components/Switch.js +55 -21
- package/components/SwitchIcon.js +10 -8
- package/components/Tab.js +11 -9
- package/components/TabContent.js +4 -3
- package/components/TabList.js +2 -2
- package/components/TabPanel.js +11 -8
- package/components/TextArea.js +38 -35
- package/components/Tooltip.js +2 -2
- package/components/TopAppBar.js +65 -147
- package/core/Composition.js +985 -628
- package/core/CompositionAdapter.js +315 -0
- package/core/CustomElement.js +153 -90
- package/core/DomAdapter.js +586 -0
- package/core/ICustomElement.d.ts +2 -2
- package/core/css.js +8 -7
- package/core/customTypes.js +53 -31
- package/{utils → core}/jsonMergePatch.js +36 -14
- package/core/observe.js +111 -57
- package/core/optimizations.js +23 -0
- package/core/template.js +17 -11
- package/core/test.js +126 -0
- package/core/typings.d.ts +11 -5
- package/core/uid.js +13 -0
- package/dist/index.min.js +83 -152
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/mixins/AriaReflectorMixin.js +1 -2
- package/mixins/AriaToolbarMixin.js +2 -3
- package/mixins/ControlMixin.js +25 -17
- package/mixins/DensityMixin.js +0 -1
- package/mixins/FlexableMixin.js +1 -2
- package/mixins/FormAssociatedMixin.js +13 -10
- package/mixins/InputMixin.js +2 -9
- package/mixins/KeyboardNavMixin.js +14 -1
- package/mixins/PopupMixin.js +757 -0
- package/mixins/RTLObserverMixin.js +0 -1
- package/mixins/ResizeObserverMixin.js +0 -1
- package/mixins/RippleMixin.js +3 -4
- package/mixins/ScrollListenerMixin.js +41 -32
- package/mixins/SemiStickyMixin.js +151 -0
- package/mixins/ShapeMixin.js +29 -24
- package/mixins/StateMixin.js +11 -6
- package/mixins/SurfaceMixin.js +3 -57
- package/mixins/TextFieldMixin.js +57 -65
- package/mixins/ThemableMixin.js +78 -156
- package/mixins/TooltipTriggerMixin.js +7 -13
- package/mixins/TouchTargetMixin.js +4 -3
- package/package.json +9 -5
- package/theming/index.js +1 -1
- package/theming/themableMixinLoader.js +12 -0
- package/utils/{hct → material-color}/blend.js +8 -10
- package/utils/{hct → material-color/hct}/Cam16.js +196 -69
- package/utils/{hct → material-color/hct}/Hct.js +61 -19
- package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
- package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
- package/utils/{hct → material-color}/helper.js +11 -18
- package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
- package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
- package/utils/material-color/scheme/Scheme.js +376 -0
- package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
- package/utils/popup.js +46 -25
- package/components/ListSelect.js +0 -220
- package/components/Option.js +0 -91
- package/components/Pane.js +0 -281
- package/core/identify.js +0 -40
- package/utils/hct/Scheme.js +0 -587
- /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
package/core/test.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import CustomElement from './CustomElement.js';
|
|
2
|
+
|
|
3
|
+
/** @param {number} max */
|
|
4
|
+
function _random(max) {
|
|
5
|
+
return Math.round(Math.random() * 1000) % max;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
CustomElement
|
|
9
|
+
.extend()
|
|
10
|
+
.observe({
|
|
11
|
+
data: { type: 'object', reflect: false, value: [] },
|
|
12
|
+
selected: { type: 'integer', reflect: false },
|
|
13
|
+
})
|
|
14
|
+
.methods({
|
|
15
|
+
buildData(count = 1000) {
|
|
16
|
+
const adjectives = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome', 'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy', 'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive', 'fancy'];
|
|
17
|
+
const colours = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown', 'white', 'black', 'orange'];
|
|
18
|
+
const nouns = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie', 'sandwich', 'burger', 'pizza', 'mouse', 'keyboard'];
|
|
19
|
+
const data = [];
|
|
20
|
+
for (let i = 0; i < count; i++) { data.push({ id: this.id++, label: `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}` }); }
|
|
21
|
+
return data;
|
|
22
|
+
},
|
|
23
|
+
updateData(mod = 10) {
|
|
24
|
+
for (let i = 0; i < this.data.length; i += 10) {
|
|
25
|
+
this.data[i].label += ' !!!';
|
|
26
|
+
// this.data[i] = Object.assign({}, this.data[i], {label: this.data[i].label +' !!!'});
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
onItemClick({ currentTarget }) {
|
|
31
|
+
this.selected = currentTarget.dataset.id;
|
|
32
|
+
return false;
|
|
33
|
+
},
|
|
34
|
+
onRemoveClick({ currentTarget }) {
|
|
35
|
+
const id = currentTarget.dataset.id;
|
|
36
|
+
this.data = this.data.filter((item) => item.id !== id);
|
|
37
|
+
return false;
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
.html`
|
|
41
|
+
<link href="/css/currentStyle.css" rel="stylesheet"/>
|
|
42
|
+
<div class=container>
|
|
43
|
+
<div class=jumbotron>
|
|
44
|
+
<div class=row>
|
|
45
|
+
<div class=col-md-6><h1>MDW unkeyed</h1></div>
|
|
46
|
+
<div class=col-md-6>
|
|
47
|
+
<div class=row>
|
|
48
|
+
<div class="col-sm-6 smallpad">
|
|
49
|
+
<button id=run class="btn btn-primary btn-block">Create 1,000 rows</button>
|
|
50
|
+
</div>
|
|
51
|
+
<div class="col-sm-6 smallpad">
|
|
52
|
+
<button id=runlots class="btn btn-primary btn-block">Create 10,000 rows</button>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="col-sm-6 smallpad">
|
|
55
|
+
<button id=add class="btn btn-primary btn-block">Append 1,000 rows</button>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="col-sm-6 smallpad">
|
|
58
|
+
<button id=update class="btn btn-primary btn-block">Update every 10th row</button>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="col-sm-6 smallpad">
|
|
61
|
+
<button id=clear class="btn btn-primary btn-block" >Clear</button>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="col-sm-6 smallpad">
|
|
64
|
+
<button id=swaprows class="btn btn-primary btn-block">Swap Rows</button>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<table id=table class="table table-hover table-striped test-data">
|
|
71
|
+
<tbody>
|
|
72
|
+
<tr mdw-for="{item of data}" id={item.id} class=${({ item, _selected }) => (item?.id == _selected ? 'danger' : '')}>
|
|
73
|
+
<td class="col-md-1">{item.id}</td>
|
|
74
|
+
<td class="col-md-4"><a on-click={onLabelClick} data-id={item.id} >{item.label}</a></td>
|
|
75
|
+
<td class="col-md-1"><a on-click={onRemoveClick} data-id={item.id} ><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
|
|
76
|
+
<td class="col-md-6"></td>
|
|
77
|
+
</tr>
|
|
78
|
+
</tbody>
|
|
79
|
+
</table>
|
|
80
|
+
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
|
|
81
|
+
</div>
|
|
82
|
+
`
|
|
83
|
+
.childEvents({
|
|
84
|
+
run: {
|
|
85
|
+
click() {
|
|
86
|
+
this.data = this.buildData();
|
|
87
|
+
this.selected = null;
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
runlots: {
|
|
91
|
+
click() {
|
|
92
|
+
this.data = this.buildData(10_000);
|
|
93
|
+
this.selected = null;
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
add: {
|
|
97
|
+
click() {
|
|
98
|
+
this.data = this.data.concat(this.buildData(1000));
|
|
99
|
+
this.selected = null;
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
update: {
|
|
103
|
+
click() {
|
|
104
|
+
this.updateData();
|
|
105
|
+
this.data = this.data.slice();
|
|
106
|
+
this.selected = null;
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
swaprows: {
|
|
110
|
+
click() {
|
|
111
|
+
if (this.data.length > 998) {
|
|
112
|
+
const newData = this.data.slice();
|
|
113
|
+
const tmp = this.newData[1];
|
|
114
|
+
this.newData[1] = this.newData[998];
|
|
115
|
+
this.newData[998] = tmp;
|
|
116
|
+
this.data = newData;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
clear: {
|
|
121
|
+
click() {
|
|
122
|
+
this.data = [];
|
|
123
|
+
this.selected = null;
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
}).register('benchmark-app');
|
package/core/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type ObserverPropertyType = 'string' | 'boolean' | 'map' | 'set' | 'float' | 'integer' | 'object' | 'function';
|
|
1
|
+
type ObserverPropertyType = 'string' | 'boolean' | 'map' | 'set' | 'float' | 'integer' | 'object' | 'function' | 'array';
|
|
2
2
|
|
|
3
3
|
type InlineTemplate<T1, T2=T1> = (fn: (this:T1, data: T2) => any) => string;
|
|
4
4
|
|
|
@@ -10,6 +10,7 @@ type ParsedObserverPropertyType<T extends ObserverPropertyType> =
|
|
|
10
10
|
T extends 'boolean' ? boolean
|
|
11
11
|
: T extends 'string' ? string
|
|
12
12
|
: T extends 'float' | 'integer' ? number
|
|
13
|
+
: T extends 'array' ? any[]
|
|
13
14
|
: T extends 'object' ? any
|
|
14
15
|
: T extends 'function' ? (...args:any) => any
|
|
15
16
|
: unknown;
|
|
@@ -73,7 +74,11 @@ type ParsedProps<T> = {
|
|
|
73
74
|
: never
|
|
74
75
|
};
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
interface HTMLElementEventMapFixed extends HTMLElementEventMap {
|
|
78
|
+
input: InputEvent;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type HTMLElementCancellableEventMap = Pick<HTMLElementEventMapFixed,
|
|
77
82
|
'auxclick' |
|
|
78
83
|
'beforeinput' |
|
|
79
84
|
// 'cancel' |
|
|
@@ -108,13 +113,13 @@ type HTMLElementCancellableEventMap = Pick<HTMLElementEventMap,
|
|
|
108
113
|
'wheel'
|
|
109
114
|
>
|
|
110
115
|
|
|
111
|
-
type CompositionEventMap =
|
|
116
|
+
type CompositionEventMap = HTMLElementEventMapFixed & {
|
|
112
117
|
[P in keyof HTMLElementCancellableEventMap as `~${P}`]: Omit<HTMLElementCancellableEventMap[P], 'preventDefault'>
|
|
113
118
|
};
|
|
114
119
|
|
|
115
120
|
type CompositionEventListener<T, K = keyof CompositionEventMap> = {
|
|
116
121
|
type?: K
|
|
117
|
-
|
|
122
|
+
tag?: string,
|
|
118
123
|
capture?: boolean;
|
|
119
124
|
once?: boolean;
|
|
120
125
|
passive?: boolean;
|
|
@@ -123,7 +128,8 @@ type CompositionEventListener<T, K = keyof CompositionEventMap> = {
|
|
|
123
128
|
this: T,
|
|
124
129
|
event: (K extends keyof CompositionEventMap ? CompositionEventMap[K] : Event) & {currentTarget:HTMLElement}
|
|
125
130
|
) => any;
|
|
126
|
-
prop?:
|
|
131
|
+
prop?: string;
|
|
132
|
+
deepProp?: string[],
|
|
127
133
|
};
|
|
128
134
|
|
|
129
135
|
type CompositionEventListenerObject<T> =
|
package/core/uid.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @type {Set<string>} */
|
|
2
|
+
const generatedUIDs = new Set();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} [prefix='x'] Prefix all UIDs by string to apply a name or ensure starts with [A-Z] character
|
|
6
|
+
* @param {number} [n] Maximum number of variations needed. Calculated as 32^n.
|
|
7
|
+
@return {string} */
|
|
8
|
+
export function generateUID(prefix = 'mdw_', n = 4) {
|
|
9
|
+
let id;
|
|
10
|
+
while (generatedUIDs.has(id = Math.random().toString(36).slice(2, n + 2)));
|
|
11
|
+
generatedUIDs.add(id);
|
|
12
|
+
return `${prefix}${id}`;
|
|
13
|
+
}
|