@devtools-ui/toggle 0.1.1-next.2

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,85 @@
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/toggle/src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Toggle: () => Toggle,
34
+ ToggleComponent: () => ToggleComponent,
35
+ toggleTransform: () => toggleTransform
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+
39
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/component/index.tsx
40
+ var import_react = __toESM(require("react"));
41
+ var import_react2 = require("@chakra-ui/react");
42
+ var import_react3 = require("@player-ui/react");
43
+ var ToggleComponent = (props) => {
44
+ const { value, label, id, setCheck } = props;
45
+ const onChange = (e) => {
46
+ setCheck(e.target.checked);
47
+ };
48
+ return /* @__PURE__ */ import_react.default.createElement(import_react2.FormControl, { display: "flex", alignItems: "center" }, 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.Switch, { id, onChange }));
49
+ };
50
+
51
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/dsl/index.tsx
52
+ var import_react4 = __toESM(require("react"));
53
+ var import_dsl = require("@player-tools/dsl");
54
+ var import_text = require("@devtools-ui/text");
55
+ var Toggle = (props) => {
56
+ const { children, binding, ...rest } = props;
57
+ return /* @__PURE__ */ import_react4.default.createElement(import_dsl.Asset, { type: "toggle", ...rest }, /* @__PURE__ */ import_react4.default.createElement("property", { name: "binding" }, binding.toValue()), props.children);
58
+ };
59
+ Toggle.Label = (0, import_dsl.createSlot)({
60
+ name: "label",
61
+ TextComp: import_text.Text,
62
+ isArray: false,
63
+ wrapInAsset: true
64
+ });
65
+
66
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/transform/index.ts
67
+ var toggleTransform = (asset, options) => {
68
+ return {
69
+ ...asset,
70
+ setCheck(val) {
71
+ if (asset.binding === void 0) {
72
+ return;
73
+ }
74
+ return options.data.model.set([[asset.binding, val]]);
75
+ },
76
+ value: asset.binding === void 0 ? "" : options.data.model.get(asset.binding)
77
+ };
78
+ };
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ Toggle,
82
+ ToggleComponent,
83
+ toggleTransform
84
+ });
85
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/component/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/dsl/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/transform/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./component\";\nexport * from \"./dsl\";\nexport * from \"./transform\";\n","import React from \"react\";\nimport { Switch, FormControl, FormLabel } from \"@chakra-ui/react\";\nimport { ReactAsset } from \"@player-ui/react\";\nimport type { TransformedToggle } from \"../types\";\n\nexport const ToggleComponent = (props: TransformedToggle) => {\n const { value, label, id, setCheck } = props;\n\n const onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n setCheck(e.target.checked);\n };\n\n return (\n <FormControl display=\"flex\" alignItems=\"center\">\n {label && (\n <FormLabel htmlFor={id}>\n <ReactAsset {...label.asset} />\n </FormLabel>\n )}\n <Switch id={id} onChange={onChange} />\n </FormControl>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { ToggleAsset } from \"../types\";\n\nexport const Toggle = (\n props: Omit<AssetPropsWithChildren<ToggleAsset>, \"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=\"toggle\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {props.children}\n </Asset>\n );\n};\n\nToggle.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n isArray: false,\n wrapInAsset: true,\n});\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { ToggleAsset, TransformedToggle } from \"../types\";\n\nexport const toggleTransform: TransformFunction<\n ToggleAsset,\n TransformedToggle\n> = (asset, options) => {\n return {\n ...asset,\n setCheck(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;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,IAAAA,gBAA+C;AAC/C,IAAAA,gBAA2B;AAGpB,IAAM,kBAAkB,CAAC,UAA6B;AAC3D,QAAM,EAAE,OAAO,OAAO,IAAI,SAAS,IAAI;AAEvC,QAAM,WAAuD,CAAC,MAAM;AAClE,aAAS,EAAE,OAAO,OAAO;AAAA,EAC3B;AAEA,SACE,6BAAAC,QAAA,cAAC,6BAAY,SAAQ,QAAO,YAAW,YACpC,SACC,6BAAAA,QAAA,cAAC,2BAAU,SAAS,MAClB,6BAAAA,QAAA,cAAC,4BAAY,GAAG,MAAM,OAAO,CAC/B,GAEF,6BAAAA,QAAA,cAAC,wBAAO,IAAQ,UAAoB,CACtC;AAEJ;;;ACtBA,IAAAC,gBAAkB;AAClB,iBAKO;AACP,kBAAqB;AAGd,IAAM,SAAS,CACpB,UAIG;AACH,QAAM,EAAE,UAAU,SAAS,GAAG,KAAK,IAAI;AAEvC,SACE,8BAAAC,QAAA,cAAC,oBAAM,MAAK,UAAU,GAAG,QACvB,8BAAAA,QAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GAC3C,MAAM,QACT;AAEJ;AAEA,OAAO,YAAQ,uBAAW;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf,CAAC;;;AC5BM,IAAM,kBAGT,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":["import_react","React","import_react","React"]}
@@ -0,0 +1,49 @@
1
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/component/index.tsx
2
+ import React from "react";
3
+ import { Switch, FormControl, FormLabel } from "@chakra-ui/react";
4
+ import { ReactAsset } from "@player-ui/react";
5
+ var ToggleComponent = (props) => {
6
+ const { value, label, id, setCheck } = props;
7
+ const onChange = (e) => {
8
+ setCheck(e.target.checked);
9
+ };
10
+ return /* @__PURE__ */ React.createElement(FormControl, { display: "flex", alignItems: "center" }, label && /* @__PURE__ */ React.createElement(FormLabel, { htmlFor: id }, /* @__PURE__ */ React.createElement(ReactAsset, { ...label.asset })), /* @__PURE__ */ React.createElement(Switch, { id, onChange }));
11
+ };
12
+
13
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/dsl/index.tsx
14
+ import React2 from "react";
15
+ import {
16
+ Asset,
17
+ createSlot
18
+ } from "@player-tools/dsl";
19
+ import { Text } from "@devtools-ui/text";
20
+ var Toggle = (props) => {
21
+ const { children, binding, ...rest } = props;
22
+ return /* @__PURE__ */ React2.createElement(Asset, { type: "toggle", ...rest }, /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()), props.children);
23
+ };
24
+ Toggle.Label = createSlot({
25
+ name: "label",
26
+ TextComp: Text,
27
+ isArray: false,
28
+ wrapInAsset: true
29
+ });
30
+
31
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/transform/index.ts
32
+ var toggleTransform = (asset, options) => {
33
+ return {
34
+ ...asset,
35
+ setCheck(val) {
36
+ if (asset.binding === void 0) {
37
+ return;
38
+ }
39
+ return options.data.model.set([[asset.binding, val]]);
40
+ },
41
+ value: asset.binding === void 0 ? "" : options.data.model.get(asset.binding)
42
+ };
43
+ };
44
+ export {
45
+ Toggle,
46
+ ToggleComponent,
47
+ toggleTransform
48
+ };
49
+ //# sourceMappingURL=index.mjs.map
package/dist/index.mjs ADDED
@@ -0,0 +1,49 @@
1
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/component/index.tsx
2
+ import React from "react";
3
+ import { Switch, FormControl, FormLabel } from "@chakra-ui/react";
4
+ import { ReactAsset } from "@player-ui/react";
5
+ var ToggleComponent = (props) => {
6
+ const { value, label, id, setCheck } = props;
7
+ const onChange = (e) => {
8
+ setCheck(e.target.checked);
9
+ };
10
+ return /* @__PURE__ */ React.createElement(FormControl, { display: "flex", alignItems: "center" }, label && /* @__PURE__ */ React.createElement(FormLabel, { htmlFor: id }, /* @__PURE__ */ React.createElement(ReactAsset, { ...label.asset })), /* @__PURE__ */ React.createElement(Switch, { id, onChange }));
11
+ };
12
+
13
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/dsl/index.tsx
14
+ import React2 from "react";
15
+ import {
16
+ Asset,
17
+ createSlot
18
+ } from "@player-tools/dsl";
19
+ import { Text } from "@devtools-ui/text";
20
+ var Toggle = (props) => {
21
+ const { children, binding, ...rest } = props;
22
+ return /* @__PURE__ */ React2.createElement(Asset, { type: "toggle", ...rest }, /* @__PURE__ */ React2.createElement("property", { name: "binding" }, binding.toValue()), props.children);
23
+ };
24
+ Toggle.Label = createSlot({
25
+ name: "label",
26
+ TextComp: Text,
27
+ isArray: false,
28
+ wrapInAsset: true
29
+ });
30
+
31
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/transform/index.ts
32
+ var toggleTransform = (asset, options) => {
33
+ return {
34
+ ...asset,
35
+ setCheck(val) {
36
+ if (asset.binding === void 0) {
37
+ return;
38
+ }
39
+ return options.data.model.set([[asset.binding, val]]);
40
+ },
41
+ value: asset.binding === void 0 ? "" : options.data.model.get(asset.binding)
42
+ };
43
+ };
44
+ export {
45
+ Toggle,
46
+ ToggleComponent,
47
+ toggleTransform
48
+ };
49
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/component/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/dsl/index.tsx","../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/toggle/src/transform/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Switch, FormControl, FormLabel } from \"@chakra-ui/react\";\nimport { ReactAsset } from \"@player-ui/react\";\nimport type { TransformedToggle } from \"../types\";\n\nexport const ToggleComponent = (props: TransformedToggle) => {\n const { value, label, id, setCheck } = props;\n\n const onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n setCheck(e.target.checked);\n };\n\n return (\n <FormControl display=\"flex\" alignItems=\"center\">\n {label && (\n <FormLabel htmlFor={id}>\n <ReactAsset {...label.asset} />\n </FormLabel>\n )}\n <Switch id={id} onChange={onChange} />\n </FormControl>\n );\n};\n","import React from \"react\";\nimport {\n AssetPropsWithChildren,\n Asset,\n createSlot,\n BindingTemplateInstance,\n} from \"@player-tools/dsl\";\nimport { Text } from \"@devtools-ui/text\";\nimport type { ToggleAsset } from \"../types\";\n\nexport const Toggle = (\n props: Omit<AssetPropsWithChildren<ToggleAsset>, \"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=\"toggle\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {props.children}\n </Asset>\n );\n};\n\nToggle.Label = createSlot({\n name: \"label\",\n TextComp: Text,\n isArray: false,\n wrapInAsset: true,\n});\n","import type { TransformFunction } from \"@player-ui/player\";\nimport { ToggleAsset, TransformedToggle } from \"../types\";\n\nexport const toggleTransform: TransformFunction<\n ToggleAsset,\n TransformedToggle\n> = (asset, options) => {\n return {\n ...asset,\n setCheck(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;AAClB,SAAS,QAAQ,aAAa,iBAAiB;AAC/C,SAAS,kBAAkB;AAGpB,IAAM,kBAAkB,CAAC,UAA6B;AAC3D,QAAM,EAAE,OAAO,OAAO,IAAI,SAAS,IAAI;AAEvC,QAAM,WAAuD,CAAC,MAAM;AAClE,aAAS,EAAE,OAAO,OAAO;AAAA,EAC3B;AAEA,SACE,oCAAC,eAAY,SAAQ,QAAO,YAAW,YACpC,SACC,oCAAC,aAAU,SAAS,MAClB,oCAAC,cAAY,GAAG,MAAM,OAAO,CAC/B,GAEF,oCAAC,UAAO,IAAQ,UAAoB,CACtC;AAEJ;;;ACtBA,OAAOA,YAAW;AAClB;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,YAAY;AAGd,IAAM,SAAS,CACpB,UAIG;AACH,QAAM,EAAE,UAAU,SAAS,GAAG,KAAK,IAAI;AAEvC,SACE,gBAAAA,OAAA,cAAC,SAAM,MAAK,UAAU,GAAG,QACvB,gBAAAA,OAAA,cAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GAC3C,MAAM,QACT;AAEJ;AAEA,OAAO,QAAQ,WAAW;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf,CAAC;;;AC5BM,IAAM,kBAGT,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":["React"]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@devtools-ui/toggle",
3
+ "version": "0.1.1-next.2",
4
+ "main": "dist/cjs/index.cjs",
5
+ "dependencies": {
6
+ "@devtools-ui/text": "0.1.1-next.2",
7
+ "@devtools-ui/collection": "0.1.1-next.2",
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-next.3",
13
+ "@player-ui/player": "0.7.3-next.3",
14
+ "@player-ui/react": "0.7.3-next.3",
15
+ "@player-ui/types": "0.7.3-next.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,23 @@
1
+ import React from "react";
2
+ import { Switch, FormControl, FormLabel } from "@chakra-ui/react";
3
+ import { ReactAsset } from "@player-ui/react";
4
+ import type { TransformedToggle } from "../types";
5
+
6
+ export const ToggleComponent = (props: TransformedToggle) => {
7
+ const { value, label, id, setCheck } = props;
8
+
9
+ const onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
10
+ setCheck(e.target.checked);
11
+ };
12
+
13
+ return (
14
+ <FormControl display="flex" alignItems="center">
15
+ {label && (
16
+ <FormLabel htmlFor={id}>
17
+ <ReactAsset {...label.asset} />
18
+ </FormLabel>
19
+ )}
20
+ <Switch id={id} onChange={onChange} />
21
+ </FormControl>
22
+ );
23
+ };
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { describe, expect, test } from "vitest";
3
+ import { render, expression as e, binding as b } from "@player-tools/dsl";
4
+ import { Toggle } from "../";
5
+
6
+ describe("DSL: Toggle", () => {
7
+ test("Renders toggle", async () => {
8
+ const rendered = await render(
9
+ <Toggle binding={b`my_binding`}>
10
+ <Toggle.Label>Toggle Label</Toggle.Label>
11
+ </Toggle>
12
+ );
13
+
14
+ expect(rendered.jsonValue).toStrictEqual({
15
+ type: "toggle",
16
+ binding: "my_binding",
17
+ id: "root",
18
+ label: {
19
+ asset: {
20
+ id: "label",
21
+ type: "text",
22
+ value: "Toggle Label",
23
+ },
24
+ },
25
+ });
26
+ });
27
+ });
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import {
3
+ AssetPropsWithChildren,
4
+ Asset,
5
+ createSlot,
6
+ BindingTemplateInstance,
7
+ } from "@player-tools/dsl";
8
+ import { Text } from "@devtools-ui/text";
9
+ import type { ToggleAsset } from "../types";
10
+
11
+ export const Toggle = (
12
+ props: Omit<AssetPropsWithChildren<ToggleAsset>, "binding"> & {
13
+ /** The binding as a tagged template instance */
14
+ binding: BindingTemplateInstance;
15
+ }
16
+ ) => {
17
+ const { children, binding, ...rest } = props;
18
+
19
+ return (
20
+ <Asset type="toggle" {...rest}>
21
+ <property name="binding">{binding.toValue()}</property>
22
+ {props.children}
23
+ </Asset>
24
+ );
25
+ };
26
+
27
+ Toggle.Label = createSlot({
28
+ name: "label",
29
+ TextComp: Text,
30
+ isArray: false,
31
+ wrapInAsset: true,
32
+ });
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 { ToggleAsset, TransformedToggle } from "../types";
3
+
4
+ export const toggleTransform: TransformFunction<
5
+ ToggleAsset,
6
+ TransformedToggle
7
+ > = (asset, options) => {
8
+ return {
9
+ ...asset,
10
+ setCheck(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,18 @@
1
+ import { Asset, AssetWrapper, Expression } from "@player-ui/types";
2
+ import type { TextAsset } from "@devtools-ui/text";
3
+
4
+ export interface ToggleAsset extends Asset<"toggle"> {
5
+ /** Label */
6
+ label?: AssetWrapper<TextAsset>;
7
+ /** Dot sepparated string Representation of a path within the data-model */
8
+ binding?: string;
9
+ }
10
+
11
+ /** A stateful instance of the asset */
12
+ export interface TransformedToggle extends ToggleAsset {
13
+ // The result of the transformation (transform/index.ts)
14
+ /** A function to commit the new value to the data-model */
15
+ setCheck: (newValue: boolean) => void;
16
+ /** The current value of the toggle from the data-model */
17
+ value: boolean;
18
+ }
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { TransformedToggle } from "../types";
3
+ export declare const ToggleComponent: (props: TransformedToggle) => React.JSX.Element;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { AssetPropsWithChildren, BindingTemplateInstance } from "@player-tools/dsl";
3
+ import type { ToggleAsset } from "../types";
4
+ export declare const Toggle: {
5
+ (props: Omit<AssetPropsWithChildren<ToggleAsset>, "binding"> & {
6
+ /** The binding as a tagged template instance */
7
+ binding: BindingTemplateInstance;
8
+ }): React.JSX.Element;
9
+ Label: (props: {
10
+ children?: React.ReactNode;
11
+ }) => React.JSX.Element;
12
+ };
13
+ //# 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 { ToggleAsset, TransformedToggle } from "../types";
3
+ export declare const toggleTransform: TransformFunction<ToggleAsset, TransformedToggle>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { Asset, AssetWrapper } from "@player-ui/types";
2
+ import type { TextAsset } from "@devtools-ui/text";
3
+ export interface ToggleAsset extends Asset<"toggle"> {
4
+ /** Label */
5
+ label?: AssetWrapper<TextAsset>;
6
+ /** Dot sepparated string Representation of a path within the data-model */
7
+ binding?: string;
8
+ }
9
+ /** A stateful instance of the asset */
10
+ export interface TransformedToggle extends ToggleAsset {
11
+ /** A function to commit the new value to the data-model */
12
+ setCheck: (newValue: boolean) => void;
13
+ /** The current value of the toggle from the data-model */
14
+ value: boolean;
15
+ }
16
+ //# sourceMappingURL=index.d.ts.map