cx 26.4.3 → 26.5.1

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 (74) hide show
  1. package/build/charts/axis/Axis.d.ts +8 -0
  2. package/build/charts/axis/Axis.d.ts.map +1 -1
  3. package/build/charts/axis/Axis.js +18 -1
  4. package/build/charts/axis/TimeAxis.js +1 -0
  5. package/build/data/AugmentedViewBase.d.ts.map +1 -1
  6. package/build/data/AugmentedViewBase.js +5 -4
  7. package/build/data/View.d.ts +0 -1
  8. package/build/data/View.d.ts.map +1 -1
  9. package/build/data/View.js +1 -3
  10. package/build/ui/Format.d.ts.map +1 -1
  11. package/build/ui/Format.js +26 -2
  12. package/build/util/Format.d.ts.map +1 -1
  13. package/build/util/Format.js +6 -0
  14. package/build/util/date/dateQuarter.d.ts +7 -0
  15. package/build/util/date/dateQuarter.d.ts.map +1 -0
  16. package/build/util/date/dateQuarter.js +8 -0
  17. package/build/util/date/dayBefore.d.ts +12 -0
  18. package/build/util/date/dayBefore.d.ts.map +1 -0
  19. package/build/util/date/dayBefore.js +15 -0
  20. package/build/util/date/index.d.ts +2 -0
  21. package/build/util/date/index.d.ts.map +1 -1
  22. package/build/util/date/index.js +2 -0
  23. package/build/widgets/form/DateTimePicker.d.ts.map +1 -1
  24. package/build/widgets/form/DateTimePicker.js +53 -31
  25. package/build/widgets/form/Field.d.ts.map +1 -1
  26. package/build/widgets/form/Field.js +2 -1
  27. package/build/widgets/form/LookupField.js +2 -1
  28. package/build/widgets/form/Wheel.d.ts +8 -0
  29. package/build/widgets/form/Wheel.d.ts.map +1 -1
  30. package/build/widgets/form/Wheel.js +30 -7
  31. package/build/widgets/grid/Grid.d.ts +1 -1
  32. package/build/widgets/grid/Grid.d.ts.map +1 -1
  33. package/dist/charts.css +6 -0
  34. package/dist/charts.js +18 -1
  35. package/dist/data.js +5 -4
  36. package/dist/manifest.js +772 -763
  37. package/dist/ui.js +33 -1
  38. package/dist/util.js +32 -0
  39. package/dist/widgets.css +9 -3
  40. package/dist/widgets.js +230 -174
  41. package/package.json +1 -1
  42. package/src/charts/RangeMarker.scss +3 -0
  43. package/src/charts/axis/Axis.tsx +31 -1
  44. package/src/charts/axis/TimeAxis.tsx +1 -0
  45. package/src/charts/index.scss +1 -0
  46. package/src/data/AugmentedViewBase.ts +5 -4
  47. package/src/data/View.ts +16 -61
  48. package/src/ui/DataProxy.ts +55 -55
  49. package/src/ui/Format.spec.ts +32 -0
  50. package/src/ui/Format.ts +27 -2
  51. package/src/ui/Rescope.ts +50 -50
  52. package/src/ui/adapter/ArrayAdapter.ts +229 -229
  53. package/src/ui/exprHelpers.ts +96 -96
  54. package/src/util/Format.spec.ts +11 -0
  55. package/src/util/Format.ts +7 -0
  56. package/src/util/date/dateQuarter.ts +8 -0
  57. package/src/util/date/dayBefore.ts +15 -0
  58. package/src/util/date/index.ts +2 -0
  59. package/src/widgets/Sandbox.ts +104 -104
  60. package/src/widgets/form/ColorField.scss +112 -112
  61. package/src/widgets/form/DateTimeField.scss +111 -111
  62. package/src/widgets/form/DateTimePicker.tsx +453 -392
  63. package/src/widgets/form/Field.tsx +2 -1
  64. package/src/widgets/form/LookupField.maps.scss +26 -26
  65. package/src/widgets/form/LookupField.scss +10 -3
  66. package/src/widgets/form/LookupField.tsx +4 -1
  67. package/src/widgets/form/MonthField.scss +113 -113
  68. package/src/widgets/form/NumberField.scss +72 -72
  69. package/src/widgets/form/Select.scss +104 -104
  70. package/src/widgets/form/TextField.scss +66 -66
  71. package/src/widgets/form/ValidationGroup.spec.tsx +30 -1
  72. package/src/widgets/form/Wheel.tsx +36 -7
  73. package/src/widgets/grid/Grid.tsx +1 -1
  74. package/src/widgets/nav/MenuItem.tsx +525 -525
