@xplortech/apollo-core 0.0.0 → 0.0.2
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 +151 -5
- package/dist/apollo-core/apollo-core.css +4 -0
- package/dist/apollo-core/apollo-core.esm.js +1 -1
- package/dist/apollo-core/apollo-core.js +130 -0
- package/dist/apollo-core/p-1c170a38.system.js +1 -0
- package/dist/apollo-core/p-50ea2036.system.js +1 -0
- package/dist/apollo-core/p-88225b28.system.js +1 -0
- package/dist/apollo-core/p-933b8694.entry.js +1 -0
- package/dist/apollo-core/p-c0ff6f68.system.entry.js +1 -0
- package/dist/apollo-core/p-fc3282b6.js +1 -0
- package/dist/cjs/apollo-core.cjs.js +2 -2
- package/dist/cjs/{index-3ceb30c2.js → index-5a391b2a.js} +399 -27
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/xpl-button_3.cjs.entry.js +144 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/xpl-button/xpl-button.js +73 -0
- package/dist/collection/components/xpl-pagination/xpl-pagination.js +188 -3
- package/dist/collection/components/xpl-table/xpl-table.js +1 -1
- package/dist/custom-elements/index.d.ts +6 -0
- package/dist/custom-elements/index.js +88 -7
- package/dist/esm/apollo-core.js +2 -2
- package/dist/esm/{index-52844266.js → index-6fd7b087.js} +399 -27
- package/dist/esm/loader.js +2 -2
- package/dist/esm/xpl-button_3.entry.js +138 -0
- package/dist/esm-es5/apollo-core.js +1 -0
- package/dist/esm-es5/index-6fd7b087.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/xpl-button_3.entry.js +1 -0
- package/dist/index.js +1 -1
- package/dist/loader/index.js +1 -1
- package/dist/types/.stencil/xpl-button/xpl-button.d.ts +6 -0
- package/dist/types/.stencil/xpl-pagination/xpl-pagination.d.ts +22 -0
- package/dist/types/components.d.ts +31 -0
- package/package.json +3 -5
- package/dist/apollo-core/p-1c829417.js +0 -1
- package/dist/apollo-core/p-64ea0ce6.entry.js +0 -1
- package/dist/apollo-core/p-b76559ae.entry.js +0 -1
- package/dist/cjs/xpl-pagination.cjs.entry.js +0 -16
- package/dist/cjs/xpl-table.cjs.entry.js +0 -54
- package/dist/esm/xpl-pagination.entry.js +0 -12
- package/dist/esm/xpl-table.entry.js +0 -50
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-5a391b2a.js');
|
|
6
|
+
|
|
7
|
+
const XplButton = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
index.registerInstance(this, hostRef);
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
let className = "xpl-button";
|
|
13
|
+
if (this.type === "secondary")
|
|
14
|
+
className += " xpl-button--secondary";
|
|
15
|
+
if (this.type === "subtle")
|
|
16
|
+
className += " xpl-button--subtle";
|
|
17
|
+
return (index.h(index.Host, null,
|
|
18
|
+
/**
|
|
19
|
+
* Conditionally render either an <a> or <button> element
|
|
20
|
+
* depending on if there's an `href` or not
|
|
21
|
+
*/
|
|
22
|
+
this.href ? (index.h("a", { class: className, href: this.href, role: "button" }, index.h("slot", null))) : this.disabled ? (index.h("button", { class: className, role: "button", disabled: true }, index.h("slot", null))) : (index.h("button", { class: className, role: "button" }, index.h("slot", null)))));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const XplPagination = class {
|
|
27
|
+
constructor(hostRef) {
|
|
28
|
+
index.registerInstance(this, hostRef);
|
|
29
|
+
this.page = index.createEvent(this, "page", 7);
|
|
30
|
+
this.current = 1;
|
|
31
|
+
/**
|
|
32
|
+
* Private `_goto` method respects the `waitForCallback` prop --
|
|
33
|
+
* it will always emit the `page` event, but won't actually update
|
|
34
|
+
* the state of what the current page is, leaving that to the caller
|
|
35
|
+
* to update once (presumably) some other data has loaded.
|
|
36
|
+
*/
|
|
37
|
+
this._goto = (n) => {
|
|
38
|
+
this.page.emit(n);
|
|
39
|
+
if (!this.waitForCallback) {
|
|
40
|
+
this.current = n;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
this.goPrev = () => {
|
|
44
|
+
if (this.current > 1)
|
|
45
|
+
this._goto(this.current - 1);
|
|
46
|
+
};
|
|
47
|
+
this.goNext = () => {
|
|
48
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
49
|
+
if (this.current < numPages)
|
|
50
|
+
this._goto(this.current + 1);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Calling `goto` with a page number (which should probably be
|
|
55
|
+
* taken from the `page` event) updates the pagination's state
|
|
56
|
+
* and re-renders it, showing the appropriate buttons given the current page.
|
|
57
|
+
* @param n
|
|
58
|
+
*/
|
|
59
|
+
async goto(n) {
|
|
60
|
+
this.current = n;
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
64
|
+
let showing = [1];
|
|
65
|
+
if (numPages < 7)
|
|
66
|
+
showing = [1, 2, 3, 4, 5, 6];
|
|
67
|
+
if (this.current <= 3 || this.current >= numPages - 2) {
|
|
68
|
+
showing = [1, 2, 3, "...", numPages - 2, numPages - 1, numPages];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
showing = [
|
|
72
|
+
1,
|
|
73
|
+
"...",
|
|
74
|
+
this.current - 1,
|
|
75
|
+
this.current,
|
|
76
|
+
this.current + 1,
|
|
77
|
+
"...",
|
|
78
|
+
numPages,
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
const showingFirst = (this.current - 1) * this.perPage + 1;
|
|
82
|
+
const showingLast = Math.min(showingFirst + this.perPage - 1, this.total);
|
|
83
|
+
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) => {
|
|
84
|
+
if (n === "...") {
|
|
85
|
+
return index.h("span", { class: "xpl-pagination-ellipsis" }, "...");
|
|
86
|
+
}
|
|
87
|
+
if (n === this.current) {
|
|
88
|
+
return (index.h("button", { "aria-current": "page", class: "xpl-pagination-current" }, n));
|
|
89
|
+
}
|
|
90
|
+
return index.h("button", { onClick: () => this._goto(n) }, n);
|
|
91
|
+
}), 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" }))))))));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const XplTable = class {
|
|
96
|
+
constructor(hostRef) {
|
|
97
|
+
index.registerInstance(this, hostRef);
|
|
98
|
+
this.tableSelect = index.createEvent(this, "tableSelect", 7);
|
|
99
|
+
this.areAllSelected = false;
|
|
100
|
+
this.selectAll = (e) => {
|
|
101
|
+
const { target } = e;
|
|
102
|
+
if (!(target instanceof HTMLInputElement))
|
|
103
|
+
return;
|
|
104
|
+
const { checked } = target;
|
|
105
|
+
this.areAllSelected = checked;
|
|
106
|
+
this.selected = this.selected.map(() => checked);
|
|
107
|
+
this.onChange();
|
|
108
|
+
};
|
|
109
|
+
this.selectOne = (e, i) => {
|
|
110
|
+
const { target } = e;
|
|
111
|
+
if (!(target instanceof HTMLInputElement))
|
|
112
|
+
return;
|
|
113
|
+
const { checked } = target;
|
|
114
|
+
this.areAllSelected = false;
|
|
115
|
+
this.selected[i] = checked;
|
|
116
|
+
this.onChange();
|
|
117
|
+
};
|
|
118
|
+
this.onChange = () => {
|
|
119
|
+
this.tableSelect.emit({
|
|
120
|
+
selected: this.selected,
|
|
121
|
+
areAllSelected: this.areAllSelected,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
componentWillLoad() {
|
|
126
|
+
this.areAllSelected = false;
|
|
127
|
+
this.selected = new Array(this.data.length).fill(false);
|
|
128
|
+
}
|
|
129
|
+
render() {
|
|
130
|
+
return (index.h(index.Host, null, index.h("div", { class: "xpl-table-container" }, index.h("table", { class: `xpl-table${this.striped ? " xpl-table--striped" : ""}${this.fixed ? " xpl-table--sticky" : ""}` }, this.columns && (index.h("thead", null, this.columns.map((column, i) => {
|
|
131
|
+
return (index.h("th", null, this.multiselect && i === 0 ? (index.h("input", { type: "checkbox", onChange: (e) => {
|
|
132
|
+
this.selectAll(e);
|
|
133
|
+
}, checked: this.areAllSelected })) : null, column));
|
|
134
|
+
}))), this.data && (index.h("tbody", null, this.data.map((row) => {
|
|
135
|
+
return (index.h("tr", null, row.map((cell, i) => {
|
|
136
|
+
return (index.h("td", null, this.multiselect && i === 0 ? (index.h("input", { checked: this.selected[i], type: "checkbox", onChange: (e) => this.selectOne(e, i) })) : null, cell));
|
|
137
|
+
})));
|
|
138
|
+
})))))));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
exports.xpl_button = XplButton;
|
|
143
|
+
exports.xpl_pagination = XplPagination;
|
|
144
|
+
exports.xpl_table = XplTable;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Component, Host, h, Prop } from "@stencil/core";
|
|
2
|
+
export class XplButton {
|
|
3
|
+
render() {
|
|
4
|
+
let className = "xpl-button";
|
|
5
|
+
if (this.type === "secondary")
|
|
6
|
+
className += " xpl-button--secondary";
|
|
7
|
+
if (this.type === "subtle")
|
|
8
|
+
className += " xpl-button--subtle";
|
|
9
|
+
return (h(Host, null,
|
|
10
|
+
/**
|
|
11
|
+
* Conditionally render either an <a> or <button> element
|
|
12
|
+
* depending on if there's an `href` or not
|
|
13
|
+
*/
|
|
14
|
+
this.href ? (h("a", { class: className, href: this.href, role: "button" },
|
|
15
|
+
h("slot", null))) : this.disabled ? (h("button", { class: className, role: "button", disabled: true },
|
|
16
|
+
h("slot", null))) : (h("button", { class: className, role: "button" },
|
|
17
|
+
h("slot", null)))));
|
|
18
|
+
}
|
|
19
|
+
static get is() { return "xpl-button"; }
|
|
20
|
+
static get properties() { return {
|
|
21
|
+
"disabled": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"mutable": false,
|
|
24
|
+
"complexType": {
|
|
25
|
+
"original": "boolean",
|
|
26
|
+
"resolved": "boolean",
|
|
27
|
+
"references": {}
|
|
28
|
+
},
|
|
29
|
+
"required": false,
|
|
30
|
+
"optional": true,
|
|
31
|
+
"docs": {
|
|
32
|
+
"tags": [],
|
|
33
|
+
"text": ""
|
|
34
|
+
},
|
|
35
|
+
"attribute": "disabled",
|
|
36
|
+
"reflect": false
|
|
37
|
+
},
|
|
38
|
+
"type": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"mutable": false,
|
|
41
|
+
"complexType": {
|
|
42
|
+
"original": "\"primary\" | \"secondary\" | \"subtle\"",
|
|
43
|
+
"resolved": "\"primary\" | \"secondary\" | \"subtle\"",
|
|
44
|
+
"references": {}
|
|
45
|
+
},
|
|
46
|
+
"required": false,
|
|
47
|
+
"optional": false,
|
|
48
|
+
"docs": {
|
|
49
|
+
"tags": [],
|
|
50
|
+
"text": ""
|
|
51
|
+
},
|
|
52
|
+
"attribute": "type",
|
|
53
|
+
"reflect": false
|
|
54
|
+
},
|
|
55
|
+
"href": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"mutable": false,
|
|
58
|
+
"complexType": {
|
|
59
|
+
"original": "string",
|
|
60
|
+
"resolved": "string",
|
|
61
|
+
"references": {}
|
|
62
|
+
},
|
|
63
|
+
"required": false,
|
|
64
|
+
"optional": true,
|
|
65
|
+
"docs": {
|
|
66
|
+
"tags": [],
|
|
67
|
+
"text": ""
|
|
68
|
+
},
|
|
69
|
+
"attribute": "href",
|
|
70
|
+
"reflect": false
|
|
71
|
+
}
|
|
72
|
+
}; }
|
|
73
|
+
}
|
|
@@ -1,9 +1,194 @@
|
|
|
1
|
-
import { Component, Host, h } from "@stencil/core";
|
|
1
|
+
import { Component, Host, h, Event, Prop, State, Method, } from "@stencil/core";
|
|
2
2
|
export class XplPagination {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.current = 1;
|
|
5
|
+
/**
|
|
6
|
+
* Private `_goto` method respects the `waitForCallback` prop --
|
|
7
|
+
* it will always emit the `page` event, but won't actually update
|
|
8
|
+
* the state of what the current page is, leaving that to the caller
|
|
9
|
+
* to update once (presumably) some other data has loaded.
|
|
10
|
+
*/
|
|
11
|
+
this._goto = (n) => {
|
|
12
|
+
this.page.emit(n);
|
|
13
|
+
if (!this.waitForCallback) {
|
|
14
|
+
this.current = n;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
this.goPrev = () => {
|
|
18
|
+
if (this.current > 1)
|
|
19
|
+
this._goto(this.current - 1);
|
|
20
|
+
};
|
|
21
|
+
this.goNext = () => {
|
|
22
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
23
|
+
if (this.current < numPages)
|
|
24
|
+
this._goto(this.current + 1);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Calling `goto` with a page number (which should probably be
|
|
29
|
+
* taken from the `page` event) updates the pagination's state
|
|
30
|
+
* and re-renders it, showing the appropriate buttons given the current page.
|
|
31
|
+
* @param n
|
|
32
|
+
*/
|
|
33
|
+
async goto(n) {
|
|
34
|
+
this.current = n;
|
|
35
|
+
}
|
|
3
36
|
render() {
|
|
37
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
38
|
+
let showing = [1];
|
|
39
|
+
if (numPages < 7)
|
|
40
|
+
showing = [1, 2, 3, 4, 5, 6];
|
|
41
|
+
if (this.current <= 3 || this.current >= numPages - 2) {
|
|
42
|
+
showing = [1, 2, 3, "...", numPages - 2, numPages - 1, numPages];
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
showing = [
|
|
46
|
+
1,
|
|
47
|
+
"...",
|
|
48
|
+
this.current - 1,
|
|
49
|
+
this.current,
|
|
50
|
+
this.current + 1,
|
|
51
|
+
"...",
|
|
52
|
+
numPages,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
const showingFirst = (this.current - 1) * this.perPage + 1;
|
|
56
|
+
const showingLast = Math.min(showingFirst + this.perPage - 1, this.total);
|
|
4
57
|
return (h(Host, null,
|
|
5
|
-
h("
|
|
58
|
+
h("div", { class: "xpl-pagination" },
|
|
59
|
+
h("div", null,
|
|
60
|
+
h("p", null,
|
|
61
|
+
"Showing",
|
|
62
|
+
" ",
|
|
63
|
+
h("span", null, showingFirst),
|
|
64
|
+
" ",
|
|
65
|
+
"to",
|
|
66
|
+
" ",
|
|
67
|
+
h("span", null, showingLast),
|
|
68
|
+
" ",
|
|
69
|
+
"of",
|
|
70
|
+
" ",
|
|
71
|
+
h("span", null, this.total),
|
|
72
|
+
" ",
|
|
73
|
+
"results")),
|
|
74
|
+
h("div", null,
|
|
75
|
+
h("nav", { "aria-label": "Pagination" },
|
|
76
|
+
h("button", { onClick: this.goPrev, class: "xpl-pagination-prev" },
|
|
77
|
+
h("span", null, "Previous"),
|
|
78
|
+
h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" },
|
|
79
|
+
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" }))),
|
|
80
|
+
showing.map((n) => {
|
|
81
|
+
if (n === "...") {
|
|
82
|
+
return h("span", { class: "xpl-pagination-ellipsis" }, "...");
|
|
83
|
+
}
|
|
84
|
+
if (n === this.current) {
|
|
85
|
+
return (h("button", { "aria-current": "page", class: "xpl-pagination-current" }, n));
|
|
86
|
+
}
|
|
87
|
+
return h("button", { onClick: () => this._goto(n) }, n);
|
|
88
|
+
}),
|
|
89
|
+
h("button", { onClick: this.goNext, class: "xpl-pagination-next" },
|
|
90
|
+
h("span", null, "Next"),
|
|
91
|
+
h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" },
|
|
92
|
+
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" }))))))));
|
|
6
93
|
}
|
|
7
94
|
static get is() { return "xpl-pagination"; }
|
|
8
|
-
static get
|
|
95
|
+
static get properties() { return {
|
|
96
|
+
"total": {
|
|
97
|
+
"type": "number",
|
|
98
|
+
"mutable": false,
|
|
99
|
+
"complexType": {
|
|
100
|
+
"original": "number",
|
|
101
|
+
"resolved": "number",
|
|
102
|
+
"references": {}
|
|
103
|
+
},
|
|
104
|
+
"required": false,
|
|
105
|
+
"optional": false,
|
|
106
|
+
"docs": {
|
|
107
|
+
"tags": [],
|
|
108
|
+
"text": ""
|
|
109
|
+
},
|
|
110
|
+
"attribute": "total",
|
|
111
|
+
"reflect": false
|
|
112
|
+
},
|
|
113
|
+
"perPage": {
|
|
114
|
+
"type": "number",
|
|
115
|
+
"mutable": false,
|
|
116
|
+
"complexType": {
|
|
117
|
+
"original": "number",
|
|
118
|
+
"resolved": "number",
|
|
119
|
+
"references": {}
|
|
120
|
+
},
|
|
121
|
+
"required": false,
|
|
122
|
+
"optional": false,
|
|
123
|
+
"docs": {
|
|
124
|
+
"tags": [],
|
|
125
|
+
"text": ""
|
|
126
|
+
},
|
|
127
|
+
"attribute": "per-page",
|
|
128
|
+
"reflect": false
|
|
129
|
+
},
|
|
130
|
+
"waitForCallback": {
|
|
131
|
+
"type": "boolean",
|
|
132
|
+
"mutable": false,
|
|
133
|
+
"complexType": {
|
|
134
|
+
"original": "boolean",
|
|
135
|
+
"resolved": "boolean",
|
|
136
|
+
"references": {}
|
|
137
|
+
},
|
|
138
|
+
"required": false,
|
|
139
|
+
"optional": false,
|
|
140
|
+
"docs": {
|
|
141
|
+
"tags": [],
|
|
142
|
+
"text": ""
|
|
143
|
+
},
|
|
144
|
+
"attribute": "wait-for-callback",
|
|
145
|
+
"reflect": false
|
|
146
|
+
}
|
|
147
|
+
}; }
|
|
148
|
+
static get states() { return {
|
|
149
|
+
"current": {}
|
|
150
|
+
}; }
|
|
151
|
+
static get events() { return [{
|
|
152
|
+
"method": "page",
|
|
153
|
+
"name": "page",
|
|
154
|
+
"bubbles": true,
|
|
155
|
+
"cancelable": true,
|
|
156
|
+
"composed": true,
|
|
157
|
+
"docs": {
|
|
158
|
+
"tags": [],
|
|
159
|
+
"text": ""
|
|
160
|
+
},
|
|
161
|
+
"complexType": {
|
|
162
|
+
"original": "any",
|
|
163
|
+
"resolved": "any",
|
|
164
|
+
"references": {}
|
|
165
|
+
}
|
|
166
|
+
}]; }
|
|
167
|
+
static get methods() { return {
|
|
168
|
+
"goto": {
|
|
169
|
+
"complexType": {
|
|
170
|
+
"signature": "(n: number) => Promise<void>",
|
|
171
|
+
"parameters": [{
|
|
172
|
+
"tags": [{
|
|
173
|
+
"text": "n",
|
|
174
|
+
"name": "param"
|
|
175
|
+
}],
|
|
176
|
+
"text": ""
|
|
177
|
+
}],
|
|
178
|
+
"references": {
|
|
179
|
+
"Promise": {
|
|
180
|
+
"location": "global"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"return": "Promise<void>"
|
|
184
|
+
},
|
|
185
|
+
"docs": {
|
|
186
|
+
"text": "Calling `goto` with a page number (which should probably be \ntaken from the `page` event) updates the pagination's state\nand re-renders it, showing the appropriate buttons given the current page.",
|
|
187
|
+
"tags": [{
|
|
188
|
+
"name": "param",
|
|
189
|
+
"text": "n"
|
|
190
|
+
}]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}; }
|
|
9
194
|
}
|
|
@@ -34,7 +34,7 @@ export class XplTable {
|
|
|
34
34
|
render() {
|
|
35
35
|
return (h(Host, null,
|
|
36
36
|
h("div", { class: "xpl-table-container" },
|
|
37
|
-
h("table", { class: `xpl-table${this.striped ? " xpl-table--striped" : ""} xpl-table--sticky` },
|
|
37
|
+
h("table", { class: `xpl-table${this.striped ? " xpl-table--striped" : ""}${this.fixed ? " xpl-table--sticky" : ""}` },
|
|
38
38
|
this.columns && (h("thead", null, this.columns.map((column, i) => {
|
|
39
39
|
return (h("th", null,
|
|
40
40
|
this.multiselect && i === 0 ? (h("input", { type: "checkbox", onChange: (e) => {
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import type { Components, JSX } from "../types/components";
|
|
4
4
|
|
|
5
|
+
interface XplButton extends Components.XplButton, HTMLElement {}
|
|
6
|
+
export const XplButton: {
|
|
7
|
+
prototype: XplButton;
|
|
8
|
+
new (): XplButton;
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
interface XplPagination extends Components.XplPagination, HTMLElement {}
|
|
6
12
|
export const XplPagination: {
|
|
7
13
|
prototype: XplPagination;
|
|
@@ -1,14 +1,93 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h, Host, createEvent, proxyCustomElement } from '@stencil/core/internal/client';
|
|
2
2
|
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
3
3
|
|
|
4
|
+
const XplButton$1 = class extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.__registerHost();
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
let className = "xpl-button";
|
|
11
|
+
if (this.type === "secondary")
|
|
12
|
+
className += " xpl-button--secondary";
|
|
13
|
+
if (this.type === "subtle")
|
|
14
|
+
className += " xpl-button--subtle";
|
|
15
|
+
return (h(Host, null,
|
|
16
|
+
/**
|
|
17
|
+
* Conditionally render either an <a> or <button> element
|
|
18
|
+
* depending on if there's an `href` or not
|
|
19
|
+
*/
|
|
20
|
+
this.href ? (h("a", { class: className, href: this.href, role: "button" }, h("slot", null))) : this.disabled ? (h("button", { class: className, role: "button", disabled: true }, h("slot", null))) : (h("button", { class: className, role: "button" }, h("slot", null)))));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
4
24
|
const XplPagination$1 = class extends HTMLElement {
|
|
5
25
|
constructor() {
|
|
6
26
|
super();
|
|
7
27
|
this.__registerHost();
|
|
8
|
-
|
|
28
|
+
this.page = createEvent(this, "page", 7);
|
|
29
|
+
this.current = 1;
|
|
30
|
+
/**
|
|
31
|
+
* Private `_goto` method respects the `waitForCallback` prop --
|
|
32
|
+
* it will always emit the `page` event, but won't actually update
|
|
33
|
+
* the state of what the current page is, leaving that to the caller
|
|
34
|
+
* to update once (presumably) some other data has loaded.
|
|
35
|
+
*/
|
|
36
|
+
this._goto = (n) => {
|
|
37
|
+
this.page.emit(n);
|
|
38
|
+
if (!this.waitForCallback) {
|
|
39
|
+
this.current = n;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
this.goPrev = () => {
|
|
43
|
+
if (this.current > 1)
|
|
44
|
+
this._goto(this.current - 1);
|
|
45
|
+
};
|
|
46
|
+
this.goNext = () => {
|
|
47
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
48
|
+
if (this.current < numPages)
|
|
49
|
+
this._goto(this.current + 1);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Calling `goto` with a page number (which should probably be
|
|
54
|
+
* taken from the `page` event) updates the pagination's state
|
|
55
|
+
* and re-renders it, showing the appropriate buttons given the current page.
|
|
56
|
+
* @param n
|
|
57
|
+
*/
|
|
58
|
+
async goto(n) {
|
|
59
|
+
this.current = n;
|
|
9
60
|
}
|
|
10
61
|
render() {
|
|
11
|
-
|
|
62
|
+
const numPages = Math.ceil(this.total / this.perPage);
|
|
63
|
+
let showing = [1];
|
|
64
|
+
if (numPages < 7)
|
|
65
|
+
showing = [1, 2, 3, 4, 5, 6];
|
|
66
|
+
if (this.current <= 3 || this.current >= numPages - 2) {
|
|
67
|
+
showing = [1, 2, 3, "...", numPages - 2, numPages - 1, numPages];
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
showing = [
|
|
71
|
+
1,
|
|
72
|
+
"...",
|
|
73
|
+
this.current - 1,
|
|
74
|
+
this.current,
|
|
75
|
+
this.current + 1,
|
|
76
|
+
"...",
|
|
77
|
+
numPages,
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
const showingFirst = (this.current - 1) * this.perPage + 1;
|
|
81
|
+
const showingLast = Math.min(showingFirst + this.perPage - 1, this.total);
|
|
82
|
+
return (h(Host, null, h("div", { class: "xpl-pagination" }, h("div", null, h("p", null, "Showing", " ", h("span", null, showingFirst), " ", "to", " ", h("span", null, showingLast), " ", "of", " ", h("span", null, this.total), " ", "results")), h("div", null, h("nav", { "aria-label": "Pagination" }, h("button", { onClick: this.goPrev, class: "xpl-pagination-prev" }, h("span", null, "Previous"), h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" }, 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) => {
|
|
83
|
+
if (n === "...") {
|
|
84
|
+
return h("span", { class: "xpl-pagination-ellipsis" }, "...");
|
|
85
|
+
}
|
|
86
|
+
if (n === this.current) {
|
|
87
|
+
return (h("button", { "aria-current": "page", class: "xpl-pagination-current" }, n));
|
|
88
|
+
}
|
|
89
|
+
return h("button", { onClick: () => this._goto(n) }, n);
|
|
90
|
+
}), h("button", { onClick: this.goNext, class: "xpl-pagination-next" }, h("span", null, "Next"), h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" }, 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" }))))))));
|
|
12
91
|
}
|
|
13
92
|
};
|
|
14
93
|
|
|
@@ -48,7 +127,7 @@ const XplTable$1 = class extends HTMLElement {
|
|
|
48
127
|
this.selected = new Array(this.data.length).fill(false);
|
|
49
128
|
}
|
|
50
129
|
render() {
|
|
51
|
-
return (h(Host, null, h("div", { class: "xpl-table-container" }, h("table", { class: `xpl-table${this.striped ? " xpl-table--striped" : ""} xpl-table--sticky` }, this.columns && (h("thead", null, this.columns.map((column, i) => {
|
|
130
|
+
return (h(Host, null, h("div", { class: "xpl-table-container" }, h("table", { class: `xpl-table${this.striped ? " xpl-table--striped" : ""}${this.fixed ? " xpl-table--sticky" : ""}` }, this.columns && (h("thead", null, this.columns.map((column, i) => {
|
|
52
131
|
return (h("th", null, this.multiselect && i === 0 ? (h("input", { type: "checkbox", onChange: (e) => {
|
|
53
132
|
this.selectAll(e);
|
|
54
133
|
}, checked: this.areAllSelected })) : null, column));
|
|
@@ -60,12 +139,14 @@ const XplTable$1 = class extends HTMLElement {
|
|
|
60
139
|
}
|
|
61
140
|
};
|
|
62
141
|
|
|
63
|
-
const
|
|
142
|
+
const XplButton = /*@__PURE__*/proxyCustomElement(XplButton$1, [4,"xpl-button",{"disabled":[4],"type":[1],"href":[1]}]);
|
|
143
|
+
const XplPagination = /*@__PURE__*/proxyCustomElement(XplPagination$1, [0,"xpl-pagination",{"total":[2],"perPage":[2,"per-page"],"waitForCallback":[4,"wait-for-callback"],"current":[32]}]);
|
|
64
144
|
const XplTable = /*@__PURE__*/proxyCustomElement(XplTable$1, [0,"xpl-table",{"columns":[16],"data":[16],"fixed":[4],"multiselect":[4],"striped":[4],"areAllSelected":[32],"selected":[32]}]);
|
|
65
145
|
const defineCustomElements = (opts) => {
|
|
66
146
|
if (typeof customElements !== 'undefined') {
|
|
67
147
|
[
|
|
68
|
-
|
|
148
|
+
XplButton,
|
|
149
|
+
XplPagination,
|
|
69
150
|
XplTable
|
|
70
151
|
].forEach(cmp => {
|
|
71
152
|
if (!customElements.get(cmp.is)) {
|
|
@@ -75,4 +156,4 @@ const defineCustomElements = (opts) => {
|
|
|
75
156
|
}
|
|
76
157
|
};
|
|
77
158
|
|
|
78
|
-
export { XplPagination, XplTable, defineCustomElements };
|
|
159
|
+
export { XplButton, XplPagination, XplTable, defineCustomElements };
|
package/dist/esm/apollo-core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as promiseResolve, b as bootstrapLazy } from './index-
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-6fd7b087.js';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
Stencil Client Patch Browser v2.6.0 | MIT Licensed | https://stenciljs.com
|
|
@@ -13,5 +13,5 @@ const patchBrowser = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
patchBrowser().then(options => {
|
|
16
|
-
return bootstrapLazy([["xpl-
|
|
16
|
+
return bootstrapLazy([["xpl-button_3",[[4,"xpl-button",{"disabled":[4],"type":[1],"href":[1]}],[0,"xpl-pagination",{"total":[2],"perPage":[2,"per-page"],"waitForCallback":[4,"wait-for-callback"],"current":[32],"goto":[64]}],[0,"xpl-table",{"columns":[16],"data":[16],"fixed":[4],"multiselect":[4],"striped":[4],"areAllSelected":[32],"selected":[32]}]]]], options);
|
|
17
17
|
});
|