cx 25.5.1 → 25.6.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.
Files changed (45) hide show
  1. package/dist/charts.js +40 -21
  2. package/dist/manifest.js +771 -771
  3. package/dist/ui.js +0 -15
  4. package/dist/widgets.js +34 -25
  5. package/package.json +1 -1
  6. package/src/charts/LineGraph.js +1 -1
  7. package/src/charts/axis/NumericAxis.d.ts +46 -46
  8. package/src/charts/helpers/PointReducer.d.ts +9 -0
  9. package/src/charts/helpers/PointReducer.js +36 -22
  10. package/src/data/AugmentedViewBase.js +77 -77
  11. package/src/data/ExposedRecordView.js +75 -75
  12. package/src/data/ExposedValueView.js +73 -73
  13. package/src/data/Ref.d.ts +24 -24
  14. package/src/data/Ref.spec.js +79 -79
  15. package/src/data/StoreRef.spec.js +24 -24
  16. package/src/data/StructuredDataAccessor.d.ts +7 -7
  17. package/src/data/SubscribableView.js +54 -54
  18. package/src/ui/Container.js +154 -154
  19. package/src/ui/DataProxy.js +31 -45
  20. package/src/ui/DetachedScope.js +98 -98
  21. package/src/ui/Instance.d.ts +72 -72
  22. package/src/ui/Instance.js +623 -623
  23. package/src/ui/IsolatedScope.js +30 -30
  24. package/src/ui/Repeater.js +109 -109
  25. package/src/ui/Rescope.js +35 -35
  26. package/src/ui/Restate.js +167 -167
  27. package/src/ui/Widget.js +184 -184
  28. package/src/ui/adapter/ArrayAdapter.js +152 -152
  29. package/src/ui/adapter/TreeAdapter.js +101 -101
  30. package/src/ui/createFunctionalComponent.d.ts +1 -1
  31. package/src/ui/index.d.ts +42 -42
  32. package/src/ui/layout/exploreChildren.d.ts +12 -12
  33. package/src/ui/layout/exploreChildren.js +27 -27
  34. package/src/util/debounce.js +18 -18
  35. package/src/util/validatedDebounce.js +19 -19
  36. package/src/widgets/Button.js +118 -118
  37. package/src/widgets/List.js +594 -594
  38. package/src/widgets/form/Calendar.d.ts +86 -86
  39. package/src/widgets/form/Checkbox.js +5 -2
  40. package/src/widgets/form/MonthField.d.ts +5 -0
  41. package/src/widgets/form/MonthField.js +1 -0
  42. package/src/widgets/form/MonthPicker.d.ts +13 -0
  43. package/src/widgets/form/MonthPicker.js +25 -21
  44. package/src/widgets/grid/Grid.js +3421 -3421
  45. package/src/widgets/nav/Route.js +102 -102
