kemet-ui 0.2.0 → 1.0.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 (66) hide show
  1. package/custom-elements.json +5546 -855
  2. package/dist/components/kemet-accordion-panel.js +178 -0
  3. package/dist/components/kemet-accordion.js +105 -72
  4. package/dist/components/kemet-badge.js +102 -0
  5. package/dist/components/kemet-button.js +230 -0
  6. package/dist/components/kemet-checkbox.js +298 -0
  7. package/dist/components/kemet-combo.js +207 -0
  8. package/dist/components/kemet-count.js +112 -0
  9. package/dist/components/kemet-draggable.js +19 -6
  10. package/dist/components/kemet-drawer.js +38 -15
  11. package/dist/components/kemet-drawer.styles.js +6 -0
  12. package/dist/components/kemet-field.js +233 -0
  13. package/dist/components/kemet-flipcard-trigger.js +4 -5
  14. package/dist/components/kemet-flipcard.js +26 -3
  15. package/dist/components/kemet-icon.js +19 -3
  16. package/dist/components/kemet-input.js +650 -0
  17. package/dist/components/kemet-modal-close.js +23 -4
  18. package/dist/components/kemet-modal.js +78 -13
  19. package/dist/components/kemet-modal.styles.js +14 -2
  20. package/dist/components/kemet-option.js +45 -0
  21. package/dist/components/kemet-popover-close.js +1 -1
  22. package/dist/components/kemet-popover.js +75 -12
  23. package/dist/components/kemet-radio.js +214 -0
  24. package/dist/components/kemet-radios.js +218 -0
  25. package/dist/components/kemet-rotator.js +23 -4
  26. package/dist/components/kemet-scroll-link.js +21 -2
  27. package/dist/components/kemet-scroll-nav.js +25 -2
  28. package/dist/components/kemet-scroll-snap-paginator.js +68 -26
  29. package/dist/components/kemet-scroll-snap-slide.js +23 -13
  30. package/dist/components/kemet-scroll-snap.js +31 -16
  31. package/dist/components/kemet-select.js +365 -0
  32. package/dist/components/kemet-svg.js +18 -2
  33. package/dist/components/kemet-svgs.js +7 -3
  34. package/dist/components/kemet-tab-panel.js +15 -1
  35. package/dist/components/kemet-tab.js +48 -1
  36. package/dist/components/kemet-tabs.js +289 -83
  37. package/dist/components/kemet-tabs.styles.js +200 -0
  38. package/dist/components/kemet-textarea.js +395 -0
  39. package/dist/components/kemet-toggle.js +225 -0
  40. package/dist/kemet-components.cjs +5128 -1200
  41. package/dist/kemet-components.js +5117 -1173
  42. package/dist/kemet-components.min.js +1536 -421
  43. package/dist/styles/kemet.components.css +12 -260
  44. package/dist/styles/kemet.components.css.map +1 -1
  45. package/dist/styles/kemet.core.css +2371 -503
  46. package/dist/styles/kemet.core.css.map +1 -1
  47. package/dist/styles/scss/components/_config.scss +0 -25
  48. package/dist/styles/scss/components/accordion.scss +4 -53
  49. package/dist/styles/scss/components/modal.scss +5 -9
  50. package/dist/styles/scss/components/scrollsnap.scss +0 -57
  51. package/dist/styles/scss/core/_config.scss +160 -3
  52. package/dist/styles/scss/core/_helpers.scss +109 -2
  53. package/dist/styles/scss/core/attributes.scss +16 -0
  54. package/dist/styles/scss/core/base.scss +38 -0
  55. package/dist/styles/scss/core/layout.scss +6 -5
  56. package/dist/styles/scss/kemet.components.scss +0 -2
  57. package/dist/styles/scss/kemet.core.scss +1 -2
  58. package/package.json +34 -56
  59. package/dist/components/kemet-carousel-link.js +0 -54
  60. package/dist/components/kemet-carousel-next.js +0 -46
  61. package/dist/components/kemet-carousel-prev.js +0 -46
  62. package/dist/components/kemet-carousel-slide.js +0 -83
  63. package/dist/components/kemet-carousel.js +0 -236
  64. package/dist/components/kemet-ratio.js +0 -61
  65. package/dist/styles/scss/components/flipcard.scss +0 -14
  66. package/dist/styles/scss/components/tabs.scss +0 -73
