@gravity-ui/dashkit 10.4.2 → 10.4.4

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.
@@ -20,16 +20,16 @@ jest.mock('../../GridLayout/GridLayout', () => {
20
20
  });
21
21
  import React from 'react';
22
22
  import { act, render } from '@testing-library/react';
23
- import { DashKitContext } from "../../../context/index.js";
23
+ import { DashKitContext, DashkitOverlayControlsContext } from "../../../context/index.js";
24
24
  import { withContext } from "../../../hocs/withContext.js";
25
25
  import { RegisterManager } from "../../../utils/index.js";
26
26
  import { DashKit, _emitSymbol } from "../DashKit.js";
27
27
  const PLUGIN_TYPE = 'controlled-layout-test';
28
- const createConfig = (x) => ({
28
+ const createConfig = (x, itemIds = ['item1']) => ({
29
29
  salt: 'test',
30
30
  counter: 1,
31
- items: [{ id: 'item1', type: PLUGIN_TYPE, namespace: 'default', data: {} }],
32
- layout: [{ i: 'item1', x, y: 0, w: 2, h: 2 }],
31
+ items: itemIds.map((id) => ({ id, type: PLUGIN_TYPE, namespace: 'default', data: {} })),
32
+ layout: itemIds.map((i) => ({ i, x, y: 0, w: 2, h: 2 })),
33
33
  aliases: {},
34
34
  connections: [],
35
35
  });
@@ -63,14 +63,78 @@ const createProps = ({ config, emitDashKitEvent, onChange = jest.fn(), }) => {
63
63
  };
64
64
  };
65
65
  let captured = {};
66
+ let capturedControlsContext;
67
+ let renderedItemIds = [];
68
+ let layoutEffectAction;
66
69
  const ContextCapture = () => {
67
- captured = React.useContext(DashKitContext);
70
+ const dashkitContext = React.useContext(DashKitContext);
71
+ const controlsContext = React.useContext(DashkitOverlayControlsContext);
72
+ captured = dashkitContext;
73
+ capturedControlsContext = controlsContext || undefined;
74
+ renderedItemIds.push({
75
+ config: captured.configItems.map(({ id }) => id),
76
+ layout: captured.layout.map(({ i }) => i),
77
+ });
78
+ React.useLayoutEffect(() => {
79
+ layoutEffectAction === null || layoutEffectAction === void 0 ? void 0 : layoutEffectAction(dashkitContext, controlsContext || undefined);
80
+ }, [controlsContext, dashkitContext]);
68
81
  return null;
69
82
  };
70
83
  const TestComponent = withContext(ContextCapture);
71
84
  describe('DashKit controlled layout strategy', () => {
72
85
  beforeEach(() => {
73
86
  captured = {};
87
+ capturedControlsContext = undefined;
88
+ renderedItemIds = [];
89
+ layoutEffectAction = undefined;
90
+ });
91
+ it('updates visual layout in same render as externally added config item', () => {
92
+ const initialConfig = createConfig(0);
93
+ const externalConfig = createConfig(3, ['item1', 'item2']);
94
+ const dashkit = new DashKit(DashKit.defaultProps);
95
+ const { rerender } = render(React.createElement(TestComponent, Object.assign({}, createProps({ config: initialConfig, emitDashKitEvent: dashkit[_emitSymbol] }))));
96
+ act(() => {
97
+ rerender(React.createElement(TestComponent, Object.assign({}, createProps({
98
+ config: externalConfig,
99
+ emitDashKitEvent: dashkit[_emitSymbol],
100
+ }))));
101
+ });
102
+ expect(renderedItemIds).toEqual(expect.arrayContaining([
103
+ { config: ['item1'], layout: ['item1'] },
104
+ { config: ['item1', 'item2'], layout: ['item1', 'item2'] },
105
+ ]));
106
+ expect(renderedItemIds.every(({ config, layout }) => config.join(',') === layout.join(','))).toBe(true);
107
+ });
108
+ it('uses external baseline in child layout effect', () => {
109
+ const initialConfig = createConfig(0);
110
+ const externalConfig = createConfig(3, ['item1', 'item2']);
111
+ const nextLayout = [
112
+ { i: 'item1', x: 4, y: 0, w: 2, h: 2 },
113
+ externalConfig.layout[1],
114
+ ];
115
+ const dashkit = new DashKit(DashKit.defaultProps);
116
+ const onEventChange = jest.fn();
117
+ let layoutItemInLayoutEffect;
118
+ let layoutItemAfterLayoutChange;
119
+ dashkit.on('change', onEventChange);
120
+ const { rerender } = render(React.createElement(TestComponent, Object.assign({}, createProps({ config: initialConfig, emitDashKitEvent: dashkit[_emitSymbol] }))));
121
+ layoutEffectAction = (dashkitContext, controlsContext) => {
122
+ layoutEffectAction = undefined;
123
+ layoutItemInLayoutEffect = (controlsContext === null || controlsContext === void 0 ? void 0 : controlsContext.getLayoutItem('item2')) || undefined;
124
+ dashkitContext.layoutChange(nextLayout);
125
+ layoutItemAfterLayoutChange = (controlsContext === null || controlsContext === void 0 ? void 0 : controlsContext.getLayoutItem('item1')) || undefined;
126
+ };
127
+ act(() => {
128
+ rerender(React.createElement(TestComponent, Object.assign({}, createProps({
129
+ config: externalConfig,
130
+ emitDashKitEvent: dashkit[_emitSymbol],
131
+ }))));
132
+ });
133
+ expect(layoutItemInLayoutEffect).toMatchObject(externalConfig.layout[1]);
134
+ expect(onEventChange).toHaveBeenCalledTimes(1);
135
+ expect(onEventChange.mock.calls[0][0].previousLayout).toMatchObject(externalConfig.layout);
136
+ expect(layoutItemAfterLayoutChange).toMatchObject(nextLayout[0]);
137
+ expect(capturedControlsContext === null || capturedControlsContext === void 0 ? void 0 : capturedControlsContext.getLayoutItem('item1')).toMatchObject(nextLayout[0]);
74
138
  });
75
139
  it('Case 1: keeps internal layout after change event without config update, then applies external config update', () => {
76
140
  const initialConfig = createConfig(0);
@@ -1 +1 @@
1
- {"version":3,"file":"controlled-layout.test.js","sourceRoot":"../../../../../src","sources":["components/DashKit/__tests__/controlled-layout.test.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;IAClC,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACjB,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC,OAAO;QACH,MAAM,EAAE,CAAC,EAAC,QAAQ,EAAuB,EAAE,EAAE,CACzC,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC;QACrD,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI;QACxB,IAAI,EAAE,GAAG,EAAE,CAA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CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEtE,gDAAgD;QAChD,GAAG,CAAC,GAAG,EAAE;YACL,QAAQ,CACJ,oBAAC,aAAa,oBACN,WAAW,CAAC;gBACZ,MAAM,EAAE,OAAO;gBACf,gBAAgB,EAAE,OAAO,CAAC,WAAW,CAAC;gBACtC,QAAQ;aACX,CAAC,EACJ,CACL,CAAC;QACN,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/**\n * @jest-environment jsdom\n */\n\njest.mock('@gravity-ui/icons', () => ({\n Ellipsis: 'ellipsis',\n Gear: 'gear',\n Xmark: 'xmark',\n}));\n\njest.mock('@gravity-ui/uikit', () => {\n const ReactMock = require('react');\n\n return {\n Button: ({children}: {children?: unknown}) =>\n ReactMock.createElement('button', null, children),\n DropdownMenu: () => null,\n Icon: () => null,\n };\n});\n\njest.mock('../../GridLayout/GridLayout', () => {\n const ReactMock = require('react');\n\n return ReactMock.forwardRef(() => null);\n});\n\nimport React from 'react';\n\nimport {act, render} from '@testing-library/react';\n\nimport {DashKitContext, type DashKitCtxShape} from '../../../context';\nimport {type DashKitWithContextProps, withContext} from '../../../hocs/withContext';\nimport type {Config} from '../../../shared';\nimport {RegisterManager} from '../../../utils';\nimport {DashKit, _emitSymbol} from '../DashKit';\n\nconst PLUGIN_TYPE = 'controlled-layout-test';\n\nconst createConfig = (x: number): Config => ({\n salt: 'test',\n counter: 1,\n items: [{id: 'item1', type: PLUGIN_TYPE, namespace: 'default', data: {}}],\n layout: [{i: 'item1', x, y: 0, w: 2, h: 2}],\n aliases: {},\n connections: [],\n});\n\nconst createProps = ({\n config,\n emitDashKitEvent,\n onChange = jest.fn(),\n}: {\n config: Config;\n emitDashKitEvent: DashKitWithContextProps['emitDashKitEvent'];\n onChange?: jest.Mock;\n}) => {\n const registerManager = new RegisterManager();\n registerManager.registerPlugin({\n type: PLUGIN_TYPE,\n defaultLayout: {x: 0, y: 0, w: 2, h: 2},\n renderer: () => null,\n });\n\n return {\n config,\n editMode: true,\n layout: config.layout,\n registerManager,\n forwardedMetaRef: React.createRef(),\n emitDashKitEvent,\n itemsStateAndParams: {},\n defaultGlobalParams: {},\n globalParams: {},\n context: {},\n settings: {\n autoupdateInterval: 0,\n silentLoading: false,\n },\n noOverlay: false,\n focusable: false,\n onItemEdit: jest.fn(),\n onChange,\n onDrop: jest.fn(),\n };\n};\n\nlet captured: DashKitCtxShape = {} as DashKitCtxShape;\n\nconst ContextCapture = () => {\n captured = React.useContext(DashKitContext);\n return null;\n};\n\nconst TestComponent = withContext(ContextCapture);\n\ndescribe('DashKit controlled layout strategy', () => {\n beforeEach(() => {\n captured = {} as DashKitCtxShape;\n });\n\n it('Case 1: keeps internal layout after change event without config update, then applies external config update', () => {\n const initialConfig = createConfig(0);\n const nextInternalLayout: Config['layout'] = [{i: 'item1', x: 1, y: 0, w: 2, h: 2}];\n const externalConfig = createConfig(3);\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n const onChange = jest.fn();\n const onEventChange = jest.fn();\n\n dashkit.on('change', onEventChange);\n\n const {rerender} = render(\n <TestComponent\n {...createProps({\n config: initialConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n\n // Layout is now enriched with plugin defaults (minW, minH, etc)\n expect(captured.layout).toMatchObject(initialConfig.layout);\n expect(captured.layout[0]).toHaveProperty('minW');\n expect(captured.layout[0]).toHaveProperty('minH');\n\n act(() => {\n captured.layoutChange(nextInternalLayout);\n });\n\n // Verify that change event was fired with correct layout\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(onEventChange.mock.calls[0][0].layout).toEqual(nextInternalLayout);\n expect(onChange).toHaveBeenCalledTimes(1);\n\n // Now apply external config update\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: externalConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n\n // External props should win and layout should be updated\n expect(captured.layout).toMatchObject(externalConfig.layout);\n });\n\n it('Case 2: uses on(change) without updating props - internal state persists', () => {\n const initialConfig = createConfig(0);\n const nextInternalLayout: Config['layout'] = [{i: 'item1', x: 5, y: 0, w: 2, h: 2}];\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n const onChange = jest.fn();\n const onEventChange = jest.fn();\n const capturedLayouts: Config['layout'][] = [];\n\n // Listen to change event but DON'T update props\n dashkit.on('change', (event) => {\n capturedLayouts.push(event.layout);\n onEventChange(event);\n });\n\n const {rerender} = render(\n <TestComponent\n {...createProps({\n config: initialConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n\n // Initial layout should be enriched\n expect(captured.layout).toMatchObject(initialConfig.layout);\n\n // Trigger layout change\n act(() => {\n captured.layoutChange(nextInternalLayout);\n });\n\n // Event should fire with new layout\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(capturedLayouts[0]).toEqual(nextInternalLayout);\n\n // onChange callback fires (consumer COULD update props here, but doesn't in this case)\n expect(onChange).toHaveBeenCalledTimes(1);\n\n // Props remain unchanged - simulating consumer NOT updating props\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: initialConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n\n // Layout should still reflect the change (internal state wins)\n // Note: we verify the event fired correctly\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(capturedLayouts[0]).toMatchObject(nextInternalLayout);\n });\n\n it('Case 3: alternates between props.layout updates and on(change) events', () => {\n const config1 = createConfig(0);\n const config2 = createConfig(2);\n const internalChange: Config['layout'] = [{i: 'item1', x: 5, y: 0, w: 2, h: 2}];\n const config3 = createConfig(8);\n\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n const onChange = jest.fn();\n const onEventChange = jest.fn();\n\n dashkit.on('change', onEventChange);\n\n const {rerender} = render(\n <TestComponent\n {...createProps({\n config: config1,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n\n // Start with config1\n expect(captured.layout).toMatchObject(config1.layout);\n\n // Update via props (external update)\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: config2,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n expect(captured.layout).toMatchObject(config2.layout);\n\n // Update via internal change (user drag)\n act(() => {\n captured.layoutChange(internalChange);\n });\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(onEventChange.mock.calls[0][0].layout).toEqual(internalChange);\n\n // Update via props again (external update wins)\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: config3,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n expect(captured.layout).toMatchObject(config3.layout);\n });\n});\n"]}
1
+ {"version":3,"file":"controlled-layout.test.js","sourceRoot":"../../../../../src","sources":["components/DashKit/__tests__/controlled-layout.test.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;IAClC,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACjB,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC,OAAO;QACH,MAAM,EAAE,CAAC,EAAC,QAAQ,EAAuB,EAAE,EAAE,CACzC,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,IA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,EAAE;YACL,QAAQ,CACJ,oBAAC,aAAa,oBACN,WAAW,CAAC;gBACZ,MAAM,EAAE,OAAO;gBACf,gBAAgB,EAAE,OAAO,CAAC,WAAW,CAAC;gBACtC,QAAQ;aACX,CAAC,EACJ,CACL,CAAC;QACN,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEtD,yCAAyC;QACzC,GAAG,CAAC,GAAG,EAAE;YACL,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,aAAa,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEtE,gDAAgD;QAChD,GAAG,CAAC,GAAG,EAAE;YACL,QAAQ,CACJ,oBAAC,aAAa,oBACN,WAAW,CAAC;gBACZ,MAAM,EAAE,OAAO;gBACf,gBAAgB,EAAE,OAAO,CAAC,WAAW,CAAC;gBACtC,QAAQ;aACX,CAAC,EACJ,CACL,CAAC;QACN,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/**\n * @jest-environment jsdom\n */\n\njest.mock('@gravity-ui/icons', () => ({\n Ellipsis: 'ellipsis',\n Gear: 'gear',\n Xmark: 'xmark',\n}));\n\njest.mock('@gravity-ui/uikit', () => {\n const ReactMock = require('react');\n\n return {\n Button: ({children}: {children?: unknown}) =>\n ReactMock.createElement('button', null, children),\n DropdownMenu: () => null,\n Icon: () => null,\n };\n});\n\njest.mock('../../GridLayout/GridLayout', () => {\n const ReactMock = require('react');\n\n return ReactMock.forwardRef(() => null);\n});\n\nimport React from 'react';\n\nimport {act, render} from '@testing-library/react';\n\nimport {DashKitContext, DashkitOverlayControlsContext} from '../../../context';\nimport type {DashKitCtxShape, OverlayControlsCtxShape} from '../../../context';\nimport {type DashKitWithContextProps, withContext} from '../../../hocs/withContext';\nimport type {Config} from '../../../shared';\nimport {RegisterManager} from '../../../utils';\nimport {DashKit, _emitSymbol} from '../DashKit';\n\nconst PLUGIN_TYPE = 'controlled-layout-test';\n\nconst createConfig = (x: number, itemIds = ['item1']): Config => ({\n salt: 'test',\n counter: 1,\n items: itemIds.map((id) => ({id, type: PLUGIN_TYPE, namespace: 'default', data: {}})),\n layout: itemIds.map((i) => ({i, x, y: 0, w: 2, h: 2})),\n aliases: {},\n connections: [],\n});\n\nconst createProps = ({\n config,\n emitDashKitEvent,\n onChange = jest.fn(),\n}: {\n config: Config;\n emitDashKitEvent: DashKitWithContextProps['emitDashKitEvent'];\n onChange?: jest.Mock;\n}) => {\n const registerManager = new RegisterManager();\n registerManager.registerPlugin({\n type: PLUGIN_TYPE,\n defaultLayout: {x: 0, y: 0, w: 2, h: 2},\n renderer: () => null,\n });\n\n return {\n config,\n editMode: true,\n layout: config.layout,\n registerManager,\n forwardedMetaRef: React.createRef(),\n emitDashKitEvent,\n itemsStateAndParams: {},\n defaultGlobalParams: {},\n globalParams: {},\n context: {},\n settings: {\n autoupdateInterval: 0,\n silentLoading: false,\n },\n noOverlay: false,\n focusable: false,\n onItemEdit: jest.fn(),\n onChange,\n onDrop: jest.fn(),\n };\n};\n\nlet captured: DashKitCtxShape = {} as DashKitCtxShape;\nlet capturedControlsContext: OverlayControlsCtxShape | undefined;\nlet renderedItemIds: Array<{config: string[]; layout: string[]}> = [];\nlet layoutEffectAction:\n | ((\n dashkitContext: DashKitCtxShape,\n controlsContext: OverlayControlsCtxShape | undefined,\n ) => void)\n | undefined;\n\nconst ContextCapture = () => {\n const dashkitContext = React.useContext(DashKitContext);\n const controlsContext = React.useContext(DashkitOverlayControlsContext);\n\n captured = dashkitContext;\n capturedControlsContext = controlsContext || undefined;\n renderedItemIds.push({\n config: captured.configItems.map(({id}) => id),\n layout: captured.layout.map(({i}) => i),\n });\n\n React.useLayoutEffect(() => {\n layoutEffectAction?.(dashkitContext, controlsContext || undefined);\n }, [controlsContext, dashkitContext]);\n\n return null;\n};\n\nconst TestComponent = withContext(ContextCapture);\n\ndescribe('DashKit controlled layout strategy', () => {\n beforeEach(() => {\n captured = {} as DashKitCtxShape;\n capturedControlsContext = undefined;\n renderedItemIds = [];\n layoutEffectAction = undefined;\n });\n\n it('updates visual layout in same render as externally added config item', () => {\n const initialConfig = createConfig(0);\n const externalConfig = createConfig(3, ['item1', 'item2']);\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n\n const {rerender} = render(\n <TestComponent\n {...createProps({config: initialConfig, emitDashKitEvent: dashkit[_emitSymbol]})}\n />,\n );\n\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: externalConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n })}\n />,\n );\n });\n\n expect(renderedItemIds).toEqual(\n expect.arrayContaining([\n {config: ['item1'], layout: ['item1']},\n {config: ['item1', 'item2'], layout: ['item1', 'item2']},\n ]),\n );\n expect(\n renderedItemIds.every(({config, layout}) => config.join(',') === layout.join(',')),\n ).toBe(true);\n });\n\n it('uses external baseline in child layout effect', () => {\n const initialConfig = createConfig(0);\n const externalConfig = createConfig(3, ['item1', 'item2']);\n const nextLayout: Config['layout'] = [\n {i: 'item1', x: 4, y: 0, w: 2, h: 2},\n externalConfig.layout[1],\n ];\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n const onEventChange = jest.fn();\n let layoutItemInLayoutEffect: Config['layout'][number] | undefined;\n let layoutItemAfterLayoutChange: Config['layout'][number] | undefined;\n\n dashkit.on('change', onEventChange);\n\n const {rerender} = render(\n <TestComponent\n {...createProps({config: initialConfig, emitDashKitEvent: dashkit[_emitSymbol]})}\n />,\n );\n\n layoutEffectAction = (dashkitContext, controlsContext) => {\n layoutEffectAction = undefined;\n layoutItemInLayoutEffect = controlsContext?.getLayoutItem('item2') || undefined;\n dashkitContext.layoutChange(nextLayout);\n layoutItemAfterLayoutChange = controlsContext?.getLayoutItem('item1') || undefined;\n };\n\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: externalConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n })}\n />,\n );\n });\n\n expect(layoutItemInLayoutEffect).toMatchObject(externalConfig.layout[1]);\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(onEventChange.mock.calls[0][0].previousLayout).toMatchObject(externalConfig.layout);\n expect(layoutItemAfterLayoutChange).toMatchObject(nextLayout[0]);\n expect(capturedControlsContext?.getLayoutItem('item1')).toMatchObject(nextLayout[0]);\n });\n\n it('Case 1: keeps internal layout after change event without config update, then applies external config update', () => {\n const initialConfig = createConfig(0);\n const nextInternalLayout: Config['layout'] = [{i: 'item1', x: 1, y: 0, w: 2, h: 2}];\n const externalConfig = createConfig(3);\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n const onChange = jest.fn();\n const onEventChange = jest.fn();\n\n dashkit.on('change', onEventChange);\n\n const {rerender} = render(\n <TestComponent\n {...createProps({\n config: initialConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n\n // Layout is now enriched with plugin defaults (minW, minH, etc)\n expect(captured.layout).toMatchObject(initialConfig.layout);\n expect(captured.layout[0]).toHaveProperty('minW');\n expect(captured.layout[0]).toHaveProperty('minH');\n\n act(() => {\n captured.layoutChange(nextInternalLayout);\n });\n\n // Verify that change event was fired with correct layout\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(onEventChange.mock.calls[0][0].layout).toEqual(nextInternalLayout);\n expect(onChange).toHaveBeenCalledTimes(1);\n\n // Now apply external config update\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: externalConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n\n // External props should win and layout should be updated\n expect(captured.layout).toMatchObject(externalConfig.layout);\n });\n\n it('Case 2: uses on(change) without updating props - internal state persists', () => {\n const initialConfig = createConfig(0);\n const nextInternalLayout: Config['layout'] = [{i: 'item1', x: 5, y: 0, w: 2, h: 2}];\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n const onChange = jest.fn();\n const onEventChange = jest.fn();\n const capturedLayouts: Config['layout'][] = [];\n\n // Listen to change event but DON'T update props\n dashkit.on('change', (event) => {\n capturedLayouts.push(event.layout);\n onEventChange(event);\n });\n\n const {rerender} = render(\n <TestComponent\n {...createProps({\n config: initialConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n\n // Initial layout should be enriched\n expect(captured.layout).toMatchObject(initialConfig.layout);\n\n // Trigger layout change\n act(() => {\n captured.layoutChange(nextInternalLayout);\n });\n\n // Event should fire with new layout\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(capturedLayouts[0]).toEqual(nextInternalLayout);\n\n // onChange callback fires (consumer COULD update props here, but doesn't in this case)\n expect(onChange).toHaveBeenCalledTimes(1);\n\n // Props remain unchanged - simulating consumer NOT updating props\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: initialConfig,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n\n // Layout should still reflect the change (internal state wins)\n // Note: we verify the event fired correctly\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(capturedLayouts[0]).toMatchObject(nextInternalLayout);\n });\n\n it('Case 3: alternates between props.layout updates and on(change) events', () => {\n const config1 = createConfig(0);\n const config2 = createConfig(2);\n const internalChange: Config['layout'] = [{i: 'item1', x: 5, y: 0, w: 2, h: 2}];\n const config3 = createConfig(8);\n\n const dashkit = new DashKit(\n DashKit.defaultProps as unknown as ConstructorParameters<typeof DashKit>[0],\n );\n const onChange = jest.fn();\n const onEventChange = jest.fn();\n\n dashkit.on('change', onEventChange);\n\n const {rerender} = render(\n <TestComponent\n {...createProps({\n config: config1,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n\n // Start with config1\n expect(captured.layout).toMatchObject(config1.layout);\n\n // Update via props (external update)\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: config2,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n expect(captured.layout).toMatchObject(config2.layout);\n\n // Update via internal change (user drag)\n act(() => {\n captured.layoutChange(internalChange);\n });\n expect(onEventChange).toHaveBeenCalledTimes(1);\n expect(onEventChange.mock.calls[0][0].layout).toEqual(internalChange);\n\n // Update via props again (external update wins)\n act(() => {\n rerender(\n <TestComponent\n {...createProps({\n config: config3,\n emitDashKitEvent: dashkit[_emitSymbol],\n onChange,\n })}\n />,\n );\n });\n expect(captured.layout).toMatchObject(config3.layout);\n });\n});\n"]}
@@ -38,7 +38,7 @@ declare class PassiveWidthProvider extends React.Component<PassiveWidthProviderP
38
38
  private gridItems;
39
39
  private lastAppliedWidth?;
40
40
  private resizeObserver?;
41
- private settledWidthCommitFrame?;
41
+ private settledWidthCommitTimer?;
42
42
  private isComponentMounted;
43
43
  componentDidMount(): void;
44
44
  componentDidUpdate(): void;
@@ -48,6 +48,7 @@ declare class PassiveWidthProvider extends React.Component<PassiveWidthProviderP
48
48
  private updateGridItems;
49
49
  private handlePointerDown;
50
50
  private syncSettledWidth;
51
+ private cancelSettledWidthCommit;
51
52
  private scheduleSettledWidthCommit;
52
53
  private syncElement;
53
54
  private observeElement;
@@ -6,6 +6,7 @@ import ReactGridLayout, { utils } from 'react-grid-layout';
6
6
  import ResizeObserverPolyfill from 'resize-observer-polyfill';
7
7
  import { DROPPING_ELEMENT_CLASS_NAME, OVERLAY_CLASS_NAME } from "../../constants/index.js";
8
8
  const GRID_LAYOUT_CLASS_NAME = 'react-grid-layout';
9
+ const SETTLED_WIDTH_COMMIT_DELAY = 150;
9
10
  const isRefObject = (value) => {
10
11
  return (typeof value === 'object' &&
11
12
  value !== null &&
@@ -395,6 +396,7 @@ class PassiveWidthProvider extends React.Component {
395
396
  if (!this.props.isDraggable && !this.props.isResizable) {
396
397
  return;
397
398
  }
399
+ this.cancelSettledWidthCommit();
398
400
  flushSync(() => {
399
401
  this.setState((state) => ({
400
402
  interactionRevision: state.interactionRevision + 1,
@@ -403,6 +405,7 @@ class PassiveWidthProvider extends React.Component {
403
405
  });
404
406
  };
405
407
  this.syncSettledWidth = () => {
408
+ this.cancelSettledWidthCommit();
406
409
  if (this.state.settledWidth === this.widthRef.current) {
407
410
  return;
408
411
  }
@@ -410,18 +413,22 @@ class PassiveWidthProvider extends React.Component {
410
413
  this.setState({ settledWidth: this.widthRef.current });
411
414
  });
412
415
  };
413
- this.scheduleSettledWidthCommit = () => {
414
- if (this.settledWidthCommitFrame !== undefined) {
415
- window.cancelAnimationFrame(this.settledWidthCommitFrame);
416
+ this.cancelSettledWidthCommit = () => {
417
+ if (this.settledWidthCommitTimer === undefined) {
418
+ return;
416
419
  }
417
- this.settledWidthCommitFrame = window.requestAnimationFrame(() => {
418
- this.settledWidthCommitFrame = window.requestAnimationFrame(() => {
419
- this.settledWidthCommitFrame = undefined;
420
- if (this.state.settledWidth !== this.widthRef.current) {
421
- this.setState({ settledWidth: this.widthRef.current });
422
- }
423
- });
424
- });
420
+ window.clearTimeout(this.settledWidthCommitTimer);
421
+ this.settledWidthCommitTimer = undefined;
422
+ };
423
+ this.scheduleSettledWidthCommit = () => {
424
+ this.cancelSettledWidthCommit();
425
+ // DOM grid items update in ResizeObserver; React reconciles only after resizing settles.
426
+ this.settledWidthCommitTimer = window.setTimeout(() => {
427
+ this.settledWidthCommitTimer = undefined;
428
+ if (this.isComponentMounted && this.state.settledWidth !== this.widthRef.current) {
429
+ this.setState({ settledWidth: this.widthRef.current });
430
+ }
431
+ }, SETTLED_WIDTH_COMMIT_DELAY);
425
432
  };
426
433
  this.syncElement = () => {
427
434
  var _a;
@@ -471,10 +478,7 @@ class PassiveWidthProvider extends React.Component {
471
478
  this.isComponentMounted = false;
472
479
  (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
473
480
  this.resizeObserver = undefined;
474
- if (this.settledWidthCommitFrame !== undefined) {
475
- window.cancelAnimationFrame(this.settledWidthCommitFrame);
476
- this.settledWidthCommitFrame = undefined;
477
- }
481
+ this.cancelSettledWidthCommit();
478
482
  (_b = this.element) === null || _b === void 0 ? void 0 : _b.removeEventListener('pointerdown', this.handlePointerDown, true);
479
483
  this.element = null;
480
484
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReactGridLayout.js","sourceRoot":"../../../../src","sources":["components/GridLayout/ReactGridLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAEpC,+DAA+D;AAC/D,OAAO,eAAe,EAAE,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAC,2BAA2B,EAAE,kBAAkB,EAAC,iCAAwB;AAEhF,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAEnD,MAAM,WAAW,GAAG,CAChB,KAAgC,EACQ,EAAE;IAC1C,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CACpC,CAAC;AACN,CAAC,CAAC;AAsCF,MAAM,gBAAgB,GAAG,CAAC,EACtB,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,KAAK,EACL,CAAC,EACD,CAAC,EACD,CA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QAChC,IAAI,IAAI,CAAC,uBAAuB,KAAK,SAAS,EAAE,CAAC;YAC7C,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YAC1D,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QAC7C,CAAC;QACD,MAAA,IAAI,CAAC,OAAO,0CAAE,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAC/E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,MAAM;QACF,MAAM,KAAiC,IAAI,CAAC,KAAK,EAA3C,EAAC,kBAAkB,OAAwB,EAAnB,KAAK,cAA7B,sBAA8B,CAAa,CAAC;QAElD,IAAI,kBAAkB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YAC9C,OAAO,CACH,6BACI,SAAS,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9E,GAAG,EAAE,IAAI,CAAC,UAAU,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,GACpB,CACL,CAAC;QACN,CAAC;QAED,OAAO,CACH,oBAAC,cAAc,oBACP,KAAK,IACT,QAAQ,EAAE,IAAI,CAAC,UAAU,EACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EACvC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAChC,CACL,CAAC;IACN,CAAC;CA4IJ;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,oBAAoB,CAAC","sourcesContent":["import React from 'react';\n\nimport {flushSync} from 'react-dom';\nimport type {Layout as RGLLayout} from 'react-grid-layout';\n// @ts-expect-error - utils is not exported in type definitions\nimport ReactGridLayout, {utils} from 'react-grid-layout';\nimport ResizeObserverPolyfill from 'resize-observer-polyfill';\n\nimport {DROPPING_ELEMENT_CLASS_NAME, OVERLAY_CLASS_NAME} from '../../constants';\n\nconst GRID_LAYOUT_CLASS_NAME = 'react-grid-layout';\n\nconst isRefObject = (\n value: React.Ref<HTMLDivElement>,\n): value is React.RefObject<HTMLDivElement> => {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'current' in value &&\n typeof value.current === 'object'\n );\n};\n\ntype SharedDragPosition = {\n offsetX: number;\n offsetY: number;\n};\n\ntype DragOverLayoutProps = ReactGridLayout.ReactGridLayoutProps & {\n innerRef?: React.Ref<HTMLDivElement>;\n isDragCaptured?: boolean;\n dragStateRef?: React.MutableRefObject<{isDragging: boolean; sourceGroup: string | null}>;\n sharedDragPositionRef?: React.MutableRefObject<SharedDragPosition | null>;\n group?: string;\n onDragTargetRestore?: () => void;\n transformScaleRef?: React.MutableRefObject<number>;\n groupResetRegistryRef?: React.MutableRefObject<Map<string, () => void>>;\n externalLayoutRevision?: number;\n onBeforeDragOver?: () => void;\n};\n\ntype DragOverLayoutState = {\n layout: RGLLayout[];\n activeDrag: RGLLayout | null;\n};\n\ntype RGLLayoutWithPlaceholder = RGLLayout & {placeholder?: boolean};\n\ntype PassiveWidthProviderProps = DragOverLayoutProps & {\n measureBeforeMount?: boolean;\n};\n\ntype OnDragMethod = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n) => void;\n\nconst getGridItemStyle = ({\n cols,\n containerPadding,\n margin,\n width,\n x,\n y,\n w,\n h,\n rowHeight,\n useCSSTransforms,\n}: {\n cols: number;\n containerPadding: [number, number];\n h: number;\n margin: [number, number];\n rowHeight: number;\n useCSSTransforms: boolean;\n w: number;\n width: number;\n x: number;\n y: number;\n}) => {\n const [marginX, marginY] = margin;\n const [paddingX, paddingY] = containerPadding;\n const columnWidth = (width - marginX * (cols - 1) - paddingX * 2) / cols;\n const position = {\n height: Math.round(rowHeight * h + marginY * (h - 1)),\n left: Math.round((columnWidth + marginX) * x + paddingX),\n top: Math.round(paddingY + (rowHeight + marginY) * y),\n width: Math.round(columnWidth * w + marginX * (w - 1)),\n };\n\n return useCSSTransforms\n ? {...utils.setTransform(position), left: '', top: ''}\n : {\n ...utils.setTopLeft(position),\n MozTransform: '',\n OTransform: '',\n WebkitTransform: '',\n msTransform: '',\n transform: '',\n };\n};\n\nclass DragOverLayout extends ReactGridLayout {\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. We need to narrow the props type from ReactGridLayoutProps to DragOverLayoutProps for type safety in our custom methods\n props: DragOverLayoutProps;\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. State is initialized by parent constructor\n state: DragOverLayoutState;\n\n parentOnDrag: OnDragMethod;\n parentOnDragStop: OnDragMethod;\n parentOnDragOver: (e: MouseEvent) => false | void;\n _savedDraggedOutLayout: RGLLayout[] | null = null;\n // Suppresses onLayoutMaybeChanged during imperative layout restore actions.\n // Without this flag, our setState would trigger onLayoutChange back to the consumer\n // that just initiated the action, causing a spurious 'change' event.\n _isRestoringExternalLayout = false;\n private readonly gridItemChildren = new WeakMap<\n React.ReactElement,\n {child: React.ReactElement; metadata: Record<string, string>}\n >();\n\n constructor(props: DragOverLayoutProps, context?: unknown) {\n super(props, context);\n\n // @ts-expect-error - onDrag is a protected method in parent class\n this.parentOnDrag = this.onDrag;\n // @ts-expect-error - assigning custom method to parent's onDrag\n this.onDrag = this.extendedOnDrag;\n\n // @ts-expect-error - onDragStop is a protected method in parent class\n this.parentOnDragStop = this.onDragStop;\n // @ts-expect-error - assigning custom method to parent's onDragStop\n this.onDragStop = this.extendedOnDragStop;\n // @ts-expect-error - onDragOver is a protected method in parent class\n this.parentOnDragOver = this.onDragOver;\n // @ts-expect-error - assigning custom method to parent's onDragOver\n this.onDragOver = this.extendedOnDragOver;\n }\n\n componentDidMount(): void {\n super.componentDidMount?.();\n\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.set(\n this.props.group,\n this.resetExternalPlaceholder,\n );\n }\n\n // If cursor is moved out of the window there is a bug\n // which leaves placeholder element in grid, this action needed to reset this state\n window.addEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.addEventListener('mouseup', this.mouseUpHandler);\n innerElement.addEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.addEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.addEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n componentDidUpdate(prevProps: DragOverLayoutProps, prevState: DragOverLayoutState): void {\n const revisionChanged =\n prevProps.externalLayoutRevision !== this.props.externalLayoutRevision;\n\n if (revisionChanged && this.props.layout) {\n const newLayout = utils.synchronizeLayoutWithChildren(\n this.props.layout,\n this.props.children,\n this.props.cols,\n utils.compactType(this.props),\n this.props.allowOverlap,\n );\n\n this._isRestoringExternalLayout = true;\n // Override both layout and propsLayout so getDerivedStateFromProps\n // doesn't revert our update on the next render cycle.\n this.setState(\n {\n layout: newLayout,\n propsLayout: this.props.layout,\n } as unknown as DragOverLayoutState,\n () => {\n this._isRestoringExternalLayout = false;\n },\n );\n // RGL's shouldComponentUpdate only tracks activeDrag/mounted/droppingPosition — not\n // state.layout. So setState({layout}) alone is silently ignored (no re-render).\n // forceUpdate bypasses SCU and is batched with the setState above, producing a\n // single render cycle with the merged state that includes the restored layout.\n this.forceUpdate();\n // Don't call super here: restoring is an external action, not a user drag/resize.\n // onLayoutMaybeChanged is suppressed via _isRestoringExternalLayout.\n return;\n }\n\n // Maintain parent behavior for all non-restore cycles (drag, resize, etc.).\n super.componentDidUpdate?.(prevProps, prevState);\n }\n\n onLayoutMaybeChanged(newLayout: RGLLayout[], oldLayout: RGLLayout[]): void {\n if (this._isRestoringExternalLayout) {\n return;\n }\n // @ts-expect-error — onLayoutMaybeChanged is not in ReactGridLayout's public types\n super.onLayoutMaybeChanged(newLayout, oldLayout);\n }\n\n componentWillUnmount(): void {\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.delete(this.props.group);\n }\n\n window.removeEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.removeEventListener('mouseup', this.mouseUpHandler);\n innerElement.removeEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.removeEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.removeEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n // react-grid-layout doens't calculate it's height when last element is removed\n // and just keeps the previous value\n // so for autosize to work in that case we are resetting it's height value\n containerHeight(): string | undefined {\n if (this.props.autoSize && this.state.layout.length === 0) {\n return;\n }\n\n // eslint-disable-next-line consistent-return\n // @ts-expect-error - containerHeight is a protected method in parent class\n return super.containerHeight();\n }\n\n // innerRef is passed by WithProvider without this wrapper there are only\n // * findDOMNode - deprecated\n // * rewrite whole ReactGridLayout.render method\n // so in that case don't try to use this class on it's own\n // or pass innerRef: React.MutableRef as it's not optional prop\n getInnerElement(): HTMLDivElement | null {\n const {innerRef} = this.props;\n\n return innerRef && isRefObject(innerRef) && innerRef.current ? innerRef.current : null;\n }\n\n // Reset placeholder when item dragged from outside\n resetExternalPlaceholder = (): void => {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n if (this.dragEnterCounter) {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n this.dragEnterCounter = 0;\n // @ts-expect-error - removeDroppingPlaceholder is a protected method in parent class\n this.removeDroppingPlaceholder();\n }\n };\n\n // Hide placeholder when element is dragged out\n hideLocalPlaceholder = (i: string): RGLLayout[] => {\n const {layout} = this.state;\n const {cols} = this.props;\n const savedLayout = layout.map((item) => ({...item}));\n\n let hiddenElement: RGLLayout | undefined;\n const newLayout = utils.compact(\n layout.filter((item) => {\n if (item.i === i) {\n hiddenElement = item;\n return false;\n }\n\n return true;\n }),\n utils.compactType(this.props),\n cols,\n );\n\n if (hiddenElement) {\n newLayout.push(hiddenElement);\n }\n\n this.setState({\n activeDrag: null,\n layout: newLayout,\n });\n\n return savedLayout;\n };\n\n extendedOnDrag = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n if (this.props.isDragCaptured) {\n if (!this._savedDraggedOutLayout) {\n this._savedDraggedOutLayout = this.hideLocalPlaceholder(i);\n }\n\n return;\n }\n\n this._savedDraggedOutLayout = null;\n // parent onDrag will show new placeholder again\n this.parentOnDrag(i, x, y, sintEv);\n };\n\n extendedOnDragStop = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n // Restoring layout if item was dropped outside of the grid\n if (this._savedDraggedOutLayout) {\n const savedLayout = this._savedDraggedOutLayout;\n const l = utils.getLayoutItem(savedLayout, i);\n\n // Create placeholder (display only)\n const placeholder: RGLLayoutWithPlaceholder = {\n w: l.w,\n h: l.h,\n x: l.x,\n y: l.y,\n placeholder: true,\n i: i,\n };\n\n this.setState(\n {\n layout: savedLayout,\n activeDrag: placeholder,\n },\n () => {\n this.parentOnDragStop(i, x, y, sintEv);\n },\n );\n\n this._savedDraggedOutLayout = null;\n } else {\n this.parentOnDragStop(i, x, y, sintEv);\n }\n };\n\n extendedOnDragOver = (e: MouseEvent): false | void => {\n this.props.onBeforeDragOver?.();\n return this.parentOnDragOver(e);\n };\n\n isSharedDragTarget = (): boolean => {\n const drag = this.props.dragStateRef?.current;\n return Boolean(drag?.isDragging);\n };\n\n // Proxy mouse events -> drag methods for dnd between groups\n mouseEnterHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragEnter is a protected method in parent class\n this.onDragEnter(e);\n } else if (this.props.isDragCaptured) {\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseLeaveHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragLeave is a protected method in parent class\n this.onDragLeave(e);\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseMoveHandler = (e: MouseEvent): void => {\n if (\n this.isSharedDragTarget() &&\n this.props.group !== this.props.dragStateRef?.current.sourceGroup\n ) {\n if (!(e as MouseEvent & {nativeEvent?: MouseEvent}).nativeEvent) {\n // Emulate nativeEvent for firefox\n const target = this.getInnerElement() || (e.target as HTMLElement);\n\n (e as MouseEvent & {nativeEvent: Partial<MouseEvent>}).nativeEvent = {\n clientX: e.clientX,\n clientY: e.clientY,\n target,\n };\n }\n\n // @ts-expect-error - onDragOver is a protected method in parent class\n this.onDragOver(e);\n }\n };\n\n mouseUpHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n e.preventDefault();\n const {droppingItem} = this.props;\n const {layout} = this.state;\n const item = layout.find((l) => l.i === droppingItem?.i);\n\n // reset dragEnter counter on drop for all registered groups\n this.props.groupResetRegistryRef?.current.forEach((reset) => reset());\n\n if (item) {\n this.props.onDrop?.(layout, item, e);\n }\n }\n };\n\n calculateDroppingPosition(itemProps: {\n containerWidth: number;\n cols: number;\n w: number;\n h: number;\n rowHeight: number;\n margin: [number, number];\n transformScale: number;\n droppingPosition: {left: number; top: number};\n }): {left: number; top: number} {\n const {containerWidth, cols, w, h, rowHeight, margin, transformScale, droppingPosition} =\n itemProps;\n const sharedDragPosition = this.props.sharedDragPositionRef?.current;\n\n let offsetX: number, offsetY: number;\n\n if (sharedDragPosition) {\n offsetX = sharedDragPosition.offsetX;\n offsetY = sharedDragPosition.offsetY;\n } else {\n offsetX = (((containerWidth / cols) * w) / 2 || 0) * transformScale;\n offsetY = ((h * rowHeight + (h - 1) * margin[1]) / 2 || 0) * transformScale;\n }\n\n return {\n ...droppingPosition,\n left: droppingPosition.left - offsetX,\n top: droppingPosition.top - offsetY,\n };\n }\n\n // Drop item from outside gets 0,0 droppingPosition\n // centering cursor on newly creted grid item\n // And cause grid-layout using it's own GridItem to make it look\n // like overlay adding className\n processGridItem(\n child: React.ReactElement,\n isDroppingItem?: boolean,\n ): React.ReactElement | undefined {\n // @ts-expect-error - processGridItem is a protected method in parent class\n const gridItem = super.processGridItem?.(child, isDroppingItem);\n\n if (!gridItem) {\n return gridItem;\n }\n\n const {cols, containerPadding, h, margin, rowHeight, useCSSTransforms, w, x, y} =\n gridItem.props;\n const [marginX, marginY] = margin;\n const [paddingX, paddingY] = containerPadding;\n const gridItemMetadata: Record<string, string> = {\n 'data-dashkit-grid-cols': String(cols),\n 'data-dashkit-grid-h': String(h),\n 'data-dashkit-grid-margin-x': String(marginX),\n 'data-dashkit-grid-margin-y': String(marginY),\n 'data-dashkit-grid-padding-x': String(paddingX),\n 'data-dashkit-grid-padding-y': String(paddingY),\n 'data-dashkit-grid-row-height': String(rowHeight),\n 'data-dashkit-grid-use-css-transforms': String(useCSSTransforms),\n 'data-dashkit-grid-w': String(w),\n 'data-dashkit-grid-x': String(x),\n 'data-dashkit-grid-y': String(y),\n };\n // Lazy proxy for transformScaleRef so react-draggable reads fresh scale without re-render.\n const {transformScaleRef} = this.props;\n const lazyScale = transformScaleRef\n ? ({valueOf: () => transformScaleRef.current} as unknown as number)\n : undefined;\n\n if (isDroppingItem) {\n // React.cloneElement is just cleaner then copy-paste whole processGridItem method\n return React.cloneElement(gridItem, {\n ...(lazyScale !== undefined && {transformScale: lazyScale}),\n // hiding preview if dragging shared item\n style: this.isSharedDragTarget()\n ? {...gridItem.props.style, opacity: 0}\n : gridItem.props.style,\n className: `${OVERLAY_CLASS_NAME} ${DROPPING_ELEMENT_CLASS_NAME}`,\n droppingPosition: this.calculateDroppingPosition(gridItem.props),\n });\n }\n\n const gridChild = gridItem.props.children as React.ReactElement<Record<string, string>>;\n const cachedGridItemChild = this.gridItemChildren.get(gridChild);\n const gridItemChild =\n cachedGridItemChild &&\n Object.keys(gridItemMetadata).every(\n (key) => cachedGridItemChild.metadata[key] === gridItemMetadata[key],\n )\n ? cachedGridItemChild.child\n : React.cloneElement(gridChild, gridItemMetadata);\n\n if (gridItemChild !== cachedGridItemChild?.child) {\n this.gridItemChildren.set(gridChild, {\n child: gridItemChild,\n metadata: gridItemMetadata,\n });\n }\n\n if (lazyScale !== undefined) {\n return React.cloneElement(gridItem, {\n children: gridItemChild,\n transformScale: lazyScale,\n });\n }\n\n return React.cloneElement(gridItem, {children: gridItemChild});\n }\n}\n\nclass PassiveWidthProvider extends React.Component<\n PassiveWidthProviderProps,\n {interactionRevision: number; isMounted: boolean; settledWidth: number}\n> {\n state = {interactionRevision: 0, isMounted: false, settledWidth: 1280};\n\n private element: HTMLDivElement | null = null;\n private readonly elementRef = React.createRef<HTMLDivElement>();\n private readonly widthRef = {current: 1280};\n private gridItems: HTMLElement[] = [];\n private lastAppliedWidth?: number;\n private resizeObserver?: ResizeObserver;\n private settledWidthCommitFrame?: number;\n private isComponentMounted = false;\n\n componentDidMount() {\n this.isComponentMounted = true;\n this.syncElement();\n this.setState({isMounted: true, settledWidth: this.widthRef.current});\n }\n\n componentDidUpdate() {\n this.syncElement();\n this.cacheGridItems();\n this.updateGridItems(this.widthRef.current);\n }\n\n componentWillUnmount() {\n this.isComponentMounted = false;\n this.resizeObserver?.disconnect();\n this.resizeObserver = undefined;\n if (this.settledWidthCommitFrame !== undefined) {\n window.cancelAnimationFrame(this.settledWidthCommitFrame);\n this.settledWidthCommitFrame = undefined;\n }\n this.element?.removeEventListener('pointerdown', this.handlePointerDown, true);\n this.element = null;\n }\n\n render() {\n const {measureBeforeMount, ...props} = this.props;\n\n if (measureBeforeMount && !this.state.isMounted) {\n return (\n <div\n className={[props.className, GRID_LAYOUT_CLASS_NAME].filter(Boolean).join(' ')}\n ref={this.elementRef}\n style={props.style}\n />\n );\n }\n\n return (\n <DragOverLayout\n {...props}\n innerRef={this.elementRef}\n onBeforeDragOver={this.syncSettledWidth}\n width={this.state.settledWidth}\n />\n );\n }\n\n private cacheGridItems = () => {\n const node = this.element;\n this.gridItems = node\n ? Array.from(node.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement &&\n child.matches('.react-grid-item[data-dashkit-grid-cols]'),\n )\n : [];\n this.lastAppliedWidth = undefined;\n };\n\n private updateGridItems = (width: number) => {\n if (width === this.lastAppliedWidth) {\n return;\n }\n this.lastAppliedWidth = width;\n\n this.gridItems.forEach((item) => {\n if (\n item.classList.contains('react-draggable-dragging') ||\n item.classList.contains('resizing')\n ) {\n return;\n }\n\n const {dataset, style} = item;\n const cols = Number(dataset.dashkitGridCols);\n const x = Number(dataset.dashkitGridX);\n const y = Number(dataset.dashkitGridY);\n const w = Number(dataset.dashkitGridW);\n const h = Number(dataset.dashkitGridH);\n const marginX = Number(dataset.dashkitGridMarginX);\n const marginY = Number(dataset.dashkitGridMarginY);\n const paddingX = Number(dataset.dashkitGridPaddingX);\n const paddingY = Number(dataset.dashkitGridPaddingY);\n const rowHeight = Number(dataset.dashkitGridRowHeight);\n const useCSSTransforms = dataset.dashkitGridUseCssTransforms === 'true';\n\n if (\n [cols, x, y, w, h, marginX, marginY, paddingX, paddingY, rowHeight].some(\n (value) => !Number.isFinite(value),\n )\n ) {\n return;\n }\n\n Object.assign(\n style,\n getGridItemStyle({\n cols,\n containerPadding: [paddingX, paddingY],\n h,\n margin: [marginX, marginY],\n rowHeight,\n useCSSTransforms,\n w,\n width,\n x,\n y,\n }),\n );\n });\n };\n\n private handlePointerDown = () => {\n if (!this.props.isDraggable && !this.props.isResizable) {\n return;\n }\n\n flushSync(() => {\n this.setState((state) => ({\n interactionRevision: state.interactionRevision + 1,\n settledWidth: this.widthRef.current,\n }));\n });\n };\n\n private syncSettledWidth = () => {\n if (this.state.settledWidth === this.widthRef.current) {\n return;\n }\n\n flushSync(() => {\n this.setState({settledWidth: this.widthRef.current});\n });\n };\n\n private scheduleSettledWidthCommit = () => {\n if (this.settledWidthCommitFrame !== undefined) {\n window.cancelAnimationFrame(this.settledWidthCommitFrame);\n }\n this.settledWidthCommitFrame = window.requestAnimationFrame(() => {\n this.settledWidthCommitFrame = window.requestAnimationFrame(() => {\n this.settledWidthCommitFrame = undefined;\n if (this.state.settledWidth !== this.widthRef.current) {\n this.setState({settledWidth: this.widthRef.current});\n }\n });\n });\n };\n\n private syncElement = () => {\n const node = this.elementRef.current;\n if (node === this.element) {\n return;\n }\n\n if (this.element) {\n this.resizeObserver?.unobserve(this.element);\n this.element.removeEventListener('pointerdown', this.handlePointerDown, true);\n }\n\n this.element = node;\n if (node && this.isComponentMounted) {\n this.observeElement(node);\n }\n };\n\n private observeElement = (node: HTMLDivElement) => {\n this.widthRef.current = node.clientWidth;\n this.cacheGridItems();\n this.updateGridItems(this.widthRef.current);\n node.addEventListener('pointerdown', this.handlePointerDown, true);\n this.resizeObserver ??= new (\n typeof ResizeObserver === 'function' ? ResizeObserver : ResizeObserverPolyfill\n )((entries: ResizeObserverEntry[]) => {\n const entry = entries.find((currentEntry) => currentEntry.target === this.element);\n if (!entry) {\n return;\n }\n\n this.widthRef.current = entry.contentRect.width;\n this.updateGridItems(this.widthRef.current);\n this.scheduleSettledWidthCommit();\n });\n this.resizeObserver.observe(node);\n };\n}\n\nexport const Layout = PassiveWidthProvider;\n"]}
1
+ {"version":3,"file":"ReactGridLayout.js","sourceRoot":"../../../../src","sources":["components/GridLayout/ReactGridLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAEpC,+DAA+D;AAC/D,OAAO,eAAe,EAAE,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAC,2BAA2B,EAAE,kBAAkB,EAAC,iCAAwB;AAEhF,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAEvC,MAAM,WAAW,GAAG,CAChB,KAAgC,EACQ,EAAE;IAC1C,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CACpC,CAAC;AACN,CAAC,CAAC;AAsCF,MAAM,gBAAgB,GAAG,CAAC,EACtB,IAAI,EACJ,gBAA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,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,oBAAoB;;QAChB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAChC,MAAA,IAAI,CAAC,cAAc,0CAAE,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAChC,MAAA,IAAI,CAAC,OAAO,0CAAE,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAC/E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,MAAM;QACF,MAAM,KAAiC,IAAI,CAAC,KAAK,EAA3C,EAAC,kBAAkB,OAAwB,EAAnB,KAAK,cAA7B,sBAA8B,CAAa,CAAC;QAElD,IAAI,kBAAkB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YAC9C,OAAO,CACH,6BACI,SAAS,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9E,GAAG,EAAE,IAAI,CAAC,UAAU,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,GACpB,CACL,CAAC;QACN,CAAC;QAED,OAAO,CACH,oBAAC,cAAc,oBACP,KAAK,IACT,QAAQ,EAAE,IAAI,CAAC,UAAU,EACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EACvC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAChC,CACL,CAAC;IACN,CAAC;CAmJJ;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,oBAAoB,CAAC","sourcesContent":["import React from 'react';\n\nimport {flushSync} from 'react-dom';\nimport type {Layout as RGLLayout} from 'react-grid-layout';\n// @ts-expect-error - utils is not exported in type definitions\nimport ReactGridLayout, {utils} from 'react-grid-layout';\nimport ResizeObserverPolyfill from 'resize-observer-polyfill';\n\nimport {DROPPING_ELEMENT_CLASS_NAME, OVERLAY_CLASS_NAME} from '../../constants';\n\nconst GRID_LAYOUT_CLASS_NAME = 'react-grid-layout';\nconst SETTLED_WIDTH_COMMIT_DELAY = 150;\n\nconst isRefObject = (\n value: React.Ref<HTMLDivElement>,\n): value is React.RefObject<HTMLDivElement> => {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'current' in value &&\n typeof value.current === 'object'\n );\n};\n\ntype SharedDragPosition = {\n offsetX: number;\n offsetY: number;\n};\n\ntype DragOverLayoutProps = ReactGridLayout.ReactGridLayoutProps & {\n innerRef?: React.Ref<HTMLDivElement>;\n isDragCaptured?: boolean;\n dragStateRef?: React.MutableRefObject<{isDragging: boolean; sourceGroup: string | null}>;\n sharedDragPositionRef?: React.MutableRefObject<SharedDragPosition | null>;\n group?: string;\n onDragTargetRestore?: () => void;\n transformScaleRef?: React.MutableRefObject<number>;\n groupResetRegistryRef?: React.MutableRefObject<Map<string, () => void>>;\n externalLayoutRevision?: number;\n onBeforeDragOver?: () => void;\n};\n\ntype DragOverLayoutState = {\n layout: RGLLayout[];\n activeDrag: RGLLayout | null;\n};\n\ntype RGLLayoutWithPlaceholder = RGLLayout & {placeholder?: boolean};\n\ntype PassiveWidthProviderProps = DragOverLayoutProps & {\n measureBeforeMount?: boolean;\n};\n\ntype OnDragMethod = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n) => void;\n\nconst getGridItemStyle = ({\n cols,\n containerPadding,\n margin,\n width,\n x,\n y,\n w,\n h,\n rowHeight,\n useCSSTransforms,\n}: {\n cols: number;\n containerPadding: [number, number];\n h: number;\n margin: [number, number];\n rowHeight: number;\n useCSSTransforms: boolean;\n w: number;\n width: number;\n x: number;\n y: number;\n}) => {\n const [marginX, marginY] = margin;\n const [paddingX, paddingY] = containerPadding;\n const columnWidth = (width - marginX * (cols - 1) - paddingX * 2) / cols;\n const position = {\n height: Math.round(rowHeight * h + marginY * (h - 1)),\n left: Math.round((columnWidth + marginX) * x + paddingX),\n top: Math.round(paddingY + (rowHeight + marginY) * y),\n width: Math.round(columnWidth * w + marginX * (w - 1)),\n };\n\n return useCSSTransforms\n ? {...utils.setTransform(position), left: '', top: ''}\n : {\n ...utils.setTopLeft(position),\n MozTransform: '',\n OTransform: '',\n WebkitTransform: '',\n msTransform: '',\n transform: '',\n };\n};\n\nclass DragOverLayout extends ReactGridLayout {\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. We need to narrow the props type from ReactGridLayoutProps to DragOverLayoutProps for type safety in our custom methods\n props: DragOverLayoutProps;\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. State is initialized by parent constructor\n state: DragOverLayoutState;\n\n parentOnDrag: OnDragMethod;\n parentOnDragStop: OnDragMethod;\n parentOnDragOver: (e: MouseEvent) => false | void;\n _savedDraggedOutLayout: RGLLayout[] | null = null;\n // Suppresses onLayoutMaybeChanged during imperative layout restore actions.\n // Without this flag, our setState would trigger onLayoutChange back to the consumer\n // that just initiated the action, causing a spurious 'change' event.\n _isRestoringExternalLayout = false;\n private readonly gridItemChildren = new WeakMap<\n React.ReactElement,\n {child: React.ReactElement; metadata: Record<string, string>}\n >();\n\n constructor(props: DragOverLayoutProps, context?: unknown) {\n super(props, context);\n\n // @ts-expect-error - onDrag is a protected method in parent class\n this.parentOnDrag = this.onDrag;\n // @ts-expect-error - assigning custom method to parent's onDrag\n this.onDrag = this.extendedOnDrag;\n\n // @ts-expect-error - onDragStop is a protected method in parent class\n this.parentOnDragStop = this.onDragStop;\n // @ts-expect-error - assigning custom method to parent's onDragStop\n this.onDragStop = this.extendedOnDragStop;\n // @ts-expect-error - onDragOver is a protected method in parent class\n this.parentOnDragOver = this.onDragOver;\n // @ts-expect-error - assigning custom method to parent's onDragOver\n this.onDragOver = this.extendedOnDragOver;\n }\n\n componentDidMount(): void {\n super.componentDidMount?.();\n\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.set(\n this.props.group,\n this.resetExternalPlaceholder,\n );\n }\n\n // If cursor is moved out of the window there is a bug\n // which leaves placeholder element in grid, this action needed to reset this state\n window.addEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.addEventListener('mouseup', this.mouseUpHandler);\n innerElement.addEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.addEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.addEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n componentDidUpdate(prevProps: DragOverLayoutProps, prevState: DragOverLayoutState): void {\n const revisionChanged =\n prevProps.externalLayoutRevision !== this.props.externalLayoutRevision;\n\n if (revisionChanged && this.props.layout) {\n const newLayout = utils.synchronizeLayoutWithChildren(\n this.props.layout,\n this.props.children,\n this.props.cols,\n utils.compactType(this.props),\n this.props.allowOverlap,\n );\n\n this._isRestoringExternalLayout = true;\n // Override both layout and propsLayout so getDerivedStateFromProps\n // doesn't revert our update on the next render cycle.\n this.setState(\n {\n layout: newLayout,\n propsLayout: this.props.layout,\n } as unknown as DragOverLayoutState,\n () => {\n this._isRestoringExternalLayout = false;\n },\n );\n // RGL's shouldComponentUpdate only tracks activeDrag/mounted/droppingPosition — not\n // state.layout. So setState({layout}) alone is silently ignored (no re-render).\n // forceUpdate bypasses SCU and is batched with the setState above, producing a\n // single render cycle with the merged state that includes the restored layout.\n this.forceUpdate();\n // Don't call super here: restoring is an external action, not a user drag/resize.\n // onLayoutMaybeChanged is suppressed via _isRestoringExternalLayout.\n return;\n }\n\n // Maintain parent behavior for all non-restore cycles (drag, resize, etc.).\n super.componentDidUpdate?.(prevProps, prevState);\n }\n\n onLayoutMaybeChanged(newLayout: RGLLayout[], oldLayout: RGLLayout[]): void {\n if (this._isRestoringExternalLayout) {\n return;\n }\n // @ts-expect-error — onLayoutMaybeChanged is not in ReactGridLayout's public types\n super.onLayoutMaybeChanged(newLayout, oldLayout);\n }\n\n componentWillUnmount(): void {\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.delete(this.props.group);\n }\n\n window.removeEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.removeEventListener('mouseup', this.mouseUpHandler);\n innerElement.removeEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.removeEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.removeEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n // react-grid-layout doens't calculate it's height when last element is removed\n // and just keeps the previous value\n // so for autosize to work in that case we are resetting it's height value\n containerHeight(): string | undefined {\n if (this.props.autoSize && this.state.layout.length === 0) {\n return;\n }\n\n // eslint-disable-next-line consistent-return\n // @ts-expect-error - containerHeight is a protected method in parent class\n return super.containerHeight();\n }\n\n // innerRef is passed by WithProvider without this wrapper there are only\n // * findDOMNode - deprecated\n // * rewrite whole ReactGridLayout.render method\n // so in that case don't try to use this class on it's own\n // or pass innerRef: React.MutableRef as it's not optional prop\n getInnerElement(): HTMLDivElement | null {\n const {innerRef} = this.props;\n\n return innerRef && isRefObject(innerRef) && innerRef.current ? innerRef.current : null;\n }\n\n // Reset placeholder when item dragged from outside\n resetExternalPlaceholder = (): void => {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n if (this.dragEnterCounter) {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n this.dragEnterCounter = 0;\n // @ts-expect-error - removeDroppingPlaceholder is a protected method in parent class\n this.removeDroppingPlaceholder();\n }\n };\n\n // Hide placeholder when element is dragged out\n hideLocalPlaceholder = (i: string): RGLLayout[] => {\n const {layout} = this.state;\n const {cols} = this.props;\n const savedLayout = layout.map((item) => ({...item}));\n\n let hiddenElement: RGLLayout | undefined;\n const newLayout = utils.compact(\n layout.filter((item) => {\n if (item.i === i) {\n hiddenElement = item;\n return false;\n }\n\n return true;\n }),\n utils.compactType(this.props),\n cols,\n );\n\n if (hiddenElement) {\n newLayout.push(hiddenElement);\n }\n\n this.setState({\n activeDrag: null,\n layout: newLayout,\n });\n\n return savedLayout;\n };\n\n extendedOnDrag = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n if (this.props.isDragCaptured) {\n if (!this._savedDraggedOutLayout) {\n this._savedDraggedOutLayout = this.hideLocalPlaceholder(i);\n }\n\n return;\n }\n\n this._savedDraggedOutLayout = null;\n // parent onDrag will show new placeholder again\n this.parentOnDrag(i, x, y, sintEv);\n };\n\n extendedOnDragStop = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n // Restoring layout if item was dropped outside of the grid\n if (this._savedDraggedOutLayout) {\n const savedLayout = this._savedDraggedOutLayout;\n const l = utils.getLayoutItem(savedLayout, i);\n\n // Create placeholder (display only)\n const placeholder: RGLLayoutWithPlaceholder = {\n w: l.w,\n h: l.h,\n x: l.x,\n y: l.y,\n placeholder: true,\n i: i,\n };\n\n this.setState(\n {\n layout: savedLayout,\n activeDrag: placeholder,\n },\n () => {\n this.parentOnDragStop(i, x, y, sintEv);\n },\n );\n\n this._savedDraggedOutLayout = null;\n } else {\n this.parentOnDragStop(i, x, y, sintEv);\n }\n };\n\n extendedOnDragOver = (e: MouseEvent): false | void => {\n this.props.onBeforeDragOver?.();\n return this.parentOnDragOver(e);\n };\n\n isSharedDragTarget = (): boolean => {\n const drag = this.props.dragStateRef?.current;\n return Boolean(drag?.isDragging);\n };\n\n // Proxy mouse events -> drag methods for dnd between groups\n mouseEnterHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragEnter is a protected method in parent class\n this.onDragEnter(e);\n } else if (this.props.isDragCaptured) {\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseLeaveHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragLeave is a protected method in parent class\n this.onDragLeave(e);\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseMoveHandler = (e: MouseEvent): void => {\n if (\n this.isSharedDragTarget() &&\n this.props.group !== this.props.dragStateRef?.current.sourceGroup\n ) {\n if (!(e as MouseEvent & {nativeEvent?: MouseEvent}).nativeEvent) {\n // Emulate nativeEvent for firefox\n const target = this.getInnerElement() || (e.target as HTMLElement);\n\n (e as MouseEvent & {nativeEvent: Partial<MouseEvent>}).nativeEvent = {\n clientX: e.clientX,\n clientY: e.clientY,\n target,\n };\n }\n\n // @ts-expect-error - onDragOver is a protected method in parent class\n this.onDragOver(e);\n }\n };\n\n mouseUpHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n e.preventDefault();\n const {droppingItem} = this.props;\n const {layout} = this.state;\n const item = layout.find((l) => l.i === droppingItem?.i);\n\n // reset dragEnter counter on drop for all registered groups\n this.props.groupResetRegistryRef?.current.forEach((reset) => reset());\n\n if (item) {\n this.props.onDrop?.(layout, item, e);\n }\n }\n };\n\n calculateDroppingPosition(itemProps: {\n containerWidth: number;\n cols: number;\n w: number;\n h: number;\n rowHeight: number;\n margin: [number, number];\n transformScale: number;\n droppingPosition: {left: number; top: number};\n }): {left: number; top: number} {\n const {containerWidth, cols, w, h, rowHeight, margin, transformScale, droppingPosition} =\n itemProps;\n const sharedDragPosition = this.props.sharedDragPositionRef?.current;\n\n let offsetX: number, offsetY: number;\n\n if (sharedDragPosition) {\n offsetX = sharedDragPosition.offsetX;\n offsetY = sharedDragPosition.offsetY;\n } else {\n offsetX = (((containerWidth / cols) * w) / 2 || 0) * transformScale;\n offsetY = ((h * rowHeight + (h - 1) * margin[1]) / 2 || 0) * transformScale;\n }\n\n return {\n ...droppingPosition,\n left: droppingPosition.left - offsetX,\n top: droppingPosition.top - offsetY,\n };\n }\n\n // Drop item from outside gets 0,0 droppingPosition\n // centering cursor on newly creted grid item\n // And cause grid-layout using it's own GridItem to make it look\n // like overlay adding className\n processGridItem(\n child: React.ReactElement,\n isDroppingItem?: boolean,\n ): React.ReactElement | undefined {\n // @ts-expect-error - processGridItem is a protected method in parent class\n const gridItem = super.processGridItem?.(child, isDroppingItem);\n\n if (!gridItem) {\n return gridItem;\n }\n\n const {cols, containerPadding, h, margin, rowHeight, useCSSTransforms, w, x, y} =\n gridItem.props;\n const [marginX, marginY] = margin;\n const [paddingX, paddingY] = containerPadding;\n const gridItemMetadata: Record<string, string> = {\n 'data-dashkit-grid-cols': String(cols),\n 'data-dashkit-grid-h': String(h),\n 'data-dashkit-grid-margin-x': String(marginX),\n 'data-dashkit-grid-margin-y': String(marginY),\n 'data-dashkit-grid-padding-x': String(paddingX),\n 'data-dashkit-grid-padding-y': String(paddingY),\n 'data-dashkit-grid-row-height': String(rowHeight),\n 'data-dashkit-grid-use-css-transforms': String(useCSSTransforms),\n 'data-dashkit-grid-w': String(w),\n 'data-dashkit-grid-x': String(x),\n 'data-dashkit-grid-y': String(y),\n };\n // Lazy proxy for transformScaleRef so react-draggable reads fresh scale without re-render.\n const {transformScaleRef} = this.props;\n const lazyScale = transformScaleRef\n ? ({valueOf: () => transformScaleRef.current} as unknown as number)\n : undefined;\n\n if (isDroppingItem) {\n // React.cloneElement is just cleaner then copy-paste whole processGridItem method\n return React.cloneElement(gridItem, {\n ...(lazyScale !== undefined && {transformScale: lazyScale}),\n // hiding preview if dragging shared item\n style: this.isSharedDragTarget()\n ? {...gridItem.props.style, opacity: 0}\n : gridItem.props.style,\n className: `${OVERLAY_CLASS_NAME} ${DROPPING_ELEMENT_CLASS_NAME}`,\n droppingPosition: this.calculateDroppingPosition(gridItem.props),\n });\n }\n\n const gridChild = gridItem.props.children as React.ReactElement<Record<string, string>>;\n const cachedGridItemChild = this.gridItemChildren.get(gridChild);\n const gridItemChild =\n cachedGridItemChild &&\n Object.keys(gridItemMetadata).every(\n (key) => cachedGridItemChild.metadata[key] === gridItemMetadata[key],\n )\n ? cachedGridItemChild.child\n : React.cloneElement(gridChild, gridItemMetadata);\n\n if (gridItemChild !== cachedGridItemChild?.child) {\n this.gridItemChildren.set(gridChild, {\n child: gridItemChild,\n metadata: gridItemMetadata,\n });\n }\n\n if (lazyScale !== undefined) {\n return React.cloneElement(gridItem, {\n children: gridItemChild,\n transformScale: lazyScale,\n });\n }\n\n return React.cloneElement(gridItem, {children: gridItemChild});\n }\n}\n\nclass PassiveWidthProvider extends React.Component<\n PassiveWidthProviderProps,\n {interactionRevision: number; isMounted: boolean; settledWidth: number}\n> {\n state = {interactionRevision: 0, isMounted: false, settledWidth: 1280};\n\n private element: HTMLDivElement | null = null;\n private readonly elementRef = React.createRef<HTMLDivElement>();\n private readonly widthRef = {current: 1280};\n private gridItems: HTMLElement[] = [];\n private lastAppliedWidth?: number;\n private resizeObserver?: ResizeObserver;\n private settledWidthCommitTimer?: number;\n private isComponentMounted = false;\n\n componentDidMount() {\n this.isComponentMounted = true;\n this.syncElement();\n this.setState({isMounted: true, settledWidth: this.widthRef.current});\n }\n\n componentDidUpdate() {\n this.syncElement();\n this.cacheGridItems();\n this.updateGridItems(this.widthRef.current);\n }\n\n componentWillUnmount() {\n this.isComponentMounted = false;\n this.resizeObserver?.disconnect();\n this.resizeObserver = undefined;\n this.cancelSettledWidthCommit();\n this.element?.removeEventListener('pointerdown', this.handlePointerDown, true);\n this.element = null;\n }\n\n render() {\n const {measureBeforeMount, ...props} = this.props;\n\n if (measureBeforeMount && !this.state.isMounted) {\n return (\n <div\n className={[props.className, GRID_LAYOUT_CLASS_NAME].filter(Boolean).join(' ')}\n ref={this.elementRef}\n style={props.style}\n />\n );\n }\n\n return (\n <DragOverLayout\n {...props}\n innerRef={this.elementRef}\n onBeforeDragOver={this.syncSettledWidth}\n width={this.state.settledWidth}\n />\n );\n }\n\n private cacheGridItems = () => {\n const node = this.element;\n this.gridItems = node\n ? Array.from(node.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement &&\n child.matches('.react-grid-item[data-dashkit-grid-cols]'),\n )\n : [];\n this.lastAppliedWidth = undefined;\n };\n\n private updateGridItems = (width: number) => {\n if (width === this.lastAppliedWidth) {\n return;\n }\n this.lastAppliedWidth = width;\n\n this.gridItems.forEach((item) => {\n if (\n item.classList.contains('react-draggable-dragging') ||\n item.classList.contains('resizing')\n ) {\n return;\n }\n\n const {dataset, style} = item;\n const cols = Number(dataset.dashkitGridCols);\n const x = Number(dataset.dashkitGridX);\n const y = Number(dataset.dashkitGridY);\n const w = Number(dataset.dashkitGridW);\n const h = Number(dataset.dashkitGridH);\n const marginX = Number(dataset.dashkitGridMarginX);\n const marginY = Number(dataset.dashkitGridMarginY);\n const paddingX = Number(dataset.dashkitGridPaddingX);\n const paddingY = Number(dataset.dashkitGridPaddingY);\n const rowHeight = Number(dataset.dashkitGridRowHeight);\n const useCSSTransforms = dataset.dashkitGridUseCssTransforms === 'true';\n\n if (\n [cols, x, y, w, h, marginX, marginY, paddingX, paddingY, rowHeight].some(\n (value) => !Number.isFinite(value),\n )\n ) {\n return;\n }\n\n Object.assign(\n style,\n getGridItemStyle({\n cols,\n containerPadding: [paddingX, paddingY],\n h,\n margin: [marginX, marginY],\n rowHeight,\n useCSSTransforms,\n w,\n width,\n x,\n y,\n }),\n );\n });\n };\n\n private handlePointerDown = () => {\n if (!this.props.isDraggable && !this.props.isResizable) {\n return;\n }\n\n this.cancelSettledWidthCommit();\n flushSync(() => {\n this.setState((state) => ({\n interactionRevision: state.interactionRevision + 1,\n settledWidth: this.widthRef.current,\n }));\n });\n };\n\n private syncSettledWidth = () => {\n this.cancelSettledWidthCommit();\n if (this.state.settledWidth === this.widthRef.current) {\n return;\n }\n\n flushSync(() => {\n this.setState({settledWidth: this.widthRef.current});\n });\n };\n\n private cancelSettledWidthCommit = () => {\n if (this.settledWidthCommitTimer === undefined) {\n return;\n }\n window.clearTimeout(this.settledWidthCommitTimer);\n this.settledWidthCommitTimer = undefined;\n };\n\n private scheduleSettledWidthCommit = () => {\n this.cancelSettledWidthCommit();\n // DOM grid items update in ResizeObserver; React reconciles only after resizing settles.\n this.settledWidthCommitTimer = window.setTimeout(() => {\n this.settledWidthCommitTimer = undefined;\n if (this.isComponentMounted && this.state.settledWidth !== this.widthRef.current) {\n this.setState({settledWidth: this.widthRef.current});\n }\n }, SETTLED_WIDTH_COMMIT_DELAY);\n };\n\n private syncElement = () => {\n const node = this.elementRef.current;\n if (node === this.element) {\n return;\n }\n\n if (this.element) {\n this.resizeObserver?.unobserve(this.element);\n this.element.removeEventListener('pointerdown', this.handlePointerDown, true);\n }\n\n this.element = node;\n if (node && this.isComponentMounted) {\n this.observeElement(node);\n }\n };\n\n private observeElement = (node: HTMLDivElement) => {\n this.widthRef.current = node.clientWidth;\n this.cacheGridItems();\n this.updateGridItems(this.widthRef.current);\n node.addEventListener('pointerdown', this.handlePointerDown, true);\n this.resizeObserver ??= new (\n typeof ResizeObserver === 'function' ? ResizeObserver : ResizeObserverPolyfill\n )((entries: ResizeObserverEntry[]) => {\n const entry = entries.find((currentEntry) => currentEntry.target === this.element);\n if (!entry) {\n return;\n }\n\n this.widthRef.current = entry.contentRect.width;\n this.updateGridItems(this.widthRef.current);\n this.scheduleSettledWidthCommit();\n });\n this.resizeObserver.observe(node);\n };\n}\n\nexport const Layout = PassiveWidthProvider;\n"]}
@@ -10,8 +10,6 @@ jest.mock('../../Item/Item', () => ({
10
10
  }));
11
11
  const resizeObservers = [];
12
12
  const mockPolyfillObservers = [];
13
- const animationFrameCallbacks = new Map();
14
- let animationFrameId = 0;
15
13
  jest.mock('resize-observer-polyfill', () => ({
16
14
  __esModule: true,
17
15
  default: class {
@@ -64,27 +62,15 @@ const emitPolyfillResizeFor = (element, width) => {
64
62
  observer.callback([{ contentRect: { width }, target: element }]);
65
63
  });
66
64
  };
67
- const runAnimationFrame = () => {
68
- const callbacks = Array.from(animationFrameCallbacks.values());
69
- animationFrameCallbacks.clear();
70
- callbacks.forEach((callback) => callback(0));
71
- };
72
65
  const gridItem = (React.createElement(GridItem, { adjustWidgetLayout: jest.fn(), id: "item", item: { data: {} }, key: "item", layout: [] }));
73
66
  describe('Layout passive resize', () => {
74
67
  beforeEach(() => {
75
68
  resizeObservers.length = 0;
76
69
  mockPolyfillObservers.length = 0;
77
- animationFrameCallbacks.clear();
78
- animationFrameId = 0;
79
70
  global.ResizeObserver = TestResizeObserver;
80
- window.requestAnimationFrame = jest.fn((callback) => {
81
- animationFrameId += 1;
82
- animationFrameCallbacks.set(animationFrameId, callback);
83
- return animationFrameId;
84
- });
85
- window.cancelAnimationFrame = jest.fn((frame) => {
86
- animationFrameCallbacks.delete(frame);
87
- });
71
+ });
72
+ afterEach(() => {
73
+ jest.useRealTimers();
88
74
  });
89
75
  test('does not render ReactGridLayout for passive container resize', () => {
90
76
  const renderSpy = jest.spyOn(ReactGridLayout.prototype, 'render');
@@ -111,42 +97,45 @@ describe('Layout passive resize', () => {
111
97
  expect(item === null || item === void 0 ? void 0 : item.style.width).toBe('213px');
112
98
  expect(item === null || item === void 0 ? void 0 : item.style.transform).toBe('translate(158px,10px)');
113
99
  });
114
- test('commits only latest width after delivery between two quiet frames', () => {
100
+ test('commits only latest width after resize settles', () => {
101
+ jest.useFakeTimers();
115
102
  const renderSpy = jest.spyOn(ReactGridLayout.prototype, 'render');
116
103
  render(React.createElement(Layout, { cols: 12, isDraggable: true, layout: [{ h: 1, i: 'item', w: 1, x: 0, y: 0 }], rowHeight: 100 },
117
104
  React.createElement("div", { key: "item" })));
118
105
  const rendersBeforeResize = renderSpy.mock.calls.length;
119
106
  act(() => {
120
107
  emitResize(900);
121
- runAnimationFrame();
108
+ jest.advanceTimersByTime(100);
122
109
  emitResize(1000);
123
110
  });
124
111
  expect(renderSpy).toHaveBeenCalledTimes(rendersBeforeResize);
125
112
  act(() => {
126
- runAnimationFrame();
113
+ jest.advanceTimersByTime(149);
127
114
  });
128
115
  expect(renderSpy).toHaveBeenCalledTimes(rendersBeforeResize);
129
116
  act(() => {
130
- runAnimationFrame();
117
+ jest.advanceTimersByTime(1);
131
118
  });
132
119
  expect(renderSpy).toHaveBeenCalledTimes(rendersBeforeResize + 1);
133
120
  expect(renderSpy.mock.instances.at(-1).props.width).toBe(1000);
134
121
  renderSpy.mockRestore();
135
122
  });
136
- test('cancels second quiet frame on unmount', () => {
123
+ test('cancels settled width commit on unmount', () => {
124
+ jest.useFakeTimers();
137
125
  const renderSpy = jest.spyOn(ReactGridLayout.prototype, 'render');
138
126
  const { unmount } = render(React.createElement(Layout, { cols: 12, isDraggable: true, layout: [{ h: 1, i: 'item', w: 1, x: 0, y: 0 }], rowHeight: 100 },
139
127
  React.createElement("div", { key: "item" })));
140
128
  const rendersBeforeResize = renderSpy.mock.calls.length;
141
129
  act(() => {
142
130
  emitResize(900);
143
- runAnimationFrame();
131
+ jest.advanceTimersByTime(100);
144
132
  });
145
133
  expect(renderSpy).toHaveBeenCalledTimes(rendersBeforeResize);
134
+ expect(jest.getTimerCount()).toBe(1);
146
135
  unmount();
147
- expect(window.cancelAnimationFrame).toHaveBeenLastCalledWith(2);
136
+ expect(jest.getTimerCount()).toBe(0);
148
137
  act(() => {
149
- runAnimationFrame();
138
+ jest.advanceTimersByTime(150);
150
139
  });
151
140
  expect(renderSpy).toHaveBeenCalledTimes(rendersBeforeResize);
152
141
  renderSpy.mockRestore();