@headless-adminapp/app 1.1.5 → 1.1.7

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 (38) hide show
  1. package/app/index.d.ts +0 -1
  2. package/app/index.js +1 -3
  3. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +4 -0
  4. package/builders/CommandBuilder/DefaultCommandBuilder.js +12 -0
  5. package/builders/CommandBuilder/FormCommandBuilder.js +13 -0
  6. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +5 -0
  7. package/builders/CommandBuilder/SubgridCommandBuilder.js +31 -3
  8. package/builders/CommandBuilder/ViewCommandBuilder.d.ts +6 -0
  9. package/builders/CommandBuilder/ViewCommandBuilder.js +71 -4
  10. package/builders/DefineFormExperience.d.ts +1 -1
  11. package/components/ScrollView/index.d.ts +1 -0
  12. package/components/ScrollView/index.js +24 -1
  13. package/dataform/DataFormProvider/ReadonlyInfoResolver.js +3 -0
  14. package/dataform/DataFormProvider/utils.js +1 -1
  15. package/dataform/hooks/useLoadFormGridPage.js +1 -1
  16. package/datagrid/column-filter/constants.js +23 -0
  17. package/datagrid/hooks/useLoadMainGridPage.js +1 -1
  18. package/datagrid/hooks/useOpenRecord.d.ts +1 -1
  19. package/datagrid/hooks/useOpenRecord.js +5 -4
  20. package/metadata/hooks/useExperienceViewCommands.js +2 -2
  21. package/metadata/hooks/useExperienceViewSubgridCommands.js +2 -2
  22. package/package.json +2 -2
  23. package/transport/hooks/useRetriveRecords.d.ts +1 -1
  24. package/utils/getAttributeFormattedValue.js +5 -0
  25. package/dataform/test.d.ts +0 -57
  26. package/dataform/test.js +0 -247
  27. package/insights/InsightsProvider.d.ts +0 -8
  28. package/insights/InsightsProvider.js +0 -27
  29. package/metadata/hooks/useAppStore.d.ts +0 -1
  30. package/metadata/hooks/useAppStore.js +0 -8
  31. package/store/ClientAppStore.d.ts +0 -7
  32. package/store/ClientAppStore.js +0 -17
  33. package/widget/context.d.ts +0 -2
  34. package/widget/context.js +0 -5
  35. package/widget/hooks/index.d.ts +0 -3
  36. package/widget/hooks/index.js +0 -8
  37. package/widget/index.d.ts +0 -1
  38. package/widget/index.js +0 -5
package/app/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { AppContext } from './context';
2
2
  export { useAppContext } from './hooks';
3
3
  export { AppProvider } from './AppProvider';
4
- export { LayoutProvider } from './LayoutProvider';
package/app/index.js CHANGED
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LayoutProvider = exports.AppProvider = exports.useAppContext = exports.AppContext = void 0;
3
+ exports.AppProvider = exports.useAppContext = exports.AppContext = void 0;
4
4
  var context_1 = require("./context");
5
5
  Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return context_1.AppContext; } });
6
6
  var hooks_1 = require("./hooks");
7
7
  Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return hooks_1.useAppContext; } });
8
8
  var AppProvider_1 = require("./AppProvider");
9
9
  Object.defineProperty(exports, "AppProvider", { enumerable: true, get: function () { return AppProvider_1.AppProvider; } });
