@zag-js/clipboard 2.0.0-next.0 → 2.0.0-next.1
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/dist/clipboard.connect.js +6 -1
- package/dist/clipboard.connect.mjs +6 -1
- package/dist/clipboard.types.d.mts +15 -1
- package/dist/clipboard.types.d.ts +15 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +10 -7
|
@@ -40,6 +40,9 @@ function connect(service, normalize) {
|
|
|
40
40
|
const { state, send, context, scope, prop } = service;
|
|
41
41
|
const copied = state.matches("copied");
|
|
42
42
|
const translations = prop("translations");
|
|
43
|
+
function getIndicatorState(props) {
|
|
44
|
+
return { copied: props.copied, visible: props.copied === copied };
|
|
45
|
+
}
|
|
43
46
|
return {
|
|
44
47
|
copied,
|
|
45
48
|
value: context.get("value"),
|
|
@@ -96,10 +99,12 @@ function connect(service, normalize) {
|
|
|
96
99
|
}
|
|
97
100
|
});
|
|
98
101
|
},
|
|
102
|
+
getIndicatorState,
|
|
99
103
|
getIndicatorProps(props) {
|
|
104
|
+
const indicatorState = getIndicatorState(props);
|
|
100
105
|
return normalize.element({
|
|
101
106
|
...import_clipboard.parts.indicator.attrs(scope.id),
|
|
102
|
-
hidden:
|
|
107
|
+
hidden: !indicatorState.visible
|
|
103
108
|
});
|
|
104
109
|
}
|
|
105
110
|
};
|
|
@@ -6,6 +6,9 @@ function connect(service, normalize) {
|
|
|
6
6
|
const { state, send, context, scope, prop } = service;
|
|
7
7
|
const copied = state.matches("copied");
|
|
8
8
|
const translations = prop("translations");
|
|
9
|
+
function getIndicatorState(props) {
|
|
10
|
+
return { copied: props.copied, visible: props.copied === copied };
|
|
11
|
+
}
|
|
9
12
|
return {
|
|
10
13
|
copied,
|
|
11
14
|
value: context.get("value"),
|
|
@@ -62,10 +65,12 @@ function connect(service, normalize) {
|
|
|
62
65
|
}
|
|
63
66
|
});
|
|
64
67
|
},
|
|
68
|
+
getIndicatorState,
|
|
65
69
|
getIndicatorProps(props) {
|
|
70
|
+
const indicatorState = getIndicatorState(props);
|
|
66
71
|
return normalize.element({
|
|
67
72
|
...parts.indicator.attrs(scope.id),
|
|
68
|
-
hidden:
|
|
73
|
+
hidden: !indicatorState.visible
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
};
|
|
@@ -62,6 +62,16 @@ type ClipboardMachine = Machine<ClipboardSchema>;
|
|
|
62
62
|
interface IndicatorProps {
|
|
63
63
|
copied: boolean;
|
|
64
64
|
}
|
|
65
|
+
interface IndicatorState {
|
|
66
|
+
/**
|
|
67
|
+
* The copied state this indicator represents
|
|
68
|
+
*/
|
|
69
|
+
copied: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the indicator matches the current copied state
|
|
72
|
+
*/
|
|
73
|
+
visible: boolean;
|
|
74
|
+
}
|
|
65
75
|
interface ClipboardApi<T extends PropTypes = PropTypes> {
|
|
66
76
|
/**
|
|
67
77
|
* Whether the value has been copied to the clipboard
|
|
@@ -84,7 +94,11 @@ interface ClipboardApi<T extends PropTypes = PropTypes> {
|
|
|
84
94
|
getControlProps: () => T["element"];
|
|
85
95
|
getTriggerProps: () => T["button"];
|
|
86
96
|
getInputProps: () => T["input"];
|
|
97
|
+
/**
|
|
98
|
+
* Returns the state of the indicator
|
|
99
|
+
*/
|
|
100
|
+
getIndicatorState: (props: IndicatorProps) => IndicatorState;
|
|
87
101
|
getIndicatorProps: (props: IndicatorProps) => T["element"];
|
|
88
102
|
}
|
|
89
103
|
|
|
90
|
-
export type { ClipboardApi, ClipboardMachine, ClipboardProps, ClipboardSchema, ClipboardService, CopyStatusDetails, ElementIds, IndicatorProps, IntlTranslations, ValueChangeDetails };
|
|
104
|
+
export type { ClipboardApi, ClipboardMachine, ClipboardProps, ClipboardSchema, ClipboardService, CopyStatusDetails, ElementIds, IndicatorProps, IndicatorState, IntlTranslations, ValueChangeDetails };
|
|
@@ -62,6 +62,16 @@ type ClipboardMachine = Machine<ClipboardSchema>;
|
|
|
62
62
|
interface IndicatorProps {
|
|
63
63
|
copied: boolean;
|
|
64
64
|
}
|
|
65
|
+
interface IndicatorState {
|
|
66
|
+
/**
|
|
67
|
+
* The copied state this indicator represents
|
|
68
|
+
*/
|
|
69
|
+
copied: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the indicator matches the current copied state
|
|
72
|
+
*/
|
|
73
|
+
visible: boolean;
|
|
74
|
+
}
|
|
65
75
|
interface ClipboardApi<T extends PropTypes = PropTypes> {
|
|
66
76
|
/**
|
|
67
77
|
* Whether the value has been copied to the clipboard
|
|
@@ -84,7 +94,11 @@ interface ClipboardApi<T extends PropTypes = PropTypes> {
|
|
|
84
94
|
getControlProps: () => T["element"];
|
|
85
95
|
getTriggerProps: () => T["button"];
|
|
86
96
|
getInputProps: () => T["input"];
|
|
97
|
+
/**
|
|
98
|
+
* Returns the state of the indicator
|
|
99
|
+
*/
|
|
100
|
+
getIndicatorState: (props: IndicatorProps) => IndicatorState;
|
|
87
101
|
getIndicatorProps: (props: IndicatorProps) => T["element"];
|
|
88
102
|
}
|
|
89
103
|
|
|
90
|
-
export type { ClipboardApi, ClipboardMachine, ClipboardProps, ClipboardSchema, ClipboardService, CopyStatusDetails, ElementIds, IndicatorProps, IntlTranslations, ValueChangeDetails };
|
|
104
|
+
export type { ClipboardApi, ClipboardMachine, ClipboardProps, ClipboardSchema, ClipboardService, CopyStatusDetails, ElementIds, IndicatorProps, IndicatorState, IntlTranslations, ValueChangeDetails };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './clipboard.anatomy.mjs';
|
|
|
2
2
|
export { connect } from './clipboard.connect.mjs';
|
|
3
3
|
export { machine } from './clipboard.machine.mjs';
|
|
4
4
|
export { contextProps, indicatorProps, props, splitIndicatorProps } from './clipboard.props.mjs';
|
|
5
|
-
export { ClipboardApi as Api, CopyStatusDetails, ElementIds, IndicatorProps, IntlTranslations, ClipboardMachine as Machine, ClipboardProps as Props, ClipboardService as Service, ValueChangeDetails } from './clipboard.types.mjs';
|
|
5
|
+
export { ClipboardApi as Api, CopyStatusDetails, ElementIds, IndicatorProps, IndicatorState, IntlTranslations, ClipboardMachine as Machine, ClipboardProps as Props, ClipboardService as Service, ValueChangeDetails } from './clipboard.types.mjs';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/types';
|
|
8
8
|
import '@zag-js/core';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './clipboard.anatomy.js';
|
|
|
2
2
|
export { connect } from './clipboard.connect.js';
|
|
3
3
|
export { machine } from './clipboard.machine.js';
|
|
4
4
|
export { contextProps, indicatorProps, props, splitIndicatorProps } from './clipboard.props.js';
|
|
5
|
-
export { ClipboardApi as Api, CopyStatusDetails, ElementIds, IndicatorProps, IntlTranslations, ClipboardMachine as Machine, ClipboardProps as Props, ClipboardService as Service, ValueChangeDetails } from './clipboard.types.js';
|
|
5
|
+
export { ClipboardApi as Api, CopyStatusDetails, ElementIds, IndicatorProps, IndicatorState, IntlTranslations, ClipboardMachine as Machine, ClipboardProps as Props, ClipboardService as Service, ValueChangeDetails } from './clipboard.types.js';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/types';
|
|
8
8
|
import '@zag-js/core';
|
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.1",
|
|
4
4
|
"description": "Core logic for the clipboard widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"homepage": "https://github.com/chakra-ui/zag#readme",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"main": "dist/index.js",
|
|
18
|
-
"repository":
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/chakra-ui/zag/tree/main/packages/clipboard"
|
|
21
|
+
},
|
|
19
22
|
"sideEffects": false,
|
|
20
23
|
"files": [
|
|
21
24
|
"dist"
|
|
@@ -27,11 +30,11 @@
|
|
|
27
30
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@zag-js/anatomy": "2.0.0-next.
|
|
31
|
-
"@zag-js/core": "2.0.0-next.
|
|
32
|
-
"@zag-js/dom-query": "2.0.0-next.
|
|
33
|
-
"@zag-js/utils": "2.0.0-next.
|
|
34
|
-
"@zag-js/types": "2.0.0-next.
|
|
33
|
+
"@zag-js/anatomy": "2.0.0-next.1",
|
|
34
|
+
"@zag-js/core": "2.0.0-next.1",
|
|
35
|
+
"@zag-js/dom-query": "2.0.0-next.1",
|
|
36
|
+
"@zag-js/utils": "2.0.0-next.1",
|
|
37
|
+
"@zag-js/types": "2.0.0-next.1"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
40
|
"clean-package": "2.2.0"
|