@warp-ds/elements 2.2.0-next.26 → 2.2.0-next.28
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/custom-elements.json +0 -18
- package/dist/packages/slider/index.js +155 -95
- package/dist/packages/slider/index.js.map +3 -3
- package/dist/packages/slider/slider-thumb.js +108 -66
- package/dist/packages/slider/slider-thumb.js.map +3 -3
- package/dist/packages/slider/slider.js +45 -27
- package/dist/packages/slider/slider.js.map +3 -3
- package/dist/packages/slider/slider.react.stories.js +2 -3
- package/dist/packages/slider/slider.stories.d.ts +1 -0
- package/dist/packages/slider/slider.stories.js +6 -12
- package/dist/packages/slider/styles/w-slider-thumb.styles.js +62 -27
- package/dist/packages/slider/styles/w-slider.styles.js +32 -16
- package/dist/packages/steps/index.js +7 -7
- package/dist/packages/steps/index.js.map +2 -2
- package/dist/packages/textfield/index.js +12 -3
- package/dist/packages/textfield/index.js.map +2 -2
- package/dist/packages/textfield/styles/w-textfield.styles.js +9 -0
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
|
@@ -5972,14 +5972,6 @@
|
|
|
5972
5972
|
},
|
|
5973
5973
|
"description": "Function to format the to- and from labels and value in the slider thumb tooltip."
|
|
5974
5974
|
},
|
|
5975
|
-
{
|
|
5976
|
-
"kind": "field",
|
|
5977
|
-
"name": "#thumbSize",
|
|
5978
|
-
"privacy": "private",
|
|
5979
|
-
"type": {
|
|
5980
|
-
"text": "number"
|
|
5981
|
-
}
|
|
5982
|
-
},
|
|
5983
5975
|
{
|
|
5984
5976
|
"kind": "method",
|
|
5985
5977
|
"name": "#syncSliderThumbs",
|
|
@@ -6029,16 +6021,6 @@
|
|
|
6029
6021
|
}
|
|
6030
6022
|
],
|
|
6031
6023
|
"description": "We use CSS variables to fill the active track with a background color."
|
|
6032
|
-
},
|
|
6033
|
-
{
|
|
6034
|
-
"kind": "method",
|
|
6035
|
-
"name": "#getActiveRangeWidth",
|
|
6036
|
-
"privacy": "private",
|
|
6037
|
-
"return": {
|
|
6038
|
-
"type": {
|
|
6039
|
-
"text": "number"
|
|
6040
|
-
}
|
|
6041
|
-
}
|
|
6042
6024
|
}
|
|
6043
6025
|
],
|
|
6044
6026
|
"attributes": [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ue=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var te=d=>{throw TypeError(d)};var s=(d,r,e,o)=>{for(var i=o>1?void 0:o?me(r,e):r,t=d.length-1,v;t>=0;t--)(v=d[t])&&(i=(o?v(r,e,i):v(i))||i);return o&&i&&ue(r,e,i),i};var ve=(d,r,e)=>r.has(d)||te("Cannot "+e);var X=(d,r,e)=>r.has(d)?te("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(d):r.set(d,e);var b=(d,r,e)=>(ve(d,r,"access private method"),e);var l=function(d,r,e,o){if(e==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?d!==r||!o:!r.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?o:e==="a"?o.call(d):o?o.value:r.get(d)},p=function(d,r,e,o,i){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?d!==r||!i:!r.has(d))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?i.call(d,e):i?i.value=e:r.set(d,e),e};function S(d){var r,e,o,i,t,v,_,P,z,F,E,O,A,I,L,C,U,B,H;class ge extends d{constructor(...a){var n,h,g;super(...a),r.add(this),this.internals=this.attachInternals(),e.set(this,!1),o.set(this,!1),i.set(this,!1),t.set(this,void 0),v.set(this,void 0),_.set(this,!0),z.set(this,""),F.set(this,()=>{p(this,i,!0,"f"),p(this,e,!0,"f"),l(this,r,"m",C).call(this)}),E.set(this,()=>{p(this,e,!1,"f"),l(this,r,"m",U).call(this,this.shouldFormValueUpdate()?l(this,z,"f"):""),!this.validity.valid&&l(this,i,"f")&&p(this,o,!0,"f");let y=l(this,r,"m",C).call(this);this.validationMessageCallback&&this.validationMessageCallback(y?this.internals.validationMessage:"")}),O.set(this,()=>{var y;l(this,_,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),p(this,_,!1,"f")),p(this,i,!0,"f"),p(this,o,!0,"f"),l(this,r,"m",C).call(this),(y=this===null||this===void 0?void 0:this.validationMessageCallback)===null||y===void 0||y.call(this,this.showError?this.internals.validationMessage:"")}),A.set(this,void 0),I.set(this,!1),L.set(this,Promise.resolve()),(n=this.addEventListener)===null||n===void 0||n.call(this,"focus",l(this,F,"f")),(h=this.addEventListener)===null||h===void 0||h.call(this,"blur",l(this,E,"f")),(g=this.addEventListener)===null||g===void 0||g.call(this,"invalid",l(this,O,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let a=this.validators.map(g=>g.attribute).flat(),n=super.observedAttributes||[];return[...new Set([...n,...a])]}static getValidator(a){return this.validators.find(n=>n.attribute===a)||null}static getValidators(a){return this.validators.filter(n=>{var h;if(n.attribute===a||!((h=n.attribute)===null||h===void 0)&&h.includes(a))return!0})}get form(){return this.internals.form}get showError(){return l(this,r,"m",C).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(a,n,h){var g;(g=super.attributeChangedCallback)===null||g===void 0||g.call(this,a,n,h);let T=this.constructor.getValidators(a);T!=null&&T.length&&this.validationTarget&&this.setValue(l(this,z,"f"))}setValue(a){var n;p(this,o,!1,"f"),(n=this.validationMessageCallback)===null||n===void 0||n.call(this,""),p(this,z,a,"f");let g=this.shouldFormValueUpdate()?a:null;this.internals.setFormValue(g),l(this,r,"m",U).call(this,g),this.valueChangedCallback&&this.valueChangedCallback(g),l(this,r,"m",C).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(a=>a(l(this,L,"f")))}formResetCallback(){var a,n;p(this,i,!1,"f"),p(this,o,!1,"f"),l(this,r,"m",C).call(this),(a=this.resetFormControl)===null||a===void 0||a.call(this),(n=this.validationMessageCallback)===null||n===void 0||n.call(this,l(this,r,"m",C).call(this)?this.validationMessage:"")}}return e=new WeakMap,o=new WeakMap,i=new WeakMap,t=new WeakMap,v=new WeakMap,_=new WeakMap,z=new WeakMap,F=new WeakMap,E=new WeakMap,O=new WeakMap,A=new WeakMap,I=new WeakMap,L=new WeakMap,r=new WeakSet,P=function(){let a=this.getRootNode(),n=`${this.localName}[name="${this.getAttribute("name")}"]`;return a.querySelectorAll(n)},C=function(){if(this.hasAttribute("disabled"))return!1;let a=l(this,o,"f")||l(this,i,"f")&&!this.validity.valid&&!l(this,e,"f");return a&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),a},U=function(a){let n=this.constructor,h={},g=n.validators,y=[],T=g.some(f=>f.isValid instanceof Promise);l(this,I,"f")||(p(this,L,new Promise(f=>{p(this,A,f,"f")}),"f"),p(this,I,!0,"f")),l(this,t,"f")&&(l(this,t,"f").abort(),p(this,v,l(this,t,"f"),"f"));let j=new AbortController;p(this,t,j,"f");let N,re=!1;g.length&&(g.forEach(f=>{let G=f.key||"customError",$=f.isValid(this,a,j.signal);$ instanceof Promise?(y.push($),$.then(J=>{J!=null&&(h[G]=!J,N=l(this,r,"m",H).call(this,f,a),l(this,r,"m",B).call(this,h,N))})):(h[G]=!$,this.validity[G]!==!$&&(re=!0),!$&&!N&&(N=l(this,r,"m",H).call(this,f,a)))}),Promise.allSettled(y).then(()=>{var f;j!=null&&j.signal.aborted||(p(this,I,!1,"f"),(f=l(this,A,"f"))===null||f===void 0||f.call(this))}),(re||!T)&&l(this,r,"m",B).call(this,h,N))},B=function(a,n){if(this.validationTarget)this.internals.setValidity(a,n,this.validationTarget),p(this,_,!1,"f");else{if(this.internals.setValidity(a,n),this.internals.validity.valid)return;p(this,_,!0,"f")}},H=function(a,n){if(this.validityCallback){let h=this.validityCallback(a.key||"customError");if(h)return h}return a.message instanceof Function?a.message(this,n):a.message},ge}import{html as ie,LitElement as se,nothing as fe}from"lit";import{property as k}from"lit/decorators.js";import{css as oe}from"lit";var R=oe`
|
|
2
2
|
*,
|
|
3
3
|
:before,
|
|
4
4
|
:after {
|
|
@@ -271,7 +271,7 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
271
271
|
svg {
|
|
272
272
|
pointer-events: none;
|
|
273
273
|
}
|
|
274
|
-
`,
|
|
274
|
+
`,Fe=oe`*, :before, :after {
|
|
275
275
|
--w-rotate: 0;
|
|
276
276
|
--w-rotate-x: 0;
|
|
277
277
|
--w-rotate-y: 0;
|
|
@@ -2437,7 +2437,7 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2437
2437
|
display: none
|
|
2438
2438
|
}
|
|
2439
2439
|
}
|
|
2440
|
-
`;import{css as
|
|
2440
|
+
`;import{css as we}from"lit";var ae=we`
|
|
2441
2441
|
.w-slider {
|
|
2442
2442
|
position: relative;
|
|
2443
2443
|
border: none;
|
|
@@ -2465,10 +2465,12 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2465
2465
|
|
|
2466
2466
|
/* The --min value can be non-zero, f. ex. choosing a year from 1950 to 2025. Normalize the values so we start at 0 and run to max - min. */
|
|
2467
2467
|
--_value-range: calc(var(--max) - var(--min));
|
|
2468
|
-
|
|
2468
|
+
|
|
2469
|
+
/** Round up to the nearest --step, which defaults to 1 (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/range#step) */
|
|
2470
|
+
--_from-in-range: round(up, max(calc(var(--from) - var(--min)), 0), var(--step, 1));
|
|
2469
2471
|
|
|
2470
2472
|
/* limit to maximum value in range so typing a value larger than max doesn't explode layouts */
|
|
2471
|
-
--_to-in-range: min(calc(var(--to) - var(--min)), var(--_value-range));
|
|
2473
|
+
--_to-in-range: round(up, min(calc(var(--to) - var(--min)), var(--_value-range)), var(--step, 1));
|
|
2472
2474
|
|
|
2473
2475
|
/* Position the starting point of the fill in the case of a non-zero --from value in a range slider.
|
|
2474
2476
|
* In other words, given a width of 100% how many percent should be left unfilled/blank
|
|
@@ -2501,17 +2503,36 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2501
2503
|
grid-area: description;
|
|
2502
2504
|
}
|
|
2503
2505
|
|
|
2504
|
-
.w-
|
|
2506
|
+
.w-slider__range {
|
|
2505
2507
|
align-self: center;
|
|
2506
2508
|
background: var(--w-slider-track-background);
|
|
2507
2509
|
border-radius: 4px;
|
|
2510
|
+
height: var(--w-slider-track-active-height);
|
|
2508
2511
|
position: absolute;
|
|
2512
|
+
/* For range sliders to avoid overlapping the slider thumbs we transform them to
|
|
2513
|
+
be visually to the left and right of their respective input[type="range"]. This
|
|
2514
|
+
padding is here so the active-range element is the same width as the input fields. */
|
|
2515
|
+
padding-inline-start: var(--active-range-inline-start-padding, 0);
|
|
2516
|
+
padding-inline-end: var(--active-range-inline-end-padding, 0);
|
|
2509
2517
|
top: var(--_range-top);
|
|
2510
2518
|
left: 0;
|
|
2511
2519
|
right: 0;
|
|
2512
2520
|
grid-area: slider;
|
|
2513
2521
|
}
|
|
2514
2522
|
|
|
2523
|
+
.w-slider__active-range {
|
|
2524
|
+
box-sizing: content-box;
|
|
2525
|
+
background: var(--w-slider-track-active-background);
|
|
2526
|
+
height: var(--w-slider-track-active-height);
|
|
2527
|
+
|
|
2528
|
+
border-start-start-radius: var(--active-range-border-radius, 0);
|
|
2529
|
+
border-end-start-radius: var(--active-range-border-radius, 0);
|
|
2530
|
+
|
|
2531
|
+
margin-left: calc(calc(var(--_blank-values-before) * 1%) - var(--active-range-inline-start-padding, 0px));
|
|
2532
|
+
width: calc(calc(var(--_filled-values) * 1%) + var(--active-range-inline-end-padding, 0px));
|
|
2533
|
+
z-index: 1;
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2515
2536
|
.w-slider__markers {
|
|
2516
2537
|
--_marker-height: 7px;
|
|
2517
2538
|
--_marker-width: 1px;
|
|
@@ -2521,9 +2542,14 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2521
2542
|
/* Creates a linear gradient with --_marker-width wide markers
|
|
2522
2543
|
followed by enough transparent that we can repeat the gradient
|
|
2523
2544
|
along the X axis and have markers visible where we want them. */
|
|
2524
|
-
background: linear-gradient(
|
|
2545
|
+
background: linear-gradient(
|
|
2546
|
+
to right,
|
|
2547
|
+
var(--w-slider-marker-color) var(--_marker-width),
|
|
2548
|
+
rgba(0, 0, 0, 0) 1px calc(100% - 1px),
|
|
2549
|
+
var(--w-slider-marker-color) 100%
|
|
2550
|
+
) repeat-x;
|
|
2525
2551
|
--_step-width-as-percent: calc(var(--markers) / var(--_value-range) * 100);
|
|
2526
|
-
background-size: calc(var(--_step-width-as-percent) * 1%
|
|
2552
|
+
background-size: calc(var(--_step-width-as-percent) * 1%) var(--_marker-height);
|
|
2527
2553
|
|
|
2528
2554
|
background-position: bottom 0 left 8px right 8px;
|
|
2529
2555
|
position: absolute;
|
|
@@ -2532,17 +2558,7 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2532
2558
|
right: 1px;
|
|
2533
2559
|
grid-area: slider;
|
|
2534
2560
|
height: var(--_marker-height);
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
.w-slider__active-range::before {
|
|
2538
|
-
background: var(--w-slider-track-active-background);
|
|
2539
|
-
border-radius: 4px;
|
|
2540
|
-
content: '';
|
|
2541
|
-
display: block;
|
|
2542
|
-
height: var(--w-slider-track-active-height);
|
|
2543
|
-
|
|
2544
|
-
margin-left: calc(var(--_blank-values-before) * 1%);
|
|
2545
|
-
width: calc(var(--_filled-values) * 1%);
|
|
2561
|
+
margin-inline: var(--w-slider-thumb-offset);
|
|
2546
2562
|
}
|
|
2547
2563
|
|
|
2548
2564
|
slot::slotted(w-slider-thumb) {
|
|
@@ -2553,19 +2569,21 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2553
2569
|
bottom: 0;
|
|
2554
2570
|
grid-area: slider;
|
|
2555
2571
|
}
|
|
2556
|
-
`;var
|
|
2557
|
-
<fieldset id="fieldset" class="w-slider" @input="${
|
|
2572
|
+
`;var m,V,ne,le,K,u=class extends S(se){constructor(){super(...arguments);X(this,m);this.disabled=!1;this.invalid=!1;this.required=!1}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.step&&this.style.setProperty("--step",String(this.step)),this.style.setProperty("--min",this.min),this.style.setProperty("--max",this.max),this.markers&&this.style.setProperty("--markers",String(this.markers)),b(this,m,V).call(this)}updated(e){(e.has("disabled")||e.has("invalid")||e.has("required")||e.has("min")||e.has("step")||e.has("max")||e.has("suffix")||e.has("formatter"))&&b(this,m,V).call(this)}render(){return ie`
|
|
2573
|
+
<fieldset id="fieldset" class="w-slider" @input="${b(this,m,ne)}" @slidervalidity="${b(this,m,le)}">
|
|
2558
2574
|
<legend class="w-slider__label">
|
|
2559
2575
|
<slot id="label" name="label">${this.label}</slot>
|
|
2560
2576
|
</legend>
|
|
2561
2577
|
<slot class="w-slider__description" name="description"></slot>
|
|
2562
|
-
${this.markers?
|
|
2563
|
-
<div class="w-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
<slot class="w-slider__slider"
|
|
2578
|
+
${this.markers?ie`<div class="w-slider__markers"></div>`:fe}
|
|
2579
|
+
<div class="w-slider__range">
|
|
2580
|
+
<div class="w-slider__active-range"></div>
|
|
2581
|
+
</div>
|
|
2582
|
+
<slot class="w-slider__slider" @slotchange=${b(this,m,V)}></slot>
|
|
2583
|
+
<slot class="w-slider__slider" name="from" @slotchange=${b(this,m,V)}></slot>
|
|
2584
|
+
<slot class="w-slider__slider" name="to" @slotchange=${b(this,m,V)}></slot>
|
|
2567
2585
|
</fieldset>
|
|
2568
|
-
`}};
|
|
2586
|
+
`}};m=new WeakSet,V=function(){let e=this.querySelectorAll("w-slider-thumb"),o=!1;for(let t of e.values())t.min=this.min,t.max=this.max,t.step=this.step,t.suffix=this.suffix,t.required=this.required,t.formatter=this.formatter,t.ariaLabel||(t.slot||(t.ariaLabel=this.label),t.slot==="from"&&(t.ariaLabel=`${this.label} min`),t.slot==="to"&&(t.ariaLabel=`${this.label} max`)),(t.slot==="from"||t.slot==="to")&&(o=!0),t.forceDisabled=this.disabled,t.forceInvalid=this.invalid,b(this,m,K).call(this,t);let i=this.shadowRoot.querySelector("fieldset");o?(i.style.setProperty("--active-range-inline-start-padding","var(--w-slider-thumb-size)"),i.style.setProperty("--active-range-inline-end-padding","var(--w-slider-thumb-size)")):i.style.setProperty("--active-range-border-radius","4px")},ne=function(e){let o=e.target;b(this,m,K).call(this,o)},le=function(e){e.stopPropagation(),this.invalid=e.detail.invalid},K=function(e){var i,t;let o=e.slot;if(o||this.style.setProperty("--from","0"),o==="from"){let v=(i=e.value)!=null?i:e.value=this.min;this.style.setProperty("--from",v)}if(!o||o==="to"){let v=(t=e.value)!=null?t:e.value=this.max;this.style.setProperty("--to",v)}},u.shadowRootOptions={...se.shadowRootOptions,delegatesFocus:!0},u.styles=[R,ae],s([k({reflect:!0})],u.prototype,"label",2),s([k({type:Boolean,reflect:!0})],u.prototype,"disabled",2),s([k({type:Boolean,reflect:!0})],u.prototype,"invalid",2),s([k({type:Boolean,reflect:!0})],u.prototype,"required",2),s([k({reflect:!0})],u.prototype,"min",2),s([k({reflect:!0})],u.prototype,"max",2),s([k({type:Number,reflect:!0})],u.prototype,"markers",2),s([k({type:Number,reflect:!0})],u.prototype,"step",2),s([k({reflect:!0})],u.prototype,"suffix",2),s([k({attribute:!1})],u.prototype,"formatter",2);customElements.get("w-slider")||customElements.define("w-slider",u);import{html as q,LitElement as he,nothing as Q}from"lit";import{property as M,query as be,state as x}from"lit/decorators.js";import{ifDefined as W}from"lit/directives/if-defined.js";import{css as xe}from"lit";var de=xe`
|
|
2569
2587
|
.w-slider-thumb {
|
|
2570
2588
|
position: relative;
|
|
2571
2589
|
display: grid;
|
|
@@ -2582,6 +2600,7 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2582
2600
|
background-color: transparent;
|
|
2583
2601
|
grid-area: slider;
|
|
2584
2602
|
height: 44px; /* touch target */
|
|
2603
|
+
margin-left: 0;
|
|
2585
2604
|
pointer-events: none; /* let clicks pass through for range slider where we place two inputs over each other */
|
|
2586
2605
|
}
|
|
2587
2606
|
|
|
@@ -2591,14 +2610,6 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2591
2610
|
height: var(--w-slider-track-height);
|
|
2592
2611
|
}
|
|
2593
2612
|
|
|
2594
|
-
.w-slider-thumb__range:hover::-webkit-slider-thumb {
|
|
2595
|
-
background: var(--w-s-color-background-primary-hover);
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
.w-slider-thumb__range:hover::-moz-range-thumb {
|
|
2599
|
-
background: var(--w-s-color-background-primary-hover);
|
|
2600
|
-
}
|
|
2601
|
-
|
|
2602
2613
|
/*
|
|
2603
2614
|
Use anchor positioning to place the tooltip target in relation to the slider thumb.
|
|
2604
2615
|
We use a polyfill to bring support to older Safari, Firefox at time of writing.
|
|
@@ -2607,11 +2618,12 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2607
2618
|
anchor-name: --thumb;
|
|
2608
2619
|
|
|
2609
2620
|
appearance: none;
|
|
2621
|
+
cursor: pointer;
|
|
2610
2622
|
background: var(--w-s-color-background-primary);
|
|
2611
2623
|
border-radius: 50%;
|
|
2612
2624
|
height: var(--w-slider-thumb-size);
|
|
2613
2625
|
margin-top: calc(-1 * calc(var(--w-slider-thumb-offset) - calc(var(--w-slider-track-height) / 2)));
|
|
2614
|
-
pointer-events:
|
|
2626
|
+
pointer-events: initial;
|
|
2615
2627
|
width: var(--w-slider-thumb-size);
|
|
2616
2628
|
z-index: 1;
|
|
2617
2629
|
}
|
|
@@ -2620,6 +2632,7 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2620
2632
|
anchor-name: --thumb;
|
|
2621
2633
|
|
|
2622
2634
|
appearance: none;
|
|
2635
|
+
cursor: pointer;
|
|
2623
2636
|
background: var(--w-s-color-background-primary);
|
|
2624
2637
|
border-radius: 50%;
|
|
2625
2638
|
border-color: transparent;
|
|
@@ -2628,32 +2641,54 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2628
2641
|
pointer-events: initial;
|
|
2629
2642
|
width: var(--w-slider-thumb-size);
|
|
2630
2643
|
z-index: 1;
|
|
2644
|
+
|
|
2645
|
+
box-shadow: none;
|
|
2631
2646
|
}
|
|
2632
2647
|
|
|
2633
|
-
.w-slider-
|
|
2634
|
-
|
|
2635
|
-
|
|
2648
|
+
.w-slider-thumb__range:active::-webkit-slider-thumb,
|
|
2649
|
+
.w-slider-thumb__range:hover::-webkit-slider-thumb {
|
|
2650
|
+
background: var(--w-s-color-background-primary-hover);
|
|
2651
|
+
box-shadow: var(--w-shadow-slider-handle-hover);
|
|
2652
|
+
}
|
|
2636
2653
|
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2654
|
+
.w-slider-thumb__range:focus,
|
|
2655
|
+
.w-slider-thumb__range:focus-visible {
|
|
2656
|
+
outline: none;
|
|
2657
|
+
}
|
|
2640
2658
|
|
|
2641
|
-
|
|
2642
|
-
border-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2659
|
+
.w-slider-thumb__range:focus-visible::-webkit-slider-thumb {
|
|
2660
|
+
outline: 2px solid var(--w-s-color-border-focus);
|
|
2661
|
+
outline-offset: var(--w-outline-offset, 1px);
|
|
2662
|
+
box-shadow: none;
|
|
2663
|
+
}
|
|
2646
2664
|
|
|
2647
|
-
|
|
2665
|
+
.w-slider-thumb__range:active::-moz-range-thumb,
|
|
2666
|
+
.w-slider-thumb__range:hover::-moz-range-thumb {
|
|
2667
|
+
background: var(--w-s-color-background-primary-hover);
|
|
2668
|
+
box-shadow: var(--w-shadow-slider-handle-hover);
|
|
2669
|
+
}
|
|
2648
2670
|
|
|
2649
|
-
|
|
2650
|
-
|
|
2671
|
+
.w-slider-thumb__range:focus-visible::-moz-range-thumb {
|
|
2672
|
+
outline: 2px solid var(--w-s-color-border-focus);
|
|
2673
|
+
outline-offset: var(--w-outline-offset, 1px);
|
|
2674
|
+
box-shadow: none;
|
|
2651
2675
|
}
|
|
2652
2676
|
|
|
2653
|
-
.w-slider-thumb__tooltip
|
|
2677
|
+
.w-slider-thumb__tooltip-target {
|
|
2654
2678
|
display: block;
|
|
2679
|
+
pointer-events: none;
|
|
2680
|
+
position: absolute;
|
|
2681
|
+
border: 2px solid transparent;
|
|
2682
|
+
border-radius: 20px;
|
|
2683
|
+
width: 8px;
|
|
2684
|
+
height: 8px;
|
|
2685
|
+
position-anchor: --thumb;
|
|
2686
|
+
position-area: center; /* Position the tooltip target right on the range thumb */
|
|
2655
2687
|
}
|
|
2656
2688
|
|
|
2689
|
+
/* Uncomment this to debug the invisible anchor target */
|
|
2690
|
+
/* .w-slider-thumb__tooltip-target { border-color: lime; } */
|
|
2691
|
+
|
|
2657
2692
|
.w-slider-thumb__from-marker,
|
|
2658
2693
|
.w-slider-thumb__to-marker {
|
|
2659
2694
|
margin-inline: 2px; /* visual alignment with input border, slider thumb */
|
|
@@ -2682,8 +2717,21 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2682
2717
|
grid-column: 1 / 2; /* Range sliders should leave the gap empty. */
|
|
2683
2718
|
}
|
|
2684
2719
|
|
|
2685
|
-
:host([name='from']) .w-slider-thumb__range
|
|
2686
|
-
margin-left:
|
|
2720
|
+
:host([name='from']) .w-slider-thumb__range {
|
|
2721
|
+
margin-left: var(--w-slider-thumb-size);
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
:host([name='to']) .w-slider-thumb__range {
|
|
2725
|
+
margin-right: var(--w-slider-thumb-size);
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
:host([name='from']) .w-slider-thumb__range::-webkit-slider-thumb,
|
|
2729
|
+
:host([name='from']) .w-slider-thumb__tooltip-target {
|
|
2730
|
+
transform: translateX(calc(-1 * var(--w-slider-thumb-size) - 1px));
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
:host([name='from']) .w-slider-thumb__range::-moz-range-thumb {
|
|
2734
|
+
transform: translateX(calc(-1 * var(--w-slider-thumb-size) - 1px));
|
|
2687
2735
|
}
|
|
2688
2736
|
|
|
2689
2737
|
:host([name='to']) .w-slider-thumb__textfield {
|
|
@@ -2691,84 +2739,93 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2691
2739
|
grid-column: 3 / 4;
|
|
2692
2740
|
}
|
|
2693
2741
|
|
|
2742
|
+
:host([name='to']) .w-slider-thumb__tooltip-target,
|
|
2694
2743
|
:host([name='to']) .w-slider-thumb__range::-webkit-slider-thumb {
|
|
2695
|
-
|
|
2744
|
+
transform: translateX(calc(var(--w-slider-thumb-size) - 1px));
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
:host([name='to']) .w-slider-thumb__range::-moz-range-thumb {
|
|
2748
|
+
transform: translateX(calc(var(--w-slider-thumb-size) - 1px));
|
|
2696
2749
|
}
|
|
2697
|
-
`;import{css as
|
|
2750
|
+
`;import{css as ke}from"lit";var ce=ke`*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.hidden{display:none}.absolute{position:absolute}.relative{position:relative}.static{position:static}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}`;var pe={};var w,Z,D,ee,c=class extends S(he){constructor(){super(...arguments);X(this,w);this._invalid=!1;this._showTooltip=!1;this.anchorPositioningStyleElement=null}async connectedCallback(){var e;if(super.connectedCallback(),"anchorName"in document.documentElement.style)await this.updateComplete;else{let o=pe.url.substring(0,pe.url.lastIndexOf("/"));try{let[{default:i}]=await Promise.all([import(`${o}/oddbird-css-anchor-positioning.js`),this.updateComplete]);this.anchorPositioningStyleElement||(this.anchorPositioningStyleElement=document.createElement("style"),this.shadowRoot.prepend(this.anchorPositioningStyleElement)),this.anchorPositioningStyleElement.textContent=`
|
|
2698
2751
|
/*
|
|
2699
|
-
* The polyfill can only anchor to ::before and ::after pseudo elements.
|
|
2752
|
+
* The polyfill can only anchor to ::before and ::after pseudo elements, not the pseudo element slider thumb.
|
|
2700
2753
|
* We work around that by recreating a transparent version of the active range
|
|
2701
2754
|
* so that we can position relative to that, without crossing the shadow root boundary.
|
|
2702
2755
|
*/
|
|
2703
|
-
|
|
2704
|
-
anchor-name: --polyfilled-thumb;
|
|
2705
|
-
|
|
2706
|
-
/* We have to compensate for the width of the thumb inside the track to find its center. */
|
|
2707
|
-
--_value: var(--_to-as-percent-of-max);
|
|
2708
|
-
--_offset-origin: 50; /* at this point the offset is zero */
|
|
2709
|
-
--_thumb-offset-percent: calc(var(--_value) - var(--_offset-origin));
|
|
2710
|
-
--_thumb-offset-pixels: calc(var(--w-slider-thumb-size) * calc(var(--_thumb-offset-percent) / 100));
|
|
2711
|
-
|
|
2756
|
+
.polyfill-range {
|
|
2712
2757
|
align-self: center;
|
|
2713
2758
|
background: transparent;
|
|
2759
|
+
height: var(--w-slider-track-active-height);
|
|
2714
2760
|
position: absolute;
|
|
2761
|
+
padding-inline-start: var(--active-range-inline-start-padding, 0);
|
|
2762
|
+
padding-inline-end: var(--active-range-inline-end-padding, 0);
|
|
2715
2763
|
top: var(--_range-top);
|
|
2716
|
-
height: var(--w-slider-track-active-height);
|
|
2717
2764
|
left: 0;
|
|
2718
2765
|
right: 0;
|
|
2719
2766
|
grid-area: slider;
|
|
2720
|
-
margin-left: calc(var(--_blank-values-before) * 1%);
|
|
2721
|
-
width: calc(calc(var(--_filled-values) * 1%) - var(--_thumb-offset-pixels));
|
|
2722
2767
|
}
|
|
2723
2768
|
|
|
2724
|
-
|
|
2725
|
-
|
|
2769
|
+
.polyfill-active-range {
|
|
2770
|
+
anchor-name: --polyfilled-thumb;
|
|
2771
|
+
|
|
2772
|
+
box-sizing: content-box;
|
|
2773
|
+
background: transparent;
|
|
2774
|
+
height: var(--w-slider-track-active-height);
|
|
2775
|
+
|
|
2776
|
+
border-start-start-radius: var(--active-range-border-radius, 0);
|
|
2777
|
+
border-end-start-radius: var(--active-range-border-radius, 0);
|
|
2726
2778
|
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
left: anchor(--polyfilled-thumb right);
|
|
2779
|
+
margin-left: calc(calc(var(--_blank-values-before) * 1%) - var(--active-range-inline-start-padding, 0px));
|
|
2780
|
+
width: calc(calc(var(--_filled-values) * 1%) + var(--active-range-inline-end-padding, 0px));
|
|
2730
2781
|
}
|
|
2731
2782
|
|
|
2732
|
-
|
|
2733
|
-
|
|
2783
|
+
#target {
|
|
2784
|
+
position: absolute;
|
|
2785
|
+
top: anchor(--polyfilled-thumb top);
|
|
2786
|
+
right: anchor(--polyfilled-thumb right);
|
|
2787
|
+
margin-right: 12px;
|
|
2788
|
+
}
|
|
2734
2789
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2790
|
+
:host([name='from']) .polyfill-active-range {
|
|
2791
|
+
margin-left: calc(calc(var(--_blank-values-before) * 1%) - var(--active-range-inline-start-padding, 0px));
|
|
2792
|
+
width: calc(calc(var(--_filled-values) * 1%) + var(--active-range-inline-end-padding, 0px));
|
|
2737
2793
|
}
|
|
2738
2794
|
|
|
2739
2795
|
:host([name='from']) #target {
|
|
2740
2796
|
left: anchor(--polyfilled-thumb left);
|
|
2797
|
+
margin-left: 38px;
|
|
2741
2798
|
}
|
|
2742
|
-
`,await i({roots:[this.shadowRoot],elements:[this.anchorPositioningStyleElement]})}catch(i){console.error(new Error("Error registering the CSS anchor positioning polyfill. The UI will look broken.",{cause:i}))}}this.range.value=(e=this.value)!=null?e:this.max}updated(e){
|
|
2799
|
+
`,await i({roots:[this.shadowRoot],elements:[this.anchorPositioningStyleElement]})}catch(i){console.error(new Error("Error registering the CSS anchor positioning polyfill. The UI will look broken.",{cause:i}))}}this.range.value=(e=this.value)!=null?e:this.max}updated(e){e.has("value")&&this.setValue(this.value),e.has("_invalid")&&this.dispatchEvent(new CustomEvent("slidervalidity",{bubbles:!0,detail:{invalid:this._invalid}}))}render(){return q`
|
|
2743
2800
|
<div class="w-slider-thumb">
|
|
2744
2801
|
<label for="range">${this.label}</label>
|
|
2745
|
-
${"anchorName"in document.documentElement.style?
|
|
2802
|
+
${"anchorName"in document.documentElement.style?Q:q`<div class="polyfill-range"><div class="polyfill-active-range"></div></div>`}
|
|
2746
2803
|
<input
|
|
2747
2804
|
id="range"
|
|
2748
2805
|
aria-label="${this.ariaLabel}"
|
|
2749
|
-
aria-describedby="${
|
|
2806
|
+
aria-describedby="${W(this.ariaDescription?"aria-description":void 0)}"
|
|
2750
2807
|
class="w-slider-thumb__range"
|
|
2751
2808
|
type="range"
|
|
2752
2809
|
.value="${this.value}"
|
|
2753
2810
|
min="${this.min}"
|
|
2754
2811
|
max="${this.max}"
|
|
2755
2812
|
name="${this.name}"
|
|
2756
|
-
step="${
|
|
2813
|
+
step="${W(this.step?this.step:void 0)}"
|
|
2757
2814
|
?disabled="${this.disabled||this.forceDisabled}"
|
|
2758
|
-
@mousedown="${
|
|
2759
|
-
@mouseup="${
|
|
2760
|
-
@touchstart="${
|
|
2761
|
-
@touchend="${
|
|
2762
|
-
@focus="${
|
|
2763
|
-
@blur="${
|
|
2764
|
-
@input="${
|
|
2815
|
+
@mousedown="${b(this,w,Z)}"
|
|
2816
|
+
@mouseup="${b(this,w,D)}"
|
|
2817
|
+
@touchstart="${b(this,w,Z)}"
|
|
2818
|
+
@touchend="${b(this,w,D)}"
|
|
2819
|
+
@focus="${b(this,w,Z)}"
|
|
2820
|
+
@blur="${b(this,w,D)}"
|
|
2821
|
+
@input="${b(this,w,ee)}" />
|
|
2765
2822
|
|
|
2766
2823
|
<span class="w-slider-thumb__from-marker">${this.formatter?this.formatter(this.min):this.min} ${this.suffix}</span>
|
|
2767
2824
|
<span class="w-slider-thumb__to-marker">${this.formatter?this.formatter(this.max):this.max} ${this.suffix}</span>
|
|
2768
2825
|
|
|
2769
2826
|
<w-textfield
|
|
2770
2827
|
aria-label="${this.ariaLabel}"
|
|
2771
|
-
aria-description="${
|
|
2828
|
+
aria-description="${W(this.ariaDescription)}"
|
|
2772
2829
|
class="w-slider-thumb__textfield"
|
|
2773
2830
|
type="number"
|
|
2774
2831
|
min="${this.min}"
|
|
@@ -2776,16 +2833,19 @@ var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ae=a=>{t
|
|
|
2776
2833
|
.formatter=${this.formatter}
|
|
2777
2834
|
.value="${this.value}"
|
|
2778
2835
|
?invalid="${this.forceInvalid||this._invalid}"
|
|
2779
|
-
@input="${
|
|
2780
|
-
${this.suffix?q`<w-affix slot="suffix" label="${this.suffix}"></w-affix>`:
|
|
2836
|
+
@input="${b(this,w,ee)}">
|
|
2837
|
+
${this.suffix?q`<w-affix slot="suffix" label="${this.suffix}"></w-affix>`:Q}
|
|
2781
2838
|
</w-textfield>
|
|
2782
2839
|
|
|
2783
|
-
<
|
|
2784
|
-
|
|
2785
|
-
|
|
2840
|
+
<w-attention tooltip placement="top" flip distance="24" .show="${this._showTooltip}">
|
|
2841
|
+
<output id="target" class="w-slider-thumb__tooltip-target" slot="target"></output>
|
|
2842
|
+
<span slot="message">
|
|
2843
|
+
${this.value?this.formatter?this.formatter(this.value):this.value:0}${this.suffix?q` ${this.suffix}`:Q}
|
|
2844
|
+
</span>
|
|
2845
|
+
</w-attention>
|
|
2786
2846
|
|
|
2787
2847
|
<!-- aria-description is still not recommended for general use, so make a visually hidden element and refer to it with aria-describedby -->
|
|
2788
2848
|
<span class="sr-only" id="aria-description">${this.ariaDescription}</span>
|
|
2789
2849
|
</div>
|
|
2790
|
-
`}};
|
|
2850
|
+
`}};w=new WeakSet,Z=function(){this._showTooltip=!0,this.shadowRoot.querySelector("w-attention").handleDone()},D=function(){this._showTooltip=!1},ee=function(e){let o=e.currentTarget.tagName==="W-TEXTFIELD";if(e instanceof CustomEvent)return;let i=e.currentTarget.value;if(i==="")return this.required&&(this._invalid=!0),!1;this._invalid&&(this._invalid=!1);let t=Number.parseInt(i),v=Number.parseInt(this.max),_=Number.parseInt(this.min);(t>v||t<_)&&(this._invalid=!0);let P=!1;if(this.slot){let z=getComputedStyle(this),F=z.getPropertyValue("--to"),E=z.getPropertyValue("--from");if(o&&(t>Number.parseInt(F)||t<Number.parseInt(E)))return this._invalid=!0,!1;this.slot==="from"?t>Number.parseInt(F)&&(P=!0,this.value=F):t<Number.parseInt(E)&&(P=!0,this.value=E)}return P?(e.preventDefault(),this.range.value=this.value,!1):(this.value=i,this.shadowRoot.querySelector("w-attention").handleDone(),!0)},c.shadowRootOptions={...he.shadowRootOptions,delegatesFocus:!0},c.styles=[R,ce,de],s([M({attribute:"aria-label",reflect:!0})],c.prototype,"ariaLabel",2),s([M({attribute:"aria-description",reflect:!0})],c.prototype,"ariaDescription",2),s([M({reflect:!0})],c.prototype,"label",2),s([M({reflect:!0})],c.prototype,"name",2),s([M({reflect:!0})],c.prototype,"value",2),s([M({type:Boolean,reflect:!0})],c.prototype,"disabled",2),s([x()],c.prototype,"markers",2),s([x()],c.prototype,"required",2),s([x()],c.prototype,"step",2),s([x()],c.prototype,"min",2),s([x()],c.prototype,"max",2),s([x()],c.prototype,"suffix",2),s([x()],c.prototype,"forceDisabled",2),s([x()],c.prototype,"forceInvalid",2),s([x()],c.prototype,"formatter",2),s([be('input[type="range"]')],c.prototype,"range",2),s([be("w-textfield")],c.prototype,"textfield",2),s([x()],c.prototype,"_invalid",2),s([x()],c.prototype,"_showTooltip",2);customElements.get("w-slider-thumb")||customElements.define("w-slider-thumb",c);export{u as WarpSlider,c as WarpSliderThumb};
|
|
2791
2851
|
//# sourceMappingURL=index.js.map
|