namirasoft-site-react 1.4.339 → 1.4.340

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 (290) 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/NSBanner.module.css +47 -47
  7. package/dist/components/NSBarAction.module.css +84 -84
  8. package/dist/components/NSBarAlert.module.css +79 -79
  9. package/dist/components/NSBarNotification.module.css +34 -34
  10. package/dist/components/NSBarTitle.module.css +9 -9
  11. package/dist/components/NSBox.module.css +50 -50
  12. package/dist/components/NSBoxBaseCombo.module.css +6 -6
  13. package/dist/components/NSBoxBoolean.module.css +67 -67
  14. package/dist/components/NSBoxDate.module.css +4 -4
  15. package/dist/components/NSBoxDateTime.module.css +4 -4
  16. package/dist/components/NSBoxDuration.module.css +4 -4
  17. package/dist/components/NSBoxFile.module.css +10 -10
  18. package/dist/components/NSBoxPhone.module.css +35 -35
  19. package/dist/components/NSBoxRadio.module.css +33 -33
  20. package/dist/components/NSBoxSchemaBase.module.css +17 -17
  21. package/dist/components/NSBoxSchemaVariable.module.css +16 -16
  22. package/dist/components/NSBoxTextArea.module.css +12 -12
  23. package/dist/components/NSBoxTime.module.css +4 -4
  24. package/dist/components/NSButton.module.css +57 -57
  25. package/dist/components/NSButtonBlue.module.css +4 -4
  26. package/dist/components/NSButtonGreen.module.css +4 -4
  27. package/dist/components/NSButtonRed.module.css +4 -4
  28. package/dist/components/NSCard.module.css +114 -114
  29. package/dist/components/NSCardScreenshot.module.css +41 -41
  30. package/dist/components/NSChartColumn.module.css +7 -7
  31. package/dist/components/NSChartTable.module.css +21 -21
  32. package/dist/components/NSColumn.module.css +16 -16
  33. package/dist/components/NSCopyBox.module.css +39 -39
  34. package/dist/components/NSDialog.module.css +112 -112
  35. package/dist/components/NSDialogPageSelection.module.css +103 -103
  36. package/dist/components/NSDownTimer.module.css +55 -55
  37. package/dist/components/NSDownload.module.css +46 -46
  38. package/dist/components/NSElectronicCard.module.css +60 -60
  39. package/dist/components/NSEntityCardBackground.module.css +27 -27
  40. package/dist/components/NSFilterBox.module.css +56 -56
  41. package/dist/components/NSFilterItem.module.css +24 -24
  42. package/dist/components/NSFooter.module.css +134 -134
  43. package/dist/components/NSHeader.module.css +291 -291
  44. package/dist/components/NSHeaderScreenshot.module.css +35 -35
  45. package/dist/components/NSID.js +2 -0
  46. package/dist/components/NSID.js.map +1 -1
  47. package/dist/components/NSLabel.module.css +25 -25
  48. package/dist/components/NSLabelErrorNotifier.module.css +2 -2
  49. package/dist/components/NSLayout.module.css +14 -14
  50. package/dist/components/NSLine.module.css +15 -15
  51. package/dist/components/NSLink.module.css +36 -36
  52. package/dist/components/NSListGrouped.module.css +69 -69
  53. package/dist/components/NSLoading.module.css +30 -30
  54. package/dist/components/NSMenuAction.js +2 -2
  55. package/dist/components/NSMenuAction.module.css +88 -88
  56. package/dist/components/NSMenuButton.module.css +44 -44
  57. package/dist/components/NSNoData.module.css +9 -9
  58. package/dist/components/NSPagination.module.css +85 -85
  59. package/dist/components/NSPanel.module.css +19 -19
  60. package/dist/components/NSPanelAccordion.module.css +4 -4
  61. package/dist/components/NSRange.module.css +66 -66
  62. package/dist/components/NSRow.module.css +17 -17
  63. package/dist/components/NSSection.module.css +4 -4
  64. package/dist/components/NSSectionCards.module.css +38 -38
  65. package/dist/components/NSSectionTiles.module.css +10 -10
  66. package/dist/components/NSTabPage.module.css +59 -59
  67. package/dist/components/NSTable.module.css +263 -263
  68. package/dist/components/NSTile.module.css +76 -76
  69. package/dist/components/NSTimelineMonthly.module.css +71 -71
  70. package/dist/components/NSTitle.module.css +15 -15
  71. package/dist/index.css +6 -0
  72. package/dist/pages/NSNotFoundPage.module.css +18 -18
  73. package/dist/pages/NSUpdating.module.css +35 -35
  74. package/package.json +80 -80
  75. package/public/index.html +38 -38
  76. package/src/App.css +33 -33
  77. package/src/App.tsx +131 -131
  78. package/src/Color.tsx +10 -10
  79. package/src/CopyToClipboard.ts +6 -6
  80. package/src/NSBoxBuilder.tsx +914 -914
  81. package/src/Validator.ts +163 -163
  82. package/src/components/INSBox.tsx +6 -6
  83. package/src/components/NSBanner.module.css +47 -47
  84. package/src/components/NSBanner.tsx +80 -80
  85. package/src/components/NSBarAction.module.css +84 -84
  86. package/src/components/NSBarAction.tsx +90 -90
  87. package/src/components/NSBarAlert.module.css +79 -79
  88. package/src/components/NSBarAlert.tsx +35 -35
  89. package/src/components/NSBarNotification.module.css +34 -34
  90. package/src/components/NSBarNotification.tsx +85 -85
  91. package/src/components/NSBarTitle.module.css +9 -9
  92. package/src/components/NSBarTitle.tsx +23 -23
  93. package/src/components/NSBox.module.css +50 -50
  94. package/src/components/NSBox.tsx +19 -19
  95. package/src/components/NSBoxBaseCombo.module.css +6 -6
  96. package/src/components/NSBoxBaseCombo.tsx +314 -314
  97. package/src/components/NSBoxBaseLayout.tsx +88 -88
  98. package/src/components/NSBoxBaseLayoutRecursive.tsx +54 -54
  99. package/src/components/NSBoxBoolean.module.css +67 -67
  100. package/src/components/NSBoxBoolean.tsx +119 -119
  101. package/src/components/NSBoxBooleans.tsx +161 -161
  102. package/src/components/NSBoxColor.tsx +95 -95
  103. package/src/components/NSBoxCombo.tsx +91 -91
  104. package/src/components/NSBoxDate.module.css +4 -4
  105. package/src/components/NSBoxDate.tsx +90 -90
  106. package/src/components/NSBoxDateTime.module.css +4 -4
  107. package/src/components/NSBoxDateTime.tsx +105 -105
  108. package/src/components/NSBoxDouble.tsx +94 -94
  109. package/src/components/NSBoxDuration.module.css +4 -4
  110. package/src/components/NSBoxDuration.tsx +95 -95
  111. package/src/components/NSBoxDynamic.tsx +67 -67
  112. package/src/components/NSBoxDynamics.tsx +68 -68
  113. package/src/components/NSBoxEmail.tsx +98 -98
  114. package/src/components/NSBoxEntity.tsx +101 -101
  115. package/src/components/NSBoxEnum.tsx +108 -108
  116. package/src/components/NSBoxFile.module.css +10 -10
  117. package/src/components/NSBoxFile.tsx +101 -101
  118. package/src/components/NSBoxFilePath.tsx +95 -95
  119. package/src/components/NSBoxFont.tsx +95 -95
  120. package/src/components/NSBoxIPV4.tsx +95 -95
  121. package/src/components/NSBoxIPV4Range.tsx +95 -95
  122. package/src/components/NSBoxIPV6.tsx +92 -92
  123. package/src/components/NSBoxIPV6Range.tsx +95 -95
  124. package/src/components/NSBoxInteger.tsx +91 -91
  125. package/src/components/NSBoxMoney.tsx +95 -95
  126. package/src/components/NSBoxPassword.tsx +106 -106
  127. package/src/components/NSBoxPhone.module.css +35 -35
  128. package/src/components/NSBoxPhone.tsx +107 -107
  129. package/src/components/NSBoxRadio.module.css +33 -33
  130. package/src/components/NSBoxRadio.tsx +91 -91
  131. package/src/components/NSBoxSchemaBase.module.css +17 -17
  132. package/src/components/NSBoxSchemaBase.tsx +540 -540
  133. package/src/components/NSBoxSchemaVariable.module.css +16 -16
  134. package/src/components/NSBoxSchemaVariable.tsx +250 -250
  135. package/src/components/NSBoxSearch.tsx +97 -97
  136. package/src/components/NSBoxString.tsx +91 -91
  137. package/src/components/NSBoxTextArea.module.css +12 -12
  138. package/src/components/NSBoxTextArea.tsx +98 -98
  139. package/src/components/NSBoxTime.module.css +4 -4
  140. package/src/components/NSBoxTime.tsx +93 -93
  141. package/src/components/NSBoxTimeZone.tsx +95 -95
  142. package/src/components/NSBoxURL.tsx +104 -104
  143. package/src/components/NSBoxVersion.tsx +95 -95
  144. package/src/components/NSButton.module.css +57 -57
  145. package/src/components/NSButton.tsx +25 -25
  146. package/src/components/NSButtonBlue.module.css +4 -4
  147. package/src/components/NSButtonBlue.tsx +19 -19
  148. package/src/components/NSButtonGreen.module.css +4 -4
  149. package/src/components/NSButtonGreen.tsx +19 -19
  150. package/src/components/NSButtonRed.module.css +4 -4
  151. package/src/components/NSButtonRed.tsx +19 -19
  152. package/src/components/NSCard.module.css +114 -114
  153. package/src/components/NSCard.tsx +63 -63
  154. package/src/components/NSCardScreenshot.module.css +41 -41
  155. package/src/components/NSCardScreenshot.tsx +31 -31
  156. package/src/components/NSChartColumn.module.css +7 -7
  157. package/src/components/NSChartColumn.tsx +106 -106
  158. package/src/components/NSChartDoughnut.tsx +112 -112
  159. package/src/components/NSChartPie.tsx +105 -105
  160. package/src/components/NSChartRange.tsx +14 -14
  161. package/src/components/NSChartTable.module.css +21 -21
  162. package/src/components/NSChartTable.tsx +94 -94
  163. package/src/components/NSColumn.module.css +16 -16
  164. package/src/components/NSColumn.tsx +24 -24
  165. package/src/components/NSCopy.tsx +58 -58
  166. package/src/components/NSCopyBox.module.css +39 -39
  167. package/src/components/NSCopyBox.tsx +53 -53
  168. package/src/components/NSDialog.module.css +112 -112
  169. package/src/components/NSDialog.tsx +61 -61
  170. package/src/components/NSDialogDelete.tsx +26 -26
  171. package/src/components/NSDialogInfo.tsx +32 -32
  172. package/src/components/NSDialogPageSelection.module.css +103 -103
  173. package/src/components/NSDialogPageSelection.tsx +227 -227
  174. package/src/components/NSDownTimer.module.css +55 -55
  175. package/src/components/NSDownTimer.tsx +91 -91
  176. package/src/components/NSDownload.module.css +46 -46
  177. package/src/components/NSDownload.tsx +66 -66
  178. package/src/components/NSElectronicCard.module.css +60 -60
  179. package/src/components/NSElectronicCard.tsx +46 -46
  180. package/src/components/NSEntityCardBackground.module.css +27 -27
  181. package/src/components/NSEntityCardBackground.tsx +36 -36
  182. package/src/components/NSFilterBox.module.css +56 -56
  183. package/src/components/NSFilterBox.tsx +506 -506
  184. package/src/components/NSFilterItem.module.css +24 -24
  185. package/src/components/NSFilterItem.tsx +27 -27
  186. package/src/components/NSFooter.module.css +134 -134
  187. package/src/components/NSFooter.tsx +321 -321
  188. package/src/components/NSHeader.module.css +291 -291
  189. package/src/components/NSHeader.tsx +261 -261
  190. package/src/components/NSHeaderScreenshot.module.css +35 -35
  191. package/src/components/NSHeaderScreenshot.tsx +39 -39
  192. package/src/components/NSID.tsx +133 -131
  193. package/src/components/NSLabel.module.css +25 -25
  194. package/src/components/NSLabel.tsx +46 -46
  195. package/src/components/NSLabelErrorNotifier.module.css +2 -2
  196. package/src/components/NSLabelErrorNotifier.tsx +35 -35
  197. package/src/components/NSLayout.module.css +14 -14
  198. package/src/components/NSLayout.tsx +126 -126
  199. package/src/components/NSLine.module.css +15 -15
  200. package/src/components/NSLine.tsx +13 -13
  201. package/src/components/NSLink.module.css +36 -36
  202. package/src/components/NSLink.tsx +25 -25
  203. package/src/components/NSLinkBlue.tsx +21 -21
  204. package/src/components/NSLinkGreen.tsx +12 -12
  205. package/src/components/NSLinkRed.tsx +12 -12
  206. package/src/components/NSListGrouped.module.css +69 -69
  207. package/src/components/NSListGrouped.tsx +106 -106
  208. package/src/components/NSListProduct.tsx +44 -44
  209. package/src/components/NSLoading.module.css +30 -30
  210. package/src/components/NSLoading.tsx +21 -21
  211. package/src/components/NSMenuAction.module.css +88 -88
  212. package/src/components/NSMenuAction.tsx +90 -90
  213. package/src/components/NSMenuButton.module.css +44 -44
  214. package/src/components/NSMenuButton.tsx +206 -206
  215. package/src/components/NSNoData.module.css +9 -9
  216. package/src/components/NSNoData.tsx +24 -24
  217. package/src/components/NSPagination.module.css +85 -85
  218. package/src/components/NSPagination.tsx +182 -182
  219. package/src/components/NSPanel.module.css +19 -19
  220. package/src/components/NSPanel.tsx +24 -24
  221. package/src/components/NSPanelAccordion.module.css +4 -4
  222. package/src/components/NSPanelAccordion.tsx +51 -51
  223. package/src/components/NSRange.module.css +66 -66
  224. package/src/components/NSRange.tsx +83 -83
  225. package/src/components/NSRepeater.tsx +256 -256
  226. package/src/components/NSRepeaterNSBoxSchemaVariable.tsx +90 -90
  227. package/src/components/NSRepeaterNSTag.tsx +81 -81
  228. package/src/components/NSRow.module.css +17 -17
  229. package/src/components/NSRow.tsx +24 -24
  230. package/src/components/NSSection.module.css +4 -4
  231. package/src/components/NSSection.tsx +26 -26
  232. package/src/components/NSSectionCards.module.css +38 -38
  233. package/src/components/NSSectionCards.tsx +51 -51
  234. package/src/components/NSSectionTiles.module.css +10 -10
  235. package/src/components/NSSectionTiles.tsx +25 -25
  236. package/src/components/NSSectionTitle.tsx +21 -21
  237. package/src/components/NSSpace.tsx +28 -28
  238. package/src/components/NSTabPage.module.css +59 -59
  239. package/src/components/NSTabPage.tsx +91 -91
  240. package/src/components/NSTable.module.css +263 -263
  241. package/src/components/NSTable.tsx +482 -482
  242. package/src/components/NSTag.tsx +74 -74
  243. package/src/components/NSTile.module.css +76 -76
  244. package/src/components/NSTile.tsx +27 -27
  245. package/src/components/NSTimelineMonthly.module.css +71 -71
  246. package/src/components/NSTimelineMonthly.tsx +44 -44
  247. package/src/components/NSTitle.module.css +15 -15
  248. package/src/components/NSTitle.tsx +19 -19
  249. package/src/formatter/BackColorFormatter.tsx +23 -23
  250. package/src/formatter/BaseColumnFormatter.ts +16 -16
  251. package/src/formatter/BaseURLImageFormatter.tsx +33 -33
  252. package/src/formatter/BooleanFormatter.ts +22 -22
  253. package/src/formatter/DateFormatter.ts +21 -21
  254. package/src/formatter/DateTimeFormatter.ts +21 -21
  255. package/src/formatter/DurationFormatter.ts +13 -13
  256. package/src/formatter/EmailFormatter.tsx +21 -21
  257. package/src/formatter/EnumFormatter.ts +13 -13
  258. package/src/formatter/FloatFormatter.ts +23 -23
  259. package/src/formatter/ForeColorFormatter.tsx +24 -24
  260. package/src/formatter/IDFormatter.tsx +30 -30
  261. package/src/formatter/IPFormatter.ts +13 -13
  262. package/src/formatter/IntegerFormatter.ts +23 -23
  263. package/src/formatter/JsonFormatter.ts +21 -21
  264. package/src/formatter/MoneyFormatter.ts +30 -30
  265. package/src/formatter/PhoneFormatter.tsx +21 -21
  266. package/src/formatter/StringFormatter.tsx +43 -43
  267. package/src/formatter/TimeFormatter.ts +21 -21
  268. package/src/formatter/URLFormatter.tsx +21 -21
  269. package/src/formatter/UnknowFormatter.ts +18 -18
  270. package/src/index.tsx +7 -7
  271. package/src/main.ts +222 -222
  272. package/src/pages/NSNotFoundPage.module.css +18 -18
  273. package/src/pages/NSNotFoundPage.tsx +11 -11
  274. package/src/pages/NSUpdating.module.css +35 -35
  275. package/src/pages/NSUpdating.tsx +32 -32
  276. package/src/props/IBackgroundPropps.ts +5 -5
  277. package/src/props/IBaseComponentProps.ts +8 -8
  278. package/src/props/IHeaderIconProps.ts +10 -10
  279. package/src/props/IHeaderProps.ts +7 -7
  280. package/src/props/IImageProps.ts +4 -4
  281. package/src/props/ILinkProps.ts +5 -5
  282. package/src/props/IValidationNumberProps.ts +4 -4
  283. package/src/props/IValidationPrecisionProps.ts +3 -3
  284. package/src/props/IValidationProps.ts +9 -9
  285. package/src/props/IValidationRegexProps.ts +4 -4
  286. package/src/props/IValidationStringProps.ts +4 -4
  287. package/src/routing/NSNotifier.ts +114 -114
  288. package/src/routing/NSRouterMaker.tsx +20 -20
  289. package/src/routing/NSRouterMakerComponent.ts +5 -5
  290. package/src/routing/NSRouterMakerProps.ts +5 -5
