devextreme-react 24.1.2-beta → 24.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +23 -23
- package/cjs/accordion.d.ts +3 -3
- package/cjs/accordion.js +34 -37
- package/cjs/action-sheet.d.ts +3 -3
- package/cjs/action-sheet.js +34 -37
- package/cjs/autocomplete.d.ts +2 -2
- package/cjs/autocomplete.js +79 -82
- package/cjs/bar-gauge.d.ts +2 -2
- package/cjs/bar-gauge.js +97 -100
- package/cjs/box.d.ts +3 -3
- package/cjs/box.js +34 -37
- package/cjs/bullet.d.ts +2 -2
- package/cjs/bullet.js +44 -50
- package/cjs/button-group.d.ts +2 -2
- package/cjs/button-group.js +34 -37
- package/cjs/button.d.ts +2 -2
- package/cjs/button.js +22 -28
- package/cjs/calendar.d.ts +2 -2
- package/cjs/calendar.js +27 -31
- package/cjs/chart.d.ts +2 -2
- package/cjs/chart.js +305 -308
- package/cjs/check-box.d.ts +2 -2
- package/cjs/check-box.js +24 -29
- package/cjs/circular-gauge.d.ts +2 -2
- package/cjs/circular-gauge.js +103 -106
- package/cjs/color-box.d.ts +2 -2
- package/cjs/color-box.js +76 -79
- package/cjs/common/charts.d.ts +2 -2
- package/cjs/common/charts.js +2 -2
- package/cjs/common/data/custom-store.d.ts +2 -2
- package/cjs/common/data/custom-store.js +2 -2
- package/cjs/common/grids.d.ts +2 -2
- package/cjs/common/grids.js +2 -2
- package/cjs/common/index.d.ts +2 -2
- package/cjs/common/index.js +2 -2
- package/cjs/context-menu.d.ts +3 -3
- package/cjs/context-menu.js +76 -79
- package/cjs/core/component-base.d.ts +2 -2
- package/cjs/core/component-base.js +107 -141
- package/cjs/core/component.d.ts +2 -2
- package/cjs/core/component.js +29 -43
- package/cjs/core/config.d.ts +2 -2
- package/cjs/core/config.js +4 -15
- package/cjs/core/configuration/comparer.d.ts +2 -2
- package/cjs/core/configuration/comparer.js +27 -27
- package/cjs/core/configuration/config-node.d.ts +2 -2
- package/cjs/core/configuration/config-node.js +2 -2
- package/cjs/core/configuration/react/element.d.ts +2 -3
- package/cjs/core/configuration/react/element.js +10 -10
- package/cjs/core/configuration/react/templates.d.ts +2 -2
- package/cjs/core/configuration/react/templates.js +2 -2
- package/cjs/core/configuration/react/tree.d.ts +2 -2
- package/cjs/core/configuration/react/tree.js +33 -40
- package/cjs/core/configuration/tree.d.ts +2 -2
- package/cjs/core/configuration/tree.js +24 -24
- package/cjs/core/configuration/utils.d.ts +2 -2
- package/cjs/core/configuration/utils.js +12 -17
- package/cjs/core/extension-component.d.ts +2 -2
- package/cjs/core/extension-component.js +20 -35
- package/cjs/core/helpers.d.ts +2 -3
- package/cjs/core/helpers.js +30 -161
- package/cjs/core/nested-option.d.ts +2 -2
- package/cjs/core/nested-option.js +8 -8
- package/cjs/core/options-manager.d.ts +2 -2
- package/cjs/core/options-manager.js +85 -128
- package/cjs/core/template-manager.d.ts +2 -2
- package/cjs/core/template-manager.js +51 -82
- package/cjs/core/template-wrapper.d.ts +2 -2
- package/cjs/core/template-wrapper.js +32 -49
- package/cjs/core/template.d.ts +2 -2
- package/cjs/core/template.js +4 -4
- package/cjs/core/types.d.ts +2 -2
- package/cjs/core/types.js +2 -2
- package/cjs/core/widget-config.d.ts +2 -2
- package/cjs/core/widget-config.js +21 -22
- package/cjs/data-grid.d.ts +3 -3
- package/cjs/data-grid.js +290 -292
- package/cjs/date-box.d.ts +2 -2
- package/cjs/date-box.js +83 -85
- package/cjs/date-range-box.d.ts +2 -2
- package/cjs/date-range-box.js +82 -85
- package/cjs/defer-rendering.d.ts +2 -2
- package/cjs/defer-rendering.js +50 -56
- package/cjs/diagram.d.ts +16 -16
- package/cjs/diagram.js +109 -112
- package/cjs/draggable.d.ts +2 -2
- package/cjs/draggable.js +29 -34
- package/cjs/drawer.d.ts +2 -2
- package/cjs/drawer.js +27 -31
- package/cjs/drop-down-box.d.ts +2 -2
- package/cjs/drop-down-box.js +76 -79
- package/cjs/drop-down-button.d.ts +2 -2
- package/cjs/drop-down-button.js +68 -73
- package/cjs/file-manager.d.ts +2 -2
- package/cjs/file-manager.js +59 -65
- package/cjs/file-uploader.d.ts +2 -2
- package/cjs/file-uploader.js +24 -29
- package/cjs/filter-builder.d.ts +2 -2
- package/cjs/filter-builder.js +47 -50
- package/cjs/form.d.ts +2 -2
- package/cjs/form.js +94 -98
- package/cjs/funnel.d.ts +2 -2
- package/cjs/funnel.js +109 -113
- package/cjs/gallery.d.ts +3 -3
- package/cjs/gallery.js +34 -37
- package/cjs/gantt.d.ts +2 -2
- package/cjs/gantt.js +101 -106
- package/cjs/html-editor.d.ts +2 -2
- package/cjs/html-editor.js +64 -68
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +2 -2
- package/cjs/linear-gauge.d.ts +2 -2
- package/cjs/linear-gauge.js +103 -107
- package/cjs/list.d.ts +3 -3
- package/cjs/list.js +52 -55
- package/cjs/load-indicator.d.ts +2 -2
- package/cjs/load-indicator.js +19 -26
- package/cjs/load-panel.d.ts +2 -2
- package/cjs/load-panel.js +62 -65
- package/cjs/lookup.d.ts +2 -2
- package/cjs/lookup.js +79 -82
- package/cjs/map.d.ts +2 -2
- package/cjs/map.js +46 -50
- package/cjs/menu.d.ts +3 -3
- package/cjs/menu.js +76 -79
- package/cjs/multi-view.d.ts +3 -3
- package/cjs/multi-view.js +34 -37
- package/cjs/number-box.d.ts +2 -2
- package/cjs/number-box.js +37 -41
- package/cjs/pie-chart.d.ts +2 -2
- package/cjs/pie-chart.js +136 -139
- package/cjs/pivot-grid-field-chooser.d.ts +2 -2
- package/cjs/pivot-grid-field-chooser.js +38 -44
- package/cjs/pivot-grid.d.ts +2 -2
- package/cjs/pivot-grid.js +62 -68
- package/cjs/polar-chart.d.ts +2 -2
- package/cjs/polar-chart.js +238 -242
- package/cjs/popover.d.ts +2 -2
- package/cjs/popover.js +74 -76
- package/cjs/popup.d.ts +2 -2
- package/cjs/popup.js +68 -70
- package/cjs/progress-bar.d.ts +2 -2
- package/cjs/progress-bar.js +24 -29
- package/cjs/radio-group.d.ts +2 -2
- package/cjs/radio-group.js +34 -37
- package/cjs/range-selector.d.ts +2 -2
- package/cjs/range-selector.js +208 -212
- package/cjs/range-slider.d.ts +2 -2
- package/cjs/range-slider.js +37 -41
- package/cjs/recurrence-editor.d.ts +2 -2
- package/cjs/recurrence-editor.js +24 -29
- package/cjs/resizable.d.ts +2 -2
- package/cjs/resizable.js +24 -29
- package/cjs/responsive-box.d.ts +3 -3
- package/cjs/responsive-box.js +43 -46
- package/cjs/sankey.d.ts +2 -2
- package/cjs/sankey.js +85 -89
- package/cjs/scheduler.d.ts +2 -2
- package/cjs/scheduler.js +46 -49
- package/cjs/scroll-view.d.ts +2 -2
- package/cjs/scroll-view.js +19 -26
- package/cjs/select-box.d.ts +2 -2
- package/cjs/select-box.js +79 -82
- package/cjs/slider.d.ts +2 -2
- package/cjs/slider.js +37 -41
- package/cjs/sortable.d.ts +2 -2
- package/cjs/sortable.js +29 -34
- package/cjs/sparkline.d.ts +2 -2
- package/cjs/sparkline.js +44 -50
- package/cjs/speed-dial-action.d.ts +2 -2
- package/cjs/speed-dial-action.js +19 -26
- package/cjs/splitter.d.ts +6 -6
- package/cjs/splitter.js +34 -37
- package/cjs/switch.d.ts +2 -2
- package/cjs/switch.js +24 -29
- package/cjs/tab-panel.d.ts +3 -3
- package/cjs/tab-panel.js +34 -37
- package/cjs/tabs.d.ts +3 -3
- package/cjs/tabs.js +34 -37
- package/cjs/tag-box.d.ts +2 -2
- package/cjs/tag-box.js +79 -82
- package/cjs/text-area.d.ts +2 -2
- package/cjs/text-area.js +24 -29
- package/cjs/text-box.d.ts +2 -2
- package/cjs/text-box.js +34 -38
- package/cjs/tile-view.d.ts +3 -3
- package/cjs/tile-view.js +34 -37
- package/cjs/toast.d.ts +2 -2
- package/cjs/toast.js +65 -67
- package/cjs/toolbar.d.ts +3 -3
- package/cjs/toolbar.js +34 -37
- package/cjs/tooltip.d.ts +2 -2
- package/cjs/tooltip.js +71 -73
- package/cjs/tree-list.d.ts +3 -3
- package/cjs/tree-list.js +250 -254
- package/cjs/tree-map.d.ts +2 -2
- package/cjs/tree-map.js +91 -95
- package/cjs/tree-view.d.ts +3 -3
- package/cjs/tree-view.js +43 -46
- package/cjs/validation-group.d.ts +2 -2
- package/cjs/validation-group.js +19 -26
- package/cjs/validation-summary.d.ts +3 -3
- package/cjs/validation-summary.js +34 -37
- package/cjs/validator.d.ts +2 -2
- package/cjs/validator.js +57 -63
- package/cjs/vector-map.d.ts +2 -2
- package/cjs/vector-map.js +106 -110
- package/esm/accordion.js +29 -32
- package/esm/action-sheet.js +29 -32
- package/esm/autocomplete.js +74 -77
- package/esm/bar-gauge.js +92 -95
- package/esm/box.js +29 -32
- package/esm/bullet.js +39 -45
- package/esm/button-group.js +29 -32
- package/esm/button.js +18 -24
- package/esm/calendar.js +23 -27
- package/esm/chart.js +300 -303
- package/esm/check-box.js +20 -25
- package/esm/circular-gauge.js +98 -101
- package/esm/color-box.js +71 -74
- package/esm/common/charts.js +2 -2
- package/esm/common/data/custom-store.js +2 -2
- package/esm/common/grids.js +2 -2
- package/esm/common/index.js +2 -2
- package/esm/context-menu.js +71 -74
- package/esm/core/component-base.js +94 -131
- package/esm/core/component.js +25 -39
- package/esm/core/config.js +4 -15
- package/esm/core/configuration/comparer.js +25 -25
- package/esm/core/configuration/config-node.js +2 -2
- package/esm/core/configuration/react/element.js +9 -9
- package/esm/core/configuration/react/templates.js +2 -2
- package/esm/core/configuration/react/tree.js +28 -35
- package/esm/core/configuration/tree.js +23 -23
- package/esm/core/configuration/utils.js +12 -17
- package/esm/core/extension-component.js +17 -32
- package/esm/core/helpers.js +30 -163
- package/esm/core/nested-option.js +6 -6
- package/esm/core/options-manager.js +81 -124
- package/esm/core/template-manager.js +44 -75
- package/esm/core/template-wrapper.js +27 -44
- package/esm/core/template.js +3 -3
- package/esm/core/types.js +2 -2
- package/esm/core/widget-config.js +21 -22
- package/esm/data-grid.js +285 -287
- package/esm/date-box.js +78 -80
- package/esm/date-range-box.js +77 -80
- package/esm/defer-rendering.js +45 -51
- package/esm/diagram.js +104 -107
- package/esm/draggable.js +24 -29
- package/esm/drawer.js +23 -27
- package/esm/drop-down-box.js +71 -74
- package/esm/drop-down-button.js +63 -68
- package/esm/file-manager.js +54 -60
- package/esm/file-uploader.js +20 -25
- package/esm/filter-builder.js +42 -45
- package/esm/form.js +89 -93
- package/esm/funnel.js +104 -108
- package/esm/gallery.js +29 -32
- package/esm/gantt.js +96 -101
- package/esm/html-editor.js +59 -63
- package/esm/index.js +2 -2
- package/esm/linear-gauge.js +98 -102
- package/esm/list.js +47 -50
- package/esm/load-indicator.js +15 -22
- package/esm/load-panel.js +57 -60
- package/esm/lookup.js +74 -77
- package/esm/map.js +41 -45
- package/esm/menu.js +71 -74
- package/esm/multi-view.js +29 -32
- package/esm/number-box.js +32 -36
- package/esm/pie-chart.js +131 -134
- package/esm/pivot-grid-field-chooser.js +33 -39
- package/esm/pivot-grid.js +57 -63
- package/esm/polar-chart.js +233 -237
- package/esm/popover.js +69 -71
- package/esm/popup.js +63 -65
- package/esm/progress-bar.js +20 -25
- package/esm/radio-group.js +29 -32
- package/esm/range-selector.js +203 -207
- package/esm/range-slider.js +32 -36
- package/esm/recurrence-editor.js +20 -25
- package/esm/resizable.js +20 -25
- package/esm/responsive-box.js +38 -41
- package/esm/sankey.js +80 -84
- package/esm/scheduler.js +41 -44
- package/esm/scroll-view.js +15 -22
- package/esm/select-box.js +74 -77
- package/esm/slider.js +32 -36
- package/esm/sortable.js +24 -29
- package/esm/sparkline.js +39 -45
- package/esm/speed-dial-action.js +15 -22
- package/esm/splitter.js +29 -32
- package/esm/switch.js +20 -25
- package/esm/tab-panel.js +29 -32
- package/esm/tabs.js +29 -32
- package/esm/tag-box.js +74 -77
- package/esm/text-area.js +20 -25
- package/esm/text-box.js +29 -33
- package/esm/tile-view.js +29 -32
- package/esm/toast.js +60 -62
- package/esm/toolbar.js +29 -32
- package/esm/tooltip.js +66 -68
- package/esm/tree-list.js +245 -249
- package/esm/tree-map.js +86 -90
- package/esm/tree-view.js +38 -41
- package/esm/validation-group.js +15 -22
- package/esm/validation-summary.js +29 -32
- package/esm/validator.js +52 -58
- package/esm/vector-map.js +101 -105
- package/package.json +50 -51
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* devextreme-react
|
|
3
|
-
* Version: 24.1.
|
|
4
|
-
* Build date:
|
|
3
|
+
* Version: 24.1.3
|
|
4
|
+
* Build date: Tue Jun 11 2024
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
|
|
7
7
|
*
|
|
@@ -11,33 +11,6 @@
|
|
|
11
11
|
* https://github.com/DevExpress/devextreme-react
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var __assign = (this && this.__assign) || function () {
|
|
15
|
-
__assign = Object.assign || function(t) {
|
|
16
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17
|
-
s = arguments[i];
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
return __assign.apply(this, arguments);
|
|
24
|
-
};
|
|
25
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
26
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
|
-
if (!m) return o;
|
|
28
|
-
var i = m.call(o), r, ar = [], e;
|
|
29
|
-
try {
|
|
30
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31
|
-
}
|
|
32
|
-
catch (error) { e = { error: error }; }
|
|
33
|
-
finally {
|
|
34
|
-
try {
|
|
35
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
-
}
|
|
37
|
-
finally { if (e) throw e.error; }
|
|
38
|
-
}
|
|
39
|
-
return ar;
|
|
40
|
-
};
|
|
41
14
|
import * as React from 'react';
|
|
42
15
|
import * as events from 'devextreme/events';
|
|
43
16
|
import { useState, useMemo, useCallback, useEffect, useRef, } from 'react';
|
|
@@ -47,7 +20,7 @@ import { DX_REMOVE_EVENT } from './component-base';
|
|
|
47
20
|
import { getOption as getConfigOption } from './config';
|
|
48
21
|
function normalizeProps(props) {
|
|
49
22
|
if (getConfigOption('useLegacyTemplateEngine')) {
|
|
50
|
-
|
|
23
|
+
const model = props.data;
|
|
51
24
|
if (model && Object.prototype.hasOwnProperty.call(model, 'key')) {
|
|
52
25
|
model.dxkey = model.key;
|
|
53
26
|
}
|
|
@@ -55,32 +28,30 @@ function normalizeProps(props) {
|
|
|
55
28
|
}
|
|
56
29
|
return props;
|
|
57
30
|
}
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var subscribeOnRemoval = useCallback(function (container, onRemoved) {
|
|
31
|
+
export const TemplateManager = ({ init }) => {
|
|
32
|
+
const [instantiationModels, setInstantiationModels] = useState(new TemplateInstantiationModels());
|
|
33
|
+
const [updateContext, setUpdateContext] = useState();
|
|
34
|
+
const widgetId = useRef('');
|
|
35
|
+
const templateFactories = useRef({});
|
|
36
|
+
const subscribeOnRemoval = useCallback((container, onRemoved) => {
|
|
65
37
|
if (container.nodeType === Node.ELEMENT_NODE) {
|
|
66
38
|
events.on(container, DX_REMOVE_EVENT, onRemoved);
|
|
67
39
|
}
|
|
68
40
|
}, []);
|
|
69
|
-
|
|
41
|
+
const unsubscribeOnRemoval = useCallback((container, onRemoved) => {
|
|
70
42
|
if (container.nodeType === Node.ELEMENT_NODE) {
|
|
71
43
|
events.off(container, DX_REMOVE_EVENT, onRemoved);
|
|
72
44
|
}
|
|
73
45
|
}, []);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var template = currentInstantiationModels.get(key);
|
|
46
|
+
const unwrapElement = useCallback((element) => (element.get ? element.get(0) : element), []);
|
|
47
|
+
const createMapKey = useCallback((key1, key2) => ({ key1, key2 }), []);
|
|
48
|
+
const getRandomId = useCallback(() => `${generateID()}${generateID()}${generateID()}`, []);
|
|
49
|
+
const getRenderFunc = useCallback((templateKey) => ({ model: data, index, container, onRendered, }) => {
|
|
50
|
+
const containerElement = unwrapElement(container);
|
|
51
|
+
const key = createMapKey(data, containerElement);
|
|
52
|
+
const onRemoved = () => {
|
|
53
|
+
setInstantiationModels((currentInstantiationModels) => {
|
|
54
|
+
const template = currentInstantiationModels.get(key);
|
|
84
55
|
if (template) {
|
|
85
56
|
currentInstantiationModels.delete(key);
|
|
86
57
|
return currentInstantiationModels.shallowCopy();
|
|
@@ -88,49 +59,48 @@ export var TemplateManager = function (_a) {
|
|
|
88
59
|
return currentInstantiationModels;
|
|
89
60
|
});
|
|
90
61
|
};
|
|
91
|
-
|
|
92
|
-
setInstantiationModels(
|
|
62
|
+
const hostWidgetId = widgetId.current;
|
|
63
|
+
setInstantiationModels((currentInstantiationModels) => {
|
|
93
64
|
currentInstantiationModels.set(key, {
|
|
94
|
-
templateKey
|
|
95
|
-
index
|
|
65
|
+
templateKey,
|
|
66
|
+
index,
|
|
96
67
|
componentKey: getRandomId(),
|
|
97
|
-
onRendered:
|
|
68
|
+
onRendered: () => {
|
|
98
69
|
unsubscribeOnRemoval(containerElement, onRemoved);
|
|
99
70
|
if (hostWidgetId === widgetId.current) {
|
|
100
|
-
onRendered
|
|
71
|
+
onRendered?.();
|
|
101
72
|
}
|
|
102
73
|
},
|
|
103
|
-
onRemoved
|
|
74
|
+
onRemoved,
|
|
104
75
|
});
|
|
105
76
|
return currentInstantiationModels.shallowCopy();
|
|
106
77
|
});
|
|
107
78
|
return containerElement;
|
|
108
|
-
}
|
|
109
|
-
useMemo(
|
|
79
|
+
}, [unsubscribeOnRemoval, createMapKey]);
|
|
80
|
+
useMemo(() => {
|
|
110
81
|
function getTemplateFunction(template) {
|
|
111
82
|
switch (template.type) {
|
|
112
|
-
case 'children': return
|
|
113
|
-
case 'render': return
|
|
83
|
+
case 'children': return () => template.content;
|
|
84
|
+
case 'render': return (props) => {
|
|
114
85
|
normalizeProps(props);
|
|
115
86
|
return template.content(props.data, props.index);
|
|
116
87
|
};
|
|
117
|
-
case 'component': return
|
|
88
|
+
case 'component': return (props) => {
|
|
118
89
|
props = normalizeProps(props);
|
|
119
90
|
return React.createElement.bind(null, template.content)(props);
|
|
120
91
|
};
|
|
121
|
-
default: return
|
|
92
|
+
default: return () => React.createElement(React.Fragment);
|
|
122
93
|
}
|
|
123
94
|
}
|
|
124
95
|
function createDXTemplates(templateOptions) {
|
|
125
|
-
|
|
126
|
-
.reduce(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, {});
|
|
96
|
+
const factories = Object.entries(templateOptions)
|
|
97
|
+
.reduce((res, [key, template]) => ({
|
|
98
|
+
...res,
|
|
99
|
+
[key]: getTemplateFunction(template),
|
|
100
|
+
}), {});
|
|
131
101
|
templateFactories.current = factories;
|
|
132
|
-
|
|
133
|
-
.reduce(
|
|
102
|
+
const dxTemplates = Object.keys(factories)
|
|
103
|
+
.reduce((templates, templateKey) => {
|
|
134
104
|
templates[templateKey] = { render: getRenderFunc(templateKey) };
|
|
135
105
|
return templates;
|
|
136
106
|
}, {});
|
|
@@ -141,11 +111,11 @@ export var TemplateManager = function (_a) {
|
|
|
141
111
|
setInstantiationModels(new TemplateInstantiationModels());
|
|
142
112
|
}
|
|
143
113
|
function updateTemplates(onUpdated) {
|
|
144
|
-
setUpdateContext({ onUpdated
|
|
114
|
+
setUpdateContext({ onUpdated });
|
|
145
115
|
}
|
|
146
|
-
init({ createDXTemplates
|
|
116
|
+
init({ createDXTemplates, clearInstantiationModels, updateTemplates });
|
|
147
117
|
}, [init, getRenderFunc]);
|
|
148
|
-
useEffect(
|
|
118
|
+
useEffect(() => {
|
|
149
119
|
if (updateContext) {
|
|
150
120
|
updateContext.onUpdated();
|
|
151
121
|
}
|
|
@@ -153,10 +123,9 @@ export var TemplateManager = function (_a) {
|
|
|
153
123
|
if (instantiationModels.empty) {
|
|
154
124
|
return null;
|
|
155
125
|
}
|
|
156
|
-
return (React.createElement(React.Fragment, null, Array.from(instantiationModels).map(
|
|
157
|
-
var _b = __read(_a, 2), _c = _b[0], data = _c.key1, container = _c.key2, _d = _b[1], index = _d.index, templateKey = _d.templateKey, componentKey = _d.componentKey, onRendered = _d.onRendered, onRemoved = _d.onRemoved;
|
|
126
|
+
return (React.createElement(React.Fragment, null, Array.from(instantiationModels).map(([{ key1: data, key2: container }, { index, templateKey, componentKey, onRendered, onRemoved, }]) => {
|
|
158
127
|
subscribeOnRemoval(container, onRemoved);
|
|
159
|
-
|
|
128
|
+
const factory = templateFactories.current[templateKey];
|
|
160
129
|
if (factory) {
|
|
161
130
|
return React.createElement(TemplateWrapper, { key: componentKey, templateFactory: factory, data: data, index: index, container: container, onRemoved: onRemoved, onRendered: onRendered });
|
|
162
131
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* devextreme-react
|
|
3
|
-
* Version: 24.1.
|
|
4
|
-
* Build date:
|
|
3
|
+
* Version: 24.1.3
|
|
4
|
+
* Build date: Tue Jun 11 2024
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
|
|
7
7
|
*
|
|
@@ -11,52 +11,35 @@
|
|
|
11
11
|
* https://github.com/DevExpress/devextreme-react
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
15
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
16
|
-
if (!m) return o;
|
|
17
|
-
var i = m.call(o), r, ar = [], e;
|
|
18
|
-
try {
|
|
19
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
20
|
-
}
|
|
21
|
-
catch (error) { e = { error: error }; }
|
|
22
|
-
finally {
|
|
23
|
-
try {
|
|
24
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
25
|
-
}
|
|
26
|
-
finally { if (e) throw e.error; }
|
|
27
|
-
}
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
14
|
import * as React from 'react';
|
|
31
15
|
import * as events from 'devextreme/events';
|
|
32
16
|
import { useCallback, useLayoutEffect, useEffect, useState, useRef, useMemo, memo, } from 'react';
|
|
33
17
|
import { createPortal } from 'react-dom';
|
|
34
18
|
import { DX_REMOVE_EVENT } from './component-base';
|
|
35
19
|
import { RemovalLockerContext } from './helpers';
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
const createHiddenNode = (containerNodeName, ref, defaultElement) => {
|
|
21
|
+
const style = { display: 'none' };
|
|
38
22
|
switch (containerNodeName) {
|
|
39
23
|
case 'TABLE':
|
|
40
24
|
return React.createElement("tbody", { style: style, ref: ref });
|
|
41
25
|
case 'TBODY':
|
|
42
26
|
return React.createElement("tr", { style: style, ref: ref });
|
|
43
27
|
default:
|
|
44
|
-
return React.createElement(defaultElement, { style
|
|
28
|
+
return React.createElement(defaultElement, { style, ref });
|
|
45
29
|
}
|
|
46
30
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if ((args === null || args === void 0 ? void 0 : args.isUnmounting) || isRemovalLocked.current) {
|
|
31
|
+
const TemplateWrapperComponent = ({ templateFactory, data, index, container, onRemoved, onRendered, }) => {
|
|
32
|
+
const [removalListenerRequired, setRemovalListenerRequired] = useState(false);
|
|
33
|
+
const isRemovalLocked = useRef(false);
|
|
34
|
+
const removalLocker = useMemo(() => ({
|
|
35
|
+
lock() { isRemovalLocked.current = true; },
|
|
36
|
+
unlock() { isRemovalLocked.current = false; },
|
|
37
|
+
}), []);
|
|
38
|
+
const element = useRef();
|
|
39
|
+
const hiddenNodeElement = useRef();
|
|
40
|
+
const removalListenerElement = useRef();
|
|
41
|
+
const onTemplateRemoved = useCallback((_, args) => {
|
|
42
|
+
if (args?.isUnmounting || isRemovalLocked.current) {
|
|
60
43
|
return;
|
|
61
44
|
}
|
|
62
45
|
if (element.current) {
|
|
@@ -67,8 +50,8 @@ var TemplateWrapperComponent = function (_a) {
|
|
|
67
50
|
}
|
|
68
51
|
onRemoved();
|
|
69
52
|
}, [onRemoved]);
|
|
70
|
-
useLayoutEffect(
|
|
71
|
-
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
const el = element.current;
|
|
72
55
|
if (el && el.nodeType === Node.ELEMENT_NODE) {
|
|
73
56
|
events.off(el, DX_REMOVE_EVENT, onTemplateRemoved);
|
|
74
57
|
events.on(el, DX_REMOVE_EVENT, onTemplateRemoved);
|
|
@@ -80,7 +63,7 @@ var TemplateWrapperComponent = function (_a) {
|
|
|
80
63
|
events.off(removalListenerElement.current, DX_REMOVE_EVENT, onTemplateRemoved);
|
|
81
64
|
events.on(removalListenerElement.current, DX_REMOVE_EVENT, onTemplateRemoved);
|
|
82
65
|
}
|
|
83
|
-
return
|
|
66
|
+
return () => {
|
|
84
67
|
if (element.current) {
|
|
85
68
|
container.appendChild(element.current);
|
|
86
69
|
}
|
|
@@ -95,20 +78,20 @@ var TemplateWrapperComponent = function (_a) {
|
|
|
95
78
|
}
|
|
96
79
|
};
|
|
97
80
|
}, [onTemplateRemoved, removalListenerRequired, container]);
|
|
98
|
-
useEffect(
|
|
81
|
+
useEffect(() => {
|
|
99
82
|
onRendered();
|
|
100
83
|
}, [onRendered]);
|
|
101
|
-
|
|
84
|
+
const hiddenNode = createHiddenNode(container?.nodeName, (node) => {
|
|
102
85
|
hiddenNodeElement.current = node;
|
|
103
|
-
element.current = node
|
|
86
|
+
element.current = node?.previousSibling;
|
|
104
87
|
}, 'div');
|
|
105
|
-
|
|
106
|
-
? createHiddenNode(container
|
|
88
|
+
const removalListener = removalListenerRequired
|
|
89
|
+
? createHiddenNode(container?.nodeName, (node) => { removalListenerElement.current = node; }, 'span')
|
|
107
90
|
: undefined;
|
|
108
91
|
return createPortal(React.createElement(React.Fragment, null,
|
|
109
92
|
React.createElement(RemovalLockerContext.Provider, { value: removalLocker },
|
|
110
|
-
templateFactory({ data
|
|
93
|
+
templateFactory({ data, index, onRendered }),
|
|
111
94
|
hiddenNode,
|
|
112
95
|
removalListener)), container);
|
|
113
96
|
};
|
|
114
|
-
export
|
|
97
|
+
export const TemplateWrapper = memo(TemplateWrapperComponent);
|
package/esm/core/template.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* devextreme-react
|
|
3
|
-
* Version: 24.1.
|
|
4
|
-
* Build date:
|
|
3
|
+
* Version: 24.1.3
|
|
4
|
+
* Build date: Tue Jun 11 2024
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
|
|
7
7
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { memo } from 'react';
|
|
15
|
-
|
|
15
|
+
const Template = memo(() => null);
|
|
16
16
|
function findProps(child) {
|
|
17
17
|
if (child.type !== Template) {
|
|
18
18
|
return undefined;
|
package/esm/core/types.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* devextreme-react
|
|
3
|
-
* Version: 24.1.
|
|
4
|
-
* Build date:
|
|
3
|
+
* Version: 24.1.3
|
|
4
|
+
* Build date: Tue Jun 11 2024
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
|
|
7
7
|
*
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
* https://github.com/DevExpress/devextreme-react
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const elementPropNames = ['style', 'id'];
|
|
15
|
+
const classNamePropName = 'className';
|
|
16
|
+
const refPropName = ['dropZone', 'dialogTrigger'];
|
|
17
|
+
const internalProps = {
|
|
18
18
|
WidgetClass: {},
|
|
19
19
|
isPortalComponent: false,
|
|
20
20
|
defaults: {},
|
|
@@ -23,10 +23,10 @@ var internalProps = {
|
|
|
23
23
|
subscribableOptions: [],
|
|
24
24
|
independentEvents: [],
|
|
25
25
|
useRequestAnimationFrameFlag: false,
|
|
26
|
-
clearExtensions:
|
|
27
|
-
renderChildren:
|
|
28
|
-
beforeCreateWidget:
|
|
29
|
-
afterCreateWidget:
|
|
26
|
+
clearExtensions: () => undefined,
|
|
27
|
+
renderChildren: () => undefined,
|
|
28
|
+
beforeCreateWidget: () => undefined,
|
|
29
|
+
afterCreateWidget: () => undefined,
|
|
30
30
|
};
|
|
31
31
|
function isIgnoredProp(name) {
|
|
32
32
|
return name === 'children'
|
|
@@ -35,9 +35,8 @@ function isIgnoredProp(name) {
|
|
|
35
35
|
|| Object.prototype.hasOwnProperty.call(internalProps, name);
|
|
36
36
|
}
|
|
37
37
|
function getRefElement(value) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if ((_b = (_a = value.current).instance) === null || _b === void 0 ? void 0 : _b.call(_a).element()) {
|
|
38
|
+
if (value?.current) {
|
|
39
|
+
if (value.current.instance?.().element()) {
|
|
41
40
|
return value.current.instance().element();
|
|
42
41
|
}
|
|
43
42
|
return value.current;
|
|
@@ -46,17 +45,17 @@ function getRefElement(value) {
|
|
|
46
45
|
}
|
|
47
46
|
function separateProps(props, defaultsProps, templateProps) {
|
|
48
47
|
templateProps = templateProps || [];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
templateProps.forEach(
|
|
48
|
+
const defaults = {};
|
|
49
|
+
const options = {};
|
|
50
|
+
const templates = {};
|
|
51
|
+
const knownTemplates = {};
|
|
52
|
+
templateProps.forEach((value) => {
|
|
54
53
|
knownTemplates[value.component] = true;
|
|
55
54
|
knownTemplates[value.render] = true;
|
|
56
55
|
});
|
|
57
|
-
Object.keys(props).forEach(
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
Object.keys(props).forEach((key) => {
|
|
57
|
+
const defaultOptionName = defaultsProps ? defaultsProps[key] : null;
|
|
58
|
+
const value = props[key];
|
|
60
59
|
if (isIgnoredProp(key)) {
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
@@ -74,7 +73,7 @@ function separateProps(props, defaultsProps, templateProps) {
|
|
|
74
73
|
}
|
|
75
74
|
options[key] = props[key];
|
|
76
75
|
});
|
|
77
|
-
return { options
|
|
76
|
+
return { options, defaults, templates };
|
|
78
77
|
}
|
|
79
78
|
function getClassName(props) {
|
|
80
79
|
return props[classNamePropName];
|