@@ -1,86 +1,86 @@
1
- import * as Cx from "../../core";
2
- import { FieldProps } from "./Field";
3
-
4
- interface DayInfo {
5
- mod?: string;
6
- className?: string;
7
- style?: Cx.Record;
8
- unselectable?: boolean;
9
- disabled?: boolean;
10
- }
11
-
12
- interface DayData {
13
- [day: string]: DayInfo;
14
- }
15
-
16
- interface CalendarProps extends FieldProps {
17
- /** Selected date. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
18
- value?: Cx.Prop<string | Date>;
19
-
20
- /** View reference date. If no date is selected, this date is used to determine which month to show in the calendar. */
21
- refDate?: Cx.Prop<string | Date>;
22
-
23
- /** Minimum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
24
- minValue?: Cx.Prop<string | Date>;
25
-
26
- /** Set to `true` to disallow the `minValue`. Default value is `false`. */
27
- minExclusive?: Cx.BooleanProp;
28
-
29
- /** Maximum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
30
- maxValue?: Cx.Prop<string | Date>;
31
-
32
- /** Set to `true` to disallow the `maxValue`. Default value is `false`. */
33
- maxExclusive?: Cx.BooleanProp;
34
-
35
- /** Base CSS class to be applied to the calendar. Defaults to `calendar`. */
36
- baseClass?: string;
37
-
38
- /** Highlight today's date. Default is true. */
39
- highlightToday?: boolean;
40
-
41
- /** Maximum value error text. */
42
- maxValueErrorText?: string;
43
-
44
- /** Maximum exclusive value error text. */
45
- maxExclusiveErrorText?: string;
46
-
47
- /** Minimum value error text. */
48
- minValueErrorText?: string;
49
-
50
- /** Minimum exclusive value error text. */
51
- minExclusiveErrorText?: string;
52
-
53
- /** The function that will be used to convert Date objects before writing data to the store.
54
- * Default implementation is Date.toISOString.
55
- * See also Culture.setDefaultDateEncoding.
56
- */
57
- encoding?: (date: Date) => any;
58
-
59
- /** Set to true to show the button for quickly selecting today's date. */
60
- showTodayButton?: boolean;
61
-
62
- /** Localizable text for the todayButton. Defaults to `"Today"`. */
63
- todayButtonText?: string;
64
-
65
- /** Defines which days of week should be displayed as disabled, i.e. `[0, 6]` will make Sunday and Saturday unselectable. */
66
- disabledDaysOfWeek?: number[];
67
-
68
- /** Set to true to show weeks starting from Monday. */
69
- startWithMonday?: boolean;
70
-
71
- /** Map of days to additional day information such as style, className, mod, unselectable and disabled.
72
- * Keys for the map should be created with date.toDateString().
73
- * Example. {
74
- * [new Date().toDateString()]: {
75
- * style: "color: red",
76
- * className: 'test-class',
77
- * mod: 'holiday',
78
- * unselectable: false,
79
- * disabled: false
80
- * }
81
- * }
82
- */
83
- dayData?: Cx.Prop<DayData>;
84
- }
85
-
86
- export class Calendar extends Cx.Widget<CalendarProps> {}
1
+ import * as Cx from "../../core";
2
+ import { FieldProps } from "./Field";
3
+
4
+ interface DayInfo {
5
+ mod?: string;
6
+ className?: string;
7
+ style?: Cx.Record;
8
+ unselectable?: boolean;
9
+ disabled?: boolean;
10
+ }
11
+
12
+ interface DayData {
13
+ [day: string]: DayInfo;
14
+ }
15
+
16
+ interface CalendarProps extends FieldProps {
17
+ /** Selected date. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
18
+ value?: Cx.Prop<string | Date>;
19
+
20
+ /** View reference date. If no date is selected, this date is used to determine which month to show in the calendar. */
21
+ refDate?: Cx.Prop<string | Date>;
22
+
23
+ /** Minimum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
24
+ minValue?: Cx.Prop<string | Date>;
25
+
26
+ /** Set to `true` to disallow the `minValue`. Default value is `false`. */
27
+ minExclusive?: Cx.BooleanProp;
28
+
29
+ /** Maximum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
30
+ maxValue?: Cx.Prop<string | Date>;
31
+
32
+ /** Set to `true` to disallow the `maxValue`. Default value is `false`. */
33
+ maxExclusive?: Cx.BooleanProp;
34
+
35
+ /** Base CSS class to be applied to the calendar. Defaults to `calendar`. */
36
+ baseClass?: string;
37
+
38
+ /** Highlight today's date. Default is true. */
39
+ highlightToday?: boolean;
40
+
41
+ /** Maximum value error text. */
42
+ maxValueErrorText?: string;
43
+
44
+ /** Maximum exclusive value error text. */
45
+ maxExclusiveErrorText?: string;
46
+
47
+ /** Minimum value error text. */
48
+ minValueErrorText?: string;
49
+
50
+ /** Minimum exclusive value error text. */
51
+ minExclusiveErrorText?: string;
52
+
53
+ /** The function that will be used to convert Date objects before writing data to the store.
54
+ * Default implementation is Date.toISOString.
55
+ * See also Culture.setDefaultDateEncoding.
56
+ */
57
+ encoding?: (date: Date) => any;
58
+
59
+ /** Set to true to show the button for quickly selecting today's date. */
60
+ showTodayButton?: boolean;
61
+
62
+ /** Localizable text for the todayButton. Defaults to `"Today"`. */
63
+ todayButtonText?: string;
64
+
65
+ /** Defines which days of week should be displayed as disabled, i.e. `[0, 6]` will make Sunday and Saturday unselectable. */
66
+ disabledDaysOfWeek?: number[];
67
+
68
+ /** Set to true to show weeks starting from Monday. */
69
+ startWithMonday?: boolean;
70
+
71
+ /** Map of days to additional day information such as style, className, mod, unselectable and disabled.
72
+ * Keys for the map should be created with date.toDateString().
73
+ * Example. {
74
+ * [new Date().toDateString()]: {
75
+ * style: "color: red",
76
+ * className: 'test-class',
77
+ * mod: 'holiday',
78
+ * unselectable: false,
79
+ * disabled: false
80
+ * }
81
+ * }
82
+ */
83
+ dayData?: Cx.Prop<DayData>;
84
+ }
85
+
86
+ export class Calendar extends Cx.Widget<CalendarProps> {}
@@ -24,7 +24,7 @@ export class Checkbox extends Field {
24
24
  required: undefined,
25
25
  viewText: undefined,
26
26
  },
27
- ...arguments
27
+ ...arguments,
28
28
  );
29
29
  }
30
30
 