10
- var LayoutProvider_1 = require("./LayoutProvider");
11
- Object.defineProperty(exports, "LayoutProvider", { enumerable: true, get: function () { return LayoutProvider_1.LayoutProvider; } });
@@ -8,6 +8,7 @@ export declare namespace DefaultCommandBuilder {
8
8
  interface CreateDefaultViewCommandStrings {
9
9
  new: string;
10
10
  edit: string;
11
+ view: string;
11
12
  delete: string;
12
13
  refresh: string;
13
14
  export: string;
@@ -20,6 +21,7 @@ export declare namespace DefaultCommandBuilder {
20
21
  icons: {
21
22
  New: Icon;
22
23
  Edit: Icon;
24
+ View: Icon;
23
25
  Delete: Icon;
24
26
  Refresh: Icon;
25
27
  Export: Icon;
@@ -52,6 +54,7 @@ export declare namespace DefaultCommandBuilder {
52
54
  interface CreateDefaultSubgridCommandStrings {
53
55
  new: string;
54
56
  edit: string;
57
+ view: string;
55
58
  delete: string;
56
59
  refresh: string;
57
60
  export: string;
@@ -63,6 +66,7 @@ export declare namespace DefaultCommandBuilder {
63
66
  icons: {
64
67
  New: Icon;
65
68
  Edit: Icon;
69
+ View: Icon;
66
70
  Delete: Icon;
67
71
  Refresh: Icon;
68
72
  Export: Icon;
@@ -9,6 +9,7 @@ var DefaultCommandBuilder;
9
9
  DefaultCommandBuilder.defaultViewCommandStrings = {
10
10
  new: 'New',
11
11
  edit: 'Edit',
12
+ view: 'View',
12
13
  delete: 'Delete',
13
14
  deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
14
15
  refresh: 'Refresh',
@@ -38,6 +39,11 @@ var DefaultCommandBuilder;
38
39
  text: strings.edit,
39
40
  localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
40
41
  }),
42
+ ViewCommandBuilder_1.ViewCommandBuilder.createViewRecordCommand({
43
+ Icon: icons.View,
44
+ text: strings.view,
45
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.view),
46
+ }),
41
47
  ViewCommandBuilder_1.ViewCommandBuilder.createDeleteRecordCommand({
42
48
  Icon: icons.Delete,
43
49
  text: strings.delete,
@@ -112,6 +118,7 @@ var DefaultCommandBuilder;
112
118
  const defaultSubgridCommandStrings = {
113
119
  new: 'New',
114
120
  edit: 'Edit',
121
+ view: 'View',
115
122
  delete: 'Delete',
116
123
  refresh: 'Refresh',
117
124
  export: 'Export',
@@ -132,6 +139,11 @@ var DefaultCommandBuilder;
132
139
  text: strings.edit,
133
140
  localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
134
141
  }),
142
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createEditRecordCommand({
143
+ Icon: icons.View,
144
+ text: strings.view,
145
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.view),
146
+ }),
135
147
  SubgridCommandBuilder_1.SubgridCommandBuilder.createDeleteRecordCommand({
136
148
  Icon: icons.Delete,
137
149
  text: strings.delete,
@@ -16,6 +16,10 @@ var EnabledRules;
16
16
  return !context.primaryControl.schema.restrictions?.disableDelete;
17
17
  }
18
18
  EnabledRules.HasDeletePermission = HasDeletePermission;
19
+ function IsPhysicalSchema(context) {
20
+ return !context.primaryControl.schema.virtual;
21
+ }
22
+ EnabledRules.IsPhysicalSchema = IsPhysicalSchema;
19
23
  })(EnabledRules || (EnabledRules = {}));
20
24
  var FormCommandBuilder;
21
25
  (function (FormCommandBuilder) {
@@ -31,6 +35,9 @@ var FormCommandBuilder;
31
35
  },
32
36
  hidden: [
33
37
  (context) => {
38
+ if (!EnabledRules.IsPhysicalSchema(context)) {
39
+ return true;
40
+ }
34
41
  if (context.primaryControl.readonly) {
35
42
  return true;
36
43
  }
@@ -56,6 +63,9 @@ var FormCommandBuilder;
56
63
  },
57
64
  hidden: [
58
65
  (context) => {
66
+ if (!EnabledRules.IsPhysicalSchema(context)) {
67
+ return true;
68
+ }
59
69
  if (context.primaryControl.readonly) {
60
70
  return true;
61
71
  }
@@ -96,6 +106,9 @@ var FormCommandBuilder;
96
106
  localizedText: localizedTexts,
97
107
  danger: true,
98
108
  hidden: (context) => {
109
+ if (!EnabledRules.IsPhysicalSchema(context)) {
110
+ return true;
111
+ }
99
112
  if (!context.primaryControl.recordId) {
100
113
  return true;
101
114
  }
@@ -13,6 +13,11 @@ export declare namespace SubgridCommandBuilder {
13
13
  text: string;
14
14
  localizedTexts?: Record<string, string>;
15
15
  }): SubGridCommandItemExperience;
16
+ function createViewRecordCommand({ Icon, text, localizedTexts, }: {
17
+ Icon: Icon;
18
+ text: string;
19
+ localizedTexts?: Record<string, string>;
20
+ }): SubGridCommandItemExperience;
16
21
  function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
17
22
  Icon: Icon;
18
23
  text: string;
@@ -26,6 +26,10 @@ var EnabledRules;
26
26
  return context.secondaryControl.selectedIds.length > 0;
27
27
  }
28
28
  EnabledRules.HasAtLeastOneRecordSelected = HasAtLeastOneRecordSelected;
29
+ function IsPhysicalSchema(context) {
30
+ return !context.secondaryControl.schema.virtual;
31
+ }
32
+ EnabledRules.IsPhysicalSchema = IsPhysicalSchema;
29
33
  })(EnabledRules || (EnabledRules = {}));
30
34
  var SubgridCommandBuilder;
31
35
  (function (SubgridCommandBuilder) {
@@ -54,7 +58,10 @@ var SubgridCommandBuilder;
54
58
  });
55
59
  }
56
60
  },
57
- hidden: (context) => !EnabledRules.HasCreatePermisssion(context),
61
+ hidden: [
62
+ (context) => !EnabledRules.HasCreatePermisssion(context),
63
+ (context) => !EnabledRules.IsPhysicalSchema(context),
64
+ ],
58
65
  };
59
66
  }
60
67
  SubgridCommandBuilder.createNewRecordCommand = createNewRecordCommand;
@@ -66,12 +73,32 @@ var SubgridCommandBuilder;
66
73
  localizedText: localizedTexts,
67
74
  isContextMenu: true,
68
75
  onClick: (context) => {
69
- context.secondaryControl.openRecord(context.secondaryControl.selectedIds[0]);
76
+ context.secondaryControl.openRecord(context.secondaryControl.selectedIds[0], context.secondaryControl.schema.logicalName);
70
77
  },
71
- hidden: [(context) => !EnabledRules.HasSingleRecordSelected(context)],
78
+ hidden: [
79
+ (context) => !EnabledRules.HasSingleRecordSelected(context),
80
+ (context) => !EnabledRules.IsPhysicalSchema(context),
81
+ ],
72
82
  };
73
83
  }
74
84
  SubgridCommandBuilder.createEditRecordCommand = createEditRecordCommand;
