@flux-ui/internals 3.0.0-next.5 → 3.0.0-next.51
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/README.md +36 -0
- package/dist/composable/index.d.ts +2 -17
- package/dist/composable/index.js +1 -0
- package/dist/composable-CJXC7sly.js +2 -0
- package/dist/composable-CJXC7sly.js.map +1 -0
- package/dist/data/index.d.ts +246 -1
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +2 -0
- package/dist/data/index.js.map +1 -0
- package/dist/directive/index.d.ts +2 -3
- package/dist/directive/index.js +1 -0
- package/dist/directive-Dprka-AO.js +2 -0
- package/dist/directive-Dprka-AO.js.map +1 -0
- package/dist/index-B79OP5Th.d.ts +70 -0
- package/dist/index-B79OP5Th.d.ts.map +1 -0
- package/dist/index-BRS2s2tX.d.ts +14 -0
- package/dist/index-BRS2s2tX.d.ts.map +1 -0
- package/dist/index-BhkFHXuX.d.ts +98 -0
- package/dist/index-BhkFHXuX.d.ts.map +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -0
- package/dist/util/index.d.ts +2 -13
- package/dist/util/index.js +1 -0
- package/dist/util-CwaOsSvo.js +2 -0
- package/dist/util-CwaOsSvo.js.map +1 -0
- package/package.json +31 -18
- package/src/composable/index.ts +1 -5
- package/src/composable/useFocusTrap.ts +1 -1
- package/src/composable/useFocusTrapReturn.ts +11 -7
- package/src/composable/useFocusZone.ts +10 -9
- package/src/composable/useScrollEdges.ts +70 -0
- package/src/directive/focusTrap.ts +4 -0
- package/src/directive/heightTransition.ts +6 -2
- package/src/util/animationFrameDebounce.ts +14 -0
- package/src/util/focusTrap.ts +2 -1
- package/src/util/index.ts +2 -1
- package/dist/composable/useCalendar.d.ts +0 -20
- package/dist/composable/useCalendarMonthSwitcher.d.ts +0 -10
- package/dist/composable/useCalendarYearSwitcher.d.ts +0 -8
- package/dist/composable/useClickOutside.d.ts +0 -4
- package/dist/composable/useComponentId.d.ts +0 -2
- package/dist/composable/useDebouncedRef.d.ts +0 -2
- package/dist/composable/useEventListener.d.ts +0 -2
- package/dist/composable/useFocusTrap.d.ts +0 -8
- package/dist/composable/useFocusTrapLock.d.ts +0 -2
- package/dist/composable/useFocusTrapReturn.d.ts +0 -2
- package/dist/composable/useFocusTrapSubscription.d.ts +0 -2
- package/dist/composable/useFocusZone.d.ts +0 -6
- package/dist/composable/useInView.d.ts +0 -6
- package/dist/composable/useInterval.d.ts +0 -2
- package/dist/composable/useMutationObserver.d.ts +0 -2
- package/dist/composable/useRemembered.d.ts +0 -2
- package/dist/composable/useScrollPosition.d.ts +0 -7
- package/dist/data/color.d.ts +0 -242
- package/dist/directive/focusTrap.d.ts +0 -5
- package/dist/directive/heightTransition.d.ts +0 -5
- package/dist/flux-internals.js +0 -4
- package/dist/flux-internals.js.map +0 -42
- package/dist/util/flattenVNodeTree.d.ts +0 -2
- package/dist/util/focusTrap.d.ts +0 -8
- package/dist/util/getBidirectionalFocusElement.d.ts +0 -1
- package/dist/util/getComponentName.d.ts +0 -7
- package/dist/util/getComponentProps.d.ts +0 -1
- package/dist/util/getExposedRef.d.ts +0 -2
- package/dist/util/getFocusableElement.d.ts +0 -1
- package/dist/util/getFocusableElements.d.ts +0 -1
- package/dist/util/getKeyboardFocusableElements.d.ts +0 -1
- package/dist/util/unrefTemplateElement.d.ts +0 -4
- package/dist/util/warn.d.ts +0 -1
- package/dist/util/wrapFocus.d.ts +0 -1
- package/src/composable/useClickOutside.ts +0 -38
- package/src/composable/useComponentId.ts +0 -8
- package/src/composable/useDebouncedRef.ts +0 -38
- package/src/composable/useInterval.ts +0 -23
- package/src/composable/useMutationObserver.ts +0 -38
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { n as FocusTrapListener, s as TemplateRef } from "./index-B79OP5Th.js";
|
|
2
|
+
import { ComponentPublicInstance, Ref } from "vue";
|
|
3
|
+
import { DateTime } from "luxon";
|
|
4
|
+
|
|
5
|
+
//#region src/composable/useCalendar.d.ts
|
|
6
|
+
declare function export_default$12(initialDate: DateTime, options?: UseCalendarOptions): UseCalendarReturn;
|
|
7
|
+
type UseCalendarOptions = {
|
|
8
|
+
readonly monthLength?: "short" | "long";
|
|
9
|
+
readonly weekDayLength?: "short" | "long";
|
|
10
|
+
};
|
|
11
|
+
type UseCalendarReturn = {
|
|
12
|
+
readonly isTransitioningToPast: Ref<boolean>;
|
|
13
|
+
readonly viewDate: Ref<DateTime>;
|
|
14
|
+
readonly viewDateNext: Ref<DateTime>;
|
|
15
|
+
readonly viewDatePrevious: Ref<DateTime>;
|
|
16
|
+
readonly viewMonth: Ref<string>;
|
|
17
|
+
readonly viewYear: Ref<string>;
|
|
18
|
+
readonly dates: Ref<DateTime[]>;
|
|
19
|
+
readonly days: Ref<string[]>;
|
|
20
|
+
setViewDate(date: DateTime): void;
|
|
21
|
+
nextMonth(): void;
|
|
22
|
+
previousMonth(): void;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/composable/useCalendarMonthSwitcher.d.ts
|
|
26
|
+
declare function export_default$11(currentDate: Ref<DateTime>, displayLength: "short" | "long"): UseCalendarMonthSwitcherReturn;
|
|
27
|
+
type MonthEntry = {
|
|
28
|
+
readonly date: DateTime;
|
|
29
|
+
readonly label: string;
|
|
30
|
+
};
|
|
31
|
+
type UseCalendarMonthSwitcherReturn = {
|
|
32
|
+
readonly months: Ref<MonthEntry[]>;
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/composable/useCalendarYearSwitcher.d.ts
|
|
36
|
+
declare function export_default$10(currentDate: Ref<DateTime>, limit?: number): UseCalendarYearSwitcherReturn;
|
|
37
|
+
type UseCalendarYearSwitcherReturn = {
|
|
38
|
+
readonly years: Ref<number[]>;
|
|
39
|
+
next(): void;
|
|
40
|
+
previous(): void;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/composable/useEventListener.d.ts
|
|
44
|
+
declare function export_default$9<K extends keyof HTMLElementEventMap>(elementRef: TemplateRef<HTMLElement>, eventName: K, listener: (evt: HTMLElementEventMap[K]) => any, options?: AddEventListenerOptions): void;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/composable/useInView.d.ts
|
|
47
|
+
declare function export_default$8<TElement extends HTMLElement>(containerRef: TemplateRef<TElement>, options?: UseInViewOptions): Ref<boolean>;
|
|
48
|
+
type UseInViewOptions = IntersectionObserverInit & {
|
|
49
|
+
readonly initial?: boolean;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/composable/useRemembered.d.ts
|
|
53
|
+
declare function export_default$7<T>(key: string, initialValue: T): Ref<T>;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/composable/useScrollEdges.d.ts
|
|
56
|
+
declare function export_default$6<TElement extends HTMLElement>(elementRef: TemplateRef<TElement>): UseScrollEdgesReturn;
|
|
57
|
+
type UseScrollEdgesReturn = {
|
|
58
|
+
readonly isAtStart: Ref<boolean>;
|
|
59
|
+
readonly isAtEnd: Ref<boolean>;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/composable/useScrollPosition.d.ts
|
|
63
|
+
declare function export_default$5<TElement extends HTMLElement>(elementRef?: TemplateRef<TElement>): UseScrollPositionReturn;
|
|
64
|
+
type UseScrollPositionReturn = {
|
|
65
|
+
readonly x: Ref<number>;
|
|
66
|
+
readonly y: Ref<number>;
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/composable/useFocusTrap.d.ts
|
|
70
|
+
declare function export_default$4(containerRef: TemplateRef<HTMLElement>, options?: UseFocusTrapOptions): void;
|
|
71
|
+
type UseFocusTrapOptions = {
|
|
72
|
+
attachTo?: HTMLElement | Document;
|
|
73
|
+
disable?: Ref<boolean>;
|
|
74
|
+
disableReturn?: Ref<boolean>;
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/composable/useFocusTrapLock.d.ts
|
|
78
|
+
declare function export_default$3(autoFocus?: boolean): Ref<boolean>;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/composable/useFocusTrapReturn.d.ts
|
|
81
|
+
declare function export_default$2(containerRef: TemplateRef<HTMLElement>, disabled: Ref<boolean>): void;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/composable/useFocusTrapSubscription.d.ts
|
|
84
|
+
declare function export_default$1(listener: FocusTrapListener): void;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/composable/useFocusZone.d.ts
|
|
87
|
+
type EligibleElement = ComponentPublicInstance | HTMLElement;
|
|
88
|
+
declare function export_default<TElement extends EligibleElement>(containerRef: Ref<TElement>, {
|
|
89
|
+
cycle,
|
|
90
|
+
direction
|
|
91
|
+
}?: UseFocusZoneOptions): void;
|
|
92
|
+
type UseFocusZoneOptions = {
|
|
93
|
+
readonly cycle?: boolean;
|
|
94
|
+
readonly direction?: "bidirectional" | "horizontal" | "vertical";
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { export_default$4 as a, export_default$7 as c, export_default$10 as d, export_default$11 as f, export_default$3 as i, export_default$8 as l, export_default$1 as n, export_default$5 as o, export_default$12 as p, export_default$2 as r, export_default$6 as s, export_default as t, export_default$9 as u };
|
|
98
|
+
//# sourceMappingURL=index-BhkFHXuX.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BhkFHXuX.d.ts","names":[],"sources":["../src/composable/useCalendar.ts","../src/composable/useCalendarMonthSwitcher.ts","../src/composable/useCalendarYearSwitcher.ts","../src/composable/useEventListener.ts","../src/composable/useInView.ts","../src/composable/useRemembered.ts","../src/composable/useScrollEdges.ts","../src/composable/useScrollPosition.ts","../src/composable/useFocusTrap.ts","../src/composable/useFocusTrapLock.ts","../src/composable/useFocusTrapReturn.ts","../src/composable/useFocusTrapSubscription.ts","../src/composable/useFocusZone.ts"],"mappings":";;;;;iBAC+C,iBAAA,CAEtB,WAAA,EAAa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AAA,GAAA,CAGG,GAAA,UAAa,YAAA,EAAc,CAAA,GAAI,GAAA,CAAI,CAAA;;;iBCF9B,gBAAA,kBAGS,WAAA,CAAA,CAAa,UAAA,EAAY,WAAA,CAAY,QAAA,IAAY,oBAAA;AAAA,KA6D/E,oBAAA;EAAA,SACC,SAAA,EAAW,GAAA;EAAA,SACX,OAAA,EAAS,GAAA;AAAA;;;iBClEW,gBAAA,kBAGS,WAAA,CAAA,CAAa,UAAA,GAAa,WAAA,CAAY,QAAA,IAAY,uBAAA;AAAA,KAyBhF,uBAAA;EAAA,SACC,CAAA,EAAG,GAAA;EAAA,SACH,CAAA,EAAG,GAAA;AAAA;;;iBC9BiB,gBAAA,CAKR,YAAA,EAAc,WAAA,CAAY,WAAA,GAAc,OAAA,GAAS,mBAAA;AAAA,KAoGrE,mBAAA;EACD,QAAA,GAAW,WAAA,GAAc,QAAA;EACzB,OAAA,GAAU,GAAA;EACV,aAAA,GAAgB,GAAA;AAAA;;;iBC9GK,gBAAA,CAMA,SAAA,aAA6B,GAAA;;;iBCLC,gBAAA,CAE9B,YAAA,EAAc,WAAA,CAAY,WAAA,GAAc,QAAA,EAAU,GAAA;;;iBCFpC,gBAAA,CAGd,QAAA,EAAU,iBAAA;;;KCA9B,eAAA,GAAkB,uBAAA,GAA0B,WAAA;AAAA,iBAAA,cAAA,kBAEP,eAAA,CAAA,CAAiB,YAAA,EAAc,GAAA,CAAI,QAAA;EAAY,KAAA;EAAc;AAAA,IAA8B,mBAAA;AAAA,KAsHhI,mBAAA;EAAA,SACQ,KAAA;EAAA,SACA,SAAA;AAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { a as export_default$14, c as export_default$20, d as export_default$12, f as export_default$11, i as export_default$15, l as export_default$19, n as export_default$17, o as export_default$22, p as export_default$10, r as export_default$16, s as export_default$21, t as export_default$18, u as export_default$13 } from "./index-BhkFHXuX.js";
|
|
2
|
+
import { _ as export_default, a as export_default$23, c as export_default$9, d as export_default$6, f as export_default$5, g as export_default$1, h as export_default$2, i as export_default$24, l as export_default$8, m as export_default$3, n as FocusTrapListener, o as TemplateElement, p as export_default$4, r as _default, s as TemplateRef, t as isSSR, u as export_default$7 } from "./index-B79OP5Th.js";
|
|
3
|
+
import { amber100, amber200, amber300, amber400, amber50, amber500, amber600, amber700, amber800, amber900, amber950, blue100, blue200, blue300, blue400, blue50, blue500, blue600, blue700, blue800, blue900, blue950, cyan100, cyan200, cyan300, cyan400, cyan50, cyan500, cyan600, cyan700, cyan800, cyan900, cyan950, emerald100, emerald200, emerald300, emerald400, emerald50, emerald500, emerald600, emerald700, emerald800, emerald900, emerald950, fuchsia100, fuchsia200, fuchsia300, fuchsia400, fuchsia50, fuchsia500, fuchsia600, fuchsia700, fuchsia800, fuchsia900, fuchsia950, gray100, gray200, gray300, gray400, gray50, gray500, gray600, gray700, gray800, gray900, gray950, green100, green200, green300, green400, green50, green500, green600, green700, green800, green900, green950, indigo100, indigo200, indigo300, indigo400, indigo50, indigo500, indigo600, indigo700, indigo800, indigo900, indigo950, lime100, lime200, lime300, lime400, lime50, lime500, lime600, lime700, lime800, lime900, lime950, neutral100, neutral200, neutral300, neutral400, neutral50, neutral500, neutral600, neutral700, neutral800, neutral900, neutral950, orange100, orange200, orange300, orange400, orange50, orange500, orange600, orange700, orange800, orange900, orange950, pink100, pink200, pink300, pink400, pink50, pink500, pink600, pink700, pink800, pink900, pink950, purple100, purple200, purple300, purple400, purple50, purple500, purple600, purple700, purple800, purple900, purple950, red100, red200, red300, red400, red50, red500, red600, red700, red800, red900, red950, rose100, rose200, rose300, rose400, rose50, rose500, rose600, rose700, rose800, rose900, rose950, sky100, sky200, sky300, sky400, sky50, sky500, sky600, sky700, sky800, sky900, sky950, slate100, slate200, slate300, slate400, slate50, slate500, slate600, slate700, slate800, slate900, slate950, stone100, stone200, stone300, stone400, stone50, stone500, stone600, stone700, stone800, stone900, stone950, teal100, teal200, teal300, teal400, teal50, teal500, teal600, teal700, teal800, teal900, teal950, violet100, violet200, violet300, violet400, violet50, violet500, violet600, violet700, violet800, violet900, violet950, yellow100, yellow200, yellow300, yellow400, yellow50, yellow500, yellow600, yellow700, yellow800, yellow900, yellow950, zinc100, zinc200, zinc300, zinc400, zinc50, zinc500, zinc600, zinc700, zinc800, zinc900, zinc950 } from "./data/index.js";
|
|
4
|
+
import { n as _default$1, t as _default$2 } from "./index-BRS2s2tX.js";
|
|
5
|
+
export { _default as FOCUS_TRAP_LOCKS, FocusTrapListener, TemplateElement, TemplateRef, amber100, amber200, amber300, amber400, amber50, amber500, amber600, amber700, amber800, amber900, amber950, export_default as animationFrameDebounce, blue100, blue200, blue300, blue400, blue50, blue500, blue600, blue700, blue800, blue900, blue950, cyan100, cyan200, cyan300, cyan400, cyan50, cyan500, cyan600, cyan700, cyan800, cyan900, cyan950, emerald100, emerald200, emerald300, emerald400, emerald50, emerald500, emerald600, emerald700, emerald800, emerald900, emerald950, export_default$1 as flattenVNodeTree, fuchsia100, fuchsia200, fuchsia300, fuchsia400, fuchsia50, fuchsia500, fuchsia600, fuchsia700, fuchsia800, fuchsia900, fuchsia950, export_default$2 as getBidirectionalFocusElement, export_default$3 as getComponentName, export_default$4 as getComponentProps, export_default$5 as getExposedRef, export_default$6 as getFocusableElement, export_default$7 as getFocusableElements, export_default$8 as getKeyboardFocusableElements, gray100, gray200, gray300, gray400, gray50, gray500, gray600, gray700, gray800, gray900, gray950, green100, green200, green300, green400, green50, green500, green600, green700, green800, green900, green950, indigo100, indigo200, indigo300, indigo400, indigo50, indigo500, indigo600, indigo700, indigo800, indigo900, indigo950, isSSR, lime100, lime200, lime300, lime400, lime50, lime500, lime600, lime700, lime800, lime900, lime950, neutral100, neutral200, neutral300, neutral400, neutral50, neutral500, neutral600, neutral700, neutral800, neutral900, neutral950, orange100, orange200, orange300, orange400, orange50, orange500, orange600, orange700, orange800, orange900, orange950, pink100, pink200, pink300, pink400, pink50, pink500, pink600, pink700, pink800, pink900, pink950, purple100, purple200, purple300, purple400, purple50, purple500, purple600, purple700, purple800, purple900, purple950, red100, red200, red300, red400, red50, red500, red600, red700, red800, red900, red950, rose100, rose200, rose300, rose400, rose50, rose500, rose600, rose700, rose800, rose900, rose950, sky100, sky200, sky300, sky400, sky50, sky500, sky600, sky700, sky800, sky900, sky950, slate100, slate200, slate300, slate400, slate50, slate500, slate600, slate700, slate800, slate900, slate950, stone100, stone200, stone300, stone400, stone50, stone500, stone600, stone700, stone800, stone900, stone950, teal100, teal200, teal300, teal400, teal50, teal500, teal600, teal700, teal800, teal900, teal950, export_default$9 as unrefTemplateElement, export_default$10 as useCalendar, export_default$11 as useCalendarMonthSwitcher, export_default$12 as useCalendarYearSwitcher, export_default$13 as useEventListener, export_default$14 as useFocusTrap, export_default$15 as useFocusTrapLock, export_default$16 as useFocusTrapReturn, export_default$17 as useFocusTrapSubscription, export_default$18 as useFocusZone, export_default$19 as useInView, export_default$20 as useRemembered, export_default$21 as useScrollEdges, export_default$22 as useScrollPosition, _default$1 as vFocusTrap, _default$2 as vHeightTransition, violet100, violet200, violet300, violet400, violet50, violet500, violet600, violet700, violet800, violet900, violet950, export_default$23 as warn, export_default$24 as wrapFocus, yellow100, yellow200, yellow300, yellow400, yellow50, yellow500, yellow600, yellow700, yellow800, yellow900, yellow950, zinc100, zinc200, zinc300, zinc400, zinc50, zinc500, zinc600, zinc700, zinc800, zinc900, zinc950 };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./composable-CJXC7sly.js";import{a as p,c as m,d as h,f as g,i as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E}from"./util-CwaOsSvo.js";import{amber100 as D,amber200 as O,amber300 as k,amber400 as A,amber50 as j,amber500 as M,amber600 as N,amber700 as P,amber800 as F,amber900 as I,amber950 as L,blue100 as R,blue200 as z,blue300 as B,blue400 as V,blue50 as H,blue500 as U,blue600 as W,blue700 as G,blue800 as K,blue900 as q,blue950 as J,cyan100 as Y,cyan200 as X,cyan300 as Z,cyan400 as Q,cyan50 as $,cyan500 as ee,cyan600 as te,cyan700 as ne,cyan800 as re,cyan900 as ie,cyan950 as ae,emerald100 as oe,emerald200 as se,emerald300 as ce,emerald400 as le,emerald50 as ue,emerald500 as de,emerald600 as fe,emerald700 as pe,emerald800 as me,emerald900 as he,emerald950 as ge,fuchsia100 as _e,fuchsia200 as ve,fuchsia300 as ye,fuchsia400 as be,fuchsia50 as xe,fuchsia500 as Se,fuchsia600 as Ce,fuchsia700 as we,fuchsia800 as Te,fuchsia900 as Ee,fuchsia950 as De,gray100 as Oe,gray200 as ke,gray300 as Ae,gray400 as je,gray50 as Me,gray500 as Ne,gray600 as Pe,gray700 as Fe,gray800 as Ie,gray900 as Le,gray950 as Re,green100 as ze,green200 as Be,green300 as Ve,green400 as He,green50 as Ue,green500 as We,green600 as Ge,green700 as Ke,green800 as qe,green900 as Je,green950 as Ye,indigo100 as Xe,indigo200 as Ze,indigo300 as Qe,indigo400 as $e,indigo50 as et,indigo500 as tt,indigo600 as nt,indigo700 as rt,indigo800 as it,indigo900 as at,indigo950 as ot,lime100 as st,lime200 as ct,lime300 as lt,lime400 as ut,lime50 as dt,lime500 as ft,lime600 as pt,lime700 as mt,lime800 as ht,lime900 as gt,lime950 as _t,neutral100 as vt,neutral200 as yt,neutral300 as bt,neutral400 as xt,neutral50 as St,neutral500 as Ct,neutral600 as wt,neutral700 as Tt,neutral800 as Et,neutral900 as Dt,neutral950 as Ot,orange100 as kt,orange200 as At,orange300 as jt,orange400 as Mt,orange50 as Nt,orange500 as Pt,orange600 as Ft,orange700 as It,orange800 as Lt,orange900 as Rt,orange950 as zt,pink100 as Bt,pink200 as Vt,pink300 as Ht,pink400 as Ut,pink50 as Wt,pink500 as Gt,pink600 as Kt,pink700 as qt,pink800 as Jt,pink900 as Yt,pink950 as Xt,purple100 as Zt,purple200 as Qt,purple300 as $t,purple400 as en,purple50 as tn,purple500 as nn,purple600 as rn,purple700 as an,purple800 as on,purple900 as sn,purple950 as cn,red100 as ln,red200 as un,red300 as dn,red400 as fn,red50 as pn,red500 as mn,red600 as hn,red700 as gn,red800 as _n,red900 as vn,red950 as yn,rose100 as bn,rose200 as xn,rose300 as Sn,rose400 as Cn,rose50 as wn,rose500 as Tn,rose600 as En,rose700 as Dn,rose800 as On,rose900 as kn,rose950 as An,sky100 as jn,sky200 as Mn,sky300 as Nn,sky400 as Pn,sky50 as Fn,sky500 as In,sky600 as Ln,sky700 as Rn,sky800 as zn,sky900 as Bn,sky950 as Vn,slate100 as Hn,slate200 as Un,slate300 as Wn,slate400 as Gn,slate50 as Kn,slate500 as qn,slate600 as Jn,slate700 as Yn,slate800 as Xn,slate900 as Zn,slate950 as Qn,stone100 as $n,stone200 as er,stone300 as tr,stone400 as nr,stone50 as rr,stone500 as ir,stone600 as ar,stone700 as or,stone800 as sr,stone900 as cr,stone950 as lr,teal100 as ur,teal200 as dr,teal300 as fr,teal400 as pr,teal50 as mr,teal500 as hr,teal600 as gr,teal700 as _r,teal800 as vr,teal900 as yr,teal950 as br,violet100 as xr,violet200 as Sr,violet300 as Cr,violet400 as wr,violet50 as Tr,violet500 as Er,violet600 as Dr,violet700 as Or,violet800 as kr,violet900 as Ar,violet950 as jr,yellow100 as Mr,yellow200 as Nr,yellow300 as Pr,yellow400 as Fr,yellow50 as Ir,yellow500 as Lr,yellow600 as Rr,yellow700 as zr,yellow800 as Br,yellow900 as Vr,yellow950 as Hr,zinc100 as Ur,zinc200 as Wr,zinc300 as Gr,zinc400 as Kr,zinc50 as qr,zinc500 as Jr,zinc600 as Yr,zinc700 as Xr,zinc800 as Zr,zinc900 as Qr,zinc950 as $r}from"./data/index.js";import{n as ei,t as ti}from"./directive-Dprka-AO.js";export{b as FOCUS_TRAP_LOCKS,D as amber100,O as amber200,k as amber300,A as amber400,j as amber50,M as amber500,N as amber600,P as amber700,F as amber800,I as amber900,L as amber950,y as animationFrameDebounce,R as blue100,z as blue200,B as blue300,V as blue400,H as blue50,U as blue500,W as blue600,G as blue700,K as blue800,q as blue900,J as blue950,Y as cyan100,X as cyan200,Z as cyan300,Q as cyan400,$ as cyan50,ee as cyan500,te as cyan600,ne as cyan700,re as cyan800,ie as cyan900,ae as cyan950,oe as emerald100,se as emerald200,ce as emerald300,le as emerald400,ue as emerald50,de as emerald500,fe as emerald600,pe as emerald700,me as emerald800,he as emerald900,ge as emerald950,S as flattenVNodeTree,_e as fuchsia100,ve as fuchsia200,ye as fuchsia300,be as fuchsia400,xe as fuchsia50,Se as fuchsia500,Ce as fuchsia600,we as fuchsia700,Te as fuchsia800,Ee as fuchsia900,De as fuchsia950,h as getBidirectionalFocusElement,E as getComponentName,v as getComponentProps,m as getExposedRef,w as getFocusableElement,g as getFocusableElements,x as getKeyboardFocusableElements,Oe as gray100,ke as gray200,Ae as gray300,je as gray400,Me as gray50,Ne as gray500,Pe as gray600,Fe as gray700,Ie as gray800,Le as gray900,Re as gray950,ze as green100,Be as green200,Ve as green300,He as green400,Ue as green50,We as green500,Ge as green600,Ke as green700,qe as green800,Je as green900,Ye as green950,Xe as indigo100,Ze as indigo200,Qe as indigo300,$e as indigo400,et as indigo50,tt as indigo500,nt as indigo600,rt as indigo700,it as indigo800,at as indigo900,ot as indigo950,T as isSSR,st as lime100,ct as lime200,lt as lime300,ut as lime400,dt as lime50,ft as lime500,pt as lime600,mt as lime700,ht as lime800,gt as lime900,_t as lime950,vt as neutral100,yt as neutral200,bt as neutral300,xt as neutral400,St as neutral50,Ct as neutral500,wt as neutral600,Tt as neutral700,Et as neutral800,Dt as neutral900,Ot as neutral950,kt as orange100,At as orange200,jt as orange300,Mt as orange400,Nt as orange50,Pt as orange500,Ft as orange600,It as orange700,Lt as orange800,Rt as orange900,zt as orange950,Bt as pink100,Vt as pink200,Ht as pink300,Ut as pink400,Wt as pink50,Gt as pink500,Kt as pink600,qt as pink700,Jt as pink800,Yt as pink900,Xt as pink950,Zt as purple100,Qt as purple200,$t as purple300,en as purple400,tn as purple50,nn as purple500,rn as purple600,an as purple700,on as purple800,sn as purple900,cn as purple950,ln as red100,un as red200,dn as red300,fn as red400,pn as red50,mn as red500,hn as red600,gn as red700,_n as red800,vn as red900,yn as red950,bn as rose100,xn as rose200,Sn as rose300,Cn as rose400,wn as rose50,Tn as rose500,En as rose600,Dn as rose700,On as rose800,kn as rose900,An as rose950,jn as sky100,Mn as sky200,Nn as sky300,Pn as sky400,Fn as sky50,In as sky500,Ln as sky600,Rn as sky700,zn as sky800,Bn as sky900,Vn as sky950,Hn as slate100,Un as slate200,Wn as slate300,Gn as slate400,Kn as slate50,qn as slate500,Jn as slate600,Yn as slate700,Xn as slate800,Zn as slate900,Qn as slate950,$n as stone100,er as stone200,tr as stone300,nr as stone400,rr as stone50,ir as stone500,ar as stone600,or as stone700,sr as stone800,cr as stone900,lr as stone950,ur as teal100,dr as teal200,fr as teal300,pr as teal400,mr as teal50,hr as teal500,gr as teal600,_r as teal700,vr as teal800,yr as teal900,br as teal950,p as unrefTemplateElement,c as useCalendar,r as useCalendarMonthSwitcher,n as useCalendarYearSwitcher,f as useEventListener,l as useFocusTrap,e as useFocusTrapLock,i as useFocusTrapReturn,o as useFocusTrapSubscription,d as useFocusZone,a as useInView,t as useRemembered,u as useScrollEdges,s as useScrollPosition,ei as vFocusTrap,ti as vHeightTransition,xr as violet100,Sr as violet200,Cr as violet300,wr as violet400,Tr as violet50,Er as violet500,Dr as violet600,Or as violet700,kr as violet800,Ar as violet900,jr as violet950,_ as warn,C as wrapFocus,Mr as yellow100,Nr as yellow200,Pr as yellow300,Fr as yellow400,Ir as yellow50,Lr as yellow500,Rr as yellow600,zr as yellow700,Br as yellow800,Vr as yellow900,Hr as yellow950,Ur as zinc100,Wr as zinc200,Gr as zinc300,Kr as zinc400,qr as zinc50,Jr as zinc500,Yr as zinc600,Xr as zinc700,Zr as zinc800,Qr as zinc900,$r as zinc950};
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export { default as getComponentName } from "./getComponentName";
|
|
4
|
-
export { default as getComponentProps } from "./getComponentProps";
|
|
5
|
-
export { default as getExposedRef } from "./getExposedRef";
|
|
6
|
-
export { default as getFocusableElement } from "./getFocusableElement";
|
|
7
|
-
export { default as getFocusableElements } from "./getFocusableElements";
|
|
8
|
-
export { default as getKeyboardFocusableElements } from "./getKeyboardFocusableElements";
|
|
9
|
-
export { default as unrefTemplateElement, type TemplateElement, type TemplateRef } from "./unrefTemplateElement";
|
|
10
|
-
export { default as warn } from "./warn";
|
|
11
|
-
export { default as wrapFocus } from "./wrapFocus";
|
|
12
|
-
export { default as FOCUS_TRAP_LOCKS, type FocusTrapListener } from "./focusTrap";
|
|
13
|
-
export declare const isSSR: unknown;
|
|
1
|
+
import { _ as export_default, a as export_default$10, c as export_default$9, d as export_default$6, f as export_default$5, g as export_default$1, h as export_default$2, i as export_default$11, l as export_default$8, m as export_default$3, n as FocusTrapListener, o as TemplateElement, p as export_default$4, r as _default, s as TemplateRef, t as isSSR, u as export_default$7 } from "../index-B79OP5Th.js";
|
|
2
|
+
export { _default as FOCUS_TRAP_LOCKS, FocusTrapListener, TemplateElement, TemplateRef, export_default as animationFrameDebounce, export_default$1 as flattenVNodeTree, export_default$2 as getBidirectionalFocusElement, export_default$3 as getComponentName, export_default$4 as getComponentProps, export_default$5 as getExposedRef, export_default$6 as getFocusableElement, export_default$7 as getFocusableElements, export_default$8 as getKeyboardFocusableElements, isSSR, export_default$9 as unrefTemplateElement, export_default$10 as warn, export_default$11 as wrapFocus };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"../util-CwaOsSvo.js";export{s as FOCUS_TRAP_LOCKS,o as animationFrameDebounce,l as flattenVNodeTree,n as getBidirectionalFocusElement,p as getComponentName,a as getComponentProps,t as getExposedRef,d as getFocusableElement,r as getFocusableElements,c as getKeyboardFocusableElements,f as isSSR,e as unrefTemplateElement,i as warn,u as wrapFocus};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Fragment as e,unref as t}from"vue";import{isHtmlElement as n}from"@basmilius/utils";import{camelCase as r}from"lodash-es";function i(e){if(typeof requestAnimationFrame>`u`)return(()=>{});let t=0;return(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(e)})}function a(t){let n=[];for(let r of t){if(r.type===e&&Array.isArray(r.children)){n.push(...r.children);continue}n.push(r)}return n}const o=[`a:not([disabled])`,`button:not([disabled])`,`input[type=checkbox]:not([disabled])`,`input[type=radio]:not([disabled])`,`input[type=text]:not([disabled])`,`[tabindex]:not([disabled]):not([tabindex="-1"])`].join(`,`);function s(e){return Array.from(e.querySelectorAll(o)).filter(n).filter(e=>e.offsetWidth>0||e.offsetHeight>0||e===document.activeElement)}function c(e,t,n){let r=s(e),i=r.indexOf(t);if(i===-1)return null;let a=d(r);l(a,i,n);let o=u(i,n,a,r);return o||((n===`up`||n===`left`)&&(o=r[i-1]),(n===`down`||n===`right`)&&(o=r[i+1])),o}function l(e,t,n){let r=e[t];e.forEach(e=>{let t=e.center;switch(n){case`up`:t={x:t.x,y:e.top+e.height};break;case`down`:t={x:t.x,y:e.top};break;case`left`:t={x:e.left+e.width,y:t.y};break;case`right`:t={x:e.left,y:t.y};break}e.distance=Math.sqrt((r.center.x-t.x)**2+(r.center.y-t.y)**2)})}function u(e,t,n,r){let i=n[e],a=[];switch(t){case`up`:a=n.map((t,n)=>n===e||t.top+t.height>i.top?2**53-1:t.distance);break;case`down`:a=n.map((t,n)=>n===e||t.top<i.top+i.height?2**53-1:t.distance);break;case`left`:a=n.map((t,n)=>n===e||t.left+t.width>i.left?2**53-1:t.distance);break;case`right`:a=n.map((t,n)=>n===e||t.left<i.left+i.width?2**53-1:t.distance);break}let o=a.indexOf(Math.min(...a));return a[o]===2**53-1?null:r[o]}function d(e){return e.map(e=>e.getBoundingClientRect()).map(e=>({height:e.height,width:e.width,top:e.top,left:e.left,right:e.right,bottom:e.bottom,center:{x:e.left+e.width/2,y:e.top+e.height/2},distance:0}))}function f(e){let t=`UnknownComponent`;return e.type&&e.type.__name&&(t=e.type.__name),t}function p(e){return Object.fromEntries(Object.entries(e.props??{}).map(([e,t])=>[r(e),t]))}function m(e,t){if(!e.exposed||!(t in e.exposed))throw Error(`'${t}' was not exposed by the component.`);return e.exposed[t]}function h(e,t,r=void 0){let i=s(e),a=r||document.activeElement;return!a||!n(a)?i[0]||void 0:i[i.indexOf(a)+t]||void 0}function g(e){return Array.from(e.querySelectorAll(`a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)||e.getAttribute(`disabled`)!==`true`).filter(e=>!e.hasAttribute(`aria-disabled`)||e.getAttribute(`aria-disabled`)!==`true`)}function _(e){let r=t(e);return n(r)?r:r?.$el}function v(...e){console.warn(`[Flux]`,...e)}function y(e,t,n=!1){let r=b(e),i=t.compareDocumentPosition(e),a;a=i&&Node.DOCUMENT_POSITION_PRECEDING||n?r.firstChild():r.lastChild(),(a===null?e:a).focus()}function b(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}const x=new class{get active(){return this.current?.isEnabled??!1}get current(){return this.#t[this.#t.length-1]??null}#e=[];#t=[];add(e,t,n=!0){let r={id:e,setEnabled:t,isEnabled:!0};this.current&&this.toggle(this.current,!1),this.#t.push(r),n&&(this.toggle(r,!0),this.emit())}remove(e){let t=this.#t.find(t=>t.id===e);t&&this.toggle(t,!1);let n=this.current?.id===e;this.#t=this.#t.filter(t=>t.id!==e),n&&this.current&&this.toggle(this.current,!0),this.emit()}emit(){this.#e.forEach(e=>e(this.active,this.#t))}subscribe(e){return this.#e.push(e),e(this.active,this.#t),()=>this.#e=this.#e.filter(t=>t!==e)}toggle(e,t){e.setEnabled(t),e.isEnabled=t}},S=!globalThis.document;export{_ as a,m as c,c as d,s as f,v as i,p as l,i as m,x as n,g as o,a as p,y as r,h as s,S as t,f as u};
|
|
2
|
+
//# sourceMappingURL=util-CwaOsSvo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-CwaOsSvo.js","names":["getFocusableElements","getFocusableElements","#traps","#listeners"],"sources":["../src/util/animationFrameDebounce.ts","../src/util/flattenVNodeTree.ts","../src/util/getFocusableElements.ts","../src/util/getBidirectionalFocusElement.ts","../src/util/getComponentName.ts","../src/util/getComponentProps.ts","../src/util/getExposedRef.ts","../src/util/getFocusableElement.ts","../src/util/getKeyboardFocusableElements.ts","../src/util/unrefTemplateElement.ts","../src/util/warn.ts","../src/util/wrapFocus.ts","../src/util/focusTrap.ts","../src/util/index.ts"],"sourcesContent":["import type { FluxMaybePromise } from '@flux-ui/types';\n\nexport default function <T extends () => FluxMaybePromise<void>>(fn: T): T {\n if (typeof requestAnimationFrame === 'undefined') {\n return (() => {}) as T;\n }\n\n let animationFrame = 0;\n\n return (() => {\n cancelAnimationFrame(animationFrame);\n animationFrame = requestAnimationFrame(fn);\n }) as T;\n}\n","import type { VNode } from 'vue';\nimport { Fragment } from 'vue';\n\nexport default function (vnodes: VNode[]): VNode[] {\n const flattened: VNode[] = [];\n\n for (const vnode of vnodes) {\n if (vnode.type === Fragment && Array.isArray(vnode.children)) {\n flattened.push(...(vnode.children as VNode[]));\n continue;\n }\n\n flattened.push(vnode);\n }\n\n return flattened;\n}\n","import { isHtmlElement } from '@basmilius/utils';\n\nconst FOCUSABLE_ELEMENTS = [\n 'a:not([disabled])',\n 'button:not([disabled])',\n 'input[type=checkbox]:not([disabled])',\n 'input[type=radio]:not([disabled])',\n 'input[type=text]:not([disabled])',\n '[tabindex]:not([disabled]):not([tabindex=\"-1\"])'\n].join(',');\n\nexport default function (container: HTMLElement): HTMLElement[] {\n return Array.from(container.querySelectorAll(FOCUSABLE_ELEMENTS))\n .filter(isHtmlElement)\n .filter(elm => elm.offsetWidth > 0 || elm.offsetHeight > 0 || elm === document.activeElement);\n}\n","import getFocusableElements from './getFocusableElements';\n\nexport default function (container: HTMLElement, currentElement: HTMLElement, direction: 'up' | 'down' | 'left' | 'right'): HTMLElement | null {\n const elements = getFocusableElements(container);\n const currentIndex = elements.indexOf(currentElement);\n\n if (currentIndex === -1) {\n return null;\n }\n\n const elementInfos = getBidirectionalInfoForElements(elements);\n\n calculateBidirectionalDistances(elementInfos, currentIndex, direction);\n\n let candidate = determineBidirectionalCandidate(currentIndex, direction, elementInfos, elements);\n\n if (!candidate) {\n if (direction === 'up' || direction === 'left') {\n candidate = elements[currentIndex - 1];\n }\n\n if (direction === 'down' || direction === 'right') {\n candidate = elements[currentIndex + 1];\n }\n }\n\n return candidate;\n}\n\nfunction calculateBidirectionalDistances(elementInfos: BidirectionalInfo[], currentIndex: number, direction: 'up' | 'down' | 'left' | 'right'): void {\n const current = elementInfos[currentIndex];\n\n elementInfos.forEach(r => {\n let point = r.center;\n\n switch (direction) {\n case 'up':\n point = {x: point.x, y: r.top + r.height};\n break;\n\n case 'down':\n point = {x: point.x, y: r.top};\n break;\n\n case 'left':\n point = {x: r.left + r.width, y: point.y};\n break;\n\n case 'right':\n point = {x: r.left, y: point.y};\n break;\n }\n\n r.distance = Math.sqrt(Math.pow(current.center.x - point.x, 2) + Math.pow(current.center.y - point.y, 2));\n });\n}\n\nfunction determineBidirectionalCandidate(currentIndex: number, direction: 'up' | 'down' | 'left' | 'right', elementInfos: BidirectionalInfo[], elements: HTMLElement[]): HTMLElement | null {\n const current = elementInfos[currentIndex];\n let distances: number[] = [];\n\n switch (direction) {\n case 'up':\n distances = elementInfos.map((r, index) => index === currentIndex || r.top + r.height > current.top ? Number.MAX_SAFE_INTEGER : r.distance);\n break;\n\n case 'down':\n distances = elementInfos.map((r, index) => index === currentIndex || r.top < current.top + current.height ? Number.MAX_SAFE_INTEGER : r.distance);\n break;\n\n case 'left':\n distances = elementInfos.map((r, index) => index === currentIndex || r.left + r.width > current.left ? Number.MAX_SAFE_INTEGER : r.distance);\n break;\n\n case 'right':\n distances = elementInfos.map((r, index) => index === currentIndex || r.left < current.left + current.width ? Number.MAX_SAFE_INTEGER : r.distance);\n break;\n }\n\n const candidateIndex = distances.indexOf(Math.min(...distances));\n\n if (distances[candidateIndex] !== Number.MAX_SAFE_INTEGER) {\n return elements[candidateIndex];\n }\n\n return null;\n}\n\nfunction getBidirectionalInfoForElements(elements: HTMLElement[]): BidirectionalInfo[] {\n return elements\n .map(elm => elm.getBoundingClientRect())\n .map(rect => ({\n height: rect.height,\n width: rect.width,\n top: rect.top,\n left: rect.left,\n right: rect.right,\n bottom: rect.bottom,\n center: {\n x: rect.left + rect.width / 2,\n y: rect.top + rect.height / 2\n },\n distance: 0\n }));\n}\n\ntype BidirectionalInfo = Omit<DOMRect, 'x' | 'y' | 'toJSON'> & {\n center: { x: number; y: number; };\n distance: number;\n}\n","import type { VNode } from 'vue';\n\nexport default function (component: ExtendedVNode): string {\n let name = 'UnknownComponent';\n\n if (component.type && component.type.__name) {\n name = component.type.__name;\n }\n\n return name;\n}\n\ntype ExtendedVNode = {\n readonly type: VNode['type'] & {\n readonly __name?: string;\n };\n}\n","import { camelCase } from 'lodash-es';\n\nexport default function <T extends object>(component: any): T {\n return Object.fromEntries(\n Object.entries(component.props ?? {})\n .map(([key, value]) => [camelCase(key), value])\n ) as T;\n}\n","import type { ComponentInternalInstance, Ref } from 'vue';\n\nexport default function <T>(instance: ComponentInternalInstance, key: string): Ref<T> {\n if (!instance.exposed || !(key in instance.exposed)) {\n throw new Error(`'${key}' was not exposed by the component.`);\n }\n\n return instance.exposed[key];\n}\n","import { isHtmlElement } from '@basmilius/utils';\nimport getFocusableElements from './getFocusableElements';\n\nexport default function (container: HTMLElement, direction: number, activeElement: HTMLElement | undefined = undefined): HTMLElement | undefined {\n const elements = getFocusableElements(container);\n const focusedElement = activeElement || document.activeElement;\n\n if (!focusedElement || !isHtmlElement(focusedElement))\n return elements[0] || undefined;\n\n const currentIndex = elements.indexOf(focusedElement);\n\n return elements[currentIndex + direction] || undefined;\n}\n","export default function (root: HTMLElement): HTMLElement[] {\n return Array.from<HTMLElement>(root.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"])'))\n .filter(elm => !elm.hasAttribute('disabled') || elm.getAttribute('disabled') !== 'true')\n .filter(elm => !elm.hasAttribute('aria-disabled') || elm.getAttribute('aria-disabled') !== 'true');\n}\n","import { isHtmlElement } from '@basmilius/utils';\nimport { ComponentPublicInstance, ShallowRef, unref } from 'vue';\n\nexport type TemplateElement<TElement extends HTMLElement> = ComponentPublicInstance<any, any, any, any, any, any, any, any, any, any, any, any, any, any, TElement> | TElement | null;\nexport type TemplateRef<TElement extends HTMLElement> = Readonly<ShallowRef<TemplateElement<TElement>>>;\n\nexport default function <T extends HTMLElement>(ref: TemplateRef<T>): T | null {\n const value = unref(ref);\n\n if (isHtmlElement(value)) {\n return value as T;\n }\n\n return value?.$el;\n}\n","export default function (...data: any): void {\n console.warn('[Flux]', ...data);\n}\n","export default function (elm: HTMLElement, targetElm: Element, forceFirst: boolean = false): void {\n const walker = createFocusWalker(elm);\n const position = targetElm.compareDocumentPosition(elm);\n let wrappedTarget: HTMLElement | null;\n\n if (position && Node.DOCUMENT_POSITION_PRECEDING || forceFirst) {\n wrappedTarget = walker.firstChild() as HTMLElement | null;\n } else {\n wrappedTarget = walker.lastChild() as HTMLElement | null;\n }\n\n const newFocus = wrappedTarget !== null ? wrappedTarget : elm;\n newFocus.focus();\n}\n\nfunction createFocusWalker(elm: HTMLElement): TreeWalker {\n return document.createTreeWalker(elm, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: HTMLButtonElement) => node.tabIndex >= 0 && !node.disabled ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP\n });\n}\n","class FocusTrapLockStack {\n get active(): boolean {\n return this.current?.isEnabled ?? false;\n }\n\n get current(): FocusTrap | null {\n return this.#traps[this.#traps.length - 1] ?? null;\n }\n\n #listeners: FocusTrapListener[] = [];\n #traps: FocusTrap[] = [];\n\n add(id: FocusTrap['id'], setEnabled: FocusTrap['setEnabled'], autoFocus: boolean = true): void {\n const trap: FocusTrap = {id, setEnabled, isEnabled: true};\n this.current && this.toggle(this.current, false);\n this.#traps.push(trap);\n\n if (autoFocus) {\n this.toggle(trap, true);\n this.emit();\n }\n }\n\n remove(id: FocusTrap['id']): void {\n const trap = this.#traps.find(t => t.id === id);\n trap && this.toggle(trap, false);\n\n const current = this.current;\n const wasCurrent = current?.id === id;\n this.#traps = this.#traps.filter(t => t.id !== id);\n\n wasCurrent && this.current && this.toggle(this.current, true);\n this.emit();\n }\n\n emit(): void {\n this.#listeners.forEach(listener => listener(this.active, this.#traps));\n }\n\n subscribe(listener: FocusTrapListener): () => void {\n this.#listeners.push(listener);\n listener(this.active, this.#traps);\n\n return () => this.#listeners = this.#listeners.filter(l => l !== listener);\n }\n\n toggle(trap: FocusTrap, isEnabled: boolean): void {\n trap.setEnabled(isEnabled);\n trap.isEnabled = isEnabled;\n }\n}\n\ninterface FocusTrap {\n id: string;\n isEnabled: boolean;\n\n setEnabled(isEnabled: boolean): void;\n}\n\nexport type FocusTrapListener = (isEnabled: boolean, focusTraps: FocusTrap[]) => void;\n\nconst _default: FocusTrapLockStack = new FocusTrapLockStack();\nexport default _default;\n","export { default as animationFrameDebounce } from './animationFrameDebounce';\nexport { default as flattenVNodeTree } from './flattenVNodeTree';\nexport { default as getBidirectionalFocusElement } from './getBidirectionalFocusElement';\nexport { default as getComponentName } from './getComponentName';\nexport { default as getComponentProps } from './getComponentProps';\nexport { default as getExposedRef } from './getExposedRef';\nexport { default as getFocusableElement } from './getFocusableElement';\nexport { default as getFocusableElements } from './getFocusableElements';\nexport { default as getKeyboardFocusableElements } from './getKeyboardFocusableElements';\nexport { default as unrefTemplateElement, type TemplateElement, type TemplateRef } from './unrefTemplateElement';\nexport { default as warn } from './warn';\nexport { default as wrapFocus } from './wrapFocus';\n\nexport { default as FOCUS_TRAP_LOCKS, type FocusTrapListener } from './focusTrap';\n\nexport const isSSR: boolean = !globalThis.document;\n"],"mappings":"iIAEA,SAAA,EAAiE,EAAU,CACvE,GAAI,OAAO,sBAA0B,IACjC,WAAc,IAGlB,IAAI,EAAiB,EAErB,WAAc,CACV,qBAAqB,EAAe,CACpC,EAAiB,sBAAsB,EAAG,GCRlD,SAAA,EAAyB,EAA0B,CAC/C,IAAM,EAAqB,EAAE,CAE7B,IAAK,IAAM,KAAS,EAAQ,CACxB,GAAI,EAAM,OAAS,GAAY,MAAM,QAAQ,EAAM,SAAS,CAAE,CAC1D,EAAU,KAAK,GAAI,EAAM,SAAqB,CAC9C,SAGJ,EAAU,KAAK,EAAM,CAGzB,OAAO,ECbX,MAAM,EAAqB,CACvB,oBACA,yBACA,uCACA,oCACA,mCACA,kDACH,CAAC,KAAK,IAAI,CAEX,SAAA,EAAyB,EAAuC,CAC5D,OAAO,MAAM,KAAK,EAAU,iBAAiB,EAAmB,CAAC,CAC5D,OAAO,EAAc,CACrB,OAAO,GAAO,EAAI,YAAc,GAAK,EAAI,aAAe,GAAK,IAAQ,SAAS,cAAc,CCZrG,SAAA,EAAyB,EAAwB,EAA6B,EAAiE,CAC3I,IAAM,EAAWA,EAAqB,EAAU,CAC1C,EAAe,EAAS,QAAQ,EAAe,CAErD,GAAI,IAAiB,GACjB,OAAO,KAGX,IAAM,EAAe,EAAgC,EAAS,CAE9D,EAAgC,EAAc,EAAc,EAAU,CAEtE,IAAI,EAAY,EAAgC,EAAc,EAAW,EAAc,EAAS,CAYhG,OAVK,KACG,IAAc,MAAQ,IAAc,UACpC,EAAY,EAAS,EAAe,KAGpC,IAAc,QAAU,IAAc,WACtC,EAAY,EAAS,EAAe,KAIrC,EAGX,SAAS,EAAgC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K,QAAS,GAAK,CAC7D,KAAK,MAAM,CAGf,MAAa,CACT,MAAA,EAAgB,QAAQ,GAAY,EAAS,KAAK,OAAQ,MAAA,EAAY,CAAC,CAG3E,UAAU,EAAyC,CAI/C,OAHA,MAAA,EAAgB,KAAK,EAAS,CAC9B,EAAS,KAAK,OAAQ,MAAA,EAAY,KAErB,MAAA,EAAkB,MAAA,EAAgB,OAAO,GAAK,IAAM,EAAS,CAG9E,OAAO,EAAiB,EAA0B,CAC9C,EAAK,WAAW,EAAU,CAC1B,EAAK,UAAY,ICjCZ,EAAiB,CAAC,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flux-ui/internals",
|
|
3
3
|
"description": "Contains internal workings of Flux UI packages.",
|
|
4
|
-
"version": "3.0.0-next.
|
|
4
|
+
"version": "3.0.0-next.51",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/basmilius",
|
|
8
|
-
"homepage": "https://flux.
|
|
8
|
+
"homepage": "https://flux-ui.dev",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/basmilius/flux.git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"flux"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "
|
|
25
|
+
"build": "tsdown"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
@@ -32,30 +32,43 @@
|
|
|
32
32
|
"access": "public",
|
|
33
33
|
"provenance": true
|
|
34
34
|
},
|
|
35
|
-
"main": "./dist/
|
|
36
|
-
"module": "./dist/
|
|
35
|
+
"main": "./dist/index.js",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
37
|
"types": "./dist/index.d.ts",
|
|
38
|
-
"typings": "./dist/index.d.ts",
|
|
39
38
|
"sideEffects": false,
|
|
40
39
|
"exports": {
|
|
41
40
|
".": {
|
|
42
41
|
"types": "./dist/index.d.ts",
|
|
43
|
-
"default": "./dist/
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./composable": {
|
|
45
|
+
"types": "./dist/composable/index.d.ts",
|
|
46
|
+
"default": "./dist/composable/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./data": {
|
|
49
|
+
"types": "./dist/data/index.d.ts",
|
|
50
|
+
"default": "./dist/data/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./directive": {
|
|
53
|
+
"types": "./dist/directive/index.d.ts",
|
|
54
|
+
"default": "./dist/directive/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./util": {
|
|
57
|
+
"types": "./dist/util/index.d.ts",
|
|
58
|
+
"default": "./dist/util/index.js"
|
|
44
59
|
}
|
|
45
60
|
},
|
|
46
61
|
"dependencies": {
|
|
47
|
-
"@basmilius/
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
62
|
+
"@basmilius/common": "^3.19.0",
|
|
63
|
+
"@basmilius/utils": "^3.19.0",
|
|
64
|
+
"@flux-ui/types": "3.0.0-next.51",
|
|
65
|
+
"lodash-es": "^4.18.1",
|
|
66
|
+
"luxon": "^3.7.2",
|
|
67
|
+
"vue": "^3.6.0-beta.10"
|
|
51
68
|
},
|
|
52
69
|
"devDependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"@types/
|
|
55
|
-
"
|
|
56
|
-
"lodash-es": "^4.17.21",
|
|
57
|
-
"luxon": "^3.6.1",
|
|
58
|
-
"oxc-transform": "^0.66.0",
|
|
59
|
-
"vue": "^3.5.13"
|
|
70
|
+
"@types/bun": "^1.3.13",
|
|
71
|
+
"@types/luxon": "^3.7.1",
|
|
72
|
+
"tsdown": "^0.21.10"
|
|
60
73
|
}
|
|
61
74
|
}
|
package/src/composable/index.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
export { default as useCalendar } from './useCalendar';
|
|
2
2
|
export { default as useCalendarMonthSwitcher } from './useCalendarMonthSwitcher';
|
|
3
3
|
export { default as useCalendarYearSwitcher } from './useCalendarYearSwitcher';
|
|
4
|
-
export { default as useClickOutside } from './useClickOutside';
|
|
5
|
-
export { default as useComponentId } from './useComponentId';
|
|
6
|
-
export { default as useDebouncedRef } from './useDebouncedRef';
|
|
7
4
|
export { default as useEventListener } from './useEventListener';
|
|
8
|
-
export { default as useInterval } from './useInterval';
|
|
9
5
|
export { default as useInView } from './useInView';
|
|
10
|
-
export { default as useMutationObserver } from './useMutationObserver';
|
|
11
6
|
export { default as useRemembered } from './useRemembered';
|
|
7
|
+
export { default as useScrollEdges } from './useScrollEdges';
|
|
12
8
|
export { default as useScrollPosition } from './useScrollPosition';
|
|
13
9
|
|
|
14
10
|
export { default as useFocusTrap } from './useFocusTrap';
|
|
@@ -13,7 +13,7 @@ export default function (containerRef: TemplateRef<HTMLElement>, options: UseFoc
|
|
|
13
13
|
const {disable = ref(false), disableReturn = ref(false), attachTo = null} = options;
|
|
14
14
|
const enabled = useFocusTrapLock(!disable);
|
|
15
15
|
|
|
16
|
-
useFocusTrapReturn(disableReturn);
|
|
16
|
+
useFocusTrapReturn(containerRef, disableReturn);
|
|
17
17
|
|
|
18
18
|
watch(containerRef, (_, __, onCleanup) => {
|
|
19
19
|
const container = unrefTemplateElement(containerRef);
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
1
|
+
import { type Ref, unref, watch } from 'vue';
|
|
2
|
+
import { type TemplateRef, unrefTemplateElement } from '../util';
|
|
3
3
|
|
|
4
|
-
export default function (disabled: Ref<boolean>): void {
|
|
5
|
-
|
|
4
|
+
export default function (containerRef: TemplateRef<HTMLElement>, disabled: Ref<boolean>): void {
|
|
5
|
+
watch(containerRef, (_, __, onCleanup) => {
|
|
6
|
+
const container = unrefTemplateElement(containerRef);
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
if (unref(disabled)) {
|
|
8
|
+
if (!container || unref(disabled)) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const previousTarget = document.activeElement as HTMLElement | null;
|
|
13
|
+
|
|
14
|
+
onCleanup(() => {
|
|
15
|
+
requestAnimationFrame(() => previousTarget?.focus());
|
|
16
|
+
});
|
|
13
17
|
});
|
|
14
18
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
import { getBidirectionalFocusElement, getFocusableElement, getFocusableElements
|
|
4
|
-
import useMutationObserver from './useMutationObserver';
|
|
1
|
+
import { unwrapElement, useMutationObserver } from '@basmilius/common';
|
|
2
|
+
import { type ComponentPublicInstance, type Ref, watch } from 'vue';
|
|
3
|
+
import { getBidirectionalFocusElement, getFocusableElement, getFocusableElements } from '../util';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
type EligibleElement = ComponentPublicInstance | HTMLElement;
|
|
6
|
+
|
|
7
|
+
export default function <TElement extends EligibleElement>(containerRef: Ref<TElement>, {cycle = true, direction = 'bidirectional'}: UseFocusZoneOptions = {}): void {
|
|
7
8
|
useMutationObserver(containerRef, () => updateFocus(findInitialIndex(), false));
|
|
8
9
|
|
|
9
10
|
function findInitialIndex(): number {
|
|
10
|
-
const container =
|
|
11
|
+
const container = unwrapElement(containerRef);
|
|
11
12
|
const elements = getFocusableElements(container);
|
|
12
13
|
const isActiveIndex = elements.findIndex(e => e.classList.contains('is-active'));
|
|
13
14
|
const notDisabledIndex = elements.findIndex(e => !e.hasAttribute('aria-disabled'));
|
|
@@ -24,7 +25,7 @@ export default function <TElement extends HTMLElement>(containerRef: TemplateRef
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
function updateFocus(elementIndex: number, doFocus: boolean = true): void {
|
|
27
|
-
const container =
|
|
28
|
+
const container = unwrapElement(containerRef)!;
|
|
28
29
|
const elements = getFocusableElements(container);
|
|
29
30
|
elements.forEach((elm, index) => elm.tabIndex = index === elementIndex ? 0 : -1);
|
|
30
31
|
|
|
@@ -32,7 +33,7 @@ export default function <TElement extends HTMLElement>(containerRef: TemplateRef
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
function onKeyDown(evt: KeyboardEvent): void {
|
|
35
|
-
const container =
|
|
36
|
+
const container = unwrapElement(containerRef)!;
|
|
36
37
|
const elements = getFocusableElements(container);
|
|
37
38
|
|
|
38
39
|
if (['Enter', ' '].includes(evt.key)) {
|
|
@@ -52,7 +53,7 @@ export default function <TElement extends HTMLElement>(containerRef: TemplateRef
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
watch(containerRef, (_, __, onCleanup) => {
|
|
55
|
-
const container =
|
|
56
|
+
const container = unwrapElement(containerRef);
|
|
56
57
|
|
|
57
58
|
if (!container) {
|
|
58
59
|
return;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
3
|
+
import type { TemplateRef } from '../util';
|
|
4
|
+
import { unrefTemplateElement } from '../util';
|
|
5
|
+
|
|
6
|
+
export default function <TElement extends HTMLElement>(elementRef: TemplateRef<TElement>): UseScrollEdgesReturn {
|
|
7
|
+
const isAtStart = ref(true);
|
|
8
|
+
const isAtEnd = ref(true);
|
|
9
|
+
|
|
10
|
+
watch(elementRef, (_, __, onCleanup) => {
|
|
11
|
+
const element = unrefTemplateElement(elementRef);
|
|
12
|
+
|
|
13
|
+
if (!element) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const update = (): void => {
|
|
18
|
+
const {scrollTop, scrollHeight, clientHeight} = element;
|
|
19
|
+
|
|
20
|
+
isAtStart.value = scrollTop <= 0;
|
|
21
|
+
isAtEnd.value = Math.ceil(scrollTop + clientHeight) >= scrollHeight;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const resizeObserver = new ResizeObserver(update);
|
|
25
|
+
resizeObserver.observe(element);
|
|
26
|
+
|
|
27
|
+
for (const child of Array.from(element.children)) {
|
|
28
|
+
resizeObserver.observe(child);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const mutationObserver = new MutationObserver(mutations => {
|
|
32
|
+
for (const mutation of mutations) {
|
|
33
|
+
for (const node of Array.from(mutation.addedNodes)) {
|
|
34
|
+
if (node instanceof Element) {
|
|
35
|
+
resizeObserver.observe(node);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const node of Array.from(mutation.removedNodes)) {
|
|
40
|
+
if (node instanceof Element) {
|
|
41
|
+
resizeObserver.unobserve(node);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
update();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
mutationObserver.observe(element, {childList: true});
|
|
50
|
+
element.addEventListener('scroll', update, {passive: true});
|
|
51
|
+
|
|
52
|
+
update();
|
|
53
|
+
|
|
54
|
+
onCleanup(() => {
|
|
55
|
+
element.removeEventListener('scroll', update);
|
|
56
|
+
resizeObserver.disconnect();
|
|
57
|
+
mutationObserver.disconnect();
|
|
58
|
+
});
|
|
59
|
+
}, {immediate: true});
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
isAtStart,
|
|
63
|
+
isAtEnd
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type UseScrollEdgesReturn = {
|
|
68
|
+
readonly isAtStart: Ref<boolean>;
|
|
69
|
+
readonly isAtEnd: Ref<boolean>;
|
|
70
|
+
};
|
|
@@ -34,7 +34,7 @@ class HeightTransition {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
getComputedStyle(this.#root);
|
|
37
|
-
requestAnimationFrame(() =>
|
|
37
|
+
requestAnimationFrame(() => this.#root.style.height = height);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -49,7 +49,11 @@ export default {
|
|
|
49
49
|
const heightTransition = new HeightTransition(elm);
|
|
50
50
|
heightTransition.register();
|
|
51
51
|
heightTransitions.set(elm, heightTransition);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
getSSRProps(): Record<string, unknown> {
|
|
55
|
+
return {};
|
|
52
56
|
}
|
|
53
|
-
} satisfies Directive;
|
|
57
|
+
} satisfies Directive as Directive;
|
|
54
58
|
|
|
55
59
|
const heightTransitions: WeakMap<HTMLElement, HeightTransition> = new WeakMap();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FluxMaybePromise } from '@flux-ui/types';
|
|
2
|
+
|
|
3
|
+
export default function <T extends () => FluxMaybePromise<void>>(fn: T): T {
|
|
4
|
+
if (typeof requestAnimationFrame === 'undefined') {
|
|
5
|
+
return (() => {}) as T;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let animationFrame = 0;
|
|
9
|
+
|
|
10
|
+
return (() => {
|
|
11
|
+
cancelAnimationFrame(animationFrame);
|
|
12
|
+
animationFrame = requestAnimationFrame(fn);
|
|
13
|
+
}) as T;
|
|
14
|
+
}
|
package/src/util/focusTrap.ts
CHANGED
package/src/util/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default as animationFrameDebounce } from './animationFrameDebounce';
|
|
1
2
|
export { default as flattenVNodeTree } from './flattenVNodeTree';
|
|
2
3
|
export { default as getBidirectionalFocusElement } from './getBidirectionalFocusElement';
|
|
3
4
|
export { default as getComponentName } from './getComponentName';
|
|
@@ -12,4 +13,4 @@ export { default as wrapFocus } from './wrapFocus';
|
|
|
12
13
|
|
|
13
14
|
export { default as FOCUS_TRAP_LOCKS, type FocusTrapListener } from './focusTrap';
|
|
14
15
|
|
|
15
|
-
export const isSSR = !globalThis.document;
|
|
16
|
+
export const isSSR: boolean = !globalThis.document;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DateTime } from "luxon";
|
|
2
|
-
import { type Ref } from "vue";
|
|
3
|
-
export default function(initialDate: DateTime, options?: UseCalendarOptions): UseCalendarReturn;
|
|
4
|
-
type UseCalendarOptions = {
|
|
5
|
-
readonly monthLength?: "short" | "long"
|
|
6
|
-
readonly weekDayLength?: "short" | "long"
|
|
7
|
-
};
|
|
8
|
-
type UseCalendarReturn = {
|
|
9
|
-
readonly isTransitioningToPast: Ref<boolean>
|
|
10
|
-
readonly viewDate: Ref<DateTime>
|
|
11
|
-
readonly viewDateNext: Ref<DateTime>
|
|
12
|
-
readonly viewDatePrevious: Ref<DateTime>
|
|
13
|
-
readonly viewMonth: Ref<string>
|
|
14
|
-
readonly viewYear: Ref<string>
|
|
15
|
-
readonly dates: Ref<DateTime[]>
|
|
16
|
-
readonly days: Ref<string[]>
|
|
17
|
-
setViewDate(date: DateTime): void
|
|
18
|
-
nextMonth(): void
|
|
19
|
-
previousMonth(): void
|
|
20
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DateTime } from "luxon";
|
|
2
|
-
import type { Ref } from "vue";
|
|
3
|
-
export default function(currentDate: Ref<DateTime>, displayLength: "short" | "long"): UseCalendarMonthSwitcherReturn;
|
|
4
|
-
type MonthEntry = {
|
|
5
|
-
readonly date: DateTime
|
|
6
|
-
readonly label: string
|
|
7
|
-
};
|
|
8
|
-
type UseCalendarMonthSwitcherReturn = {
|
|
9
|
-
readonly months: Ref<MonthEntry[]>
|
|
10
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { DateTime } from "luxon";
|
|
2
|
-
import type { Ref } from "vue";
|
|
3
|
-
export default function(currentDate: Ref<DateTime>, limit?: number): UseCalendarYearSwitcherReturn;
|
|
4
|
-
type UseCalendarYearSwitcherReturn = {
|
|
5
|
-
readonly years: Ref<number[]>
|
|
6
|
-
next(): void
|
|
7
|
-
previous(): void
|
|
8
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Ref } from "vue";
|
|
2
|
-
import type { TemplateRef } from "../util";
|
|
3
|
-
type Handler = ((evt: PointerEvent) => void) | ((evt: PointerEvent) => Promise<void>);
|
|
4
|
-
export default function<TElement extends HTMLElement>(elementRefs: TemplateRef<TElement> | TemplateRef<TElement>[], enabled: boolean | Ref<boolean>, onOutsideClick: Handler): void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Ref } from "vue";
|
|
2
|
-
import type { TemplateRef } from "../util";
|
|
3
|
-
export default function(containerRef: TemplateRef<HTMLElement>, options?: UseFocusTrapOptions): void;
|
|
4
|
-
type UseFocusTrapOptions = {
|
|
5
|
-
attachTo?: HTMLElement | Document
|
|
6
|
-
disable?: Ref<boolean>
|
|
7
|
-
disableReturn?: Ref<boolean>
|
|
8
|
-
};
|