namirasoft-site-react 1.4.259 → 1.4.261

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.
Files changed (288) hide show
  1. package/.dockerignore +86 -86
  2. package/.env.template +10 -10
  3. package/Dockerfile +18 -18
  4. package/config-overrides.js +72 -72
  5. package/dist/App.css +34 -0
  6. package/dist/components/NSBarAction.module.css +84 -84
  7. package/dist/components/NSBarAlert.module.css +79 -79
  8. package/dist/components/NSBarNotification.module.css +34 -34
  9. package/dist/components/NSBarTitle.module.css +9 -9
  10. package/dist/components/NSBox.module.css +50 -50
  11. package/dist/components/NSBoxBaseCombo.module.css +6 -6
  12. package/dist/components/NSBoxBoolean.module.css +67 -67
  13. package/dist/components/NSBoxDate.module.css +4 -4
  14. package/dist/components/NSBoxDateTime.module.css +4 -4
  15. package/dist/components/NSBoxDuration.module.css +4 -4
  16. package/dist/components/NSBoxFile.module.css +10 -10
  17. package/dist/components/NSBoxPhone.module.css +35 -35
  18. package/dist/components/NSBoxRadio.module.css +33 -33
  19. package/dist/components/NSBoxSchemaBase.module.css +17 -17
  20. package/dist/components/NSBoxSchemaVariable.module.css +16 -16
  21. package/dist/components/NSBoxTextArea.module.css +12 -12
  22. package/dist/components/NSBoxTime.module.css +4 -4
  23. package/dist/components/NSButton.module.css +57 -57
  24. package/dist/components/NSButtonBlue.module.css +4 -4
  25. package/dist/components/NSButtonGreen.module.css +4 -4
  26. package/dist/components/NSButtonRed.module.css +4 -4
  27. package/dist/components/NSCard.module.css +114 -114
  28. package/dist/components/NSCardScreenshot.module.css +41 -41
  29. package/dist/components/NSChartColumn.module.css +7 -7
  30. package/dist/components/NSChartTable.module.css +21 -21
  31. package/dist/components/NSColumn.module.css +16 -16
  32. package/dist/components/NSCopyBox.module.css +39 -39
  33. package/dist/components/NSDialog.module.css +112 -112
  34. package/dist/components/NSDialogPageSelection.module.css +103 -103
  35. package/dist/components/NSDownTimer.module.css +55 -55
  36. package/dist/components/NSDownload.module.css +46 -46
  37. package/dist/components/NSElectronicCard.module.css +60 -60
  38. package/dist/components/NSEntityCardBackground.module.css +27 -27
  39. package/dist/components/NSFilterBox.module.css +56 -56
  40. package/dist/components/NSFilterItem.module.css +24 -24
  41. package/dist/components/NSFooter.module.css +134 -134
  42. package/dist/components/NSHeader.module.css +291 -291
  43. package/dist/components/NSHeaderScreenshot.module.css +35 -35
  44. package/dist/components/NSLabel.module.css +25 -25
  45. package/dist/components/NSLabelErrorNotifier.module.css +2 -2
  46. package/dist/components/NSLayout.module.css +14 -14
  47. package/dist/components/NSLine.module.css +15 -15
  48. package/dist/components/NSLink.module.css +36 -36
  49. package/dist/components/NSListGrouped.module.css +69 -69
  50. package/dist/components/NSLoading.module.css +30 -30
  51. package/dist/components/NSMenuAction.js +2 -2
  52. package/dist/components/NSMenuAction.module.css +88 -88
  53. package/dist/components/NSMenuButton.module.css +44 -44
  54. package/dist/components/NSNoData.module.css +9 -9
  55. package/dist/components/NSPagination.module.css +85 -85
  56. package/dist/components/NSPanel.module.css +19 -19
  57. package/dist/components/NSPanelAccordion.module.css +4 -4
  58. package/dist/components/NSRange.module.css +66 -66
  59. package/dist/components/NSRow.module.css +17 -17
  60. package/dist/components/NSSection.module.css +4 -4
  61. package/dist/components/NSSectionCards.module.css +38 -38
  62. package/dist/components/NSSectionTiles.module.css +10 -10
  63. package/dist/components/NSTabPage.module.css +59 -59
  64. package/dist/components/NSTable.module.css +263 -263
  65. package/dist/components/NSTile.module.css +76 -76
  66. package/dist/components/NSTimelineMonthly.module.css +71 -71
  67. package/dist/components/NSTitle.module.css +15 -15
  68. package/dist/formatter/MoneyFormatter.js +1 -1
  69. package/dist/formatter/MoneyFormatter.js.map +1 -1
  70. package/dist/index.css +6 -0
  71. package/dist/pages/NSNotFoundPage.module.css +18 -18
  72. package/dist/pages/NSUpdating.module.css +35 -35
  73. package/package.json +76 -76
  74. package/public/index.html +38 -38
  75. package/src/App.css +33 -33
  76. package/src/App.tsx +130 -130
  77. package/src/Color.tsx +10 -10
  78. package/src/CopyToClipboard.ts +6 -6
  79. package/src/NSBoxBuilder.tsx +912 -912
  80. package/src/Validator.ts +147 -147
  81. package/src/components/INSBox.tsx +6 -6
  82. package/src/components/NSBarAction.module.css +84 -84
  83. package/src/components/NSBarAction.tsx +90 -90
  84. package/src/components/NSBarAlert.module.css +79 -79
  85. package/src/components/NSBarAlert.tsx +35 -35
  86. package/src/components/NSBarNotification.module.css +34 -34
  87. package/src/components/NSBarNotification.tsx +89 -89
  88. package/src/components/NSBarTitle.module.css +9 -9
  89. package/src/components/NSBarTitle.tsx +23 -23
  90. package/src/components/NSBox.module.css +50 -50
  91. package/src/components/NSBox.tsx +19 -19
  92. package/src/components/NSBoxBaseCombo.module.css +6 -6
  93. package/src/components/NSBoxBaseCombo.tsx +314 -314
  94. package/src/components/NSBoxBaseLayout.tsx +88 -88
  95. package/src/components/NSBoxBaseLayoutRecursive.tsx +54 -54
  96. package/src/components/NSBoxBoolean.module.css +67 -67
  97. package/src/components/NSBoxBoolean.tsx +119 -119
  98. package/src/components/NSBoxBooleans.tsx +161 -161
  99. package/src/components/NSBoxColor.tsx +95 -95
  100. package/src/components/NSBoxCombo.tsx +91 -91
  101. package/src/components/NSBoxDate.module.css +4 -4
  102. package/src/components/NSBoxDate.tsx +90 -90
  103. package/src/components/NSBoxDateTime.module.css +4 -4
  104. package/src/components/NSBoxDateTime.tsx +105 -105
  105. package/src/components/NSBoxDouble.tsx +94 -94
  106. package/src/components/NSBoxDuration.module.css +4 -4
  107. package/src/components/NSBoxDuration.tsx +95 -95
  108. package/src/components/NSBoxDynamic.tsx +67 -67
  109. package/src/components/NSBoxDynamics.tsx +68 -68
  110. package/src/components/NSBoxEmail.tsx +98 -98
  111. package/src/components/NSBoxEntity.tsx +101 -101
  112. package/src/components/NSBoxEnum.tsx +108 -108
  113. package/src/components/NSBoxFile.module.css +10 -10
  114. package/src/components/NSBoxFile.tsx +101 -101
  115. package/src/components/NSBoxFilePath.tsx +95 -95
  116. package/src/components/NSBoxFont.tsx +95 -95
  117. package/src/components/NSBoxIPV4.tsx +95 -95
  118. package/src/components/NSBoxIPV4Range.tsx +95 -95
  119. package/src/components/NSBoxIPV6.tsx +92 -92
  120. package/src/components/NSBoxIPV6Range.tsx +95 -95
  121. package/src/components/NSBoxInteger.tsx +91 -91
  122. package/src/components/NSBoxMoney.tsx +95 -95
  123. package/src/components/NSBoxPassword.tsx +106 -106
  124. package/src/components/NSBoxPhone.module.css +35 -35
  125. package/src/components/NSBoxPhone.tsx +107 -107
  126. package/src/components/NSBoxRadio.module.css +33 -33
  127. package/src/components/NSBoxRadio.tsx +91 -91
  128. package/src/components/NSBoxSchemaBase.module.css +17 -17
  129. package/src/components/NSBoxSchemaBase.tsx +539 -539
  130. package/src/components/NSBoxSchemaVariable.module.css +16 -16
  131. package/src/components/NSBoxSchemaVariable.tsx +251 -251
  132. package/src/components/NSBoxSearch.tsx +97 -97
  133. package/src/components/NSBoxString.tsx +91 -91
  134. package/src/components/NSBoxTextArea.module.css +12 -12
  135. package/src/components/NSBoxTextArea.tsx +98 -98
  136. package/src/components/NSBoxTime.module.css +4 -4
  137. package/src/components/NSBoxTime.tsx +93 -93
  138. package/src/components/NSBoxTimeZone.tsx +95 -95
  139. package/src/components/NSBoxURL.tsx +104 -104
  140. package/src/components/NSBoxVersion.tsx +95 -95
  141. package/src/components/NSButton.module.css +57 -57
  142. package/src/components/NSButton.tsx +25 -25
  143. package/src/components/NSButtonBlue.module.css +4 -4
  144. package/src/components/NSButtonBlue.tsx +19 -19
  145. package/src/components/NSButtonGreen.module.css +4 -4
  146. package/src/components/NSButtonGreen.tsx +19 -19
  147. package/src/components/NSButtonRed.module.css +4 -4
  148. package/src/components/NSButtonRed.tsx +19 -19
  149. package/src/components/NSCard.module.css +114 -114
  150. package/src/components/NSCard.tsx +63 -63
  151. package/src/components/NSCardScreenshot.module.css +41 -41
  152. package/src/components/NSCardScreenshot.tsx +31 -31
  153. package/src/components/NSChartColumn.module.css +7 -7
  154. package/src/components/NSChartColumn.tsx +106 -106
  155. package/src/components/NSChartDoughnut.tsx +112 -112
  156. package/src/components/NSChartPie.tsx +105 -105
  157. package/src/components/NSChartRange.tsx +14 -14
  158. package/src/components/NSChartTable.module.css +21 -21
  159. package/src/components/NSChartTable.tsx +94 -94
  160. package/src/components/NSColumn.module.css +16 -16
  161. package/src/components/NSColumn.tsx +24 -24
  162. package/src/components/NSCopy.tsx +56 -56
  163. package/src/components/NSCopyBox.module.css +39 -39
  164. package/src/components/NSCopyBox.tsx +53 -53
  165. package/src/components/NSDialog.module.css +112 -112
  166. package/src/components/NSDialog.tsx +61 -61
  167. package/src/components/NSDialogDelete.tsx +26 -26
  168. package/src/components/NSDialogInfo.tsx +32 -32
  169. package/src/components/NSDialogPageSelection.module.css +103 -103
  170. package/src/components/NSDialogPageSelection.tsx +227 -227
  171. package/src/components/NSDownTimer.module.css +55 -55
  172. package/src/components/NSDownTimer.tsx +77 -77
  173. package/src/components/NSDownload.module.css +46 -46
  174. package/src/components/NSDownload.tsx +66 -66
  175. package/src/components/NSElectronicCard.module.css +60 -60
  176. package/src/components/NSElectronicCard.tsx +46 -46
  177. package/src/components/NSEntityCardBackground.module.css +27 -27
  178. package/src/components/NSEntityCardBackground.tsx +36 -36
  179. package/src/components/NSFilterBox.module.css +56 -56
  180. package/src/components/NSFilterBox.tsx +494 -494
  181. package/src/components/NSFilterItem.module.css +24 -24
  182. package/src/components/NSFilterItem.tsx +27 -27
  183. package/src/components/NSFooter.module.css +134 -134
  184. package/src/components/NSFooter.tsx +321 -321
  185. package/src/components/NSHeader.module.css +291 -291
  186. package/src/components/NSHeader.tsx +261 -261
  187. package/src/components/NSHeaderScreenshot.module.css +35 -35
  188. package/src/components/NSHeaderScreenshot.tsx +39 -39
  189. package/src/components/NSLabel.module.css +25 -25
  190. package/src/components/NSLabel.tsx +46 -46
  191. package/src/components/NSLabelErrorNotifier.module.css +2 -2
  192. package/src/components/NSLabelErrorNotifier.tsx +35 -35
  193. package/src/components/NSLayout.module.css +14 -14
  194. package/src/components/NSLayout.tsx +130 -130
  195. package/src/components/NSLine.module.css +15 -15
  196. package/src/components/NSLine.tsx +13 -13
  197. package/src/components/NSLink.module.css +36 -36
  198. package/src/components/NSLink.tsx +25 -25
  199. package/src/components/NSLinkBlue.tsx +21 -21
  200. package/src/components/NSLinkGreen.tsx +12 -12
  201. package/src/components/NSLinkRed.tsx +12 -12
  202. package/src/components/NSListGrouped.module.css +69 -69
  203. package/src/components/NSListGrouped.tsx +106 -106
  204. package/src/components/NSListProduct.tsx +44 -44
  205. package/src/components/NSLoading.module.css +30 -30
  206. package/src/components/NSLoading.tsx +21 -21
  207. package/src/components/NSMenuAction.module.css +88 -88
  208. package/src/components/NSMenuAction.tsx +90 -90
  209. package/src/components/NSMenuButton.module.css +44 -44
  210. package/src/components/NSMenuButton.tsx +206 -206
  211. package/src/components/NSNoData.module.css +9 -9
  212. package/src/components/NSNoData.tsx +24 -24
  213. package/src/components/NSPagination.module.css +85 -85
  214. package/src/components/NSPagination.tsx +182 -182
  215. package/src/components/NSPanel.module.css +19 -19
  216. package/src/components/NSPanel.tsx +24 -24
  217. package/src/components/NSPanelAccordion.module.css +4 -4
  218. package/src/components/NSPanelAccordion.tsx +51 -51
  219. package/src/components/NSRange.module.css +66 -66
  220. package/src/components/NSRange.tsx +83 -83
  221. package/src/components/NSRepeater.tsx +240 -240
  222. package/src/components/NSRepeaterNSBoxSchemaVariable.tsx +84 -84
  223. package/src/components/NSRepeaterNSTag.tsx +79 -79
  224. package/src/components/NSRow.module.css +17 -17
  225. package/src/components/NSRow.tsx +24 -24
  226. package/src/components/NSSection.module.css +4 -4
  227. package/src/components/NSSection.tsx +26 -26
  228. package/src/components/NSSectionCards.module.css +38 -38
  229. package/src/components/NSSectionCards.tsx +51 -51
  230. package/src/components/NSSectionTiles.module.css +10 -10
  231. package/src/components/NSSectionTiles.tsx +25 -25
  232. package/src/components/NSSectionTitle.tsx +21 -21
  233. package/src/components/NSSpace.tsx +28 -28
  234. package/src/components/NSTabPage.module.css +59 -59
  235. package/src/components/NSTabPage.tsx +91 -91
  236. package/src/components/NSTable.module.css +263 -263
  237. package/src/components/NSTable.tsx +471 -471
  238. package/src/components/NSTag.tsx +74 -74
  239. package/src/components/NSTile.module.css +76 -76
  240. package/src/components/NSTile.tsx +27 -27
  241. package/src/components/NSTimelineMonthly.module.css +71 -71
  242. package/src/components/NSTimelineMonthly.tsx +44 -44
  243. package/src/components/NSTitle.module.css +15 -15
  244. package/src/components/NSTitle.tsx +19 -19
  245. package/src/formatter/BackColorFormatter.tsx +23 -23
  246. package/src/formatter/BaseColumnFormatter.ts +16 -16
  247. package/src/formatter/BaseURLImageFormatter.tsx +28 -28
  248. package/src/formatter/BooleanFormatter.ts +22 -22
  249. package/src/formatter/DateFormatter.ts +20 -20
  250. package/src/formatter/DateTimeFormatter.ts +20 -20
  251. package/src/formatter/DurationFormatter.ts +13 -13
  252. package/src/formatter/EmailFormatter.tsx +21 -21
  253. package/src/formatter/EnumFormatter.ts +13 -13
  254. package/src/formatter/FloatFormatter.ts +23 -23
  255. package/src/formatter/ForeColorFormatter.tsx +24 -24
  256. package/src/formatter/IDFormatter.tsx +37 -37
  257. package/src/formatter/IPFormatter.ts +13 -13
  258. package/src/formatter/IntegerFormatter.ts +23 -23
  259. package/src/formatter/JsonFormatter.ts +21 -21
  260. package/src/formatter/MoneyFormatter.ts +23 -23
  261. package/src/formatter/PhoneFormatter.tsx +21 -21
  262. package/src/formatter/StringFormatter.tsx +43 -43
  263. package/src/formatter/TimeFormatter.ts +20 -20
  264. package/src/formatter/URLFormatter.tsx +21 -21
  265. package/src/formatter/UnknowFormatter.ts +18 -18
  266. package/src/index.tsx +7 -7
  267. package/src/main.ts +210 -210
  268. package/src/pages/NSNotFoundPage.module.css +18 -18
  269. package/src/pages/NSNotFoundPage.tsx +11 -11
  270. package/src/pages/NSUpdating.module.css +35 -35
  271. package/src/pages/NSUpdating.tsx +32 -32
  272. package/src/props/IBackgroundPropps.ts +5 -5
  273. package/src/props/IBaseComponentProps.ts +8 -8
  274. package/src/props/IHeaderIconProps.ts +10 -10
  275. package/src/props/IHeaderProps.ts +7 -7
  276. package/src/props/IImageProps.ts +4 -4
  277. package/src/props/ILinkProps.ts +5 -5
  278. package/src/props/IValidationNumberProps.ts +4 -4
  279. package/src/props/IValidationPrecisionProps.ts +3 -3
  280. package/src/props/IValidationProps.ts +9 -9
  281. package/src/props/IValidationRegexProps.ts +4 -4
  282. package/src/props/IValidationStringProps.ts +4 -4
  283. package/src/routing/INSRouterMaker.ts +6 -6
  284. package/src/routing/INSRouterProps.ts +5 -5
  285. package/src/routing/INSRouterState.ts +5 -5
  286. package/src/routing/NSRouterMaker.tsx +33 -33
  287. package/src/routing/Notifier.ts +79 -79
  288. package/tsconfig.json +43 -43
