@akanjs/ui 1.0.5 → 1.0.6

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.
@@ -1,4 +1,5 @@
1
1
  import { type Type } from "@akanjs/base";
2
+ import { Cnst } from "@akanjs/constant";
2
3
  declare function Object(): import("react/jsx-runtime").JSX.Element;
3
4
  declare namespace Object {
4
5
  var Type: ({ objRef, arrDepth, nullable }: ObjectTypeProps) => import("react/jsx-runtime").JSX.Element;
@@ -12,7 +13,7 @@ interface ObjectTypeProps {
12
13
  nullable?: boolean;
13
14
  }
14
15
  interface ObjectDetailProps {
15
- objRef: Type;
16
+ objRef: Cnst;
16
17
  }
17
18
  interface ObjectSchemaProps {
18
19
  objRef: Type;
package/cjs/Load/Units.js CHANGED
@@ -65,8 +65,6 @@ function Render({
65
65
  modelInitAt: `${modelName}InitAt`,
66
66
  modelObjList: `${modelName}ObjList`,
67
67
  modelObjInsight: `${modelName}ObjInsight`,
68
- lightCrystalizeModel: `lightCrystalize${ModelName}`,
69
- crystalizeModelInsight: `crystalize${ModelName}Insight`,
70
68
  pageOfModel: `pageOf${ModelName}`,
71
69
  lastPageOfModel: `lastPageOf${ModelName}`,
72
70
  limitOfModel: `limitOf${ModelName}`,
@@ -103,15 +101,13 @@ function Render({
103
101
  if (loaded.current)
104
102
  return modelList;
105
103
  const initModelObjList = init[names.modelObjList];
106
- const lightCrystalizeModel = cnst.lightCrystalize;
107
- return new import_base.DataList(initModelObjList.map((model) => lightCrystalizeModel(model)));
104
+ return new import_base.DataList(initModelObjList.map((model) => new cnst.light().set(model)));
108
105
  }, []);
109
106
  (0, import_react.useEffect)(() => {
110
107
  if (loaded.current)
111
108
  return;
112
109
  const modelObjInsight = init[names.modelObjInsight];
113
- const crystalizeModelInsight = cnst.crystalizeInsight;
114
- const insight2 = crystalizeModelInsight(modelObjInsight);
110
+ const insight2 = new cnst.insight().set(modelObjInsight);
115
111
  const initPageOfModel2 = init[names.pageOfModel];
116
112
  const initLastPageOfModel = init[names.lastPageOfModel];
117
113
  const initLimitOfModel2 = init[names.limitOfModel];
package/cjs/Load/View.js CHANGED
@@ -52,9 +52,7 @@ function Render({
52
52
  if (loaded.current)
53
53
  return model;
54
54
  const modelObj2 = view[`${refName}Obj`];
55
- const crystalizeModel = cnst.crystalize;
56
- const crystal = crystalizeModel(modelObj2);
57
- return crystal;
55
+ return new cnst.full().set(modelObj2);
58
56
  }, []);
59
57
  (0, import_react.useEffect)(() => {
60
58
  if (loaded.current)
@@ -132,10 +132,9 @@ function EditModal({
132
132
  const refName2 = modelEdit.refName;
133
133
  const editType = refName2 && modelEdit[names.modelObj] ? "edit" : "new";
134
134
  const cnst = import_constant.constantInfo.getDatabase(modelName);
135
- const crystalizeModel = cnst.crystalize;
136
135
  const modelRef = cnst.full;
137
136
  if (editType === "edit") {
138
- const crystal = crystalizeModel(modelEdit[names.modelObj]);
137
+ const crystal = new modelRef().set(modelEdit[names.modelObj]);
139
138
  import_store2.st.set({
140
139
  [names.model]: crystal,
141
140
  [names.modelLoading]: false,
@@ -145,7 +144,7 @@ function EditModal({
145
144
  [names.modelViewAt]: modelEdit[names.modelViewAt]
146
145
  });
147
146
  } else {
148
- const crystal = crystalizeModel(modelEdit);
147
+ const crystal = new modelRef().set(modelEdit);
149
148
  void storeDo[names.newModel](crystal, { modal, setDefault: true, sliceName });
150
149
  }
151
150
  return () => {
@@ -45,7 +45,6 @@ const NewWrapper_Client = ({
45
45
  const storeDo = import_store.st.do;
46
46
  const storeUse = import_store.st.use;
47
47
  const cnst = import_constant.constantInfo.getDatabase(modelName);
48
- const crystalizeModel = cnst.crystalize;
49
48
  const modelModal = storeUse[names.modelModal]();
50
49
  const disabled = modelModal === "edit";
51
50
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -56,7 +55,7 @@ const NewWrapper_Client = ({
56
55
  e.stopPropagation();
57
56
  if (disabled)
58
57
  return;
59
- const crystal = crystalizeModel(partial);
58
+ const crystal = new cnst.full().set(partial);
60
59
  void storeDo[names.newModel](crystal, { modal, setDefault, sliceName });
61
60
  resets?.forEach((reset) => {
62
61
  void storeDo[`reset${(0, import_common.capitalize)(reset)}`]();
@@ -68,7 +68,6 @@ const ObjectType = ({ objRef, arrDepth, nullable }) => {
68
68
  Object2.Type = ObjectType;
69
69
  const ObjectDetail = ({ objRef }) => {
70
70
  const modelRefName = import_constant.constantInfo.getRefName(objRef);
71
- const fieldMetas = (0, import_constant.getFieldMetas)(objRef);
72
71
  const { l } = (0, import_client.usePage)();
73
72
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { className: "table", children: [
74
73
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { className: "text-bold", children: [
@@ -78,25 +77,27 @@ const ObjectDetail = ({ objRef }) => {
78
77
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: "text-center text-base", children: "Description" }),
79
78
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: "text-center text-base", children: "Enum" })
80
79
  ] }) }),
81
- fieldMetas.map(({ key, arrDepth, nullable, modelRef, isClass, enum: enumOpt, isMap, of }, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { className: "font-normal", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
82
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "", children: key }),
83
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { className: "text-center", children: [
84
- isClass ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ObjectType, { objRef: modelRef, arrDepth }) : `${"[".repeat(arrDepth)}${(0, import_constant.getGqlTypeStr)(modelRef)}${"]".repeat(arrDepth)}${nullable ? "" : "!"}`,
85
- isMap ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
86
- " => ",
87
- (() => {
88
- const [valueRef, valueArrDepth] = (0, import_base.getNonArrayModel)(of);
89
- if ((0, import_base.isGqlClass)(of))
90
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ObjectType, { objRef: valueRef, arrDepth: valueArrDepth });
91
- else
92
- return `${"[".repeat(valueArrDepth)}${import_base.scalarNameMap.get(of)}${"]".repeat(valueArrDepth)}`;
93
- })()
94
- ] }) : null
95
- ] }),
96
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l._(`${modelRefName}.${key}`) }),
97
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l._(`${modelRefName}.${key}.desc`) }),
98
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "flex flex-wrap items-center justify-center gap-2 text-center", children: enumOpt ? enumOpt.map((opt, idx2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tooltip tooltip-primary", "data-tip": l._(`${enumOpt.refName}.${opt}`), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "btn btn-xs", children: opt }) }, idx2)) : "-" })
99
- ] }) }, idx))
80
+ global.Object.entries(objRef.field).map(
81
+ ([key, { arrDepth, nullable, modelRef, isClass, enum: enumOpt, isMap, of }], idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { className: "font-normal", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "", children: key }),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { className: "text-center", children: [
84
+ isClass ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ObjectType, { objRef: modelRef, arrDepth }) : `${"[".repeat(arrDepth)}${(0, import_constant.getGqlTypeStr)(modelRef)}${"]".repeat(arrDepth)}${nullable ? "" : "!"}`,
85
+ isMap ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
86
+ " => ",
87
+ (() => {
88
+ const [valueRef, valueArrDepth] = (0, import_base.getNonArrayModel)(of);
89
+ if ((0, import_base.isGqlClass)(of))
90
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ObjectType, { objRef: valueRef, arrDepth: valueArrDepth });
91
+ else
92
+ return `${"[".repeat(valueArrDepth)}${import_base.scalarNameMap.get(of)}${"]".repeat(valueArrDepth)}`;
93
+ })()
94
+ ] }) : null
95
+ ] }),
96
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l._(`${modelRefName}.${key}`) }),
97
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l._(`${modelRefName}.${key}.desc`) }),
98
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "flex flex-wrap items-center justify-center gap-2 text-center", children: enumOpt ? enumOpt.map((opt, idx2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tooltip tooltip-primary", "data-tip": l._(`${enumOpt.refName}.${opt}`), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "btn btn-xs", children: opt }) }, idx2)) : "-" })
99
+ ] }) }, idx)
100
+ )
100
101
  ] }) });
