import { createId } from "@paralleldrive/cuid2";
export const gen_detail = () => {
const res = {
id: createId(),
name: "prop_3",
type: "item",
dim: {
w: "full",
h: "full",
},
childs: [
{
id: createId(),
name: "detail",
type: "item",
dim: {
w: "full",
h: "full",
},
childs: [
{
id: createId(),
adv: {
js: '
\n \n {children}\n \n
',
css: "",
jsBuilt:
'render(/* @__PURE__ */ React.createElement("div", { ...props }, /* @__PURE__ */ React.createElement(\n Local,\n {\n name: "form",\n value: {\n hook: null\n }\n },\n children\n)));\n',
},
dim: {
h: "full",
w: "full",
},
name: "form",
type: "item",
childs: [
{
id: createId(),
adv: {
css: "",
},
dim: {
h: "full",
w: "full",
},
name: "jsx: body",
type: "item",
childs: [
{
id: createId(),
adv: {
css: "",
},
dim: {
h: "full",
w: "full",
},
name: "field",
type: "item",
childs: [],
script: {
props: {
name: {
value: '"hello"',
},
type: {
value: ' "text";\n',
},
label: {
value: '"hello"',
},
},
},
component: {
id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67",
props: {
fill: {
idx: 11,
meta: {
type: "text",
},
name: "prop_11",
type: "string",
value: "`Haha`",
valueBuilt: "`Haha`",
},
name: {
idx: 1,
meta: {
type: "text",
},
name: "prop_1",
type: "string",
value: "`field_name`",
valueBuilt: "`field_name`",
},
type: {
idx: 3,
meta: {
type: "option",
options:
'[\n "text", "buttons", "date", "datetime"\n]',
optionsBuilt:
' [\n "text",\n "buttons",\n "date",\n "datetime"\n];\n',
},
name: "prop_3",
type: "string",
value: '"text"',
valueBuilt: '"text"',
},
label: {
idx: 1,
meta: {
type: "text",
},
name: "prop_1",
type: "string",
value: "`Name`",
valueBuilt: "`Name`",
},
title: {
idx: 7,
meta: {
type: "text",
},
name: "prop_7",
type: "string",
value: '"hello"',
valueBuilt: ' "hello";\n',
},
custom: {
idx: 5,
meta: {
type: "option",
options:
'[\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n },\n]\n',
option_mode: "button",
optionsBuilt:
' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n',
},
name: "prop_11",
type: "string",
value: '"y"',
valueBuilt: '"y"',
},
options: {
idx: 5,
meta: {
type: "text",
},
name: "prop_5",
type: "string",
value:
'async () => {\r\n return [\r\n {\r\n value: "sample1",\r\n label: "sample1",\r\n },\r\n ];\r\n}',
valueBuilt:
' async () => {\n return [\n {\n value: "sample1",\n label: "sample1"\n }\n ];\n};\n',
},
required: {
idx: 7,
meta: {
type: "option",
options:
'[\n {\n label: "yes",\n value: "y",\n },\n {\n label: "no",\n value: "n",\n },\n] ',
optionsBuilt:
' [\n {\n label: "yes",\n value: "y"\n },\n {\n label: "no",\n value: "n"\n }\n];\n',
},
name: "prop_7",
type: "string",
value: '"n"',
valueBuilt: ' "n";\n',
},
label_alt: {
idx: 2,
meta: {
type: "text",
},
name: "prop_10",
type: "string",
value: '""',
valueBuilt: ' "";\n',
},
on_change: {
idx: 11,
meta: {
type: "text",
},
name: "prop_11",
type: "string",
value: "({ value }) => {}",
valueBuilt: " ({ value }) => {\n};\n",
},
placeholder: {
idx: 3,
meta: {
type: "text",
},
name: "prop_11",
type: "string",
value: '""',
visible:
'["text", "number", "password"].includes(type)',
valueBuilt: ' "";\n',
},
slider_options: {
idx: 9,
meta: {
type: "text",
},
name: "prop_9",
type: "string",
value:
'async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" },\n };\n}',
visible: "type === 'slider'",
valueBuilt:
' async () => {\n return {\n step: 1,\n min: { value: 0, label: "Start" },\n max: { value: 100, label: "End" }\n };\n};\n',
},
suffix: {
idx: 12,
meta: {
type: "text",
},
name: "prop_11",
type: "string",
value: '("")',
visible:
'["number", "text", "password"].includes(type)',
valueBuilt: ' "";\n',
},
rel_fields: {
idx: 11,
name: "prop_11",
type: "string",
value: "[]",
valueBuilt: " [];\n",
meta: {
type: "option",
option_mode: "checkbox",
options:
"async () => {\n const result: { label: string; value: string; options?: any[] }[] = [];\n const fields = await db._schema.columns(rel_table);\n for (const [k, v] of Object.entries(fields)) {\n result.push({ value: k, label: k });\n }\n\n const rels = await db._schema.rels(rel_table);\n for (const [k, v] of Object.entries(rels)) {\n let options = [];\n const fields = await db._schema.columns(v.to.table);\n for (const [k, v] of Object.entries(fields)) {\n options.push({ value: k, label: k });\n }\n\n result.push({ value: k, label: k, options });\n }\n\n return result;\n}",
optionsBuilt:
" async () => {\n const result = [];\n const fields = await db._schema.columns(rel_table);\n for (const [k, v] of Object.entries(fields)) {\n result.push({ value: k, label: k });\n }\n const rels = await db._schema.rels(rel_table);\n for (const [k, v] of Object.entries(rels)) {\n let options = [];\n const fields2 = await db._schema.columns(v.to.table);\n for (const [k2, v2] of Object.entries(fields2)) {\n options.push({ value: k2, label: k2 });\n }\n result.push({ value: k, label: k, options });\n }\n return result;\n};\n",
},
label: "fields",
},
rel_query: {
idx: 11,
name: "prop_11",
type: "string",
value: "async () => {\n return {};\n}",
valueBuilt: " async () => {\n return {};\n};\n",
meta: {
type: "text",
},
label: "query",
},
},
ref_ids: {},
instances: {
npj543t5rpwx932a153hsfyl: {
zmit41kbgkbqcsmm8aspp8zy: "mo4m0rnyey4y6v7tlajod95l",
},
},
},
originalid: createId(),
},
],
},
{
id: createId(),
adv: {
js: "