cx 24.3.0 → 24.3.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.
package/dist/widgets.js CHANGED
@@ -2201,15 +2201,22 @@ function captureMouse2(e, _ref) {
2201
2201
  surface.className = "cxb-mousecapture";
2202
2202
  surface.style.cursor = cursor || getComputedStyle(e.currentTarget).cursor;
2203
2203
  document.body.appendChild(surface);
2204
+
2205
+ // In case when the event originates from an iframe,
2206
+ // we use that document as events do not bubble up. //
2207
+ var parentDocument = e.target.ownerDocument;
2208
+ var options = {
2209
+ capture: true,
2210
+ };
2204
2211
  var active = true;
2205
- surface.addEventListener("mousemove", move);
2206
- surface.addEventListener("mouseup", end);
2207
- if (onDblClick) surface.addEventListener("dblclick", doubleClick);
2212
+ parentDocument.addEventListener("mousemove", move, options);
2213
+ parentDocument.addEventListener("mouseup", end, options);
2214
+ if (onDblClick) parentDocument.addEventListener("dblclick", doubleClick);
2208
2215
  function tear() {
2209
2216
  if (surface == null) return;
2210
- surface.removeEventListener("mousemove", move);
2211
- surface.removeEventListener("mouseup", end);
2212
- if (onDblClick) surface.removeEventListener("dblclick", onDblClick);
2217
+ parentDocument.removeEventListener("mousemove", move, options);
2218
+ parentDocument.removeEventListener("mouseup", end, options);
2219
+ if (onDblClick) parentDocument.removeEventListener("dblclick", onDblClick, options);
2213
2220
  document.body.removeChild(surface);
2214
2221
  surface = null;
2215
2222
  }
@@ -16009,28 +16016,29 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16009
16016
  ),
16010
16017
  );
16011
16018
  }
16012
- headerRows.push(
16013
- /*#__PURE__*/ jsx(
16014
- "tbody",
16015
- {
16016
- className: CSS.element(baseClass, "header"),
16017
- children: result.map(function (h, i) {
16018
- return /*#__PURE__*/ jsx(
16019
- "tr",
16020
- {
16021
- children: h,
16022
- },
16023
- i,
16024
- );
16025
- }),
16026
- },
16027
- "h" + key + lineIndex,
16028
- ),
16019
+ headerRows.push.apply(
16020
+ headerRows,
16021
+ result.map(function (h, i) {
16022
+ return /*#__PURE__*/ jsx(
16023
+ "tr",
16024
+ {
16025
+ children: h,
16026
+ },
16027
+ lineIndex + "-" + i,
16028
+ );
16029
+ }),
16029
16030
  );
16030
16031
  }
16031
16032
  });
16032
16033
  if (headerRows.length == 0) return null;
16033
- return headerRows;
16034
+ return /*#__PURE__*/ jsx(
16035
+ "tbody",
16036
+ {
16037
+ className: CSS.element(baseClass, "header"),
16038
+ children: headerRows,
16039
+ },
16040
+ "h" + key,
16041
+ );
16034
16042
  };
