@xplortech/apollo-core 0.4.1 → 0.5.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.
Files changed (186) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/style.css +291 -104
  3. package/dist/apollo-core/apollo-core.css +5509 -7
  4. package/dist/apollo-core/apollo-core.esm.js +125 -1
  5. package/dist/apollo-core/app-globals-0f993ce5.js +3 -0
  6. package/dist/apollo-core/css-shim-bbdf0cc6.js +4 -0
  7. package/dist/apollo-core/dom-1f98a75f.js +73 -0
  8. package/dist/apollo-core/index-3c9f25ef.js +2938 -0
  9. package/dist/apollo-core/index-3eb5568f.js +2938 -0
  10. package/dist/apollo-core/index-912d1a21.js +584 -0
  11. package/dist/apollo-core/index.esm.js +1 -0
  12. package/dist/{cjs/regular-872f5226.js → apollo-core/regular-133c23b5.js} +12 -3
  13. package/dist/apollo-core/shadow-css-67b66845.js +389 -0
  14. package/dist/apollo-core/xpl-application-shell.entry.js +52 -0
  15. package/dist/apollo-core/xpl-avatar.entry.js +19 -0
  16. package/dist/apollo-core/xpl-backdrop.entry.js +21 -0
  17. package/dist/apollo-core/xpl-badge.entry.js +17 -0
  18. package/dist/{collection/components/xpl-breadcrumbs/xpl-breadcrumb-item/xpl-breadcrumb-item.js → apollo-core/xpl-breadcrumb-item.entry.js} +9 -12
  19. package/dist/apollo-core/xpl-breadcrumbs.entry.js +14 -0
  20. package/dist/{esm → apollo-core}/xpl-button-row.entry.js +1 -1
  21. package/dist/apollo-core/xpl-button.entry.js +34 -0
  22. package/dist/apollo-core/xpl-checkbox.entry.js +25 -0
  23. package/dist/{esm → apollo-core}/xpl-choicelist.entry.js +1 -1
  24. package/dist/apollo-core/xpl-content-area.entry.js +16 -0
  25. package/dist/{esm → apollo-core}/xpl-divider.entry.js +1 -1
  26. package/dist/{esm → apollo-core}/xpl-grid-item.entry.js +1 -1
  27. package/dist/{esm → apollo-core}/xpl-grid.entry.js +1 -1
  28. package/dist/{esm → apollo-core}/xpl-input.entry.js +20 -3
  29. package/dist/{esm → apollo-core}/xpl-list.entry.js +2 -2
  30. package/dist/apollo-core/xpl-main-nav.entry.js +26 -0
  31. package/dist/apollo-core/xpl-nav-item.entry.js +12 -0
  32. package/dist/{esm → apollo-core}/xpl-pagination.entry.js +1 -1
  33. package/dist/apollo-core/xpl-radio.entry.js +25 -0
  34. package/dist/apollo-core/xpl-secondary-nav.entry.js +12 -0
  35. package/dist/{esm → apollo-core}/xpl-select.entry.js +43 -2
  36. package/dist/apollo-core/xpl-table.entry.js +85 -0
  37. package/dist/{esm → apollo-core}/xpl-tag.entry.js +1 -1
  38. package/dist/{esm → apollo-core}/xpl-toggle.entry.js +2 -2
  39. package/dist/apollo-core/xpl-utility-bar.entry.js +25 -0
  40. package/dist/custom-elements/index.d.ts +6 -0
  41. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/application-shell.stories.d.ts +62 -0
  42. package/dist/types/components/xpl-application-shell/test/xpl-application-shell.e2e.d.ts +1 -0
  43. package/dist/types/components/xpl-application-shell/xpl-application-shell.d.ts +24 -0
  44. package/dist/types/components/xpl-avatar/test/xpl-avatar.e2e.d.ts +1 -0
  45. package/dist/types/components/xpl-avatar/test/xpl-avatar.spec.d.ts +1 -0
  46. package/dist/types/components/xpl-backdrop/test/xpl-backdrop.e2e.d.ts +1 -0
  47. package/dist/types/components/xpl-backdrop/xpl-backdrop.d.ts +5 -0
  48. package/dist/types/components/xpl-badge/test/xpl-badge.e2e.d.ts +1 -0
  49. package/dist/types/components/xpl-badge/test/xpl-badge.spec.d.ts +1 -0
  50. package/dist/types/components/xpl-breadcrumbs/xpl-breadcrumb-item/test/xpl-breadcrumb-item.e2e.d.ts +1 -0
  51. package/dist/types/components/xpl-breadcrumbs/xpl-breadcrumbs/test/xpl-breadcrumbs.e2e.d.ts +1 -0
  52. package/dist/types/components/xpl-button/test/xpl-button.e2e.d.ts +1 -0
  53. package/dist/types/components/xpl-button/test/xpl-button.spec.d.ts +1 -0
  54. package/dist/types/components/xpl-button-row/test/xpl-button-row.e2e.d.ts +1 -0
  55. package/dist/types/components/xpl-button-row/test/xpl-button-row.spec.d.ts +1 -0
  56. package/dist/types/components/xpl-checkbox/test/xpl-checkbox.e2e.d.ts +1 -0
  57. package/dist/types/components/xpl-checkbox/test/xpl-checkbox.spec.d.ts +1 -0
  58. package/dist/types/components/xpl-choicelist/test/xpl-choicelist.e2e.d.ts +1 -0
  59. package/dist/types/components/xpl-choicelist/test/xpl-choicelist.spec.d.ts +1 -0
  60. package/dist/types/components/xpl-content-area/test/xpl-content-area.e2e.d.ts +1 -0
  61. package/dist/types/components/xpl-divider/test/xpl-divider.e2e.d.ts +1 -0
  62. package/dist/types/components/xpl-divider/test/xpl-divider.spec.d.ts +1 -0
  63. package/dist/types/components/xpl-grid/test/xpl-grid.e2e.d.ts +1 -0
  64. package/dist/types/components/xpl-grid/test/xpl-grid.spec.d.ts +1 -0
  65. package/dist/types/components/xpl-grid-item/test/xpl-grid-item.e2e.d.ts +1 -0
  66. package/dist/types/components/xpl-grid-item/test/xpl-grid-item.spec.d.ts +1 -0
  67. package/dist/types/components/xpl-input/test/xpl-input.e2e.d.ts +1 -0
  68. package/dist/types/components/xpl-input/test/xpl-input.spec.d.ts +1 -0
  69. package/dist/types/components/xpl-list/test/xpl-list.e2e.d.ts +1 -0
  70. package/dist/types/components/xpl-list/test/xpl-list.spec.d.ts +1 -0
  71. package/dist/types/components/xpl-main-nav/test/xpl-main-nav.e2e.d.ts +1 -0
  72. package/dist/types/components/xpl-main-nav/xpl-main-nav.d.ts +9 -0
  73. package/dist/types/components/xpl-nav-item/test/xpl-nav-item.e2e.d.ts +1 -0
  74. package/dist/types/components/xpl-pagination/test/xpl-pagination.e2e.d.ts +1 -0
  75. package/dist/types/components/xpl-pagination/test/xpl-pagination.spec.d.ts +1 -0
  76. package/dist/types/components/xpl-radio/test/xpl-radio.e2e.d.ts +1 -0
  77. package/dist/types/components/xpl-radio/test/xpl-radio.spec.d.ts +1 -0
  78. package/dist/types/components/xpl-secondary-nav/test/secondary-nav.e2e.d.ts +1 -0
  79. package/dist/types/components/xpl-select/test/xpl-select.e2e.d.ts +1 -0
  80. package/dist/types/components/xpl-select/test/xpl-select.spec.d.ts +1 -0
  81. package/dist/types/components/xpl-table/test/xpl-table.e2e.d.ts +1 -0
  82. package/dist/types/components/xpl-table/test/xpl-table.spec.d.ts +1 -0
  83. package/dist/types/components/xpl-tag/test/xpl-tag.e2e.d.ts +1 -0
  84. package/dist/types/components/xpl-tag/test/xpl-tag.spec.d.ts +1 -0
  85. package/dist/types/components/xpl-toggle/test/xpl-toggle.e2e.d.ts +1 -0
  86. package/dist/types/components/xpl-toggle/test/xpl-toggle.spec.d.ts +1 -0
  87. package/dist/types/components/xpl-utility-bar/test/xpl-utility-bar.e2e.d.ts +1 -0
  88. package/dist/types/components/xpl-utility-bar/xpl-utility-bar.d.ts +12 -0
  89. package/dist/types/components.d.ts +61 -0
  90. package/package.json +1 -1
  91. package/dist/apollo-core/p-0027c582.entry.js +0 -1
  92. package/dist/apollo-core/p-2c551f4d.entry.js +0 -1
  93. package/dist/apollo-core/p-2f90296c.js +0 -10
  94. package/dist/apollo-core/p-6081e432.entry.js +0 -1
  95. package/dist/apollo-core/p-612984e5.entry.js +0 -1
  96. package/dist/apollo-core/p-63ea199d.entry.js +0 -1
  97. package/dist/apollo-core/p-650f6416.entry.js +0 -1
  98. package/dist/apollo-core/p-6ad97405.entry.js +0 -1
  99. package/dist/apollo-core/p-9b9511e4.entry.js +0 -1
  100. package/dist/apollo-core/p-ad90fe4d.js +0 -1
  101. package/dist/apollo-core/p-c6fec744.entry.js +0 -1
  102. package/dist/apollo-core/p-ea8e0991.js +0 -1
  103. package/dist/apollo-core/p-ed04cedd.entry.js +0 -1
  104. package/dist/apollo-core/p-eec5a0f1.entry.js +0 -1
  105. package/dist/apollo-core/p-f4f646d9.entry.js +0 -1
  106. package/dist/cjs/apollo-core.cjs.js +0 -19
  107. package/dist/cjs/index-9662f096.js +0 -1541
  108. package/dist/cjs/index.cjs.js +0 -2
  109. package/dist/cjs/loader.cjs.js +0 -21
  110. package/dist/cjs/v4-14140ff3.js +0 -77
  111. package/dist/cjs/xpl-avatar_14.cjs.entry.js +0 -293
  112. package/dist/cjs/xpl-button-row.cjs.entry.js +0 -24
  113. package/dist/cjs/xpl-choicelist.cjs.entry.js +0 -36
  114. package/dist/cjs/xpl-divider.cjs.entry.js +0 -18
  115. package/dist/cjs/xpl-grid-item.cjs.entry.js +0 -25
  116. package/dist/cjs/xpl-grid.cjs.entry.js +0 -35
  117. package/dist/cjs/xpl-input.cjs.entry.js +0 -2527
  118. package/dist/cjs/xpl-list.cjs.entry.js +0 -63
  119. package/dist/cjs/xpl-pagination.cjs.entry.js +0 -76
  120. package/dist/cjs/xpl-select.cjs.entry.js +0 -623
  121. package/dist/cjs/xpl-tag.cjs.entry.js +0 -21
  122. package/dist/cjs/xpl-toggle.cjs.entry.js +0 -34
  123. package/dist/collection/collection-manifest.json +0 -36
  124. package/dist/collection/components/xpl-avatar/xpl-avatar.js +0 -158
  125. package/dist/collection/components/xpl-backdrop/xpl-backdrop.js +0 -7
  126. package/dist/collection/components/xpl-badge/xpl-badge.js +0 -50
  127. package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumbs/xpl-breadcrumbs.js +0 -15
  128. package/dist/collection/components/xpl-button/xpl-button.js +0 -214
  129. package/dist/collection/components/xpl-button-row/xpl-button-row.js +0 -119
  130. package/dist/collection/components/xpl-checkbox/xpl-checkbox.js +0 -185
  131. package/dist/collection/components/xpl-choicelist/xpl-choicelist.js +0 -143
  132. package/dist/collection/components/xpl-content-area/xpl-content-area.js +0 -39
  133. package/dist/collection/components/xpl-divider/xpl-divider.js +0 -30
  134. package/dist/collection/components/xpl-dropdown/xpl-dropdown.js +0 -32
  135. package/dist/collection/components/xpl-grid/xpl-grid.js +0 -26
  136. package/dist/collection/components/xpl-grid-item/xpl-grid-item.js +0 -93
  137. package/dist/collection/components/xpl-input/xpl-input.js +0 -471
  138. package/dist/collection/components/xpl-list/xpl-list.js +0 -93
  139. package/dist/collection/components/xpl-main-nav/xpl-main-nav.js +0 -43
  140. package/dist/collection/components/xpl-nav-item/xpl-nav-item.js +0 -10
  141. package/dist/collection/components/xpl-pagination/xpl-pagination.js +0 -189
  142. package/dist/collection/components/xpl-radio/xpl-radio.js +0 -168
  143. package/dist/collection/components/xpl-secondary-nav/xpl-secondary-nav.js +0 -9
  144. package/dist/collection/components/xpl-select/xpl-select.js +0 -311
  145. package/dist/collection/components/xpl-table/xpl-table.js +0 -194
  146. package/dist/collection/components/xpl-tag/xpl-tag.js +0 -30
  147. package/dist/collection/components/xpl-toggle/xpl-toggle.js +0 -157
  148. package/dist/collection/components/xpl-utility-bar/xpl-utility-bar.js +0 -10
  149. package/dist/custom-elements/index.js +0 -19877
  150. package/dist/esm/apollo-core.js +0 -17
  151. package/dist/esm/index-619763f9.js +0 -1512
  152. package/dist/esm/index.js +0 -1
  153. package/dist/esm/loader.js +0 -17
  154. package/dist/esm/polyfills/core-js.js +0 -11
  155. package/dist/esm/polyfills/css-shim.js +0 -1
  156. package/dist/esm/polyfills/dom.js +0 -79
  157. package/dist/esm/polyfills/es5-html-element.js +0 -1
  158. package/dist/esm/polyfills/index.js +0 -34
  159. package/dist/esm/polyfills/system.js +0 -6
  160. package/dist/esm/regular-86225e9d.js +0 -16041
  161. package/dist/esm/v4-929670b7.js +0 -75
  162. package/dist/esm/xpl-avatar_14.entry.js +0 -276
  163. package/dist/index.cjs.js +0 -1
  164. package/dist/index.js +0 -1
  165. package/dist/stories/avatar.stories.js +0 -173
  166. package/dist/stories/backdrop.stories.js +0 -18
  167. package/dist/stories/badge.stories.js +0 -48
  168. package/dist/stories/breadcrumbs.stories.js +0 -115
  169. package/dist/stories/button-row.stories.js +0 -64
  170. package/dist/stories/button.stories.js +0 -98
  171. package/dist/stories/checkbox.stories.js +0 -76
  172. package/dist/stories/choicelist.stories.js +0 -112
  173. package/dist/stories/content-area.stories.js +0 -53
  174. package/dist/stories/divider.stories.js +0 -34
  175. package/dist/stories/grid.stories.js +0 -100
  176. package/dist/stories/input.stories.js +0 -252
  177. package/dist/stories/list.stories.js +0 -134
  178. package/dist/stories/main-nav.stories.js +0 -308
  179. package/dist/stories/pagination.stories.js +0 -84
  180. package/dist/stories/radio.stories.js +0 -66
  181. package/dist/stories/secondary-nav.stories.js +0 -76
  182. package/dist/stories/select.stories.js +0 -111
  183. package/dist/stories/table.stories.js +0 -107
  184. package/dist/stories/tabs.stories.js +0 -24
  185. package/dist/stories/toggle.stories.js +0 -80
  186. package/dist/stories/utility-bar.stories.js +0 -94
