@headless-adminapp/fluent 0.0.17-alpha.7 → 1.0.0

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 (270) hide show
  1. package/App/App.d.ts +0 -1
  2. package/App/App.js +2 -4
  3. package/App/AppHeaderContianer.d.ts +5 -1
  4. package/App/AppHeaderContianer.js +43 -26
  5. package/App/AppLogo.js +15 -4
  6. package/App/AppUI.js +9 -1
  7. package/App/LayoutProvider.d.ts +7 -0
  8. package/App/LayoutProvider.js +17 -0
  9. package/App/NavigationContainer.d.ts +10 -1
  10. package/App/NavigationContainer.js +22 -22
  11. package/App/QuickActionItem.js +2 -2
  12. package/App/utils.js +3 -4
  13. package/CommandBar/Button.d.ts +2 -1
  14. package/CommandBar/Button.js +2 -2
  15. package/CommandBar/Divider.d.ts +2 -1
  16. package/CommandBar/Divider.js +2 -2
  17. package/CommandBar/IconButton.d.ts +2 -1
  18. package/CommandBar/IconButton.js +2 -2
  19. package/CommandBar/Label.d.ts +2 -1
  20. package/CommandBar/Label.js +2 -2
  21. package/CommandBar/MenuButton.d.ts +2 -1
  22. package/CommandBar/MenuButton.js +3 -3
  23. package/CommandBar/MenuItem.js +5 -4
  24. package/CommandBar/MenuItems.js +4 -4
  25. package/CommandBar/MenuList.js +5 -4
  26. package/CommandBar/Wrapper.d.ts +2 -2
  27. package/CommandBar/Wrapper.js +2 -2
  28. package/CommandBar/index.d.ts +6 -6
  29. package/DataGrid/ActionCell.d.ts +1 -1
  30. package/DataGrid/ActionCell.js +8 -4
  31. package/DataGrid/CustomizeColumns/AddColumns.js +35 -37
  32. package/DataGrid/CustomizeColumns/ColumnItem.js +8 -6
  33. package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
  34. package/DataGrid/CustomizeColumns/CustomizeColumns.js +3 -6
  35. package/DataGrid/FormSubgridViewSelector.js +1 -5
  36. package/DataGrid/GridColumnHeader/ConditionValueControl.js +19 -25
  37. package/DataGrid/GridColumnHeader/FilterForm.js +9 -10
  38. package/DataGrid/GridColumnHeader/OperatorSelect.js +10 -3
  39. package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +22 -13
  40. package/DataGrid/GridColumnHeader/utils.js +10 -7
  41. package/DataGrid/GridHeaderDesktop.js +4 -5
  42. package/DataGrid/GridHeaderMobile.d.ts +5 -0
  43. package/DataGrid/GridHeaderMobile.js +29 -0
  44. package/DataGrid/GridListContainer.d.ts +12 -0
  45. package/DataGrid/GridListContainer.js +93 -0
  46. package/DataGrid/GridPaginationContainer.js +1 -2
  47. package/DataGrid/GridTableContainer.js +113 -77
  48. package/DataGrid/TableCell/TableCellBase.d.ts +2 -2
  49. package/DataGrid/TableCell/TableCellBase.js +6 -1
  50. package/DataGrid/TableCell/TableCellCheckbox.js +6 -5
  51. package/DataGrid/TableCell/TableCellChoice.d.ts +15 -0
  52. package/DataGrid/TableCell/TableCellChoice.js +30 -0
  53. package/DataGrid/TableCell/TableCellLink.d.ts +2 -1
  54. package/DataGrid/TableCell/TableCellLink.js +13 -5
  55. package/DataGrid/TableCell/TableCellText.js +9 -4
  56. package/DataGrid/types.d.ts +5 -0
  57. package/DataGrid/types.js +2 -0
  58. package/DataGrid/useTableColumns.d.ts +2 -3
  59. package/DataGrid/useTableColumns.js +297 -155
  60. package/DialogContainer/AlertDialog.js +3 -6
  61. package/DialogContainer/ConfirmDialog.js +5 -9
  62. package/DialogContainer/DialogContainer.js +2 -13
  63. package/DialogContainer/ErrorDialog.js +3 -6
  64. package/DialogContainer/PromptDialog.d.ts +13 -2
  65. package/DialogContainer/PromptDialog.js +44 -39
  66. package/Insights/CommandBarContainer.d.ts +1 -0
  67. package/Insights/CommandBarContainer.js +18 -0
  68. package/Insights/FilterBarContainer.d.ts +1 -0
  69. package/Insights/FilterBarContainer.js +99 -0
  70. package/Insights/Grid.d.ts +6 -0
  71. package/Insights/Grid.js +26 -0
  72. package/Insights/InsightsContainer.d.ts +1 -0
  73. package/Insights/InsightsContainer.js +35 -0
  74. package/Insights/WidgetChartContainer.d.ts +7 -0
  75. package/Insights/WidgetChartContainer.js +56 -0
  76. package/Insights/WidgetDataGridContainer.d.ts +4 -0
  77. package/Insights/WidgetDataGridContainer.js +80 -0
  78. package/Insights/WidgetTableContainer.d.ts +7 -0
  79. package/Insights/WidgetTableContainer.js +57 -0
  80. package/Insights/WidgetTileContainer.d.ts +7 -0
  81. package/Insights/WidgetTileContainer.js +24 -0
  82. package/Insights/WidgetTitleBar.d.ts +7 -0
  83. package/Insights/WidgetTitleBar.js +21 -0
  84. package/Insights/Widgets.d.ts +4 -0
  85. package/Insights/Widgets.js +57 -0
  86. package/Insights/charts/AreaChart.d.ts +5 -0
  87. package/Insights/charts/AreaChart.js +20 -0
  88. package/Insights/charts/BarChart.d.ts +5 -0
  89. package/Insights/charts/BarChart.js +20 -0
  90. package/Insights/charts/ComposedChart.d.ts +5 -0
  91. package/Insights/charts/ComposedChart.js +19 -0
  92. package/Insights/charts/CustomTooltipContent.d.ts +7 -0
  93. package/Insights/charts/CustomTooltipContent.js +25 -0
  94. package/Insights/charts/GaugeChart.d.ts +5 -0
  95. package/Insights/charts/GaugeChart.js +8 -0
  96. package/Insights/charts/LineChart.d.ts +5 -0
  97. package/Insights/charts/LineChart.js +21 -0
  98. package/Insights/charts/OhlcChart.d.ts +6 -0
  99. package/Insights/charts/OhlcChart.js +119 -0
  100. package/Insights/charts/PieChart.d.ts +5 -0
  101. package/Insights/charts/PieChart.js +54 -0
  102. package/Insights/charts/RadarChart.d.ts +5 -0
  103. package/Insights/charts/RadarChart.js +38 -0
  104. package/Insights/charts/ScatterChart.d.ts +5 -0
  105. package/Insights/charts/ScatterChart.js +81 -0
  106. package/Insights/charts/constants.d.ts +1 -0
  107. package/Insights/charts/constants.js +25 -0
  108. package/Insights/charts/formatters.d.ts +14 -0
  109. package/Insights/charts/formatters.js +186 -0
  110. package/Insights/charts/index.d.ts +4 -0
  111. package/Insights/charts/index.js +13 -0
  112. package/Insights/charts/renderers.d.ts +10 -0
  113. package/Insights/charts/renderers.js +64 -0
  114. package/Insights/hooks/useQueriesData.d.ts +7 -0
  115. package/Insights/hooks/useQueriesData.js +90 -0
  116. package/Insights/hooks/useWidgetDetail.d.ts +10 -0
  117. package/Insights/hooks/useWidgetDetail.js +39 -0
  118. package/OverflowCommandBar/OverflowCommandBar.js +1 -4
  119. package/OverflowCommandBar/OverflowMenu.js +5 -17
  120. package/OverflowCommandBar/render.js +3 -4
  121. package/OverflowCommandBar/utils.js +2 -3
  122. package/PageBoard/BoardColumn.d.ts +5 -0
  123. package/PageBoard/BoardColumn.js +9 -0
  124. package/PageBoard/BoardColumnCard.d.ts +12 -0
  125. package/PageBoard/BoardColumnCard.js +29 -0
  126. package/PageBoard/BoardColumnUI.d.ts +2 -0
  127. package/PageBoard/BoardColumnUI.js +76 -0
  128. package/PageBoard/BoardingColumnCardLoading.d.ts +1 -0
  129. package/PageBoard/BoardingColumnCardLoading.js +21 -0
  130. package/PageBoard/Header.d.ts +7 -0
  131. package/PageBoard/Header.js +31 -0
  132. package/PageBoard/PageBoard.d.ts +7 -0
  133. package/PageBoard/PageBoard.js +46 -0
  134. package/PageBoard/index.d.ts +1 -0
  135. package/PageBoard/index.js +5 -0
  136. package/PageCalendar/CalendarSection.d.ts +20 -0
  137. package/PageCalendar/CalendarSection.js +108 -0
  138. package/PageCalendar/EventDialog/AttributeController.d.ts +10 -0
  139. package/PageCalendar/EventDialog/AttributeController.js +17 -0
  140. package/PageCalendar/EventDialog/EventDialog.d.ts +25 -0
  141. package/PageCalendar/EventDialog/EventDialog.js +21 -0
  142. package/PageCalendar/EventDialog/EventFormBody.d.ts +18 -0
  143. package/PageCalendar/EventDialog/EventFormBody.js +69 -0
  144. package/PageCalendar/EventDialog/EventFormContent.d.ts +10 -0
  145. package/PageCalendar/EventDialog/EventFormContent.js +27 -0
  146. package/PageCalendar/EventDialog/types.d.ts +3 -0
  147. package/PageCalendar/EventDialog/types.js +2 -0
  148. package/PageCalendar/EventDialog/utils.d.ts +23 -0
  149. package/PageCalendar/EventDialog/utils.js +57 -0
  150. package/PageCalendar/Header.d.ts +8 -0
  151. package/PageCalendar/Header.js +35 -0
  152. package/PageCalendar/PageCalendar.d.ts +7 -0
  153. package/PageCalendar/PageCalendar.js +231 -0
  154. package/PageCalendar/TitleSelector.d.ts +10 -0
  155. package/PageCalendar/TitleSelector.js +73 -0
  156. package/PageCalendar/ViewSelector.d.ts +8 -0
  157. package/PageCalendar/ViewSelector.js +52 -0
  158. package/PageCalendar/baseEventAttributes.d.ts +35 -0
  159. package/PageCalendar/baseEventAttributes.js +38 -0
  160. package/PageCalendar/context.d.ts +20 -0
  161. package/PageCalendar/context.js +5 -0
  162. package/PageCalendar/hooks/index.d.ts +1 -0
  163. package/PageCalendar/hooks/index.js +17 -0
  164. package/PageCalendar/hooks/useConfig.d.ts +3 -0
  165. package/PageCalendar/hooks/useConfig.js +8 -0
  166. package/PageCalendar/index.d.ts +1 -0
  167. package/PageCalendar/index.js +5 -0
  168. package/PageCalendar/renderEventContent.d.ts +2 -0
  169. package/PageCalendar/renderEventContent.js +22 -0
  170. package/PageCalendar/types.d.ts +5 -0
  171. package/PageCalendar/types.js +9 -0
  172. package/PageCalendar/utils.d.ts +3 -0
  173. package/PageCalendar/utils.js +17 -0
  174. package/PageEntityForm/CommandContainer.js +9 -5
  175. package/PageEntityForm/PageCustomEntityForm.d.ts +15 -0
  176. package/PageEntityForm/PageCustomEntityForm.js +17 -0
  177. package/PageEntityForm/PageEntityFormDesktopContainer.js +42 -22
  178. package/PageEntityForm/ProcessFlow.d.ts +10 -0
  179. package/PageEntityForm/ProcessFlow.js +84 -0
  180. package/PageEntityForm/RecordAvatar.d.ts +2 -0
  181. package/PageEntityForm/RecordAvatar.js +83 -0
  182. package/PageEntityForm/RecordCard.d.ts +1 -1
  183. package/PageEntityForm/RecordCard.js +60 -53
  184. package/PageEntityForm/RecordCardLoading.d.ts +8 -0
  185. package/PageEntityForm/RecordCardLoading.js +24 -0
  186. package/PageEntityForm/RecordSetNavigatorContainer.js +1 -2
  187. package/PageEntityForm/RelatedViewSelector.d.ts +0 -2
  188. package/PageEntityForm/RelatedViewSelector.js +37 -11
  189. package/PageEntityForm/SectionContainer.d.ts +2 -2
  190. package/PageEntityForm/SectionContainer.js +77 -13
  191. package/PageEntityForm/StandardControl.d.ts +1 -22
  192. package/PageEntityForm/StandardControl.js +103 -117
  193. package/PageEntityForm/SubgridControl.d.ts +1 -0
  194. package/PageEntityForm/SubgridControl.js +4 -2
  195. package/PageEntityForm/UploadImageDialog.d.ts +12 -0
  196. package/PageEntityForm/UploadImageDialog.js +114 -0
  197. package/PageEntityView/FormSubgridContainer.js +5 -2
  198. package/PageEntityView/FormSubgridNotAvailableContainer.d.ts +2 -0
  199. package/PageEntityView/FormSubgridNotAvailableContainer.js +48 -0
  200. package/PageEntityView/PageEntityView.js +4 -1
  201. package/PageEntityView/PageEntityViewDesktopFrame.js +1 -0
  202. package/PageEntityView/PageEntityViewMobileContainer.d.ts +2 -0
  203. package/PageEntityView/PageEntityViewMobileContainer.js +14 -0
  204. package/PageEntityView/PageEntityViewStringContext.d.ts +2 -0
  205. package/PageEntityView/PageEntityViewStringContext.js +2 -0
  206. package/PageInsights/PageInsights.d.ts +9 -0
  207. package/PageInsights/PageInsights.js +25 -0
  208. package/PageInsights/index.d.ts +1 -0
  209. package/PageInsights/index.js +6 -0
  210. package/ToastNotificationContainer/index.js +1 -2
  211. package/componentStore.d.ts +2 -0
  212. package/componentStore.js +5 -0
  213. package/components/BodyLoading.d.ts +1 -1
  214. package/components/BodyLoading.js +13 -8
  215. package/components/DndProvider.d.ts +12 -0
  216. package/components/DndProvider.js +68 -0
  217. package/components/LoginForm.js +5 -21
  218. package/form/FormControl.js +19 -41
  219. package/form/controls/AttachmentControl.d.ts +27 -0
  220. package/form/controls/AttachmentControl.js +220 -0
  221. package/form/controls/AttachmentsControl.d.ts +6 -0
  222. package/form/controls/AttachmentsControl.js +35 -0
  223. package/form/controls/CurrencyControl.js +38 -6
  224. package/form/controls/DateControl.d.ts +1 -1
  225. package/form/controls/DateControl.js +15 -3
  226. package/form/controls/DateRangeControl.js +4 -6
  227. package/form/controls/DateTimeControl.d.ts +1 -1
  228. package/form/controls/DateTimeControl.js +107 -12
  229. package/form/controls/DecimalControl.d.ts +5 -0
  230. package/form/controls/DecimalControl.js +52 -0
  231. package/form/controls/DurationControl.d.ts +4 -0
  232. package/form/controls/DurationControl.js +209 -0
  233. package/form/controls/EmailControl.d.ts +1 -1
  234. package/form/controls/EmailControl.js +5 -5
  235. package/form/controls/IntegerControl.d.ts +4 -0
  236. package/form/controls/IntegerControl.js +25 -0
  237. package/form/controls/LookupControl.d.ts +1 -0
  238. package/form/controls/LookupControl.js +57 -13
  239. package/form/controls/MultiSelectControl.js +3 -3
  240. package/form/controls/MultiSelectLookupControl.js +16 -17
  241. package/form/controls/PasswordControl.js +1 -1
  242. package/form/controls/RichTextControl.d.ts +5 -0
  243. package/form/controls/RichTextControl.js +33 -0
  244. package/form/controls/SelectControl.js +4 -5
  245. package/form/controls/SwitchControl.d.ts +1 -1
  246. package/form/controls/SwitchControl.js +4 -2
  247. package/form/controls/TelephoneControl.d.ts +1 -1
  248. package/form/controls/TelephoneControl.js +26 -4
  249. package/form/controls/TextAreaControl.d.ts +1 -1
  250. package/form/controls/TextAreaControl.js +6 -6
  251. package/form/controls/TextControl.js +4 -4
  252. package/form/controls/UrlControl.d.ts +4 -0
  253. package/form/controls/UrlControl.js +16 -0
  254. package/form/controls/useLookupData.js +26 -41
  255. package/form/layout/FormSection/FormSection.js +10 -3
  256. package/form/layout/FormTab/FormTab.js +4 -4
  257. package/form/types.d.ts +2 -2
  258. package/package.json +17 -12
  259. package/styles.css +149 -0
  260. package/types/index.d.ts +18 -0
  261. package/utils/avatar.d.ts +2 -0
  262. package/utils/avatar.js +45 -0
  263. package/App/AppProvider.d.ts +0 -9
  264. package/App/AppProvider.js +0 -50
  265. package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
  266. package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
  267. package/DataGrid/getAttributeFormattedValue.d.ts +0 -16
  268. package/DataGrid/getAttributeFormattedValue.js +0 -92
  269. package/form/controls/NumberControl.d.ts +0 -4
  270. package/form/controls/NumberControl.js +0 -16
