@warp-ds/elements 2.2.0-next.18 → 2.2.0-next.19
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/README.md +18 -0
- package/dist/custom-elements.json +2574 -1052
- package/dist/index.d.ts +1819 -103
- package/dist/packages/rip-and-tear-checkbox/checkbox.js +143 -193
- package/dist/packages/rip-and-tear-checkbox/checkbox.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio-group-styles.js +3 -3
- package/dist/packages/rip-and-tear-radio/radio-group-styles.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio-group.js +244 -311
- package/dist/packages/rip-and-tear-radio/radio-group.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio-styles.js +3 -3
- package/dist/packages/rip-and-tear-radio/radio-styles.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio.js +180 -102
- package/dist/packages/rip-and-tear-radio/radio.js.map +7 -0
- package/dist/packages/tabs/tab-panel.js +2440 -50
- package/dist/packages/tabs/tab-panel.js.map +7 -0
- package/dist/packages/tabs/tab.js +2451 -91
- package/dist/packages/tabs/tab.js.map +7 -0
- package/dist/packages/tabs/tabs.js +2444 -234
- package/dist/packages/tabs/tabs.js.map +7 -0
- package/dist/packages/tabs/tabs.stories.js +2473 -12
- package/dist/packages/tabs/tabs.stories.js.map +7 -0
- package/dist/vscode.html-custom-data.json +206 -18
- package/dist/web-types.json +435 -35
- package/package.json +3 -3
|
@@ -1,273 +1,248 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The radio group's label. Required for proper accessibility. If you need to display HTML, use the `label` slot
|
|
60
|
-
* instead.
|
|
61
|
-
*/
|
|
62
|
-
this.label = '';
|
|
63
|
-
/** The radio groups's hint. If you need to display HTML, use the `hint` slot instead. */
|
|
64
|
-
this.hint = '';
|
|
65
|
-
/** The name of the radio group, submitted as a name/value pair with form data. */
|
|
66
|
-
this.name = null;
|
|
67
|
-
/** Disables the radio group and all child radios. */
|
|
68
|
-
this.disabled = false;
|
|
69
|
-
/** The orientation in which to show radio items. */
|
|
70
|
-
this.orientation = 'vertical';
|
|
71
|
-
this._value = null;
|
|
72
|
-
/** The default value of the form control. Primarily used for resetting the form control. */
|
|
73
|
-
this.defaultValue = this.getAttribute('value') || null;
|
|
74
|
-
/** The radio group's size. This size will be applied to all child radios and radio buttons, except when explicitly overridden. */
|
|
75
|
-
this.size = 'medium';
|
|
76
|
-
/** Ensures a child radio is checked before allowing the containing form to submit. */
|
|
77
|
-
this.required = false;
|
|
78
|
-
/**
|
|
79
|
-
* Used for SSR. if true, will show slotted label on initial render.
|
|
80
|
-
*/
|
|
81
|
-
this.withLabel = false;
|
|
82
|
-
/**
|
|
83
|
-
* Used for SSR. if true, will show slotted hint on initial render.
|
|
84
|
-
*/
|
|
85
|
-
this.withHint = false;
|
|
86
|
-
this.handleRadioClick = (e) => {
|
|
87
|
-
const clickedRadio = e.target.closest('w-radio');
|
|
88
|
-
/* eslint-disable */
|
|
89
|
-
if (!clickedRadio || clickedRadio.disabled || clickedRadio.forceDisabled || this.disabled) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const oldValue = this.value;
|
|
93
|
-
this.value = clickedRadio.value;
|
|
94
|
-
clickedRadio.checked = true;
|
|
95
|
-
const radios = this.getAllRadios();
|
|
96
|
-
for (const radio of radios) {
|
|
97
|
-
if (clickedRadio === radio) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
radio.checked = false;
|
|
101
|
-
radio.setAttribute('tabindex', '-1');
|
|
102
|
-
}
|
|
103
|
-
if (this.value !== oldValue) {
|
|
104
|
-
this.updateComplete.then(() => {
|
|
105
|
-
this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));
|
|
106
|
-
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
this.addEventListener('keydown', this.handleKeyDown);
|
|
111
|
-
this.addEventListener('click', this.handleRadioClick);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* We use the first available radio as the validationTarget similar to native HTML that shows the validation popup on
|
|
115
|
-
* the first radio element.
|
|
116
|
-
*/
|
|
117
|
-
get validationTarget() {
|
|
118
|
-
const radio = this.querySelector(':is(w-radio):not([disabled])');
|
|
119
|
-
if (!radio)
|
|
120
|
-
return undefined;
|
|
121
|
-
return radio;
|
|
122
|
-
}
|
|
123
|
-
updated(changedProperties) {
|
|
124
|
-
if (changedProperties.has('disabled') || changedProperties.has('value')) {
|
|
125
|
-
this.syncRadioElements();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
formResetCallback(...args) {
|
|
129
|
-
this.value = this.defaultValue;
|
|
130
|
-
super.formResetCallback(...args);
|
|
131
|
-
this.syncRadioElements();
|
|
132
|
-
}
|
|
133
|
-
getAllRadios() {
|
|
134
|
-
return [...this.querySelectorAll('w-radio')];
|
|
135
|
-
}
|
|
136
|
-
handleLabelClick() {
|
|
137
|
-
this.focus();
|
|
1
|
+
var O=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var V=s=>{throw TypeError(s)};var l=(s,r,t,e)=>{for(var a=e>1?void 0:e?B(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(a=(e?o(r,t,a):o(a))||a);return e&&a&&O(r,t,a),a};var x=(s,r,t)=>r.has(s)||V("Cannot "+t);var C=(s,r,t)=>(x(s,r,"read from private field"),t?t.call(s):r.get(s)),S=(s,r,t)=>r.has(s)?V("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(s):r.set(s,t),A=(s,r,t,e)=>(x(s,r,"write to private field"),e?e.call(s,t):r.set(s,t),t);import{html as J}from"lit";import{property as m,query as Q,state as U}from"lit/decorators.js";import{classMap as F}from"lit/directives/class-map.js";import{isServer as k}from"lit";import{property as b}from"lit/decorators.js";import{LitElement as $,unsafeCSS as _}from"lit";import{property as L}from"lit/decorators.js";import{css as P}from"lit";var R=P`
|
|
2
|
+
:host {
|
|
3
|
+
box-sizing: border-box !important;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host *,
|
|
7
|
+
:host *::before,
|
|
8
|
+
:host *::after {
|
|
9
|
+
box-sizing: inherit !important;
|
|
10
|
+
}
|
|
11
|
+
`;var g,p=class extends ${constructor(){super();S(this,g,!1);this.initialReflectedProperties=new Map;this.customStates={set:(t,e)=>{var a;(a=this.internals)!=null&&a.states&&(e?this.internals.states.add(t):this.internals.states.delete(t))},has:t=>{var e;return(e=this.internals)!=null&&e.states?this.internals.states.has(t):!1}};try{this.internals=this.attachInternals()}catch(e){console.error("Element internals are not supported in your browser. Consider using a polyfill")}this.customStates.set("wa-defined",!0);let t=this.constructor;for(let[e,a]of t.elementProperties)a.default==="inherit"&&a.initial!==void 0&&typeof e=="string"&&this.customStates.set(`initial-${e}-${a.initial}`,!0)}static get styles(){let t=Array.isArray(this.css)?this.css:this.css?[this.css]:[];return[R,...t].map(e=>typeof e=="string"?_(e):e)}attributeChangedCallback(t,e,a){C(this,g)||(this.constructor.elementProperties.forEach((i,o)=>{i.reflect&&this[o]!=null&&this.initialReflectedProperties.set(o,this[o])}),A(this,g,!0)),super.attributeChangedCallback(t,e,a)}willUpdate(t){super.willUpdate(t),this.initialReflectedProperties.forEach((e,a)=>{t.has(a)&&this[a]==null&&(this[a]=e)})}relayNativeEvent(t,e){t.stopImmediatePropagation(),this.dispatchEvent(new t.constructor(t.type,{...t,...e}))}};g=new WeakMap,l([L()],p.prototype,"dir",2),l([L()],p.prototype,"lang",2);var T=()=>({observedAttributes:["custom-error"],checkValidity(s){let r={message:"",isValid:!0,invalidKeys:[]};return s.customError&&(r.message=s.customError,r.isValid=!1,r.invalidKeys=["customError"]),r}});var w=class extends Event{constructor(){super("w-invalid",{bubbles:!0,cancelable:!1,composed:!0})}};var c=class extends p{constructor(){super();this.name=null;this.disabled=!1;this.required=!1;this.assumeInteractionOn=["input"];this.validators=[];this.valueHasChanged=!1;this.hasInteracted=!1;this.customError=null;this.emittedEvents=[];this.emitInvalid=t=>{t.target===this&&(this.hasInteracted=!0,this.dispatchEvent(new w))};this.handleInteraction=t=>{var a;let e=this.emittedEvents;e.includes(t.type)||e.push(t.type),e.length===((a=this.assumeInteractionOn)==null?void 0:a.length)&&(this.hasInteracted=!0)};k||this.addEventListener("invalid",this.emitInvalid)}static get validators(){return[T()]}static get observedAttributes(){let t=new Set(super.observedAttributes||[]);for(let e of this.validators)if(e.observedAttributes)for(let a of e.observedAttributes)t.add(a);return[...t]}connectedCallback(){super.connectedCallback(),this.updateValidity(),this.assumeInteractionOn.forEach(t=>{this.addEventListener(t,this.handleInteraction)})}firstUpdated(...t){super.firstUpdated(...t),this.updateValidity()}willUpdate(t){if(!k&&t.has("customError")&&(this.customError||(this.customError=null),this.setCustomValidity(this.customError||"")),t.has("value")||t.has("disabled")){let e=this.value;if(Array.isArray(e)){if(this.name){let a=new FormData;for(let i of e)a.append(this.name,i);this.setValue(a,a)}}else this.setValue(e,e)}t.has("disabled")&&(this.customStates.set("disabled",this.disabled),(this.hasAttribute("disabled")||!k&&!this.matches(":disabled"))&&this.toggleAttribute("disabled",this.disabled)),this.updateValidity(),super.willUpdate(t)}get labels(){return this.internals.labels}getForm(){return this.internals.form}get validity(){return this.internals.validity}get willValidate(){return this.internals.willValidate}get validationMessage(){return this.internals.validationMessage}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return this.updateValidity(),this.hasInteracted=!0,this.internals.reportValidity()}get validationTarget(){return this.input||void 0}setValidity(...t){let e=t[0],a=t[1],i=t[2];i||(i=this.validationTarget),this.internals.setValidity(e,a,i||void 0),this.requestUpdate("validity"),this.setCustomStates()}setCustomStates(){let t=!!this.required,e=this.internals.validity.valid,a=this.hasInteracted;this.customStates.set("required",t),this.customStates.set("optional",!t),this.customStates.set("invalid",!e),this.customStates.set("valid",e),this.customStates.set("user-invalid",!e&&a),this.customStates.set("user-valid",e&&a)}setCustomValidity(t){if(!t){this.customError=null,this.setValidity({});return}this.customError=t,this.setValidity({customError:!0},t,this.validationTarget)}formResetCallback(){this.resetValidity(),this.hasInteracted=!1,this.valueHasChanged=!1,this.emittedEvents=[],this.updateValidity()}formDisabledCallback(t){this.disabled=t,this.updateValidity()}formStateRestoreCallback(t,e){this.value=t,e==="restore"&&this.resetValidity(),this.updateValidity()}setValue(...t){let[e,a]=t;this.internals.setFormValue(e,a)}get allValidators(){let t=this.constructor.validators||[],e=this.validators||[];return[...t,...e]}resetValidity(){this.setCustomValidity(""),this.setValidity({})}updateValidity(){if(this.disabled||this.hasAttribute("disabled")||!this.willValidate){this.resetValidity();return}let t=this.allValidators;if(!(t!=null&&t.length))return;let e={customError:!!this.customError},a=this.validationTarget||this.input||void 0,i="";for(let o of t){let{isValid:n,message:v,invalidKeys:u}=o.checkValidity(this);n||(i||(i=v),(u==null?void 0:u.length)>=0&&u.forEach(h=>e[h]=!0))}i||(i=this.validationMessage),this.setValidity(e,i,a)}};c.formAssociated=!0,l([b({reflect:!0})],c.prototype,"name",2),l([b({type:Boolean})],c.prototype,"disabled",2),l([b({state:!0,attribute:!1})],c.prototype,"valueHasChanged",2),l([b({state:!0,attribute:!1})],c.prototype,"hasInteracted",2),l([b({attribute:"custom-error",reflect:!0})],c.prototype,"customError",2),l([b({attribute:!1,state:!0,type:Object})],c.prototype,"validity",1);var I="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var H=(s=21)=>{let r="",t=crypto.getRandomValues(new Uint8Array(s|=0));for(;s--;)r+=I[t[s]&63];return r};function M(s=""){return`${s}${H()}`}import{html as j}from"lit";import{property as y,state as q}from"lit/decorators.js";import{css as K}from"lit";var D=K`
|
|
12
|
+
:host {
|
|
13
|
+
color: var(--wa-form-control-value-color);
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
flex-direction: row;
|
|
16
|
+
align-items: top;
|
|
17
|
+
font-family: inherit;
|
|
18
|
+
font-weight: var(--wa-form-control-value-font-weight);
|
|
19
|
+
line-height: var(--wa-form-control-value-line-height);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
user-select: none;
|
|
22
|
+
-webkit-user-select: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host(:focus) {
|
|
26
|
+
outline: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[part~='label'] {
|
|
30
|
+
display: inline;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[part~='hint'] {
|
|
34
|
+
margin-block-start: 0.5em;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Default appearance */
|
|
38
|
+
:host([appearance='default']) {
|
|
39
|
+
.control {
|
|
40
|
+
flex: 0 0 auto;
|
|
41
|
+
position: relative;
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
width: var(--wa-form-control-toggle-size, 2rem);
|
|
46
|
+
height: var(--wa-form-control-toggle-size, 2rem);
|
|
47
|
+
border-color: var(--wa-form-control-border-color, gray);
|
|
48
|
+
border-radius: 50%;
|
|
49
|
+
border-style: var(--wa-form-control-border-style, solid);
|
|
50
|
+
border-width: var(--wa-form-control-border-width, 1px);
|
|
51
|
+
background-color: var(--wa-form-control-background-color, white);
|
|
52
|
+
color: transparent;
|
|
53
|
+
transition-property: all;
|
|
54
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
55
|
+
transition-duration: 150ms;
|
|
56
|
+
|
|
57
|
+
margin-inline-end: 0.5em;
|
|
138
58
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
// Disabled radios should never be tabbable
|
|
192
|
-
radios
|
|
193
|
-
.filter((radio) => radio.disabled)
|
|
194
|
-
.forEach((radio) => {
|
|
195
|
-
radio.tabIndex = -1;
|
|
196
|
-
});
|
|
197
|
-
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([appearance='clickable']) .control {
|
|
62
|
+
position: absolute;
|
|
63
|
+
inset: 0;
|
|
64
|
+
height: 100%;
|
|
65
|
+
width: 100%;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Checked */
|
|
70
|
+
:host(:state(checked)):not(:host([appearance='clickable'])) .control {
|
|
71
|
+
/* color: var(--checked-icon-color, white); */
|
|
72
|
+
border-color: var(--wa-form-control-activated-color, blue);
|
|
73
|
+
background-color: var(--wa-form-control-background-color, white);
|
|
74
|
+
border-width: 0.6rem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Focus */
|
|
78
|
+
:host(:focus-visible) .control {
|
|
79
|
+
outline: 2px solid var(--w-s-color-border-focus);
|
|
80
|
+
outline-offset: var(--w-outline-offset, 1px);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([appearance='clickable']:focus-visible) .control {
|
|
84
|
+
outline-offset: -4px;
|
|
85
|
+
border-radius: 8px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Disabled */
|
|
89
|
+
:host(:state(disabled)) {
|
|
90
|
+
opacity: 0.5;
|
|
91
|
+
cursor: not-allowed;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Button appearance */
|
|
95
|
+
:host([appearance='button']) {
|
|
96
|
+
align-items: center;
|
|
97
|
+
min-height: var(--wa-form-control-height);
|
|
98
|
+
background-color: var(--wa-color-surface-default);
|
|
99
|
+
border: var(--wa-form-control-border-width) var(--wa-form-control-border-style) var(--wa-form-control-border-color);
|
|
100
|
+
border-radius: var(--wa-border-radius-m);
|
|
101
|
+
padding: 0 var(--wa-form-control-padding-inline);
|
|
102
|
+
transition:
|
|
103
|
+
background-color var(--wa-transition-fast),
|
|
104
|
+
border-color var(--wa-transition-fast);
|
|
105
|
+
|
|
106
|
+
.control {
|
|
107
|
+
display: none;
|
|
198
108
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
radios[index].shadowRoot.querySelector('button').focus();
|
|
235
|
-
}
|
|
236
|
-
if (this.value !== oldValue) {
|
|
237
|
-
this.updateComplete.then(() => {
|
|
238
|
-
this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));
|
|
239
|
-
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
event.preventDefault();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Horizontal grouping - remove inner border radius */
|
|
112
|
+
:host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-inner]) {
|
|
113
|
+
border-radius: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-first]) {
|
|
117
|
+
border-start-end-radius: 0;
|
|
118
|
+
border-end-end-radius: 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-last]) {
|
|
122
|
+
border-start-start-radius: 0;
|
|
123
|
+
border-end-start-radius: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Vertical grouping - remove inner border radius */
|
|
127
|
+
:host([appearance='button'][data-wa-radio-vertical][data-wa-radio-inner]) {
|
|
128
|
+
border-radius: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host([appearance='button'][data-wa-radio-vertical][data-wa-radio-first]) {
|
|
132
|
+
border-end-start-radius: 0;
|
|
133
|
+
border-end-end-radius: 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:host([appearance='button'][data-wa-radio-vertical][data-wa-radio-last]) {
|
|
137
|
+
border-start-start-radius: 0;
|
|
138
|
+
border-start-end-radius: 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@media (hover: hover) {
|
|
142
|
+
:host([appearance='button']:hover:not(:state(disabled), :state(checked))) {
|
|
143
|
+
background-color: color-mix(in srgb, var(--wa-color-surface-default) 95%, var(--wa-color-mix-hover));
|
|
243
144
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
:host([appearance='button']:focus-visible) {
|
|
148
|
+
outline: var(--wa-focus-ring);
|
|
149
|
+
outline-offset: var(--wa-focus-ring-offset);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
:host([appearance='button']:state(checked)) {
|
|
153
|
+
border-color: var(--wa-form-control-activated-color);
|
|
154
|
+
background-color: var(--wa-color-brand-fill-quiet);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:host([appearance='button']:state(checked):focus-visible) {
|
|
158
|
+
outline: var(--wa-focus-ring-style) var(--wa-focus-ring-width) var(--wa-color-brand-border-loud);
|
|
159
|
+
outline-offset: var(--wa-focus-ring-offset);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Remove inner borders and handle overlap */
|
|
163
|
+
:host([appearance='button'][data-wa-radio-horizontal]:not([data-wa-radio-first])) {
|
|
164
|
+
margin-inline-start: calc(-1 * var(--wa-form-control-border-width));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
:host([appearance='button'][data-wa-radio-vertical]:not([data-wa-radio-first])) {
|
|
168
|
+
margin-block-start: calc(-1 * var(--wa-form-control-border-width));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Ensure interactive states are visible above adjacent buttons */
|
|
172
|
+
:host([appearance='button']:hover),
|
|
173
|
+
:host([appearance='button']:state(checked)) {
|
|
174
|
+
position: relative;
|
|
175
|
+
z-index: 1;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
:host([appearance='button']:focus-visible) {
|
|
179
|
+
z-index: 2;
|
|
180
|
+
}
|
|
181
|
+
`;var f=class extends c{constructor(){super();this.checked=!1;this.forceDisabled=!1;this.form=null;this.appearance="default";this.size="medium";this.disabled=!1;this.handleClick=()=>{!this.disabled&&!this.forceDisabled&&(this.checked=!0)};this.addEventListener("click",this.handleClick)}connectedCallback(){super.connectedCallback(),this.setInitialAttributes()}setInitialAttributes(){this.setAttribute("role","radio"),this.tabIndex=0,this.setAttribute("aria-disabled",this.disabled||this.forceDisabled?"true":"false")}updated(t){if(super.updated(t),t.has("checked")&&(this.customStates.set("checked",this.checked),this.setAttribute("aria-checked",this.checked?"true":"false"),!this.disabled&&!this.forceDisabled&&(this.tabIndex=this.checked?0:-1)),t.has("disabled")||t.has("forceDisabled")){let e=this.disabled||this.forceDisabled;this.customStates.set("disabled",e),this.setAttribute("aria-disabled",e?"true":"false"),e?this.tabIndex=-1:this.tabIndex=this.checked?0:-1}}setValue(){}render(){return j`
|
|
182
|
+
<span part="control" class="control"></span>
|
|
183
|
+
<slot part="label" class="label"></slot>
|
|
184
|
+
`}};f.css=[D],l([q()],f.prototype,"checked",2),l([q()],f.prototype,"forceDisabled",2),l([y({reflect:!0})],f.prototype,"form",2),l([y({reflect:!0})],f.prototype,"value",2),l([y({reflect:!0})],f.prototype,"appearance",2),l([y({reflect:!0})],f.prototype,"size",2),l([y({type:Boolean})],f.prototype,"disabled",2);import{css as X}from"lit";var N=X`
|
|
185
|
+
:host {
|
|
186
|
+
display: block;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.form-control {
|
|
190
|
+
position: relative;
|
|
191
|
+
border: none;
|
|
192
|
+
padding: 0;
|
|
193
|
+
margin: 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.label {
|
|
197
|
+
font-size: var(--w-font-size-s);
|
|
198
|
+
line-height: var(--w-line-height-s);
|
|
199
|
+
font-weight: 700;
|
|
200
|
+
-webkit-font-smoothing: antialiased;
|
|
201
|
+
-moz-osx-font-smoothing: grayscale;
|
|
202
|
+
font-smoothing: grayscale;
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
padding-bottom: 0.4rem;
|
|
205
|
+
color: var(--w-s-color-text);
|
|
206
|
+
display: block;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.radio-group-required .label::after {
|
|
210
|
+
content: var(--wa-form-control-required-content);
|
|
211
|
+
margin-inline-start: var(--wa-form-control-required-content-offset);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.button-group {
|
|
215
|
+
display: flex;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
[part~='form-control-input'] {
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: column;
|
|
221
|
+
flex-wrap: wrap;
|
|
222
|
+
gap: 0.75em;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Horizontal */
|
|
226
|
+
:host([orientation='horizontal']) [part~='form-control-input'] {
|
|
227
|
+
flex-direction: row;
|
|
228
|
+
gap: 1em;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Help text */
|
|
232
|
+
[part~='hint'] {
|
|
233
|
+
margin-block-start: 0.5em;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* Radios have the "button" appearance */
|
|
237
|
+
:host fieldset.has-radio-buttons {
|
|
238
|
+
[part~='form-control-input'] {
|
|
239
|
+
gap: 0;
|
|
256
240
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const hasHintSlot = this.hasUpdated ? this.hasSlotController.test('hint') : this.withHint;
|
|
260
|
-
const hasLabel = this.label ? true : !!hasLabelSlot;
|
|
261
|
-
const hasHint = this.hint ? true : !!hasHintSlot;
|
|
262
|
-
return html `
|
|
241
|
+
}
|
|
242
|
+
`;var z=(s={})=>{let{validationElement:r,validationProperty:t}=s;r||(r=Object.assign(document.createElement("input"),{required:!0})),t||(t="value");let e={observedAttributes:["required"],message:r.validationMessage,checkValidity(a){var u;let i={message:"",isValid:!0,invalidKeys:[]};return((u=a.required)!=null?u:a.hasAttribute("required"))&&!a[t]&&(i.message=typeof e.message=="function"?e.message(a):e.message||"",i.isValid=!1,i.invalidKeys.push("valueMissing")),i}};return e};var E=class{constructor(r,...t){this.slotNames=[];this.handleSlotChange=r=>{let t=r.target;(this.slotNames.includes("[default]")&&!t.name||t.name&&this.slotNames.includes(t.name))&&this.host.requestUpdate()};(this.host=r).addController(this),this.slotNames=t}hasDefaultSlot(){return[...this.host.childNodes].some(r=>{if(r.nodeType===Node.TEXT_NODE&&r.textContent.trim()!=="")return!0;if(r.nodeType===Node.ELEMENT_NODE){let t=r;if(t.tagName.toLowerCase()==="w-visually-hidden")return!1;if(!t.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(r){return this.host.querySelector(`:scope > [slot="${r}"]`)!==null}test(r){return r==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(r)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}};var d=class extends c{constructor(){super();this.hasSlotController=new E(this,"hint","label");this.hasRadioButtons=!1;this.label="";this.hint="";this.name=null;this.disabled=!1;this.orientation="vertical";this._value=null;this.defaultValue=this.getAttribute("value")||null;this.size="medium";this.required=!1;this.withLabel=!1;this.withHint=!1;this.handleRadioClick=t=>{let e=t.target.closest("w-radio");if(!e||e.disabled||e.forceDisabled||this.disabled)return;let a=this.value;this.value=e.value,e.checked=!0;let i=this.getAllRadios();for(let o of i)e!==o&&(o.checked=!1,o.setAttribute("tabindex","-1"));this.value!==a&&this.updateComplete.then(()=>{this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})};this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("click",this.handleRadioClick)}static get validators(){let t=[z({validationElement:Object.assign(document.createElement("input"),{required:!0,type:"radio",name:M("__w-radio")})})];return[...super.validators,...t]}get value(){var t;return this.valueHasChanged?this._value:(t=this._value)!=null?t:this.defaultValue}set value(t){typeof t=="number"&&(t=String(t)),this.valueHasChanged=!0,this._value=t}get validationTarget(){let t=this.querySelector(":is(w-radio):not([disabled])");if(t)return t}updated(t){(t.has("disabled")||t.has("value"))&&this.syncRadioElements()}formResetCallback(...t){this.value=this.defaultValue,super.formResetCallback(...t),this.syncRadioElements()}getAllRadios(){return[...this.querySelectorAll("w-radio")]}handleLabelClick(){this.focus()}async syncRadioElements(){let t=this.getAllRadios(),e=!1;if(t.forEach((a,i)=>{a.appearance==="button"&&(e=!0),a.setAttribute("size",this.size),a.toggleAttribute("data-w-radio-horizontal",this.orientation!=="vertical"),a.toggleAttribute("data-w-radio-vertical",this.orientation==="vertical"),a.toggleAttribute("data-w-radio-first",i===0),a.toggleAttribute("data-w-radio-inner",i!==0&&i!==t.length-1),a.toggleAttribute("data-w-radio-last",i===t.length-1),a.forceDisabled=this.disabled}),this.hasRadioButtons=e,await Promise.all(t.map(async a=>{await a.updateComplete,!a.disabled&&a.value===this.value?a.checked=!0:a.checked=!1})),this.disabled)t.forEach(a=>{a.tabIndex=-1});else{let a=t.filter(o=>!o.disabled),i=a.find(o=>o.checked);a.length>0&&(i?a.forEach(o=>{o.tabIndex=o.checked?0:-1}):a.forEach((o,n)=>{o.tabIndex=n===0?0:-1})),t.filter(o=>o.disabled).forEach(o=>{o.tabIndex=-1})}}handleKeyDown(t){var u;if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(t.key)||this.disabled)return;let e=this.getAllRadios().filter(h=>!h.disabled);if(e.length<=0)return;t.preventDefault();let a=this.value,i=(u=e.find(h=>h.checked))!=null?u:e[0],o=t.key===" "?0:["ArrowUp","ArrowLeft"].includes(t.key)?-1:1,n=e.indexOf(i)+o;n||(n=0),n<0&&(n=e.length-1),n>e.length-1&&(n=0);let v=e.some(h=>h.tagName.toLowerCase()==="w-radio-button");this.getAllRadios().forEach(h=>{h.checked=!1,v||h.setAttribute("tabindex","-1")}),this.value=e[n].value,e[n].checked=!0,v?e[n].shadowRoot.querySelector("button").focus():(e[n].setAttribute("tabindex","0"),e[n].focus()),this.value!==a&&this.updateComplete.then(()=>{this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),t.preventDefault()}focus(t){if(this.disabled)return;let e=this.getAllRadios(),a=e.find(n=>n.checked),i=e.find(n=>!n.disabled),o=a||i;o&&o.focus(t)}render(){let t=this.hasUpdated?this.hasSlotController.test("label"):this.withLabel,e=this.hasUpdated?this.hasSlotController.test("hint"):this.withHint,a=this.label?!0:!!t,i=this.hint?!0:!!e;return J`
|
|
263
243
|
<fieldset
|
|
264
244
|
part="form-control"
|
|
265
|
-
class=${
|
|
266
|
-
'form-control': true,
|
|
267
|
-
'form-control-radio-group': true,
|
|
268
|
-
'form-control-has-label': hasLabel,
|
|
269
|
-
'has-radio-buttons': this.hasRadioButtons,
|
|
270
|
-
})}
|
|
245
|
+
class=${F({"form-control":!0,"form-control-radio-group":!0,"form-control-has-label":a,"has-radio-buttons":this.hasRadioButtons})}
|
|
271
246
|
role="radiogroup"
|
|
272
247
|
aria-labelledby="label"
|
|
273
248
|
aria-describedby="hint"
|
|
@@ -277,7 +252,7 @@ export class WRadioGroup extends BaseFormAssociatedElement {
|
|
|
277
252
|
part="form-control-label"
|
|
278
253
|
id="label"
|
|
279
254
|
class="label"
|
|
280
|
-
aria-hidden=${
|
|
255
|
+
aria-hidden=${a?"false":"true"}
|
|
281
256
|
@click=${this.handleLabelClick}>
|
|
282
257
|
<slot name="label">${this.label}</slot>
|
|
283
258
|
</label>
|
|
@@ -288,52 +263,10 @@ export class WRadioGroup extends BaseFormAssociatedElement {
|
|
|
288
263
|
id="hint"
|
|
289
264
|
name="hint"
|
|
290
265
|
part="hint"
|
|
291
|
-
class=${
|
|
292
|
-
|
|
293
|
-
})}
|
|
294
|
-
aria-hidden=${hasHint ? 'false' : 'true'}
|
|
266
|
+
class=${F({"has-slotted":i})}
|
|
267
|
+
aria-hidden=${i?"false":"true"}
|
|
295
268
|
>${this.hint}</slot
|
|
296
269
|
>
|
|
297
270
|
</fieldset>
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
__decorate([
|
|
302
|
-
state()
|
|
303
|
-
], WRadioGroup.prototype, "hasRadioButtons", void 0);
|
|
304
|
-
__decorate([
|
|
305
|
-
query('slot:not([name])')
|
|
306
|
-
], WRadioGroup.prototype, "defaultSlot", void 0);
|
|
307
|
-
__decorate([
|
|
308
|
-
property()
|
|
309
|
-
], WRadioGroup.prototype, "label", void 0);
|
|
310
|
-
__decorate([
|
|
311
|
-
property({ attribute: 'hint' })
|
|
312
|
-
], WRadioGroup.prototype, "hint", void 0);
|
|
313
|
-
__decorate([
|
|
314
|
-
property({ reflect: true })
|
|
315
|
-
], WRadioGroup.prototype, "name", void 0);
|
|
316
|
-
__decorate([
|
|
317
|
-
property({ type: Boolean, reflect: true })
|
|
318
|
-
], WRadioGroup.prototype, "disabled", void 0);
|
|
319
|
-
__decorate([
|
|
320
|
-
property({ reflect: true })
|
|
321
|
-
], WRadioGroup.prototype, "orientation", void 0);
|
|
322
|
-
__decorate([
|
|
323
|
-
state()
|
|
324
|
-
], WRadioGroup.prototype, "value", null);
|
|
325
|
-
__decorate([
|
|
326
|
-
property({ attribute: 'value', reflect: true })
|
|
327
|
-
], WRadioGroup.prototype, "defaultValue", void 0);
|
|
328
|
-
__decorate([
|
|
329
|
-
property({ reflect: true })
|
|
330
|
-
], WRadioGroup.prototype, "size", void 0);
|
|
331
|
-
__decorate([
|
|
332
|
-
property({ type: Boolean, reflect: true })
|
|
333
|
-
], WRadioGroup.prototype, "required", void 0);
|
|
334
|
-
__decorate([
|
|
335
|
-
property({ type: Boolean, attribute: 'with-label' })
|
|
336
|
-
], WRadioGroup.prototype, "withLabel", void 0);
|
|
337
|
-
__decorate([
|
|
338
|
-
property({ type: Boolean, attribute: 'with-hint' })
|
|
339
|
-
], WRadioGroup.prototype, "withHint", void 0);
|
|
271
|
+
`}};d.css=[N],d.shadowRootOptions={...c.shadowRootOptions,delegatesFocus:!0},l([U()],d.prototype,"hasRadioButtons",2),l([Q("slot:not([name])")],d.prototype,"defaultSlot",2),l([m()],d.prototype,"label",2),l([m({attribute:"hint"})],d.prototype,"hint",2),l([m({reflect:!0})],d.prototype,"name",2),l([m({type:Boolean,reflect:!0})],d.prototype,"disabled",2),l([m({reflect:!0})],d.prototype,"orientation",2),l([U()],d.prototype,"value",1),l([m({attribute:"value",reflect:!0})],d.prototype,"defaultValue",2),l([m({reflect:!0})],d.prototype,"size",2),l([m({type:Boolean,reflect:!0})],d.prototype,"required",2),l([m({type:Boolean,attribute:"with-label"})],d.prototype,"withLabel",2),l([m({type:Boolean,attribute:"with-hint"})],d.prototype,"withHint",2);export{d as WRadioGroup};
|
|
272
|
+
//# sourceMappingURL=radio-group.js.map
|