package/dist/ui.js CHANGED
@@ -15,12 +15,12 @@ import {
15
15
  ZoomIntoPropertyView,
16
16
  setGetExpressionCacheCallback,
17
17
  setGetStringTemplateCacheCallback,
18
+ StringTemplate,
18
19
  SubscribableView,
19
20
  Store,
20
21
  NestedDataView,
21
22
  Grouper,
22
23
  getComparer,
23
- StringTemplate,
24
24
  } from "cx/data";
25
25
  export { computable, createAccessorModelProxy, createModel } from "cx/data";
26
26
  import {
@@ -53,7 +53,9 @@ import {
53
53
  Format as Format$1,
54
54
  resolveMinMaxFractionDigits,
55
55
  parseDateInvariant,
56
+ dayBefore,
56
57
  setGetFormatCacheCallback,
58
+ dateQuarter,
57
59
  TraversalStack,
58
60
  reverseSlice,
59
61
  appDataFlag,
@@ -1902,6 +1904,31 @@ class ZIndexManager {
1902
1904
  }
1903
1905
 
1904
1906
  const Format = Format$1;
1907
+ // The `quarter` formatter renders a calendar quarter via a string-template
1908
+ // pattern with `{q}` (quarter number), `{yyyy}` and `{yy}` (year) placeholders.
1909
+ // Placeholders are case-insensitive (`{Q}`, `{YYYY}`, `{YY}` work too). It lives
1910
+ // here rather than in util/Format because it depends on StringTemplate from the
1911
+ // data layer, which util/ cannot import. It is registered eagerly since it does
1912
+ // not depend on culture settings.
1913
+ Format$1.registerFactory("quarter", (fmt, pattern, mode) => {
1914
+ let exclusive = mode === "exclusive" || mode === "ex" || mode === "e";
1915
+ let template = StringTemplate.get(pattern || "Q{q} {yyyy}");
1916
+ return (value) => {
1917
+ let date = parseDateInvariant(value);
1918
+ if (exclusive) date = dayBefore(date);
1919
+ let q = dateQuarter(date);
1920
+ let yyyy = date.getFullYear();
1921
+ let yy = String(yyyy % 100).padStart(2, "0");
1922
+ return template({
1923
+ q,
1924
+ Q: q,
1925
+ yyyy,
1926
+ YYYY: yyyy,
1927
+ yy,
1928
+ YY: yy,
1929
+ });
1930
+ };
1931
+ });
1905
1932
  let cultureSensitiveFormatsRegistered = false;
1906
1933
  function resolveNumberFormattingFlags(flags) {
1907
1934
  if (!flags) return null;
@@ -1966,6 +1993,11 @@ function enableCultureSensitiveFormatting() {
1966
1993
  let formatter = culture.getFormatter(format);
1967
1994
  return (value) => formatter.format(parseDateInvariant(value));
1968
1995
  });
1996
+ Format$1.registerFactory(["dayBefore", "daybefore"], (fmt, format = "yyyyMd hhmm") => {
1997
+ let culture = Culture.getDateTimeCulture();
1998
+ let formatter = culture.getFormatter(format);
1999
+ return (value) => formatter.format(dayBefore(parseDateInvariant(value)));
2000
+ });
1969
2001
  setGetFormatCacheCallback(() => {
1970
2002
  let cache = getCurrentCultureCache();
1971
2003
  if (!cache.formatCache) cache.formatCache = {};
package/dist/util.js CHANGED
@@ -156,6 +156,22 @@ function overrideParseDateInvariant(newImpl) {
156
156
  impl = newImpl;
157
157
  }
158
158
 
159
+ /**
160
+ * Returns a new `Date` representing the calendar day before the given date,
161
+ * keeping the same time of day. Month and year boundaries are handled
162
+ * automatically. The input is not mutated.
163
+ *
164
+ * Useful for displaying the exclusive end of a date range as an inclusive
165
+ * value, e.g. a period ending at `2021-01-01` shown as `Dec 2020`.
166
+ * @param date
167
+ * @returns {Date}
168
+ */
169
+ function dayBefore(date) {
170
+ let result = new Date(date.getTime());
171
+ result.setDate(result.getDate() - 1);
172
+ return result;
173
+ }
174
+
159
175
  const defaultFormatter = (v) => v.toString();
160
176
  let formatFactory = {
161
177
  string: function () {
@@ -225,6 +241,10 @@ let formatFactory = {
225
241
  let time = formatFactory.time();
226
242
  return (value) => date(value) + " " + time(value);
227
243
  },
244
+ dayBefore: function () {
245
+ let datetime = formatFactory.datetime();
246
+ return (value) => datetime(dayBefore(parseDateInvariant(value)));
247
+ },
228
248
  ellipsis: function (part0, length, where) {
229
249
  length = Number(length);
230
250
  if (!(length > 3)) length = 10;
@@ -288,6 +308,7 @@ formatFactory.ps = formatFactory.percentageSign;
288
308
  formatFactory.d = formatFactory.date;
289
309
  formatFactory.t = formatFactory.time;
290
310
  formatFactory.dt = formatFactory.datetime;
311
+ formatFactory.daybefore = formatFactory.dayBefore;
291
312
  formatFactory.zeropad = formatFactory.zeroPad;
292
313
  formatFactory.leftpad = formatFactory.leftPad;
293
314
  formatFactory.capitalize = formatFactory.capitalize;
@@ -715,6 +736,15 @@ function dateDiff(d1, d2) {
715
736
  return d1.getTime() - d2.getTime();
716
737
  }
717
738
 
739
+ /**
740
+ * Returns the calendar quarter (1-4) the given date falls in.
741
+ * @param date
742
+ * @returns {number}
743
+ */
744
+ function dateQuarter(date) {
745
+ return Math.floor(date.getMonth() / 3) + 1;
746
+ }
747
+
718
748
  /**
719
749
  * Zeros out time for the given Date object. E.g. for date object representing Wed Apr 19 2017 14:31:51 GMT+0200
720
750
  * returns Wed Apr 19 2017 00:00:00 GMT+0200.
@@ -1575,6 +1605,8 @@ export {
1575
1605
  coalesce,
1576
1606
  createComponentFactory,
1577
1607
  dateDiff,
1608
+ dateQuarter,
1609
+ dayBefore,
1578
1610
  debounce,
1579
1611
  debug,
1580
1612
  deprecatedFlag,
package/dist/widgets.css CHANGED
@@ -1429,9 +1429,6 @@ th.cxe-calendar-display {
1429
1429
  }
1430
1430
 
1431
1431
  .cxs-single > .cxe-lookupfield-input {
1432
- overflow: hidden;
1433
- text-overflow: ellipsis;
1434
- white-space: nowrap;
1435
1432
  flex-basis: 0%;
1436
1433
  flex-grow: 1;
1437
1434
  }
@@ -1440,6 +1437,15 @@ th.cxe-calendar-display {
1440
1437
  padding-left: 26px;
1441
1438
  }
1442
1439
 
1440
+ .cxe-lookupfield-text {
1441
+ overflow: hidden;
1442
+ text-overflow: ellipsis;
1443
+ white-space: nowrap;
1444
+ min-width: 0;
1445
+ flex-basis: 0%;
1446
+ flex-grow: 1;
1447
+ }
1448
+
1443
1449
  .cxe-lookupfield-tags {
1444
1450
  display: flex;
1445
1451
  margin: -2px -2px -2px -2px;