@zag-js/clipboard 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.
@@ -51,14 +51,13 @@ function connect(service, normalize) {
51
51
  },
52
52
  getRootProps() {
53
53
  return normalize.element({
54
- ...import_clipboard.parts.root.attrs,
55
- "data-copied": (0, import_dom_query.dataAttr)(copied),
56
- id: dom.getRootId(scope)
54
+ ...import_clipboard.parts.root.attrs(scope.id),
55
+ "data-copied": (0, import_dom_query.dataAttr)(copied)
57
56
  });
58
57
  },
59
58
  getLabelProps() {
60
59
  return normalize.label({
61
- ...import_clipboard.parts.label.attrs,
60
+ ...import_clipboard.parts.label.attrs(scope.id),
62
61
  htmlFor: dom.getInputId(scope),
63
62
  "data-copied": (0, import_dom_query.dataAttr)(copied),
64
63
  id: dom.getLabelId(scope)
@@ -66,13 +65,13 @@ function connect(service, normalize) {
66
65
  },
67
66
  getControlProps() {
68
67
  return normalize.element({
69
- ...import_clipboard.parts.control.attrs,
68
+ ...import_clipboard.parts.control.attrs(scope.id),
70
69
  "data-copied": (0, import_dom_query.dataAttr)(copied)
71
70
  });
72
71
  },
73
72
  getInputProps() {
74
73
  return normalize.input({
75
- ...import_clipboard.parts.input.attrs,
74
+ ...import_clipboard.parts.input.attrs(scope.id),
76
75
  defaultValue: context.get("value"),
77
76
  "data-copied": (0, import_dom_query.dataAttr)(copied),
78
77
  readOnly: true,
@@ -88,7 +87,7 @@ function connect(service, normalize) {
88
87
  },
89
88
  getTriggerProps() {
90
89
  return normalize.button({
91
- ...import_clipboard.parts.trigger.attrs,
90
+ ...import_clipboard.parts.trigger.attrs(scope.id),
92
91
  type: "button",
93
92
  "aria-label": translations.triggerLabel?.(copied),
94
93
  "data-copied": (0, import_dom_query.dataAttr)(copied),
@@ -99,7 +98,7 @@ function connect(service, normalize) {
99
98
  },
100
99
  getIndicatorProps(props) {
101
100
  return normalize.element({
102
- ...import_clipboard.parts.indicator.attrs,
101
+ ...import_clipboard.parts.indicator.attrs(scope.id),
103
102
  hidden: props.copied !== copied
104
103
  });
105
104
  }
@@ -17,14 +17,13 @@ function connect(service, normalize) {
17
17
  },
18
18
  getRootProps() {
19
19
  return normalize.element({
20
- ...parts.root.attrs,
21
- "data-copied": dataAttr(copied),
22
- id: dom.getRootId(scope)
20
+ ...parts.root.attrs(scope.id),
21
+ "data-copied": dataAttr(copied)
23
22
  });
24
23
  },
25
24
  getLabelProps() {
26
25
  return normalize.label({
27
- ...parts.label.attrs,
26
+ ...parts.label.attrs(scope.id),
28
27
  htmlFor: dom.getInputId(scope),
29
28
  "data-copied": dataAttr(copied),
30
29
  id: dom.getLabelId(scope)
@@ -32,13 +31,13 @@ function connect(service, normalize) {
32
31
  },
33
32
  getControlProps() {
34
33
  return normalize.element({
35
- ...parts.control.attrs,
34
+ ...parts.control.attrs(scope.id),
36
35
  "data-copied": dataAttr(copied)
37
36
  });
38
37
  },
39
38
  getInputProps() {
40
39
  return normalize.input({
41
- ...parts.input.attrs,
40
+ ...parts.input.attrs(scope.id),
42
41
  defaultValue: context.get("value"),
43
42
  "data-copied": dataAttr(copied),
44
43
  readOnly: true,
@@ -54,7 +53,7 @@ function connect(service, normalize) {
54
53
  },
55
54
  getTriggerProps() {
56
55
  return normalize.button({
57
- ...parts.trigger.attrs,
56
+ ...parts.trigger.attrs(scope.id),
58
57
  type: "button",
59
58
  "aria-label": translations.triggerLabel?.(copied),
60
59
  "data-copied": dataAttr(copied),
@@ -65,7 +64,7 @@ function connect(service, normalize) {
65
64
  },
66
65
  getIndicatorProps(props) {
67
66
  return normalize.element({
68
- ...parts.indicator.attrs,
67
+ ...parts.indicator.attrs(scope.id),
69
68
  hidden: props.copied !== copied
70
69
  });
71
70
  }
@@ -28,10 +28,11 @@ __export(clipboard_dom_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(clipboard_dom_exports);
30
30
  var import_dom_query = require("@zag-js/dom-query");
31
- var getRootId = (ctx) => ctx.ids?.root ?? `clip:${ctx.id}`;
32
- var getInputId = (ctx) => ctx.ids?.input ?? `clip:${ctx.id}:input`;
33
- var getLabelId = (ctx) => ctx.ids?.label ?? `clip:${ctx.id}:label`;
34
- var getInputEl = (ctx) => ctx.getById(getInputId(ctx));
31
+ var import_clipboard = require("./clipboard.anatomy.js");
32
+ var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
33
+ var getInputId = (ctx) => ctx.ids?.input ?? `${ctx.id}:input`;
34
+ var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
35
+ var getInputEl = (ctx) => ctx.query(ctx.selector(import_clipboard.parts.input));
35
36
  var writeToClipboard = (ctx, value) => copyText(ctx.getDoc(), value);
36
37
  function createNode(doc, text) {
37
38
  const node = doc.createElement("pre");
@@ -1,9 +1,10 @@
1
1
  // src/clipboard.dom.ts
2
2
  import { getWindow } from "@zag-js/dom-query";
3
- var getRootId = (ctx) => ctx.ids?.root ?? `clip:${ctx.id}`;
4
- var getInputId = (ctx) => ctx.ids?.input ?? `clip:${ctx.id}:input`;
5
- var getLabelId = (ctx) => ctx.ids?.label ?? `clip:${ctx.id}:label`;
6
- var getInputEl = (ctx) => ctx.getById(getInputId(ctx));
3
+ import { parts } from "./clipboard.anatomy.mjs";
4
+ var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
5
+ var getInputId = (ctx) => ctx.ids?.input ?? `${ctx.id}:input`;
6
+ var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
7
+ var getInputEl = (ctx) => ctx.query(ctx.selector(parts.input));
7
8
  var writeToClipboard = (ctx, value) => copyText(ctx.getDoc(), value);
8
9
  function createNode(doc, text) {
9
10
  const node = doc.createElement("pre");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/clipboard",
3
- "version": "1.41.0",
3
+ "version": "2.0.0-next.0",
4
4
  "description": "Core logic for the clipboard 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/utils": "1.41.0",
34
- "@zag-js/types": "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/utils": "2.0.0-next.0",
34
+ "@zag-js/types": "2.0.0-next.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "clean-package": "2.2.0"