@nanoporetech-digital/components 5.6.0 → 5.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/CHANGELOG.md +27 -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 +70 -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-4f7bee74.js → nano-table-31c953f4.js} +15 -5
- package/dist/cjs/nano-table-31c953f4.js.map +1 -0
- package/dist/cjs/nano-table.cjs.entry.js +1 -1
- package/dist/cjs/{table.worker-40cb9711.js → table.worker-31839f14.js} +2 -2
- package/dist/cjs/table.worker-31839f14.js.map +1 -0
- package/dist/collection/components/details/details.css +29 -54
- package/dist/collection/components/details/details.js +95 -91
- 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 +73 -63
- 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 +71 -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-1a47793e.js → nano-table-c365bb42.js} +15 -5
- package/dist/esm/nano-table-c365bb42.js.map +1 -0
- package/dist/esm/nano-table.entry.js +1 -1
- package/dist/esm/{table.worker-b4d2b9f2.js → table.worker-66324663.js} +2 -2
- package/dist/esm/table.worker-66324663.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-2cc0faeb.js +5 -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-512194c4.entry.js +5 -0
- package/dist/nano-components/p-512194c4.entry.js.map +1 -0
- package/dist/nano-components/p-7c0c892a.js +5 -0
- package/dist/nano-components/p-7c0c892a.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-db9325e8.entry.js → p-c2ccac87.entry.js} +2 -2
- package/dist/types/components/details/details.d.ts +14 -26
- 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 +16 -10
- package/docs-json.json +44 -67
- package/docs-vscode.json +4 -33
- package/hydrate/index.js +114 -83
- package/package.json +2 -2
- package/dist/cjs/nano-table-4f7bee74.js.map +0 -1
- package/dist/cjs/table.worker-40cb9711.js.map +0 -1
- package/dist/esm/nano-table-1a47793e.js.map +0 -1
- package/dist/esm/table.worker-b4d2b9f2.js.map +0 -1
- package/dist/nano-components/p-4764da42.js +0 -5
- package/dist/nano-components/p-47e84d30.js +0 -5
- package/dist/nano-components/p-47e84d30.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-4764da42.js.map → p-2cc0faeb.js.map} +0 -0
- /package/dist/nano-components/{p-db9325e8.entry.js.map → p-c2ccac87.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,48 @@ 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.color = undefined;
|
45
57
|
}
|
46
58
|
toggleClick() {
|
47
59
|
this.stateChanging = true;
|
@@ -51,76 +63,78 @@ export class Details {
|
|
51
63
|
this.hide();
|
52
64
|
}
|
53
65
|
hide() {
|
54
|
-
this.nanoClosed.emit(this.open);
|
55
|
-
|
56
|
-
|
66
|
+
const nanoClose = this.nanoClosed.emit(this.open);
|
67
|
+
if (nanoClose.defaultPrevented) {
|
68
|
+
this.open = true;
|
69
|
+
this.detailsEl.open = true;
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
this.bodyEl.style.height = this.contentEl.scrollHeight + 'px';
|
73
|
+
displayTransition(this.bodyEl, 'is-shown', false).then(() => {
|
74
|
+
this.stateChanging = false;
|
75
|
+
this.detailsEl.open = false;
|
76
|
+
});
|
77
|
+
requestAnimationFrame(() => {
|
78
|
+
this.bodyEl.style.height = '0px';
|
79
|
+
});
|
57
80
|
}
|
58
81
|
show() {
|
59
|
-
this.nanoOpened.emit();
|
60
|
-
|
82
|
+
const nanoOpen = this.nanoOpened.emit();
|
83
|
+
this.detailsEl.open = true;
|
84
|
+
if (nanoOpen.defaultPrevented) {
|
85
|
+
this.open = false;
|
86
|
+
this.detailsEl.open = false;
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
displayTransition(this.bodyEl, 'is-shown', true).then(() => {
|
61
90
|
this.stateChanging = false;
|
91
|
+
this.bodyEl.style.height = 'auto';
|
62
92
|
});
|
63
|
-
this.
|
93
|
+
this.bodyEl.style.height = this.contentEl.scrollHeight + 'px';
|
64
94
|
}
|
65
|
-
|
66
|
-
if (!this.
|
67
|
-
!this.contentArea ||
|
68
|
-
!this.contentEl ||
|
69
|
-
this.stateChanging)
|
95
|
+
attachMo() {
|
96
|
+
if (this.mo || !this.detailsEl || !Build.isBrowser)
|
70
97
|
return;
|
71
|
-
|
72
|
-
if (this.
|
73
|
-
|
74
|
-
|
75
|
-
|
98
|
+
this.mo = new MutationObserver((changes) => {
|
99
|
+
if (this.stateChanging)
|
100
|
+
return;
|
101
|
+
for (const change of changes) {
|
102
|
+
if (change.type === 'attributes' && change.attributeName === 'open') {
|
103
|
+
this.open = this.detailsEl.open;
|
104
|
+
}
|
76
105
|
}
|
77
106
|
});
|
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);
|
107
|
+
this.mo.observe(this.detailsEl, { attributes: true });
|
84
108
|
}
|
85
109
|
componentWillLoad() {
|
86
|
-
this.hasStartSlot = !!this.
|
87
|
-
this.hasEndSlot = !!this.
|
88
|
-
setTimeout(() => {
|
89
|
-
this.isLoading = false;
|
90
|
-
}, 100);
|
110
|
+
this.hasStartSlot = !!this.host.querySelector('[slot="icon-start"]');
|
111
|
+
this.hasEndSlot = !!this.host.querySelector('[slot="icon-end"]');
|
91
112
|
}
|
92
113
|
componentDidLoad() {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}, 0);
|
98
|
-
}
|
99
|
-
if (Build.isBrowser)
|
100
|
-
this.attachRO();
|
114
|
+
this.bodyEl.style.height = this.open ? 'auto' : '0';
|
115
|
+
if (this.open)
|
116
|
+
this.detailsEl.setAttribute('open', 'true');
|
117
|
+
this.attachMo();
|
101
118
|
}
|
102
119
|
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();
|
120
|
+
this.attachMo();
|
108
121
|
}
|
109
122
|
disconnectedCallback() {
|
110
|
-
if (this.mo)
|
123
|
+
if (this.mo) {
|
111
124
|
this.mo.disconnect();
|
112
|
-
|
113
|
-
|
125
|
+
this.mo = undefined;
|
126
|
+
}
|
114
127
|
}
|
115
128
|
render() {
|
116
|
-
return (h(
|
129
|
+
return (h("details", { part: "base", ref: (d) => (this.detailsEl = d), class: {
|
130
|
+
details: true,
|
117
131
|
open: this.open,
|
118
|
-
|
119
|
-
} }, h("
|
132
|
+
disabled: this.disabled,
|
133
|
+
} }, 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
134
|
transform: this.open ? `rotate(${this.iconRotation}deg)` : '',
|
121
|
-
} }, h("slot", { name: "icon-start" }))) : (''), h("div", {
|
135
|
+
} }, 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
136
|
transform: this.open ? `rotate(${this.iconRotation}deg)` : '',
|
123
|
-
} }, h("slot", { name: "icon-end" }))) : ('')), h("div", { class: "
|
137
|
+
} }, 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
138
|
}
|
125
139
|
static get is() { return "nano-details"; }
|
126
140
|
static get encapsulation() { return "shadow"; }
|
@@ -148,7 +162,7 @@ export class Details {
|
|
148
162
|
"optional": false,
|
149
163
|
"docs": {
|
150
164
|
"tags": [],
|
151
|
-
"text": "
|
165
|
+
"text": "Summary / handle text. Use the `label` slot for HTML markup"
|
152
166
|
},
|
153
167
|
"getter": false,
|
154
168
|
"setter": false,
|
@@ -176,6 +190,26 @@ export class Details {
|
|
176
190
|
"reflect": true,
|
177
191
|
"defaultValue": "false"
|
178
192
|
},
|
193
|
+
"disabled": {
|
194
|
+
"type": "boolean",
|
195
|
+
"mutable": true,
|
196
|
+
"complexType": {
|
197
|
+
"original": "boolean",
|
198
|
+
"resolved": "boolean",
|
199
|
+
"references": {}
|
200
|
+
},
|
201
|
+
"required": false,
|
202
|
+
"optional": false,
|
203
|
+
"docs": {
|
204
|
+
"tags": [],
|
205
|
+
"text": "Disables the details so it can't be toggled."
|
206
|
+
},
|
207
|
+
"getter": false,
|
208
|
+
"setter": false,
|
209
|
+
"attribute": "disabled",
|
210
|
+
"reflect": true,
|
211
|
+
"defaultValue": "false"
|
212
|
+
},
|
179
213
|
"noHandle": {
|
180
214
|
"type": "boolean",
|
181
215
|
"mutable": false,
|
@@ -188,7 +222,7 @@ export class Details {
|
|
188
222
|
"optional": false,
|
189
223
|
"docs": {
|
190
224
|
"tags": [],
|
191
|
-
"text": "
|
225
|
+
"text": "Hide the handle. (You will need to control the hiding / showing of content with script)"
|
192
226
|
},
|
193
227
|
"getter": false,
|
194
228
|
"setter": false,
|
@@ -215,38 +249,9 @@ export class Details {
|
|
215
249
|
"attribute": "icon-rotation",
|
216
250
|
"reflect": false,
|
217
251
|
"defaultValue": "90"
|
218
|
-
},
|
219
|
-
"color": {
|
220
|
-
"type": "string",
|
221
|
-
"mutable": false,
|
222
|
-
"complexType": {
|
223
|
-
"original": "Color",
|
224
|
-
"resolved": "\"danger\" | \"dark\" | \"light\" | \"medium\" | \"primary\" | \"secondary\" | \"success\" | \"tertiary\" | \"warning\"",
|
225
|
-
"references": {
|
226
|
-
"Color": {
|
227
|
-
"location": "import",
|
228
|
-
"path": "../../interface"
|
229
|
-
}
|
230
|
-
}
|
231
|
-
},
|
232
|
-
"required": false,
|
233
|
-
"optional": true,
|
234
|
-
"docs": {
|
235
|
-
"tags": [],
|
236
|
-
"text": "Color to use from your application's color palette."
|
237
|
-
},
|
238
|
-
"getter": false,
|
239
|
-
"setter": false,
|
240
|
-
"attribute": "color",
|
241
|
-
"reflect": false
|
242
252
|
}
|
243
253
|
};
|
244
254
|
}
|
245
|
-
static get states() {
|
246
|
-
return {
|
247
|
-
"isLoading": {}
|
248
|
-
};
|
249
|
-
}
|
250
255
|
static get events() {
|
251
256
|
return [{
|
252
257
|
"method": "nanoOpened",
|
@@ -280,7 +285,7 @@ export class Details {
|
|
280
285
|
}
|
281
286
|
}];
|
282
287
|
}
|
283
|
-
static get elementRef() { return "
|
288
|
+
static get elementRef() { return "host"; }
|
284
289
|
static get watchers() {
|
285
290
|
return [{
|
286
291
|
"propName": "open",
|
@@ -288,5 +293,4 @@ export class Details {
|
|
288
293
|
}];
|
289
294
|
}
|
290
295
|
}
|
291
|
-
let slideIds = 0;
|
292
296
|
//# 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,CAAC,EACD,OAAO,EACP,KAAK,EACL,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D;;GAEG;AACH;;;;;;;;;;;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Q,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,"file":"details.js","sourceRoot":"","sources":["../../../src/components/details/details.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EAEL,IAAI,EACJ,CAAC,EACD,OAAO,EACP,KAAK,EACL,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;GAEG;AACH;;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AG,CACrB,CACR,CAAC,CAAC,CAAC,CACF,EAAE,CACH;QACD,WAAK,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,OAAO,IAC5B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAM,IAAI,EAAC,OAAO,GAAG,CAC5C;QACL,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CACjB,YACE,IAAI,EAAC,WAAW,EAChB,KAAK,EAAC,gBAAgB,EACtB,KAAK,EAAE;YACL,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,EAAE;WAC9D;UAED,YAAM,IAAI,EAAC,UAAU,GAAG,CACnB,CACR,CAAC,CAAC,CAAC,CACF,EAAE,CACH,CACO;MACV,WACE,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,MAAM,EACZ,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,EACjC,QAAQ,EAAC,IAAI,EACb,IAAI,EAAC,QAAQ,qBACG,QAAQ;QAExB,WACE,IAAI,EAAC,SAAS,EACd,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,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\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 * 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.bodyEl.style.height = this.contentEl.scrollHeight + '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 this.bodyEl.style.height = this.contentEl.scrollHeight + '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,CAAC,UAAU,GAAG,CAAC,GAAG,IAAI;QAC1B,CAAC,CAAC,EAAE,CAAC,UACT;;iDAEuC,EAAE,CAAC,IAAI;gBAExC,EAAE,CAAC,QAAQ;QACT,CAAC,CAAC,kBAAkB,EAAE,CAAC,QAAQ,GAAG;QAClC,CAAC,CAAC,iCAAiC,EAAE,CAAC,IAAI,yBAAyB,EAAE,CAAC,IAAI,kCAC9E;;cAEA,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;SAClB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACZ,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,SAAS,CAAC;2CACU,EAAE,CAAC,IAAI,cAAc,IAAI;6CACvB,EAAE,CAAC,IAAI,cAAc,IAAI;yCAC7B,IAAI;;2CAEF,EAAE,CAAC,IAAI,aAAa,IAAI;6CACtB,EAAE,CAAC,IAAI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AC,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\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,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,IAAI,MAAM,GAAG,CAAC,CAAC;AAEf;;;;;;;;;;;;;GAaG;AAMH,MAAM,OAAO,IAAI;;IACP,UAAK,GAKP,EAAE,CAAC;IACD,WAAM,GAAG,YAAY,GAAG,MAAM,EAAE,CAAC;IAkHuB,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,CAAC,UAAU,GAAG,CAAC,GAAG,IAAI;QAC1B,CAAC,CAAC,EAAE,CAAC,UACT;eACK,IAAI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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table-interface.js","sourceRoot":"","sources":["../../../src/components/table/table-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { JSXBase } from '@stencil/core/internal';\nimport type { VNode, FunctionalComponent } from '@stencil/core';\n\nexport declare namespace TableTypes {\n /** The column property */\n type ColumnProp = string | number;\n\n /** Possible positions. Horizontally means l/r. Vertically means top/bottom */\n type Position = 'start' | 'end' | 'top' | 'bottom';\n\n /** A function to assess whether a rendered row will be pinned to the top or bottom */\n type PinFunc = (props?: RowDataSchemaModel) => Position;\n\n /** Function called, via intersection observer, when an element's pinned status changes */\n type PinnedCb = (\n positions: { [key in Position]?: boolean },\n target: Element\n ) => void;\n\n /** Potential column ordering options */\n type Order = 'asc' | 'desc' | undefined;\n\n /** Column filtering */\n interface Filter {\n prop: TableTypes.Prop;\n filter: string | boolean | string[];\n }\n\n /** Column sorting */\n interface Sort {\n prop: TableTypes.Prop;\n order: TableTypes.Order;\n }\n\n /** Potential html properties which can be passed to a cell or column */\n type CellProps = JSXBase.ThHTMLAttributes<HTMLTableCellElement>;\n\n /** Potential html properties which can be passed to a row */\n type RowProps = JSXBase.HTMLAttributes<HTMLTableRowElement>;\n\n /** data model passed to cell rendering functions */\n interface RenderModel<T = RowGeneric> {\n /** The column property being iterated over */\n prop: keyof T;\n /** The data for this cell */\n cellModel: any;\n /** The column config object */\n column: ColumnConfig<T>;\n /** The row index currently being iterated over */\n rowIndex: number;\n /** The row model currently being iterated over */\n rowModel: RowData<T>;\n }\n\n /** data model passed to row rendering functions */\n interface RowDataSchemaModel<T = RowGeneric> {\n /** the current data row model being iterated over */\n rowModel?: RowData<T>;\n /** the current data row index */\n rowIndex?: number;\n /** The row being rendered. You *must* nest this in your render function otherwise it will not be shown */\n renderedRow?: VNode;\n }\n\n /** A JSX `createElement` function passed to rendering functions.\n * You can use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n interface HFunc<T> {\n (tag: any): T;\n }\n interface HFunc<T> {\n (tag: any, data: any): T;\n }\n interface HFunc<T> {\n (tag: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: T): T;\n }\n\n /**\n * Properties that can be used with the row template `TableCell` jsx partial\n */\n type TableRowCellHelperProps = {\n header?: boolean;\n wrap?: boolean;\n cellProps?: CellProps;\n wrapperProps?: JSXBase.HTMLAttributes<HTMLDivElement>;\n };\n\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n type RowTemplateFunc<T, P> = (\n /** use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n createElement: HFunc<T>,\n /** data passed to each template */\n props: RowDataSchemaModel<P>,\n /** a helper template to minimise boilerplate.\n * A shortcut for `<td><div class=\"nano-tbl__cell-content\"></div></td>` */\n TableCell: FunctionalComponent<TableRowCellHelperProps>\n ) => T | undefined;\n\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n type CellTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n props: RenderModel<P>\n ) => TplResult;\n\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n type ColumnTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n col: ColumnConfig<P>\n ) => TplResult;\n\n /** A function used to assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n */\n type ColSortComparator = (\n prop: keyof RowData,\n order: Order\n ) => (a: RowData, b: RowData) => number;\n\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n type PropertiesFunc = (props: RenderModel) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n type ColPropertiesFunc<T> = (\n props: ColumnConfig<T>\n ) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n type RowPropertiesFunc<T> = (\n props: RowDataSchemaModel<T>\n ) => RowProps | void | undefined;\n\n type RowGeneric = { [key: string | number]: any };\n\n /** An individual table cell's data */\n type RowData<T = RowGeneric> = T & {\n __uuid?: string | number;\n __index?: number;\n };\n\n /** A data property */\n type Prop = keyof RowData;\n\n /** Valid column data types */\n type ColumnType =\n | 'text'\n | 'string'\n | 'number'\n | 'date'\n | 'boolean'\n | 'unknown';\n\n type LibJSX = { [key: string]: any };\n type JSXRender = VNode | VNode[] | LibJSX | LibJSX[];\n type TplResult = JSXRender | string | Element | undefined;\n\n /**\n * A table column's configuration\n */\n interface ColumnConfig<T = RowData> {\n /** The title of the column. Displayed in the table header `th` */\n title?: string;\n /** The row's data property to retrieve per cell render */\n prop?: keyof T;\n /** The type of data. Will affect how it is sorted and the available\n * filter operations ('text' uses browser locale to compare).\n * If none supplied, it will be derived by default using the first row of data retrieved. */\n type?: ColumnType;\n /** Whether this column is horizontally pinned to viewport */\n pinned?: Position;\n /** By default cell content too wide for the cell will not wrap,\n * but rather be trimmed with '...'.\n * *Note* 'wrap' is mutually-exclusive from `autoTooltip` */\n wrap?: boolean;\n /** Setting this to true, will automatically watch content that\n * doesn't fit and duplicate it to show in a tooltip.\n * *Note* 'autoTooltip' is mutually-exclusive from `wrap` */\n autoTooltip?: boolean;\n /** Whether this column is a row header; the cell will render a `th` not a `td` */\n rowHeader?: boolean;\n /** Whether this column can be sorted. Defaults to true */\n sortable?: boolean;\n /** Current order of this column */\n order?: Order;\n /** Whether to include this column when doing a general search. Defaults to true */\n searchable?: boolean;\n /** Current filters applied to this column */\n filter?: string | boolean | string[];\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n cellTemplate?: CellTemplateFunc<JSXRender, T>;\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n cellProperties?: PropertiesFunc;\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n columnTemplate?: ColumnTemplateFunc<JSXRender, T>;\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n columnProperties?: ColPropertiesFunc<T>;\n /** A custom sorting comparator function - assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort */\n sortCompareFn?: ColSortComparator | string;\n }\n\n /**\n * Row renderer property. Called during the rendering of any table row\n * controlling it's visual state.\n */\n interface RowRenderer<T = RowData> {\n /** Function to decide whether the row is vertically pinned. */\n pinned?: PinFunc;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: RowPropertiesFunc<T>;\n }\n\n /**\n * Row renderer property. Called during the rendering of a tables head and foot\n * controlling their visual state.\n */\n interface HeadFootRenderer<T = RowData> {\n /** Position prop. Defaults to `top` for the header and `bottom` the footer */\n pinned: Position;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row.\n * If used, and you want to see the rendered row, you *must* nest it within your\n * jsx function e.g. `(h, props) => { return [props.renderedRow, <tr><td>Custom thing</td></tr>]}`\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: () => RowProps | void | undefined;\n }\n\n type TBody = {\n rows: TableTypes.NanoTable['rows'];\n __uuid: string | number;\n };\n\n class NanoTable<T = RowGeneric> {\n rows: T[];\n columns: ColumnConfig<T>[];\n rowRender: RowRenderer<T>;\n headRender: HeadFootRenderer<T>;\n footRender: HeadFootRenderer<T>;\n }\n\n type Falsy = false | 0 | '' | null | undefined;\n}\n"]}
|
1
|
+
{"version":3,"file":"table-interface.js","sourceRoot":"","sources":["../../../src/components/table/table-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { JSXBase } from '@stencil/core/internal';\nimport type { VNode, FunctionalComponent } from '@stencil/core';\n\nexport declare namespace TableTypes {\n /** The column property */\n type ColumnProp = string | number;\n\n /** Possible positions. Horizontally means l/r. Vertically means top/bottom */\n type Position = 'start' | 'end' | 'top' | 'bottom';\n\n /** A function to assess whether a rendered row will be pinned to the top or bottom */\n type PinFunc = (props?: RowDataSchemaModel) => Position;\n\n /** Function called, via intersection observer, when an element's pinned status changes */\n type PinnedCb = (\n positions: { [key in Position]?: boolean },\n target: Element\n ) => void;\n\n /** Potential column ordering options */\n type Order = 'asc' | 'desc' | undefined;\n\n /** Column filtering */\n interface Filter {\n prop: TableTypes.Prop;\n filter: string | boolean | string[];\n }\n\n /** Column sorting */\n interface Sort {\n prop: TableTypes.Prop;\n order: TableTypes.Order;\n }\n\n /** Potential html properties which can be passed to a cell or column */\n type CellProps = JSXBase.ThHTMLAttributes<HTMLTableCellElement>;\n\n /** Potential html properties which can be passed to a row */\n type RowProps = JSXBase.HTMLAttributes<HTMLTableRowElement>;\n\n /** data model passed to cell rendering functions */\n interface RenderModel<T = RowGeneric> {\n /** The column property being iterated over */\n prop: keyof T;\n /** The data for this cell */\n cellModel: any;\n /** The column config object */\n column: ColumnConfig<T>;\n /** The row index currently being iterated over */\n rowIndex: number;\n /** The row model currently being iterated over */\n rowModel: RowData<T>;\n }\n\n /** data model passed to row rendering functions */\n interface RowDataSchemaModel<T = RowGeneric> {\n /** the current data row model being iterated over */\n rowModel?: RowData<T>;\n /** the current data row index */\n rowIndex?: number;\n /** The row being rendered. You *must* nest this in your render function otherwise it will not be shown */\n renderedRow?: VNode;\n }\n\n /** A JSX `createElement` function passed to rendering functions.\n * You can use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n interface HFunc<T> {\n (tag: any): T;\n }\n interface HFunc<T> {\n (tag: any, data: any): T;\n }\n interface HFunc<T> {\n (tag: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: T): T;\n }\n\n /**\n * Properties that can be used with the row template `TableCell` jsx partial\n */\n type TableRowCellHelperProps = {\n header?: boolean;\n wrap?: boolean;\n cellProps?: CellProps;\n wrapperProps?: JSXBase.HTMLAttributes<HTMLDivElement>;\n };\n\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n type RowTemplateFunc<T, P> = (\n /** use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n createElement: HFunc<T>,\n /** data passed to each template */\n props: RowDataSchemaModel<P>,\n /** a helper template to minimise boilerplate.\n * A shortcut for `<td><div class=\"nano-tbl__cell-content\"></div></td>` */\n TableCell: FunctionalComponent<TableRowCellHelperProps>\n ) => T | undefined;\n\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n type CellTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n props: RenderModel<P>\n ) => TplResult;\n\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n type ColumnTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n col: ColumnConfig<P>\n ) => TplResult;\n\n /** A function used to assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n */\n type ColSortComparator = (\n prop: keyof RowData,\n order: Order\n ) => (a: RowData, b: RowData) => number;\n\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n type PropertiesFunc = (props: RenderModel) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n type ColPropertiesFunc<T> = (\n props: ColumnConfig<T>\n ) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n type RowPropertiesFunc<T> = (\n props: RowDataSchemaModel<T>\n ) => RowProps | void | undefined;\n\n type RowGeneric = { [key: string | number]: any };\n\n /** An individual table cell's data */\n type RowData<T = RowGeneric> = T & {\n __uuid?: string | number;\n __index?: number;\n };\n\n /** A data property */\n type Prop = keyof RowData;\n\n /** Valid column data types */\n type ColumnType =\n | 'text'\n | 'string'\n | 'number'\n | 'date'\n | 'boolean'\n | 'unknown';\n\n type LibJSX = { [key: string]: any };\n type JSXRender = VNode | VNode[] | LibJSX | LibJSX[];\n type TplReturn = JSXRender | string | Element | undefined;\n type TplResult = TplReturn | Promise<string>;\n\n /**\n * A table column's configuration\n */\n interface ColumnConfig<T = RowData> {\n /** The title of the column. Displayed in the table header `th` */\n title?: string;\n /** The row's data property to retrieve per cell render */\n prop?: keyof T;\n /** The type of data. Will affect how it is sorted and the available\n * filter operations ('text' uses browser locale to compare).\n * If none supplied, it will be derived by default using the first row of data retrieved. */\n type?: ColumnType;\n /** Whether this column is horizontally pinned to viewport */\n pinned?: Position;\n /** By default cell content too wide for the cell will not wrap,\n * but rather be trimmed with '...'.\n * *Note* 'wrap' is mutually-exclusive from `autoTooltip` */\n wrap?: boolean;\n /** Setting this to true, will automatically watch content that\n * doesn't fit and duplicate it to show in a tooltip.\n * *Note* 'autoTooltip' is mutually-exclusive from `wrap` */\n autoTooltip?: boolean;\n /** Whether this column is a row header; the cell will render a `th` not a `td` */\n rowHeader?: boolean;\n /** Whether this column can be sorted. Defaults to true */\n sortable?: boolean;\n /** Current order of this column */\n order?: Order;\n /** Whether to include this column when doing a general search. Defaults to true */\n searchable?: boolean;\n /** Current filters applied to this column */\n filter?: string | boolean | string[];\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n cellTemplate?: CellTemplateFunc<JSXRender, T>;\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n cellProperties?: PropertiesFunc;\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n columnTemplate?: ColumnTemplateFunc<JSXRender, T>;\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n columnProperties?: ColPropertiesFunc<T>;\n /** A custom sorting comparator function - assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort */\n sortCompareFn?: ColSortComparator | string;\n }\n\n /**\n * Row renderer property. Called during the rendering of any table row\n * controlling it's visual state.\n */\n interface RowRenderer<T = RowData> {\n /** Function to decide whether the row is vertically pinned. */\n pinned?: PinFunc;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: RowPropertiesFunc<T>;\n }\n\n /**\n * Row renderer property. Called during the rendering of a tables head and foot\n * controlling their visual state.\n */\n interface HeadFootRenderer<T = RowData> {\n /** Position prop. Defaults to `top` for the header and `bottom` the footer */\n pinned: Position;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row.\n * If used, and you want to see the rendered row, you *must* nest it within your\n * jsx function e.g. `(h, props) => { return [props.renderedRow, <tr><td>Custom thing</td></tr>]}`\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: () => RowProps | void | undefined;\n }\n\n type TBody = {\n rows: TableTypes.NanoTable['rows'];\n __uuid: string | number;\n };\n\n class NanoTable<T = RowGeneric> {\n rows: T[];\n columns: ColumnConfig<T>[];\n rowRender: RowRenderer<T>;\n headRender: HeadFootRenderer<T>;\n footRender: HeadFootRenderer<T>;\n }\n\n type Falsy = false | 0 | '' | null | undefined;\n}\n"]}
|