Skip to content

Commit

Permalink
Cleanup dataMap placement and imports (#8709)
Browse files Browse the repository at this point in the history
* #8704 - Moves './src/dataMap.js' into './src/dataMap' directory. Adjusts paths in unit tests and mentions in comments.

* #8704 - Adds the changelog file

* Apply suggestions from code review

Co-authored-by: Krzysztof Budnik <571316+budnix@users.noreply.github.com>

* Adjusts imports order

Co-authored-by: Krzysztof Budnik <571316+budnix@users.noreply.github.com>
  • Loading branch information
mrpiotr-dev and budnix committed Sep 10, 2021
1 parent a5e560c commit 58589de
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 63 deletions.
7 changes: 7 additions & 0 deletions .changelogs/8704.json
@@ -0,0 +1,7 @@
{
"title": "Adjusted directories and files related to `dataMap` to prevent potential circular references.",
"type": "fixed",
"issue": 8704,
"breaking": false,
"framework": "none"
}
2 changes: 1 addition & 1 deletion src/core.js
Expand Up @@ -34,7 +34,7 @@ import {
stopObserving as keyStateStopObserving
} from './utils/keyStateObserver';
import { Selection } from './selection';
import { MetaManager, DynamicCellMetaMod, DataMap } from './dataMap/index';
import { MetaManager, DynamicCellMetaMod, DataMap } from './dataMap';
import { createUniqueMap } from './utils/dataStructures/uniqueMap';

let activeGuid = null;
Expand Down
12 changes: 6 additions & 6 deletions src/dataMap.js → src/dataMap/dataMap.js
@@ -1,8 +1,8 @@
import { stringify } from './3rdparty/SheetClip';
import { stringify } from '../3rdparty/SheetClip';
import {
cellMethodLookupFactory,
countFirstRowKeys
} from './helpers/data';
} from '../helpers/data';
import {
createObjectPropListener,
deepClone,
Expand All @@ -12,10 +12,10 @@ import {
hasOwnProperty,
isObject,
objectEach
} from './helpers/object';
import { extendArray, to2dArray } from './helpers/array';
import { rangeEach } from './helpers/number';
import { isDefined } from './helpers/mixed';
} from '../helpers/object';
import { extendArray, to2dArray } from '../helpers/array';
import { rangeEach } from '../helpers/number';
import { isDefined } from '../helpers/mixed';

const copyableLookup = cellMethodLookupFactory('copyable', false);

Expand Down
2 changes: 1 addition & 1 deletion src/dataMap/index.js
@@ -1,4 +1,4 @@
import DataMap from '../dataMap';
import DataMap from './dataMap';
import MetaManager from './metaManager';
import metaSchemaFactory from './metaManager/metaSchema';
import { DynamicCellMetaMod } from './metaManager/mods/dynamicCellMeta';
Expand Down
2 changes: 1 addition & 1 deletion src/dataMap/metaManager/__tests__/lazyFactoryMap.unit.js
@@ -1,6 +1,6 @@
/* eslint-disable no-sparse-arrays */
/* eslint-disable comma-spacing */
import LazyFactoryMap from 'handsontable/dataMap/metaManager/lazyFactoryMap';
import LazyFactoryMap from '../lazyFactoryMap';

