@proximus/lavender-radio-group 1.0.0-alpha.10
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/index.js +329 -0
- package/package.json +42 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { PxElement as h } from "@proximus/lavender-common";
|
|
2
|
+
const g = `:host{display:block}:host(:focus-visible){outline:var(--px-focus-outline-mobile) solid var(--px-border-color-focus-outline-default);outline-offset:var(--px-focus-offset-mobile)}:host([variant="selectable-tag"]:focus-visible){border-radius:var(--px-radius-pill)}:host([inverted]:focus-visible){outline-color:var(--px-border-color-focus-outline-inverted)}.radio{display:flex;align-items:flex-start;gap:var(--px-spacing-after-element-s-mobile)}.radio.all-slots-empty{gap:0}label{font-family:var(--px-font-family);font-size:var(--px-text-size-label-m-mobile);line-height:calc(var(--px-line-height-m) * 1rem);font-weight:400;color:var(--px-text-color-heading-neutral-default)}.radio:not(.selectable-tag) input{-webkit-appearance:none;-moz-appearance:none;appearance:none;pointer-events:none;margin:0;border-radius:var(--px-radius-pill);border:var(--px-border-size-m) solid var(--px-border-color-action-neutral-default);width:var(--px-action-size-m);height:var(--px-action-size-m);flex-shrink:0;transition:box-shadow .3s ease-out,background-color .3s;animation:anim-pop .2s cubic-bezier(.9,-.13,.61,.99) forwards .1s}.radio:not(.selectable-tag) input:checked{background-color:var(--px-background-color-action-primary-default);border-color:var(--px-border-color-none);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='4' fill='white'/%3E%3C/svg%3E");background-position:center center}.radio:not(.selectable-tag) input:hover:not([disabled]),.radio:not(.selectable-tag) input.hover:not([disabled]){border:var(--px-border-size-l) solid var(--px-border-color-action-hover-default)}.radio:not(.selectable-tag) input:checked:not([disabled]):hover,.radio:not(.selectable-tag) input:checked:not([disabled]).hover{box-shadow:inset 0 0 0 var(--px-border-size-s) var(--px-border-color-action-hover-default),0 0 0 var(--px-border-size-s) var(--px-border-color-action-hover-default)}.radio:not(.selectable-tag) input:disabled{background-color:var(--px-background-color-action-disabled-default);border-color:var(--px-border-color-container-main-default)}.radio:not(.selectable-tag) input:disabled:checked{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='4' fill='black' fill-opacity='0.12'/%3E%3C/svg%3E")}.radio:not(.selectable-tag) input:disabled+label{color:var(--px-text-color-action-disabled-default)}.radio:not(.selectable-tag) input.error:not(:disabled){border-color:var(--px-border-color-purpose-error-default)}.radio:not(.selectable-tag) input.error:not(:disabled):checked{background-color:var(--px-background-color-purpose-error-default)}.radio:not(.selectable-tag) input.error:not(:disabled):checked:hover,.radio:not(.selectable-tag) input.error:not(:disabled):checked.hover{background-color:var(--px-background-color-action-primary-default)}.radio:not(.selectable-tag) input[inverted]{border-color:var(--px-border-color-action-neutral-inverted)}.radio:not(.selectable-tag) input[inverted]:checked{background-color:var(--px-background-color-action-primary-inverted);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='4' fill='%235C2D91'/%3E%3C/svg%3E")}.radio:not(.selectable-tag) input[inverted]:hover:not([disabled]),.radio:not(.selectable-tag) input[inverted].hover:not([disabled]){border-color:var(--px-border-color-action-hover-inverted)}.radio:not(.selectable-tag) input[inverted]:checked:not([disabled]):hover,.radio:not(.selectable-tag) input[inverted]:checked:not([disabled]).hover{box-shadow:inset 0 0 0 var(--px-border-size-s) var(--px-border-color-action-hover-inverted),0 0 0 var(--px-border-size-s) var(--px-border-color-action-hover-inverted)}.radio:not(.selectable-tag) input[inverted]:disabled{background-color:var(--px-background-color-action-disabled-inverted);border-color:var(--px-border-color-container-main-inverted)}.radio:not(.selectable-tag) input[inverted]:disabled:checked{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='4' fill='white' fill-opacity='0.16'/%3E%3C/svg%3E")}.radio:not(.selectable-tag) input[inverted]:disabled+label{color:var(--px-text-color-action-disabled-inverted)}.radio:not(.selectable-tag) input[inverted].error:not(:disabled){border-color:var(--px-border-color-purpose-error-inverted)}.radio:not(.selectable-tag) input[inverted].error:not(:disabled):checked{background-color:var(--px-background-color-purpose-error-inverted);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='4' fill='white'/%3E%3C/svg%3E")}.radio:not(.selectable-tag) input[inverted].error:not(:disabled):checked:hover,.radio:not(.selectable-tag) input[inverted].error:not(:disabled):checked.hover{background-color:var( --px-background-color-action-primary-inverted );background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='4' fill='%235C2D91'/%3E%3C/svg%3E")}.radio:not(.selectable-tag) input[inverted]+label{color:var(--px-text-color-heading-neutral-inverted)}.radio.selectable-tag{gap:0}.radio.selectable-tag input{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin:0}.radio.selectable-tag label{line-height:var(--px-line-height-m);display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;gap:var(--px-spacing-after-element-xs-mobile);background-color:var(--px-background-color-action-neutral-inverted);color:var(--px-text-color-action-neutral-default);padding:var(--px-padding-2xs-mobile) var(--px-padding-xs-mobile);border:var(--px-border-size-m) solid var(--px-border-color-action-neutral-default);border-radius:var(--px-radius-pill);transition:all .2s ease-in-out 0s}.radio.selectable-tag input:hover:not([disabled],[aria-disabled=true])+label,.radio.selectable-tag input.hover:not([disabled],[aria-disabled=true])+label{color:var(--px-text-color-action-brand-default);background:var(--px-background-color-action-hover-bordered-default);border-color:var(--px-border-color-action-hover-default);cursor:pointer}.radio.selectable-tag input:active:not([disabled],[aria-disabled=true])+label{background:var(--px-background-color-action-active-default);color:var(--px-text-color-action-active-inverted);border-color:var(--px-border-color-none)}.radio.selectable-tag input:checked+label,.radio.selectable-tag input:checked+label:hover{background-color:var(--px-background-color-action-active-default);border-color:var(--px-border-color-none);color:var(--px-text-color-action-active-inverted)}.radio.selectable-tag input[disabled]+label{background:var(--px-background-color-action-disabled-default);color:var(--px-text-color-action-disabled-default);border-color:var(--px-border-color-none)}:host([inverted]) .radio.selectable-tag label{background:var(--px-background-color-action-neutral-default);color:var(--px-text-color-action-brand-inverted);border-color:var(--px-border-color-action-neutral-inverted)}:host([inverted]) .radio.selectable-tag input:hover:not([disabled],[aria-disabled=true])+label,:host([inverted]) .radio.selectable-tag input.hover:not([disabled],[aria-disabled=true])+label{color:var(--px-text-color-action-brand-inverted);background:var(--px-background-color-action-hover-bordered-inverted);border-color:var(--px-border-color-action-hover-inverted)}:host([inverted]) .radio.selectable-tag input:active:not([disabled],[aria-disabled=true])+label{background:var(--px-background-color-action-active-inverted);color:var(--px-text-color-action-active-default);border-color:var(--px-border-color-none)}:host([inverted]) .radio.selectable-tag input:checked+label,:host([inverted]) .radio.selectable-tag input:checked+label:hover{background-color:var(--px-background-color-action-active-inverted);border-color:var(--px-border-color-none);color:var(--px-text-color-action-active-default)}:host([inverted]) .radio.selectable-tag input[disabled]+label{background:var(--px-background-color-action-disabled-inverted);color:var(--px-text-color-action-disabled-inverted);border-color:var(--px-border-color-none)}@media only screen and (min-width: 768px){:host(:focus-visible){outline-width:var(--px-focus-outline-tablet);outline-offset:var(--px-focus-offset-tablet)}label{font-size:var(--px-text-size-label-m-tablet)}}@media only screen and (min-width: 1025px){:host(:focus-visible){outline-width:var(--px-focus-outline-desktop);outline-offset:var(--px-focus-offset-desktop)}label{font-size:var(--px-text-size-label-m-desktop)}}@keyframes anim-pop{0%{transform:scale(0)}to{transform:scale(1)}}`, p = new CSSStyleSheet();
|
|
3
|
+
p.replaceSync(g);
|
|
4
|
+
const s = class s extends h {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(p), this.template = () => `<div class="radio" tabindex="-1">
|
|
7
|
+
<input type="radio" tabindex="-1" />
|
|
8
|
+
<label><slot name="before"></slot><slot name="label"></slot></label>
|
|
9
|
+
</div>`, this.shadowRoot && (this.shadowRoot.innerHTML = this.template());
|
|
10
|
+
}
|
|
11
|
+
static get observedAttributes() {
|
|
12
|
+
return [...super.observedAttributes, "hover"];
|
|
13
|
+
}
|
|
14
|
+
attributeChangedCallback(e, t, r) {
|
|
15
|
+
if (t !== r)
|
|
16
|
+
switch (e) {
|
|
17
|
+
case "hover":
|
|
18
|
+
this.$el.classList.toggle("hover");
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
super.attributeChangedCallback(e, t, r);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
get $radio() {
|
|
26
|
+
return this.shadowRoot.querySelector(".radio");
|
|
27
|
+
}
|
|
28
|
+
get $labelSlot() {
|
|
29
|
+
return this.querySelector('[slot="label"]');
|
|
30
|
+
}
|
|
31
|
+
get $iconSlot() {
|
|
32
|
+
return this.querySelector('px-icon[slot="before"]');
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
s.nativeName = "input";
|
|
36
|
+
let o = s;
|
|
37
|
+
customElements.define("px-radio-base", o);
|
|
38
|
+
const u = ["", "default", "selectable-tag"], x = ["", "error"], n = class n extends o {
|
|
39
|
+
constructor() {
|
|
40
|
+
var e, t;
|
|
41
|
+
super(), this.internals = (e = this.attachInternals) == null ? void 0 : e.call(this), this.tabIndex = ((t = this.parentElement) == null ? void 0 : t.firstElementChild) === this ? 0 : -1, this.internals && (this.internals.role = "radio", this.internals.ariaChecked = `${this.checked}`);
|
|
42
|
+
}
|
|
43
|
+
static get observedAttributes() {
|
|
44
|
+
return [...super.observedAttributes, "state", "variant", "inverted"];
|
|
45
|
+
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
this.addEventListener("keypress", (e) => {
|
|
48
|
+
switch (e.stopPropagation(), e.preventDefault(), e.code) {
|
|
49
|
+
case "Space":
|
|
50
|
+
this.click();
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}), this.addEventListener("click", (e) => {
|
|
54
|
+
this.checked || (this.checked = !0), e.stopPropagation(), e.preventDefault();
|
|
55
|
+
}), this.setupForId(), this.hasAttribute("checked") && (this.checked = !0), this.$iconSlot && (this.$iconSlot.setAttribute("size", "xs"), this.$iconSlot.setAttribute("color", "inherit")), !this.$labelSlot && !this.$iconSlot ? this.$radio.classList.add("all-slots-empty") : this.$radio.classList.remove("all-slots-empty");
|
|
56
|
+
}
|
|
57
|
+
attributeChangedCallback(e, t, r) {
|
|
58
|
+
if (t !== r)
|
|
59
|
+
switch (e) {
|
|
60
|
+
case "state":
|
|
61
|
+
this.updateAttribute(t, r, x, e);
|
|
62
|
+
break;
|
|
63
|
+
case "variant":
|
|
64
|
+
this.updateAttribute(t, r, u, e);
|
|
65
|
+
break;
|
|
66
|
+
case "checked":
|
|
67
|
+
this.handleCheckedChange(r !== null);
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
super.attributeChangedCallback(e, t, r);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Form-associated callbacks
|
|
75
|
+
static get formAssociated() {
|
|
76
|
+
return !0;
|
|
77
|
+
}
|
|
78
|
+
// Set default behavior when the element is attached to a form
|
|
79
|
+
formResetCallback() {
|
|
80
|
+
this.checked = !1;
|
|
81
|
+
}
|
|
82
|
+
formStateRestoreCallback(e) {
|
|
83
|
+
this.checked = e;
|
|
84
|
+
}
|
|
85
|
+
updateAttribute(e, t, r, a) {
|
|
86
|
+
var c, b;
|
|
87
|
+
if (!this.checkName(r, t)) {
|
|
88
|
+
console.error(
|
|
89
|
+
`${t} is not a valid ${a} value for`,
|
|
90
|
+
this.$el
|
|
91
|
+
);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
e !== null && (a === "variant" ? (c = this.$el.parentElement) == null || c.classList.toggle(e) : this.$el.classList.toggle(e)), t !== null && (a === "variant" ? (b = this.$el.parentElement) == null || b.classList.toggle(t) : this.$el.classList.toggle(t));
|
|
95
|
+
}
|
|
96
|
+
handleCheckedChange(e) {
|
|
97
|
+
var t;
|
|
98
|
+
this.$el.checked = e, (t = this.internals) == null || t.setFormValue(this.formData()), e ? (this.tabIndex = 0, this.internals && (this.internals.ariaChecked = "true"), this.setAttribute("checked", "")) : (this.tabIndex = -1, this.removeAttribute("checked"), this.internals && (this.internals.ariaChecked = "false")), e && this.dispatchEvent(
|
|
99
|
+
new Event("change", {
|
|
100
|
+
bubbles: !0,
|
|
101
|
+
composed: !0
|
|
102
|
+
// Allow the event to pass through shadow DOM boundaries
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
formData() {
|
|
107
|
+
if (this.$el.name) {
|
|
108
|
+
const e = new FormData(), t = this.getAttribute("name");
|
|
109
|
+
return t && (this.$el.checked ? e.set(t, this.$el.value) : e.delete(t)), e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
setupForId() {
|
|
113
|
+
const e = Math.random().toString(36).substr(2, 9);
|
|
114
|
+
this.$el.setAttribute("id", e), this.$label && this.$label.setAttribute("for", e);
|
|
115
|
+
}
|
|
116
|
+
checkName(e, t) {
|
|
117
|
+
return e.includes(t);
|
|
118
|
+
}
|
|
119
|
+
get state() {
|
|
120
|
+
return this.getAttribute("state");
|
|
121
|
+
}
|
|
122
|
+
set state(e) {
|
|
123
|
+
this.setAttribute("state", e);
|
|
124
|
+
}
|
|
125
|
+
get disabled() {
|
|
126
|
+
return this.getAttribute("disabled") !== null;
|
|
127
|
+
}
|
|
128
|
+
set disabled(e) {
|
|
129
|
+
e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
130
|
+
}
|
|
131
|
+
get $label() {
|
|
132
|
+
return this.shadowRoot.querySelector("label");
|
|
133
|
+
}
|
|
134
|
+
get inverted() {
|
|
135
|
+
return this.getAttribute("inverted");
|
|
136
|
+
}
|
|
137
|
+
set inverted(e) {
|
|
138
|
+
this.setAttribute("inverted", e);
|
|
139
|
+
}
|
|
140
|
+
get checked() {
|
|
141
|
+
return this.$el.checked;
|
|
142
|
+
}
|
|
143
|
+
set checked(e) {
|
|
144
|
+
e ? this.setAttribute("checked", e ? "" : "false") : this.removeAttribute("checked");
|
|
145
|
+
}
|
|
146
|
+
get $radio() {
|
|
147
|
+
return this.shadowRoot.querySelector(".radio");
|
|
148
|
+
}
|
|
149
|
+
get $labelSlot() {
|
|
150
|
+
return this.querySelector('[slot="label"]');
|
|
151
|
+
}
|
|
152
|
+
get $iconSlot() {
|
|
153
|
+
return this.querySelector('px-icon[slot="before"]');
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
n.nativeName = "input";
|
|
157
|
+
let i = n;
|
|
158
|
+
customElements.define("px-radio", i);
|
|
159
|
+
const f = "div[role=radiogroup]{display:flex;flex-direction:column;gap:var( --px-radiogroup-gap--mobile, var(--px-spacing-after-element-xs-mobile) )}div[role=radiogroup].selectable-tag{display:inline-flex;flex-direction:row}@media screen and (min-width: 768px){div[role=radiogroup]{gap:var( --px-radiogroup-gap--tablet, var(--px-spacing-after-element-xs-tablet) )}}@media screen and (min-width: 1025px){div[role=radiogroup]{gap:var( --px-radiogroup-gap--laptop, var(--px-spacing-after-element-xs-desktop) )}}", v = new CSSStyleSheet();
|
|
160
|
+
v.replaceSync(f);
|
|
161
|
+
const k = [
|
|
162
|
+
"",
|
|
163
|
+
"after-element-none",
|
|
164
|
+
"after-element-2xs",
|
|
165
|
+
"after-element-xs",
|
|
166
|
+
"after-element-s",
|
|
167
|
+
"after-element-default",
|
|
168
|
+
"after-element-l"
|
|
169
|
+
], d = class d extends h {
|
|
170
|
+
constructor() {
|
|
171
|
+
var e;
|
|
172
|
+
super(v), this.template = () => `<div role="radiogroup">
|
|
173
|
+
<slot></slot>
|
|
174
|
+
</div>`, this.handleKeyDown = () => {
|
|
175
|
+
var r;
|
|
176
|
+
const t = this.currentCheckedRadio ? ((r = this.currentCheckedRadio) == null ? void 0 : r.nextElementSibling) ?? this.$radioList[0] : this.$radioList[1];
|
|
177
|
+
t.checked = !0, t.focus();
|
|
178
|
+
}, this.handleKeyUp = () => {
|
|
179
|
+
var r;
|
|
180
|
+
const t = ((r = this.currentCheckedRadio) == null ? void 0 : r.previousElementSibling) ?? this.$radioList[this.$radioList.length - 1];
|
|
181
|
+
t.checked = !0, t.focus();
|
|
182
|
+
}, this.handleRadioChange = (t) => {
|
|
183
|
+
const r = t.target;
|
|
184
|
+
if (r.localName === "px-tile-radio" || r.localName === "px-radio") {
|
|
185
|
+
this.currentCheckedRadio = r;
|
|
186
|
+
const a = r.getAttribute("name");
|
|
187
|
+
a && this.currentCheckedRadio.checked && this.uncheckOtherRadios(a);
|
|
188
|
+
}
|
|
189
|
+
}, this.shadowRoot.innerHTML = this.template(), this.internals = (e = this.attachInternals) == null ? void 0 : e.call(this);
|
|
190
|
+
}
|
|
191
|
+
static get observedAttributes() {
|
|
192
|
+
return [
|
|
193
|
+
...super.observedAttributes,
|
|
194
|
+
"name",
|
|
195
|
+
"gap",
|
|
196
|
+
"variant",
|
|
197
|
+
"required",
|
|
198
|
+
"disabled",
|
|
199
|
+
"state",
|
|
200
|
+
"inverted"
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
connectedCallback() {
|
|
204
|
+
(!this.hasAttribute("name") || this.getAttribute("name") === "") && console.error(
|
|
205
|
+
'<px-radio-group> requires a "name" attribute to function properly.'
|
|
206
|
+
), this.addEventListener("change", this.handleRadioChange), this.addEventListener("keydown", (e) => {
|
|
207
|
+
switch (e.code) {
|
|
208
|
+
case "ArrowUp":
|
|
209
|
+
case "ArrowDown":
|
|
210
|
+
e.stopPropagation(), e.preventDefault();
|
|
211
|
+
}
|
|
212
|
+
}), this.addEventListener("keyup", (e) => {
|
|
213
|
+
switch (e.stopPropagation(), e.preventDefault(), e.code) {
|
|
214
|
+
case "ArrowUp":
|
|
215
|
+
case "ArrowLeft":
|
|
216
|
+
this.handleKeyUp();
|
|
217
|
+
break;
|
|
218
|
+
case "ArrowDown":
|
|
219
|
+
case "ArrowRight":
|
|
220
|
+
this.handleKeyDown();
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
disconnectedCallback() {
|
|
226
|
+
this.removeEventListener("change", this.handleRadioChange);
|
|
227
|
+
}
|
|
228
|
+
attributeChangedCallback(e, t, r) {
|
|
229
|
+
t !== r && (e === "gap" ? this.updateGap(t, r, k) : e === "variant" ? this.updateVariant(t, r, u) : this.$radioList.forEach((a) => {
|
|
230
|
+
if (r === null)
|
|
231
|
+
a.removeAttribute(e);
|
|
232
|
+
else
|
|
233
|
+
switch (e) {
|
|
234
|
+
case "required":
|
|
235
|
+
this.$el.ariaRequired = "true";
|
|
236
|
+
break;
|
|
237
|
+
case "state":
|
|
238
|
+
r === "error" && (this.$el.ariaInvalid = "true", a.setAttribute(e, r));
|
|
239
|
+
break;
|
|
240
|
+
case "disabled":
|
|
241
|
+
this.$el.ariaDisabled = "true", a.setAttribute(e, r);
|
|
242
|
+
break;
|
|
243
|
+
default:
|
|
244
|
+
a.setAttribute(e, r);
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
uncheckOtherRadios(e) {
|
|
250
|
+
this.querySelectorAll(
|
|
251
|
+
`px-radio[name="${e}"], px-tile-radio[name="${e}"]`
|
|
252
|
+
).forEach((r) => {
|
|
253
|
+
r !== this.currentCheckedRadio && (r.checked = !1);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
updateVariant(e, t, r) {
|
|
257
|
+
if (!this.checkName(r, t)) {
|
|
258
|
+
console.error(`${t} is not a valid variant value for`, this.$el);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
e !== null && e !== "" && this.$el.classList.toggle(e), t !== null && t !== "" && (this.$el.classList.toggle(t), this.$radioList.forEach((a) => {
|
|
262
|
+
a.setAttribute("variant", t);
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
updateGap(e, t, r) {
|
|
266
|
+
if (!this.checkName(r, t)) {
|
|
267
|
+
console.error(`${t} is not a valid gap value for`, this.$el);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.updateGapStyle(e), this.updateGapStyle(t);
|
|
271
|
+
}
|
|
272
|
+
updateGapStyle(e) {
|
|
273
|
+
e !== null && e !== "" && e !== "default" && (this.$el.style.setProperty(
|
|
274
|
+
"--px-radiogroup-gap--mobile",
|
|
275
|
+
`var(--px-spacing-${e}-mobile)`
|
|
276
|
+
), this.$el.style.setProperty(
|
|
277
|
+
"--px-radiogroup-gap--tablet",
|
|
278
|
+
`var(--px-spacing-${e}-tablet)`
|
|
279
|
+
), this.$el.style.setProperty(
|
|
280
|
+
"--px-radiogroup-gap--laptop",
|
|
281
|
+
`var(--px-spacing-${e}-desktop)`
|
|
282
|
+
));
|
|
283
|
+
}
|
|
284
|
+
checkName(e, t) {
|
|
285
|
+
return e.includes(t);
|
|
286
|
+
}
|
|
287
|
+
get $radioList() {
|
|
288
|
+
return this.querySelectorAll(
|
|
289
|
+
"px-radio, px-tile-radio"
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
get gap() {
|
|
293
|
+
return this.getAttribute("gap");
|
|
294
|
+
}
|
|
295
|
+
set gap(e) {
|
|
296
|
+
this.setAttribute("gap", e);
|
|
297
|
+
}
|
|
298
|
+
get variant() {
|
|
299
|
+
return this.getAttribute("variant");
|
|
300
|
+
}
|
|
301
|
+
set variant(e) {
|
|
302
|
+
this.setAttribute("variant", e);
|
|
303
|
+
}
|
|
304
|
+
get state() {
|
|
305
|
+
return this.getAttribute("state");
|
|
306
|
+
}
|
|
307
|
+
set state(e) {
|
|
308
|
+
this.setAttribute("state", e);
|
|
309
|
+
}
|
|
310
|
+
get $label() {
|
|
311
|
+
return this.shadowRoot.querySelector("label");
|
|
312
|
+
}
|
|
313
|
+
get inverted() {
|
|
314
|
+
return this.getAttribute("inverted");
|
|
315
|
+
}
|
|
316
|
+
set inverted(e) {
|
|
317
|
+
this.setAttribute("inverted", e);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
d.nativeName = "div";
|
|
321
|
+
let l = d;
|
|
322
|
+
customElements.define("px-radio-group", l);
|
|
323
|
+
export {
|
|
324
|
+
i as Radio,
|
|
325
|
+
l as Radiogroup,
|
|
326
|
+
k as gapValues,
|
|
327
|
+
x as stateValues,
|
|
328
|
+
u as variantValues
|
|
329
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-radio-group",
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"development": "./src/index.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./src/*.css": {
|
|
13
|
+
"development": "src/*.css"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rm -rf dist;tsc; vite build",
|
|
22
|
+
"test": "vitest run --coverage"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "98b517c6cedf3a4b9c2757688bf307ac432aebb3",
|
|
28
|
+
"lerna": {
|
|
29
|
+
"command": {
|
|
30
|
+
"publish": {
|
|
31
|
+
"assets": [
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"package.json",
|
|
34
|
+
"dist/*.js",
|
|
35
|
+
"dist/*.cjs",
|
|
36
|
+
"dist/css/**/*.css",
|
|
37
|
+
"dist/js/**/*.js"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|