@leve-ui/tree-view 0.0.0-stage → 0.0.0
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/LICENSE +21 -0
- package/lib/index.qwik.cjs +4 -0
- package/lib/index.qwik.mjs +4 -0
- package/lib/tree-view-context.qwik.cjs +153 -0
- package/lib/tree-view-context.qwik.mjs +153 -0
- package/lib/tree-view-group.qwik.cjs +34 -0
- package/lib/tree-view-group.qwik.mjs +34 -0
- package/lib/tree-view-item-indicator.qwik.cjs +25 -0
- package/lib/tree-view-item-indicator.qwik.mjs +25 -0
- package/lib/tree-view-item-trigger.qwik.cjs +42 -0
- package/lib/tree-view-item-trigger.qwik.mjs +42 -0
- package/lib/tree-view-item.qwik.cjs +141 -0
- package/lib/tree-view-item.qwik.mjs +141 -0
- package/lib/tree-view-root.qwik.cjs +195 -0
- package/lib/tree-view-root.qwik.mjs +195 -0
- package/lib/tree-view.qwik.cjs +12 -0
- package/lib/tree-view.qwik.mjs +12 -0
- package/lib-types/index.d.ts +6 -0
- package/lib-types/tree-view-context.d.ts +88 -0
- package/lib-types/tree-view-group.d.ts +12 -0
- package/lib-types/tree-view-item-indicator.d.ts +10 -0
- package/lib-types/tree-view-item-trigger.d.ts +12 -0
- package/lib-types/tree-view-item.d.ts +31 -0
- package/lib-types/tree-view-root.d.ts +43 -0
- package/lib-types/tree-view.d.ts +5 -0
- package/package.json +58 -3
- package/README.md +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TreeViewGroup } from "./tree-view-group.qwik.mjs";
|
|
2
|
+
import { TreeViewItem } from "./tree-view-item.qwik.mjs";
|
|
3
|
+
import { TreeViewItemIndicator } from "./tree-view-item-indicator.qwik.mjs";
|
|
4
|
+
import { TreeViewItemTrigger } from "./tree-view-item-trigger.qwik.mjs";
|
|
5
|
+
import { TreeViewRoot } from "./tree-view-root.qwik.mjs";
|
|
6
|
+
export {
|
|
7
|
+
TreeViewGroup as Group,
|
|
8
|
+
TreeViewItem as Item,
|
|
9
|
+
TreeViewItemIndicator as ItemIndicator,
|
|
10
|
+
TreeViewItemTrigger as ItemTrigger,
|
|
11
|
+
TreeViewRoot as Root
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as TreeView from './tree-view';
|
|
2
|
+
export type { TreeViewGroupProps } from './tree-view-group';
|
|
3
|
+
export type { TreeViewItemProps } from './tree-view-item';
|
|
4
|
+
export type { TreeViewItemIndicatorProps } from './tree-view-item-indicator';
|
|
5
|
+
export type { TreeViewItemTriggerProps } from './tree-view-item-trigger';
|
|
6
|
+
export type { TreeViewRootProps } from './tree-view-root';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type QRL, type ReadonlySignal, type Signal } from '@builder.io/qwik';
|
|
2
|
+
export declare const ROOT_SELECTOR = "[data-leve-tree-view]";
|
|
3
|
+
export declare const ITEM_SELECTOR = "[data-leve-tree-view-item]";
|
|
4
|
+
export declare const GROUP_SELECTOR = "[data-leve-tree-view-group]";
|
|
5
|
+
/** An item registered with a TreeView, used only to pick the initial tab stop during SSR. */
|
|
6
|
+
export interface TreeViewItemRegistration {
|
|
7
|
+
value: string;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
visible: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function isTreeItemAvailable(item: TreeViewItemRegistration): boolean;
|
|
12
|
+
export interface TreeViewContext {
|
|
13
|
+
selectedValues: ReadonlySignal<string[]>;
|
|
14
|
+
expandedValues: ReadonlySignal<string[]>;
|
|
15
|
+
multiple: ReadonlySignal<boolean>;
|
|
16
|
+
disabled: ReadonlySignal<boolean>;
|
|
17
|
+
focusedValue: Signal<string | null>;
|
|
18
|
+
items: TreeViewItemRegistration[];
|
|
19
|
+
selectItem$: QRL<(value: string) => Promise<void>>;
|
|
20
|
+
toggleExpanded$: QRL<(value: string) => Promise<void>>;
|
|
21
|
+
expandItem$: QRL<(value: string) => Promise<void>>;
|
|
22
|
+
collapseItem$: QRL<(value: string) => Promise<void>>;
|
|
23
|
+
expandItems$: QRL<(values: string[]) => Promise<void>>;
|
|
24
|
+
}
|
|
25
|
+
export declare const treeViewContextId: import("@builder.io/qwik").ContextId<TreeViewContext>;
|
|
26
|
+
export interface TreeViewItemContext {
|
|
27
|
+
value: string;
|
|
28
|
+
branch: ReadonlySignal<boolean>;
|
|
29
|
+
expanded: ReadonlySignal<boolean>;
|
|
30
|
+
selected: ReadonlySignal<boolean>;
|
|
31
|
+
disabled: ReadonlySignal<boolean>;
|
|
32
|
+
visible: ReadonlySignal<boolean>;
|
|
33
|
+
depth: ReadonlySignal<number>;
|
|
34
|
+
}
|
|
35
|
+
export declare const treeViewItemContextId: import("@builder.io/qwik").ContextId<TreeViewItemContext>;
|
|
36
|
+
export interface TreeViewGroupContext {
|
|
37
|
+
depth: ReadonlySignal<number>;
|
|
38
|
+
visible: ReadonlySignal<boolean>;
|
|
39
|
+
disabled: ReadonlySignal<boolean>;
|
|
40
|
+
}
|
|
41
|
+
export declare const treeViewGroupContextId: import("@builder.io/qwik").ContextId<TreeViewGroupContext>;
|
|
42
|
+
/**
|
|
43
|
+
* Sorts registered items in DOM order within the enclosing TreeView root (`adr/0035`).
|
|
44
|
+
*/
|
|
45
|
+
export declare function sortTreeViewItems(el: Element | null | undefined, items: TreeViewItemRegistration[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Returns `true` when no ancestor container between `item` and `root` is hidden or collapsed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isTreeItemVisible(item: HTMLElement, root: Element): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Returns all visible tree items belonging to `root` in DOM order.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getVisibleTreeItems(root: Element): HTMLElement[];
|
|
54
|
+
/**
|
|
55
|
+
* Returns the direct child `TreeView.Group` element owned by `item`, if any.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getDirectChildGroup(item: Element): HTMLElement | null;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the direct child `TreeView.Item` elements owned by `group` in DOM order.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getDirectChildItems(group: Element): HTMLElement[];
|
|
62
|
+
/**
|
|
63
|
+
* Extracts the accessible label of a tree item for typeahead matching,
|
|
64
|
+
* ignoring nested groups and decorative `aria-hidden="true"` indicators.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getTreeItemLabel(item: HTMLElement): string;
|
|
67
|
+
/**
|
|
68
|
+
* Updates roving `tabIndex` across all items in `root` so only `target` has `tabIndex={0}`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function setTreeTabStop(root: Element, target: HTMLElement): void;
|
|
71
|
+
/**
|
|
72
|
+
* Updates roving `tabIndex`, syncs `focusedValue`, and focuses `target`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function focusTreeItem(root: Element, target: HTMLElement, focusedValue?: Signal<string | null>): void;
|
|
75
|
+
/**
|
|
76
|
+
* Moves roving focus among visible enabled tree items using exact element identity
|
|
77
|
+
* (avoiding ancestor-containment ambiguity on nested `treeitem` elements).
|
|
78
|
+
*/
|
|
79
|
+
export declare function moveTreeRovingFocus(event: KeyboardEvent, root: Element, visibleItems: readonly HTMLElement[], currentItem: HTMLElement, focusedValue: Signal<string | null>): HTMLElement | null;
|
|
80
|
+
/**
|
|
81
|
+
* Clears the typeahead buffer associated with `root`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resetTreeTypeahead(root: Element): void;
|
|
84
|
+
/**
|
|
85
|
+
* Moves focus to the next visible enabled tree item matching typed characters,
|
|
86
|
+
* using exact element identity for nested tree items.
|
|
87
|
+
*/
|
|
88
|
+
export declare function moveTreeTypeaheadFocus(event: KeyboardEvent, root: Element, visibleItems: readonly HTMLElement[], currentItem: HTMLElement, focusedValue: Signal<string | null>): HTMLElement | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type TreeViewGroupProps = PropsOf<'ul'>;
|
|
3
|
+
/**
|
|
4
|
+
* Container for child tree items (`<ul role="group">`) nested inside a branch `TreeView.Item`.
|
|
5
|
+
*
|
|
6
|
+
* Hidden via the `hidden` attribute while its parent item is collapsed, and increments
|
|
7
|
+
* the nesting depth in context so child items compute `aria-level` and `data-depth`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TreeViewGroup: import("@builder.io/qwik").Component<{
|
|
10
|
+
compact?: boolean | undefined;
|
|
11
|
+
type?: string | undefined;
|
|
12
|
+
} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLUListElement>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type TreeViewItemIndicatorProps = PropsOf<'span'>;
|
|
3
|
+
/**
|
|
4
|
+
* Decorative indicator (`<span aria-hidden="true">`) inside a `TreeView.ItemTrigger`,
|
|
5
|
+
* typically used for a branch chevron or selection checkmark.
|
|
6
|
+
*
|
|
7
|
+
* Exposes `data-state` (`"open"` / `"closed"` on branches, `"checked"` / `"unchecked"` on leaves)
|
|
8
|
+
* and `data-selected` for styling.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TreeViewItemIndicator: import("@builder.io/qwik").Component<{} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type TreeViewItemTriggerProps = PropsOf<'div'>;
|
|
3
|
+
/**
|
|
4
|
+
* Clickable row trigger inside a `TreeView.Item` (`<div>`).
|
|
5
|
+
*
|
|
6
|
+
* Focuses the enclosing `treeitem`, updates selection, and toggles expansion when the item is a branch.
|
|
7
|
+
* Kept as a `<div>` rather than `<button>` so the parent `<li role="treeitem">` owns focus and
|
|
8
|
+
* keyboard interactions without nesting interactive elements.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TreeViewItemTrigger: import("@builder.io/qwik").Component<{
|
|
11
|
+
align?: string | undefined;
|
|
12
|
+
} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type TreeViewItemProps = Omit<PropsOf<'li'>, 'value'> & {
|
|
3
|
+
/** A unique value that identifies this tree item. */
|
|
4
|
+
value: string;
|
|
5
|
+
/**
|
|
6
|
+
* Whether this item is a branch node that can be expanded or collapsed.
|
|
7
|
+
* Set `true` on items that contain a nested `TreeView.Group`.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
branch?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Disables this item and any nested items inside it.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** The text used by typeahead when the item's text content is not suitable. */
|
|
17
|
+
textValue?: string;
|
|
18
|
+
/** Overrides `aria-level` for this item. Derived from nesting depth (`1` at the root level) by default. */
|
|
19
|
+
level?: number;
|
|
20
|
+
/** Sets `aria-setsize` for this item when rendering a flat or virtualized structure. */
|
|
21
|
+
setsize?: number;
|
|
22
|
+
/** Sets `aria-posinset` for this item when rendering a flat or virtualized structure. */
|
|
23
|
+
posinset?: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* An individual node (`<li role="treeitem">`) inside a `TreeView`.
|
|
27
|
+
*
|
|
28
|
+
* Manages roving `tabIndex`, selection (`aria-selected`), branch expansion (`aria-expanded`),
|
|
29
|
+
* and nesting depth (`aria-level` and `data-depth`).
|
|
30
|
+
*/
|
|
31
|
+
export declare const TreeViewItem: import("@builder.io/qwik").Component<TreeViewItemProps>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type PropsOf, type QRL, type Signal } from '@builder.io/qwik';
|
|
2
|
+
export type TreeViewRootProps = PropsOf<'ul'> & {
|
|
3
|
+
/**
|
|
4
|
+
* Whether multiple tree items can be selected at once.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The values of the items selected initially (uncontrolled).
|
|
10
|
+
* @default []
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: string[];
|
|
13
|
+
/** A signal with the values of the selected items (controlled). */
|
|
14
|
+
'bind:value'?: Signal<string[]>;
|
|
15
|
+
/** Called when the selected items change. */
|
|
16
|
+
onValueChange$?: QRL<(value: string[]) => void>;
|
|
17
|
+
/**
|
|
18
|
+
* The values of the branch items expanded initially (uncontrolled).
|
|
19
|
+
* @default []
|
|
20
|
+
*/
|
|
21
|
+
defaultExpandedValue?: string[];
|
|
22
|
+
/** A signal with the values of the expanded branch items (controlled). */
|
|
23
|
+
'bind:expandedValue'?: Signal<string[]>;
|
|
24
|
+
/** Called when the expanded branch items change. */
|
|
25
|
+
onExpandedValueChange$?: QRL<(value: string[]) => void>;
|
|
26
|
+
/**
|
|
27
|
+
* Disables all items in the tree view.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Synchronously prevents default page scrolling on tree navigation and activation keys.
|
|
34
|
+
*/
|
|
35
|
+
export declare const syncKeyDown$: import("@builder.io/qwik").SyncQRL<(event: KeyboardEvent) => void>;
|
|
36
|
+
/**
|
|
37
|
+
* Root container for a hierarchical tree view (`<ul role="tree">`).
|
|
38
|
+
*
|
|
39
|
+
* Complies with the WAI-ARIA APG Tree View pattern with roving tabindex focus management,
|
|
40
|
+
* single or multiple selection, controlled/uncontrolled expansion and selection state,
|
|
41
|
+
* arrow key navigation, `*` sibling expansion, and typeahead search.
|
|
42
|
+
*/
|
|
43
|
+
export declare const TreeViewRoot: import("@builder.io/qwik").Component<TreeViewRootProps>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { TreeViewGroup as Group } from './tree-view-group';
|
|
2
|
+
export { TreeViewItem as Item } from './tree-view-item';
|
|
3
|
+
export { TreeViewItemIndicator as ItemIndicator } from './tree-view-item-indicator';
|
|
4
|
+
export { TreeViewItemTrigger as ItemTrigger } from './tree-view-item-trigger';
|
|
5
|
+
export { TreeViewRoot as Root } from './tree-view-root';
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leve-ui/tree-view",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Headless, WAI-ARIA compliant TreeView component for Qwik. Bring your own styles.",
|
|
5
|
+
"homepage": "https://leve-ui.dev/components/tree-view/",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/leve-ui/leve-ui/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/leve-ui/leve-ui.git",
|
|
12
|
+
"directory": "packages/components/tree-view"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"main": "./lib/index.qwik.cjs",
|
|
18
|
+
"module": "./lib/index.qwik.mjs",
|
|
19
|
+
"qwik": "./lib/index.qwik.mjs",
|
|
20
|
+
"types": "./lib-types/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"@leve-ui/source": "./src/index.ts",
|
|
24
|
+
"types": "./lib-types/index.d.ts",
|
|
25
|
+
"import": "./lib/index.qwik.mjs",
|
|
26
|
+
"require": "./lib/index.qwik.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib",
|
|
31
|
+
"lib-types"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"qwik",
|
|
35
|
+
"headless-ui",
|
|
36
|
+
"accessibility",
|
|
37
|
+
"wai-aria",
|
|
38
|
+
"tree-view"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@leve-ui/utils": "0.3.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@builder.io/qwik": "^1.20.4"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@builder.io/qwik": "1.20.4",
|
|
48
|
+
"typescript": "~5.9.3",
|
|
49
|
+
"vite": "^7.3.8",
|
|
50
|
+
"vitest": "^5.1.0",
|
|
51
|
+
"@leve-ui/tsconfig": "0.0.0",
|
|
52
|
+
"@leve-ui/vite-config": "0.0.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "pnpm build:lib && pnpm build:types",
|
|
56
|
+
"build:lib": "vite build --mode lib",
|
|
57
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run"
|
|
60
|
+
}
|
|
6
61
|
}
|
package/README.md
DELETED