@headless-adminapp/app 1.5.2 → 1.5.5

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.
package/board/types.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface BoardConfig<S extends SchemaAttributes = SchemaAttributes> {
38
38
  title: string;
39
39
  description: string;
40
40
  schema: Schema<S>;
41
- sorting: SortingState<S>;
41
+ sorting: SortingState<Extract<keyof S, string>>;
42
42
  projection: {
43
43
  columns: Array<keyof S>;
44
44
  expand?: Partial<Record<keyof S, string[]>>;
@@ -1,4 +1,5 @@
1
1
  import type { EntityMainGridCommandContext, EntityMainGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
2
+ import type { SchemaAttributes } from '@headless-adminapp/core/schema';
2
3
  import type { Localized } from '@headless-adminapp/core/types';
3
4
  import type { Icon } from '@headless-adminapp/icons';
4
5
  export declare namespace EnabledRules {
@@ -79,7 +80,7 @@ export declare namespace ViewCommandBuilder {
79
80
  };
80
81
  }): EntityMainGridCommandItemExperience;
81
82
  }
82
- export declare function exportRecordsToExcel(context: EntityMainGridCommandContext): Promise<void>;
83
+ export declare function exportRecordsToExcel<S extends SchemaAttributes = SchemaAttributes>(context: EntityMainGridCommandContext<S>): Promise<void>;
83
84
  export declare function exportRecordsToCSV(context: EntityMainGridCommandContext): Promise<void>;
84
85
  export declare function processDeleteRecordRequest(context: EntityMainGridCommandContext, { stringSet, localizedStringSet, }: {
85
86
  stringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
@@ -1,6 +1,6 @@
1
1
  import type { Locale } from '@headless-adminapp/core/experience/locale';
2
2
  import type { ColumnCondition, SortingState, View } from '@headless-adminapp/core/experience/view';
3
- import type { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
3
+ import type { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
4
4
  import type { ISchemaStore } from '@headless-adminapp/core/store';
5
5
  import type { Filter, IDataService } from '@headless-adminapp/core/transport';
6
6
  import type { TransformedViewColumn } from '../datagrid';
@@ -24,7 +24,7 @@ export declare function retriveRecords<S extends SchemaAttributes = SchemaAttrib
24
24
  extraFilter?: Filter;
25
25
  columnFilters?: Partial<Record<string, ColumnCondition>>;
26
26
  schemaStore: ISchemaStore;
27
- sorting: SortingState<S>;
27
+ sorting: SortingState<Extract<keyof S, string>>;
28
28
  skip: number;
29
29
  limit: number;
30
- }): Promise<import("@headless-adminapp/core/transport").RetriveRecordsResult<InferredSchemaType<S>>>;
30
+ }): Promise<import("@headless-adminapp/core/transport").RetriveRecordsResult<S>>;
package/builders/utils.js CHANGED
@@ -177,7 +177,6 @@ async function retriveRecords({ gridColumns, dataService, schema, search, view,
177
177
  columnFilters, schemaStore),
178
178
  skip,
179
179
  limit,
180
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
181
180
  sort: sorting,
182
181
  });
183
182
  return result;
