@xplortech/apollo-core 0.5.2 → 0.5.3

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.
Files changed (173) hide show
  1. package/dist/apollo-core/apollo-core.css +5468 -9
  2. package/dist/apollo-core/apollo-core.esm.js +125 -1
  3. package/dist/apollo-core/app-globals-0f993ce5.js +3 -0
  4. package/dist/apollo-core/css-shim-bbdf0cc6.js +4 -0
  5. package/dist/apollo-core/dom-1f98a75f.js +73 -0
  6. package/dist/apollo-core/index-3c9f25ef.js +2938 -0
  7. package/dist/apollo-core/index-912d1a21.js +584 -0
  8. package/dist/apollo-core/index.esm.js +1 -0
  9. package/dist/{cjs/regular-872f5226.js → apollo-core/regular-133c23b5.js} +12 -3
  10. package/dist/apollo-core/shadow-css-67b66845.js +389 -0
  11. package/dist/apollo-core/xpl-application-shell.entry.js +50 -0
  12. package/dist/apollo-core/xpl-avatar.entry.js +19 -0
  13. package/dist/apollo-core/xpl-backdrop.entry.js +21 -0
  14. package/dist/{esm → apollo-core}/xpl-badge.entry.js +1 -1
  15. package/dist/{collection/components/xpl-breadcrumbs/xpl-breadcrumb-item/xpl-breadcrumb-item.js → apollo-core/xpl-breadcrumb-item.entry.js} +9 -12
  16. package/dist/apollo-core/xpl-breadcrumbs.entry.js +14 -0
  17. package/dist/{esm → apollo-core}/xpl-button-row.entry.js +1 -1
  18. package/dist/apollo-core/xpl-button.entry.js +34 -0
  19. package/dist/apollo-core/xpl-checkbox.entry.js +25 -0
  20. package/dist/{esm → apollo-core}/xpl-choicelist.entry.js +1 -1
  21. package/dist/apollo-core/xpl-content-area.entry.js +16 -0
  22. package/dist/{esm → apollo-core}/xpl-divider.entry.js +1 -1
  23. package/dist/{esm → apollo-core}/xpl-grid-item.entry.js +1 -1
  24. package/dist/{esm → apollo-core}/xpl-grid.entry.js +1 -1
  25. package/dist/{esm → apollo-core}/xpl-input.entry.js +20 -3
  26. package/dist/{esm → apollo-core}/xpl-list.entry.js +2 -2
  27. package/dist/apollo-core/xpl-main-nav.entry.js +26 -0
  28. package/dist/apollo-core/xpl-nav-item.entry.js +12 -0
  29. package/dist/{esm → apollo-core}/xpl-pagination.entry.js +1 -1
  30. package/dist/apollo-core/xpl-radio.entry.js +25 -0
  31. package/dist/apollo-core/xpl-secondary-nav.entry.js +12 -0
  32. package/dist/{esm → apollo-core}/xpl-select.entry.js +43 -3
  33. package/dist/{esm → apollo-core}/xpl-table.entry.js +1 -1
  34. package/dist/{esm → apollo-core}/xpl-tag.entry.js +1 -1
  35. package/dist/{esm → apollo-core}/xpl-toggle.entry.js +2 -2
  36. package/dist/apollo-core/xpl-utility-bar.entry.js +25 -0
  37. package/dist/types/components/xpl-choicelist/choice.d.ts +1 -1
  38. package/dist/types/components/xpl-choicelist/xpl-choicelist.d.ts +1 -0
  39. package/dist/types/components/xpl-dropdown/dropdownchoice.d.ts +5 -5
  40. package/dist/types/components/xpl-dropdown/xpl-dropdown.d.ts +1 -0
  41. package/dist/types/components/xpl-list/listitem.d.ts +15 -15
  42. package/dist/types/components/xpl-list/xpl-list.d.ts +1 -0
  43. package/dist/types/components/xpl-select/xpl-select.d.ts +1 -0
  44. package/dist/types/components.d.ts +3 -0
  45. package/package.json +1 -1
  46. package/dist/apollo-core/p-0203d4e8.entry.js +0 -1
  47. package/dist/apollo-core/p-0b2c612e.entry.js +0 -1
  48. package/dist/apollo-core/p-128a0240.entry.js +0 -1
  49. package/dist/apollo-core/p-2f90296c.js +0 -10
  50. package/dist/apollo-core/p-30003b15.entry.js +0 -1
  51. package/dist/apollo-core/p-4e56a2ca.entry.js +0 -1
  52. package/dist/apollo-core/p-5854d1e4.entry.js +0 -1
  53. package/dist/apollo-core/p-611536d8.entry.js +0 -1
  54. package/dist/apollo-core/p-7c9fee7e.entry.js +0 -1
  55. package/dist/apollo-core/p-8b6633c7.js +0 -1
  56. package/dist/apollo-core/p-97cd1f73.entry.js +0 -1
  57. package/dist/apollo-core/p-9c5ca308.entry.js +0 -1
  58. package/dist/apollo-core/p-ad90fe4d.js +0 -1
  59. package/dist/apollo-core/p-bd4a7e3c.entry.js +0 -1
  60. package/dist/apollo-core/p-dab8e7a1.entry.js +0 -1
  61. package/dist/apollo-core/p-eb63b401.entry.js +0 -1
  62. package/dist/apollo-core/p-ee2f4422.entry.js +0 -1
  63. package/dist/apollo-core/p-f167aa05.entry.js +0 -1
  64. package/dist/cjs/apollo-core.cjs.js +0 -19
  65. package/dist/cjs/index-944adb2e.js +0 -1609
  66. package/dist/cjs/index.cjs.js +0 -2
  67. package/dist/cjs/loader.cjs.js +0 -21
  68. package/dist/cjs/v4-14140ff3.js +0 -77
  69. package/dist/cjs/xpl-application-shell_11.cjs.entry.js +0 -230
  70. package/dist/cjs/xpl-badge.cjs.entry.js +0 -21
  71. package/dist/cjs/xpl-button-row.cjs.entry.js +0 -24
  72. package/dist/cjs/xpl-checkbox_2.cjs.entry.js +0 -51
  73. package/dist/cjs/xpl-choicelist.cjs.entry.js +0 -36
  74. package/dist/cjs/xpl-divider.cjs.entry.js +0 -18
  75. package/dist/cjs/xpl-grid-item.cjs.entry.js +0 -25
  76. package/dist/cjs/xpl-grid.cjs.entry.js +0 -35
  77. package/dist/cjs/xpl-input.cjs.entry.js +0 -2527
  78. package/dist/cjs/xpl-list.cjs.entry.js +0 -63
  79. package/dist/cjs/xpl-pagination.cjs.entry.js +0 -76
  80. package/dist/cjs/xpl-select.cjs.entry.js +0 -623
  81. package/dist/cjs/xpl-table.cjs.entry.js +0 -89
  82. package/dist/cjs/xpl-tag.cjs.entry.js +0 -21
  83. package/dist/cjs/xpl-toggle.cjs.entry.js +0 -34
  84. package/dist/collection/collection-manifest.json +0 -37
  85. package/dist/collection/components/xpl-application-shell/xpl-application-shell.js +0 -143
  86. package/dist/collection/components/xpl-avatar/xpl-avatar.js +0 -158
  87. package/dist/collection/components/xpl-backdrop/xpl-backdrop.js +0 -41
  88. package/dist/collection/components/xpl-badge/xpl-badge.js +0 -50
  89. package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumbs/xpl-breadcrumbs.js +0 -15
  90. package/dist/collection/components/xpl-button/xpl-button.js +0 -214
  91. package/dist/collection/components/xpl-button-row/xpl-button-row.js +0 -119
  92. package/dist/collection/components/xpl-checkbox/xpl-checkbox.js +0 -185
  93. package/dist/collection/components/xpl-choicelist/xpl-choicelist.js +0 -143
  94. package/dist/collection/components/xpl-content-area/xpl-content-area.js +0 -39
  95. package/dist/collection/components/xpl-divider/xpl-divider.js +0 -30
  96. package/dist/collection/components/xpl-dropdown/xpl-dropdown.js +0 -32
  97. package/dist/collection/components/xpl-grid/xpl-grid.js +0 -26
  98. package/dist/collection/components/xpl-grid-item/xpl-grid-item.js +0 -93
  99. package/dist/collection/components/xpl-input/xpl-input.js +0 -471
  100. package/dist/collection/components/xpl-list/xpl-list.js +0 -93
  101. package/dist/collection/components/xpl-main-nav/xpl-main-nav.js +0 -72
  102. package/dist/collection/components/xpl-nav-item/xpl-nav-item.js +0 -10
  103. package/dist/collection/components/xpl-pagination/xpl-pagination.js +0 -189
  104. package/dist/collection/components/xpl-radio/xpl-radio.js +0 -168
  105. package/dist/collection/components/xpl-secondary-nav/xpl-secondary-nav.js +0 -9
  106. package/dist/collection/components/xpl-select/xpl-select.js +0 -311
  107. package/dist/collection/components/xpl-table/xpl-table.js +0 -194
  108. package/dist/collection/components/xpl-tag/xpl-tag.js +0 -30
  109. package/dist/collection/components/xpl-toggle/xpl-toggle.js +0 -157
  110. package/dist/collection/components/xpl-utility-bar/xpl-utility-bar.js +0 -70
  111. package/dist/custom-elements/index.js +0 -19959
  112. package/dist/esm/apollo-core.js +0 -17
  113. package/dist/esm/index-899dba3b.js +0 -1580
  114. package/dist/esm/index.js +0 -1
  115. package/dist/esm/loader.js +0 -17
  116. package/dist/esm/polyfills/core-js.js +0 -11
  117. package/dist/esm/polyfills/css-shim.js +0 -1
  118. package/dist/esm/polyfills/dom.js +0 -79
  119. package/dist/esm/polyfills/es5-html-element.js +0 -1
  120. package/dist/esm/polyfills/index.js +0 -34
  121. package/dist/esm/polyfills/system.js +0 -6
  122. package/dist/esm/regular-86225e9d.js +0 -16041
  123. package/dist/esm/v4-929670b7.js +0 -75
  124. package/dist/esm/xpl-application-shell_11.entry.js +0 -216
  125. package/dist/esm/xpl-checkbox_2.entry.js +0 -46
  126. package/dist/index.cjs.js +0 -1
  127. package/dist/index.js +0 -1
  128. package/dist/stories/application-shell.stories.js +0 -766
  129. package/dist/stories/avatar.stories.js +0 -173
  130. package/dist/stories/backdrop.stories.js +0 -18
  131. package/dist/stories/badge.stories.js +0 -48
  132. package/dist/stories/breadcrumbs.stories.js +0 -115
  133. package/dist/stories/button-row.stories.js +0 -64
  134. package/dist/stories/button.stories.js +0 -98
  135. package/dist/stories/checkbox.stories.js +0 -76
  136. package/dist/stories/choicelist.stories.js +0 -112
  137. package/dist/stories/content-area.stories.js +0 -53
  138. package/dist/stories/divider.stories.js +0 -34
  139. package/dist/stories/grid.stories.js +0 -100
  140. package/dist/stories/input.stories.js +0 -252
  141. package/dist/stories/list.stories.js +0 -134
  142. package/dist/stories/main-nav.stories.js +0 -308
  143. package/dist/stories/pagination.stories.js +0 -84
  144. package/dist/stories/radio.stories.js +0 -66
  145. package/dist/stories/secondary-nav.stories.js +0 -76
  146. package/dist/stories/select.stories.js +0 -111
  147. package/dist/stories/table.stories.js +0 -107
  148. package/dist/stories/tabs.stories.js +0 -24
  149. package/dist/stories/toggle.stories.js +0 -80
  150. package/dist/stories/utility-bar.stories.js +0 -94
  151. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/application-shell.stories.d.ts +0 -0
  152. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/avatar.stories.d.ts +0 -0
  153. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/backdrop.stories.d.ts +0 -0
  154. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/badge.stories.d.ts +0 -0
  155. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/breadcrumbs.stories.d.ts +0 -0
  156. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/button-row.stories.d.ts +0 -0
  157. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/button.stories.d.ts +0 -0
  158. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/checkbox.stories.d.ts +0 -0
  159. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/choicelist.stories.d.ts +0 -0
  160. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/content-area.stories.d.ts +0 -0
  161. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/divider.stories.d.ts +0 -0
  162. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/grid.stories.d.ts +0 -0
  163. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/input.stories.d.ts +0 -0
  164. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/list.stories.d.ts +0 -0
  165. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/main-nav.stories.d.ts +0 -0
  166. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/pagination.stories.d.ts +0 -0
  167. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/radio.stories.d.ts +0 -0
  168. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/secondary-nav.stories.d.ts +0 -0
  169. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/select.stories.d.ts +0 -0
  170. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/table.stories.d.ts +0 -0
  171. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/tabs.stories.d.ts +0 -0
  172. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/toggle.stories.d.ts +0 -0
  173. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/utility-bar.stories.d.ts +0 -0
