@uzum-tech/ui 2.0.2 → 2.0.3

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/index.js CHANGED
@@ -111399,6 +111399,7 @@
111399
111399
  const notificationEnvOptions = {
111400
111400
  ...notificationProps,
111401
111401
  duration: Number,
111402
+ pauseOnVisibilityChange: Boolean,
111402
111403
  onClose: Function,
111403
111404
  onLeave: Function,
111404
111405
  onAfterEnter: Function,
@@ -111428,10 +111429,45 @@
111428
111429
  const { wipTransitionCountRef } = vue.inject(notificationProviderInjectionKey);
111429
111430
  const showRef = vue.ref(true);
111430
111431
  let timerId = null;
111432
+ let remainingDuration = null;
111433
+ let timerStartedAt = null;
111434
+ let timerPausedForVisibility = false;
111435
+ function clearTimer() {
111436
+ if (timerId !== null) {
111437
+ window.clearTimeout(timerId);
111438
+ timerId = null;
111439
+ }
111440
+ }
111431
111441
  function hide() {
111432
111442
  showRef.value = false;
111433
- if (timerId) {
111434
- window.clearTimeout(timerId);
111443
+ clearTimer();
111444
+ }
111445
+ function startTimer(duration) {
111446
+ clearTimer();
111447
+ remainingDuration = duration;
111448
+ timerStartedAt = Date.now();
111449
+ timerId = window.setTimeout(hide, duration);
111450
+ }
111451
+ function handleVisibilityChange() {
111452
+ if (document.visibilityState === "hidden") {
111453
+ if (timerId !== null) {
111454
+ clearTimer();
111455
+ if (timerStartedAt !== null && remainingDuration !== null) {
111456
+ remainingDuration = Math.max(
111457
+ 0,
111458
+ remainingDuration - (Date.now() - timerStartedAt)
111459
+ );
111460
+ }
111461
+ timerStartedAt = null;
111462
+ timerPausedForVisibility = true;
111463
+ }
111464
+ } else if (timerPausedForVisibility) {
111465
+ timerPausedForVisibility = false;
111466
+ if (remainingDuration !== null && remainingDuration > 0) {
111467
+ startTimer(remainingDuration);
111468
+ } else {
111469
+ hide();
111470
+ }
111435
111471
  }
111436
111472
  }
111437
111473
  function handleBeforeEnter(el) {
@@ -111480,16 +111516,13 @@
111480
111516
  function setHideTimeout() {
111481
111517
  const { duration } = props;
111482
111518
  if (duration) {
111483
- timerId = window.setTimeout(hide, duration);
111519
+ startTimer(duration);
111484
111520
  }
111485
111521
  }
111486
111522
  function handleMouseenter(e) {
111487
111523
  if (e.currentTarget !== e.target)
111488
111524
  return;
111489
- if (timerId !== null) {
111490
- window.clearTimeout(timerId);
111491
- timerId = null;
111492
- }
111525
+ clearTimer();
111493
111526
  }
111494
111527
  function handleMouseleave(e) {
111495
111528
  if (e.currentTarget !== e.target)
@@ -111510,8 +111543,14 @@
111510
111543
  }
111511
111544
  vue.onMounted(() => {
111512
111545
  if (props.duration) {
111513
- timerId = window.setTimeout(hide, props.duration);
111546
+ startTimer(props.duration);
111514
111547
  }
111548
+ if (props.pauseOnVisibilityChange) {
111549
+ document.addEventListener("visibilitychange", handleVisibilityChange);
111550
+ }
111551
+ });
111552
+ vue.onBeforeUnmount(() => {
111553
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
111515
111554
  });
111516
111555
  return {
111517
111556
  show: showRef,
@@ -111558,12 +111597,16 @@
111558
111597
  var style = c$1([cB("notification-container", `
111559
111598
  z-index: 4000;
111560
111599
  position: fixed;
111600
+ left: 0;
111601
+ right: 0;
111561
111602
  overflow: visible;
111562
111603
  display: flex;
111563
111604
  flex-direction: column;
111564
111605
  align-items: flex-end;
111606
+ pointer-events: none;
111565
111607
  `, [c$1(">", [cB("scrollbar", `
111566
- width: initial;
111608
+ width: -moz-fit-content;
111609
+ width: fit-content;
111567
111610
  overflow: visible;
111568
111611
  height: -moz-fit-content !important;
111569
111612
  height: fit-content !important;
@@ -111589,8 +111632,7 @@
111589
111632
  margin-bottom: 0;
111590
111633
  margin-top: 12px;
111591
111634
  `)]), cM("top, bottom", `
111592
- left: 50%;
111593
- transform: translateX(-50%);
111635
+ align-items: center;
111594
111636
  `, [cB("notification-wrapper", [c$1("&.notification-transition-enter-from, &.notification-transition-leave-to", `
111595
111637
  transform: scale(0.85);
111596
111638
  `), c$1("&.notification-transition-leave-from, &.notification-transition-enter-to", `
@@ -111599,15 +111641,11 @@
111599
111641
  transform-origin: top center;
111600
111642
  `)]), cM("bottom", [cB("notification-wrapper", `
111601
111643
  transform-origin: bottom center;
111602
- `)]), cM("top-right", `
111603
- right: 0;
111604
- `, [placementTransformStyle("top-right")]), cM("top-left", `
111605
- left: 0;
111606
- `, [placementTransformStyle("top-left")]), cM("bottom-right", `
111607
- right: 0;
111608
- `, [placementTransformStyle("bottom-right")]), cM("bottom-left", `
111609
- left: 0;
111610
- `, [placementTransformStyle("bottom-left")]), cM("scrollable", [cM("top-right", `
111644
+ `)]), cM("top-right, bottom-right", `
111645
+ align-items: flex-end;
111646
+ `), cM("top-left, bottom-left", `
111647
+ align-items: flex-start;
111648
+ `), cM("scrollable", [cM("top-right", `
111611
111649
  top: 0;
111612
111650
  `), cM("top-left", `
111613
111651
  top: 0;
@@ -111644,6 +111682,7 @@
111644
111682
  `)]), cB("notification", `
111645
111683
  background-color: var(--u-color);
111646
111684
  color: var(--u-text-color);
111685
+ pointer-events: auto;
111647
111686
  transition:
111648
111687
  background-color .3s var(--u-bezier),
111649
111688
  color .3s var(--u-bezier),
@@ -111742,16 +111781,6 @@
111742
111781
  `, [c$1("&:first-child", {
111743
111782
  margin: 0
111744
111783
  })])])])])]);
111745
- function placementTransformStyle(placement) {
111746
- const direction = placement.split("-")[1];
111747
- const transformXEnter = direction === "left" ? "calc(-100%)" : "calc(100%)";
111748
- const transformXLeave = "0";
111749
- return cB("notification-wrapper", [c$1("&.notification-transition-enter-from, &.notification-transition-leave-to", `
111750
- transform: translate(${transformXEnter}, 0);
111751
- `), c$1("&.notification-transition-leave-from, &.notification-transition-enter-to", `
111752
- transform: translate(${transformXLeave}, 0);
111753
- `)]);
111754
- }
111755
111784
 
111756
111785
  const notificationApiInjectionKey = createInjectionKey("u-notification-api");
111757
111786
  const notificationProviderProps = {
@@ -112596,7 +112625,7 @@
112596
112625
  });
112597
112626
  }