85
+ function createViewRecordCommand({ Icon, text, localizedTexts, }) {
86
+ return {
87
+ type: 'button',
88
+ Icon,
89
+ text,
90
+ localizedText: localizedTexts,
91
+ isContextMenu: true,
92
+ onClick: (context) => {
93
+ context.secondaryControl.openRecord(context.secondaryControl.selectedIds[0], context.secondaryControl.schema.logicalName);
94
+ },
95
+ hidden: [
96
+ (context) => !EnabledRules.HasSingleRecordSelected(context),
97
+ (context) => EnabledRules.IsPhysicalSchema(context),
98
+ ],
99
+ };
100
+ }
101
+ SubgridCommandBuilder.createViewRecordCommand = createViewRecordCommand;
75
102
  function plurialize(count, singular, plural) {
76
103
  if (Array.isArray(singular)) {
77
104
  plural = singular[1];
@@ -130,6 +157,7 @@ var SubgridCommandBuilder;
130
157
  hidden: [
131
158
  (context) => !EnabledRules.HasAtLeastOneRecordSelected(context),
132
159
  (context) => !EnabledRules.HasDeletePermission(context),
160
+ (context) => !EnabledRules.IsPhysicalSchema(context),
133
161
  ],
134
162
  };
135
163
  }
@@ -7,6 +7,7 @@ export declare namespace EnabledRules {
7
7
  function HasDeletePermission(context: EntityMainGridCommandContext): boolean;
8
8
  function HasSingleRecordSelected(context: EntityMainGridCommandContext): boolean;
9
9
  function HasAtLeastOneRecordSelected(context: EntityMainGridCommandContext): boolean;
10
+ function IsPhysicalSchema(context: EntityMainGridCommandContext): boolean;
10
11
  }
11
12
  export declare namespace ViewCommandBuilder {
12
13
  function createNewRecordCommand({ Icon, text, localizedTexts, }: {
@@ -19,6 +20,11 @@ export declare namespace ViewCommandBuilder {
19
20
  text: string;
20
21
  localizedTexts?: Record<string, string>;
21
22
  }): EntityMainGridCommandItemExperience;
23
+ function createViewRecordCommand({ Icon, text, localizedTexts, }: {
24
+ Icon: Icon;
25
+ text: string;
26
+ localizedTexts?: Record<string, string>;
27
+ }): EntityMainGridCommandItemExperience;
22
28
  interface DeleteRecordCommandStringSet {
23
29
  confirmation: {
24
30
  title: string | [string, string];
@@ -17,7 +17,35 @@ var EnabledRules;
17
17
  }
18
18
  EnabledRules.HasUpdatePermission = HasUpdatePermission;
19
19
  function HasDeletePermission(context) {
20
- return !context.primaryControl.schema.restrictions?.disableDelete;
20
+ if (context.primaryControl.schema.restrictions?.disableDelete) {
21
+ return false;
22
+ }
23
+ if (context.primaryControl.schema.virtual) {
24
+ const baseSchemaLogicalName = context.primaryControl.schema.baseSchemaLogicalName;
25
+ const virtualLogicalNameAttribute = context.primaryControl.schema.virtualLogicalNameAttribute;
26
+ if (!baseSchemaLogicalName && !virtualLogicalNameAttribute) {
27
+ return false;
28
+ }
29
+ if (baseSchemaLogicalName) {
30
+ const baseSchema = context.stores.schemaStore.getSchema(baseSchemaLogicalName);
31
+ if (!baseSchema) {
32
+ return false;
33
+ }
34
+ if (baseSchema.restrictions?.disableDelete) {
35
+ return false;
36
+ }
37
+ }
38
+ else if (virtualLogicalNameAttribute) {
39
+ const logicalNames = Array.from(new Set(context.primaryControl.selectedRecords.map((x) => x.$entity)));
40
+ const schemas = logicalNames.map((x) => context.stores.schemaStore.getSchema(x));
41
+ if (!schemas.length ||
42
+ schemas.some((x) => x.restrictions?.disableDelete) ||
43
+ schemas.some((x) => x.virtual)) {
44
+ return false;
45
+ }
46
+ }
47
+ }
48
+ return true;
21
49
  }
22
50
  EnabledRules.HasDeletePermission = HasDeletePermission;
23
51
  function HasSingleRecordSelected(context) {
@@ -28,6 +56,10 @@ var EnabledRules;
28
56
  return context.primaryControl.selectedIds.length > 0;
29
57
  }
30
58
  EnabledRules.HasAtLeastOneRecordSelected = HasAtLeastOneRecordSelected;
59
+ function IsPhysicalSchema(context) {
60
+ return !context.primaryControl.schema.virtual;
61
+ }
62
+ EnabledRules.IsPhysicalSchema = IsPhysicalSchema;
31
63
  })(EnabledRules || (exports.EnabledRules = EnabledRules = {}));
32
64
  var ViewCommandBuilder;
33
65
  (function (ViewCommandBuilder) {
@@ -46,6 +78,9 @@ var ViewCommandBuilder;
46
78
  if (!EnabledRules.HasCreatePermisssion(context)) {
47
79
  return true;
48
80
  }
81
+ if (!EnabledRules.IsPhysicalSchema(context)) {
82
+ return true;
83
+ }
49
84
  return false;
50
85
  },
51
86
  };
@@ -59,12 +94,32 @@ var ViewCommandBuilder;
59
94
  localizedText: localizedTexts,
60
95
  isContextMenu: true,
61
96
  onClick: (context) => {
62
- context.primaryControl.openRecord(context.primaryControl.selectedIds[0]);
97
+ context.primaryControl.openRecord(context.primaryControl.selectedIds[0], context.primaryControl.schema.logicalName);
63
98
  },
64
- hidden: [(context) => !EnabledRules.HasSingleRecordSelected(context)],
99
+ hidden: [
100
+ (context) => !EnabledRules.HasSingleRecordSelected(context),
101
+ (context) => !EnabledRules.IsPhysicalSchema(context),
102
+ ],
65
103
  };
