@zag-js/splitter 1.41.0 → 2.0.0-next.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.
@@ -167,10 +167,9 @@ function connect(service, normalize) {
167
167
  },
168
168
  getRootProps() {
169
169
  return normalize.element({
170
- ...import_splitter.parts.root.attrs,
170
+ ...import_splitter.parts.root.attrs(scope.id),
171
171
  "data-orientation": orientation,
172
172
  "data-dragging": (0, import_dom_query.dataAttr)(dragging),
173
- id: dom.getRootId(scope),
174
173
  dir: prop("dir"),
175
174
  style: {
176
175
  display: "flex",
@@ -184,14 +183,13 @@ function connect(service, normalize) {
184
183
  getPanelProps(props) {
185
184
  const { id } = props;
186
185
  return normalize.element({
187
- ...import_splitter.parts.panel.attrs,
186
+ ...import_splitter.parts.panel.attrs(scope.id),
188
187
  "data-orientation": orientation,
189
188
  "data-dragging": (0, import_dom_query.dataAttr)(dragging),
190
189
  dir: prop("dir"),
191
190
  "data-id": id,
192
191
  "data-index": (0, import_panel.findPanelIndex)(prop("panels"), id),
193
192
  id: dom.getPanelId(scope, id),
194
- "data-ownedby": dom.getRootId(scope),
195
193
  style: getPanelStyle(id)
196
194
  });
197
195
  },
@@ -199,12 +197,11 @@ function connect(service, normalize) {
199
197
  getResizeTriggerIndicator(props) {
200
198
  const triggerState = getResizeTriggerState(props);
201
199
  return normalize.element({
202
- ...import_splitter.parts.resizeTriggerIndicator.attrs,
200
+ ...import_splitter.parts.resizeTriggerIndicator.attrs(scope.id),
203
201
  "data-orientation": orientation,
204
202
  "data-focus": (0, import_dom_query.dataAttr)(triggerState.focused),
205
203
  "data-dragging": (0, import_dom_query.dataAttr)(triggerState.dragging),
206
- "data-disabled": (0, import_dom_query.dataAttr)(triggerState.disabled),
207
- "data-ownedby": dom.getRootId(scope)
204
+ "data-disabled": (0, import_dom_query.dataAttr)(triggerState.disabled)
208
205
  });
209
206
  },
210
207
  getResizeTriggerProps(props) {
@@ -213,12 +210,11 @@ function connect(service, normalize) {
213
210
  const resolvedId = resolveResizeTriggerId(id);
214
211
  const aria = (0, import_aria.getAriaValue)(getResolvedSizes(), panels, resolvedId);
215
212
  return normalize.element({
216
- ...import_splitter.parts.resizeTrigger.attrs,
213
+ ...import_splitter.parts.resizeTrigger.attrs(scope.id),
217
214
  dir: prop("dir"),
218
215
  id: dom.getResizeTriggerId(scope, id),
219
216
  role: "separator",
220
217
  "data-id": id,
221
- "data-ownedby": dom.getRootId(scope),
222
218
  tabIndex: triggerState.disabled ? void 0 : 0,
223
219
  "aria-valuenow": aria.valueNow,
224
220
  "aria-valuemin": aria.valueMin,
@@ -135,10 +135,9 @@ function connect(service, normalize) {
135
135
  },
136
136
  getRootProps() {
137
137
  return normalize.element({
138
- ...parts.root.attrs,
138
+ ...parts.root.attrs(scope.id),
139
139
  "data-orientation": orientation,
140
140
  "data-dragging": dataAttr(dragging),
141
- id: dom.getRootId(scope),
142
141
  dir: prop("dir"),
143
142
  style: {
144
143
  display: "flex",
@@ -152,14 +151,13 @@ function connect(service, normalize) {
152
151
  getPanelProps(props) {
153
152
  const { id } = props;
154
153
  return normalize.element({
155
- ...parts.panel.attrs,
154
+ ...parts.panel.attrs(scope.id),
156
155
  "data-orientation": orientation,
157
156
  "data-dragging": dataAttr(dragging),
158
157
  dir: prop("dir"),
159
158
  "data-id": id,
160
159
  "data-index": findPanelIndex(prop("panels"), id),
161
160
  id: dom.getPanelId(scope, id),
162
- "data-ownedby": dom.getRootId(scope),
163
161
  style: getPanelStyle(id)
164
162
  });
165
163
  },
@@ -167,12 +165,11 @@ function connect(service, normalize) {
167
165
  getResizeTriggerIndicator(props) {
168
166
  const triggerState = getResizeTriggerState(props);
169
167
  return normalize.element({
170
- ...parts.resizeTriggerIndicator.attrs,
168
+ ...parts.resizeTriggerIndicator.attrs(scope.id),
171
169
  "data-orientation": orientation,
172
170
  "data-focus": dataAttr(triggerState.focused),
173
171
  "data-dragging": dataAttr(triggerState.dragging),
174
- "data-disabled": dataAttr(triggerState.disabled),
175
- "data-ownedby": dom.getRootId(scope)
172
+ "data-disabled": dataAttr(triggerState.disabled)
176
173
  });
177
174
  },
178
175
  getResizeTriggerProps(props) {
@@ -181,12 +178,11 @@ function connect(service, normalize) {
181
178
  const resolvedId = resolveResizeTriggerId(id);
182
179
  const aria = getAriaValue(getResolvedSizes(), panels, resolvedId);
183
180
  return normalize.element({
184
- ...parts.resizeTrigger.attrs,
181
+ ...parts.resizeTrigger.attrs(scope.id),
185
182
  dir: prop("dir"),
186
183
  id: dom.getResizeTriggerId(scope, id),
187
184
  role: "separator",
188
185
  "data-id": id,
189
- "data-ownedby": dom.getRootId(scope),
190
186
  tabIndex: triggerState.disabled ? void 0 : 0,
191
187
  "aria-valuenow": aria.valueNow,
192
188
  "aria-valuemin": aria.valueMin,
@@ -7,9 +7,9 @@ declare const getRootId: (ctx: Scope) => any;
7
7
  declare const getResizeTriggerId: (ctx: Scope, id: string) => any;
8
8
  declare const getLabelId: (ctx: Scope) => any;
9
9
  declare const getPanelId: (ctx: Scope, id: string | number) => any;
10
- declare const getPanelEls: (ctx: Scope) => HTMLElement[];
11
10
  declare const getGlobalCursorId: (ctx: Scope) => string;
12
11
  declare const getRootEl: (ctx: Scope) => HTMLElement | null;
12
+ declare const getPanelEls: (ctx: Scope) => HTMLElement[];
13
13
  declare const getResizeTriggerEl: (ctx: Scope, id: string | null | undefined) => HTMLElement | null;
14
14
  declare const getPanelEl: (ctx: Scope, id: string | number) => HTMLElement | null;
15
15
  declare const resolveResizeTriggerId: (ctx: Scope, id: ResizeTriggerId) => `${string}:${string}` | null;
@@ -7,9 +7,9 @@ declare const getRootId: (ctx: Scope) => any;
7
7
  declare const getResizeTriggerId: (ctx: Scope, id: string) => any;
8
8
  declare const getLabelId: (ctx: Scope) => any;
9
9
  declare const getPanelId: (ctx: Scope, id: string | number) => any;
10
- declare const getPanelEls: (ctx: Scope) => HTMLElement[];
11
10
  declare const getGlobalCursorId: (ctx: Scope) => string;
12
11
  declare const getRootEl: (ctx: Scope) => HTMLElement | null;
12
+ declare const getPanelEls: (ctx: Scope) => HTMLElement[];
13
13
  declare const getResizeTriggerEl: (ctx: Scope, id: string | null | undefined) => HTMLElement | null;
14
14
  declare const getPanelEl: (ctx: Scope, id: string | number) => HTMLElement | null;
15
15
  declare const resolveResizeTriggerId: (ctx: Scope, id: ResizeTriggerId) => `${string}:${string}` | null;
@@ -38,15 +38,16 @@ __export(splitter_dom_exports, {
38
38
  });
39
39
  module.exports = __toCommonJS(splitter_dom_exports);
40
40
  var import_dom_query = require("@zag-js/dom-query");
41
- var getRootId = (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`;
42
- var getResizeTriggerId = (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`;
43
- var getLabelId = (ctx) => ctx.ids?.label ?? `splitter:${ctx.id}:label`;
44
- var getPanelId = (ctx, id) => ctx.ids?.panel?.(id) ?? `splitter:${ctx.id}:panel:${id}`;
45
- var getPanelEls = (ctx) => (0, import_dom_query.queryAll)(getRootEl(ctx), `[data-part=panel][data-ownedby='${CSS.escape(getRootId(ctx))}']`);
46
- var getGlobalCursorId = (ctx) => `splitter:${ctx.id}:global-cursor`;
47
- var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
48
- var getResizeTriggerEl = (ctx, id) => id != null ? ctx.getById(getResizeTriggerId(ctx, id)) : null;
49
- var getPanelEl = (ctx, id) => ctx.getById(getPanelId(ctx, id));
41
+ var import_splitter = require("./splitter.anatomy.js");
42
+ var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
43
+ var getResizeTriggerId = (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `${ctx.id}:splitter:${id}`;
44
+ var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
45
+ var getPanelId = (ctx, id) => ctx.ids?.panel?.(id) ?? `${ctx.id}:panel:${id}`;
46
+ var getGlobalCursorId = (ctx) => `${ctx.id}:global-cursor`;
47
+ var getRootEl = (ctx) => ctx.query(ctx.selector(import_splitter.parts.root));
48
+ var getPanelEls = (ctx) => ctx.queryAll(ctx.selector(import_splitter.parts.panel));
49
+ var getResizeTriggerEl = (ctx, id) => id != null ? ctx.query(`${ctx.selector(import_splitter.parts.resizeTrigger)}[data-id="${id}"]`) : null;
50
+ var getPanelEl = (ctx, id) => ctx.query(`${ctx.selector(import_splitter.parts.panel)}[data-id="${id}"]`);
50
51
  var getPanelIdFromEl = (el) => {
51
52
  return (0, import_dom_query.isHTMLElement)(el) && el.dataset.part === "panel" ? el.dataset.id : void 0;
52
53
  };
@@ -81,7 +82,7 @@ var getCursor = (state, x) => {
81
82
  return cursor;
82
83
  };
83
84
  var getResizeTriggerEls = (ctx) => {
84
- return (0, import_dom_query.queryAll)(getRootEl(ctx), `[role=separator][data-ownedby='${CSS.escape(getRootId(ctx))}']`);
85
+ return ctx.queryAll(ctx.selector(import_splitter.parts.resizeTrigger));
85
86
  };
86
87
  var getGlobalCursorEl = (ctx) => {
87
88
  return ctx.getDoc().getElementById(getGlobalCursorId(ctx));
@@ -1,16 +1,17 @@
1
1
  import "./chunk-QZ7TP4HQ.mjs";
2
2
 
3
3
  // src/splitter.dom.ts
4
- import { isHTMLElement, queryAll } from "@zag-js/dom-query";
5
- var getRootId = (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`;
6
- var getResizeTriggerId = (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`;
7
- var getLabelId = (ctx) => ctx.ids?.label ?? `splitter:${ctx.id}:label`;
8
- var getPanelId = (ctx, id) => ctx.ids?.panel?.(id) ?? `splitter:${ctx.id}:panel:${id}`;
9
- var getPanelEls = (ctx) => queryAll(getRootEl(ctx), `[data-part=panel][data-ownedby='${CSS.escape(getRootId(ctx))}']`);
10
- var getGlobalCursorId = (ctx) => `splitter:${ctx.id}:global-cursor`;
11
- var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
12
- var getResizeTriggerEl = (ctx, id) => id != null ? ctx.getById(getResizeTriggerId(ctx, id)) : null;
13
- var getPanelEl = (ctx, id) => ctx.getById(getPanelId(ctx, id));
4
+ import { isHTMLElement } from "@zag-js/dom-query";
5
+ import { parts } from "./splitter.anatomy.mjs";
6
+ var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
7
+ var getResizeTriggerId = (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `${ctx.id}:splitter:${id}`;
8
+ var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
9
+ var getPanelId = (ctx, id) => ctx.ids?.panel?.(id) ?? `${ctx.id}:panel:${id}`;
10
+ var getGlobalCursorId = (ctx) => `${ctx.id}:global-cursor`;
11
+ var getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
12
+ var getPanelEls = (ctx) => ctx.queryAll(ctx.selector(parts.panel));
13
+ var getResizeTriggerEl = (ctx, id) => id != null ? ctx.query(`${ctx.selector(parts.resizeTrigger)}[data-id="${id}"]`) : null;
14
+ var getPanelEl = (ctx, id) => ctx.query(`${ctx.selector(parts.panel)}[data-id="${id}"]`);
14
15
  var getPanelIdFromEl = (el) => {
15
16
  return isHTMLElement(el) && el.dataset.part === "panel" ? el.dataset.id : void 0;
16
17
  };
@@ -45,7 +46,7 @@ var getCursor = (state, x) => {
45
46
  return cursor;
46
47
  };
47
48
  var getResizeTriggerEls = (ctx) => {
48
- return queryAll(getRootEl(ctx), `[role=separator][data-ownedby='${CSS.escape(getRootId(ctx))}']`);
49
+ return ctx.queryAll(ctx.selector(parts.resizeTrigger));
49
50
  };
50
51
  var getGlobalCursorEl = (ctx) => {
51
52
  return ctx.getDoc().getElementById(getGlobalCursorId(ctx));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/splitter",
3
- "version": "1.41.0",
3
+ "version": "2.0.0-next.0",
4
4
  "description": "Core logic for the splitter widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,11 +27,11 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/anatomy": "1.41.0",
31
- "@zag-js/core": "1.41.0",
32
- "@zag-js/dom-query": "1.41.0",
33
- "@zag-js/types": "1.41.0",
34
- "@zag-js/utils": "1.41.0"
30
+ "@zag-js/anatomy": "2.0.0-next.0",
31
+ "@zag-js/core": "2.0.0-next.0",
32
+ "@zag-js/dom-query": "2.0.0-next.0",
33
+ "@zag-js/types": "2.0.0-next.0",
34
+ "@zag-js/utils": "2.0.0-next.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "clean-package": "2.2.0"