@@ -1,311 +0,0 @@
1
- /// <reference path="../xpl-dropdown/dropdownchoice.d.ts"></reference>
2
- import { v4 as uuid } from "uuid";
3
- import { Component, Host, h, Prop, State } from "@stencil/core";
4
- import { XplDropdown } from "../xpl-dropdown/xpl-dropdown";
5
- import throttle from "lodash.throttle";
6
- function tagWidth(text) {
7
- const context = document.createElement("canvas").getContext("2d");
8
- context.font = "14px apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
9
- return context.measureText(text).width + 44; // = text + l/r padding + margin-right
10
- }
11
- export class XplSelect {
12
- constructor() {
13
- /**
14
- * An array of choices for the user to choose from.
15
- * Each choice should be of the form:
16
- * {
17
- * label: string;
18
- * href?: string;
19
- * value?: string;
20
- * isGroupHeading?: boolean;
21
- * }
22
- */
23
- this.choices = [];
24
- /**
25
- * Whether to allow a single choice or multiple choices.
26
- */
27
- this.mode = "single";
28
- /**
29
- * Only used in multi-choice selects. If `true`,
30
- * badges representing selections that would overflow the
31
- * container are replaced with "+x more" (where x is the
32
- * number not shown). If `false`, the container's height will
33
- * adjust to show all badges representing selections.
34
- */
35
- this.truncate = true;
36
- this.active = false;
37
- this.id = uuid();
38
- this.keepFocus = false;
39
- this.value = "";
40
- // infinity isn't real, it's just a mathematical construct, it can't hurt you
41
- this.visibleChoices = Infinity;
42
- }
43
- componentWillLoad() {
44
- this.selected = this.choices && this.choices.length > 0 ? this.choices.map(() => false) : [];
45
- window.addEventListener("click", (e) => {
46
- const el = e.target;
47
- const select = el.closest(".xpl-select");
48
- if (select === null || select !== this.container) {
49
- this.active = false;
50
- }
51
- });
52
- window.addEventListener("resize", throttle(() => {
53
- this.maybeTruncateChoices();
54
- }, 250));
55
- }
56
- maybeTruncateChoices() {
57
- if (this.mode === "single" || !this.truncate)
58
- return;
59
- const containerWidth = this.container.getBoundingClientRect().width;
60
- let visibleChoices = 0;
61
- let visibleChoicesWidth = 0;
62
- const actualNumSelected = this.selected.filter(a => a).length;
63
- for (let i = 0; i < actualNumSelected; i++) {
64
- visibleChoicesWidth += tagWidth(this.getDisplayValue(i));
65
- if (visibleChoicesWidth > containerWidth - 140)
66
- break;
67
- visibleChoices++;
68
- }
69
- if (visibleChoices >= actualNumSelected)
70
- visibleChoices = Infinity;
71
- if (visibleChoices < 1)
72
- visibleChoices = 1;
73
- this.visibleChoices = visibleChoices;
74
- }
75
- getDisplayValue(i) {
76
- return this.choices[i].label;
77
- }
78
- getActualValue(i) {
79
- return this.choices[i].value || this.choices[i].label;
80
- }
81
- update(selected) {
82
- this.selected = selected;
83
- if (this.mode === "single") {
84
- const selected = this.selected.findIndex(v => v);
85
- this.value = selected >= 0 ?
86
- this.getActualValue(selected) :
87
- "";
88
- }
89
- else if (this.mode === "multi") {
90
- this.value = this.selected.map((v, i) => {
91
- return v ? this.getActualValue(i) : "";
92
- }).filter(v => v.length > 0).join("|");
93
- }
94
- }
95
- render() {
96
- let visibleChoices = 0;
97
- return (h(Host, { class: {
98
- "xpl-select": true,
99
- "xpl-select--disabled": this.disabled,
100
- "xpl-select--no-truncate": !this.truncate,
101
- }, onKeyDown: (e) => {
102
- if (e.key === "Escape")
103
- this.active = false;
104
- }, ref: (el) => (this.container = el) },
105
- this.label || this.description ? (h("label", { class: {
106
- "xpl-label": true,
107
- "xpl-label--disabled": this.disabled,
108
- }, htmlFor: this.id },
109
- this.label,
110
- this.description && h("small", { class: {
111
- "xpl-description": true,
112
- "xpl-description--disabled": this.disabled,
113
- } }, this.description))) : null,
114
- h("div", { class: {
115
- "xpl-input": true,
116
- "xpl-input--disabled": this.disabled,
117
- "xpl-input--error": this.error !== undefined
118
- } },
119
- h("div", { class: "xpl-input-wrapper" },
120
- h("div", { class: {
121
- "xpl-select-value": true,
122
- "xpl-select-value--active": this.mode === "multi" && this.value.length > 0,
123
- "has-value": this.value.length > 0,
124
- } },
125
- this.mode === "single" ?
126
- (this.value || this.placeholder) :
127
- (this.value.length > 0 ?
128
- this.selected.map((v, i) => {
129
- if (!v)
130
- return null;
131
- if (visibleChoices >= this.visibleChoices)
132
- return null;
133
- visibleChoices++;
134
- return (h("xpl-tag", { onClose: () => {
135
- this.selected = this.selected.map((v, j) => i === j ? false : v);
136
- this.update(this.selected);
137
- this.maybeTruncateChoices();
138
- } }, this.getDisplayValue(i)));
139
- }) :
140
- this.placeholder),
141
- this.visibleChoices < Infinity && `+ ${this.selected.filter(a => a).length - this.visibleChoices} more`),
142
- h("button", { disabled: this.disabled, id: this.id, onKeyDown: (e) => {
143
- if (e.key === "Tab")
144
- this.keepFocus = true;
145
- }, onClick: () => {
146
- if (!this.disabled)
147
- this.active = !this.active;
148
- } })),
149
- !this.disabled && (h(XplDropdown, { active: this.active, choices: this.choices, mode: this.mode, selected: this.selected, update: (selected) => {
150
- this.update(selected);
151
- this.maybeTruncateChoices();
152
- } })),
153
- this.error !== undefined && this.error.length > 0 && h("label", { class: "xpl-input-error", htmlFor: this.id },
154
- h("svg", { width: "10", height: "11", viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
155
- 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)),
157
- h("input", { type: "hidden", value: this.value })));
158
- }
159
- static get is() { return "xpl-select"; }
160
- static get properties() { return {
161
- "choices": {
162
- "type": "unknown",
163
- "mutable": false,
164
- "complexType": {
165
- "original": "DropdownChoice[]",
166
- "resolved": "DropdownChoice[]",
167
- "references": {
168
- "DropdownChoice": {
169
- "location": "global"
170
- }
171
- }
172
- },
173
- "required": false,
174
- "optional": true,
175
- "docs": {
176
- "tags": [],
177
- "text": "An array of choices for the user to choose from.\nEach choice should be of the form:\n{\n label: string;\n href?: string;\n value?: string;\n isGroupHeading?: boolean;\n}"
178
- },
179
- "defaultValue": "[]"
180
- },
181
- "description": {
182
- "type": "string",
183
- "mutable": false,
184
- "complexType": {
185
- "original": "string",
186
- "resolved": "string",
187
- "references": {}
188
- },
189
- "required": false,
190
- "optional": true,
191
- "docs": {
192
- "tags": [],
193
- "text": "Optional text that appears below the input label."
194
- },
195
- "attribute": "description",
196
- "reflect": false
197
- },
198
- "disabled": {
199
- "type": "boolean",
200
- "mutable": false,
201
- "complexType": {
202
- "original": "boolean",
203
- "resolved": "boolean",
204
- "references": {}
205
- },
206
- "required": false,
207
- "optional": true,
208
- "docs": {
209
- "tags": [],
210
- "text": ""
211
- },
212
- "attribute": "disabled",
213
- "reflect": false
214
- },
215
- "error": {
216
- "type": "string",
217
- "mutable": false,
218
- "complexType": {
219
- "original": "string",
220
- "resolved": "string",
221
- "references": {}
222
- },
223
- "required": false,
224
- "optional": true,
225
- "docs": {
226
- "tags": [],
227
- "text": "If an empty string (attribute present with no value),\nwill display visually as an error. If a string is\nincluded, will display visually as an error and include\nthe value as an error message."
228
- },
229
- "attribute": "error",
230
- "reflect": false
231
- },
232
- "label": {
233
- "type": "string",
234
- "mutable": false,
235
- "complexType": {
236
- "original": "string",
237
- "resolved": "string",
238
- "references": {}
239
- },
240
- "required": false,
241
- "optional": true,
242
- "docs": {
243
- "tags": [],
244
- "text": ""
245
- },
246
- "attribute": "label",
247
- "reflect": false
248
- },
249
- "mode": {
250
- "type": "string",
251
- "mutable": false,
252
- "complexType": {
253
- "original": "\"single\" | \"multi\"",
254
- "resolved": "\"multi\" | \"single\"",
255
- "references": {}
256
- },
257
- "required": false,
258
- "optional": true,
259
- "docs": {
260
- "tags": [],
261
- "text": "Whether to allow a single choice or multiple choices."
262
- },
263
- "attribute": "mode",
264
- "reflect": false,
265
- "defaultValue": "\"single\""
266
- },
267
- "placeholder": {
268
- "type": "string",
269
- "mutable": false,
270
- "complexType": {
271
- "original": "string",
272
- "resolved": "string",
273
- "references": {}
274
- },
275
- "required": false,
276
- "optional": false,
277
- "docs": {
278
- "tags": [],
279
- "text": ""
280
- },
281
- "attribute": "placeholder",
282
- "reflect": false
283
- },
284
- "truncate": {
285
- "type": "boolean",
286
- "mutable": false,
287
- "complexType": {
288
- "original": "boolean",
289
- "resolved": "boolean",
290
- "references": {}
291
- },
292
- "required": false,
293
- "optional": true,
294
- "docs": {
295
- "tags": [],
296
- "text": "Only used in multi-choice selects. If `true`,\nbadges representing selections that would overflow the\ncontainer are replaced with \"+x more\" (where x is the\nnumber not shown). If `false`, the container's height will\nadjust to show all badges representing selections."
297
- },
298
- "attribute": "truncate",
299
- "reflect": false,
300
- "defaultValue": "true"
301
- }
302
- }; }
303
- static get states() { return {
304
- "active": {},
305
- "id": {},
306
- "keepFocus": {},
307
- "selected": {},
308
- "value": {},
309
- "visibleChoices": {}
310
- }; }
311
- }
@@ -1,194 +0,0 @@
1
- import { Component, Host, Prop, State, Event, h, } from "@stencil/core";
2
- export class XplTable {
3
- constructor() {
4
- this.areAllSelected = false;
5
- this.hasScrolled = false;
6
- this.selectAll = (e) => {
7
- const { target } = e;
8
- if (!(target instanceof HTMLInputElement))
9
- return;
10
- const { checked } = target;
11
- this.areAllSelected = checked;
12
- this.selected = this.selected.map(() => checked);
13
- this.onChange();
14
- };
15
- this.selectOne = (e, i) => {
16
- const { target } = e;
17
- if (!(target instanceof HTMLInputElement))
18
- return;
19
- const { checked } = target;
20
- this.areAllSelected = false;
21
- this.selected = this.selected.map((v, _i) => (_i === i ? checked : v));
22
- this.onChange();
23
- };
24
- this.onChange = () => {
25
- this.tableSelect.emit({
26
- selected: this.selected,
27
- areAllSelected: this.areAllSelected,
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
- };
50
- }
51
- componentWillLoad() {
52
- this.areAllSelected = false;
53
- this.rowData = this.data !== undefined ? Array.from(this.data) : [];
54
- this.selected = new Array(this.rowData.length).fill(false);
55
- }
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";
64
- return (h(Host, null,
65
- h("div", { class: "xpl-table-container", onScroll: this.onScroll, ref: (el) => (this.container = el) },
66
- h("table", { class: className },
67
- this.columns && (h("thead", null, this.columns.map((column, i) => {
68
- return (h("th", null, this.multiselect && i === 0 ? (h("label", { htmlFor: "__xpl-table-th" },
69
- h("input", { checked: this.areAllSelected, id: "__xpl-table-th",
70
- // appear indeterminate when at least one but not all
71
- // are selected
72
- indeterminate: !this.areAllSelected &&
73
- this.selected.some((a) => a), onChange: (e) => {
74
- this.selectAll(e);
75
- }, type: "checkbox" }),
76
- column)) : (column)));
77
- }))),
78
- h("tbody", null, this.rowData.map((row, rowNum) => {
79
- return (h("tr", { class: this.selected && this.selected[rowNum]
80
- ? "xpl-table-row-selected"
81
- : "" }, row.map((cell, i) => {
82
- return (h("td", null, this.multiselect && i === 0 ? (h("label", { htmlFor: "__xpl-table-row-" + rowNum },
83
- h("input", { id: "__xpl-table-row-" + rowNum, checked: this.selected[rowNum], type: "checkbox", onChange: (e) => this.selectOne(e, rowNum) }),
84
- h("div", { innerHTML: cell }))) : (h("div", { innerHTML: cell }))));
85
- })));
86
- }))))));
87
- }
88
- static get is() { return "xpl-table"; }
89
- static get properties() { return {
90
- "columns": {
91
- "type": "unknown",
92
- "mutable": false,
93
- "complexType": {
94
- "original": "string[]",
95
- "resolved": "string[]",
96
- "references": {}
97
- },
98
- "required": false,
99
- "optional": true,
100
- "docs": {
101
- "tags": [],
102
- "text": ""
103
- }
104
- },
105
- "data": {
106
- "type": "unknown",
107
- "mutable": false,
108
- "complexType": {
109
- "original": "string[][]",
110
- "resolved": "string[][]",
111
- "references": {}
112
- },
113
- "required": false,
114
- "optional": true,
115
- "docs": {
116
- "tags": [],
117
- "text": ""
118
- }
119
- },
120
- "freeze": {
121
- "type": "boolean",
122
- "mutable": false,
123
- "complexType": {
124
- "original": "boolean",
125
- "resolved": "boolean",
126
- "references": {}
127
- },
128
- "required": false,
129
- "optional": true,
130
- "docs": {
131
- "tags": [],
132
- "text": ""
133
- },
134
- "attribute": "freeze",
135
- "reflect": false
136
- },
137
- "multiselect": {
138
- "type": "boolean",
139
- "mutable": false,
140
- "complexType": {
141
- "original": "boolean",
142
- "resolved": "boolean",
143
- "references": {}
144
- },
145
- "required": false,
146
- "optional": true,
147
- "docs": {
148
- "tags": [],
149
- "text": ""
150
- },
151
- "attribute": "multiselect",
152
- "reflect": false
153
- },
154
- "striped": {
155
- "type": "boolean",
156
- "mutable": false,
157
- "complexType": {
158
- "original": "boolean",
159
- "resolved": "boolean",
160
- "references": {}
161
- },
162
- "required": false,
163
- "optional": true,
164
- "docs": {
165
- "tags": [],
166
- "text": ""
167
- },
168
- "attribute": "striped",
169
- "reflect": false
170
- }
171
- }; }
172
- static get states() { return {
173
- "areAllSelected": {},
174
- "rowData": {},
175
- "hasScrolled": {},
176
- "selected": {}
177
- }; }
178
- static get events() { return [{
179
- "method": "tableSelect",
180
- "name": "tableSelect",
181
- "bubbles": true,
182
- "cancelable": true,
183
- "composed": true,
184
- "docs": {
185
- "tags": [],
186
- "text": ""
187
- },
188
- "complexType": {
189
- "original": "any",
190
- "resolved": "any",
191
- "references": {}
192
- }
193
- }]; }
194
- }
@@ -1,30 +0,0 @@
1
- import { Component, Host, h, Event } from '@stencil/core';
2
- export class XplTag {
3
- render() {
4
- return (h(Host, { class: "xpl-tag-container" },
5
- h("button", { class: "xpl-tag", onClick: () => {
6
- this.close.emit();
7
- } },
8
- h("slot", null)),
9
- h("button", { class: "xpl-tag__close", onClick: () => {
10
- this.close.emit();
11
- } }, "\u00D7")));
12
- }
13
- static get is() { return "xpl-tag"; }
14
- static get events() { return [{
15
- "method": "close",
16
- "name": "close",
17
- "bubbles": true,
18
- "cancelable": true,
19
- "composed": true,
20
- "docs": {
21
- "tags": [],
22
- "text": ""
23
- },
24
- "complexType": {
25
- "original": "any",
26
- "resolved": "any",
27
- "references": {}
28
- }
29
- }]; }
30
- }
@@ -1,157 +0,0 @@
1
- import { Component, Host, h, Prop, State } from "@stencil/core";
2
- import { v4 as uuid } from "uuid";
3
- export class XplToggle {
4
- constructor() {
5
- /**
6
- * The size of the toggle -- `default` or `small`
7
- */
8
- this.variant = "default";
9
- this.id = uuid();
10
- }
11
- render() {
12
- let containerClassName = "xpl-toggle-container";
13
- if (this.disabled)
14
- containerClassName += " xpl-toggle-container--disabled";
15
- let className = "xpl-toggle";
16
- if (this.variant === "small")
17
- className += " xpl-toggle--small";
18
- return (h(Host, { class: containerClassName },
19
- (this.heading || this.description) && (h("label", { class: {
20
- "xpl-label": true,
21
- "xpl-label--disabled": this.disabled
22
- }, htmlFor: this.id },
23
- this.heading,
24
- this.description && h("small", { class: {
25
- "xpl-description": true,
26
- "xpl-description--disabled": this.disabled
27
- } }, this.description))),
28
- h("input", { class: className, type: "checkbox", checked: this.checked, disabled: this.disabled, id: this.id, name: this.name }),
29
- this.label && h("label", { htmlFor: this.id }, this.label)));
30
- }
31
- static get is() { return "xpl-toggle"; }
32
- static get properties() { return {
33
- "checked": {
34
- "type": "boolean",
35
- "mutable": false,
36
- "complexType": {
37
- "original": "boolean",
38
- "resolved": "boolean",
39
- "references": {}
40
- },
41
- "required": false,
42
- "optional": true,
43
- "docs": {
44
- "tags": [],
45
- "text": ""
46
- },
47
- "attribute": "checked",
48
- "reflect": false
49
- },
50
- "description": {
51
- "type": "string",
52
- "mutable": false,
53
- "complexType": {
54
- "original": "string",
55
- "resolved": "string",
56
- "references": {}
57
- },
58
- "required": false,
59
- "optional": true,
60
- "docs": {
61
- "tags": [],
62
- "text": "The toggle's description appears *above* the toggle."
63
- },
64
- "attribute": "description",
65
- "reflect": false
66
- },
67
- "disabled": {
68
- "type": "boolean",
69
- "mutable": false,
70
- "complexType": {
71
- "original": "boolean",
72
- "resolved": "boolean",
73
- "references": {}
74
- },
75
- "required": false,
76
- "optional": true,
77
- "docs": {
78
- "tags": [],
79
- "text": ""
80
- },
81
- "attribute": "disabled",
82
- "reflect": false
83
- },
84
- "heading": {
85
- "type": "string",
86
- "mutable": false,
87
- "complexType": {
88
- "original": "string",
89
- "resolved": "string",
90
- "references": {}
91
- },
92
- "required": false,
93
- "optional": true,
94
- "docs": {
95
- "tags": [],
96
- "text": "The toggle's heading appears *above* the toggle."
97
- },
98
- "attribute": "heading",
99
- "reflect": false
100
- },
101
- "label": {
102
- "type": "string",
103
- "mutable": false,
104
- "complexType": {
105
- "original": "string",
106
- "resolved": "string",
107
- "references": {}
108
- },
109
- "required": false,
110
- "optional": true,
111
- "docs": {
112
- "tags": [],
113
- "text": "The toggle's label appears *to the right of* the toggle."
114
- },
115
- "attribute": "label",
116
- "reflect": false
117
- },
118
- "name": {
119
- "type": "string",
120
- "mutable": false,
121
- "complexType": {
122
- "original": "string",
123
- "resolved": "string",
124
- "references": {}
125
- },
126
- "required": false,
127
- "optional": true,
128
- "docs": {
129
- "tags": [],
130
- "text": ""
131
- },
132
- "attribute": "name",
133
- "reflect": false
134
- },
135
- "variant": {
136
- "type": "string",
137
- "mutable": false,
138
- "complexType": {
139
- "original": "\"default\" | \"small\"",
140
- "resolved": "\"default\" | \"small\"",
141
- "references": {}
142
- },
143
- "required": false,
144
- "optional": true,
145
- "docs": {
146
- "tags": [],
147
- "text": "The size of the toggle -- `default` or `small`"
148
- },
149
- "attribute": "variant",
150
- "reflect": false,
151
- "defaultValue": "\"default\""
152
- }
153
- }; }
154
- static get states() { return {
155
- "id": {}
156
- }; }
157
- }