@zag-js/clipboard 2.0.0-next.1 → 2.0.0-next.3
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
|
function getIndicatorState(props) {
|
|
44
48
|
return { copied: props.copied, visible: props.copied === copied };
|
|
45
49
|
}
|
|
@@ -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
|
function getIndicatorState(props) {
|
|
10
14
|
return { copied: props.copied, visible: props.copied === copied };
|
|
11
15
|
}
|
|
@@ -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 {
|
|
2
|
+
import { CommonProperties, PropTypes } from '@zag-js/types';
|
|
3
3
|
|
|
4
4
|
interface CopyStatusDetails {
|
|
5
5
|
copied: boolean;
|
|
@@ -10,11 +10,11 @@ interface ValueChangeDetails {
|
|
|
10
10
|
interface IntlTranslations {
|
|
11
11
|
triggerLabel?: ((copied: boolean) => string) | undefined;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
root
|
|
15
|
-
input
|
|
16
|
-
label
|
|
17
|
-
}
|
|
13
|
+
interface ElementIds {
|
|
14
|
+
root?: string | undefined;
|
|
15
|
+
input?: string | undefined;
|
|
16
|
+
label?: string | undefined;
|
|
17
|
+
}
|
|
18
18
|
interface ClipboardProps extends CommonProperties {
|
|
19
19
|
/**
|
|
20
20
|
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
@@ -49,7 +49,8 @@ interface ClipboardProps extends CommonProperties {
|
|
|
49
49
|
}
|
|
50
50
|
interface ClipboardSchema {
|
|
51
51
|
state: "idle" | "copied";
|
|
52
|
-
props:
|
|
52
|
+
props: ClipboardProps;
|
|
53
|
+
defaultPropKey: "timeout" | "defaultValue";
|
|
53
54
|
context: {
|
|
54
55
|
value: string;
|
|
55
56
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Service, Machine } from '@zag-js/core';
|
|
2
|
-
import {
|
|
2
|
+
import { CommonProperties, PropTypes } from '@zag-js/types';
|
|
3
3
|
|
|
4
4
|
interface CopyStatusDetails {
|
|
5
5
|
copied: boolean;
|
|
@@ -10,11 +10,11 @@ interface ValueChangeDetails {
|
|
|
10
10
|
interface IntlTranslations {
|
|
11
11
|
triggerLabel?: ((copied: boolean) => string) | undefined;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
root
|
|
15
|
-
input
|
|
16
|
-
label
|
|
17
|
-
}
|
|
13
|
+
interface ElementIds {
|
|
14
|
+
root?: string | undefined;
|
|
15
|
+
input?: string | undefined;
|
|
16
|
+
label?: string | undefined;
|
|
17
|
+
}
|
|
18
18
|
interface ClipboardProps extends CommonProperties {
|
|
19
19
|
/**
|
|
20
20
|
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
@@ -49,7 +49,8 @@ interface ClipboardProps extends CommonProperties {
|
|
|
49
49
|
}
|
|
50
50
|
interface ClipboardSchema {
|
|
51
51
|
state: "idle" | "copied";
|
|
52
|
-
props:
|
|
52
|
+
props: ClipboardProps;
|
|
53
|
+
defaultPropKey: "timeout" | "defaultValue";
|
|
53
54
|
context: {
|
|
54
55
|
value: string;
|
|
55
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/clipboard",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.3",
|
|
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": "2.0.0-next.
|
|
34
|
-
"@zag-js/core": "2.0.0-next.
|
|
35
|
-
"@zag-js/dom-query": "2.0.0-next.
|
|
36
|
-
"@zag-js/utils": "2.0.0-next.
|
|
37
|
-
"@zag-js/types": "2.0.0-next.
|
|
33
|
+
"@zag-js/anatomy": "2.0.0-next.3",
|
|
34
|
+
"@zag-js/core": "2.0.0-next.3",
|
|
35
|
+
"@zag-js/dom-query": "2.0.0-next.3",
|
|
36
|
+
"@zag-js/utils": "2.0.0-next.3",
|
|
37
|
+
"@zag-js/types": "2.0.0-next.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "tsup",
|
|
70
|
-
"lint": "
|
|
70
|
+
"lint": "oxlint src",
|
|
71
71
|
"typecheck": "tsc --noEmit"
|
|
72
72
|
}
|
|
73
73
|
}
|