cx 22.4.1 → 22.5.0
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 +29 -9
- package/dist/manifest.js +495 -495
- package/dist/util.js +15 -9
- package/dist/widgets.js +39 -13
- package/package.json +1 -1
- package/src/core.d.ts +2 -0
- package/src/data/comparer.spec.js +28 -28
- package/src/data/createAccessorModelProxy.js +29 -7
- package/src/data/createAccessorModelProxy.spec.tsx +16 -2
- package/src/ui/Controller.d.ts +38 -1
- package/src/ui/Repeater.d.ts +3 -0
- package/src/ui/layout/Content.d.ts +7 -4
- package/src/util/isTouchEvent.js +33 -21
- package/src/util/scrollElementIntoView.d.ts +2 -1
- package/src/util/scrollElementIntoView.js +7 -32
- package/src/widgets/DocumentTitle.d.ts +2 -1
- package/src/widgets/List.d.ts +4 -1
- package/src/widgets/List.js +16 -14
- package/src/widgets/form/Calendar.d.ts +4 -1
- package/src/widgets/form/Calendar.js +23 -23
- package/src/widgets/form/TextField.js +3 -4
- package/src/widgets/grid/Grid.js +13 -4
- package/src/widgets/grid/GridRow.js +3 -3
- package/src/widgets/nav/Link.d.ts +5 -1
- package/src/widgets/nav/LinkButton.d.ts +1 -1
package/src/widgets/List.js
CHANGED
|
@@ -235,21 +235,23 @@ class ListComponent extends VDOM.Component {
|
|
|
235
235
|
if (widget.autoFocus) FocusManager.focus(this.el);
|
|
236
236
|
|
|
237
237
|
if (widget.onScroll) {
|
|
238
|
-
this.unsubscribeScroll = addEventListenerWithOptions(
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
this.unsubscribeScroll = addEventListenerWithOptions(
|
|
239
|
+
this.el,
|
|
240
|
+
"scroll",
|
|
241
|
+
(event) => {
|
|
242
|
+
instance.invoke("onScroll", event, instance);
|
|
243
|
+
},
|
|
244
|
+
{ passive: true }
|
|
245
|
+
);
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
this.componentDidUpdate();
|
|
244
249
|
}
|
|
245
250
|
|
|
246
251
|
UNSAFE_componentWillReceiveProps(props) {
|
|
247
|
-
if (this.state.focused && props.instance.widget.selectMode)
|
|
248
|
-
|
|
249
|
-
else if (this.state.
|
|
250
|
-
this.moveCursor(props.items.length - 1);
|
|
251
|
-
else if (this.state.focused && this.state.cursor < 0)
|
|
252
|
-
this.moveCursor(0);
|
|
252
|
+
if (this.state.focused && props.instance.widget.selectMode) this.showCursor(true, props.items);
|
|
253
|
+
else if (this.state.cursor >= props.items.length) this.moveCursor(props.items.length - 1);
|
|
254
|
+
else if (this.state.focused && this.state.cursor < 0) this.moveCursor(0);
|
|
253
255
|
}
|
|
254
256
|
|
|
255
257
|
componentWillUnmount() {
|
|
@@ -268,7 +270,7 @@ class ListComponent extends VDOM.Component {
|
|
|
268
270
|
select: true,
|
|
269
271
|
selectOptions: {
|
|
270
272
|
toggle: e.ctrlKey && !e.shiftKey,
|
|
271
|
-
add: e.ctrlKey && e.shiftKey
|
|
273
|
+
add: e.ctrlKey && e.shiftKey,
|
|
272
274
|
},
|
|
273
275
|
selectRange: e.shiftKey,
|
|
274
276
|
});
|
|
@@ -284,7 +286,7 @@ class ListComponent extends VDOM.Component {
|
|
|
284
286
|
select: true,
|
|
285
287
|
selectOptions: {
|
|
286
288
|
toggle: e.ctrlKey && !e.shiftKey,
|
|
287
|
-
add: e.ctrlKey && e.shiftKey
|
|
289
|
+
add: e.ctrlKey && e.shiftKey,
|
|
288
290
|
},
|
|
289
291
|
selectRange: e.shiftKey,
|
|
290
292
|
});
|
|
@@ -388,7 +390,7 @@ class ListComponent extends VDOM.Component {
|
|
|
388
390
|
let selectedRowSelector = `.${CSS.element(baseClass, "item")}.${CSS.state("selected")}`;
|
|
389
391
|
let firstSelectedRow = this.el.querySelector(selectedRowSelector);
|
|
390
392
|
if (firstSelectedRow != this.selectedEl) {
|
|
391
|
-
if (firstSelectedRow) scrollElementIntoView(firstSelectedRow);
|
|
393
|
+
if (firstSelectedRow) scrollElementIntoView(firstSelectedRow, true, false, 0, this.el);
|
|
392
394
|
this.selectedEl = firstSelectedRow;
|
|
393
395
|
}
|
|
394
396
|
}
|
|
@@ -422,7 +424,7 @@ class ListComponent extends VDOM.Component {
|
|
|
422
424
|
}
|
|
423
425
|
});
|
|
424
426
|
}
|
|
425
|
-
})
|
|
427
|
+
});
|
|
426
428
|
}
|
|
427
429
|
|
|
428
430
|
selectRange(from, to, options) {
|
|
@@ -515,7 +517,7 @@ class ListComponent extends VDOM.Component {
|
|
|
515
517
|
select: true,
|
|
516
518
|
selectOptions: {
|
|
517
519
|
toggle: e.ctrlKey && !e.shiftKey,
|
|
518
|
-
add: e.ctrlKey && e.shiftKey
|
|
520
|
+
add: e.ctrlKey && e.shiftKey,
|
|
519
521
|
},
|
|
520
522
|
selectRange: e.shiftKey,
|
|
521
523
|
});
|
|
@@ -51,7 +51,10 @@ interface CalendarProps extends FieldProps {
|
|
|
51
51
|
todayButtonText?: string;
|
|
52
52
|
|
|
53
53
|
/** Defines which days of week should be displayed as disabled, i.e. `[0, 6]` will make Sunday and Saturday unselectable. */
|
|
54
|
-
disabledDaysOfWeek?: number[]
|
|
54
|
+
disabledDaysOfWeek?: number[];
|
|
55
|
+
|
|
56
|
+
/** Set to true to show weeks starting from Monday. */
|
|
57
|
+
startWithMonday?: boolean;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
export class Calendar extends Cx.Widget<CalendarProps> {}
|
|
@@ -34,15 +34,14 @@ export class Calendar extends Field {
|
|
|
34
34
|
minExclusive: undefined,
|
|
35
35
|
maxValue: undefined,
|
|
36
36
|
maxExclusive: undefined,
|
|
37
|
-
focusable: undefined
|
|
37
|
+
focusable: undefined,
|
|
38
38
|
},
|
|
39
39
|
...arguments
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
init() {
|
|
44
|
-
if (this.unfocusable)
|
|
45
|
-
this.focusable = false;
|
|
44
|
+
if (this.unfocusable) this.focusable = false;
|
|
46
45
|
|
|
47
46
|
super.init();
|
|
48
47
|
}
|
|
@@ -127,18 +126,18 @@ export class Calendar extends Field {
|
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
Calendar.prototype.baseClass = "calendar";
|
|
130
|
+
Calendar.prototype.highlightToday = true;
|
|
131
|
+
Calendar.prototype.maxValueErrorText = "Select a date not after {0:d}.";
|
|
132
|
+
Calendar.prototype.maxExclusiveErrorText = "Select a date before {0:d}.";
|
|
133
|
+
Calendar.prototype.minValueErrorText = "Select a date not before {0:d}.";
|
|
134
|
+
Calendar.prototype.minExclusiveErrorText = "Select a date after {0:d}.";
|
|
135
|
+
Calendar.prototype.disabledDaysOfWeekErrorText = "Selected day of week is not allowed.";
|
|
136
|
+
Calendar.prototype.suppressErrorsUntilVisited = false;
|
|
137
|
+
Calendar.prototype.showTodayButton = false;
|
|
138
|
+
Calendar.prototype.todayButtonText = "Today";
|
|
139
|
+
Calendar.prototype.startWithMonday = false;
|
|
140
|
+
Calendar.prototype.focusable = true;
|
|
142
141
|
|
|
143
142
|
Localization.registerPrototype("cx/widgets/Calendar", Calendar);
|
|
144
143
|
|
|
@@ -175,13 +174,18 @@ export class CalendarCmp extends VDOM.Component {
|
|
|
175
174
|
getPage(refDate) {
|
|
176
175
|
refDate = monthStart(refDate); //make a copy
|
|
177
176
|
|
|
177
|
+
let startWithMonday = this.props.instance.widget.startWithMonday;
|
|
178
|
+
|
|
179
|
+
let startDay = startWithMonday ? 1 : 0;
|
|
178
180
|
let startDate = new Date(refDate);
|
|
179
|
-
startDate.
|
|
181
|
+
while (startDate.getDay() != startDay) startDate.setDate(startDate.getDate() - 1);
|
|
180
182
|
|
|
181
183
|
let endDate = new Date(refDate);
|
|
182
184
|
endDate.setMonth(refDate.getMonth() + 1);
|
|
183
185
|
endDate.setDate(endDate.getDate() - 1);
|
|
184
|
-
|
|
186
|
+
|
|
187
|
+
let endDay = startWithMonday ? 0 : 6;
|
|
188
|
+
while (endDate.getDay() != endDay) endDate.setDate(endDate.getDate() + 1);
|
|
185
189
|
|
|
186
190
|
return {
|
|
187
191
|
refDate,
|
|
@@ -373,19 +377,15 @@ export class CalendarCmp extends VDOM.Component {
|
|
|
373
377
|
let { data, widget } = this.props.instance;
|
|
374
378
|
let { CSS, baseClass, disabledDaysOfWeek, startWithMonday } = widget;
|
|
375
379
|
|
|
376
|
-
let refDate = this.state.refDate;
|
|
380
|
+
let { refDate, startDate, endDate } = this.getPage(this.state.refDate);
|
|
377
381
|
|
|
378
382
|
let month = refDate.getMonth();
|
|
379
383
|
let year = refDate.getFullYear();
|
|
380
|
-
|
|
381
|
-
let startDate = new Date(year, month, 1);
|
|
382
|
-
startDate.setDate(1 - startDate.getDay() + (startWithMonday ? 1 : 0));
|
|
383
|
-
|
|
384
384
|
let weeks = [];
|
|
385
385
|
let date = startDate;
|
|
386
386
|
|
|
387
387
|
let today = zeroTime(new Date());
|
|
388
|
-
while (date
|
|
388
|
+
while (date >= startDate && date <= endDate) {
|
|
389
389
|
let days = [];
|
|
390
390
|
for (let i = 0; i < 7; i++) {
|
|
391
391
|
let unselectable = !validationCheck(date, data, disabledDaysOfWeek);
|
|
@@ -37,7 +37,7 @@ export class TextField extends Field {
|
|
|
37
37
|
minLength: undefined,
|
|
38
38
|
maxLength: undefined,
|
|
39
39
|
icon: undefined,
|
|
40
|
-
trim: undefined
|
|
40
|
+
trim: undefined,
|
|
41
41
|
},
|
|
42
42
|
...arguments
|
|
43
43
|
);
|
|
@@ -269,7 +269,7 @@ class Input extends VDOM.Component {
|
|
|
269
269
|
|
|
270
270
|
let value = text || widget.emptyValue;
|
|
271
271
|
if (!instance.set("value", value, { immediate })) {
|
|
272
|
-
if (text != this.
|
|
272
|
+
if (text != this.input.value && immediate) this.input.value = text;
|
|
273
273
|
} else {
|
|
274
274
|
if (value) instance.setState({ visited: true });
|
|
275
275
|
}
|
|
@@ -277,8 +277,7 @@ class Input extends VDOM.Component {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
trimmed(value) {
|
|
280
|
-
if (this.props.data.trim && isString(value))
|
|
281
|
-
return value.trim();
|
|
280
|
+
if (this.props.data.trim && isString(value)) return value.trim();
|
|
282
281
|
return value;
|
|
283
282
|
}
|
|
284
283
|
}
|
package/src/widgets/grid/Grid.js
CHANGED
|
@@ -907,7 +907,7 @@ export class Grid extends Widget {
|
|
|
907
907
|
let data = store.getData();
|
|
908
908
|
let skip = 0;
|
|
909
909
|
|
|
910
|
-
let { header } = instance;
|
|
910
|
+
let { header, state } = instance;
|
|
911
911
|
let rowStyle = {};
|
|
912
912
|
|
|
913
913
|
let lines = [];
|
|
@@ -921,7 +921,7 @@ export class Grid extends Widget {
|
|
|
921
921
|
|
|
922
922
|
let v,
|
|
923
923
|
c = ci.widget,
|
|
924
|
-
colSpan,
|
|
924
|
+
colSpan = 1,
|
|
925
925
|
pad,
|
|
926
926
|
cls = "",
|
|
927
927
|
style = null;
|
|
@@ -934,7 +934,6 @@ export class Grid extends Widget {
|
|
|
934
934
|
empty = false;
|
|
935
935
|
cls = CSS.expand(c.footer.class(data)) || "";
|
|
936
936
|
style = parseStyle(c.footer.style(data));
|
|
937
|
-
|
|
938
937
|
if (c.footer.expand) {
|
|
939
938
|
colSpan = 1;
|
|
940
939
|
for (
|
|
@@ -959,6 +958,16 @@ export class Grid extends Widget {
|
|
|
959
958
|
|
|
960
959
|
if (pad !== false) cls += (cls ? " " : "") + CSS.state("pad");
|
|
961
960
|
|
|
961
|
+
// apply column width to footers too, but only if colSpan == 1,
|
|
962
|
+
// otherwise set 1px so that the footer is not participating in the layout
|
|
963
|
+
|
|
964
|
+
let maxWidth = 1;
|
|
965
|
+
if (colSpan == 1) maxWidth = state.colWidth[c.uniqueColumnId];
|
|
966
|
+
style = {
|
|
967
|
+
...style,
|
|
968
|
+
maxWidth,
|
|
969
|
+
};
|
|
970
|
+
|
|
962
971
|
return (
|
|
963
972
|
<td key={i} className={cls} colSpan={colSpan} style={style}>
|
|
964
973
|
{v}
|
|
@@ -2475,7 +2484,7 @@ class GridComponent extends VDOM.Component {
|
|
|
2475
2484
|
if (!futureState.cellEdit && wasCellEditing) {
|
|
2476
2485
|
//If cell editing is in progress, moving the cursor may cause that the cell editor is unmounted before
|
|
2477
2486
|
//the blur event which may cause data loss for components which do not have reactOn=change set, e.g. NumberField.
|
|
2478
|
-
unfocusElement();
|
|
2487
|
+
unfocusElement(null, false);
|
|
2479
2488
|
let record = this.getRecordAt(prevState.cursor);
|
|
2480
2489
|
if ((!this.cellEditorValid || cancelEdit) && this.cellEditUndoData)
|
|
2481
2490
|
record.store.set(widget.recordName, this.cellEditUndoData);
|
|
@@ -119,7 +119,7 @@ export class GridRowComponent extends VDOM.Component {
|
|
|
119
119
|
e.stopPropagation();
|
|
120
120
|
|
|
121
121
|
//close context menu
|
|
122
|
-
unfocusElement(e.target);
|
|
122
|
+
unfocusElement(e.target, false);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -134,7 +134,7 @@ export class GridRowComponent extends VDOM.Component {
|
|
|
134
134
|
selectRange: e.shiftKey,
|
|
135
135
|
selectOptions: {
|
|
136
136
|
toggle: e.ctrlKey && !e.shiftKey,
|
|
137
|
-
add: e.ctrlKey && e.shiftKey
|
|
137
|
+
add: e.ctrlKey && e.shiftKey,
|
|
138
138
|
},
|
|
139
139
|
cellIndex: this.getCellIndex(e),
|
|
140
140
|
});
|
|
@@ -190,7 +190,7 @@ export class GridRowComponent extends VDOM.Component {
|
|
|
190
190
|
selectRange: e.shiftKey,
|
|
191
191
|
selectOptions: {
|
|
192
192
|
toggle: e.ctrlKey && !e.shiftKey,
|
|
193
|
-
add: e.ctrlKey && e.shiftKey
|
|
193
|
+
add: e.ctrlKey && e.shiftKey,
|
|
194
194
|
},
|
|
195
195
|
cellIndex: this.getCellIndex(e),
|
|
196
196
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import * as Cx from "../../core";
|
|
3
|
+
import { Instance } from "../../ui/Instance";
|
|
4
|
+
import { LinkButtonProps } from "./LinkButton";
|
|
2
5
|
|
|
3
|
-
interface LinkProps extends
|
|
6
|
+
interface LinkProps extends LinkButtonProps {
|
|
4
7
|
/** Set to `true` to disable the link. */
|
|
5
8
|
disabled?: Cx.BooleanProp;
|
|
6
9
|
|
|
@@ -17,6 +20,7 @@ interface LinkProps extends Cx.HtmlElementProps {
|
|
|
17
20
|
|
|
18
21
|
activeClass?: Cx.ClassProp;
|
|
19
22
|
activeStyle?: Cx.StyleProp;
|
|
23
|
+
onClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export class Link extends Cx.Widget<LinkProps> {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Cx from "../../core";
|
|
2
2
|
import { ButtonProps } from "../Button";
|
|
3
3
|
|
|
4
|
-
interface LinkButtonProps extends ButtonProps {
|
|
4
|
+
export interface LinkButtonProps extends ButtonProps {
|
|
5
5
|
/** Url to the link's target location. Should start with `~/` or `#/` for pushState/hash based navigation. */
|
|
6
6
|
href?: Cx.StringProp;
|
|
7
7
|
|