@@ -25,7 +25,6 @@ const useStyles = (0, react_components_1.makeStyles)({
25
25
  },
26
26
  });
27
27
  const RecordSetNavigatorContainer = () => {
28
- var _a, _b;
29
28
  const { data, cardView, schema } = (0, hooks_2.useRecordSetResult)();
30
29
  const [visible] = (0, hooks_2.useRecordSetVisibility)();
31
30
  const recordId = (0, hooks_1.useRecordId)();
@@ -55,7 +54,7 @@ const RecordSetNavigatorContainer = () => {
55
54
  flexDirection: 'column',
56
55
  paddingInline: 16,
57
56
  paddingBlock: 8,
58
- }, children: (0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: (_b = (_a = schema.localizedPluralLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : schema === null || schema === void 0 ? void 0 : schema.pluralLabel }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { vertical: false, style: { opacity: 0.2 } }) }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(ScrollView_1.ScrollView, { autoHide: true, rtl: direction === 'rtl', children: data === null || data === void 0 ? void 0 : data.map((record) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { role: "button", className: (0, react_components_1.mergeClasses)(styles.item, recordId ===
57
+ }, children: (0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: schema.localizedPluralLabels?.[language] ?? schema?.pluralLabel }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { vertical: false, style: { opacity: 0.2 } }) }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(ScrollView_1.ScrollView, { autoHide: true, rtl: direction === 'rtl', children: data?.map((record) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { role: "button", className: (0, react_components_1.mergeClasses)(styles.item, recordId ===
59
58
  record[schema.idAttribute] &&
60
59
  styles.selected), onClick: () => {
61
60
  openForm({
@@ -2,8 +2,6 @@ import { Localized } from '@headless-adminapp/core/types';
2
2
  export interface RelatedItemInfo {
3
3
  key: string;
4
4
  logicalName: string;
5
- label: string;
6
- localizedLabels?: Localized<string>;
7
5
  pluralLabel: string;
8
6
  localizedPluralLabels?: Localized<string>;
9
7
  attributeName: string;
@@ -10,7 +10,35 @@ const utils_1 = require("@headless-adminapp/core/attributes/utils");
10
10
  const icons_1 = require("@headless-adminapp/icons");
11
11
  const react_1 = require("react");
12
12
  const PageEntityFormStringContext_1 = require("./PageEntityFormStringContext");
13
- function getRelatedItems(currentSchema, schemas) {
13
+ function getRelatedItems(currentSchema, schemas, relatedItems) {
14
+ if (relatedItems === null) {
15
+ return [];
16
+ }
17
+ if (relatedItems) {
18
+ return relatedItems.map((item) => {
19
+ const schema = schemas[item.logicalName];
20
+ if (!schema) {
21
+ throw new Error(`Schema not found: ${item.logicalName}`);
22
+ }
23
+ if (!schema.attributes[item.attributeName]) {
24
+ throw new Error(`Attribute not found: ${item.logicalName}.${item.attributeName}`);
25
+ }
26
+ const attribute = schema.attributes[item.attributeName];
27
+ if (!(0, utils_1.isLookupAttribute)(attribute)) {
28
+ throw new Error(`Attribute is not a lookup: ${item.logicalName}.${item.attributeName}`);
29
+ }
30
+ if (attribute.entity !== currentSchema.logicalName) {
31
+ throw new Error(`Attribute entity does not match: ${item.logicalName}.${item.attributeName}`);
32
+ }
33
+ return {
34
+ key: `${schema.logicalName}.${item.attributeName}`,
35
+ logicalName: schema.logicalName,
36
+ attributeName: item.attributeName,
37
+ pluralLabel: item.pluralLabel ?? schema.pluralLabel,
38
+ localizedPluralLabels: item.localizedPluralLabels ?? schema.localizedPluralLabels,
39
+ };
40
+ });
41
+ }
14
42
  return Object.values(schemas)
15
43
  .map((s) => {
16
44
  return Object.entries(s.attributes)
@@ -34,11 +62,9 @@ function getRelatedItems(currentSchema, schemas) {
34
62
  return {
35
63
  key: `${s.logicalName}.${item.key}`,
36
64
  logicalName: s.logicalName,
37
- label: s.label,
38
- localizedLabels: s.localizedLabels,
39
- pluralLabel: s.pluralLabel,
40
- localizedPluralLabels: s.localizedPluralLabels,
41
65
  attributeName: item.key,
66
+ pluralLabel: item.attribute.relatedLabel ?? s.pluralLabel,
67
+ localizedPluralLabels: item.attribute.localizedRelatedLabel ?? s.localizedPluralLabels,
42
68
  };
43
69
  });
44
70
  })
@@ -46,11 +72,13 @@ function getRelatedItems(currentSchema, schemas) {
46
72
  }
47
73
  function RelatedViewSelector(props) {
48
74
  const schema = (0, hooks_1.useDataFormSchema)();
75
+ const recordId = (0, hooks_1.useRecordId)();
76
+ const formConfig = (0, hooks_1.useSelectedForm)();
49
77
  const { schemas } = (0, hooks_2.useMetadata)();
50
78
  const strings = (0, PageEntityFormStringContext_1.usePageEntityFormStrings)();
51
79
  const { language } = (0, locale_1.useLocale)();
52
- const data = (0, react_1.useMemo)(() => getRelatedItems(schema, schemas), [schema, schemas]);
53
- if (!data.length) {
80
+ const data = (0, react_1.useMemo)(() => getRelatedItems(schema, schemas, formConfig.experience.relatedItems), [formConfig.experience.relatedItems, schema, schemas]);
81
+ if (!data.length || !recordId) {
54
82
  return null;
55
83
  }
56
84
  return ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: (0, jsx_runtime_1.jsxs)("button", { style: {
@@ -70,8 +98,6 @@ function RelatedViewSelector(props) {
70
98
  outlineStyle: 'none',
71
99
  textTransform: 'none',
72
100
  columnGap: react_components_1.tokens.spacingHorizontalSNudge,
73
- }, children: [strings.related, (0, jsx_runtime_1.jsx)(icons_1.Icons.ChevronDown, { size: 16 })] }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: data.map((item) => {
74
- var _a, _b;
75
- return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => props.onSelect(item), children: (_b = (_a = item.localizedPluralLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : item.pluralLabel }, item.key));
76
- }) }) })] }));
101
+ color: react_components_1.tokens.colorNeutralForeground2,
102
+ }, children: [strings.related, (0, jsx_runtime_1.jsx)(icons_1.Icons.ChevronDown, { size: 16 })] }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: data.map((item) => ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => props.onSelect(item), children: item.localizedPluralLabels?.[language] ?? item.pluralLabel }, item.key))) }) })] }));
77
103
  }