66
104
  }
67
105
  ViewCommandBuilder.createEditRecordCommand = createEditRecordCommand;
106
+ function createViewRecordCommand({ Icon, text, localizedTexts, }) {
107
+ return {
108
+ type: 'button',
109
+ Icon,
110
+ text,
111
+ localizedText: localizedTexts,
112
+ isContextMenu: true,
113
+ onClick: (context) => {
114
+ context.primaryControl.openRecord(context.primaryControl.selectedIds[0], context.primaryControl.schema.logicalName);
115
+ },
116
+ hidden: [
117
+ (context) => !EnabledRules.HasSingleRecordSelected(context),
118
+ (context) => EnabledRules.IsPhysicalSchema(context),
119
+ ],
120
+ };
121
+ }
122
+ ViewCommandBuilder.createViewRecordCommand = createViewRecordCommand;
68
123
  ViewCommandBuilder.defaultDeleteRecordStringSet = {
69
124
  confirmation: {
70
125
  text: [
@@ -201,6 +256,18 @@ async function processDeleteRecordRequest(context, { stringSet, localizedStringS
201
256
  if (!recordIds.length) {
202
257
  return;
203
258
  }
259
+ let logicalName = context.primaryControl.schema.logicalName;
260
+ if (context.primaryControl.schema.virtual) {
261
+ const baseSchemaLogicalName = context.primaryControl.schema.baseSchemaLogicalName;
262
+ if (!baseSchemaLogicalName) {
263
+ return;
264
+ }
265
+ const baseSchema = context.stores.schemaStore.getSchema(baseSchemaLogicalName);
266
+ if (!baseSchema) {
267
+ return;
268
+ }
269
+ logicalName = baseSchema.logicalName;
270
+ }
204
271
  const localizeSelector = (0, utils_2.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
205
272
  try {
206
273
  const confirmResult = await context.utility.openConfirmDialog({
@@ -214,7 +281,7 @@ async function processDeleteRecordRequest(context, { stringSet, localizedStringS
214
281
  }
215
282
  context.utility.showProgressIndicator((0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
216
283
  for (const recordId of recordIds) {
217
- await context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
284
+ await context.dataService.deleteRecord(logicalName, recordId);
218
285
  }
219
286
  context.utility.showNotification({
220
287
  title: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.successNotification.title)),
@@ -20,7 +20,7 @@ export declare namespace DefineFormExperience {
20
20
  type TabColumn<S extends SchemaAttributes = SchemaAttributes> = {
21
21
  sections: Section<S>[];
22
22
  };
23
- type Section<S extends SchemaAttributes = SchemaAttributes> = Pick<$Section<S>, 'label' | 'columnCount' | 'labelPosition' | 'name' | 'localizedLabels' | 'hidden' | 'hideLabel' | 'noPadding'> & {
23
+ type Section<S extends SchemaAttributes = SchemaAttributes> = Pick<$Section<S>, 'label' | 'columnCount' | 'labelPosition' | 'name' | 'localizedLabels' | 'hidden' | 'hideLabel' | 'noPadding' | 'fullHeight'> & {
24
24
  controls: SectionControl<S>[];
25
25
  };
26
26
  export type SectionControl<S extends SchemaAttributes = SchemaAttributes> = $SectionControl<S> | keyof S;
@@ -5,6 +5,7 @@ interface ScrollViewProps {
5
5
  autoHide?: boolean;
6
6
  rtl?: boolean;
7
7
  onScroll?: ScrollbarProps['onScroll'];
8
+ shadowEffect?: boolean;
8
9
  }
9
10
  export declare const ScrollView: FC<PropsWithChildren<ScrollViewProps>>;
10
11
  export {};
@@ -6,6 +6,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ScrollView = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const clsx_1 = __importDefault(require("clsx"));
9
+ const react_1 = require("react");
9
10
  const react_custom_scrollbars_2_1 = require("react-custom-scrollbars-2");
10
- const ScrollView = ({ children, className, rtl, autoHide, onScroll, }) => ((0, jsx_runtime_1.jsx)(react_custom_scrollbars_2_1.Scrollbars, { autoHide: autoHide, className: (0, clsx_1.default)(className, 'hdl-scrollbar', rtl && 'rtl'), onScroll: onScroll, children: children }));
11
+ function getReaminingSpace(div) {
12
+ return div.scrollHeight - div.scrollTop - div.clientHeight;
13
+ }
14
+ const ScrollView = ({ children, className, rtl, autoHide, onScroll, shadowEffect = false, }) => {
15
+ const [isTop, setIsTop] = (0, react_1.useState)(true);
16
+ const [isBottom, setIsBottom] = (0, react_1.useState)(false);
17
+ const handleScroll = (event) => {
18
+ const div = event.target;
19
+ const remainingSpace = getReaminingSpace(div);
20
+ const _isTop = div.scrollTop === 0;
21
+ const _isBottom = remainingSpace <= 0;
22
+ if (isTop !== _isTop) {
23
+ setIsTop(_isTop);
24
+ }
25
+ if (isBottom !== _isBottom) {
26
+ setIsBottom(_isBottom);
27
+ }
28
+ if (onScroll) {
29
+ onScroll(event);
30
+ }
31
+ };
32
+ return ((0, jsx_runtime_1.jsx)(react_custom_scrollbars_2_1.Scrollbars, { autoHide: autoHide, className: (0, clsx_1.default)(className, 'hdl-scrollbar', rtl && 'rtl', shadowEffect && !isTop && 'hdl-scrollbar-shadow-top', shadowEffect && !isBottom && 'hdl-scrollbar-shadow-bottom'), onScroll: handleScroll, children: children }));
33
+ };
11
34
  exports.ScrollView = ScrollView;
@@ -15,6 +15,9 @@ function ReadonlyInfoResolver({ setFormReadOnly, }) {
15
15
  if (schema.restrictions?.disableUpdate && recordId) {
16
16
  readonly = true;
17
17
  }
18
+ if (schema.virtual) {
19
+ readonly = true;
20
+ }
18
21
  const setValue = (0, mutable_1.useContextSetValue)(context_1.DataFormContext);
19
22
  (0, react_1.useEffect)(() => {
20
23
  setValue({
@@ -73,7 +73,7 @@ function getIsFieldDisabled({ attribute, isFormReadonly, disabledFields, control
73
73
  disabledFields[control.attributeName] !== undefined) {
74
74
  disabled = disabledFields[control.attributeName];
75
75
  }
76
- else if (control.disabled !== undefined) {
76
+ else if ('disabled' in control && control.disabled !== undefined) {
77
77
  disabled = control.disabled;
78
78
  }
79
79
  else if (attribute.readonly !== undefined) {
@@ -44,7 +44,7 @@ function useLoadFormGridPage(logicalName, formId) {
44
44
  loading: false,
45
45
  error: true,
46
46
  title: 'Form not found',
47
- message: 'The form was not found',
47
+ message: `The form was not found for "${logicalName}"`,
48
48
  };
49
49
  }
50
50
  if (form.logicalName !== schema.logicalName) {
@@ -441,6 +441,28 @@ const lookupOperatorOptions = [
441
441
  controls: [],
442
442
  },
443
443
  ];
444
+ const regardingOperatorOptions = [
445
+ {
446
+ value: 'in',
447
+ labelKey: 'equals',
448
+ controls: ['regarding'],
449
+ },
450
+ {
451
+ value: 'not-in',
452
+ labelKey: 'doesNotEqual',
453
+ controls: ['regarding'],
454
+ },
455
+ {
456
+ value: 'not-null',
457
+ labelKey: 'containsData',
458
+ controls: [],
459
+ },
460
+ {
461
+ value: 'null',
462
+ labelKey: 'doesNotContainData',
463
+ controls: [],
464
+ },
465
+ ];
444
466
  const booleanOperatorOptions = [
445
467
  {
446
468
  value: 'in',
@@ -514,4 +536,5 @@ exports.operatorOptions = {
514
536
  mixed: mixedOperatorOptions,
515
537
  daterange: [],
516
538
  lookups: [],
539
+ regarding: regardingOperatorOptions,
517
540
  };
@@ -28,7 +28,7 @@ function useLoadMainGridPage(logicalName, viewId) {
28
28
  loading: false,
29
29
  error: true,
30
30
  title: 'View not found',
31
- message: 'The view was not found',
31
+ message: `The view was not found for schema "${schema.logicalName}"`,
32
32
  };
33
33
  }
34
34
  if (view.logicalName !== schema.logicalName) {
@@ -1 +1 @@
1
- export declare function useOpenRecord(): (id: string) => void;
1
+ export declare function useOpenRecord(): (id: string, logicalName: string) => void;
@@ -15,14 +15,15 @@ function useOpenRecord() {
15
15
  const recordSetSetter = (0, recordset_1.useRecordSetSetter)();
16
16
  const dataRef = (0, react_1.useRef)(data);
17
17
  dataRef.current = data;
18
- return (0, react_1.useCallback)((id) => {
18
+ return (0, react_1.useCallback)((id, logicalName) => {
19
19
  const path = routeResolver({
20
- logicalName: schema.logicalName,
20
+ logicalName: logicalName,
21
21
  type: app_1.PageType.EntityForm,
22
22
  id,
23
23
  });
24
- recordSetSetter(schema.logicalName, dataRef.current?.records.map((x) => x[schema.idAttribute]) ??
25
- []);
24
+ if (logicalName === schema.logicalName) {
25
+ recordSetSetter(schema.logicalName, dataRef.current?.records.map((x) => x[schema.idAttribute]) ?? []);
26
+ }
26
27
  router.push(path);
27
28
  }, [
28
29
  recordSetSetter,
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useExperienceViewCommands = useExperienceViewCommands;
4
- const app_1 = require("@headless-adminapp/app/app");
5
4
  const react_query_1 = require("@tanstack/react-query");
5
+ const useAppContext_1 = require("../../app/hooks/useAppContext");
6
6
  const useExperienceStore_1 = require("./useExperienceStore");
7
7
  /** @todo move in different dir */
8
8
  function useExperienceViewCommands(logicalName) {
9
9
  const experienceStore = (0, useExperienceStore_1.useExperienceStore)();
10
- const { appExperience: { viewCommands }, } = (0, app_1.useAppContext)();
10
+ const { appExperience: { viewCommands }, } = (0, useAppContext_1.useAppContext)();
11
11
  const { data: commands } = (0, react_query_1.useQuery)({
12
12
  queryKey: ['experience-schema-view-commands', logicalName],
13
13
  queryFn: async () => {
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useExperienceViewSubgridCommands = useExperienceViewSubgridCommands;
4
- const app_1 = require("@headless-adminapp/app/app");
5
4
  const react_query_1 = require("@tanstack/react-query");
5
+ const useAppContext_1 = require("../../app/hooks/useAppContext");
6
6
  const useExperienceStore_1 = require("./useExperienceStore");
7
7
  /** @todo move in different dir */
8
8
  function useExperienceViewSubgridCommands(logicalName) {
9
9
  const experienceStore = (0, useExperienceStore_1.useExperienceStore)();
10
- const { appExperience: { subgridCommands }, } = (0, app_1.useAppContext)();
10
+ const { appExperience: { subgridCommands }, } = (0, useAppContext_1.useAppContext)();
11
11
  const { data: commands } = (0, react_query_1.useQuery)({
12
12
  queryKey: ['experience-schema-view-subgrid-commands', logicalName],
13
13
  queryFn: async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -36,5 +36,5 @@
36
36
  "uuid": "11.0.3",
37
37
  "yup": "^1.4.0"
38
38
  },
39
- "gitHead": "76976de5e79eb752b80bb090de8228392851f0cc"
39
+ "gitHead": "e5d75e8b5da3f818064090455eefd3cb27b5a2ce"
40
40
  }
@@ -7,7 +7,7 @@ interface UseRetriveRecordProps<S extends SchemaAttributes = SchemaAttributes> {
7
7
  search?: string;
8
8
  filter?: Filter | null;
9
9
  sorting?: SortingState<S>;
10
- columns: string[];
10
+ columns: (keyof S)[];
11
11
  expand?: Partial<Record<string, string[]>>;
12
12
  maxRecords?: number;
13
13
  disabled?: boolean;
@@ -93,6 +93,9 @@ function getAttributeChoicesFormattedValue(attribute, value) {
93
93
  function getAttributeLookupFormattedValue(value) {
94
94
  return value?.name;
95
95
  }
96
+ function getAttributeRegardingFormattedValue(value) {
97
+ return value?.name;
98
+ }
96
99
  function getAttributeMoneyFormattedValue(value, options) {
97
100
  const locale = options?.locale ?? defaultLocale;
98
101
  const currency = options?.currency ?? defaultCurrency;
@@ -171,6 +174,8 @@ function getAttributeFormattedValue(attribute, value, options) {
171
174
  return getAttributeLookupFormattedValue(value);
172
175
  case 'lookups':
173
176
  return getAttributeLookupsFormattedValue(value, options);
177
+ case 'regarding':
178
+ return getAttributeRegardingFormattedValue(value);
174
179
  case 'money':
175
180
  return getAttributeMoneyFormattedValue(value, options);
176
181
  case 'number':
@@ -1,57 +0,0 @@
1
- import { Attribute } from '@headless-adminapp/core';
2
- import { SectionControl } from '@headless-adminapp/core/experience/form/SectionControl';
3
- import { SchemaAttributes } from '@headless-adminapp/core/schema';
4
- import { ContextValue } from '../mutable';
5
- import { DataFormContextState } from './context';
6
- import { Section } from '@headless-adminapp/core/experience/form';
7
- import { Tab } from '@headless-adminapp/core/experience/form/Tab';
8
- export declare class FormUiManager<SA extends SchemaAttributes = SchemaAttributes> {
9
- private readonly contextState;
10
- constructor(contextState: ContextValue<DataFormContextState<SA>>);
11
- private get context();
12
- getAttribute(attributeName: keyof SA): FormAttribute<SA> | null;
13
- getControl<C extends Control<SA>>(name: string): C | null;
14
- getSection(name: string): FormSection<SA> | null;
15
- getTab(name: string): FormTab<SA> | null;
16
- }
17
- declare class FormAttribute<SA extends SchemaAttributes = SchemaAttributes> {
18
- private readonly contextState;
19
- private readonly attributeName;
20
- private readonly attribute;
21
- constructor(contextState: ContextValue<DataFormContextState<SA>>, attributeName: keyof SA, attribute: Attribute);
22
- getInnerAttribute(): Attribute;
23
- setRequired(state: boolean): void;
24
- getRequired(): boolean;
25
- resetRequired(): void;
26
- getControls(): Control<SA>[];
27
- }
28
- declare class Control<SA extends SchemaAttributes = SchemaAttributes> {
29
- private readonly contextState;
30
- private readonly control;
31
- constructor(contextState: ContextValue<DataFormContextState<SA>>, control: SectionControl<SA>);
32
- private get context();
33
- getKey(): string | undefined;
34
- getDisabled(): boolean;
35
- setDisabled(state: boolean): void;
36
- resetDisabled(): void;
37
- getHidden(): boolean;
38
- setHidden(state: boolean): void;
39
- resetHidden(): void;
40
- }
41
- declare class FormSection<SA extends SchemaAttributes = SchemaAttributes> {
42
- private readonly contextState;
43
- private readonly section;
44
- constructor(contextState: ContextValue<DataFormContextState<SA>>, section: Section<SA>);
45
- setHidden(state: boolean): void;
46
- getHidden(): boolean;
47
- resetHidden(): void;
48
- }
49
- declare class FormTab<SA extends SchemaAttributes = SchemaAttributes> {
50
- private readonly contextState;
51
- private readonly tab;
52
- constructor(contextState: ContextValue<DataFormContextState<SA>>, tab: Tab<SA>);
53
- setHidden(state: boolean): void;
54
- getHidden(): boolean;
55
- resetHidden(): void;
56
- }
57
- export {};
package/dataform/test.js DELETED
@@ -1,247 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormUiManager = void 0;
4
- const utils_1 = require("./DataFormProvider/utils");
5
- class FormUiManager {
6
- contextState;
7
- constructor(contextState) {
8
- this.contextState = contextState;
9
- }
10
- get context() {
11
- return this.contextState.value.current;
12
- }
13
- getAttribute(attributeName) {
14
- return new FormAttribute(this.contextState, attributeName, this.context.schema.attributes[attributeName]);
15
- }
16
- getControl(name) {
17
- const control = this.context.formInternal.controls.dict[name] ?? null;
18
- if (!control) {
19
- return null;
20
- }
21
- return new Control(this.contextState, control);
22
- }
23
- getSection(name) {
24
- const section = this.context.formInternal.sections.dict[name];
25
- if (!section) {
26
- return null;
27
- }
28
- return new FormSection(this.contextState, section);
29
- }
30
- getTab(name) {
31
- const tab = this.context.formInternal.tabs.dict[name];
32
- if (!tab) {
33
- return null;
34
- }
35
- return new FormTab(this.contextState, tab);
36
- }
37
- }
38
- exports.FormUiManager = FormUiManager;
39
- class FormAttribute {
40
- contextState;
41
- attributeName;
42
- attribute;
43
- constructor(contextState, attributeName, attribute) {
44
- this.contextState = contextState;
45
- this.attributeName = attributeName;
46
- this.attribute = attribute;
47
- }
48
- getInnerAttribute() {
49
- return this.attribute;
50
- }
51
- setRequired(state) {
52
- const control = this.contextState.value.current.formInternal.controls.dict[this.attributeName];
53
- if (!control) {
54
- return;
55
- }
56
- if (control.type !== 'standard') {
57
- return;
58
- }
59
- this.contextState.setValue((prev) => {
60
- return {
61
- requiredFields: {
62
- ...prev.requiredFields,
63
- [this.attributeName]: state,
64
- },
65
- };
66
- });
67
- }
68
- getRequired() {
69
- const attribute = this.attribute;
70
- const control = this.contextState.value.current.formInternal.controls.dict[this.attributeName];
71
- if (control.type !== 'standard') {
72
- return false;
73
- }
74
- return (0, utils_1.getIsFieldRequired)({
75
- attribute,
76
- control,
77
- requiredFields: this.contextState.value.current.requiredFields,
78
- });
79
- }
80
- resetRequired() {
81
- this.contextState.setValue((prev) => {
82
- const requiredFields = { ...prev.requiredFields };
83
- delete requiredFields[this.attributeName];
84
- return {
85
- requiredFields,
86
- };
87
- });
88
- }
89
- getControls() {
90
- return this.contextState.value.current.formInternal.controls.list
91
- .filter((control) => control.type === 'standard' &&
92
- control.attributeName === this.attributeName)
93
- .map((control) => new Control(this.contextState, control));
94
- }
95
- }
96
- class Control {
97
- contextState;
98
- control;
99
- constructor(contextState, control) {
100
- this.contextState = contextState;
101
- this.control = control;
102
- }
103
- get context() {
104
- return this.contextState.value.current;
105
- }
106
- getKey() {
107
- let key = this.control.key;
108
- if (!key && this.control.type === 'standard') {
109
- key = this.control.attributeName;
110
- }
111
- return key;
112
- }
113
- getDisabled() {
114
- if (this.control.type !== 'standard') {
115
- return false;
116
- }
117
- const attributeName = this.control.attributeName;
118
- return (0, utils_1.getIsFieldDisabled)({
119
- control: this.control,
120
- attribute: this.context.schema.attributes[attributeName],
121
- disabledFields: this.context.disabledControls,
122
- isFormReadonly: this.context.isReadonly,
123
- });
124
- }
125
- setDisabled(state) {
126
- if (this.control.type !== 'standard') {
127
- return;
128
- }
129
- const key = this.control.attributeName;
130
- this.contextState.setValue((prev) => {
131
- return {
132
- disabledControls: {
133
- ...prev.disabledControls,
134
- [key]: state,
135
- },
136
- };
137
- });
138
- }
139
- resetDisabled() {
140
- if (this.control.type !== 'standard') {
141
- return;
142
- }
143
- const key = this.control.attributeName;
144
- this.contextState.setValue((prev) => {
145
- const disabledFields = { ...prev.disabledControls };
146
- delete disabledFields[key];
147
- return {
148
- disabledControls: disabledFields,
149
- };
150
- });
151
- }
152
- getHidden() {
153
- return (0, utils_1.getIsControlHidden)({
154
- control: this.control,
155
- hiddenControls: this.context.hiddenControls,
156
- });
157
- }
158
- setHidden(state) {
159
- const key = this.getKey();
160
- if (!key) {
161
- return;
162
- }
163
- this.contextState.setValue((prev) => {
164
- return {
165
- hiddenControls: {
166
- ...prev.hiddenControls,
167
- [key]: state,
168
- },
169
- };
170
- });
171
- }
172
- resetHidden() {
173
- const key = this.getKey();
174
- if (!key) {
175
- return;
176
- }
177
- this.contextState.setValue((prev) => {
178
- const hiddenControls = { ...prev.hiddenControls };
179
- delete hiddenControls[key];
180
- return {
181
- hiddenControls,
182
- };
183
- });
184
- }
185
- }
186
- class FormSection {
187
- contextState;
188
- section;
189
- constructor(contextState, section) {
190
- this.contextState = contextState;
191
- this.section = section;
192
- }
193
- setHidden(state) {
194
- this.contextState.setValue((prev) => {
195
- return {
196
- hiddenSections: {
197
- ...prev.hiddenSections,
198
- [this.section.name]: state,
199
- },
200
- };
201
- });
202
- }
203
- getHidden() {
204
- return (this.contextState.value.current.hiddenSections[this.section.name] ??
205
- this.section.hidden ??
206
- false);
207
- }
208
- resetHidden() {
209
- this.contextState.setValue((prev) => {
210
- const hiddenSections = { ...prev.hiddenSections };
211
- delete hiddenSections[this.section.name];
212
- return {
213
- hiddenSections,
214
- };
215
- });
216
- }
217
- }
218
- class FormTab {
219
- contextState;
220
- tab;
221
- constructor(contextState, tab) {
222
- this.contextState = contextState;
223
- this.tab = tab;
224
- }
225
- setHidden(state) {
226
- this.contextState.setValue((prev) => {
227
- return {
228
- hiddenTabs: {
229
- ...prev.hiddenTabs,
230
- [this.tab.name]: state,
231
- },
232
- };
233
- });
234
- }
235
- getHidden() {
236
- return this.contextState.value.current.hiddenTabs[this.tab.name] ?? false;
237
- }
238
- resetHidden() {
239
- this.contextState.setValue((prev) => {
240
- const hiddenTabs = { ...prev.hiddenTabs };
241
- delete hiddenTabs[this.tab.name];
242
- return {
243
- hiddenTabs,
244
- };
245
- });
246
- }
247
- }
@@ -1,8 +0,0 @@
1
- import { InsightExpereince, InsightLookup } from '@headless-adminapp/core/experience/insights';
2
- import { SchemaAttributes } from '@headless-adminapp/core/schema';
3
- import { PropsWithChildren } from 'react';
4
- export declare function InsightsProvider<SA extends SchemaAttributes = SchemaAttributes>({ children, experience, insightLookup, onInsightSelect, }: PropsWithChildren<{
5
- experience: InsightExpereince<SA>;
6
- insightLookup: InsightLookup[];
7
- onInsightSelect: (id: string) => void;
8
- }>): import("react/jsx-runtime").JSX.Element;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InsightsProvider = InsightsProvider;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const mutable_1 = require("../mutable");
7
- const context_1 = require("./context");
8
- function InsightsProvider({ children, experience, insightLookup, onInsightSelect, }) {
9
- const onInsightSelectRef = (0, react_1.useRef)(onInsightSelect);
10
- onInsightSelectRef.current = onInsightSelect;
11
- const onInsightSelectInternal = (0, react_1.useCallback)((id) => {
12
- onInsightSelectRef.current(id);
13
- }, [onInsightSelectRef]);
14
- const insightsValues = (0, mutable_1.useCreateContextStore)({
15
- experience,
16
- data: experience.defaultData,
17
- insightLookup: insightLookup,
18
- onInsightSelect: onInsightSelectInternal,
19
- });
20
- (0, react_1.useEffect)(() => {
21
- insightsValues.setValue({
22
- experience,
23
- data: experience.defaultData,
24
- });
25
- }, [experience, insightsValues]);
26
- return ((0, jsx_runtime_1.jsx)(context_1.InsightsContext.Provider, { value: insightsValues, children: children }));
27
- }
@@ -1 +0,0 @@
1
- export declare function useAppExperience(): import("@headless-adminapp/core/experience/app").AppExperience;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useAppExperience = useAppExperience;
4
- const context_1 = require("../../mutable/context");
5
- const context_2 = require("../context");
6
- function useAppExperience() {
7
- return (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.app);
8
- }
@@ -1,7 +0,0 @@
1
- import { AppExperience } from '@headless-adminapp/core/experience/app';
2
- import { IClientAppStore } from '@headless-adminapp/core/store';
3
- export declare class ClientAppStore implements IClientAppStore {
4
- private apps;
5
- register(app: AppExperience): void;
6
- getApp(id: string): Promise<AppExperience>;
7
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientAppStore = void 0;
4
- class ClientAppStore {
5
- apps = {};
6
- register(app) {
7
- this.apps[app.id] = app;
8
- }
9
- async getApp(id) {
10
- const app = this.apps[id];
11
- if (!app) {
12
- throw new Error(`App Experience for ${id} not found`);
13
- }
14
- return app;
15
- }
16
- }
17
- exports.ClientAppStore = ClientAppStore;
@@ -1,2 +0,0 @@
1
- import { WidgetState } from '@headless-adminapp/core/experience/insights';
2
- export declare const WidgetContext: import("react").Context<import("../mutable").ContextValue<WidgetState<import("@headless-adminapp/core/schema").SchemaAttributes>>>;
package/widget/context.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WidgetContext = void 0;
4
- const mutable_1 = require("../mutable");
5
- exports.WidgetContext = (0, mutable_1.createContext)();
@@ -1,3 +0,0 @@
1
- import { WidgetState } from '@headless-adminapp/core/experience/insights';
2
- import { SchemaAttributes } from '@headless-adminapp/core/schema';
3
- export declare function useWidgetState<S extends SchemaAttributes = SchemaAttributes>(): WidgetState<S>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useWidgetState = useWidgetState;
4
- const mutable_1 = require("../../mutable");
5
- const context_1 = require("../context");
6
- function useWidgetState() {
7
- return (0, mutable_1.useContextSelector)(context_1.WidgetContext, (state) => state);
8
- }
package/widget/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { WidgetContext } from './context';
package/widget/index.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WidgetContext = void 0;
4
- var context_1 = require("./context");
5
- Object.defineProperty(exports, "WidgetContext", { enumerable: true, get: function () { return context_1.WidgetContext; } });