jsbox-cview 1.0.0 → 1.1.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 (47) hide show
  1. package/dist/components/alert/input-alert.js +39 -0
  2. package/dist/components/alert/login-alert.js +45 -0
  3. package/dist/components/alert/plain-alert.js +25 -0
  4. package/dist/components/alert/uialert.js +89 -0
  5. package/dist/components/artificial-flowlayout.js +258 -0
  6. package/dist/components/base.js +43 -0
  7. package/dist/components/custom-navigation-bar.js +519 -0
  8. package/dist/components/dialogs/dialog-sheet.js +67 -0
  9. package/dist/components/dialogs/form-dialog.js +24 -0
  10. package/dist/components/dialogs/list-dialog.js +87 -0
  11. package/dist/components/dialogs/text-dialog.js +31 -0
  12. package/dist/components/dynamic-itemsize-matrix.js +129 -0
  13. package/dist/components/dynamic-preference-listview.js +557 -0
  14. package/dist/components/dynamic-rowheight-list.js +44 -0
  15. package/dist/components/enhanced-imageview.js +114 -0
  16. package/dist/components/image-pager.js +157 -0
  17. package/dist/components/page-control.js +76 -0
  18. package/dist/components/pageviewer-titlebar.js +143 -0
  19. package/dist/components/pageviewer.js +96 -0
  20. package/dist/components/rotating-view.js +102 -0
  21. package/dist/components/searchbar.js +322 -0
  22. package/dist/components/sheet.js +82 -0
  23. package/dist/components/single-views.js +429 -0
  24. package/dist/components/spinners/loading-double-rings.js +104 -0
  25. package/dist/components/spinners/loading-dual-ring.js +82 -0
  26. package/dist/components/spinners/loading-wedges.js +104 -0
  27. package/dist/components/spinners/spinner-androidstyle.js +248 -0
  28. package/dist/components/static-preference-listview.js +798 -0
  29. package/dist/components/symbol-button.js +79 -0
  30. package/dist/components/tabbar.js +357 -0
  31. package/dist/controller/base-controller.js +178 -0
  32. package/dist/controller/controller-router.js +68 -0
  33. package/dist/controller/pageviewer-controller.js +63 -0
  34. package/dist/controller/presented-page-controller.js +48 -0
  35. package/dist/controller/splitview-controller.js +252 -0
  36. package/dist/controller/tabbar-controller.js +74 -0
  37. package/dist/index.js +58 -0
  38. package/dist/test.js +1 -0
  39. package/dist/utils/colors.js +15 -0
  40. package/dist/utils/cvid.js +28 -0
  41. package/dist/utils/l10n.js +44 -0
  42. package/dist/utils/path.js +107 -0
  43. package/dist/utils/rect.js +72 -0
  44. package/dist/utils/uitools.js +95 -0
  45. package/index.ts +42 -0
  46. package/package.json +4 -3
  47. package/tsconfig.json +5 -3