@@ -1,6 +1,6 @@
1
1
  import { Section } from '@headless-adminapp/core/experience/form';
2
- import { SchemaAttributes } from '@headless-adminapp/core/schema';
2
+ import type { SchemaAttributes } from '@headless-adminapp/core/schema';
3
3
  export declare function SectionContainer<S extends SchemaAttributes = SchemaAttributes>({ section }: {
4
4
  section: Section<S>;
5
5
  readOnly: boolean;
6
- }): import("react/jsx-runtime").JSX.Element;
6
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -2,10 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SectionContainer = SectionContainer;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const builders_1 = require("@headless-adminapp/app/builders");
5
+ const dataform_1 = require("@headless-adminapp/app/dataform");
6
+ const constants_1 = require("@headless-adminapp/app/dataform/constants");
7
+ const utils_1 = require("@headless-adminapp/app/dataform/DataFormProvider/utils");
6
8
  const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
9
+ const useEventManager_1 = require("@headless-adminapp/app/dataform/hooks/useEventManager");
7
10
  const locale_1 = require("@headless-adminapp/app/locale");
11
+ const utils_2 = require("@headless-adminapp/app/locale/utils");
12
+ const mutable_1 = require("@headless-adminapp/app/mutable");
13
+ const react_1 = require("react");
8
14
  const react_hook_form_1 = require("react-hook-form");
