@wow-two-beta/fe 0.0.39 → 0.0.41
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/auth/BffSession.d.ts +3 -3
- package/dist/auth/BffSession.js +3 -3
- package/dist/auth/BffSession.js.map +1 -1
- package/dist/auth/BffSessionSync.d.ts +2 -2
- package/dist/auth/BffSessionSync.js.map +1 -1
- package/dist/auth/BffStrategy.d.ts +7 -7
- package/dist/auth/BffStrategy.js +7 -7
- package/dist/auth/BffStrategy.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/formsEngine/AppForm.d.ts +12 -3
- package/dist/formsEngine/FormOperations.d.ts +18 -0
- package/dist/formsEngine/FormOperations.js +9 -0
- package/dist/formsEngine/FormOperations.js.map +1 -1
- package/dist/formsEngine/adapters/house/HouseFormCore.js +15 -6
- package/dist/formsEngine/adapters/house/HouseFormCore.js.map +1 -1
- package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.d.ts +4 -0
- package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js +10 -1
- package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js.map +1 -1
- package/dist/formsEngine/adapters/tanstack/UseAppForm.js +9 -6
- package/dist/formsEngine/adapters/tanstack/UseAppForm.js.map +1 -1
- package/dist/foundation/animation/animatedLayout/AnimatedLayout.d.ts +3 -3
- package/dist/foundation/dom/FocusTarget.d.ts +13 -0
- package/dist/foundation/dom/FocusTarget.js +12 -0
- package/dist/foundation/dom/FocusTarget.js.map +1 -0
- package/dist/foundation/dom/index.d.ts +1 -0
- package/dist/foundation/dom/index.js +3 -0
- package/dist/foundation/dom/index.js.map +1 -1
- package/dist/foundation/primitives/index.d.ts +1 -0
- package/dist/foundation/primitives/index.js +3 -0
- package/dist/foundation/primitives/index.js.map +1 -1
- package/dist/foundation/primitives/swapTransition/SwapTransition.d.ts +76 -0
- package/dist/foundation/primitives/swapTransition/SwapTransition.js +240 -0
- package/dist/foundation/primitives/swapTransition/SwapTransition.js.map +1 -0
- package/dist/foundation/primitives/swapTransition/index.d.ts +1 -0
- package/dist/index.css +11 -0
- package/dist/presentation/actions/refreshButton/RefreshButton.vue.js.map +1 -1
- package/dist/presentation/display/animatedNumberText/AnimatedNumberText.vue.d.ts +1 -1
- package/dist/presentation/display/carousel/Carousel.vue.d.ts +1 -1
- package/dist/presentation/display/countUpText/CountUpText.vue.d.ts +1 -1
- package/dist/presentation/display/scrollRevealGroup/ScrollRevealGroup.vue.d.ts +2 -2
- package/dist/presentation/forms/imageCropEditor/ImageCropEditor.vue.d.ts +1 -1
- package/dist/presentation/forms/imageEditor/ImageEditor.vue.d.ts +1 -1
- package/dist/presentation/forms/phoneInput/PhoneInput.vue.d.ts +4 -0
- package/dist/presentation/forms/phoneInput/PhoneInput.vue.js +19 -6
- package/dist/presentation/forms/phoneInput/PhoneInput.vue.js.map +1 -1
- package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js +17 -5
- package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js.map +1 -1
- package/package.json +1 -1
|
@@ -17,3 +17,4 @@ export * from './hooks/UseScrollActivity';
|
|
|
17
17
|
export { DomOrderExtensions } from './DomOrderExtensions';
|
|
18
18
|
export { resolveElement } from './ResolveElement';
|
|
19
19
|
export { ScrollRegionAttribute, findScrollRegions } from './ScrollRegion';
|
|
20
|
+
export { FocusTargetAttribute, focusTarget } from './FocusTarget';
|
|
@@ -16,6 +16,7 @@ import { ScrollIdleDelay, ScrollingAttribute, useScrollActivity } from "./hooks/
|
|
|
16
16
|
import { DomOrderExtensions } from "./DomOrderExtensions.js";
|
|
17
17
|
import { resolveElement } from "./ResolveElement.js";
|
|
18
18
|
import { ScrollRegionAttribute, findScrollRegions } from "./ScrollRegion.js";
|
|
19
|
+
import { FocusTargetAttribute, focusTarget } from "./FocusTarget.js";
|
|
19
20
|
export {
|
|
20
21
|
AriaAttribute,
|
|
21
22
|
AttributeValue,
|
|
@@ -23,6 +24,7 @@ export {
|
|
|
23
24
|
DomEvent,
|
|
24
25
|
DomOrderExtensions,
|
|
25
26
|
ElementTag,
|
|
27
|
+
FocusTargetAttribute,
|
|
26
28
|
HtmlElement,
|
|
27
29
|
Key,
|
|
28
30
|
PressExtensions,
|
|
@@ -33,6 +35,7 @@ export {
|
|
|
33
35
|
composeEventHandlers,
|
|
34
36
|
dataAttr,
|
|
35
37
|
findScrollRegions,
|
|
38
|
+
focusTarget,
|
|
36
39
|
resolveElement,
|
|
37
40
|
useEventListener,
|
|
38
41
|
useFocusTrap,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -20,6 +20,7 @@ import { Orientation, RovingFocusKey, useRovingFocusItem } from "./rovingFocusGr
|
|
|
20
20
|
import { Presence } from "./presence/Presence.js";
|
|
21
21
|
import { Primitive } from "./slot/Primitive.js";
|
|
22
22
|
import { Slottable, mergeProps, renderSlotClone, renderableChildren } from "./slot/Slot.js";
|
|
23
|
+
import { SwapTransition, SwapTransitionAttribute } from "./swapTransition/SwapTransition.js";
|
|
23
24
|
import { createCollection } from "./collection/Collection.js";
|
|
24
25
|
export {
|
|
25
26
|
AccessibleIcon,
|
|
@@ -48,6 +49,8 @@ export {
|
|
|
48
49
|
default12 as ScrollLockProvider,
|
|
49
50
|
default13 as ScrollViewport,
|
|
50
51
|
Slottable,
|
|
52
|
+
SwapTransition,
|
|
53
|
+
SwapTransitionAttribute,
|
|
51
54
|
default14 as VisuallyHidden,
|
|
52
55
|
colorModeScript,
|
|
53
56
|
createCollection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { SlotsType, VNode } from 'vue';
|
|
2
|
+
/** Present on the box while a swap runs — from the old content's fade-out to the new content's fade-in. */
|
|
3
|
+
export declare const SwapTransitionAttribute = "data-swapping";
|
|
4
|
+
/** Props for `SwapTransition`. */
|
|
5
|
+
export interface SwapTransitionProps {
|
|
6
|
+
/** Whether swaps and height changes animate. Defaults to `true`; `false` swaps instantly. */
|
|
7
|
+
readonly isEnabled?: boolean;
|
|
8
|
+
/** The height phase in milliseconds. Defaults to `200`. */
|
|
9
|
+
readonly duration?: number;
|
|
10
|
+
/** Each fade phase in milliseconds. Defaults to `120`. */
|
|
11
|
+
readonly fadeDuration?: number;
|
|
12
|
+
/** The easing curve of every phase. Defaults to the house ease-out curve. */
|
|
13
|
+
readonly easing?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Swaps its content with a fade and a height animation: on a change of the single child's key or type, the old
|
|
17
|
+
* content fades out, the box animates to the new content's height, and the new content fades in. While shown, the box
|
|
18
|
+
* follows its content's own height changes the same way. The first render, `:is-enabled="false"` and
|
|
19
|
+
* `prefers-reduced-motion` swap and resize instantly.
|
|
20
|
+
*
|
|
21
|
+
* Renders a `div` box (caller `class`, `style` and attributes fall through to it) around a `flow-root` content
|
|
22
|
+
* wrapper. The leaving content is `inert`; focus inside it moves to the box as a programmatic focus target, so it
|
|
23
|
+
* never falls back to the document body.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SwapTransition: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
26
|
+
/** Whether swaps and height changes animate. Defaults to `true`. */
|
|
27
|
+
isEnabled: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
/** The height phase in milliseconds. Defaults to `200`. */
|
|
32
|
+
duration: {
|
|
33
|
+
type: NumberConstructor;
|
|
34
|
+
default: undefined;
|
|
35
|
+
};
|
|
36
|
+
/** Each fade phase in milliseconds. Defaults to `120`. */
|
|
37
|
+
fadeDuration: {
|
|
38
|
+
type: NumberConstructor;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
/** The easing curve of every phase. Defaults to the house ease-out curve. */
|
|
42
|
+
easing: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: undefined;
|
|
45
|
+
};
|
|
46
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
49
|
+
/** Whether swaps and height changes animate. Defaults to `true`. */
|
|
50
|
+
isEnabled: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
54
|
+
/** The height phase in milliseconds. Defaults to `200`. */
|
|
55
|
+
duration: {
|
|
56
|
+
type: NumberConstructor;
|
|
57
|
+
default: undefined;
|
|
58
|
+
};
|
|
59
|
+
/** Each fade phase in milliseconds. Defaults to `120`. */
|
|
60
|
+
fadeDuration: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
default: undefined;
|
|
63
|
+
};
|
|
64
|
+
/** The easing curve of every phase. Defaults to the house ease-out curve. */
|
|
65
|
+
easing: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
}>> & Readonly<{}>, {
|
|
70
|
+
easing: string;
|
|
71
|
+
duration: number;
|
|
72
|
+
isEnabled: boolean;
|
|
73
|
+
fadeDuration: number;
|
|
74
|
+
}, SlotsType<{
|
|
75
|
+
default?: () => VNode[];
|
|
76
|
+
}>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { defineComponent, shallowRef, onMounted, onBeforeUnmount, h, Transition } from "vue";
|
|
2
|
+
import { animate, AnimationDefaults } from "../../animation/Animate.js";
|
|
3
|
+
import { useReducedMotion } from "../../device/hooks/UseReducedMotion.js";
|
|
4
|
+
import { FocusTargetAttribute, focusTarget } from "../../dom/FocusTarget.js";
|
|
5
|
+
const SwapTransitionAttribute = "data-swapping";
|
|
6
|
+
const FadeDurationMs = 120;
|
|
7
|
+
const SettleSlackMs = 250;
|
|
8
|
+
const ContentStyle = { display: "flow-root" };
|
|
9
|
+
function settle(handle, ms) {
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
const timer = setTimeout(() => {
|
|
12
|
+
handle.finish();
|
|
13
|
+
resolve();
|
|
14
|
+
}, ms + SettleSlackMs);
|
|
15
|
+
void handle.finished.then(() => {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
resolve();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const SwapTransition = defineComponent({
|
|
22
|
+
name: "SwapTransition",
|
|
23
|
+
props: {
|
|
24
|
+
/** Whether swaps and height changes animate. Defaults to `true`. */
|
|
25
|
+
isEnabled: { type: Boolean, default: void 0 },
|
|
26
|
+
/** The height phase in milliseconds. Defaults to `200`. */
|
|
27
|
+
duration: { type: Number, default: void 0 },
|
|
28
|
+
/** Each fade phase in milliseconds. Defaults to `120`. */
|
|
29
|
+
fadeDuration: { type: Number, default: void 0 },
|
|
30
|
+
/** The easing curve of every phase. Defaults to the house ease-out curve. */
|
|
31
|
+
easing: { type: String, default: void 0 }
|
|
32
|
+
},
|
|
33
|
+
slots: Object,
|
|
34
|
+
setup(props, { slots }) {
|
|
35
|
+
const box = shallowRef(null);
|
|
36
|
+
const content = shallowRef(null);
|
|
37
|
+
const prefersReducedMotion = useReducedMotion();
|
|
38
|
+
let phase = 0;
|
|
39
|
+
let handle = null;
|
|
40
|
+
let isSwapping = false;
|
|
41
|
+
let isEntering = false;
|
|
42
|
+
let isFollowing = false;
|
|
43
|
+
let isDisposed = false;
|
|
44
|
+
let lastHeight = null;
|
|
45
|
+
let observer = null;
|
|
46
|
+
const heightDuration = () => props.duration ?? AnimationDefaults.duration;
|
|
47
|
+
const fadeDuration = () => props.fadeDuration ?? FadeDurationMs;
|
|
48
|
+
const isAnimated = () => (props.isEnabled ?? true) && !prefersReducedMotion.value && document.visibilityState !== "hidden";
|
|
49
|
+
function stop() {
|
|
50
|
+
phase += 1;
|
|
51
|
+
handle?.cancel();
|
|
52
|
+
handle = null;
|
|
53
|
+
}
|
|
54
|
+
async function play(element, keyframes, duration) {
|
|
55
|
+
stop();
|
|
56
|
+
const token = phase;
|
|
57
|
+
const current = animate(element, keyframes, { duration, easing: props.easing });
|
|
58
|
+
handle = current;
|
|
59
|
+
await settle(current, duration);
|
|
60
|
+
if (token !== phase || isDisposed) return false;
|
|
61
|
+
handle = null;
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
async function resizeTo(boxElement, to) {
|
|
65
|
+
const from = boxElement.getBoundingClientRect().height;
|
|
66
|
+
boxElement.style.height = `${to}px`;
|
|
67
|
+
if (from === to) return true;
|
|
68
|
+
return play(boxElement, [{ height: `${from}px` }, { height: `${to}px` }], heightDuration());
|
|
69
|
+
}
|
|
70
|
+
function pin(boxElement) {
|
|
71
|
+
const height = boxElement.getBoundingClientRect().height;
|
|
72
|
+
stop();
|
|
73
|
+
isFollowing = false;
|
|
74
|
+
isSwapping = true;
|
|
75
|
+
boxElement.setAttribute(SwapTransitionAttribute, "");
|
|
76
|
+
boxElement.style.height = `${height}px`;
|
|
77
|
+
boxElement.style.overflow = "hidden";
|
|
78
|
+
}
|
|
79
|
+
function release() {
|
|
80
|
+
isSwapping = false;
|
|
81
|
+
isFollowing = false;
|
|
82
|
+
const boxElement = box.value;
|
|
83
|
+
if (boxElement) {
|
|
84
|
+
boxElement.style.height = "";
|
|
85
|
+
boxElement.style.overflow = "";
|
|
86
|
+
boxElement.removeAttribute(SwapTransitionAttribute);
|
|
87
|
+
}
|
|
88
|
+
const inner = content.value;
|
|
89
|
+
if (inner) {
|
|
90
|
+
inner.style.opacity = "";
|
|
91
|
+
inner.inert = false;
|
|
92
|
+
lastHeight = inner.getBoundingClientRect().height;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function parkFocus(boxElement, inner) {
|
|
96
|
+
const active = boxElement.ownerDocument.activeElement;
|
|
97
|
+
if (!active || !inner.contains(active)) return;
|
|
98
|
+
const hadTabIndex = boxElement.hasAttribute("tabindex");
|
|
99
|
+
const hadMarker = boxElement.hasAttribute(FocusTargetAttribute);
|
|
100
|
+
if (!focusTarget(boxElement)) return;
|
|
101
|
+
boxElement.addEventListener(
|
|
102
|
+
"blur",
|
|
103
|
+
() => {
|
|
104
|
+
if (!hadTabIndex) boxElement.removeAttribute("tabindex");
|
|
105
|
+
if (!hadMarker) boxElement.removeAttribute(FocusTargetAttribute);
|
|
106
|
+
},
|
|
107
|
+
{ once: true }
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function onBeforeLeave() {
|
|
111
|
+
const boxElement = box.value;
|
|
112
|
+
const inner = content.value;
|
|
113
|
+
if (!boxElement || !inner) return;
|
|
114
|
+
parkFocus(boxElement, inner);
|
|
115
|
+
if (!isAnimated()) return;
|
|
116
|
+
const opacity = getComputedStyle(inner).opacity;
|
|
117
|
+
pin(boxElement);
|
|
118
|
+
inner.style.opacity = opacity;
|
|
119
|
+
inner.inert = true;
|
|
120
|
+
}
|
|
121
|
+
function onLeave(_element, done) {
|
|
122
|
+
const inner = content.value;
|
|
123
|
+
if (!inner || !isSwapping) {
|
|
124
|
+
queueMicrotask(done);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const from = inner.style.opacity || "1";
|
|
128
|
+
inner.style.opacity = "0";
|
|
129
|
+
if (Number(from) === 0) {
|
|
130
|
+
queueMicrotask(done);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
void play(inner, [{ opacity: from }, { opacity: "0" }], fadeDuration()).then(() => {
|
|
134
|
+
if (!isDisposed) done();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function onAfterLeave() {
|
|
138
|
+
const boxElement = box.value;
|
|
139
|
+
const inner = content.value;
|
|
140
|
+
if (inner) inner.inert = false;
|
|
141
|
+
if (!boxElement || !inner || !isSwapping || isEntering) return;
|
|
142
|
+
void resizeTo(boxElement, inner.getBoundingClientRect().height).then((isComplete) => {
|
|
143
|
+
if (isComplete) release();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function onBeforeEnter() {
|
|
147
|
+
isEntering = true;
|
|
148
|
+
const boxElement = box.value;
|
|
149
|
+
const inner = content.value;
|
|
150
|
+
if (!boxElement || !inner) return;
|
|
151
|
+
inner.inert = false;
|
|
152
|
+
if (!isAnimated()) {
|
|
153
|
+
if (isSwapping) {
|
|
154
|
+
stop();
|
|
155
|
+
release();
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
pin(boxElement);
|
|
160
|
+
inner.style.opacity = "0";
|
|
161
|
+
}
|
|
162
|
+
function onEnter(_element, done) {
|
|
163
|
+
const boxElement = box.value;
|
|
164
|
+
const inner = content.value;
|
|
165
|
+
if (!boxElement || !inner || !isSwapping) {
|
|
166
|
+
done();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
void (async () => {
|
|
170
|
+
if (!await resizeTo(boxElement, inner.getBoundingClientRect().height)) return;
|
|
171
|
+
inner.style.opacity = "";
|
|
172
|
+
if (!await play(inner, [{ opacity: "0" }, { opacity: "1" }], fadeDuration())) return;
|
|
173
|
+
done();
|
|
174
|
+
})();
|
|
175
|
+
}
|
|
176
|
+
function onAfterEnter() {
|
|
177
|
+
isEntering = false;
|
|
178
|
+
release();
|
|
179
|
+
}
|
|
180
|
+
function onEnterCancelled() {
|
|
181
|
+
isEntering = false;
|
|
182
|
+
}
|
|
183
|
+
function onResize() {
|
|
184
|
+
const boxElement = box.value;
|
|
185
|
+
const inner = content.value;
|
|
186
|
+
if (!boxElement || !inner) return;
|
|
187
|
+
const height = inner.getBoundingClientRect().height;
|
|
188
|
+
const previous = lastHeight;
|
|
189
|
+
lastHeight = height;
|
|
190
|
+
if (isSwapping || previous === null || previous === height || !isAnimated()) return;
|
|
191
|
+
const from = isFollowing ? boxElement.getBoundingClientRect().height : previous;
|
|
192
|
+
stop();
|
|
193
|
+
isFollowing = true;
|
|
194
|
+
boxElement.style.height = `${height}px`;
|
|
195
|
+
boxElement.style.overflow = "hidden";
|
|
196
|
+
void play(boxElement, [{ height: `${from}px` }, { height: `${height}px` }], heightDuration()).then(
|
|
197
|
+
(isComplete) => {
|
|
198
|
+
if (isComplete && !isSwapping) release();
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
onMounted(() => {
|
|
203
|
+
const inner = content.value;
|
|
204
|
+
if (!inner || typeof ResizeObserver === "undefined") return;
|
|
205
|
+
lastHeight = inner.getBoundingClientRect().height;
|
|
206
|
+
observer = new ResizeObserver(onResize);
|
|
207
|
+
observer.observe(inner);
|
|
208
|
+
});
|
|
209
|
+
onBeforeUnmount(() => {
|
|
210
|
+
isDisposed = true;
|
|
211
|
+
stop();
|
|
212
|
+
observer?.disconnect();
|
|
213
|
+
observer = null;
|
|
214
|
+
});
|
|
215
|
+
return () => h("div", { ref: box }, [
|
|
216
|
+
h("div", { ref: content, style: ContentStyle }, [
|
|
217
|
+
h(
|
|
218
|
+
Transition,
|
|
219
|
+
{
|
|
220
|
+
mode: "out-in",
|
|
221
|
+
css: false,
|
|
222
|
+
onBeforeLeave,
|
|
223
|
+
onLeave,
|
|
224
|
+
onAfterLeave,
|
|
225
|
+
onBeforeEnter,
|
|
226
|
+
onEnter,
|
|
227
|
+
onAfterEnter,
|
|
228
|
+
onEnterCancelled
|
|
229
|
+
},
|
|
230
|
+
() => slots.default?.()
|
|
231
|
+
)
|
|
232
|
+
])
|
|
233
|
+
]);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
export {
|
|
237
|
+
SwapTransition,
|
|
238
|
+
SwapTransitionAttribute
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=SwapTransition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapTransition.js","sources":["../../../../src/foundation/primitives/swapTransition/SwapTransition.ts"],"sourcesContent":["// A content swap that never jumps: the old content fades out, the box animates its height to the new content's\n// height, and the new content fades in. Between swaps the box follows its content's own height changes.\n//\n// AUTHORED AS `defineComponent` IN PLAIN TS, like `Presence`: the whole job is a render function around Vue's\n// `<Transition>` and imperative motion on two wrapper elements.\n//\n// NON-OBVIOUS DECISIONS:\n//\n// - VUE'S `<Transition mode=\"out-in\">` OWNS THE SWAP. It keeps the leaving child mounted until its leave hook\n// calls `done`, waits for it before rendering the newest child, and cancels an entering child that a newer swap\n// replaces. This component only supplies JS hooks (`css: false`); it never retains a vnode of its own.\n//\n// - THE WRAPPERS ANIMATE, NEVER THE CONTENT. The fades run on the inner wrapper and the height on the outer box,\n// so a child's own inline styles and root shape are untouched. The inner wrapper is `display: flow-root`, so a\n// child's margins stay inside the measured height in every phase.\n//\n// - COMMIT THE END, ANIMATE FROM THE START. Each phase writes its final value inline and runs a `fill: 'none'`\n// WAAPI animation from the current value (`foundation/animation` `animate`), so a cancelled or finished phase\n// always leaves the committed value behind. A swap that interrupts another reads the height and opacity on\n// screen first, so it continues from where the previous motion stood.\n//\n// - A TIMER FLOOR UNDER EVERY PHASE. A hidden document runs no animation frames, so a WAAPI `finish` may never\n// arrive while a tab is in the background; out-in would then never render the new content. Each phase settles\n// on its animation or on a timer past its duration, whichever lands first.\n\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n Transition,\n type SlotsType,\n type StyleValue,\n type VNode,\n} from 'vue';\n\nimport { animate, AnimationDefaults, type AnimationHandle } from '../../animation';\nimport { useReducedMotion } from '../../device';\nimport { FocusTargetAttribute, focusTarget } from '../../dom';\n\n/** Present on the box while a swap runs — from the old content's fade-out to the new content's fade-in. */\nexport const SwapTransitionAttribute = 'data-swapping';\n\n/** The default length of each fade, in milliseconds. */\nconst FadeDurationMs = 120;\n\n/** How long past its duration a phase waits for its animation before settling on a timer instead. */\nconst SettleSlackMs = 250;\n\n/** Keeps a child's margins inside the measured content box in every phase. */\nconst ContentStyle: StyleValue = { display: 'flow-root' };\n\n/** Props for `SwapTransition`. */\nexport interface SwapTransitionProps {\n /** Whether swaps and height changes animate. Defaults to `true`; `false` swaps instantly. */\n readonly isEnabled?: boolean;\n /** The height phase in milliseconds. Defaults to `200`. */\n readonly duration?: number;\n /** Each fade phase in milliseconds. Defaults to `120`. */\n readonly fadeDuration?: number;\n /** The easing curve of every phase. Defaults to the house ease-out curve. */\n readonly easing?: string;\n}\n\n/** Settles when `handle` finishes, or `ms` plus a slack later when no animation frame runs (a hidden document). */\nfunction settle(handle: AnimationHandle, ms: number): Promise<void> {\n return new Promise((resolve) => {\n const timer = setTimeout(() => {\n handle.finish();\n resolve();\n }, ms + SettleSlackMs);\n void handle.finished.then(() => {\n clearTimeout(timer);\n resolve();\n });\n });\n}\n\n/**\n * Swaps its content with a fade and a height animation: on a change of the single child's key or type, the old\n * content fades out, the box animates to the new content's height, and the new content fades in. While shown, the box\n * follows its content's own height changes the same way. The first render, `:is-enabled=\"false\"` and\n * `prefers-reduced-motion` swap and resize instantly.\n *\n * Renders a `div` box (caller `class`, `style` and attributes fall through to it) around a `flow-root` content\n * wrapper. The leaving content is `inert`; focus inside it moves to the box as a programmatic focus target, so it\n * never falls back to the document body.\n */\nexport const SwapTransition = defineComponent({\n name: 'SwapTransition',\n\n props: {\n /** Whether swaps and height changes animate. Defaults to `true`. */\n isEnabled: { type: Boolean, default: undefined },\n /** The height phase in milliseconds. Defaults to `200`. */\n duration: { type: Number, default: undefined },\n /** Each fade phase in milliseconds. Defaults to `120`. */\n fadeDuration: { type: Number, default: undefined },\n /** The easing curve of every phase. Defaults to the house ease-out curve. */\n easing: { type: String, default: undefined },\n },\n\n slots: Object as SlotsType<{ default?: () => VNode[] }>,\n\n setup(props, { slots }) {\n const box = shallowRef<HTMLElement | null>(null);\n const content = shallowRef<HTMLElement | null>(null);\n const prefersReducedMotion = useReducedMotion();\n\n let phase = 0;\n let handle: AnimationHandle | null = null;\n let isSwapping = false;\n let isEntering = false;\n let isFollowing = false;\n let isDisposed = false;\n let lastHeight: number | null = null;\n let observer: ResizeObserver | null = null;\n\n const heightDuration = (): number => props.duration ?? AnimationDefaults.duration;\n const fadeDuration = (): number => props.fadeDuration ?? FadeDurationMs;\n const isAnimated = (): boolean =>\n (props.isEnabled ?? true) && !prefersReducedMotion.value && document.visibilityState !== 'hidden';\n\n /** Cancels the running phase; its continuation sees a newer `phase` and stops. */\n function stop(): void {\n phase += 1;\n handle?.cancel();\n handle = null;\n }\n\n /** Runs one phase; resolves `true` when it ran to its end, `false` when a newer phase or unmount replaced it. */\n async function play(element: HTMLElement, keyframes: Keyframe[], duration: number): Promise<boolean> {\n stop();\n const token = phase;\n const current = animate(element, keyframes, { duration, easing: props.easing });\n handle = current;\n await settle(current, duration);\n if (token !== phase || isDisposed) return false;\n handle = null;\n return true;\n }\n\n /** Animates the box from the height on screen to `to`, committing `to` first. */\n async function resizeTo(boxElement: HTMLElement, to: number): Promise<boolean> {\n const from = boxElement.getBoundingClientRect().height;\n boxElement.style.height = `${to}px`;\n if (from === to) return true;\n return play(boxElement, [{ height: `${from}px` }, { height: `${to}px` }], heightDuration());\n }\n\n /** Holds the box at the height on screen, stopping whatever motion ran, for the swap that starts now. */\n function pin(boxElement: HTMLElement): void {\n const height = boxElement.getBoundingClientRect().height;\n stop();\n isFollowing = false;\n isSwapping = true;\n boxElement.setAttribute(SwapTransitionAttribute, '');\n boxElement.style.height = `${height}px`;\n boxElement.style.overflow = 'hidden';\n }\n\n /** Hands the box back to its content: auto height, visible overflow, full opacity. */\n function release(): void {\n isSwapping = false;\n isFollowing = false;\n const boxElement = box.value;\n if (boxElement) {\n boxElement.style.height = '';\n boxElement.style.overflow = '';\n boxElement.removeAttribute(SwapTransitionAttribute);\n }\n const inner = content.value;\n if (inner) {\n inner.style.opacity = '';\n inner.inert = false;\n lastHeight = inner.getBoundingClientRect().height;\n }\n }\n\n /** Moves focus held inside the leaving content to the box, removing the box's focus target marks on blur. */\n function parkFocus(boxElement: HTMLElement, inner: HTMLElement): void {\n const active = boxElement.ownerDocument.activeElement;\n if (!active || !inner.contains(active)) return;\n const hadTabIndex = boxElement.hasAttribute('tabindex');\n const hadMarker = boxElement.hasAttribute(FocusTargetAttribute);\n if (!focusTarget(boxElement)) return;\n boxElement.addEventListener(\n 'blur',\n () => {\n if (!hadTabIndex) boxElement.removeAttribute('tabindex');\n if (!hadMarker) boxElement.removeAttribute(FocusTargetAttribute);\n },\n { once: true },\n );\n }\n\n function onBeforeLeave(): void {\n const boxElement = box.value;\n const inner = content.value;\n if (!boxElement || !inner) return;\n parkFocus(boxElement, inner);\n if (!isAnimated()) return;\n // A swap that cancels an entering one fades out from the opacity on screen.\n const opacity = getComputedStyle(inner).opacity;\n pin(boxElement);\n inner.style.opacity = opacity;\n inner.inert = true;\n }\n\n function onLeave(_element: Element, done: () => void): void {\n const inner = content.value;\n if (!inner || !isSwapping) {\n // Out-in renders the next child from `done`; called inside this patch, it would patch over a placeholder\n // that is not mounted yet. A microtask later the patch is over and nothing has painted.\n queueMicrotask(done);\n return;\n }\n const from = inner.style.opacity || '1';\n inner.style.opacity = '0';\n // Content still transparent (a swap that cancels one mid-height) has nothing to fade.\n if (Number(from) === 0) {\n queueMicrotask(done);\n return;\n }\n // Always finish the leave: out-in renders nothing new until `done` runs.\n void play(inner, [{ opacity: from }, { opacity: '0' }], fadeDuration()).then(() => {\n if (!isDisposed) done();\n });\n }\n\n function onAfterLeave(): void {\n const boxElement = box.value;\n const inner = content.value;\n if (inner) inner.inert = false;\n // Out-in mounts the next child before this hook runs; none (a `v-if` turned false) settles on empty content.\n if (!boxElement || !inner || !isSwapping || isEntering) return;\n void resizeTo(boxElement, inner.getBoundingClientRect().height).then((isComplete) => {\n if (isComplete) release();\n });\n }\n\n function onBeforeEnter(): void {\n isEntering = true;\n const boxElement = box.value;\n const inner = content.value;\n if (!boxElement || !inner) return;\n inner.inert = false;\n if (!isAnimated()) {\n if (isSwapping) {\n stop();\n release();\n }\n return;\n }\n pin(boxElement);\n inner.style.opacity = '0';\n }\n\n function onEnter(_element: Element, done: () => void): void {\n const boxElement = box.value;\n const inner = content.value;\n if (!boxElement || !inner || !isSwapping) {\n done();\n return;\n }\n void (async () => {\n if (!(await resizeTo(boxElement, inner.getBoundingClientRect().height))) return;\n inner.style.opacity = '';\n if (!(await play(inner, [{ opacity: '0' }, { opacity: '1' }], fadeDuration()))) return;\n done();\n })();\n }\n\n function onAfterEnter(): void {\n isEntering = false;\n release();\n }\n\n function onEnterCancelled(): void {\n // The leave hooks that follow read the height and opacity on screen before stopping this motion.\n isEntering = false;\n }\n\n /** Between swaps, animates the box from the content's previous height to its new one. */\n function onResize(): void {\n const boxElement = box.value;\n const inner = content.value;\n if (!boxElement || !inner) return;\n const height = inner.getBoundingClientRect().height;\n const previous = lastHeight;\n lastHeight = height;\n if (isSwapping || previous === null || previous === height || !isAnimated()) return;\n // Idle, the auto-height box already shows the new height; a running follow shows its own frame.\n const from = isFollowing ? boxElement.getBoundingClientRect().height : previous;\n stop();\n isFollowing = true;\n boxElement.style.height = `${height}px`;\n boxElement.style.overflow = 'hidden';\n void play(boxElement, [{ height: `${from}px` }, { height: `${height}px` }], heightDuration()).then(\n (isComplete) => {\n if (isComplete && !isSwapping) release();\n },\n );\n }\n\n // `onMounted` never runs on the server: the observer and every measurement stay client-side.\n onMounted(() => {\n const inner = content.value;\n if (!inner || typeof ResizeObserver === 'undefined') return;\n lastHeight = inner.getBoundingClientRect().height;\n observer = new ResizeObserver(onResize);\n observer.observe(inner);\n });\n\n onBeforeUnmount(() => {\n isDisposed = true;\n stop();\n observer?.disconnect();\n observer = null;\n });\n\n return () =>\n h('div', { ref: box }, [\n h('div', { ref: content, style: ContentStyle }, [\n h(\n Transition,\n {\n mode: 'out-in',\n css: false,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n },\n () => slots.default?.(),\n ),\n ]),\n ]);\n },\n});\n"],"names":[],"mappings":";;;;AA0CO,MAAM,0BAA0B;AAGvC,MAAM,iBAAiB;AAGvB,MAAM,gBAAgB;AAGtB,MAAM,eAA2B,EAAE,SAAS,YAAA;AAe5C,SAAS,OAAO,QAAyB,IAA2B;AAClE,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,QAAQ,WAAW,MAAM;AAC7B,aAAO,OAAA;AACP,cAAA;AAAA,IACF,GAAG,KAAK,aAAa;AACrB,SAAK,OAAO,SAAS,KAAK,MAAM;AAC9B,mBAAa,KAAK;AAClB,cAAA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AAYO,MAAM,iBAAiB,gBAAgB;AAAA,EAC5C,MAAM;AAAA,EAEN,OAAO;AAAA;AAAA,IAEL,WAAW,EAAE,MAAM,SAAS,SAAS,OAAA;AAAA;AAAA,IAErC,UAAU,EAAE,MAAM,QAAQ,SAAS,OAAA;AAAA;AAAA,IAEnC,cAAc,EAAE,MAAM,QAAQ,SAAS,OAAA;AAAA;AAAA,IAEvC,QAAQ,EAAE,MAAM,QAAQ,SAAS,OAAA;AAAA,EAAU;AAAA,EAG7C,OAAO;AAAA,EAEP,MAAM,OAAO,EAAE,SAAS;AACtB,UAAM,MAAM,WAA+B,IAAI;AAC/C,UAAM,UAAU,WAA+B,IAAI;AACnD,UAAM,uBAAuB,iBAAA;AAE7B,QAAI,QAAQ;AACZ,QAAI,SAAiC;AACrC,QAAI,aAAa;AACjB,QAAI,aAAa;AACjB,QAAI,cAAc;AAClB,QAAI,aAAa;AACjB,QAAI,aAA4B;AAChC,QAAI,W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cAAc,aAAa,QAAQ,aAAa,UAAU,CAAC,aAAc;AAE7E,YAAM,OAAO,cAAc,WAAW,sBAAA,EAAwB,SAAS;AACvE,WAAA;AACA,oBAAc;AACd,iBAAW,MAAM,SAAS,GAAG,MAAM;AACnC,iBAAW,MAAM,WAAW;AAC5B,WAAK,KAAK,YAAY,CAAC,EAAE,QAAQ,GAAG,IAAI,KAAA,GAAQ,EAAE,QAAQ,GAAG,MAAM,KAAA,CAAM,GAAG,eAAA,CAAgB,EAAE;AAAA,QAC5F,CAAC,eAAe;AACd,cAAI,cAAc,CAAC,WAAY,SAAA;AAAA,QACjC;AAAA,MAAA;AAAA,IAEJ;AAGA,cAAU,MAAM;AACd,YAAM,QAAQ,QAAQ;AACtB,UAAI,CAAC,SAAS,OAAO,mBAAmB,YAAa;AACrD,mBAAa,MAAM,wBAAwB;AAC3C,iBAAW,IAAI,eAAe,QAAQ;AACtC,eAAS,QAAQ,KAAK;AAAA,IACxB,CAAC;AAED,oBAAgB,MAAM;AACpB,mBAAa;AACb,WAAA;AACA,gBAAU,WAAA;AACV,iBAAW;AAAA,IACb,CAAC;AAED,WAAO,MACL,EAAE,OAAO,EAAE,KAAK,OAAO;AAAA,MACrB,EAAE,OAAO,EAAE,KAAK,SAAS,OAAO,gBAAgB;AAAA,QAC9C;AAAA,UACE;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,KAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,UAEF,MAAM,MAAM,UAAA;AAAA,QAAU;AAAA,MACxB,CACD;AAAA,IAAA,CACF;AAAA,EACL;AACF,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SwapTransition, SwapTransitionAttribute, type SwapTransitionProps } from './SwapTransition';
|
package/dist/index.css
CHANGED
|
@@ -291,6 +291,17 @@ body {
|
|
|
291
291
|
color: var(--color-foreground);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
/* A programmatic focus target — what `focusTarget` (`foundation/dom`) marks with `data-focus-target`: a page's `main`
|
|
295
|
+
after a route change, a heading, a region holding focus while its content swaps. It is not a control, so it draws
|
|
296
|
+
no focus ring, and a screen reader still lands on it. The selector outweighs preflight's Firefox ring in the same
|
|
297
|
+
layer, `:-moz-focusring:where(:not(iframe)) { outline: auto }`, which a zero-specificity `:where()` lost to;
|
|
298
|
+
`@layer base` still leaves a utility the app sets on the element in charge. */
|
|
299
|
+
@layer base {
|
|
300
|
+
[data-focus-target]:focus {
|
|
301
|
+
outline: none;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
294
305
|
/* ---------------------------------------------------------------------------
|
|
295
306
|
* Scrollbars — a slim themed track and a pill-shaped thumb on every scroll container, always visible.
|
|
296
307
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshButton.vue.js","sources":["../../../../src/presentation/actions/refreshButton/RefreshButton.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ButtonProps } from '../button';\n\n/** @internal The `ButtonProps` this preset decides itself. */\ntype OwnedButtonProp = keyof Pick<ButtonProps, 'isLoading' | 'shape' | 'leadingSlot'>;\n\n/** Defines the forwarded `ButtonProps`, minus the ones the refresh preset sets. */\ntype RefreshButtonAttributes = Omit<ButtonProps, OwnedButtonProp>;\n\n/** Defines props for the one refresh control a region shows. */\nexport interface RefreshButtonProps extends /* @vue-ignore */ RefreshButtonAttributes {\n /** True from the click until the refresh settles — `useRefresh`'s `refreshing`; the icon spins and clicks wait. */\n readonly isRefreshing?: boolean;\n\n /** The visible label, or the accessible name of an icon-only button. Default `\"Refresh\"`, localized. */\n readonly label?: string;\n\n /** Renders the icon alone, square at its size, named by `label`. */\n readonly isIconOnly?: boolean;\n\n /** The visual surface style. Default `outline`; `ghost` inside a panel header. */\n readonly variant?: ButtonProps['variant'];\n\n /** The size step. Default `sm`; `md` beside page-level controls. */\n readonly size?: ButtonProps['size'];\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\nimport { RefreshCw } from 'lucide-vue-next';\nimport { useLocaleDefaults } from '../../../foundation/i18n';\nimport { Icon } from '../../../foundation/icons';\nimport Button from '../button/Button.vue';\n\n/**\n * Renders the refresh control a region reruns its reads with — a `Button` preset that swaps the refresh icon for the\n * spinner while `isRefreshing`, keeps its label and width, and swallows repeat clicks until the refresh settles. Pair\n * it with `useRefresh` from `@wow-two-beta/fe/query`, which also drives the region's placeholders.\n */\ndefineOptions({ name: 'RefreshButton', inheritAttrs: false });\n\nconst componentProps = withDefaults(defineProps<RefreshButtonProps>(), {\n isRefreshing: false,\n label: undefined,\n isIconOnly: false,\n variant: 'outline',\n size: 'sm',\n});\nconst props = useLocaleDefaults(componentProps, 'RefreshButton', { label: 'Refresh' });\n\nconst attrs = useAttrs();\n\n/** The icon-only form names itself through `aria-label`, and `title` shows the name on hover. */\nconst naming = computed(() =>\n props.isIconOnly ? { 'aria-label': props.label, title: props.label } : ({} as Record<string, string>),\n);\n</script>\n\n<template>\n <Button\n tone=\"neutral\"\n :variant=\"props.variant\"\n :size=\"props.size\"\n :shape=\"props.isIconOnly ? 'square' : 'default'\"\n :is-loading=\"props.isRefreshing\"\n v-bind=\"{ ...naming, ...attrs }\"\n >\n <template #leading><Icon :icon=\"RefreshCw\" :size=\"14\" /></template>\n <template v-if=\"!props.isIconOnly\">{{ props.label }}</template>\n </Button>\n</template>\n"],"names":["_openBlock","_createBlock","Button","_mergeProps","_unref","_createVNode","Icon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;AA0CA,UAAM,iBAAiB;AAOvB,UAAM,QAAQ,kBAAkB,gBAAgB,iBAAiB,EAAE,OAAO,WAAW;AAErF,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS;AAAA,MAAS,MACtB,MAAM,aAAa,EAAE,cAAc,MAAM,OAAO,OAAO,MAAM,UAAW,CAAA;AAAA,IAAC;;AAKzE,aAAAA,UAAA,GAAAC,YAUSC,aAVTC,WAUS;AAAA,QATP,MAAK;AAAA,QACJ,SAASC,MAAA,KAAA,EAAM;AAAA,QACf,MAAMA,MAAA,KAAA,EAAM;AAAA,QACZ,OAAOA,MAAA,KAAA,EAAM,aAAU,WAAA;AAAA,QACvB,cAAYA,MAAA,KAAA,EAAM;AAAA,MAAA,GACN,EAAA,GAAA,OAAA,UAAWA,MAAA,KAAA,EAAA,CAAK,GAAA;AAAA,QAElB,iBAAQ,MAAqC;AAAA,UAArCC,YAAqCD,MAAAE,WAAA,GAAA;AAAA,YAA9B,MAAMF,MAAA,SAAA;AAAA,YAAY,MAAM;AAAA,UAAA;;
|
|
1
|
+
{"version":3,"file":"RefreshButton.vue.js","sources":["../../../../src/presentation/actions/refreshButton/RefreshButton.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ButtonProps } from '../button';\n\n/** @internal The `ButtonProps` this preset decides itself. */\ntype OwnedButtonProp = keyof Pick<ButtonProps, 'isLoading' | 'shape' | 'leadingSlot'>;\n\n/** Defines the forwarded `ButtonProps`, minus the ones the refresh preset sets. */\ntype RefreshButtonAttributes = Omit<ButtonProps, OwnedButtonProp>;\n\n/** Defines props for the one refresh control a region shows. */\nexport interface RefreshButtonProps extends /* @vue-ignore */ RefreshButtonAttributes {\n /** True from the click until the refresh settles — `useRefresh`'s `refreshing`; the icon spins and clicks wait. */\n readonly isRefreshing?: boolean;\n\n /** The visible label, or the accessible name of an icon-only button. Default `\"Refresh\"`, localized. */\n readonly label?: string;\n\n /** Renders the icon alone, square at its size, named by `label`. */\n readonly isIconOnly?: boolean;\n\n /** The visual surface style. Default `outline`; `ghost` inside a panel header. */\n readonly variant?: ButtonProps['variant'];\n\n /** The size step. Default `sm`; `md` beside page-level controls. */\n readonly size?: ButtonProps['size'];\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\nimport { RefreshCw } from 'lucide-vue-next';\nimport { useLocaleDefaults } from '../../../foundation/i18n';\nimport { Icon } from '../../../foundation/icons';\nimport Button from '../button/Button.vue';\n\n/**\n * Renders the refresh control a region reruns its reads with — a `Button` preset that swaps the refresh icon for the\n * spinner while `isRefreshing`, keeps its label and width, and swallows repeat clicks until the refresh settles. Pair\n * it with `useRefresh` from `@wow-two-beta/fe/query`, which also drives the region's placeholders.\n */\ndefineOptions({ name: 'RefreshButton', inheritAttrs: false });\n\nconst componentProps = withDefaults(defineProps<RefreshButtonProps>(), {\n isRefreshing: false,\n label: undefined,\n isIconOnly: false,\n variant: 'outline',\n size: 'sm',\n});\nconst props = useLocaleDefaults(componentProps, 'RefreshButton', { label: 'Refresh' });\n\nconst attrs = useAttrs();\n\n/** The icon-only form names itself through `aria-label`, and `title` shows the name on hover. */\nconst naming = computed(() =>\n props.isIconOnly ? { 'aria-label': props.label, title: props.label } : ({} as Record<string, string>),\n);\n</script>\n\n<template>\n <Button\n tone=\"neutral\"\n :variant=\"props.variant\"\n :size=\"props.size\"\n :shape=\"props.isIconOnly ? 'square' : 'default'\"\n :is-loading=\"props.isRefreshing\"\n v-bind=\"{ ...naming, ...attrs }\"\n >\n <template #leading><Icon :icon=\"RefreshCw\" :size=\"14\" /></template>\n <template v-if=\"!props.isIconOnly\">{{ props.label }}</template>\n </Button>\n</template>\n"],"names":["_openBlock","_createBlock","Button","_mergeProps","_unref","_createVNode","Icon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;AA0CA,UAAM,iBAAiB;AAOvB,UAAM,QAAQ,kBAAkB,gBAAgB,iBAAiB,EAAE,OAAO,WAAW;AAErF,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS;AAAA,MAAS,MACtB,MAAM,aAAa,EAAE,cAAc,MAAM,OAAO,OAAO,MAAM,UAAW,CAAA;AAAA,IAAC;;AAKzE,aAAAA,UAAA,GAAAC,YAUSC,aAVTC,WAUS;AAAA,QATP,MAAK;AAAA,QACJ,SAASC,MAAA,KAAA,EAAM;AAAA,QACf,MAAMA,MAAA,KAAA,EAAM;AAAA,QACZ,OAAOA,MAAA,KAAA,EAAM,aAAU,WAAA;AAAA,QACvB,cAAYA,MAAA,KAAA,EAAM;AAAA,MAAA,GACN,EAAA,GAAA,OAAA,UAAWA,MAAA,KAAA,EAAA,CAAK,GAAA;AAAA,QAElB,iBAAQ,MAAqC;AAAA,UAArCC,YAAqCD,MAAAE,WAAA,GAAA;AAAA,YAA9B,MAAMF,MAAA,SAAA;AAAA,YAAY,MAAM;AAAA,UAAA;;yBAClD,MAA+D;AAAA,UAA9C,CAAAA,MAAA,KAAA,EAAM,2BAAvBG,mBAA+DC,UAAA,EAAA,KAAA,KAAA;AAAA,YAAzBC,gBAAAC,gBAAAN,MAAA,KAAA,EAAM,KAAK,GAAA,CAAA;AAAA,UAAA;;;;;;;"}
|
|
@@ -16,8 +16,8 @@ declare const _default: __VLS_WithSlots<import('vue').DefineComponent<AnimatedNu
|
|
|
16
16
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<AnimatedNumberTextProps> & Readonly<{}>, {
|
|
17
17
|
readonly as: ElementTag;
|
|
18
18
|
readonly format: (value: number) => string;
|
|
19
|
-
readonly duration: number;
|
|
20
19
|
readonly easing: (t: number) => number;
|
|
20
|
+
readonly duration: number;
|
|
21
21
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
|
|
22
22
|
/** The rich override for the formatted number — receives the live tween value. */
|
|
23
23
|
value?(props: {
|
|
@@ -21,8 +21,8 @@ declare const _default: __VLS_WithSlots<import('vue').DefineComponent<CarouselPr
|
|
|
21
21
|
}, string, import('vue').PublicProps, Readonly<CarouselProps> & Readonly<{
|
|
22
22
|
"onUpdate:index"?: ((index: number) => any) | undefined;
|
|
23
23
|
}>, {
|
|
24
|
-
readonly canLoop: boolean;
|
|
25
24
|
readonly index: number;
|
|
25
|
+
readonly canLoop: boolean;
|
|
26
26
|
readonly defaultIndex: number;
|
|
27
27
|
readonly autoPlay: number;
|
|
28
28
|
readonly slidesCount: number;
|
|
@@ -21,8 +21,8 @@ declare const _default: __VLS_WithSlots<import('vue').DefineComponent<CountUpTex
|
|
|
21
21
|
readonly as: ElementTag;
|
|
22
22
|
readonly format: (value: number) => string;
|
|
23
23
|
readonly from: number;
|
|
24
|
-
readonly duration: number;
|
|
25
24
|
readonly easing: (t: number) => number;
|
|
25
|
+
readonly duration: number;
|
|
26
26
|
readonly canTriggerOnView: boolean;
|
|
27
27
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
|
|
28
28
|
/** The rich override for the formatted number — receives the live tween value. */
|
|
@@ -33,10 +33,10 @@ declare const _default: __VLS_WithSlots<import('vue').DefineComponent<ScrollReve
|
|
|
33
33
|
el: Readonly<import('vue').ShallowRef<HTMLElement | null>>;
|
|
34
34
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ScrollRevealGroupProps> & Readonly<{}>, {
|
|
35
35
|
readonly as: ElementTag;
|
|
36
|
-
readonly threshold: number;
|
|
37
36
|
readonly duration: number;
|
|
38
|
-
readonly effect: ScrollRevealGroupEffect;
|
|
39
37
|
readonly delay: number;
|
|
38
|
+
readonly threshold: number;
|
|
39
|
+
readonly effect: ScrollRevealGroupEffect;
|
|
40
40
|
readonly isOnce: boolean;
|
|
41
41
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
|
|
42
42
|
default(): unknown;
|
|
@@ -33,10 +33,10 @@ declare const _default: import('vue').DefineComponent<ImageCropEditorProps, {
|
|
|
33
33
|
}, string, import('vue').PublicProps, Readonly<ImageCropEditorProps> & Readonly<{
|
|
34
34
|
"onUpdate:modelValue"?: ((crop: CropRect) => any) | undefined;
|
|
35
35
|
}>, {
|
|
36
|
+
readonly alt: string;
|
|
36
37
|
readonly isDisabled: boolean;
|
|
37
38
|
readonly isReadOnly: boolean;
|
|
38
39
|
readonly maxHeight: string;
|
|
39
|
-
readonly alt: string;
|
|
40
40
|
readonly defaultValue: CropRect | null;
|
|
41
41
|
readonly modelValue: CropRect | null;
|
|
42
42
|
readonly aspectRatio: number;
|
|
@@ -26,9 +26,9 @@ declare const _default: import('vue').DefineComponent<ImageEditorProps, {}, {},
|
|
|
26
26
|
onPreview?: ((recipe: ImageEditRecipe) => any) | undefined;
|
|
27
27
|
}>, {
|
|
28
28
|
readonly error: string;
|
|
29
|
+
readonly alt: string;
|
|
29
30
|
readonly isDisabled: boolean;
|
|
30
31
|
readonly isReadOnly: boolean;
|
|
31
|
-
readonly alt: string;
|
|
32
32
|
readonly defaultValue: ImageEditRecipe;
|
|
33
33
|
readonly modelValue: ImageEditRecipe;
|
|
34
34
|
readonly maxDimension: number;
|
|
@@ -20,8 +20,12 @@ export interface PhoneInputProps extends /* @vue-ignore */ NativeInputAttributes
|
|
|
20
20
|
readonly name?: string;
|
|
21
21
|
}
|
|
22
22
|
declare const _default: import('vue').DefineComponent<PhoneInputProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
23
|
+
blur: (event: FocusEvent) => any;
|
|
24
|
+
focus: (event: FocusEvent) => any;
|
|
23
25
|
"update:modelValue": (e164: string) => any;
|
|
24
26
|
}, string, import('vue').PublicProps, Readonly<PhoneInputProps> & Readonly<{
|
|
27
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
28
|
+
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
25
29
|
"onUpdate:modelValue"?: ((e164: string) => any) | undefined;
|
|
26
30
|
}>, {
|
|
27
31
|
readonly placeholder: string;
|
|
@@ -27,7 +27,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
27
27
|
placeholder: { default: void 0 },
|
|
28
28
|
name: {}
|
|
29
29
|
},
|
|
30
|
-
emits: ["update:modelValue"],
|
|
30
|
+
emits: ["update:modelValue", "focus", "blur"],
|
|
31
31
|
setup(__props, { emit: __emit }) {
|
|
32
32
|
const props = __props;
|
|
33
33
|
const emit = __emit;
|
|
@@ -147,13 +147,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
147
147
|
function placeCaret(field, caret) {
|
|
148
148
|
if (field.ownerDocument.activeElement === field) field.setSelectionRange(caret, caret);
|
|
149
149
|
}
|
|
150
|
+
function isInside(event) {
|
|
151
|
+
const root = event.currentTarget;
|
|
152
|
+
return event.relatedTarget instanceof Node && root.contains(event.relatedTarget);
|
|
153
|
+
}
|
|
154
|
+
function onFocusin(event) {
|
|
155
|
+
if (!isInside(event)) emit("focus", event);
|
|
156
|
+
}
|
|
157
|
+
function onFocusout(event) {
|
|
158
|
+
if (!isInside(event)) emit("blur", event);
|
|
159
|
+
}
|
|
150
160
|
const OwnedAttributes = /* @__PURE__ */ new Set(["class"]);
|
|
151
161
|
const passthroughAttrs = computed(
|
|
152
162
|
() => Object.fromEntries(Object.entries(attrs).filter(([key]) => !OwnedAttributes.has(key)))
|
|
153
163
|
);
|
|
154
164
|
const rootClass = computed(
|
|
155
165
|
() => cn(
|
|
156
|
-
"inline-flex items-stretch overflow-hidden rounded-md border bg-background",
|
|
166
|
+
"inline-flex h-10 items-stretch overflow-hidden rounded-md border bg-background",
|
|
157
167
|
invalid.value ? "border-destructive" : "border-input",
|
|
158
168
|
disabled.value && "opacity-60",
|
|
159
169
|
readOnly.value && "bg-muted text-muted-foreground",
|
|
@@ -162,19 +172,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
162
172
|
);
|
|
163
173
|
const selectClass = computed(
|
|
164
174
|
() => cn(
|
|
165
|
-
"h-
|
|
175
|
+
"h-full cursor-pointer border-r border-input bg-card pl-2 pr-1 text-sm outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
|
|
166
176
|
readOnly.value && "cursor-default bg-muted text-muted-foreground"
|
|
167
177
|
)
|
|
168
178
|
);
|
|
169
179
|
const prefixClass = computed(
|
|
170
180
|
() => cn(
|
|
171
|
-
"flex h-
|
|
181
|
+
"flex h-full items-center border-r border-input bg-card px-2 text-sm",
|
|
172
182
|
readOnly.value && "bg-muted text-muted-foreground"
|
|
173
183
|
)
|
|
174
184
|
);
|
|
175
185
|
const inputClass = cn(
|
|
176
186
|
inputBaseVariants({ size: InputSize.Md }),
|
|
177
|
-
"rounded-none border-0 focus-visible:ring-0 readonly:focus-visible:ring-0"
|
|
187
|
+
"h-full rounded-none border-0 focus-visible:ring-0 readonly:focus-visible:ring-0"
|
|
178
188
|
);
|
|
179
189
|
const formResetAnchor = useTemplateRef("formResetAnchor");
|
|
180
190
|
const formResetRevision = useNativeFormReset(formResetAnchor, () => {
|
|
@@ -186,7 +196,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
186
196
|
key: unref(formResetRevision),
|
|
187
197
|
"data-readonly": readOnly.value || void 0,
|
|
188
198
|
class: rootClass.value
|
|
189
|
-
}, passthroughAttrs.value
|
|
199
|
+
}, passthroughAttrs.value, {
|
|
200
|
+
onFocusin,
|
|
201
|
+
onFocusout
|
|
202
|
+
}), [
|
|
190
203
|
allowed.value.length === 1 ? (openBlock(), createElementBlock("span", {
|
|
191
204
|
key: 0,
|
|
192
205
|
class: normalizeClass(prefixClass.value)
|