cx 22.4.3 → 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/util.js CHANGED
@@ -1204,15 +1204,17 @@ var lastTouchEvent = 0;
1204
1204
  var isTouchDetectionEnabled = false;
1205
1205
  function enableTouchEventDetection() {
1206
1206
  if (isTouchDevice() && !isTouchDetectionEnabled) {
1207
- var options;
1207
+ var options = true; //capture
1208
+
1208
1209
  if (browserSupportsPassiveEventHandlers())
1209
1210
  options = {
1210
- passive: true
1211
+ passive: true,
1212
+ capture: true
1211
1213
  };
1212
1214
  document.addEventListener(
1213
1215
  "touchstart",
1214
1216
  function() {
1215
- lastTouchEvent = new Date().getTime();
1217
+ lastTouchEvent = Date.now();
1216
1218
  },
1217
1219
  options
1218
1220
  );
@@ -1220,14 +1222,14 @@ function enableTouchEventDetection() {
1220
1222
  "touchmove",
1221
1223
  function() {
1222
1224
  //console.log('TOUCHMOVE');
1223
- lastTouchEvent = new Date().getTime();
1225
+ lastTouchEvent = Date.now();
1224
1226
  },
1225
1227
  options
1226
1228
  );
1227
1229
  document.addEventListener(
1228
1230
  "touchend",
1229
1231
  function() {
1230
- lastTouchEvent = new Date().getTime(); //console.log('TOUCHEND');
1232
+ lastTouchEvent = Date.now(); //console.log('TOUCHEND');
1231
1233
  },
1232
1234
  options
1233
1235
  );
@@ -1235,7 +1237,7 @@ function enableTouchEventDetection() {
1235
1237
  }
1236
1238
  }
1237
1239
  function isTouchEvent() {
1238
- return isTouchDevice() && (!isTouchDetectionEnabled || new Date().getTime() - lastTouchEvent < 1000);
1240
+ return isTouchDevice() && (!isTouchDetectionEnabled || Date.now() - lastTouchEvent < 1000);
1239
1241
  } //enable touch event detection if there is no performance penalty on scrolling
1240
1242
 
1241
1243
  if (isTouchDevice() && browserSupportsPassiveEventHandlers()) enableTouchEventDetection();
package/dist/widgets.js CHANGED
@@ -9355,12 +9355,23 @@ var CalendarCmp = /*#__PURE__*/ (function(_VDOM$Component) {
9355
9355
  _proto2.getPage = function getPage(refDate) {
9356
9356
  refDate = monthStart(refDate); //make a copy
9357
9357
 
9358
+ var startWithMonday = this.props.instance.widget.startWithMonday;
9359
+ var startDay = startWithMonday ? 1 : 0;
9358
9360
  var startDate = new Date(refDate);
9359
- startDate.setDate(1 - startDate.getDay());
9361
+
9362
+ while (startDate.getDay() != startDay) {
9363
+ startDate.setDate(startDate.getDate() - 1);
9364
+ }
9365
+
9360
9366
  var endDate = new Date(refDate);
9361
9367
  endDate.setMonth(refDate.getMonth() + 1);
9362
9368
  endDate.setDate(endDate.getDate() - 1);
9363
- endDate.setDate(endDate.getDate() + 6 - endDate.getDay());
9369
+ var endDay = startWithMonday ? 0 : 6;
9370
+
9371
+ while (endDate.getDay() != endDay) {
9372
+ endDate.setDate(endDate.getDate() + 1);
9373
+ }
9374
+
9364
9375
  return {
9365
9376
  refDate: refDate,
9366
9377
  startDate: startDate,
@@ -9574,16 +9585,19 @@ var CalendarCmp = /*#__PURE__*/ (function(_VDOM$Component) {
9574
9585
  baseClass = widget.baseClass,
9575
9586
  disabledDaysOfWeek = widget.disabledDaysOfWeek,
9576
9587
  startWithMonday = widget.startWithMonday;
9577
- var refDate = this.state.refDate;
9588
+
9589
+ var _this$getPage = this.getPage(this.state.refDate),
9590
+ refDate = _this$getPage.refDate,
9591
+ startDate = _this$getPage.startDate,
9592
+ endDate = _this$getPage.endDate;
9593
+
9578
9594
  var month = refDate.getMonth();
9579
9595
  var year = refDate.getFullYear();
9580
- var startDate = new Date(year, month, 1);
9581
- startDate.setDate(1 - startDate.getDay() + (startWithMonday ? 1 : 0));
9582
9596
  var weeks = [];
9583
9597
  var date = startDate;
9584
9598
  var today = zeroTime(new Date());
9585
9599
 
9586
- while (date < refDate || date.getMonth() == month) {
9600
+ while (date >= startDate && date <= endDate) {
9587
9601
  var days = [];
9588
9602
 
9589
9603
  for (var i = 0; i < 7; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "22.4.3",
3
+ "version": "22.5.0",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "src/index.js",
@@ -41,6 +41,9 @@ interface RepeaterProps extends PureContainerProps {
41
41
 
42
42
  /** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
43
43
  sortOptions?: CollatorOptions;
44
+
45
+ /** A field used to get the unique identifier of the record. Setting keyField improves performance on sort operations as the widget is able to movement of records inside the collection. */
46
+ keyField: StringProp;
44
47
  }
45
48
 
46
49
  export class Repeater extends Widget<RepeaterProps> {}
@@ -1,11 +1,14 @@
1
- import * as Cx from '../../core';
1
+ import * as Cx from "../../core";
2
2
 
3
3
  interface ContentProps extends Cx.PureContainerProps {
4
+ /** Placeholder name where the content is rendered. */
5
+ name?: string;
4
6
 
5
- name?: string,
6
- putInto?: string,
7
- isContent?: boolean
7
+ /** Placeholder name where the content is rendered. */
8
+ for?: string;
8
9
 
10
+ /** Placeholder name where the content is rendered. */
11
+ putInto?: string;
9
12
  }
10
13
 
11
14
  export class Content extends Cx.Widget<ContentProps> {}
@@ -1,5 +1,5 @@
1
- import { browserSupportsPassiveEventHandlers } from './browserSupportsPassiveEventHandlers';
2
- import { isTouchDevice } from './isTouchDevice';
1
+ import { browserSupportsPassiveEventHandlers } from "./browserSupportsPassiveEventHandlers";
2
+ import { isTouchDevice } from "./isTouchDevice";
3
3
 
4
4
  // This is primarily used for tooltips which behave differently on touch.
5
5
  // For example, tooltips are commonly toggled on touch or disabled completely.
@@ -15,38 +15,50 @@ let isTouchDetectionEnabled = false;
15
15
 
16
16
  export function enableTouchEventDetection() {
17
17
  if (isTouchDevice() && !isTouchDetectionEnabled) {
18
- let options;
18
+ let options = true; //capture
19
19
 
20
20
  if (browserSupportsPassiveEventHandlers())
21
21
  options = {
22
- passive: true
22
+ passive: true,
23
+ capture: true,
23
24
  };
24
25
 
25
- document.addEventListener('touchstart', () => {
26
- insideTouchEvent++;
27
- //console.log('TOUCHSTART');
28
- lastTouchEvent = new Date().getTime();
29
- }, options);
26
+ document.addEventListener(
27
+ "touchstart",
28
+ () => {
29
+ insideTouchEvent++;
30
+ //console.log('TOUCHSTART');
31
+ lastTouchEvent = Date.now();
32
+ },
33
+ options
34
+ );
30
35
 
31
- document.addEventListener('touchmove', () => {
32
- //console.log('TOUCHMOVE');
33
- lastTouchEvent = new Date().getTime();
34
- }, options);
36
+ document.addEventListener(
37
+ "touchmove",
38
+ () => {
39
+ //console.log('TOUCHMOVE');
40
+ lastTouchEvent = Date.now();
41
+ },
42
+ options
43
+ );
35
44
 
36
- document.addEventListener('touchend', () => {
37
- insideTouchEvent--;
38
- lastTouchEvent = new Date().getTime();
39
- //console.log('TOUCHEND');
40
- }, options);
45
+ document.addEventListener(
46
+ "touchend",
47
+ () => {
48
+ insideTouchEvent--;
49
+ lastTouchEvent = Date.now();
50
+ //console.log('TOUCHEND');
51
+ },
52
+ options
53
+ );
41
54
 
42
55
  isTouchDetectionEnabled = true;
43
56
  }
44
57
  }
45
58
 
46
59
  export function isTouchEvent() {
47
- return isTouchDevice() && (!isTouchDetectionEnabled || (new Date().getTime() - lastTouchEvent) < 1000);
60
+ return isTouchDevice() && (!isTouchDetectionEnabled || Date.now() - lastTouchEvent < 1000);
48
61
  }
49
62
 
50
63
  //enable touch event detection if there is no performance penalty on scrolling
51
- if (isTouchDevice() && browserSupportsPassiveEventHandlers())
52
- enableTouchEventDetection();
64
+ if (isTouchDevice() && browserSupportsPassiveEventHandlers()) enableTouchEventDetection();
@@ -1,3 +1,4 @@
1
+ import * as React from "react";
1
2
  import {
2
3
  BooleanProp,
3
4
  ClassProp,
@@ -11,7 +12,7 @@ import {
11
12
  StructuredProp,
12
13
  StyledContainerProps,
13
14
  StyleProp,
14
- Widget,
15
+ Widget
15
16
  } from "../core";
16
17
  import { Instance } from "./../ui/Instance";
17
18
 
@@ -79,6 +80,8 @@ interface ListProps extends StyledContainerProps {
79
80
 
80
81
  /** Callback to be invoked when the list is being scrolled. Useful for loading additional items. */
81
82
  onScroll?: (event: Event, instance: Instance) => void;
83
+
84
+ onItemClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
82
85
  }
83
86
 
84
87
  export class List extends Widget<ListProps> {}
@@ -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
- Calendar.prototype.baseClass = "calendar";
131
- Calendar.prototype.highlightToday = true;
132
- Calendar.prototype.maxValueErrorText = "Select a date not after {0:d}.";
133
- Calendar.prototype.maxExclusiveErrorText = "Select a date before {0:d}.";
134
- Calendar.prototype.minValueErrorText = "Select a date not before {0:d}.";
135
- Calendar.prototype.minExclusiveErrorText = "Select a date after {0:d}.";
136
- Calendar.prototype.disabledDaysOfWeekErrorText = "Selected day of week is not allowed.";
137
- Calendar.prototype.suppressErrorsUntilVisited = false;
138
- Calendar.prototype.showTodayButton = false;
139
- Calendar.prototype.todayButtonText = "Today";
140
- Calendar.prototype.startWithMonday = false;
141
- Calendar.prototype.focusable = true;
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.setDate(1 - startDate.getDay());
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
- endDate.setDate(endDate.getDate() + 6 - endDate.getDay());
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 < refDate || date.getMonth() == month) {
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);
@@ -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 Cx.HtmlElementProps {
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