15
+ const componentStore_1 = require("../componentStore");
9
16
  const SectionControl_1 = require("../DataForm/SectionControl");
10
17
  const layout_1 = require("../form/layout");
11
18
  const StandardControl_1 = require("./StandardControl");
@@ -14,46 +21,103 @@ function SectionContainer({ section }) {
14
21
  const schema = (0, hooks_1.useDataFormSchema)();
15
22
  const formInstance = (0, hooks_1.useFormInstance)();
16
23
  const recordId = (0, hooks_1.useRecordId)();
17
- const readonly = (0, hooks_1.useFormIsReadonly)();
24
+ const isFormReadonly = (0, hooks_1.useFormIsReadonly)();
18
25
  const { language } = (0, locale_1.useLocale)();
19
- return ((0, jsx_runtime_1.jsx)(layout_1.FormSection, { title: (0, builders_1.localizedLabel)(language, section), columnCount: section.columnCount, labelPosition: section.labelPosition, noPadding: section.noPadding, hideLabel: section.hideLabel, children: section.controls.map((control, index) => {
20
- var _a;
26
+ const eventManager = (0, useEventManager_1.useEventManager)();
27
+ const disabledControls = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.disabledControls);
28
+ const hiddenControls = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.hiddenControls);
29
+ const requiredFields = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.requiredFields);
30
+ const hiddenSections = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.hiddenSections);
31
+ const visibleControls = (0, react_1.useMemo)(() => section.controls.filter((control) => {
32
+ return !(0, utils_1.getIsControlHidden)({
33
+ control,
34
+ hiddenControls,
35
+ });
36
+ }), [section.controls, hiddenControls]);
37
+ if (hiddenSections[section.name] || visibleControls.length === 0) {
38
+ return null;
39
+ }
40
+ return ((0, jsx_runtime_1.jsx)(layout_1.FormSection, { title: (0, utils_2.localizedLabel)(language, section), columnCount: section.columnCount, labelPosition: section.labelPosition, noPadding: section.noPadding, hideLabel: section.hideLabel, children: visibleControls.map((control, index) => {
21
41
  switch (control.type) {
22
- case 'standard':
42
+ case 'standard': {
23
43
  const attribute = schema.attributes[control.attributeName];
44
+ let Control = StandardControl_1.StandardControl;
45
+ if (control.component) {
46
+ if (typeof control.component === 'function') {
47
+ Control = control.component;
48
+ }
49
+ else if (typeof control.component === 'string') {
50
+ const OverrideControl = componentStore_1.componentStore.getComponent(control.component);
51
+ if (OverrideControl) {
52
+ Control = OverrideControl;
53
+ }
54
+ }
55
+ }
56
+ const disabled = (0, utils_1.getIsFieldDisabled)({
57
+ isFormReadonly,
58
+ disabledFields: disabledControls,
59
+ attribute,
60
+ control,
61
+ });
62
+ const required = (0, utils_1.getIsFieldRequired)({
63
+ attribute,
64
+ requiredFields,
65
+ control,
66
+ });
24
67
  return ((0, jsx_runtime_1.jsx)("div", { style: {
25
68
  gridColumn: control.span
26
69
  ? `var(--section-item-span-${control.span})`
27
70
  : undefined,
28
71
  }, children: (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: formInstance.control, name: control.attributeName, render: ({ field, fieldState, formState }) => {
29
- var _a, _b, _c, _d, _e, _f, _g;
30
72
  const isError = (fieldState.isTouched || formState.isSubmitted) &&
31
- !!((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message);
73
+ !!fieldState.error?.message;
32
74
  const errorMessage = fieldState.isTouched || formState.isSubmitted
33
- ? (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message
75
+ ? fieldState.error?.message
34
76
  : '';
35
- const label = (_g = (_f = (_d = (_c = control.localizedLabels) === null || _c === void 0 ? void 0 : _c[language]) !== null && _d !== void 0 ? _d : (_e = attribute.localizedLabels) === null || _e === void 0 ? void 0 : _e[language]) !== null && _f !== void 0 ? _f : control.label) !== null && _g !== void 0 ? _g : attribute.label;
36
- return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelPosition: section.labelPosition, required: attribute.required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(StandardControl_1.StandardControl, { attribute: attribute, name: control.attributeName, value: field.value, onChange: field.onChange, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError, disabled: readonly, label: label, placeholder: label, allowNavigation: true, allowNewRecord: true }) }));
77
+ const label = control.localizedLabels?.[language] ??
78
+ attribute.localizedLabels?.[language] ??
79
+ control.label ??
80
+ attribute.label;
81
+ return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelPosition: section.labelPosition, required: required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(Control, { attribute: attribute, name: control.attributeName, value: field.value, onChange: (value) => {
82
+ field.onChange(value);
83
+ eventManager.emit(constants_1.EVENT_KEY_ON_FIELD_CHANGE, control.attributeName, value);
84
+ }, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError, readOnly: disabled, label: label, placeholder: label, allowNavigation: true, allowNewRecord: true, fileServiceContext: {
85
+ type: 'entity-form',
86
+ recordId,
87
+ attributeName: control.attributeName,
88
+ logicalName: schema.logicalName,
89
+ } }) }));
37
90
  } }, control.attributeName) }, control.attributeName));
91
+ }
38
92
  case 'editablegrid': {
39
93
  return null;
40
94
  }
41
95
  case 'quickview':
42
96
  return null;
43
- case 'subgrid':
44
- return ((0, jsx_runtime_1.jsx)(SubgridControl_1.SubgridControl, { logicalName: control.logicalName, allowViewSelection: control.allowViewSelection, viewId: control.viewId, availableViewIds: control.availableViewIds, associated: !control.associatedAttribute
97
+ case 'subgrid': {
98
+ let ContainerComponent = null;
99
+ if (control.component) {
100
+ if (typeof control.component === 'function') {
101
+ ContainerComponent = control.component;
102
+ }
103
+ else if (typeof control.component === 'string') {
104
+ ContainerComponent = componentStore_1.componentStore.getComponent(control.component);
105
+ }
106
+ }
107
+ return ((0, jsx_runtime_1.jsx)(SubgridControl_1.SubgridControl, { logicalName: control.logicalName, allowViewSelection: control.allowViewSelection, viewId: control.viewId, availableViewIds: control.availableViewIds, ContainerComponent: ContainerComponent, associated: !control.associatedAttribute
45
108
  ? false
46
109
  : {
47
110
  logicalName: schema.logicalName,
48
111
  id: recordId,
49
112
  refAttributeName: control.associatedAttribute,
50
113
  } }, index));
114
+ }
51
115
  case 'spacer':
52
116
  return ((0, jsx_runtime_1.jsx)("div", { style: {
53
117
  gridColumn: control.span
54
118
  ? `var(--section-item-span-${control.span})`
55
119
  : undefined,
56
- display: `var(--section-item-spacer-${(_a = control.span) !== null && _a !== void 0 ? _a : 1})`,
120
+ display: `var(--section-item-spacer-${control.span ?? 1})`,
57
121
  } }, index));
58
122
  default:
59
123
  return null;
@@ -1,24 +1,3 @@
1
- import type { Attribute } from '@headless-adminapp/core/attributes';
1
+ import type { StandardControlProps } from '@headless-adminapp/core/experience/form/SectionControl';
2
2
  import { FC } from 'react';
3
- interface StandardControlProps {
4
- attribute: Attribute;
5
- label?: string;
6
- isError: boolean;
7
- errorMessage: string | undefined;
8
- name: string;
9
- value: any;
10
- placeholder?: string;
11
- onChange: (value: any) => void;
12
- onBlur: () => void;
13
- disabled?: boolean;
14
- borderOnFocusOnly?: boolean;
15
- hideLabel?: boolean;
16
- hidePlaceholder?: boolean;
17
- allowQuickCreate?: boolean;
18
- readOnly?: boolean;
19
- quickViewControl?: boolean;
20
- allowNavigation?: boolean;
21
- allowNewRecord?: boolean;
22
- }
23
3
  export declare const StandardControl: FC<StandardControlProps>;
24
- export {};
@@ -8,42 +8,53 @@ const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const hooks_1 = require("@headless-adminapp/app/metadata/hooks");
9
9
  const transport_1 = require("@headless-adminapp/app/transport");
10
10
  const react_1 = require("react");
11
+ const componentStore_1 = require("../componentStore");
12
+ const AttachmentControl_1 = require("../form/controls/AttachmentControl");
13
+ const AttachmentsControl_1 = require("../form/controls/AttachmentsControl");
11
14
  const CurrencyControl_1 = require("../form/controls/CurrencyControl");
12
15
  const DateControl_1 = require("../form/controls/DateControl");
13
16
  const DateRangeControl_1 = require("../form/controls/DateRangeControl");
14
17
  const DateTimeControl_1 = require("../form/controls/DateTimeControl");
18
+ const DecimalControl_1 = require("../form/controls/DecimalControl");
19
+ const DurationControl_1 = require("../form/controls/DurationControl");
15
20
  const EmailControl_1 = require("../form/controls/EmailControl");
21
+ const IntegerControl_1 = require("../form/controls/IntegerControl");
16
22
  const LookupControl_1 = require("../form/controls/LookupControl");
17
23
  const MultiSelectControl_1 = __importDefault(require("../form/controls/MultiSelectControl"));
18
24
  const MultiSelectLookupControl_1 = require("../form/controls/MultiSelectLookupControl");
19
- const NumberControl_1 = require("../form/controls/NumberControl");
25
+ const RichTextControl_1 = require("../form/controls/RichTextControl");
20
26
  const SelectControl_1 = __importDefault(require("../form/controls/SelectControl"));
21
27
  const SwitchControl_1 = require("../form/controls/SwitchControl");
22
28
  const TelephoneControl_1 = require("../form/controls/TelephoneControl");
23
29
  const TextAreaControl_1 = require("../form/controls/TextAreaControl");
24
30
  const TextControl_1 = require("../form/controls/TextControl");
25
- const StandardControl = ({ attribute, label: _label, isError,
26
- // errorMessage,
27
- name, value, onBlur, onChange,
28
- // dataService,
29
- // fileService,
30
- disabled, borderOnFocusOnly, placeholder: _placeholder,
31
- // hideLabel,
32
- hidePlaceholder, readOnly,
33
- // quickViewControl,
34
- allowNavigation, allowNewRecord, }) => {
35
- var _a;
36
- const isDisabled = attribute.readonly || disabled;
31
+ const UrlControl_1 = require("../form/controls/UrlControl");
32
+ // Standard Control (Base control)
33
+ // TextControl
34
+ // TextInput
35
+ const StandardControl = (props) => {
36
+ const { attribute, label: _label, isError,
37
+ // errorMessage,
38
+ name, value, onBlur, onChange,
39
+ // dataService,
40
+ // fileService,
41
+ borderOnFocusOnly, placeholder: _placeholder,
42
+ // hideLabel,
43
+ hidePlaceholder, readOnly,
44
+ // quickViewControl,
45
+ allowNavigation, allowNewRecord, } = props;
46
+ const isDisabled = readOnly;
37
47
  // const label = hideLabel ? undefined : _label ?? attribute.label;
38
48
  const placeholder = hidePlaceholder
39
49
  ? undefined
40
- : (_a = _placeholder !== null && _placeholder !== void 0 ? _placeholder : _label) !== null && _a !== void 0 ? _a : attribute.label;
50
+ : _placeholder ?? _label ?? attribute.label;
41
51
  // const required = quickViewControl ? false : attribute.required;
42
52
  const dataService = (0, transport_1.useDataService)();
53
+ const fileService = (0, transport_1.useFileService)();
43
54
  const { schemaStore, experienceStore } = (0, hooks_1.useMetadata)();
44
55
  // const { openQuickCreate } = useQuickCreateForm();
45
56
  switch (attribute.type) {
46
- case 'string':
57
+ case 'string': {
47
58
  const controlProps = {
48
59
  name,
49
60
  placeholder,
@@ -51,25 +62,58 @@ allowNavigation, allowNewRecord, }) => {
51
62
  onChange,
52
63
  onBlur,
53
64
  error: isError,
54
- disabled: isDisabled,
65
+ disabled: readOnly,
55
66
  readOnly,
56
67
  };
57
68
  switch (attribute.format) {
58
- case 'text':
59
- return ((0, jsx_runtime_1.jsx)(TextControl_1.TextControl, Object.assign({}, controlProps, { textTransform: attribute.textTransform })));
60
- case 'email':
61
- return (0, jsx_runtime_1.jsx)(EmailControl_1.EmailControl, Object.assign({}, controlProps));
62
- case 'phone':
63
- return (0, jsx_runtime_1.jsx)(TelephoneControl_1.TelephoneControl, Object.assign({}, controlProps));
64
- case 'url':
65
- return (0, jsx_runtime_1.jsx)(TextControl_1.TextControl, Object.assign({}, controlProps));
66
- case 'textarea':
67
- return (0, jsx_runtime_1.jsx)(TextAreaControl_1.TextAreaControl, Object.assign({}, controlProps));
69
+ case 'text': {
70
+ const Control = componentStore_1.componentStore.getComponent('Form.TextControl') ?? TextControl_1.TextControl;
71
+ return ((0, jsx_runtime_1.jsx)(Control, { ...controlProps, textTransform: attribute.textTransform }));
72
+ }
73
+ case 'email': {
74
+ const Control = componentStore_1.componentStore.getComponent('Form.EmailControl') ?? EmailControl_1.EmailControl;
75
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
76
+ }
77
+ case 'phone': {
78
+ const Control = componentStore_1.componentStore.getComponent('Form.TelephoneControl') ?? TelephoneControl_1.TelephoneControl;
79
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
80
+ }
81
+ case 'url': {
82
+ const Control = componentStore_1.componentStore.getComponent('Form.UrlControl') ??
83
+ UrlControl_1.UrlControl;
84
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
85
+ }
86
+ case 'textarea': {
87
+ const Control = componentStore_1.componentStore.getComponent('Form.TextAreaControl') ?? TextAreaControl_1.TextAreaControl;
88
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
89
+ }
90
+ case 'richtext': {
91
+ const Control = componentStore_1.componentStore.getComponent('Form.RichTextControl') ?? RichTextControl_1.RichTextControl;
92
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
93
+ }
68
94
  default:
69
95
  return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
70
96
  }
71
- case 'number':
72
- return ((0, jsx_runtime_1.jsx)(NumberControl_1.NumberControl, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly }));
97
+ }
98
+ case 'number': {
99
+ switch (attribute.format) {
100
+ case 'decimal': {
101
+ const Control = componentStore_1.componentStore.getComponent('Form.DecimalControl') ?? DecimalControl_1.DecimalControl;
102
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly, decimalPlaces: attribute.decimalPlaces }));
103
+ }
104
+ case 'integer': {
105
+ const Control = componentStore_1.componentStore.getComponent('Form.IntegerControl') ?? IntegerControl_1.IntegerControl;
106
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly }));
107
+ }
108
+ case 'duration': {
109
+ const Control = componentStore_1.componentStore.getComponent('Form.DurationControl') ?? DurationControl_1.DurationControl;
110
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly }));
111
+ }
112
+ default: {
113
+ return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
114
+ }
115
+ }
116
+ }
73
117
  case 'date': {
74
118
  const controlProps = {
75
119
  name,
@@ -82,10 +126,13 @@ allowNavigation, allowNewRecord, }) => {
82
126
  readOnly,
83
127
  };
