@zag-js/clipboard 1.43.0 → 1.43.2
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.
|
@@ -34,12 +34,16 @@ __export(clipboard_connect_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(clipboard_connect_exports);
|
|
36
36
|
var import_dom_query = require("@zag-js/dom-query");
|
|
37
|
+
var import_utils = require("@zag-js/utils");
|
|
37
38
|
var import_clipboard = require("./clipboard.anatomy.js");
|
|
38
39
|
var dom = __toESM(require("./clipboard.dom.js"));
|
|
40
|
+
var defaultTranslations = {
|
|
41
|
+
triggerLabel: (copied) => copied ? "Copied to clipboard" : "Copy to clipboard"
|
|
42
|
+
};
|
|
39
43
|
function connect(service, normalize) {
|
|
40
44
|
const { state, send, context, scope, prop } = service;
|
|
41
45
|
const copied = state.matches("copied");
|
|
42
|
-
const translations = prop("translations");
|
|
46
|
+
const translations = (0, import_utils.mergeWithDefault)(defaultTranslations, prop("translations"));
|
|
43
47
|
return {
|
|
44
48
|
copied,
|
|
45
49
|
value: context.get("value"),
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// src/clipboard.connect.ts
|
|
2
2
|
import { dataAttr } from "@zag-js/dom-query";
|
|
3
|
+
import { mergeWithDefault } from "@zag-js/utils";
|
|
3
4
|
import { parts } from "./clipboard.anatomy.mjs";
|
|
4
5
|
import * as dom from "./clipboard.dom.mjs";
|
|
6
|
+
var defaultTranslations = {
|
|
7
|
+
triggerLabel: (copied) => copied ? "Copied to clipboard" : "Copy to clipboard"
|
|
8
|
+
};
|
|
5
9
|
function connect(service, normalize) {
|
|
6
10
|
const { state, send, context, scope, prop } = service;
|
|
7
11
|
const copied = state.matches("copied");
|
|
8
|
-
const translations = prop("translations");
|
|
12
|
+
const translations = mergeWithDefault(defaultTranslations, prop("translations"));
|
|
9
13
|
return {
|
|
10
14
|
copied,
|
|
11
15
|
value: context.get("value"),
|
|
@@ -42,11 +42,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
42
42
|
return {
|
|
43
43
|
timeout: 3e3,
|
|
44
44
|
defaultValue: "",
|
|
45
|
-
...props
|
|
46
|
-
translations: {
|
|
47
|
-
triggerLabel: (copied) => copied ? "Copied to clipboard" : "Copy to clipboard",
|
|
48
|
-
...props.translations
|
|
49
|
-
}
|
|
45
|
+
...props
|
|
50
46
|
};
|
|
51
47
|
},
|
|
52
48
|
initialState() {
|
|
@@ -8,11 +8,7 @@ var machine = createMachine({
|
|
|
8
8
|
return {
|
|
9
9
|
timeout: 3e3,
|
|
10
10
|
defaultValue: "",
|
|
11
|
-
...props
|
|
12
|
-
translations: {
|
|
13
|
-
triggerLabel: (copied) => copied ? "Copied to clipboard" : "Copy to clipboard",
|
|
14
|
-
...props.translations
|
|
15
|
-
}
|
|
11
|
+
...props
|
|
16
12
|
};
|
|
17
13
|
},
|
|
18
14
|
initialState() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Service, Machine } from '@zag-js/core';
|
|
2
|
-
import { RequiredBy, CommonProperties, PropTypes } from '@zag-js/types';
|
|
2
|
+
import { RequiredBy, CommonProperties, Partial, PropTypes } from '@zag-js/types';
|
|
3
3
|
|
|
4
4
|
interface CopyStatusDetails {
|
|
5
5
|
copied: boolean;
|
|
@@ -7,9 +7,9 @@ interface CopyStatusDetails {
|
|
|
7
7
|
interface ValueChangeDetails {
|
|
8
8
|
value: string;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
triggerLabel
|
|
12
|
-
}
|
|
10
|
+
type IntlTranslations = Partial<{
|
|
11
|
+
triggerLabel: (copied: boolean) => string;
|
|
12
|
+
}>;
|
|
13
13
|
type ElementIds = Partial<{
|
|
14
14
|
root: string;
|
|
15
15
|
input: string;
|
|
@@ -49,7 +49,7 @@ interface ClipboardProps extends CommonProperties {
|
|
|
49
49
|
}
|
|
50
50
|
interface ClipboardSchema {
|
|
51
51
|
state: "idle" | "copied";
|
|
52
|
-
props: RequiredBy<ClipboardProps, "timeout"
|
|
52
|
+
props: RequiredBy<ClipboardProps, "timeout">;
|
|
53
53
|
context: {
|
|
54
54
|
value: string;
|
|
55
55
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Service, Machine } from '@zag-js/core';
|
|
2
|
-
import { RequiredBy, CommonProperties, PropTypes } from '@zag-js/types';
|
|
2
|
+
import { RequiredBy, CommonProperties, Partial, PropTypes } from '@zag-js/types';
|
|
3
3
|
|
|
4
4
|
interface CopyStatusDetails {
|
|
5
5
|
copied: boolean;
|
|
@@ -7,9 +7,9 @@ interface CopyStatusDetails {
|
|
|
7
7
|
interface ValueChangeDetails {
|
|
8
8
|
value: string;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
triggerLabel
|
|
12
|
-
}
|
|
10
|
+
type IntlTranslations = Partial<{
|
|
11
|
+
triggerLabel: (copied: boolean) => string;
|
|
12
|
+
}>;
|
|
13
13
|
type ElementIds = Partial<{
|
|
14
14
|
root: string;
|
|
15
15
|
input: string;
|
|
@@ -49,7 +49,7 @@ interface ClipboardProps extends CommonProperties {
|
|
|
49
49
|
}
|
|
50
50
|
interface ClipboardSchema {
|
|
51
51
|
state: "idle" | "copied";
|
|
52
|
-
props: RequiredBy<ClipboardProps, "timeout"
|
|
52
|
+
props: RequiredBy<ClipboardProps, "timeout">;
|
|
53
53
|
context: {
|
|
54
54
|
value: string;
|
|
55
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/clipboard",
|
|
3
|
-
"version": "1.43.
|
|
3
|
+
"version": "1.43.2",
|
|
4
4
|
"description": "Core logic for the clipboard widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@zag-js/anatomy": "1.43.
|
|
34
|
-
"@zag-js/core": "1.43.
|
|
35
|
-
"@zag-js/dom-query": "1.43.
|
|
36
|
-
"@zag-js/utils": "1.43.
|
|
37
|
-
"@zag-js/types": "1.43.
|
|
33
|
+
"@zag-js/anatomy": "1.43.2",
|
|
34
|
+
"@zag-js/core": "1.43.2",
|
|
35
|
+
"@zag-js/dom-query": "1.43.2",
|
|
36
|
+
"@zag-js/utils": "1.43.2",
|
|
37
|
+
"@zag-js/types": "1.43.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|