@unabridged/midwest 0.14.3 → 0.15.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/app/assets/javascript/midwest/index.ts +4 -0
- package/app/assets/javascript/midwest.js +66 -0
- package/app/assets/javascript/midwest.js.map +1 -1
- package/app/assets/stylesheets/midwest.css +1 -1
- package/app/assets/stylesheets/midwest.tailwind.css +5 -1
- package/dist/css/midwest.css +1 -1
- package/dist/javascript/collection/app/assets/javascript/midwest/index.js +4 -0
- package/dist/javascript/collection/app/assets/javascript/midwest/index.js.map +1 -1
- package/dist/javascript/collection/app/components/midwest/form/range_component/range_component_controller.js +25 -0
- package/dist/javascript/collection/app/components/midwest/form/range_component/range_component_controller.js.map +1 -0
- package/dist/javascript/collection/app/components/midwest/rating_component/rating_component_controller.js +47 -0
- package/dist/javascript/collection/app/components/midwest/rating_component/rating_component_controller.js.map +1 -0
- package/dist/javascript/midwest.js +66 -0
- package/dist/javascript/midwest.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,6 +15,8 @@ import Badge from '../../../components/midwest/badge_component/badge_component_c
|
|
|
15
15
|
import Confirmation from '../../../components/midwest/confirmation_component/confirmation_component_controller'
|
|
16
16
|
import AvatarGroup from '../../../components/midwest/avatar_group_component/avatar_group_component_controller'
|
|
17
17
|
import Chart from '../../../components/midwest/chart_component/chart_component_controller'
|
|
18
|
+
import Range from '../../../components/midwest/form/range_component/range_component_controller'
|
|
19
|
+
import Rating from '../../../components/midwest/rating_component/rating_component_controller'
|
|
18
20
|
/* IMPORTS */
|
|
19
21
|
|
|
20
22
|
export { Card, Banner, CountdownTimer, Chart }
|
|
@@ -37,5 +39,7 @@ export function registerMidwestControllers (application: any) {
|
|
|
37
39
|
application.register('midwest-confirmation', Confirmation)
|
|
38
40
|
application.register('midwest-avatar-group', AvatarGroup)
|
|
39
41
|
application.register('midwest-chart', Chart)
|
|
42
|
+
application.register('midwest-range', Range)
|
|
43
|
+
application.register('midwest-rating', Rating)
|
|
40
44
|
/* EXPORTS */
|
|
41
45
|
}
|
|
@@ -3740,6 +3740,70 @@ class Chart extends Controller {
|
|
|
3740
3740
|
}
|
|
3741
3741
|
}
|
|
3742
3742
|
|
|
3743
|
+
class Range extends Controller {
|
|
3744
|
+
static targets = ["input", "output"];
|
|
3745
|
+
connect() {
|
|
3746
|
+
this.sync();
|
|
3747
|
+
}
|
|
3748
|
+
update() {
|
|
3749
|
+
this.sync();
|
|
3750
|
+
}
|
|
3751
|
+
sync() {
|
|
3752
|
+
const input = this.inputTarget;
|
|
3753
|
+
const min = Number(input.min) || 0;
|
|
3754
|
+
const max = Number(input.max) || 100;
|
|
3755
|
+
const val = Number(input.value);
|
|
3756
|
+
const pct = max === min ? 0 : (val - min) / (max - min) * 100;
|
|
3757
|
+
input.style.setProperty("--pct", `${pct}%`);
|
|
3758
|
+
if (this.hasOutputTarget) {
|
|
3759
|
+
this.outputTarget.value = String(val);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
class Rating extends Controller {
|
|
3765
|
+
static targets = ["star"];
|
|
3766
|
+
connect() {
|
|
3767
|
+
this.refreshFilledState();
|
|
3768
|
+
}
|
|
3769
|
+
preview(event) {
|
|
3770
|
+
const label = event.currentTarget;
|
|
3771
|
+
const hoverValue = Number(label.dataset.value);
|
|
3772
|
+
this.starTargets.forEach((star) => {
|
|
3773
|
+
const starValue = Number(star.dataset.value);
|
|
3774
|
+
star.classList.toggle("is-previewed", starValue <= hoverValue);
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
resetPreview() {
|
|
3778
|
+
this.starTargets.forEach((star) => star.classList.remove("is-previewed"));
|
|
3779
|
+
this.refreshFilledState();
|
|
3780
|
+
}
|
|
3781
|
+
select(event) {
|
|
3782
|
+
const label = event.currentTarget;
|
|
3783
|
+
const input = this.element.querySelector(
|
|
3784
|
+
`#${label.htmlFor}`
|
|
3785
|
+
);
|
|
3786
|
+
if (input) {
|
|
3787
|
+
input.checked = true;
|
|
3788
|
+
this.element.classList.add("has-value");
|
|
3789
|
+
}
|
|
3790
|
+
this.refreshFilledState();
|
|
3791
|
+
}
|
|
3792
|
+
refreshFilledState() {
|
|
3793
|
+
const checked = this.element.querySelector(
|
|
3794
|
+
'input[type="radio"]:checked'
|
|
3795
|
+
);
|
|
3796
|
+
const selectedValue = checked ? Number(checked.value) : 0;
|
|
3797
|
+
this.starTargets.forEach((star) => {
|
|
3798
|
+
const starValue = Number(star.dataset.value);
|
|
3799
|
+
star.classList.toggle("is-filled", starValue <= selectedValue);
|
|
3800
|
+
});
|
|
3801
|
+
if (selectedValue > 0) {
|
|
3802
|
+
this.element.classList.add("has-value");
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
|
|
3743
3807
|
function registerMidwestControllers(application) {
|
|
3744
3808
|
application.register("midwest-card", Card);
|
|
3745
3809
|
application.register("midwest-banner", Banner);
|
|
@@ -3758,6 +3822,8 @@ function registerMidwestControllers(application) {
|
|
|
3758
3822
|
application.register("midwest-confirmation", ConfirmationController);
|
|
3759
3823
|
application.register("midwest-avatar-group", AvatarGroup);
|
|
3760
3824
|
application.register("midwest-chart", Chart);
|
|
3825
|
+
application.register("midwest-range", Range);
|
|
3826
|
+
application.register("midwest-rating", Rating);
|
|
3761
3827
|
}
|
|
3762
3828
|
|
|
3763
3829
|
export { Banner, Card, Chart, CountdownTimer, registerMidwestControllers };
|