jsl-ui 9.0.1 → 9.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.
@@ -1,6 +1,6 @@
1
1
  import { IJSLComponent, IJSLVNode } from "jsl-render";
2
2
  import { IDialogOptions, JSLDialog } from "../../ui/dialog";
3
- import { IMoveableOptions } from '../../interaction/moveable';
3
+ import { IMoveableOptions } from "../../interaction/moveable";
4
4
  import { IResizeOptions } from "../../interaction/resizable";
5
5
  export interface IDialogComponentOptions extends IDialogOptions {
6
6
  width?: string;
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { JSLRender } from "jsl-render";
13
13
  import { Dialog } from "../../ui/dialog";
14
- import { Moveable } from '../../interaction/moveable';
14
+ import { Moveable } from "../../interaction/moveable";
15
15
  import { EventHandler } from "../../interaction/eventhandler";
16
16
  import { Resizable } from "../../interaction/resizable";
17
17
  import { UILang } from "../../core/lang";
@@ -7,6 +7,7 @@
7
7
  padding: 0.3rem;
8
8
  border-bottom: 1px solid #c9c9c9;
9
9
  border-top: 1px solid #c9c9c9;
10
+ flex-shrink: 0;
10
11
  background: linear-gradient(90deg,
11
12
  rgb(255,255,255) 0%,
12
13
  rgb(246,246,246) 20%,
@@ -9,6 +9,10 @@ export interface ISelectRenderArg<T = any> {
9
9
  isSelected: boolean;
10
10
  isCurrent: boolean;
11
11
  }
12
+ export interface ISelectRenderGroupArg {
13
+ groupValue: any;
14
+ node: IJSLVNode;
15
+ }
12
16
  export interface ISelectComponentOptions<T = any, TValue = any, TBinding = any> {
13
17
  data: T[];
14
18
  style?: string;
@@ -25,6 +29,7 @@ export interface ISelectComponentOptions<T = any, TValue = any, TBinding = any>
25
29
  enableAnimation?: boolean;
26
30
  allowEmpty?: boolean;
27
31
  onRender?: (args: ISelectRenderArg<T>) => void | IJSLVNode;
32
+ onRenderGroup?: (args: ISelectRenderGroupArg) => void | IJSLVNode;
28
33
  matchSearch?: (data: T, term: string) => boolean;
29
34
  onAppend?: (dom: HTMLDivElement) => void;
30
35
  enableKeyboard?: boolean;
@@ -33,6 +38,7 @@ export interface ISelectComponentOptions<T = any, TValue = any, TBinding = any>
33
38
  bindTo?: TBinding;
34
39
  property?: keyof TBinding;
35
40
  converter?: IDataConverter<any, TValue>;
41
+ groupProperty?: keyof T;
36
42
  bindMode?: "toModel" | "fromModel" | "both";
37
43
  onChange?: EventHandler<TValue, T> | ((keyValue?: TValue, item?: T) => void);
38
44
  value?: TValue;
@@ -38,6 +38,9 @@ var SelectComponent = /** @class */ (function () {
38
38
  onAppend: function (dom) {
39
39
  document.body.appendChild(dom);
40
40
  },
41
+ onRenderGroup: function (args) {
42
+ args.node.content = args.groupValue;
43
+ },
41
44
  onRender: o.multiple ? function (args) {
42
45
  if (args.isCurrent) {
43
46
  args.node.content = args.data.map(function (d) { return d[_this.options.textColumn]; }).join(", ");
@@ -16,6 +16,7 @@ export declare class SelectDDAreaComponent implements IJSLComponent {
16
16
  private static TAB_KEY;
17
17
  onRender: EventHandler<any[], void>;
18
18
  private filteredData;
19
+ private renderedData;
19
20
  private dom;
20
21
  private scrollContainer;
21
22
  private isScrolling;
@@ -1,3 +1,10 @@
1
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
2
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
4
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
5
+ r[k] = a[j];
6
+ return r;
7
+ };
1
8
  import { VirtualRenderComponent } from "../virtual-render/VirtualRenderComponent";
2
9
  import { EventHandler } from "../../interaction/eventhandler";
3
10
  function isInternetExplorer() {
@@ -17,7 +24,7 @@ var SelectDDAreaComponent = /** @class */ (function () {
17
24
  }
18
25
  SelectDDAreaComponent.prototype.onCreate = function (node) {
19
26
  var _this = this;
20
- var _a;
27
+ var _a, _b;
21
28
  this.dom = node.dom;
22
29
  this.scrollContainer = this.dom.querySelector(".sel-dd-items");
23
30
  var item = this.component.getSelected();
@@ -26,7 +33,7 @@ var SelectDDAreaComponent = /** @class */ (function () {
26
33
  item = item[0];
27
34
  }
28
35
  if (item != null) {
29
- var d = (_a = this.filteredData, (_a !== null && _a !== void 0 ? _a : this.options.data));
36
+ var d = (_b = (_a = this.renderedData, (_a !== null && _a !== void 0 ? _a : this.filteredData)), (_b !== null && _b !== void 0 ? _b : this.options.data));
30
37
  var idx = d.indexOf(item);
31
38
  this.scrollContainer.scrollTop = this.options.rowHeight * idx;
32
39
  }
@@ -55,7 +62,27 @@ var SelectDDAreaComponent = /** @class */ (function () {
55
62
  var _this = this;
56
63
  var _a;
57
64
  var data = (_a = this.filteredData, (_a !== null && _a !== void 0 ? _a : this.options.data));
65
+ if (this.options.groupProperty != null) {
66
+ var sortedData = __spreadArrays(data);
67
+ sortedData.sort(function (a, b) {
68
+ return a[_this.options.groupProperty] < b[_this.options.groupProperty] ? -1
69
+ : a[_this.options.groupProperty] > b[_this.options.groupProperty] ? 1 : (data.indexOf(a) - data.indexOf(b) // preserve order if it is for same group
70
+ );
71
+ });
72
+ data = [];
73
+ var prevGroupVal = NaN;
74
+ for (var _i = 0, sortedData_1 = sortedData; _i < sortedData_1.length; _i++) {
75
+ var x = sortedData_1[_i];
76
+ if (x[this.options.groupProperty] !== prevGroupVal) {
77
+ // create group entry
78
+ data.push({ __isGroup: true, __groupValue: x[this.options.groupProperty] });
79
+ prevGroupVal = x[this.options.groupProperty];
80
+ }
81
+ data.push(x);
82
+ }
83
+ }
58
84
  this.onRender.notify(data);
85
+ this.renderedData = data;
59
86
  var ddNode = {
60
87
  tag: "div", animation: this.options.enableAnimation ? { attr: "opacity", from: "0", to: "1", duration: 400 } : undefined, children: [
61
88
  {
@@ -145,6 +172,23 @@ var SelectDDAreaComponent = /** @class */ (function () {
145
172
  bufferSizeInPx: 20,
146
173
  renderRow: function (args) {
147
174
  var result = { tag: "div", attr: { class: "sel-dd-item" } };
175
+ if (_this.options.groupProperty && args.rowData.__isGroup) {
176
+ result.attr.class += " sel-dd-group";
177
+ var groupValue = args.rowData.__groupValue;
178
+ var groupArgs = {
179
+ groupValue: groupValue, node: result
180
+ };
181
+ var resGroup = _this.options.onRenderGroup(groupArgs);
182
+ if (resGroup != null) {
183
+ result.children = [resGroup];
184
+ }
185
+ result.attr.mousedown = function (evt) {
186
+ evt.preventDefault();
187
+ evt.stopPropagation();
188
+ evt.stopImmediatePropagation();
189
+ };
190
+ return result;
191
+ }
148
192
  var renderArg = {
149
193
  data: args.rowData,
150
194
  node: result,
@@ -162,8 +206,8 @@ var SelectDDAreaComponent = /** @class */ (function () {
162
206
  }
163
207
  result.attr.mousedown = function (evt) {
164
208
  if (_this.options.multiple) {
165
- evt.preventDefault(),
166
- evt.stopPropagation();
209
+ evt.preventDefault();
210
+ evt.stopPropagation();
167
211
  evt.stopImmediatePropagation();
168
212
  var currentSelection = _this.component.getSelected();
169
213
  if (currentSelection.indexOf(args.rowData) >= 0) {
@@ -191,11 +235,11 @@ var SelectDDAreaComponent = /** @class */ (function () {
191
235
  return ddNode;
192
236
  };
193
237
  SelectDDAreaComponent.prototype.navigateDown = function () {
194
- var _a, _b;
195
- var d = (_a = this.filteredData, (_a !== null && _a !== void 0 ? _a : this.options.data));
196
- var selItem = (_b = this.component.getFocus(), (_b !== null && _b !== void 0 ? _b : this.component.getSelected()));
238
+ var _a, _b, _c;
239
+ var d = (_b = (_a = this.renderedData, (_a !== null && _a !== void 0 ? _a : this.filteredData)), (_b !== null && _b !== void 0 ? _b : this.options.data));
240
+ var selItem = (_c = this.component.getFocus(), (_c !== null && _c !== void 0 ? _c : this.component.getSelected()));
197
241
  if (selItem == null) {
198
- this.component.setFocus(d[0]);
242
+ this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
199
243
  return;
200
244
  }
201
245
  if (Array.isArray(selItem)) {
@@ -203,33 +247,40 @@ var SelectDDAreaComponent = /** @class */ (function () {
203
247
  }
204
248
  var idx = d.indexOf(selItem);
205
249
  if (idx < 0) {
206
- this.component.setFocus(d[0]);
250
+ this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
207
251
  }
208
- else if (idx < d.length - 1) {
209
- this.component.setFocus(d[idx + 1]);
210
- this.scrollContainer.scrollTop = this.options.rowHeight * idx;
211
- // this.scrollContainer.scrollTop += this.options.rowHeight; // TODO: fune tuning needed when currently selected item is already outside of bounds
252
+ else {
253
+ while (idx < d.length - 1) {
254
+ idx++;
255
+ if (!d[idx].__isGroup) {
256
+ this.component.setFocus(d[idx]);
257
+ this.scrollContainer.scrollTop = this.options.rowHeight * idx;
258
+ break;
259
+ }
260
+ }
212
261
  }
213
262
  };
214
263
  SelectDDAreaComponent.prototype.navigateUp = function () {
215
- var _a, _b;
216
- var d = (_a = this.filteredData, (_a !== null && _a !== void 0 ? _a : this.options.data));
217
- var selItem = (_b = this.component.getFocus(), (_b !== null && _b !== void 0 ? _b : this.component.getSelected()));
264
+ var _a, _b, _c;
265
+ var d = (_b = (_a = this.renderedData, (_a !== null && _a !== void 0 ? _a : this.filteredData)), (_b !== null && _b !== void 0 ? _b : this.options.data));
266
+ var selItem = (_c = this.component.getFocus(), (_c !== null && _c !== void 0 ? _c : this.component.getSelected()));
218
267
  if (selItem == null) {
219
- this.component.setFocus(d[0]);
268
+ this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
220
269
  return;
221
270
  }
222
271
  if (Array.isArray(selItem)) {
223
272
  selItem = selItem[0];
224
273
  }
225
274
  var idx = d.indexOf(selItem);
226
- if (idx > 0) {
227
- this.component.setFocus(d[idx - 1]);
228
- this.scrollContainer.scrollTop = this.options.rowHeight * (idx - 1);
229
- // this.scrollContainer.scrollTop -= this.options.rowHeight; // TODO: fune tuning needed when currently selected item is already outside of bounds
230
- return;
275
+ while (idx > 0) {
276
+ idx--;
277
+ if (!d[idx].__isGroup) {
278
+ this.component.setFocus(d[idx]);
279
+ this.scrollContainer.scrollTop = this.options.rowHeight * idx;
280
+ return;
281
+ }
231
282
  }
232
- this.component.setFocus(d[0]);
283
+ this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
233
284
  };
234
285
  SelectDDAreaComponent.prototype.search = function (term) {
235
286
  var _this = this;
@@ -139,7 +139,7 @@
139
139
  }
140
140
  }
141
141
 
142
- .sel-dd-item {
142
+ .sel-dd-item:not(.sel-dd-group) {
143
143
  &:hover {
144
144
  background: #d0d0d0;
145
145
  }
@@ -175,4 +175,13 @@
175
175
  height: 100%;
176
176
  line-height: 26px;
177
177
  }
178
+
179
+ .sel-dd-group {
180
+ font-weight: bold;
181
+ background: #e0e0e0;
182
+ text-align: center;
183
+ // &:hover {
184
+ // background: #d0d0d0;
185
+ // }
186
+ }
178
187
  }
@@ -2,6 +2,7 @@ export declare abstract class helper {
2
2
  static emptyGuid: string;
3
3
  static random(): number;
4
4
  static newGuid(): string;
5
+ static newSeqGuid(): string;
5
6
  static newDomGuid(): string;
6
7
  static isObject(obj: any): boolean;
7
8
  static isGuid(id: any): boolean;
@@ -7,6 +7,17 @@ var helper = /** @class */ (function () {
7
7
  helper.newGuid = function () {
8
8
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { var r = helper.random() * 16 | 0, v = c == "x" ? r : r & 0x3 | 0x8; return v.toString(16); });
9
9
  };
10
+ helper.newSeqGuid = function () {
11
+ var d = new Date().getTime().toString(16);
12
+ while (d.length < 12) {
13
+ d = "0" + d;
14
+ }
15
+ if (d.length > 12) {
16
+ d = d.substring(0, 12);
17
+ }
18
+ return "xxxxxxxx-xxxx-4xxx-yxxx-".replace(/[xy]/g, function (c) { var r = helper.random() * 16 | 0, v = c == "x" ? r : r & 0x3 | 0x8; return v.toString(16); })
19
+ + d;
20
+ };
10
21
  helper.newDomGuid = function () {
11
22
  return "axxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { var r = helper.random() * 16 | 0, v = c == "x" ? r : r & 0x3 | 0x8; return v.toString(16); });
12
23
  };
@@ -0,0 +1 @@
1
+ export declare function CellExternalCopyManager(options: any): void;