@@ -1,189 +0,0 @@
1
- import { Component, Host, h, Event, Prop, State, Method, } from "@stencil/core";
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
- }
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);
57
- return (h(Host, null,
58
- h("div", { class: "xpl-pagination" },
59
- h("div", null,
60
- h("p", null,
61
- "Showing ",
62
- h("span", null, showingFirst),
63
- " to ",
64
- h("span", null, showingLast),
65
- " ",
66
- "of ",
67
- h("span", null, this.total),
68
- " results")),
69
- h("div", null,
70
- h("nav", { "aria-label": "Pagination" },
71
- h("button", { onClick: this.goPrev, class: "xpl-pagination-prev" },
72
- h("span", null, "Previous"),
73
- h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" },
74
- 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
- showing.map((n) => {
76
- if (n === "...") {
77
- return h("span", { class: "xpl-pagination-ellipsis" }, "...");
78
- }
79
- if (n === this.current) {
80
- return (h("button", { "aria-current": "page", class: "xpl-pagination-current" }, n));
81
- }
82
- return h("button", { onClick: () => this._goto(n) }, n);
83
- }),
84
- h("button", { onClick: this.goNext, class: "xpl-pagination-next" },
85
- h("span", null, "Next"),
86
- h("svg", { viewBox: "0 0 20 20", "aria-hidden": "true" },
87
- 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" }))))))));
88
- }
89
- static get is() { return "xpl-pagination"; }
90
- static get properties() { return {
91
- "total": {
92
- "type": "number",
93
- "mutable": false,
94
- "complexType": {
95
- "original": "number",
96
- "resolved": "number",
97
- "references": {}
98
- },
99
- "required": false,
100
- "optional": false,
101
- "docs": {
102
- "tags": [],
103
- "text": ""
104
- },
105
- "attribute": "total",
106
- "reflect": false
107
- },
108
- "perPage": {
109
- "type": "number",
110
- "mutable": false,
111
- "complexType": {
112
- "original": "number",
113
- "resolved": "number",
114
- "references": {}
115
- },
116
- "required": false,
117
- "optional": false,
118
- "docs": {
119
- "tags": [],
120
- "text": ""
121
- },
122
- "attribute": "per-page",
123
- "reflect": false
124
- },
125
- "waitForCallback": {
126
- "type": "boolean",
127
- "mutable": false,
128
- "complexType": {
129
- "original": "boolean",
130
- "resolved": "boolean",
131
- "references": {}
132
- },
133
- "required": false,
134
- "optional": false,
135
- "docs": {
136
- "tags": [],
137
- "text": ""
138
- },
139
- "attribute": "wait-for-callback",
140
- "reflect": false
141
- }
142
- }; }
143
- static get states() { return {
144
- "current": {}
145
- }; }
146
- static get events() { return [{
147
- "method": "page",
148
- "name": "page",
149
- "bubbles": true,
150
- "cancelable": true,
151
- "composed": true,
152
- "docs": {
153
- "tags": [],
154
- "text": ""
155
- },
156
- "complexType": {
157
- "original": "any",
158
- "resolved": "any",
159
- "references": {}
160
- }
161
- }]; }
162
- static get methods() { return {
163
- "goto": {
164
- "complexType": {
165
- "signature": "(n: number) => Promise<void>",
166
- "parameters": [{
167
- "tags": [{
168
- "text": "n",
169
- "name": "param"
170
- }],
171
- "text": ""
172
- }],
173
- "references": {
174
- "Promise": {
175
- "location": "global"
176
- }
177
- },
178
- "return": "Promise<void>"
179
- },
180
- "docs": {
181
- "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.",
182
- "tags": [{
183
- "name": "param",
184
- "text": "n"
185
- }]
186
- }
187
- }
188
- }; }
189
- }
@@ -1,168 +0,0 @@
1
- import { Component, Host, h, Prop, State, Event } from "@stencil/core";
2
- import { v4 as uuid } from "uuid";
3
- export class XplRadio {
4
- constructor() {
5
- this.id = uuid();
6
- }
7
- render() {
8
- return (h(Host, { class: {
9
- "xpl-checkbox-radio-container": true,
10
- "styled": this.styled,
11
- "disabled": this.disabled,
12
- } },
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
- h("label", { class: {
15
- "xpl-label": true,
16
- "xpl-label--disabled": this.disabled
17
- }, htmlFor: this.id },
18
- h("slot", null),
19
- this.description && h("small", { class: {
20
- "xpl-description": true,
21
- "xpl-description--disabled": this.disabled
22
- } }, this.description))));
23
- }
24
- static get is() { return "xpl-radio"; }
25
- static get properties() { return {
26
- "checked": {
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": ""
39
- },
40
- "attribute": "checked",
41
- "reflect": false
42
- },
43
- "description": {
44
- "type": "string",
45
- "mutable": false,
46
- "complexType": {
47
- "original": "string",
48
- "resolved": "string",
49
- "references": {}
50
- },
51
- "required": false,
52
- "optional": true,
53
- "docs": {
54
- "tags": [],
55
- "text": ""
56
- },
57
- "attribute": "description",
58
- "reflect": false
59
- },
60
- "disabled": {
61
- "type": "boolean",
62
- "mutable": false,
63
- "complexType": {
64
- "original": "boolean",
65
- "resolved": "boolean",
66
- "references": {}
67
- },
68
- "required": false,
69
- "optional": true,
70
- "docs": {
71
- "tags": [],
72
- "text": ""
73
- },
74
- "attribute": "disabled",
75
- "reflect": false
76
- },
77
- "name": {
78
- "type": "string",
79
- "mutable": false,
80
- "complexType": {
81
- "original": "string",
82
- "resolved": "string",
83
- "references": {}
84
- },
85
- "required": false,
86
- "optional": true,
87
- "docs": {
88
- "tags": [],
89
- "text": ""
90
- },
91
- "attribute": "name",
92
- "reflect": false
93
- },
94
- "required": {
95
- "type": "boolean",
96
- "mutable": false,
97
- "complexType": {
98
- "original": "boolean",
99
- "resolved": "boolean",
100
- "references": {}
101
- },
102
- "required": false,
103
- "optional": true,
104
- "docs": {
105
- "tags": [],
106
- "text": ""
107
- },
108
- "attribute": "required",
109
- "reflect": false
110
- },
111
- "styled": {
112
- "type": "boolean",
113
- "mutable": false,
114
- "complexType": {
115
- "original": "boolean",
116
- "resolved": "boolean",
117
- "references": {}
118
- },
119
- "required": false,
120
- "optional": true,
121
- "docs": {
122
- "tags": [],
123
- "text": ""
124
- },
125
- "attribute": "styled",
126
- "reflect": false
127
- },
128
- "value": {
129
- "type": "string",
130
- "mutable": false,
131
- "complexType": {
132
- "original": "string",
133
- "resolved": "string",
134
- "references": {}
135
- },
136
- "required": false,
137
- "optional": true,
138
- "docs": {
139
- "tags": [],
140
- "text": ""
141
- },
142
- "attribute": "value",
143
- "reflect": false
144
- }
145
- }; }
146
- static get states() { return {
147
- "id": {}
148
- }; }
149
- static get events() { return [{
150
- "method": "radioChange",
151
- "name": "radioChange",
152
- "bubbles": true,
153
- "cancelable": true,
154
- "composed": true,
155
- "docs": {
156
- "tags": [{
157
- "text": undefined,
158
- "name": "private"
159
- }],
160
- "text": ""
161
- },
162
- "complexType": {
163
- "original": "any",
164
- "resolved": "any",
165
- "references": {}
166
- }
167
- }]; }
168
- }
@@ -1,9 +0,0 @@
1
- import { Component, Host, h } from '@stencil/core';
2
- export class XplSecondaryNav {
3
- render() {
4
- return (h(Host, { class: "xpl-secondary-nav" },
5
- h("nav", { "aria-label": "Secondary Nav" },
6
- h("slot", null))));
7
- }
8
- static get is() { return "xpl-secondary-nav"; }
9
- }
@@ -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
- }