112598
112627
 
112599
- var version = "2.0.2";
112628
+ var version = "2.0.3";
112600
112629
 
112601
112630
  function create({
112602
112631
  componentPrefix = "U",
package/dist/index.mjs CHANGED
@@ -111395,6 +111395,7 @@ const Notification = defineComponent({
111395
111395
  const notificationEnvOptions = {
111396
111396
  ...notificationProps,
111397
111397
  duration: Number,
111398
+ pauseOnVisibilityChange: Boolean,
111398
111399
  onClose: Function,
111399
111400
  onLeave: Function,
111400
111401
  onAfterEnter: Function,
@@ -111424,10 +111425,45 @@ const NotificationEnvironment = defineComponent({
111424
111425
  const { wipTransitionCountRef } = inject(notificationProviderInjectionKey);
111425
111426
  const showRef = ref(true);
111426
111427
  let timerId = null;
111428
+ let remainingDuration = null;
111429
+ let timerStartedAt = null;
111430
+ let timerPausedForVisibility = false;
111431
+ function clearTimer() {
111432
+ if (timerId !== null) {
111433
+ window.clearTimeout(timerId);
111434
+ timerId = null;
111435
+ }
111436
+ }
111427
111437
  function hide() {
111428
111438
  showRef.value = false;
111429
- if (timerId) {
111430
- window.clearTimeout(timerId);
111439
+ clearTimer();
111440
+ }
111441
+ function startTimer(duration) {
111442
+ clearTimer();
111443
+ remainingDuration = duration;
111444
+ timerStartedAt = Date.now();
111445
+ timerId = window.setTimeout(hide, duration);
111446
+ }
111447
+ function handleVisibilityChange() {
111448
+ if (document.visibilityState === "hidden") {
111449
+ if (timerId !== null) {
111450
+ clearTimer();
111451
+ if (timerStartedAt !== null && remainingDuration !== null) {
111452
+ remainingDuration = Math.max(
111453
+ 0,
111454
+ remainingDuration - (Date.now() - timerStartedAt)
111455
+ );
111456
+ }
111457
+ timerStartedAt = null;
111458
+ timerPausedForVisibility = true;
111459
+ }
111460
+ } else if (timerPausedForVisibility) {
111461
+ timerPausedForVisibility = false;
111462
+ if (remainingDuration !== null && remainingDuration > 0) {
111463
+ startTimer(remainingDuration);
111464
+ } else {
111465
+ hide();
111466
+ }
111431
111467
  }
111432
111468
  }
111433
111469
  function handleBeforeEnter(el) {
@@ -111476,16 +111512,13 @@ const NotificationEnvironment = defineComponent({
111476
111512
  function setHideTimeout() {
111477
111513
  const { duration } = props;
111478
111514
  if (duration) {
111479
- timerId = window.setTimeout(hide, duration);
111515
+ startTimer(duration);
111480
111516
  }
111481
111517
  }
111482
111518
  function handleMouseenter(e) {
111483
111519
  if (e.currentTarget !== e.target)
111484
111520
  return;
111485
- if (timerId !== null) {
111486
- window.clearTimeout(timerId);
111487
- timerId = null;
111488
- }
111521
+ clearTimer();
111489
111522
  }
111490
111523
  function handleMouseleave(e) {
111491
111524
  if (e.currentTarget !== e.target)
@@ -111506,8 +111539,14 @@ const NotificationEnvironment = defineComponent({
111506
111539
  }
111507
111540
  onMounted(() => {
111508
111541
  if (props.duration) {
111509
- timerId = window.setTimeout(hide, props.duration);
111542
+ startTimer(props.duration);
111510
111543
  }
111544
+ if (props.pauseOnVisibilityChange) {
111545
+ document.addEventListener("visibilitychange", handleVisibilityChange);
111546
+ }
111547
+ });
111548
+ onBeforeUnmount(() => {
111549
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
111511
111550
  });
111512
111551
  return {
111513
111552
  show: showRef,
@@ -111554,12 +111593,16 @@ const NotificationEnvironment = defineComponent({
111554
111593
  var style = c$1([cB("notification-container", `
111555
111594
  z-index: 4000;
111556
111595
  position: fixed;
111596
+ left: 0;
111597
+ right: 0;
111557
111598
  overflow: visible;
111558
111599
  display: flex;
111559
111600
  flex-direction: column;
111560
111601
  align-items: flex-end;
111602
+ pointer-events: none;
111561
111603
  `, [c$1(">", [cB("scrollbar", `
111562
- width: initial;
111604
+ width: -moz-fit-content;
111605
+ width: fit-content;
111563
111606
  overflow: visible;
111564
111607
  height: -moz-fit-content !important;
111565
111608
  height: fit-content !important;
@@ -111585,8 +111628,7 @@ var style = c$1([cB("notification-container", `
111585
111628
  margin-bottom: 0;
111586
111629
  margin-top: 12px;
111587
111630
  `)]), cM("top, bottom", `
111588
- left: 50%;
111589
- transform: translateX(-50%);
111631
+ align-items: center;
111590
111632
  `, [cB("notification-wrapper", [c$1("&.notification-transition-enter-from, &.notification-transition-leave-to", `
111591
111633
  transform: scale(0.85);
111592
111634
  `), c$1("&.notification-transition-leave-from, &.notification-transition-enter-to", `
@@ -111595,15 +111637,11 @@ var style = c$1([cB("notification-container", `
111595
111637
  transform-origin: top center;
111596
111638
  `)]), cM("bottom", [cB("notification-wrapper", `
111597
111639
  transform-origin: bottom center;
111598
- `)]), cM("top-right", `
111599
- right: 0;
111600
- `, [placementTransformStyle("top-right")]), cM("top-left", `
111601
- left: 0;
111602
- `, [placementTransformStyle("top-left")]), cM("bottom-right", `
111603
- right: 0;
111604
- `, [placementTransformStyle("bottom-right")]), cM("bottom-left", `
111605
- left: 0;
111606
- `, [placementTransformStyle("bottom-left")]), cM("scrollable", [cM("top-right", `
111640
+ `)]), cM("top-right, bottom-right", `
111641
+ align-items: flex-end;
111642
+ `), cM("top-left, bottom-left", `
111643
+ align-items: flex-start;
111644
+ `), cM("scrollable", [cM("top-right", `
111607
111645
  top: 0;
111608
111646
  `), cM("top-left", `
111609
111647
  top: 0;
@@ -111640,6 +111678,7 @@ var style = c$1([cB("notification-container", `
111640
111678
  `)]), cB("notification", `
111641
111679
  background-color: var(--u-color);
111642
111680
  color: var(--u-text-color);
111681
+ pointer-events: auto;
111643
111682
  transition:
111644
111683
  background-color .3s var(--u-bezier),
111645
111684
  color .3s var(--u-bezier),
@@ -111738,16 +111777,6 @@ var style = c$1([cB("notification-container", `
111738
111777
  `, [c$1("&:first-child", {
111739
111778
  margin: 0
111740
111779
  })])])])])]);
111741
- function placementTransformStyle(placement) {
111742
- const direction = placement.split("-")[1];
111743
- const transformXEnter = direction === "left" ? "calc(-100%)" : "calc(100%)";
111744
- const transformXLeave = "0";
111745
- return cB("notification-wrapper", [c$1("&.notification-transition-enter-from, &.notification-transition-leave-to", `
111746
- transform: translate(${transformXEnter}, 0);
111747
- `), c$1("&.notification-transition-leave-from, &.notification-transition-enter-to", `
111748
- transform: translate(${transformXLeave}, 0);
111749
- `)]);
111750
- }
111751
111780
 
111752
111781
  const notificationApiInjectionKey = createInjectionKey("u-notification-api");
111753
111782
  const notificationProviderProps = {
@@ -112592,7 +112621,7 @@ function useThemeVars() {
112592
112621
  });
112593
112622
  }
112594
112623
 
112595
- var version = "2.0.2";
112624
+ var version = "2.0.3";
112596
112625
 
112597
112626
  function create({
112598
112627
  componentPrefix = "U",