@@ -0,0 +1,798 @@
1
+ "use strict";
2
+ /**
3
+ * # cview PreferenceListView_static
4
+ *
5
+ * 便捷的设置列表实现. 其所有 cell 均为静态 cell, 可以同时使用 list 控件的 props(除了 template, data)和 events(除了 didSelect), 同时具有独特方法 set(key, value), 以及独特方法 changed
6
+ *
7
+ * sections 为 Array, 里面的 section 定义:
8
+ *
9
+ * - title?: string 标题.
10
+ * - rows: {type: string}[] 内容
11
+ *
12
+ * row定义:
13
+ *
14
+ * - 通用:
15
+ *
16
+ * - type: string 类型. 包括'string', 'number', 'integer', 'stepper','boolean', 'slider', 'list', 'tab','info', 'link', 'action'
17
+ * - key?: string 键. 如没有则不会返回其值.
18
+ * - title?: string 标题
19
+ * - value?: any 在下面专项里详解.
20
+ * - titleColor?: $color = $color("primaryText") 标题颜色
21
+ *
22
+ * - string:
23
+ *
24
+ * - value?: string
25
+ * - placeholder?: string
26
+ * - textColor?: $color = $color("primaryText")
27
+ *
28
+ * - number, integer:
29
+ *
30
+ * - value?: number
31
+ * - placeholder?: string
32
+ * - textColor?: $color = $color("primaryText")
33
+ * - min?: number 最小值
34
+ * - max?: number 最大值
35
+ *
36
+ * - stepper:
37
+ *
38
+ * - value?: number
39
+ * - placeholder?: string
40
+ * - min?: number 最小值
41
+ * - max?: number 最大值
42
+ *
43
+ * - boolean:
44
+ *
45
+ * - value?: boolean
46
+ * - onColor?: $color = $color("#34C85A")
47
+ * - thumbColor
48
+ *
49
+ * - slider:
50
+ *
51
+ * - value?: number 即 slider.value
52
+ * - decimal?: number = 1 精度
53
+ * - min?: number
54
+ * - max?: number
55
+ * - minColor?: $color = $color("systemLink")
56
+ * - maxColor?: $color
57
+ * - thumbColor?: $color
58
+ *
59
+ * - list:
60
+ *
61
+ * - value?: number 即 index, -1 时为不选
62
+ * - items?: string[]
63
+ *
64
+ * - tab:
65
+ *
66
+ * - value?: number 即 index, -1 时为不选
67
+ * - items?: string[]
68
+ *
69
+ * - info:
70
+ *
71
+ * - value?: string
72
+ *
73
+ * - link:
74
+ *
75
+ * - value?: string url
76
+ *
77
+ * - action:
78
+ *
79
+ * - value?: function 点击后会执行的函数
80
+ * - destructive?: boolean = false 是否为危险动作,若是则为红色
81
+ *
82
+ * Methods:
83
+ *
84
+ * - set(key, value) 设定 key 对应的 value
85
+ * - cview.values 获取全部的 values
86
+ *
87
+ * Events:
88
+ *
89
+ * - changed: values => {}
90
+ */
91
+ Object.defineProperty(exports, "__esModule", { value: true });
92
+ exports.PreferenceListView = void 0;
93
+ const base_1 = require("./base");
94
+ const uitools_1 = require("../utils/uitools");
95
+ class Cell extends base_1.Base {
96
+ constructor({ key, title, value, titleColor = $color("primaryText"), changedEvent }, values) {
97
+ super();
98
+ this._key = key;
99
+ this._title = title;
100
+ this._value = value;
101
+ this._titleColor = titleColor;
102
+ this._changedEvent = changedEvent;
103
+ this._values = values;
104
+ const selectableTypes = [
105
+ "string",
106
+ "number",
107
+ "integer",
108
+ "stepper",
109
+ "list",
110
+ "link",
111
+ "action"
112
+ ];
113
+ this._defineView = () => {
114
+ return {
115
+ type: "view",
116
+ props: {
117
+ selectable: selectableTypes.includes(this._type),
118
+ id: this.id
119
+ },
120
+ layout: $layout.fill,
121
+ views: [this._defineTitleView(), this._defineValueView()]
122
+ };
123
+ };
124
+ }
125
+ set value(value) {
126
+ if (this._handleValue)
127
+ value = this._handleValue(value);
128
+ if (this._key)
129
+ this._values[this._key] = value;
130
+ this._value = value;
131
+ }
132
+ get value() {
133
+ return this._value;
134
+ }
135
+ get type() {
136
+ return this._type;
137
+ }
138
+ get key() {
139
+ return this._key;
140
+ }
141
+ _defineTitleView() {
142
+ return {
143
+ type: "label",
144
+ props: {
145
+ id: "title",
146
+ text: this._title,
147
+ textColor: this._titleColor,
148
+ font: $font(17)
149
+ },
150
+ layout: (make, view) => {
151
+ make.centerY.equalTo(view.super);
152
+ make.width.equalTo((0, uitools_1.getTextWidth)(this._title || ""));
153
+ make.left.inset(15);
154
+ }
155
+ };
156
+ }
157
+ }
158
+ class BaseStringCell extends Cell {
159
+ constructor(props, values) {
160
+ super(props, values);
161
+ const { placeholder, textColor } = props;
162
+ this._placeholder = placeholder;
163
+ this._textColor = textColor;
164
+ }
165
+ _defineValueView() {
166
+ var _a;
167
+ return {
168
+ type: "view",
169
+ props: {},
170
+ layout: (make, view) => {
171
+ make.top.bottom.inset(0);
172
+ make.left.equalTo(view.prev.right).inset(10);
173
+ make.right.inset(15);
174
+ },
175
+ views: [
176
+ {
177
+ type: "image",
178
+ props: {
179
+ symbol: "chevron.right",
180
+ tintColor: $color("lightGray", "darkGray"),
181
+ contentMode: 1
182
+ },
183
+ layout: (make, view) => {
184
+ make.centerY.equalTo(view.super);
185
+ make.size.equalTo($size(17, 17));
186
+ make.right.inset(0);
187
+ }
188
+ },
189
+ {
190
+ type: "label",
191
+ props: {
192
+ id: "label",
193
+ text: (_a = this._handleText(this._value)) === null || _a === void 0 ? void 0 : _a.toString(),
194
+ align: $align.right,
195
+ font: $font(17),
196
+ textColor: this._textColor,
197
+ bgcolor: $color("clear"),
198
+ userInteractionEnabled: false
199
+ },
200
+ layout: (make, view) => {
201
+ make.centerY.equalTo(view.super);
202
+ make.left.inset(0);
203
+ make.right.equalTo(view.prev.left).inset(5);
204
+ }
205
+ }
206
+ ]
207
+ };
208
+ }
209
+ _handleValue(text) {
210
+ const result = this._handleText(text);
211
+ const label = this.view.get("label");
212
+ if (result === undefined)
213
+ label.text = "";
214
+ else
215
+ label.text = result.toString();
216
+ return result;
217
+ }
218
+ }
219
+ class StringCell extends BaseStringCell {
220
+ constructor(props, values) {
221
+ super(props, values);
222
+ this._type = "string";
223
+ }
224
+ _handleText(text) {
225
+ return text;
226
+ }
227
+ }
228
+ class NumberCell extends BaseStringCell {
229
+ constructor(props, values) {
230
+ super(props, values);
231
+ this._type = "number";
232
+ const { min, max } = props;
233
+ this._min = min;
234
+ this._max = max;
235
+ }
236
+ _handleText(text) {
237
+ if (!text)
238
+ return;
239
+ const result = parseFloat(text);
240
+ if (isNaN(result))
241
+ return;
242
+ if (this._min !== undefined && result < this._min)
243
+ return;
244
+ if (this._max !== undefined && result > this._max)
245
+ return;
246
+ return result;
247
+ }
248
+ }
249
+ class IntegerCell extends BaseStringCell {
250
+ constructor(props, values) {
251
+ super(props, values);
252
+ this._type = "integer";
253
+ const { min, max } = props;
254
+ this._min = min || 0;
255
+ this._max = max;
256
+ }
257
+ _handleText(text) {
258
+ if (!text)
259
+ return;
260
+ const result = parseInt(text);
261
+ if (isNaN(result))
262
+ return;
263
+ if (this._min !== undefined && result < this._min)
264
+ return;
265
+ if (this._max !== undefined && result > this._max)
266
+ return;
267
+ return result;
268
+ }
269
+ }
270
+ class StepperCell extends Cell {
271
+ constructor(props, values) {
272
+ super(props, values);
273
+ this._type = "stepper";
274
+ const { max, min } = props;
275
+ this._max = max;
276
+ this._min = min || 0;
277
+ }
278
+ _defineValueView() {
279
+ return {
280
+ type: "view",
281
+ props: {},
282
+ views: [
283
+ {
284
+ type: "stepper",
285
+ props: {
286
+ id: "stepper",
287
+ value: this._value || this._min,
288
+ max: this._max,
289
+ min: this._min
290
+ },
291
+ layout: (make, view) => {
292
+ make.centerY.equalTo(view.super);
293
+ make.right.inset(0);
294
+ },
295
+ events: {
296
+ changed: sender => {
297
+ this.value = sender.value;
298
+ if (this._changedEvent)
299
+ this._changedEvent();
300
+ }
301
+ }
302
+ },
303
+ {
304
+ type: "label",
305
+ props: {
306
+ id: "label",
307
+ text: this._value || this._min,
308
+ align: $align.right
309
+ },
310
+ layout: (make, view) => {
311
+ make.top.bottom.inset(0);
312
+ make.right.equalTo(view.prev.left).inset(10);
313
+ make.width.equalTo(30);
314
+ }
315
+ }
316
+ ],
317
+ layout: (make, view) => {
318
+ make.top.bottom.inset(0);
319
+ make.left.equalTo(view.prev.right).inset(10);
320
+ make.right.inset(15);
321
+ }
322
+ };
323
+ }
324
+ _handleValue(num) {
325
+ if (isNaN(num))
326
+ num = this._min;
327
+ if (this._min !== undefined && num < this._min)
328
+ num = this._min;
329
+ if (this._max !== undefined && num > this._max)
330
+ num = this._max;
331
+ const label = this.view.get("label");
332
+ label.text = num.toString();
333
+ const stepper = this.view.get("stepper");
334
+ stepper.value = num;
335
+ return num;
336
+ }
337
+ }
338
+ class BooleanCell extends Cell {
339
+ constructor(props, values) {
340
+ super(props, values);
341
+ this._type = "boolean";
342
+ const { onColor = $color("#34C85A"), thumbColor } = props;
343
+ this._onColor = onColor;
344
+ this._thumbColor = thumbColor;
345
+ }
346
+ _defineValueView() {
347
+ return {
348
+ type: "switch",
349
+ props: {
350
+ id: "switch",
351
+ on: this._value,
352
+ onColor: this._onColor,
353
+ thumbColor: this._thumbColor
354
+ },
355
+ layout: (make, view) => {
356
+ make.size.equalTo($size(51, 31));
357
+ make.centerY.equalTo(view.super);
358
+ make.right.inset(15);
359
+ },
360
+ events: {
361
+ changed: sender => {
362
+ this.value = sender.on;
363
+ if (this._changedEvent)
364
+ this._changedEvent();
365
+ }
366
+ }
367
+ };
368
+ }
369
+ _handleValue(bool) {
370
+ const switchView = this.view.get("switch");
371
+ switchView.on = bool;
372
+ return bool;
373
+ }
374
+ }
375
+ class SliderCell extends Cell {
376
+ constructor(props, values) {
377
+ super(props, values);
378
+ this._type = "slider";
379
+ const { decimal = 1, min = 0, max = 1, minColor = $color("systemLink"), maxColor, thumbColor } = props;
380
+ this._decimal = decimal;
381
+ this._min = min;
382
+ this._max = max;
383
+ this._minColor = minColor;
384
+ this._maxColor = maxColor;
385
+ this._thumbColor = thumbColor;
386
+ }
387
+ _defineValueView() {
388
+ return {
389
+ type: "view",
390
+ props: {},
391
+ views: [
392
+ {
393
+ type: "label",
394
+ props: {
395
+ id: "label",
396
+ text: this._value.toFixed(this._decimal),
397
+ align: $align.center
398
+ },
399
+ layout: (make, view) => {
400
+ make.top.right.bottom.inset(0);
401
+ make.width.equalTo(44);
402
+ }
403
+ },
404
+ {
405
+ type: "slider",
406
+ props: {
407
+ id: "slider",
408
+ value: this._value,
409
+ max: this._max,
410
+ min: this._min,
411
+ minColor: this._minColor,
412
+ maxColor: this._maxColor,
413
+ thumbColor: this._thumbColor,
414
+ continuous: true
415
+ },
416
+ layout: (make, view) => {
417
+ make.top.left.bottom.inset(0);
418
+ make.right.equalTo(view.prev.left);
419
+ },
420
+ events: {
421
+ changed: sender => {
422
+ const adjustedValue = parseFloat(sender.value.toFixed(this._decimal));
423
+ const label = sender.prev;
424
+ label.text = adjustedValue.toString();
425
+ if (this._key) {
426
+ this._values[this._key] = adjustedValue;
427
+ this._value = adjustedValue;
428
+ }
429
+ },
430
+ touchesEnded: sender => {
431
+ const adjustedValue = parseFloat(sender.value.toFixed(this._decimal));
432
+ this.value = adjustedValue;
433
+ if (this._changedEvent)
434
+ this._changedEvent();
435
+ }
436
+ }
437
+ }
438
+ ],
439
+ layout: (make, view) => {
440
+ make.top.bottom.inset(0);
441
+ make.left.lessThanOrEqualTo(view.prev.right).inset(10).priority(999);
442
+ make.width.lessThanOrEqualTo(250);
443
+ make.right.inset(15);
444
+ }
445
+ };
446
+ }
447
+ _handleValue(num) {
448
+ if (isNaN(num))
449
+ num = this._min;
450
+ if (this._min !== undefined && num < this._min)
451
+ num = this._min;
452
+ if (this._max !== undefined && num > this._max)
453
+ num = this._max;
454
+ const adjustedValue = parseFloat(num.toFixed(this._decimal));
455
+ const label = this.view.get("label");
456
+ label.text = adjustedValue.toString();
457
+ const slider = this.view.get("slider");
458
+ slider.value = adjustedValue;
459
+ return adjustedValue;
460
+ }
461
+ }
462
+ class ListCell extends Cell {
463
+ constructor(props, values) {
464
+ super(props, values);
465
+ this._type = "list";
466
+ const { items } = props;
467
+ this._items = items;
468
+ }
469
+ _defineValueView() {
470
+ return {
471
+ type: "view",
472
+ props: {},
473
+ layout: (make, view) => {
474
+ make.top.bottom.inset(0);
475
+ make.left.equalTo(view.prev.right).inset(10);
476
+ make.right.inset(15);
477
+ },
478
+ views: [
479
+ {
480
+ type: "image",
481
+ props: {
482
+ symbol: "chevron.right",
483
+ tintColor: $color("lightGray", "darkGray"),
484
+ contentMode: 1
485
+ },
486
+ layout: (make, view) => {
487
+ make.centerY.equalTo(view.super);
488
+ make.size.equalTo($size(17, 17));
489
+ make.right.inset(0);
490
+ }
491
+ },
492
+ {
493
+ type: "label",
494
+ props: {
495
+ id: "label",
496
+ text: this._items[this._value],
497
+ textColor: $color("secondaryText"),
498
+ align: $align.right
499
+ },
500
+ layout: (make, view) => {
501
+ make.centerY.equalTo(view.super);
502
+ make.left.inset(0);
503
+ make.right.equalTo(view.prev.left).inset(5);
504
+ }
505
+ }
506
+ ]
507
+ };
508
+ }
509
+ _handleValue(num) {
510
+ const label = this.view.get("label");
511
+ label.text = this._items[num];
512
+ return num;
513
+ }
514
+ }
515
+ class TabCell extends Cell {
516
+ constructor(props, values) {
517
+ super(props, values);
518
+ this._type = "tab";
519
+ const { items, value = -1 } = props;
520
+ this._items = items;
521
+ this._value = value;
522
+ }
523
+ _defineValueView() {
524
+ return {
525
+ type: "tab",
526
+ props: {
527
+ id: "tab",
528
+ items: this._items,
529
+ index: this._value
530
+ },
531
+ layout: (make, view) => {
532
+ make.centerY.equalTo(view.super);
533
+ make.height.equalTo(34);
534
+ make.left.lessThanOrEqualTo(view.prev.right).inset(10).priority(999);
535
+ make.width.lessThanOrEqualTo(250);
536
+ make.right.inset(15);
537
+ },
538
+ events: {
539
+ changed: sender => {
540
+ this.value = sender.index;
541
+ if (this._changedEvent)
542
+ this._changedEvent();
543
+ }
544
+ }
545
+ };
546
+ }
547
+ _handleValue(num) {
548
+ const tab = this.view.get("tab");
549
+ tab.index = num;
550
+ return num;
551
+ }
552
+ }
553
+ class InfoCell extends Cell {
554
+ constructor(props, values) {
555
+ super(props, values);
556
+ this._type = "info";
557
+ }
558
+ _defineValueView() {
559
+ return {
560
+ type: "label",
561
+ props: {
562
+ id: "label",
563
+ text: this._value,
564
+ textColor: $color("secondaryText"),
565
+ align: $align.right
566
+ },
567
+ layout: (make, view) => {
568
+ make.top.bottom.inset(0);
569
+ make.left.equalTo(view.prev.right).inset(10);
570
+ make.right.inset(15);
571
+ }
572
+ };
573
+ }
574
+ _handleValue(text) {
575
+ const label = this.view.get("label");
576
+ label.text = text;
577
+ return text;
578
+ }
579
+ }
580
+ class LinkCell extends Cell {
581
+ constructor(props, values) {
582
+ super(props, values);
583
+ this._type = "link";
584
+ }
585
+ _defineValueView() {
586
+ return {
587
+ type: "label",
588
+ props: {
589
+ id: "label",
590
+ styledText: {
591
+ text: this._value,
592
+ font: $font(17),
593
+ styles: [
594
+ {
595
+ range: $range(0, this._value.length),
596
+ link: this._value
597
+ }
598
+ ]
599
+ },
600
+ align: $align.right
601
+ },
602
+ layout: (make, view) => {
603
+ make.top.bottom.inset(0);
604
+ make.left.equalTo(view.prev.right).inset(10);
605
+ make.right.inset(15);
606
+ }
607
+ };
608
+ }
609
+ _handleValue(text) {
610
+ const label = this.view.get("label");
611
+ label.styledText = {
612
+ text,
613
+ font: $font(17),
614
+ styles: [
615
+ {
616
+ range: $range(0, text.length),
617
+ link: text
618
+ }
619
+ ]
620
+ };
621
+ return text;
622
+ }
623
+ }
624
+ class ActionCell extends Cell {
625
+ constructor(props, values) {
626
+ super(props, values);
627
+ this._type = "action";
628
+ const { destructive = false } = props;
629
+ this._destructive = destructive;
630
+ this._values = values;
631
+ }
632
+ _defineTitleView() {
633
+ return {
634
+ type: "label",
635
+ props: {},
636
+ layout: make => make.width.equalTo(0)
637
+ };
638
+ }
639
+ _defineValueView() {
640
+ return {
641
+ type: "label",
642
+ props: {
643
+ text: this._title,
644
+ textColor: this._destructive ? $color("red") : $color("systemLink")
645
+ },
646
+ layout: (make, view) => {
647
+ make.top.bottom.inset(0);
648
+ make.left.equalTo(view.prev.left);
649
+ make.left.right.inset(15);
650
+ }
651
+ };
652
+ }
653
+ _handleValue() {
654
+ return;
655
+ }
656
+ }
657
+ class PreferenceListView extends base_1.Base {
658
+ constructor({ sections, props = {}, layout, events = {} }) {
659
+ super();
660
+ this._sections = sections;
661
+ this._values = {};
662
+ const excludedTypes = ["action", "info", "link"];
663
+ sections.forEach(section => {
664
+ section.rows.forEach(row => {
665
+ if (row.key && !excludedTypes.includes(row.type)) {
666
+ this._values[row.key] = row.value;
667
+ }
668
+ });
669
+ });
670
+ this._props = props;
671
+ this._layout = layout;
672
+ this._cells = this._sections.map(section => ({
673
+ title: section.title,
674
+ rows: section.rows.map(props => {
675
+ if (events.changed)
676
+ props.changedEvent = () => {
677
+ if (events.changed)
678
+ events.changed(this.values);
679
+ };
680
+ return this._createCell(props);
681
+ })
682
+ }));
683
+ this._defineView = () => {
684
+ return {
685
+ type: "list",
686
+ props: Object.assign(Object.assign({ style: 2 }, this._props), { id: this.id, data: this._cells.map(section => ({
687
+ title: section.title,
688
+ rows: section.rows.map(cell => cell.definition)
689
+ })) }),
690
+ layout: this._layout,
691
+ events: {
692
+ didSelect: (sender, indexPath, data) => {
693
+ const cell = this._cells[indexPath.section].rows[indexPath.row];
694
+ switch (cell._type) {
695
+ case "string": {
696
+ $input.text({
697
+ type: $kbType.default,
698
+ placeholder: cell._placeholder,
699
+ handler: text => {
700
+ cell.value = text;
701
+ if (cell._changedEvent)
702
+ cell._changedEvent();
703
+ }
704
+ });
705
+ break;
706
+ }
707
+ case "number": {
708
+ $input.text({
709
+ type: $kbType.decimal,
710
+ placeholder: cell._placeholder,
711
+ handler: text => {
712
+ cell.value = parseFloat(text);
713
+ if (cell._changedEvent)
714
+ cell._changedEvent();
715
+ }
716
+ });
717
+ break;
718
+ }
719
+ case "integer": {
720
+ $input.text({
721
+ type: $kbType.number,
722
+ placeholder: cell._placeholder,
723
+ handler: text => {
724
+ cell.value = parseInt(text);
725
+ if (cell._changedEvent)
726
+ cell._changedEvent();
727
+ }
728
+ });
729
+ break;
730
+ }
731
+ case "list": {
732
+ $ui.menu({
733
+ items: cell._items,
734
+ handler: (title, index) => {
735
+ cell.value = index;
736
+ if (cell._changedEvent)
737
+ cell._changedEvent();
738
+ }
739
+ });
740
+ break;
741
+ }
742
+ case "link": {
743
+ $safari.open({ url: cell.value });
744
+ break;
745
+ }
746
+ case "action": {
747
+ cell.value();
748
+ break;
749
+ }
750
+ default:
751
+ break;
752
+ }
753
+ }
754
+ }
755
+ };
756
+ };
757
+ }
758
+ _createCell(props) {
759
+ switch (props.type) {
760
+ case "string":
761
+ return new StringCell(props, this._values);
762
+ case "number":
763
+ return new NumberCell(props, this._values);
764
+ case "integer":
765
+ return new IntegerCell(props, this._values);
766
+ case "stepper":
767
+ return new StepperCell(props, this._values);
768
+ case "boolean":
769
+ return new BooleanCell(props, this._values);
770
+ case "slider":
771
+ return new SliderCell(props, this._values);
772
+ case "list":
773
+ return new ListCell(props, this._values);
774
+ case "tab":
775
+ return new TabCell(props, this._values);
776
+ case "info":
777
+ return new InfoCell(props, this._values);
778
+ case "link":
779
+ return new LinkCell(props, this._values);
780
+ case "action":
781
+ return new ActionCell(props, this._values);
782
+ default:
783
+ throw new Error("Invalid cell type");
784
+ }
785
+ }
786
+ get values() {
787
+ return this._values;
788
+ }
789
+ set(key, value) {
790
+ this._cells.forEach(section => {
791
+ section.rows.forEach(row => {
792
+ if (row.key === key)
793
+ row.value = value;
794
+ });
795
+ });
796
+ }
797
+ }
798
+ exports.PreferenceListView = PreferenceListView;