@headless-adminapp/app 1.4.17 → 1.4.18

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.
@@ -12,6 +12,7 @@ const context_1 = require("../../mutable/context");
12
12
  const context_2 = require("../context");
13
13
  const DataResolver_1 = require("./DataResolver");
14
14
  const transformViewColumns_1 = require("./transformViewColumns");
15
+ const useGridCellRangeResolver_1 = require("./useGridCellRangeResolver");
15
16
  function mergeInitialStateWithHistory(initialValue, historyState) {
16
17
  return {
17
18
  ...initialValue,
@@ -57,6 +58,7 @@ function DataGridProvider(props) {
57
58
  maxRecords: props.maxRecords,
58
59
  associated: props.associated,
59
60
  disabled: props.disabled ?? false,
61
+ cellSelectionRange: null,
60
62
  }, router.getState(historyKey)));
61
63
  (0, react_1.useEffect)(() => {
62
64
  function listener(state, prevState, changes) {
@@ -113,5 +115,6 @@ function DataGridProvider(props) {
113
115
  disabled: props.disabled ?? false,
114
116
  });
115
117
  }, [props.disabled, contextValue]);
118
+ (0, useGridCellRangeResolver_1.useGridCellRangeResolver)(contextValue);
116
119
  return ((0, jsx_runtime_1.jsxs)(context_2.GridContext.Provider, { value: contextValue, children: [(0, jsx_runtime_1.jsx)(DataResolver_1.DataResolver, {}), props.children] }));
117
120
  }
@@ -0,0 +1,5 @@
1
+ import { MutableValue } from '@headless-adminapp/app/mutable';
2
+ import { EntityMainGridCommandContext, EntitySubGridCommandContext } from '@headless-adminapp/core/experience/view';
3
+ import { SchemaAttributes } from '@headless-adminapp/core/schema';
4
+ import { GridContextState } from '../context';
5
+ export declare function useGridCellRangeResolver<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext>(context: MutableValue<GridContextState<S, CommandContext>>): void;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGridCellRangeResolver = useGridCellRangeResolver;
4
+ const mutable_1 = require("@headless-adminapp/app/mutable");
5
+ const react_1 = require("react");
6
+ function useGridCellRangeResolver(context) {
7
+ const data = (0, mutable_1.useMutableStateSelector)(context, (state) => state.data);
8
+ (0, react_1.useEffect)(() => {
9
+ const handleMouseUp = () => {
10
+ if (context.value.current.cellSelectionRange?.active) {
11
+ context.setValue({
12
+ cellSelectionRange: {
13
+ ...context.value.current.cellSelectionRange,
14
+ active: false,
15
+ },
16
+ });
17
+ }
18
+ };
19
+ document.addEventListener('mouseup', handleMouseUp);
20
+ return () => {
21
+ document.removeEventListener('mouseup', handleMouseUp);
22
+ };
23
+ }, [context]);
24
+ (0, react_1.useEffect)(() => {
25
+ context.setValue({
26
+ cellSelectionRange: null,
27
+ });
28
+ }, [data, context]);
29
+ }
@@ -25,6 +25,7 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
25
25
  sorting: SortingState<S>;
26
26
  quickFilterValues: Record<string, unknown>;
27
27
  selectedIds: string[];
28
+ cellSelectionRange?: CellSelectionRange | null;
28
29
  data: RetriveRecordsResult<InferredSchemaType<S>> | null;
29
30
  dataState: {
30
31
  isFetching: boolean;
@@ -36,3 +37,14 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
36
37
  allowViewSelection: boolean;
37
38
  }
38
39
  export declare const GridContext: import("react").Context<import("../mutable/context").ContextValue<GridContextState<SchemaAttributes, EntityMainGridCommandContext>>>;
40
+ export interface CellSelectionRange {
41
+ start: {
42
+ row: number;
43
+ column: number;
44
+ };
45
+ end: {
46
+ row: number;
47
+ column: number;
48
+ };
49
+ active: boolean;
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "1.4.17",
3
+ "version": "1.4.18",
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": "a5a471cce4df9e87552b23e3de8c90d53e4adf43"
41
+ "gitHead": "802e32306b195f91185aa52a2fec6c49af42c29b"
42
42
  }
@@ -7,7 +7,7 @@ const react_1 = require("react");
7
7
  const context_1 = require("./context");
8
8
  const defaultRouteResolver = (0, route_1.createRouteResolver)(route_1.defaultRouteInfo);
9
9
  const defaultIsRouteActive = (0, route_1.createIsRouteActive)(route_1.defaultRouteInfo);
10
- const RouteProvider = ({ children, pathname, router, searchParams, basePath, routeResolver = defaultRouteResolver, isRouteActive = defaultIsRouteActive, }) => {
10
+ const RouteProvider = ({ children, pathname, router, searchParams, basePath = '', routeResolver = defaultRouteResolver, isRouteActive = defaultIsRouteActive, }) => {
11
11
  const basePathRef = (0, react_1.useRef)(basePath);
12
12
  basePathRef.current = basePath;
13
13
  const routeResolverRef = (0, react_1.useRef)(routeResolver);
@@ -19,7 +19,7 @@ export interface RouterInstance {
19
19
  export declare const RouterContext: import("react").Context<RouterInstance>;
20
20
  export declare const RouterPathnameContext: import("react").Context<string>;
21
21
  export declare const RouterSearchParamsContext: import("react").Context<ReadonlyURLSearchParams>;
22
- export declare const RouterBasePathContext: import("react").Context<string | undefined>;
22
+ export declare const RouterBasePathContext: import("react").Context<string>;
23
23
  export interface RouteHelperContext {
24
24
  routeResolver: InternalRouteResolver;
25
25
  isRouteActive: InternalIsRouteActive;
package/route/context.js CHANGED
@@ -5,5 +5,5 @@ const react_1 = require("react");
5
5
  exports.RouterContext = (0, react_1.createContext)(null);
6
6
  exports.RouterPathnameContext = (0, react_1.createContext)(null);
7
7
  exports.RouterSearchParamsContext = (0, react_1.createContext)(null);
8
- exports.RouterBasePathContext = (0, react_1.createContext)(undefined);
8
+ exports.RouterBasePathContext = (0, react_1.createContext)('');
9
9
  exports.RouteHelperContext = (0, react_1.createContext)(null);
@@ -1 +1 @@
1
- export declare function useBasePath(): string | undefined;
1
+ export declare function useBasePath(): string;