@xplortech/apollo-core 0.0.4 → 0.0.6
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/build/style.css +88 -33
- package/dist/apollo-core/apollo-core.css +8 -3
- package/dist/apollo-core/apollo-core.esm.js +1 -1
- package/dist/apollo-core/p-3f7da885.js +1 -0
- package/dist/apollo-core/p-5d786409.entry.js +1 -0
- package/dist/apollo-core/p-b9df8412.entry.js +10 -0
- package/dist/cjs/apollo-core.cjs.js +2 -2
- package/dist/cjs/{index-5a391b2a.js → index-d0d9877d.js} +13 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/xpl-button_2.cjs.entry.js +16159 -0
- package/dist/cjs/xpl-pagination.cjs.entry.js +76 -0
- package/dist/collection/components/xpl-button/xpl-button.js +7 -4
- package/dist/collection/components/xpl-table/xpl-table.js +49 -16
- package/dist/custom-elements/index.js +14511 -923
- package/dist/esm/apollo-core.js +2 -2
- package/dist/esm/{index-6fd7b087.js → index-252a5f91.js} +13 -0
- package/dist/esm/loader.js +2 -2
- package/dist/{apollo-core/apollo-core.js → esm/polyfills/core-js.js} +1 -120
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/xpl-button_2.entry.js +16154 -0
- package/dist/esm/xpl-pagination.entry.js +72 -0
- package/dist/index.js +1 -1
- package/dist/types/.stencil/xpl-button/xpl-button.d.ts +2 -1
- package/dist/types/.stencil/xpl-table/xpl-table.d.ts +10 -1
- package/dist/types/components.d.ts +2 -2
- package/loader/index.js +1 -1
- package/package.json +4 -5
- package/dist/apollo-core/p-1c170a38.system.js +0 -1
- package/dist/apollo-core/p-50ea2036.system.js +0 -1
- package/dist/apollo-core/p-65c82873.system.entry.js +0 -5
- package/dist/apollo-core/p-88225b28.system.js +0 -1
- package/dist/apollo-core/p-9c2250b6.entry.js +0 -5
- package/dist/apollo-core/p-fc3282b6.js +0 -1
- package/dist/cjs/xpl-button_3.cjs.entry.js +0 -2641
- package/dist/esm/xpl-button_3.entry.js +0 -2635
- package/dist/esm-es5/apollo-core.js +0 -1
- package/dist/esm-es5/index-6fd7b087.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/xpl-button_3.entry.js +0 -5
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-d0d9877d.js');
|
|
6
|
+
|
|
7
|
+
const XplPagination = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
index.registerInstance(this, hostRef);
|
|
10
|
+
this.page = index.createEvent(this, "page", 7);
|
|
11
|
+
this.current = 1;
|
|
12
|
+
/**
|
|
13
|
+
* Private `_goto` method respects the `waitForCallback` prop --
|
|
14
|
+
* it will always emit the `page` event, but won't actually update
|
|
15
|
+
* the state of what the current page is, leaving that to the caller
|
|
16
|
+
* to update once (presumably) some other data has loaded.
|
|
17
|
+
*/
|
|
18
|
+
this._goto = (n) => {
|
|
19
|
+
this.page.emit(n);
|
|
20
|
+
if (!this.waitForCallback) {
|
|
21
|
+
this.current = n;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
this.goPrev = () => {
|
|
25
|
+
if (this.current > 1)
|
|
26
|
+
this._goto(this.current - 1);
|
|
27
|
+
};
|
|
28
|
+
this.goNext = () => {
|
|
29
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
30
|
+
if (this.current < numPages)
|
|
31
|
+
this._goto(this.current + 1);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calling `goto` with a page number (which should probably be
|
|
36
|
+
* taken from the `page` event) updates the pagination's state
|
|
37
|
+
* and re-renders it, showing the appropriate buttons given the current page.
|
|
38
|
+
* @param n
|
|
39
|
+
*/
|
|
40
|
+
async goto(n) {
|
|
41
|
+
this.current = n;
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
45
|
+
let showing = [1];
|
|
46
|
+
if (numPages < 7)
|
|
47
|
+
showing = [1, 2, 3, 4, 5, 6];
|
|
48
|
+
if (this.current <= 3 || this.current >= numPages - 2) {
|
|
49
|
+
showing = [1, 2, 3, "...", numPages - 2, numPages - 1, numPages];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
showing = [
|
|
53
|
+
1,
|
|
54
|
+
"...",
|
|
55
|
+
this.current - 1,
|
|
56
|
+
this.current,
|
|
57
|
+
this.current + 1,
|
|
58
|
+
"...",
|
|
59
|
+
numPages,
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
const showingFirst = (this.current - 1) * this.perPage + 1;
|
|
63
|
+
const showingLast = Math.min(showingFirst + this.perPage - 1, this.total);
|
|
64
|
+
return (index.h(index.Host, null, index.h("div", { class: "xpl-pagination" }, index.h("div", null, index.h("p", null, "Showing ", index.h("span", null, showingFirst), " to ", index.h("span", null, showingLast), " ", "of ", index.h("span", null, this.total), " results")), index.h("div", null, index.h("nav", { "aria-label": "Pagination" }, index.h("button", { onClick: this.goPrev, class: "xpl-pagination-prev" }, index.h("span", null, "Previous"), index.h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" }, index.h("path", { "fill-rule": "evenodd", d: "M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z", "clip-rule": "evenodd" }))), showing.map((n) => {
|
|
65
|
+
if (n === "...") {
|
|
66
|
+
return index.h("span", { class: "xpl-pagination-ellipsis" }, "...");
|
|
67
|
+
}
|
|
68
|
+
if (n === this.current) {
|
|
69
|
+
return (index.h("button", { "aria-current": "page", class: "xpl-pagination-current" }, n));
|
|
70
|
+
}
|
|
71
|
+
return index.h("button", { onClick: () => this._goto(n) }, n);
|
|
72
|
+
}), index.h("button", { onClick: this.goNext, class: "xpl-pagination-next" }, index.h("span", null, "Next"), index.h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" }, index.h("path", { "fill-rule": "evenodd", d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", "clip-rule": "evenodd" }))))))));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.xpl_pagination = XplPagination;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component, Host, h, Prop } from "@stencil/core";
|
|
2
|
-
import "
|
|
2
|
+
import "../../../font-awesome/fontawesome";
|
|
3
|
+
import "../../../font-awesome/regular";
|
|
3
4
|
export class XplButton {
|
|
4
5
|
constructor() {
|
|
5
6
|
this.disabled = undefined;
|
|
@@ -20,7 +21,7 @@ export class XplButton {
|
|
|
20
21
|
className += " xpl-button--xs";
|
|
21
22
|
if (this.iconOnly)
|
|
22
23
|
className += " xpl-button--icon-only";
|
|
23
|
-
const icon = this.icon ? (h("i", { class: `
|
|
24
|
+
const icon = this.icon ? (h("i", { class: `far fa-${this.icon} ${this.iconTrailing ? "trailing" : this.iconOnly ? "" : "leading"}` })) : null;
|
|
24
25
|
return (h(Host, null,
|
|
25
26
|
/**
|
|
26
27
|
* Conditionally render either an <a> or <button> element
|
|
@@ -28,10 +29,12 @@ export class XplButton {
|
|
|
28
29
|
*/
|
|
29
30
|
this.href ? (h("a", { class: className, href: this.href, role: "button" },
|
|
30
31
|
!this.iconTrailing && icon,
|
|
31
|
-
h("
|
|
32
|
+
this.iconOnly ? h("span", { class: "sr-only" },
|
|
33
|
+
h("slot", null)) : h("slot", null),
|
|
32
34
|
this.iconTrailing && icon)) : (h("button", { class: className, disabled: this.disabled, type: this.type },
|
|
33
35
|
!this.iconTrailing && icon,
|
|
34
|
-
h("
|
|
36
|
+
this.iconOnly ? h("span", { class: "sr-only" },
|
|
37
|
+
h("slot", null)) : h("slot", null),
|
|
35
38
|
this.iconTrailing && icon))));
|
|
36
39
|
}
|
|
37
40
|
static get is() { return "xpl-button"; }
|
|
@@ -2,6 +2,7 @@ import { Component, Host, Prop, State, Event, h, } from "@stencil/core";
|
|
|
2
2
|
export class XplTable {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.areAllSelected = false;
|
|
5
|
+
this.hasScrolled = false;
|
|
5
6
|
this.selectAll = (e) => {
|
|
6
7
|
const { target } = e;
|
|
7
8
|
if (!(target instanceof HTMLInputElement))
|
|
@@ -17,7 +18,7 @@ export class XplTable {
|
|
|
17
18
|
return;
|
|
18
19
|
const { checked } = target;
|
|
19
20
|
this.areAllSelected = false;
|
|
20
|
-
this.selected
|
|
21
|
+
this.selected = this.selected.map((v, _i) => (_i === i ? checked : v));
|
|
21
22
|
this.onChange();
|
|
22
23
|
};
|
|
23
24
|
this.onChange = () => {
|
|
@@ -26,29 +27,59 @@ export class XplTable {
|
|
|
26
27
|
areAllSelected: this.areAllSelected,
|
|
27
28
|
});
|
|
28
29
|
};
|
|
30
|
+
this.onScroll = () => {
|
|
31
|
+
this.hasScrolled = this.container.scrollLeft > 0;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* TODO: Need to figure out how this interplays with data
|
|
35
|
+
* received from an API/server
|
|
36
|
+
*/
|
|
37
|
+
this.sortBy = (col, ascending = true) => {
|
|
38
|
+
this.rowData.sort((a, b) => {
|
|
39
|
+
const A = a[col];
|
|
40
|
+
const B = b[col];
|
|
41
|
+
if (typeof A === "number" && typeof B === "number") {
|
|
42
|
+
const f = ascending ? 1 : -1;
|
|
43
|
+
return A > B ? f : -f;
|
|
44
|
+
}
|
|
45
|
+
return -1;
|
|
46
|
+
});
|
|
47
|
+
this.rowData = Array.from(this.rowData);
|
|
48
|
+
this.render();
|
|
49
|
+
};
|
|
29
50
|
}
|
|
30
51
|
componentWillLoad() {
|
|
31
52
|
this.areAllSelected = false;
|
|
32
|
-
this.
|
|
53
|
+
this.rowData = this.data ? Array.from(this.data) : [];
|
|
54
|
+
this.selected = new Array(this.rowData.length).fill(false);
|
|
33
55
|
}
|
|
34
56
|
render() {
|
|
57
|
+
let className = "xpl-table";
|
|
58
|
+
if (this.striped)
|
|
59
|
+
className += " xpl-table--striped";
|
|
60
|
+
if (this.freeze)
|
|
61
|
+
className += " xpl-table--freeze";
|
|
62
|
+
if (this.hasScrolled)
|
|
63
|
+
className += " xpl-table--has-scrolled";
|
|
35
64
|
return (h(Host, null,
|
|
36
|
-
h("div", { class: "xpl-table-container" },
|
|
37
|
-
h("table", { class:
|
|
65
|
+
h("div", { class: "xpl-table-container", onScroll: this.onScroll, ref: (el) => (this.container = el) },
|
|
66
|
+
h("table", { class: className },
|
|
38
67
|
this.columns && (h("thead", null, this.columns.map((column, i) => {
|
|
39
|
-
return (h("th", null,
|
|
40
|
-
|
|
68
|
+
return (h("th", null, this.multiselect && i === 0 ? (h("label", { htmlFor: "__xpl-table-th" },
|
|
69
|
+
h("input", { id: "__xpl-table-th", type: "checkbox", onChange: (e) => {
|
|
41
70
|
this.selectAll(e);
|
|
42
|
-
}, checked: this.areAllSelected })
|
|
43
|
-
column));
|
|
71
|
+
}, checked: this.areAllSelected }),
|
|
72
|
+
column)) : (column)));
|
|
44
73
|
}))),
|
|
45
|
-
|
|
46
|
-
return (h("tr",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
74
|
+
h("tbody", null, this.rowData.map((row, rowNum) => {
|
|
75
|
+
return (h("tr", { class: this.selected && this.selected[rowNum]
|
|
76
|
+
? "xpl-table-row-selected"
|
|
77
|
+
: "" }, row.map((cell, i) => {
|
|
78
|
+
return (h("td", null, this.multiselect && i === 0 ? (h("label", { htmlFor: "__xpl-table-row-" + rowNum },
|
|
79
|
+
h("input", { id: "__xpl-table-row-" + rowNum, checked: this.selected[rowNum], type: "checkbox", onChange: (e) => this.selectOne(e, rowNum) }),
|
|
80
|
+
cell)) : (cell)));
|
|
50
81
|
})));
|
|
51
|
-
}))))))
|
|
82
|
+
}))))));
|
|
52
83
|
}
|
|
53
84
|
static get is() { return "xpl-table"; }
|
|
54
85
|
static get properties() { return {
|
|
@@ -82,7 +113,7 @@ export class XplTable {
|
|
|
82
113
|
"text": ""
|
|
83
114
|
}
|
|
84
115
|
},
|
|
85
|
-
"
|
|
116
|
+
"freeze": {
|
|
86
117
|
"type": "boolean",
|
|
87
118
|
"mutable": false,
|
|
88
119
|
"complexType": {
|
|
@@ -96,7 +127,7 @@ export class XplTable {
|
|
|
96
127
|
"tags": [],
|
|
97
128
|
"text": ""
|
|
98
129
|
},
|
|
99
|
-
"attribute": "
|
|
130
|
+
"attribute": "freeze",
|
|
100
131
|
"reflect": false
|
|
101
132
|
},
|
|
102
133
|
"multiselect": {
|
|
@@ -136,6 +167,8 @@ export class XplTable {
|
|
|
136
167
|
}; }
|
|
137
168
|
static get states() { return {
|
|
138
169
|
"areAllSelected": {},
|
|
170
|
+
"rowData": {},
|
|
171
|
+
"hasScrolled": {},
|
|
139
172
|
"selected": {}
|
|
140
173
|
}; }
|
|
141
174
|
static get events() { return [{
|