@devtools-ui/table 0.4.0 → 0.4.1-next.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/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @devtools-ui/table
2
+
3
+ ## Overview
4
+
5
+ `@devtools-ui/table` is a component package designed to be leveraged by a [Player-UI assets plugin](https://player-ui.github.io/next/plugins).
6
+
7
+ It provides a Table component. It extracts the column headers and rows from the provided binding and renders them in a table.
8
+
9
+ This package is part of a mono-repo built with Bazel, ensuring fast and reliable builds.
10
+
11
+ ## Installation
12
+
13
+ To install `@devtools-ui/table`, you can use pnpm or yarn:
14
+
15
+ ```sh
16
+ pnpm i @devtools-ui/table
17
+ ```
18
+
19
+ or
20
+
21
+ ```sh
22
+ yarn add @devtools-ui/table
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ You can leverage this asset through the `@devtools-ui/plugin`:
28
+
29
+ ```ts
30
+ import { Table } from "@devtools-ui/plugin";
31
+
32
+ // and use it to define your Player-UI content:
33
+ myFlow = {
34
+ id: "my_flow",
35
+ views: [<Table binding={b`my_binding`} />],
36
+ };
37
+ ```
38
+
39
+ For more information on how to author Player-UI content using DSL, please check our [Player-UI docs](https://player-ui.github.io/next/dsl#tsxjsx-content-authoring-player-dsl).
40
+
41
+ Or, your can leverage this asset in your own plugin:
42
+
43
+ ```ts
44
+ // TransformPlugin.ts
45
+ import type { Player, PlayerPlugin } from "@player-ui/player";
46
+ import { AssetTransformPlugin } from "@player-ui/asset-transform-plugin";
47
+ import { tableTransform } from "@devtools-ui/table";
48
+
49
+ export class TransformsPlugin implements PlayerPlugin {
50
+ name = "my-plugin-transforms";
51
+
52
+ apply(player: Player) {
53
+ player.registerPlugin(
54
+ new AssetTransformPlugin([[{ type: "table" }, tableTransform]])
55
+ );
56
+ }
57
+ }
58
+ ```
59
+
60
+ ```ts
61
+ // AssetRegistryPlugin.ts
62
+ import React from "react";
63
+ import type { Player } from "@player-ui/player";
64
+ import type {
65
+ ExtendedPlayerPlugin,
66
+ ReactPlayer,
67
+ ReactPlayerPlugin,
68
+ } from "@player-ui/react";
69
+ import { AssetProviderPlugin } from "@player-ui/asset-provider-plugin-react";
70
+ import { TransformsPlugin } from "./TransformPlugin";
71
+ import { TableAsset, TableComponent } from "@devtools-ui/table";
72
+
73
+ export class AssetsRegistryPlugin
74
+ implements ReactPlayerPlugin, ExtendedPlayerPlugin<[TableAsset]>
75
+ {
76
+ name = "my-plugin";
77
+
78
+ applyReact(reactPlayer: ReactPlayer) {
79
+ reactPlayer.registerPlugin(
80
+ new AssetProviderPlugin([["table", TableComponent]])
81
+ );
82
+ }
83
+
84
+ apply(player: Player) {
85
+ player.registerPlugin(new TransformsPlugin());
86
+ }
87
+ }
88
+ ```
89
+
90
+ ## Contributing
91
+
92
+ We welcome contributions to `@devtools-ui/table`!
@@ -81,10 +81,10 @@ var TableComponent = (props) => {
81
81
 
82
82
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/dsl/index.tsx
83
83
  var import_react3 = __toESM(require("react"));
84
- var import_dsl = require("@player-tools/dsl");
84
+ var import_react_dsl = require("@player-lang/react-dsl");
85
85
  var Table2 = (props) => {
86
86
  const { binding, children, ...rest } = props;
87
- return /* @__PURE__ */ import_react3.default.createElement(import_dsl.Asset, { type: "table", ...rest }, binding && /* @__PURE__ */ import_react3.default.createElement("property", { name: "binding" }, binding.toValue()), children);
87
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_dsl.Asset, { type: "table", ...rest }, binding && /* @__PURE__ */ import_react3.default.createElement("property", { name: "binding" }, binding.toValue()), children);
88
88
  };
89
89
 
90
90
  // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/transform/index.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import {\n Table,\n TableContainer,\n Tbody,\n Td,\n Th,\n Thead,\n Tr,\n} from \"@chakra-ui/react\";\nimport React from \"react\";\nimport type { TransformedTable } from \"../types\";\n\n/**\n * Hook to convert the data we get from the Player Content into the properties our component expects:\n */\nconst useTablePros = (props: TransformedTable) => {\n // Translate the properties we get from the Player Content (DSL > JSON > transformer)\n // into what the elements that compose your component expect (platform-specific, for\n // platform-agnostic transformations, see the transformer):\n\n const { rows } = props;\n\n const parsedRows = rows.map((row) =>\n Object.entries(row).reduce((acc, [key, value]) => {\n if (key === \"time\") {\n return {\n ...acc,\n [key]: new Date(value).toLocaleString(),\n };\n }\n\n if (value === null || value === undefined) {\n return {\n ...acc,\n [key]: \"\",\n };\n }\n\n if (typeof value === \"object\") {\n return {\n ...acc,\n [key]: JSON.stringify(value),\n };\n }\n\n return { ...acc, [key]: value };\n }, {} as Record<string, string>)\n );\n\n // Get the keys to use as column headers (checking all the rows for cases where we have different keys):\n const headers = Array.from(new Set(rows.flatMap((row) => Object.keys(row))));\n\n return {\n ...props,\n headers,\n rows: parsedRows,\n } as const;\n};\n\nexport const TableComponent = (props: TransformedTable) => {\n const { headers, rows } = useTablePros(props);\n\n if (!rows.length) {\n return null;\n }\n\n return (\n <TableContainer width={\"100%\"} overflowY={\"auto\"} overflowX={\"auto\"}>\n <Table variant=\"simple\">\n <Thead>\n <Tr>\n {headers.map((key) => (\n <Th key={key}>{key}</Th>\n ))}\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, index) => (\n <Tr key={index}>\n {headers.map((key) => (\n <Td key={key}>{row[key] ?? \"\"}</Td>\n ))}\n </Tr>\n ))}\n </Tbody>\n </Table>\n </TableContainer>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { TableAsset } 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 Table = (\n props: Omit<AssetPropsWithChildren<TableAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"table\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { TableAsset, TransformedTable } 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 tableTransform: TransformFunction<TableAsset, TransformedTable> = (\n asset,\n options\n) => {\n return {\n ...asset,\n rows:\n asset.binding === undefined\n ? []\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,eAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;ACAA,mBAQO;AACP,IAAAC,gBAAkB;AAMlB,IAAM,eAAe,CAAC,UAA4B;AAKhD,QAAM,EAAE,KAAK,IAAI;AAEjB,QAAM,aAAa,KAAK;AAAA,IAAI,CAAC,QAC3B,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AAChD,UAAI,QAAQ,QAAQ;AAClB,eAAO;AAAA,UACL,GAAG;AAAA,UACH,CAAC,GAAG,GAAG,IAAI,KAAK,KAAK,EAAE,eAAe;AAAA,QACxC;AAAA,MACF;AAEA,UAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,eAAO;AAAA,UACL,GAAG;AAAA,UACH,CAAC,GAAG,GAAG;AAAA,QACT;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C,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GACvD,QACH;AAEJ;;;ACnBO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MACE,MAAM,YAAY,SACd,CAAC,IACD,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,EACT;AACF;","names":["Table","import_react","React","import_react","Table","React"]}
1
+ {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import {\n Table,\n TableContainer,\n Tbody,\n Td,\n Th,\n Thead,\n Tr,\n} from \"@chakra-ui/react\";\nimport React from \"react\";\nimport type { TransformedTable } from \"../types\";\n\n/**\n * Hook to convert the data we get from the Player Content into the properties our component expects:\n */\nconst useTablePros = (props: TransformedTable) => {\n // Translate the properties we get from the Player Content (DSL > JSON > transformer)\n // into what the elements that compose your component expect (platform-specific, for\n // platform-agnostic transformations, see the transformer):\n\n const { rows } = props;\n\n const parsedRows = rows.map((row) =>\n Object.entries(row).reduce((acc, [key, value]) => {\n if (key === \"time\") {\n return {\n ...acc,\n [key]: new Date(value).toLocaleString(),\n };\n }\n\n if (value === null || value === undefined) {\n return {\n ...acc,\n [key]: \"\",\n };\n }\n\n if (typeof value === \"object\") {\n return {\n ...acc,\n [key]: JSON.stringify(value),\n };\n }\n\n return { ...acc, [key]: value };\n }, {} as Record<string, string>)\n );\n\n // Get the keys to use as column headers (checking all the rows for cases where we have different keys):\n const headers = Array.from(new Set(rows.flatMap((row) => Object.keys(row))));\n\n return {\n ...props,\n headers,\n rows: parsedRows,\n } as const;\n};\n\nexport const TableComponent = (props: TransformedTable) => {\n const { headers, rows } = useTablePros(props);\n\n if (!rows.length) {\n return null;\n }\n\n return (\n <TableContainer width={\"100%\"} overflowY={\"auto\"} overflowX={\"auto\"}>\n <Table variant=\"simple\">\n <Thead>\n <Tr>\n {headers.map((key) => (\n <Th key={key}>{key}</Th>\n ))}\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, index) => (\n <Tr key={index}>\n {headers.map((key) => (\n <Td key={key}>{row[key] ?? \"\"}</Td>\n ))}\n </Tr>\n ))}\n </Tbody>\n </Table>\n </TableContainer>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n BindingTemplateInstance,\n} from \"@player-lang/react-dsl\";\nimport type { TableAsset } 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 Table = (\n props: Omit<AssetPropsWithChildren<TableAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"table\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { TableAsset, TransformedTable } 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 tableTransform: TransformFunction<TableAsset, TransformedTable> = (\n asset,\n options\n) => {\n return {\n ...asset,\n rows:\n asset.binding === undefined\n ? []\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,eAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;ACAA,mBAQO;AACP,IAAA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CACH,CACF,GACA,8BAAAA,QAAA,cAAC,0BACE,KAAK,IAAI,CAAC,KAAK,UACd,8BAAAA,QAAA,cAAC,mBAAG,KAAK,SACN,QAAQ,IAAI,CAAC,QACZ,8BAAAA,QAAA,cAAC,mBAAG,OAAW,IAAI,GAAG,KAAK,EAAG,CAC/B,CACH,CACD,CACH,CACF,CACF;AAEJ;;;ACxFA,IAAAC,gBAAkB;AAClB,uBAIO;AAOA,IAAMC,SAAQ,CACnB,UAIG;AACH,QAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI;AAEvC,SACE,8BAAAC,QAAA,cAAC,0BAAM,MAAK,SAAS,GAAG,QACrB,WAAW,8BAAAA,QAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GACvD,QACH;AAEJ;;;ACnBO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MACE,MAAM,YAAY,SACd,CAAC,IACD,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,EACT;AACF;","names":["Table","import_react","React","import_react","Table","React"]}
@@ -53,7 +53,7 @@ var TableComponent = (props) => {
53
53
  import React2 from "react";
54
54
  import {
55
55
  Asset
56
- } from "@player-tools/dsl";
56
+ } from "@player-lang/react-dsl";
57
57
  var Table2 = (props) => {
58
58
  const { binding, children, ...rest } = props;
59
59
  return /* @__PURE__ */ React2.createElement(Asset, { type: "table", ...rest }, binding && /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()), children);
package/dist/index.mjs CHANGED
@@ -53,7 +53,7 @@ var TableComponent = (props) => {
53
53
  import React2 from "react";
54
54
  import {
55
55
  Asset
56
- } from "@player-tools/dsl";
56
+ } from "@player-lang/react-dsl";
57
57
  var Table2 = (props) => {
58
58
  const { binding, children, ...rest } = props;
59
59
  return /* @__PURE__ */ React2.createElement(Asset, { type: "table", ...rest }, binding && /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()), children);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/transform/index.ts"],"sourcesContent":["import {\n Table,\n TableContainer,\n Tbody,\n Td,\n Th,\n Thead,\n Tr,\n} from \"@chakra-ui/react\";\nimport React from \"react\";\nimport type { TransformedTable } from \"../types\";\n\n/**\n * Hook to convert the data we get from the Player Content into the properties our component expects:\n */\nconst useTablePros = (props: TransformedTable) => {\n // Translate the properties we get from the Player Content (DSL > JSON > transformer)\n // into what the elements that compose your component expect (platform-specific, for\n // platform-agnostic transformations, see the transformer):\n\n const { rows } = props;\n\n const parsedRows = rows.map((row) =>\n Object.entries(row).reduce((acc, [key, value]) => {\n if (key === \"time\") {\n return {\n ...acc,\n [key]: new Date(value).toLocaleString(),\n };\n }\n\n if (value === null || value === undefined) {\n return {\n ...acc,\n [key]: \"\",\n };\n }\n\n if (typeof value === \"object\") {\n return {\n ...acc,\n [key]: JSON.stringify(value),\n };\n }\n\n return { ...acc, [key]: value };\n }, {} as Record<string, string>)\n );\n\n // Get the keys to use as column headers (checking all the rows for cases where we have different keys):\n const headers = Array.from(new Set(rows.flatMap((row) => Object.keys(row))));\n\n return {\n ...props,\n headers,\n rows: parsedRows,\n } as const;\n};\n\nexport const TableComponent = (props: TransformedTable) => {\n const { headers, rows } = useTablePros(props);\n\n if (!rows.length) {\n return null;\n }\n\n return (\n <TableContainer width={\"100%\"} overflowY={\"auto\"} overflowX={\"auto\"}>\n <Table variant=\"simple\">\n <Thead>\n <Tr>\n {headers.map((key) => (\n <Th key={key}>{key}</Th>\n ))}\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, index) => (\n <Tr key={index}>\n {headers.map((key) => (\n <Td key={key}>{row[key] ?? \"\"}</Td>\n ))}\n </Tr>\n ))}\n </Tbody>\n </Table>\n </TableContainer>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport type { TableAsset } 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 Table = (\n props: Omit<AssetPropsWithChildren<TableAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"table\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { TableAsset, TransformedTable } 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 tableTransform: TransformFunction<TableAsset, TransformedTable> = (\n asset,\n options\n) => {\n return {\n ...asset,\n rows:\n asset.binding === undefined\n ? []\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n };\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,WAAW;AAMlB,IAAM,eAAe,CAAC,UAA4B;AAKhD,QAAM,EAAE,KAAK,IAAI;AAEjB,QAAM,aAAa,KAAK;AAAA,IAAI,CAAC,QAC3B,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AAChD,UAAI,QAAQ,QAAQ;AAClB,eAAO;AAAA,UACL,GAAG;AAAA,UACH,CAAC,GAAG,GAAG,IAAI,KAAK,KAAK,EAAE,eAAe;AAAA,QACxC;AAAA,MACF;AAEA,UAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,eAAO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vD,QACH;AAEJ;;;ACnBO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MACE,MAAM,YAAY,SACd,CAAC,IACD,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,EACT;AACF;","names":["React","Table"]}
1
+ {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/table/src/transform/index.ts"],"sourcesContent":["import {\n Table,\n TableContainer,\n Tbody,\n Td,\n Th,\n Thead,\n Tr,\n} from \"@chakra-ui/react\";\nimport React from \"react\";\nimport type { TransformedTable } from \"../types\";\n\n/**\n * Hook to convert the data we get from the Player Content into the properties our component expects:\n */\nconst useTablePros = (props: TransformedTable) => {\n // Translate the properties we get from the Player Content (DSL > JSON > transformer)\n // into what the elements that compose your component expect (platform-specific, for\n // platform-agnostic transformations, see the transformer):\n\n const { rows } = props;\n\n const parsedRows = rows.map((row) =>\n Object.entries(row).reduce((acc, [key, value]) => {\n if (key === \"time\") {\n return {\n ...acc,\n [key]: new Date(value).toLocaleString(),\n };\n }\n\n if (value === null || value === undefined) {\n return {\n ...acc,\n [key]: \"\",\n };\n }\n\n if (typeof value === \"object\") {\n return {\n ...acc,\n [key]: JSON.stringify(value),\n };\n }\n\n return { ...acc, [key]: value };\n }, {} as Record<string, string>)\n );\n\n // Get the keys to use as column headers (checking all the rows for cases where we have different keys):\n const headers = Array.from(new Set(rows.flatMap((row) => Object.keys(row))));\n\n return {\n ...props,\n headers,\n rows: parsedRows,\n } as const;\n};\n\nexport const TableComponent = (props: TransformedTable) => {\n const { headers, rows } = useTablePros(props);\n\n if (!rows.length) {\n return null;\n }\n\n return (\n <TableContainer width={\"100%\"} overflowY={\"auto\"} overflowX={\"auto\"}>\n <Table variant=\"simple\">\n <Thead>\n <Tr>\n {headers.map((key) => (\n <Th key={key}>{key}</Th>\n ))}\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, index) => (\n <Tr key={index}>\n {headers.map((key) => (\n <Td key={key}>{row[key] ?? \"\"}</Td>\n ))}\n </Tr>\n ))}\n </Tbody>\n </Table>\n </TableContainer>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n BindingTemplateInstance,\n} from \"@player-lang/react-dsl\";\nimport type { TableAsset } 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 Table = (\n props: Omit<AssetPropsWithChildren<TableAsset>, \"binding\"> & {\n /** The binding */\n binding?: BindingTemplateInstance;\n }\n) => {\n const { binding, children, ...rest } = props;\n\n return (\n <Asset type=\"table\" {...rest}>\n {binding && <property name=\"binding\">{binding.toValue()}</property>}\n {children}\n </Asset>\n );\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { TableAsset, TransformedTable } 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 tableTransform: TransformFunction<TableAsset, TransformedTable> = (\n asset,\n options\n) => {\n return {\n ...asset,\n rows:\n asset.binding === undefined\n ? []\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: false,\n }),\n };\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,WAAW;AAMlB,IAAM,eAAe,CAAC,UAA4B;AAKhD,QAAM,EAAE,KAAK,IAAI;AAEjB,QAAM,aAAa,KAAK;AAAA,IAAI,CAAC,QAC3B,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AA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UAIG;AACH,QAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI;AAEvC,SACE,gBAAAD,OAAA,cAAC,SAAM,MAAK,SAAS,GAAG,QACrB,WAAW,gBAAAA,OAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GACvD,QACH;AAEJ;;;ACnBO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MACE,MAAM,YAAY,SACd,CAAC,IACD,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,EACT;AACF;","names":["React","Table"]}
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
+ "sideEffects": false,
3
+ "files": [
4
+ "dist",
5
+ "src",
6
+ "types"
7
+ ],
2
8
  "name": "@devtools-ui/table",
3
- "version": "0.4.0",
9
+ "version": "0.4.1-next.0",
4
10
  "main": "dist/cjs/index.cjs",
5
11
  "dependencies": {
6
- "@devtools-ui/text": "0.4.0",
7
- "@devtools-ui/collection": "0.4.0",
12
+ "@devtools-ui/text": "0.4.1-next.0",
13
+ "@devtools-ui/collection": "0.4.1-next.0",
8
14
  "@chakra-ui/react": "^2.8.2",
9
15
  "@emotion/react": "^11.11.4",
10
16
  "@emotion/styled": "^11.11.0",
@@ -16,7 +22,6 @@
16
22
  },
17
23
  "module": "dist/index.legacy-esm.js",
18
24
  "types": "types/index.d.ts",
19
- "sideEffects": false,
20
25
  "exports": {
21
26
  "./package.json": "./package.json",
22
27
  "./dist/index.css": "./dist/index.css",
@@ -26,16 +31,11 @@
26
31
  "default": "./dist/cjs/index.cjs"
27
32
  }
28
33
  },
29
- "files": [
30
- "dist",
31
- "src",
32
- "types"
33
- ],
34
34
  "peerDependencies": {
35
- "@player-tools/dsl": "0.7.0-next.3",
36
- "@player-ui/asset-transform-plugin": "0.9.1-next.0",
37
- "@player-ui/player": "0.9.1-next.0",
38
- "@player-ui/react": "0.9.1-next.0",
39
- "@player-ui/types": "0.9.1-next.0"
35
+ "@player-lang/react-dsl": "1.0.1",
36
+ "@player-ui/asset-transform-plugin": "0.15.5",
37
+ "@player-ui/player": "0.15.5",
38
+ "@player-ui/react": "0.15.5",
39
+ "@player-ui/types": "0.15.5"
40
40
  }
41
41
  }
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { describe, expect, test } from "vitest";
3
- import { render, binding as b } from "@player-tools/dsl";
3
+ import { render, binding as b } from "@player-lang/react-dsl";
4
4
  import { Table } from "../";
5
5
 
6
6
  describe("DSL: Table", () => {
package/src/dsl/index.tsx CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  AssetPropsWithChildren,
4
4
  Asset,
5
5
  BindingTemplateInstance,
6
- } from "@player-tools/dsl";
6
+ } from "@player-lang/react-dsl";
7
7
  import type { TableAsset } from "../types";
8
8
 
9
9
  /**
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { AssetPropsWithChildren, BindingTemplateInstance } from "@player-tools/dsl";
2
+ import { AssetPropsWithChildren, BindingTemplateInstance } from "@player-lang/react-dsl";
3
3
  import type { TableAsset } from "../types";
4
4
  /**
5
5
  * Defines the component DSL representation, so users of this plugin can author Player-UI