@decidables/decidables-elements 0.4.9 → 0.5.0
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/CHANGELOG.md +9 -0
- package/README.md +50 -0
- package/lib/decidablesElements.esm.js +102 -21
- package/lib/decidablesElements.esm.js.map +1 -1
- package/lib/decidablesElements.esm.min.js +84 -39
- package/lib/decidablesElements.esm.min.js.map +1 -1
- package/lib/decidablesElements.umd.js +102 -21
- package/lib/decidablesElements.umd.js.map +1 -1
- package/lib/decidablesElements.umd.min.js +85 -40
- package/lib/decidablesElements.umd.min.js.map +1 -1
- package/package.json +2 -2
- package/src/button.js +5 -2
- package/src/slider.js +126 -19
|
@@ -3407,6 +3407,9 @@
|
|
|
3407
3407
|
static get styles() {
|
|
3408
3408
|
return [super.styles, i$3`
|
|
3409
3409
|
:host {
|
|
3410
|
+
---decidables-button-background-color-disabled: var(--decidables-button-background-color, var(---color-element-disabled));
|
|
3411
|
+
---decidables-button-background-color-enabled: var(--decidables-button-background-color, var(---color-element-enabled));
|
|
3412
|
+
|
|
3410
3413
|
margin: 0.25rem;
|
|
3411
3414
|
}
|
|
3412
3415
|
|
|
@@ -3426,7 +3429,7 @@
|
|
|
3426
3429
|
}
|
|
3427
3430
|
|
|
3428
3431
|
button:disabled {
|
|
3429
|
-
background-color: var(
|
|
3432
|
+
background-color: var(---decidables-button-background-color-disabled);
|
|
3430
3433
|
outline: none;
|
|
3431
3434
|
box-shadow: none;
|
|
3432
3435
|
}
|
|
@@ -3434,7 +3437,7 @@
|
|
|
3434
3437
|
button:enabled {
|
|
3435
3438
|
cursor: pointer;
|
|
3436
3439
|
|
|
3437
|
-
background-color: var(
|
|
3440
|
+
background-color: var(---decidables-button-background-color-enabled);
|
|
3438
3441
|
outline: none;
|
|
3439
3442
|
box-shadow: var(---shadow-2);
|
|
3440
3443
|
}
|
|
@@ -3485,6 +3488,11 @@
|
|
|
3485
3488
|
type: Boolean,
|
|
3486
3489
|
reflect: true
|
|
3487
3490
|
},
|
|
3491
|
+
scale: {
|
|
3492
|
+
attribute: 'scale',
|
|
3493
|
+
type: Boolean,
|
|
3494
|
+
reflect: true
|
|
3495
|
+
},
|
|
3488
3496
|
max: {
|
|
3489
3497
|
attribute: 'max',
|
|
3490
3498
|
type: Number,
|
|
@@ -3504,6 +3512,11 @@
|
|
|
3504
3512
|
attribute: 'value',
|
|
3505
3513
|
type: Number,
|
|
3506
3514
|
reflect: true
|
|
3515
|
+
},
|
|
3516
|
+
nonlinear: {
|
|
3517
|
+
attribute: false,
|
|
3518
|
+
type: Boolean,
|
|
3519
|
+
reflect: false
|
|
3507
3520
|
}
|
|
3508
3521
|
};
|
|
3509
3522
|
}
|
|
@@ -3512,13 +3525,30 @@
|
|
|
3512
3525
|
|
|
3513
3526
|
// Attributes
|
|
3514
3527
|
this.disabled = false;
|
|
3528
|
+
this.scale = false;
|
|
3515
3529
|
this.max = undefined;
|
|
3516
3530
|
this.min = undefined;
|
|
3517
3531
|
this.step = undefined;
|
|
3518
3532
|
this.value = undefined;
|
|
3533
|
+
this.nonlinear = false;
|
|
3534
|
+
|
|
3535
|
+
// Properties
|
|
3536
|
+
this.rangeMax = undefined;
|
|
3537
|
+
this.rangeMin = undefined;
|
|
3538
|
+
this.rangeStep = undefined;
|
|
3539
|
+
this.rangeValue = undefined;
|
|
3540
|
+
|
|
3541
|
+
// Transform
|
|
3542
|
+
this.toRange = undefined;
|
|
3543
|
+
this.fromRange = undefined;
|
|
3519
3544
|
}
|
|
3520
|
-
|
|
3521
|
-
this.
|
|
3545
|
+
nonlinearRange(nonlinear, toRange, fromRange) {
|
|
3546
|
+
this.nonlinear = nonlinear;
|
|
3547
|
+
this.toRange = nonlinear ? toRange : undefined;
|
|
3548
|
+
this.fromRange = nonlinear ? fromRange : undefined;
|
|
3549
|
+
}
|
|
3550
|
+
rangeChanged(event) {
|
|
3551
|
+
this.value = this.nonlinear ? this.fromRange(event.target.value) : event.target.value;
|
|
3522
3552
|
this.dispatchEvent(new CustomEvent('change', {
|
|
3523
3553
|
detail: {
|
|
3524
3554
|
value: this.value
|
|
@@ -3526,12 +3556,25 @@
|
|
|
3526
3556
|
bubbles: true
|
|
3527
3557
|
}));
|
|
3528
3558
|
}
|
|
3529
|
-
|
|
3559
|
+
rangeInputted(event) {
|
|
3560
|
+
this.value = this.nonlinear ? this.fromRange(event.target.value) : event.target.value;
|
|
3561
|
+
}
|
|
3562
|
+
spinnerInputted(event) {
|
|
3530
3563
|
this.value = event.target.value;
|
|
3531
3564
|
}
|
|
3565
|
+
willUpdate() {
|
|
3566
|
+
this.rangeMax = this.max === undefined ? undefined : this.nonlinear ? this.toRange(this.max) : this.max;
|
|
3567
|
+
this.rangeMin = this.min === undefined ? undefined : this.nonlinear ? this.toRange(this.min) : this.min;
|
|
3568
|
+
this.rangeStep = this.step === undefined ? undefined : this.nonlinear ? 'any' : this.step;
|
|
3569
|
+
this.rangeValue = this.value === undefined ? undefined : this.nonlinear ? this.toRange(this.value) : this.value;
|
|
3570
|
+
}
|
|
3532
3571
|
static get styles() {
|
|
3533
3572
|
return [super.styles, i$3`
|
|
3534
3573
|
:host {
|
|
3574
|
+
---decidables-slider-background-color: var(--decidables-slider-background-color, var(---color-element-disabled));
|
|
3575
|
+
---decidables-slider-color: var(--decidables-slider-color, var(---color-element-enabled));
|
|
3576
|
+
---decidables-spinner-background-color: var(--decidables-slider-background-color, none);
|
|
3577
|
+
|
|
3535
3578
|
---shadow-2-rotate: var(--shadow-2-rotate, ${r$3(this.cssBoxShadow(2, true, false))});
|
|
3536
3579
|
---shadow-4-rotate: var(--shadow-4-rotate, ${r$3(this.cssBoxShadow(4, true, false))});
|
|
3537
3580
|
---shadow-8-rotate: var(--shadow-8-rotate, ${r$3(this.cssBoxShadow(8, true, false))});
|
|
@@ -3549,7 +3592,10 @@
|
|
|
3549
3592
|
}
|
|
3550
3593
|
|
|
3551
3594
|
.range {
|
|
3552
|
-
|
|
3595
|
+
position: relative;
|
|
3596
|
+
display: flex;
|
|
3597
|
+
|
|
3598
|
+
flex-direction: row;
|
|
3553
3599
|
|
|
3554
3600
|
width: 3.5rem;
|
|
3555
3601
|
height: 4.75rem;
|
|
@@ -3560,6 +3606,8 @@
|
|
|
3560
3606
|
--decidables-spinner-input-width: 3.5rem;
|
|
3561
3607
|
|
|
3562
3608
|
margin: 0 0.25rem 0.25rem;
|
|
3609
|
+
|
|
3610
|
+
background: var(---decidables-spinner-background-color);
|
|
3563
3611
|
}
|
|
3564
3612
|
|
|
3565
3613
|
/* Adapted from http://danielstern.ca/range.css/#/ */
|
|
@@ -3598,14 +3646,14 @@
|
|
|
3598
3646
|
width: 100%;
|
|
3599
3647
|
height: 4px;
|
|
3600
3648
|
|
|
3601
|
-
background: var(---
|
|
3649
|
+
background: var(---decidables-slider-background-color);
|
|
3602
3650
|
border: 0;
|
|
3603
3651
|
border-radius: 2px;
|
|
3604
3652
|
box-shadow: none;
|
|
3605
3653
|
}
|
|
3606
3654
|
|
|
3607
3655
|
input[type=range]:focus::-webkit-slider-runnable-track {
|
|
3608
|
-
background: var(---
|
|
3656
|
+
background: var(---decidables-slider-background-color);
|
|
3609
3657
|
}
|
|
3610
3658
|
|
|
3611
3659
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
@@ -3613,7 +3661,7 @@
|
|
|
3613
3661
|
width: 100%;
|
|
3614
3662
|
height: 4px;
|
|
3615
3663
|
|
|
3616
|
-
background: var(---
|
|
3664
|
+
background: var(---decidables-slider-background-color);
|
|
3617
3665
|
border: 0;
|
|
3618
3666
|
border-radius: 2px;
|
|
3619
3667
|
box-shadow: none;
|
|
@@ -3633,7 +3681,7 @@
|
|
|
3633
3681
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3634
3682
|
input[type=range]::-ms-fill-lower {
|
|
3635
3683
|
background: #cccccc;
|
|
3636
|
-
/* background: var(---
|
|
3684
|
+
/* background: var(---decidables-slider-background-color); */
|
|
3637
3685
|
border: 0;
|
|
3638
3686
|
border-radius: 2px;
|
|
3639
3687
|
box-shadow: none;
|
|
@@ -3642,7 +3690,7 @@
|
|
|
3642
3690
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3643
3691
|
input[type=range]::-ms-fill-upper {
|
|
3644
3692
|
background: #cccccc;
|
|
3645
|
-
/* background: var(---
|
|
3693
|
+
/* background: var(---decidables-slider-background-color); */
|
|
3646
3694
|
border: 0;
|
|
3647
3695
|
border-radius: 2px;
|
|
3648
3696
|
box-shadow: none;
|
|
@@ -3650,12 +3698,12 @@
|
|
|
3650
3698
|
|
|
3651
3699
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3652
3700
|
input[type=range]:focus::-ms-fill-lower {
|
|
3653
|
-
background: var(---
|
|
3701
|
+
background: var(---decidables-slider-background-color);
|
|
3654
3702
|
}
|
|
3655
3703
|
|
|
3656
3704
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3657
3705
|
input[type=range]:focus::-ms-fill-upper {
|
|
3658
|
-
background: var(---
|
|
3706
|
+
background: var(---decidables-slider-background-color);
|
|
3659
3707
|
}
|
|
3660
3708
|
|
|
3661
3709
|
/* Thumb */
|
|
@@ -3673,12 +3721,12 @@
|
|
|
3673
3721
|
}
|
|
3674
3722
|
|
|
3675
3723
|
input[type=range]:disabled::-webkit-slider-thumb {
|
|
3676
|
-
background: var(---
|
|
3724
|
+
background: var(---decidables-slider-background-color);
|
|
3677
3725
|
box-shadow: none;
|
|
3678
3726
|
}
|
|
3679
3727
|
|
|
3680
3728
|
input[type=range]:enabled::-webkit-slider-thumb {
|
|
3681
|
-
background: var(---
|
|
3729
|
+
background: var(---decidables-slider-color);
|
|
3682
3730
|
box-shadow: var(---shadow-2-rotate);
|
|
3683
3731
|
}
|
|
3684
3732
|
|
|
@@ -3709,13 +3757,13 @@
|
|
|
3709
3757
|
|
|
3710
3758
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3711
3759
|
input[type=range]:disabled::-moz-range-thumb {
|
|
3712
|
-
background: var(---
|
|
3760
|
+
background: var(---decidables-slider-background-color);
|
|
3713
3761
|
box-shadow: none;
|
|
3714
3762
|
}
|
|
3715
3763
|
|
|
3716
3764
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3717
3765
|
input[type=range]:enabled::-moz-range-thumb {
|
|
3718
|
-
background: var(---
|
|
3766
|
+
background: var(---decidables-slider-color);
|
|
3719
3767
|
box-shadow: var(---shadow-2-rotate);
|
|
3720
3768
|
}
|
|
3721
3769
|
|
|
@@ -3752,13 +3800,13 @@
|
|
|
3752
3800
|
|
|
3753
3801
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3754
3802
|
input[type=range]:disabled::-ms-thumb {
|
|
3755
|
-
background: var(---
|
|
3803
|
+
background: var(---decidables-slider-background-color);
|
|
3756
3804
|
box-shadow: none;
|
|
3757
3805
|
}
|
|
3758
3806
|
|
|
3759
3807
|
/* stylelint-disable-next-line no-descending-specificity */ /* stylelint ERROR */
|
|
3760
3808
|
input[type=range]:enabled::-ms-thumb {
|
|
3761
|
-
background: var(---
|
|
3809
|
+
background: var(---decidables-slider-color);
|
|
3762
3810
|
box-shadow: var(---shadow-2-rotate);
|
|
3763
3811
|
}
|
|
3764
3812
|
|
|
@@ -3780,6 +3828,33 @@
|
|
|
3780
3828
|
:host(.keyboard) input[type=range]:enabled:focus:active::-ms-thumb {
|
|
3781
3829
|
box-shadow: var(---shadow-8-rotate);
|
|
3782
3830
|
}
|
|
3831
|
+
|
|
3832
|
+
datalist {
|
|
3833
|
+
position: absolute;
|
|
3834
|
+
left: 2rem;
|
|
3835
|
+
z-index: -1;
|
|
3836
|
+
display: flex;
|
|
3837
|
+
|
|
3838
|
+
flex-direction: column;
|
|
3839
|
+
|
|
3840
|
+
align-items: flex-start;
|
|
3841
|
+
justify-content: space-between;
|
|
3842
|
+
|
|
3843
|
+
height: 4.75rem;
|
|
3844
|
+
|
|
3845
|
+
font-size: 0.75rem;
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
option {
|
|
3849
|
+
padding: 0;
|
|
3850
|
+
|
|
3851
|
+
line-height: 0.8;
|
|
3852
|
+
min-block-size: 0;
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
option::before {
|
|
3856
|
+
content: "– ";
|
|
3857
|
+
}
|
|
3783
3858
|
`];
|
|
3784
3859
|
}
|
|
3785
3860
|
render() {
|
|
@@ -3788,9 +3863,15 @@
|
|
|
3788
3863
|
<slot></slot>
|
|
3789
3864
|
</label>
|
|
3790
3865
|
<div class="range">
|
|
3791
|
-
<input ?disabled=${this.disabled} type="range" id="slider" min=${o(this.
|
|
3866
|
+
<input ?disabled=${this.disabled} type="range" id="slider" min=${o(this.rangeMin)} max=${o(this.rangeMax)} step=${o(this.rangeStep)} .value=${this.rangeValue} @change=${this.rangeChanged.bind(this)} @input=${this.rangeInputted.bind(this)}>
|
|
3867
|
+
${this.scale ? x`
|
|
3868
|
+
<datalist id="ticks">
|
|
3869
|
+
<option value=${o(this.rangeMax)} label=${o(this.max)}></option>
|
|
3870
|
+
<option value=${o(this.rangeMin)} label=${o(this.min)}></option>
|
|
3871
|
+
</datalist>
|
|
3872
|
+
` : x``}
|
|
3792
3873
|
</div>
|
|
3793
|
-
<decidables-spinner ?disabled=${this.disabled} min=${o(this.min)} max=${o(this.max)} step=${o(this.step)} .value=${this.value} @input=${this.
|
|
3874
|
+
<decidables-spinner ?disabled=${this.disabled} min=${o(this.min)} max=${o(this.max)} step=${o(this.step)} .value=${this.value} @input=${this.spinnerInputted.bind(this)}></decidables-spinner>
|
|
3794
3875
|
`;
|
|
3795
3876
|
}
|
|
3796
3877
|
}
|