@gamecrafters/base-ui 0.0.29 → 0.0.30
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/build/components/accordion/Accordion.d.ts +2 -0
- package/build/components/accordion/Accordion.types.d.ts +10 -0
- package/build/components/accordion/index.d.ts +2 -0
- package/build/components/badge/Badge.d.ts +13 -0
- package/build/components/badge/Badge.types.d.ts +13 -0
- package/build/components/badge/index.d.ts +2 -0
- package/build/components/clipboard/Clipboard.d.ts +10 -5
- package/build/components/clipboard/Clipboard.types.d.ts +38 -11
- package/build/components/clipboard/ClipboardContext.d.ts +1 -0
- package/build/components/clipboard/ClipboardCopyText.d.ts +9 -0
- package/build/components/clipboard/ClipboardIndicator.d.ts +4 -3
- package/build/components/clipboard/ClipboardLabel.d.ts +7 -0
- package/build/components/clipboard/ClipboardValueText.d.ts +7 -0
- package/build/components/clipboard/index.d.ts +58 -10
- package/build/components/clipboard/useClipboard.d.ts +3 -0
- package/build/components/collapsible/Collapsible.types.d.ts +8 -2
- package/build/components/collapsible/CollapsiblePanel.d.ts +9 -0
- package/build/components/collapsible/index.d.ts +19 -2
- package/build/components/index.d.ts +4 -1
- package/build/components/json-tree-view/JSONTreeView.d.ts +8 -0
- package/build/components/json-tree-view/JSONTreeView.types.d.ts +47 -0
- package/build/components/json-tree-view/JSONTreeViewContext.d.ts +3 -0
- package/build/components/json-tree-view/JSONTreeViewKey.d.ts +7 -0
- package/build/components/json-tree-view/JSONTreeViewNode.d.ts +7 -0
- package/build/components/json-tree-view/JSONTreeViewValue.d.ts +7 -0
- package/build/components/json-tree-view/index.d.ts +5 -0
- package/build/components/json-tree-view/jsonNodes.d.ts +5 -0
- package/build/components/json-tree-view/jsonTokens.d.ts +4 -0
- package/build/components/marquee/Marquee.d.ts +20 -6
- package/build/components/marquee/Marquee.types.d.ts +52 -19
- package/build/components/marquee/MarqueeContent.d.ts +7 -0
- package/build/components/marquee/MarqueeContext.d.ts +3 -0
- package/build/components/marquee/MarqueeEdge.d.ts +8 -0
- package/build/components/marquee/MarqueeItem.d.ts +7 -0
- package/build/components/marquee/MarqueeViewport.d.ts +7 -0
- package/build/components/marquee/index.d.ts +72 -2
- package/build/components/marquee/useMarquee.d.ts +2 -14
- package/build/components/resizable/Resizable.d.ts +7 -0
- package/build/components/resizable/Resizable.types.d.ts +23 -0
- package/build/components/{splitter → resizable}/index.d.ts +9 -9
- package/build/components/table-of-contents/TableOfContents.d.ts +14 -3
- package/build/components/table-of-contents/TableOfContents.types.d.ts +80 -21
- package/build/components/table-of-contents/TableOfContentsContent.d.ts +7 -0
- package/build/components/table-of-contents/TableOfContentsContext.d.ts +5 -0
- package/build/components/table-of-contents/TableOfContentsIndicator.d.ts +7 -0
- package/build/components/table-of-contents/TableOfContentsItem.d.ts +2 -2
- package/build/components/table-of-contents/TableOfContentsLink.d.ts +7 -0
- package/build/components/table-of-contents/TableOfContentsList.d.ts +3 -1
- package/build/components/table-of-contents/TableOfContentsNav.d.ts +8 -0
- package/build/components/table-of-contents/TableOfContentsTitle.d.ts +1 -1
- package/build/components/table-of-contents/headingScroll.d.ts +12 -0
- package/build/components/table-of-contents/index.d.ts +63 -13
- package/build/components/table-of-contents/useTableOfContents.d.ts +3 -0
- package/build/components/timer/Timer.d.ts +16 -0
- package/build/components/timer/Timer.types.d.ts +64 -0
- package/build/components/timer/TimerActionTrigger.d.ts +9 -0
- package/build/components/timer/TimerArea.d.ts +7 -0
- package/build/components/timer/TimerContext.d.ts +2 -0
- package/build/components/timer/TimerControl.d.ts +7 -0
- package/build/components/timer/TimerItem.d.ts +8 -0
- package/build/components/timer/TimerSeparator.d.ts +7 -0
- package/build/components/timer/index.d.ts +66 -0
- package/build/components/timer/timerDuration.d.ts +5 -0
- package/build/components/timer/useTimer.d.ts +3 -0
- package/build/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/build/lib/hotkey/hotkey.d.ts +48 -0
- package/build/lib/hotkey/index.d.ts +27 -0
- package/build/lib/hotkey/macos-symbol-layer.d.ts +6 -0
- package/build/lib/hotkey/macos-uppercase-layer.d.ts +6 -0
- package/build/lib/hotkey/radix-trie.d.ts +22 -0
- package/build/lib/hotkey/sequence.d.ts +39 -0
- package/build/lib/hotkey/utilities.d.ts +21 -0
- package/build/main.cjs.js +70 -70
- package/build/main.esm.js +68 -68
- package/build/styles/main.css +1 -1
- package/package.json +1 -1
- package/build/components/splitter/Splitter.d.ts +0 -7
- package/build/components/splitter/Splitter.types.d.ts +0 -23
- package/build/components/table-of-contents/TableOfContentsGroup.d.ts +0 -9
- package/build/components/table-of-contents/useTableOfContentsActiveId.d.ts +0 -2
- /package/build/components/{collapsible/CollapsibleContent.d.ts → clipboard/ClipboardControl.d.ts} +0 -0
- /package/build/components/{splitter/SplitterPanel.d.ts → resizable/ResizablePanel.d.ts} +0 -0
- /package/build/components/{splitter/SplitterResizeTrigger.d.ts → resizable/ResizableResizeTrigger.d.ts} +0 -0
- /package/build/components/{splitter/SplitterResizeTriggerIndicator.d.ts → resizable/ResizableResizeTriggerIndicator.d.ts} +0 -0
- /package/build/components/{splitter/SplitterResizeTriggerSeparator.d.ts → resizable/ResizableResizeTriggerSeparator.d.ts} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { PolymorphicProps } from "../../utilities/polymorphic";
|
|
3
|
+
import type { ButtonContentProps, ButtonSize, ButtonVariant } from "../button";
|
|
4
|
+
export type TimerUnit = "days" | "hours" | "minutes" | "seconds" | "milliseconds";
|
|
5
|
+
export type TimerStatus = "idle" | "running" | "paused" | "completed";
|
|
6
|
+
export type TimerTime = Record<TimerUnit, number>;
|
|
7
|
+
export type TimerFormattedTime = Record<TimerUnit, string>;
|
|
8
|
+
export type TimerAction = "start" | "pause" | "resume" | "reset";
|
|
9
|
+
export type TimerTickDetails = {
|
|
10
|
+
value: number;
|
|
11
|
+
time: TimerTime;
|
|
12
|
+
formattedTime: TimerFormattedTime;
|
|
13
|
+
};
|
|
14
|
+
type TimerStoreProps = {
|
|
15
|
+
countdown?: boolean;
|
|
16
|
+
startMs?: number;
|
|
17
|
+
targetMs?: number;
|
|
18
|
+
interval?: number;
|
|
19
|
+
autoStart?: boolean;
|
|
20
|
+
};
|
|
21
|
+
type TimerCallbacks = {
|
|
22
|
+
onTick?: (details: TimerTickDetails) => void;
|
|
23
|
+
onComplete?: () => void;
|
|
24
|
+
};
|
|
25
|
+
export type UseTimerProps = TimerStoreProps & TimerCallbacks;
|
|
26
|
+
export type UseTimerReturn = {
|
|
27
|
+
value: number;
|
|
28
|
+
time: TimerTime;
|
|
29
|
+
formattedTime: TimerFormattedTime;
|
|
30
|
+
status: TimerStatus;
|
|
31
|
+
running: boolean;
|
|
32
|
+
paused: boolean;
|
|
33
|
+
completed: boolean;
|
|
34
|
+
start: () => void;
|
|
35
|
+
pause: () => void;
|
|
36
|
+
resume: () => void;
|
|
37
|
+
reset: () => void;
|
|
38
|
+
};
|
|
39
|
+
type TimerOwnProps = TimerStoreProps & {
|
|
40
|
+
className?: string;
|
|
41
|
+
};
|
|
42
|
+
export type TimerProps<As extends React.ElementType = "div"> = PolymorphicProps<As, "div", TimerOwnProps> & TimerCallbacks;
|
|
43
|
+
export type TimerElementProps = TimerProps<"div">;
|
|
44
|
+
export type TimerAreaProps<As extends React.ElementType = "div"> = PolymorphicProps<As, "div", {
|
|
45
|
+
className?: string;
|
|
46
|
+
}>;
|
|
47
|
+
export type TimerItemProps<As extends React.ElementType = "div"> = PolymorphicProps<As, "div", {
|
|
48
|
+
type: TimerUnit;
|
|
49
|
+
className?: string;
|
|
50
|
+
}>;
|
|
51
|
+
export type TimerSeparatorProps<As extends React.ElementType = "div"> = PolymorphicProps<As, "div", {
|
|
52
|
+
className?: string;
|
|
53
|
+
}>;
|
|
54
|
+
export type TimerControlProps<As extends React.ElementType = "div"> = PolymorphicProps<As, "div", {
|
|
55
|
+
className?: string;
|
|
56
|
+
}>;
|
|
57
|
+
export type TimerActionTriggerProps = Omit<React.ComponentPropsWithoutRef<"button">, "type" | "value"> & ButtonContentProps & {
|
|
58
|
+
action: TimerAction;
|
|
59
|
+
variant?: ButtonVariant;
|
|
60
|
+
size?: ButtonSize;
|
|
61
|
+
className?: string;
|
|
62
|
+
};
|
|
63
|
+
export type TimerContextValue = Partial<UseTimerReturn>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TimerAction } from "./Timer.types";
|
|
3
|
+
declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "value" | "type"> & import("..").ButtonContentProps & {
|
|
4
|
+
action: TimerAction;
|
|
5
|
+
variant?: import("..").ButtonVariant;
|
|
6
|
+
size?: import("..").ButtonSize;
|
|
7
|
+
className?: string;
|
|
8
|
+
} & React.RefAttributes<any>) => React.ReactNode;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const _default: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "div" : As> & {
|
|
3
|
+
className?: string;
|
|
4
|
+
}, "as"> & {
|
|
5
|
+
as?: As | undefined;
|
|
6
|
+
} & React.RefAttributes<any>) => React.ReactNode;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const _default: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "div" : As> & {
|
|
3
|
+
className?: string;
|
|
4
|
+
}, "as"> & {
|
|
5
|
+
as?: As | undefined;
|
|
6
|
+
} & React.RefAttributes<any>) => React.ReactNode;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const _default: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "div" : As> & {
|
|
3
|
+
type: import("./Timer.types").TimerUnit;
|
|
4
|
+
className?: string;
|
|
5
|
+
}, "as"> & {
|
|
6
|
+
as?: As | undefined;
|
|
7
|
+
} & React.RefAttributes<any>) => React.ReactNode;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const _default: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "div" : As> & {
|
|
3
|
+
className?: string;
|
|
4
|
+
}, "as"> & {
|
|
5
|
+
as?: As | undefined;
|
|
6
|
+
} & React.RefAttributes<any>) => React.ReactNode;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import TimerActionTrigger from "./TimerActionTrigger";
|
|
2
|
+
import TimerArea from "./TimerArea";
|
|
3
|
+
import TimerControl from "./TimerControl";
|
|
4
|
+
import TimerItem from "./TimerItem";
|
|
5
|
+
import TimerSeparator from "./TimerSeparator";
|
|
6
|
+
export declare const Timer: (<As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "div" : As> & {
|
|
7
|
+
countdown?: boolean;
|
|
8
|
+
startMs?: number;
|
|
9
|
+
targetMs?: number;
|
|
10
|
+
interval?: number;
|
|
11
|
+
autoStart?: boolean;
|
|
12
|
+
} & {
|
|
13
|
+
className?: string;
|
|
14
|
+
}, "as"> & {
|
|
15
|
+
as?: As | undefined;
|
|
16
|
+
} & {
|
|
17
|
+
onTick?: (details: import("./Timer.types").TimerTickDetails) => void;
|
|
18
|
+
onComplete?: () => void;
|
|
19
|
+
} & import("react").RefAttributes<any>) => React.ReactNode) & {
|
|
20
|
+
Root: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "div" : As> & {
|
|
21
|
+
countdown?: boolean;
|
|
22
|
+
startMs?: number;
|
|
23
|
+
targetMs?: number;
|
|
24
|
+
interval?: number;
|
|
25
|
+
autoStart?: boolean;
|
|
26
|
+
} & {
|
|
27
|
+
className?: string;
|
|
28
|
+
}, "as"> & {
|
|
29
|
+
as?: As | undefined;
|
|
30
|
+
} & {
|
|
31
|
+
onTick?: (details: import("./Timer.types").TimerTickDetails) => void;
|
|
32
|
+
onComplete?: () => void;
|
|
33
|
+
} & import("react").RefAttributes<any>) => React.ReactNode;
|
|
34
|
+
Area: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "div" : As> & {
|
|
35
|
+
className?: string;
|
|
36
|
+
}, "as"> & {
|
|
37
|
+
as?: As | undefined;
|
|
38
|
+
} & import("react").RefAttributes<any>) => React.ReactNode;
|
|
39
|
+
Item: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "div" : As> & {
|
|
40
|
+
type: import("./Timer.types").TimerUnit;
|
|
41
|
+
className?: string;
|
|
42
|
+
}, "as"> & {
|
|
43
|
+
as?: As | undefined;
|
|
44
|
+
} & import("react").RefAttributes<any>) => React.ReactNode;
|
|
45
|
+
Separator: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "div" : As> & {
|
|
46
|
+
className?: string;
|
|
47
|
+
}, "as"> & {
|
|
48
|
+
as?: As | undefined;
|
|
49
|
+
} & import("react").RefAttributes<any>) => React.ReactNode;
|
|
50
|
+
Control: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "div" : As> & {
|
|
51
|
+
className?: string;
|
|
52
|
+
}, "as"> & {
|
|
53
|
+
as?: As | undefined;
|
|
54
|
+
} & import("react").RefAttributes<any>) => React.ReactNode;
|
|
55
|
+
ActionTrigger: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "value" | "type"> & import("..").ButtonContentProps & {
|
|
56
|
+
action: import("./Timer.types").TimerAction;
|
|
57
|
+
variant?: import("..").ButtonVariant;
|
|
58
|
+
size?: import("..").ButtonSize;
|
|
59
|
+
className?: string;
|
|
60
|
+
} & import("react").RefAttributes<any>) => React.ReactNode;
|
|
61
|
+
};
|
|
62
|
+
export { TimerArea, TimerItem, TimerSeparator, TimerControl, TimerActionTrigger };
|
|
63
|
+
export { TimerContext, useTimerContext } from "./TimerContext";
|
|
64
|
+
export { useTimer, DEFAULT_TIMER_INTERVAL } from "./useTimer";
|
|
65
|
+
export { splitTime, formatTime } from "./timerDuration";
|
|
66
|
+
export * from "./Timer.types";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import type { TimerFormattedTime, TimerTime } from "./Timer.types";
|
|
3
|
+
export declare const splitTime: (value: number) => TimerTime;
|
|
4
|
+
export declare const formatTime: (time: TimerTime) => TimerFormattedTime;
|
|
5
|
+
export declare const now: () => dayjs.Dayjs;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useIsomorphicLayoutEffect: typeof
|
|
1
|
+
import { useLayoutEffect } from "react";
|
|
2
|
+
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a keyboard event as a hotkey string, and putting a written one into the same form so
|
|
3
|
+
* that the two can be compared.
|
|
4
|
+
*/
|
|
5
|
+
import type { NormalizedSequenceString } from "./sequence";
|
|
6
|
+
declare const normalizedHotkeyBrand: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* A hotkey string with modifier keys in standard order. Build one with `eventToHotkeyString` or
|
|
9
|
+
* normalize a string via `normalizeHotkey`.
|
|
10
|
+
*
|
|
11
|
+
* A full list of key names can be found here:
|
|
12
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
|
|
13
|
+
*
|
|
14
|
+
* Examples:
|
|
15
|
+
* "s" // Lowercase character for single letters
|
|
16
|
+
* "S" // Uppercase character for shift plus a letter
|
|
17
|
+
* "1" // Number character
|
|
18
|
+
* "?" // Shift plus "/" symbol
|
|
19
|
+
* "Enter" // Enter key
|
|
20
|
+
* "ArrowUp" // Up arrow
|
|
21
|
+
* "Control+s" // Control modifier plus letter
|
|
22
|
+
* "Control+Alt+Delete" // Multiple modifiers
|
|
23
|
+
*/
|
|
24
|
+
export type NormalizedHotkeyString = NormalizedSequenceString & {
|
|
25
|
+
[normalizedHotkeyBrand]: true;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Returns a hotkey character string for keydown and keyup events.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* document.addEventListener("keydown", function (event) {
|
|
32
|
+
* if (eventToHotkeyString(event) === "h") ...
|
|
33
|
+
* })
|
|
34
|
+
*/
|
|
35
|
+
export declare function eventToHotkeyString(event: KeyboardEvent, platform?: string): NormalizedHotkeyString;
|
|
36
|
+
/**
|
|
37
|
+
* Normalizes a hotkey string before comparing it to the serialized event string produced by
|
|
38
|
+
* `eventToHotkeyString`.
|
|
39
|
+
* - Replaces the `Mod` modifier with `Meta` on mac, `Control` on other platforms.
|
|
40
|
+
* - Ensures modifiers are sorted in a consistent order
|
|
41
|
+
*
|
|
42
|
+
* @param hotkey a hotkey string
|
|
43
|
+
* @param platform NOTE: this param is only intended to be used to mock `navigator.platform` in
|
|
44
|
+
* tests. `window.navigator.platform` is used by default.
|
|
45
|
+
* @returns normalized representation of the given hotkey string
|
|
46
|
+
*/
|
|
47
|
+
export declare function normalizeHotkey(hotkey: string, platform?: string | undefined): NormalizedHotkeyString;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hotkey library
|
|
3
|
+
*
|
|
4
|
+
* Fires an element when the key, or the sequence of keys, it was installed under is typed. A field
|
|
5
|
+
* is focused and anything else is pressed, and every element dispatches a cancellable
|
|
6
|
+
* `hotkey-fire` event first so a caller can do something else instead.
|
|
7
|
+
*
|
|
8
|
+
* for (const el of document.querySelectorAll("[data-hotkey]")) {
|
|
9
|
+
* install(el);
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* The hotkey is read from the element's `data-hotkey` attribute, or handed to `install` directly.
|
|
13
|
+
* A hotkey typed inside a field is meant for the field rather than for the page, unless the field
|
|
14
|
+
* was named as the hotkey's `data-hotkey-scope`.
|
|
15
|
+
*
|
|
16
|
+
* Ported from @github/hotkey (MIT).
|
|
17
|
+
*/
|
|
18
|
+
export { eventToHotkeyString, normalizeHotkey } from "./hotkey";
|
|
19
|
+
export type { NormalizedHotkeyString } from "./hotkey";
|
|
20
|
+
export { SequenceTracker, normalizeSequence, SEQUENCE_DELIMITER } from "./sequence";
|
|
21
|
+
export type { NormalizedSequenceString } from "./sequence";
|
|
22
|
+
export { RadixTrie, Leaf } from "./radix-trie";
|
|
23
|
+
export { isFormField, fireDeterminedAction, expandHotkeyToEdges } from "./utilities";
|
|
24
|
+
/** Registers an element to be fired when its hotkey is typed */
|
|
25
|
+
export declare function install(element: HTMLElement, hotkey?: string): void;
|
|
26
|
+
/** Takes an element back off its hotkey */
|
|
27
|
+
export declare function uninstall(element: HTMLElement): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map of special symbols to the keys that would be pressed (while holding `Option`) to type them
|
|
3
|
+
* on macOS on an English layout. Most of these are standardised across most language layouts, so
|
|
4
|
+
* this will not work 100% in every language but it should work most of the time.
|
|
5
|
+
*/
|
|
6
|
+
export declare const macosSymbolLayerKeys: Record<string, string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map of "uppercase" symbols to the keys that would be pressed (while holding `Shift`) to type
|
|
3
|
+
* them on macOS on an English layout. Most of these are standardised across most language layouts,
|
|
4
|
+
* so this will not work 100% in every language but it should work most of the time.
|
|
5
|
+
*/
|
|
6
|
+
export declare const macosUppercaseLayerKeys: Record<string, string>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tree the installed hotkeys are held in. A sequence is stored a key to a level, so that what
|
|
3
|
+
* has been typed so far is a position in the tree rather than a search through everything
|
|
4
|
+
* installed: `g c` and `g i` share the `g` above them, and reaching a leaf is what fires.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Leaf<T> {
|
|
7
|
+
parent: RadixTrie<T>;
|
|
8
|
+
children: T[];
|
|
9
|
+
constructor(trie: RadixTrie<T>);
|
|
10
|
+
delete(value: T): boolean;
|
|
11
|
+
add(value: T): Leaf<T>;
|
|
12
|
+
}
|
|
13
|
+
export declare class RadixTrie<T> {
|
|
14
|
+
parent: RadixTrie<T> | null;
|
|
15
|
+
children: {
|
|
16
|
+
[key: string]: RadixTrie<T> | Leaf<T>;
|
|
17
|
+
};
|
|
18
|
+
constructor(trie?: RadixTrie<T>);
|
|
19
|
+
get(edge: string): RadixTrie<T> | Leaf<T>;
|
|
20
|
+
insert(edges: string[]): RadixTrie<T> | Leaf<T>;
|
|
21
|
+
delete(node: RadixTrie<T> | Leaf<T>): boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys pressed one after another rather than together, and the wait that holds them as one
|
|
3
|
+
* sequence before it is given up on.
|
|
4
|
+
*/
|
|
5
|
+
import type { NormalizedHotkeyString } from "./hotkey";
|
|
6
|
+
interface SequenceTrackerOptions {
|
|
7
|
+
onReset?: () => void;
|
|
8
|
+
}
|
|
9
|
+
/** What stands between one hotkey of a sequence and the next */
|
|
10
|
+
export declare const SEQUENCE_DELIMITER = " ";
|
|
11
|
+
declare const sequenceBrand: unique symbol;
|
|
12
|
+
/**
|
|
13
|
+
* Sequence of hotkeys, separated by spaces. For example, `Mod+m g`. Obtain one through the
|
|
14
|
+
* `SequenceTracker` class or by normalizing a string with `normalizeSequence`.
|
|
15
|
+
*/
|
|
16
|
+
export type NormalizedSequenceString = string & {
|
|
17
|
+
[sequenceBrand]: true;
|
|
18
|
+
};
|
|
19
|
+
export declare class SequenceTracker {
|
|
20
|
+
/**
|
|
21
|
+
* How long a part-typed sequence is held before it is given up on. Long enough to reach the
|
|
22
|
+
* next key without hurrying, short enough that a key pressed later is not read as part of
|
|
23
|
+
* something typed a moment ago
|
|
24
|
+
*/
|
|
25
|
+
static readonly CHORD_TIMEOUT = 1500;
|
|
26
|
+
private _path;
|
|
27
|
+
private timer;
|
|
28
|
+
private onReset;
|
|
29
|
+
constructor({ onReset }?: SequenceTrackerOptions);
|
|
30
|
+
get path(): readonly NormalizedHotkeyString[];
|
|
31
|
+
get sequence(): NormalizedSequenceString;
|
|
32
|
+
registerKeypress(event: KeyboardEvent): void;
|
|
33
|
+
reset(): void;
|
|
34
|
+
private killTimer;
|
|
35
|
+
private startTimer;
|
|
36
|
+
}
|
|
37
|
+
/** Puts every hotkey of a sequence into the one form, so that two sequences can be compared */
|
|
38
|
+
export declare function normalizeSequence(sequence: string): NormalizedSequenceString;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a hotkey does when it fires, and how a written hotkey is read into the edges of the tree
|
|
3
|
+
* the installed ones are held in.
|
|
4
|
+
*/
|
|
5
|
+
import type { NormalizedHotkeyString } from "./hotkey";
|
|
6
|
+
/**
|
|
7
|
+
* Whether the element is one a reader types into. A hotkey pressed inside one of these is meant
|
|
8
|
+
* for the field rather than for the page, unless the field was named as a scope.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isFormField(element: Node): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Fires the element a hotkey was installed on: a field is focused and anything else is pressed.
|
|
13
|
+
* The `hotkey-fire` event is dispatched first and can be cancelled, so a caller who wants
|
|
14
|
+
* something else to happen says so there.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fireDeterminedAction(el: HTMLElement, path: readonly NormalizedHotkeyString[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Reads a hotkey string into the sequences it stands for, each of those being the edges walked
|
|
19
|
+
* down the tree to reach it. `a b,Control+/` is two: `["a", "b"]` and `["Control+/"]`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function expandHotkeyToEdges(hotkey: string): NormalizedHotkeyString[][];
|