@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/utils/popup.js
CHANGED
|
@@ -63,6 +63,7 @@ export function canAnchorPopup(options) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
|
|
66
67
|
let { width, height } = options;
|
|
67
68
|
if (width == null || height == null) {
|
|
68
69
|
const { popup } = options;
|
|
@@ -75,42 +76,62 @@ export function canAnchorPopup(options) {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
let top;
|
|
80
|
+
let right;
|
|
81
|
+
let bottom;
|
|
82
|
+
let left;
|
|
83
|
+
const margin = options.margin ?? 0;
|
|
84
|
+
const pageTop = margin;
|
|
85
|
+
const pageBottom = document.documentElement.clientHeight - margin;
|
|
86
|
+
const pageRight = document.documentElement.clientWidth - margin;
|
|
87
|
+
const pageLeft = margin;
|
|
88
|
+
|
|
89
|
+
const offsetX = options.offsetX ?? 0;
|
|
90
|
+
const offsetY = options.offsetY ?? 0;
|
|
91
|
+
pageX += offsetX;
|
|
92
|
+
pageY += offsetY;
|
|
86
93
|
|
|
87
|
-
// eslint-disable-next-line default-case
|
|
88
94
|
switch (directionY) {
|
|
89
95
|
case 'up':
|
|
90
|
-
pageY
|
|
96
|
+
bottom = Math.min(pageY, pageBottom);
|
|
97
|
+
top = Math.max(bottom - height, pageTop);
|
|
91
98
|
break;
|
|
92
99
|
case 'center':
|
|
93
|
-
pageY
|
|
100
|
+
top = Math.max(pageY - height / 2, pageTop);
|
|
101
|
+
bottom = Math.min(pageY + height / 2, pageBottom);
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
top = Math.max(pageY, pageTop);
|
|
105
|
+
bottom = Math.min(top + height, pageBottom);
|
|
94
106
|
}
|
|
95
107
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
switch (directionX) {
|
|
109
|
+
case 'left':
|
|
110
|
+
right = Math.min(pageX, pageRight);
|
|
111
|
+
left = Math.max(right - width, pageLeft);
|
|
112
|
+
break;
|
|
113
|
+
case 'center':
|
|
114
|
+
left = Math.max(pageX - width / 2, pageLeft);
|
|
115
|
+
right = Math.min(pageX + width / 2, pageRight);
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
left = Math.max(pageX, pageLeft);
|
|
119
|
+
right = Math.min(left + width, pageRight);
|
|
106
120
|
}
|
|
107
121
|
|
|
122
|
+
// compute area
|
|
123
|
+
const fullSize = width * height;
|
|
124
|
+
const realSize = (bottom - top) * (right - left);
|
|
125
|
+
|
|
126
|
+
const visibility = realSize / fullSize;
|
|
127
|
+
|
|
108
128
|
return {
|
|
109
129
|
...options,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
top,
|
|
131
|
+
right,
|
|
132
|
+
bottom,
|
|
133
|
+
left,
|
|
134
|
+
visibility,
|
|
114
135
|
transformOriginX: directionX === 'center' ? 'center' : (directionX === 'left' ? 'right' : 'left'),
|
|
115
136
|
transformOriginY: directionY === 'center' ? 'center' : (directionY === 'up' ? 'bottom' : 'top'),
|
|
116
137
|
};
|
package/components/ListSelect.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { constructHTMLOptionsCollectionProxy } from '../dom/HTMLOptionsCollectionProxy.js';
|
|
2
|
-
import FormAssociatedMixin from '../mixins/FormAssociatedMixin.js';
|
|
3
|
-
import KeyboardNavMixin from '../mixins/KeyboardNavMixin.js';
|
|
4
|
-
import StateMixin from '../mixins/StateMixin.js';
|
|
5
|
-
|
|
6
|
-
import List from './List.js';
|
|
7
|
-
import ListOption from './ListOption.js';
|
|
8
|
-
|
|
9
|
-
/** @implements {HTMLSelectElement} */
|
|
10
|
-
export default class ListSelect extends List
|
|
11
|
-
.mixin(StateMixin)
|
|
12
|
-
.mixin(FormAssociatedMixin)
|
|
13
|
-
.mixin(KeyboardNavMixin) {
|
|
14
|
-
static {
|
|
15
|
-
this.autoRegister('mdw-list-select');
|
|
16
|
-
// eslint-disable-next-line no-unused-expressions
|
|
17
|
-
this.css`
|
|
18
|
-
:host(:disabled) {
|
|
19
|
-
cursor: not-allowed;
|
|
20
|
-
pointer-events: none;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
:host([internals-disabled]) {
|
|
24
|
-
cursor: not-allowed;
|
|
25
|
-
pointer-events: none;
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
this.on({
|
|
29
|
-
disabledStateChanged(oldValue, newValue) {
|
|
30
|
-
this._kbdFocusable = !newValue;
|
|
31
|
-
this.tabIndex = newValue ? -1 : 0;
|
|
32
|
-
},
|
|
33
|
-
multipleChanged(oldValue, newValue) {
|
|
34
|
-
this.updateAriaProperty('ariaMultiSelectable', newValue ? 'true' : 'false');
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** @type {HTMLCollectionOf<ListOption> & HTMLOptionsCollection} */
|
|
40
|
-
_optionsCollection = null;
|
|
41
|
-
|
|
42
|
-
constructor() {
|
|
43
|
-
super();
|
|
44
|
-
this.refs.slot.addEventListener('slotchange', this.onSlotChange);
|
|
45
|
-
this.addEventListener('keydown', this.onControlKeydown);
|
|
46
|
-
this.addEventListener('click', this.onListSelectClick);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
connectedCallback() {
|
|
50
|
-
super.connectedCallback();
|
|
51
|
-
if (!this.hasAttribute('tabindex')) {
|
|
52
|
-
this.tabIndex = 0;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
* _selectedOptionsGenerator() {
|
|
57
|
-
for (const el of this.options) {
|
|
58
|
-
if (!el.selected) continue;
|
|
59
|
-
yield el;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @param {Event} event
|
|
65
|
-
* @this {HTMLSlotElement}
|
|
66
|
-
* @return {void}
|
|
67
|
-
*/
|
|
68
|
-
onSlotChange(event) {
|
|
69
|
-
/** @type {{host:ListSelect}} */ // @ts-ignore Coerce
|
|
70
|
-
const { host } = this.getRootNode();
|
|
71
|
-
host.refreshTabIndexes();
|
|
72
|
-
let index = 0;
|
|
73
|
-
for (const el of host.options) {
|
|
74
|
-
el._index = index++;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @param {KeyboardEvent} event
|
|
80
|
-
* @this {ListSelect}
|
|
81
|
-
* @return {void}
|
|
82
|
-
*/
|
|
83
|
-
onControlKeydown(event) {
|
|
84
|
-
if (event.key === 'Spacebar' || event.key === ' ') {
|
|
85
|
-
const target = event.target;
|
|
86
|
-
if (!(target instanceof ListOption)) return;
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
event.preventDefault();
|
|
89
|
-
this.onListSelectClick.call(this, event);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @param {MouseEvent|KeyboardEvent} event
|
|
95
|
-
* @this {ListSelect}
|
|
96
|
-
* @return {void}
|
|
97
|
-
*/
|
|
98
|
-
onListSelectClick(event) {
|
|
99
|
-
console.log('onListSelectClick');
|
|
100
|
-
const target = event.target;
|
|
101
|
-
if (!(target instanceof ListOption)) return;
|
|
102
|
-
event.stopPropagation();
|
|
103
|
-
if (target.disabledState) return;
|
|
104
|
-
|
|
105
|
-
// Perform unselect
|
|
106
|
-
if (target.selected) {
|
|
107
|
-
if (this.multiple) {
|
|
108
|
-
const selections = [...this.selectedOptions];
|
|
109
|
-
if (this.required && selections.length === 1) return;
|
|
110
|
-
if (selections.length === 0) {
|
|
111
|
-
console.warn('impossible??');
|
|
112
|
-
}
|
|
113
|
-
target.selected = false;
|
|
114
|
-
let firstSelection = selections.shift();
|
|
115
|
-
if (firstSelection === target) {
|
|
116
|
-
// Get new first selection (or undefined)
|
|
117
|
-
firstSelection = selections.shift();
|
|
118
|
-
}
|
|
119
|
-
this._value = firstSelection?.value ?? '';
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (this.required) return;
|
|
123
|
-
target.selected = false;
|
|
124
|
-
this._value = '';
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (this.multiple) {
|
|
129
|
-
// Skip ctrlKey requirement
|
|
130
|
-
target.selected = true;
|
|
131
|
-
this._value = this.selectedOptions.next().value;
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
for (const el of this.options) {
|
|
136
|
-
el.selected = el === target;
|
|
137
|
-
}
|
|
138
|
-
this._value = target.value;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
formResetCallback() {
|
|
142
|
-
// TODO: Reset dirty on options
|
|
143
|
-
super.formResetCallback();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
get options() {
|
|
147
|
-
if (!this._optionsCollection) {
|
|
148
|
-
this._optionsCollection = constructHTMLOptionsCollectionProxy({
|
|
149
|
-
host: this,
|
|
150
|
-
collection: this.getElementsByTagName(ListOption.elementName),
|
|
151
|
-
OptionConstructor: ListOption,
|
|
152
|
-
GroupConstructor: ListOption,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return this._optionsCollection;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
get selectedOptions() {
|
|
159
|
-
return this._selectedOptionsGenerator();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// @ts-ignore @override
|
|
163
|
-
get type() { return 'select'; }
|
|
164
|
-
|
|
165
|
-
/** @override */
|
|
166
|
-
get kbdNavQuery() { return ListOption.elementName; }
|
|
167
|
-
|
|
168
|
-
// @ts-ignore @override
|
|
169
|
-
get length() {
|
|
170
|
-
return this.options.length;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
get selectedIndex() {
|
|
174
|
-
return this.options.selectedIndex;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
set selectedIndex(value) {
|
|
178
|
-
this.options.selectedIndex = value;
|
|
179
|
-
this._value = (this.options.item(value)?.value) ?? '';
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
get value() {
|
|
183
|
-
return this._value;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/** @param {string} v */
|
|
187
|
-
set value(v) {
|
|
188
|
-
for (const el of this.options) {
|
|
189
|
-
el.selected = (el.value === v);
|
|
190
|
-
}
|
|
191
|
-
this._value = v;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
get add() { return this.options.add; }
|
|
195
|
-
|
|
196
|
-
get item() { return this.options.item; }
|
|
197
|
-
|
|
198
|
-
get namedItem() { return this.options.namedItem; }
|
|
199
|
-
|
|
200
|
-
* [Symbol.iterator]() {
|
|
201
|
-
for (const el of this.options) {
|
|
202
|
-
yield el;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
get kbdNavFocusableWhenDisabled() { return true; }
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// https://html.spec.whatwg.org/multipage/form-elements.html#htmlselectelement
|
|
210
|
-
|
|
211
|
-
// [CEReactions] attribute DOMString autocomplete;
|
|
212
|
-
// ListSelect.prototype.disabled = ListSelect.prop('disabled', { type: 'boolean' });
|
|
213
|
-
// readonly attribute HTMLFormElement? form;
|
|
214
|
-
ListSelect.prototype.multiple = ListSelect.prop('multiple', { type: 'boolean' });
|
|
215
|
-
// [CEReactions] attribute boolean multiple;
|
|
216
|
-
// [CEReactions] attribute DOMString name;
|
|
217
|
-
// [CEReactions] attribute boolean required;
|
|
218
|
-
ListSelect.prototype.size = ListSelect.prop('size', { type: 'integer', empty: 0 });
|
|
219
|
-
ListSelect.prototype._ariaRole = 'listbox';
|
|
220
|
-
ListSelect.prototype.delegatesFocus = true;
|
package/components/Option.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
|
|
2
|
-
|
|
3
|
-
import MenuItem from './MenuItem.js';
|
|
4
|
-
|
|
5
|
-
// https://html.spec.whatwg.org/multipage/form-elements.html#htmloptionelement
|
|
6
|
-
|
|
7
|
-
/** @implements {HTMLOptionElement} */
|
|
8
|
-
export default class Option extends MenuItem
|
|
9
|
-
.extend()
|
|
10
|
-
.set({
|
|
11
|
-
disabled: undefined, // Remove observer
|
|
12
|
-
_index: -1,
|
|
13
|
-
})
|
|
14
|
-
.observe({
|
|
15
|
-
// ListOption.prototype._form = ListOption.prop('_form');
|
|
16
|
-
_label: { attr: 'label', nullParser: String },
|
|
17
|
-
defaultSelected: { attr: 'selected', type: 'boolean' },
|
|
18
|
-
_selected: 'boolean',
|
|
19
|
-
_value: { attr: 'value', reflect: true },
|
|
20
|
-
})
|
|
21
|
-
.define({
|
|
22
|
-
index() { return this._index; },
|
|
23
|
-
form() { return /** @type {import('./ListSelect.js').default} */ (this.parentElement)?.form; },
|
|
24
|
-
|
|
25
|
-
label: {
|
|
26
|
-
get() { return this._label; },
|
|
27
|
-
/** @param {string} value */
|
|
28
|
-
set(value) {
|
|
29
|
-
this._label = value;
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
value: {
|
|
33
|
-
get() { return this._value || this.text; },
|
|
34
|
-
/** @param {string} value */
|
|
35
|
-
set(value) { this._label = value; },
|
|
36
|
-
},
|
|
37
|
-
selected: {
|
|
38
|
-
get() { return this._selected; },
|
|
39
|
-
/** @param {boolean} value */
|
|
40
|
-
set(value) { this._selected = value; },
|
|
41
|
-
},
|
|
42
|
-
disabled: {
|
|
43
|
-
get() {
|
|
44
|
-
return this.getAttribute('aria-disabled') === 'true' || this._disabled;
|
|
45
|
-
},
|
|
46
|
-
/** @param {boolean} value */
|
|
47
|
-
set(value) {
|
|
48
|
-
this._disabled = value;
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
.on('composed', ({ $ }) => {
|
|
54
|
-
// $('#state').setAttribute('state-disabled', 'focus hover');
|
|
55
|
-
})
|
|
56
|
-
.onPropChanged({
|
|
57
|
-
checkbox(oldValue, newValue) {
|
|
58
|
-
if (newValue) {
|
|
59
|
-
this.setAttribute('aria-selected', String(this.hasAttribute('selected')));
|
|
60
|
-
} else {
|
|
61
|
-
this.removeAttribute('aria-selected');
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
_selected(oldValue, newValue) {
|
|
65
|
-
this.setAttribute('aria-selected', String(newValue));
|
|
66
|
-
},
|
|
67
|
-
}) {
|
|
68
|
-
static { this.autoRegister('mdw-option'); }
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param {string} [text]
|
|
72
|
-
* @param {string} [value]
|
|
73
|
-
* @param {boolean} [defaultSelected]
|
|
74
|
-
* @param {boolean} [selected]
|
|
75
|
-
*/
|
|
76
|
-
constructor(text, value, defaultSelected, selected) {
|
|
77
|
-
super();
|
|
78
|
-
if (text !== undefined) {
|
|
79
|
-
this.text = text;
|
|
80
|
-
}
|
|
81
|
-
if (value !== undefined) {
|
|
82
|
-
this._value = value;
|
|
83
|
-
}
|
|
84
|
-
if (defaultSelected !== undefined) {
|
|
85
|
-
this.defaultSelected = defaultSelected;
|
|
86
|
-
}
|
|
87
|
-
if (selected !== undefined) {
|
|
88
|
-
this._selected = selected;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
package/components/Pane.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import CustomElement from '../core/CustomElement.js';
|
|
2
|
-
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
3
|
-
|
|
4
|
-
export default CustomElement
|
|
5
|
-
.mixin(ThemableMixin)
|
|
6
|
-
.extend()
|
|
7
|
-
.observe({
|
|
8
|
-
columns: 'integer',
|
|
9
|
-
flexible: 'boolean',
|
|
10
|
-
fixed: 'boolean',
|
|
11
|
-
split: 'boolean',
|
|
12
|
-
navDrawer: 'boolean',
|
|
13
|
-
navRail: 'boolean',
|
|
14
|
-
})
|
|
15
|
-
.html/* html */`
|
|
16
|
-
<slot id=slot></slot>
|
|
17
|
-
`
|
|
18
|
-
.css`
|
|
19
|
-
/* https://m2.material.io/design/layout/responsive-layout-grid.html#columns-gutters-and-margins */
|
|
20
|
-
/*
|
|
21
|
-
* Window breakpoints
|
|
22
|
-
* Compact (0 <= width < 600px):
|
|
23
|
-
* * Single: 100vw - padding
|
|
24
|
-
* * Padding: 16px
|
|
25
|
-
* * Spacer: 0 (none)
|
|
26
|
-
* Medium (600px <= width < 840px)
|
|
27
|
-
* * Single: 100vw - padding - (?navrail)
|
|
28
|
-
* * [Fixed]: 360px
|
|
29
|
-
* * [Flexable]: 100vw - 360px - spacer - padding
|
|
30
|
-
* * [Split] 50vw - ((padding + spacer) / 2)
|
|
31
|
-
* * Padding: 24px
|
|
32
|
-
* * Spacer: 24px
|
|
33
|
-
* Expanded (840px <= width)
|
|
34
|
-
* * Single: 100vw - padding - (?navrail | ?navdrawer)
|
|
35
|
-
* * [Fixed] 360px
|
|
36
|
-
* * [Flexable] 100vw - 360px - spacer - padding - (?navrail | ?navdrawer)
|
|
37
|
-
* * [Split] 50vw - ((padding + spacer + (?navrail | ?navdrawer)) / 2)
|
|
38
|
-
* * Padding: 24px
|
|
39
|
-
* * Spacer: 24px
|
|
40
|
-
*
|
|
41
|
-
* | Screen size | Margin | Body | Layout columns |
|
|
42
|
-
* |---------------------|---------|---------|----------------|
|
|
43
|
-
* | Extra-small (phone) | | | |
|
|
44
|
-
* | 0-631dp | 16dp | Scaling | 4 |
|
|
45
|
-
* | 632 - 647 | Scaling | 600dp | 8 |
|
|
46
|
-
* | Small (tablet) | | | |
|
|
47
|
-
* | 648-887 | 24dp | Scaling | 8 |
|
|
48
|
-
* | 888-1239 | Scaling | 840dp | 12 |
|
|
49
|
-
* | Medium (laptop) | | | |
|
|
50
|
-
* | 1240-1439 | 200dp | Scaling | 12 |
|
|
51
|
-
* | Large (desktop) | | | |
|
|
52
|
-
* | 1440+ | Scaling | 1040 | 12 |
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* Column count is pane-based, not window based requiring newly computed values.
|
|
56
|
-
* Gutters are irrelevant to pane sizing.
|
|
57
|
-
* Nav Rail is ~80px.
|
|
58
|
-
* Nav Drawer is ~360px.
|
|
59
|
-
* Padding and spacers are set by pane's parent.
|
|
60
|
-
* Avoid using CSS Variables because panes are at top of document tree. https://bugs.chromium.org/p/chromium/issues/detail?id=1056209
|
|
61
|
-
* Container queries would reduce code considerably.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/* Compact */
|
|
65
|
-
:host {
|
|
66
|
-
display: grid;
|
|
67
|
-
align-content: flex-start;
|
|
68
|
-
gap: 16px;
|
|
69
|
-
grid-auto-flow: row;
|
|
70
|
-
grid-template-columns: repeat(4, 1fr);
|
|
71
|
-
|
|
72
|
-
max-inline-size: 600px;
|
|
73
|
-
|
|
74
|
-
flex: 1;
|
|
75
|
-
|
|
76
|
-
transition-duration: 200ms;
|
|
77
|
-
/* stylelint-disable-next-line liberty/use-logical-spec */
|
|
78
|
-
transition-property: visibility, width, max-inline-size;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/* Will set 8col when window is 600px + padding (2x16) */
|
|
82
|
-
/* Will set 12col when window is 840px + padding (2x24) */
|
|
83
|
-
@media screen and (min-width: 632px) { :host { grid-template-columns: repeat(8, 1fr); } }
|
|
84
|
-
@media screen and (min-width: 888px) { :host { grid-template-columns: repeat(12, 1fr); } }
|
|
85
|
-
|
|
86
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) */
|
|
87
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) */
|
|
88
|
-
@media screen and (min-width: 648px) { :host { max-inline-size: 840px } }
|
|
89
|
-
@media screen and (min-width: 1240px) { :host { max-inline-size: 1040px; } }
|
|
90
|
-
|
|
91
|
-
/* NAVRAIL */
|
|
92
|
-
|
|
93
|
-
:host([nav-rail]) {
|
|
94
|
-
grid-template-columns: repeat(4, 1fr);
|
|
95
|
-
|
|
96
|
-
max-inline-size: 600px;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/* Will set 8col when window is 600px + padding (2x24) + navrail (80) */
|
|
100
|
-
/* Will set 12col when window is 840px + padding (2x24) + navrail (80) */
|
|
101
|
-
@media screen and (min-width: 728px) { :host([nav-rail]) { grid-template-columns: repeat(8, 1fr); } }
|
|
102
|
-
@media screen and (min-width: 968px) { :host([nav-rail]) { grid-template-columns: repeat(12, 1fr); } }
|
|
103
|
-
|
|
104
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + navrail (80) */
|
|
105
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + navrail (80) */
|
|
106
|
-
@media screen and (min-width: 728px) { :host([nav-rail]) { max-inline-size: 840px } }
|
|
107
|
-
@media screen and (min-width: 1320px) { :host([nav-rail]) { max-inline-size: 1040px; } }
|
|
108
|
-
|
|
109
|
-
/* NAVDRAWER */
|
|
110
|
-
|
|
111
|
-
:host([nav-drawer]) {
|
|
112
|
-
grid-template-columns: repeat(4, 1fr);
|
|
113
|
-
|
|
114
|
-
max-inline-size: 600px;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/* Will set 8col when window is 600px + padding (2x24) + navdrawer (360) */
|
|
118
|
-
/* Will set 12col when window is 840px + padding (2x24) + navdrawer (360) */
|
|
119
|
-
@media screen and (min-width: 1008px) { :host([nav-rail]) { grid-template-columns: repeat(8, 1fr); } }
|
|
120
|
-
@media screen and (min-width: 1248px) { :host([nav-rail]) { grid-template-columns: repeat(12, 1fr); } }
|
|
121
|
-
|
|
122
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + navrail (360) */
|
|
123
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + navrail (360) */
|
|
124
|
-
@media screen and (min-width: 1008px) { :host([nav-rail]) { max-inline-size: 840px } }
|
|
125
|
-
@media screen and (min-width: 1600px) { :host([nav-rail]) { max-inline-size: 1040px; } }
|
|
126
|
-
|
|
127
|
-
/* FLEXIBLE */
|
|
128
|
-
|
|
129
|
-
:host([flexible]) {
|
|
130
|
-
grid-template-columns: repeat(4, 1fr);
|
|
131
|
-
|
|
132
|
-
max-inline-size: 600px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/* Will set 8col when window is 600px + padding (2x24) + spacer (24) + fixed (360) */
|
|
136
|
-
/* Will set 12col when window is 840px + padding (2x24) + spacer (24) + fixed (360) */
|
|
137
|
-
@media screen and (min-width: 1032px) { :host([flexible]) { grid-template-columns: repeat(8, 1fr); } }
|
|
138
|
-
@media screen and (min-width: 1272px) { :host([flexible]) { grid-template-columns: repeat(12, 1fr); } }
|
|
139
|
-
|
|
140
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + spacer (24) + fixed (360) */
|
|
141
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + spacer (24) + fixed (360) */
|
|
142
|
-
@media screen and (min-width: 1032px) { :host([flexible]) { max-inline-size: 840px } }
|
|
143
|
-
@media screen and (min-width: 1624px) { :host([flexible]) { max-inline-size: 1040px; } }
|
|
144
|
-
|
|
145
|
-
/* FLEXIBLE + NAV RAIL */
|
|
146
|
-
|
|
147
|
-
:host([flexible]:where([nav-rail])) {
|
|
148
|
-
grid-template-columns: repeat(4, 1fr);
|
|
149
|
-
|
|
150
|
-
max-inline-size: 600px;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/* Will set 8col when window is 600px + padding (2x24) + spacer (24) + fixed (360) + navrail (80) */
|
|
154
|
-
/* Will set 12col when window is 840px + padding (2x24) + spacer (24) + fixed (360) + navrail (80) */
|
|
155
|
-
@media screen and (min-width: 1112px) { :host([flexible]:where([nav-rail])) { grid-template-columns: repeat(8, 1fr); } }
|
|
156
|
-
@media screen and (min-width: 1352px) { :host([flexible]:where([nav-rail])) { grid-template-columns: repeat(12, 1fr); } }
|
|
157
|
-
|
|
158
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + spacer (24) + fixed (360) + navrail (80) */
|
|
159
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + spacer (24) + fixed (360) + navrail (80) */
|
|
160
|
-
@media screen and (min-width: 1112px) { :host([flexible]:where([nav-rail])) { max-inline-size: 840px } }
|
|
161
|
-
@media screen and (min-width: 1704px) { :host([flexible]:where([nav-rail])) { max-inline-size: 1040px; } }
|
|
162
|
-
|
|
163
|
-
/* FLEXIBLE + NAV DRAWER */
|
|
164
|
-
|
|
165
|
-
:host([flexible]:where([nav-drawer])) {
|
|
166
|
-
grid-template-columns: repeat(4, 1fr);
|
|
167
|
-
|
|
168
|
-
max-inline-size: 600px;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/* Will set 8col when window is 600px + padding (2x24) + spacer (24) + fixed (360) + navdrawer (360) */
|
|
172
|
-
/* Will set 12col when window is 840px + padding (2x24) + spacer (24) + fixed (360) + navdrawer (360) */
|
|
173
|
-
@media screen and (min-width: 1392px) { :host([flexible]:where([nav-drawer])) { grid-template-columns: repeat(8, 1fr); } }
|
|
174
|
-
@media screen and (min-width: 1632px) { :host([flexible]:where([nav-drawer])) { grid-template-columns: repeat(12, 1fr); } }
|
|
175
|
-
|
|
176
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + spacer (24) + fixed (360) + navdrawer (360) */
|
|
177
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + spacer (24) + fixed (360) + navdrawer (360) */
|
|
178
|
-
@media screen and (min-width: 1392px) { :host([flexible]:where([nav-drawer])) { max-inline-size: 840px } }
|
|
179
|
-
@media screen and (min-width: 1984px) { :host([flexible]:where([nav-drawer])) { max-inline-size: 1040px; } }
|
|
180
|
-
|
|
181
|
-
/* SPLIT */
|
|
182
|
-
|
|
183
|
-
:host([split]) {
|
|
184
|
-
grid-template-columns: repeat(4, 1fr);
|
|
185
|
-
|
|
186
|
-
max-inline-size: 600px;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/* Will set 8col when window is 600px + padding (2x24) + spacer (24) + split (600) */
|
|
190
|
-
/* Will set 12col when window is 840px + padding (2x24) + spacer (24) + split (840) */
|
|
191
|
-
@media screen and (min-width: 1272px) { :host([split]) { grid-template-columns: repeat(8, 1fr); } }
|
|
192
|
-
@media screen and (min-width: 1752px) { :host([split]) { grid-template-columns: repeat(12, 1fr); } }
|
|
193
|
-
|
|
194
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + spacer (24) + split (600) */
|
|
195
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + spacer (24) + split (840) */
|
|
196
|
-
@media screen and (min-width: 1272px) { :host([split]) { max-inline-size: 840px } }
|
|
197
|
-
@media screen and (min-width: 2104px) { :host([split]) { max-inline-size: 1040px; } }
|
|
198
|
-
|
|
199
|
-
/* SPLIT + NAVRAIL */
|
|
200
|
-
|
|
201
|
-
:host([split]:where([nav-rail])) {
|
|
202
|
-
grid-template-columns: repeat(4, 1fr);
|
|
203
|
-
|
|
204
|
-
max-inline-size: 600px;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/* Will set 8col when window is 600px + padding (2x24) + spacer (24) + split (600) + navrail (80) */
|
|
208
|
-
/* Will set 12col when window is 840px + padding (2x24) + spacer (24) + split (840) + navrail (80) */
|
|
209
|
-
@media screen and (min-width: 1352px) { :host([split]:where([nav-rail])) { grid-template-columns: repeat(8, 1fr); } }
|
|
210
|
-
@media screen and (min-width: 1832px) { :host([split]:where([nav-rail])) { grid-template-columns: repeat(12, 1fr); } }
|
|
211
|
-
|
|
212
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + spacer (24) + split (600) + navrail (80) */
|
|
213
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + spacer (24) + split (840) + navrail (80) */
|
|
214
|
-
@media screen and (min-width: 1352px) { :host([split]:where([nav-rail])) { max-inline-size: 840px } }
|
|
215
|
-
@media screen and (min-width: 2184px) { :host([split]:where([nav-rail])) { max-inline-size: 1040px; } }
|
|
216
|
-
|
|
217
|
-
/* SPLIT + NAVDRAWER */
|
|
218
|
-
|
|
219
|
-
:host([split]:where([nav-drawer])) {
|
|
220
|
-
grid-template-columns: repeat(4, 1fr);
|
|
221
|
-
|
|
222
|
-
max-inline-size: 600px;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/* Will set 8col when window is 600px + padding (2x24) + spacer (24) + split (600) + navdrawer (360) */
|
|
226
|
-
/* Will set 12col when window is 840px + padding (2x24) + spacer (24) + split (840) + navdrawer (360) */
|
|
227
|
-
@media screen and (min-width: 1632px) { :host([split]:where([nav-drawer])) { grid-template-columns: repeat(8, 1fr); } }
|
|
228
|
-
@media screen and (min-width: 2112px) { :host([split]:where([nav-drawer])) { grid-template-columns: repeat(12, 1fr); } }
|
|
229
|
-
|
|
230
|
-
/* Will cap to 840px when window is 600px + padding (2x24px) + spacer (24) + split (600) + navdrawer (360) */
|
|
231
|
-
/* Will cap to 1040px when window is 840px + padding (2x200px) + spacer (24) + split (840) + navdrawer (360) */
|
|
232
|
-
@media screen and (min-width: 1632px) { :host([split]:where([nav-drawer])) { max-inline-size: 840px } }
|
|
233
|
-
@media screen and (min-width: 2464px) { :host([split]:where([nav-drawer])) { max-inline-size: 1040px; } }
|
|
234
|
-
|
|
235
|
-
:host([full-width]) {
|
|
236
|
-
max-inline-size: none;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** FIXED **/
|
|
240
|
-
|
|
241
|
-
:host([fixed]) {
|
|
242
|
-
grid-template-columns: repeat(4, 1fr);
|
|
243
|
-
|
|
244
|
-
inline-size:360px;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
@media screen and (max-width: 600px) {
|
|
248
|
-
:host(:nth-of-type(2)) {
|
|
249
|
-
display: none;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/* Will cap to 360px when window is 360px + padding (2x24px) + spacer (24) + 360px */
|
|
253
|
-
@media screen and (min-width: 792px) {
|
|
254
|
-
:host([fixed]) {
|
|
255
|
-
max-inline-size: 360px
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
#scrim {
|
|
260
|
-
position: absolute;
|
|
261
|
-
inset: 0;
|
|
262
|
-
|
|
263
|
-
grid-area: auto;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
#slot::slotted(*) { grid-column: 1 / none }
|
|
267
|
-
#slot::slotted([colspan="1"]) { grid-column-end: span 1; }
|
|
268
|
-
#slot::slotted([colspan="2"]) { grid-column-end: span 2; }
|
|
269
|
-
#slot::slotted([colspan="3"]) { grid-column-end: span 3; }
|
|
270
|
-
#slot::slotted([colspan="4"]) { grid-column-end: span 4; }
|
|
271
|
-
#slot::slotted([colspan="5"]) { grid-column-end: span 5; }
|
|
272
|
-
#slot::slotted([colspan="6"]) { grid-column-end: span 6; }
|
|
273
|
-
#slot::slotted([colspan="7"]) { grid-column-end: span 7; }
|
|
274
|
-
#slot::slotted([colspan="8"]) { grid-column-end: span 8; }
|
|
275
|
-
#slot::slotted([colspan="9"]) { grid-column-end: span 9; }
|
|
276
|
-
#slot::slotted([colspan="10"]) { grid-column-end: span 10; }
|
|
277
|
-
#slot::slotted([colspan="11"]) { grid-column-end: span 11; }
|
|
278
|
-
#slot::slotted([colspan="12"]) { grid-column-end: span 12; }
|
|
279
|
-
|
|
280
|
-
`
|
|
281
|
-
.autoRegister('mdw-pane');
|