@xplortech/apollo-core 0.5.2 → 1.0.0-beta.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/build/style.css +758 -383
- package/dist/apollo-core/apollo-core.css +4 -4
- package/dist/apollo-core/apollo-core.esm.js +1 -1
- package/dist/apollo-core/{p-5854d1e4.entry.js → p-09b2f746.entry.js} +1 -1
- package/dist/apollo-core/p-0bc956c6.entry.js +1 -0
- package/dist/apollo-core/p-1b1e7207.entry.js +1 -0
- package/dist/apollo-core/{p-f167aa05.entry.js → p-20389bb6.entry.js} +1 -1
- package/dist/apollo-core/{p-ee2f4422.entry.js → p-25983fde.entry.js} +1 -1
- package/dist/apollo-core/{p-128a0240.entry.js → p-4a348764.entry.js} +1 -1
- package/dist/apollo-core/{p-eb63b401.entry.js → p-4e2b69e8.entry.js} +1 -1
- package/dist/apollo-core/{p-97cd1f73.entry.js → p-84bf6b2d.entry.js} +1 -1
- package/dist/apollo-core/{p-611536d8.entry.js → p-880c0359.entry.js} +1 -1
- package/dist/apollo-core/p-8e47a5be.entry.js +1 -0
- package/dist/apollo-core/p-93958292.entry.js +1 -0
- package/dist/apollo-core/p-93c27db5.entry.js +1 -0
- package/dist/apollo-core/{p-0b2c612e.entry.js → p-b2327e2c.entry.js} +1 -1
- package/dist/apollo-core/p-c55b5d9c.entry.js +1 -0
- package/dist/apollo-core/p-e369d7af.entry.js +1 -0
- package/dist/apollo-core/p-e60ecaef.entry.js +1 -0
- package/dist/apollo-core/p-f929c958.js +1 -0
- package/dist/cjs/apollo-core.cjs.js +2 -2
- package/dist/cjs/{index-944adb2e.js → index-54ba5804.js} +14 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/xpl-application-shell.cjs.entry.js +58 -0
- package/dist/cjs/xpl-avatar_12.cjs.entry.js +299 -0
- package/dist/cjs/xpl-backdrop.cjs.entry.js +25 -0
- package/dist/cjs/xpl-button-row.cjs.entry.js +2 -4
- package/dist/cjs/xpl-choicelist.cjs.entry.js +21 -14
- package/dist/cjs/xpl-divider.cjs.entry.js +2 -2
- package/dist/cjs/xpl-dropdown-group_3.cjs.entry.js +104 -0
- package/dist/cjs/xpl-dropdown_2.cjs.entry.js +123 -0
- package/dist/cjs/xpl-grid-item.cjs.entry.js +2 -2
- package/dist/cjs/xpl-grid.cjs.entry.js +12 -12
- package/dist/cjs/xpl-input.cjs.entry.js +33 -26
- package/dist/cjs/xpl-list.cjs.entry.js +17 -19
- package/dist/cjs/xpl-main-nav.cjs.entry.js +30 -0
- package/dist/cjs/xpl-pagination.cjs.entry.js +8 -8
- package/dist/cjs/xpl-select.cjs.entry.js +87 -85
- package/dist/cjs/xpl-toggle.cjs.entry.js +13 -13
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/xpl-application-shell/xpl-application-shell.js +11 -7
- package/dist/collection/components/xpl-avatar/xpl-avatar.js +7 -7
- package/dist/collection/components/xpl-backdrop/xpl-backdrop.js +1 -1
- package/dist/collection/components/xpl-badge/xpl-badge.js +5 -5
- package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumb-item/xpl-breadcrumb-item.js +0 -2
- package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumbs/xpl-breadcrumbs.js +0 -2
- package/dist/collection/components/xpl-button/xpl-button.js +79 -82
- package/dist/collection/components/xpl-button-row/xpl-button-row.js +7 -9
- package/dist/collection/components/xpl-checkbox/xpl-checkbox.js +11 -11
- package/dist/collection/components/xpl-choicelist/xpl-choicelist.js +22 -15
- package/dist/collection/components/xpl-content-area/xpl-content-area.js +5 -5
- package/dist/collection/components/xpl-divider/xpl-divider.js +1 -1
- package/dist/collection/components/xpl-dropdown/xpl-dropdown-group/xpl-dropdown-group.js +66 -0
- package/dist/collection/components/xpl-dropdown/xpl-dropdown-heading/xpl-dropdown-heading.js +27 -0
- package/dist/collection/components/xpl-dropdown/xpl-dropdown-option/xpl-dropdown-option.js +110 -0
- package/dist/collection/components/xpl-dropdown/xpl-dropdown.js +259 -31
- package/dist/collection/components/xpl-grid/xpl-grid.js +11 -11
- package/dist/collection/components/xpl-grid-item/xpl-grid-item.js +1 -1
- package/dist/collection/components/xpl-input/xpl-input.js +49 -42
- package/dist/collection/components/xpl-list/xpl-list.js +24 -26
- package/dist/collection/components/xpl-main-nav/xpl-main-nav.js +3 -3
- package/dist/collection/components/xpl-nav-item/xpl-nav-item.js +59 -2
- package/dist/collection/components/xpl-pagination/xpl-pagination.js +11 -10
- package/dist/collection/components/xpl-radio/xpl-radio.js +11 -11
- package/dist/collection/components/xpl-select/xpl-select.js +97 -64
- package/dist/collection/components/xpl-table/xpl-table.js +18 -12
- package/dist/collection/components/xpl-toggle/xpl-toggle.js +16 -16
- package/dist/collection/components/xpl-utility-bar/xpl-utility-bar.js +4 -8
- package/dist/custom-elements/index.d.ts +24 -0
- package/dist/custom-elements/index.js +18936 -18694
- package/dist/esm/apollo-core.js +2 -2
- package/dist/esm/{index-899dba3b.js → index-3df6db84.js} +14 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/xpl-application-shell.entry.js +54 -0
- package/dist/esm/xpl-avatar_12.entry.js +284 -0
- package/dist/esm/xpl-backdrop.entry.js +21 -0
- package/dist/esm/xpl-button-row.entry.js +2 -4
- package/dist/esm/xpl-choicelist.entry.js +21 -14
- package/dist/esm/xpl-divider.entry.js +2 -2
- package/dist/esm/xpl-dropdown-group_3.entry.js +98 -0
- package/dist/esm/xpl-dropdown_2.entry.js +118 -0
- package/dist/esm/xpl-grid-item.entry.js +2 -2
- package/dist/esm/xpl-grid.entry.js +12 -12
- package/dist/esm/xpl-input.entry.js +33 -26
- package/dist/esm/xpl-list.entry.js +17 -19
- package/dist/esm/xpl-main-nav.entry.js +26 -0
- package/dist/esm/xpl-pagination.entry.js +8 -8
- package/dist/esm/xpl-select.entry.js +87 -85
- package/dist/esm/xpl-toggle.entry.js +13 -13
- package/dist/stories/application-shell.stories.js +31 -30
- package/dist/stories/avatar.stories.js +38 -38
- package/dist/stories/backdrop.stories.js +3 -3
- package/dist/stories/badge.stories.js +16 -16
- package/dist/stories/breadcrumbs.stories.js +18 -16
- package/dist/stories/button-row.stories.js +18 -14
- package/dist/stories/button.stories.js +69 -57
- package/dist/stories/checkbox.stories.js +21 -19
- package/dist/stories/choicelist.stories.js +19 -19
- package/dist/stories/content-area.stories.js +6 -6
- package/dist/stories/divider.stories.js +7 -7
- package/dist/stories/dropdown.stories.js +377 -0
- package/dist/stories/grid.stories.js +19 -19
- package/dist/stories/input.stories.js +93 -77
- package/dist/stories/list.stories.js +72 -52
- package/dist/stories/main-nav.stories.js +8 -8
- package/dist/stories/radio.stories.js +18 -16
- package/dist/stories/secondary-nav.stories.js +5 -5
- package/dist/stories/select.stories.js +54 -46
- package/dist/stories/table.stories.js +29 -29
- package/dist/stories/toggle.stories.js +30 -26
- package/dist/stories/utility-bar.stories.js +4 -4
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/application-shell.stories.d.ts +4 -4
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/avatar.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/backdrop.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/badge.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/breadcrumbs.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/button-row.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/button.stories.d.ts +19 -10
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/checkbox.stories.d.ts +2 -2
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/choicelist.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/content-area.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/divider.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/dropdown.stories.d.ts +134 -0
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/grid.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/input.stories.d.ts +5 -5
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/list.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/main-nav.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/radio.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/secondary-nav.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/select.stories.d.ts +2 -2
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/table.stories.d.ts +1 -1
- package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/toggle.stories.d.ts +2 -2
- package/dist/types/components/xpl-application-shell/xpl-application-shell.d.ts +2 -2
- package/dist/types/components/xpl-avatar/xpl-avatar.d.ts +3 -3
- package/dist/types/components/xpl-badge/xpl-badge.d.ts +1 -1
- package/dist/types/components/xpl-button/xpl-button.d.ts +32 -8
- package/dist/types/components/xpl-button-row/xpl-button-row.d.ts +3 -3
- package/dist/types/components/xpl-checkbox/xpl-checkbox.d.ts +1 -1
- package/dist/types/components/xpl-content-area/xpl-content-area.d.ts +3 -3
- package/dist/types/components/xpl-dropdown/xpl-dropdown-group/xpl-dropdown-group.d.ts +7 -0
- package/dist/types/components/xpl-dropdown/xpl-dropdown-heading/xpl-dropdown-heading.d.ts +5 -0
- package/dist/types/components/xpl-input/xpl-input.d.ts +4 -4
- package/dist/types/components/xpl-list/xpl-list.d.ts +2 -2
- package/dist/types/components/xpl-main-nav/xpl-main-nav.d.ts +1 -1
- package/dist/types/components/xpl-nav-item/xpl-nav-item.d.ts +10 -0
- package/dist/types/components/xpl-pagination/xpl-pagination.d.ts +1 -1
- package/dist/types/components/xpl-radio/xpl-radio.d.ts +1 -1
- package/dist/types/components/xpl-select/xpl-select.d.ts +6 -2
- package/dist/types/components/xpl-table/xpl-table.d.ts +1 -1
- package/dist/types/components/xpl-toggle/xpl-toggle.d.ts +1 -1
- package/dist/types/components.d.ts +264 -40
- package/package.json +10 -4
- package/dist/apollo-core/p-0203d4e8.entry.js +0 -1
- package/dist/apollo-core/p-30003b15.entry.js +0 -1
- package/dist/apollo-core/p-4e56a2ca.entry.js +0 -1
- package/dist/apollo-core/p-7c9fee7e.entry.js +0 -1
- package/dist/apollo-core/p-8b6633c7.js +0 -1
- package/dist/apollo-core/p-9c5ca308.entry.js +0 -1
- package/dist/apollo-core/p-bd4a7e3c.entry.js +0 -1
- package/dist/apollo-core/p-dab8e7a1.entry.js +0 -1
- package/dist/cjs/xpl-application-shell_11.cjs.entry.js +0 -230
- package/dist/cjs/xpl-badge.cjs.entry.js +0 -21
- package/dist/cjs/xpl-checkbox_2.cjs.entry.js +0 -51
- package/dist/cjs/xpl-table.cjs.entry.js +0 -89
- package/dist/cjs/xpl-tag.cjs.entry.js +0 -21
- package/dist/esm/xpl-application-shell_11.entry.js +0 -216
- package/dist/esm/xpl-badge.entry.js +0 -17
- package/dist/esm/xpl-checkbox_2.entry.js +0 -46
- package/dist/esm/xpl-table.entry.js +0 -85
- package/dist/esm/xpl-tag.entry.js +0 -17
- package/dist/types/components/xpl-choicelist/choice.d.ts +0 -6
- package/dist/types/components/xpl-dropdown/dropdownchoice.d.ts +0 -6
- package/dist/types/components/xpl-dropdown/xpl-dropdown.d.ts +0 -10
- package/dist/types/components/xpl-list/listitem.d.ts +0 -16
|
@@ -1,10 +1,67 @@
|
|
|
1
|
-
import { Component, Host, h } from '@stencil/core';
|
|
1
|
+
import { Component, Event, Host, h, Prop } from '@stencil/core';
|
|
2
2
|
export class XplNavItem {
|
|
3
|
+
constructor() {
|
|
4
|
+
/**
|
|
5
|
+
* @property {boolean} - Whether or not the item should control the main nav state on click
|
|
6
|
+
*/
|
|
7
|
+
this.navControl = false;
|
|
8
|
+
}
|
|
9
|
+
onNavToggle() {
|
|
10
|
+
if (window.innerWidth <= 640) {
|
|
11
|
+
this.navOpen.emit(false);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
3
14
|
render() {
|
|
4
|
-
return (h(Host, { class: "xpl-nav-item", role: "listitem"
|
|
15
|
+
return (h(Host, { class: "xpl-nav-item", role: "listitem", onClick: () => {
|
|
16
|
+
if (this.navControl) {
|
|
17
|
+
this.onNavToggle();
|
|
18
|
+
}
|
|
19
|
+
} },
|
|
5
20
|
h("slot", { name: "link" },
|
|
6
21
|
h("slot", { name: "icon" }),
|
|
7
22
|
h("slot", null))));
|
|
8
23
|
}
|
|
9
24
|
static get is() { return "xpl-nav-item"; }
|
|
25
|
+
static get properties() { return {
|
|
26
|
+
"navControl": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"mutable": false,
|
|
29
|
+
"complexType": {
|
|
30
|
+
"original": "boolean",
|
|
31
|
+
"resolved": "boolean",
|
|
32
|
+
"references": {}
|
|
33
|
+
},
|
|
34
|
+
"required": false,
|
|
35
|
+
"optional": true,
|
|
36
|
+
"docs": {
|
|
37
|
+
"tags": [{
|
|
38
|
+
"text": "{boolean} - Whether or not the item should control the main nav state on click",
|
|
39
|
+
"name": "property"
|
|
40
|
+
}],
|
|
41
|
+
"text": ""
|
|
42
|
+
},
|
|
43
|
+
"attribute": "nav-control",
|
|
44
|
+
"reflect": false,
|
|
45
|
+
"defaultValue": "false"
|
|
46
|
+
}
|
|
47
|
+
}; }
|
|
48
|
+
static get events() { return [{
|
|
49
|
+
"method": "navOpen",
|
|
50
|
+
"name": "navOpen",
|
|
51
|
+
"bubbles": true,
|
|
52
|
+
"cancelable": true,
|
|
53
|
+
"composed": true,
|
|
54
|
+
"docs": {
|
|
55
|
+
"tags": [{
|
|
56
|
+
"text": "{boolean} - Emits the desired state of the navigation bar (open: true/false)",
|
|
57
|
+
"name": "event"
|
|
58
|
+
}],
|
|
59
|
+
"text": ""
|
|
60
|
+
},
|
|
61
|
+
"complexType": {
|
|
62
|
+
"original": "boolean",
|
|
63
|
+
"resolved": "boolean",
|
|
64
|
+
"references": {}
|
|
65
|
+
}
|
|
66
|
+
}]; }
|
|
10
67
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Host, h, Event, Prop, State, Method, } from
|
|
1
|
+
import { Component, Host, h, Event, Prop, State, Method, } from '@stencil/core';
|
|
2
2
|
export class XplPagination {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.current = 1;
|
|
@@ -39,16 +39,16 @@ export class XplPagination {
|
|
|
39
39
|
if (numPages < 7)
|
|
40
40
|
showing = [1, 2, 3, 4, 5, 6];
|
|
41
41
|
if (this.current <= 3 || this.current >= numPages - 2) {
|
|
42
|
-
showing = [1, 2, 3,
|
|
42
|
+
showing = [1, 2, 3, '...', numPages - 2, numPages - 1, numPages];
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
showing = [
|
|
46
46
|
1,
|
|
47
|
-
|
|
47
|
+
'...',
|
|
48
48
|
this.current - 1,
|
|
49
49
|
this.current,
|
|
50
50
|
this.current + 1,
|
|
51
|
-
|
|
51
|
+
'...',
|
|
52
52
|
numPages,
|
|
53
53
|
];
|
|
54
54
|
}
|
|
@@ -60,10 +60,11 @@ export class XplPagination {
|
|
|
60
60
|
h("p", null,
|
|
61
61
|
"Showing ",
|
|
62
62
|
h("span", null, showingFirst),
|
|
63
|
-
" to
|
|
63
|
+
" to",
|
|
64
|
+
' ',
|
|
64
65
|
h("span", null, showingLast),
|
|
65
|
-
" ",
|
|
66
|
-
|
|
66
|
+
" of",
|
|
67
|
+
' ',
|
|
67
68
|
h("span", null, this.total),
|
|
68
69
|
" results")),
|
|
69
70
|
h("div", null,
|
|
@@ -73,13 +74,13 @@ export class XplPagination {
|
|
|
73
74
|
h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" },
|
|
74
75
|
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" }))),
|
|
75
76
|
showing.map((n) => {
|
|
76
|
-
if (n ===
|
|
77
|
-
return h("span", { class: "xpl-pagination-ellipsis" }, "...");
|
|
77
|
+
if (n === '...') {
|
|
78
|
+
return (h("span", { class: "xpl-pagination-ellipsis" }, "..."));
|
|
78
79
|
}
|
|
79
80
|
if (n === this.current) {
|
|
80
81
|
return (h("button", { "aria-current": "page", class: "xpl-pagination-current" }, n));
|
|
81
82
|
}
|
|
82
|
-
return h("button", { onClick: () => this._goto(n) }, n);
|
|
83
|
+
return (h("button", { onClick: () => this._goto(n) }, n));
|
|
83
84
|
}),
|
|
84
85
|
h("button", { onClick: this.goNext, class: "xpl-pagination-next" },
|
|
85
86
|
h("span", null, "Next"),
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Component, Host, h, Prop, State, Event } from
|
|
2
|
-
import { v4 as uuid } from
|
|
1
|
+
import { Component, Host, h, Prop, State, Event, } from '@stencil/core';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
3
|
export class XplRadio {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.id = uuid();
|
|
6
6
|
}
|
|
7
7
|
render() {
|
|
8
8
|
return (h(Host, { class: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
'xpl-checkbox-radio-container': true,
|
|
10
|
+
styled: this.styled,
|
|
11
|
+
disabled: this.disabled,
|
|
12
12
|
} },
|
|
13
13
|
h("input", { class: "xpl-radio", type: "radio", checked: this.checked, disabled: this.disabled, id: this.id, name: this.name, required: this.required, value: this.value, onChange: () => this.radioChange.emit(true) }),
|
|
14
14
|
h("label", { class: {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
'xpl-label': true,
|
|
16
|
+
'xpl-label--disabled': this.disabled,
|
|
17
17
|
}, htmlFor: this.id },
|
|
18
18
|
h("slot", null),
|
|
19
|
-
this.description && h("small", { class: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} }, this.description))));
|
|
19
|
+
this.description && (h("small", { class: {
|
|
20
|
+
'xpl-description': true,
|
|
21
|
+
'xpl-description--disabled': this.disabled,
|
|
22
|
+
} }, this.description)))));
|
|
23
23
|
}
|
|
24
24
|
static get is() { return "xpl-radio"; }
|
|
25
25
|
static get properties() { return {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { XplDropdown } from "../xpl-dropdown/xpl-dropdown";
|
|
5
|
-
import throttle from "lodash.throttle";
|
|
1
|
+
import { v4 as uuid } from 'uuid';
|
|
2
|
+
import { Component, Host, h, Prop, State } from '@stencil/core';
|
|
3
|
+
import throttle from 'lodash.throttle';
|
|
6
4
|
function tagWidth(text) {
|
|
7
|
-
const context = document.createElement(
|
|
8
|
-
context.font =
|
|
5
|
+
const context = document.createElement('canvas').getContext('2d');
|
|
6
|
+
context.font =
|
|
7
|
+
"14px apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
|
|
9
8
|
return context.measureText(text).width + 44; // = text + l/r padding + margin-right
|
|
10
9
|
}
|
|
11
10
|
export class XplSelect {
|
|
@@ -24,7 +23,7 @@ export class XplSelect {
|
|
|
24
23
|
/**
|
|
25
24
|
* Whether to allow a single choice or multiple choices.
|
|
26
25
|
*/
|
|
27
|
-
this.mode =
|
|
26
|
+
this.mode = 'single';
|
|
28
27
|
/**
|
|
29
28
|
* Only used in multi-choice selects. If `true`,
|
|
30
29
|
* badges representing selections that would overflow the
|
|
@@ -36,30 +35,37 @@ export class XplSelect {
|
|
|
36
35
|
this.active = false;
|
|
37
36
|
this.id = uuid();
|
|
38
37
|
this.keepFocus = false;
|
|
39
|
-
this.value =
|
|
38
|
+
this.value = '';
|
|
39
|
+
this.displayValue = '';
|
|
40
40
|
// infinity isn't real, it's just a mathematical construct, it can't hurt you
|
|
41
41
|
this.visibleChoices = Infinity;
|
|
42
42
|
}
|
|
43
43
|
componentWillLoad() {
|
|
44
|
-
this.selected =
|
|
45
|
-
|
|
44
|
+
this.selected =
|
|
45
|
+
this.choices && this.choices.length > 0
|
|
46
|
+
? this.choices.map(() => false)
|
|
47
|
+
: [];
|
|
48
|
+
window.addEventListener('click', (e) => {
|
|
46
49
|
const el = e.target;
|
|
47
|
-
const select = el.closest(
|
|
50
|
+
const select = el.closest('.xpl-select');
|
|
48
51
|
if (select === null || select !== this.container) {
|
|
49
52
|
this.active = false;
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
|
-
window.addEventListener(
|
|
55
|
+
window.addEventListener('resize', throttle(() => {
|
|
53
56
|
this.maybeTruncateChoices();
|
|
54
57
|
}, 250));
|
|
55
58
|
}
|
|
59
|
+
componentDidLoad() {
|
|
60
|
+
this.dropdown = this.container.querySelector('xpl-dropdown');
|
|
61
|
+
}
|
|
56
62
|
maybeTruncateChoices() {
|
|
57
|
-
if (this.mode ===
|
|
63
|
+
if (this.mode === 'single' || !this.truncate)
|
|
58
64
|
return;
|
|
59
65
|
const containerWidth = this.container.getBoundingClientRect().width;
|
|
60
66
|
let visibleChoices = 0;
|
|
61
67
|
let visibleChoicesWidth = 0;
|
|
62
|
-
const actualNumSelected = this.selected.filter(a => a).length;
|
|
68
|
+
const actualNumSelected = this.selected.filter((a) => a).length;
|
|
63
69
|
for (let i = 0; i < actualNumSelected; i++) {
|
|
64
70
|
visibleChoicesWidth += tagWidth(this.getDisplayValue(i));
|
|
65
71
|
if (visibleChoicesWidth > containerWidth - 140)
|
|
@@ -72,88 +78,114 @@ export class XplSelect {
|
|
|
72
78
|
visibleChoices = 1;
|
|
73
79
|
this.visibleChoices = visibleChoices;
|
|
74
80
|
}
|
|
81
|
+
flattenChoices() {
|
|
82
|
+
return this.choices.reduce((acc, curr) => [
|
|
83
|
+
...acc,
|
|
84
|
+
...(curr.groupName ? curr.options : [curr]),
|
|
85
|
+
], []);
|
|
86
|
+
}
|
|
75
87
|
getDisplayValue(i) {
|
|
76
|
-
return this.
|
|
88
|
+
return this.flattenChoices()[i].label || this.flattenChoices()[i].value;
|
|
77
89
|
}
|
|
78
90
|
getActualValue(i) {
|
|
79
|
-
return this.
|
|
91
|
+
return this.flattenChoices()[i].value || this.flattenChoices()[i].label;
|
|
80
92
|
}
|
|
81
|
-
update(
|
|
82
|
-
this.selected =
|
|
83
|
-
if (this.mode ===
|
|
84
|
-
const selected = this.selected.findIndex(v => v);
|
|
85
|
-
this.value = selected >= 0 ?
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
update() {
|
|
94
|
+
this.selected = this.flattenChoices().map(({ isSelected }) => isSelected);
|
|
95
|
+
if (this.mode === 'single') {
|
|
96
|
+
const selected = this.selected.findIndex((v) => v);
|
|
97
|
+
this.value = selected >= 0 ? this.getActualValue(selected) : '';
|
|
98
|
+
this.displayValue =
|
|
99
|
+
selected >= 0 ? this.getDisplayValue(selected) : '';
|
|
88
100
|
}
|
|
89
|
-
else if (this.mode ===
|
|
90
|
-
this.value = this.selected
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
else if (this.mode === 'multi') {
|
|
102
|
+
this.value = this.selected
|
|
103
|
+
.map((v, i) => {
|
|
104
|
+
return v ? this.getActualValue(i) : '';
|
|
105
|
+
})
|
|
106
|
+
.filter((v) => v.length > 0)
|
|
107
|
+
.join('|');
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
110
|
render() {
|
|
96
111
|
let visibleChoices = 0;
|
|
97
112
|
return (h(Host, { class: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
'xpl-select': true,
|
|
114
|
+
'xpl-select--disabled': this.disabled,
|
|
115
|
+
'xpl-select--no-truncate': !this.truncate,
|
|
101
116
|
}, onKeyDown: (e) => {
|
|
102
|
-
if (e.key ===
|
|
117
|
+
if (e.key === 'Escape')
|
|
103
118
|
this.active = false;
|
|
104
119
|
}, ref: (el) => (this.container = el) },
|
|
105
120
|
this.label || this.description ? (h("label", { class: {
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
'xpl-label': true,
|
|
122
|
+
'xpl-label--disabled': this.disabled,
|
|
108
123
|
}, htmlFor: this.id },
|
|
109
124
|
this.label,
|
|
110
|
-
this.description && h("small", { class: {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
} }, this.description))) : null,
|
|
125
|
+
this.description && (h("small", { class: {
|
|
126
|
+
'xpl-description': true,
|
|
127
|
+
'xpl-description--disabled': this.disabled,
|
|
128
|
+
} }, this.description)))) : null,
|
|
114
129
|
h("div", { class: {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
'xpl-input': true,
|
|
131
|
+
'xpl-input--disabled': this.disabled,
|
|
132
|
+
'xpl-input--error': this.error !== undefined,
|
|
118
133
|
} },
|
|
119
134
|
h("div", { class: "xpl-input-wrapper" },
|
|
120
135
|
h("div", { class: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
'xpl-select-value': true,
|
|
137
|
+
'xpl-select-value--active': this.mode === 'multi' &&
|
|
138
|
+
this.value.length > 0,
|
|
139
|
+
'has-value': this.value.length > 0,
|
|
124
140
|
} },
|
|
125
|
-
this.mode ===
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.selected.map((v, i) => {
|
|
141
|
+
this.mode === 'single'
|
|
142
|
+
? this.displayValue || this.placeholder
|
|
143
|
+
: this.value.length > 0
|
|
144
|
+
? this.selected.map((v, i) => {
|
|
129
145
|
if (!v)
|
|
130
146
|
return null;
|
|
131
147
|
if (visibleChoices >= this.visibleChoices)
|
|
132
148
|
return null;
|
|
133
149
|
visibleChoices++;
|
|
134
150
|
return (h("xpl-tag", { onClose: () => {
|
|
135
|
-
this.
|
|
136
|
-
|
|
151
|
+
this.flattenChoices().forEach((v, j) => {
|
|
152
|
+
if (i === j)
|
|
153
|
+
v.isSelected =
|
|
154
|
+
false;
|
|
155
|
+
});
|
|
156
|
+
const mapOptions = (option) => {
|
|
157
|
+
option.options =
|
|
158
|
+
option.groupName
|
|
159
|
+
? option.options.map(mapOptions)
|
|
160
|
+
: undefined;
|
|
161
|
+
return option;
|
|
162
|
+
};
|
|
163
|
+
this.choices =
|
|
164
|
+
this.choices.map(mapOptions);
|
|
165
|
+
this.update();
|
|
137
166
|
this.maybeTruncateChoices();
|
|
138
167
|
} }, this.getDisplayValue(i)));
|
|
139
|
-
})
|
|
140
|
-
this.placeholder
|
|
141
|
-
this.visibleChoices < Infinity &&
|
|
168
|
+
})
|
|
169
|
+
: this.placeholder,
|
|
170
|
+
this.visibleChoices < Infinity &&
|
|
171
|
+
`+ ${this.selected.filter((a) => a).length -
|
|
172
|
+
this.visibleChoices} more`),
|
|
142
173
|
h("button", { disabled: this.disabled, id: this.id, onKeyDown: (e) => {
|
|
143
|
-
if (e.key ===
|
|
174
|
+
if (e.key === 'Tab')
|
|
144
175
|
this.keepFocus = true;
|
|
145
176
|
}, onClick: () => {
|
|
177
|
+
const { dropdown } = this;
|
|
146
178
|
if (!this.disabled)
|
|
147
|
-
|
|
179
|
+
dropdown.isOpen = !dropdown.isOpen;
|
|
148
180
|
} })),
|
|
149
|
-
!this.disabled && (h(
|
|
150
|
-
this.update(
|
|
181
|
+
!this.disabled && (h("xpl-dropdown", { options: this.choices, mode: this.mode, triggerId: this.id, update: () => {
|
|
182
|
+
this.update();
|
|
151
183
|
this.maybeTruncateChoices();
|
|
152
184
|
} })),
|
|
153
|
-
this.error !== undefined && this.error.length > 0 && h("label", { class: "xpl-input-error", htmlFor: this.id },
|
|
185
|
+
this.error !== undefined && this.error.length > 0 && (h("label", { class: "xpl-input-error", htmlFor: this.id },
|
|
154
186
|
h("svg", { width: "10", height: "11", viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
155
187
|
h("path", { d: "M9.84375 5.25C9.84375 2.59375 7.65625 0.40625 5 0.40625C2.32422 0.40625 0.15625 2.59375 0.15625 5.25C0.15625 7.92578 2.32422 10.0938 5 10.0938C7.65625 10.0938 9.84375 7.92578 9.84375 5.25ZM5 6.22656C5.48828 6.22656 5.89844 6.63672 5.89844 7.125C5.89844 7.63281 5.48828 8.02344 5 8.02344C4.49219 8.02344 4.10156 7.63281 4.10156 7.125C4.10156 6.63672 4.49219 6.22656 5 6.22656ZM4.14062 3.00391C4.12109 2.86719 4.23828 2.75 4.375 2.75H5.60547C5.74219 2.75 5.85938 2.86719 5.83984 3.00391L5.70312 5.66016C5.68359 5.79688 5.58594 5.875 5.46875 5.875H4.51172C4.39453 5.875 4.29688 5.79688 4.27734 5.66016L4.14062 3.00391Z" })),
|
|
156
|
-
this.error)),
|
|
188
|
+
this.error))),
|
|
157
189
|
h("input", { type: "hidden", value: this.value })));
|
|
158
190
|
}
|
|
159
191
|
static get is() { return "xpl-select"; }
|
|
@@ -162,10 +194,10 @@ export class XplSelect {
|
|
|
162
194
|
"type": "unknown",
|
|
163
195
|
"mutable": false,
|
|
164
196
|
"complexType": {
|
|
165
|
-
"original": "
|
|
166
|
-
"resolved": "
|
|
197
|
+
"original": "SelectChoice[]",
|
|
198
|
+
"resolved": "SelectChoice[]",
|
|
167
199
|
"references": {
|
|
168
|
-
"
|
|
200
|
+
"SelectChoice": {
|
|
169
201
|
"location": "global"
|
|
170
202
|
}
|
|
171
203
|
}
|
|
@@ -250,7 +282,7 @@ export class XplSelect {
|
|
|
250
282
|
"type": "string",
|
|
251
283
|
"mutable": false,
|
|
252
284
|
"complexType": {
|
|
253
|
-
"original": "
|
|
285
|
+
"original": "'single' | 'multi'",
|
|
254
286
|
"resolved": "\"multi\" | \"single\"",
|
|
255
287
|
"references": {}
|
|
256
288
|
},
|
|
@@ -262,7 +294,7 @@ export class XplSelect {
|
|
|
262
294
|
},
|
|
263
295
|
"attribute": "mode",
|
|
264
296
|
"reflect": false,
|
|
265
|
-
"defaultValue": "
|
|
297
|
+
"defaultValue": "'single'"
|
|
266
298
|
},
|
|
267
299
|
"placeholder": {
|
|
268
300
|
"type": "string",
|
|
@@ -306,6 +338,7 @@ export class XplSelect {
|
|
|
306
338
|
"keepFocus": {},
|
|
307
339
|
"selected": {},
|
|
308
340
|
"value": {},
|
|
341
|
+
"displayValue": {},
|
|
309
342
|
"visibleChoices": {}
|
|
310
343
|
}; }
|
|
311
344
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Host, Prop, State, Event, h, } from
|
|
1
|
+
import { Component, Host, Prop, State, Event, h, } from '@stencil/core';
|
|
2
2
|
export class XplTable {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.areAllSelected = false;
|
|
@@ -38,7 +38,7 @@ export class XplTable {
|
|
|
38
38
|
this.rowData.sort((a, b) => {
|
|
39
39
|
const A = a[col];
|
|
40
40
|
const B = b[col];
|
|
41
|
-
if (typeof A ===
|
|
41
|
+
if (typeof A === 'number' && typeof B === 'number') {
|
|
42
42
|
const f = ascending ? 1 : -1;
|
|
43
43
|
return A > B ? f : -f;
|
|
44
44
|
}
|
|
@@ -54,13 +54,13 @@ export class XplTable {
|
|
|
54
54
|
this.selected = new Array(this.rowData.length).fill(false);
|
|
55
55
|
}
|
|
56
56
|
render() {
|
|
57
|
-
let className =
|
|
57
|
+
let className = 'xpl-table';
|
|
58
58
|
if (this.striped)
|
|
59
|
-
className +=
|
|
59
|
+
className += ' xpl-table--striped';
|
|
60
60
|
if (this.freeze)
|
|
61
|
-
className +=
|
|
61
|
+
className += ' xpl-table--freeze';
|
|
62
62
|
if (this.hasScrolled)
|
|
63
|
-
className +=
|
|
63
|
+
className += ' xpl-table--has-scrolled';
|
|
64
64
|
return (h(Host, null,
|
|
65
65
|
h("div", { class: "xpl-table-container", onScroll: this.onScroll, ref: (el) => (this.container = el) },
|
|
66
66
|
h("table", { class: className },
|
|
@@ -69,18 +69,24 @@ export class XplTable {
|
|
|
69
69
|
h("input", { checked: this.areAllSelected, id: "__xpl-table-th",
|
|
70
70
|
// appear indeterminate when at least one but not all
|
|
71
71
|
// are selected
|
|
72
|
-
indeterminate: !this
|
|
72
|
+
indeterminate: !this
|
|
73
|
+
.areAllSelected &&
|
|
73
74
|
this.selected.some((a) => a), onChange: (e) => {
|
|
74
75
|
this.selectAll(e);
|
|
75
76
|
}, type: "checkbox" }),
|
|
76
77
|
column)) : (column)));
|
|
77
78
|
}))),
|
|
78
79
|
h("tbody", null, this.rowData.map((row, rowNum) => {
|
|
79
|
-
return (h("tr", { class: this.selected &&
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
return (h("tr", { class: this.selected &&
|
|
81
|
+
this.selected[rowNum]
|
|
82
|
+
? 'xpl-table-row-selected'
|
|
83
|
+
: '' }, row.map((cell, i) => {
|
|
84
|
+
return (h("td", null, this.multiselect &&
|
|
85
|
+
i === 0 ? (h("label", { htmlFor: '__xpl-table-row-' +
|
|
86
|
+
rowNum },
|
|
87
|
+
h("input", { id: '__xpl-table-row-' +
|
|
88
|
+
rowNum, checked: this
|
|
89
|
+
.selected[rowNum], type: "checkbox", onChange: (e) => this.selectOne(e, rowNum) }),
|
|
84
90
|
h("div", { innerHTML: cell }))) : (h("div", { innerHTML: cell }))));
|
|
85
91
|
})));
|
|
86
92
|
}))))));
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Component, Host, h, Prop, State } from
|
|
2
|
-
import { v4 as uuid } from
|
|
1
|
+
import { Component, Host, h, Prop, State } from '@stencil/core';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
3
|
export class XplToggle {
|
|
4
4
|
constructor() {
|
|
5
5
|
/**
|
|
6
6
|
* The size of the toggle -- `default` or `small`
|
|
7
7
|
*/
|
|
8
|
-
this.variant =
|
|
8
|
+
this.variant = 'default';
|
|
9
9
|
this.id = uuid();
|
|
10
10
|
}
|
|
11
11
|
render() {
|
|
12
|
-
let containerClassName =
|
|
12
|
+
let containerClassName = 'xpl-toggle-container';
|
|
13
13
|
if (this.disabled)
|
|
14
|
-
containerClassName +=
|
|
15
|
-
let className =
|
|
16
|
-
if (this.variant ===
|
|
17
|
-
className +=
|
|
14
|
+
containerClassName += ' xpl-toggle-container--disabled';
|
|
15
|
+
let className = 'xpl-toggle';
|
|
16
|
+
if (this.variant === 'small')
|
|
17
|
+
className += ' xpl-toggle--small';
|
|
18
18
|
return (h(Host, { class: containerClassName },
|
|
19
19
|
(this.heading || this.description) && (h("label", { class: {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
'xpl-label': true,
|
|
21
|
+
'xpl-label--disabled': this.disabled,
|
|
22
22
|
}, htmlFor: this.id },
|
|
23
23
|
this.heading,
|
|
24
|
-
this.description && h("small", { class: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} }, this.description))),
|
|
24
|
+
this.description && (h("small", { class: {
|
|
25
|
+
'xpl-description': true,
|
|
26
|
+
'xpl-description--disabled': this.disabled,
|
|
27
|
+
} }, this.description)))),
|
|
28
28
|
h("input", { class: className, type: "checkbox", checked: this.checked, disabled: this.disabled, id: this.id, name: this.name }),
|
|
29
29
|
this.label && h("label", { htmlFor: this.id }, this.label)));
|
|
30
30
|
}
|
|
@@ -136,7 +136,7 @@ export class XplToggle {
|
|
|
136
136
|
"type": "string",
|
|
137
137
|
"mutable": false,
|
|
138
138
|
"complexType": {
|
|
139
|
-
"original": "
|
|
139
|
+
"original": "'default' | 'small'",
|
|
140
140
|
"resolved": "\"default\" | \"small\"",
|
|
141
141
|
"references": {}
|
|
142
142
|
},
|
|
@@ -148,7 +148,7 @@ export class XplToggle {
|
|
|
148
148
|
},
|
|
149
149
|
"attribute": "variant",
|
|
150
150
|
"reflect": false,
|
|
151
|
-
"defaultValue": "
|
|
151
|
+
"defaultValue": "'default'"
|
|
152
152
|
}
|
|
153
153
|
}; }
|
|
154
154
|
static get states() { return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Event, Host, h, Prop, State } from '@stencil/core';
|
|
1
|
+
import { Component, Event, Host, h, Prop, State, } from '@stencil/core';
|
|
2
2
|
export class XplUtilityBar {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.open = true;
|
|
@@ -13,13 +13,9 @@ export class XplUtilityBar {
|
|
|
13
13
|
render() {
|
|
14
14
|
return (h(Host, null,
|
|
15
15
|
h("nav", { "aria-label": "utility navigation bar", class: "xpl-utility-bar" },
|
|
16
|
-
this.navControl
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
h("button", { onClick: () => this.onNavToggle(), innerHTML: `${this.bars}` }),
|
|
20
|
-
h("slot", { name: "aside" }))
|
|
21
|
-
:
|
|
22
|
-
h("slot", { name: "aside" }),
|
|
16
|
+
this.navControl ? (h("div", null,
|
|
17
|
+
h("button", { onClick: () => this.onNavToggle(), innerHTML: `${this.bars}` }),
|
|
18
|
+
h("slot", { name: "aside" }))) : (h("slot", { name: "aside" })),
|
|
23
19
|
h("slot", { name: "main" }))));
|
|
24
20
|
}
|
|
25
21
|
static get is() { return "xpl-utility-bar"; }
|
|
@@ -74,6 +74,30 @@ export const XplDivider: {
|
|
|
74
74
|
new (): XplDivider;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
interface XplDropdown extends Components.XplDropdown, HTMLElement {}
|
|
78
|
+
export const XplDropdown: {
|
|
79
|
+
prototype: XplDropdown;
|
|
80
|
+
new (): XplDropdown;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
interface XplDropdownGroup extends Components.XplDropdownGroup, HTMLElement {}
|
|
84
|
+
export const XplDropdownGroup: {
|
|
85
|
+
prototype: XplDropdownGroup;
|
|
86
|
+
new (): XplDropdownGroup;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
interface XplDropdownHeading extends Components.XplDropdownHeading, HTMLElement {}
|
|
90
|
+
export const XplDropdownHeading: {
|
|
91
|
+
prototype: XplDropdownHeading;
|
|
92
|
+
new (): XplDropdownHeading;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
interface XplDropdownOption extends Components.XplDropdownOption, HTMLElement {}
|
|
96
|
+
export const XplDropdownOption: {
|
|
97
|
+
prototype: XplDropdownOption;
|
|
98
|
+
new (): XplDropdownOption;
|
|
99
|
+
};
|
|
100
|
+
|
|
77
101
|
interface XplGrid extends Components.XplGrid, HTMLElement {}
|
|
78
102
|
export const XplGrid: {
|
|
79
103
|
prototype: XplGrid;
|