84
128
  if (attribute.format === 'datetime') {
85
- return (0, jsx_runtime_1.jsx)(DateTimeControl_1.DateTimeControl, Object.assign({}, controlProps));
129
+ const Control = componentStore_1.componentStore.getComponent('Form.DateTimeControl') ?? DateTimeControl_1.DateTimeControl;
130
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
86
131
  }
87
132
  else {
88
- return (0, jsx_runtime_1.jsx)(DateControl_1.DateControl, Object.assign({}, controlProps));
133
+ const Control = componentStore_1.componentStore.getComponent('Form.DateControl') ??
134
+ DateControl_1.DateControl;
135
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
89
136
  }
90
137
  }
91
138
  case 'daterange': {
@@ -99,105 +146,40 @@ allowNavigation, allowNewRecord, }) => {
99
146
  disabled: isDisabled,
100
147
  readOnly,
101
148
  };
102
- return (0, jsx_runtime_1.jsx)(DateRangeControl_1.DateRangeControl, Object.assign({}, controlProps));
149
+ const Control = componentStore_1.componentStore.getComponent('Form.DateRangeControl') ?? DateRangeControl_1.DateRangeControl;
150
+ return (0, jsx_runtime_1.jsx)(Control, { ...controlProps });
103
151
  }
104
152
  case 'money': {
105
- return ((0, jsx_runtime_1.jsx)(CurrencyControl_1.CurrencyControl, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
153
+ const Control = componentStore_1.componentStore.getComponent('Form.CurrencyControl') ?? CurrencyControl_1.CurrencyControl;
154
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
106
155
  }
107
156
  case 'lookup': {
108
- // const experienceSchema = getExperienceSchema(attribute.entity);
109
- // const routes = getExperienceRoutes(attribute.entity);
110
- // const path = routes?.create?.();
111
- // let createButtonProps:
112
- // | {
113
- // label: string;
114
- // onClick: () => void;
115
- // }
116
- // | undefined;
117
- // if (allowQuickCreate && experienceSchema.defaultQuickCreateForm) {
118
- // createButtonProps = {
119
- // label: 'New record',
120
- // onClick: async () => {
121
- // try {
122
- // const result = await openQuickCreate({
123
- // logicalName: attribute.entity,
124
- // });
125
- // if (result) {
126
- // onChange(result);
127
- // }
128
- // } catch (error) {
129
- // console.error(error);
130
- // }
131
- // },
132
- // };
133
- // } else if (path) {
134
- // createButtonProps = {
135
- // label: 'New record',
136
- // onClick: () => {
137
- // router.push(path);
138
- // },
139
- // };
140
- // }
141
- // return (
142
- // <FormControl
143
- // type="lookup"
144
- // name={name}
145
- // label={label}
146
- // placeholder={placeholder}
147
- // required={required}
148
- // value={value}
149
- // onChange={onChange}
150
- // onBlur={onBlur}
151
- // error={isError}
152
- // helperText={errorMessage}
153
- // disabled={isDisabled}
154
- // borderOnFocusOnly={borderOnFocusOnly}
155
- // readOnly={readOnly}
156
- // createButton={createButtonProps}
157
- // openRecord={
158
- // routes?.edit
159
- // ? (id) => {
160
- // router.push(routes.edit!(id));
161
- // }
162
- // : undefined
163
- // }
164
- // async
165
- // dataResolver={async (options) => {
166
- // const lookupSchema = getSchema(attribute.entity);
167
- // const data = await dataService.retriveRecords({
168
- // logicalName: attribute.entity,
169
- // search: options?.search ?? '',
170
- // columnFilters: {},
171
- // pagination: {
172
- // pageIndex: 0,
173
- // rowsPerPage: 10,
174
- // sortBy: 'createdAt',
175
- // sortOrder: 'desc',
176
- // },
177
- // viewFilter: null,
178
- // columns: ['_id', lookupSchema.primaryAttribute ?? 'name'],
179
- // limit: options?.limit ?? 10,
180
- // });
181
- // return data.records.map((x: any) => ({
182
- // _id: x._id,
183
- // name: x[lookupSchema.primaryAttribute ?? 'name'],
184
- // }));
185
- // }}
186
- // />
187
- // );
188
- return ((0, jsx_runtime_1.jsx)(LookupControl_1.LookupControl, { name: name, value: value, onChange: onChange, onBlur: onBlur, placeholder: placeholder, disabled: isDisabled, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, allowNavigation: allowNavigation, allowNewRecord: allowNewRecord }));
157
+ const Control = componentStore_1.componentStore.getComponent('Form.LookupControl') ?? LookupControl_1.LookupControl;
158
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, placeholder: placeholder, disabled: isDisabled, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, allowNavigation: allowNavigation, allowNewRecord: allowNewRecord }));
189
159
  }
