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,230 @@
1
+ import { html, css, LitElement } from 'lit';
2
+ import '../kemet-icon/kemet-icon.js';
3
+ import { FormSubmitController } from '../../utilities/controllers/forms.js';
4
+
5
+ export default class KemetButton extends LitElement {
6
+ static get styles() {
7
+ return [
8
+ css`
9
+ :host {
10
+ cursor: pointer;
11
+ display: inline-flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ font-size: var(--kemet-button-font-size, inherit);
15
+ color: var(--kemet-button-color, var(--kemet-color-white));
16
+ width: var(--kemet-button-width, auto);
17
+ height: var(--kemet-button-height, auto);
18
+ border: var(--kemet-button-border, 0);
19
+ border-radius: var(--kemet-button-border-radius, 0);
20
+ transition: filter var(--kemet-button-transition-speed, 300ms) ease;
21
+ background-color: var(--kemet-button-background-color, var(--kemet-color-primary));
22
+ }
23
+
24
+ :host(:hover:not([disabled])) {
25
+ filter: brightness(var(--kemet-button-hover-brightness, 1.25));
26
+ }
27
+
28
+ :host([disabled]) {
29
+ opacity: var(--kemet-button-disabled-opacity, 0.5);
30
+ }
31
+
32
+ .button {
33
+ cursor: pointer;
34
+ text-decoration: none;
35
+ display: flex;
36
+ gap: var(--kemet-button-gap, 0.5rem);
37
+ align-items: center;
38
+ color: inherit;
39
+ font-size: inherit;
40
+ padding: var(--kemet-button-padding, 1rem 1.25rem);
41
+ border: 0;
42
+ background: none;
43
+ }
44
+
45
+ :host([disabled]) .button {
46
+ cursor: not-allowed;
47
+ }
48
+
49
+ :host([type='text']) {
50
+ --kemet-button-color: var(--kemet-color-primary);
51
+ --kemet-button-background-color: none;
52
+ }
53
+
54
+ :host([type='text']:hover) {
55
+ text-decoration: var(--kemet-button-hover-decoration, underline);
56
+ }
57
+
58
+ :host([type='circle']) {
59
+ --kemet-button-border-radius: 50%;
60
+ --kemet-button-width: var(--kemet-button-circle-size, 50px);
61
+ --kemet-button-height: var(--kemet-button-circle-size, 50px);
62
+ }
63
+
64
+ :host([type='rounded']) {
65
+ --kemet-button-border-radius: var(--kemet-button-rounded-amount, 6px);
66
+ }
67
+
68
+ :host([type='pill']) {
69
+ --kemet-button-border-radius: 10rem;
70
+ }
71
+
72
+ :host([outlined]) {
73
+ --kemet-button-color: var(--kemet-color-primary);
74
+ --kemet-button-background-color: var(--kemet-color-white);
75
+ --kemet-button-border: var(--kemet-button-border-width, 1px) var(--kemet-button-border-style, solid) var(--kemet-button-border-color, var(--kemet-color-primary));
76
+ }
77
+ `,
78
+ ];
79
+ }
80
+
81
+ static get properties() {
82
+ return {
83
+ /**
84
+ * Determines whether or not the button is active
85
+ */
86
+ active: {
87
+ type: Boolean,
88
+ reflect: true,
89
+ },
90
+ /**
91
+ * Is true when the button is hovered
92
+ */
93
+ hover: {
94
+ type: Boolean,
95
+ reflect: true,
96
+ },
97
+ /**
98
+ * Is true when the button is focused
99
+ */
100
+ focused: {
101
+ type: Boolean,
102
+ reflect: true,
103
+ },
104
+ /**
105
+ * The url a button should link too
106
+ */
107
+ link: {
108
+ type: String,
109
+ },
110
+ /**
111
+ * Outline style for a button
112
+ */
113
+ outlined: {
114
+ type: Boolean,
115
+ reflect: true,
116
+ },
117
+ /**
118
+ * Determines whether not a button is disabled
119
+ */
120
+ disabled: {
121
+ type: Boolean,
122
+ reflect: true,
123
+ },
124
+ /**
125
+ * Controls the type of button
126
+ * standard | text | circle | rounded | pill
127
+ */
128
+ type: {
129
+ type: String,
130
+ reflect: true,
131
+ },
132
+ };
133
+ }
134
+
135
+ constructor() {
136
+ super();
137
+
138
+ this.addEventListener('click', this.handleClick.bind(this));
139
+ this.addEventListener('mouseover', this.handleMouseOver.bind(this));
140
+ this.addEventListener('mouseout', this.handleMouseOut.bind(this));
141
+ this.addEventListener('blur', this.handleBlur.bind(this));
142
+ this.addEventListener('keyup', event => this.handleKeyUp(event));
143
+
144
+ this.type = 'standard';
145
+ this.outline = false;
146
+ this.disable = false;
147
+
148
+ /**
149
+ * Used only for form reactive controller
150
+ */
151
+ this.formSubmitController = new FormSubmitController(this);
152
+ }
153
+
154
+ render() {
155
+ if (this.link && !this.disabled) {
156
+ return html`
157
+ <a href=${this.link} class="button" role="button" part="button">
158
+ <slot name="left"></slot>
159
+ <slot></slot>
160
+ <slot name="right"></slot>
161
+ </a>
162
+ `;
163
+ }
164
+
165
+ return html`
166
+ <button class="button" part="button" ?disabled=${this.disabled} aria-disabled=${this.disabled ? 'true' : 'false'}>
167
+ <slot name="left"></slot>
168
+ <slot></slot>
169
+ <slot name="right"></slot>
170
+ </button>
171
+ `;
172
+ }
173
+
174
+ /**
175
+ * Sets hover to true onMouseOver
176
+ * @private
177
+ */
178
+ handleMouseOver() {
179
+ this.hover = true;
180
+ }
181
+
182
+ /**
183
+ * Sets hover to false onMouseOut
184
+ * @private
185
+ */
186
+ handleMouseOut() {
187
+ this.hover = false;
188
+ }
189
+
190
+ /**
191
+ * Handles click behavior
192
+ * @private
193
+ */
194
+ handleClick() {
195
+ this.hover = false;
196
+ this.active = true;
197
+
198
+ setTimeout(() => {
199
+ this.active = false;
200
+ }, 300);
201
+
202
+ if (this.shadowRoot.querySelector('button')) {
203
+ this.formSubmitController.submit(this);
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Handles blur
209
+ * @private
210
+ */
211
+ handleBlur() {
212
+ this.focused = false;
213
+ this.active = false;
214
+ this.hover = false;
215
+ }
216
+
217
+ /**
218
+ * Handles keyup
219
+ * @private
220
+ * @param {object} event - event object
221
+ */
222
+ handleKeyUp(event) {
223
+ if (event.key === 'Tab') {
224
+ this.focused = true;
225
+ }
226
+ }
227
+ }
228
+
229
+ // eslint-disable-next-line no-unused-expressions
230
+ customElements.get('kemet-button') || customElements.define('kemet-button', KemetButton);
@@ -0,0 +1,298 @@
1
+ import { html, css, LitElement } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { live } from 'lit/directives/live.js';
4
+ import { FormSubmitController } from '../../utilities/controllers/forms.js';
5
+
6
+ export default class KemetCheckbox extends LitElement {
7
+ static get styles() {
8
+ return [
9
+ css`
10
+ *,
11
+ *::before,
12
+ *::after {
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ :host {
17
+ display: inline-block;
18
+ }
19
+
20
+ :host([disabled]) {
21
+ opacity: 0.5;
22
+ }
23
+
24
+ label {
25
+ display: inline-flex;
26
+ gap: 0.5rem;
27
+ align-items: center;
28
+ }
29
+
30
+ input {
31
+ cursor: pointer;
32
+ margin: 0;
33
+ padding: 0;
34
+ width: var(--kemet-checkbox-size, 18px);
35
+ height: var(--kemet-checkbox-size, 18px);
36
+ position: absolute;
37
+ opacity: 0;
38
+ }
39
+
40
+ button {
41
+ margin: 0;
42
+ border: none;
43
+ background: none;
44
+ }
45
+
46
+ [part='checkbox'] {
47
+ color: var(--kemet-checkbox-color, var(--kemet-color-primary));
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ width: var(--kemet-checkbox-size, 18px);
52
+ height: var(--kemet-checkbox-size, 18px);
53
+ border: var(--kemet-checkbox-border, 1px solid var(--kemet-color-primary));
54
+ }
55
+
56
+ :host([rounded]) [part='checkbox'] {
57
+ border-radius: var(--kemet-checkbox-border-radius, 4px);
58
+ }
59
+
60
+ :host([filled][checked]) [part='checkbox'],
61
+ :host([filled][indeterminate]) [part='checkbox'] {
62
+ border: none;
63
+ background-color: var(--kemet-checkbox-filled-background-color, var(--kemet-color-primary));
64
+ }
65
+
66
+ [part='mark'] {
67
+ display: flex;
68
+ width: calc(var(--kemet-checkbox-size, 18px) - 4px);
69
+ height: calc(var(--kemet-checkbox-size, 18px) - 4px);
70
+ }
71
+
72
+ :host([filled][checked]) [part='mark'],
73
+ :host([filled][indeterminate]) [part='mark'] {
74
+ color: var(--kemet-checkbox-filled-color, var(--kemet-color-white));
75
+ }
76
+
77
+ [part='message'] {
78
+ display: block;
79
+ margin-top: 0.5rem;
80
+ }
81
+
82
+ :host([status='error']) [part='message'] {
83
+ color: var(--kemet-color-error);
84
+ }
85
+
86
+ :host([status='warning']) [part='message'] {
87
+ color: var(--kemet-color-error);
88
+ }
89
+ `,
90
+ ];
91
+ }
92
+
93
+ static get properties() {
94
+ return {
95
+ label: {
96
+ type: String,
97
+ },
98
+ checked: {
99
+ type: Boolean,
100
+ reflect: true,
101
+ },
102
+ indeterminate: {
103
+ type: Boolean,
104
+ reflect: true,
105
+ },
106
+ name: {
107
+ type: String,
108
+ },
109
+ value: {
110
+ type: String,
111
+ },
112
+ disabled: {
113
+ type: Boolean,
114
+ reflect: true,
115
+ },
116
+ required: {
117
+ type: Boolean,
118
+ reflect: true,
119
+ },
120
+ focused: {
121
+ type: Boolean,
122
+ reflect: true,
123
+ },
124
+ rounded: {
125
+ type: Boolean,
126
+ reflect: true,
127
+ },
128
+ filled: {
129
+ type: Boolean,
130
+ reflect: true,
131
+ },
132
+ status: {
133
+ type: String,
134
+ reflect: true,
135
+ },
136
+ message: {
137
+ type: String,
138
+ },
139
+ };
140
+ }
141
+
142
+ constructor() {
143
+ super();
144
+
145
+ // managed properties
146
+ this.label = '';
147
+ this.name = 'checkbox';
148
+ this.disabled = false;
149
+ this.required = false;
150
+ this.rounded = false;
151
+ this.filled = false;
152
+ this.status = 'standard';
153
+
154
+ /**
155
+ * Used only for form reactive controller
156
+ */
157
+ this.formSubmitController = new FormSubmitController(this);
158
+ }
159
+
160
+ firstUpdated() {
161
+ this.input = this.shadowRoot.querySelector('input');
162
+ }
163
+
164
+ render() {
165
+ return html`
166
+ <label part="label">
167
+ <input
168
+ type="checkbox"
169
+ name=${ifDefined(this.name)}
170
+ .value=${this.value}
171
+ .indeterminate=${live(this.indeterminate)}
172
+ .checked=${live(this.checked)}
173
+ .disabled=${this.disabled}
174
+ .required=${this.required}
175
+ aria-checked=${this.checked ? 'true' : 'false'}
176
+ @click=${() => this.handleClick()}
177
+ @blur=${() => this.handleBlur()}
178
+ @focus=${() => this.handleFocus()}
179
+ @change=${() => this.handleChange()}
180
+ />
181
+ <button part="checkbox" aria-label=${this.label}>
182
+ ${this.makeCheckMark()}
183
+ </button>
184
+ <span part="text">${this.label}</span>
185
+ </label>
186
+ ${this.makeMessage()}
187
+ `;
188
+ }
189
+
190
+ click() {
191
+ this.input.click();
192
+ }
193
+
194
+ handleClick() {
195
+ this.checked = !this.checked;
196
+ this.indeterminate = false;
197
+
198
+ /**
199
+ * Fires when the state of the checkbox changes
200
+ */
201
+ this.dispatchEvent(
202
+ new CustomEvent('kemet-checkbox-change', {
203
+ bubbles: true,
204
+ composed: true,
205
+ detail: this,
206
+ }),
207
+ );
208
+ }
209
+
210
+ handleBlur() {
211
+ this.focused = false;
212
+
213
+ /**
214
+ * Fires when the checkbox loses or receives focus
215
+ */
216
+ this.dispatchEvent(
217
+ new CustomEvent('kemet-checkbox-focused', {
218
+ bubbles: true,
219
+ composed: true,
220
+ detail: false,
221
+ }),
222
+ );
223
+ }
224
+
225
+ handleFocus() {
226
+ this.focused = true;
227
+ /**
228
+ * Fires when the checkbox loses or receives focus
229
+ */
230
+ this.dispatchEvent(
231
+ new CustomEvent('kemet-checkbox-focused', {
232
+ bubbles: true,
233
+ composed: true,
234
+ detail: true,
235
+ }),
236
+ );
237
+ }
238
+
239
+ handleChange() {
240
+ this.value = this.checked;
241
+
242
+ if (this.input.checkValidity()) {
243
+ this.status = 'standard';
244
+ }
245
+ }
246
+
247
+ makeMessage() {
248
+ if (this.status === 'error' || this.status === 'warning') {
249
+ return html`<span part="message">${this.message}</span>`;
250
+ }
251
+
252
+ return null;
253
+ }
254
+
255
+ makeCheckMark() {
256
+ if (this.checked) {
257
+ return html`
258
+ <span part="mark">
259
+ <svg viewBox="0 0 16 16">
260
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
261
+ <g stroke="currentColor" stroke-width="2">
262
+ <g transform="translate(3.428571, 3.428571)">
263
+ <path d="M0,5.71428571 L3.42857143,9.14285714"></path>
264
+ <path d="M9.14285714,0 L3.42857143,9.14285714"></path>
265
+ </g>
266
+ </g>
267
+ </g>
268
+ </svg>
269
+ </span>
270
+ `;
271
+ }
272
+
273
+ if (!this.checked && this.indeterminate) {
274
+ return html`
275
+ <span part="mark">
276
+ <svg viewBox="0 0 16 16">
277
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
278
+ <g stroke="currentColor" stroke-width="2">
279
+ <g transform="translate(2.285714, 6.857143)">
280
+ <path d="M10.2857143,1.14285714 L1.14285714,1.14285714"></path>
281
+ </g>
282
+ </g>
283
+ </g>
284
+ </svg>
285
+ </span>
286
+ `;
287
+ }
288
+
289
+ return null;
290
+ }
291
+
292
+ checkValidity() {
293
+ return this.input.checkValidity();
294
+ }
295
+ }
296
+
297
+ // eslint-disable-next-line no-unused-expressions
298
+ customElements.get('kemet-checkbox') || customElements.define('kemet-checkbox', KemetCheckbox);