@@ -1,915 +1,915 @@
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 = NamirasoftMap.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
- title={this.title}
799
- createItem={(gIndex: number, lIndex: number, ref: React.RefObject<INSBox>, onChange: () => void, onDelete: undefined | ((index: number) => void)) =>
800
- {
801
- let title = "Item " + (lIndex + 1)
802
- let props = {
803
- ...this.props,
804
- title,
805
- onChanged: (box: NSBoxDynamic) =>
806
- {
807
- this.props.onChanged?.(box);
808
- onChange();
809
- },
810
- style: { ...this.props.style },
811
- variable: new BaseVariableSchema(title, schema.items[0]),
812
- multiple: false
813
- };
814
- let builder = new NSBoxBuilder(this.box, props, ref, "NSBoxBuilder_NSRepeater_Item_" + (gIndex + 1),
815
- onDelete ? () => { onDelete(gIndex) } : undefined
816
- );
817
- builder.depth = this.depth + 1;
818
- return builder.runSynch(callback);
819
- }}
820
- setValue={function (item: INSBox, _: number, value: string | null): void
821
- {
822
- if (value)
823
- item.setValue(value);
824
- }}
825
- getValue={function (item: INSBox, checkError: boolean): string
826
- {
827
- return item.getValue(checkError)
828
- }}
829
- isEmpty={function (item: INSBox, value: string | null): boolean
830
- {
831
- return item.isEmpty(value)
832
- }}
833
- required={schema.required}
834
- min={schema.min ?? undefined}
835
- max={schema.max ?? undefined}
836
- />
837
- </NSBoxBaseLayoutRecursive>
838
- );
839
- }
840
- protected override _toObject(schema: ObjectSchema, callback: (schema: BaseTypeSchema) => void)
841
- {
842
- let children: React.JSX.Element[] | null = this.ifOjbect((_, fields) =>
843
- {
844
- return fields.map((_, index) =>
845
- {
846
- return this.builders[index].builder.runSynch(callback);
847
- }).filter(x => x).map(x => x as React.JSX.Element);
848
- });
849
- if (!children)
850
- return null;
851
-
852
- let menu = safeMenuMenuItem(this.props, () => { });
853
-
854
- return (
855
- <NSBoxBaseLayoutRecursive
856
- id={this.props.id}
857
- {...this.props}
858
- required
859
- title={this.title + ((schema.name && schema.name !== this.title) ? ` (${schema.name})` : "")}
860
- depth={this.depth}
861
- menu={menu}
862
- >
863
- {children}
864
- </NSBoxBaseLayoutRecursive>
865
- );
866
- }
867
- protected override _toType(schema: TypeSchema)
868
- {
869
- if (this.multiple)
870
- return null;
871
- return (
872
- <NSBoxSchemaBase
873
- ref={this.box_ref as React.RefObject<any>}
874
- key={this.key}
875
- {...this.props}
876
-
877
- required={schema.required}
878
- valids={schema.valids}
879
- invalids={schema.invalids}
880
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
881
-
882
- title={this.title}
883
- placeholder={this.placeholder}
884
- defaultValue={undefined}
885
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
886
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
887
- menu={this.menu}
888
- />
889
- );
890
- }
891
- protected override _toVariable(schema: VariableSchema)
892
- {
893
- if (this.multiple)
894
- return null;
895
- return (
896
- <NSBoxSchemaVariable
897
- ref={this.box_ref as React.RefObject<any>}
898
- key={this.key}
899
- {...this.props}
900
-
901
- required={schema.required}
902
- valids={schema.valids}
903
- invalids={schema.invalids}
904
- // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
905
-
906
- title={this.title}
907
- placeholder={this.placeholder}
908
- defaultValue={undefined}
909
- onChanged={(_) => { this.props.onChanged?.(this.box); }}
910
- onClicked={(_) => { this.props.onClicked?.(this.box); }}
911
- menu={this.menu}
912
- />
913
- );
914
- }
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 = NamirasoftMap.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
+ title={this.title}
799
+ createItem={(gIndex: number, lIndex: number, ref: React.RefObject<INSBox>, onChange: () => void, onDelete: undefined | ((index: number) => void)) =>
800
+ {
801
+ let title = "Item " + (lIndex + 1)
802
+ let props = {
803
+ ...this.props,
804
+ title,
805
+ onChanged: (box: NSBoxDynamic) =>
806
+ {
807
+ this.props.onChanged?.(box);
808
+ onChange();
809
+ },
810
+ style: { ...this.props.style },
811
+ variable: new BaseVariableSchema(title, schema.items[0]),
812
+ multiple: false
813
+ };
814
+ let builder = new NSBoxBuilder(this.box, props, ref, "NSBoxBuilder_NSRepeater_Item_" + (gIndex + 1),
815
+ onDelete ? () => { onDelete(gIndex) } : undefined
816
+ );
817
+ builder.depth = this.depth + 1;
818
+ return builder.runSynch(callback);
819
+ }}
820
+ setValue={function (item: INSBox, _: number, value: string | null): void
821
+ {
822
+ if (value)
823
+ item.setValue(value);
824
+ }}
825
+ getValue={function (item: INSBox, checkError: boolean): string
826
+ {
827
+ return item.getValue(checkError)
828
+ }}
829
+ isEmpty={function (item: INSBox, value: string | null): boolean
830
+ {
831
+ return item.isEmpty(value)
832
+ }}
833
+ required={schema.required}
834
+ min={schema.min ?? undefined}
835
+ max={schema.max ?? undefined}
836
+ />
837
+ </NSBoxBaseLayoutRecursive>
838
+ );
839
+ }
840
+ protected override _toObject(schema: ObjectSchema, callback: (schema: BaseTypeSchema) => void)
841
+ {
842
+ let children: React.JSX.Element[] | null = this.ifOjbect((_, fields) =>
843
+ {
844
+ return fields.map((_, index) =>
845
+ {
846
+ return this.builders[index].builder.runSynch(callback);
847
+ }).filter(x => x).map(x => x as React.JSX.Element);
848
+ });
849
+ if (!children)
850
+ return null;
851
+
852
+ let menu = safeMenuMenuItem(this.props, () => { });
853
+
854
+ return (
855
+ <NSBoxBaseLayoutRecursive
856
+ id={this.props.id}
857
+ {...this.props}
858
+ required
859
+ title={this.title + ((schema.name && schema.name !== this.title) ? ` (${schema.name})` : "")}
860
+ depth={this.depth}
861
+ menu={menu}
862
+ >
863
+ {children}
864
+ </NSBoxBaseLayoutRecursive>
865
+ );
866
+ }
867
+ protected override _toType(schema: TypeSchema)
868
+ {
869
+ if (this.multiple)
870
+ return null;
871
+ return (
872
+ <NSBoxSchemaBase
873
+ ref={this.box_ref as React.RefObject<any>}
874
+ key={this.key}
875
+ {...this.props}
876
+
877
+ required={schema.required}
878
+ valids={schema.valids}
879
+ invalids={schema.invalids}
880
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
881
+
882
+ title={this.title}
883
+ placeholder={this.placeholder}
884
+ defaultValue={undefined}
885
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
886
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
887
+ menu={this.menu}
888
+ />
889
+ );
890
+ }
891
+ protected override _toVariable(schema: VariableSchema)
892
+ {
893
+ if (this.multiple)
894
+ return null;
895
+ return (
896
+ <NSBoxSchemaVariable
897
+ ref={this.box_ref as React.RefObject<any>}
898
+ key={this.key}
899
+ {...this.props}
900
+
901
+ required={schema.required}
902
+ valids={schema.valids}
903
+ invalids={schema.invalids}
904
+ // regex={schema.regex ? { name: variable.name, regex: schema.regex } : undefined}
905
+
906
+ title={this.title}
907
+ placeholder={this.placeholder}
908
+ defaultValue={undefined}
909
+ onChanged={(_) => { this.props.onChanged?.(this.box); }}
910
+ onClicked={(_) => { this.props.onClicked?.(this.box); }}
911
+ menu={this.menu}
912
+ />
913
+ );
914
+ }
915
915
  }