@zag-js/toc 1.37.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Chakra UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ export { anatomy } from './toc.anatomy.mjs';
2
+ export { connect } from './toc.connect.mjs';
3
+ export { machine } from './toc.machine.mjs';
4
+ export { itemProps, props, splitItemProps, splitProps } from './toc.props.mjs';
5
+ export { ActiveChangeDetails, TocApi as Api, ElementIds, ItemProps, ItemState, TocMachine as Machine, TocProps as Props, TocService as Service, TocItem } from './toc.types.mjs';
6
+ import '@zag-js/anatomy';
7
+ import '@zag-js/core';
8
+ import '@zag-js/types';
@@ -0,0 +1,8 @@
1
+ export { anatomy } from './toc.anatomy.js';
2
+ export { connect } from './toc.connect.js';
3
+ export { machine } from './toc.machine.js';
4
+ export { itemProps, props, splitItemProps, splitProps } from './toc.props.js';
5
+ export { ActiveChangeDetails, TocApi as Api, ElementIds, ItemProps, ItemState, TocMachine as Machine, TocProps as Props, TocService as Service, TocItem } from './toc.types.js';
6
+ import '@zag-js/anatomy';
7
+ import '@zag-js/core';
8
+ import '@zag-js/types';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ anatomy: () => import_toc.anatomy,
25
+ connect: () => import_toc2.connect,
26
+ machine: () => import_toc3.machine
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var import_toc = require("./toc.anatomy.js");
30
+ var import_toc2 = require("./toc.connect.js");
31
+ var import_toc3 = require("./toc.machine.js");
32
+ __reExport(index_exports, require("./toc.props.js"), module.exports);
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ anatomy,
36
+ connect,
37
+ machine,
38
+ ...require("./toc.props.js")
39
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ // src/index.ts
2
+ import { anatomy } from "./toc.anatomy.mjs";
3
+ import { connect } from "./toc.connect.mjs";
4
+ import { machine } from "./toc.machine.mjs";
5
+ export * from "./toc.props.mjs";
6
+ export {
7
+ anatomy,
8
+ connect,
9
+ machine
10
+ };
@@ -0,0 +1,6 @@
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "title" | "list" | "item" | "link" | "indicator">;
4
+ declare const parts: Record<"root" | "title" | "list" | "item" | "link" | "indicator", _zag_js_anatomy.AnatomyPart>;
5
+
6
+ export { anatomy, parts };
@@ -0,0 +1,6 @@
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "title" | "list" | "item" | "link" | "indicator">;
4
+ declare const parts: Record<"root" | "title" | "list" | "item" | "link" | "indicator", _zag_js_anatomy.AnatomyPart>;
5
+
6
+ export { anatomy, parts };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/toc.anatomy.ts
21
+ var toc_anatomy_exports = {};
22
+ __export(toc_anatomy_exports, {
23
+ anatomy: () => anatomy,
24
+ parts: () => parts
25
+ });
26
+ module.exports = __toCommonJS(toc_anatomy_exports);
27
+ var import_anatomy = require("@zag-js/anatomy");
28
+ var anatomy = (0, import_anatomy.createAnatomy)("toc").parts("root", "title", "list", "item", "link", "indicator");
29
+ var parts = anatomy.build();
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ anatomy,
33
+ parts
34
+ });
@@ -0,0 +1,8 @@
1
+ // src/toc.anatomy.ts
2
+ import { createAnatomy } from "@zag-js/anatomy";
3
+ var anatomy = createAnatomy("toc").parts("root", "title", "list", "item", "link", "indicator");
4
+ var parts = anatomy.build();
5
+ export {
6
+ anatomy,
7
+ parts
8
+ };
@@ -0,0 +1,7 @@
1
+ import { Service } from '@zag-js/core';
2
+ import { PropTypes, NormalizeProps } from '@zag-js/types';
3
+ import { TocSchema, TocApi } from './toc.types.mjs';
4
+
5
+ declare function connect<T extends PropTypes>(service: Service<TocSchema>, normalize: NormalizeProps<T>): TocApi<T>;
6
+
7
+ export { connect };
@@ -0,0 +1,7 @@
1
+ import { Service } from '@zag-js/core';
2
+ import { PropTypes, NormalizeProps } from '@zag-js/types';
3
+ import { TocSchema, TocApi } from './toc.types.js';
4
+
5
+ declare function connect<T extends PropTypes>(service: Service<TocSchema>, normalize: NormalizeProps<T>): TocApi<T>;
6
+
7
+ export { connect };
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/toc.connect.ts
31
+ var toc_connect_exports = {};
32
+ __export(toc_connect_exports, {
33
+ connect: () => connect
34
+ });
35
+ module.exports = __toCommonJS(toc_connect_exports);
36
+ var import_dom_query = require("@zag-js/dom-query");
37
+ var import_utils = require("@zag-js/utils");
38
+ var import_toc = require("./toc.anatomy.js");
39
+ var dom = __toESM(require("./toc.dom.js"));
40
+ function connect(service, normalize) {
41
+ const { send, context, scope, computed, prop } = service;
42
+ const items = prop("items");
43
+ const activeItems = computed("activeItems");
44
+ const activeIds = context.get("activeIds");
45
+ const firstActiveId = (0, import_utils.first)(activeIds);
46
+ const lastActiveId = (0, import_utils.last)(activeIds);
47
+ function getItemState(props) {
48
+ const { item } = props;
49
+ return {
50
+ active: activeIds.includes(item.value),
51
+ first: item.value === firstActiveId,
52
+ last: item.value === lastActiveId,
53
+ depth: item.depth
54
+ };
55
+ }
56
+ return {
57
+ activeIds,
58
+ activeItems,
59
+ items,
60
+ setActiveIds(value) {
61
+ send({ type: "ACTIVE_IDS.SET", value });
62
+ },
63
+ getItemState,
64
+ getRootProps() {
65
+ const rect = context.get("indicatorRect");
66
+ return normalize.element({
67
+ ...import_toc.parts.root.attrs,
68
+ id: dom.getRootId(scope),
69
+ dir: prop("dir"),
70
+ "aria-labelledby": dom.getTitleId(scope),
71
+ style: {
72
+ "--top": (0, import_utils.toPx)(rect?.y),
73
+ "--left": (0, import_utils.toPx)(rect?.x),
74
+ "--width": (0, import_utils.toPx)(rect?.width),
75
+ "--height": (0, import_utils.toPx)(rect?.height)
76
+ }
77
+ });
78
+ },
79
+ getTitleProps() {
80
+ return normalize.element({
81
+ ...import_toc.parts.title.attrs,
82
+ id: dom.getTitleId(scope),
83
+ dir: prop("dir")
84
+ });
85
+ },
86
+ getListProps() {
87
+ return normalize.element({
88
+ ...import_toc.parts.list.attrs,
89
+ id: dom.getListId(scope),
90
+ dir: prop("dir")
91
+ });
92
+ },
93
+ getItemProps(props) {
94
+ const { item } = props;
95
+ const itemState = getItemState(props);
96
+ return normalize.element({
97
+ ...import_toc.parts.item.attrs,
98
+ id: dom.getItemId(scope, item.value),
99
+ dir: prop("dir"),
100
+ "data-value": item.value,
101
+ "data-depth": String(itemState.depth),
102
+ "data-active": (0, import_dom_query.dataAttr)(itemState.active),
103
+ "data-first": (0, import_dom_query.dataAttr)(itemState.first),
104
+ "data-last": (0, import_dom_query.dataAttr)(itemState.last),
105
+ style: {
106
+ "--depth": itemState.depth
107
+ }
108
+ });
109
+ },
110
+ getLinkProps(props) {
111
+ const { item } = props;
112
+ const itemState = getItemState(props);
113
+ return normalize.element({
114
+ ...import_toc.parts.link.attrs,
115
+ id: dom.getLinkId(scope, item.value),
116
+ dir: prop("dir"),
117
+ "data-value": item.value,
118
+ "data-active": (0, import_dom_query.dataAttr)(itemState.active),
119
+ "aria-current": itemState.active ? "location" : void 0
120
+ });
121
+ },
122
+ getIndicatorProps() {
123
+ const rect = context.get("indicatorRect");
124
+ return normalize.element({
125
+ ...import_toc.parts.indicator.attrs,
126
+ id: dom.getIndicatorId(scope),
127
+ hidden: isRectEmpty(rect),
128
+ style: {
129
+ position: "absolute"
130
+ }
131
+ });
132
+ }
133
+ };
134
+ }
135
+ var isRectEmpty = (rect) => rect == null || rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0;
136
+ // Annotate the CommonJS export names for ESM import in node:
137
+ 0 && (module.exports = {
138
+ connect
139
+ });
@@ -0,0 +1,104 @@
1
+ // src/toc.connect.ts
2
+ import { dataAttr } from "@zag-js/dom-query";
3
+ import { first, last, toPx } from "@zag-js/utils";
4
+ import { parts } from "./toc.anatomy.mjs";
5
+ import * as dom from "./toc.dom.mjs";
6
+ function connect(service, normalize) {
7
+ const { send, context, scope, computed, prop } = service;
8
+ const items = prop("items");
9
+ const activeItems = computed("activeItems");
10
+ const activeIds = context.get("activeIds");
11
+ const firstActiveId = first(activeIds);
12
+ const lastActiveId = last(activeIds);
13
+ function getItemState(props) {
14
+ const { item } = props;
15
+ return {
16
+ active: activeIds.includes(item.value),
17
+ first: item.value === firstActiveId,
18
+ last: item.value === lastActiveId,
19
+ depth: item.depth
20
+ };
21
+ }
22
+ return {
23
+ activeIds,
24
+ activeItems,
25
+ items,
26
+ setActiveIds(value) {
27
+ send({ type: "ACTIVE_IDS.SET", value });
28
+ },
29
+ getItemState,
30
+ getRootProps() {
31
+ const rect = context.get("indicatorRect");
32
+ return normalize.element({
33
+ ...parts.root.attrs,
34
+ id: dom.getRootId(scope),
35
+ dir: prop("dir"),
36
+ "aria-labelledby": dom.getTitleId(scope),
37
+ style: {
38
+ "--top": toPx(rect?.y),
39
+ "--left": toPx(rect?.x),
40
+ "--width": toPx(rect?.width),
41
+ "--height": toPx(rect?.height)
42
+ }
43
+ });
44
+ },
45
+ getTitleProps() {
46
+ return normalize.element({
47
+ ...parts.title.attrs,
48
+ id: dom.getTitleId(scope),
49
+ dir: prop("dir")
50
+ });
51
+ },
52
+ getListProps() {
53
+ return normalize.element({
54
+ ...parts.list.attrs,
55
+ id: dom.getListId(scope),
56
+ dir: prop("dir")
57
+ });
58
+ },
59
+ getItemProps(props) {
60
+ const { item } = props;
61
+ const itemState = getItemState(props);
62
+ return normalize.element({
63
+ ...parts.item.attrs,
64
+ id: dom.getItemId(scope, item.value),
65
+ dir: prop("dir"),
66
+ "data-value": item.value,
67
+ "data-depth": String(itemState.depth),
68
+ "data-active": dataAttr(itemState.active),
69
+ "data-first": dataAttr(itemState.first),
70
+ "data-last": dataAttr(itemState.last),
71
+ style: {
72
+ "--depth": itemState.depth
73
+ }
74
+ });
75
+ },
76
+ getLinkProps(props) {
77
+ const { item } = props;
78
+ const itemState = getItemState(props);
79
+ return normalize.element({
80
+ ...parts.link.attrs,
81
+ id: dom.getLinkId(scope, item.value),
82
+ dir: prop("dir"),
83
+ "data-value": item.value,
84
+ "data-active": dataAttr(itemState.active),
85
+ "aria-current": itemState.active ? "location" : void 0
86
+ });
87
+ },
88
+ getIndicatorProps() {
89
+ const rect = context.get("indicatorRect");
90
+ return normalize.element({
91
+ ...parts.indicator.attrs,
92
+ id: dom.getIndicatorId(scope),
93
+ hidden: isRectEmpty(rect),
94
+ style: {
95
+ position: "absolute"
96
+ }
97
+ });
98
+ }
99
+ };
100
+ }
101
+ var isRectEmpty = (rect) => rect == null || rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0;
102
+ export {
103
+ connect
104
+ };
@@ -0,0 +1,19 @@
1
+ import { Scope } from '@zag-js/core';
2
+
3
+ declare const getRootId: (ctx: Scope) => any;
4
+ declare const getTitleId: (ctx: Scope) => any;
5
+ declare const getListId: (ctx: Scope) => any;
6
+ declare const getItemId: (ctx: Scope, value: string) => any;
7
+ declare const getLinkId: (ctx: Scope, value: string) => any;
8
+ declare const getIndicatorId: (ctx: Scope) => any;
9
+ declare const getRootEl: (ctx: Scope) => HTMLElement | null;
10
+ declare const getListEl: (ctx: Scope) => HTMLElement | null;
11
+ declare const getItemEl: (ctx: Scope, value: string | undefined | null) => HTMLElement | null;
12
+ declare const getIndicatorEl: (ctx: Scope) => HTMLElement | null;
13
+ /**
14
+ * Get the heading element in the document by its slug/id.
15
+ * This queries the actual document, not the TOC container.
16
+ */
17
+ declare const getHeadingEl: (ctx: Scope, value: string) => HTMLElement | null;
18
+
19
+ export { getHeadingEl, getIndicatorEl, getIndicatorId, getItemEl, getItemId, getLinkId, getListEl, getListId, getRootEl, getRootId, getTitleId };
@@ -0,0 +1,19 @@
1
+ import { Scope } from '@zag-js/core';
2
+
3
+ declare const getRootId: (ctx: Scope) => any;
4
+ declare const getTitleId: (ctx: Scope) => any;
5
+ declare const getListId: (ctx: Scope) => any;
6
+ declare const getItemId: (ctx: Scope, value: string) => any;
7
+ declare const getLinkId: (ctx: Scope, value: string) => any;
8
+ declare const getIndicatorId: (ctx: Scope) => any;
9
+ declare const getRootEl: (ctx: Scope) => HTMLElement | null;
10
+ declare const getListEl: (ctx: Scope) => HTMLElement | null;
11
+ declare const getItemEl: (ctx: Scope, value: string | undefined | null) => HTMLElement | null;
12
+ declare const getIndicatorEl: (ctx: Scope) => HTMLElement | null;
13
+ /**
14
+ * Get the heading element in the document by its slug/id.
15
+ * This queries the actual document, not the TOC container.
16
+ */
17
+ declare const getHeadingEl: (ctx: Scope, value: string) => HTMLElement | null;
18
+
19
+ export { getHeadingEl, getIndicatorEl, getIndicatorId, getItemEl, getItemId, getLinkId, getListEl, getListId, getRootEl, getRootId, getTitleId };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/toc.dom.ts
21
+ var toc_dom_exports = {};
22
+ __export(toc_dom_exports, {
23
+ getHeadingEl: () => getHeadingEl,
24
+ getIndicatorEl: () => getIndicatorEl,
25
+ getIndicatorId: () => getIndicatorId,
26
+ getItemEl: () => getItemEl,
27
+ getItemId: () => getItemId,
28
+ getLinkId: () => getLinkId,
29
+ getListEl: () => getListEl,
30
+ getListId: () => getListId,
31
+ getRootEl: () => getRootEl,
32
+ getRootId: () => getRootId,
33
+ getTitleId: () => getTitleId
34
+ });
35
+ module.exports = __toCommonJS(toc_dom_exports);
36
+ var getRootId = (ctx) => ctx.ids?.root ?? `toc:${ctx.id}`;
37
+ var getTitleId = (ctx) => ctx.ids?.title ?? `toc:${ctx.id}:title`;
38
+ var getListId = (ctx) => ctx.ids?.list ?? `toc:${ctx.id}:list`;
39
+ var getItemId = (ctx, value) => ctx.ids?.item?.(value) ?? `toc:${ctx.id}:item-${value}`;
40
+ var getLinkId = (ctx, value) => ctx.ids?.link?.(value) ?? `toc:${ctx.id}:link-${value}`;
41
+ var getIndicatorId = (ctx) => ctx.ids?.indicator ?? `toc:${ctx.id}:indicator`;
42
+ var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
43
+ var getListEl = (ctx) => ctx.getById(getListId(ctx));
44
+ var getItemEl = (ctx, value) => {
45
+ if (value == null) return null;
46
+ return ctx.getById(getItemId(ctx, value));
47
+ };
48
+ var getIndicatorEl = (ctx) => ctx.getById(getIndicatorId(ctx));
49
+ var getHeadingEl = (ctx, value) => {
50
+ const doc = ctx.getDoc();
51
+ return doc.getElementById(value);
52
+ };
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ getHeadingEl,
56
+ getIndicatorEl,
57
+ getIndicatorId,
58
+ getItemEl,
59
+ getItemId,
60
+ getLinkId,
61
+ getListEl,
62
+ getListId,
63
+ getRootEl,
64
+ getRootId,
65
+ getTitleId
66
+ });
@@ -0,0 +1,31 @@
1
+ // src/toc.dom.ts
2
+ var getRootId = (ctx) => ctx.ids?.root ?? `toc:${ctx.id}`;
3
+ var getTitleId = (ctx) => ctx.ids?.title ?? `toc:${ctx.id}:title`;
4
+ var getListId = (ctx) => ctx.ids?.list ?? `toc:${ctx.id}:list`;
5
+ var getItemId = (ctx, value) => ctx.ids?.item?.(value) ?? `toc:${ctx.id}:item-${value}`;
6
+ var getLinkId = (ctx, value) => ctx.ids?.link?.(value) ?? `toc:${ctx.id}:link-${value}`;
7
+ var getIndicatorId = (ctx) => ctx.ids?.indicator ?? `toc:${ctx.id}:indicator`;
8
+ var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
9
+ var getListEl = (ctx) => ctx.getById(getListId(ctx));
10
+ var getItemEl = (ctx, value) => {
11
+ if (value == null) return null;
12
+ return ctx.getById(getItemId(ctx, value));
13
+ };
14
+ var getIndicatorEl = (ctx) => ctx.getById(getIndicatorId(ctx));
15
+ var getHeadingEl = (ctx, value) => {
16
+ const doc = ctx.getDoc();
17
+ return doc.getElementById(value);
18
+ };
19
+ export {
20
+ getHeadingEl,
21
+ getIndicatorEl,
22
+ getIndicatorId,
23
+ getItemEl,
24
+ getItemId,
25
+ getLinkId,
26
+ getListEl,
27
+ getListId,
28
+ getRootEl,
29
+ getRootId,
30
+ getTitleId
31
+ };
@@ -0,0 +1,7 @@
1
+ import * as _zag_js_core from '@zag-js/core';
2
+ import { TocSchema } from './toc.types.mjs';
3
+ import '@zag-js/types';
4
+
5
+ declare const machine: _zag_js_core.Machine<TocSchema>;
6
+
7
+ export { machine };
@@ -0,0 +1,7 @@
1
+ import * as _zag_js_core from '@zag-js/core';
2
+ import { TocSchema } from './toc.types.js';
3
+ import '@zag-js/types';
4
+
5
+ declare const machine: _zag_js_core.Machine<TocSchema>;
6
+
7
+ export { machine };