190
160
  case 'lookups': {
191
- return ((0, jsx_runtime_1.jsx)(MultiSelectLookupControl_1.MultiSelectLookupControl, { name: name, value: value, onChange: onChange, onBlur: onBlur, placeholder: placeholder, disabled: isDisabled, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, allowNavigation: allowNavigation, allowNewRecord: allowNewRecord }));
161
+ const Control = componentStore_1.componentStore.getComponent('Form.MultiSelectLookupControl') ?? MultiSelectLookupControl_1.MultiSelectLookupControl;
162
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, placeholder: placeholder, disabled: isDisabled, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, allowNavigation: allowNavigation, allowNewRecord: allowNewRecord }));
192
163
  }
193
164
  case 'boolean': {
194
- return ((0, jsx_runtime_1.jsx)(SwitchControl_1.SwitchControl, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly }));
165
+ const Control = componentStore_1.componentStore.getComponent('Form.SwitchControl') ?? SwitchControl_1.SwitchControl;
166
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly }));
195
167
  }
196
168
  case 'choice': {
197
- return ((0, jsx_runtime_1.jsx)(SelectControl_1.default, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
169
+ const Control = componentStore_1.componentStore.getComponent('Form.SelectControl') ?? SelectControl_1.default;
170
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
198
171
  }
199
172
  case 'choices': {
200
- return ((0, jsx_runtime_1.jsx)(MultiSelectControl_1.default, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
173
+ const Control = componentStore_1.componentStore.getComponent('Form.MultiSelectControl') ?? MultiSelectControl_1.default;
174
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
175
+ }
176
+ case 'attachment': {
177
+ const Control = componentStore_1.componentStore.getComponent('Form.AttachmentControl') ?? AttachmentControl_1.AttachmentControl;
178
+ return ((0, jsx_runtime_1.jsx)(Control, { fileService: fileService, format: attribute.format, location: attribute.location, name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly, fileServiceContext: props.fileServiceContext }));
179
+ }
180
+ case 'attachments': {
181
+ const Control = componentStore_1.componentStore.getComponent('Form.AttachmentsControl') ?? AttachmentsControl_1.AttachmentsControl;
182
+ return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
201
183
  }
202
184
  // case 'attachment': {
203
185
  // return (
@@ -222,6 +204,10 @@ allowNavigation, allowNewRecord, }) => {
222
204
  // );
223
205
  // }
224
206
  }
207
+ const FallBackControl = componentStore_1.componentStore.getComponent('StandardControl.FallBack');
208
+ if (FallBackControl) {
209
+ return (0, jsx_runtime_1.jsx)(FallBackControl, { ...props });
210
+ }
225
211
  return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
226
212
  };
227
213
  exports.StandardControl = StandardControl;
@@ -8,6 +8,7 @@ interface SubgridControlProps {
8
8
  id: string;
9
9
  refAttributeName: string;
10
10
  };
11
+ ContainerComponent?: React.ComponentType<any> | null;
11
12
  }
