@warp-ds/elements 2.2.0-next.27 → 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 +105 -123
- package/dist/index.d.ts +31 -31
- 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/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/vscode.html-custom-data.json +20 -20
- package/dist/web-types.json +39 -39
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ee=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var N=l=>{throw TypeError(l)};var u=(l,r,e,t)=>{for(var n=t>1?void 0:t?re(r,e):r,a=l.length-1,v;a>=0;a--)(v=l[a])&&(n=(t?v(r,e,n):v(n))||n);return t&&n&&ee(r,e,n),n};var oe=(l,r,e)=>r.has(l)||N("Cannot "+e);var R=(l,r,e)=>r.has(l)?N("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(l):r.set(l,e);var m=(l,r,e)=>(oe(l,r,"access private method"),e);var s=function(l,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?l!==r||!t:!r.has(l))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(l):t?t.value:r.get(l)},c=function(l,r,e,t,n){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?l!==r||!n:!r.has(l))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?n.call(l,e):n?n.value=e:r.set(l,e),e};function W(l){var r,e,t,n,a,v,k,K,z,P,j,S,E,C,T,x,A,X,Z;class Q extends l{constructor(...o){var i,d,b;super(...o),r.add(this),this.internals=this.attachInternals(),e.set(this,!1),t.set(this,!1),n.set(this,!1),a.set(this,void 0),v.set(this,void 0),k.set(this,!0),z.set(this,""),P.set(this,()=>{c(this,n,!0,"f"),c(this,e,!0,"f"),s(this,r,"m",x).call(this)}),j.set(this,()=>{c(this,e,!1,"f"),s(this,r,"m",A).call(this,this.shouldFormValueUpdate()?s(this,z,"f"):""),!this.validity.valid&&s(this,n,"f")&&c(this,t,!0,"f");let f=s(this,r,"m",x).call(this);this.validationMessageCallback&&this.validationMessageCallback(f?this.internals.validationMessage:"")}),S.set(this,()=>{var f;s(this,k,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),c(this,k,!1,"f")),c(this,n,!0,"f"),c(this,t,!0,"f"),s(this,r,"m",x).call(this),(f=this===null||this===void 0?void 0:this.validationMessageCallback)===null||f===void 0||f.call(this,this.showError?this.internals.validationMessage:"")}),E.set(this,void 0),C.set(this,!1),T.set(this,Promise.resolve()),(i=this.addEventListener)===null||i===void 0||i.call(this,"focus",s(this,P,"f")),(d=this.addEventListener)===null||d===void 0||d.call(this,"blur",s(this,j,"f")),(b=this.addEventListener)===null||b===void 0||b.call(this,"invalid",s(this,S,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let o=this.validators.map(b=>b.attribute).flat(),i=super.observedAttributes||[];return[...new Set([...i,...o])]}static getValidator(o){return this.validators.find(i=>i.attribute===o)||null}static getValidators(o){return this.validators.filter(i=>{var d;if(i.attribute===o||!((d=i.attribute)===null||d===void 0)&&d.includes(o))return!0})}get form(){return this.internals.form}get showError(){return s(this,r,"m",x).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(o,i,d){var b;(b=super.attributeChangedCallback)===null||b===void 0||b.call(this,o,i,d);let V=this.constructor.getValidators(o);V!=null&&V.length&&this.validationTarget&&this.setValue(s(this,z,"f"))}setValue(o){var i;c(this,t,!1,"f"),(i=this.validationMessageCallback)===null||i===void 0||i.call(this,""),c(this,z,o,"f");let b=this.shouldFormValueUpdate()?o:null;this.internals.setFormValue(b),s(this,r,"m",A).call(this,b),this.valueChangedCallback&&this.valueChangedCallback(b),s(this,r,"m",x).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(o=>o(s(this,T,"f")))}formResetCallback(){var o,i;c(this,n,!1,"f"),c(this,t,!1,"f"),s(this,r,"m",x).call(this),(o=this.resetFormControl)===null||o===void 0||o.call(this),(i=this.validationMessageCallback)===null||i===void 0||i.call(this,s(this,r,"m",x).call(this)?this.validationMessage:"")}}return e=new WeakMap,t=new WeakMap,n=new WeakMap,a=new WeakMap,v=new WeakMap,k=new WeakMap,z=new WeakMap,P=new WeakMap,j=new WeakMap,S=new WeakMap,E=new WeakMap,C=new WeakMap,T=new WeakMap,r=new WeakSet,K=function(){let o=this.getRootNode(),i=`${this.localName}[name="${this.getAttribute("name")}"]`;return o.querySelectorAll(i)},x=function(){if(this.hasAttribute("disabled"))return!1;let o=s(this,t,"f")||s(this,n,"f")&&!this.validity.valid&&!s(this,e,"f");return o&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),o},A=function(o){let i=this.constructor,d={},b=i.validators,f=[],V=b.some(p=>p.isValid instanceof Promise);s(this,C,"f")||(c(this,T,new Promise(p=>{c(this,E,p,"f")}),"f"),c(this,C,!0,"f")),s(this,a,"f")&&(s(this,a,"f").abort(),c(this,v,s(this,a,"f"),"f"));let M=new AbortController;c(this,a,M,"f");let Y,q=!1;b.length&&(b.forEach(p=>{let I=p.key||"customError",y=p.isValid(this,o,M.signal);y instanceof Promise?(f.push(y),y.then($=>{$!=null&&(d[I]=!$,Y=s(this,r,"m",Z).call(this,p,o),s(this,r,"m",X).call(this,d,Y))})):(d[I]=!y,this.validity[I]!==!y&&(q=!0),!y&&!Y&&(Y=s(this,r,"m",Z).call(this,p,o)))}),Promise.allSettled(f).then(()=>{var p;M!=null&&M.signal.aborted||(c(this,C,!1,"f"),(p=s(this,E,"f"))===null||p===void 0||p.call(this))}),(q||!V)&&s(this,r,"m",X).call(this,d,Y))},X=function(o,i){if(this.validationTarget)this.internals.setValidity(o,i,this.validationTarget),c(this,k,!1,"f");else{if(this.internals.setValidity(o,i),this.internals.validity.valid)return;c(this,k,!0,"f")}},Z=function(o,i){if(this.validityCallback){let d=this.validityCallback(o.key||"customError");if(d)return d}return o.message instanceof Function?o.message(this,i):o.message},Q}import{html as G,LitElement as D,nothing as ae}from"lit";import{property as w}from"lit/decorators.js";import{css as O}from"lit";var U=O`
|
|
2
2
|
*,
|
|
3
3
|
:before,
|
|
4
4
|
:after {
|
|
@@ -271,7 +271,7 @@ var ie=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var U=a=>{th
|
|
|
271
271
|
svg {
|
|
272
272
|
pointer-events: none;
|
|
273
273
|
}
|
|
274
|
-
`,
|
|
274
|
+
`,de=O`*, :before, :after {
|
|
275
275
|
--w-rotate: 0;
|
|
276
276
|
--w-rotate-x: 0;
|
|
277
277
|
--w-rotate-y: 0;
|
|
@@ -2437,7 +2437,7 @@ var ie=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var U=a=>{th
|
|
|
2437
2437
|
display: none
|
|
2438
2438
|
}
|
|
2439
2439
|
}
|
|
2440
|
-
`;import{css as
|
|
2440
|
+
`;import{css as te}from"lit";var B=te`
|
|
2441
2441
|
.w-slider {
|
|
2442
2442
|
position: relative;
|
|
2443
2443
|
border: none;
|
|
@@ -2465,10 +2465,12 @@ var ie=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var U=a=>{th
|
|
|
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 ie=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var U=a=>{th
|
|
|
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 ie=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var U=a=>{th
|
|
|
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 ie=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var U=a=>{th
|
|
|
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,17 +2569,19 @@ var ie=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var U=a=>{th
|
|
|
2553
2569
|
bottom: 0;
|
|
2554
2570
|
grid-area: slider;
|
|
2555
2571
|
}
|
|
2556
|
-
`;var
|
|
2557
|
-
<fieldset id="fieldset" class="w-slider" @input="${m(this,
|
|
2572
|
+
`;var g,_,H,J,L,h=class extends W(D){constructor(){super(...arguments);R(this,g);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)),m(this,g,_).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"))&&m(this,g,_).call(this)}render(){return G`
|
|
2573
|
+
<fieldset id="fieldset" class="w-slider" @input="${m(this,g,H)}" @slidervalidity="${m(this,g,J)}">
|
|
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?G`<div class="w-slider__markers"></div>`:ae}
|
|
2579
|
+
<div class="w-slider__range">
|
|
2580
|
+
<div class="w-slider__active-range"></div>
|
|
2581
|
+
</div>
|
|
2582
|
+
<slot class="w-slider__slider" @slotchange=${m(this,g,_)}></slot>
|
|
2583
|
+
<slot class="w-slider__slider" name="from" @slotchange=${m(this,g,_)}></slot>
|
|
2584
|
+
<slot class="w-slider__slider" name="to" @slotchange=${m(this,g,_)}></slot>
|
|
2567
2585
|
</fieldset>
|
|
2568
|
-
`}};
|
|
2586
|
+
`}};g=new WeakSet,_=function(){let e=this.querySelectorAll("w-slider-thumb"),t=!1;for(let a of e.values())a.min=this.min,a.max=this.max,a.step=this.step,a.suffix=this.suffix,a.required=this.required,a.formatter=this.formatter,a.ariaLabel||(a.slot||(a.ariaLabel=this.label),a.slot==="from"&&(a.ariaLabel=`${this.label} min`),a.slot==="to"&&(a.ariaLabel=`${this.label} max`)),(a.slot==="from"||a.slot==="to")&&(t=!0),a.forceDisabled=this.disabled,a.forceInvalid=this.invalid,m(this,g,L).call(this,a);let n=this.shadowRoot.querySelector("fieldset");t?(n.style.setProperty("--active-range-inline-start-padding","var(--w-slider-thumb-size)"),n.style.setProperty("--active-range-inline-end-padding","var(--w-slider-thumb-size)")):n.style.setProperty("--active-range-border-radius","4px")},H=function(e){let t=e.target;m(this,g,L).call(this,t)},J=function(e){e.stopPropagation(),this.invalid=e.detail.invalid},L=function(e){var n,a;let t=e.slot;if(t||this.style.setProperty("--from","0"),t==="from"){let v=(n=e.value)!=null?n:e.value=this.min;this.style.setProperty("--from",v)}if(!t||t==="to"){let v=(a=e.value)!=null?a:e.value=this.max;this.style.setProperty("--to",v)}},h.shadowRootOptions={...D.shadowRootOptions,delegatesFocus:!0},h.styles=[U,B],u([w({reflect:!0})],h.prototype,"label",2),u([w({type:Boolean,reflect:!0})],h.prototype,"disabled",2),u([w({type:Boolean,reflect:!0})],h.prototype,"invalid",2),u([w({type:Boolean,reflect:!0})],h.prototype,"required",2),u([w({reflect:!0})],h.prototype,"min",2),u([w({reflect:!0})],h.prototype,"max",2),u([w({type:Number,reflect:!0})],h.prototype,"markers",2),u([w({type:Number,reflect:!0})],h.prototype,"step",2),u([w({reflect:!0})],h.prototype,"suffix",2),u([w({attribute:!1})],h.prototype,"formatter",2);customElements.get("w-slider")||customElements.define("w-slider",h);export{h as WarpSlider};
|
|
2569
2587
|
//# sourceMappingURL=slider.js.map
|