@devtools-ui/copy-to-clipboard 0.4.0-next.0 → 0.4.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.
- package/dist/cjs/index.cjs +11 -8
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +11 -8
- package/dist/index.mjs +11 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/transform/index.ts +16 -12
package/dist/cjs/index.cjs
CHANGED
|
@@ -90,16 +90,19 @@ CopyToClipboard2.Label = (0, import_dsl.createSlot)({
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/transform/index.ts
|
|
93
|
+
var getData = (asset, options) => {
|
|
94
|
+
if (asset.binding === void 0) {
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
const obj = options.data.model.get(asset.binding, {
|
|
98
|
+
includeInvalid: true,
|
|
99
|
+
formatted: false
|
|
100
|
+
});
|
|
101
|
+
return typeof obj === "string" ? obj : JSON.stringify(obj, null, 2);
|
|
102
|
+
};
|
|
93
103
|
var copyToClipboardTransform = (asset, options) => ({
|
|
94
104
|
...asset,
|
|
95
|
-
data: asset
|
|
96
|
-
options.data.model.get(asset.binding, {
|
|
97
|
-
includeInvalid: true,
|
|
98
|
-
formatted: false
|
|
99
|
-
}),
|
|
100
|
-
null,
|
|
101
|
-
2
|
|
102
|
-
)
|
|
105
|
+
data: getData(asset, options)
|
|
103
106
|
});
|
|
104
107
|
// Annotate the CommonJS export names for ESM import in node:
|
|
105
108
|
0 && (module.exports = {
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import { ReactAsset } from \"@player-ui/react\";\nimport React, { useCallback } from \"react\";\nimport type { TransformedCopyToClipboard } from \"../types\";\nimport { CopyToClipboard } from \"react-copy-to-clipboard\";\nimport { useToast, Button } from \"@chakra-ui/react\";\n\nexport const CopyToClipboardComponent = (props: TransformedCopyToClipboard) => {\n const { label, data } = props;\n const toast = useToast();\n const handleCopy = useCallback(\n (_: string, result: boolean) => {\n if (result) {\n toast({\n title: \"Data copied to clipboard\",\n description: \"Data copied successfully\",\n status: \"success\",\n duration: 3000,\n isClosable: true,\n });\n } else {\n toast({\n title: \"Failed to copy\",\n description: \"Failed to copy data to clipboard\",\n status: \"error\",\n duration: 3000,\n isClosable: true,\n });\n }\n },\n [toast]\n );\n\n return (\n <CopyToClipboard text={data} onCopy={handleCopy}>\n <Button>{label && <ReactAsset {...label.asset} />}</Button>\n </CopyToClipboard>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { CopyToClipboardAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation, so users of this plugin can author Player-UI\n * content leveraging .jsx/.tsx syntax.\n */\nexport const CopyToClipboard = (\n props: Omit<AssetPropsWithChildren<CopyToClipboardAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"copy-to-clipboard\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\nCopyToClipboard.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { CopyToClipboardAsset, TransformedCopyToClipboard } from \"../types\";\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const copyToClipboardTransform: TransformFunction<\n CopyToClipboardAsset,\n TransformedCopyToClipboard\n> = (asset, options) => ({\n ...asset,\n data
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import { ReactAsset } from \"@player-ui/react\";\nimport React, { useCallback } from \"react\";\nimport type { TransformedCopyToClipboard } from \"../types\";\nimport { CopyToClipboard } from \"react-copy-to-clipboard\";\nimport { useToast, Button } from \"@chakra-ui/react\";\n\nexport const CopyToClipboardComponent = (props: TransformedCopyToClipboard) => {\n const { label, data } = props;\n const toast = useToast();\n const handleCopy = useCallback(\n (_: string, result: boolean) => {\n if (result) {\n toast({\n title: \"Data copied to clipboard\",\n description: \"Data copied successfully\",\n status: \"success\",\n duration: 3000,\n isClosable: true,\n });\n } else {\n toast({\n title: \"Failed to copy\",\n description: \"Failed to copy data to clipboard\",\n status: \"error\",\n duration: 3000,\n isClosable: true,\n });\n }\n },\n [toast]\n );\n\n return (\n <CopyToClipboard text={data} onCopy={handleCopy}>\n <Button>{label && <ReactAsset {...label.asset} />}</Button>\n </CopyToClipboard>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { CopyToClipboardAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation, so users of this plugin can author Player-UI\n * content leveraging .jsx/.tsx syntax.\n */\nexport const CopyToClipboard = (\n props: Omit<AssetPropsWithChildren<CopyToClipboardAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"copy-to-clipboard\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\nCopyToClipboard.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type { TransformFunction, Resolve } from \"@player-ui/player\";\nimport { CopyToClipboardAsset, TransformedCopyToClipboard } from \"../types\";\n\nconst getData = (\n asset: CopyToClipboardAsset,\n options: Resolve.NodeResolveOptions\n): string => {\n if (asset.binding === undefined) {\n return \"\";\n }\n const obj = options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n });\n return typeof obj === \"string\" ? obj : JSON.stringify(obj, null, 2);\n};\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const copyToClipboardTransform: TransformFunction<\n CopyToClipboardAsset,\n TransformedCopyToClipboard\n> = (asset, options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cAAC,6BAAW,QAAX,MAAmB,MAAM,QAAS,CACrC;AAEJ;AAEAD,iBAAgB,YAAQ,uBAAW;AAAA,EACjC,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACf,CAAC;;;AC3CD,IAAM,UAAU,CACd,OACA,YACW;AACX,MAAI,MAAM,YAAY,QAAW;AAC/B,WAAO;AAAA,EACT;AACA,QAAM,MAAM,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,IAChD,gBAAgB;AAAA,IAChB,WAAW;AAAA,EACb,CAAC;AACD,SAAO,OAAO,QAAQ,WAAW,MAAM,KAAK,UAAU,KAAK,MAAM,CAAC;AACpE;AAMO,IAAM,2BAGT,CAAC,OAAO,aAAa;AAAA,EACvB,GAAG;AAAA,EACH,MAAM,QAAQ,OAAO,OAAO;AAC9B;","names":["CopyToClipboard","import_react","React","import_react","CopyToClipboard","React"]}
|
package/dist/index.legacy-esm.js
CHANGED
|
@@ -55,16 +55,19 @@ CopyToClipboard2.Label = createSlot({
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/transform/index.ts
|
|
58
|
+
var getData = (asset, options) => {
|
|
59
|
+
if (asset.binding === void 0) {
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
const obj = options.data.model.get(asset.binding, {
|
|
63
|
+
includeInvalid: true,
|
|
64
|
+
formatted: false
|
|
65
|
+
});
|
|
66
|
+
return typeof obj === "string" ? obj : JSON.stringify(obj, null, 2);
|
|
67
|
+
};
|
|
58
68
|
var copyToClipboardTransform = (asset, options) => ({
|
|
59
69
|
...asset,
|
|
60
|
-
data: asset
|
|
61
|
-
options.data.model.get(asset.binding, {
|
|
62
|
-
includeInvalid: true,
|
|
63
|
-
formatted: false
|
|
64
|
-
}),
|
|
65
|
-
null,
|
|
66
|
-
2
|
|
67
|
-
)
|
|
70
|
+
data: getData(asset, options)
|
|
68
71
|
});
|
|
69
72
|
export {
|
|
70
73
|
CopyToClipboard2 as CopyToClipboard,
|
package/dist/index.mjs
CHANGED
|
@@ -55,16 +55,19 @@ CopyToClipboard2.Label = createSlot({
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/transform/index.ts
|
|
58
|
+
var getData = (asset, options) => {
|
|
59
|
+
if (asset.binding === void 0) {
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
const obj = options.data.model.get(asset.binding, {
|
|
63
|
+
includeInvalid: true,
|
|
64
|
+
formatted: false
|
|
65
|
+
});
|
|
66
|
+
return typeof obj === "string" ? obj : JSON.stringify(obj, null, 2);
|
|
67
|
+
};
|
|
58
68
|
var copyToClipboardTransform = (asset, options) => ({
|
|
59
69
|
...asset,
|
|
60
|
-
data: asset
|
|
61
|
-
options.data.model.get(asset.binding, {
|
|
62
|
-
includeInvalid: true,
|
|
63
|
-
formatted: false
|
|
64
|
-
}),
|
|
65
|
-
null,
|
|
66
|
-
2
|
|
67
|
-
)
|
|
70
|
+
data: getData(asset, options)
|
|
68
71
|
});
|
|
69
72
|
export {
|
|
70
73
|
CopyToClipboard2 as CopyToClipboard,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/transform/index.ts"],"sourcesContent":["import { ReactAsset } from \"@player-ui/react\";\nimport React, { useCallback } from \"react\";\nimport type { TransformedCopyToClipboard } from \"../types\";\nimport { CopyToClipboard } from \"react-copy-to-clipboard\";\nimport { useToast, Button } from \"@chakra-ui/react\";\n\nexport const CopyToClipboardComponent = (props: TransformedCopyToClipboard) => {\n const { label, data } = props;\n const toast = useToast();\n const handleCopy = useCallback(\n (_: string, result: boolean) => {\n if (result) {\n toast({\n title: \"Data copied to clipboard\",\n description: \"Data copied successfully\",\n status: \"success\",\n duration: 3000,\n isClosable: true,\n });\n } else {\n toast({\n title: \"Failed to copy\",\n description: \"Failed to copy data to clipboard\",\n status: \"error\",\n duration: 3000,\n isClosable: true,\n });\n }\n },\n [toast]\n );\n\n return (\n <CopyToClipboard text={data} onCopy={handleCopy}>\n <Button>{label && <ReactAsset {...label.asset} />}</Button>\n </CopyToClipboard>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { CopyToClipboardAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation, so users of this plugin can author Player-UI\n * content leveraging .jsx/.tsx syntax.\n */\nexport const CopyToClipboard = (\n props: Omit<AssetPropsWithChildren<CopyToClipboardAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"copy-to-clipboard\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\nCopyToClipboard.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { CopyToClipboardAsset, TransformedCopyToClipboard } from \"../types\";\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const copyToClipboardTransform: TransformFunction<\n CopyToClipboardAsset,\n TransformedCopyToClipboard\n> = (asset, options) => ({\n ...asset,\n data
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/copy-to-clipboard/src/transform/index.ts"],"sourcesContent":["import { ReactAsset } from \"@player-ui/react\";\nimport React, { useCallback } from \"react\";\nimport type { TransformedCopyToClipboard } from \"../types\";\nimport { CopyToClipboard } from \"react-copy-to-clipboard\";\nimport { useToast, Button } from \"@chakra-ui/react\";\n\nexport const CopyToClipboardComponent = (props: TransformedCopyToClipboard) => {\n const { label, data } = props;\n const toast = useToast();\n const handleCopy = useCallback(\n (_: string, result: boolean) => {\n if (result) {\n toast({\n title: \"Data copied to clipboard\",\n description: \"Data copied successfully\",\n status: \"success\",\n duration: 3000,\n isClosable: true,\n });\n } else {\n toast({\n title: \"Failed to copy\",\n description: \"Failed to copy data to clipboard\",\n status: \"error\",\n duration: 3000,\n isClosable: true,\n });\n }\n },\n [toast]\n );\n\n return (\n <CopyToClipboard text={data} onCopy={handleCopy}>\n <Button>{label && <ReactAsset {...label.asset} />}</Button>\n </CopyToClipboard>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { CopyToClipboardAsset } from \"../types\";\n\n/**\n * Defines the component DSL representation, so users of this plugin can author Player-UI\n * content leveraging .jsx/.tsx syntax.\n */\nexport const CopyToClipboard = (\n props: Omit<AssetPropsWithChildren<CopyToClipboardAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"copy-to-clipboard\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\nCopyToClipboard.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type { TransformFunction, Resolve } from \"@player-ui/player\";\nimport { CopyToClipboardAsset, TransformedCopyToClipboard } from \"../types\";\n\nconst getData = (\n asset: CopyToClipboardAsset,\n options: Resolve.NodeResolveOptions\n): string => {\n if (asset.binding === undefined) {\n return \"\";\n }\n const obj = options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n });\n return typeof obj === \"string\" ? obj : JSON.stringify(obj, null, 2);\n};\n\n/**\n * Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)\n * and embeds Player state and methods:\n */\nexport const copyToClipboardTransform: TransformFunction<\n CopyToClipboardAsset,\n TransformedCopyToClipboard\n> = (asset, options) => ({\n ...asset,\n data: getData(asset, options),\n});\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,OAAO,SAAS,mBAAmB;AAEnC,SAAS,uBAAuB;AAChC,SAAS,UAAU,cAAc;AAE1B,IAAM,2BAA2B,CAAC,UAAsC;AAC7E,QAAM,EAAE,OAAO,KAAK,IAAI;AACxB,QAAM,QAAQ,SAAS;AACvB,QAAM,aAAa;AAAA,IACjB,CAAC,GAAW,WAAoB;AAC9B,UAAI,QAAQ;AACV,cAAM;AAAA,UACJ,OAAO;AAAA,UACP,aAAa;AAAA,UACb,QAAQ;AAAA,UACR,UAAU;AAAA,UACV,YAAY;AAAA,QACd,CAAC;AAAA,MACH,OAAO;AACL,cAAM;AAAA,UACJ,OAAO;AAAA,UACP,aAAa;AAAA,U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GED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtools-ui/copy-to-clipboard",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"main": "dist/cjs/index.cjs",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@devtools-ui/text": "0.4.0
|
|
7
|
-
"@devtools-ui/collection": "0.4.0
|
|
6
|
+
"@devtools-ui/text": "0.4.0",
|
|
7
|
+
"@devtools-ui/collection": "0.4.0",
|
|
8
8
|
"@chakra-ui/react": "^2.8.2",
|
|
9
9
|
"@emotion/react": "^11.11.4",
|
|
10
10
|
"@emotion/styled": "^11.11.0",
|
package/src/transform/index.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import type { TransformFunction } from "@player-ui/player";
|
|
1
|
+
import type { TransformFunction, Resolve } from "@player-ui/player";
|
|
2
2
|
import { CopyToClipboardAsset, TransformedCopyToClipboard } from "../types";
|
|
3
3
|
|
|
4
|
+
const getData = (
|
|
5
|
+
asset: CopyToClipboardAsset,
|
|
6
|
+
options: Resolve.NodeResolveOptions
|
|
7
|
+
): string => {
|
|
8
|
+
if (asset.binding === undefined) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
const obj = options.data.model.get(asset.binding, {
|
|
12
|
+
includeInvalid: true,
|
|
13
|
+
formatted: false,
|
|
14
|
+
});
|
|
15
|
+
return typeof obj === "string" ? obj : JSON.stringify(obj, null, 2);
|
|
16
|
+
};
|
|
17
|
+
|
|
4
18
|
/**
|
|
5
19
|
* Platform-agnostic transform function that takes the properties we get from the Player Content (DSL > JSON)
|
|
6
20
|
* and embeds Player state and methods:
|
|
@@ -10,15 +24,5 @@ export const copyToClipboardTransform: TransformFunction<
|
|
|
10
24
|
TransformedCopyToClipboard
|
|
11
25
|
> = (asset, options) => ({
|
|
12
26
|
...asset,
|
|
13
|
-
data:
|
|
14
|
-
asset.binding === undefined
|
|
15
|
-
? ""
|
|
16
|
-
: JSON.stringify(
|
|
17
|
-
options.data.model.get(asset.binding, {
|
|
18
|
-
includeInvalid: true,
|
|
19
|
-
formatted: false,
|
|
20
|
-
}),
|
|
21
|
-
null,
|
|
22
|
-
2
|
|
23
|
-
),
|
|
27
|
+
data: getData(asset, options),
|
|
24
28
|
});
|