@leavepulse/ui 0.20.0 → 0.20.1

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.
@@ -4,8 +4,8 @@ export interface UseSettledOptions {
4
4
  delay?: MaybeRefOrGetter<number>;
5
5
  }
6
6
  /**
7
- * Returns a ref that flips true once `open` has been true for the length of the
8
- * overlay's opening animation. Gate expensive content on it:
7
+ * Returns a ref that flips true once `open` has been truthy for the length of
8
+ * the overlay's opening animation. Gate expensive content on it:
9
9
  *
10
10
  * ```ts
11
11
  * const settled = useSettled(() => isOpen.value)
@@ -15,7 +15,12 @@ export interface UseSettledOptions {
15
15
  * <RowSkeletons v-else />
16
16
  * ```
17
17
  *
18
+ * Anything truthy counts as open, so an id can be passed instead of a boolean.
19
+ * That is the useful form when the same panel is reused for different subjects:
20
+ * the wait restarts when the id changes, because the panel is mounting a whole
21
+ * new body without ever having closed.
22
+ *
18
23
  * With reduced motion there is no animation to protect, so it resolves on the
19
24
  * next tick rather than making the user wait for a delay that buys nothing.
20
25
  */
21
- export declare function useSettled(open: MaybeRefOrGetter<boolean>, options?: UseSettledOptions): import('vue').Ref<boolean, boolean>;
26
+ export declare function useSettled(open: MaybeRefOrGetter<unknown>, options?: UseSettledOptions): import('vue').Ref<boolean, boolean>;
@@ -11,12 +11,13 @@ function useSettled(open, options = {}) {
11
11
  }
12
12
  watch(
13
13
  () => toValue(open),
14
- (isOpen) => {
14
+ (value) => {
15
15
  clear();
16
- if (!isOpen) {
16
+ if (!value) {
17
17
  settled.value = false;
18
18
  return;
19
19
  }
20
+ settled.value = false;
20
21
  const reduced = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
21
22
  const wait = reduced ? 0 : toValue(options.delay) ?? SETTLE_MS;
22
23
  timer = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leavepulse/ui",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "type": "module",
5
5
  "description": "LeavePulse token-driven Vue component kit.",
6
6
  "repository": {
@@ -28,8 +28,8 @@ export interface UseSettledOptions {
28
28
  }
29
29
 
30
30
  /**
31
- * Returns a ref that flips true once `open` has been true for the length of the
32
- * overlay's opening animation. Gate expensive content on it:
31
+ * Returns a ref that flips true once `open` has been truthy for the length of
32
+ * the overlay's opening animation. Gate expensive content on it:
33
33
  *
34
34
  * ```ts
35
35
  * const settled = useSettled(() => isOpen.value)
@@ -39,11 +39,16 @@ export interface UseSettledOptions {
39
39
  * <RowSkeletons v-else />
40
40
  * ```
41
41
  *
42
+ * Anything truthy counts as open, so an id can be passed instead of a boolean.
43
+ * That is the useful form when the same panel is reused for different subjects:
44
+ * the wait restarts when the id changes, because the panel is mounting a whole
45
+ * new body without ever having closed.
46
+ *
42
47
  * With reduced motion there is no animation to protect, so it resolves on the
43
48
  * next tick rather than making the user wait for a delay that buys nothing.
44
49
  */
45
50
  export function useSettled(
46
- open: MaybeRefOrGetter<boolean>,
51
+ open: MaybeRefOrGetter<unknown>,
47
52
  options: UseSettledOptions = {},
48
53
  ) {
49
54
  const settled = ref(false)
@@ -58,12 +63,16 @@ export function useSettled(
58
63
 
59
64
  watch(
60
65
  () => toValue(open),
61
- (isOpen) => {
66
+ (value) => {
62
67
  clear()
63
- if (!isOpen) {
68
+ if (!value) {
64
69
  settled.value = false
65
70
  return
66
71
  }
72
+ // Restarted on the value, not on open/closed: a panel handed a different
73
+ // id stays open while its whole body is replaced, and that second mount
74
+ // is as expensive as the first.
75
+ settled.value = false
67
76
  const reduced =
68
77
  typeof window !== "undefined" &&
69
78
  window.matchMedia?.("(prefers-reduced-motion: reduce)").matches