@player-ui/reference-assets-plugin-components 0.15.0 → 0.15.1--canary.802.31569
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +4 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/index.tsx +7 -0
- package/types/index.d.ts +2 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -44,6 +44,7 @@ __export(src_exports, {
|
|
|
44
44
|
PrimaryInfoSlot: () => PrimaryInfoSlot,
|
|
45
45
|
SubtitleSlot: () => SubtitleSlot,
|
|
46
46
|
Text: () => Text,
|
|
47
|
+
Throwing: () => Throwing,
|
|
47
48
|
TitleSlot: () => TitleSlot,
|
|
48
49
|
ValueSlot: () => ValueSlot,
|
|
49
50
|
dataRefs: () => dataRefs,
|
|
@@ -127,6 +128,9 @@ var ChatMessage = (props) => {
|
|
|
127
128
|
return /* @__PURE__ */ import_react.default.createElement(import_dsl.Asset, { type: "chat-message" }, /* @__PURE__ */ import_react.default.createElement("property", { name: "id" }, id), children);
|
|
128
129
|
};
|
|
129
130
|
ChatMessage.Value = ValueSlot;
|
|
131
|
+
var Throwing = (props) => {
|
|
132
|
+
return /* @__PURE__ */ import_react.default.createElement(import_dsl.Asset, { type: "throwing", ...props });
|
|
133
|
+
};
|
|
130
134
|
// Annotate the CommonJS export names for ESM import in node:
|
|
131
135
|
0 && (module.exports = {
|
|
132
136
|
Action,
|
|
@@ -143,6 +147,7 @@ ChatMessage.Value = ValueSlot;
|
|
|
143
147
|
PrimaryInfoSlot,
|
|
144
148
|
SubtitleSlot,
|
|
145
149
|
Text,
|
|
150
|
+
Throwing,
|
|
146
151
|
TitleSlot,
|
|
147
152
|
ValueSlot,
|
|
148
153
|
dataRefs,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/components/src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport type {\n WithChildren,\n AssetPropsWithChildren,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n DSLSchema as PlayerDSLSchema,\n DataTypeReference,\n DataTypeRefs,\n ValidatorFunctionRefs,\n WithPlayerTypes,\n} from \"@player-tools/dsl\";\nimport {\n createSlot,\n Asset,\n View,\n getObjectReferences,\n toJsonProperties,\n ObjectWithIndexTracking,\n GeneratedIDProperty,\n toJsonElement,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type {\n ActionAsset,\n TextAsset,\n CollectionAsset,\n InfoAsset,\n InputAsset,\n ImageAsset,\n ChoiceAsset,\n ChoiceItem as ChoiceItemType,\n ChatMessageAsset,\n} from \"@player-ui/reference-assets-plugin\";\nimport { dataTypes, validators } from \"@player-ui/common-types-plugin\";\n\nexport const dataRefs = getObjectReferences<\n typeof dataTypes,\n DataTypeRefs<typeof dataTypes>\n>(dataTypes);\n\nexport const validationRefs = getObjectReferences<\n typeof validators,\n ValidatorFunctionRefs<typeof validators>\n>(validators);\n\nexport type DSLSchema = PlayerDSLSchema<\n DataTypeReference<typeof dataTypes, ValidatorFunctionRefs<typeof validators>>\n>;\n\nexport const Text = (\n props: Omit<AssetPropsWithChildren<TextAsset>, \"value\"> & {\n value?: string;\n },\n) => {\n return (\n <Asset type=\"text\" {...props}>\n <property name=\"value\">{props.children}</property>\n </Asset>\n );\n};\n\nexport const Collection = (props: AssetPropsWithChildren<CollectionAsset>) => {\n return <Asset type=\"collection\" {...props} />;\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\n/** A utility for quickly creating named slots using the text and collection factories */\nconst slotFactory = (name: string, isArray = false, wrapInAsset = true) =>\n createSlot({\n name,\n TextComp: Text,\n CollectionComp,\n isArray,\n wrapInAsset,\n });\n\nexport const LabelSlot = slotFactory(\"label\");\nexport const ValueSlot = slotFactory(\"value\");\nexport const TitleSlot = slotFactory(\"title\");\nexport const NoteSlot = slotFactory(\"note\");\nexport const SubtitleSlot = slotFactory(\"subtitle\");\nexport const ActionsSlot = slotFactory(\"actions\", true);\nexport const PrimaryInfoSlot = slotFactory(\"primaryInfo\");\nexport const ItemsSlot = slotFactory(\"items\", true, false);\n\nCollection.Values = createSlot({\n name: \"values\",\n isArray: true,\n TextComp: Text,\n wrapInAsset: true,\n});\n\nCollection.Label = LabelSlot;\n\nexport const Action = (\n props: Omit<AssetPropsWithChildren<ActionAsset>, \"exp\"> & {\n /** An optional expression to execute before transitioning */\n exp?: ExpressionTemplateInstance | Array<ExpressionTemplateInstance>;\n },\n) => {\n const { exp, children, ...rest } = props;\n\n return (\n <Asset type=\"action\" {...rest}>\n <property name=\"exp\">\n {Array.isArray(exp)\n ? toJsonElement(exp.map((e) => e.toValue()))\n : exp?.toValue()}\n </property>\n {children}\n </Asset>\n );\n};\n\nAction.Label = LabelSlot;\n\nexport const Image = (props: AssetPropsWithChildren<ImageAsset>) => {\n return <Asset type=\"image\" {...props} />;\n};\n\nImage.Caption = slotFactory(\"caption\");\n\nexport const Input = (\n props: Omit<AssetPropsWithChildren<InputAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"input\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nInput.Label = LabelSlot;\nInput.Note = NoteSlot;\n\nexport const Info = (props: AssetPropsWithChildren<InfoAsset>) => {\n return <View type=\"info\" {...props} />;\n};\n\nInfo.Title = TitleSlot;\nInfo.Subtitle = SubtitleSlot;\nInfo.PrimaryInfo = PrimaryInfoSlot;\nInfo.Actions = ActionsSlot;\nInfo.Footer = slotFactory(\"footer\");\n\nexport const Choice = (\n props: Omit<AssetPropsWithChildren<ChoiceAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"choice\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nChoice.Title = TitleSlot;\nChoice.Note = NoteSlot;\nChoice.Items = ItemsSlot;\n\nconst ChoiceItem = (\n props: WithChildren<\n WithPlayerTypes<\n Omit<ChoiceItemType, \"id\"> & {\n id?: string;\n }\n >\n >,\n) => {\n const { children, id, ...rest } = props;\n\n return (\n <ObjectWithIndexTracking>\n {id && (\n <property name=\"id\">\n <value>{id}</value>\n </property>\n )}\n {!id && <GeneratedIDProperty />}\n {toJsonProperties(rest, { propertiesToSkip: [\"applicability\"] })}\n {children}\n </ObjectWithIndexTracking>\n );\n};\n\nChoiceItem.Label = LabelSlot;\nChoice.Item = ChoiceItem;\n\nexport const ChatMessage = (\n props: Omit<AssetPropsWithChildren<ChatMessageAsset>, \"id\"> & {\n id: string;\n },\n) => {\n const { id, children } = props;\n return (\n <Asset type=\"chat-message\">\n <property name=\"id\">{id}</property>\n {children}\n </Asset>\n );\n};\n\nChatMessage.Value = ValueSlot;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAYlB,iBASO;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/components/src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport type {\n WithChildren,\n AssetPropsWithChildren,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n DSLSchema as PlayerDSLSchema,\n DataTypeReference,\n DataTypeRefs,\n ValidatorFunctionRefs,\n WithPlayerTypes,\n} from \"@player-tools/dsl\";\nimport {\n createSlot,\n Asset,\n View,\n getObjectReferences,\n toJsonProperties,\n ObjectWithIndexTracking,\n GeneratedIDProperty,\n toJsonElement,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type {\n ActionAsset,\n TextAsset,\n CollectionAsset,\n InfoAsset,\n InputAsset,\n ImageAsset,\n ChoiceAsset,\n ChoiceItem as ChoiceItemType,\n ChatMessageAsset,\n ThrowingAsset,\n} from \"@player-ui/reference-assets-plugin\";\nimport { dataTypes, validators } from \"@player-ui/common-types-plugin\";\n\nexport const dataRefs = getObjectReferences<\n typeof dataTypes,\n DataTypeRefs<typeof dataTypes>\n>(dataTypes);\n\nexport const validationRefs = getObjectReferences<\n typeof validators,\n ValidatorFunctionRefs<typeof validators>\n>(validators);\n\nexport type DSLSchema = PlayerDSLSchema<\n DataTypeReference<typeof dataTypes, ValidatorFunctionRefs<typeof validators>>\n>;\n\nexport const Text = (\n props: Omit<AssetPropsWithChildren<TextAsset>, \"value\"> & {\n value?: string;\n },\n) => {\n return (\n <Asset type=\"text\" {...props}>\n <property name=\"value\">{props.children}</property>\n </Asset>\n );\n};\n\nexport const Collection = (props: AssetPropsWithChildren<CollectionAsset>) => {\n return <Asset type=\"collection\" {...props} />;\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\n/** A utility for quickly creating named slots using the text and collection factories */\nconst slotFactory = (name: string, isArray = false, wrapInAsset = true) =>\n createSlot({\n name,\n TextComp: Text,\n CollectionComp,\n isArray,\n wrapInAsset,\n });\n\nexport const LabelSlot = slotFactory(\"label\");\nexport const ValueSlot = slotFactory(\"value\");\nexport const TitleSlot = slotFactory(\"title\");\nexport const NoteSlot = slotFactory(\"note\");\nexport const SubtitleSlot = slotFactory(\"subtitle\");\nexport const ActionsSlot = slotFactory(\"actions\", true);\nexport const PrimaryInfoSlot = slotFactory(\"primaryInfo\");\nexport const ItemsSlot = slotFactory(\"items\", true, false);\n\nCollection.Values = createSlot({\n name: \"values\",\n isArray: true,\n TextComp: Text,\n wrapInAsset: true,\n});\n\nCollection.Label = LabelSlot;\n\nexport const Action = (\n props: Omit<AssetPropsWithChildren<ActionAsset>, \"exp\"> & {\n /** An optional expression to execute before transitioning */\n exp?: ExpressionTemplateInstance | Array<ExpressionTemplateInstance>;\n },\n) => {\n const { exp, children, ...rest } = props;\n\n return (\n <Asset type=\"action\" {...rest}>\n <property name=\"exp\">\n {Array.isArray(exp)\n ? toJsonElement(exp.map((e) => e.toValue()))\n : exp?.toValue()}\n </property>\n {children}\n </Asset>\n );\n};\n\nAction.Label = LabelSlot;\n\nexport const Image = (props: AssetPropsWithChildren<ImageAsset>) => {\n return <Asset type=\"image\" {...props} />;\n};\n\nImage.Caption = slotFactory(\"caption\");\n\nexport const Input = (\n props: Omit<AssetPropsWithChildren<InputAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"input\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nInput.Label = LabelSlot;\nInput.Note = NoteSlot;\n\nexport const Info = (props: AssetPropsWithChildren<InfoAsset>) => {\n return <View type=\"info\" {...props} />;\n};\n\nInfo.Title = TitleSlot;\nInfo.Subtitle = SubtitleSlot;\nInfo.PrimaryInfo = PrimaryInfoSlot;\nInfo.Actions = ActionsSlot;\nInfo.Footer = slotFactory(\"footer\");\n\nexport const Choice = (\n props: Omit<AssetPropsWithChildren<ChoiceAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"choice\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nChoice.Title = TitleSlot;\nChoice.Note = NoteSlot;\nChoice.Items = ItemsSlot;\n\nconst ChoiceItem = (\n props: WithChildren<\n WithPlayerTypes<\n Omit<ChoiceItemType, \"id\"> & {\n id?: string;\n }\n >\n >,\n) => {\n const { children, id, ...rest } = props;\n\n return (\n <ObjectWithIndexTracking>\n {id && (\n <property name=\"id\">\n <value>{id}</value>\n </property>\n )}\n {!id && <GeneratedIDProperty />}\n {toJsonProperties(rest, { propertiesToSkip: [\"applicability\"] })}\n {children}\n </ObjectWithIndexTracking>\n );\n};\n\nChoiceItem.Label = LabelSlot;\nChoice.Item = ChoiceItem;\n\nexport const ChatMessage = (\n props: Omit<AssetPropsWithChildren<ChatMessageAsset>, \"id\"> & {\n id: string;\n },\n) => {\n const { id, children } = props;\n return (\n <Asset type=\"chat-message\">\n <property name=\"id\">{id}</property>\n {children}\n </Asset>\n );\n};\n\nChatMessage.Value = ValueSlot;\n\nexport const Throwing = (\n props: AssetPropsWithChildren<ThrowingAsset>,\n): React.ReactElement => {\n return <Asset type=\"throwing\" {...props} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAYlB,iBASO;AAcP,iCAAsC;AAE/B,IAAM,eAAW,gCAGtB,oCAAS;AAEJ,IAAM,qBAAiB,gCAG5B,qCAAU;AAML,IAAM,OAAO,CAClB,UAGG;AACH,SACE,6BAAAA,QAAA,cAAC,oBAAM,MAAK,QAAQ,GAAG,SACrB,6BAAAA,QAAA,cAAC,cAAS,MAAK,WAAS,MAAM,QAAS,CACzC;AAEJ;AAEO,IAAM,aAAa,CAAC,UAAmD;AAC5E,SAAO,6BAAAA,QAAA,cAAC,oBAAM,MAAK,cAAc,GAAG,OAAO;AAC7C;AAEA,IAAM,iBAAiB,CAAC,UAA6C;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;","names":["React"]}
|
package/dist/index.legacy-esm.js
CHANGED
|
@@ -85,6 +85,9 @@ var ChatMessage = (props) => {
|
|
|
85
85
|
return /* @__PURE__ */ React.createElement(Asset, { type: "chat-message" }, /* @__PURE__ */ React.createElement("property", { name: "id" }, id), children);
|
|
86
86
|
};
|
|
87
87
|
ChatMessage.Value = ValueSlot;
|
|
88
|
+
var Throwing = (props) => {
|
|
89
|
+
return /* @__PURE__ */ React.createElement(Asset, { type: "throwing", ...props });
|
|
90
|
+
};
|
|
88
91
|
export {
|
|
89
92
|
Action,
|
|
90
93
|
ActionsSlot,
|
|
@@ -100,6 +103,7 @@ export {
|
|
|
100
103
|
PrimaryInfoSlot,
|
|
101
104
|
SubtitleSlot,
|
|
102
105
|
Text,
|
|
106
|
+
Throwing,
|
|
103
107
|
TitleSlot,
|
|
104
108
|
ValueSlot,
|
|
105
109
|
dataRefs,
|
package/dist/index.mjs
CHANGED
|
@@ -85,6 +85,9 @@ var ChatMessage = (props) => {
|
|
|
85
85
|
return /* @__PURE__ */ React.createElement(Asset, { type: "chat-message" }, /* @__PURE__ */ React.createElement("property", { name: "id" }, id), children);
|
|
86
86
|
};
|
|
87
87
|
ChatMessage.Value = ValueSlot;
|
|
88
|
+
var Throwing = (props) => {
|
|
89
|
+
return /* @__PURE__ */ React.createElement(Asset, { type: "throwing", ...props });
|
|
90
|
+
};
|
|
88
91
|
export {
|
|
89
92
|
Action,
|
|
90
93
|
ActionsSlot,
|
|
@@ -100,6 +103,7 @@ export {
|
|
|
100
103
|
PrimaryInfoSlot,
|
|
101
104
|
SubtitleSlot,
|
|
102
105
|
Text,
|
|
106
|
+
Throwing,
|
|
103
107
|
TitleSlot,
|
|
104
108
|
ValueSlot,
|
|
105
109
|
dataRefs,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/components/src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport type {\n WithChildren,\n AssetPropsWithChildren,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n DSLSchema as PlayerDSLSchema,\n DataTypeReference,\n DataTypeRefs,\n ValidatorFunctionRefs,\n WithPlayerTypes,\n} from \"@player-tools/dsl\";\nimport {\n createSlot,\n Asset,\n View,\n getObjectReferences,\n toJsonProperties,\n ObjectWithIndexTracking,\n GeneratedIDProperty,\n toJsonElement,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type {\n ActionAsset,\n TextAsset,\n CollectionAsset,\n InfoAsset,\n InputAsset,\n ImageAsset,\n ChoiceAsset,\n ChoiceItem as ChoiceItemType,\n ChatMessageAsset,\n} from \"@player-ui/reference-assets-plugin\";\nimport { dataTypes, validators } from \"@player-ui/common-types-plugin\";\n\nexport const dataRefs = getObjectReferences<\n typeof dataTypes,\n DataTypeRefs<typeof dataTypes>\n>(dataTypes);\n\nexport const validationRefs = getObjectReferences<\n typeof validators,\n ValidatorFunctionRefs<typeof validators>\n>(validators);\n\nexport type DSLSchema = PlayerDSLSchema<\n DataTypeReference<typeof dataTypes, ValidatorFunctionRefs<typeof validators>>\n>;\n\nexport const Text = (\n props: Omit<AssetPropsWithChildren<TextAsset>, \"value\"> & {\n value?: string;\n },\n) => {\n return (\n <Asset type=\"text\" {...props}>\n <property name=\"value\">{props.children}</property>\n </Asset>\n );\n};\n\nexport const Collection = (props: AssetPropsWithChildren<CollectionAsset>) => {\n return <Asset type=\"collection\" {...props} />;\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\n/** A utility for quickly creating named slots using the text and collection factories */\nconst slotFactory = (name: string, isArray = false, wrapInAsset = true) =>\n createSlot({\n name,\n TextComp: Text,\n CollectionComp,\n isArray,\n wrapInAsset,\n });\n\nexport const LabelSlot = slotFactory(\"label\");\nexport const ValueSlot = slotFactory(\"value\");\nexport const TitleSlot = slotFactory(\"title\");\nexport const NoteSlot = slotFactory(\"note\");\nexport const SubtitleSlot = slotFactory(\"subtitle\");\nexport const ActionsSlot = slotFactory(\"actions\", true);\nexport const PrimaryInfoSlot = slotFactory(\"primaryInfo\");\nexport const ItemsSlot = slotFactory(\"items\", true, false);\n\nCollection.Values = createSlot({\n name: \"values\",\n isArray: true,\n TextComp: Text,\n wrapInAsset: true,\n});\n\nCollection.Label = LabelSlot;\n\nexport const Action = (\n props: Omit<AssetPropsWithChildren<ActionAsset>, \"exp\"> & {\n /** An optional expression to execute before transitioning */\n exp?: ExpressionTemplateInstance | Array<ExpressionTemplateInstance>;\n },\n) => {\n const { exp, children, ...rest } = props;\n\n return (\n <Asset type=\"action\" {...rest}>\n <property name=\"exp\">\n {Array.isArray(exp)\n ? toJsonElement(exp.map((e) => e.toValue()))\n : exp?.toValue()}\n </property>\n {children}\n </Asset>\n );\n};\n\nAction.Label = LabelSlot;\n\nexport const Image = (props: AssetPropsWithChildren<ImageAsset>) => {\n return <Asset type=\"image\" {...props} />;\n};\n\nImage.Caption = slotFactory(\"caption\");\n\nexport const Input = (\n props: Omit<AssetPropsWithChildren<InputAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"input\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nInput.Label = LabelSlot;\nInput.Note = NoteSlot;\n\nexport const Info = (props: AssetPropsWithChildren<InfoAsset>) => {\n return <View type=\"info\" {...props} />;\n};\n\nInfo.Title = TitleSlot;\nInfo.Subtitle = SubtitleSlot;\nInfo.PrimaryInfo = PrimaryInfoSlot;\nInfo.Actions = ActionsSlot;\nInfo.Footer = slotFactory(\"footer\");\n\nexport const Choice = (\n props: Omit<AssetPropsWithChildren<ChoiceAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"choice\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nChoice.Title = TitleSlot;\nChoice.Note = NoteSlot;\nChoice.Items = ItemsSlot;\n\nconst ChoiceItem = (\n props: WithChildren<\n WithPlayerTypes<\n Omit<ChoiceItemType, \"id\"> & {\n id?: string;\n }\n >\n >,\n) => {\n const { children, id, ...rest } = props;\n\n return (\n <ObjectWithIndexTracking>\n {id && (\n <property name=\"id\">\n <value>{id}</value>\n </property>\n )}\n {!id && <GeneratedIDProperty />}\n {toJsonProperties(rest, { propertiesToSkip: [\"applicability\"] })}\n {children}\n </ObjectWithIndexTracking>\n );\n};\n\nChoiceItem.Label = LabelSlot;\nChoice.Item = ChoiceItem;\n\nexport const ChatMessage = (\n props: Omit<AssetPropsWithChildren<ChatMessageAsset>, \"id\"> & {\n id: string;\n },\n) => {\n const { id, children } = props;\n return (\n <Asset type=\"chat-message\">\n <property name=\"id\">{id}</property>\n {children}\n </Asset>\n );\n};\n\nChatMessage.Value = ValueSlot;\n"],"mappings":";AAAA,OAAO,WAAW;AAYlB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/components/src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport type {\n WithChildren,\n AssetPropsWithChildren,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n DSLSchema as PlayerDSLSchema,\n DataTypeReference,\n DataTypeRefs,\n ValidatorFunctionRefs,\n WithPlayerTypes,\n} from \"@player-tools/dsl\";\nimport {\n createSlot,\n Asset,\n View,\n getObjectReferences,\n toJsonProperties,\n ObjectWithIndexTracking,\n GeneratedIDProperty,\n toJsonElement,\n} from \"@player-tools/dsl\";\nimport type { Asset as AssetType } from \"@player-ui/player\";\nimport type {\n ActionAsset,\n TextAsset,\n CollectionAsset,\n InfoAsset,\n InputAsset,\n ImageAsset,\n ChoiceAsset,\n ChoiceItem as ChoiceItemType,\n ChatMessageAsset,\n ThrowingAsset,\n} from \"@player-ui/reference-assets-plugin\";\nimport { dataTypes, validators } from \"@player-ui/common-types-plugin\";\n\nexport const dataRefs = getObjectReferences<\n typeof dataTypes,\n DataTypeRefs<typeof dataTypes>\n>(dataTypes);\n\nexport const validationRefs = getObjectReferences<\n typeof validators,\n ValidatorFunctionRefs<typeof validators>\n>(validators);\n\nexport type DSLSchema = PlayerDSLSchema<\n DataTypeReference<typeof dataTypes, ValidatorFunctionRefs<typeof validators>>\n>;\n\nexport const Text = (\n props: Omit<AssetPropsWithChildren<TextAsset>, \"value\"> & {\n value?: string;\n },\n) => {\n return (\n <Asset type=\"text\" {...props}>\n <property name=\"value\">{props.children}</property>\n </Asset>\n );\n};\n\nexport const Collection = (props: AssetPropsWithChildren<CollectionAsset>) => {\n return <Asset type=\"collection\" {...props} />;\n};\n\nconst CollectionComp = (props: AssetPropsWithChildren<AssetType>) => {\n return (\n <Collection>\n <Collection.Values>{props.children}</Collection.Values>\n </Collection>\n );\n};\n\n/** A utility for quickly creating named slots using the text and collection factories */\nconst slotFactory = (name: string, isArray = false, wrapInAsset = true) =>\n createSlot({\n name,\n TextComp: Text,\n CollectionComp,\n isArray,\n wrapInAsset,\n });\n\nexport const LabelSlot = slotFactory(\"label\");\nexport const ValueSlot = slotFactory(\"value\");\nexport const TitleSlot = slotFactory(\"title\");\nexport const NoteSlot = slotFactory(\"note\");\nexport const SubtitleSlot = slotFactory(\"subtitle\");\nexport const ActionsSlot = slotFactory(\"actions\", true);\nexport const PrimaryInfoSlot = slotFactory(\"primaryInfo\");\nexport const ItemsSlot = slotFactory(\"items\", true, false);\n\nCollection.Values = createSlot({\n name: \"values\",\n isArray: true,\n TextComp: Text,\n wrapInAsset: true,\n});\n\nCollection.Label = LabelSlot;\n\nexport const Action = (\n props: Omit<AssetPropsWithChildren<ActionAsset>, \"exp\"> & {\n /** An optional expression to execute before transitioning */\n exp?: ExpressionTemplateInstance | Array<ExpressionTemplateInstance>;\n },\n) => {\n const { exp, children, ...rest } = props;\n\n return (\n <Asset type=\"action\" {...rest}>\n <property name=\"exp\">\n {Array.isArray(exp)\n ? toJsonElement(exp.map((e) => e.toValue()))\n : exp?.toValue()}\n </property>\n {children}\n </Asset>\n );\n};\n\nAction.Label = LabelSlot;\n\nexport const Image = (props: AssetPropsWithChildren<ImageAsset>) => {\n return <Asset type=\"image\" {...props} />;\n};\n\nImage.Caption = slotFactory(\"caption\");\n\nexport const Input = (\n props: Omit<AssetPropsWithChildren<InputAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"input\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nInput.Label = LabelSlot;\nInput.Note = NoteSlot;\n\nexport const Info = (props: AssetPropsWithChildren<InfoAsset>) => {\n return <View type=\"info\" {...props} />;\n};\n\nInfo.Title = TitleSlot;\nInfo.Subtitle = SubtitleSlot;\nInfo.PrimaryInfo = PrimaryInfoSlot;\nInfo.Actions = ActionsSlot;\nInfo.Footer = slotFactory(\"footer\");\n\nexport const Choice = (\n props: Omit<AssetPropsWithChildren<ChoiceAsset>, \"binding\"> & {\n /** The binding */\n binding: BindingTemplateInstance;\n },\n) => {\n const { binding, children, ...rest } = props;\n return (\n <Asset type=\"choice\" {...rest}>\n <property name=\"binding\">{binding.toValue()}</property>\n {children}\n </Asset>\n );\n};\n\nChoice.Title = TitleSlot;\nChoice.Note = NoteSlot;\nChoice.Items = ItemsSlot;\n\nconst ChoiceItem = (\n props: WithChildren<\n WithPlayerTypes<\n Omit<ChoiceItemType, \"id\"> & {\n id?: string;\n }\n >\n >,\n) => {\n const { children, id, ...rest } = props;\n\n return (\n <ObjectWithIndexTracking>\n {id && (\n <property name=\"id\">\n <value>{id}</value>\n </property>\n )}\n {!id && <GeneratedIDProperty />}\n {toJsonProperties(rest, { propertiesToSkip: [\"applicability\"] })}\n {children}\n </ObjectWithIndexTracking>\n );\n};\n\nChoiceItem.Label = LabelSlot;\nChoice.Item = ChoiceItem;\n\nexport const ChatMessage = (\n props: Omit<AssetPropsWithChildren<ChatMessageAsset>, \"id\"> & {\n id: string;\n },\n) => {\n const { id, children } = props;\n return (\n <Asset type=\"chat-message\">\n <property name=\"id\">{id}</property>\n {children}\n </Asset>\n );\n};\n\nChatMessage.Value = ValueSlot;\n\nexport const Throwing = (\n props: AssetPropsWithChildren<ThrowingAsset>,\n): React.ReactElement => {\n return <Asset type=\"throwing\" {...props} />;\n};\n"],"mappings":";AAAA,OAAO,WAAW;AAYlB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAcP,SAAS,WAAW,kBAAkB;AAE/B,IAAM,WAAW,oBAGtB,SAAS;AAEJ,IAAM,iBAAiB,oBAG5B,UAAU;AAML,IAAM,OAAO,CAClB,UAGG;AACH,SACE,oCAAC,SAAM,MAAK,QAAQ,GAAG,SACrB,oCAAC,cAAS,MAAK,WAAS,MAAM,QAAS,CACzC;AAEJ;AAEO,IAAM,aAAa,CAAC,UAAmD;AAC5E,SAAO,oCAAC,SAAM,MAAK,cAAc,GAAG,OAAO;AAC7C;AAEA,IAAM,iBAAiB,CAAC,UAA6C;AACnE,SACE,oCAAC,kBACC,oCAAC,WAAW,QAAX,MAAmB,MAAM,QAAS,CACrC;AAEJ;AAGA,IAAM,cAAc,CAAC,MAAc,UAAU,OAAO,cAAc,SAChE,WAAW;AAAA,EACT;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEI,IAAM,YAAY,YAAY,OAAO;AACrC,IAAM,YAAY,YAAY,OAAO;AACrC,IAAM,YAAY,Y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,SAAM,MAAK,UAAU,GAAG,QACvB,oCAAC,cAAS,MAAK,aAAW,QAAQ,QAAQ,CAAE,GAC3C,QACH;AAEJ;AAEA,OAAO,QAAQ;AACf,OAAO,OAAO;AACd,OAAO,QAAQ;AAEf,IAAM,aAAa,CACjB,UAOG;AACH,QAAM,EAAE,UAAU,IAAI,GAAG,KAAK,IAAI;AAElC,SACE,oCAAC,+BACE,MACC,oCAAC,cAAS,MAAK,QACb,oCAAC,eAAO,EAAG,CACb,GAED,CAAC,MAAM,oCAAC,yBAAoB,GAC5B,iBAAiB,MAAM,EAAE,kBAAkB,CAAC,eAAe,EAAE,CAAC,GAC9D,QACH;AAEJ;AAEA,WAAW,QAAQ;AACnB,OAAO,OAAO;AAEP,IAAM,cAAc,CACzB,UAGG;AACH,QAAM,EAAE,IAAI,SAAS,IAAI;AACzB,SACE,oCAAC,SAAM,MAAK,kBACV,oCAAC,cAAS,MAAK,QAAM,EAAG,GACvB,QACH;AAEJ;AAEA,YAAY,QAAQ;AAEb,IAAM,WAAW,CACtB,UACuB;AACvB,SAAO,oCAAC,SAAM,MAAK,YAAY,GAAG,OAAO;AAC3C;","names":[]}
|
package/package.json
CHANGED
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/reference-assets-plugin-components",
|
|
9
|
-
"version": "0.15.
|
|
9
|
+
"version": "0.15.1--canary.802.31569",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@player-ui/player": "0.15.
|
|
12
|
+
"@player-ui/player": "0.15.1--canary.802.31569",
|
|
13
13
|
"react": "^18.2.0",
|
|
14
14
|
"@types/react": "^18.2.39",
|
|
15
15
|
"@player-tools/dsl": "0.12.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@player-ui/common-types-plugin": "0.15.
|
|
19
|
-
"@player-ui/reference-assets-plugin": "0.15.
|
|
18
|
+
"@player-ui/common-types-plugin": "0.15.1--canary.802.31569",
|
|
19
|
+
"@player-ui/reference-assets-plugin": "0.15.1--canary.802.31569",
|
|
20
20
|
"tslib": "^2.6.2"
|
|
21
21
|
},
|
|
22
22
|
"module": "dist/index.legacy-esm.js",
|
package/src/index.tsx
CHANGED
|
@@ -31,6 +31,7 @@ import type {
|
|
|
31
31
|
ChoiceAsset,
|
|
32
32
|
ChoiceItem as ChoiceItemType,
|
|
33
33
|
ChatMessageAsset,
|
|
34
|
+
ThrowingAsset,
|
|
34
35
|
} from "@player-ui/reference-assets-plugin";
|
|
35
36
|
import { dataTypes, validators } from "@player-ui/common-types-plugin";
|
|
36
37
|
|
|
@@ -218,3 +219,9 @@ export const ChatMessage = (
|
|
|
218
219
|
};
|
|
219
220
|
|
|
220
221
|
ChatMessage.Value = ValueSlot;
|
|
222
|
+
|
|
223
|
+
export const Throwing = (
|
|
224
|
+
props: AssetPropsWithChildren<ThrowingAsset>,
|
|
225
|
+
): React.ReactElement => {
|
|
226
|
+
return <Asset type="throwing" {...props} />;
|
|
227
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { WithChildren, AssetPropsWithChildren, BindingTemplateInstance, ExpressionTemplateInstance, DSLSchema as PlayerDSLSchema, DataTypeReference, ValidatorFunctionRefs, WithPlayerTypes } from "@player-tools/dsl";
|
|
3
|
-
import type { ActionAsset, TextAsset, CollectionAsset, InfoAsset, InputAsset, ImageAsset, ChoiceAsset, ChoiceItem as ChoiceItemType, ChatMessageAsset } from "@player-ui/reference-assets-plugin";
|
|
3
|
+
import type { ActionAsset, TextAsset, CollectionAsset, InfoAsset, InputAsset, ImageAsset, ChoiceAsset, ChoiceItem as ChoiceItemType, ChatMessageAsset, ThrowingAsset } from "@player-ui/reference-assets-plugin";
|
|
4
4
|
import { dataTypes, validators } from "@player-ui/common-types-plugin";
|
|
5
5
|
export declare const dataRefs: {
|
|
6
6
|
BooleanTypeRef: boolean;
|
|
@@ -141,4 +141,5 @@ export declare const ChatMessage: {
|
|
|
141
141
|
children?: React.ReactNode;
|
|
142
142
|
}) => React.JSX.Element;
|
|
143
143
|
};
|
|
144
|
+
export declare const Throwing: (props: AssetPropsWithChildren<ThrowingAsset>) => React.ReactElement;
|
|
144
145
|
//# sourceMappingURL=index.d.ts.map
|