@nanoporetech-digital/components 5.7.0 → 5.8.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/CHANGELOG.md +30 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nano-components.cjs.js +1 -1
- package/dist/cjs/nano-details.cjs.entry.js +74 -56
- package/dist/cjs/nano-details.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-grid_2.cjs.entry.js +10 -8
- package/dist/cjs/nano-grid_2.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-slide.cjs.entry.js +1 -1
- package/dist/cjs/nano-slide.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-slides.cjs.entry.js +1 -1
- package/dist/cjs/nano-slides.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-tab-group.cjs.entry.js +1 -1
- package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-tab.cjs.entry.js +2 -2
- package/dist/cjs/nano-tab.cjs.entry.js.map +1 -1
- package/dist/cjs/{nano-table-e0a0c40f.js → nano-table-0f4ea38f.js} +15 -5
- package/dist/cjs/nano-table-0f4ea38f.js.map +1 -0
- package/dist/cjs/nano-table.cjs.entry.js +1 -1
- package/dist/cjs/{table.worker-249333f1.js → table.worker-ba6685a0.js} +2 -2
- package/dist/cjs/table.worker-ba6685a0.js.map +1 -0
- package/dist/collection/components/details/details.css +29 -54
- package/dist/collection/components/details/details.js +109 -81
- package/dist/collection/components/details/details.js.map +1 -1
- package/dist/collection/components/grid/grid.js +19 -17
- package/dist/collection/components/grid/grid.js.map +1 -1
- package/dist/collection/components/slides/slide.css +4 -0
- package/dist/collection/components/slides/slides.css +2 -1
- package/dist/collection/components/table/table-interface.js.map +1 -1
- package/dist/collection/components/table/table.cell.js +13 -3
- package/dist/collection/components/table/table.cell.js.map +1 -1
- package/dist/collection/components/table/table.js +5 -2
- package/dist/collection/components/table/table.js.map +1 -1
- package/dist/collection/components/tabs/tab-group.js +1 -1
- package/dist/collection/components/tabs/tab-group.js.map +1 -1
- package/dist/collection/components/tabs/tab.js +2 -2
- package/dist/collection/components/tabs/tab.js.map +1 -1
- package/dist/components/grid.js +19 -17
- package/dist/components/grid.js.map +1 -1
- package/dist/components/nano-details.js +77 -62
- package/dist/components/nano-details.js.map +1 -1
- package/dist/components/nano-slide.js +1 -1
- package/dist/components/nano-slide.js.map +1 -1
- package/dist/components/nano-slides.js +1 -1
- package/dist/components/nano-slides.js.map +1 -1
- package/dist/components/nano-tab-group.js +1 -1
- package/dist/components/nano-tab-group.js.map +1 -1
- package/dist/components/nano-tab.js +2 -2
- package/dist/components/nano-tab.js.map +1 -1
- package/dist/components/table.js +13 -3
- package/dist/components/table.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nano-components.js +1 -1
- package/dist/esm/nano-details.entry.js +75 -57
- package/dist/esm/nano-details.entry.js.map +1 -1
- package/dist/esm/nano-grid_2.entry.js +10 -8
- package/dist/esm/nano-grid_2.entry.js.map +1 -1
- package/dist/esm/nano-slide.entry.js +1 -1
- package/dist/esm/nano-slide.entry.js.map +1 -1
- package/dist/esm/nano-slides.entry.js +1 -1
- package/dist/esm/nano-slides.entry.js.map +1 -1
- package/dist/esm/nano-tab-group.entry.js +1 -1
- package/dist/esm/nano-tab-group.entry.js.map +1 -1
- package/dist/esm/nano-tab.entry.js +2 -2
- package/dist/esm/nano-tab.entry.js.map +1 -1
- package/dist/esm/{nano-table-d769b1dd.js → nano-table-cc0fc046.js} +15 -5
- package/dist/esm/nano-table-cc0fc046.js.map +1 -0
- package/dist/esm/nano-table.entry.js +1 -1
- package/dist/esm/{table.worker-cb6af8ab.js → table.worker-ca7b069b.js} +2 -2
- package/dist/esm/table.worker-ca7b069b.js.map +1 -0
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/nano-components.esm.js.map +1 -1
- package/dist/nano-components/p-20086faa.entry.js +5 -0
- package/dist/nano-components/p-20086faa.entry.js.map +1 -0
- package/dist/nano-components/{p-d62b48bc.entry.js → p-3cac5f6d.entry.js} +2 -2
- package/dist/nano-components/{p-d62b48bc.entry.js.map → p-3cac5f6d.entry.js.map} +1 -1
- package/dist/nano-components/p-3d8fb8a1.entry.js +5 -0
- package/dist/nano-components/p-3d8fb8a1.entry.js.map +1 -0
- package/dist/nano-components/{p-94b4479b.js → p-43573870.js} +2 -2
- package/dist/nano-components/{p-6ae6d4a6.entry.js → p-4b7e85b2.entry.js} +2 -2
- package/dist/nano-components/p-5ca9275c.entry.js +5 -0
- package/dist/nano-components/p-5ca9275c.entry.js.map +1 -0
- package/dist/nano-components/{p-bedada62.entry.js → p-92195a83.entry.js} +2 -2
- package/dist/nano-components/{p-bedada62.entry.js.map → p-92195a83.entry.js.map} +1 -1
- package/dist/nano-components/{p-6106c383.entry.js → p-935968b8.entry.js} +3 -3
- package/dist/nano-components/{p-6106c383.entry.js.map → p-935968b8.entry.js.map} +1 -1
- package/dist/nano-components/p-d2705006.js +5 -0
- package/dist/nano-components/p-d2705006.js.map +1 -0
- package/dist/types/components/details/details.d.ts +18 -25
- package/dist/types/components/grid/grid.d.ts +1 -0
- package/dist/types/components/table/table-interface.d.ts +2 -1
- package/dist/types/components/table/table.d.ts +1 -1
- package/dist/types/components.d.ts +24 -10
- package/docs-json.json +63 -67
- package/docs-vscode.json +8 -33
- package/hydrate/index.js +118 -82
- package/package.json +2 -2
- package/dist/cjs/nano-table-e0a0c40f.js.map +0 -1
- package/dist/cjs/table.worker-249333f1.js.map +0 -1
- package/dist/esm/nano-table-d769b1dd.js.map +0 -1
- package/dist/esm/table.worker-cb6af8ab.js.map +0 -1
- package/dist/nano-components/p-3018d4df.js +0 -5
- package/dist/nano-components/p-3018d4df.js.map +0 -1
- package/dist/nano-components/p-50f2fdb3.entry.js +0 -5
- package/dist/nano-components/p-50f2fdb3.entry.js.map +0 -1
- package/dist/nano-components/p-9d65f5de.entry.js +0 -5
- package/dist/nano-components/p-9d65f5de.entry.js.map +0 -1
- package/dist/nano-components/p-a03993f9.entry.js +0 -5
- package/dist/nano-components/p-a03993f9.entry.js.map +0 -1
- /package/dist/nano-components/{p-6ae6d4a6.entry.js.map → p-43573870.js.map} +0 -0
- /package/dist/nano-components/{p-94b4479b.js.map → p-4b7e85b2.entry.js.map} +0 -0
@@ -1,8 +1,7 @@
|
|
1
1
|
/*!
|
2
2
|
* Web Components for Nanopore digital Web Apps
|
3
3
|
*/
|
4
|
-
import { h,
|
5
|
-
import { createColorClasses } from '../../utils/theme';
|
4
|
+
import { h, Build, } from '@stencil/core';
|
6
5
|
import { displayTransition } from '../../utils/transitions';
|
7
6
|
/**
|
8
7
|
* A simple element used to hide or reveal more content with slide effect. Can be used independently or nested within a [accordion](story/components-accordion--accordion) element to add 'one item open at a time' support.
|
@@ -13,35 +12,49 @@ import { displayTransition } from '../../utils/transitions';
|
|
13
12
|
* @slot label - can be used when you wish to insert complex label markup
|
14
13
|
* @slot icon-end - used for icons at the end of the handle
|
15
14
|
*
|
16
|
-
* @part
|
15
|
+
* @part base - the root `details` element
|
16
|
+
* @part header - the main `summary` ui control
|
17
17
|
* @part label - the text wrapper of the ui control
|
18
18
|
* @part icon--start - the icon wrapper at the start of the ui control
|
19
19
|
* @part icon--end - the icon wrapper at the end of the ui control
|
20
|
+
* @part body - the wrapper around content
|
20
21
|
* @part content - the main content wrapper
|
21
22
|
*/
|
22
23
|
export class Details {
|
23
24
|
constructor() {
|
24
|
-
this.slideId = `nano-details-${slideIds++}`;
|
25
25
|
this.stateChanging = false;
|
26
|
-
this.onKeyDown = (
|
27
|
-
|
26
|
+
this.onKeyDown = (e) => {
|
27
|
+
if (this.stateChanging || this.disabled)
|
28
|
+
return;
|
29
|
+
switch (e.key) {
|
28
30
|
case 'Enter':
|
29
31
|
case ' ':
|
32
|
+
e.preventDefault();
|
30
33
|
this.open = !this.open;
|
31
34
|
break;
|
35
|
+
case 'ArrowUp':
|
36
|
+
e.preventDefault();
|
37
|
+
this.open = false;
|
38
|
+
break;
|
39
|
+
case 'ArrowDown':
|
40
|
+
e.preventDefault();
|
41
|
+
this.open = true;
|
42
|
+
break;
|
32
43
|
}
|
33
44
|
};
|
34
|
-
this.onMouseDown = () => {
|
35
|
-
|
45
|
+
this.onMouseDown = (e) => {
|
46
|
+
e.preventDefault();
|
47
|
+
this.headerEl.focus();
|
48
|
+
if (this.stateChanging || this.disabled)
|
36
49
|
return;
|
37
50
|
this.open = !this.open;
|
38
51
|
};
|
39
|
-
this.isLoading = true;
|
40
52
|
this.label = '';
|
41
53
|
this.open = false;
|
54
|
+
this.disabled = false;
|
42
55
|
this.noHandle = false;
|
43
56
|
this.iconRotation = 90;
|
44
|
-
this.
|
57
|
+
this.useCacheHeight = false;
|
45
58
|
}
|
46
59
|
toggleClick() {
|
47
60
|
this.stateChanging = true;
|
@@ -51,76 +64,81 @@ export class Details {
|
|
51
64
|
this.hide();
|
52
65
|
}
|
53
66
|
hide() {
|
54
|
-
this.nanoClosed.emit(this.open);
|
55
|
-
|
56
|
-
|
67
|
+
const nanoClose = this.nanoClosed.emit(this.open);
|
68
|
+
if (nanoClose.defaultPrevented) {
|
69
|
+
this.open = true;
|
70
|
+
this.detailsEl.open = true;
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
this.cacheHeight = this.contentEl.scrollHeight;
|
74
|
+
this.bodyEl.style.height = this.cacheHeight + 'px';
|
75
|
+
displayTransition(this.bodyEl, 'is-shown', false).then(() => {
|
76
|
+
this.stateChanging = false;
|
77
|
+
this.detailsEl.open = false;
|
78
|
+
});
|
79
|
+
requestAnimationFrame(() => {
|
80
|
+
this.bodyEl.style.height = '0px';
|
81
|
+
});
|
57
82
|
}
|
58
83
|
show() {
|
59
|
-
this.nanoOpened.emit();
|
60
|
-
|
84
|
+
const nanoOpen = this.nanoOpened.emit();
|
85
|
+
this.detailsEl.open = true;
|
86
|
+
if (nanoOpen.defaultPrevented) {
|
87
|
+
this.open = false;
|
88
|
+
this.detailsEl.open = false;
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
displayTransition(this.bodyEl, 'is-shown', true).then(() => {
|
61
92
|
this.stateChanging = false;
|
93
|
+
this.bodyEl.style.height = 'auto';
|
62
94
|
});
|
63
|
-
this.
|
95
|
+
this.bodyEl.style.height =
|
96
|
+
(this.useCacheHeight ? this.cacheHeight : this.contentEl.scrollHeight) +
|
97
|
+
'px';
|
64
98
|
}
|
65
|
-
|
66
|
-
if (!this.
|
67
|
-
!this.contentArea ||
|
68
|
-
!this.contentEl ||
|
69
|
-
this.stateChanging)
|
99
|
+
attachMo() {
|
100
|
+
if (this.mo || !this.detailsEl || !Build.isBrowser)
|
70
101
|
return;
|
71
|
-
|
72
|
-
if (this.
|
73
|
-
|
74
|
-
|
75
|
-
|
102
|
+
this.mo = new MutationObserver((changes) => {
|
103
|
+
if (this.stateChanging)
|
104
|
+
return;
|
105
|
+
for (const change of changes) {
|
106
|
+
if (change.type === 'attributes' && change.attributeName === 'open') {
|
107
|
+
this.open = this.detailsEl.open;
|
108
|
+
}
|
76
109
|
}
|
77
110
|
});
|
78
|
-
|
79
|
-
attachRO() {
|
80
|
-
if (this.ro || !this.contentArea)
|
81
|
-
return;
|
82
|
-
const ro = (this.ro = new ResizeObserver(() => this.resize()));
|
83
|
-
ro.observe(this.contentArea);
|
111
|
+
this.mo.observe(this.detailsEl, { attributes: true });
|
84
112
|
}
|
85
113
|
componentWillLoad() {
|
86
|
-
this.hasStartSlot = !!this.
|
87
|
-
this.hasEndSlot = !!this.
|
88
|
-
setTimeout(() => {
|
89
|
-
this.isLoading = false;
|
90
|
-
}, 100);
|
114
|
+
this.hasStartSlot = !!this.host.querySelector('[slot="icon-start"]');
|
115
|
+
this.hasEndSlot = !!this.host.querySelector('[slot="icon-end"]');
|
91
116
|
}
|
92
117
|
componentDidLoad() {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}, 0);
|
98
|
-
}
|
99
|
-
if (Build.isBrowser)
|
100
|
-
this.attachRO();
|
118
|
+
this.bodyEl.style.height = this.open ? 'auto' : '0';
|
119
|
+
if (this.open)
|
120
|
+
this.detailsEl.setAttribute('open', 'true');
|
121
|
+
this.attachMo();
|
101
122
|
}
|
102
123
|
connectedCallback() {
|
103
|
-
|
104
|
-
return;
|
105
|
-
const mo = (this.mo = new MutationObserver(() => this.resize()));
|
106
|
-
mo.observe(this.el, { childList: true, subtree: true, attributes: false });
|
107
|
-
this.attachRO();
|
124
|
+
this.attachMo();
|
108
125
|
}
|
109
126
|
disconnectedCallback() {
|
110
|
-
if (this.mo)
|
127
|
+
if (this.mo) {
|
111
128
|
this.mo.disconnect();
|
112
|
-
|
113
|
-
|
129
|
+
this.mo = undefined;
|
130
|
+
}
|
114
131
|
}
|
115
132
|
render() {
|
116
|
-
return (h(
|
133
|
+
return (h("details", { part: "base", ref: (d) => (this.detailsEl = d), class: {
|
134
|
+
details: true,
|
117
135
|
open: this.open,
|
118
|
-
|
119
|
-
} }, h("
|
136
|
+
disabled: this.disabled,
|
137
|
+
} }, h("summary", { part: "header", "aria-controls": "content", "aria-expanded": this.open ? 'true' : 'false', "aria-disabled": this.disabled ? 'true' : 'false', tabindex: this.disabled ? '-1' : '0', style: { display: this.noHandle ? 'none' : '' }, id: "header", role: "button", class: "header", ref: (s) => (this.headerEl = s), onKeyDown: this.onKeyDown, onClick: this.onMouseDown }, this.hasStartSlot ? (h("span", { part: "icon--start", class: "icon icon--start", style: {
|
120
138
|
transform: this.open ? `rotate(${this.iconRotation}deg)` : '',
|
121
|
-
} }, h("slot", { name: "icon-start" }))) : (''), h("div", {
|
139
|
+
} }, h("slot", { name: "icon-start" }))) : (''), h("div", { part: "label", class: "label" }, this.label ? this.label : h("slot", { name: "label" })), this.hasEndSlot ? (h("span", { part: "icon--end", class: "icon icon--end", style: {
|
122
140
|
transform: this.open ? `rotate(${this.iconRotation}deg)` : '',
|
123
|
-
} }, h("slot", { name: "icon-end" }))) : ('')), h("div", { class: "
|
141
|
+
} }, h("slot", { name: "icon-end" }))) : ('')), h("div", { part: "body", class: "body", ref: (div) => (this.bodyEl = div), tabindex: "-1", role: "region", "aria-labelledby": "header" }, h("div", { part: "content", ref: (div) => (this.contentEl = div), class: "content", id: "content" }, h("slot", null)))));
|
124
142
|
}
|
125
143
|
static get is() { return "nano-details"; }
|
126
144
|
static get encapsulation() { return "shadow"; }
|
@@ -148,7 +166,7 @@ export class Details {
|
|
148
166
|
"optional": false,
|
149
167
|
"docs": {
|
150
168
|
"tags": [],
|
151
|
-
"text": "
|
169
|
+
"text": "Summary / handle text. Use the `label` slot for HTML markup"
|
152
170
|
},
|
153
171
|
"getter": false,
|
154
172
|
"setter": false,
|
@@ -176,6 +194,26 @@ export class Details {
|
|
176
194
|
"reflect": true,
|
177
195
|
"defaultValue": "false"
|
178
196
|
},
|
197
|
+
"disabled": {
|
198
|
+
"type": "boolean",
|
199
|
+
"mutable": true,
|
200
|
+
"complexType": {
|
201
|
+
"original": "boolean",
|
202
|
+
"resolved": "boolean",
|
203
|
+
"references": {}
|
204
|
+
},
|
205
|
+
"required": false,
|
206
|
+
"optional": false,
|
207
|
+
"docs": {
|
208
|
+
"tags": [],
|
209
|
+
"text": "Disables the details so it can't be toggled."
|
210
|
+
},
|
211
|
+
"getter": false,
|
212
|
+
"setter": false,
|
213
|
+
"attribute": "disabled",
|
214
|
+
"reflect": true,
|
215
|
+
"defaultValue": "false"
|
216
|
+
},
|
179
217
|
"noHandle": {
|
180
218
|
"type": "boolean",
|
181
219
|
"mutable": false,
|
@@ -188,7 +226,7 @@ export class Details {
|
|
188
226
|
"optional": false,
|
189
227
|
"docs": {
|
190
228
|
"tags": [],
|
191
|
-
"text": "
|
229
|
+
"text": "Hide the handle. (You will need to control the hiding / showing of content with script)"
|
192
230
|
},
|
193
231
|
"getter": false,
|
194
232
|
"setter": false,
|
@@ -216,37 +254,28 @@ export class Details {
|
|
216
254
|
"reflect": false,
|
217
255
|
"defaultValue": "90"
|
218
256
|
},
|
219
|
-
"
|
220
|
-
"type": "
|
257
|
+
"useCacheHeight": {
|
258
|
+
"type": "boolean",
|
221
259
|
"mutable": false,
|
222
260
|
"complexType": {
|
223
|
-
"original": "
|
224
|
-
"resolved": "
|
225
|
-
"references": {
|
226
|
-
"Color": {
|
227
|
-
"location": "import",
|
228
|
-
"path": "../../interface"
|
229
|
-
}
|
230
|
-
}
|
261
|
+
"original": "boolean",
|
262
|
+
"resolved": "boolean",
|
263
|
+
"references": {}
|
231
264
|
},
|
232
265
|
"required": false,
|
233
|
-
"optional":
|
266
|
+
"optional": false,
|
234
267
|
"docs": {
|
235
268
|
"tags": [],
|
236
|
-
"text": "
|
269
|
+
"text": "Sometimes, nested content will resize within the details component which results in choppy show/hide animations.\nSet `useCacheHeight` to `true` try to keep animations smooth."
|
237
270
|
},
|
238
271
|
"getter": false,
|
239
272
|
"setter": false,
|
240
|
-
"attribute": "
|
241
|
-
"reflect": false
|
273
|
+
"attribute": "use-cache-height",
|
274
|
+
"reflect": false,
|
275
|
+
"defaultValue": "false"
|
242
276
|
}
|
243
277
|
};
|
244
278
|
}
|
245
|
-
static get states() {
|
246
|
-
return {
|
247
|
-
"isLoading": {}
|
248
|
-
};
|
249
|
-
}
|
250
279
|
static get events() {
|
251
280
|
return [{
|
252
281
|
"method": "nanoOpened",
|
@@ -280,7 +309,7 @@ export class Details {
|
|
280
309
|
}
|
281
310
|
}];
|
282
311
|
}
|
283
|
-
static get elementRef() { return "
|
312
|
+
static get elementRef() { return "host"; }
|
284
313
|
static get watchers() {
|
285
314
|
return [{
|
286
315
|
"propName": "open",
|
@@ -288,5 +317,4 @@ export class Details {
|
|
288
317
|
}];
|
289
318
|
}
|
290
319
|
}
|
291
|
-
let slideIds = 0;
|
292
320
|
//# sourceMappingURL=details.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"details.js","sourceRoot":"","sources":["../../../src/components/details/details.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EAEL,IAAI,EACJ,C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AAC,SAAS,GAAG,GAAG,CAAC,EACpC,QAAQ,EAAC,IAAI,EACb,EAAE,EAAE,IAAI,CAAC,OAAO,EAChB,IAAI,EAAC,SAAS;UAEd,WAAK,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,EAAE,KAAK,EAAC,eAAe;YAChE,eAAQ,CACJ,CACF,CACF,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,QAAQ,GAAG,CAAC,CAAC","sourcesContent":["import {\n Component,\n Event,\n EventEmitter,\n Prop,\n h,\n Element,\n Watch,\n Host,\n State,\n writeTask,\n readTask,\n Build,\n} from '@stencil/core';\nimport { createColorClasses } from '../../utils/theme';\nimport { displayTransition } from '../../utils/transitions';\nimport type { Color } from '../../interface';\n\n/**\n * A simple element used to hide or reveal more content with slide effect. Can be used independently or nested within a [accordion](story/components-accordion--accordion) element to add 'one item open at a time' support.\n */\n/**\n * @slot - content that will be hidden / revealed\n * @slot icon-start - used for icons at the start of the handle\n * @slot label - can be used when you wish to insert complex label markup\n * @slot icon-end - used for icons at the end of the handle\n *\n * @part button - the main details ui control\n * @part label - the text wrapper of the ui control\n * @part icon--start - the icon wrapper at the start of the ui control\n * @part icon--end - the icon wrapper at the end of the ui control\n * @part content - the main content wrapper\n */\n@Component({\n tag: 'nano-details',\n styleUrl: 'details.scss',\n shadow: true,\n})\nexport class Details {\n private hasStartSlot: boolean;\n private hasEndSlot: boolean;\n private slideId = `nano-details-${slideIds++}`;\n private mo?: MutationObserver;\n private ro?: ResizeObserver;\n private contentArea: HTMLDivElement;\n private stateChanging: boolean = false;\n\n @State() isLoading = true;\n\n @Element() private el: HTMLNanoDetailsElement;\n\n private contentEl: HTMLElement;\n\n /**\n * Button / handle text to be used if no complex markup required.\n * Otherwise use label slot.\n */\n @Prop() label: string = '';\n\n /**\n * Should item be open on load\n */\n @Prop({ mutable: true, reflect: true }) open: boolean = false;\n\n /**\n * Have no handle - you will need to control the hiding / showing of content with script\n */\n @Prop() noHandle: boolean = false;\n\n /**\n * Icon slot rotation amount (degrees) on open\n */\n @Prop() iconRotation: number = 90;\n\n /**\n * Color to use from your application's color palette.\n */\n @Prop() color?: Color;\n\n /**\n * Emitted when the component opens.\n * Note: when wrapped in an accordion this event will not propogate. Use nanoToggle events instead.\n */\n @Event() nanoOpened: EventEmitter;\n\n /**\n * Emitted when the component closes.\n * Note: when wrapped in an accordion this event will not propogate. Use nanoToggle events instead.\n */\n @Event() nanoClosed: EventEmitter;\n\n @Watch('open')\n toggleClick() {\n this.stateChanging = true;\n if (this.open) this.show();\n else this.hide();\n }\n\n private onKeyDown = (ev: KeyboardEvent) => {\n switch (ev.key) {\n case 'Enter':\n case ' ':\n this.open = !this.open;\n break;\n }\n };\n\n private onMouseDown = () => {\n if (this.stateChanging) return;\n this.open = !this.open;\n };\n\n private hide() {\n this.nanoClosed.emit(this.open);\n displayTransition(this.contentEl, 'is-shown', false).then(\n () => (this.stateChanging = false)\n );\n this.contentEl.style.height = '0px';\n }\n\n private show() {\n this.nanoOpened.emit();\n displayTransition(this.contentEl, 'is-shown', true).then(() => {\n this.stateChanging = false;\n });\n this.contentEl.style.height = this.contentArea.scrollHeight + 'px';\n }\n\n private resize() {\n if (\n !this.open ||\n !this.contentArea ||\n !this.contentEl ||\n this.stateChanging\n )\n return;\n readTask(() => {\n if (this.contentArea.scrollHeight > 0) {\n writeTask(() => {\n this.contentEl.style.height = this.contentArea.scrollHeight + 'px';\n });\n }\n });\n }\n\n private attachRO() {\n if (this.ro || !this.contentArea) return;\n\n const ro = (this.ro = new ResizeObserver(() => this.resize()));\n ro.observe(this.contentArea);\n }\n\n componentWillLoad() {\n this.hasStartSlot = !!this.el.querySelector('[slot=\"icon-start\"]');\n this.hasEndSlot = !!this.el.querySelector('[slot=\"icon-end\"]');\n setTimeout(() => {\n this.isLoading = false;\n }, 100);\n }\n\n componentDidLoad() {\n if (this.open) {\n // disable animation on start\n setTimeout(() => {\n this.show();\n }, 0);\n }\n if (Build.isBrowser) this.attachRO();\n }\n\n connectedCallback() {\n if (!Build.isBrowser) return;\n const mo = (this.mo = new MutationObserver(() => this.resize()));\n mo.observe(this.el, { childList: true, subtree: true, attributes: false });\n this.attachRO();\n }\n\n disconnectedCallback() {\n if (this.mo) this.mo.disconnect();\n if (this.ro) this.ro.disconnect();\n }\n\n render() {\n return (\n <Host class={{ ...createColorClasses(this.color) }}>\n <div\n class={{\n open: this.open,\n loaded: !this.isLoading,\n }}\n >\n <button\n onKeyDown={this.onKeyDown}\n onMouseDown={this.onMouseDown}\n onTouchEnd={this.onMouseDown}\n aria-controls={this.slideId}\n aria-expanded={this.open ? 'true' : 'false'}\n style={{ display: this.noHandle ? 'none' : '' }}\n part=\"button\"\n >\n {this.hasStartSlot ? (\n <span\n part=\"icon--start\"\n class=\"icon icon--start\"\n style={{\n transform: this.open ? `rotate(${this.iconRotation}deg)` : '',\n }}\n >\n <slot name=\"icon-start\" />\n </span>\n ) : (\n ''\n )}\n <div class=\"label\" part=\"label\">\n {this.label ? this.label : <slot name=\"label\" />}\n </div>\n {this.hasEndSlot ? (\n <span\n part=\"icon--end\"\n class=\"icon icon--end\"\n style={{\n transform: this.open ? `rotate(${this.iconRotation}deg)` : '',\n }}\n >\n <slot name=\"icon-end\" />\n </span>\n ) : (\n ''\n )}\n </button>\n <div\n class=\"content\"\n ref={(div) => (this.contentEl = div)}\n tabindex=\"-1\"\n id={this.slideId}\n part=\"content\"\n >\n <div ref={(div) => (this.contentArea = div)} class=\"content__area\">\n <slot />\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n\nlet slideIds = 0;\n"]}
|
1
|
+
{"version":3,"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AAG,GAAG,CAAC,EACpC,KAAK,EAAC,SAAS,EACf,EAAE,EAAC,SAAS;UAEZ,eAAQ,CACJ,CACF,CACE,CACX,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Event,\n EventEmitter,\n Prop,\n h,\n Element,\n Watch,\n Build,\n} from '@stencil/core';\nimport { displayTransition } from '../../utils/transitions';\n\n/**\n * A simple element used to hide or reveal more content with slide effect. Can be used independently or nested within a [accordion](story/components-accordion--accordion) element to add 'one item open at a time' support.\n */\n/**\n * @slot - content that will be hidden / revealed\n * @slot icon-start - used for icons at the start of the handle\n * @slot label - can be used when you wish to insert complex label markup\n * @slot icon-end - used for icons at the end of the handle\n *\n * @part base - the root `details` element\n * @part header - the main `summary` ui control\n * @part label - the text wrapper of the ui control\n * @part icon--start - the icon wrapper at the start of the ui control\n * @part icon--end - the icon wrapper at the end of the ui control\n * @part body - the wrapper around content\n * @part content - the main content wrapper\n */\n@Component({\n tag: 'nano-details',\n styleUrl: 'details.scss',\n shadow: true,\n})\nexport class Details {\n private hasStartSlot: boolean;\n private hasEndSlot: boolean;\n private mo?: MutationObserver;\n private stateChanging: boolean = false;\n private bodyEl: HTMLElement;\n private detailsEl: HTMLDetailsElement;\n private headerEl: HTMLElement;\n private contentEl: HTMLDivElement;\n private cacheHeight: number;\n\n @Element() private host: HTMLNanoDetailsElement;\n\n /** Summary / handle text. Use the `label` slot for HTML markup */\n @Prop() label: string = '';\n\n /** Should item be open on load */\n @Prop({ mutable: true, reflect: true }) open: boolean = false;\n\n /** Disables the details so it can't be toggled. */\n @Prop({ mutable: true, reflect: true }) disabled: boolean = false;\n\n /** Hide the handle. (You will need to control the hiding / showing of content with script) */\n @Prop() noHandle: boolean = false;\n\n /** Icon slot rotation amount (degrees) on open */\n @Prop() iconRotation: number = 90;\n\n /**\n * Sometimes, nested content will resize within the details component which results in choppy show/hide animations.\n * Set `useCacheHeight` to `true` try to keep animations smooth. */\n @Prop() useCacheHeight = false;\n\n /**\n * Emitted when the component opens.\n * Note: when wrapped in an accordion this event will not propogate. Use nanoToggle events instead.\n */\n @Event() nanoOpened: EventEmitter;\n\n /**\n * Emitted when the component closes.\n * Note: when wrapped in an accordion this event will not propogate. Use nanoToggle events instead.\n */\n @Event() nanoClosed: EventEmitter;\n\n @Watch('open')\n toggleClick() {\n this.stateChanging = true;\n if (this.open) this.show();\n else this.hide();\n }\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (this.stateChanging || this.disabled) return;\n\n switch (e.key) {\n case 'Enter':\n case ' ':\n e.preventDefault();\n this.open = !this.open;\n break;\n case 'ArrowUp':\n e.preventDefault();\n this.open = false;\n break;\n case 'ArrowDown':\n e.preventDefault();\n this.open = true;\n break;\n }\n };\n\n private onMouseDown = (e: MouseEvent) => {\n e.preventDefault();\n this.headerEl.focus();\n\n if (this.stateChanging || this.disabled) return;\n this.open = !this.open;\n };\n\n private hide() {\n const nanoClose = this.nanoClosed.emit(this.open);\n\n if (nanoClose.defaultPrevented) {\n this.open = true;\n this.detailsEl.open = true;\n return;\n }\n\n this.cacheHeight = this.contentEl.scrollHeight;\n this.bodyEl.style.height = this.cacheHeight + 'px';\n\n displayTransition(this.bodyEl, 'is-shown', false).then(() => {\n this.stateChanging = false;\n this.detailsEl.open = false;\n });\n\n requestAnimationFrame(() => {\n this.bodyEl.style.height = '0px';\n });\n }\n\n private show() {\n const nanoOpen = this.nanoOpened.emit();\n this.detailsEl.open = true;\n\n if (nanoOpen.defaultPrevented) {\n this.open = false;\n this.detailsEl.open = false;\n return;\n }\n\n displayTransition(this.bodyEl, 'is-shown', true).then(() => {\n this.stateChanging = false;\n this.bodyEl.style.height = 'auto';\n });\n\n this.bodyEl.style.height =\n (this.useCacheHeight ? this.cacheHeight : this.contentEl.scrollHeight) +\n 'px';\n }\n\n private attachMo() {\n if (this.mo || !this.detailsEl || !Build.isBrowser) return;\n\n this.mo = new MutationObserver((changes) => {\n if (this.stateChanging) return;\n\n for (const change of changes) {\n if (change.type === 'attributes' && change.attributeName === 'open') {\n this.open = this.detailsEl.open;\n }\n }\n });\n this.mo.observe(this.detailsEl, { attributes: true });\n }\n\n componentWillLoad() {\n this.hasStartSlot = !!this.host.querySelector('[slot=\"icon-start\"]');\n this.hasEndSlot = !!this.host.querySelector('[slot=\"icon-end\"]');\n }\n\n componentDidLoad() {\n this.bodyEl.style.height = this.open ? 'auto' : '0';\n if (this.open) this.detailsEl.setAttribute('open', 'true');\n this.attachMo();\n }\n\n connectedCallback() {\n this.attachMo();\n }\n\n disconnectedCallback() {\n if (this.mo) {\n this.mo.disconnect();\n this.mo = undefined;\n }\n }\n\n render() {\n return (\n <details\n part=\"base\"\n ref={(d: HTMLDetailsElement) => (this.detailsEl = d)}\n class={{\n details: true,\n open: this.open,\n disabled: this.disabled,\n }}\n >\n <summary\n part=\"header\"\n aria-controls=\"content\"\n aria-expanded={this.open ? 'true' : 'false'}\n aria-disabled={this.disabled ? 'true' : 'false'}\n tabindex={this.disabled ? '-1' : '0'}\n style={{ display: this.noHandle ? 'none' : '' }}\n id=\"header\"\n role=\"button\"\n class=\"header\"\n ref={(s) => (this.headerEl = s)}\n onKeyDown={this.onKeyDown}\n onClick={this.onMouseDown}\n >\n {this.hasStartSlot ? (\n <span\n part=\"icon--start\"\n class=\"icon icon--start\"\n style={{\n transform: this.open ? `rotate(${this.iconRotation}deg)` : '',\n }}\n >\n <slot name=\"icon-start\" />\n </span>\n ) : (\n ''\n )}\n <div part=\"label\" class=\"label\">\n {this.label ? this.label : <slot name=\"label\" />}\n </div>\n {this.hasEndSlot ? (\n <span\n part=\"icon--end\"\n class=\"icon icon--end\"\n style={{\n transform: this.open ? `rotate(${this.iconRotation}deg)` : '',\n }}\n >\n <slot name=\"icon-end\" />\n </span>\n ) : (\n ''\n )}\n </summary>\n <div\n part=\"body\"\n class=\"body\"\n ref={(div) => (this.bodyEl = div)}\n tabindex=\"-1\"\n role=\"region\"\n aria-labelledby=\"header\"\n >\n <div\n part=\"content\"\n ref={(div) => (this.contentEl = div)}\n class=\"content\"\n id=\"content\"\n >\n <slot />\n </div>\n </div>\n </details>\n );\n }\n}\n"]}
|
@@ -17,6 +17,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
17
17
|
};
|
18
18
|
import { h, Host } from '@stencil/core';
|
19
19
|
import { ConstructibleStyle } from '../../utils/constructible-style';
|
20
|
+
let gridId = 0;
|
20
21
|
/**
|
21
22
|
* A lightweight, context-aware CSS grid implementation.
|
22
23
|
*
|
@@ -34,6 +35,7 @@ import { ConstructibleStyle } from '../../utils/constructible-style';
|
|
34
35
|
export class Grid {
|
35
36
|
constructor() {
|
36
37
|
this.grids = [];
|
38
|
+
this.gridId = 'nano-grid-' + gridId++;
|
37
39
|
this.styles = () => {
|
38
40
|
const css = /* css */ `
|
39
41
|
${this.grids
|
@@ -41,7 +43,7 @@ export class Grid {
|
|
41
43
|
@container (min-width: ${typeof bp.breakpoint === 'number'
|
42
44
|
? bp.breakpoint + 1 + 'px'
|
43
45
|
: bp.breakpoint}) {
|
44
|
-
.grid {
|
46
|
+
#${this.gridId}.grid {
|
45
47
|
--current-grid-size: "grid size: ${bp.name}";
|
46
48
|
${bp.template
|
47
49
|
? `grid-template: ${bp.template};`
|
@@ -51,11 +53,11 @@ export class Grid {
|
|
51
53
|
.map((_, i) => {
|
52
54
|
const gItm = i + 1;
|
53
55
|
return /* css */ `
|
54
|
-
.grid > [grid-states~="${bp.name}-col-start-${gItm}"],
|
56
|
+
#${this.gridId}.grid > [grid-states~="${bp.name}-col-start-${gItm}"],
|
55
57
|
::slotted([grid-states~="${bp.name}-col-start-${gItm}"]) {
|
56
58
|
grid-column-start: ${gItm} !important;
|
57
59
|
}
|
58
|
-
.grid > [grid-states~="${bp.name}-col-span-${gItm}"],
|
60
|
+
#${this.gridId}.grid > [grid-states~="${bp.name}-col-span-${gItm}"],
|
59
61
|
::slotted([grid-states~="${bp.name}-col-span-${gItm}"]) {
|
60
62
|
grid-column-end: span ${gItm} !important;
|
61
63
|
}
|
@@ -66,11 +68,11 @@ export class Grid {
|
|
66
68
|
.map((_, i) => {
|
67
69
|
const gItm = i + 1;
|
68
70
|
return /* css */ `
|
69
|
-
.grid > [grid-states~="${bp.name}-row-start-${gItm}"],
|
71
|
+
#${this.gridId}.grid > [grid-states~="${bp.name}-row-start-${gItm}"],
|
70
72
|
::slotted([grid-states~="${bp.name}-row-start-${gItm}"]) {
|
71
73
|
grid-row-start: ${gItm} !important;
|
72
74
|
}
|
73
|
-
.grid > [grid-states~="${bp.name}-row-span-${gItm}"],
|
75
|
+
#${this.gridId}.grid > [grid-states~="${bp.name}-row-span-${gItm}"],
|
74
76
|
::slotted([grid-states~="${bp.name}-row-span-${gItm}"]) {
|
75
77
|
grid-row-end: span ${gItm} !important;
|
76
78
|
}
|
@@ -79,7 +81,7 @@ export class Grid {
|
|
79
81
|
.join('')}
|
80
82
|
${this.showHelper &&
|
81
83
|
/* css */ `
|
82
|
-
.grid--helper :nth-child(-n+${bp.cols}) {
|
84
|
+
#${this.gridId} .grid--helper :nth-child(-n+${bp.cols}) {
|
83
85
|
display: block !important;
|
84
86
|
}
|
85
87
|
`}
|
@@ -122,7 +124,7 @@ export class Grid {
|
|
122
124
|
name: 'm',
|
123
125
|
template: this.mTpl,
|
124
126
|
});
|
125
|
-
if (this.
|
127
|
+
if (this.lCols)
|
126
128
|
this.grids.push({
|
127
129
|
cols: this.lCols,
|
128
130
|
breakpoint: this.mSize,
|
@@ -154,7 +156,7 @@ export class Grid {
|
|
154
156
|
this.constructSizeArray();
|
155
157
|
}
|
156
158
|
render() {
|
157
|
-
return (h(Host, null, h("div", { part: "grid", class: "grid" }, h("slot", null)), this.showHelper && (h("div", { class: "grid grid--helper", part: "helper" }, [...Array(24)].map(() => (h("div", { class: "grid__helper-item" })))))));
|
159
|
+
return (h(Host, null, h("div", { part: "grid", class: "grid", id: this.gridId }, h("slot", null)), this.showHelper && (h("div", { class: "grid grid--helper", part: "helper" }, [...Array(24)].map(() => (h("div", { class: "grid__helper-item" })))))));
|
158
160
|
}
|
159
161
|
static get is() { return "nano-grid"; }
|
160
162
|
static get encapsulation() { return "shadow"; }
|
@@ -187,7 +189,7 @@ export class Grid {
|
|
187
189
|
"getter": false,
|
188
190
|
"setter": false,
|
189
191
|
"attribute": "s-size",
|
190
|
-
"reflect":
|
192
|
+
"reflect": true,
|
191
193
|
"defaultValue": "300"
|
192
194
|
},
|
193
195
|
"mSize": {
|
@@ -207,7 +209,7 @@ export class Grid {
|
|
207
209
|
"getter": false,
|
208
210
|
"setter": false,
|
209
211
|
"attribute": "m-size",
|
210
|
-
"reflect":
|
212
|
+
"reflect": true,
|
211
213
|
"defaultValue": "550"
|
212
214
|
},
|
213
215
|
"lSize": {
|
@@ -227,7 +229,7 @@ export class Grid {
|
|
227
229
|
"getter": false,
|
228
230
|
"setter": false,
|
229
231
|
"attribute": "l-size",
|
230
|
-
"reflect":
|
232
|
+
"reflect": true,
|
231
233
|
"defaultValue": "800"
|
232
234
|
},
|
233
235
|
"xlSize": {
|
@@ -247,7 +249,7 @@ export class Grid {
|
|
247
249
|
"getter": false,
|
248
250
|
"setter": false,
|
249
251
|
"attribute": "xl-size",
|
250
|
-
"reflect":
|
252
|
+
"reflect": true,
|
251
253
|
"defaultValue": "1000"
|
252
254
|
},
|
253
255
|
"sCols": {
|
@@ -267,7 +269,7 @@ export class Grid {
|
|
267
269
|
"getter": false,
|
268
270
|
"setter": false,
|
269
271
|
"attribute": "s-cols",
|
270
|
-
"reflect":
|
272
|
+
"reflect": true
|
271
273
|
},
|
272
274
|
"mCols": {
|
273
275
|
"type": "number",
|
@@ -286,7 +288,7 @@ export class Grid {
|
|
286
288
|
"getter": false,
|
287
289
|
"setter": false,
|
288
290
|
"attribute": "m-cols",
|
289
|
-
"reflect":
|
291
|
+
"reflect": true
|
290
292
|
},
|
291
293
|
"lCols": {
|
292
294
|
"type": "number",
|
@@ -305,7 +307,7 @@ export class Grid {
|
|
305
307
|
"getter": false,
|
306
308
|
"setter": false,
|
307
309
|
"attribute": "l-cols",
|
308
|
-
"reflect":
|
310
|
+
"reflect": true
|
309
311
|
},
|
310
312
|
"xlCols": {
|
311
313
|
"type": "number",
|
@@ -324,7 +326,7 @@ export class Grid {
|
|
324
326
|
"getter": false,
|
325
327
|
"setter": false,
|
326
328
|
"attribute": "xl-cols",
|
327
|
-
"reflect":
|
329
|
+
"reflect": true
|
328
330
|
},
|
329
331
|
"xxlCols": {
|
330
332
|
"type": "number",
|
@@ -343,7 +345,7 @@ export class Grid {
|
|
343
345
|
"getter": false,
|
344
346
|
"setter": false,
|
345
347
|
"attribute": "xxl-cols",
|
346
|
-
"reflect":
|
348
|
+
"reflect": true
|
347
349
|
},
|
348
350
|
"sTpl": {
|
349
351
|
"type": "string",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/components/grid/grid.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;;;;;;;;;;;GAaG;AAMH,MAAM,OAAO,IAAI;;IACP,UAAK,GAKP,EAAE,CAAC;IAkHuD,WAAM,GACpE,GAAG,EAAE;MACH,MAAM,GAAG,GAAG,SAAS,CAAC;QACpB,IAAI,CAAC,KAAK;SACT,GAAG,CACF,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC;mCAEhB,OAAO,EAAE,CAAC,UAAU,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAE,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CA+DjD","sourcesContent":["import { Component, h, Prop, Host, State, Watch } from '@stencil/core';\nimport { ConstructibleStyle } from '../../utils/constructible-style';\n\n/**\n * A lightweight, context-aware CSS grid implementation.\n *\n * - Define multiple grids templates at different breakpoints\n * - Uses `@container` queries to select the correct grid depending on the current dimensions\n * - Use `grid-states=\"...\"` on direct descendants for `column` / `row` - `start` / `end`\n * - SSR optimised\n\n * @part grid - the main grid element.\n * Use this to set css such as `justify-items|content` / `align-items|content` / `place-content`\n * @part helper - a replica grid showed when `show-helper` is true\n *\n * @slot - default slot. Use this to place grid items. Use `grid-states=\"...\"` attribute to opt-out of auto / sequential placement.\n */\n@Component({\n tag: 'nano-grid',\n styleUrl: 'grid.scss',\n shadow: true,\n})\nexport class Grid {\n private grids: {\n cols: number;\n breakpoint: number | string;\n name: string;\n template?: string;\n }[] = [];\n @State() cacheKey: string;\n\n /** the component's small breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop() sSize: number | string = 300;\n\n /** the component's medium breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop() mSize: number | string = 550;\n\n /** the component's large breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop() lSize: number | string = 800;\n\n /** the component's xl breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop() xlSize: number | string = 1000;\n\n /** the number of columns the grid has at the small breakpoint. */\n @Prop() sCols: number;\n\n /** the number of columns the grid has at the medium breakpoint. */\n @Prop() mCols: number;\n\n /** the number of columns the grid has at the large breakpoint. */\n @Prop() lCols: number;\n\n /** the number of columns the grid has at the xl breakpoint. */\n @Prop() xlCols: number;\n\n /** the number of columns the grid has at the xxl breakpoint (anything greater than the xl breakpoint) */\n @Prop() xxlCols: number;\n\n /** Optional small `grid-template`. *Note* - you must set `sCols` for this to take affect */\n @Prop() sTpl?: string;\n\n /** Optional medium `grid-template`. *Note* - you must set `mCols` for this to take affect */\n @Prop() mTpl?: string;\n\n /** Optional large `grid-template`. *Note* - you must set `lCols` for this to take affect */\n @Prop() lTpl?: string;\n\n /** Optional xl `grid-template`. *Note* - you must set `xlCols` for this to take affect */\n @Prop() xlTpl?: string;\n\n /** Optional xxl `grid-template`. *Note* - you must set `xxlCols` for this to take affect */\n @Prop() xxlTpl?: string;\n\n /** shows a grid helper to visualise where columns are */\n @Prop({ reflect: true }) showHelper: boolean = false;\n\n @Watch('sTpl')\n @Watch('mTpl')\n @Watch('lTpl')\n @Watch('xlTpl')\n @Watch('xxlTpl')\n @Watch('sSize')\n @Watch('mSize')\n @Watch('lSize')\n @Watch('xlSize')\n @Watch('sCols')\n @Watch('mCols')\n @Watch('lCols')\n @Watch('xlCols')\n @Watch('xxlCols')\n @Watch('showHelper')\n constructSizeArray() {\n this.grids = [];\n\n if (this.sCols)\n this.grids.push({\n cols: this.sCols,\n breakpoint: 0,\n name: 's',\n template: this.sTpl,\n });\n if (this.mCols)\n this.grids.push({\n cols: this.mCols,\n breakpoint: this.sSize,\n name: 'm',\n template: this.mTpl,\n });\n if (this.lSize)\n this.grids.push({\n cols: this.lCols,\n breakpoint: this.mSize,\n name: 'l',\n template: this.lTpl,\n });\n if (this.xlCols)\n this.grids.push({\n cols: this.xlCols,\n breakpoint: this.lSize,\n name: 'xl',\n template: this.xlTpl,\n });\n if (this.xxlCols)\n this.grids.push({\n cols: this.xxlCols,\n breakpoint: this.xlSize,\n name: 'xxl',\n template: this.xxlTpl,\n });\n\n this.cacheKey =\n this.grids\n .map((bp) => `${bp.cols}-${bp.breakpoint}-${bp.template || ''}`)\n .join('') +\n '-helper-' +\n this.showHelper;\n }\n\n @ConstructibleStyle({ cacheKeyProperty: 'cacheKey' }) protected styles =\n () => {\n const css = /* css */ `\n ${this.grids\n .map(\n (bp) => /* css */ `\n @container (min-width: ${\n typeof bp.breakpoint === 'number'\n ? bp.breakpoint + 1 + 'px'\n : bp.breakpoint\n }) {\n .grid {\n --current-grid-size: \"grid size: ${bp.name}\";\n ${\n bp.template\n ? `grid-template: ${bp.template};`\n : `grid-template-columns: repeat(${bp.cols}, minmax(calc((100% / ${bp.cols}) - var(--grid-col-gap)), 1fr));`\n }\n }\n ${[...Array(bp.cols)]\n .map((_, i) => {\n const gItm = i + 1;\n return /* css */ `\n .grid > [grid-states~=\"${bp.name}-col-start-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-col-start-${gItm}\"]) {\n grid-column-start: ${gItm} !important;\n }\n .grid > [grid-states~=\"${bp.name}-col-span-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-col-span-${gItm}\"]) {\n grid-column-end: span ${gItm} !important;\n }\n `;\n })\n .join('')}\n ${[...Array(24)]\n .map((_, i) => {\n const gItm = i + 1;\n return /* css */ `\n .grid > [grid-states~=\"${bp.name}-row-start-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-row-start-${gItm}\"]) {\n grid-row-start: ${gItm} !important;\n }\n .grid > [grid-states~=\"${bp.name}-row-span-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-row-span-${gItm}\"]) {\n grid-row-end: span ${gItm} !important;\n }\n `;\n })\n .join('')}\n ${\n this.showHelper &&\n /* css */ `\n .grid--helper :nth-child(-n+${bp.cols}) {\n display: block !important;\n }\n `\n }\n }\n `\n )\n .join('')}\n `;\n return css;\n };\n\n componentWillLoad() {\n this.constructSizeArray();\n }\n\n render() {\n return (\n <Host>\n <div part=\"grid\" class=\"grid\">\n <slot />\n </div>\n {this.showHelper && (\n <div class=\"grid grid--helper\" part=\"helper\">\n {[...Array(24)].map(() => (\n <div class=\"grid__helper-item\" />\n ))}\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/components/grid/grid.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,CA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AAC,mBAAmB,EAAC,IAAI,EAAC,QAAQ,IACzC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CACxB,WAAK,KAAK,EAAC,mBAAmB,GAAG,CAClC,CAAC,CACE,CACP,CACI,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AArFC;EAAC,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC;;oCA+DjD","sourcesContent":["import { Component, h, Prop, Host, State, Watch } from '@stencil/core';\nimport { ConstructibleStyle } from '../../utils/constructible-style';\n\nlet gridId = 0;\n\n/**\n * A lightweight, context-aware CSS grid implementation.\n *\n * - Define multiple grids templates at different breakpoints\n * - Uses `@container` queries to select the correct grid depending on the current dimensions\n * - Use `grid-states=\"...\"` on direct descendants for `column` / `row` - `start` / `end`\n * - SSR optimised\n\n * @part grid - the main grid element.\n * Use this to set css such as `justify-items|content` / `align-items|content` / `place-content`\n * @part helper - a replica grid showed when `show-helper` is true\n *\n * @slot - default slot. Use this to place grid items. Use `grid-states=\"...\"` attribute to opt-out of auto / sequential placement.\n */\n@Component({\n tag: 'nano-grid',\n styleUrl: 'grid.scss',\n shadow: true,\n})\nexport class Grid {\n private grids: {\n cols: number;\n breakpoint: number | string;\n name: string;\n template?: string;\n }[] = [];\n private gridId = 'nano-grid-' + gridId++;\n @State() cacheKey: string;\n\n /** the component's small breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) sSize: number | string = 300;\n\n /** the component's medium breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) mSize: number | string = 550;\n\n /** the component's large breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) lSize: number | string = 800;\n\n /** the component's xl breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) xlSize: number | string = 1000;\n\n /** the number of columns the grid has at the small breakpoint. */\n @Prop({ reflect: true }) sCols: number;\n\n /** the number of columns the grid has at the medium breakpoint. */\n @Prop({ reflect: true }) mCols: number;\n\n /** the number of columns the grid has at the large breakpoint. */\n @Prop({ reflect: true }) lCols: number;\n\n /** the number of columns the grid has at the xl breakpoint. */\n @Prop({ reflect: true }) xlCols: number;\n\n /** the number of columns the grid has at the xxl breakpoint (anything greater than the xl breakpoint) */\n @Prop({ reflect: true }) xxlCols: number;\n\n /** Optional small `grid-template`. *Note* - you must set `sCols` for this to take affect */\n @Prop() sTpl?: string;\n\n /** Optional medium `grid-template`. *Note* - you must set `mCols` for this to take affect */\n @Prop() mTpl?: string;\n\n /** Optional large `grid-template`. *Note* - you must set `lCols` for this to take affect */\n @Prop() lTpl?: string;\n\n /** Optional xl `grid-template`. *Note* - you must set `xlCols` for this to take affect */\n @Prop() xlTpl?: string;\n\n /** Optional xxl `grid-template`. *Note* - you must set `xxlCols` for this to take affect */\n @Prop() xxlTpl?: string;\n\n /** shows a grid helper to visualise where columns are */\n @Prop({ reflect: true }) showHelper: boolean = false;\n\n @Watch('sTpl')\n @Watch('mTpl')\n @Watch('lTpl')\n @Watch('xlTpl')\n @Watch('xxlTpl')\n @Watch('sSize')\n @Watch('mSize')\n @Watch('lSize')\n @Watch('xlSize')\n @Watch('sCols')\n @Watch('mCols')\n @Watch('lCols')\n @Watch('xlCols')\n @Watch('xxlCols')\n @Watch('showHelper')\n constructSizeArray() {\n this.grids = [];\n\n if (this.sCols)\n this.grids.push({\n cols: this.sCols,\n breakpoint: 0,\n name: 's',\n template: this.sTpl,\n });\n if (this.mCols)\n this.grids.push({\n cols: this.mCols,\n breakpoint: this.sSize,\n name: 'm',\n template: this.mTpl,\n });\n if (this.lCols)\n this.grids.push({\n cols: this.lCols,\n breakpoint: this.mSize,\n name: 'l',\n template: this.lTpl,\n });\n if (this.xlCols)\n this.grids.push({\n cols: this.xlCols,\n breakpoint: this.lSize,\n name: 'xl',\n template: this.xlTpl,\n });\n if (this.xxlCols)\n this.grids.push({\n cols: this.xxlCols,\n breakpoint: this.xlSize,\n name: 'xxl',\n template: this.xxlTpl,\n });\n\n this.cacheKey =\n this.grids\n .map((bp) => `${bp.cols}-${bp.breakpoint}-${bp.template || ''}`)\n .join('') +\n '-helper-' +\n this.showHelper;\n }\n\n @ConstructibleStyle({ cacheKeyProperty: 'cacheKey' }) protected styles =\n () => {\n const css = /* css */ `\n ${this.grids\n .map(\n (bp) => /* css */ `\n @container (min-width: ${\n typeof bp.breakpoint === 'number'\n ? bp.breakpoint + 1 + 'px'\n : bp.breakpoint\n }) {\n #${this.gridId}.grid {\n --current-grid-size: \"grid size: ${bp.name}\";\n ${\n bp.template\n ? `grid-template: ${bp.template};`\n : `grid-template-columns: repeat(${bp.cols}, minmax(calc((100% / ${bp.cols}) - var(--grid-col-gap)), 1fr));`\n }\n }\n ${[...Array(bp.cols)]\n .map((_, i) => {\n const gItm = i + 1;\n return /* css */ `\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-col-start-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-col-start-${gItm}\"]) {\n grid-column-start: ${gItm} !important;\n }\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-col-span-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-col-span-${gItm}\"]) {\n grid-column-end: span ${gItm} !important;\n }\n `;\n })\n .join('')}\n ${[...Array(24)]\n .map((_, i) => {\n const gItm = i + 1;\n return /* css */ `\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-row-start-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-row-start-${gItm}\"]) {\n grid-row-start: ${gItm} !important;\n }\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-row-span-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-row-span-${gItm}\"]) {\n grid-row-end: span ${gItm} !important;\n }\n `;\n })\n .join('')}\n ${\n this.showHelper &&\n /* css */ `\n #${this.gridId} .grid--helper :nth-child(-n+${bp.cols}) {\n display: block !important;\n }\n `\n }\n }\n `\n )\n .join('')}\n `;\n return css;\n };\n\n componentWillLoad() {\n this.constructSizeArray();\n }\n\n render() {\n return (\n <Host>\n <div part=\"grid\" class=\"grid\" id={this.gridId}>\n <slot />\n </div>\n {this.showHelper && (\n <div class=\"grid grid--helper\" part=\"helper\">\n {[...Array(24)].map(() => (\n <div class=\"grid__helper-item\" />\n ))}\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
|