@@ -148,9 +148,17 @@ async function updateRecord({ recordId, values, form, schema, dataService, initi
148
148
  async function saveRecord({ values, form, schema, dataService, initialValues, record, schemaStore, }) {
149
149
  let recordId;
150
150
  if (record) {
151
- recordId = record[schema.idAttribute];
151
+ const idAttributeValue = record[schema.idAttribute];
152
+ if (typeof idAttributeValue === 'object' &&
153
+ idAttributeValue !== null &&
154
+ 'id' in idAttributeValue) {
155
+ recordId = idAttributeValue.id;
156
+ }
157
+ else {
158
+ recordId = idAttributeValue;
159
+ }
152
160
  const updateResult = await updateRecord({
153
- recordId,
161
+ recordId: recordId,
154
162
  values,
155
163
  form,
156
164
  schema,
@@ -4,7 +4,7 @@ import type { EntityMainGridCommandContext, EntitySubGridCommandContext, View }
4
4
  import type { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
5
5
  import type { Filter } from '@headless-adminapp/core/transport';
6
6
  import { type PropsWithChildren } from 'react';
7
- export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext> {
7
+ export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>> {
8
8
  schema: Schema<S>;
9
9
  views: LocalizedDataLookup[];
10
10
  view: View<S>;
@@ -21,4 +21,4 @@ export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttrib
21
21
  maxRecords?: number;
22
22
  disabled?: boolean;
23
23
  }
24
- export declare function DataGridProvider<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext>(props: PropsWithChildren<DataGridProviderProps<S, CommandContext>>): import("react/jsx-runtime").JSX.Element;
24
+ export declare function DataGridProvider<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>>(props: PropsWithChildren<DataGridProviderProps<S, CommandContext>>): import("react/jsx-runtime").JSX.Element;
@@ -2,4 +2,4 @@ import { type MutableValue } from '@headless-adminapp/app/mutable';
2
2
  import type { EntityMainGridCommandContext, EntitySubGridCommandContext } from '@headless-adminapp/core/experience/view';
3
3
  import type { SchemaAttributes } from '@headless-adminapp/core/schema';
4
4
  import type { GridContextState } from '../context';
5
- export declare function useGridCellRangeResolver<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext>(context: MutableValue<GridContextState<S, CommandContext>>): void;
5
+ export declare function useGridCellRangeResolver<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>>(context: MutableValue<GridContextState<S, CommandContext>>): void;
@@ -5,7 +5,7 @@ import { type TransformedViewColumn } from '@headless-adminapp/core/experience/v
5
5
  import type { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
6
6
  import type { Filter, RetriveRecordsResult } from '@headless-adminapp/core/transport';
7
7
  export { type TransformedViewColumn } from '@headless-adminapp/core/experience/view/ViewColumn';
8
- export interface GridContextState<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext> {
8
+ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>> {
9
9
  schema: Schema<S>;
10
10
  view: View<S>;
11
11
  viewLookup: LocalizedDataLookup[];
@@ -22,7 +22,7 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
22
22
  columns: TransformedViewColumn<S>[];
23
23
  searchText: string;
24
24
  columnFilters: Partial<Record<keyof S, ColumnCondition>>;
25
- sorting: SortingState<S>;
25
+ sorting: SortingState<Extract<keyof S, string>>;
26
26
  quickFilterValues: Record<string, unknown>;
27
27
  selectedIds: string[];
28
28
  cellSelectionRange?: CellSelectionRange | null;
@@ -36,7 +36,7 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
36
36
  isSubGrid: boolean;
37
37
  allowViewSelection: boolean;
38
38
  }
39
- export declare const GridContext: import("react").Context<import("../mutable/context").ContextValue<GridContextState<SchemaAttributes, EntityMainGridCommandContext>>>;
39
+ export declare const GridContext: import("react").Context<import("../mutable/context").ContextValue<GridContextState<SchemaAttributes, EntityMainGridCommandContext<SchemaAttributes>>>>;
40
40
  export interface CellSelectionRange {
41
41
  start: {
42
42
  row: number;
@@ -1,3 +1,3 @@
1
1
  import type { SortingState } from '@headless-adminapp/core/experience/view';
2
2
  import type { SchemaAttributes } from '@headless-adminapp/core/schema';
3
- export declare function useGridSorting<S extends SchemaAttributes = SchemaAttributes>(): readonly [SortingState<SchemaAttributes>, (value: SortingState<S>) => void];
3
+ export declare function useGridSorting<S extends SchemaAttributes = SchemaAttributes>(): readonly [SortingState<Extract<keyof S, string>>, (value: SortingState<Extract<keyof S, string>>) => void];
@@ -8,7 +8,6 @@ function useGridSorting() {
8
8
  const sorting = (0, context_1.useContextSelector)(context_2.GridContext, (state) => state.sorting);
9
9
  const setValue = (0, context_1.useContextSetValue)(context_2.GridContext);
10
10
  const setSorting = (0, react_1.useCallback)((value) => {
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
11
  setValue({ sorting: value });
13
12
  }, [setValue]);
14
13
  return [sorting, setSorting];
@@ -1,7 +1,8 @@
1
1
  import type { EntityMainGridCommandContext } from '@headless-adminapp/core/experience/view';
2
+ import type { SchemaAttributes } from '@headless-adminapp/core/schema';
2
3
  import type { CommandItemState, MenuItemCommandState, UtilityContextState } from '../../command/types';
3
4
  export declare function useUtility(): UtilityContextState;
4
- export declare function useGridControlContext(): EntityMainGridCommandContext['primaryControl'];
5
- export declare function useMainGridCommandHandlerContext(): EntityMainGridCommandContext;
5
+ export declare function useGridControlContext<S extends SchemaAttributes = SchemaAttributes>(): EntityMainGridCommandContext<S>['primaryControl'];
6
+ export declare function useMainGridCommandHandlerContext<S extends SchemaAttributes = SchemaAttributes>(): EntityMainGridCommandContext<S>;
6
7
  export declare function useMainGridCommands(): CommandItemState[][];
7
8
  export declare function useMainGridContextCommands(): MenuItemCommandState[][];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "1.5.2",
3
+ "version": "1.5.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -38,5 +38,5 @@
38
38
  "uuid": "11.0.3",
39
39
  "yup": "^1.4.0"
40
40
  },
41
- "gitHead": "42d358877a1744b855966feb6d85fcbb7c3c8dae"
41
+ "gitHead": "be617f4ad13130c9fcfa7760857c062fa896de39"
42
42
  }
@@ -6,7 +6,7 @@ interface UseRetriveRecordProps<S extends SchemaAttributes = SchemaAttributes> {
6
6
  schema: Schema<S>;
7
7
  search?: string;
8
8
  filter?: Filter | null;
9
- sorting?: SortingState<S>;
9
+ sorting?: SortingState<Extract<keyof S, string>>;
10
10
  columns: (keyof S)[];
11
11
  expand?: Partial<Record<string, string[]>>;
12
12
  maxRecords?: number;