@cas-smartdesign/radio-button-group 4.0.1
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/LICENSE +8 -0
- package/dist/docs/4_validation.js +1 -0
- package/dist/docs/5_segmented_button.js +1 -0
- package/dist/docs/doc.css +1 -0
- package/dist/docs/doc.mjs +522 -0
- package/dist/docs/index.html +23 -0
- package/dist/radio-button-group-with-externals.js +102 -0
- package/dist/radio-button-group-with-externals.js.map +7 -0
- package/dist/radio-button-group.d.ts +61 -0
- package/dist/radio-button-group.mjs +276 -0
- package/dist/radio-button-group.mjs.map +1 -0
- package/dist/radio-button.d.ts +19 -0
- package/dist/types.d.ts +5 -0
- package/npm-third-party-licenses.json +192 -0
- package/package.json +38 -0
- package/readme.md +66 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { LitElement, TemplateResult, PropertyValues } from "lit";
|
|
2
|
+
import { ValidationLevel } from "@cas-smartdesign/field-validation-message";
|
|
3
|
+
import type { LayoutType, IValueChangeEvent } from "./types";
|
|
4
|
+
export { RadioButton } from "./radio-button";
|
|
5
|
+
export type * from "./types";
|
|
6
|
+
declare global {
|
|
7
|
+
interface HTMLElementTagNameMap {
|
|
8
|
+
[RadioButtonGroup.ID]: RadioButtonGroup;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export interface CustomEventMap extends HTMLElementEventMap {
|
|
12
|
+
"value-change": CustomEvent<IValueChangeEvent>;
|
|
13
|
+
}
|
|
14
|
+
export interface RadioButtonGroup {
|
|
15
|
+
addEventListener<K extends keyof CustomEventMap>(event: K, listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null, options?: AddEventListenerOptions | boolean): void;
|
|
16
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
|
|
17
|
+
removeEventListener<K extends keyof CustomEventMap>(type: K, listener: (this: this, ev: CustomEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
18
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
19
|
+
dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class RadioButtonGroup extends LitElement {
|
|
22
|
+
static readonly ID = "sd-radio-button-group";
|
|
23
|
+
static ensureDefined: () => void;
|
|
24
|
+
layout: LayoutType;
|
|
25
|
+
value: string;
|
|
26
|
+
uncheckAllowed: boolean;
|
|
27
|
+
disabled: boolean;
|
|
28
|
+
validationMessage: string;
|
|
29
|
+
validationIconSrc: string;
|
|
30
|
+
validationLevel: ValidationLevel;
|
|
31
|
+
private _buttonsSlot;
|
|
32
|
+
private _buttons;
|
|
33
|
+
private _focusIndex;
|
|
34
|
+
private _checkedButton;
|
|
35
|
+
get focusIndex(): number;
|
|
36
|
+
set focusIndex(index: number);
|
|
37
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
38
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
39
|
+
static get styles(): import("lit").CSSResult[];
|
|
40
|
+
render(): TemplateResult;
|
|
41
|
+
private handleSlotChange;
|
|
42
|
+
private updateCheckedButton;
|
|
43
|
+
private handleFocusIn;
|
|
44
|
+
private handleFocusOut;
|
|
45
|
+
private disableButtons;
|
|
46
|
+
private enableButtons;
|
|
47
|
+
private handleButtonClick;
|
|
48
|
+
private fireValueChangeEvent;
|
|
49
|
+
private handleKeyDown;
|
|
50
|
+
private getNextFocusIndex;
|
|
51
|
+
private getPreviousFocusIndex;
|
|
52
|
+
private isFocusable;
|
|
53
|
+
private updateChecked;
|
|
54
|
+
private toggleButton;
|
|
55
|
+
private updateValue;
|
|
56
|
+
private updateFocused;
|
|
57
|
+
private checkButton;
|
|
58
|
+
private uncheckButton;
|
|
59
|
+
private get buttonsSlot();
|
|
60
|
+
private get selectedIndex();
|
|
61
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { LitElement as b, css as g, unsafeCSS as v, html as f } from "lit";
|
|
2
|
+
import { property as n } from "lit/decorators/property.js";
|
|
3
|
+
import { ifDefined as x } from "lit/directives/if-defined.js";
|
|
4
|
+
import { ValidationLevel as k } from "@cas-smartdesign/field-validation-message";
|
|
5
|
+
const y = ":host{display:block}:host,.label,.checkbox{outline:none}:host([disabled]){pointer-events:none}:host([disabled]) .root{opacity:.6;cursor:default;filter:grayscale(100%)}:host(:not([disabled])[focused]) .highlight{display:block!important}:host([checked]) circle.inner{display:block!important}:host([checked]) circle.outer{stroke:var(--sd-radio-button-checked-color, #1467ba)!important}.root{display:inline-flex;align-items:center;vertical-align:middle;width:100%;padding-top:6px;padding-bottom:6px}.root .radio-button-container{position:relative;display:inline-block;width:28px;height:28px;box-sizing:border-box;cursor:pointer;margin-right:5px;flex-shrink:0}.root .radio-button-container input{position:absolute;top:0;left:0;opacity:0}.root .radio-button-container circle.highlight{stroke:var(--sd-radio-button-highlight-color, rgba(20, 103, 186, .3))}.root .radio-button-container circle.inner{fill:var(--sd-radio-button-checked-color, #1467ba)}.root .radio-button-container circle.outer{stroke:var(--sd-radio-button-unchecked-color, #767676)}.root .label{font-family:Segoe UI,Lucida Sans,Arial,sans-serif;text-overflow:ellipsis;overflow-x:hidden;-webkit-user-select:none;user-select:none;cursor:pointer;padding-top:2px;padding-bottom:2px}";
|
|
6
|
+
var I = Object.defineProperty, m = Object.getOwnPropertyDescriptor, p = (o, t, e, s) => {
|
|
7
|
+
for (var i = s > 1 ? void 0 : s ? m(t, e) : t, c = o.length - 1, d; c >= 0; c--)
|
|
8
|
+
(d = o[c]) && (i = (s ? d(t, e, i) : d(i)) || i);
|
|
9
|
+
return s && i && I(t, e, i), i;
|
|
10
|
+
};
|
|
11
|
+
let w = 0;
|
|
12
|
+
var a;
|
|
13
|
+
const u = (a = class extends b {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(), this.checked = !1, this.value = "", this.disabled = !1, this.label = "", this.handleClick = (t) => {
|
|
16
|
+
t.preventDefault();
|
|
17
|
+
}, this.a11yID = a.ID + "_" + w++;
|
|
18
|
+
}
|
|
19
|
+
static get styles() {
|
|
20
|
+
return [
|
|
21
|
+
g`
|
|
22
|
+
${v(y)}
|
|
23
|
+
`
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
return f`
|
|
28
|
+
<div class="root">
|
|
29
|
+
<div class="radio-button-container">
|
|
30
|
+
<input
|
|
31
|
+
type="radio"
|
|
32
|
+
id="${this.a11yID}"
|
|
33
|
+
.checked="${this.checked}"
|
|
34
|
+
?disabled="${this.disabled}"
|
|
35
|
+
@click="${this.handleClick}"
|
|
36
|
+
class="radio-button"
|
|
37
|
+
/>
|
|
38
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-14 -14 28 28">
|
|
39
|
+
<circle
|
|
40
|
+
class="highlight"
|
|
41
|
+
style="display:none"
|
|
42
|
+
r="11px"
|
|
43
|
+
fill="transparent"
|
|
44
|
+
stroke-width="6px"
|
|
45
|
+
></circle>
|
|
46
|
+
<circle class="inner" r="6px" style="display:none" stroke="none"></circle>
|
|
47
|
+
<circle class="outer" r="9px" fill="transparent" stroke-width="2px"></circle>
|
|
48
|
+
</svg>
|
|
49
|
+
</div>
|
|
50
|
+
<label class="label" for="${this.a11yID}" @click="${this.handleClick}">${this.label}</label>
|
|
51
|
+
</div>
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
}, a.ID = "sd-radio-button", a.ensureDefined = () => {
|
|
55
|
+
customElements.get(a.ID) || customElements.define(a.ID, a);
|
|
56
|
+
}, a);
|
|
57
|
+
p([
|
|
58
|
+
n({ type: Boolean, reflect: !0, attribute: !0 })
|
|
59
|
+
], u.prototype, "checked", 2);
|
|
60
|
+
p([
|
|
61
|
+
n({ type: String, reflect: !0, attribute: !0 })
|
|
62
|
+
], u.prototype, "value", 2);
|
|
63
|
+
p([
|
|
64
|
+
n({ type: Boolean, reflect: !0, attribute: !0 })
|
|
65
|
+
], u.prototype, "disabled", 2);
|
|
66
|
+
p([
|
|
67
|
+
n({ type: String, reflect: !0, attribute: !0 })
|
|
68
|
+
], u.prototype, "label", 2);
|
|
69
|
+
let B = u;
|
|
70
|
+
const _ = ":host(:focus){outline:none}.buttons-container{display:flex}.buttons-container.vertical{flex-direction:column}.validation-message{margin-left:5px}";
|
|
71
|
+
var C = Object.defineProperty, D = Object.getOwnPropertyDescriptor, h = (o, t, e, s) => {
|
|
72
|
+
for (var i = s > 1 ? void 0 : s ? D(t, e) : t, c = o.length - 1, d; c >= 0; c--)
|
|
73
|
+
(d = o[c]) && (i = (s ? d(t, e, i) : d(i)) || i);
|
|
74
|
+
return s && i && C(t, e, i), i;
|
|
75
|
+
}, l;
|
|
76
|
+
const r = (l = class extends b {
|
|
77
|
+
constructor() {
|
|
78
|
+
super(...arguments), this.layout = "horizontal", this.value = "", this.uncheckAllowed = !1, this.disabled = !1, this._focusIndex = -1, this._checkedButton = null, this.handleSlotChange = () => {
|
|
79
|
+
this._buttons = this.buttonsSlot.assignedElements(), this._buttons.forEach((t) => {
|
|
80
|
+
!t.hasAttribute("disabled") && this.disabled && t.setAttribute("disabled", ""), t.setAttribute("tabIndex", "-1"), this.updateCheckedButton(t);
|
|
81
|
+
});
|
|
82
|
+
}, this.handleFocusIn = (t) => {
|
|
83
|
+
const e = t.target, s = this._buttons.findIndex((i) => i == e);
|
|
84
|
+
this.focusIndex = this.focusIndex >= 0 ? this.focusIndex : this.getNextFocusIndex(s !== -1 ? s : 0), this.updateFocused(null, this._buttons[this.focusIndex]);
|
|
85
|
+
}, this.handleFocusOut = () => {
|
|
86
|
+
this.updateFocused(this._buttons[this.focusIndex]);
|
|
87
|
+
}, this.handleButtonClick = (t) => {
|
|
88
|
+
this.focus();
|
|
89
|
+
const e = this._buttons.find((i) => i.contains(t.target)), s = this._buttons.findIndex((i) => i == e);
|
|
90
|
+
s >= 0 && (this.focusIndex = s, this.updateChecked());
|
|
91
|
+
}, this.handleKeyDown = (t) => {
|
|
92
|
+
let e = !0;
|
|
93
|
+
switch (t.key) {
|
|
94
|
+
case "Down":
|
|
95
|
+
case "ArrowDown": {
|
|
96
|
+
const s = this.getNextFocusIndex(this.focusIndex + 1);
|
|
97
|
+
this.focusIndex = s !== -1 ? s : this.getNextFocusIndex(0), this.uncheckAllowed || this.updateChecked();
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "Up":
|
|
101
|
+
case "ArrowUp": {
|
|
102
|
+
const s = this.getPreviousFocusIndex(this.focusIndex - 1);
|
|
103
|
+
this.focusIndex = s !== -1 ? s : this.getPreviousFocusIndex(this.childElementCount - 1), this.uncheckAllowed || this.updateChecked();
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "Enter": {
|
|
107
|
+
this.updateChecked();
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
default:
|
|
111
|
+
e = !1;
|
|
112
|
+
}
|
|
113
|
+
e && (t.preventDefault(), t.stopPropagation());
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
get focusIndex() {
|
|
117
|
+
return this._focusIndex;
|
|
118
|
+
}
|
|
119
|
+
set focusIndex(t) {
|
|
120
|
+
if (t >= -1 && t < this.childElementCount) {
|
|
121
|
+
const e = this._focusIndex;
|
|
122
|
+
if (this._focusIndex = t, e !== t) {
|
|
123
|
+
const s = this._buttons[e], i = this._buttons[this.focusIndex];
|
|
124
|
+
this.updateFocused(s, i);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
firstUpdated(t) {
|
|
129
|
+
super.firstUpdated(t), this.buttonsSlot.addEventListener("slotchange", this.handleSlotChange), this.addEventListener("focusin", this.handleFocusIn), this.addEventListener("focusout", this.handleFocusOut), this.addEventListener("keydown", this.handleKeyDown);
|
|
130
|
+
}
|
|
131
|
+
updated(t) {
|
|
132
|
+
super.updated(t), t.has("disabled") && (this.disabled ? this.disableButtons() : this.enableButtons());
|
|
133
|
+
}
|
|
134
|
+
static get styles() {
|
|
135
|
+
return [
|
|
136
|
+
g`
|
|
137
|
+
${v(_)}
|
|
138
|
+
`
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
render() {
|
|
142
|
+
return f`
|
|
143
|
+
<div
|
|
144
|
+
class="buttons-container ${this.layout === "vertical" ? "vertical" : "horizontal"}"
|
|
145
|
+
@click="${x(this.disabled ? void 0 : this.handleButtonClick)}"
|
|
146
|
+
>
|
|
147
|
+
<slot></slot>
|
|
148
|
+
</div>
|
|
149
|
+
${this.validationMessage && f`
|
|
150
|
+
<sd-field-validation-message
|
|
151
|
+
class="validation-message"
|
|
152
|
+
.message=${this.validationMessage}
|
|
153
|
+
.icon=${this.validationIconSrc}
|
|
154
|
+
.level=${this.validationLevel}
|
|
155
|
+
>
|
|
156
|
+
</sd-field-validation-message>
|
|
157
|
+
`}
|
|
158
|
+
`;
|
|
159
|
+
}
|
|
160
|
+
updateCheckedButton(t) {
|
|
161
|
+
if (this._checkedButton && this._checkedButton !== t)
|
|
162
|
+
this.uncheckButton(t);
|
|
163
|
+
else if (t.hasAttribute("checked")) {
|
|
164
|
+
this._checkedButton = t;
|
|
165
|
+
const e = t.getAttribute("value");
|
|
166
|
+
this.updateValue(e);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
disableButtons() {
|
|
170
|
+
var t;
|
|
171
|
+
(t = this._buttons) == null || t.forEach((e) => {
|
|
172
|
+
e.setAttribute("disabled", "");
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
enableButtons() {
|
|
176
|
+
var t;
|
|
177
|
+
(t = this._buttons) == null || t.forEach((e) => {
|
|
178
|
+
e.removeAttribute("disabled");
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
fireValueChangeEvent() {
|
|
182
|
+
this.dispatchEvent(
|
|
183
|
+
new CustomEvent("value-change", {
|
|
184
|
+
detail: {
|
|
185
|
+
value: this.value,
|
|
186
|
+
selectedIndex: this.selectedIndex
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
getNextFocusIndex(t) {
|
|
192
|
+
for (let e = t; e < this.childElementCount; e++) {
|
|
193
|
+
const s = this._buttons[e];
|
|
194
|
+
if (this.isFocusable(s))
|
|
195
|
+
return e;
|
|
196
|
+
}
|
|
197
|
+
return -1;
|
|
198
|
+
}
|
|
199
|
+
getPreviousFocusIndex(t) {
|
|
200
|
+
for (let e = t; e >= 0; e--) {
|
|
201
|
+
const s = this._buttons[e];
|
|
202
|
+
if (this.isFocusable(s))
|
|
203
|
+
return e;
|
|
204
|
+
}
|
|
205
|
+
return -1;
|
|
206
|
+
}
|
|
207
|
+
isFocusable(t) {
|
|
208
|
+
return !t.hasAttribute("disabled");
|
|
209
|
+
}
|
|
210
|
+
updateChecked() {
|
|
211
|
+
const t = this._checkedButton, e = this._buttons[this.focusIndex];
|
|
212
|
+
this._checkedButton = e, t && t !== e && this.uncheckButton(t), e && this.toggleButton(e);
|
|
213
|
+
}
|
|
214
|
+
toggleButton(t) {
|
|
215
|
+
t.hasAttribute("checked") ? this.uncheckAllowed && (this.uncheckButton(t), this._checkedButton = null, this.updateValue("")) : (this.checkButton(t), this.updateValue(t.getAttribute("value")));
|
|
216
|
+
}
|
|
217
|
+
updateValue(t) {
|
|
218
|
+
this.value = t, this.fireValueChangeEvent();
|
|
219
|
+
}
|
|
220
|
+
updateFocused(t, e) {
|
|
221
|
+
var s, i;
|
|
222
|
+
(s = t == null ? void 0 : t.removeAttribute) == null || s.call(t, "focused"), (i = e == null ? void 0 : e.setAttribute) == null || i.call(e, "focused", "");
|
|
223
|
+
}
|
|
224
|
+
checkButton(t) {
|
|
225
|
+
t.setAttribute("checked", "");
|
|
226
|
+
}
|
|
227
|
+
uncheckButton(t) {
|
|
228
|
+
t.removeAttribute("checked");
|
|
229
|
+
}
|
|
230
|
+
get buttonsSlot() {
|
|
231
|
+
return this.shadowRoot && !this._buttonsSlot && (this._buttonsSlot = this.shadowRoot.querySelector("slot")), this._buttonsSlot;
|
|
232
|
+
}
|
|
233
|
+
get selectedIndex() {
|
|
234
|
+
return this._buttons.indexOf(this._checkedButton);
|
|
235
|
+
}
|
|
236
|
+
}, l.ID = "sd-radio-button-group", l.ensureDefined = () => {
|
|
237
|
+
B.ensureDefined(), customElements.get(l.ID) || customElements.define(l.ID, l);
|
|
238
|
+
}, l);
|
|
239
|
+
h([
|
|
240
|
+
n({ type: String, reflect: !0, attribute: !0 })
|
|
241
|
+
], r.prototype, "layout", 2);
|
|
242
|
+
h([
|
|
243
|
+
n({ type: String })
|
|
244
|
+
], r.prototype, "value", 2);
|
|
245
|
+
h([
|
|
246
|
+
n({ type: Boolean, reflect: !0, attribute: "uncheck-allowed" })
|
|
247
|
+
], r.prototype, "uncheckAllowed", 2);
|
|
248
|
+
h([
|
|
249
|
+
n({ type: Boolean, reflect: !0, attribute: !0 })
|
|
250
|
+
], r.prototype, "disabled", 2);
|
|
251
|
+
h([
|
|
252
|
+
n({ type: String })
|
|
253
|
+
], r.prototype, "validationMessage", 2);
|
|
254
|
+
h([
|
|
255
|
+
n({ type: String })
|
|
256
|
+
], r.prototype, "validationIconSrc", 2);
|
|
257
|
+
h([
|
|
258
|
+
n({
|
|
259
|
+
type: {
|
|
260
|
+
fromAttribute(o) {
|
|
261
|
+
return o && k[o.toLowerCase()];
|
|
262
|
+
},
|
|
263
|
+
toAttribute(o) {
|
|
264
|
+
return o && o.toLowerCase();
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
reflect: !0
|
|
268
|
+
})
|
|
269
|
+
], r.prototype, "validationLevel", 2);
|
|
270
|
+
let A = r;
|
|
271
|
+
A.ensureDefined();
|
|
272
|
+
export {
|
|
273
|
+
B as RadioButton,
|
|
274
|
+
A as RadioButtonGroup
|
|
275
|
+
};
|
|
276
|
+
//# sourceMappingURL=radio-button-group.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-button-group.mjs","sources":["../radio-button.ts","../radio-button-group.ts"],"sourcesContent":["import { LitElement, TemplateResult, html, unsafeCSS, css, nothing } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButton.ID]: RadioButton;\n }\n}\n\nimport style from \"./scss/button.scss?inline\";\nlet idCounter = 0;\n\nexport class RadioButton extends LitElement {\n public static readonly ID = \"sd-radio-button\";\n public static ensureDefined = (): void => {\n if (!customElements.get(RadioButton.ID)) {\n customElements.define(RadioButton.ID, RadioButton);\n }\n };\n @property({ type: Boolean, reflect: true, attribute: true })\n public checked = false;\n @property({ type: String, reflect: true, attribute: true })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String, reflect: true, attribute: true })\n public label = \"\";\n\n private a11yID;\n\n constructor() {\n super();\n this.a11yID = RadioButton.ID + \"_\" + idCounter++;\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"root\">\n <div class=\"radio-button-container\">\n <input\n type=\"radio\"\n id=\"${this.a11yID}\"\n .checked=\"${this.checked}\"\n ?disabled=\"${this.disabled}\"\n @click=\"${this.handleClick}\"\n class=\"radio-button\"\n />\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-14 -14 28 28\">\n <circle\n class=\"highlight\"\n style=\"display:none\"\n r=\"11px\"\n fill=\"transparent\"\n stroke-width=\"6px\"\n ></circle>\n <circle class=\"inner\" r=\"6px\" style=\"display:none\" stroke=\"none\"></circle>\n <circle class=\"outer\" r=\"9px\" fill=\"transparent\" stroke-width=\"2px\"></circle>\n </svg>\n </div>\n <label class=\"label\" for=\"${this.a11yID}\" @click=\"${this.handleClick}\">${this.label}</label>\n </div>\n `;\n }\n\n private handleClick = (event: MouseEvent): void => {\n event.preventDefault();\n };\n}\n","import { LitElement, TemplateResult, html, PropertyValues, ComplexAttributeConverter, unsafeCSS, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { RadioButton } from \"./radio-button\";\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\nimport type { LayoutType, IValueChangeEvent } from \"./types\";\n\nexport { RadioButton } from \"./radio-button\";\nexport type * from \"./types\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButtonGroup.ID]: RadioButtonGroup;\n }\n}\nimport style from \"./scss/group.scss?inline\";\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport interface RadioButtonGroup {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport class RadioButtonGroup extends LitElement {\n public static readonly ID = \"sd-radio-button-group\";\n public static ensureDefined = (): void => {\n RadioButton.ensureDefined();\n if (!customElements.get(RadioButtonGroup.ID)) {\n customElements.define(RadioButtonGroup.ID, RadioButtonGroup);\n }\n };\n @property({ type: String, reflect: true, attribute: true })\n public layout: LayoutType = \"horizontal\";\n @property({ type: String })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: \"uncheck-allowed\" })\n public uncheckAllowed = false;\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String })\n public validationMessage: string;\n @property({ type: String })\n public validationIconSrc: string;\n @property({\n type: {\n fromAttribute(value: string): ValidationLevel {\n return value && ValidationLevel[value.toLowerCase()];\n },\n toAttribute(value: ValidationLevel): string {\n return value && value.toLowerCase();\n },\n } as ComplexAttributeConverter,\n reflect: true,\n })\n public validationLevel: ValidationLevel;\n\n private _buttonsSlot: HTMLSlotElement;\n private _buttons: HTMLElement[];\n private _focusIndex = -1;\n private _checkedButton: HTMLElement = null;\n\n public get focusIndex(): number {\n return this._focusIndex;\n }\n\n public set focusIndex(index: number) {\n if (index >= -1 && index < this.childElementCount) {\n const oldValue = this._focusIndex;\n this._focusIndex = index;\n if (oldValue !== index) {\n const previousButton = this._buttons[oldValue];\n const currentButton = this._buttons[this.focusIndex];\n this.updateFocused(previousButton, currentButton);\n }\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.buttonsSlot.addEventListener(\"slotchange\", this.handleSlotChange);\n this.addEventListener(\"focusin\", this.handleFocusIn);\n this.addEventListener(\"focusout\", this.handleFocusOut);\n this.addEventListener(\"keydown\", this.handleKeyDown);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has(\"disabled\")) {\n this.disabled ? this.disableButtons() : this.enableButtons();\n }\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n public render(): TemplateResult {\n return html`\n <div\n class=\"buttons-container ${this.layout === \"vertical\" ? \"vertical\" : \"horizontal\"}\"\n @click=\"${ifDefined(this.disabled ? undefined : this.handleButtonClick)}\"\n >\n <slot></slot>\n </div>\n ${this.validationMessage &&\n html`\n <sd-field-validation-message\n class=\"validation-message\"\n .message=${this.validationMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>\n `}\n `;\n }\n\n private handleSlotChange = (): void => {\n this._buttons = this.buttonsSlot.assignedElements() as HTMLElement[];\n this._buttons.forEach((button) => {\n if (!button.hasAttribute(\"disabled\") && this.disabled) {\n button.setAttribute(\"disabled\", \"\");\n }\n // prevent radio buttons to be able to get focus by tabbing\n // as focus is handled by this element\n button.setAttribute(\"tabIndex\", \"-1\");\n this.updateCheckedButton(button);\n });\n };\n\n private updateCheckedButton(button: HTMLElement): void {\n if (this._checkedButton && this._checkedButton !== button) {\n this.uncheckButton(button);\n } else if (button.hasAttribute(\"checked\")) {\n this._checkedButton = button;\n const value = button.getAttribute(\"value\");\n this.updateValue(value);\n }\n }\n\n private handleFocusIn = (event: FocusEvent): void => {\n const target = event.target as HTMLElement;\n const ind = this._buttons.findIndex((button) => button == target);\n this.focusIndex = this.focusIndex >= 0 ? this.focusIndex : this.getNextFocusIndex(ind !== -1 ? ind : 0);\n this.updateFocused(null, this._buttons[this.focusIndex]);\n };\n\n private handleFocusOut = (): void => {\n this.updateFocused(this._buttons[this.focusIndex]);\n };\n\n private disableButtons(): void {\n this._buttons?.forEach((button) => {\n button.setAttribute(\"disabled\", \"\");\n });\n }\n\n private enableButtons(): void {\n this._buttons?.forEach((button) => {\n button.removeAttribute(\"disabled\");\n });\n }\n\n private handleButtonClick = (event: MouseEvent): void => {\n // the individual buttons are not focusable\n this.focus();\n const target = this._buttons.find((button) => button.contains(event.target as Node));\n const targetIndex = this._buttons.findIndex((button) => button == target);\n if (targetIndex >= 0) {\n this.focusIndex = targetIndex;\n this.updateChecked();\n }\n };\n\n private fireValueChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(\"value-change\", {\n detail: {\n value: this.value,\n selectedIndex: this.selectedIndex,\n },\n }),\n );\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n let shouldPrevent = true;\n switch (event.key) {\n case \"Down\":\n case \"ArrowDown\": {\n const newIndex = this.getNextFocusIndex(this.focusIndex + 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getNextFocusIndex(0);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n break;\n }\n case \"Up\":\n case \"ArrowUp\": {\n const newIndex = this.getPreviousFocusIndex(this.focusIndex - 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getPreviousFocusIndex(this.childElementCount - 1);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n break;\n }\n case \"Enter\": {\n this.updateChecked();\n break;\n }\n default: {\n shouldPrevent = false;\n }\n }\n if (shouldPrevent) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n private getNextFocusIndex(index: number): number {\n for (let i = index; i < this.childElementCount; i++) {\n const button = this._buttons[i];\n if (this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private getPreviousFocusIndex(index: number): number {\n for (let i = index; i >= 0; i--) {\n const button = this._buttons[i];\n if (this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private isFocusable(button: HTMLElement): boolean {\n return !button.hasAttribute(\"disabled\");\n }\n\n private updateChecked(): void {\n const previousChecked = this._checkedButton;\n const currentChecked = this._buttons[this.focusIndex];\n this._checkedButton = currentChecked;\n if (previousChecked && previousChecked !== currentChecked) {\n this.uncheckButton(previousChecked);\n }\n if (currentChecked) {\n this.toggleButton(currentChecked);\n }\n }\n\n private toggleButton(button: HTMLElement): void {\n const checked = button.hasAttribute(\"checked\");\n if (checked) {\n if (this.uncheckAllowed) {\n this.uncheckButton(button);\n this._checkedButton = null;\n this.updateValue(\"\");\n }\n } else {\n this.checkButton(button);\n this.updateValue(button.getAttribute(\"value\"));\n }\n }\n\n private updateValue(newValue: string): void {\n this.value = newValue;\n this.fireValueChangeEvent();\n }\n\n private updateFocused(previousFocused?: HTMLElement, currentFocused?: HTMLElement): void {\n previousFocused?.removeAttribute?.(\"focused\");\n currentFocused?.setAttribute?.(\"focused\", \"\");\n }\n\n private checkButton(button: HTMLElement): void {\n button.setAttribute(\"checked\", \"\");\n }\n\n private uncheckButton(button: HTMLElement): void {\n button.removeAttribute(\"checked\");\n }\n\n private get buttonsSlot(): HTMLSlotElement {\n if (this.shadowRoot && !this._buttonsSlot) {\n this._buttonsSlot = this.shadowRoot.querySelector(\"slot\");\n }\n return this._buttonsSlot;\n }\n\n private get selectedIndex(): number {\n return this._buttons.indexOf(this._checkedButton);\n }\n}\n\nRadioButtonGroup.ensureDefined();\n"],"names":["idCounter","_RadioButton","_a","LitElement","event","css","unsafeCSS","style","html","__decorateClass","property","RadioButton","_RadioButtonGroup","button","target","ind","targetIndex","shouldPrevent","newIndex","index","oldValue","previousButton","currentButton","changedProperties","ifDefined","value","i","previousChecked","currentChecked","newValue","previousFocused","currentFocused","_b","ValidationLevel","RadioButtonGroup"],"mappings":";;;;;;;;;;AAUA,IAAIA,IAAY;;AAET,MAAMC,KAANC,IAAA,cAA0BC,EAAW;AAAA,EAkBxC,cAAc;AACJ,aAXV,KAAO,UAAU,IAEjB,KAAO,QAAQ,IAEf,KAAO,WAAW,IAElB,KAAO,QAAQ,IA8CP,KAAA,cAAc,CAACC,MAA4B;AAC/C,MAAAA,EAAM,eAAe;AAAA,IAAA,GAzChB,KAAA,SAASF,EAAY,KAAK,MAAMF;AAAA,EACzC;AAAA,EAEA,WAAW,SAAS;AACT,WAAA;AAAA,MACHK;AAAA,kBACMC,EAAUC,CAAK,CAAC;AAAA;AAAA,IAAA;AAAA,EAG9B;AAAA,EAEO,SAAyB;AACrB,WAAAC;AAAA;AAAA;AAAA;AAAA;AAAA,8BAKe,KAAK,MAAM;AAAA,oCACL,KAAK,OAAO;AAAA,qCACX,KAAK,QAAQ;AAAA,kCAChB,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4CAeN,KAAK,MAAM,aAAa,KAAK,WAAW,KAAK,KAAK,KAAK;AAAA;AAAA;AAAA,EAG/F;AAKJ,GA9DIN,EAAuB,KAAK,mBAC5BA,EAAc,gBAAgB,MAAY;AACtC,EAAK,eAAe,IAAIA,EAAY,EAAE,KACnB,eAAA,OAAOA,EAAY,IAAIA,CAAW;AACrD,GALDA;AAQIO,EAAA;AAAA,EADNC,EAAS,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EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM,WAAW,IAAM;AAAA,GAdlDE,EAeF,WAAA,YAAA,CAAA;AAEAH,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ;AAAA,GAhBjBE,EAiBF,WAAA,qBAAA,CAAA;AAEAH,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ;AAAA,GAlBjBE,EAmBF,WAAA,qBAAA,CAAA;AAYAH,EAAA;AAAA,EAXNC,EAAS;AAAA,IACN,MAAM;AAAA,MACF,cAAce,GAAgC;AAC1C,eAAOA,KAASQ,EAAgBR,EAAM,YAAa,CAAA;AAAA,MACvD;AAAA,MACA,YAAYA,GAAgC;AACjC,eAAAA,KAASA,EAAM;MAC1B;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,EAAA,CACZ;AAAA,GA9BQb,EA+BF,WAAA,mBAAA,CAAA;AA/BJ,IAAMsB,IAANtB;AA0RPsB,EAAiB,cAAc;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from "lit";
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
[RadioButton.ID]: RadioButton;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare class RadioButton extends LitElement {
|
|
8
|
+
static readonly ID = "sd-radio-button";
|
|
9
|
+
static ensureDefined: () => void;
|
|
10
|
+
checked: boolean;
|
|
11
|
+
value: string;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
label: string;
|
|
14
|
+
private a11yID;
|
|
15
|
+
constructor();
|
|
16
|
+
static get styles(): import("lit").CSSResult[];
|
|
17
|
+
render(): TemplateResult;
|
|
18
|
+
private handleClick;
|
|
19
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@cypress/vite-dev-server@5.0.7": {
|
|
3
|
+
"licenses": "MIT",
|
|
4
|
+
"repository": "https://github.com/cypress-io/cypress",
|
|
5
|
+
"licenseUrl": "https://github.com/cypress-io/cypress/tree/develop/npm/vite-dev-server#readme"
|
|
6
|
+
},
|
|
7
|
+
"@rollup/plugin-node-resolve@15.2.3": {
|
|
8
|
+
"licenses": "MIT",
|
|
9
|
+
"repository": "https://github.com/rollup/plugins",
|
|
10
|
+
"licenseUrl": "https://github.com/rollup/plugins/raw/HEAD/LICENSE"
|
|
11
|
+
},
|
|
12
|
+
"@types/node@20.10.6": {
|
|
13
|
+
"licenses": "MIT",
|
|
14
|
+
"repository": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
|
15
|
+
"licenseUrl": "https://github.com/DefinitelyTyped/DefinitelyTyped/raw/HEAD/LICENSE"
|
|
16
|
+
},
|
|
17
|
+
"@types/postcss-prefix-selector@1.16.3": {
|
|
18
|
+
"licenses": "MIT",
|
|
19
|
+
"repository": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
|
20
|
+
"licenseUrl": "https://github.com/DefinitelyTyped/DefinitelyTyped/raw/HEAD/LICENSE"
|
|
21
|
+
},
|
|
22
|
+
"@typescript-eslint/eslint-plugin@6.17.0": {
|
|
23
|
+
"licenses": "MIT",
|
|
24
|
+
"repository": "https://github.com/typescript-eslint/typescript-eslint",
|
|
25
|
+
"licenseUrl": "https://github.com/typescript-eslint/typescript-eslint/raw/HEAD/LICENSE"
|
|
26
|
+
},
|
|
27
|
+
"@typescript-eslint/parser@6.17.0": {
|
|
28
|
+
"licenses": "BSD-2-Clause",
|
|
29
|
+
"repository": "https://github.com/typescript-eslint/typescript-eslint",
|
|
30
|
+
"licenseUrl": "https://github.com/typescript-eslint/typescript-eslint/raw/HEAD/LICENSE"
|
|
31
|
+
},
|
|
32
|
+
"@vitest/coverage-v8@1.1.1": {
|
|
33
|
+
"licenses": "MIT",
|
|
34
|
+
"repository": "https://github.com/vitest-dev/vitest",
|
|
35
|
+
"licenseUrl": "https://github.com/vitest-dev/vitest/raw/HEAD/LICENSE"
|
|
36
|
+
},
|
|
37
|
+
"@vitest/ui@1.1.1": {
|
|
38
|
+
"licenses": "MIT",
|
|
39
|
+
"repository": "https://github.com/vitest-dev/vitest",
|
|
40
|
+
"licenseUrl": "https://github.com/vitest-dev/vitest/raw/HEAD/LICENSE"
|
|
41
|
+
},
|
|
42
|
+
"axe-core@4.8.3": {
|
|
43
|
+
"licenses": "MPL-2.0",
|
|
44
|
+
"repository": "https://github.com/dequelabs/axe-core",
|
|
45
|
+
"licenseUrl": "https://github.com/dequelabs/axe-core/raw/HEAD/LICENSE"
|
|
46
|
+
},
|
|
47
|
+
"cypress-axe@1.5.0": {
|
|
48
|
+
"licenses": "MIT",
|
|
49
|
+
"repository": "https://github.com/component-driven/cypress-axe",
|
|
50
|
+
"licenseUrl": "https://github.com/component-driven/cypress-axe/raw/HEAD/License.md"
|
|
51
|
+
},
|
|
52
|
+
"cypress-real-events@1.13.0": {
|
|
53
|
+
"licenses": "MIT",
|
|
54
|
+
"repository": "https://github.com/dmtrKovalenko/cypress-real-events",
|
|
55
|
+
"licenseUrl": "https://github.com/dmtrKovalenko/cypress-real-events"
|
|
56
|
+
},
|
|
57
|
+
"cypress@13.6.2": {
|
|
58
|
+
"licenses": "MIT",
|
|
59
|
+
"repository": "https://github.com/cypress-io/cypress",
|
|
60
|
+
"licenseUrl": "https://cypress.io"
|
|
61
|
+
},
|
|
62
|
+
"esbuild@0.19.11": {
|
|
63
|
+
"licenses": "MIT",
|
|
64
|
+
"repository": "https://github.com/evanw/esbuild",
|
|
65
|
+
"licenseUrl": "https://github.com/evanw/esbuild/raw/HEAD/LICENSE.md"
|
|
66
|
+
},
|
|
67
|
+
"eslint-config-google@0.14.0": {
|
|
68
|
+
"licenses": "Apache-2.0",
|
|
69
|
+
"repository": "https://github.com/google/eslint-config-google",
|
|
70
|
+
"licenseUrl": "https://github.com/google/eslint-config-google/raw/HEAD/LICENSE"
|
|
71
|
+
},
|
|
72
|
+
"eslint-config-prettier@9.1.0": {
|
|
73
|
+
"licenses": "MIT",
|
|
74
|
+
"repository": "https://github.com/prettier/eslint-config-prettier",
|
|
75
|
+
"licenseUrl": "https://github.com/prettier/eslint-config-prettier/raw/HEAD/LICENSE"
|
|
76
|
+
},
|
|
77
|
+
"eslint@8.56.0": {
|
|
78
|
+
"licenses": "MIT",
|
|
79
|
+
"repository": "https://github.com/eslint/eslint",
|
|
80
|
+
"licenseUrl": "https://github.com/eslint/eslint/raw/HEAD/LICENSE"
|
|
81
|
+
},
|
|
82
|
+
"github-markdown-css@5.5.0": {
|
|
83
|
+
"licenses": "MIT",
|
|
84
|
+
"repository": "https://github.com/sindresorhus/github-markdown-css",
|
|
85
|
+
"licenseUrl": "https://github.com/sindresorhus/github-markdown-css/raw/HEAD/license"
|
|
86
|
+
},
|
|
87
|
+
"highlight.js@11.9.0": {
|
|
88
|
+
"licenses": "BSD-3-Clause",
|
|
89
|
+
"repository": "https://github.com/highlightjs/highlight.js",
|
|
90
|
+
"licenseUrl": "https://github.com/highlightjs/highlight.js/raw/HEAD/LICENSE"
|
|
91
|
+
},
|
|
92
|
+
"junit-report-builder@3.1.0": {
|
|
93
|
+
"licenses": "MIT",
|
|
94
|
+
"repository": "https://github.com/davidparsson/junit-report-builder",
|
|
95
|
+
"licenseUrl": "https://github.com/davidparsson/junit-report-builder/raw/HEAD/LICENSE"
|
|
96
|
+
},
|
|
97
|
+
"lint-staged@15.2.0": {
|
|
98
|
+
"licenses": "MIT",
|
|
99
|
+
"repository": "https://github.com/okonet/lint-staged",
|
|
100
|
+
"licenseUrl": "https://github.com/okonet/lint-staged/raw/HEAD/LICENSE"
|
|
101
|
+
},
|
|
102
|
+
"lit@2.8.0": {
|
|
103
|
+
"licenses": "BSD-3-Clause",
|
|
104
|
+
"repository": "https://github.com/lit/lit",
|
|
105
|
+
"licenseUrl": "https://github.com/lit/lit/raw/HEAD/LICENSE"
|
|
106
|
+
},
|
|
107
|
+
"marked@11.1.1": {
|
|
108
|
+
"licenses": "MIT",
|
|
109
|
+
"repository": "https://github.com/markedjs/marked",
|
|
110
|
+
"licenseUrl": "https://github.com/markedjs/marked/raw/HEAD/LICENSE.md"
|
|
111
|
+
},
|
|
112
|
+
"postcss-prefix-selector@1.16.0": {
|
|
113
|
+
"licenses": "MIT",
|
|
114
|
+
"repository": "https://github.com/RadValentin/postcss-prefix-selector",
|
|
115
|
+
"licenseUrl": "https://github.com/RadValentin/postcss-prefix-selector/raw/HEAD/LICENSE"
|
|
116
|
+
},
|
|
117
|
+
"postcss@8.4.32": {
|
|
118
|
+
"licenses": "MIT",
|
|
119
|
+
"repository": "https://github.com/postcss/postcss",
|
|
120
|
+
"licenseUrl": "https://github.com/postcss/postcss/raw/HEAD/LICENSE"
|
|
121
|
+
},
|
|
122
|
+
"prettier@3.1.1": {
|
|
123
|
+
"licenses": "MIT",
|
|
124
|
+
"repository": "https://github.com/prettier/prettier",
|
|
125
|
+
"licenseUrl": "https://github.com/prettier/prettier/raw/HEAD/LICENSE"
|
|
126
|
+
},
|
|
127
|
+
"resolve-pkg@2.0.0": {
|
|
128
|
+
"licenses": "MIT",
|
|
129
|
+
"repository": "https://github.com/sindresorhus/resolve-pkg",
|
|
130
|
+
"licenseUrl": "https://github.com/sindresorhus/resolve-pkg/raw/HEAD/license"
|
|
131
|
+
},
|
|
132
|
+
"sass@1.69.6": {
|
|
133
|
+
"licenses": "MIT",
|
|
134
|
+
"repository": "https://github.com/sass/dart-sass",
|
|
135
|
+
"licenseUrl": "https://github.com/sass/dart-sass/raw/HEAD/LICENSE"
|
|
136
|
+
},
|
|
137
|
+
"stylelint-config-recommended-scss@14.0.0": {
|
|
138
|
+
"licenses": "MIT",
|
|
139
|
+
"repository": "https://github.com/stylelint-scss/stylelint-config-recommended-scss",
|
|
140
|
+
"licenseUrl": "https://github.com/stylelint-scss/stylelint-config-recommended-scss/raw/HEAD/LICENSE"
|
|
141
|
+
},
|
|
142
|
+
"stylelint-config-standard@36.0.0": {
|
|
143
|
+
"licenses": "MIT",
|
|
144
|
+
"repository": "https://github.com/stylelint/stylelint-config-standard",
|
|
145
|
+
"licenseUrl": "https://github.com/stylelint/stylelint-config-standard/raw/HEAD/LICENSE"
|
|
146
|
+
},
|
|
147
|
+
"stylelint-scss@6.0.0": {
|
|
148
|
+
"licenses": "MIT",
|
|
149
|
+
"repository": "https://github.com/stylelint-scss/stylelint-scss",
|
|
150
|
+
"licenseUrl": "https://github.com/stylelint-scss/stylelint-scss/raw/HEAD/LICENSE"
|
|
151
|
+
},
|
|
152
|
+
"stylelint@16.1.0": {
|
|
153
|
+
"licenses": "MIT",
|
|
154
|
+
"repository": "https://github.com/stylelint/stylelint",
|
|
155
|
+
"licenseUrl": "https://github.com/stylelint/stylelint/raw/HEAD/LICENSE"
|
|
156
|
+
},
|
|
157
|
+
"tsup@8.0.1": {
|
|
158
|
+
"licenses": "MIT",
|
|
159
|
+
"repository": "https://github.com/egoist/tsup",
|
|
160
|
+
"licenseUrl": "https://github.com/egoist/tsup/raw/HEAD/LICENSE"
|
|
161
|
+
},
|
|
162
|
+
"turbo@1.11.2": {
|
|
163
|
+
"licenses": "MPL-2.0",
|
|
164
|
+
"repository": "https://github.com/vercel/turbo",
|
|
165
|
+
"licenseUrl": "https://github.com/vercel/turbo/raw/HEAD/LICENSE"
|
|
166
|
+
},
|
|
167
|
+
"typescript@5.3.3": {
|
|
168
|
+
"licenses": "Apache-2.0",
|
|
169
|
+
"repository": "https://github.com/Microsoft/TypeScript",
|
|
170
|
+
"licenseUrl": "https://github.com/Microsoft/TypeScript/raw/HEAD/LICENSE.txt"
|
|
171
|
+
},
|
|
172
|
+
"vite-tsconfig-paths@4.2.3": {
|
|
173
|
+
"licenses": "MIT",
|
|
174
|
+
"repository": "https://github.com/aleclarson/vite-tsconfig-paths",
|
|
175
|
+
"licenseUrl": "https://github.com/aleclarson/vite-tsconfig-paths/raw/HEAD/LICENSE"
|
|
176
|
+
},
|
|
177
|
+
"vite@5.0.10": {
|
|
178
|
+
"licenses": "MIT",
|
|
179
|
+
"repository": "https://github.com/vitejs/vite",
|
|
180
|
+
"licenseUrl": "https://github.com/vitejs/vite/raw/HEAD/LICENSE.md"
|
|
181
|
+
},
|
|
182
|
+
"vitest@1.1.1": {
|
|
183
|
+
"licenses": "MIT",
|
|
184
|
+
"repository": "https://github.com/vitest-dev/vitest",
|
|
185
|
+
"licenseUrl": "https://github.com/vitest-dev/vitest/raw/HEAD/LICENSE.md"
|
|
186
|
+
},
|
|
187
|
+
"yargs@17.7.2": {
|
|
188
|
+
"licenses": "MIT",
|
|
189
|
+
"repository": "https://github.com/yargs/yargs",
|
|
190
|
+
"licenseUrl": "https://github.com/yargs/yargs/raw/HEAD/LICENSE"
|
|
191
|
+
}
|
|
192
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cas-smartdesign/radio-button-group",
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "Radio button and radio button group elements with SmartDesign look & feel",
|
|
5
|
+
"main": "dist/radio-button-group-with-externals.js",
|
|
6
|
+
"module": "dist/radio-button-group.mjs",
|
|
7
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
8
|
+
"types": "dist/radio-button-group.d.ts",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"lit": "^2.8.0",
|
|
11
|
+
"@cas-smartdesign/field-validation-message": "^5.0.1",
|
|
12
|
+
"@cas-smartdesign/styles": "^3.6.1"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"npm-third-party-licenses.json"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"registry": "https://registry.npmjs.org/",
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@cas-smartdesign/button": "^5.0.1",
|
|
24
|
+
"@cas-smartdesign/element-preview": "^0.2.1",
|
|
25
|
+
"@cas-smartdesign/license-generator": "^1.6.1"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"version": "pnpm version",
|
|
29
|
+
"generate-declaration": "tsc -p tsconfig.types.json",
|
|
30
|
+
"build:no-license": "vite build && pnpm generate-declaration && vite build --mode documentation",
|
|
31
|
+
"build": "pnpm generate-license && pnpm build:no-license",
|
|
32
|
+
"watch": "vite build --watch",
|
|
33
|
+
"dev": "vite",
|
|
34
|
+
"generate-license": "sd-license-generator --r ../../",
|
|
35
|
+
"test:component": "pnpm cypress run --component --quiet --browser chrome",
|
|
36
|
+
"cypress:open": "pnpm cypress open --component"
|
|
37
|
+
}
|
|
38
|
+
}
|