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.
- package/custom-elements.json +5546 -855
- package/dist/components/kemet-accordion-panel.js +178 -0
- package/dist/components/kemet-accordion.js +105 -72
- package/dist/components/kemet-badge.js +102 -0
- package/dist/components/kemet-button.js +230 -0
- package/dist/components/kemet-checkbox.js +298 -0
- package/dist/components/kemet-combo.js +207 -0
- package/dist/components/kemet-count.js +112 -0
- package/dist/components/kemet-draggable.js +19 -6
- package/dist/components/kemet-drawer.js +38 -15
- package/dist/components/kemet-drawer.styles.js +6 -0
- package/dist/components/kemet-field.js +233 -0
- package/dist/components/kemet-flipcard-trigger.js +4 -5
- package/dist/components/kemet-flipcard.js +26 -3
- package/dist/components/kemet-icon.js +19 -3
- package/dist/components/kemet-input.js +650 -0
- package/dist/components/kemet-modal-close.js +23 -4
- package/dist/components/kemet-modal.js +78 -13
- package/dist/components/kemet-modal.styles.js +14 -2
- package/dist/components/kemet-option.js +45 -0
- package/dist/components/kemet-popover-close.js +1 -1
- package/dist/components/kemet-popover.js +75 -12
- package/dist/components/kemet-radio.js +214 -0
- package/dist/components/kemet-radios.js +218 -0
- package/dist/components/kemet-rotator.js +23 -4
- package/dist/components/kemet-scroll-link.js +21 -2
- package/dist/components/kemet-scroll-nav.js +25 -2
- package/dist/components/kemet-scroll-snap-paginator.js +68 -26
- package/dist/components/kemet-scroll-snap-slide.js +23 -13
- package/dist/components/kemet-scroll-snap.js +31 -16
- package/dist/components/kemet-select.js +365 -0
- package/dist/components/kemet-svg.js +18 -2
- package/dist/components/kemet-svgs.js +7 -3
- package/dist/components/kemet-tab-panel.js +15 -1
- package/dist/components/kemet-tab.js +48 -1
- package/dist/components/kemet-tabs.js +289 -83
- package/dist/components/kemet-tabs.styles.js +200 -0
- package/dist/components/kemet-textarea.js +395 -0
- package/dist/components/kemet-toggle.js +225 -0
- package/dist/kemet-components.cjs +5128 -1200
- package/dist/kemet-components.js +5117 -1173
- package/dist/kemet-components.min.js +1536 -421
- package/dist/styles/kemet.components.css +12 -260
- package/dist/styles/kemet.components.css.map +1 -1
- package/dist/styles/kemet.core.css +2371 -503
- package/dist/styles/kemet.core.css.map +1 -1
- package/dist/styles/scss/components/_config.scss +0 -25
- package/dist/styles/scss/components/accordion.scss +4 -53
- package/dist/styles/scss/components/modal.scss +5 -9
- package/dist/styles/scss/components/scrollsnap.scss +0 -57
- package/dist/styles/scss/core/_config.scss +160 -3
- package/dist/styles/scss/core/_helpers.scss +109 -2
- package/dist/styles/scss/core/attributes.scss +16 -0
- package/dist/styles/scss/core/base.scss +38 -0
- package/dist/styles/scss/core/layout.scss +6 -5
- package/dist/styles/scss/kemet.components.scss +0 -2
- package/dist/styles/scss/kemet.core.scss +1 -2
- package/package.json +34 -56
- package/dist/components/kemet-carousel-link.js +0 -54
- package/dist/components/kemet-carousel-next.js +0 -46
- package/dist/components/kemet-carousel-prev.js +0 -46
- package/dist/components/kemet-carousel-slide.js +0 -83
- package/dist/components/kemet-carousel.js +0 -236
- package/dist/components/kemet-ratio.js +0 -61
- package/dist/styles/scss/components/flipcard.scss +0 -14
- package/dist/styles/scss/components/tabs.scss +0 -73
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit';
|
|
2
|
+
import { FormSubmitController } from '../../utilities/controllers/forms.js';
|
|
3
|
+
|
|
4
|
+
export default class KemetRadios extends LitElement {
|
|
5
|
+
static get styles() {
|
|
6
|
+
return [
|
|
7
|
+
css`
|
|
8
|
+
*,
|
|
9
|
+
*::before,
|
|
10
|
+
*::after {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fieldset {
|
|
19
|
+
border: 0;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
display: flex;
|
|
23
|
+
gap: 0.5rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
legend {
|
|
27
|
+
margin-bottom: 1rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host([axis='vertical']) fieldset {
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[part='message'] {
|
|
35
|
+
display: block;
|
|
36
|
+
margin-top: 0.5rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([status='error']) [part='message'] {
|
|
40
|
+
color: var(--kemet-color-error);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:host([status='warning']) [part='message'] {
|
|
44
|
+
color: var(--kemet-color-error);
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static get properties() {
|
|
51
|
+
return {
|
|
52
|
+
/**
|
|
53
|
+
* The legend text for the fieldset
|
|
54
|
+
*/
|
|
55
|
+
legend: {
|
|
56
|
+
type: String,
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* The direction of the button's layout
|
|
60
|
+
*/
|
|
61
|
+
axis: {
|
|
62
|
+
type: String,
|
|
63
|
+
reflect: true,
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* The value of the selected radio button
|
|
67
|
+
*/
|
|
68
|
+
value: {
|
|
69
|
+
type: String,
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* The name of the radio button set
|
|
73
|
+
*/
|
|
74
|
+
name: {
|
|
75
|
+
type: String,
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* The status of the radio button set
|
|
79
|
+
*/
|
|
80
|
+
status: {
|
|
81
|
+
type: String,
|
|
82
|
+
reflect: true,
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* Validation message for the user
|
|
86
|
+
*/
|
|
87
|
+
message: {
|
|
88
|
+
type: String,
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Determines whether or not the radio button set is required
|
|
92
|
+
*/
|
|
93
|
+
required: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
constructor() {
|
|
100
|
+
super();
|
|
101
|
+
|
|
102
|
+
// managed properties
|
|
103
|
+
this.legend = '';
|
|
104
|
+
this.axis = 'horizontal';
|
|
105
|
+
this.name = 'radios';
|
|
106
|
+
this.status = 'standard';
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Used only for form reactive controller
|
|
110
|
+
*/
|
|
111
|
+
this.formSubmitController = new FormSubmitController(this);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
firstUpdated() {
|
|
115
|
+
this.radios = this.querySelectorAll('kemet-radio');
|
|
116
|
+
this.setAttribute('role', 'radiogroup');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
render() {
|
|
120
|
+
return html`
|
|
121
|
+
<fieldset part="fieldset">
|
|
122
|
+
${this.legend !== '' ? html`<legend part="legend">${this.legend}</legend>` : null}
|
|
123
|
+
<slot @click=${event => this.handleClick(event)} @keydown=${event => this.handleKeyDown(event)} @slotchange=${() => this.handleSlotChange()}></slot>
|
|
124
|
+
</fieldset>
|
|
125
|
+
${this.makeMessage()}
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
handleClick(event) {
|
|
130
|
+
const { target } = event;
|
|
131
|
+
|
|
132
|
+
this.radios.forEach((radio) => {
|
|
133
|
+
radio.checked = false;
|
|
134
|
+
radio.tabIndex = radio === target ? 0 : -1;
|
|
135
|
+
radio.setAttribute('aria-checked', 'false');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (!target.disabled) {
|
|
139
|
+
target.checked = true;
|
|
140
|
+
target.setAttribute('aria-checked', 'true');
|
|
141
|
+
this.value = target.value;
|
|
142
|
+
this.status = 'standard';
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Fires when the state of the checkbox changes
|
|
146
|
+
*/
|
|
147
|
+
this.dispatchEvent(
|
|
148
|
+
new CustomEvent('kemet-radios-change', {
|
|
149
|
+
bubbles: true,
|
|
150
|
+
composed: true,
|
|
151
|
+
detail: target,
|
|
152
|
+
}),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
handleKeyDown(event) {
|
|
158
|
+
const radios = Array.from(this.radios);
|
|
159
|
+
const arrowKeys = ['ArrowUp', 'ArrowRight', 'ArrowDown', 'ArrowLeft'];
|
|
160
|
+
const forwardKeys = ['ArrowRight', 'ArrowDown'];
|
|
161
|
+
const shift = forwardKeys.includes(event.key) ? 1 : -1;
|
|
162
|
+
const checkedIndex = radios.findIndex(radio => radio.checked) ?? radios[0];
|
|
163
|
+
|
|
164
|
+
let index = checkedIndex + shift;
|
|
165
|
+
|
|
166
|
+
if (arrowKeys.includes(event.key)) {
|
|
167
|
+
if (index < 0) {
|
|
168
|
+
index = radios.length - 1;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (index > radios.length - 1) {
|
|
172
|
+
index = 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this.radios.forEach((radio) => {
|
|
176
|
+
radio.checked = false;
|
|
177
|
+
radio.tabIndex = -1;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
this.radios[index].focus();
|
|
181
|
+
this.radios[index].checked = true;
|
|
182
|
+
this.radios[index].tabIndex = 0;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
handleSlotChange() {
|
|
187
|
+
const radios = Array.from(this.radios);
|
|
188
|
+
const checkedRadio = radios.find(radio => radio.checked);
|
|
189
|
+
|
|
190
|
+
this.radios.forEach((radio) => {
|
|
191
|
+
radio.tabIndex = -1;
|
|
192
|
+
radio.input.tabIndex = -1;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
if (checkedRadio) {
|
|
196
|
+
checkedRadio.tabIndex = 0;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
makeMessage() {
|
|
201
|
+
if (this.status === 'error' || this.status === 'warning') {
|
|
202
|
+
return html`<span part="message">${this.message}</span>`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
checkValidity() {
|
|
209
|
+
if (this.required) {
|
|
210
|
+
return !!this.value;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// eslint-disable-next-line no-unused-expressions
|
|
218
|
+
customElements.get('kemet-radios') || customElements.define('kemet-radios', KemetRadios);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { html, css, LitElement } from 'lit';
|
|
2
2
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
3
3
|
|
|
4
|
-
export class KemetRotator extends LitElement {
|
|
4
|
+
export default class KemetRotator extends LitElement {
|
|
5
5
|
static get styles() {
|
|
6
6
|
return css`
|
|
7
7
|
:host {
|
|
@@ -77,22 +77,40 @@ export class KemetRotator extends LitElement {
|
|
|
77
77
|
|
|
78
78
|
static get properties() {
|
|
79
79
|
return {
|
|
80
|
+
/**
|
|
81
|
+
* The index number for the current slide.
|
|
82
|
+
*/
|
|
80
83
|
activeSlide: {
|
|
81
84
|
type: Number,
|
|
82
85
|
},
|
|
86
|
+
/**
|
|
87
|
+
* The width of the rotator block.
|
|
88
|
+
*/
|
|
83
89
|
width: {
|
|
84
90
|
type: String,
|
|
85
91
|
},
|
|
92
|
+
/**
|
|
93
|
+
* The height of the rotator block.
|
|
94
|
+
*/
|
|
86
95
|
height: {
|
|
87
96
|
type: String,
|
|
88
97
|
},
|
|
98
|
+
/**
|
|
99
|
+
* Text in the rotator. Supports HTML.
|
|
100
|
+
*/
|
|
89
101
|
messages: {
|
|
90
102
|
type: Array,
|
|
91
103
|
},
|
|
104
|
+
/**
|
|
105
|
+
* The transition effect type.
|
|
106
|
+
*/
|
|
92
107
|
effect: {
|
|
93
108
|
type: String,
|
|
94
109
|
reflect: true,
|
|
95
110
|
},
|
|
111
|
+
/**
|
|
112
|
+
* How fast, in seconds, each slide lasts. Stop the rotator with 0.
|
|
113
|
+
*/
|
|
96
114
|
rotationSpeed: {
|
|
97
115
|
type: Number,
|
|
98
116
|
attribute: 'rotation-speed',
|
|
@@ -110,12 +128,12 @@ export class KemetRotator extends LitElement {
|
|
|
110
128
|
this.rotationSpeed = 3;
|
|
111
129
|
this.width = 'auto';
|
|
112
130
|
this.height = 'auto';
|
|
131
|
+
}
|
|
113
132
|
|
|
133
|
+
firstUpdated() {
|
|
114
134
|
// standard properties
|
|
115
135
|
this.prevSlide = null;
|
|
116
|
-
}
|
|
117
136
|
|
|
118
|
-
firstUpdated() {
|
|
119
137
|
window.addEventListener('resize', this.setDimensions.bind(this));
|
|
120
138
|
}
|
|
121
139
|
|
|
@@ -189,4 +207,5 @@ export class KemetRotator extends LitElement {
|
|
|
189
207
|
}
|
|
190
208
|
}
|
|
191
209
|
|
|
192
|
-
|
|
210
|
+
// eslint-disable-next-line no-unused-expressions
|
|
211
|
+
customElements.get('kemet-rotator') || customElements.define('kemet-rotator', KemetRotator);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { html, css, LitElement } from 'lit';
|
|
2
2
|
|
|
3
|
-
export class KemetScrollLink extends LitElement {
|
|
3
|
+
export default class KemetScrollLink extends LitElement {
|
|
4
4
|
static get styles() {
|
|
5
5
|
return css`
|
|
6
6
|
:host {
|
|
@@ -12,17 +12,30 @@ export class KemetScrollLink extends LitElement {
|
|
|
12
12
|
|
|
13
13
|
static get properties() {
|
|
14
14
|
return {
|
|
15
|
+
/**
|
|
16
|
+
* A DOM element that establishes the context of scrolling.
|
|
17
|
+
*/
|
|
15
18
|
element: {
|
|
16
19
|
type: Object,
|
|
17
20
|
},
|
|
21
|
+
/**
|
|
22
|
+
* A DOM element that represents the destination of the scroll link.
|
|
23
|
+
* If no target is specified it will default to the top of the page.
|
|
24
|
+
*/
|
|
18
25
|
target: {
|
|
19
26
|
type: Object,
|
|
20
27
|
},
|
|
28
|
+
/**
|
|
29
|
+
* Allows the horizontal scrolling to stop short of the given value.
|
|
30
|
+
*/
|
|
21
31
|
xOffset: {
|
|
22
32
|
type: Number,
|
|
23
33
|
attribute: 'x-offset',
|
|
24
34
|
reflect: true,
|
|
25
35
|
},
|
|
36
|
+
/**
|
|
37
|
+
* Allows the vertical scrolling to stop short of the given value.
|
|
38
|
+
*/
|
|
26
39
|
yOffset: {
|
|
27
40
|
type: Number,
|
|
28
41
|
attribute: 'y-offset',
|
|
@@ -34,10 +47,15 @@ export class KemetScrollLink extends LitElement {
|
|
|
34
47
|
constructor() {
|
|
35
48
|
super();
|
|
36
49
|
|
|
50
|
+
// managed properties
|
|
37
51
|
this.element = this.element || window;
|
|
38
52
|
this.target = this.target || document.querySelector('body');
|
|
39
53
|
this.xOffset = 0;
|
|
40
54
|
this.yOffset = 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
firstUpdated() {
|
|
58
|
+
// standard properties
|
|
41
59
|
this.keyCodes = {
|
|
42
60
|
ENTER: 13,
|
|
43
61
|
SPACE: 32,
|
|
@@ -75,4 +93,5 @@ export class KemetScrollLink extends LitElement {
|
|
|
75
93
|
}
|
|
76
94
|
}
|
|
77
95
|
|
|
78
|
-
|
|
96
|
+
// eslint-disable-next-line no-unused-expressions
|
|
97
|
+
customElements.get('kemet-scroll-link') || customElements.define('kemet-scroll-link', KemetScrollLink);
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
|
|
3
|
-
export class KemetScrollNav extends LitElement {
|
|
3
|
+
export default class KemetScrollNav extends LitElement {
|
|
4
4
|
static get styles() {
|
|
5
5
|
return [
|
|
6
6
|
css`
|
|
7
7
|
:host {
|
|
8
8
|
display: block;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
padding: var(--kemet-scroll-nav-padding, 1rem 2rem);
|
|
11
|
+
background-color: var(--kemet-scroll-nav-background, #fafafa);
|
|
12
|
+
transition: all var(--kemet-scroll-nav-transition, 300ms) ease;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
:host([transform]),
|
|
@@ -14,20 +18,38 @@ export class KemetScrollNav extends LitElement {
|
|
|
14
18
|
top: 0;
|
|
15
19
|
width: 100%;
|
|
16
20
|
}
|
|
21
|
+
|
|
22
|
+
:host([effect="resize"]) {
|
|
23
|
+
height: var(--kemet-scroll-nav-resize-height, 400px);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([transform][effect="resize"]) {
|
|
27
|
+
height: var(--kemet-scroll-nav-resize-height-transformed, 100px);
|
|
28
|
+
}
|
|
17
29
|
`,
|
|
18
30
|
];
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
static get properties() {
|
|
22
34
|
return {
|
|
35
|
+
/**
|
|
36
|
+
* Determines where the transform point is activated. Values include: (sticky | resize)
|
|
37
|
+
*/
|
|
23
38
|
effect: {
|
|
24
39
|
type: String,
|
|
25
40
|
reflect: true,
|
|
26
41
|
},
|
|
42
|
+
/**
|
|
43
|
+
* Whether or not the nav has shifted into a new state.
|
|
44
|
+
*/
|
|
27
45
|
transform: {
|
|
28
46
|
type: Boolean,
|
|
29
47
|
reflect: true,
|
|
30
48
|
},
|
|
49
|
+
/**
|
|
50
|
+
* Allows for an arbitrary adjustment of the transform point in pixels.
|
|
51
|
+
* Works with negative values.
|
|
52
|
+
*/
|
|
31
53
|
offset: {
|
|
32
54
|
type: Number,
|
|
33
55
|
},
|
|
@@ -72,4 +94,5 @@ export class KemetScrollNav extends LitElement {
|
|
|
72
94
|
}
|
|
73
95
|
}
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
// eslint-disable-next-line no-unused-expressions
|
|
98
|
+
customElements.get('kemet-scroll-nav') || customElements.define('kemet-scroll-nav', KemetScrollNav);
|
|
@@ -1,29 +1,75 @@
|
|
|
1
1
|
import { html, css, LitElement } from 'lit';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export default class KemetScrollSnapPaginator extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return css`
|
|
6
|
+
:host {
|
|
7
|
+
margin: auto;
|
|
8
|
+
padding: var(--kemet-scroll-snap-paginator-padding, 1rem 0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
nav {
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: var(--kemet-scroll-snap-paginator-gap, 0.5rem);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host([center]) nav {
|
|
17
|
+
justify-content: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.link {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
color: var(--kemet-scroll-snap-paginator-link-color, var(--kemet-color-primary));
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
8
26
|
|
|
9
|
-
export class KemetScrollSnapPaginator extends LitElement {
|
|
10
27
|
static get properties() {
|
|
11
28
|
return {
|
|
29
|
+
/**
|
|
30
|
+
* Information about each slide.
|
|
31
|
+
*/
|
|
12
32
|
slides: {
|
|
13
33
|
type: Array,
|
|
14
34
|
},
|
|
35
|
+
/**
|
|
36
|
+
* A string representing which icon to use for pagination. Supports icons used in kemet-icon.
|
|
37
|
+
*/
|
|
15
38
|
icon: {
|
|
16
39
|
type: String,
|
|
17
40
|
},
|
|
41
|
+
/**
|
|
42
|
+
* The size in pixels of the icons.
|
|
43
|
+
*/
|
|
44
|
+
size: {
|
|
45
|
+
type: Number,
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Determines whether to center the pagination items.
|
|
49
|
+
*/
|
|
50
|
+
center: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
reflect: true,
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Will hide inactive pagination items if set to true.
|
|
56
|
+
*/
|
|
18
57
|
hideFocusedLinks: {
|
|
19
58
|
type: Boolean,
|
|
20
59
|
attribute: 'hide-focused-links',
|
|
21
60
|
},
|
|
61
|
+
/**
|
|
62
|
+
* If set to true, the pages in the pagination iterator will appear as a set of numbers.
|
|
63
|
+
*/
|
|
22
64
|
useNumberPages: {
|
|
23
65
|
type: Boolean,
|
|
24
66
|
reflect: true,
|
|
25
67
|
attribute: 'use-number-pages',
|
|
26
68
|
},
|
|
69
|
+
/**
|
|
70
|
+
* If set to true, the pages in the pagination iterator will appear as the label set on
|
|
71
|
+
* the slide.
|
|
72
|
+
*/
|
|
27
73
|
useLabelPages: {
|
|
28
74
|
type: Boolean,
|
|
29
75
|
reflect: true,
|
|
@@ -35,22 +81,16 @@ export class KemetScrollSnapPaginator extends LitElement {
|
|
|
35
81
|
constructor() {
|
|
36
82
|
super();
|
|
37
83
|
|
|
84
|
+
// managed properties
|
|
38
85
|
this.slides = [];
|
|
39
|
-
this.icon = '
|
|
86
|
+
this.icon = 'circle-fill';
|
|
87
|
+
this.size = 16;
|
|
40
88
|
this.hideFocusedLinks = false;
|
|
41
89
|
this.useNumberPages = false;
|
|
42
90
|
this.useLabelPages = false;
|
|
43
91
|
}
|
|
44
92
|
|
|
45
|
-
|
|
46
|
-
return css`
|
|
47
|
-
:host {
|
|
48
|
-
margin: auto;
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
firstUpdated() {
|
|
93
|
+
updated() {
|
|
54
94
|
const scrollSnapElement = this.closest('kemet-scroll-snap');
|
|
55
95
|
|
|
56
96
|
if (scrollSnapElement) {
|
|
@@ -60,13 +100,9 @@ export class KemetScrollSnapPaginator extends LitElement {
|
|
|
60
100
|
}
|
|
61
101
|
}
|
|
62
102
|
|
|
63
|
-
createRenderRoot() {
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
103
|
render() {
|
|
68
104
|
return html`
|
|
69
|
-
<nav>${this.makePagination()}</nav>
|
|
105
|
+
<nav part="nav">${this.makePagination()}</nav>
|
|
70
106
|
`;
|
|
71
107
|
}
|
|
72
108
|
|
|
@@ -79,7 +115,7 @@ export class KemetScrollSnapPaginator extends LitElement {
|
|
|
79
115
|
|
|
80
116
|
if (slide.focused) {
|
|
81
117
|
return html`
|
|
82
|
-
<span>${this.pageDisplay(slide, counter)}</span>
|
|
118
|
+
<span part="span">${this.pageDisplay(slide, counter)}</span>
|
|
83
119
|
`;
|
|
84
120
|
}
|
|
85
121
|
|
|
@@ -87,8 +123,10 @@ export class KemetScrollSnapPaginator extends LitElement {
|
|
|
87
123
|
<span
|
|
88
124
|
class="link"
|
|
89
125
|
tabindex="0"
|
|
126
|
+
role="button"
|
|
90
127
|
@keyup="${event => this.handleKeyboardInput(event, slide.id)}"
|
|
91
|
-
@click=${() => this.slideLink(slide.id)}
|
|
128
|
+
@click=${() => this.slideLink(slide.id)}
|
|
129
|
+
aria-label="${slide.label}">
|
|
92
130
|
${this.pageDisplay(slide, counter)}
|
|
93
131
|
</span>
|
|
94
132
|
`;
|
|
@@ -107,10 +145,13 @@ export class KemetScrollSnapPaginator extends LitElement {
|
|
|
107
145
|
return slide.label;
|
|
108
146
|
}
|
|
109
147
|
|
|
110
|
-
return this.icon
|
|
148
|
+
return html`<kemet-icon icon=${this.icon} size=${this.size}></kemet-icon>`;
|
|
111
149
|
}
|
|
112
150
|
|
|
113
151
|
slideLink(index) {
|
|
152
|
+
/**
|
|
153
|
+
* Fires when a set of slides are focused on.
|
|
154
|
+
*/
|
|
114
155
|
this.dispatchEvent(new CustomEvent('kemet-scroll-snap-focus', {
|
|
115
156
|
bubbles: true,
|
|
116
157
|
composed: true,
|
|
@@ -119,10 +160,11 @@ export class KemetScrollSnapPaginator extends LitElement {
|
|
|
119
160
|
}
|
|
120
161
|
|
|
121
162
|
handleKeyboardInput(event, id) {
|
|
122
|
-
if (event.
|
|
163
|
+
if (event.code === 'Enter' || event.code === 'Space') {
|
|
123
164
|
this.slideLink(id);
|
|
124
165
|
}
|
|
125
166
|
}
|
|
126
167
|
}
|
|
127
168
|
|
|
128
|
-
|
|
169
|
+
// eslint-disable-next-line no-unused-expressions
|
|
170
|
+
customElements.get('kemet-scroll-snap-paginator') || customElements.define('kemet-scroll-snap-paginator', KemetScrollSnapPaginator);
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { html, css, LitElement } from 'lit';
|
|
2
2
|
|
|
3
|
-
export class KemetScrollSnapSlide extends LitElement {
|
|
3
|
+
export default class KemetScrollSnapSlide extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return css`
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
flex: 0 0 auto;
|
|
9
|
+
width: var(--kemet-scroll-snap-slide-width, 100%);
|
|
10
|
+
scroll-snap-align: var(--kemet-scroll-snap-slide-align, center);
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
static get properties() {
|
|
5
16
|
return {
|
|
17
|
+
/**
|
|
18
|
+
* Is true when the slide is fully visible in it's container.
|
|
19
|
+
*/
|
|
6
20
|
focused: {
|
|
7
21
|
type: Boolean,
|
|
8
22
|
reflect: true,
|
|
9
23
|
},
|
|
24
|
+
/**
|
|
25
|
+
* Identifies the slide.
|
|
26
|
+
*/
|
|
10
27
|
index: {
|
|
11
28
|
type: String,
|
|
12
29
|
reflect: true,
|
|
13
30
|
},
|
|
31
|
+
/**
|
|
32
|
+
* Labels the slide.
|
|
33
|
+
*/
|
|
14
34
|
label: {
|
|
15
35
|
type: String,
|
|
16
36
|
reflect: true,
|
|
@@ -22,17 +42,6 @@ export class KemetScrollSnapSlide extends LitElement {
|
|
|
22
42
|
this.addTabIndex();
|
|
23
43
|
}
|
|
24
44
|
|
|
25
|
-
static get styles() {
|
|
26
|
-
return css`
|
|
27
|
-
:host {
|
|
28
|
-
display: block;
|
|
29
|
-
flex: 0 0 auto;
|
|
30
|
-
width: var(--kememt-scroll-snap-slide-width, 100%);
|
|
31
|
-
scroll-snap-align: var(--kemet-scroll-snap-slide-align, center);
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
45
|
render() {
|
|
37
46
|
return html`
|
|
38
47
|
<slot></slot>
|
|
@@ -44,4 +53,5 @@ export class KemetScrollSnapSlide extends LitElement {
|
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
// eslint-disable-next-line no-unused-expressions
|
|
57
|
+
customElements.get('kemet-scroll-snap-slide') || customElements.define('kemet-scroll-snap-slide', KemetScrollSnapSlide);
|