cx 25.6.1 → 25.6.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/dist/widgets.css CHANGED
@@ -2519,6 +2519,11 @@ th.cxe-calendar-display {
2519
2519
  padding: 0 0.5em;
2520
2520
  color: lightgray;
2521
2521
  }
2522
+ .cxb-monthpicker th.cxs-unselectable {
2523
+ cursor: default;
2524
+ opacity: 0.5;
2525
+ pointer-events: none;
2526
+ }
2522
2527
  .cxb-monthpicker .cxe-monthpicker-year {
2523
2528
  font-size: 120%;
2524
2529
  color: gray;
package/dist/widgets.js CHANGED
@@ -1813,6 +1813,7 @@ var Sandbox = /*#__PURE__*/ (function (_PureContainer) {
1813
1813
  key: data.key,
1814
1814
  recordName: this.recordName,
1815
1815
  immutable: this.immutable,
1816
+ sealed: this.sealed,
1816
1817
  });
1817
1818
  instance.clearChildrenCache();
1818
1819
  }
@@ -1822,6 +1823,7 @@ var Sandbox = /*#__PURE__*/ (function (_PureContainer) {
1822
1823
  })(PureContainer);
1823
1824
  Sandbox.prototype.recordName = "$page";
1824
1825
  Sandbox.prototype.immutable = false;
1826
+ Sandbox.prototype.sealed = false;
1825
1827
  Widget.alias("sandbox", Sandbox);
1826
1828
 