@@ -34,7 +34,10 @@ export class Checkbox extends Field {
34
34
  <label
35
35
  key={key}
36
36
  className={data.classNames}
37
- onMouseDown={stopPropagation}
37
+ onMouseDown={(e) => {
38
+ e.stopPropagation();
39
+ if (this.unfocusable) e.preventDefault();
40
+ }}
38
41
  onMouseMove={(e) => tooltipMouseMove(e, ...getFieldTooltip(instance))}
39
42
  onMouseLeave={(e) => tooltipMouseLeave(e, ...getFieldTooltip(instance))}
40
43
  onClick={(e) => {
@@ -94,6 +94,11 @@ interface MonthFieldProps extends FieldProps {
94
94
  /** A boolean flag that determines whether the `to` date is included in the range.
95
95
  * When set to true the value stored in the to field would be the last day of the month, i.e. `2024-12-31`. */
96
96
  inclusiveTo?: boolean;
97
+
98
+ /** Optional configuration options for the MonthPicker component rendered within the dropdown.
99
+ * You can pass any valid additional MonthPicker props here, such as `startYear`, `endYear`, etc.
100
+ * Refer to the MonthPicker component documentation for a full list of supported options. */
101
+ monthPickerOptions?: Cx.Config;
97
102
  }
98
103
 
99
104
  export class MonthField extends Cx.Widget<MonthFieldProps> {}
@@ -149,6 +149,7 @@ export class MonthField extends Field {
149
149
  data={instance.data}
150
150
  instance={instance}
151
151
  monthPicker={{
152
+ ...this.monthPickerOptions,
152
153
  value: this.value,
153
154
  from: this.from,
154
155
  to: this.to,
@@ -1,4 +1,5 @@
1
1
  import * as Cx from "../../core";
2
+ import { Instance } from "../../ui";
2
3
  import { FieldProps } from "./Field";
3
4
 
4
5
  interface MonthPickerProps extends FieldProps {
@@ -71,6 +72,18 @@ interface MonthPickerProps extends FieldProps {
71
72
  /** A boolean flag that determines whether the `to` date is included in the range.
72
73
  * When set to true the value stored in the to field would be the last day of the month, i.e. `2024-12-31`. */
73
74
  inclusiveTo?: boolean;
75
+
76
+ /** Callback function that is called before writing data to the store. Return false to short-circuit updating the state. */
77
+ onBeforeSelect: (e: Event, instance: Instance, dateFrom?: Date, dateTo?: Date) => boolean;
78
+
79
+ /** Callback function that is called after value or date range has changed */
80
+ onSelect: (instance: Instance, dateFrom?: Date, dateTo?: Date) => void;
81
+
82
+ /**
83
+ * Optional parameter to hide the quarters period section on the picker.
84
+ * When true, the quarters section will not render.
85
+ */
86
+ hideQuarters?: boolean;
74
87
  }
75
88
 
76
89
  export class MonthPicker extends Cx.Widget<MonthPickerProps> {}
@@ -154,6 +154,7 @@ MonthPicker.prototype.range = false;
154
154
  MonthPicker.prototype.startYear = 1980;
155
155
  MonthPicker.prototype.endYear = 2030;
156
156
  MonthPicker.prototype.bufferSize = 15;
157
+ MonthPicker.prototype.hideQuarters = false;
157
158
 
158
159
  // Localization
159
160
  MonthPicker.prototype.maxValueErrorText = "Select {0:d} or before.";
@@ -193,7 +194,7 @@ export class MonthPickerComponent extends VDOM.Component {
193
194
  cursorQuarter: cursor.getMonth() / 3,
194
195
  column: "M",
195
196
  start: widget.startYear,
196
- end: widget.startYear + widget.bufferSize,
197
+ end: Math.min(widget.startYear + widget.bufferSize, widget.endYear),
197
198
  };
198
199
 
199
200
  this.handleMouseDown = this.handleMouseDown.bind(this);
@@ -427,8 +428,9 @@ export class MonthPickerComponent extends VDOM.Component {
427
428
  }
428
429
 
429
430
  render() {
430
- let { data, widget } = this.props.instance;
431
- let { CSS, baseClass, startYear, endYear } = widget;
431
+ let { instance } = this.props;
432
+ let { data, widget } = instance;
433
+ let { CSS, baseClass, startYear, endYear, hideQuarters } = widget;
432
434
 
433
435
  let years = [];
434
436
 
@@ -512,24 +514,26 @@ export class MonthPickerComponent extends VDOM.Component {
512
514
  </td>,
513
515
  );
514
516
  }
515
- row.push(
516
- <th
517
- key={`q${q}`}
518
- className={CSS.state({
519
- cursor:
520
- showCursor &&
521
- this.state.column == "Q" &&
522
- y == this.state.cursorYear &&
523
- q == this.state.cursorQuarter,
524
- })}
525
- data-point={`Y-${y}-Q-${q}`}
526
- onMouseEnter={this.handleMouseEnter}
527
- onMouseDown={this.handleMouseDown}
528
- onMouseUp={this.handleMouseUp}
529
- >
530
- {`Q${q + 1}`}
531
- </th>,
532
- );
517
+
518
+ if (!hideQuarters)
519
+ row.push(
520
+ <th
521
+ key={`q${q}`}
522
+ className={CSS.state({
523
+ cursor:
524
+ showCursor &&
525
+ this.state.column == "Q" &&
526
+ y == this.state.cursorYear &&
527
+ q == this.state.cursorQuarter,
528
+ })}
529
+ data-point={`Y-${y}-Q-${q}`}
530
+ onMouseEnter={this.handleMouseEnter}
531
+ onMouseDown={this.handleMouseDown}
532
+ onMouseUp={this.handleMouseUp}
533
+ >
534
+ {`Q${q + 1}`}
535
+ </th>,
536
+ );
533
537
  rows.push(row);
534
538
  }
535
539
  years.push(rows);