12
13
  export declare function SubgridControl(props: SubgridControlProps): import("react/jsx-runtime").JSX.Element;
13
14
  export {};
@@ -7,8 +7,8 @@ const DataGridProvider_1 = require("@headless-adminapp/app/datagrid/DataGridProv
7
7
  const hooks_1 = require("@headless-adminapp/app/metadata/hooks");
8
8
  const react_1 = require("react");
9
9
  const FormSubgridContainer_1 = require("../PageEntityView/FormSubgridContainer");
10
+ const FormSubgridNotAvailableContainer_1 = require("../PageEntityView/FormSubgridNotAvailableContainer");
10
11
  function SubgridControl(props) {
11
- var _a;
12
12
  const schema = (0, hooks_1.useSchema)(props.logicalName);
13
13
  const [viewId, setViewId] = (0, react_1.useState)(props.viewId);
14
14
  const { view, isLoadingView } = (0, hooks_1.useExperienceView)(props.logicalName, viewId, !!props.associated, props.availableViewIds);
@@ -62,5 +62,7 @@ function SubgridControl(props) {
62
62
  }
63
63
  return brokenContent;
64
64
  }
65
- return ((0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: viewLookup, onChangeView: setViewId, commands: (props.associated ? subgridCommands : commands), isSubGrid: props.associated ? true : false, extraFilter: extraFilter, allowViewSelection: (_a = props.allowViewSelection) !== null && _a !== void 0 ? _a : false, children: (0, jsx_runtime_1.jsx)(FormSubgridContainer_1.FormSubgridContainer, {}) }));
65
+ const ContainerComponent = props.ContainerComponent ?? FormSubgridContainer_1.FormSubgridContainer;
66
+ const disabled = !!props.associated && !props.associated.id;
67
+ return ((0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: viewLookup, onChangeView: setViewId, commands: (props.associated ? subgridCommands : commands), isSubGrid: !!props.associated, associated: props.associated, extraFilter: extraFilter, allowViewSelection: props.allowViewSelection ?? false, disabled: disabled, children: disabled ? (0, jsx_runtime_1.jsx)(FormSubgridNotAvailableContainer_1.FormSubgridNotAvailableContainer, {}) : (0, jsx_runtime_1.jsx)(ContainerComponent, {}) }));
66
68
  }
@@ -0,0 +1,12 @@
1
+ import { FileObject } from '@headless-adminapp/core/attributes/AttachmentAttribute';
2
+ import { FC } from 'react';
3
+ interface UploadImageDialogProps {
4
+ recordId: string;
5
+ recordTitle: string;
6
+ currentImage: FileObject | null;
7
+ onChange?: (value: FileObject | null) => void;
8
+ open: boolean;
9
+ onOpenChange: (open: boolean) => void;
10
+ }
11
+ export declare const UploadImageDialog: FC<UploadImageDialogProps>;
12
+ export {};