@solid-design-system/components 1.18.1 → 1.20.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/dist/components/es/button.js +1 -1
- package/dist/components/es/drawer.js +1 -1
- package/dist/components/es/form.js +1 -0
- package/dist/components/es/radio-group.js +1 -0
- package/dist/components/es/radio.js +1 -0
- package/dist/components/es/solid-components2.js +1 -1
- package/dist/components/es/solid-element.js +4 -4
- package/dist/components/es/video.js +1 -0
- package/dist/components/umd/solid-components.js +17 -17
- package/dist/custom-elements.json +1 -1
- package/dist/package/_components/button-group/button-group.d.ts +19 -0
- package/dist/package/_components/button-group/button-group.js +76 -0
- package/dist/package/_components/button-group/button-group.styles.d.ts +2 -0
- package/dist/package/_components/button-group/button-group.styles.js +6 -0
- package/dist/package/components/button/button.d.ts +5 -1
- package/dist/package/components/button/button.js +25 -3
- package/dist/package/components/radio/radio.d.ts +27 -0
- package/dist/package/components/radio/radio.js +130 -0
- package/dist/package/components/radio-group/radio-group.d.ts +52 -0
- package/dist/package/components/radio-group/radio-group.js +321 -0
- package/dist/package/components/video/video.d.ts +24 -0
- package/dist/package/components/video/video.js +117 -0
- package/dist/package/internal/form.d.ts +9 -3
- package/dist/package/internal/form.js +110 -49
- package/dist/package/internal/solid-element.d.ts +2 -0
- package/dist/package/solid-components.d.ts +3 -0
- package/dist/package/solid-components.js +12 -6
- package/dist/package/styles/tailwind.css.js +1 -1
- package/dist/versioned-components/es/accordion-group.js +1 -1
- package/dist/versioned-components/es/accordion.js +1 -1
- package/dist/versioned-components/es/badge.js +1 -1
- package/dist/versioned-components/es/brandshape.js +1 -1
- package/dist/versioned-components/es/button.js +1 -1
- package/dist/versioned-components/es/carousel-item.js +1 -1
- package/dist/versioned-components/es/carousel.js +3 -3
- package/dist/versioned-components/es/divider.js +1 -1
- package/dist/versioned-components/es/drawer.js +1 -1
- package/dist/versioned-components/es/dropdown.js +1 -1
- package/dist/versioned-components/es/form.js +1 -0
- package/dist/versioned-components/es/icon.js +1 -1
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/navigation-item.js +1 -1
- package/dist/versioned-components/es/popup.js +1 -1
- package/dist/versioned-components/es/radio-group.js +1 -0
- package/dist/versioned-components/es/radio.js +1 -0
- package/dist/versioned-components/es/solid-components2.js +1 -1
- package/dist/versioned-components/es/solid-element.js +4 -4
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/tag.js +1 -1
- package/dist/versioned-components/es/teaser.js +1 -1
- package/dist/versioned-components/es/video.js +1 -0
- package/dist/versioned-package/_components/button-group/button-group.d.ts +19 -0
- package/dist/versioned-package/_components/button-group/button-group.js +76 -0
- package/dist/versioned-package/_components/button-group/button-group.styles.d.ts +2 -0
- package/dist/versioned-package/_components/button-group/button-group.styles.js +6 -0
- package/dist/versioned-package/components/accordion/accordion.d.ts +1 -1
- package/dist/versioned-package/components/accordion/accordion.js +2 -2
- package/dist/versioned-package/components/accordion-group/accordion-group.d.ts +1 -1
- package/dist/versioned-package/components/accordion-group/accordion-group.js +3 -3
- package/dist/versioned-package/components/badge/badge.d.ts +1 -1
- package/dist/versioned-package/components/badge/badge.js +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.d.ts +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.js +1 -1
- package/dist/versioned-package/components/button/button.d.ts +6 -2
- package/dist/versioned-package/components/button/button.js +29 -7
- package/dist/versioned-package/components/carousel/carousel.d.ts +1 -1
- package/dist/versioned-package/components/carousel/carousel.js +6 -6
- package/dist/versioned-package/components/carousel-item/carousel-item.d.ts +1 -1
- package/dist/versioned-package/components/carousel-item/carousel-item.js +1 -1
- package/dist/versioned-package/components/divider/divider.d.ts +1 -1
- package/dist/versioned-package/components/divider/divider.js +2 -2
- package/dist/versioned-package/components/drawer/drawer.d.ts +1 -1
- package/dist/versioned-package/components/drawer/drawer.js +2 -2
- package/dist/versioned-package/components/dropdown/dropdown.d.ts +1 -1
- package/dist/versioned-package/components/dropdown/dropdown.js +6 -6
- package/dist/versioned-package/components/icon/icon.d.ts +1 -1
- package/dist/versioned-package/components/icon/icon.js +1 -1
- package/dist/versioned-package/components/include/include.d.ts +1 -1
- package/dist/versioned-package/components/include/include.js +1 -1
- package/dist/versioned-package/components/link/link.d.ts +1 -1
- package/dist/versioned-package/components/link/link.js +2 -2
- package/dist/versioned-package/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.js +3 -3
- package/dist/versioned-package/components/popup/popup.d.ts +1 -1
- package/dist/versioned-package/components/popup/popup.js +1 -1
- package/dist/versioned-package/components/radio/radio.d.ts +27 -0
- package/dist/versioned-package/components/radio/radio.js +130 -0
- package/dist/versioned-package/components/radio-group/radio-group.d.ts +52 -0
- package/dist/versioned-package/components/radio-group/radio-group.js +321 -0
- package/dist/versioned-package/components/spinner/spinner.d.ts +1 -1
- package/dist/versioned-package/components/spinner/spinner.js +1 -1
- package/dist/versioned-package/components/tag/tag.d.ts +1 -1
- package/dist/versioned-package/components/tag/tag.js +2 -2
- package/dist/versioned-package/components/teaser/teaser.js +1 -1
- package/dist/versioned-package/components/video/video.d.ts +24 -0
- package/dist/versioned-package/components/video/video.js +117 -0
- package/dist/versioned-package/internal/form.d.ts +9 -3
- package/dist/versioned-package/internal/form.js +110 -49
- package/dist/versioned-package/internal/solid-element.d.ts +2 -0
- package/dist/versioned-package/solid-components.d.ts +3 -0
- package/dist/versioned-package/solid-components.js +12 -6
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/versioned-styles/solid-styles.css +1 -1
- package/dist/vscode.html-custom-data.json +244 -20
- package/dist/web-types.json +1370 -380
- package/package.json +16 -9
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { customElement } from "../../internal/register-custom-element.js";
|
|
3
|
+
import { FormControlController, customErrorValidityState, valueMissingValidityState, validValidityState } from "../../internal/form.js";
|
|
4
|
+
import { HasSlotController } from "../../internal/slot.js";
|
|
5
|
+
import { query, state, property } from "lit/decorators.js";
|
|
6
|
+
import { watch } from "../../internal/watch.js";
|
|
7
|
+
import componentStyles from "../../styles/component.styles.js";
|
|
8
|
+
import cx from "classix";
|
|
9
|
+
import SdButtonGroup from "../../_components/button-group/button-group.js";
|
|
10
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
14
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
15
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16
|
+
if (decorator = decorators[i])
|
|
17
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
18
|
+
if (kind && result)
|
|
19
|
+
__defProp(target, key, result);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
let SdRadioGroup = class extends SolidElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.formControlController = new FormControlController(this);
|
|
26
|
+
this.hasSlotController = new HasSlotController(this, "label", "error-text");
|
|
27
|
+
this.customValidityMessage = "";
|
|
28
|
+
this.hasButtonGroup = false;
|
|
29
|
+
this.defaultValue = "";
|
|
30
|
+
this.invalid = false;
|
|
31
|
+
this.errorText = "";
|
|
32
|
+
this.label = "";
|
|
33
|
+
this.name = "option";
|
|
34
|
+
this.value = "";
|
|
35
|
+
this.size = "lg";
|
|
36
|
+
this.form = "";
|
|
37
|
+
this.required = false;
|
|
38
|
+
this.orientation = "vertical";
|
|
39
|
+
}
|
|
40
|
+
/** Gets the validity state object */
|
|
41
|
+
get validity() {
|
|
42
|
+
const isRequiredAndEmpty = this.required && !this.value;
|
|
43
|
+
const hasCustomValidityMessage = this.customValidityMessage !== "";
|
|
44
|
+
if (hasCustomValidityMessage) {
|
|
45
|
+
this.invalid = true;
|
|
46
|
+
return customErrorValidityState;
|
|
47
|
+
} else if (isRequiredAndEmpty) {
|
|
48
|
+
this.invalid = true;
|
|
49
|
+
return valueMissingValidityState;
|
|
50
|
+
}
|
|
51
|
+
this.invalid = false;
|
|
52
|
+
return validValidityState;
|
|
53
|
+
}
|
|
54
|
+
/** Gets the validation message */
|
|
55
|
+
get validationMessage() {
|
|
56
|
+
const isRequiredAndEmpty = this.required && !this.value;
|
|
57
|
+
const hasCustomValidityMessage = this.customValidityMessage !== "";
|
|
58
|
+
if (hasCustomValidityMessage) {
|
|
59
|
+
console.log("this.customValidityMessage", this.customValidityMessage);
|
|
60
|
+
return this.customValidityMessage;
|
|
61
|
+
} else if (isRequiredAndEmpty) {
|
|
62
|
+
console.log("this.validationInput.validationMessage", this.validationInput);
|
|
63
|
+
return this.validationInput.validationMessage;
|
|
64
|
+
}
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
connectedCallback() {
|
|
68
|
+
super.connectedCallback();
|
|
69
|
+
this.defaultValue = this.value;
|
|
70
|
+
}
|
|
71
|
+
firstUpdated() {
|
|
72
|
+
this.formControlController.updateValidity();
|
|
73
|
+
}
|
|
74
|
+
getAllRadios() {
|
|
75
|
+
return [...this.querySelectorAll("sd-1-20-0-radio, sd-1-20-0-radio-button")];
|
|
76
|
+
}
|
|
77
|
+
handleRadioClick(event) {
|
|
78
|
+
const target = event.target.closest("sd-1-20-0-radio, sd-1-20-0-radio-button");
|
|
79
|
+
const radios = this.getAllRadios();
|
|
80
|
+
const oldValue = this.value;
|
|
81
|
+
if (target.disabled) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.value = target.value;
|
|
85
|
+
radios.forEach((radio) => radio.checked = radio === target);
|
|
86
|
+
if (this.value !== oldValue) {
|
|
87
|
+
this.emit("sd-change");
|
|
88
|
+
this.emit("sd-input");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
handleKeyDown(event) {
|
|
92
|
+
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", " "].includes(event.key)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const radios = this.getAllRadios().filter((radio) => !radio.disabled);
|
|
96
|
+
const checkedRadio = radios.find((radio) => radio.checked) ?? radios[0];
|
|
97
|
+
const incr = event.key === " " ? 0 : ["ArrowUp", "ArrowLeft"].includes(event.key) ? -1 : 1;
|
|
98
|
+
const oldValue = this.value;
|
|
99
|
+
let index = radios.indexOf(checkedRadio) + incr;
|
|
100
|
+
if (index < 0) {
|
|
101
|
+
index = radios.length - 1;
|
|
102
|
+
}
|
|
103
|
+
if (index > radios.length - 1) {
|
|
104
|
+
index = 0;
|
|
105
|
+
}
|
|
106
|
+
this.getAllRadios().forEach((radio) => {
|
|
107
|
+
radio.checked = false;
|
|
108
|
+
if (!this.hasButtonGroup) {
|
|
109
|
+
radio.tabIndex = -1;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
this.value = radios[index].value;
|
|
113
|
+
radios[index].checked = true;
|
|
114
|
+
if (!this.hasButtonGroup) {
|
|
115
|
+
radios[index].tabIndex = 0;
|
|
116
|
+
radios[index].focus();
|
|
117
|
+
} else {
|
|
118
|
+
radios[index].shadowRoot.querySelector("button").focus();
|
|
119
|
+
}
|
|
120
|
+
if (this.value !== oldValue) {
|
|
121
|
+
this.emit("sd-change");
|
|
122
|
+
this.emit("sd-input");
|
|
123
|
+
}
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
}
|
|
126
|
+
handleLabelClick() {
|
|
127
|
+
const radios = this.getAllRadios();
|
|
128
|
+
const checked = radios.find((radio) => radio.checked);
|
|
129
|
+
const radioToFocus = checked || radios[0];
|
|
130
|
+
if (radioToFocus) {
|
|
131
|
+
radioToFocus.focus();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
handleInvalid(event) {
|
|
135
|
+
this.formControlController.setValidity(false);
|
|
136
|
+
this.formControlController.emitInvalidEvent(event);
|
|
137
|
+
}
|
|
138
|
+
async syncRadioElements() {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
const radios = this.getAllRadios();
|
|
141
|
+
await Promise.all(
|
|
142
|
+
// Sync the checked state and size
|
|
143
|
+
radios.map(async (radio) => {
|
|
144
|
+
await radio.updateComplete;
|
|
145
|
+
radio.checked = radio.value === this.value;
|
|
146
|
+
radio.size = this.size;
|
|
147
|
+
radio.invalid = this.invalid;
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
this.hasButtonGroup = radios.some((radio) => radio.tagName.toLowerCase() === "sd-1-20-0-radio-button");
|
|
151
|
+
if (!radios.some((radio) => radio.checked)) {
|
|
152
|
+
if (this.hasButtonGroup) {
|
|
153
|
+
const buttonRadio = (_a = radios[0].shadowRoot) == null ? void 0 : _a.querySelector("button");
|
|
154
|
+
if (buttonRadio) {
|
|
155
|
+
buttonRadio.tabIndex = 0;
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
radios[0].tabIndex = 0;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (this.hasButtonGroup) {
|
|
162
|
+
const buttonGroup = (_b = this.shadowRoot) == null ? void 0 : _b.querySelector("sd-1-20-0-button-group");
|
|
163
|
+
if (buttonGroup) {
|
|
164
|
+
buttonGroup.disableRole = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
syncRadios() {
|
|
169
|
+
if (customElements.get("sd-1-20-0-radio") && customElements.get("sd-1-20-0-radio-button")) {
|
|
170
|
+
this.syncRadioElements();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (customElements.get("sd-1-20-0-radio")) {
|
|
174
|
+
this.syncRadioElements();
|
|
175
|
+
} else {
|
|
176
|
+
customElements.whenDefined("sd-1-20-0-radio").then(() => this.syncRadios());
|
|
177
|
+
}
|
|
178
|
+
if (customElements.get("sd-1-20-0-radio-button")) {
|
|
179
|
+
this.syncRadioElements();
|
|
180
|
+
} else {
|
|
181
|
+
customElements.whenDefined("sd-1-20-0-radio-button").then(() => this.syncRadios());
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
updateCheckedRadio() {
|
|
185
|
+
const radios = this.getAllRadios();
|
|
186
|
+
radios.forEach((radio) => radio.checked = radio.value === this.value);
|
|
187
|
+
this.formControlController.setValidity(this.validity.valid);
|
|
188
|
+
}
|
|
189
|
+
handleSizeChange() {
|
|
190
|
+
this.syncRadios();
|
|
191
|
+
}
|
|
192
|
+
handleInvalidChange() {
|
|
193
|
+
this.syncRadios();
|
|
194
|
+
}
|
|
195
|
+
handleValueChange() {
|
|
196
|
+
if (this.hasUpdated) {
|
|
197
|
+
this.updateCheckedRadio();
|
|
198
|
+
this.reportValidity();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
|
|
202
|
+
checkValidity() {
|
|
203
|
+
const isRequiredAndEmpty = this.required && !this.value;
|
|
204
|
+
const hasCustomValidityMessage = this.customValidityMessage !== "";
|
|
205
|
+
if (isRequiredAndEmpty || hasCustomValidityMessage) {
|
|
206
|
+
this.formControlController.emitInvalidEvent();
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
/** Gets the associated form, if one exists. */
|
|
212
|
+
getForm() {
|
|
213
|
+
return this.formControlController.getForm();
|
|
214
|
+
}
|
|
215
|
+
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
216
|
+
// TODO: https://github.com/solid-design-system/solid/issues/501
|
|
217
|
+
reportValidity() {
|
|
218
|
+
const isValid = this.validity.valid;
|
|
219
|
+
this.errorText = this.customValidityMessage || isValid ? "" : this.validationInput.validationMessage;
|
|
220
|
+
this.formControlController.setValidity(isValid);
|
|
221
|
+
this.validationInput.hidden = true;
|
|
222
|
+
clearTimeout(this.validationTimeout);
|
|
223
|
+
if (!isValid) {
|
|
224
|
+
this.validationInput.hidden = false;
|
|
225
|
+
this.validationInput.reportValidity();
|
|
226
|
+
this.validationTimeout = setTimeout(() => this.validationInput.hidden = true, 1e4);
|
|
227
|
+
}
|
|
228
|
+
return isValid;
|
|
229
|
+
}
|
|
230
|
+
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
231
|
+
setCustomValidity(message = "") {
|
|
232
|
+
this.customValidityMessage = message;
|
|
233
|
+
this.errorText = message;
|
|
234
|
+
this.validationInput.setCustomValidity(message);
|
|
235
|
+
this.formControlController.updateValidity();
|
|
236
|
+
}
|
|
237
|
+
render() {
|
|
238
|
+
const hasLabelSlot = this.hasSlotController.test("label");
|
|
239
|
+
const hasErrorTextSlot = this.hasSlotController.test("error-text");
|
|
240
|
+
const hasLabel = this.label ? true : !!hasLabelSlot;
|
|
241
|
+
const hasErrorText = this.errorText ? true : !!hasErrorTextSlot;
|
|
242
|
+
const defaultSlot = html`<slot @slotchange="${this.syncRadios}" @click="${this.handleRadioClick}" @keydown="${this.handleKeyDown}"></slot>`;
|
|
243
|
+
return html`<fieldset part="form-control" class="${cx(
|
|
244
|
+
"form-control form-control--radio-group border-0 p-0 m-0",
|
|
245
|
+
hasLabel && "form-control--has-label",
|
|
246
|
+
hasErrorText && "text-error",
|
|
247
|
+
{
|
|
248
|
+
/* sizes, fonts */
|
|
249
|
+
sm: "text-sm",
|
|
250
|
+
lg: "text-base"
|
|
251
|
+
}[this.size]
|
|
252
|
+
)}" role="radiogroup" aria-labelledby="label" aria-errormessage="error-text"><label part="form-control-label" id="label" class="form-control__label mb-2 hidden p-0 font-bold leading-normal text-black" aria-hidden="${!hasLabel}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="${cx(
|
|
253
|
+
"form-control-input flex",
|
|
254
|
+
this.invalid && "form-control-input--invalid text-error",
|
|
255
|
+
{
|
|
256
|
+
vertical: "form-control-input--vertical flex-col",
|
|
257
|
+
horizontal: "form-control-input--horizontal flex-row"
|
|
258
|
+
}[this.orientation]
|
|
259
|
+
)}"><div class="sr-only"><div id="error-message" aria-live="assertive">${this.errorText}</div><label class="radio-group__validation"><input type="text" class="radio-group__validation-input" ?required="${this.required}" tabindex="-1" hidden @invalid="${this.handleInvalid}"></label></div>${defaultSlot}</div></fieldset>`;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
SdRadioGroup.dependencies = { "sd-1-20-0-button-group": SdButtonGroup };
|
|
263
|
+
SdRadioGroup.styles = [
|
|
264
|
+
componentStyles,
|
|
265
|
+
SolidElement.styles,
|
|
266
|
+
css`:host{display:block}.form-control-input--vertical ::slotted(sd-1-20-0-radio){margin-bottom:8px;display:flex}.form-control-input--vertical ::slotted(sd-1-20-0-radio:last-of-type){margin-bottom:0}.form-control-input--horizontal ::slotted(sd-1-20-0-radio){margin-right:24px}.form-control-input--horizontal ::slotted(sd-1-20-0-radio:last-of-type){margin-right:0}.form-control--has-label .form-control__label{display:flex}:host([required]) .form-control--has-label .form-control__label::after{content:'*';margin-left:2px}`
|
|
267
|
+
];
|
|
268
|
+
__decorateClass([
|
|
269
|
+
query("slot:not([name])")
|
|
270
|
+
], SdRadioGroup.prototype, "defaultSlot", 2);
|
|
271
|
+
__decorateClass([
|
|
272
|
+
query(".radio-group__validation-input")
|
|
273
|
+
], SdRadioGroup.prototype, "validationInput", 2);
|
|
274
|
+
__decorateClass([
|
|
275
|
+
state()
|
|
276
|
+
], SdRadioGroup.prototype, "hasButtonGroup", 2);
|
|
277
|
+
__decorateClass([
|
|
278
|
+
state()
|
|
279
|
+
], SdRadioGroup.prototype, "defaultValue", 2);
|
|
280
|
+
__decorateClass([
|
|
281
|
+
state()
|
|
282
|
+
], SdRadioGroup.prototype, "invalid", 2);
|
|
283
|
+
__decorateClass([
|
|
284
|
+
state()
|
|
285
|
+
], SdRadioGroup.prototype, "errorText", 2);
|
|
286
|
+
__decorateClass([
|
|
287
|
+
property()
|
|
288
|
+
], SdRadioGroup.prototype, "label", 2);
|
|
289
|
+
__decorateClass([
|
|
290
|
+
property()
|
|
291
|
+
], SdRadioGroup.prototype, "name", 2);
|
|
292
|
+
__decorateClass([
|
|
293
|
+
property({ reflect: true })
|
|
294
|
+
], SdRadioGroup.prototype, "value", 2);
|
|
295
|
+
__decorateClass([
|
|
296
|
+
property({ reflect: true })
|
|
297
|
+
], SdRadioGroup.prototype, "size", 2);
|
|
298
|
+
__decorateClass([
|
|
299
|
+
property({ reflect: true })
|
|
300
|
+
], SdRadioGroup.prototype, "form", 2);
|
|
301
|
+
__decorateClass([
|
|
302
|
+
property({ type: Boolean, reflect: true })
|
|
303
|
+
], SdRadioGroup.prototype, "required", 2);
|
|
304
|
+
__decorateClass([
|
|
305
|
+
property({ reflect: true })
|
|
306
|
+
], SdRadioGroup.prototype, "orientation", 2);
|
|
307
|
+
__decorateClass([
|
|
308
|
+
watch("size", { waitUntilFirstUpdate: true })
|
|
309
|
+
], SdRadioGroup.prototype, "handleSizeChange", 1);
|
|
310
|
+
__decorateClass([
|
|
311
|
+
watch("invalid", { waitUntilFirstUpdate: true })
|
|
312
|
+
], SdRadioGroup.prototype, "handleInvalidChange", 1);
|
|
313
|
+
__decorateClass([
|
|
314
|
+
watch("value")
|
|
315
|
+
], SdRadioGroup.prototype, "handleValueChange", 1);
|
|
316
|
+
SdRadioGroup = __decorateClass([
|
|
317
|
+
customElement("sd-1-20-0-radio-group")
|
|
318
|
+
], SdRadioGroup);
|
|
319
|
+
export {
|
|
320
|
+
SdRadioGroup as default
|
|
321
|
+
};
|
|
@@ -72,7 +72,7 @@ let SdTag = class extends SolidElement {
|
|
|
72
72
|
lg: "text-base",
|
|
73
73
|
sm: "text-[12px]"
|
|
74
74
|
}[this.size]
|
|
75
|
-
)}"><sd-1-
|
|
75
|
+
)}"><sd-1-20-0-icon library="system" name="close" label="remove"></sd-1-20-0-icon></slot></${tag}>`;
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
SdTag.styles = [
|
|
@@ -104,7 +104,7 @@ __decorateClass([
|
|
|
104
104
|
property()
|
|
105
105
|
], SdTag.prototype, "download", 2);
|
|
106
106
|
SdTag = __decorateClass([
|
|
107
|
-
customElement("sd-1-
|
|
107
|
+
customElement("sd-1-20-0-tag")
|
|
108
108
|
], SdTag);
|
|
109
109
|
export {
|
|
110
110
|
SdTag as default
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element';
|
|
2
|
+
export default class SdVideo extends SolidElement {
|
|
3
|
+
hostEl: HTMLElement;
|
|
4
|
+
playing: boolean;
|
|
5
|
+
overlay: boolean;
|
|
6
|
+
isBelowBreakpoint: boolean;
|
|
7
|
+
private resizeObserver;
|
|
8
|
+
private readonly hasSlotController;
|
|
9
|
+
private get poster();
|
|
10
|
+
private fadeoutPoster;
|
|
11
|
+
private hidePoster;
|
|
12
|
+
private play;
|
|
13
|
+
private handleKeydown;
|
|
14
|
+
private handleButtonResize;
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
18
|
+
static styles: import("lit").CSSResultGroup[];
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'sd-1-20-0-video': SdVideo;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { customElement } from "../../internal/register-custom-element.js";
|
|
3
|
+
import { HasSlotController } from "../../internal/slot.js";
|
|
4
|
+
import { query, property } from "lit/decorators.js";
|
|
5
|
+
import cx from "classix";
|
|
6
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
11
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
if (decorator = decorators[i])
|
|
13
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
14
|
+
if (kind && result)
|
|
15
|
+
__defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
let SdVideo = class extends SolidElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.playing = false;
|
|
22
|
+
this.overlay = false;
|
|
23
|
+
this.isBelowBreakpoint = false;
|
|
24
|
+
this.hasSlotController = new HasSlotController(this, "[default]", "play-icon", "poster");
|
|
25
|
+
}
|
|
26
|
+
/** Getter for optional poster slot. */
|
|
27
|
+
get poster() {
|
|
28
|
+
const slot = this.shadowRoot.querySelector("slot[name=poster]");
|
|
29
|
+
if ((slot == null ? void 0 : slot.assignedElements().length) > 0) {
|
|
30
|
+
return slot.assignedElements()[0];
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
/** Fade out poster after initial play. */
|
|
35
|
+
fadeoutPoster() {
|
|
36
|
+
if (this.poster instanceof HTMLImageElement) {
|
|
37
|
+
this.poster.style.opacity = "0";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Hide poster after initial play & fadeout. */
|
|
41
|
+
hidePoster() {
|
|
42
|
+
if (this.poster instanceof HTMLImageElement) {
|
|
43
|
+
this.poster.style.display = "none";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Utility function to group play behaviors. */
|
|
47
|
+
play() {
|
|
48
|
+
this.emit("sd-play");
|
|
49
|
+
this.playing = true;
|
|
50
|
+
this.fadeoutPoster();
|
|
51
|
+
}
|
|
52
|
+
/** Restrict keydown control to enter and space bar to mimic the native video tag behavior. If a KeyboardEvent is used, refocus on the native video element to give the user seamless keyboard control. */
|
|
53
|
+
handleKeydown(e) {
|
|
54
|
+
if (e instanceof KeyboardEvent && (e.key === "Enter" || e.key === " ")) {
|
|
55
|
+
this.play();
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
var _a;
|
|
58
|
+
(_a = this.querySelector("video")) == null ? void 0 : _a.focus();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Resize the play-button-bg when passing host element width breakpoint 414px. */
|
|
63
|
+
handleButtonResize() {
|
|
64
|
+
if (this.hostEl.clientWidth <= 414 && !this.isBelowBreakpoint) {
|
|
65
|
+
this.isBelowBreakpoint = true;
|
|
66
|
+
}
|
|
67
|
+
if (this.hostEl.clientWidth > 414 && this.isBelowBreakpoint) {
|
|
68
|
+
this.isBelowBreakpoint = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
connectedCallback() {
|
|
72
|
+
super.connectedCallback();
|
|
73
|
+
this.resizeObserver = new ResizeObserver(() => this.handleButtonResize());
|
|
74
|
+
this.updateComplete.then(() => {
|
|
75
|
+
this.resizeObserver.observe(this.hostEl);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
disconnectedCallback() {
|
|
79
|
+
super.disconnectedCallback();
|
|
80
|
+
this.resizeObserver.unobserve(this.hostEl);
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
return html`<div part="base" aria-label="Video Player" class="cursor-pointer"><button part="play-button" aria-label="Play video" tabindex="0" @click="${this.play}" @keydown="${this.handleKeydown}" class="${cx(
|
|
84
|
+
this.playing && "pointer-events-none",
|
|
85
|
+
"w-full h-full absolute top-0 left-0 z-30 text-primary hover:text-primary-500 sd-interactive sd-interactive--reset focus-visible:focus-outline"
|
|
86
|
+
)}"><div part="play-button-bg" class="${cx(
|
|
87
|
+
this.playing ? "opacity-0" : "opacity-100",
|
|
88
|
+
this.isBelowBreakpoint ? "w-[48px] h-[48px]" : "w-[96px] h-[96px]",
|
|
89
|
+
"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 p-4 bg-white bg-opacity-75 rounded-full play-pause-transition"
|
|
90
|
+
)}"><slot name="play-icon" part="play-icon" class="${cx(this.isBelowBreakpoint ? "text-[2rem]" : "text-[4rem]")}"><sd-1-20-0-icon id="default-play-icon" library="system" name="start"></sd-1-20-0-icon></slot></div></button> ${this.hasSlotController.test("poster") ? html`<slot name="poster" role="presentation" @transitionend="${this.hidePoster}"></slot>` : null}<div part="overlay" id="overlay" role="presentation" class="${cx(
|
|
91
|
+
this.overlay && !this.playing ? "opacity-100" : "opacity-0",
|
|
92
|
+
"bg-[rgba(0,0,0,0.65)] w-full h-full absolute top-0 left-0 pointer-events-none z-20 play-pause-transition"
|
|
93
|
+
)}"></div><slot></slot></div>`;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
SdVideo.styles = [
|
|
97
|
+
SolidElement.styles,
|
|
98
|
+
css`:host{position:relative;display:inline-block;overflow:hidden}.play-pause-transition,::slotted([slot=poster]){transition:opacity .3s}::slotted([slot=poster]){position:absolute;left:0;top:0;width:100%;z-index:10}#default-play-icon,::slotted([slot=play-icon]){position:absolute;left:50%;top:50%;translate:-50% -50%}`
|
|
99
|
+
];
|
|
100
|
+
__decorateClass([
|
|
101
|
+
query("[part=base]")
|
|
102
|
+
], SdVideo.prototype, "hostEl", 2);
|
|
103
|
+
__decorateClass([
|
|
104
|
+
property({ type: Boolean, reflect: true })
|
|
105
|
+
], SdVideo.prototype, "playing", 2);
|
|
106
|
+
__decorateClass([
|
|
107
|
+
property({ type: Boolean, reflect: true })
|
|
108
|
+
], SdVideo.prototype, "overlay", 2);
|
|
109
|
+
__decorateClass([
|
|
110
|
+
property({ type: Boolean })
|
|
111
|
+
], SdVideo.prototype, "isBelowBreakpoint", 2);
|
|
112
|
+
SdVideo = __decorateClass([
|
|
113
|
+
customElement("sd-1-20-0-video")
|
|
114
|
+
], SdVideo);
|
|
115
|
+
export {
|
|
116
|
+
SdVideo as default
|
|
117
|
+
};
|
|
@@ -5,11 +5,12 @@ export declare const formCollections: WeakMap<HTMLFormElement, Set<SolidFormCont
|
|
|
5
5
|
export interface FormControlControllerOptions {
|
|
6
6
|
form: (input: SolidFormControl) => HTMLFormElement | null;
|
|
7
7
|
name: (input: SolidFormControl) => string;
|
|
8
|
-
value: (input: SolidFormControl) => unknown
|
|
9
|
-
defaultValue: (input: SolidFormControl) => unknown
|
|
8
|
+
value: (input: SolidFormControl) => unknown;
|
|
9
|
+
defaultValue: (input: SolidFormControl) => unknown;
|
|
10
10
|
disabled: (input: SolidFormControl) => boolean;
|
|
11
11
|
reportValidity: (input: SolidFormControl) => boolean;
|
|
12
12
|
setValue: (input: SolidFormControl, value: unknown) => void;
|
|
13
|
+
assumeInteractionOn: string[];
|
|
13
14
|
}
|
|
14
15
|
export declare class FormControlController implements ReactiveController {
|
|
15
16
|
host: SolidFormControl & ReactiveControllerHost;
|
|
@@ -24,12 +25,17 @@ export declare class FormControlController implements ReactiveController {
|
|
|
24
25
|
private handleFormData;
|
|
25
26
|
private handleFormSubmit;
|
|
26
27
|
private handleFormReset;
|
|
27
|
-
private
|
|
28
|
+
private handleInteraction;
|
|
28
29
|
private reportFormValidity;
|
|
29
30
|
private setUserInteracted;
|
|
30
31
|
private doAction;
|
|
32
|
+
getForm(): HTMLFormElement | null;
|
|
31
33
|
reset(invoker?: HTMLInputElement | SdButton): void;
|
|
32
34
|
submit(invoker?: HTMLInputElement | SdButton): void;
|
|
33
35
|
setValidity(isValid: boolean): void;
|
|
34
36
|
updateValidity(): void;
|
|
37
|
+
emitInvalidEvent(originalInvalidEvent?: Event): void;
|
|
35
38
|
}
|
|
39
|
+
export declare const validValidityState: ValidityState;
|
|
40
|
+
export declare const valueMissingValidityState: ValidityState;
|
|
41
|
+
export declare const customErrorValidityState: ValidityState;
|