101
102
  };
102
103
  Object2.Detail = ObjectDetail;
package/esm/Load/Units.js CHANGED
@@ -43,8 +43,6 @@ function Render({
43
43
  modelInitAt: `${modelName}InitAt`,
44
44
  modelObjList: `${modelName}ObjList`,
45
45
  modelObjInsight: `${modelName}ObjInsight`,
46
- lightCrystalizeModel: `lightCrystalize${ModelName}`,
47
- crystalizeModelInsight: `crystalize${ModelName}Insight`,
48
46
  pageOfModel: `pageOf${ModelName}`,
49
47
  lastPageOfModel: `lastPageOf${ModelName}`,
50
48
  limitOfModel: `limitOf${ModelName}`,
@@ -81,15 +79,13 @@ function Render({
81
79
  if (loaded.current)
82
80
  return modelList;
83
81
  const initModelObjList = init[names.modelObjList];
84
- const lightCrystalizeModel = cnst.lightCrystalize;
85
- return new DataList(initModelObjList.map((model) => lightCrystalizeModel(model)));
82
+ return new DataList(initModelObjList.map((model) => new cnst.light().set(model)));
86
83
  }, []);
87
84
  useEffect(() => {
88
85
  if (loaded.current)
89
86
  return;
90
87
  const modelObjInsight = init[names.modelObjInsight];
91
- const crystalizeModelInsight = cnst.crystalizeInsight;
92
- const insight2 = crystalizeModelInsight(modelObjInsight);
88
+ const insight2 = new cnst.insight().set(modelObjInsight);
93
89
  const initPageOfModel2 = init[names.pageOfModel];
94
90
  const initLastPageOfModel = init[names.lastPageOfModel];
95
91
  const initLimitOfModel2 = init[names.limitOfModel];
package/esm/Load/View.js CHANGED
@@ -30,9 +30,7 @@ function Render({
30
30
  if (loaded.current)
31
31
  return model;
32
32
  const modelObj2 = view[`${refName}Obj`];
33
- const crystalizeModel = cnst.crystalize;
34
- const crystal = crystalizeModel(modelObj2);
35
- return crystal;
33
+ return new cnst.full().set(modelObj2);
36
34
  }, []);
37
35
  useEffect(() => {
38
36
  if (loaded.current)
@@ -110,10 +110,9 @@ function EditModal({
110
110
  const refName2 = modelEdit.refName;
111
111
  const editType = refName2 && modelEdit[names.modelObj] ? "edit" : "new";
112
112
  const cnst = constantInfo.getDatabase(modelName);
113
- const crystalizeModel = cnst.crystalize;
114
113
  const modelRef = cnst.full;
115
114
  if (editType === "edit") {
116
- const crystal = crystalizeModel(modelEdit[names.modelObj]);
115
+ const crystal = new modelRef().set(modelEdit[names.modelObj]);
117
116
  st.set({
118
117
  [names.model]: crystal,
119
118
  [names.modelLoading]: false,
@@ -123,7 +122,7 @@ function EditModal({
123
122
  [names.modelViewAt]: modelEdit[names.modelViewAt]
124
123
  });
125
124
  } else {
126
- const crystal = crystalizeModel(modelEdit);
125
+ const crystal = new modelRef().set(modelEdit);
127
126
  void storeDo[names.newModel](crystal, { modal, setDefault: true, sliceName });
128
127
  }
129
128
  return () => {
@@ -23,7 +23,6 @@ const NewWrapper_Client = ({
23
23
  const storeDo = st.do;
24
24
  const storeUse = st.use;
25
25
  const cnst = constantInfo.getDatabase(modelName);
26
- const crystalizeModel = cnst.crystalize;
27
26
  const modelModal = storeUse[names.modelModal]();
28
27
  const disabled = modelModal === "edit";
29
28
  return /* @__PURE__ */ jsx(
@@ -34,7 +33,7 @@ const NewWrapper_Client = ({
34
33
  e.stopPropagation();
35
34
  if (disabled)
36
35
  return;
37
- const crystal = crystalizeModel(partial);
36
+ const crystal = new cnst.full().set(partial);
38
37
  void storeDo[names.newModel](crystal, { modal, setDefault, sliceName });
39
38
  resets?.forEach((reset) => {
40
39
  void storeDo[`reset${capitalize(reset)}`]();
@@ -3,7 +3,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { getNonArrayModel, isGqlClass, isGqlScalar, scalarNameMap } from "@akanjs/base";
4
4
  import { usePage } from "@akanjs/client";
5
5
  import { capitalize } from "@akanjs/common";
6
- import { constantInfo, getFieldMetas, getGqlTypeStr } from "@akanjs/constant";
6
+ import { constantInfo, getGqlTypeStr } from "@akanjs/constant";
7
7
  import { useState } from "react";
8
8
  import { Modal } from "../Modal";
9
9
  function Object() {
@@ -46,7 +46,6 @@ const ObjectType = ({ objRef, arrDepth, nullable }) => {
46
46
  Object.Type = ObjectType;
47
47
  const ObjectDetail = ({ objRef }) => {
48
48
  const modelRefName = constantInfo.getRefName(objRef);
49
- const fieldMetas = getFieldMetas(objRef);
50
49
  const { l } = usePage();
51
50
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("table", { className: "table", children: [
52
51
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "text-bold", children: [
@@ -56,25 +55,27 @@ const ObjectDetail = ({ objRef }) => {
56
55
  /* @__PURE__ */ jsx("th", { className: "text-center text-base", children: "Description" }),
57
56
  /* @__PURE__ */ jsx("th", { className: "text-center text-base", children: "Enum" })
58
57
  ] }) }),
59
- fieldMetas.map(({ key, arrDepth, nullable, modelRef, isClass, enum: enumOpt, isMap, of }, idx) => /* @__PURE__ */ jsx("tbody", { className: "font-normal", children: /* @__PURE__ */ jsxs("tr", { children: [
60
- /* @__PURE__ */ jsx("td", { className: "", children: key }),
61
- /* @__PURE__ */ jsxs("td", { className: "text-center", children: [
62
- isClass ? /* @__PURE__ */ jsx(ObjectType, { objRef: modelRef, arrDepth }) : `${"[".repeat(arrDepth)}${getGqlTypeStr(modelRef)}${"]".repeat(arrDepth)}${nullable ? "" : "!"}`,
63
- isMap ? /* @__PURE__ */ jsxs(Fragment, { children: [
64
- " => ",
65
- (() => {
66
- const [valueRef, valueArrDepth] = getNonArrayModel(of);
67
- if (isGqlClass(of))
68
- return /* @__PURE__ */ jsx(ObjectType, { objRef: valueRef, arrDepth: valueArrDepth });
69
- else
70
- return `${"[".repeat(valueArrDepth)}${scalarNameMap.get(of)}${"]".repeat(valueArrDepth)}`;
71
- })()
72
- ] }) : null
73
- ] }),
74
- /* @__PURE__ */ jsx("td", { className: "text-center", children: l._(`${modelRefName}.${key}`) }),
75
- /* @__PURE__ */ jsx("td", { className: "text-center", children: l._(`${modelRefName}.${key}.desc`) }),
76
- /* @__PURE__ */ jsx("td", { className: "flex flex-wrap items-center justify-center gap-2 text-center", children: enumOpt ? enumOpt.map((opt, idx2) => /* @__PURE__ */ jsx("div", { className: "tooltip tooltip-primary", "data-tip": l._(`${enumOpt.refName}.${opt}`), children: /* @__PURE__ */ jsx("button", { className: "btn btn-xs", children: opt }) }, idx2)) : "-" })
77
- ] }) }, idx))
58
+ global.Object.entries(objRef.field).map(
59
+ ([key, { arrDepth, nullable, modelRef, isClass, enum: enumOpt, isMap, of }], idx) => /* @__PURE__ */ jsx("tbody", { className: "font-normal", children: /* @__PURE__ */ jsxs("tr", { children: [
60
+ /* @__PURE__ */ jsx("td", { className: "", children: key }),
61
+ /* @__PURE__ */ jsxs("td", { className: "text-center", children: [
62
+ isClass ? /* @__PURE__ */ jsx(ObjectType, { objRef: modelRef, arrDepth }) : `${"[".repeat(arrDepth)}${getGqlTypeStr(modelRef)}${"]".repeat(arrDepth)}${nullable ? "" : "!"}`,
63
+ isMap ? /* @__PURE__ */ jsxs(Fragment, { children: [
64
+ " => ",
65
+ (() => {
66
+ const [valueRef, valueArrDepth] = getNonArrayModel(of);
67
+ if (isGqlClass(of))
68
+ return /* @__PURE__ */ jsx(ObjectType, { objRef: valueRef, arrDepth: valueArrDepth });
69
+ else
70
+ return `${"[".repeat(valueArrDepth)}${scalarNameMap.get(of)}${"]".repeat(valueArrDepth)}`;
71
+ })()
72
+ ] }) : null
73
+ ] }),
74
+ /* @__PURE__ */ jsx("td", { className: "text-center", children: l._(`${modelRefName}.${key}`) }),
75
+ /* @__PURE__ */ jsx("td", { className: "text-center", children: l._(`${modelRefName}.${key}.desc`) }),
76
+ /* @__PURE__ */ jsx("td", { className: "flex flex-wrap items-center justify-center gap-2 text-center", children: enumOpt ? enumOpt.map((opt, idx2) => /* @__PURE__ */ jsx("div", { className: "tooltip tooltip-primary", "data-tip": l._(`${enumOpt.refName}.${opt}`), children: /* @__PURE__ */ jsx("button", { className: "btn btn-xs", children: opt }) }, idx2)) : "-" })
77
+ ] }) }, idx)
78
+ )
78
79
  ] }) });
79
80
  };
80
81
  Object.Detail = ObjectDetail;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"