@solid-design-system/components 1.19.0 → 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/umd/solid-components.js +16 -16
- 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 +4 -0
- 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/internal/form.d.ts +7 -1
- 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 +2 -0
- package/dist/package/solid-components.js +12 -8
- 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 -1
- 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 +5 -1
- 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 +1 -1
- package/dist/versioned-package/components/video/video.js +2 -2
- package/dist/versioned-package/internal/form.d.ts +7 -1
- 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 +2 -0
- package/dist/versioned-package/solid-components.js +12 -8
- 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 +201 -21
- package/dist/web-types.json +910 -122
- package/package.json +3 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import "../icon/icon.js";
|
|
2
|
+
import { css, html } from "lit";
|
|
3
|
+
import { customElement } from "../../internal/register-custom-element.js";
|
|
4
|
+
import { state, property } from "lit/decorators.js";
|
|
5
|
+
import { watch } from "../../internal/watch.js";
|
|
6
|
+
import cx from "classix";
|
|
7
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
12
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
+
if (decorator = decorators[i])
|
|
14
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
15
|
+
if (kind && result)
|
|
16
|
+
__defProp(target, key, result);
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
let SdRadio = class extends SolidElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.checked = false;
|
|
23
|
+
this.hasFocus = false;
|
|
24
|
+
this.size = "lg";
|
|
25
|
+
this.invalid = false;
|
|
26
|
+
this.disabled = false;
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback();
|
|
30
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
31
|
+
this.handleClick = this.handleClick.bind(this);
|
|
32
|
+
this.handleFocus = this.handleFocus.bind(this);
|
|
33
|
+
this.setInitialAttributes();
|
|
34
|
+
this.addEventListeners();
|
|
35
|
+
}
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
this.removeEventListeners();
|
|
38
|
+
}
|
|
39
|
+
addEventListeners() {
|
|
40
|
+
this.addEventListener("blur", this.handleBlur);
|
|
41
|
+
this.addEventListener("click", this.handleClick);
|
|
42
|
+
this.addEventListener("focus", this.handleFocus);
|
|
43
|
+
}
|
|
44
|
+
removeEventListeners() {
|
|
45
|
+
this.removeEventListener("blur", this.handleBlur);
|
|
46
|
+
this.removeEventListener("click", this.handleClick);
|
|
47
|
+
this.removeEventListener("focus", this.handleFocus);
|
|
48
|
+
}
|
|
49
|
+
handleBlur() {
|
|
50
|
+
this.hasFocus = false;
|
|
51
|
+
this.emit("sd-blur");
|
|
52
|
+
}
|
|
53
|
+
handleClick() {
|
|
54
|
+
if (!this.disabled) {
|
|
55
|
+
this.checked = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
handleFocus() {
|
|
59
|
+
this.hasFocus = true;
|
|
60
|
+
this.emit("sd-focus");
|
|
61
|
+
}
|
|
62
|
+
setInitialAttributes() {
|
|
63
|
+
this.setAttribute("role", "radio");
|
|
64
|
+
this.setAttribute("tabindex", "-1");
|
|
65
|
+
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
66
|
+
}
|
|
67
|
+
handleCheckedChange() {
|
|
68
|
+
this.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
69
|
+
this.setAttribute("tabindex", this.checked ? "0" : "-1");
|
|
70
|
+
}
|
|
71
|
+
handleDisabledChange() {
|
|
72
|
+
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
73
|
+
}
|
|
74
|
+
render() {
|
|
75
|
+
return html`<span part="base" class="${cx(
|
|
76
|
+
"sd-1-20-0-radio group inline-flex items-start items-center text-base leading-normal text-black cursor-pointer align-middle",
|
|
77
|
+
this.checked && "radio--checked",
|
|
78
|
+
this.disabled && "hover:cursor-not-allowed",
|
|
79
|
+
this.hasFocus && "radio--focused",
|
|
80
|
+
{
|
|
81
|
+
/* sizes, fonts */
|
|
82
|
+
sm: "small-size text-sm",
|
|
83
|
+
lg: "text-base"
|
|
84
|
+
}[this.size]
|
|
85
|
+
)}"><span part="${`${this.checked ? "control--checked" : "control--unchecked"}`}" class="${cx(
|
|
86
|
+
"flex-initial shrink-0 relative inline-flex items-center justify-center border rounded-full bg-white h-4 w-4",
|
|
87
|
+
this.disabled && "border-neutral-500" || this.invalid && "border-error hover:border-error-400 group-hover:border-error-400" || this.checked && "border-accent hover:border-accent-550 group-hover:border-accent-550" || "border-neutral-800 hover:bg-neutral-200 group-hover:bg-neutral-200"
|
|
88
|
+
)}">${this.checked ? html`<span part="checked" class="${cx(
|
|
89
|
+
"rounded-full inline-flex text-white border bg-accent h-2.5 w-2.5",
|
|
90
|
+
this.disabled && "bg-neutral-500" || this.invalid && "bg-error hover:bg-error-400 group-hover:bg-error-400" || this.checked && "bg-accent hover:bg-accent-550 group-hover:bg-accent-550" || "bg-neutral-800"
|
|
91
|
+
)}"></span>` : ""}</span><slot part="label" class="${cx(
|
|
92
|
+
"label ml-2 select-none inline-block",
|
|
93
|
+
this.disabled && "text-neutral-500" || this.invalid && "text-error" || "text-black"
|
|
94
|
+
)}"></slot></span>`;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
SdRadio.styles = [
|
|
98
|
+
SolidElement.styles,
|
|
99
|
+
css`:host{display:block}:host(:focus-visible){outline:0}:host(:focus-visible) [part=control--checked],:host(:focus-visible) [part=control--unchecked]{outline:2px solid #00358e;outline-offset:2px}`
|
|
100
|
+
];
|
|
101
|
+
__decorateClass([
|
|
102
|
+
state()
|
|
103
|
+
], SdRadio.prototype, "checked", 2);
|
|
104
|
+
__decorateClass([
|
|
105
|
+
state()
|
|
106
|
+
], SdRadio.prototype, "hasFocus", 2);
|
|
107
|
+
__decorateClass([
|
|
108
|
+
property({ reflect: true })
|
|
109
|
+
], SdRadio.prototype, "size", 2);
|
|
110
|
+
__decorateClass([
|
|
111
|
+
property({ type: Boolean, reflect: true })
|
|
112
|
+
], SdRadio.prototype, "invalid", 2);
|
|
113
|
+
__decorateClass([
|
|
114
|
+
property({ type: Boolean, reflect: true })
|
|
115
|
+
], SdRadio.prototype, "disabled", 2);
|
|
116
|
+
__decorateClass([
|
|
117
|
+
property()
|
|
118
|
+
], SdRadio.prototype, "value", 2);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
watch("checked")
|
|
121
|
+
], SdRadio.prototype, "handleCheckedChange", 1);
|
|
122
|
+
__decorateClass([
|
|
123
|
+
watch("disabled", { waitUntilFirstUpdate: true })
|
|
124
|
+
], SdRadio.prototype, "handleDisabledChange", 1);
|
|
125
|
+
SdRadio = __decorateClass([
|
|
126
|
+
customElement("sd-1-20-0-radio")
|
|
127
|
+
], SdRadio);
|
|
128
|
+
export {
|
|
129
|
+
SdRadio as default
|
|
130
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FormControlController } from '../../internal/form';
|
|
2
|
+
import SdButtonGroup from '../../_components/button-group/button-group';
|
|
3
|
+
import SolidElement from '../../internal/solid-element';
|
|
4
|
+
import type { SolidFormControl } from '../../internal/solid-element';
|
|
5
|
+
export default class SdRadioGroup extends SolidElement implements SolidFormControl {
|
|
6
|
+
static dependencies: {
|
|
7
|
+
'sd-1-20-0-button-group': typeof SdButtonGroup;
|
|
8
|
+
};
|
|
9
|
+
protected readonly formControlController: FormControlController;
|
|
10
|
+
private readonly hasSlotController;
|
|
11
|
+
private customValidityMessage;
|
|
12
|
+
private validationTimeout;
|
|
13
|
+
defaultSlot: HTMLSlotElement;
|
|
14
|
+
validationInput: HTMLInputElement;
|
|
15
|
+
private hasButtonGroup;
|
|
16
|
+
defaultValue: string;
|
|
17
|
+
private invalid;
|
|
18
|
+
private errorText;
|
|
19
|
+
label: string;
|
|
20
|
+
name: string;
|
|
21
|
+
value: string;
|
|
22
|
+
size: 'lg' | 'sm';
|
|
23
|
+
form: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
orientation: 'horizontal' | 'vertical';
|
|
26
|
+
get validity(): ValidityState;
|
|
27
|
+
get validationMessage(): string;
|
|
28
|
+
connectedCallback(): void;
|
|
29
|
+
firstUpdated(): void;
|
|
30
|
+
private getAllRadios;
|
|
31
|
+
private handleRadioClick;
|
|
32
|
+
private handleKeyDown;
|
|
33
|
+
private handleLabelClick;
|
|
34
|
+
private handleInvalid;
|
|
35
|
+
private syncRadioElements;
|
|
36
|
+
private syncRadios;
|
|
37
|
+
private updateCheckedRadio;
|
|
38
|
+
handleSizeChange(): void;
|
|
39
|
+
handleInvalidChange(): void;
|
|
40
|
+
handleValueChange(): void;
|
|
41
|
+
checkValidity(): boolean;
|
|
42
|
+
getForm(): HTMLFormElement | null;
|
|
43
|
+
reportValidity(): boolean;
|
|
44
|
+
setCustomValidity(message?: string): void;
|
|
45
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
46
|
+
static styles: import("lit").CSSResultGroup[];
|
|
47
|
+
}
|
|
48
|
+
declare global {
|
|
49
|
+
interface HTMLElementTagNameMap {
|
|
50
|
+
'sd-1-20-0-radio-group': SdRadioGroup;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -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
|
|
@@ -87,7 +87,7 @@ let SdVideo = class extends SolidElement {
|
|
|
87
87
|
this.playing ? "opacity-0" : "opacity-100",
|
|
88
88
|
this.isBelowBreakpoint ? "w-[48px] h-[48px]" : "w-[96px] h-[96px]",
|
|
89
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-
|
|
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
91
|
this.overlay && !this.playing ? "opacity-100" : "opacity-0",
|
|
92
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
93
|
)}"></div><slot></slot></div>`;
|
|
@@ -110,7 +110,7 @@ __decorateClass([
|
|
|
110
110
|
property({ type: Boolean })
|
|
111
111
|
], SdVideo.prototype, "isBelowBreakpoint", 2);
|
|
112
112
|
SdVideo = __decorateClass([
|
|
113
|
-
customElement("sd-1-
|
|
113
|
+
customElement("sd-1-20-0-video")
|
|
114
114
|
], SdVideo);
|
|
115
115
|
export {
|
|
116
116
|
SdVideo as default
|
|
@@ -10,6 +10,7 @@ export interface FormControlControllerOptions {
|
|
|
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;
|