cx 23.4.4 → 23.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data.js +2 -9
- package/dist/manifest.js +874 -874
- package/dist/widgets.js +32 -11
- package/package.json +1 -1
- package/src/data/Binding.js +2 -12
- package/src/data/Binding.spec.js +48 -38
- package/src/data/createAccessorModelProxy.spec.tsx +6 -0
- package/src/ui/Restate.js +158 -158
- package/src/widgets/grid/Grid.js +22 -11
package/dist/widgets.js
CHANGED
|
@@ -15849,12 +15849,19 @@ var Grid = /*#__PURE__*/ (function (_Container) {
|
|
|
15849
15849
|
onClick: function onClick(e) {
|
|
15850
15850
|
e.stopPropagation();
|
|
15851
15851
|
},
|
|
15852
|
+
"data-unique-col-id": hdwidget.uniqueColumnId,
|
|
15852
15853
|
onMouseDown: function onMouseDown(e) {
|
|
15853
15854
|
if (e.buttons != 1) return;
|
|
15854
15855
|
var resizeOverlayEl = document.createElement("div");
|
|
15855
|
-
var
|
|
15856
|
-
|
|
15857
|
-
var
|
|
15856
|
+
var headerTBody = e.target.parentElement.parentElement.parentElement;
|
|
15857
|
+
var uniqueColId = e.currentTarget.dataset.uniqueColId;
|
|
15858
|
+
var headerCell = findFirstChild(headerTBody, function (el) {
|
|
15859
|
+
var _el$dataset;
|
|
15860
|
+
return (
|
|
15861
|
+
el.tagName == "TH" && ((_el$dataset = el.dataset) == null ? void 0 : _el$dataset.uniqueColId) == uniqueColId
|
|
15862
|
+
);
|
|
15863
|
+
});
|
|
15864
|
+
var scrollAreaEl = headerTBody.parentElement.parentElement;
|
|
15858
15865
|
var gridEl = scrollAreaEl.parentElement;
|
|
15859
15866
|
var initialWidth = headerCell.offsetWidth;
|
|
15860
15867
|
var initialPosition = getCursorPos(e);
|
|
@@ -15978,15 +15985,16 @@ var Grid = /*#__PURE__*/ (function (_Container) {
|
|
|
15978
15985
|
});
|
|
15979
15986
|
}
|
|
15980
15987
|
}
|
|
15988
|
+
var uniqueColumnId = header.data.colSpan > 1 ? null : hdwidget.uniqueColumnId;
|
|
15981
15989
|
style = header.data.style;
|
|
15982
15990
|
var customWidth =
|
|
15983
15991
|
header.data.width ||
|
|
15984
|
-
instance.state.colWidth[
|
|
15992
|
+
instance.state.colWidth[uniqueColumnId] ||
|
|
15985
15993
|
header.data.defaultWidth ||
|
|
15986
|
-
instance.state.lockedColWidth[
|
|
15994
|
+
instance.state.lockedColWidth[uniqueColumnId];
|
|
15987
15995
|
if (customWidth) {
|
|
15988
|
-
if (instance.state.colWidth[
|
|
15989
|
-
instance.state.colWidth[
|
|
15996
|
+
if (instance.state.colWidth[uniqueColumnId] != customWidth)
|
|
15997
|
+
instance.state.colWidth[uniqueColumnId] = customWidth;
|
|
15990
15998
|
var s = customWidth + "px";
|
|
15991
15999
|
style = _objectSpread2(
|
|
15992
16000
|
_objectSpread2({}, style),
|
|
@@ -16018,11 +16026,24 @@ var Grid = /*#__PURE__*/ (function (_Container) {
|
|
|
16018
16026
|
resizer = _this3.renderResizer(instance, hdinst, header, colIndex);
|
|
16019
16027
|
}
|
|
16020
16028
|
if (colIndex > 0) {
|
|
16029
|
+
var _headerPrev, _headerPrev$data, _headerPrev2, _headerPrev2$data;
|
|
16021
16030
|
var hdinstPrev = line.children[colIndex - 1];
|
|
16022
|
-
var
|
|
16031
|
+
var prevLine = 3;
|
|
16032
|
+
var headerPrev;
|
|
16033
|
+
while (!headerPrev && prevLine >= 0) {
|
|
16034
|
+
headerPrev = hdinstPrev.components["header" + (prevLine + 1)];
|
|
16035
|
+
prevLine--;
|
|
16036
|
+
}
|
|
16023
16037
|
if (
|
|
16024
|
-
(hdinstPrev.widget.resizable ||
|
|
16025
|
-
|
|
16038
|
+
(hdinstPrev.widget.resizable ||
|
|
16039
|
+
((_headerPrev = headerPrev) != null &&
|
|
16040
|
+
(_headerPrev$data = _headerPrev.data) != null &&
|
|
16041
|
+
_headerPrev$data.resizable)) &&
|
|
16042
|
+
((_headerPrev2 = headerPrev) == null
|
|
16043
|
+
? void 0
|
|
16044
|
+
: (_headerPrev2$data = _headerPrev2.data) == null
|
|
16045
|
+
? void 0
|
|
16046
|
+
: _headerPrev2$data.colSpan) < 2
|
|
16026
16047
|
) {
|
|
16027
16048
|
prevColumnResizer = _this3.renderResizer(instance, hdinstPrev, headerPrev, colIndex - 1, true);
|
|
16028
16049
|
}
|
|
@@ -16053,7 +16074,7 @@ var Grid = /*#__PURE__*/ (function (_Container) {
|
|
|
16053
16074
|
return _this3.onHeaderClick(e, hdwidget, instance, l);
|
|
16054
16075
|
},
|
|
16055
16076
|
onContextMenu: onContextMenu,
|
|
16056
|
-
"data-unique-col-id": hdwidget.uniqueColumnId,
|
|
16077
|
+
"data-unique-col-id": colSpan > 1 ? null : hdwidget.uniqueColumnId,
|
|
16057
16078
|
children: [getContent(content), sortIcon, tool, prevColumnResizer, resizer],
|
|
16058
16079
|
},
|
|
16059
16080
|
colIndex
|
package/package.json
CHANGED
package/src/data/Binding.js
CHANGED
|
@@ -7,18 +7,8 @@ export class Binding {
|
|
|
7
7
|
constructor(path) {
|
|
8
8
|
this.path = path;
|
|
9
9
|
this.parts = path.split(".");
|
|
10
|
-
let body = "return
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
for (let i = 0; i < this.parts.length; i++) {
|
|
14
|
-
if (this.parts[i][0] >= "0" && this.parts[i][0] <= "9") selector += "[" + this.parts[i] + "]";
|
|
15
|
-
else selector += "." + this.parts[i];
|
|
16
|
-
|
|
17
|
-
if (i + 1 < this.parts.length) body += " && " + selector;
|
|
18
|
-
else body += " ? " + selector + " : undefined";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
body += ")";
|
|
10
|
+
let body = "return x";
|
|
11
|
+
for (let i = 0; i < this.parts.length; i++) body += '?.["' + this.parts[i] + '"]';
|
|
22
12
|
this.value = new Function("x", body);
|
|
23
13
|
}
|
|
24
14
|
|
package/src/data/Binding.spec.js
CHANGED
|
@@ -1,49 +1,59 @@
|
|
|
1
|
-
import {Binding} from
|
|
2
|
-
import assert from
|
|
3
|
-
|
|
4
|
-
describe(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
});
|
|
1
|
+
import { Binding } from "./Binding";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
|
|
4
|
+
describe("Binding", function () {
|
|
5
|
+
describe("#get()", function () {
|
|
6
|
+
it("should get value if value is defined", function () {
|
|
7
|
+
var state = { person: { name: "Joe" } };
|
|
8
|
+
var b = Binding.get("person.name");
|
|
9
|
+
assert.equal(b.value(state), "Joe");
|
|
10
|
+
});
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
it("allows non-standard property identifiers", function () {
|
|
13
|
+
var state = { person: { "@schema": "Person" } };
|
|
14
|
+
var b = Binding.get("person.@schema");
|
|
15
|
+
assert.equal(b.value(state), "Person");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
describe("#set()", function () {
|
|
20
|
+
it("produces new objects along the binding path", function () {
|
|
21
|
+
var state = { person: { name: "Joe" } };
|
|
22
|
+
var b = Binding.get("person.name");
|
|
23
|
+
var ns = b.set(state, "Jack");
|
|
24
|
+
assert.equal(ns.person.name, "Jack");
|
|
25
|
+
assert.notEqual(state, ns);
|
|
26
|
+
assert.notEqual(state.person, ns.person);
|
|
27
|
+
assert.notEqual(state.person.name, ns.person.name);
|
|
28
|
+
});
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
30
|
+
it("returns same state object if value does not change", function () {
|
|
31
|
+
var state = { person: { name: "Joe" } };
|
|
32
|
+
var b = Binding.get("person.name");
|
|
33
|
+
var ns = b.set(state, "Joe");
|
|
34
|
+
assert.equal(state, ns);
|
|
35
|
+
});
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
it("allows non-standard property identifiers", function () {
|
|
38
|
+
var state = { person: { "@schema": "Person" } };
|
|
39
|
+
var b = Binding.get("person.@schema");
|
|
40
|
+
var ns = b.set(state, "Test");
|
|
41
|
+
assert.equal(ns.person["@schema"], "Test");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
45
|
+
describe(".delete()", function () {
|
|
46
|
+
it("correctly removes pointed properties", function () {
|
|
47
|
+
var state = { person: { name: "Joe" } };
|
|
48
|
+
var b = Binding.get("person.name");
|
|
39
49
|
var ns = b.delete(state);
|
|
40
|
-
assert(
|
|
41
|
-
assert(!(
|
|
50
|
+
assert("person" in ns);
|
|
51
|
+
assert(!("name" in ns.person));
|
|
42
52
|
});
|
|
43
53
|
|
|
44
|
-
it(
|
|
45
|
-
var state = {person: {name:
|
|
46
|
-
var b = Binding.get(
|
|
54
|
+
it("does not change state if property is non-existent", function () {
|
|
55
|
+
var state = { person: { name: "Joe" } };
|
|
56
|
+
var b = Binding.get("person.name2");
|
|
47
57
|
var ns = b.delete(state);
|
|
48
58
|
assert(ns == state);
|
|
49
59
|
});
|
|
@@ -7,6 +7,7 @@ interface Model {
|
|
|
7
7
|
city: string;
|
|
8
8
|
streetNumber: number;
|
|
9
9
|
};
|
|
10
|
+
"@crazy": string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
describe("createAccessorModelProxy", () => {
|
|
@@ -35,4 +36,9 @@ describe("createAccessorModelProxy", () => {
|
|
|
35
36
|
assert.strictEqual(streetNumber.nameOf(), "streetNumber");
|
|
36
37
|
assert.strictEqual(city.nameOf(), "city");
|
|
37
38
|
});
|
|
39
|
+
|
|
40
|
+
it("allows non-standard property identifiers ", () => {
|
|
41
|
+
let model = createAccessorModelProxy<Model>();
|
|
42
|
+
assert.strictEqual(model["@crazy"].nameOf(), "@crazy");
|
|
43
|
+
});
|
|
38
44
|
});
|
package/src/ui/Restate.js
CHANGED
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
import { PureContainer } from "./PureContainer";
|
|
2
|
-
import { Store } from "../data/Store";
|
|
3
|
-
import { Cx } from "./Cx";
|
|
4
|
-
import { isString } from "../util/isString";
|
|
5
|
-
import { VDOM } from "./VDOM";
|
|
6
|
-
import { isFunction } from "../util/isFunction";
|
|
7
|
-
import { isObject } from "../util/isObject";
|
|
8
|
-
import { isUndefined } from "../util/isUndefined";
|
|
9
|
-
import { Binding } from "../data/Binding";
|
|
10
|
-
import { StructuredSelector } from "../data/StructuredSelector";
|
|
11
|
-
|
|
12
|
-
let persistenceCache = {};
|
|
13
|
-
|
|
14
|
-
export class Restate extends PureContainer {
|
|
15
|
-
declareData() {
|
|
16
|
-
return super.declareData(...arguments, {
|
|
17
|
-
deferredUntilIdle: undefined,
|
|
18
|
-
idleTimeout: undefined,
|
|
19
|
-
cacheKey: undefined,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
init() {
|
|
24
|
-
this.container = PureContainer.create({
|
|
25
|
-
type: PureContainer,
|
|
26
|
-
items: this.children || this.items,
|
|
27
|
-
layout: this.layout,
|
|
28
|
-
controller: this.controller,
|
|
29
|
-
outerLayout: this.outerLayout,
|
|
30
|
-
useParentLayout: !this.detached,
|
|
31
|
-
ws: this.ws,
|
|
32
|
-
});
|
|
33
|
-
this.privateDataSelector = new StructuredSelector({
|
|
34
|
-
props: this.data || {},
|
|
35
|
-
values: this.data,
|
|
36
|
-
});
|
|
37
|
-
delete this.items;
|
|
38
|
-
delete this.children;
|
|
39
|
-
delete this.controller;
|
|
40
|
-
delete this.outerLayout;
|
|
41
|
-
delete this.layout;
|
|
42
|
-
if (this.useParentLayout == null) this.useParentLayout = !this.detached;
|
|
43
|
-
super.init();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
initSubStore(context, instance) {
|
|
47
|
-
let { cacheKey } = instance.data;
|
|
48
|
-
this.privateDataSelector.init(instance.store);
|
|
49
|
-
instance.subStore = new RestateStore({
|
|
50
|
-
store: instance.store,
|
|
51
|
-
detached: this.detached,
|
|
52
|
-
privateData: this.data || {},
|
|
53
|
-
data: cacheKey ? persistenceCache[cacheKey] || {} : {},
|
|
54
|
-
dataSelector: this.privateDataSelector.create(),
|
|
55
|
-
onSet: (path, value) => instance.nestedDataSet(path, value, this.data),
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
instance.setStore = (store) => {
|
|
59
|
-
instance.store = store;
|
|
60
|
-
instance.subStore.setStore(store);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
if (cacheKey) {
|
|
64
|
-
instance.subscribeOnDestroy(() => {
|
|
65
|
-
persistenceCache[cacheKey] = instance.subStore.getData();
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
explore(context, instance) {
|
|
71
|
-
if (!instance.subStore) this.initSubStore(context, instance);
|
|
72
|
-
if (instance.subStore.parentDataCheck()) instance.markShouldUpdate();
|
|
73
|
-
super.explore(context, instance);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
exploreItems(context, instance, items) {
|
|
77
|
-
if (!this.detached) {
|
|
78
|
-
instance.container = instance.getChild(context, this.container, "container", instance.subStore);
|
|
79
|
-
instance.container.scheduleExploreIfVisible(context);
|
|
80
|
-
instance.children = [instance.container];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
render(context, instance, key) {
|
|
85
|
-
if (!this.detached) return instance.container.render(context);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<Cx
|
|
89
|
-
key={key}
|
|
90
|
-
widget={this.container}
|
|
91
|
-
parentInstance={instance}
|
|
92
|
-
store={instance.subStore}
|
|
93
|
-
subscribe
|
|
94
|
-
options={this.options}
|
|
95
|
-
onError={this.onError}
|
|
96
|
-
deferredUntilIdle={instance.data.deferredUntilIdle}
|
|
97
|
-
idleTimeout={instance.data.idleTimeout}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
Restate.prototype.detached = false;
|
|
104
|
-
Restate.prototype.waitForIdle = false;
|
|
105
|
-
|
|
106
|
-
export const PrivateStore = Restate;
|
|
107
|
-
|
|
108
|
-
class RestateStore extends Store {
|
|
109
|
-
constructor(config) {
|
|
110
|
-
super(config);
|
|
111
|
-
this.parentDataVersion = -1;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
getData() {
|
|
115
|
-
this.silently(() => {
|
|
116
|
-
this.parentDataCheck();
|
|
117
|
-
});
|
|
118
|
-
return super.getData();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
parentDataCheck() {
|
|
122
|
-
if (this.parentDataVersion == this.store.meta.version) return false;
|
|
123
|
-
this.parentDataVersion = this.store.meta.version;
|
|
124
|
-
this.parentData = this.dataSelector(this.store.getData());
|
|
125
|
-
return this.batch(() => {
|
|
126
|
-
for (let key in this.parentData) {
|
|
127
|
-
super.setItem(key, this.parentData[key]);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
setItem(path, value) {
|
|
133
|
-
let binding = Binding.get(path);
|
|
134
|
-
let bindingRoot = binding.parts[0];
|
|
135
|
-
if (!isObject(this.privateData) || !this.privateData.hasOwnProperty(bindingRoot)) {
|
|
136
|
-
let changed = isUndefined(value) ? super.deleteItem(path) : super.setItem(path, value);
|
|
137
|
-
return changed;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
let newValue = value;
|
|
141
|
-
if (binding.parts.length > 1) newValue = binding.set(this.getData(), value)[bindingRoot];
|
|
142
|
-
this.onSet(bindingRoot, newValue);
|
|
143
|
-
this.batch(() => {
|
|
144
|
-
super.setItem(bindingRoot, newValue);
|
|
145
|
-
this.parentDataCheck();
|
|
146
|
-
});
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
deleteItem(path) {
|
|
151
|
-
return this.setItem(path, undefined);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
doNotify() {
|
|
155
|
-
if (!this.detached) this.store.notify();
|
|
156
|
-
super.doNotify();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
1
|
+
import { PureContainer } from "./PureContainer";
|
|
2
|
+
import { Store } from "../data/Store";
|
|
3
|
+
import { Cx } from "./Cx";
|
|
4
|
+
import { isString } from "../util/isString";
|
|
5
|
+
import { VDOM } from "./VDOM";
|
|
6
|
+
import { isFunction } from "../util/isFunction";
|
|
7
|
+
import { isObject } from "../util/isObject";
|
|
8
|
+
import { isUndefined } from "../util/isUndefined";
|
|
9
|
+
import { Binding } from "../data/Binding";
|
|
10
|
+
import { StructuredSelector } from "../data/StructuredSelector";
|
|
11
|
+
|
|
12
|
+
let persistenceCache = {};
|
|
13
|
+
|
|
14
|
+
export class Restate extends PureContainer {
|
|
15
|
+
declareData() {
|
|
16
|
+
return super.declareData(...arguments, {
|
|
17
|
+
deferredUntilIdle: undefined,
|
|
18
|
+
idleTimeout: undefined,
|
|
19
|
+
cacheKey: undefined,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
init() {
|
|
24
|
+
this.container = PureContainer.create({
|
|
25
|
+
type: PureContainer,
|
|
26
|
+
items: this.children || this.items,
|
|
27
|
+
layout: this.layout,
|
|
28
|
+
controller: this.controller,
|
|
29
|
+
outerLayout: this.outerLayout,
|
|
30
|
+
useParentLayout: !this.detached,
|
|
31
|
+
ws: this.ws,
|
|
32
|
+
});
|
|
33
|
+
this.privateDataSelector = new StructuredSelector({
|
|
34
|
+
props: this.data || {},
|
|
35
|
+
values: this.data,
|
|
36
|
+
});
|
|
37
|
+
delete this.items;
|
|
38
|
+
delete this.children;
|
|
39
|
+
delete this.controller;
|
|
40
|
+
delete this.outerLayout;
|
|
41
|
+
delete this.layout;
|
|
42
|
+
if (this.useParentLayout == null) this.useParentLayout = !this.detached;
|
|
43
|
+
super.init();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
initSubStore(context, instance) {
|
|
47
|
+
let { cacheKey } = instance.data;
|
|
48
|
+
this.privateDataSelector.init(instance.store);
|
|
49
|
+
instance.subStore = new RestateStore({
|
|
50
|
+
store: instance.store,
|
|
51
|
+
detached: this.detached,
|
|
52
|
+
privateData: this.data || {},
|
|
53
|
+
data: cacheKey ? persistenceCache[cacheKey] || {} : {},
|
|
54
|
+
dataSelector: this.privateDataSelector.create(),
|
|
55
|
+
onSet: (path, value) => instance.nestedDataSet(path, value, this.data),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
instance.setStore = (store) => {
|
|
59
|
+
instance.store = store;
|
|
60
|
+
instance.subStore.setStore(store);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (cacheKey) {
|
|
64
|
+
instance.subscribeOnDestroy(() => {
|
|
65
|
+
persistenceCache[cacheKey] = instance.subStore.getData();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
explore(context, instance) {
|
|
71
|
+
if (!instance.subStore) this.initSubStore(context, instance);
|
|
72
|
+
if (instance.subStore.parentDataCheck()) instance.markShouldUpdate();
|
|
73
|
+
super.explore(context, instance);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
exploreItems(context, instance, items) {
|
|
77
|
+
if (!this.detached) {
|
|
78
|
+
instance.container = instance.getChild(context, this.container, "container", instance.subStore);
|
|
79
|
+
instance.container.scheduleExploreIfVisible(context);
|
|
80
|
+
instance.children = [instance.container];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
render(context, instance, key) {
|
|
85
|
+
if (!this.detached) return instance.container.render(context);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Cx
|
|
89
|
+
key={key}
|
|
90
|
+
widget={this.container}
|
|
91
|
+
parentInstance={instance}
|
|
92
|
+
store={instance.subStore}
|
|
93
|
+
subscribe
|
|
94
|
+
options={this.options}
|
|
95
|
+
onError={this.onError}
|
|
96
|
+
deferredUntilIdle={instance.data.deferredUntilIdle}
|
|
97
|
+
idleTimeout={instance.data.idleTimeout}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Restate.prototype.detached = false;
|
|
104
|
+
Restate.prototype.waitForIdle = false;
|
|
105
|
+
|
|
106
|
+
export const PrivateStore = Restate;
|
|
107
|
+
|
|
108
|
+
class RestateStore extends Store {
|
|
109
|
+
constructor(config) {
|
|
110
|
+
super(config);
|
|
111
|
+
this.parentDataVersion = -1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getData() {
|
|
115
|
+
this.silently(() => {
|
|
116
|
+
this.parentDataCheck();
|
|
117
|
+
});
|
|
118
|
+
return super.getData();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
parentDataCheck() {
|
|
122
|
+
if (this.parentDataVersion == this.store.meta.version) return false;
|
|
123
|
+
this.parentDataVersion = this.store.meta.version;
|
|
124
|
+
this.parentData = this.dataSelector(this.store.getData());
|
|
125
|
+
return this.batch(() => {
|
|
126
|
+
for (let key in this.parentData) {
|
|
127
|
+
super.setItem(key, this.parentData[key]);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
setItem(path, value) {
|
|
133
|
+
let binding = Binding.get(path);
|
|
134
|
+
let bindingRoot = binding.parts[0];
|
|
135
|
+
if (!isObject(this.privateData) || !this.privateData.hasOwnProperty(bindingRoot)) {
|
|
136
|
+
let changed = isUndefined(value) ? super.deleteItem(path) : super.setItem(path, value);
|
|
137
|
+
return changed;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let newValue = value;
|
|
141
|
+
if (binding.parts.length > 1) newValue = binding.set(this.getData(), value)[bindingRoot];
|
|
142
|
+
this.onSet(bindingRoot, newValue);
|
|
143
|
+
this.batch(() => {
|
|
144
|
+
super.setItem(bindingRoot, newValue);
|
|
145
|
+
this.parentDataCheck();
|
|
146
|
+
});
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
deleteItem(path) {
|
|
151
|
+
return this.setItem(path, undefined);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
doNotify() {
|
|
155
|
+
if (!this.detached) this.store.notify();
|
|
156
|
+
super.doNotify();
|
|
157
|
+
}
|
|
158
|
+
}
|
package/src/widgets/grid/Grid.js
CHANGED
|
@@ -42,6 +42,7 @@ import { StaticText } from "../../ui/StaticText";
|
|
|
42
42
|
import { unfocusElement } from "../../ui/FocusManager";
|
|
43
43
|
import { tooltipMouseMove, tooltipMouseLeave } from "../overlay/tooltip-ops";
|
|
44
44
|
import { Container } from "../../ui/Container";
|
|
45
|
+
import { findFirstChild } from "../../util/DOM";
|
|
45
46
|
|
|
46
47
|
export class Grid extends Container {
|
|
47
48
|
declareData(...args) {
|
|
@@ -510,13 +511,16 @@ export class Grid extends Container {
|
|
|
510
511
|
onClick={(e) => {
|
|
511
512
|
e.stopPropagation();
|
|
512
513
|
}}
|
|
514
|
+
data-unique-col-id={hdwidget.uniqueColumnId}
|
|
513
515
|
onMouseDown={(e) => {
|
|
514
516
|
if (e.buttons != 1) return;
|
|
515
517
|
let resizeOverlayEl = document.createElement("div");
|
|
516
|
-
|
|
517
|
-
|
|
518
|
+
|
|
519
|
+
let headerTBody = e.target.parentElement.parentElement.parentElement;
|
|
520
|
+
let uniqueColId = e.currentTarget.dataset.uniqueColId;
|
|
518
521
|
|
|
519
|
-
let
|
|
522
|
+
let headerCell = findFirstChild(headerTBody, el => el.tagName == 'TH' && el.dataset?.uniqueColId == uniqueColId);
|
|
523
|
+
let scrollAreaEl = headerTBody.parentElement.parentElement;
|
|
520
524
|
let gridEl = scrollAreaEl.parentElement;
|
|
521
525
|
let initialWidth = headerCell.offsetWidth;
|
|
522
526
|
let initialPosition = getCursorPos(e);
|
|
@@ -640,15 +644,17 @@ export class Grid extends Container {
|
|
|
640
644
|
}
|
|
641
645
|
}
|
|
642
646
|
|
|
647
|
+
let uniqueColumnId = header.data.colSpan > 1 ? null : hdwidget.uniqueColumnId;
|
|
648
|
+
|
|
643
649
|
style = header.data.style;
|
|
644
650
|
let customWidth =
|
|
645
651
|
header.data.width ||
|
|
646
|
-
instance.state.colWidth[
|
|
652
|
+
instance.state.colWidth[uniqueColumnId] ||
|
|
647
653
|
header.data.defaultWidth ||
|
|
648
|
-
instance.state.lockedColWidth[
|
|
654
|
+
instance.state.lockedColWidth[uniqueColumnId];
|
|
649
655
|
if (customWidth) {
|
|
650
|
-
if (instance.state.colWidth[
|
|
651
|
-
instance.state.colWidth[
|
|
656
|
+
if (instance.state.colWidth[uniqueColumnId] != customWidth)
|
|
657
|
+
instance.state.colWidth[uniqueColumnId] = customWidth;
|
|
652
658
|
let s = `${customWidth}px`;
|
|
653
659
|
style = {
|
|
654
660
|
...style,
|
|
@@ -686,10 +692,15 @@ export class Grid extends Container {
|
|
|
686
692
|
|
|
687
693
|
if (colIndex > 0) {
|
|
688
694
|
let hdinstPrev = line.children[colIndex - 1];
|
|
689
|
-
let
|
|
695
|
+
let prevLine = 3;
|
|
696
|
+
let headerPrev;
|
|
697
|
+
while (!headerPrev && prevLine >= 0) {
|
|
698
|
+
headerPrev = hdinstPrev.components[`header${prevLine + 1}`];
|
|
699
|
+
prevLine--;
|
|
700
|
+
}
|
|
690
701
|
if (
|
|
691
|
-
(hdinstPrev.widget.resizable ||
|
|
692
|
-
headerPrev
|
|
702
|
+
(hdinstPrev.widget.resizable || headerPrev?.data?.resizable) &&
|
|
703
|
+
headerPrev?.data?.colSpan < 2
|
|
693
704
|
) {
|
|
694
705
|
prevColumnResizer = this.renderResizer(instance, hdinstPrev, headerPrev, colIndex - 1, true);
|
|
695
706
|
}
|
|
@@ -714,7 +725,7 @@ export class Grid extends Container {
|
|
|
714
725
|
onMouseLeave={(e) => this.onHeaderMouseLeave(e, hdinst, l)}
|
|
715
726
|
onClick={(e) => this.onHeaderClick(e, hdwidget, instance, l)}
|
|
716
727
|
onContextMenu={onContextMenu}
|
|
717
|
-
data-unique-col-id={hdwidget.uniqueColumnId}
|
|
728
|
+
data-unique-col-id={colSpan > 1 ? null: hdwidget.uniqueColumnId}
|
|
718
729
|
>
|
|
719
730
|
{getContent(content)}
|
|
720
731
|
{sortIcon}
|