16035
16043
  _proto.onHeaderMouseMove = function onHeaderMouseMove(e, column, columnInstance, gridInstance, headerLine) {
16036
16044
  var _headerInstance$widge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.3.0",
3
+ "version": "24.3.1",
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",
@@ -1,212 +1,212 @@
1
- import { computable } from "./computable";
2
- import { Format } from "../util/Format";
3
- import { Binding } from "./Binding";
4
-
5
- import { quoteStr } from "../util/quote";
6
- import { isDigit } from "../util/isDigit";
7
- import { isFunction } from "../util/isFunction";
8
-
9
- /*
10
- Helper usage example
11
-
12
- Expression.registerHelper('_', _);
13
- let e = Expression.compile('_.min({data})');
14
- */
15
-
16
- let expCache = {},
17
- helpers = {},
18
- helperNames = [],
19
- helperValues = [],
20
- expFatArrows = null;
21
-
22
- function getExpr(expr) {
23
- if (expr.memoize) return expr;
24
-
25
- function memoize() {
26
- let lastValue,
27
- lastRunBindings = {},
28
- lastRunResults = {},
29
- getters = {},
30
- currentData,
31
- len = -1;
32
-
33
- let get = function (bindingWithFormat) {
34
- let getter = getters[bindingWithFormat];
35
- if (!getter) {
36
- let binding = bindingWithFormat,
37
- format;
38
- let colonIndex = bindingWithFormat.indexOf(":");
39
- if (colonIndex != -1) {
40
- format = Format.parse(bindingWithFormat.substring(colonIndex + 1));
41
- binding = bindingWithFormat.substring(0, colonIndex);
42
- } else {
43
- let nullSeparatorIndex = bindingWithFormat.indexOf(":");
44
- if (nullSeparatorIndex != -1) {
45
- format = Format.parse(bindingWithFormat.substring(nullSeparatorIndex));
46
- binding = bindingWithFormat.substring(0, nullSeparatorIndex - 1);
47
- }
48
- }
49
- let b = Binding.get(binding);
50
- getter = (data) => {
51
- let value = b.value(data);
52
- lastRunBindings[len] = b.value;
53
- lastRunResults[len] = value;
54
- len++;
55
- return value;
56
- };
57
-
58
- if (format) {
59
- let valueGetter = getter;
60
- getter = (data) => format(valueGetter(data));
61
- }
62
-
63
- getters[bindingWithFormat] = getter;
64
- }
65
- return getter(currentData);
66
- };
67
-
68
- return function (data) {
69
- let i = 0;
70
- for (; i < len; i++) if (lastRunBindings[i](data) !== lastRunResults[i]) break;
71
- if (i !== len) {
72
- len = 0;
73
- currentData = data;
74
- lastValue = expr(get);
75
- }
76
- return lastValue;
77
- };
78
- }
79
-
80
- let result = memoize();
81
- result.memoize = memoize;
82
- return result;
83
- }
84
-
85
- export function expression(str) {
86
- if (isFunction(str)) return getExpr(str);
87
-
88
- let r = expCache[str];
89
- if (r) return r;
90
-
91
- let quote = false;
92
-
93
- let termStart = -1,
94
- curlyBrackets = 0,
95
- percentExpression;
96
-
97
- let fb = ["return ("];
98
-
99
- let args = {};
100
- let formats = [];
101
- let subExpr = 0;
102
-
103
- for (let i = 0; i < str.length; i++) {
104
- let c = str[i];
105
- switch (c) {
106
- case "{":
107
- if (curlyBrackets > 0) curlyBrackets++;
108
- else {
109
- if (!quote && termStart < 0 && (str[i + 1] != "{" || str[i - 1] == "%")) {
110
- termStart = i + 1;
111
- curlyBrackets = 1;
112
- percentExpression = str[i - 1] == "%";
113
- if (percentExpression) fb.pop(); //%
114
- } else if (str[i - 1] != "{") fb.push(c);
115
- }
116
- break;
117
-
118
- case "}":
119
- if (termStart >= 0) {
120
- if (--curlyBrackets == 0) {
121
- let term = str.substring(termStart, i);
122
- let formatStart = 0;
123
- if (term[0] == "[") formatStart = term.indexOf("]");
124
- let colon = term.indexOf(":", formatStart > 0 ? formatStart : 0);
125
- let binding = colon == -1 ? term : term.substring(0, colon);
126
- let format = colon == -1 ? null : term.substring(colon + 1);
127
- if (colon == -1) {
128
- let nullSepIndex = binding.indexOf("|", formatStart);
129
- if (nullSepIndex != -1) {
130
- format = binding.substring(nullSepIndex);
131
- binding = binding.substring(0, nullSepIndex);
132
- }
133
- }
134
- let argName = binding.replace(/\./g, "_");
135
- if (isDigit(argName[0])) argName = "$" + argName;
136
- if (percentExpression || (binding[0] == "[" && binding[binding.length - 1] == "]")) {
137
- argName = `expr${++subExpr}`;
138
- args[argName] = expression(percentExpression ? binding : binding.substring(1, binding.length - 1));
139
- } else args[argName] = binding;
140
- if (format) {
141
- let formatter = "fmt" + formats.length;
142
- fb.push(formatter, "(", argName, ", ", quoteStr(format), ")");
143
- formats.push(Format.parse(format));
144
- } else fb.push(argName);
145
- termStart = -1;
146
- }
147
- } else fb.push(c);
148
-
149
- break;
150
-
151
- case '"':
152
- case "'":
153
- if (curlyBrackets == 0) {
154
- if (!quote) quote = c;
155
- else if (str[i - 1] != "\\" && quote == c) quote = false;
156
- fb.push(c);
157
- }
158
- break;
159
-
160
- default:
161
- if (termStart < 0) fb.push(c);
162
- break;
163
- }
164
- }
165
-
166
- fb.push(")");
167
-
168
- let body = fb.join("");
169
-
170
- if (expFatArrows) body = expFatArrows(body);
171
-
172
- //console.log(body);
173
- let keys = Object.keys(args);
174
-
175
- try {
176
- let compute = new Function("fmt", ...formats.map((f, i) => "fmt" + i), ...keys, ...helperNames, body).bind(
177
- Format,
178
- Format.value,
179
- ...formats,
180
- ...helperValues
181
- );
182
- let selector = computable(...keys.map((k) => args[k]), compute);
183
- expCache[str] = selector;
184
- return selector;
185
- } catch (err) {
186
- throw new Error(`Failed to parse expression: '${str}'. Error: ${err.message}`);
187
- }
188
- }
189
-
190
- export const Expression = {
191
- get: function (str) {
192
- return expression(str);
193
- },
194
-
195
- compile: function (str) {
196
- return this.get(str).memoize();
197
- },
198
-
199
- registerHelper: function (name, helper) {
200
- helpers[name] = helper;
201
- helperNames = Object.keys(helpers);
202
- helperValues = helperNames.map((n) => helpers[n]);
203
- },
204
- };
205
-
206
- export function plugFatArrowExpansion(impl) {
207
- expFatArrows = impl;
208
- }
209
-
210
- export function invalidateExpressionCache() {
211
- expCache = {};
212
- }
1
+ import { computable } from "./computable";
2
+ import { Format } from "../util/Format";
3
+ import { Binding } from "./Binding";
4
+
5
+ import { quoteStr } from "../util/quote";
6
+ import { isDigit } from "../util/isDigit";
7
+ import { isFunction } from "../util/isFunction";
8
+
9
+ /*
10
+ Helper usage example
11
+
12
+ Expression.registerHelper('_', _);
13
+ let e = Expression.compile('_.min({data})');
14
+ */
15
+
16
+ let expCache = {},
17
+ helpers = {},
18
+ helperNames = [],
19
+ helperValues = [],
20
+ expFatArrows = null;
21
+
22
+ function getExpr(expr) {
23
+ if (expr.memoize) return expr;
24
+
25
+ function memoize() {
26
+ let lastValue,
27
+ lastRunBindings = {},
28
+ lastRunResults = {},
29
+ getters = {},
30
+ currentData,
31
+ len = -1;
32
+
33
+ let get = function (bindingWithFormat) {
34
+ let getter = getters[bindingWithFormat];
35
+ if (!getter) {
36
+ let binding = bindingWithFormat,
37
+ format;
38
+ let colonIndex = bindingWithFormat.indexOf(":");
39
+ if (colonIndex != -1) {
40
+ format = Format.parse(bindingWithFormat.substring(colonIndex + 1));
41
+ binding = bindingWithFormat.substring(0, colonIndex);
42
+ } else {
43
+ let nullSeparatorIndex = bindingWithFormat.indexOf(":");
44
+ if (nullSeparatorIndex != -1) {
45
+ format = Format.parse(bindingWithFormat.substring(nullSeparatorIndex));
46
+ binding = bindingWithFormat.substring(0, nullSeparatorIndex - 1);
47
+ }
48
+ }
49
+ let b = Binding.get(binding);
50
+ getter = (data) => {
51
+ let value = b.value(data);
52
+ lastRunBindings[len] = b.value;
53
+ lastRunResults[len] = value;
54
+ len++;
55
+ return value;
56
+ };
57
+
58
+ if (format) {
59
+ let valueGetter = getter;
60
+ getter = (data) => format(valueGetter(data));
61
+ }
62
+
63
+ getters[bindingWithFormat] = getter;
64
+ }
65
+ return getter(currentData);
66
+ };
67
+
68
+ return function (data) {
69
+ let i = 0;
70
+ for (; i < len; i++) if (lastRunBindings[i](data) !== lastRunResults[i]) break;
71
+ if (i !== len) {
72
+ len = 0;
73
+ currentData = data;
74
+ lastValue = expr(get);
75
+ }
76
+ return lastValue;
77
+ };
78
+ }
79
+
80
+ let result = memoize();
81
+ result.memoize = memoize;
82
+ return result;
83
+ }
84
+
85
+ export function expression(str) {
86
+ if (isFunction(str)) return getExpr(str);
87
+
88
+ let r = expCache[str];
89
+ if (r) return r;
90
+
91
+ let quote = false;
92
+
93
+ let termStart = -1,
94
+ curlyBrackets = 0,
95
+ percentExpression;
96
+
97
+ let fb = ["return ("];
98
+
99
+ let args = {};
100
+ let formats = [];
101
+ let subExpr = 0;
102
+
103
+ for (let i = 0; i < str.length; i++) {
104
+ let c = str[i];
105
+ switch (c) {
106
+ case "{":
107
+ if (curlyBrackets > 0) curlyBrackets++;
108
+ else {
109
+ if (!quote && termStart < 0 && (str[i + 1] != "{" || str[i - 1] == "%")) {
110
+ termStart = i + 1;
111
+ curlyBrackets = 1;
112
+ percentExpression = str[i - 1] == "%";
113
+ if (percentExpression) fb.pop(); //%
114
+ } else if (str[i - 1] != "{") fb.push(c);
115
+ }
116
+ break;
117
+
118
+ case "}":
119
+ if (termStart >= 0) {
120
+ if (--curlyBrackets == 0) {
121
+ let term = str.substring(termStart, i);
122
+ let formatStart = 0;
123
+ if (term[0] == "[") formatStart = term.indexOf("]");
124
+ let colon = term.indexOf(":", formatStart > 0 ? formatStart : 0);
125
+ let binding = colon == -1 ? term : term.substring(0, colon);
126
+ let format = colon == -1 ? null : term.substring(colon + 1);
127
+ if (colon == -1) {
128
+ let nullSepIndex = binding.indexOf("|", formatStart);
129
+ if (nullSepIndex != -1) {
130
+ format = binding.substring(nullSepIndex);
131
+ binding = binding.substring(0, nullSepIndex);
132
+ }
133
+ }
134
+ let argName = binding.replace(/\./g, "_");
135
+ if (isDigit(argName[0])) argName = "$" + argName;
136
+ if (percentExpression || (binding[0] == "[" && binding[binding.length - 1] == "]")) {
137
+ argName = `expr${++subExpr}`;
138
+ args[argName] = expression(percentExpression ? binding : binding.substring(1, binding.length - 1));
139
+ } else args[argName] = binding;
140
+ if (format) {
141
+ let formatter = "fmt" + formats.length;
142
+ fb.push(formatter, "(", argName, ", ", quoteStr(format), ")");
143
+ formats.push(Format.parse(format));
144
+ } else fb.push(argName);
145
+ termStart = -1;
146
+ }
147
+ } else fb.push(c);
148
+
149
+ break;
150
+
151
+ case '"':
152
+ case "'":
153
+ if (curlyBrackets == 0) {
154
+ if (!quote) quote = c;
155
+ else if (str[i - 1] != "\\" && quote == c) quote = false;
156
+ fb.push(c);
157
+ }
158
+ break;
159
+
160
+ default:
161
+ if (termStart < 0) fb.push(c);
162
+ break;
163
+ }
164
+ }
165
+
166
+ fb.push(")");
167
+
168
+ let body = fb.join("");
169
+
170
+ if (expFatArrows) body = expFatArrows(body);
171
+
172
+ //console.log(body);
173
+ let keys = Object.keys(args);
174
+
175
+ try {
176
+ let compute = new Function("fmt", ...formats.map((f, i) => "fmt" + i), ...keys, ...helperNames, body).bind(
177
+ Format,
178
+ Format.value,
179
+ ...formats,
180
+ ...helperValues
181
+ );
182
+ let selector = computable(...keys.map((k) => args[k]), compute);
183
+ expCache[str] = selector;
184
+ return selector;
185
+ } catch (err) {
186
+ throw new Error(`Failed to parse expression: '${str}'. Error: ${err.message}`);
187
+ }
188
+ }
189
+
190
+ export const Expression = {
191
+ get: function (str) {
192
+ return expression(str);
193
+ },
194
+
195
+ compile: function (str) {
196
+ return this.get(str).memoize();
197
+ },
198
+
199
+ registerHelper: function (name, helper) {
200
+ helpers[name] = helper;
201
+ helperNames = Object.keys(helpers);
202
+ helperValues = helperNames.map((n) => helpers[n]);
203
+ },
204
+ };
205
+
206
+ export function plugFatArrowExpansion(impl) {
207
+ expFatArrows = impl;
208
+ }
209
+
210
+ export function invalidateExpressionCache() {
211
+ expCache = {};
212
+ }