@rokkit/actions 1.0.0-next.119 → 1.0.0-next.121
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/delegate.svelte.d.ts +13 -0
- package/dist/dismissable.svelte.d.ts +7 -0
- package/dist/fillable.svelte.d.ts +8 -0
- package/dist/index.d.ts +11 -0
- package/dist/kbd.d.ts +44 -0
- package/dist/keyboard.svelte.d.ts +7 -0
- package/dist/lib/event-manager.d.ts +8 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/internal.d.ts +19 -0
- package/dist/navigable.svelte.d.ts +8 -0
- package/dist/navigator.svelte.d.ts +20 -0
- package/dist/packages/actions/src/delegate.svelte.d.ts +13 -0
- package/dist/packages/actions/src/dismissable.svelte.d.ts +7 -0
- package/dist/packages/actions/src/fillable.svelte.d.ts +8 -0
- package/dist/packages/actions/src/index.d.ts +11 -0
- package/dist/packages/actions/src/kbd.d.ts +44 -0
- package/dist/packages/actions/src/keyboard.svelte.d.ts +7 -0
- package/dist/packages/actions/src/lib/event-manager.d.ts +8 -0
- package/dist/packages/actions/src/lib/index.d.ts +2 -0
- package/dist/packages/actions/src/lib/internal.d.ts +19 -0
- package/dist/packages/actions/src/navigable.svelte.d.ts +8 -0
- package/dist/packages/actions/src/navigator.svelte.d.ts +20 -0
- package/dist/packages/actions/src/pannable.svelte.d.ts +6 -0
- package/dist/packages/actions/src/skinnable.svelte.d.ts +8 -0
- package/dist/packages/actions/src/swipeable.svelte.d.ts +14 -0
- package/dist/packages/actions/src/themable.svelte.d.ts +7 -0
- package/dist/packages/actions/src/types.d.ts +72 -0
- package/dist/packages/actions/src/utils.d.ts +18 -0
- package/dist/packages/bits-ui/src/index.d.ts +2 -0
- package/dist/packages/bits-ui/src/reference.d.ts +22 -0
- package/dist/packages/bits-ui/src/tree/constants.d.ts +13 -0
- package/dist/packages/bits-ui/src/tree/index.d.ts +7 -0
- package/dist/packages/bits-ui/src/tree/types.d.ts +71 -0
- package/dist/packages/core/src/calendar.d.ts +10 -0
- package/dist/packages/core/src/colors/index.d.ts +333 -0
- package/dist/packages/core/src/connector.d.ts +8 -0
- package/dist/packages/core/src/constants.d.ts +39 -0
- package/dist/packages/core/src/events.d.ts +12 -0
- package/dist/packages/core/src/field-mapper.d.ts +63 -0
- package/dist/packages/core/src/index.d.ts +13 -0
- package/dist/packages/core/src/key-event-map.d.ts +18 -0
- package/dist/packages/core/src/mapped-items.d.ts +14 -0
- package/dist/packages/core/src/mapping.d.ts +75 -0
- package/dist/packages/core/src/nested.d.ts +18 -0
- package/dist/packages/core/src/string.d.ts +59 -0
- package/dist/packages/core/src/theme.d.ts +52 -0
- package/dist/packages/core/src/ticks.d.ts +10 -0
- package/dist/packages/core/src/types.d.ts +245 -0
- package/dist/packages/core/src/utils.d.ts +70 -0
- package/dist/packages/data/src/aggregators.d.ts +2 -0
- package/dist/packages/data/src/constants.d.ts +46 -0
- package/dist/packages/data/src/convert.d.ts +10 -0
- package/dist/packages/data/src/dataset.d.ts +43 -0
- package/dist/packages/data/src/filter.d.ts +26 -0
- package/dist/packages/data/src/formatter.d.ts +10 -0
- package/dist/packages/data/src/hierarchy.d.ts +36 -0
- package/dist/packages/data/src/index.d.ts +7 -0
- package/dist/packages/data/src/infer.d.ts +80 -0
- package/dist/packages/data/src/join.d.ts +95 -0
- package/dist/packages/data/src/list.d.ts +121 -0
- package/dist/packages/data/src/metadata.d.ts +32 -0
- package/dist/packages/data/src/model.d.ts +29 -0
- package/dist/packages/data/src/parser.d.ts +31 -0
- package/dist/packages/data/src/renamer.d.ts +37 -0
- package/dist/packages/data/src/rollup.d.ts +51 -0
- package/dist/packages/data/src/types.d.ts +346 -0
- package/dist/packages/data/src/utils.d.ts +6 -0
- package/dist/packages/data/src/view.d.ts +35 -0
- package/dist/packages/helpers/src/components/index.d.ts +2 -0
- package/dist/packages/helpers/src/index.d.ts +1 -0
- package/dist/packages/helpers/src/matchers/action.d.ts +27 -0
- package/dist/packages/helpers/src/matchers/array.d.ts +10 -0
- package/dist/packages/helpers/src/matchers/dataset.d.ts +10 -0
- package/dist/packages/helpers/src/matchers/event.d.ts +10 -0
- package/dist/packages/helpers/src/matchers/index.d.ts +4 -0
- package/dist/packages/helpers/src/matchers/internal.d.ts +1 -0
- package/dist/packages/helpers/src/mocks/animate.d.ts +1 -0
- package/dist/packages/helpers/src/mocks/element.d.ts +60 -0
- package/dist/packages/helpers/src/mocks/index.d.ts +2 -0
- package/dist/packages/helpers/src/mocks/match-media.d.ts +30 -0
- package/dist/packages/helpers/src/mocks/resize-observer.d.ts +9 -0
- package/dist/packages/helpers/src/simulators/index.d.ts +1 -0
- package/dist/packages/helpers/src/simulators/touch.d.ts +40 -0
- package/dist/packages/icons/src/convert.d.ts +22 -0
- package/dist/packages/icons/src/index.d.ts +2 -0
- package/dist/packages/input/src/index.d.ts +18 -0
- package/dist/packages/states/src/constants.d.ts +27 -0
- package/dist/packages/states/src/derive.svelte.d.ts +22 -0
- package/dist/packages/states/src/hierarchy.d.ts +34 -0
- package/dist/packages/states/src/index.d.ts +5 -0
- package/dist/packages/states/src/list-controller.svelte.d.ts +70 -0
- package/dist/packages/states/src/nested-controller.svelte.d.ts +32 -0
- package/dist/packages/states/src/proxy.svelte.d.ts +43 -0
- package/dist/packages/states/src/tabular.svelte.d.ts +5 -0
- package/dist/packages/states/src/traversal.svelte.d.ts +69 -0
- package/dist/packages/states/src/vibe.svelte.d.ts +622 -0
- package/dist/packages/themes/src/constants.d.ts +6 -0
- package/dist/packages/themes/src/index.d.ts +2 -0
- package/dist/packages/tutorial/src/assimilate.d.ts +25 -0
- package/dist/packages/tutorial/src/collector.d.ts +46 -0
- package/dist/packages/tutorial/src/files.d.ts +8 -0
- package/dist/packages/tutorial/src/index.d.ts +2 -0
- package/dist/packages/tutorial/src/metadata/base.d.ts +19 -0
- package/dist/packages/tutorial/src/metadata/factory.d.ts +19 -0
- package/dist/packages/tutorial/src/metadata/index.d.ts +2 -0
- package/dist/packages/tutorial/src/metadata/javascript.d.ts +7 -0
- package/dist/packages/tutorial/src/metadata/json.d.ts +7 -0
- package/dist/packages/tutorial/src/metadata/markdown.d.ts +7 -0
- package/dist/packages/tutorial/src/metadata/registry.d.ts +26 -0
- package/dist/packages/tutorial/src/metamodel.d.ts +45 -0
- package/dist/packages/tutorial/src/tutorial.d.ts +21 -0
- package/dist/packages/tutorial/src/types.d.ts +172 -0
- package/dist/packages/tutorial/src/utils.d.ts +13 -0
- package/dist/packages/ui/src/constants.d.ts +2 -0
- package/dist/packages/ui/src/index.d.ts +42 -0
- package/dist/packages/ui/src/input/types.d.ts +9 -0
- package/dist/packages/ui/src/lib/fields.d.ts +16 -0
- package/dist/packages/ui/src/lib/form.d.ts +95 -0
- package/dist/packages/ui/src/lib/index.d.ts +6 -0
- package/dist/packages/ui/src/lib/layout.d.ts +7 -0
- package/dist/packages/ui/src/lib/nested.d.ts +48 -0
- package/dist/packages/ui/src/lib/schema.d.ts +7 -0
- package/dist/packages/ui/src/lib/select.d.ts +8 -0
- package/dist/packages/ui/src/lib/tree.d.ts +9 -0
- package/dist/packages/ui/src/types.d.ts +5 -0
- package/dist/packages/ui/src/wrappers/index.d.ts +3 -0
- package/dist/pannable.svelte.d.ts +6 -0
- package/dist/sites/learn/src/hooks.d.ts +1 -0
- package/dist/sites/learn/src/hooks.server.d.ts +2 -0
- package/dist/sites/learn/src/lib/index.d.ts +7 -0
- package/dist/sites/learn/src/lib/media.d.ts +13 -0
- package/dist/sites/learn/src/lib/paraglide/messages/en.d.ts +3 -0
- package/dist/sites/learn/src/lib/paraglide/messages/fr.d.ts +3 -0
- package/dist/sites/learn/src/lib/paraglide/messages/hi.d.ts +3 -0
- package/dist/sites/learn/src/lib/paraglide/messages.d.ts +5 -0
- package/dist/sites/learn/src/lib/paraglide/runtime.d.ts +52 -0
- package/dist/sites/learn/src/lib/stories/02-elements/01-list/03-mapping/src/data.d.ts +5 -0
- package/dist/sites/learn/src/lib/stories/02-elements/01-list/04-mixed/src/data.d.ts +13 -0
- package/dist/sites/learn/src/lib/stories/02-elements/02-tabs/04-fields/src/data.d.ts +5 -0
- package/dist/sites/learn/src/lib/stories/02-elements/02-tabs/05-using/src/data.d.ts +6 -0
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/01-intro/src/data.d.ts +4 -0
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/02-fields/src/data.d.ts +9 -0
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/03-using/src/data.d.ts +19 -0
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/04-mixed/src/data.d.ts +30 -0
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/props.d.ts +15 -0
- package/dist/sites/learn/src/lib/stories/02-elements/04-tree/01-intro/src/data.d.ts +12 -0
- package/dist/sites/learn/src/lib/stories/02-elements/06-select/02-fields/src/data.d.ts +5 -0
- package/dist/sites/learn/src/lib/stories/02-elements/07-multi-select/02-fields/src/data.d.ts +5 -0
- package/dist/sites/learn/src/lib/stories/02-elements/08-drop-down/02-fields/src/data.d.ts +5 -0
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/02-schema/src/schema.d.ts +22 -0
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/03-layout/src/layout.d.ts +19 -0
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/03-layout/src/schema.d.ts +36 -0
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/05-validation/src/schema.d.ts +34 -0
- package/dist/sites/learn/src/lib/stories/05-templates/02-editor/01-introduction/src/data.d.ts +39 -0
- package/dist/sites/learn/src/lib/stories/05-templates/02-editor/01-introduction/src/schema.d.ts +187 -0
- package/dist/sites/learn/src/lib/stories/06-layout/03-stepper/01-intro/src/data.d.ts +37 -0
- package/dist/sites/learn/src/lib/stories/06-layout/03-stepper/02-play/src/data.d.ts +37 -0
- package/dist/sites/learn/src/lib/stories/index.d.ts +1 -0
- package/dist/sites/learn/src/lib/theme.svelte.d.ts +70 -0
- package/dist/sites/learn/src/routes/(learn)/+layout.d.ts +12 -0
- package/dist/sites/learn/src/routes/(learn)/[segment]/[...slug]/+page.d.ts +8 -0
- package/dist/sites/learn/src/routes/+layout.d.ts +18 -0
- package/dist/sites/quick-start/src/hooks.d.ts +1 -0
- package/dist/sites/quick-start/src/hooks.server.d.ts +2 -0
- package/dist/sites/quick-start/src/lib/index.d.ts +1 -0
- package/dist/sites/quick-start/src/lib/paraglide/messages/en.d.ts +3 -0
- package/dist/sites/quick-start/src/lib/paraglide/messages/fr.d.ts +3 -0
- package/dist/sites/quick-start/src/lib/paraglide/messages/hi.d.ts +3 -0
- package/dist/sites/quick-start/src/lib/paraglide/messages.d.ts +5 -0
- package/dist/sites/quick-start/src/lib/paraglide/runtime.d.ts +52 -0
- package/dist/sites/quick-start/src/routes/+layout.d.ts +9 -0
- package/dist/skinnable.svelte.d.ts +8 -0
- package/dist/swipeable.svelte.d.ts +14 -0
- package/dist/themable.svelte.d.ts +7 -0
- package/dist/types.d.ts +72 -0
- package/dist/utils.d.ts +18 -0
- package/package.json +4 -5
- package/src/kbd.js +100 -98
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {string} Theme
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} Shades
|
|
6
|
+
* @property {string} 50
|
|
7
|
+
* @property {string} 100
|
|
8
|
+
* @property {string} 200
|
|
9
|
+
* @property {string} 300
|
|
10
|
+
* @property {string} 400
|
|
11
|
+
* @property {string} 500
|
|
12
|
+
* @property {string} 600
|
|
13
|
+
* @property {string} 700
|
|
14
|
+
* @property {string} 800
|
|
15
|
+
* @property {string} 900
|
|
16
|
+
* @property {string} 950
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} Palette
|
|
20
|
+
* @property {string} primary
|
|
21
|
+
* @property {string} onPrimary
|
|
22
|
+
* @property {string} secondary
|
|
23
|
+
* @property {string} onSecondary
|
|
24
|
+
* @property {string} accent
|
|
25
|
+
* @property {string} onAccent
|
|
26
|
+
* @property {string} neutral
|
|
27
|
+
* @property {string} onNeutral
|
|
28
|
+
* @property {string} error
|
|
29
|
+
* @property {string} onError
|
|
30
|
+
* @property {string} warning
|
|
31
|
+
* @property {string} onWarning
|
|
32
|
+
* @property {string} info
|
|
33
|
+
* @property {string} onInfo
|
|
34
|
+
* @property {string} success
|
|
35
|
+
* @property {string} onSuccess
|
|
36
|
+
*/
|
|
37
|
+
export class ThemeManager {
|
|
38
|
+
/** @type {string} */
|
|
39
|
+
name: string;
|
|
40
|
+
/** @type {ThemeMode} */
|
|
41
|
+
mode: ThemeMode;
|
|
42
|
+
#private;
|
|
43
|
+
}
|
|
44
|
+
export const theme: ThemeManager;
|
|
45
|
+
export type ThemeMode = "dark" | "light";
|
|
46
|
+
export type Theme = string;
|
|
47
|
+
export type Shades = {
|
|
48
|
+
/**
|
|
49
|
+
* 50
|
|
50
|
+
*/
|
|
51
|
+
"": string;
|
|
52
|
+
};
|
|
53
|
+
export type Palette = {
|
|
54
|
+
primary: string;
|
|
55
|
+
onPrimary: string;
|
|
56
|
+
secondary: string;
|
|
57
|
+
onSecondary: string;
|
|
58
|
+
accent: string;
|
|
59
|
+
onAccent: string;
|
|
60
|
+
neutral: string;
|
|
61
|
+
onNeutral: string;
|
|
62
|
+
error: string;
|
|
63
|
+
onError: string;
|
|
64
|
+
warning: string;
|
|
65
|
+
onWarning: string;
|
|
66
|
+
info: string;
|
|
67
|
+
onInfo: string;
|
|
68
|
+
success: string;
|
|
69
|
+
onSuccess: string;
|
|
70
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @type {import('./$types').LayoutLoad} */
|
|
2
|
+
export function load(): {
|
|
3
|
+
sections: never[];
|
|
4
|
+
app: {
|
|
5
|
+
name: string;
|
|
6
|
+
version: any;
|
|
7
|
+
about: string;
|
|
8
|
+
};
|
|
9
|
+
config: {
|
|
10
|
+
code: {
|
|
11
|
+
options: {
|
|
12
|
+
icon: string;
|
|
13
|
+
value: string;
|
|
14
|
+
label: string;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const reroute: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if something is an available language tag.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* if (isAvailableLanguageTag(params.locale)) {
|
|
6
|
+
* setLanguageTag(params.locale)
|
|
7
|
+
* } else {
|
|
8
|
+
* setLanguageTag("en")
|
|
9
|
+
* }
|
|
10
|
+
*
|
|
11
|
+
* @param {any} thing
|
|
12
|
+
* @returns {thing is AvailableLanguageTag}
|
|
13
|
+
*/
|
|
14
|
+
export function isAvailableLanguageTag(thing: any): thing is AvailableLanguageTag;
|
|
15
|
+
/**
|
|
16
|
+
* The project's source language tag.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* if (newlySelectedLanguageTag === sourceLanguageTag){
|
|
20
|
+
* // do nothing as the source language tag is the default language
|
|
21
|
+
* return
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export const sourceLanguageTag: "en";
|
|
25
|
+
/**
|
|
26
|
+
* The project's available language tags.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* if (availableLanguageTags.includes(userSelectedLanguageTag) === false){
|
|
30
|
+
* throw new Error("Language tag not available")
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
33
|
+
export const availableLanguageTags: readonly ["en", "hi", "fr"];
|
|
34
|
+
/**
|
|
35
|
+
* Get the current language tag.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* if (languageTag() === "de"){
|
|
39
|
+
* console.log("Germany 🇩🇪")
|
|
40
|
+
* } else if (languageTag() === "nl"){
|
|
41
|
+
* console.log("Netherlands 🇳🇱")
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* @type {() => AvailableLanguageTag}
|
|
45
|
+
*/
|
|
46
|
+
export let languageTag: () => AvailableLanguageTag;
|
|
47
|
+
export function setLanguageTag(tag: AvailableLanguageTag | (() => AvailableLanguageTag)): void;
|
|
48
|
+
export function onSetLanguageTag(fn: (languageTag: AvailableLanguageTag) => void): void;
|
|
49
|
+
/**
|
|
50
|
+
* A language tag that is available in the project.
|
|
51
|
+
*/
|
|
52
|
+
export type AvailableLanguageTag = (typeof availableLanguageTags)[number];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies theme variables to an element
|
|
3
|
+
* @param {HTMLElement} node - Element to apply variables to
|
|
4
|
+
* @param {Object.<string, string>} variables - CSS variables and their values
|
|
5
|
+
*/
|
|
6
|
+
export function skinnable(node: HTMLElement, variables: {
|
|
7
|
+
[x: string]: string;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A svelte action function that captures swipe actions and emits event for corresponding movements.
|
|
3
|
+
*
|
|
4
|
+
* @param {HTMLElement} node
|
|
5
|
+
* @param {import(./types).SwipeableOptions} options
|
|
6
|
+
* @returns {import('./types').SvelteActionReturn}
|
|
7
|
+
*/
|
|
8
|
+
export function swipeable(node: HTMLElement, options?: {
|
|
9
|
+
horizontal: boolean;
|
|
10
|
+
vertical: boolean;
|
|
11
|
+
threshold: number;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
minSpeed: number;
|
|
14
|
+
}): import("./types").SvelteActionReturn;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update the theme attributes when the state changes.
|
|
3
|
+
*
|
|
4
|
+
* @param {HTMLElement} root
|
|
5
|
+
* @param {import('./types.js').ThemableConfig} options - Custom key mappings
|
|
6
|
+
*/
|
|
7
|
+
export function themable(root: HTMLElement, options: import("./types.js").ThemableConfig): void;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type EventMapping = {
|
|
2
|
+
/**
|
|
3
|
+
* - The event name
|
|
4
|
+
*/
|
|
5
|
+
event: string;
|
|
6
|
+
/**
|
|
7
|
+
* - The keys that trigger the event
|
|
8
|
+
*/
|
|
9
|
+
keys?: string[] | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* - The pattern that triggers the event
|
|
12
|
+
*/
|
|
13
|
+
pattern?: RegExp | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type KeyboardConfig = {
|
|
16
|
+
[x: string]: RegExp | string[];
|
|
17
|
+
};
|
|
18
|
+
export type Direction = "vertical" | "horizontal";
|
|
19
|
+
export type NavigatorOptions = {
|
|
20
|
+
/**
|
|
21
|
+
* - Whether the navigator is enabled
|
|
22
|
+
*/
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* - Whether the navigator is vertical or horizontal
|
|
26
|
+
*/
|
|
27
|
+
direction: Direction;
|
|
28
|
+
/**
|
|
29
|
+
* - Whether the navigator supports multiple selections
|
|
30
|
+
*/
|
|
31
|
+
multiselect: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type DataWrapper = {
|
|
34
|
+
moveNext: Function;
|
|
35
|
+
movePrev: Function;
|
|
36
|
+
moveFirst: Function;
|
|
37
|
+
moveLast: Function;
|
|
38
|
+
expand: Function;
|
|
39
|
+
collapse: Function;
|
|
40
|
+
select: Function;
|
|
41
|
+
toggleExpansion: Function;
|
|
42
|
+
};
|
|
43
|
+
export type NavigatorActions = {
|
|
44
|
+
next: Function;
|
|
45
|
+
prev: Function;
|
|
46
|
+
first: Function;
|
|
47
|
+
last: Function;
|
|
48
|
+
expand: Function;
|
|
49
|
+
collapse: Function;
|
|
50
|
+
select: Function;
|
|
51
|
+
};
|
|
52
|
+
export type NavigatorConfig = {
|
|
53
|
+
/**
|
|
54
|
+
* - Whether the navigator is enabled
|
|
55
|
+
*/
|
|
56
|
+
wrapper: Navigator;
|
|
57
|
+
/**
|
|
58
|
+
* - Whether the navigator is vertical or horizontal
|
|
59
|
+
*/
|
|
60
|
+
options: NavigatorOptions;
|
|
61
|
+
};
|
|
62
|
+
export type Controller = {
|
|
63
|
+
moveNext: Function;
|
|
64
|
+
movePrev: Function;
|
|
65
|
+
moveFirst: Function;
|
|
66
|
+
moveLast: Function;
|
|
67
|
+
expand?: Function | undefined;
|
|
68
|
+
collapse?: Function | undefined;
|
|
69
|
+
select: Function;
|
|
70
|
+
extendSelection: Function;
|
|
71
|
+
toggleExpansion?: Function | undefined;
|
|
72
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the closest ancestor of the given element that has the given attribute.
|
|
3
|
+
*
|
|
4
|
+
* @param {HTMLElement} element
|
|
5
|
+
* @param {string} attribute
|
|
6
|
+
* @returns {HTMLElement|null}
|
|
7
|
+
*/
|
|
8
|
+
export function getClosestAncestorWithAttribute(element: HTMLElement, attribute: string): HTMLElement | null;
|
|
9
|
+
export function handleAction(actions: any, event: any): void;
|
|
10
|
+
/**
|
|
11
|
+
* Finds and returns an index path based on data-path attribute
|
|
12
|
+
*
|
|
13
|
+
* @param {MouseEvent} event
|
|
14
|
+
* @returns {number[]|null} null or index path array
|
|
15
|
+
*/
|
|
16
|
+
export function getPathFromEvent(event: MouseEvent): number[] | null;
|
|
17
|
+
export function getEventForKey(keyMapping: import("./types.js").KeyboardConfig, key: string): string | null;
|
|
18
|
+
export function getClickAction(event: MouseEvent): string;
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/actions",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.121",
|
|
4
4
|
"description": "Contains generic actions that can be used in various components.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"main": "index.js",
|
|
8
|
-
"module": "src/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
7
|
"type": "module",
|
|
11
8
|
"publishConfig": {
|
|
12
9
|
"access": "public"
|
|
@@ -18,7 +15,9 @@
|
|
|
18
15
|
},
|
|
19
16
|
"files": [
|
|
20
17
|
"src/**/*.js",
|
|
21
|
-
"
|
|
18
|
+
"dist/**/*.d.ts",
|
|
19
|
+
"README.md",
|
|
20
|
+
"package.json"
|
|
22
21
|
],
|
|
23
22
|
"exports": {
|
|
24
23
|
"./src": "./src",
|
package/src/kbd.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* @returns {Object} Object mapping arrow keys to movement handlers
|
|
6
6
|
*/
|
|
7
7
|
function getHorizontalMovementActions(handlers, dir = 'ltr') {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
return dir === 'rtl'
|
|
9
|
+
? { ArrowRight: handlers.previous, ArrowLeft: handlers.next }
|
|
10
|
+
: { ArrowLeft: handlers.previous, ArrowRight: handlers.next }
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ function getHorizontalMovementActions(handlers, dir = 'ltr') {
|
|
|
16
16
|
* @returns {Object} Object mapping arrow keys to movement handlers
|
|
17
17
|
*/
|
|
18
18
|
function getVerticalMovementActions(handlers) {
|
|
19
|
-
|
|
19
|
+
return { ArrowUp: handlers.previous, ArrowDown: handlers.next }
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -25,7 +25,7 @@ function getVerticalMovementActions(handlers) {
|
|
|
25
25
|
* @returns {Object} Object mapping arrow keys to expand/collapse handlers
|
|
26
26
|
*/
|
|
27
27
|
function getHorizontalExpandActions(handlers) {
|
|
28
|
-
|
|
28
|
+
return { ArrowUp: handlers.collapse, ArrowDown: handlers.expand }
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -35,9 +35,9 @@ function getHorizontalExpandActions(handlers) {
|
|
|
35
35
|
* @returns {Object} Object mapping arrow keys to expand/collapse handlers
|
|
36
36
|
*/
|
|
37
37
|
function getVerticalExpandActions(handlers, dir = 'ltr') {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
return dir === 'rtl'
|
|
39
|
+
? { ArrowRight: handlers.collapse, ArrowLeft: handlers.expand }
|
|
40
|
+
: { ArrowLeft: handlers.collapse, ArrowRight: handlers.expand }
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -46,18 +46,18 @@ function getVerticalExpandActions(handlers, dir = 'ltr') {
|
|
|
46
46
|
* @returns {Object} Object mapping keys to selection handlers
|
|
47
47
|
*/
|
|
48
48
|
function getCommonActions(handlers) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
return {
|
|
50
|
+
Enter: handlers.select,
|
|
51
|
+
' ': handlers.select
|
|
52
|
+
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// Default navigation options
|
|
56
56
|
export const defaultNavigationOptions = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
orientation: 'vertical',
|
|
58
|
+
dir: 'ltr',
|
|
59
|
+
nested: false,
|
|
60
|
+
enabled: true
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -67,29 +67,29 @@ export const defaultNavigationOptions = {
|
|
|
67
67
|
* @returns {Object} Object mapping key presses to handler functions
|
|
68
68
|
*/
|
|
69
69
|
export function getKeyboardActions(options, handlers) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
const { orientation, dir, nested, enabled } = { ...defaultNavigationOptions, ...options }
|
|
71
|
+
|
|
72
|
+
if (!enabled) return {}
|
|
73
|
+
|
|
74
|
+
const common = getCommonActions(handlers)
|
|
75
|
+
|
|
76
|
+
// Determine movement actions based on orientation
|
|
77
|
+
const isHorizontal = orientation === 'horizontal'
|
|
78
|
+
const movement = isHorizontal
|
|
79
|
+
? getHorizontalMovementActions(handlers, dir)
|
|
80
|
+
: getVerticalMovementActions(handlers)
|
|
81
|
+
|
|
82
|
+
// If not nested, we don't need expand/collapse actions
|
|
83
|
+
if (!nested) {
|
|
84
|
+
return { ...common, ...movement }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Determine expand/collapse actions based on orientation
|
|
88
|
+
const expandCollapse = isHorizontal
|
|
89
|
+
? getHorizontalExpandActions(handlers)
|
|
90
|
+
: getVerticalExpandActions(handlers, dir)
|
|
91
|
+
|
|
92
|
+
return { ...common, ...movement, ...expandCollapse }
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
@@ -97,50 +97,52 @@ export function getKeyboardActions(options, handlers) {
|
|
|
97
97
|
*
|
|
98
98
|
* @param {Object} options - Navigation options
|
|
99
99
|
* @param {string} options.orientation - Whether navigation is horizontal or vertical
|
|
100
|
-
* @param {string} options.dir - Text direction ('ltr' or 'rtl')
|
|
100
|
+
* @param {string} options.dir - Text direction ('ltr' or 'rtl')
|
|
101
101
|
* @param {boolean} options.nested - Whether navigation is nested
|
|
102
102
|
* @returns {Object} Mapping of keys to actions
|
|
103
103
|
*/
|
|
104
104
|
export function createKeyboardActionMap(options) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
105
|
+
const { orientation, dir, nested } = options
|
|
106
|
+
const isHorizontal = orientation === 'horizontal'
|
|
107
|
+
|
|
108
|
+
// Define movement actions based on orientation and direction
|
|
109
|
+
let movementActions = {}
|
|
110
|
+
if (isHorizontal) {
|
|
111
|
+
movementActions =
|
|
112
|
+
dir === 'rtl'
|
|
113
|
+
? { ArrowRight: 'previous', ArrowLeft: 'next' }
|
|
114
|
+
: { ArrowLeft: 'previous', ArrowRight: 'next' }
|
|
115
|
+
} else {
|
|
116
|
+
movementActions = { ArrowUp: 'previous', ArrowDown: 'next' }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Define expand/collapse actions for nested option
|
|
120
|
+
let nestedActions = {}
|
|
121
|
+
if (nested) {
|
|
122
|
+
if (isHorizontal) {
|
|
123
|
+
nestedActions = { ArrowUp: 'collapse', ArrowDown: 'expand' }
|
|
124
|
+
} else {
|
|
125
|
+
nestedActions =
|
|
126
|
+
dir === 'rtl'
|
|
127
|
+
? { ArrowRight: 'collapse', ArrowLeft: 'expand' }
|
|
128
|
+
: { ArrowLeft: 'collapse', ArrowRight: 'expand' }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Common actions regardless of options
|
|
133
|
+
const commonActions = {
|
|
134
|
+
Enter: 'select',
|
|
135
|
+
' ': 'select',
|
|
136
|
+
Home: 'first',
|
|
137
|
+
End: 'last'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Combine all possible actions
|
|
141
|
+
return {
|
|
142
|
+
...commonActions,
|
|
143
|
+
...movementActions,
|
|
144
|
+
...nestedActions
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
/**
|
|
@@ -151,12 +153,12 @@ export function createKeyboardActionMap(options) {
|
|
|
151
153
|
* @returns {Object} Mapping of keys to actions
|
|
152
154
|
*/
|
|
153
155
|
export function createModifierKeyboardActionMap(options) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
const isHorizontal = options.orientation === 'horizontal'
|
|
157
|
+
const common = { ' ': 'extend', Home: 'first', End: 'last' }
|
|
158
|
+
const directional = isHorizontal
|
|
159
|
+
? { ArrowLeft: 'first', ArrowRight: 'last' }
|
|
160
|
+
: { ArrowUp: 'first', ArrowDown: 'last' }
|
|
161
|
+
return { ...common, ...directional }
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
/**
|
|
@@ -166,20 +168,20 @@ export function createModifierKeyboardActionMap(options) {
|
|
|
166
168
|
* @returns {string|null} The action to perform, or null if no action is defined
|
|
167
169
|
*/
|
|
168
170
|
export function getKeyboardAction(event, options = {}) {
|
|
169
|
-
|
|
171
|
+
const { key, ctrlKey, metaKey } = event
|
|
170
172
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
// Use updated options with defaults
|
|
174
|
+
const mergedOptions = { ...defaultNavigationOptions, ...options }
|
|
173
175
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
// Check for modifier keys first (highest priority)
|
|
177
|
+
if (ctrlKey || metaKey) {
|
|
178
|
+
const modifierMap = createModifierKeyboardActionMap(mergedOptions)
|
|
179
|
+
return modifierMap[key] || null
|
|
180
|
+
}
|
|
179
181
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
// Get the action map based on options
|
|
183
|
+
const actionMap = createKeyboardActionMap(mergedOptions)
|
|
182
184
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
185
|
+
// Return the action or null if no matching key
|
|
186
|
+
return actionMap[key] || null
|
|
187
|
+
}
|