@@ -0,0 +1,207 @@
1
+ import { html, css, LitElement } from 'lit';
2
+
3
+ export default class KemetCombo extends LitElement {
4
+ static get styles() {
5
+ return [
6
+ css`
7
+ :host {
8
+ opacity: 0;
9
+ width: var(--kemet-combo-width, calc(100% - 2px));
10
+ margin: var(--kemet-combo-margin, 1rem auto);
11
+ pointer-events: none;
12
+ display: block;
13
+ position: relative;
14
+ transition: opacity 0.3s ease-in-out;
15
+ }
16
+
17
+ :host([show]) {
18
+ opacity: 1;
19
+ pointer-events: auto;
20
+ }
21
+
22
+ ul {
23
+ width: 100%;
24
+ max-height: var(--kemet-combo-max-height, calc(5 * 3rem));
25
+ position: absolute;
26
+ z-index: 1;
27
+ list-style: none;
28
+ margin: 0;
29
+ padding: 0;
30
+ overflow-y: scroll;
31
+ border: var(--kemet-combo-border, 1px solid var(--kemet-color-primary));
32
+ border-radius: var(--kemet-combo-border-radius, var(--kemet-border-radius));
33
+ background-color: var(--kemet-combo-background-color, var(--kemet-color-white));
34
+ box-shadow: var(--kemet-combo-shadow, 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1));
35
+ }
36
+ li {
37
+ line-height: 3rem;
38
+ padding: 0 1.5rem;
39
+ cursor: pointer;
40
+ }
41
+ li:hover,
42
+ li:focus {
43
+ color: var(--kemet-combo-hover-color, var(--kemet-color-white));
44
+ outline: none;
45
+ background-color: var(--kemet-combo-hover-background-color, var(--kemet-color-primary));
46
+ }
47
+ `,
48
+ ];
49
+ }
50
+
51
+ static get properties() {
52
+ return {
53
+ /**
54
+ * Uniquely identifies the component. Should match the slug used in a control.
55
+ */
56
+ slug: {
57
+ type: String,
58
+ },
59
+ /**
60
+ * An array of items listed for the combo box
61
+ */
62
+ options: {
63
+ type: Array,
64
+ },
65
+ /**
66
+ * Used internally
67
+ */
68
+ filteredOptions: {
69
+ type: Array,
70
+ },
71
+ /**
72
+ * Controls the display of the combo box
73
+ */
74
+ show: {
75
+ type: Boolean,
76
+ reflect: true,
77
+ },
78
+ };
79
+ }
80
+
81
+ firstUpdated() {
82
+ // standard properties
83
+ this.field = this.closest('kemet-field');
84
+ this.input = this.field.querySelector('[slot="input"]');
85
+
86
+ // managed properties
87
+ this.slug = this.field.slug;
88
+
89
+ // events listeners
90
+ this.input.addEventListener('kemet-input-input', this.handleInput.bind(this));
91
+ this.input.addEventListener('keydown', event => this.handleInputKeyDown(event));
92
+ }
93
+
94
+ render() {
95
+ return html`
96
+ <div
97
+ role="combobox"
98
+ aria-expanded=${this.show}
99
+ aria-controls="${this.slug}-listbox"
100
+ aria-haspopup="listbox"
101
+ id="${this.slug}-combobox"
102
+ aria-label="${this.field.label}"
103
+ >
104
+ <ul role="listbox" aria-labelledby="${this.slug}-label" id="${this.slug}-listbox">
105
+ ${this.makeOptions()}
106
+ </ul>
107
+ </div>
108
+ `;
109
+ }
110
+
111
+ makeOptions() {
112
+ if (this.input) {
113
+ this.filteredOptions = this.options.filter(
114
+ option => option.toLowerCase().indexOf(this.input.value.toLowerCase()) !== -1,
115
+ );
116
+
117
+ const options = this.filteredOptions.map(
118
+ (option, index) => html`<li
119
+ id="${this.slug}-option-${index}"
120
+ role="option"
121
+ tabindex="0"
122
+ aria-selected="false"
123
+ @click=${event => this.handleSelection(event)}
124
+ @keydown=${event => this.handleOptionKeyDown(event)}
125
+ >
126
+ ${option}
127
+ </li>`,
128
+ );
129
+
130
+ return options;
131
+ }
132
+
133
+ return null;
134
+ }
135
+
136
+ handleInput(event) {
137
+ this.makeOptions();
138
+
139
+ if (event.detail.length > 0) {
140
+ this.show = true;
141
+ } else {
142
+ this.show = false;
143
+ }
144
+ }
145
+
146
+ handleSelection(event) {
147
+ this.input.value = event.target.innerText;
148
+ this.show = false;
149
+
150
+ /**
151
+ * Fires when a selection has been made
152
+ */
153
+ this.dispatchEvent(
154
+ new CustomEvent('kemet-combo-selection', {
155
+ bubbles: true,
156
+ composed: true,
157
+ detail: event.target.getAttribute('id'),
158
+ }),
159
+ );
160
+ }
161
+
162
+ handleOptionKeyDown(event) {
163
+ event.preventDefault();
164
+
165
+ if (event.code === 'ArrowDown') {
166
+ const next = event.target.nextElementSibling;
167
+
168
+ if (next) {
169
+ next.focus();
170
+ } else {
171
+ this.shadowRoot.querySelector('li').focus();
172
+ }
173
+ }
174
+
175
+ if (event.code === 'ArrowUp') {
176
+ const previous = event.target.previousElementSibling;
177
+
178
+ if (previous) {
179
+ previous.focus();
180
+ } else {
181
+ this.shadowRoot.querySelector('li:last-child').focus();
182
+ }
183
+ }
184
+
185
+ if (event.code === 'Escape' || event.code === 'Tab') {
186
+ this.show = false;
187
+ this.input.focus();
188
+ }
189
+
190
+ if (event.code === 'Enter' || event.code === 'Space') {
191
+ this.handleSelection(event);
192
+ }
193
+ }
194
+
195
+ handleInputKeyDown(event) {
196
+ if (event.code === 'ArrowDown') {
197
+ this.shadowRoot.querySelector('li').focus();
198
+ }
199
+
200
+ if (event.code === 'Escape') {
201
+ this.show = false;
202
+ }
203
+ }
204
+ }
205
+
206
+ // eslint-disable-next-line no-unused-expressions
207
+ customElements.get('kemet-combo') || customElements.define('kemet-combo', KemetCombo);
@@ -0,0 +1,112 @@
1
+ import { html, css, LitElement } from 'lit';
2
+
3
+ export default class KemetCount extends LitElement {
4
+ static get styles() {
5
+ return [
6
+ css`
7
+ :host {
8
+ display: block;
9
+ font-size: var(--kemet-count-font-size, 90%);
10
+ margin-top: 0.8rem;
11
+ }
12
+ `,
13
+ ];
14
+ }
15
+
16
+ static get properties() {
17
+ return {
18
+ /**
19
+ * The text label shown to users
20
+ */
21
+ message: {
22
+ type: String,
23
+ },
24
+ /**
25
+ * The number of characters remaining
26
+ */
27
+ remaining: {
28
+ type: Number,
29
+ },
30
+ /**
31
+ * The maximum number of characters allowed
32
+ */
33
+ limit: {
34
+ type: Number,
35
+ },
36
+ /**
37
+ * Set to true if the field should validate as soon as the character limit is reached
38
+ */
39
+ validateImmediately: {
40
+ type: Boolean,
41
+ attribute: 'validate-immediately',
42
+ },
43
+ };
44
+ }
45
+
46
+ firstUpdated() {
47
+ this.field = this.closest('kemet-field');
48
+ this.inputSlot = this.field.querySelector('[slot="input"]');
49
+
50
+ this.remaining = this.limit - this.field.length;
51
+
52
+ this.field.addEventListener('kemet-field-input', (event) => {
53
+ this.remaining = this.limit - event.detail;
54
+
55
+ const nativeElement = this.input || this.textarea;
56
+
57
+ if (nativeElement) {
58
+ if (this.remaining < 0) {
59
+ nativeElement.validity.passedLimit = true;
60
+
61
+ if (this.validateImmediately) {
62
+ this.inputSlot.status = 'error';
63
+ this.inputSlot.invalid = true;
64
+
65
+ /**
66
+ * Fires when there's a change in status.
67
+ */
68
+ this.dispatchEvent(
69
+ new CustomEvent('kemet-count-status', {
70
+ bubbles: true,
71
+ composed: true,
72
+ detail: {
73
+ status: 'error',
74
+ validity: nativeElement.validity,
75
+ element: this.inputSlot,
76
+ },
77
+ }),
78
+ );
79
+ }
80
+ } else {
81
+ this.inputSlot.status = 'standard';
82
+ nativeElement.checkValidity();
83
+
84
+ /**
85
+ * Fires when there's a change in status.
86
+ */
87
+ this.dispatchEvent(
88
+ new CustomEvent('kemet-count-status', {
89
+ bubbles: true,
90
+ composed: true,
91
+ detail: {
92
+ status: 'standard',
93
+ validity: nativeElement.validity,
94
+ element: this.inputSlot,
95
+ },
96
+ }),
97
+ );
98
+ }
99
+ }
100
+ });
101
+
102
+ this.input = this.inputSlot.shadowRoot.querySelector('input');
103
+ this.textarea = this.inputSlot.shadowRoot.querySelector('textarea');
104
+ }
105
+
106
+ render() {
107
+ return html`${this.remaining} ${this.message}`;
108
+ }
109
+ }
110
+
111
+ // eslint-disable-next-line no-unused-expressions
112
+ customElements.get('kemet-count') || customElements.define('kemet-count', KemetCount);
@@ -1,6 +1,6 @@
1
1
  import { html, css, LitElement } from 'lit';