@@ -1,913 +1,913 @@
1
- import { AnySchema, ArraySchema, BaseNumberSchema, BasePrecisionSchema, BaseTypeBuilder, BaseTypeSchema, BaseVariableSchema, BigIntSchema, BoolSchema, ColorSchema, DateSchema, DateTimeSchema, DecimalSchema, DoubleSchema, DurationSchema, EmailSchema, EntitySchema, EnumSchema, FilePathSchema, FloatSchema, FontSchema, IntegerSchema, IPV4RangeSchema, IPV4Schema, IPV6RangeSchema, IPV6Schema, MediumIntSchema, MoneySchema, ObjectSchema, PhoneSchema, RealSchema, SmallIntSchema, StringSchema, TimeSchema, TimeZoneSchema, TinyIntSchema, TypeSchema, URLSchema, VariableSchema, VariableType, VersionSchema } from "namirasoft-schema";
2
- import { NSBoxBoolean } from "./components/NSBoxBoolean";
3
- import { NSBoxCombo } from "./components/NSBoxCombo";
4
- import { NSBoxDate } from "./components/NSBoxDate";
5
- import { NSBoxDateTime } from "./components/NSBoxDateTime";
6
- import { NSBoxDouble } from "./components/NSBoxDouble";
7
- import { NSBoxDuration } from "./components/NSBoxDuration";
8
- import { NSBoxDynamic, NSBoxDynamicProps } from "./components/NSBoxDynamic";
9
- import { NSBoxEmail } from "./components/NSBoxEmail";
10
- import { NSBoxEntity } from "./components/NSBoxEntity";
11
- import { NSBoxInteger } from "./components/NSBoxInteger";
12
- import { NSBoxIPV4 } from "./components/NSBoxIPV4";
13
- import { NSBoxIPV6 } from "./components/NSBoxIPV6";
14
- import { NSBoxMoney } from "./components/NSBoxMoney";
15
- import { NSBoxPhone } from "./components/NSBoxPhone";
16
- import { NSBoxString } from "./components/NSBoxString";
17
- import { NSBoxTime } from "./components/NSBoxTime";
18
- import { NSRepeater } from "./components/NSRepeater";
19
- import { NSBoxTimeZone } from "./components/NSBoxTimeZone";
20
- import { NSBoxVersion } from "./components/NSBoxVersion";
21
- import { NSBoxIPV4Range } from "./components/NSBoxIPV4Range";
22
- import { NSBoxIPV6Range } from "./components/NSBoxIPV6Range";
23
- import { NSBoxColor } from "./components/NSBoxColor";
24
- import { NSBoxFont } from "./components/NSBoxFont";
25
- import { NSBoxFilePath } from "./components/NSBoxFilePath";
26
- import { NSBoxURL } from "./components/NSBoxURL";
27
- import { NamingConvention, ObjectService } from "namirasoft-core";
28
- import { INSBox } from "./components/INSBox";
29
- import { createRef } from "react";
30
- import { NSBoxBaseLayoutRecursive } from "./components/NSBoxBaseLayoutRecursive";
31
- import { NSMenuButtonMenuProps, safeMenuMenuItem } from "./components/NSMenuButton";
32
- import { NSBoxSchemaBase, NSBoxSchemaVariable } from "./main";
33
-
34
- export class NSBoxBuilder extends BaseTypeBuilder<React.JSX.Element | null>
35
- {
36
- private depth: number = 0;
37
- private box: NSBoxDynamic;
38
- private props: NSBoxDynamicProps;
39
- private box_ref: React.RefObject<INSBox>;
40
- private key: string;
41
- private title: string;
42
- private placeholder: string;
43
- private menu: NSMenuButtonMenuProps;
44
- private builders: { builder: NSBoxBuilder, ref: React.RefObject<INSBox> }[] = [];
45
- private multiple: boolean;
46
-
47
- constructor(box: NSBoxDynamic, props: NSBoxDynamicProps, box_ref: React.RefObject<INSBox>, key: string, onDelete?: () => void)
48
- {
49
- super(props.variable.type);
50
- this.box = box;
51
- this.props = props;
52
- this.box_ref = box_ref;
53
- this.key = key;
54
- this.toInteger = this.toInteger.bind(this);
55
- this.toPrecision = this.toPrecision.bind(this);
56
- this.ifOjbect = this.ifOjbect.bind(this);
57
-
58
- this.title = this.props.title;
59
- if (!this.title)
60
- this.title = NamingConvention.auto.convert(this.props.variable.name, NamingConvention.Pascal_Case_Space);
61
- this.placeholder = props.variable.type.example ?? "";
62
- this.multiple = props.variable.tags["multiple"] === "true";
63
- this.menu = safeMenuMenuItem(this.props, () => { });
64
- this.menu.builtin.delete = { enabled: onDelete != null, onDelete: () => { onDelete?.() } };
65
- this.builders = this.ifOjbect((_, fields) =>
66
- {
67
- return fields.map((f) =>
68
- {
69
- let title = NamingConvention.auto.convert(f.name, NamingConvention.Pascal_Case_Space);
70
- let props = {
71
- ...this.props,
72
- title,
73
- onChanged: (box: NSBoxDynamic) =>
74
- {
75
- this.props.onChanged?.(box);
76
- },
77
- variable: f,
78
- multiple: false
79
- };
80
- let ref = createRef<INSBox>();
81
- let builder = new NSBoxBuilder(this.box, props, ref, "NSBoxBuilder_Object_" + f.name);
82
- builder.depth = this.depth + 1;
83
- return { builder, ref };
84
- });
85
- }) ?? [];
86
- }
87
- private ifOjbect<T>(handler: (schema: ObjectSchema, fields: BaseVariableSchema[]) => T): T | null
88
- {
89
- if (this.props.variable.type.type === VariableType.Object)
90
- {
91
- let schema = this.props.variable.type as ObjectSchema;
92
-
93
- if (this.multiple)
94
- return null;
95
- if (schema.external)
96
- return null;
97
- if (!schema.fields)
98
- return null
99
- if (schema.fields.length === 0)
100
- return null
101
- if (schema.fields)
102
- return handler(schema, schema.fields);
103
- }
104
- return null;
105
- }
106
- getValue(checkError: boolean = true): any | null
107
- {
108
- let obj = this.box_ref.current?.getValue(checkError);
109
-
110
- let res = this.ifOjbect((_, fields) =>
111
- {
112
- let ans: { [name: string]: any } = {};
113
- fields.forEach((f, index) =>
114
- {
115
- let obj = this.builders[index].builder.getValue(checkError);
116
- ans[f.name] = obj;
117
- });
118
- return ans;
119
- });
120
- if (res != null)
121
- obj = res;
122
-
123
- return obj;
124
- }
125
- setValue(value: any | null, callback?: () => void): void
126
- {
127
- if (!this.ifOjbect((_, fields) =>
128
- {
129
- fields.forEach((f, index) =>
130
- {
131
- let obj = value?.[f.name];
132
- this.builders[index].builder.setValue(obj);
133
- });
134
- return true;
135
- }))
136
- this.box_ref.current?.setValue(value, callback);
137
- }
138
- /* VariableType */
139
- protected override _toAny(_: AnySchema)
140
- {
141
- return null;
142
- }
143
- protected override _toBool(schema: BoolSchema)
144
- {
145
- if (this.multiple)
146
- return null;
147
-
148
- return (
149
- <NSBoxBoolean
150
- ref={this.box_ref as React.RefObject<any>}
151
- key={this.key}
152
- {...this.props}
153
-
154
- required={schema.required}
155
- valids={schema.valids}
156
- invalids={schema.invalids}
157
- // regex={schema.regex}
158
-
159
- title={this.title}
160
- placeholder={this.placeholder}
161
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullBoolean() ?? undefined}
162
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
163
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
164
- menu={this.menu}
165
- />
166
- );
167
- }
168
- private toInteger(schema: BaseNumberSchema): React.JSX.Element | null
169
- {
170
- if (this.multiple)
171
- return null;
172
-
173
- return (
174
- <NSBoxInteger
175
- ref={this.box_ref as React.RefObject<any>}
176
- key={this.key}
177
- {...this.props}
178
-
179
- required={schema.required}
180
- valids={schema.valids}
181
- invalids={schema.invalids}
182
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
183
-
184
- title={this.title}
185
- placeholder={this.placeholder}
186
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullInt() ?? undefined}
187
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
188
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
189
- menu={this.menu}
190
-
191
- min={schema.min ?? undefined}
192
- max={schema.max ?? undefined}
193
- />
194
- );
195
- }
196
- protected override _toTinyInt(schema: TinyIntSchema)
197
- {
198
- return this.toInteger(schema);
199
- }
200
- protected override _toSmallInt(schema: SmallIntSchema)
201
- {
202
- return this.toInteger(schema);
203
- }
204
- protected override _toMediumInt(schema: MediumIntSchema)
205
- {
206
- return this.toInteger(schema);
207
- }
208
- protected override _toInteger(schema: IntegerSchema)
209
- {
210
- return this.toInteger(schema);
211
- }
212
- protected override _toBigInt(schema: BigIntSchema)
213
- {
214
- return this.toInteger(schema);
215
- }
216
- private toPrecision(schema: BasePrecisionSchema): React.JSX.Element | null
217
- {
218
- if (this.multiple)
219
- return null;
220
-
221
- return (
222
- <NSBoxDouble
223
- ref={this.box_ref as React.RefObject<any>}
224
- key={this.key}
225
- {...this.props}
226
-
227
- required={schema.required}
228
- valids={schema.valids}
229
- invalids={schema.invalids}
230
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
231
-
232
- title={this.title}
233
- placeholder={this.placeholder}
234
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullFloat() ?? undefined}
235
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
236
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
237
- menu={this.menu}
238
-
239
- min={schema.min ?? undefined}
240
- max={schema.max ?? undefined}
241
- precision={schema.precision ?? undefined}
242
- />
243
- );
244
- }
245
- protected override _toFloat(schema: FloatSchema)
246
- {
247
- return this.toPrecision(schema);
248
- }
249
- protected override _toDouble(schema: DoubleSchema)
250
- {
251
- return this.toPrecision(schema);
252
- }
253
- protected override _toDecimal(schema: DecimalSchema)
254
- {
255
- return this.toPrecision(schema);
256
- }
257
- protected override _toReal(schema: RealSchema)
258
- {
259
- return this.toPrecision(schema);
260
- }
261
- protected override _toMoney(schema: MoneySchema)
262
- {
263
- if (this.multiple)
264
- return null;
265
-
266
- return (
267
- <NSBoxMoney
268
- ref={this.box_ref as React.RefObject<any>}
269
- key={this.key}
270
- {...this.props}
271
-
272
- required={schema.required}
273
- valids={schema.valids}
274
- invalids={schema.invalids}
275
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
276
-
277
- title={this.title}
278
- placeholder={this.placeholder}
279
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullFloat() ?? undefined}
280
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
281
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
282
- menu={this.menu}
283
-
284
- min={schema.min ?? undefined}
285
- max={schema.max ?? undefined}
286
- precision={schema.precision ?? undefined}
287
- />
288
- );
289
- }
290
- protected override _toString(schema: StringSchema)
291
- {
292
- if (this.multiple)
293
- return null;
294
-
295
- return (
296
- <NSBoxString
297
- ref={this.box_ref as React.RefObject<any>}
298
- key={this.key}
299
- {...this.props}
300
-
301
- required={schema.required}
302
- valids={schema.valids}
303
- invalids={schema.invalids}
304
- regex={schema.regex ? { name: this.props.variable.name, regex: schema.regex } : undefined}
305
-
306
- title={this.title}
307
- placeholder={this.placeholder}
308
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
309
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
310
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
311
- menu={this.menu}
312
-
313
- min_length={schema.min_length ?? undefined}
314
- max_length={schema.max_length ?? undefined}
315
- />
316
- );
317
- }
318
- protected override _toDate(schema: DateSchema)
319
- {
320
- if (this.multiple)
321
- return null;
322
-
323
- return (
324
- <NSBoxDate
325
- ref={this.box_ref as React.RefObject<any>}
326
- key={this.key}
327
- {...this.props}
328
-
329
- required={schema.required}
330
- valids={schema.valids}
331
- invalids={schema.invalids}
332
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
333
-
334
- title={this.title}
335
- placeholder={this.placeholder}
336
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
337
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
338
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
339
- menu={this.menu}
340
- />
341
- );
342
- }
343
- protected override _toTime(schema: TimeSchema)
344
- {
345
- if (this.multiple)
346
- return null;
347
-
348
- return (
349
- <NSBoxTime
350
- ref={this.box_ref as React.RefObject<any>}
351
- key={this.key}
352
- {...this.props}
353
-
354
- required={schema.required}
355
- valids={schema.valids}
356
- invalids={schema.invalids}
357
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
358
-
359
- title={this.title}
360
- placeholder={this.placeholder}
361
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
362
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
363
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
364
- menu={this.menu}
365
- />
366
- );
367
- }
368
- protected override _toDateTime(schema: DateTimeSchema)
369
- {
370
- if (this.multiple)
371
- return null;
372
-
373
- return (
374
- <NSBoxDateTime
375
- ref={this.box_ref as React.RefObject<any>}
376
- key={this.key}
377
- {...this.props}
378
-
379
- required={schema.required}
380
- valids={schema.valids}
381
- invalids={schema.invalids}
382
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
383
-
384
- title={this.title}
385
- placeholder={this.placeholder}
386
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullDate() ?? undefined}
387
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
388
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
389
- menu={this.menu}
390
- />
391
- );
392
- }
393
- protected override _toTimeZone(schema: TimeZoneSchema)
394
- {
395
- if (this.multiple)
396
- return null;
397
-
398
- return (
399
- <NSBoxTimeZone
400
- ref={this.box_ref as React.RefObject<any>}
401
- key={this.key}
402
- {...this.props}
403
-
404
- required={schema.required}
405
- valids={schema.valids}
406
- invalids={schema.invalids}
407
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
408
-
409
- title={this.title}
410
- placeholder={this.placeholder}
411
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
412
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
413
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
414
- menu={this.menu}
415
- />
416
- );
417
- }
418
- protected override _toDuration(schema: DurationSchema)
419
- {
420
- if (this.multiple)
421
- return null;
422
-
423
- return (
424
- <NSBoxDuration
425
- ref={this.box_ref as React.RefObject<any>}
426
- key={this.key}
427
- {...this.props}
428
-
429
- required={schema.required}
430
- valids={schema.valids}
431
- invalids={schema.invalids}
432
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
433
-
434
- title={this.title}
435
- placeholder={this.placeholder}
436
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
437
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
438
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
439
- menu={this.menu}
440
- />
441
- );
442
- }
443
- protected override _toEmail(schema: EmailSchema)
444
- {
445
- if (this.multiple)
446
- return null;
447
-
448
- return (
449
- <NSBoxEmail
450
- ref={this.box_ref as React.RefObject<any>}
451
- key={this.key}
452
- {...this.props}
453
-
454
- required={schema.required}
455
- valids={schema.valids}
456
- invalids={schema.invalids}
457
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
458
-
459
- title={this.title}
460
- placeholder={this.placeholder}
461
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
462
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
463
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
464
- menu={this.menu}
465
- />
466
- );
467
- }
468
- protected override _toPhone(schema: PhoneSchema)
469
- {
470
- if (this.multiple)
471
- return null;
472
-
473
- return (
474
- <NSBoxPhone
475
- ref={this.box_ref as React.RefObject<any>}
476
- key={this.key}
477
- {...this.props}
478
-
479
- required={schema.required}
480
- valids={schema.valids}
481
- invalids={schema.invalids}
482
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
483
-
484
- title={this.title}
485
- placeholder={this.placeholder}
486
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
487
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
488
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
489
- menu={this.menu}
490
- />
491
- );
492
- }
493
- protected override _toVersion(schema: VersionSchema)
494
- {
495
- if (this.multiple)
496
- return null;
497
- return (
498
- <NSBoxVersion
499
- ref={this.box_ref as React.RefObject<any>}
500
- key={this.key}
501
- {...this.props}
502
-
503
- required={schema.required}
504
- valids={schema.valids}
505
- invalids={schema.invalids}
506
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
507
-
508
- title={this.title}
509
- placeholder={this.placeholder}
510
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
511
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
512
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
513
- menu={this.menu}
514
- />
515
- );
516
- }
517
- protected override _toIPV4(schema: IPV4Schema)
518
- {
519
- if (this.multiple)
520
- return null;
521
- return (
522
- <NSBoxIPV4
523
- ref={this.box_ref as React.RefObject<any>}
524
- key={this.key}
525
- {...this.props}
526
-
527
- required={schema.required}
528
- valids={schema.valids}
529
- invalids={schema.invalids}
530
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
531
-
532
- title={this.title}
533
- placeholder={this.placeholder}
534
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
535
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
536
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
537
- menu={this.menu}
538
- />
539
- );
540
- }
541
- protected override _toIPV6(schema: IPV6Schema)
542
- {
543
- if (this.multiple)
544
- return null;
545
- return (
546
- <NSBoxIPV6
547
- ref={this.box_ref as React.RefObject<any>}
548
- key={this.key}
549
- {...this.props}
550
-
551
- required={schema.required}
552
- valids={schema.valids}
553
- invalids={schema.invalids}
554
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
555
-
556
- title={this.title}
557
- placeholder={this.placeholder}
558
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
559
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
560
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
561
- menu={this.menu}
562
- />
563
- );
564
- }
565
- protected override _toIPV4Range(schema: IPV4RangeSchema)
566
- {
567
- if (this.multiple)
568
- return null;
569
- return (
570
- <NSBoxIPV4Range
571
- ref={this.box_ref as React.RefObject<any>}
572
- key={this.key}
573
- {...this.props}
574
-
575
- required={schema.required}
576
- valids={schema.valids}
577
- invalids={schema.invalids}
578
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
579
-
580
- title={this.title}
581
- placeholder={this.placeholder}
582
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
583
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
584
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
585
- menu={this.menu}
586
- />
587
- );
588
- }
589
- protected override _toIPV6Range(schema: IPV6RangeSchema)
590
- {
591
- if (this.multiple)
592
- return null;
593
- return (
594
- <NSBoxIPV6Range
595
- ref={this.box_ref as React.RefObject<any>}
596
- key={this.key}
597
- {...this.props}
598
-
599
- required={schema.required}
600
- valids={schema.valids}
601
- invalids={schema.invalids}
602
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
603
-
604
- title={this.title}
605
- placeholder={this.placeholder}
606
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
607
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
608
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
609
- menu={this.menu}
610
- />
611
- );
612
- }
613
- protected override _toColor(schema: ColorSchema)
614
- {
615
- if (this.multiple)
616
- return null;
617
- return (
618
- <NSBoxColor
619
- ref={this.box_ref as React.RefObject<any>}
620
- key={this.key}
621
- {...this.props}
622
-
623
- required={schema.required}
624
- valids={schema.valids}
625
- invalids={schema.invalids}
626
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
627
-
628
- title={this.title}
629
- placeholder={this.placeholder}
630
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
631
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
632
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
633
- menu={this.menu}
634
- />
635
- );
636
- }
637
- protected override _toFont(schema: FontSchema)
638
- {
639
- if (this.multiple)
640
- return null;
641
- return (
642
- <NSBoxFont
643
- ref={this.box_ref as React.RefObject<any>}
644
- key={this.key}
645
- {...this.props}
646
-
647
- required={schema.required}
648
- valids={schema.valids}
649
- invalids={schema.invalids}
650
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
651
-
652
- title={this.title}
653
- placeholder={this.placeholder}
654
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
655
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
656
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
657
- menu={this.menu}
658
- />
659
- );
660
- }
661
- protected override _toFilePath(schema: FilePathSchema)
662
- {
663
- if (this.multiple)
664
- return null;
665
- return (
666
- <NSBoxFilePath
667
- ref={this.box_ref as React.RefObject<any>}
668
- key={this.key}
669
- {...this.props}
670
-
671
- required={schema.required}
672
- valids={schema.valids}
673
- invalids={schema.invalids}
674
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
675
-
676
- title={this.title}
677
- placeholder={this.placeholder}
678
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
679
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
680
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
681
- menu={this.menu}
682
- />
683
- );
684
- }
685
- protected override _toURL(schema: URLSchema)
686
- {
687
- if (this.multiple)
688
- return null;
689
- return (
690
- <NSBoxURL
691
- ref={this.box_ref as React.RefObject<any>}
692
- key={this.key}
693
- {...this.props}
694
-
695
- required={schema.required}
696
- valids={schema.valids}
697
- invalids={schema.invalids}
698
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
699
-
700
- title={this.title}
701
- placeholder={this.placeholder}
702
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
703
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
704
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
705
- menu={this.menu}
706
- />
707
- );
708
- }
709
- protected override _toEnum(schema: EnumSchema)
710
- {
711
- return (
712
- <NSBoxCombo
713
- ref={this.box_ref as React.RefObject<any>}
714
- key={this.key}
715
- {...this.props}
716
-
717
- required={schema.required}
718
- valids={schema.valids}
719
- invalids={schema.invalids}
720
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
721
-
722
- title={this.title}
723
- placeholder={this.placeholder}
724
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
725
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
726
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
727
- menu={this.menu}
728
-
729
- multiple={this.multiple ?? false}
730
- getOptions={() =>
731
- {
732
- let valids = schema.valids;
733
- valids = valids.filter((v) => !schema.invalids.includes(v));
734
- return valids.map((v) => ({ title: v, value: v }));
735
- }}
736
- />
737
- );
738
- }
739
- protected override _toEntity(schema: EntitySchema)
740
- {
741
- return (
742
- <NSBoxEntity<any>
743
- ref={this.box_ref as React.RefObject<any>}
744
- key={this.key}
745
- {...this.props}
746
-
747
- required={schema.required}
748
- valids={schema.valids}
749
- invalids={schema.invalids}
750
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
751
-
752
- title={this.title}
753
- placeholder={this.placeholder}
754
- defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
755
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
756
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
757
- menu={this.menu}
758
-
759
- multiple={this.multiple ?? false}
760
-
761
- getItems={async () =>
762
- {
763
- // let product = Globe.namirasoft.getByProductID(schema.product);
764
- // product.meta.tables[schema.table];
765
- // product.server.List;
766
- // todo
767
- return { count: 0, rows: [] };
768
- }}
769
- getValue={(item) => item.id}
770
- getTitle={(item) => item.name}
771
- getSort={() => null}
772
- />
773
- );
774
- }
775
- protected override _toArray(schema: ArraySchema, callback: (schema: BaseTypeSchema) => void)
776
- {
777
- if (this.multiple)
778
- return null;
779
- if (schema.items.length === 0)
780
- return null;
781
- if (schema.items.length > 1)
782
- return null;
783
-
784
- let menu = safeMenuMenuItem(this.props, () => { });
785
-
786
- return (
787
- <NSBoxBaseLayoutRecursive
788
- id={this.props.id}
789
- {...this.props}
790
- required
791
- title={this.title}
792
- depth={this.depth}
793
- menu={menu}
794
- >
795
- <NSRepeater<INSBox, string>
796
- ref={this.box_ref as React.RefObject<any>}
797
- key={this.key}
798
- createItem={(gIndex: number, lIndex: number, ref: React.RefObject<INSBox>, onChange: () => void, onDelete: undefined | ((index: number) => void)) =>
799
- {
800
- let title = "Item " + (lIndex + 1)
801
- let props = {
802
- ...this.props,
803
- title,
804
- onChanged: (box: NSBoxDynamic) =>
805
- {
806
- this.props.onChanged?.(box);
807
- onChange();
808
- },
809
- style: { ...this.props.style },
810
- variable: new BaseVariableSchema(title, schema.items[0]),
811
- multiple: false
812
- };
813
- let builder = new NSBoxBuilder(this.box, props, ref, "NSBoxBuilder_NSRepeater_Item_" + (gIndex + 1),
814
- onDelete ? () => { onDelete(gIndex) } : undefined
815
- );
816
- builder.depth = this.depth + 1;
817
- return builder.runSynch(callback);
818
- }}
819
- setValue={function (item: INSBox, _: number, value: string | null): void
820
- {
821
- if (value)
822
- item.setValue(value);
823
- }}
824
- getValue={function (item: INSBox, checkError: boolean): string
825
- {
826
- return item.getValue(checkError)
827
- }}
828
- isEmpty={function (item: INSBox, value: string | null): boolean
829
- {
830
- return item.isEmpty(value)
831
- }}
832
- min={schema.min ?? undefined}
833
- max={schema.max ?? undefined}
834
- />
835
- </NSBoxBaseLayoutRecursive>
836
- );
837
- }
838
- protected override _toObject(schema: ObjectSchema, callback: (schema: BaseTypeSchema) => void)
839
- {
840
- let children: React.JSX.Element[] | null = this.ifOjbect((_, fields) =>
841
- {
842
- return fields.map((_, index) =>
843
- {
844
- return this.builders[index].builder.runSynch(callback);
845
- }).filter(x => x).map(x => x as React.JSX.Element);
846
- });
847
- if (!children)
848
- return null;
849
-
850
- let menu = safeMenuMenuItem(this.props, () => { });
851
-
852
- return (
853
- <NSBoxBaseLayoutRecursive
854
- id={this.props.id}
855
- {...this.props}
856
- required
857
- title={this.title + ((schema.name && schema.name !== this.title) ? ` (${schema.name})` : "")}
858
- depth={this.depth}
859
- menu={menu}
860
- >
861
- {children}
862
- </NSBoxBaseLayoutRecursive>
863
- );
864
- }
865
- protected override _toType(schema: TypeSchema)
866
- {
867
- if (this.multiple)
868
- return null;
869
- return (
870
- <NSBoxSchemaBase
871
- ref={this.box_ref as React.RefObject<any>}
872
- key={this.key}
873
- {...this.props}
874
-
875
- required={schema.required}
876
- valids={schema.valids}
877
- invalids={schema.invalids}
878
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
879
-
880
- title={this.title}
881
- placeholder={this.placeholder}
882
- defaultValue={undefined}
883
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
884
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
885
- menu={this.menu}
886
- />
887
- );
888
- }
889
- protected override _toVariable(schema: VariableSchema)
890
- {
891
- if (this.multiple)
892
- return null;
893
- return (
894
- <NSBoxSchemaVariable
895
- ref={this.box_ref as React.RefObject<any>}
896
- key={this.key}
897
- {...this.props}
898
-
899
- required={schema.required}
900
- valids={schema.valids}
901
- invalids={schema.invalids}
902
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
903
-
904
- title={this.title}
905
- placeholder={this.placeholder}
906
- defaultValue={undefined}
907
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
908
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
909
- menu={this.menu}
910
- />
911
- );
912
- }
1
+ import { AnySchema, ArraySchema, BaseNumberSchema, BasePrecisionSchema, BaseTypeBuilder, BaseTypeSchema, BaseVariableSchema, BigIntSchema, BoolSchema, ColorSchema, DateSchema, DateTimeSchema, DecimalSchema, DoubleSchema, DurationSchema, EmailSchema, EntitySchema, EnumSchema, FilePathSchema, FloatSchema, FontSchema, IntegerSchema, IPV4RangeSchema, IPV4Schema, IPV6RangeSchema, IPV6Schema, MediumIntSchema, MoneySchema, ObjectSchema, PhoneSchema, RealSchema, SmallIntSchema, StringSchema, TimeSchema, TimeZoneSchema, TinyIntSchema, TypeSchema, URLSchema, VariableSchema, VariableType, VersionSchema } from "namirasoft-schema";
2
+ import { NSBoxBoolean } from "./components/NSBoxBoolean";
3
+ import { NSBoxCombo } from "./components/NSBoxCombo";
4
+ import { NSBoxDate } from "./components/NSBoxDate";
5
+ import { NSBoxDateTime } from "./components/NSBoxDateTime";
6
+ import { NSBoxDouble } from "./components/NSBoxDouble";
7
+ import { NSBoxDuration } from "./components/NSBoxDuration";
8
+ import { NSBoxDynamic, NSBoxDynamicProps } from "./components/NSBoxDynamic";
9
+ import { NSBoxEmail } from "./components/NSBoxEmail";
10
+ import { NSBoxEntity } from "./components/NSBoxEntity";
11
+ import { NSBoxInteger } from "./components/NSBoxInteger";
12
+ import { NSBoxIPV4 } from "./components/NSBoxIPV4";
13
+ import { NSBoxIPV6 } from "./components/NSBoxIPV6";
14
+ import { NSBoxMoney } from "./components/NSBoxMoney";
15
+ import { NSBoxPhone } from "./components/NSBoxPhone";
16
+ import { NSBoxString } from "./components/NSBoxString";
17
+ import { NSBoxTime } from "./components/NSBoxTime";
18
+ import { NSRepeater } from "./components/NSRepeater";
19
+ import { NSBoxTimeZone } from "./components/NSBoxTimeZone";
20
+ import { NSBoxVersion } from "./components/NSBoxVersion";
21
+ import { NSBoxIPV4Range } from "./components/NSBoxIPV4Range";
22
+ import { NSBoxIPV6Range } from "./components/NSBoxIPV6Range";
23
+ import { NSBoxColor } from "./components/NSBoxColor";
24
+ import { NSBoxFont } from "./components/NSBoxFont";
25
+ import { NSBoxFilePath } from "./components/NSBoxFilePath";
26
+ import { NSBoxURL } from "./components/NSBoxURL";
27
+ import { NamingConvention, ObjectService } from "namirasoft-core";
28
+ import { INSBox } from "./components/INSBox";
29
+ import { createRef } from "react";
30
+ import { NSBoxBaseLayoutRecursive } from "./components/NSBoxBaseLayoutRecursive";
31
+ import { NSMenuButtonMenuProps, safeMenuMenuItem } from "./components/NSMenuButton";
32
+ import { NSBoxSchemaBase, NSBoxSchemaVariable } from "./main";
33
+
34
+ export class NSBoxBuilder extends BaseTypeBuilder<React.JSX.Element | null>
35
+ {
36
+ private depth: number = 0;
37
+ private box: NSBoxDynamic;
38
+ private props: NSBoxDynamicProps;
39
+ private box_ref: React.RefObject<INSBox>;
40
+ private key: string;
41
+ private title: string;
42
+ private placeholder: string;
43
+ private menu: NSMenuButtonMenuProps;
44
+ private builders: { builder: NSBoxBuilder, ref: React.RefObject<INSBox> }[] = [];
45
+ private multiple: boolean;
46
+
47
+ constructor(box: NSBoxDynamic, props: NSBoxDynamicProps, box_ref: React.RefObject<INSBox>, key: string, onDelete?: () => void)
48
+ {
49
+ super(props.variable.type);
50
+ this.box = box;
51
+ this.props = props;
52
+ this.box_ref = box_ref;
53
+ this.key = key;
54
+ this.toInteger = this.toInteger.bind(this);
55
+ this.toPrecision = this.toPrecision.bind(this);
56
+ this.ifOjbect = this.ifOjbect.bind(this);
57
+
58
+ this.title = this.props.title;
59
+ if (!this.title)
60
+ this.title = NamingConvention.auto.convert(this.props.variable.name, NamingConvention.Pascal_Case_Space);
61
+ this.placeholder = props.variable.type.example ?? "";
62
+ this.multiple = props.variable.tags["multiple"] === "true";
63
+ this.menu = safeMenuMenuItem(this.props, () => { });
64
+ this.menu.builtin.delete = { enabled: onDelete != null, onDelete: () => { onDelete?.() } };
65
+ this.builders = this.ifOjbect((_, fields) =>
66
+ {
67
+ return fields.map((f) =>
68
+ {
69
+ let title = NamingConvention.auto.convert(f.name, NamingConvention.Pascal_Case_Space);
70
+ let props = {
71
+ ...this.props,
72
+ title,
73
+ onChanged: (box: NSBoxDynamic) =>
74
+ {
75
+ this.props.onChanged?.(box);
76
+ },
77
+ variable: f,
78
+ multiple: false
79
+ };
80
+ let ref = createRef<INSBox>();
81
+ let builder = new NSBoxBuilder(this.box, props, ref, "NSBoxBuilder_Object_" + f.name);
82
+ builder.depth = this.depth + 1;
83
+ return { builder, ref };
84
+ });
85
+ }) ?? [];
86
+ }
87
+ private ifOjbect<T>(handler: (schema: ObjectSchema, fields: BaseVariableSchema[]) => T): T | null
88
+ {
89
+ if (this.props.variable.type.type === VariableType.Object)
90
+ {
91
+ let schema = this.props.variable.type as ObjectSchema;
92
+
93
+ if (this.multiple)
94
+ return null;
95
+ if (schema.external)
96
+ return null;
97
+ if (!schema.fields)
98
+ return null
99
+ if (schema.fields.length === 0)
100
+ return null
101
+ if (schema.fields)
102
+ return handler(schema, schema.fields);
103
+ }
104
+ return null;
105
+ }
106
+ getValue(checkError: boolean = true): any | null
107
+ {
108
+ let obj = this.box_ref.current?.getValue(checkError);
109
+
110
+ let res = this.ifOjbect((_, fields) =>
111
+ {
112
+ let ans: { [name: string]: any } = {};
113
+ fields.forEach((f, index) =>
114
+ {
115
+ let obj = this.builders[index].builder.getValue(checkError);
116
+ ans[f.name] = obj;
117
+ });
118
+ return ans;
119
+ });
120
+ if (res != null)
121
+ obj = res;
122
+
123
+ return obj;
124
+ }
125
+ setValue(value: any | null, callback?: () => void): void
126
+ {
127
+ if (!this.ifOjbect((_, fields) =>
128
+ {
129
+ fields.forEach((f, index) =>
130
+ {
131
+ let obj = value?.[f.name];
132
+ this.builders[index].builder.setValue(obj);
133
+ });
134
+ return true;
135
+ }))
136
+ this.box_ref.current?.setValue(value, callback);
137
+ }
138
+ /* VariableType */
139
+ protected override _toAny(_: AnySchema)
140
+ {
141
+ return null;
142
+ }
143
+ protected override _toBool(schema: BoolSchema)
144
+ {
145
+ if (this.multiple)
146
+ return null;
147
+
148
+ return (
149
+ <NSBoxBoolean
150
+ ref={this.box_ref as React.RefObject<any>}
151
+ key={this.key}
152
+ {...this.props}
153
+
154
+ required={schema.required}
155
+ valids={schema.valids}
156
+ invalids={schema.invalids}
157
+ // regex={schema.regex}
158
+
159
+ title={this.title}
160
+ placeholder={this.placeholder}
161
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullBoolean() ?? undefined}
162
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
163
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
164
+ menu={this.menu}
165
+ />
166
+ );
167
+ }
168
+ private toInteger(schema: BaseNumberSchema): React.JSX.Element | null
169
+ {
170
+ if (this.multiple)
171
+ return null;
172
+
173
+ return (
174
+ <NSBoxInteger
175
+ ref={this.box_ref as React.RefObject<any>}
176
+ key={this.key}
177
+ {...this.props}
178
+
179
+ required={schema.required}
180
+ valids={schema.valids}
181
+ invalids={schema.invalids}
182
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
183
+
184
+ title={this.title}
185
+ placeholder={this.placeholder}
186
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullInt() ?? undefined}
187
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
188
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
189
+ menu={this.menu}
190
+
191
+ min={schema.min ?? undefined}
192
+ max={schema.max ?? undefined}
193
+ />
194
+ );
195
+ }
196
+ protected override _toTinyInt(schema: TinyIntSchema)
197
+ {
198
+ return this.toInteger(schema);
199
+ }
200
+ protected override _toSmallInt(schema: SmallIntSchema)
201
+ {
202
+ return this.toInteger(schema);
203
+ }
204
+ protected override _toMediumInt(schema: MediumIntSchema)
205
+ {
206
+ return this.toInteger(schema);
207
+ }
208
+ protected override _toInteger(schema: IntegerSchema)
209
+ {
210
+ return this.toInteger(schema);
211
+ }
212
+ protected override _toBigInt(schema: BigIntSchema)
213
+ {
214
+ return this.toInteger(schema);
215
+ }
216
+ private toPrecision(schema: BasePrecisionSchema): React.JSX.Element | null
217
+ {
218
+ if (this.multiple)
219
+ return null;
220
+
221
+ return (
222
+ <NSBoxDouble
223
+ ref={this.box_ref as React.RefObject<any>}
224
+ key={this.key}
225
+ {...this.props}
226
+
227
+ required={schema.required}
228
+ valids={schema.valids}
229
+ invalids={schema.invalids}
230
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
231
+
232
+ title={this.title}
233
+ placeholder={this.placeholder}
234
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullFloat() ?? undefined}
235
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
236
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
237
+ menu={this.menu}
238
+
239
+ min={schema.min ?? undefined}
240
+ max={schema.max ?? undefined}
241
+ precision={schema.precision ?? undefined}
242
+ />
243
+ );
244
+ }
245
+ protected override _toFloat(schema: FloatSchema)
246
+ {
247
+ return this.toPrecision(schema);
248
+ }
249
+ protected override _toDouble(schema: DoubleSchema)
250
+ {
251
+ return this.toPrecision(schema);
252
+ }
253
+ protected override _toDecimal(schema: DecimalSchema)
254
+ {
255
+ return this.toPrecision(schema);
256
+ }
257
+ protected override _toReal(schema: RealSchema)
258
+ {
259
+ return this.toPrecision(schema);
260
+ }
261
+ protected override _toMoney(schema: MoneySchema)
262
+ {
263
+ if (this.multiple)
264
+ return null;
265
+
266
+ return (
267
+ <NSBoxMoney
268
+ ref={this.box_ref as React.RefObject<any>}
269
+ key={this.key}
270
+ {...this.props}
271
+
272
+ required={schema.required}
273
+ valids={schema.valids}
274
+ invalids={schema.invalids}
275
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
276
+
277
+ title={this.title}
278
+ placeholder={this.placeholder}
279
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullFloat() ?? undefined}
280
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
281
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
282
+ menu={this.menu}
283
+
284
+ min={schema.min ?? undefined}
285
+ max={schema.max ?? undefined}
286
+ precision={schema.precision ?? undefined}
287
+ />
288
+ );
289
+ }
290
+ protected override _toString(schema: StringSchema)
291
+ {
292
+ if (this.multiple)
293
+ return null;
294
+
295
+ return (
296
+ <NSBoxString
297
+ ref={this.box_ref as React.RefObject<any>}
298
+ key={this.key}
299
+ {...this.props}
300
+
301
+ required={schema.required}
302
+ valids={schema.valids}
303
+ invalids={schema.invalids}
304
+ regex={schema.regex ? { name: this.props.variable.name, regex: schema.regex } : undefined}
305
+
306
+ title={this.title}
307
+ placeholder={this.placeholder}
308
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
309
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
310
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
311
+ menu={this.menu}
312
+
313
+ min_length={schema.min_length ?? undefined}
314
+ max_length={schema.max_length ?? undefined}
315
+ />
316
+ );
317
+ }
318
+ protected override _toDate(schema: DateSchema)
319
+ {
320
+ if (this.multiple)
321
+ return null;
322
+
323
+ return (
324
+ <NSBoxDate
325
+ ref={this.box_ref as React.RefObject<any>}
326
+ key={this.key}
327
+ {...this.props}
328
+
329
+ required={schema.required}
330
+ valids={schema.valids}
331
+ invalids={schema.invalids}
332
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
333
+
334
+ title={this.title}
335
+ placeholder={this.placeholder}
336
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
337
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
338
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
339
+ menu={this.menu}
340
+ />
341
+ );
342
+ }
343
+ protected override _toTime(schema: TimeSchema)
344
+ {
345
+ if (this.multiple)
346
+ return null;
347
+
348
+ return (
349
+ <NSBoxTime
350
+ ref={this.box_ref as React.RefObject<any>}
351
+ key={this.key}
352
+ {...this.props}
353
+
354
+ required={schema.required}
355
+ valids={schema.valids}
356
+ invalids={schema.invalids}
357
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
358
+
359
+ title={this.title}
360
+ placeholder={this.placeholder}
361
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
362
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
363
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
364
+ menu={this.menu}
365
+ />
366
+ );
367
+ }
368
+ protected override _toDateTime(schema: DateTimeSchema)
369
+ {
370
+ if (this.multiple)
371
+ return null;
372
+
373
+ return (
374
+ <NSBoxDateTime
375
+ ref={this.box_ref as React.RefObject<any>}
376
+ key={this.key}
377
+ {...this.props}
378
+
379
+ required={schema.required}
380
+ valids={schema.valids}
381
+ invalids={schema.invalids}
382
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
383
+
384
+ title={this.title}
385
+ placeholder={this.placeholder}
386
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullDate() ?? undefined}
387
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
388
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
389
+ menu={this.menu}
390
+ />
391
+ );
392
+ }
393
+ protected override _toTimeZone(schema: TimeZoneSchema)
394
+ {
395
+ if (this.multiple)
396
+ return null;
397
+
398
+ return (
399
+ <NSBoxTimeZone
400
+ ref={this.box_ref as React.RefObject<any>}
401
+ key={this.key}
402
+ {...this.props}
403
+
404
+ required={schema.required}
405
+ valids={schema.valids}
406
+ invalids={schema.invalids}
407
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
408
+
409
+ title={this.title}
410
+ placeholder={this.placeholder}
411
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
412
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
413
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
414
+ menu={this.menu}
415
+ />
416
+ );
417
+ }
418
+ protected override _toDuration(schema: DurationSchema)
419
+ {
420
+ if (this.multiple)
421
+ return null;
422
+
423
+ return (
424
+ <NSBoxDuration
425
+ ref={this.box_ref as React.RefObject<any>}
426
+ key={this.key}
427
+ {...this.props}
428
+
429
+ required={schema.required}
430
+ valids={schema.valids}
431
+ invalids={schema.invalids}
432
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
433
+
434
+ title={this.title}
435
+ placeholder={this.placeholder}
436
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
437
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
438
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
439
+ menu={this.menu}
440
+ />
441
+ );
442
+ }
443
+ protected override _toEmail(schema: EmailSchema)
444
+ {
445
+ if (this.multiple)
446
+ return null;
447
+
448
+ return (
449
+ <NSBoxEmail
450
+ ref={this.box_ref as React.RefObject<any>}
451
+ key={this.key}
452
+ {...this.props}
453
+
454
+ required={schema.required}
455
+ valids={schema.valids}
456
+ invalids={schema.invalids}
457
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
458
+
459
+ title={this.title}
460
+ placeholder={this.placeholder}
461
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
462
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
463
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
464
+ menu={this.menu}
465
+ />
466
+ );
467
+ }
468
+ protected override _toPhone(schema: PhoneSchema)
469
+ {
470
+ if (this.multiple)
471
+ return null;
472
+
473
+ return (
474
+ <NSBoxPhone
475
+ ref={this.box_ref as React.RefObject<any>}
476
+ key={this.key}
477
+ {...this.props}
478
+
479
+ required={schema.required}
480
+ valids={schema.valids}
481
+ invalids={schema.invalids}
482
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
483
+
484
+ title={this.title}
485
+ placeholder={this.placeholder}
486
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
487
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
488
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
489
+ menu={this.menu}
490
+ />
491
+ );
492
+ }
493
+ protected override _toVersion(schema: VersionSchema)
494
+ {
495
+ if (this.multiple)
496
+ return null;
497
+ return (
498
+ <NSBoxVersion
499
+ ref={this.box_ref as React.RefObject<any>}
500
+ key={this.key}
501
+ {...this.props}
502
+
503
+ required={schema.required}
504
+ valids={schema.valids}
505
+ invalids={schema.invalids}
506
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
507
+
508
+ title={this.title}
509
+ placeholder={this.placeholder}
510
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
511
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
512
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
513
+ menu={this.menu}
514
+ />
515
+ );
516
+ }
517
+ protected override _toIPV4(schema: IPV4Schema)
518
+ {
519
+ if (this.multiple)
520
+ return null;
521
+ return (
522
+ <NSBoxIPV4
523
+ ref={this.box_ref as React.RefObject<any>}
524
+ key={this.key}
525
+ {...this.props}
526
+
527
+ required={schema.required}
528
+ valids={schema.valids}
529
+ invalids={schema.invalids}
530
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
531
+
532
+ title={this.title}
533
+ placeholder={this.placeholder}
534
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
535
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
536
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
537
+ menu={this.menu}
538
+ />
539
+ );
540
+ }
541
+ protected override _toIPV6(schema: IPV6Schema)
542
+ {
543
+ if (this.multiple)
544
+ return null;
545
+ return (
546
+ <NSBoxIPV6
547
+ ref={this.box_ref as React.RefObject<any>}
548
+ key={this.key}
549
+ {...this.props}
550
+
551
+ required={schema.required}
552
+ valids={schema.valids}
553
+ invalids={schema.invalids}
554
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
555
+
556
+ title={this.title}
557
+ placeholder={this.placeholder}
558
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
559
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
560
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
561
+ menu={this.menu}
562
+ />
563
+ );
564
+ }
565
+ protected override _toIPV4Range(schema: IPV4RangeSchema)
566
+ {
567
+ if (this.multiple)
568
+ return null;
569
+ return (
570
+ <NSBoxIPV4Range
571
+ ref={this.box_ref as React.RefObject<any>}
572
+ key={this.key}
573
+ {...this.props}
574
+
575
+ required={schema.required}
576
+ valids={schema.valids}
577
+ invalids={schema.invalids}
578
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
579
+
580
+ title={this.title}
581
+ placeholder={this.placeholder}
582
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
583
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
584
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
585
+ menu={this.menu}
586
+ />
587
+ );
588
+ }
589
+ protected override _toIPV6Range(schema: IPV6RangeSchema)
590
+ {
591
+ if (this.multiple)
592
+ return null;
593
+ return (
594
+ <NSBoxIPV6Range
595
+ ref={this.box_ref as React.RefObject<any>}
596
+ key={this.key}
597
+ {...this.props}
598
+
599
+ required={schema.required}
600
+ valids={schema.valids}
601
+ invalids={schema.invalids}
602
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
603
+
604
+ title={this.title}
605
+ placeholder={this.placeholder}
606
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
607
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
608
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
609
+ menu={this.menu}
610
+ />
611
+ );
612
+ }
613
+ protected override _toColor(schema: ColorSchema)
614
+ {
615
+ if (this.multiple)
616
+ return null;
617
+ return (
618
+ <NSBoxColor
619
+ ref={this.box_ref as React.RefObject<any>}
620
+ key={this.key}
621
+ {...this.props}
622
+
623
+ required={schema.required}
624
+ valids={schema.valids}
625
+ invalids={schema.invalids}
626
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
627
+
628
+ title={this.title}
629
+ placeholder={this.placeholder}
630
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
631
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
632
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
633
+ menu={this.menu}
634
+ />
635
+ );
636
+ }
637
+ protected override _toFont(schema: FontSchema)
638
+ {
639
+ if (this.multiple)
640
+ return null;
641
+ return (
642
+ <NSBoxFont
643
+ ref={this.box_ref as React.RefObject<any>}
644
+ key={this.key}
645
+ {...this.props}
646
+
647
+ required={schema.required}
648
+ valids={schema.valids}
649
+ invalids={schema.invalids}
650
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
651
+
652
+ title={this.title}
653
+ placeholder={this.placeholder}
654
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
655
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
656
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
657
+ menu={this.menu}
658
+ />
659
+ );
660
+ }
661
+ protected override _toFilePath(schema: FilePathSchema)
662
+ {
663
+ if (this.multiple)
664
+ return null;
665
+ return (
666
+ <NSBoxFilePath
667
+ ref={this.box_ref as React.RefObject<any>}
668
+ key={this.key}
669
+ {...this.props}
670
+
671
+ required={schema.required}
672
+ valids={schema.valids}
673
+ invalids={schema.invalids}
674
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
675
+
676
+ title={this.title}
677
+ placeholder={this.placeholder}
678
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
679
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
680
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
681
+ menu={this.menu}
682
+ />
683
+ );
684
+ }
685
+ protected override _toURL(schema: URLSchema)
686
+ {
687
+ if (this.multiple)
688
+ return null;
689
+ return (
690
+ <NSBoxURL
691
+ ref={this.box_ref as React.RefObject<any>}
692
+ key={this.key}
693
+ {...this.props}
694
+
695
+ required={schema.required}
696
+ valids={schema.valids}
697
+ invalids={schema.invalids}
698
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
699
+
700
+ title={this.title}
701
+ placeholder={this.placeholder}
702
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
703
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
704
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
705
+ menu={this.menu}
706
+ />
707
+ );
708
+ }
709
+ protected override _toEnum(schema: EnumSchema)
710
+ {
711
+ return (
712
+ <NSBoxCombo
713
+ ref={this.box_ref as React.RefObject<any>}
714
+ key={this.key}
715
+ {...this.props}
716
+
717
+ required={schema.required}
718
+ valids={schema.valids}
719
+ invalids={schema.invalids}
720
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
721
+
722
+ title={this.title}
723
+ placeholder={this.placeholder}
724
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
725
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
726
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
727
+ menu={this.menu}
728
+
729
+ multiple={this.multiple ?? false}
730
+ getOptions={() =>
731
+ {
732
+ let valids = schema.valids;
733
+ valids = valids.filter((v) => !schema.invalids.includes(v));
734
+ return valids.map((v) => ({ title: v, value: v }));
735
+ }}
736
+ />
737
+ );
738
+ }
739
+ protected override _toEntity(schema: EntitySchema)
740
+ {
741
+ return (
742
+ <NSBoxEntity<any>
743
+ ref={this.box_ref as React.RefObject<any>}
744
+ key={this.key}
745
+ {...this.props}
746
+
747
+ required={schema.required}
748
+ valids={schema.valids}
749
+ invalids={schema.invalids}
750
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
751
+
752
+ title={this.title}
753
+ placeholder={this.placeholder}
754
+ defaultValue={new ObjectService(this.props.variable.defaultValue).getNullString() ?? undefined}
755
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
756
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
757
+ menu={this.menu}
758
+
759
+ multiple={this.multiple ?? false}
760
+
761
+ getItems={async () =>
762
+ {
763
+ // let product = Globe.namirasoft.getByProductID(schema.product);
764
+ // product.meta.tables[schema.table];
765
+ // product.server.List;
766
+ // todo
767
+ return { count: 0, rows: [] };
768
+ }}
769
+ getValue={(item) => item.id}
770
+ getTitle={(item) => item.name}
771
+ getSort={() => null}
772
+ />
773
+ );
774
+ }
775
+ protected override _toArray(schema: ArraySchema, callback: (schema: BaseTypeSchema) => void)
776
+ {
777
+ if (this.multiple)
778
+ return null;
779
+ if (schema.items.length === 0)
780
+ return null;
781
+ if (schema.items.length > 1)
782
+ return null;
783
+
784
+ let menu = safeMenuMenuItem(this.props, () => { });
785
+
786
+ return (
787
+ <NSBoxBaseLayoutRecursive
788
+ id={this.props.id}
789
+ {...this.props}
790
+ required
791
+ title={this.title}
792
+ depth={this.depth}
793
+ menu={menu}
794
+ >
795
+ <NSRepeater<INSBox, string>
796
+ ref={this.box_ref as React.RefObject<any>}
797
+ key={this.key}
798
+ createItem={(gIndex: number, lIndex: number, ref: React.RefObject<INSBox>, onChange: () => void, onDelete: undefined | ((index: number) => void)) =>
799
+ {
800
+ let title = "Item " + (lIndex + 1)
801
+ let props = {
802
+ ...this.props,
803
+ title,
804
+ onChanged: (box: NSBoxDynamic) =>
805
+ {
806
+ this.props.onChanged?.(box);
807
+ onChange();
808
+ },
809
+ style: { ...this.props.style },
810
+ variable: new BaseVariableSchema(title, schema.items[0]),
811
+ multiple: false
812
+ };
813
+ let builder = new NSBoxBuilder(this.box, props, ref, "NSBoxBuilder_NSRepeater_Item_" + (gIndex + 1),
814
+ onDelete ? () => { onDelete(gIndex) } : undefined
815
+ );
816
+ builder.depth = this.depth + 1;
817
+ return builder.runSynch(callback);
818
+ }}
819
+ setValue={function (item: INSBox, _: number, value: string | null): void
820
+ {
821
+ if (value)
822
+ item.setValue(value);
823
+ }}
824
+ getValue={function (item: INSBox, checkError: boolean): string
825
+ {
826
+ return item.getValue(checkError)
827
+ }}
828
+ isEmpty={function (item: INSBox, value: string | null): boolean
829
+ {
830
+ return item.isEmpty(value)
831
+ }}
832
+ min={schema.min ?? undefined}
833
+ max={schema.max ?? undefined}
834
+ />
835
+ </NSBoxBaseLayoutRecursive>
836
+ );
837
+ }
838
+ protected override _toObject(schema: ObjectSchema, callback: (schema: BaseTypeSchema) => void)
839
+ {
840
+ let children: React.JSX.Element[] | null = this.ifOjbect((_, fields) =>
841
+ {
842
+ return fields.map((_, index) =>
843
+ {
844
+ return this.builders[index].builder.runSynch(callback);
845
+ }).filter(x => x).map(x => x as React.JSX.Element);
846
+ });
847
+ if (!children)
848
+ return null;
849
+
850
+ let menu = safeMenuMenuItem(this.props, () => { });
851
+
852
+ return (
853
+ <NSBoxBaseLayoutRecursive
854
+ id={this.props.id}
855
+ {...this.props}
856
+ required
857
+ title={this.title + ((schema.name && schema.name !== this.title) ? ` (${schema.name})` : "")}
858
+ depth={this.depth}
859
+ menu={menu}
860
+ >
861
+ {children}
862
+ </NSBoxBaseLayoutRecursive>
863
+ );
864
+ }
865
+ protected override _toType(schema: TypeSchema)
866
+ {
867
+ if (this.multiple)
868
+ return null;
869
+ return (
870
+ <NSBoxSchemaBase
871
+ ref={this.box_ref as React.RefObject<any>}
872
+ key={this.key}
873
+ {...this.props}
874
+
875
+ required={schema.required}
876
+ valids={schema.valids}
877
+ invalids={schema.invalids}
878
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
879
+
880
+ title={this.title}
881
+ placeholder={this.placeholder}
882
+ defaultValue={undefined}
883
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
884
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
885
+ menu={this.menu}
886
+ />
887
+ );
888
+ }
889
+ protected override _toVariable(schema: VariableSchema)
890
+ {
891
+ if (this.multiple)
892
+ return null;
893
+ return (
894
+ <NSBoxSchemaVariable
895
+ ref={this.box_ref as React.RefObject<any>}
896
+ key={this.key}
897
+ {...this.props}
898
+
899
+ required={schema.required}
900
+ valids={schema.valids}
901
+ invalids={schema.invalids}
902
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
903
+
904
+ title={this.title}
905
+ placeholder={this.placeholder}
906
+ defaultValue={undefined}
907
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
908
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
909
+ menu={this.menu}
910
+ />
911
+ );
912
+ }
913
913
  }