cx 26.0.11 → 26.0.12

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,118 +1,128 @@
1
- import { Component } from "../../util/Component";
2
- import { View } from "../../data/View";
3
-
4
- export interface SelectionOptions {
5
- toggle?: boolean;
6
- add?: boolean;
7
- }
8
-
9
- export interface SelectionConfig {
10
- bind?: string;
11
- record?: any;
12
- index?: any;
13
- toggle?: boolean;
14
- multiple?: boolean;
15
- }
16
-
17
- export class Selection extends Component {
18
- declare bind?: string;
19
- declare record?: any;
20
- declare index?: any;
21
- declare toggle: boolean;
22
- declare isDummy: boolean;
23
- declare multiple: boolean;
24
-
25
- constructor(config?: SelectionConfig) {
26
- super(config);
27
- }
28
-
29
- isSelected(store: View, record: any, index: any): boolean {
30
- return !!this.bind && store.get(this.bind) === record;
31
- }
32
-
33
- getIsSelectedDelegate(store: View): (record: any, index: any) => boolean {
34
- return (record, index) => this.isSelected(store, record, index);
35
- }
36
-
37
- select(store: View, record: any, index: any, options?: SelectionOptions): any {
38
- this.selectMultiple(store, [record], [index], options);
39
- }
40
-
41
- selectMultiple(store: View, records: any[], indexes: any[], options?: SelectionOptions): any {
42
- //abstract
43
- }
44
-
45
- declareData(...args: any[]): any {
46
- var declaration = {
47
- $selection: { structured: true },
48
- };
49
-
50
- return Object.assign(declaration, ...args);
51
- }
52
-
53
- configureWidget(widget: any): any {
54
- if (this.record || this.index) {
55
- widget.$selection = Object.assign(widget.$selection || {}, {
56
- record: this.record,
57
- index: this.index,
58
- });
59
- }
60
-
61
- return this.declareData();
62
- }
63
-
64
- selectInstance(instance: any, options?: SelectionOptions): any {
65
- var { store, data } = instance;
66
- if (!data.$selection)
67
- throw new Error(
68
- "Selection model not properly configured. Using the selectInstance method without specified record and index bindings.",
69
- );
70
- return this.select(store, data.$selection.record, data.$selection.index, options);
71
- }
72
-
73
- isInstanceSelected(instance: any): boolean {
74
- var { store, data } = instance;
75
- return data.$selection && this.isSelected(store, data.$selection.record, data.$selection.index);
76
- }
77
- }
78
-
79
- Selection.prototype.toggle = false;
80
-
81
- Selection.namespace = "ui.selection.";
82
-
83
- export class SimpleSelection extends Selection {
84
- isSelected(store: View, record: any, index: any): boolean {
85
- return this.getIsSelectedDelegate(store)(record, index);
86
- }
87
-
88
- getIsSelectedDelegate(store: View): (record: any, index: any) => boolean {
89
- var selection = this.bind && store.get(this.bind);
90
- return (record, index) => record === selection;
91
- }
92
-
93
- selectMultiple(store: View, records: any[], index: any[]): void {
94
- if (this.bind) store.set(this.bind, records[0]);
95
- }
96
- }
97
-
98
- class DummySelection extends Selection {
99
- isSelected(store: View, record: any, index: any): boolean {
100
- return false;
101
- }
102
-
103
- selectMultiple(): void {
104
- //dummy
105
- }
106
-
107
- selectInstance(): void {
108
- //dummy
109
- }
110
- }
111
-
112
- DummySelection.prototype.isDummy = true;
113
-
114
- Selection.factory = (name: any): Selection => {
115
- if (typeof name == "object") return new SimpleSelection(name);
116
-
117
- return new DummySelection();
118
- };
1
+ import { Component } from "../../util/Component";
2
+ import { View } from "../../data/View";
3
+ import { AccessorChain } from "../../data/createAccessorModelProxy";
4
+ import { Prop } from "../Prop";
5
+
6
+ export interface SelectionOptions {
7
+ toggle?: boolean;
8
+ add?: boolean;
9
+ }
10
+
11
+ export interface SelectionConfig {
12
+ /** Binding path for selection state. */
13
+ bind?: string | AccessorChain<any>;
14
+
15
+ /** Record binding. */
16
+ record?: Prop<any>;
17
+
18
+ /** Index binding. */
19
+ index?: Prop<number>;
20
+
21
+ toggle?: boolean;
22
+
23
+ /** Set to `true` to allow multiple selection. */
24
+ multiple?: boolean;
25
+ }
26
+
27
+ export class Selection extends Component {
28
+ declare bind?: string;
29
+ declare record?: any;
30
+ declare index?: any;
31
+ declare toggle: boolean;
32
+ declare isDummy: boolean;
33
+ declare multiple: boolean;
34
+
35
+ constructor(config?: SelectionConfig) {
36
+ super(config);
37
+ }
38
+
39
+ isSelected(store: View, record: any, index: any): boolean {
40
+ return !!this.bind && store.get(this.bind) === record;
41
+ }
42
+
43
+ getIsSelectedDelegate(store: View): (record: any, index: any) => boolean {
44
+ return (record, index) => this.isSelected(store, record, index);
45
+ }
46
+
47
+ select(store: View, record: any, index: any, options?: SelectionOptions): any {
48
+ this.selectMultiple(store, [record], [index], options);
49
+ }
50
+
51
+ selectMultiple(store: View, records: any[], indexes: any[], options?: SelectionOptions): any {
52
+ //abstract
53
+ }
54
+
55
+ declareData(...args: any[]): any {
56
+ var declaration = {
57
+ $selection: { structured: true },
58
+ };
59
+
60
+ return Object.assign(declaration, ...args);
61
+ }
62
+
63
+ configureWidget(widget: any): any {
64
+ if (this.record || this.index) {
65
+ widget.$selection = Object.assign(widget.$selection || {}, {
66
+ record: this.record,
67
+ index: this.index,
68
+ });
69
+ }
70
+
71
+ return this.declareData();
72
+ }
73
+
74
+ selectInstance(instance: any, options?: SelectionOptions): any {
75
+ var { store, data } = instance;
76
+ if (!data.$selection)
77
+ throw new Error(
78
+ "Selection model not properly configured. Using the selectInstance method without specified record and index bindings.",
79
+ );
80
+ return this.select(store, data.$selection.record, data.$selection.index, options);
81
+ }
82
+
83
+ isInstanceSelected(instance: any): boolean {
84
+ var { store, data } = instance;
85
+ return data.$selection && this.isSelected(store, data.$selection.record, data.$selection.index);
86
+ }
87
+ }
88
+
89
+ Selection.prototype.toggle = false;
90
+
91
+ Selection.namespace = "ui.selection.";
92
+
93
+ export class SimpleSelection extends Selection {
94
+ isSelected(store: View, record: any, index: any): boolean {
95
+ return this.getIsSelectedDelegate(store)(record, index);
96
+ }
97
+
98
+ getIsSelectedDelegate(store: View): (record: any, index: any) => boolean {
99
+ var selection = this.bind && store.get(this.bind);
100
+ return (record, index) => record === selection;
101
+ }
102
+
103
+ selectMultiple(store: View, records: any[], index: any[]): void {
104
+ if (this.bind) store.set(this.bind, records[0]);
105
+ }
106
+ }
107
+
108
+ class DummySelection extends Selection {
109
+ isSelected(store: View, record: any, index: any): boolean {
110
+ return false;
111
+ }
112
+
113
+ selectMultiple(): void {
114
+ //dummy
115
+ }
116
+
117
+ selectInstance(): void {
118
+ //dummy
119
+ }
120
+ }
121
+
122
+ DummySelection.prototype.isDummy = true;
123
+
124
+ Selection.factory = (name: any): Selection => {
125
+ if (typeof name == "object") return new SimpleSelection(name);
126
+
127
+ return new DummySelection();
128
+ };
@@ -39,6 +39,9 @@ export interface HtmlElementConfig extends StyledContainerConfig {
39
39
  /** Inner text contents. */
40
40
  text?: StringProp | NumberProp;
41
41
 
42
+ /** Inner html contents. */
43
+ html?: StringProp;
44
+
42
45
  /** Tooltip configuration. */
43
46
  tooltip?: StringProp | TooltipConfig;
44
47
  }
@@ -165,7 +168,8 @@ export class HtmlElement<
165
168
  case "vdomKey":
166
169
  return false;
167
170
 
168
- default: if (isDataAttribute(attrName)) return false;
171
+ default:
172
+ if (isDataAttribute(attrName)) return false;
169
173
  break;
170
174
  }
171
175