1827
1829
  var CxCredit = /*#__PURE__*/ (function (_HtmlElement) {
@@ -8161,7 +8163,7 @@ var Calendar = /*#__PURE__*/ (function (_Field) {
8161
8163
  widget = instance.widget;
8162
8164
  e.stopPropagation();
8163
8165
  if (data.disabled) return;
8164
- if (!validationCheck$1(date, data)) return;
8166
+ if (!validationCheck(date, data)) return;
8165
8167
  if (this.onBeforeSelect && instance.invoke("onBeforeSelect", e, instance, date) === false) return;
8166
8168
  if (widget.partial) {
8167
8169
  var mixed = parseDateInvariant(data.value);
@@ -8191,7 +8193,7 @@ Calendar.prototype.todayButtonText = "Today";
8191
8193
  Calendar.prototype.startWithMonday = false;
8192
8194
  Calendar.prototype.focusable = true;
8193
8195
  Localization.registerPrototype("cx/widgets/Calendar", Calendar);
8194
- var validationCheck$1 = function validationCheck(date, data, disabledDaysOfWeek) {
8196
+ var validationCheck = function validationCheck(date, data, disabledDaysOfWeek) {
8195
8197
  if (data.maxValue && !upperBoundCheck(date, data.maxValue, data.maxExclusive)) return false;
8196
8198
  if (data.minValue && !lowerBoundCheck(date, data.minValue, data.minExclusive)) return false;
8197
8199
  if (disabledDaysOfWeek && disabledDaysOfWeek.includes(date.getDay())) return false;
@@ -8514,7 +8516,7 @@ var CalendarCmp = /*#__PURE__*/ (function (_VDOM$Component) {
8514
8516
  var days = [];
8515
8517
  for (var i = 0; i < 7; i++) {
8516
8518
  var dayInfo = (data.dayData && data.dayData[date.toDateString()]) || empty;
8517
- var unselectable = !validationCheck$1(date, data, disabledDaysOfWeek);
8519
+ var unselectable = !validationCheck(date, data, disabledDaysOfWeek);
8518
8520
  var classNames = CSS.expand(
8519
8521
  CSS.element(baseClass, "day", {
8520
8522
  outside: month != date.getMonth(),
@@ -10811,8 +10813,8 @@ var MonthPicker = /*#__PURE__*/ (function (_Field) {
10811
10813
  _proto.init = function init() {
10812
10814
  _Field.prototype.init.call(this);
10813
10815
  };
10814
- _proto.prepareData = function prepareData(context, _ref) {
10815
- var data = _ref.data;
10816
+ _proto.prepareData = function prepareData(context, instance) {
10817
+ var data = instance.data;
10816
10818
  data.stateMods = {
10817
10819
  disabled: data.disabled,
10818
10820
  };
@@ -10828,6 +10830,13 @@ var MonthPicker = /*#__PURE__*/ (function (_Field) {
10828
10830
  if (data.refDate) data.refDate = monthStart(parseDateInvariant(data.refDate));
10829
10831
  if (data.maxValue) data.maxValue = monthStart(parseDateInvariant(data.maxValue));
10830
10832
  if (data.minValue) data.minValue = monthStart(parseDateInvariant(data.minValue));
10833
+ if (this.onCreateIsMonthDateSelectable) {
10834
+ instance.isMonthDateSelectable = instance.invoke(
10835
+ "onCreateIsMonthDateSelectable",
10836
+ data.validationParams,
10837
+ instance,
10838
+ );
10839
+ }
10831
10840
  _Field.prototype.prepareData.apply(this, arguments);
10832
10841
  };
10833
10842
  _proto.validate = function validate(context, instance) {
@@ -10864,10 +10873,12 @@ var MonthPicker = /*#__PURE__*/ (function (_Field) {
10864
10873
  };
10865
10874
  _proto.handleSelect = function handleSelect(e, instance, date1, date2) {
10866
10875
  var data = instance.data,
10867
- widget = instance.widget;
10876
+ widget = instance.widget,
10877
+ isMonthDateSelectable = instance.isMonthDateSelectable;
10868
10878
  var encode = widget.encoding || Culture.getDefaultDateEncoding();
10869
10879
  if (data.disabled) return;
10870
- if (!validationCheck(date1, data)) return;
10880
+ if (isMonthDateSelectable && !isMonthDateSelectable(date1)) return;
10881
+ if (!dateSelectableCheck(date1, data)) return;
10871
10882
  if (this.onBeforeSelect && instance.invoke("onBeforeSelect", e, instance, date1, date2) === false) return;
10872
10883
  if (this.range) {
10873
10884
  instance.set("from", encode(date1));
@@ -10894,7 +10905,7 @@ MonthPicker.prototype.minExclusiveErrorText = "Select a date after {0:d}.";
10894
10905
  MonthPicker.prototype.inclusiveTo = false;
10895
10906
  Localization.registerPrototype("cx/widgets/MonthPicker", MonthPicker);
10896
10907
  Widget.alias("month-picker", MonthPicker);
10897
- var validationCheck = function validationCheck(date, data) {
10908
+ var dateSelectableCheck = function dateSelectableCheck(date, data) {
10898
10909
  if (data.maxValue && !upperBoundCheck(date, data.maxValue, data.maxExclusive)) return false;
10899
10910
  if (data.minValue && !lowerBoundCheck(date, data.minValue, data.minExclusive)) return false;
10900
10911
  return true;
@@ -11153,11 +11164,11 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11153
11164
  if (this.props.onFocusOut) this.props.onFocusOut();
11154
11165
  };
11155
11166
  _proto2.getCursorDates = function getCursorDates(cursor) {
11156
- var _ref2 = cursor || this.state,
11157
- cursorMonth = _ref2.cursorMonth,
11158
- cursorYear = _ref2.cursorYear,
11159
- cursorQuarter = _ref2.cursorQuarter,
11160
- column = _ref2.column;
11167
+ var _ref = cursor || this.state,
11168
+ cursorMonth = _ref.cursorMonth,
11169
+ cursorYear = _ref.cursorYear,
11170
+ cursorQuarter = _ref.cursorQuarter,
11171
+ column = _ref.column;
11161
11172
  switch (column) {
11162
11173
  case "M":
11163
11174
  return [new Date(cursorYear, cursorMonth - 1, 1), new Date(cursorYear, cursorMonth, 1)];
@@ -11240,7 +11251,8 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11240
11251
  var _this3 = this;
11241
11252
  var instance = this.props.instance;
11242
11253
  var data = instance.data,
11243
- widget = instance.widget;
11254
+ widget = instance.widget,
11255
+ isMonthDateSelectable = instance.isMonthDateSelectable;
11244
11256
  var CSS = widget.CSS,
11245
11257
  baseClass = widget.baseClass,
11246
11258
  startYear = widget.startYear,
@@ -11279,30 +11291,50 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11279
11291
  var monthNames = Culture.getDateTimeCulture().getMonthNames("short");
11280
11292
  var showCursor = this.state.hover || this.state.focused;
11281
11293
  for (var y = start; y <= end; y++) {
11294
+ var selectableMonths = 4095;
11295
+ // Loop through the months in a year to check if all months are unselectable
11296
+ for (var i = 0; i < 12; i++) {
11297
+ if (
11298
+ (isMonthDateSelectable && !isMonthDateSelectable(new Date(y, i, 1))) ||
11299
+ !dateSelectableCheck(new Date(y, i, 1), data)
11300
+ ) {
11301
+ // Set month as unselectable at specified bit
11302
+ selectableMonths &= ~(1 << i);
11303
+ }
11304
+ }
11305
+
11306
+ // All bits are 0 - all months are unselectable
11307
+ var unselectableYear = selectableMonths === 0;
11282
11308
  var rows = [];
11283
11309
  for (var q = 0; q < 4; q++) {
11284
11310
  var row = [];
11285
- if (q == 0)
11311
+ if (q == 0) {
11286
11312
  row.push(
11287
11313
  /*#__PURE__*/ jsx(
11288
11314
  "th",
11289
11315
  {
11290
11316
  rowSpan: 4,
11291
11317
  "data-point": "Y-" + y,
11292
- className: CSS.element(baseClass, "year", {
11293
- cursor: showCursor && this.state.column == "Y" && y == this.state.cursorYear,
11294
- }),
11295
- onMouseEnter: this.handleMouseEnter,
11296
- onMouseDown: this.handleMouseDown,
11297
- onMouseUp: this.handleMouseUp,
11318
+ className: CSS.expand(
11319
+ CSS.element(baseClass, "year", {
11320
+ cursor: showCursor && this.state.column == "Y" && y == this.state.cursorYear,
11321
+ }),
11322
+ CSS.state({
11323
+ unselectable: unselectableYear,
11324
+ }),
11325
+ ),
11326
+ onMouseEnter: unselectableYear ? null : this.handleMouseEnter,
11327
+ onMouseDown: unselectableYear ? null : this.handleMouseDown,
11328
+ onMouseUp: unselectableYear ? null : this.handleMouseUp,
11298
11329
  children: y,
11299
11330
  },
11300
11331
  "year",
11301
11332
  ),
11302
11333
  );
11303
- for (var i = 0; i < 3; i++) {
11304
- var m = q * 3 + i + 1;
11305
- var unselectable = !validationCheck(new Date(y, m - 1, 1), data);
11334
+ }
11335
+ for (var _i = 0; _i < 3; _i++) {
11336
+ var m = q * 3 + _i + 1;
11337
+ var unselectableMonth = (selectableMonths & (1 << (m - 1))) === 0;
11306
11338
  var mno = y * 12 + m - 1;
11307
11339
  var handle = true; //isTouchDevice(); //mno === from || mno === to - 1;
11308
11340
  row.push(
@@ -11314,14 +11346,14 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11314
11346
  showCursor && this.state.column == "M" && y == this.state.cursorYear && m == this.state.cursorMonth,
11315
11347
  handle: handle,
11316
11348
  selected: mno >= from && mno < to,
11317
- unselectable: unselectable,
11349
+ unselectable: unselectableMonth,
11318
11350
  }),
11319
11351
  "data-point": "Y-" + y + "-M-" + m,
11320
- onMouseEnter: unselectable ? null : this.handleMouseEnter,
11321
- onMouseDown: unselectable ? null : this.handleMouseDown,
11322
- onMouseUp: unselectable ? null : this.handleMouseUp,
11323
- onTouchStart: unselectable ? null : this.handleMouseDown,
11324
- onTouchMove: unselectable ? null : this.handleTouchMove,
11352
+ onMouseEnter: unselectableMonth ? null : this.handleMouseEnter,
11353
+ onMouseDown: unselectableMonth ? null : this.handleMouseDown,
11354
+ onMouseUp: unselectableMonth ? null : this.handleMouseUp,
11355
+ onTouchStart: unselectableMonth ? null : this.handleMouseDown,
11356
+ onTouchMove: unselectableMonth ? null : this.handleTouchMove,
11325
11357
  onTouchEnd: this.handleMouseUp,
11326
11358
  children: monthNames[m - 1].substr(0, 3),
11327
11359
  },
@@ -11329,7 +11361,16 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11329
11361
  ),
11330
11362
  );
11331
11363
  }
11332
- if (!hideQuarters)
11364
+ if (!hideQuarters) {
11365
+ var unselectableQuarter = true;
11366
+ var _start = q * 3;
11367
+ for (var _i2 = _start; _i2 < _start + 3; _i2++) {
11368
+ if ((selectableMonths & (1 << _i2)) !== 0) {
11369
+ // found a selectable month in a quarter
11370
+ unselectableQuarter = false;
11371
+ break;
11372
+ }
11373
+ }
11333
11374
  row.push(
11334
11375
  /*#__PURE__*/ jsx(
11335
11376
  "th",
@@ -11340,16 +11381,18 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11340
11381
  this.state.column == "Q" &&
11341
11382
  y == this.state.cursorYear &&
11342
11383
  q == this.state.cursorQuarter,
11384
+ unselectable: unselectableQuarter,
11343
11385
  }),
11344
11386
  "data-point": "Y-" + y + "-Q-" + q,
11345
- onMouseEnter: this.handleMouseEnter,
11346
- onMouseDown: this.handleMouseDown,
11347
- onMouseUp: this.handleMouseUp,
11387
+ onMouseEnter: unselectableQuarter ? null : this.handleMouseEnter,
11388
+ onMouseDown: unselectableQuarter ? null : this.handleMouseDown,
11389
+ onMouseUp: unselectableQuarter ? null : this.handleMouseUp,
11348
11390
  children: "Q" + (q + 1),
11349
11391
  },
11350
11392
  "q" + q,
11351
11393
  ),
11352
11394
  );
11395
+ }
11353
11396
  rows.push(row);
11354
11397
  }
11355
11398
  years.push(rows);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "25.6.1",
3
+ "version": "25.6.3",
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",
@@ -87,6 +87,15 @@ interface LineGraphProps extends Cx.WidgetProps {
87
87
 
88
88
  /** Set to true to avoid forcing the vertical axis to accommodate y0 values. */
89
89
  hiddenBase?: boolean;
90
+
91
+ /** Set to `true` to draw smoothed lines between data points using cubic Bézier curve.
92
+ * When enabled, the graph uses control points calculated from neighboring values to create smooth transitions between data points. */
93
+ smooth?: boolean;
94
+
95
+ /** Controls the intensity of the smoothing effect applied to Bézier curves when `smooth` is enabled.
96
+ * Accepts a number between `0` (straight lines) and `0.4` (maximum smoothing).
97
+ * Values outside this range are automatically clamped. Default value is `0.05`. */
98
+ smoothingRatio?: number;
90
99
  }
91
100
 
92
101
  export class LineGraph extends Cx.Widget<LineGraphProps> {}
@@ -27,6 +27,8 @@ export class LineGraph extends Widget {
27
27
  active: true,
28
28
  stack: undefined,
29
29
  stacked: undefined,
30
+ smooth: undefined,
31
+ smoothingRatio: undefined,
30
32
  });
31
33
  }
32
34
 
@@ -35,6 +37,11 @@ export class LineGraph extends Widget {
35
37
 
36
38
  if (data.name && !data.colorName) data.colorName = data.name;
37
39
 
40
+ if (data.smooth && data.smoothingRatio != null) {
41
+ if (data.smoothingRatio < 0) data.smoothingRatio = 0;
42
+ if (data.smoothingRatio > 0.4) data.smoothingRatio = 0.4;
43
+ }
44
+
38
45
  super.prepareData(context, instance);
39
46
  }
40
47
 
@@ -161,13 +168,18 @@ export class LineGraph extends Widget {
161
168
  };
162
169
 
163
170
  let line, area;
171
+ const r = data.smoothingRatio;
164
172
 
173
+ let linePath = "";
165
174
  if (data.line) {
166
- let linePath = "";
167
175
  lineSpans.forEach((span) => {
168
176
  span.forEach((p, i) => {
169
- linePath += i == 0 ? " M " : " L ";
170
- linePath += p.x + " " + p.y;
177
+ linePath +=
178
+ i == 0
179
+ ? `M ${p.x} ${p.y}`
180
+ : !data.smooth || span.length < 2
181
+ ? `L ${p.x} ${p.y}`
182
+ : this.getCurvedPathSegment(p, span, i - 1, i - 2, i - 1, i + 1, r);
171
183
  });
172
184
  });
173
185
 
@@ -185,13 +197,35 @@ export class LineGraph extends Widget {
185
197
  lineSpans.forEach((span) => {
186
198
  let closePath = "";
187
199
  span.forEach((p, i) => {
188
- areaPath += i == 0 ? " M " : " L ";
189
- areaPath += p.x + " " + p.y;
190
- if (data.area) closePath = `L ${p.x} ${p.y0} ` + closePath;
200
+ let segment = "";
201
+ if (i == 0) {
202
+ segment = `M ${p.x} ${p.y}`;
203
+
204
+ // closing point
205
+ closePath =
206
+ !data.smooth || span.length < 2
207
+ ? `L ${p.x} ${p.y0}`
208
+ : this.getCurvedPathSegment(p, span, i + 1, i + 2, i + 1, i - 1, r, "y0");
209
+ } else {
210
+ if (!data.smooth) {
211
+ segment = `L ${p.x} ${p.y}`;
212
+ closePath = `L ${p.x} ${p.y0}` + closePath;
213
+ } else {
214
+ segment = this.getCurvedPathSegment(p, span, i - 1, i - 2, i - 1, i + 1, r, "y");
215
+
216
+ // closing point
217
+ if (i < span.length - 1)
218
+ closePath = this.getCurvedPathSegment(p, span, i + 1, i + 2, i + 1, i - 1, r, "y0") + closePath;
219
+ }
220
+ }
221
+ areaPath += segment;
191
222
  });
223
+
224
+ areaPath += `L ${span[span.length - 1].x} ${span[span.length - 1].y0}`;
192
225
  areaPath += closePath;
193
- areaPath += `L ${span[0].x} ${span[0].y}`;
226
+ areaPath += "Z";
194
227
  });
228
+
195
229
  area = (
196
230
  <path
197
231
  className={this.CSS.element(this.baseClass, "area", stateMods)}
@@ -208,6 +242,39 @@ export class LineGraph extends Widget {
208
242
  </g>
209
243
  );
210
244
  }
245
+
246
+ getCurvedPathSegment(p, points, i1, i2, j1, j2, r, yField = "y") {
247
+ const [sx, sy] = this.getControlPoint({ cp: points[i1], pp: points[i2], r, np: p, yField });
248
+ const [ex, ey] = this.getControlPoint({ cp: p, pp: points[j1], np: points[j2], r, reverse: true, yField });
249
+
250
+ return `C ${sx} ${sy}, ${ex} ${ey}, ${p.x} ${p[yField]}`;
251
+ }
252
+
253
+ getControlPoint({ cp, pp, np, r, reverse, yField = "y" }) {
254
+ // When 'current' is the first or last point of the array 'previous' or 'next' don't exist. Replace with 'current'.
255
+ const p = pp || cp;
256
+ const n = np || cp;
257
+
258
+ // Properties of the opposed-line
259
+ let { angle, length } = this.getLineInfo(p.x, p[yField], n.x, n[yField]);
260
+ // If it is end-control-point, add PI to the angle to go backward
261
+ angle = angle + (reverse ? Math.PI : 0);
262
+ length = length * r;
263
+ // The control point position is relative to the current point
264
+ const x = cp.x + Math.cos(angle) * length;
265
+ const y = cp[yField] + Math.sin(angle) * length;
266
+ return [x, y];
267
+ }
268
+
269
+ getLineInfo(p1x, p1y, p2x, p2y) {
270
+ const lengthX = p2x - p1x;
271
+ const lengthY = p2y - p1y;
272
+
273
+ return {
274
+ length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
275
+ angle: Math.atan2(lengthY, lengthX),
276
+ };
277
+ }
211
278
  }
212
279
 
213
280
  LineGraph.prototype.xAxis = "x";
@@ -227,4 +294,7 @@ LineGraph.prototype.legendShape = "rect";
227
294
  LineGraph.prototype.stack = "stack";
228
295
  LineGraph.prototype.hiddenBase = false;
229
296
 
297
+ LineGraph.prototype.smooth = false;
298
+ LineGraph.prototype.smoothingRatio = 0.05;
299
+
230
300
  Widget.alias("line-graph", LineGraph);
@@ -1,19 +1,19 @@
1
- import {View, ViewConfig} from './View';
2
-
3
- import { Binding } from './Binding';
4
-
5
- interface ExposedValueViewConfig extends ViewConfig {
6
- containerBinding: Binding;
7
- recordName?: string;
8
- immutable?: boolean;
9
- }
10
-
11
- export class ExposedValueView extends View {
12
- constructor(config?: ExposedValueViewConfig);
13
-
14
- setKey(key: string);
15
-
16
- getKey(): string;
17
-
18
- setStore(store: View);
19
- }
1
+ import { View, ViewConfig } from "./View";
2
+
3
+ import { Binding } from "./Binding";
4
+
5
+ interface ExposedValueViewConfig extends ViewConfig {
6
+ containerBinding: Binding;
7
+ recordName?: string;
8
+ immutable?: boolean;
9
+ }
10
+
11
+ export class ExposedValueView extends View {
12
+ constructor(config?: ExposedValueViewConfig);
13
+
14
+ setKey(key: string);
15
+
16
+ getKey(): string;
17
+
18
+ setStore(store: View);
19
+ }
@@ -1,16 +1,18 @@
1
- import * as Cx from "../core";
2
-
3
- interface SandboxProps extends Cx.PureContainerProps {
4
- storage: Cx.Prop<Cx.Record>;
5
-
6
- /* Cx.StringProp doesn't work for unknown reason */
7
- key?: any;
8
-
9
- accessKey?: Cx.StringProp;
10
-
11
- recordName?: Cx.RecordAlias;
12
- recordAlias?: Cx.RecordAlias;
13
- immutable?: Cx.BooleanProp;
14
- }
15
-
16
- export class Sandbox extends Cx.Widget<SandboxProps> {}
1
+ import * as Cx from "../core";
2
+
3
+ interface SandboxProps extends Cx.PureContainerProps {
4
+ storage: Cx.Prop<Cx.Record>;
5
+
6
+ /* Cx.StringProp doesn't work for unknown reason */
7
+ key?: any;
8
+
9
+ accessKey?: Cx.StringProp;
10
+
11
+ recordName?: Cx.RecordAlias;
12
+ recordAlias?: Cx.RecordAlias;
13
+
14
+ immutable?: boolean;
15
+ sealed?: boolean;
16
+ }
17
+
18
+ export class Sandbox extends Cx.Widget<SandboxProps> {}
@@ -1,63 +1,65 @@
1
- import { Widget } from "../ui/Widget";
2
- import { PureContainer } from "../ui/PureContainer";
3
- import { Binding } from "../data/Binding";
4
- import { ExposedValueView } from "../data/ExposedValueView";
5
-
6
- export class Sandbox extends PureContainer {
7
- init() {
8
- if (this.recordAlias) this.recordName = this.recordAlias;
9
-
10
- if (this.accessKey) this.key = this.accessKey;
11
-
12
- this.storageBinding = Binding.get(this.storage);
13
-
14
- super.init();
15
- }
16
-
17
- initInstance(context, instance) {
18
- instance.store = new ExposedValueView({
19
- store: instance.parentStore,
20
- containerBinding: this.storageBinding,
21
- key: null,
22
- recordName: this.recordName,
23
- immutable: this.immutable,
24
- });
25
- super.initInstance(context, instance);
26
- }
27
-
28
- applyParentStore(instance) {
29
- instance.store.setStore(instance.parentStore);
30
- }
31
-
32
- declareData() {
33
- super.declareData(
34
- {
35
- storage: undefined,
36
- key: undefined,
37
- },
38
- ...arguments,
39
- );
40
- }
41
-
42
- prepareData(context, instance) {
43
- var { store, data } = instance;
44
- if (store.getKey() !== data.key) {
45
- //when navigating to a page using the same widget tree as the previous page
46
- //everything needs to be reinstantiated, e.g. user/1 => user/2
47
- instance.store = new ExposedValueView({
48
- store: store,
49
- containerBinding: this.storageBinding,
50
- key: data.key,
51
- recordName: this.recordName,
52
- immutable: this.immutable,
53
- });
54
- instance.clearChildrenCache();
55
- }
56
- super.prepareData(context, instance);
57
- }
58
- }
59
-
60
- Sandbox.prototype.recordName = "$page";
61
- Sandbox.prototype.immutable = false;
62
-
63
- Widget.alias("sandbox", Sandbox);
1
+ import { Widget } from "../ui/Widget";
2
+ import { PureContainer } from "../ui/PureContainer";
3
+ import { Binding } from "../data/Binding";
4
+ import { ExposedValueView } from "../data/ExposedValueView";
5
+
6
+ export class Sandbox extends PureContainer {
7
+ init() {
8
+ if (this.recordAlias) this.recordName = this.recordAlias;
9
+
10
+ if (this.accessKey) this.key = this.accessKey;
11
+
12
+ this.storageBinding = Binding.get(this.storage);
13
+
14
+ super.init();
15
+ }
16
+
17
+ initInstance(context, instance) {
18
+ instance.store = new ExposedValueView({
19
+ store: instance.parentStore,
20
+ containerBinding: this.storageBinding,
21
+ key: null,
22
+ recordName: this.recordName,
23
+ immutable: this.immutable,
24
+ });
25
+ super.initInstance(context, instance);
26
+ }
27
+
28
+ applyParentStore(instance) {
29
+ instance.store.setStore(instance.parentStore);
30
+ }
31
+
32
+ declareData() {
33
+ super.declareData(
34
+ {
35
+ storage: undefined,
36
+ key: undefined,
37
+ },
38
+ ...arguments,
39
+ );
40
+ }
41
+
42
+ prepareData(context, instance) {
43
+ var { store, data } = instance;
44
+ if (store.getKey() !== data.key) {
45
+ //when navigating to a page using the same widget tree as the previous page
46
+ //everything needs to be reinstantiated, e.g. user/1 => user/2
47
+ instance.store = new ExposedValueView({
48
+ store: store,
49
+ containerBinding: this.storageBinding,
50
+ key: data.key,
51
+ recordName: this.recordName,
52
+ immutable: this.immutable,
53
+ sealed: this.sealed,
54
+ });
55
+ instance.clearChildrenCache();
56
+ }
57
+ super.prepareData(context, instance);
58
+ }
59
+ }
60
+
61
+ Sandbox.prototype.recordName = "$page";
62
+ Sandbox.prototype.immutable = false;
63
+ Sandbox.prototype.sealed = false;
64
+
65
+ Widget.alias("sandbox", Sandbox);
@@ -84,6 +84,14 @@ interface MonthPickerProps extends FieldProps {
84
84
  * When true, the quarters section will not render.
85
85
  */
86
86
  hideQuarters?: boolean;
87
+
88
+ /**
89
+ * Callback to create a function that determines if a date is selectable.
90
+ * Return `false` on factory method to disable specific month, quarter or a whole year.
91
+ *
92
+ * Note: Use the `onValidate` callback for validation purposes.
93
+ */
94
+ onCreateIsMonthDateSelectable?: (validationParams: Cx.Config, instance: Instance) => (monthDate: Date) => boolean;
87
95
  }
88
96
 
89
97
  export class MonthPicker extends Cx.Widget<MonthPickerProps> {}