@devtools-ui/radio-group 0.1.2--canary.27.1288

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.
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ RadioGroup: () => RadioGroup2,
34
+ RadioGroupComponent: () => RadioGroupComponent,
35
+ RadioItem: () => RadioItem,
36
+ radioGroupTransform: () => radioGroupTransform
37
+ });
38
+ module.exports = __toCommonJS(src_exports);
39
+
40
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/component/index.tsx
41
+ var import_react = __toESM(require("react"));
42
+ var import_react2 = require("@chakra-ui/react");
43
+ var import_react3 = require("@player-ui/react");
44
+ var RadioGroupComponent = (props) => {
45
+ const { id, label, setRadio, values } = props;
46
+ return /* @__PURE__ */ import_react.default.createElement(import_react2.RadioGroup, null, label && /* @__PURE__ */ import_react.default.createElement(import_react2.FormLabel, { htmlFor: id }, /* @__PURE__ */ import_react.default.createElement(import_react3.ReactAsset, { ...label.asset })), /* @__PURE__ */ import_react.default.createElement(import_react2.Stack, null, values?.map((radioItem) => {
47
+ const onChange = (e) => {
48
+ setRadio(e.target.value);
49
+ };
50
+ const { value, label: label2 } = radioItem;
51
+ return /* @__PURE__ */ import_react.default.createElement(import_react2.Radio, { key: value, onChange, value }, /* @__PURE__ */ import_react.default.createElement(import_react3.ReactAsset, { ...label2.asset }));
52
+ })));
53
+ };
54
+
55
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/dsl/index.tsx
56
+ var import_react4 = __toESM(require("react"));
57
+ var import_dsl = require("@player-tools/dsl");
58
+ var import_text = require("@devtools-ui/text");
59
+ var RadioGroup2 = (props) => {
60
+ const { children, binding, ...rest } = props;
61
+ return /* @__PURE__ */ import_react4.default.createElement(import_dsl.Asset, { type: "radio-group", ...rest }, /* @__PURE__ */ import_react4.default.createElement("property", { name: "binding" }, binding.toValue()), children);
62
+ };
63
+ var RadioItem = (props) => {
64
+ const { children, ...rest } = props;
65
+ return /* @__PURE__ */ import_react4.default.createElement("obj", null, (0, import_dsl.toJsonProperties)(rest), children);
66
+ };
67
+ RadioItem.Label = (0, import_dsl.createSlot)({
68
+ name: "label",
69
+ TextComp: import_text.Text,
70
+ isArray: false,
71
+ wrapInAsset: true
72
+ });
73
+ var RadioGroupValues = (props) => {
74
+ return /* @__PURE__ */ import_react4.default.createElement("property", { name: "values" }, /* @__PURE__ */ import_react4.default.createElement("array", { ...props }));
75
+ };
76
+ RadioGroup2.Label = (0, import_dsl.createSlot)({
77
+ name: "label",
78
+ TextComp: import_text.Text,
79
+ isArray: false,
80
+ wrapInAsset: true
81
+ });
82
+ RadioGroup2.Values = RadioGroupValues;
83
+ RadioGroupValues.Value = RadioItem;
84
+
85
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/transform/index.ts
86
+ var radioGroupTransform = (asset, options) => {
87
+ return {
88
+ ...asset,
89
+ setRadio(val) {
90
+ if (asset.binding === void 0) {
91
+ return;
92
+ }
93
+ return options.data.model.set([[asset.binding, val]]);
94
+ },
95
+ value: asset.binding === void 0 ? "" : options.data.model.get(asset.binding)
96
+ };
97
+ };
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ RadioGroup,
101
+ RadioGroupComponent,
102
+ RadioItem,
103
+ radioGroupTransform
104
+ });
105
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import React from \"react\";\nimport type { TransformedRadioGroup } from \"../types\";\nimport { RadioGroup, Stack, FormLabel, Radio } from \"@chakra-ui/react\";\nimport { ReactAsset } from \"@player-ui/react\";\n\nexport const RadioGroupComponent = (props: TransformedRadioGroup) => {\n const { id, label, setRadio, values } = props;\n\n return (\n <RadioGroup>\n {label && (\n <FormLabel htmlFor={id}>\n <ReactAsset {...label.asset} />\n </FormLabel>\n )}\n <Stack>\n {values?.map((radioItem) => {\n const onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n setRadio(e.target.value);\n };\n const { value, label } = radioItem;\n\n return (\n <Radio key={value} onChange={onChange} value={value}>\n <ReactAsset {...label.asset} />\n </Radio>\n );\n })}\n </Stack>\n </RadioGroup>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n WithTemplateTypes,\n WithChildren,\n toJsonProperties,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { RadioGroupAsset, RadioItemAsset } from \"../types\";\n\nexport const RadioGroup = (\n props: Omit<AssetPropsWithChildren<RadioGroupAsset>, \"binding\"> & {\n /** The binding as a tagged template instance */\n binding: BindingTemplateInstance;\n }\n) => {\n const { children, binding, ...rest } = props;\n\n return (\n <Asset type=\"radio-group\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nexport const RadioItem = (\n props: Partial<WithChildren<WithTemplateTypes<RadioItemAsset>>>\n) => {\n const { children, ...rest } = props;\n return (\n <obj>\n {toJsonProperties(rest)}\n {children}\n </obj>\n );\n};\n\nRadioItem.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n isArray: false,\n wrapInAsset: true,\n});\n\nconst RadioGroupValues = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <property name=\"values\">\n <array {...props} />\n </property>\n );\n};\n\nRadioGroup.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n isArray: false,\n wrapInAsset: true,\n});\n\nRadioGroup.Values = RadioGroupValues;\nRadioGroupValues.Value = RadioItem;\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { RadioGroupAsset, TransformedRadioGroup } from \"../types\";\n\nexport const radioGroupTransform: TransformFunction<\n RadioGroupAsset,\n TransformedRadioGroup\n> = (asset, options) => {\n return {\n ...asset,\n setRadio(val) {\n if (asset.binding === undefined) {\n return;\n }\n\n return options.data.model.set([[asset.binding, val]]);\n },\n value:\n asset.binding === undefined ? \"\" : options.data.model.get(asset.binding),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAElB,IAAAC,gBAAoD;AACpD,IAAAA,gBAA2B;AAEpB,IAAM,sBAAsB,CAAC,UAAiC;AACnE,QAAM,EAAE,IAAI,OAAO,UAAU,OAAO,IAAI;AAExC,SACE,6BAAAC,QAAA,cAAC,gCACE,SACC,6BAAAA,QAAA,cAAC,2BAAU,SAAS,MAClB,6BAAAA,QAAA,cAAC,4BAAY,GAAG,MAAM,OAAO,CAC/B,GAEF,6BAAAA,QAAA,cAAC,2BACE,QAAQ,IAAI,CAAC,cAAc;AAC1B,UAAM,WAAuD,CAAC,MAAM;AAClE,eAAS,EAAE,OAAO,KAAK;AAAA,IACzB;AACA,UAAM,EAAE,OAAO,OAAAC,OAAM,IAAI;AAEzB,WACE,6BAAAD,QAAA,cAAC,uBAAM,KAAK,OAAO,UAAoB,SACrC,6BAAAA,QAAA,cAAC,4BAAY,GAAGC,OAAM,OAAO,CAC/B;AAAA,EAEJ,CAAC,CACH,CACF;AAEJ;;;AC/BA,IAAAC,gBAAkB;AAClB,iBAQO;AAEP,kBAAqB;AAGd,IAAMC,cAAa,CACxB,UAIG;AACH,QAAM,EAAE,UAAU,SAAS,GAAG,KAAK,IAAI;AAEvC,SACE,8BAAAC,QAAA,cAAC,oBAAM,MAAK,eAAe,GAAG,QAC5B,8BAAAA,QAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GAC3C,QACH;AAEJ;AAEO,IAAM,YAAY,CACvB,UACG;AACH,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,SACE,8BAAAA,QAAA,cAAC,iBACE,6BAAiB,IAAI,GACrB,QACH;AAEJ;AAEA,UAAU,YAAQ,uBAAW;AAAA,EAC3B,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAED,IAAM,mBAAmB,CAAC,UAA6C;AACrE,SACE,8BAAAA,QAAA,cAAC,cAAS,MAAK,YACb,8BAAAA,QAAA,cAAC,WAAO,GAAG,OAAO,CACpB;AAEJ;AAEAD,YAAW,YAAQ,uBAAW;AAAA,EAC5B,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAEDA,YAAW,SAAS;AACpB,iBAAiB,QAAQ;;;AC9DlB,IAAM,sBAGT,CAAC,OAAO,YAAY;AACtB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,KAAK;AACZ,UAAI,MAAM,YAAY,QAAW;AAC/B;AAAA,MACF;AAEA,aAAO,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAAA,IACtD;AAAA,IACA,OACE,MAAM,YAAY,SAAY,KAAK,QAAQ,KAAK,MAAM,IAAI,MAAM,OAAO;AAAA,EAC3E;AACF;","names":["RadioGroup","import_react","React","label","import_react","RadioGroup","React"]}
@@ -0,0 +1,69 @@
1
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/component/index.tsx
2
+ import React from "react";
3
+ import { RadioGroup, Stack, FormLabel, Radio } from "@chakra-ui/react";
4
+ import { ReactAsset } from "@player-ui/react";
5
+ var RadioGroupComponent = (props) => {
6
+ const { id, label, setRadio, values } = props;
7
+ return /* @__PURE__ */ React.createElement(RadioGroup, null, label && /* @__PURE__ */ React.createElement(FormLabel, { htmlFor: id }, /* @__PURE__ */ React.createElement(ReactAsset, { ...label.asset })), /* @__PURE__ */ React.createElement(Stack, null, values?.map((radioItem) => {
8
+ const onChange = (e) => {
9
+ setRadio(e.target.value);
10
+ };
11
+ const { value, label: label2 } = radioItem;
12
+ return /* @__PURE__ */ React.createElement(Radio, { key: value, onChange, value }, /* @__PURE__ */ React.createElement(ReactAsset, { ...label2.asset }));
13
+ })));
14
+ };
15
+
16
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/dsl/index.tsx
17
+ import React2 from "react";
18
+ import {
19
+ Asset,
20
+ createSlot,
21
+ toJsonProperties
22
+ } from "@player-tools/dsl";
23
+ import { Text } from "@devtools-ui/text";
24
+ var RadioGroup2 = (props) => {
25
+ const { children, binding, ...rest } = props;
26
+ return /* @__PURE__ */ React2.createElement(Asset, { type: "radio-group", ...rest }, /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()), children);
27
+ };
28
+ var RadioItem = (props) => {
29
+ const { children, ...rest } = props;
30
+ return /* @__PURE__ */ React2.createElement("obj", null, toJsonProperties(rest), children);
31
+ };
32
+ RadioItem.Label = createSlot({
33
+ name: "label",
34
+ TextComp: Text,
35
+ isArray: false,
36
+ wrapInAsset: true
37
+ });
38
+ var RadioGroupValues = (props) => {
39
+ return /* @__PURE__ */ React2.createElement("property", { name: "values" }, /* @__PURE__ */ React2.createElement("array", { ...props }));
40
+ };
41
+ RadioGroup2.Label = createSlot({
42
+ name: "label",
43
+ TextComp: Text,
44
+ isArray: false,
45
+ wrapInAsset: true
46
+ });
47
+ RadioGroup2.Values = RadioGroupValues;
48
+ RadioGroupValues.Value = RadioItem;
49
+
50
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/transform/index.ts
51
+ var radioGroupTransform = (asset, options) => {
52
+ return {
53
+ ...asset,
54
+ setRadio(val) {
55
+ if (asset.binding === void 0) {
56
+ return;
57
+ }
58
+ return options.data.model.set([[asset.binding, val]]);
59
+ },
60
+ value: asset.binding === void 0 ? "" : options.data.model.get(asset.binding)
61
+ };
62
+ };
63
+ export {
64
+ RadioGroup2 as RadioGroup,
65
+ RadioGroupComponent,
66
+ RadioItem,
67
+ radioGroupTransform
68
+ };
69
+ //# sourceMappingURL=index.mjs.map
package/dist/index.mjs ADDED
@@ -0,0 +1,69 @@
1
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/component/index.tsx
2
+ import React from "react";
3
+ import { RadioGroup, Stack, FormLabel, Radio } from "@chakra-ui/react";
4
+ import { ReactAsset } from "@player-ui/react";
5
+ var RadioGroupComponent = (props) => {
6
+ const { id, label, setRadio, values } = props;
7
+ return /* @__PURE__ */ React.createElement(RadioGroup, null, label && /* @__PURE__ */ React.createElement(FormLabel, { htmlFor: id }, /* @__PURE__ */ React.createElement(ReactAsset, { ...label.asset })), /* @__PURE__ */ React.createElement(Stack, null, values?.map((radioItem) => {
8
+ const onChange = (e) => {
9
+ setRadio(e.target.value);
10
+ };
11
+ const { value, label: label2 } = radioItem;
12
+ return /* @__PURE__ */ React.createElement(Radio, { key: value, onChange, value }, /* @__PURE__ */ React.createElement(ReactAsset, { ...label2.asset }));
13
+ })));
14
+ };
15
+
16
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/dsl/index.tsx
17
+ import React2 from "react";
18
+ import {
19
+ Asset,
20
+ createSlot,
21
+ toJsonProperties
22
+ } from "@player-tools/dsl";
23
+ import { Text } from "@devtools-ui/text";
24
+ var RadioGroup2 = (props) => {
25
+ const { children, binding, ...rest } = props;
26
+ return /* @__PURE__ */ React2.createElement(Asset, { type: "radio-group", ...rest }, /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()), children);
27
+ };
28
+ var RadioItem = (props) => {
29
+ const { children, ...rest } = props;
30
+ return /* @__PURE__ */ React2.createElement("obj", null, toJsonProperties(rest), children);
31
+ };
32
+ RadioItem.Label = createSlot({
33
+ name: "label",
34
+ TextComp: Text,
35
+ isArray: false,
36
+ wrapInAsset: true
37
+ });
38
+ var RadioGroupValues = (props) => {
39
+ return /* @__PURE__ */ React2.createElement("property", { name: "values" }, /* @__PURE__ */ React2.createElement("array", { ...props }));
40
+ };
41
+ RadioGroup2.Label = createSlot({
42
+ name: "label",
43
+ TextComp: Text,
44
+ isArray: false,
45
+ wrapInAsset: true
46
+ });
47
+ RadioGroup2.Values = RadioGroupValues;
48
+ RadioGroupValues.Value = RadioItem;
49
+
50
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/transform/index.ts
51
+ var radioGroupTransform = (asset, options) => {
52
+ return {
53
+ ...asset,
54
+ setRadio(val) {
55
+ if (asset.binding === void 0) {
56
+ return;
57
+ }
58
+ return options.data.model.set([[asset.binding, val]]);
59
+ },
60
+ value: asset.binding === void 0 ? "" : options.data.model.get(asset.binding)
61
+ };
62
+ };
63
+ export {
64
+ RadioGroup2 as RadioGroup,
65
+ RadioGroupComponent,
66
+ RadioItem,
67
+ radioGroupTransform
68
+ };
69
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/radio-group/src/transform/index.ts"],"sourcesContent":["import React from \"react\";\nimport type { TransformedRadioGroup } from \"../types\";\nimport { RadioGroup, Stack, FormLabel, Radio } from \"@chakra-ui/react\";\nimport { ReactAsset } from \"@player-ui/react\";\n\nexport const RadioGroupComponent = (props: TransformedRadioGroup) => {\n const { id, label, setRadio, values } = props;\n\n return (\n <RadioGroup>\n {label && (\n <FormLabel htmlFor={id}>\n <ReactAsset {...label.asset} />\n </FormLabel>\n )}\n <Stack>\n {values?.map((radioItem) => {\n const onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n setRadio(e.target.value);\n };\n const { value, label } = radioItem;\n\n return (\n <Radio key={value} onChange={onChange} value={value}>\n <ReactAsset {...label.asset} />\n </Radio>\n );\n })}\n </Stack>\n </RadioGroup>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n WithTemplateTypes,\n WithChildren,\n toJsonProperties,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { RadioGroupAsset, RadioItemAsset } from \"../types\";\n\nexport const RadioGroup = (\n props: Omit<AssetPropsWithChildren<RadioGroupAsset>, \"binding\"> & {\n /** The binding as a tagged template instance */\n binding: BindingTemplateInstance;\n }\n) => {\n const { children, binding, ...rest } = props;\n\n return (\n <Asset type=\"radio-group\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nexport const RadioItem = (\n props: Partial<WithChildren<WithTemplateTypes<RadioItemAsset>>>\n) => {\n const { children, ...rest } = props;\n return (\n <obj>\n {toJsonProperties(rest)}\n {children}\n </obj>\n );\n};\n\nRadioItem.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n isArray: false,\n wrapInAsset: true,\n});\n\nconst RadioGroupValues = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <property name=\"values\">\n <array {...props} />\n </property>\n );\n};\n\nRadioGroup.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n isArray: false,\n wrapInAsset: true,\n});\n\nRadioGroup.Values = RadioGroupValues;\nRadioGroupValues.Value = RadioItem;\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { RadioGroupAsset, TransformedRadioGroup } from \"../types\";\n\nexport const radioGroupTransform: TransformFunction<\n RadioGroupAsset,\n TransformedRadioGroup\n> = (asset, options) => {\n return {\n ...asset,\n setRadio(val) {\n if (asset.binding === undefined) {\n return;\n }\n\n return options.data.model.set([[asset.binding, val]]);\n },\n value:\n asset.binding === undefined ? \"\" : options.data.model.get(asset.binding),\n };\n};\n"],"mappings":";AAAA,OAAO,WAAW;AAElB,SAAS,YAAY,OAAO,WAAW,aAAa;AACpD,SAAS,kBAAkB;AAEpB,IAAM,sBAAsB,CAAC,UAAiC;AACnE,QAAM,EAAE,IAAI,OAAO,UAAU,OAAO,IAAI;AAExC,SACE,oCAAC,kBACE,SACC,oCAAC,aAAU,SAAS,MAClB,oCAAC,cAAY,GAAG,MAAM,OAAO,CAC/B,GAEF,oCAAC,aACE,QAAQ,IAAI,CAAC,cAAc;AAC1B,UAAM,WAAuD,CAAC,MAAM;AAClE,eAAS,EAAE,OAAO,KAAK;AAAA,IACzB;AACA,UAAM,EAAE,OAAO,OAAAA,OAAM,IAAI;AAEzB,WACE,oCAAC,SAAM,KAAK,OAAO,UAAoB,SACrC,oCAAC,cAAY,GAAGA,OAAM,OAAO,CAC/B;AAAA,EAEJ,CAAC,CACH,CACF;AAEJ;;;AC/BA,OAAOC,YAAW;AAClB;AAAA,EAEE;AAAA,EACA;AAAA,EAIA;AAAA,OACK;AAEP,SAAS,YAAY;AAGd,IAAMC,cAAa,CACxB,UAIG;AACH,QAAM,EAAE,UAAU,SAAS,GAAG,KAAK,IAAI;AAEvC,SACE,gBAAAD,OAAA,cAAC,SAAM,MAAK,eAAe,GAAG,QAC5B,gBAAAA,OAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GAC3C,QACH;AAEJ;AAEO,IAAM,YAAY,CACvB,UACG;AACH,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,SACE,gBAAAA,OAAA,cAAC,aACE,iBAAiB,IAAI,GACrB,QACH;AAEJ;AAEA,UAAU,QAAQ,WAAW;AAAA,EAC3B,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAED,IAAM,mBAAmB,CAAC,UAA6C;AACrE,SACE,gBAAAA,OAAA,cAAC,cAAS,MAAK,YACb,gBAAAA,OAAA,cAAC,WAAO,GAAG,OAAO,CACpB;AAEJ;AAEAC,YAAW,QAAQ,WAAW;AAAA,EAC5B,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAEDA,YAAW,SAAS;AACpB,iBAAiB,QAAQ;;;AC9DlB,IAAM,sBAGT,CAAC,OAAO,YAAY;AACtB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,KAAK;AACZ,UAAI,MAAM,YAAY,QAAW;AAC/B;AAAA,MACF;AAEA,aAAO,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAAA,IACtD;AAAA,IACA,OACE,MAAM,YAAY,SAAY,KAAK,QAAQ,KAAK,MAAM,IAAI,MAAM,OAAO;AAAA,EAC3E;AACF;","names":["label","React","RadioGroup"]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@devtools-ui/radio-group",
3
+ "version": "0.1.2--canary.27.1288",
4
+ "main": "dist/cjs/index.cjs",
5
+ "dependencies": {
6
+ "@devtools-ui/text": "0.1.2--canary.27.1288",
7
+ "@devtools-ui/collection": "0.1.2--canary.27.1288",
8
+ "@chakra-ui/react": "^2.8.2",
9
+ "@emotion/react": "^11.11.4",
10
+ "@emotion/styled": "^11.11.0",
11
+ "@player-tools/dsl": "0.6.0-next.2",
12
+ "@player-ui/asset-transform-plugin": "0.7.3",
13
+ "@player-ui/player": "0.7.3",
14
+ "@player-ui/react": "0.7.3",
15
+ "@player-ui/types": "0.7.3",
16
+ "@types/react": "^18.2.51",
17
+ "dlv": "^1.1.3",
18
+ "framer-motion": "^11.0.8",
19
+ "react": "^18.2.0",
20
+ "tslib": "^2.6.2"
21
+ },
22
+ "module": "dist/index.legacy-esm.js",
23
+ "types": "types/index.d.ts",
24
+ "sideEffects": false,
25
+ "exports": {
26
+ "./package.json": "./package.json",
27
+ "./dist/index.css": "./dist/index.css",
28
+ ".": {
29
+ "types": "./types/index.d.ts",
30
+ "import": "./dist/index.mjs",
31
+ "default": "./dist/cjs/index.cjs"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "src",
37
+ "types"
38
+ ],
39
+ "peerDependencies": {}
40
+ }
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import type { TransformedRadioGroup } from "../types";
3
+ import { RadioGroup, Stack, FormLabel, Radio } from "@chakra-ui/react";
4
+ import { ReactAsset } from "@player-ui/react";
5
+
6
+ export const RadioGroupComponent = (props: TransformedRadioGroup) => {
7
+ const { id, label, setRadio, values } = props;
8
+
9
+ return (
10
+ <RadioGroup>
11
+ {label && (
12
+ <FormLabel htmlFor={id}>
13
+ <ReactAsset {...label.asset} />
14
+ </FormLabel>
15
+ )}
16
+ <Stack>
17
+ {values?.map((radioItem) => {
18
+ const onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
19
+ setRadio(e.target.value);
20
+ };
21
+ const { value, label } = radioItem;
22
+
23
+ return (
24
+ <Radio key={value} onChange={onChange} value={value}>
25
+ <ReactAsset {...label.asset} />
26
+ </Radio>
27
+ );
28
+ })}
29
+ </Stack>
30
+ </RadioGroup>
31
+ );
32
+ };
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { describe, expect, test } from "vitest";
3
+ import { render, binding as b } from "@player-tools/dsl";
4
+ import { RadioGroup } from "../";
5
+
6
+ describe("DSL: RadioGroup", () => {
7
+ test("Renders radioGroup with a couple options", async () => {
8
+ const rendered = await render(
9
+ <RadioGroup binding={b`my_binding`}>
10
+ <RadioGroup.Label>RadioGroup Label</RadioGroup.Label>
11
+ <RadioGroup.Values>
12
+ <RadioGroup.Values.Value value="opt1">
13
+ <RadioGroup.Values.Value.Label>
14
+ Option 1
15
+ </RadioGroup.Values.Value.Label>
16
+ </RadioGroup.Values.Value>
17
+ <RadioGroup.Values.Value value="opt2">
18
+ <RadioGroup.Values.Value.Label>
19
+ Option 2
20
+ </RadioGroup.Values.Value.Label>
21
+ </RadioGroup.Values.Value>
22
+ </RadioGroup.Values>
23
+ </RadioGroup>
24
+ );
25
+
26
+ expect(rendered.jsonValue).toStrictEqual({
27
+ id: "root",
28
+ type: "radio-group",
29
+ binding: "my_binding",
30
+ label: {
31
+ asset: {
32
+ id: "label",
33
+ type: "text",
34
+ value: "RadioGroup Label",
35
+ },
36
+ },
37
+ values: [
38
+ {
39
+ label: {
40
+ asset: {
41
+ id: "label",
42
+ type: "text",
43
+ value: "Option 1",
44
+ },
45
+ },
46
+ value: "opt1",
47
+ },
48
+ {
49
+ label: {
50
+ asset: {
51
+ id: "label",
52
+ type: "text",
53
+ value: "Option 2",
54
+ },
55
+ },
56
+ value: "opt2",
57
+ },
58
+ ],
59
+ });
60
+ });
61
+ });
@@ -0,0 +1,66 @@
1
+ import React from "react";
2
+ import {
3
+ AssetPropsWithChildren,
4
+ Asset,
5
+ createSlot,
6
+ BindingTemplateInstance,
7
+ WithTemplateTypes,
8
+ WithChildren,
9
+ toJsonProperties,
10
+ } from "@player-tools/dsl";
11
+ import type { Asset as AssetType } from "@player-ui/player";
12
+ import { Text } from "@devtools-ui/text";
13
+ import type { RadioGroupAsset, RadioItemAsset } from "../types";
14
+
15
+ export const RadioGroup = (
16
+ props: Omit<AssetPropsWithChildren<RadioGroupAsset>, "binding"> & {
17
+ /** The binding as a tagged template instance */
18
+ binding: BindingTemplateInstance;
19
+ }
20
+ ) => {
21
+ const { children, binding, ...rest } = props;
22
+
23
+ return (
24
+ <Asset type="radio-group" {...rest}>
25
+ <property name="binding">{binding.toValue()}</property>
26
+ {children}
27
+ </Asset>
28
+ );
29
+ };
30
+
31
+ export const RadioItem = (
32
+ props: Partial<WithChildren<WithTemplateTypes<RadioItemAsset>>>
33
+ ) => {
34
+ const { children, ...rest } = props;
35
+ return (
36
+ <obj>
37
+ {toJsonProperties(rest)}
38
+ {children}
39
+ </obj>
40
+ );
41
+ };
42
+
43
+ RadioItem.Label = createSlot({
44
+ name: "label",
45
+ TextComp: Text,
46
+ isArray: false,
47
+ wrapInAsset: true,
48
+ });
49
+
50
+ const RadioGroupValues = (props: AssetPropsWithChildren<AssetType>) => {
51
+ return (
52
+ <property name="values">
53
+ <array {...props} />
54
+ </property>
55
+ );
56
+ };
57
+
58
+ RadioGroup.Label = createSlot({
59
+ name: "label",
60
+ TextComp: Text,
61
+ isArray: false,
62
+ wrapInAsset: true,
63
+ });
64
+
65
+ RadioGroup.Values = RadioGroupValues;
66
+ RadioGroupValues.Value = RadioItem;
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./component";
3
+ export * from "./dsl";
4
+ export * from "./transform";
@@ -0,0 +1,20 @@
1
+ import type { TransformFunction } from "@player-ui/player";
2
+ import { RadioGroupAsset, TransformedRadioGroup } from "../types";
3
+
4
+ export const radioGroupTransform: TransformFunction<
5
+ RadioGroupAsset,
6
+ TransformedRadioGroup
7
+ > = (asset, options) => {
8
+ return {
9
+ ...asset,
10
+ setRadio(val) {
11
+ if (asset.binding === undefined) {
12
+ return;
13
+ }
14
+
15
+ return options.data.model.set([[asset.binding, val]]);
16
+ },
17
+ value:
18
+ asset.binding === undefined ? "" : options.data.model.get(asset.binding),
19
+ };
20
+ };
@@ -0,0 +1,26 @@
1
+ import type { Asset, AssetWrapper } from "@player-ui/types";
2
+
3
+ export interface RadioItemAsset<AnyAsset extends Asset = Asset> {
4
+ /** Value */
5
+ value: string;
6
+ /** Label */
7
+ label: AssetWrapper<AnyAsset>;
8
+ }
9
+
10
+ export interface RadioGroupAsset<AnyAsset extends Asset = Asset>
11
+ extends Asset<"radio-group"> {
12
+ /** list of assets in the collection */
13
+ values?: Array<RadioItemAsset<AnyAsset>>;
14
+ /** Label */
15
+ label?: AssetWrapper<AnyAsset>;
16
+ /** Dot sepparated string Representation of a path within the data-model */
17
+ binding?: string;
18
+ }
19
+
20
+ /** A stateful instance of the asset */
21
+ export interface TransformedRadioGroup extends RadioGroupAsset {
22
+ /** A function to commit the new value to the data-model */
23
+ setRadio: (newValue: string) => void;
24
+ /** The current value of the radio group from the data-model */
25
+ value: string;
26
+ }
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { TransformedRadioGroup } from "../types";
3
+ export declare const RadioGroupComponent: (props: TransformedRadioGroup) => React.JSX.Element;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import { AssetPropsWithChildren, BindingTemplateInstance, WithTemplateTypes, WithChildren } from "@player-tools/dsl";
3
+ import type { Asset as AssetType } from "@player-ui/player";
4
+ import type { RadioGroupAsset, RadioItemAsset } from "../types";
5
+ export declare const RadioGroup: {
6
+ (props: Omit<AssetPropsWithChildren<RadioGroupAsset>, "binding"> & {
7
+ /** The binding as a tagged template instance */
8
+ binding: BindingTemplateInstance;
9
+ }): React.JSX.Element;
10
+ Label: (props: {
11
+ children?: React.ReactNode;
12
+ }) => React.JSX.Element;
13
+ Values: {
14
+ (props: AssetPropsWithChildren<AssetType>): React.JSX.Element;
15
+ Value: {
16
+ (props: Partial<WithChildren<WithTemplateTypes<RadioItemAsset>>>): React.JSX.Element;
17
+ Label: (props: {
18
+ children?: React.ReactNode;
19
+ }) => React.JSX.Element;
20
+ };
21
+ };
22
+ };
23
+ export declare const RadioItem: {
24
+ (props: Partial<WithChildren<WithTemplateTypes<RadioItemAsset>>>): React.JSX.Element;
25
+ Label: (props: {
26
+ children?: React.ReactNode;
27
+ }) => React.JSX.Element;
28
+ };
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from "./types";
2
+ export * from "./component";
3
+ export * from "./dsl";
4
+ export * from "./transform";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { TransformFunction } from "@player-ui/player";
2
+ import { RadioGroupAsset, TransformedRadioGroup } from "../types";
3
+ export declare const radioGroupTransform: TransformFunction<RadioGroupAsset, TransformedRadioGroup>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,23 @@
1
+ import type { Asset, AssetWrapper } from "@player-ui/types";
2
+ export interface RadioItemAsset<AnyAsset extends Asset = Asset> {
3
+ /** Value */
4
+ value: string;
5
+ /** Label */
6
+ label: AssetWrapper<AnyAsset>;
7
+ }
8
+ export interface RadioGroupAsset<AnyAsset extends Asset = Asset> extends Asset<"radio-group"> {
9
+ /** list of assets in the collection */
10
+ values?: Array<RadioItemAsset<AnyAsset>>;
11
+ /** Label */
12
+ label?: AssetWrapper<AnyAsset>;
13
+ /** Dot sepparated string Representation of a path within the data-model */
14
+ binding?: string;
15
+ }
16
+ /** A stateful instance of the asset */
17
+ export interface TransformedRadioGroup extends RadioGroupAsset {
18
+ /** A function to commit the new value to the data-model */
19
+ setRadio: (newValue: string) => void;
20
+ /** The current value of the radio group from the data-model */
21
+ value: string;
22
+ }
23
+ //# sourceMappingURL=index.d.ts.map