@devtools-ui/action 0.4.0 → 0.4.1--canary.62.3837

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.
@@ -59,32 +59,32 @@ var ActionComponent = (props) => {
59
59
 
60
60
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/dsl/Action.tsx
61
61
  var import_react4 = __toESM(require("react"));
62
- var import_dsl = require("@player-tools/dsl");
62
+ var import_react_dsl = require("@player-lang/react-dsl");
63
63
  var import_collection = require("@devtools-ui/collection");
64
64
  var import_text = require("@devtools-ui/text");
65
65
  var Action = (props) => {
66
66
  const { exp, children, ...rest } = props;
67
67
  let expValue;
68
- if ((0, import_dsl.isTemplateStringInstance)(exp)) {
68
+ if ((0, import_react_dsl.isTemplateStringInstance)(exp)) {
69
69
  expValue = exp.toValue();
70
70
  } else if (Array.isArray(exp)) {
71
71
  expValue = exp.map((e) => typeof e === "string" ? e : e.toValue());
72
72
  } else if (exp) {
73
73
  expValue = exp;
74
74
  }
75
- return /* @__PURE__ */ import_react4.default.createElement(import_dsl.Asset, { type: "action", ...rest, ...expValue && { exp: expValue } }, children);
75
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_dsl.Asset, { type: "action", ...rest, ...expValue && { exp: expValue } }, children);
76
76
  };
77
77
  var CollectionComp = (props) => {
78
78
  return /* @__PURE__ */ import_react4.default.createElement(import_collection.Collection, null, /* @__PURE__ */ import_react4.default.createElement(import_collection.Collection.Values, null, props.children));
79
79
  };
80
- Action.Label = (0, import_dsl.createSlot)({
80
+ Action.Label = (0, import_react_dsl.createSlot)({
81
81
  name: "label",
82
82
  TextComp: import_text.Text,
83
83
  CollectionComp,
84
84
  isArray: false,
85
85
  wrapInAsset: true
86
86
  });
87
- Action.Icon = (0, import_dsl.createSlot)({
87
+ Action.Icon = (0, import_react_dsl.createSlot)({
88
88
  name: "icon",
89
89
  TextComp: import_text.Text,
90
90
  CollectionComp,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/components/ActionComponent.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/dsl/Action.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./components\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import React from \"react\";\nimport { Button } from \"@chakra-ui/react\";\nimport type { TransformedAction } from \"../types\";\nimport { ReactAsset } from \"@player-ui/react\";\n\nconst useActionPros = (props: TransformedAction) => {\n return {\n ...(props.label ? { children: <ReactAsset {...props.label.asset} /> } : {}),\n ...(props.icon\n ? {\n [props.metaData?.iconPosition === \"left\" ? \"leftIcon\" : \"rightIcon\"]:\n <ReactAsset {...props.icon.asset} />,\n }\n : {}),\n ...(props.run ? { onClick: props.run } : {}),\n ...(props.metaData?.variant ? { variant: props.metaData.variant } : {}),\n ...(props.metaData?.isLoading\n ? { isLoading: props.metaData.isLoading }\n : {}),\n } as const;\n};\n\nexport const ActionComponent = (props: TransformedAction) => {\n const { children, ...buttonProps } = useActionPros(props);\n\n return <Button {...buttonProps}>{children}</Button>;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n isTemplateStringInstance,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type { ActionAsset } from \"../types\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\n\nexport const Action = (props: AssetPropsWithChildren<ActionAsset>) => {\n const { exp, children, ...rest } = props;\n\n let expValue: ActionAsset[\"exp\"];\n\n if (isTemplateStringInstance(exp)) {\n expValue = exp.toValue();\n } else if (Array.isArray(exp)) {\n expValue = exp.map((e) => (typeof e === \"string\" ? e : e.toValue()));\n } else if (exp) {\n expValue = exp;\n }\n\n return (\n <Asset type=\"action\" {...rest} {...(expValue && { exp: expValue })}>\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\nAction.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n\nAction.Icon = createSlot({\n name: \"icon\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ActionAsset, TransformedAction } from \"../types\";\n\n/**\n * Attaches the methods to execute an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const actionTransform = compose(\n transform,\n composeBefore(expPropTransform)\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,IAAAA,g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AC7D,QACH;AAEJ;AAEA,IAAM,iBAAiB,CAAC,UAA6C;AACnE,SACE,8BAAAA,QAAA,cAAC,oCACC,8BAAAA,QAAA,cAAC,6BAAW,QAAX,MAAmB,MAAM,QAAS,CACrC;AAEJ;AAEA,OAAO,YAAQ,uBAAW;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAED,OAAO,WAAO,uBAAW;AAAA,EACvB,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACf,CAAC;;;ACjDD,oCAAuC;AAMvC,IAAM,YAA+D,CACnE,QACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AACJ,UAAI,OAAO,KAAK;AACd,gBAAQ,SAAS,OAAO,GAAG;AAAA,MAC7B;AAEA,UAAI,OAAO,OAAO;AAChB,cAAM,iBAAiB,OAAO,UAAU;AACxC,gBAAQ,aAAa,OAAO,OAAO,EAAE,OAAO,eAAe,CAAC;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;AAOO,IAAM,mBAAmD,CAAC,UAAU;AACzE,QAAM,YAAY,MAAM,SAAS,gBAAgB;AAEjD,MAAI,aAAa,UAAU,QAAQ,KAAK,IAAI,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,MAAM;AAAA,MACT,gBAAgB;AAAA,QACd,GAAG,OAAO,SAAS;AAAA,QACnB,kBAAkB;AAAA,UAChB,GAAI,MAAM,SAAS,gBAAgB,oBAAoB,CAAC;AAAA,UACxD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,sBAAkB;AAAA,EAC7B;AAAA,MACA,6CAAc,gBAAgB;AAChC;","names":["import_react","React","import_react","React"]}
1
+ {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/components/ActionComponent.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/dsl/Action.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./components\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import React from \"react\";\nimport { Button } from \"@chakra-ui/react\";\nimport type { TransformedAction } from \"../types\";\nimport { ReactAsset } from \"@player-ui/react\";\n\nconst useActionPros = (props: TransformedAction) => {\n return {\n ...(props.label ? { children: <ReactAsset {...props.label.asset} /> } : {}),\n ...(props.icon\n ? {\n [props.metaData?.iconPosition === \"left\" ? \"leftIcon\" : \"rightIcon\"]:\n <ReactAsset {...props.icon.asset} />,\n }\n : {}),\n ...(props.run ? { onClick: props.run } : {}),\n ...(props.metaData?.variant ? { variant: props.metaData.variant } : {}),\n ...(props.metaData?.isLoading\n ? { isLoading: props.metaData.isLoading }\n : {}),\n } as const;\n};\n\nexport const ActionComponent = (props: TransformedAction) => {\n const { children, ...buttonProps } = useActionPros(props);\n\n return <Button {...buttonProps}>{children}</Button>;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n isTemplateStringInstance,\n} from \"@player-lang/react-dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type { ActionAsset } from \"../types\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\n\nexport const Action = (props: AssetPropsWithChildren<ActionAsset>) => {\n const { exp, children, ...rest } = props;\n\n let expValue: ActionAsset[\"exp\"];\n\n if (isTemplateStringInstance(exp)) {\n expValue = exp.toValue();\n } else if (Array.isArray(exp)) {\n expValue = exp.map((e) => (typeof e === \"string\" ? e : e.toValue()));\n } else if (exp) {\n expValue = exp;\n }\n\n return (\n <Asset type=\"action\" {...rest} {...(expValue && { exp: expValue })}>\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\nAction.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n\nAction.Icon = createSlot({\n name: \"icon\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ActionAsset, TransformedAction } from \"../types\";\n\n/**\n * Attaches the methods to execute an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const actionTransform = compose(\n transform,\n composeBefore(expPropTransform)\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,IAAAA,gBAAuB;AAEvB,IAAAA,gBAA2B;AAE3B,I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CAAC,UAA6C;AACnE,SACE,8BAAAA,QAAA,cAAC,oCACC,8BAAAA,QAAA,cAAC,6BAAW,QAAX,MAAmB,MAAM,QAAS,CACrC;AAEJ;AAEA,OAAO,YAAQ,6BAAW;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAED,OAAO,WAAO,6BAAW;AAAA,EACvB,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACf,CAAC;;;ACjDD,oCAAuC;AAMvC,IAAM,YAA+D,CACnE,QACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AACJ,UAAI,OAAO,KAAK;AACd,gBAAQ,SAAS,OAAO,GAAG;AAAA,MAC7B;AAEA,UAAI,OAAO,OAAO;AAChB,cAAM,iBAAiB,OAAO,UAAU;AACxC,gBAAQ,aAAa,OAAO,OAAO,EAAE,OAAO,eAAe,CAAC;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;AAOO,IAAM,mBAAmD,CAAC,UAAU;AACzE,QAAM,YAAY,MAAM,SAAS,gBAAgB;AAEjD,MAAI,aAAa,UAAU,QAAQ,KAAK,IAAI,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,MAAM;AAAA,MACT,gBAAgB;AAAA,QACd,GAAG,OAAO,SAAS;AAAA,QACnB,kBAAkB;AAAA,UAChB,GAAI,MAAM,SAAS,gBAAgB,oBAAoB,CAAC;AAAA,UACxD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,sBAAkB;AAAA,EAC7B;AAAA,MACA,6CAAc,gBAAgB;AAChC;","names":["import_react","React","import_react","React"]}
@@ -24,7 +24,7 @@ import {
24
24
  Asset,
25
25
  createSlot,
26
26
  isTemplateStringInstance
27
- } from "@player-tools/dsl";
27
+ } from "@player-lang/react-dsl";
28
28
  import { Collection } from "@devtools-ui/collection";
29
29
  import { Text } from "@devtools-ui/text";
30
30
  var Action = (props) => {
package/dist/index.mjs CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  Asset,
25
25
  createSlot,
26
26
  isTemplateStringInstance
27
- } from "@player-tools/dsl";
27
+ } from "@player-lang/react-dsl";
28
28
  import { Collection } from "@devtools-ui/collection";
29
29
  import { Text } from "@devtools-ui/text";
30
30
  var Action = (props) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/components/ActionComponent.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/dsl/Action.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/transform/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@chakra-ui/react\";\nimport type { TransformedAction } from \"../types\";\nimport { ReactAsset } from \"@player-ui/react\";\n\nconst useActionPros = (props: TransformedAction) => {\n return {\n ...(props.label ? { children: <ReactAsset {...props.label.asset} /> } : {}),\n ...(props.icon\n ? {\n [props.metaData?.iconPosition === \"left\" ? \"leftIcon\" : \"rightIcon\"]:\n <ReactAsset {...props.icon.asset} />,\n }\n : {}),\n ...(props.run ? { onClick: props.run } : {}),\n ...(props.metaData?.variant ? { variant: props.metaData.variant } : {}),\n ...(props.metaData?.isLoading\n ? { isLoading: props.metaData.isLoading }\n : {}),\n } as const;\n};\n\nexport const ActionComponent = (props: TransformedAction) => {\n const { children, ...buttonProps } = useActionPros(props);\n\n return <Button {...buttonProps}>{children}</Button>;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n isTemplateStringInstance,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type { ActionAsset } from \"../types\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\n\nexport const Action = (props: AssetPropsWithChildren<ActionAsset>) => {\n const { exp, children, ...rest } = props;\n\n let expValue: ActionAsset[\"exp\"];\n\n if (isTemplateStringInstance(exp)) {\n expValue = exp.toValue();\n } else if (Array.isArray(exp)) {\n expValue = exp.map((e) => (typeof e === \"string\" ? e : e.toValue()));\n } else if (exp) {\n expValue = exp;\n }\n\n return (\n <Asset type=\"action\" {...rest} {...(expValue && { exp: expValue })}>\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\nAction.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n\nAction.Icon = createSlot({\n name: \"icon\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ActionAsset, TransformedAction } from \"../types\";\n\n/**\n * Attaches the methods to execute an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSk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;AAEO,IAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA,cAAc,gBAAgB;AAChC;","names":["React"]}
1
+ {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/components/ActionComponent.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/dsl/Action.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/action/src/transform/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@chakra-ui/react\";\nimport type { TransformedAction } from \"../types\";\nimport { ReactAsset } from \"@player-ui/react\";\n\nconst useActionPros = (props: TransformedAction) => {\n return {\n ...(props.label ? { children: <ReactAsset {...props.label.asset} /> } : {}),\n ...(props.icon\n ? {\n [props.metaData?.iconPosition === \"left\" ? \"leftIcon\" : \"rightIcon\"]:\n <ReactAsset {...props.icon.asset} />,\n }\n : {}),\n ...(props.run ? { onClick: props.run } : {}),\n ...(props.metaData?.variant ? { variant: props.metaData.variant } : {}),\n ...(props.metaData?.isLoading\n ? { isLoading: props.metaData.isLoading }\n : {}),\n } as const;\n};\n\nexport const ActionComponent = (props: TransformedAction) => {\n const { children, ...buttonProps } = useActionPros(props);\n\n return <Button {...buttonProps}>{children}</Button>;\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n isTemplateStringInstance,\n} from \"@player-lang/react-dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type { ActionAsset } from \"../types\";\nimport { Collection } from \"@devtools-ui/collection\";\nimport { Text } from \"@devtools-ui/text\";\n\nexport const Action = (props: AssetPropsWithChildren<ActionAsset>) => {\n const { exp, children, ...rest } = props;\n\n let expValue: ActionAsset[\"exp\"];\n\n if (isTemplateStringInstance(exp)) {\n expValue = exp.toValue();\n } else if (Array.isArray(exp)) {\n expValue = exp.map((e) => (typeof e === \"string\" ? e : e.toValue()));\n } else if (exp) {\n expValue = exp;\n }\n\n return (\n <Asset type=\"action\" {...rest} {...(expValue && { exp: expValue })}>\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\nAction.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n\nAction.Icon = createSlot({\n name: \"icon\",\n TextComp: Text,\n CollectionComp,\n isArray: false,\n wrapInAsset: true,\n});\n","import type {\n Asset,\n BeforeTransformFunction,\n TransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport { ActionAsset, TransformedAction } from \"../types\";\n\n/**\n * Attaches the methods to execute an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const actionTransform = compose(\n transform,\n composeBefore(expPropTransform)\n);\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,cAAc;AAEvB,SAAS,kBAAkB;AAE3B,IAAM,gBAAgB,CAAC,UAA6B;AAClD,SAAO;AAAA,IACL,GAAI,MAAM,QAAQ,EAAE,UAAU,oCAAC,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B,MAAM,QAAS,CACrC;AAEJ;AAEA,OAAO,QAAQ,WAAW;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAED,OAAO,OAAO,WAAW;AAAA,EACvB,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACf,CAAC;;;ACjDD,SAAS,SAAS,qBAAqB;AAMvC,IAAM,YAA+D,CACnE,QACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AACJ,UAAI,OAAO,KAAK;AACd,gBAAQ,SAAS,OAAO,GAAG;AAAA,MAC7B;AAEA,UAAI,OAAO,OAAO;AAChB,cAAM,iBAAiB,OAAO,UAAU;AACxC,gBAAQ,aAAa,OAAO,OAAO,EAAE,OAAO,eAAe,CAAC;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;AAOO,IAAM,mBAAmD,CAAC,UAAU;AACzE,QAAM,YAAY,MAAM,SAAS,gBAAgB;AAEjD,MAAI,aAAa,UAAU,QAAQ,KAAK,IAAI,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,MAAM;AAAA,MACT,gBAAgB;AAAA,QACd,GAAG,OAAO,SAAS;AAAA,QACnB,kBAAkB;AAAA,UAChB,GAAI,MAAM,SAAS,gBAAgB,oBAAoB,CAAC;AAAA,UACxD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA,cAAc,gBAAgB;AAChC;","names":["React"]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@devtools-ui/action",
3
- "version": "0.4.0",
3
+ "version": "0.4.1--canary.62.3837",
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.1--canary.62.3837",
7
+ "@devtools-ui/collection": "0.4.1--canary.62.3837",
8
8
  "@chakra-ui/react": "^2.8.2",
9
9
  "@emotion/react": "^11.11.4",
10
10
  "@emotion/styled": "^11.11.0",
@@ -32,10 +32,10 @@
32
32
  "types"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@player-tools/dsl": "0.7.0-next.3",
36
- "@player-ui/types": "0.9.1-next.0",
37
- "@player-ui/asset-transform-plugin": "0.9.1-next.0",
38
- "@player-ui/player": "0.9.1-next.0",
39
- "@player-ui/react": "0.9.1-next.0"
35
+ "@player-lang/react-dsl": "1.0.1",
36
+ "@player-ui/types": "0.15.5",
37
+ "@player-ui/asset-transform-plugin": "0.15.5",
38
+ "@player-ui/player": "0.15.5",
39
+ "@player-ui/react": "0.15.5"
40
40
  }
41
41
  }
@@ -4,7 +4,7 @@ import {
4
4
  Asset,
5
5
  createSlot,
6
6
  isTemplateStringInstance,
7
- } from "@player-tools/dsl";
7
+ } from "@player-lang/react-dsl";
8
8
  import type { Asset as AssetType } from "@player-ui/player";
9
9
  import type { ActionAsset } from "../types";
10
10
  import { Collection } from "@devtools-ui/collection";
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { describe, expect, test } from "vitest";
3
- import { render, expression as e, Asset } from "@player-tools/dsl";
3
+ import { render, expression as e, Asset } from "@player-lang/react-dsl";
4
4
  import { Action } from "../Action";
5
5
 
6
6
  describe("DSL: Action", () => {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { AssetPropsWithChildren } from "@player-tools/dsl";
2
+ import { AssetPropsWithChildren } from "@player-lang/react-dsl";
3
3
  import type { ActionAsset } from "../types";
4
4
  export declare const Action: {
5
5
  (props: AssetPropsWithChildren<ActionAsset>): React.JSX.Element;