Skip to content

Commit

Permalink
chore: added ai property to all controls
Browse files Browse the repository at this point in the history
  • Loading branch information
surajair committed Jul 27, 2024
1 parent 165561e commit 0c4a81f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@chaibuilder/runtime",
"private": false,
"version": "0.2.6",
"version": "0.2.7",
"type": "module",
"author": "Suraj Air",
"license": "BSD-3-Clause",
Expand Down
26 changes: 14 additions & 12 deletions src/package/controls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { StylingPresets } from "../runtime/STYLING_PRESETS.ts";
export interface ControlDefinition {
default?: any;
binding?: boolean;
i18n: boolean;
itemProperties?: { [key: string]: ControlDefinition };
properties?: { [key: string]: ControlDefinition };
required?: boolean;
schema: any;
ai?: Record<string, any>;
type: "slots" | "singular" | "list" | "model" | "styles";
uiSchema: any;
}
Expand Down Expand Up @@ -52,10 +52,10 @@ type ControlProps = {
default?: any;
binding?: boolean;
description?: string;
i18n?: boolean;
required?: boolean;
title: string;
builderProp?: boolean;
ai?: Record<string, any>;
};

type InputProps = ControlProps & {
Expand All @@ -71,7 +71,6 @@ export const InfoField = (props: ControlProps) =>
({
type: "singular",
default: "",
i18n: props.i18n || false,
uiSchema: {},
binding: get(props, "binding", true),
dataType: "string",
Expand All @@ -92,12 +91,12 @@ export const SingleLineText = (props: InputProps) =>
type: "singular",
default: props.default || "",
binding: get(props, "binding", true),
i18n: props.i18n || false,
dataType: "string",
required: props.required || false,
ai: props.ai || undefined,
schema: {
type: "string",
...omit(props, ["i18n", "required"]),
...omit(props, ["ai", "required"]),
},
uiSchema: {
"ui:placeholder": props.placeholder || "Enter here",
Expand All @@ -119,8 +118,8 @@ export const MultilineText = (props: TextAreaProps) =>
default: props.default || "",
binding: get(props, "binding", true),
dataType: "string",
i18n: props.i18n || false,
required: props.required || false,
ai: props.ai || undefined,
schema: {
type: "string",
...omit(props, ["i18n", "required", "rows"]),
Expand Down Expand Up @@ -148,6 +147,7 @@ export const Checkbox = (props: CheckboxProps) =>
default: props.default || false,
dataType: "boolean",
binding: get(props, "binding", true),
ai: props.ai || undefined,
schema: {
type: "boolean",
...omit(props, ["i18n", "required"]),
Expand All @@ -171,8 +171,8 @@ export const Numeric = (props: NumberProps) =>
default: props.default || "",
binding: get(props, "binding", true),
dataType: "number",
i18n: props.i18n || false,
required: props.required || false,
ai: props.ai || undefined,
schema: {
type: "number",
...omit(props, ["i18n", "required"]),
Expand All @@ -189,9 +189,9 @@ export const SelectOption = (props: SelectProps) =>
type: "singular",
default: props.default || "",
binding: get(props, "binding", true),
i18n: props.i18n || false,
required: props.required || false,
dataType: "string",
ai: props.ai || undefined,
schema: {
type: "string",
...omit(props, ["i18n", "required", "options", "binding"]),
Expand All @@ -209,6 +209,7 @@ export const Color = (props: ControlProps) =>
default: props.default || "",
binding: get(props, "binding", true),
dataType: "string",
ai: props.ai || undefined,
schema: {
type: "string",
...omit(props, ["i18n", "required"]),
Expand Down Expand Up @@ -239,9 +240,9 @@ export const RichText = (props: ControlProps) =>
({
type: "singular",
default: props.default || "",
i18n: props.i18n || false,
binding: get(props, "binding", true),
dataType: "string",
ai: props.ai || undefined,
schema: {
type: "string",
...omit(props, ["i18n", "required"]),
Expand Down Expand Up @@ -278,6 +279,7 @@ export const List = (props: ListProps) =>
itemProperties: props.itemProperties,
binding: get(props, "binding", true),
title: props.title,
ai: props.ai || undefined,
dataType: "array",
default: props.default || [],
itemTitle: props.getItemLabel ? props.getItemLabel({}) : () => "",
Expand All @@ -301,8 +303,8 @@ export const Icon = (props: ControlProps) =>
default: props.default || "",
binding: get(props, "binding", true),
type: "singular",
i18n: props.i18n || false,
dataType: "string",
ai: props.ai || undefined,
schema: {
type: "string",
title: "Icon",
Expand All @@ -327,7 +329,7 @@ export const Link = (props: LinkProps) =>
type: "singular",
binding: get(props, "binding", true),
dataType: "object",
i18n: props.i18n || false,
ai: props.ai || undefined,
schema: {
type: "object",
...(props || {}),
Expand All @@ -348,7 +350,7 @@ export const Image = (props: ControlProps) =>
default: props.default || "",
binding: get(props, "binding", true),
dataType: "string",
i18n: props.i18n || false,
ai: props.ai || undefined,
schema: {
type: "string",
...omit(props, ["i18n", "required"]),
Expand Down

0 comments on commit 0c4a81f

Please sign in to comment.