function createLazyFactoryMap(valueFactory) {
if (!valueFactory) {
Expand Down
10 changes: 5 additions & 5 deletions src/dataMap/metaManager/__tests__/metaManager.unit.js
@@ -1,8 +1,8 @@
import MetaManager from 'handsontable/dataMap/metaManager';
import GlobalMeta from 'handsontable/dataMap/metaManager/metaLayers/globalMeta';
import TableMeta from 'handsontable/dataMap/metaManager/metaLayers/tableMeta';
import ColumnMeta from 'handsontable/dataMap/metaManager/metaLayers/columnMeta';
import CellMeta from 'handsontable/dataMap/metaManager/metaLayers/cellMeta';
import MetaManager from '../';
import GlobalMeta from '../metaLayers/globalMeta';
import TableMeta from '../metaLayers/tableMeta';
import ColumnMeta from '../metaLayers/columnMeta';
import CellMeta from '../metaLayers/cellMeta';

describe('MetaManager', () => {
it('should instantiate the mod class with proper list of arguments', () => {
Expand Down
46 changes: 24 additions & 22 deletions src/dataMap/metaManager/__tests__/utils.unit.js
Expand Up @@ -3,28 +3,30 @@ import {
columnFactory,
isUnsignedNumber,
assert,
isNullish
} from 'handsontable/dataMap/metaManager/utils';
import { registerCellType } from 'handsontable/cellTypes';
import { CELL_TYPE as AUTOCOMPLETE, AutocompleteCellType } from 'handsontable/cellTypes/autocompleteType';
import { CELL_TYPE as CHECKBOX, CheckboxCellType } from 'handsontable/cellTypes/checkboxType';
import { CELL_TYPE as DATE, DateCellType } from 'handsontable/cellTypes/dateType';
import { CELL_TYPE as DROPDOWN, DropdownCellType } from 'handsontable/cellTypes/dropdownType';
import { CELL_TYPE as HANDSONTABLE, HandsontableCellType } from 'handsontable/cellTypes/handsontableType';
import { CELL_TYPE as NUMERIC, NumericCellType } from 'handsontable/cellTypes/numericType';
import { CELL_TYPE as PASSWORD, PasswordCellType } from 'handsontable/cellTypes/passwordType';
import { CELL_TYPE as TEXT, TextCellType } from 'handsontable/cellTypes/textType';
import { CELL_TYPE as TIME, TimeCellType } from 'handsontable/cellTypes/timeType';

registerCellType(AUTOCOMPLETE, AutocompleteCellType);
registerCellType(CHECKBOX, CheckboxCellType);
registerCellType(DATE, DateCellType);
registerCellType(DROPDOWN, DropdownCellType);
registerCellType(HANDSONTABLE, HandsontableCellType);
registerCellType(NUMERIC, NumericCellType);
registerCellType(PASSWORD, PasswordCellType);
registerCellType(TEXT, TextCellType);
registerCellType(TIME, TimeCellType);
isNullish,
} from '../utils';
import {
registerCellType,
AutocompleteCellType,
CheckboxCellType,
DateCellType,
DropdownCellType,
HandsontableCellType,
NumericCellType,
PasswordCellType,
TextCellType,
TimeCellType,
} from '../../../cellTypes';

registerCellType(AutocompleteCellType);
registerCellType(CheckboxCellType);
registerCellType(DateCellType);
registerCellType(DropdownCellType);
registerCellType(HandsontableCellType);
registerCellType(NumericCellType);
registerCellType(PasswordCellType);
registerCellType(TextCellType);
registerCellType(TimeCellType);

describe('MetaManager utils', () => {
describe('expandMetaType', () => {
Expand Down
11 changes: 5 additions & 6 deletions src/dataMap/metaManager/metaLayers/__tests__/cellMeta.unit.js
@@ -1,10 +1,9 @@
import GlobalMeta from 'handsontable/dataMap/metaManager/metaLayers/globalMeta';
import ColumnMeta from 'handsontable/dataMap/metaManager/metaLayers/columnMeta';
import CellMeta from 'handsontable/dataMap/metaManager/metaLayers/cellMeta';
import { registerCellType } from 'handsontable/cellTypes';
import { CELL_TYPE, TextCellType } from 'handsontable/cellTypes/textType';
import GlobalMeta from '../globalMeta';
import ColumnMeta from '../columnMeta';
import CellMeta from '../cellMeta';
import { registerCellType, TextCellType } from '../../../../cellTypes';

registerCellType(CELL_TYPE, TextCellType);
registerCellType(TextCellType);

describe('ColumnMeta', () => {
it('should reflect the changes in the cell meta when the global meta properties were changed', () => {
Expand Down
@@ -1,9 +1,8 @@
import GlobalMeta from 'handsontable/dataMap/metaManager/metaLayers/globalMeta';
import ColumnMeta from 'handsontable/dataMap/metaManager/metaLayers/columnMeta';
import { registerCellType } from 'handsontable/cellTypes';
import { CELL_TYPE, TextCellType } from 'handsontable/cellTypes/textType';
import GlobalMeta from '../globalMeta';
import ColumnMeta from '../columnMeta';
import { registerCellType, TextCellType } from '../../../../cellTypes';

registerCellType(CELL_TYPE, TextCellType);
registerCellType(TextCellType);

describe('ColumnMeta', () => {
it('should reflect the changes in column meta when the global meta properties were changed', () => {
Expand Down
@@ -1,8 +1,7 @@
import GlobalMeta from 'handsontable/dataMap/metaManager/metaLayers/globalMeta';
import { registerCellType } from 'handsontable/cellTypes';
import { CELL_TYPE, TextCellType } from 'handsontable/cellTypes/textType';
import GlobalMeta from '../globalMeta';
import { registerCellType, TextCellType } from '../../../../cellTypes';

registerCellType(CELL_TYPE, TextCellType);
registerCellType(TextCellType);

describe('GlobalMeta', () => {
it('should construct class with prepared meta object', () => {
Expand Down
@@ -1,9 +1,8 @@
import GlobalMeta from 'handsontable/dataMap/metaManager/metaLayers/globalMeta';
import TableMeta from 'handsontable/dataMap/metaManager/metaLayers/tableMeta';
import { registerCellType } from 'handsontable/cellTypes';
import { CELL_TYPE, TextCellType } from 'handsontable/cellTypes/textType';
import GlobalMeta from '../globalMeta';
import TableMeta from '../tableMeta';
import { registerCellType, TextCellType } from '../../../../cellTypes';

registerCellType(CELL_TYPE, TextCellType);
registerCellType(TextCellType);

describe('TableMeta', () => {
it('should construct class with prepared meta object', () => {
Expand Down
@@ -1,7 +1,7 @@
import { DynamicCellMetaMod } from 'handsontable/dataMap/metaManager/mods/dynamicCellMeta';
import MetaManager from 'handsontable/dataMap/metaManager';
import Handsontable from 'handsontable';
import Hooks from 'handsontable/pluginHooks';
import { DynamicCellMetaMod } from '../dynamicCellMeta';
import MetaManager from '../../';
import Hooks from '../../../../pluginHooks';

jest.mock('handsontable');

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -2,7 +2,7 @@ import Handsontable from './base';
import EventManager, { getListenersCounter } from './eventManager';
import { getRegisteredMapsCounter } from './translations';
import Hooks from './pluginHooks';
import { metaSchemaFactory } from './dataMap/index';
import { metaSchemaFactory } from './dataMap';

import jQueryWrapper from './helpers/wrappers/jquery';

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/formulas/formulas.js
Expand Up @@ -593,7 +593,7 @@ export class Formulas extends BasePlugin {
return;
}

// `column` is here as visual index because of inconsistencies related to hook execution in `src/dataMap`.
// `column` is here as visual index because of inconsistencies related to hook execution in `DataMap`.
const isFormulaCellType = this.isFormulaCellType(this.hot.toVisualRow(row), column);

if (!isFormulaCellType) {
Expand All @@ -604,7 +604,7 @@ export class Formulas extends BasePlugin {
return;
}

// `toPhysicalColumn` is here because of inconsistencies related to hook execution in `src/dataMap`.
// `toPhysicalColumn` is here because of inconsistencies related to hook execution in `DataMap`.
const address = {
row,
col: this.toPhysicalColumnPosition(column),
Expand Down Expand Up @@ -640,7 +640,7 @@ export class Formulas extends BasePlugin {

const visualColumn = this.hot.propToCol(columnOrProp);

// `column` is here as visual index because of inconsistencies related to hook execution in `src/dataMap`.
// `column` is here as visual index because of inconsistencies related to hook execution in `DataMap`.
const isFormulaCellType = this.isFormulaCellType(this.hot.toVisualRow(row), visualColumn);

if (!isFormulaCellType) {
Expand Down

0 comments on commit 58589de

Please sign in to comment.