2
2
 
3
- export class KemetDraggable extends LitElement {
3
+ export default class KemetDraggable extends LitElement {
4
4
  static get styles() {
5
5
  return css`
6
6
  :host {
@@ -15,15 +15,28 @@ export class KemetDraggable extends LitElement {
15
15
 
16
16
  static get properties() {
17
17
  return {
18
+ /**
19
+ * A unique identifier used to store the element's position in local storage.
20
+ */
18
21
  memory: {
19
22
  type: String,
20
23
  },
24
+ /**
25
+ * The elements top position in pixels.
26
+ */
21
27
  top: {
22
28
  type: String,
23
29
  },
30
+ /**
31
+ * The element's left position in pixels.
32
+ */
24
33
  left: {
25
34
  type: String,
26
35
  },
36
+ /**
37
+ * If set to true, will measure the width and height
38
+ * of the element's content and apply it to the host element.
39
+ */
27
40
  measure: {
28
41
  type: Boolean,
29
42
  },
@@ -37,17 +50,16 @@ export class KemetDraggable extends LitElement {
37
50
  this.top = 'auto';
38
51
  this.left = 'auto';
39
52
  this.measure = false;
53
+ }
40
54
 
41
- // js property defaults
55
+ firstUpdated() {
56
+ // standard properties
42
57
  this.position1 = 0;
43
58
  this.position2 = 0;
44
59
  this.position3 = 0;
45
60
  this.position4 = 0;
46
61
  this.mouseMove = event => this.drag(event);
47
62
  this.mouseUp = () => this.stopDrag();
48
- }
49
-
50
- firstUpdated() {
51
63
  this.draggableElement = this.shadowRoot.getElementById('draggable');
52
64
 
53
65
  const savedPosition = JSON.parse(localStorage.getItem(this.memory));
@@ -126,4 +138,5 @@ export class KemetDraggable extends LitElement {
126
138
  }
127
139
  }
128
140
 
129
- window.customElements.define('kemet-draggable', KemetDraggable);
141
+ // eslint-disable-next-line no-unused-expressions
142
+ customElements.get('kemet-draggable') || customElements.define('kemet-draggable', KemetDraggable);
@@ -1,25 +1,39 @@
1
1
  import { LitElement, html } from 'lit';
2
2
  import { stylesBase, stylesEffects } from './kemet-drawer.styles.js';
3
3
 
4
- export class KemetDrawer extends LitElement {
4
+ export default class KemetDrawer extends LitElement {
5
5
  static get styles() {
6
6
  return [stylesBase, stylesEffects];
7
7
  }
8
8
 
9
9
  static get properties() {
10
10
  return {
11
+ /**
12
+ * Determines if the drawer is opened or not.
13
+ */
11
14
  opened: {
12
15
  type: Boolean,
13
16
  reflect: true,
14
17
  },
18
+ /**
19
+ * The animation effect for opening and closing the drawer.
20
+ * Values include: (slide | reveal | push | scale)
21
+ */
15
22
  effect: {
16
23
  type: String,
17
24
  reflect: true,
18
25
  },
26
+ /**
27
+ * Allows you to control which side the drawer opens from.
28
+ * Values include: (left | right | top | bottom)
29
+ */
19
30
  side: {
20
31
  type: String,
21
32
  reflect: true,
22
33
  },
34
+ /**
35
+ * Adds a overlay over the content section of the Drawer when opened
36
+ */
23
37
  overlay: {
24
38
  type: Boolean,
25
39
  reflect: true,
@@ -30,7 +44,7 @@ export class KemetDrawer extends LitElement {
30
44
  constructor() {
31
45
  super();
32
46
 
33
- // property defaults
47
+ // managed properties
34
48
  this.opened = undefined;
35
49
  this.effect = 'slide';
36
50
  this.side = 'left';
@@ -47,11 +61,29 @@ export class KemetDrawer extends LitElement {
47
61
 
48
62
  updated(prevProps) {
49
63
  if (!prevProps.get('opened') && this.opened === true) {
50
- this.makeEvent('opened');
64
+ /**
65
+ * Fires when the drawer opens.
66
+ */
67
+ this.dispatchEvent(
68
+ new CustomEvent('kemet-drawer-opened', {
69
+ bubbles: true,
70
+ composed: true,
71
+ detail: this,
72
+ }),
73
+ );
51
74
  }
52
75
 
53
76
  if (prevProps.get('opened') && this.opened === false) {
54
- this.makeEvent('closed');
77
+ /**
78
+ * Fires when the drawer closes.
79
+ */
80
+ this.dispatchEvent(
81
+ new CustomEvent('kemet-drawer-closed', {
82
+ bubbles: true,
83
+ composed: true,
84
+ detail: this,
85
+ }),
86
+ );
55
87
  }
56
88
  }
57
89
 
@@ -71,16 +103,7 @@ export class KemetDrawer extends LitElement {
71
103
  </section>
72
104
  `;
73
105
  }
74
-
75
- makeEvent(type) {
76
- this.dispatchEvent(
77
- new CustomEvent(`kemet-drawer-${type}`, {
78
- bubbles: true,
79
- composed: true,
80
- detail: this,
81
- }),
82
- );
83
- }
84
106
  }
85
107
 
86
- window.customElements.define('kemet-drawer', KemetDrawer);
108
+ // eslint-disable-next-line no-unused-expressions
109
+ customElements.get('kemet-drawer') || customElements.define('kemet-drawer', KemetDrawer);
@@ -3,6 +3,12 @@ import { css, unsafeCSS } from 'lit';
3
3
  const documentHeight = `${document.documentElement.scrollHeight}px`;
4
4
 
5
5
  export const stylesBase = css`
6
+ *,
7
+ *::before,
8
+ *::after {
9
+ box-sizing: border-box;
10
+ }
11
+
6
12
  :host {
7
13
  width: 100%;
8
14
  }