@unabridged/midwest 0.10.0 → 0.10.2

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.
@@ -10,13 +10,15 @@ import Tooltip from '../../../components/midwest/tooltip_component/tooltip_compo
10
10
  import Carousel from '../../../components/midwest/carousel_component/carousel_component_controller'
11
11
  import FormLiveSummary from '../../../components/midwest/form/live_summary_component/live_summary_component_controller'
12
12
  import Form from '../../../components/midwest/form/form_controller'
13
+ import CountdownTimer from '../../../components/midwest/countdown_timer_component/countdown_timer_component_controller'
13
14
  /* IMPORTS */
14
15
 
15
- export { Card, Banner }
16
+ export { Card, Banner, CountdownTimer }
16
17
 
17
18
  export function registerMidwestControllers (application: any) {
18
19
  application.register('midwest-card', Card)
19
20
  application.register('midwest-banner', Banner)
21
+ application.register('midwest-countdown-timer', CountdownTimer)
20
22
  application.register('midwest-input', Input)
21
23
  application.register('midwest-file', File)
22
24
  application.register('midwest-dropdown', Dropdown)
@@ -3026,7 +3026,10 @@ class Dialog extends Controller {
3026
3026
  hide({ detail }) {
3027
3027
  if (!detail.success)
3028
3028
  return;
3029
+ const redirectUrl = detail.fetchResponse?.location?.href;
3029
3030
  this.dismiss();
3031
+ if (redirectUrl)
3032
+ window.Turbo?.visit(redirectUrl);
3030
3033
  }
3031
3034
  // Arrow function so `this` is stable for add/removeEventListener pairing.
3032
3035
  dismiss = () => {
@@ -3517,9 +3520,28 @@ class Form extends Controller {
3517
3520
  }
3518
3521
  }
3519
3522
 
3523
+ class CountdownTimer extends Controller {
3524
+ static values = {
3525
+ seconds: { type: Number, default: 5 }
3526
+ };
3527
+ timer = null;
3528
+ connect() {
3529
+ this.timer = setTimeout(() => {
3530
+ this.dispatch("complete", { bubbles: true });
3531
+ }, this.secondsValue * 1e3);
3532
+ }
3533
+ disconnect() {
3534
+ if (this.timer !== null) {
3535
+ clearTimeout(this.timer);
3536
+ this.timer = null;
3537
+ }
3538
+ }
3539
+ }
3540
+
3520
3541
  function registerMidwestControllers(application) {
3521
3542
  application.register("midwest-card", Card);
3522
3543
  application.register("midwest-banner", Banner);
3544
+ application.register("midwest-countdown-timer", CountdownTimer);
3523
3545
  application.register("midwest-input", Input);
3524
3546
  application.register("midwest-file", File);
3525
3547
  application.register("midwest-dropdown", Dropdown);
@@ -3532,5 +3554,5 @@ function registerMidwestControllers(application) {
3532
3554
  application.register("midwest-form", Form);
3533
3555
  }
3534
3556
 
3535
- export { Banner, Card, registerMidwestControllers };
3557
+ export { Banner, Card, CountdownTimer, registerMidwestControllers };
3536
3558
  //# sourceMappingURL=midwest.js.map