cx 24.0.3 → 24.2.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.
@@ -1,12 +1,11 @@
1
- import {SubscriberList} from "../util/SubscriberList";
2
- import {isObject} from "../util/isObject";
1
+ import { SubscriberList } from "../util/SubscriberList";
2
+ import { isObject } from "../util/isObject";
3
3
 
4
4
  let subscribers, eventBan = 0;
5
5
 
6
6
  export function executeKeyboardShortcuts(e) {
7
- if (Date.now() < eventBan)
8
- return;
9
- //Avoid duplicate executions as event.stopPropagation() for React events does not stop native events
7
+ if (Date.now() < eventBan) return;
8
+ // Avoid duplicate executions as event.stopPropagation() for React events does not stop native events
10
9
  eventBan = Date.now() + 5;
11
10
  subscribers && subscribers.notify(e);
12
11
  }
@@ -1,6 +1,6 @@
1
1
  import * as Cx from '../../core';
2
2
 
3
- import {Selection} from './Selection'
3
+ import { Selection } from './Selection'
4
4
 
5
5
  interface KeySelectionConfig {
6
6
  bind?: string;
@@ -1,6 +1,6 @@
1
1
  import * as Cx from '../../core';
2
2
 
3
- import {Selection} from './Selection'
3
+ import { Selection } from './Selection'
4
4
 
5
5
  interface PropertySelectionConfig {
6
6
  selectedField?: string
@@ -1,9 +1,7 @@
1
- import {Selection} from './Selection';
1
+ import { Selection } from './Selection';
2
2
 
3
3
  export class PropertySelection extends Selection {
4
-
5
- selectMultiple(store, records, indexes, {toggle, add} = {}) {
6
-
4
+ selectMultiple(store, records, indexes, { toggle, add } = {}) {
7
5
  if (this.toggle)
8
6
  toggle = true;
9
7
 
@@ -24,4 +24,4 @@ export class Selection extends Component {
24
24
  isInstanceSelected(instance: Instance): boolean;
25
25
  }
26
26
 
27
- export class SimpleSelection extends Selection {}
27
+ export class SimpleSelection extends Selection { }
@@ -21,6 +21,7 @@ import DropdownIcon from "../icons/drop-down";
21
21
  import ClearIcon from "../icons/clear";
22
22
  import { Localization } from "../../ui/Localization";
23
23
  import { isDefined } from "../../util/isDefined";
24
+ import { getActiveElement } from "../../util/getActiveElement";
24
25
 
25
26
  export class ColorField extends Field {
26
27
  declareData() {
@@ -219,8 +220,8 @@ class ColorInput extends VDOM.Component {
219
220
  tabIndex={data.tabIndex}
220
221
  placeholder={data.placeholder}
221
222
  {...data.inputAttrs}
222
- onInput={(e) => this.onChange(e, "input")}
223
- onChange={(e) => this.onChange(e, "change")}
223
+ onInput={(e) => this.onChange(e.target.value, "input")}
224
+ onChange={(e) => this.onChange(e.target.value, "change")}
224
225
  onKeyDown={(e) => this.onKeyDown(e)}
225
226
  onBlur={(e) => {
226
227
  this.onBlur(e);
@@ -274,7 +275,7 @@ class ColorInput extends VDOM.Component {
274
275
  switch (e.keyCode) {
275
276
  case KeyCode.enter:
276
277
  e.stopPropagation();
277
- this.onChange(e, "enter");
278
+ this.onChange(e.target.value, "enter");
278
279
  break;
279
280
 
280
281
  case KeyCode.esc:
@@ -304,7 +305,7 @@ class ColorInput extends VDOM.Component {
304
305
  this.setState({
305
306
  focus: false,
306
307
  });
307
- this.onChange(e, "blur");
308
+ this.onChange(e.target.value, "blur");
308
309
  }
309
310
 
310
311
  closeDropdown(e, callback) {
@@ -352,6 +353,9 @@ class ColorInput extends VDOM.Component {
352
353
  }
353
354
 
354
355
  componentWillUnmount() {
356
+ if (this.input == getActiveElement()) {
357
+ this.onChange(this.input.value, "blur");
358
+ }
355
359
  tooltipParentWillUnmount(this.props.instance);
356
360
  }
357
361
 
@@ -365,23 +369,24 @@ class ColorInput extends VDOM.Component {
365
369
  e.preventDefault();
366
370
  }
367
371
 
368
- onChange(e, eventType) {
372
+ onChange(inputValue, eventType) {
369
373
  let { instance, data } = this.props;
370
374
  let { widget } = instance;
371
375
 
372
- if (eventType == "blur") instance.setState({ visited: true });
376
+ if (eventType == "blur") {
377
+ instance.setState({ visited: true });
378
+ }
373
379
 
374
- let text = e.target.value;
375
380
  let isValid;
376
381
  try {
377
- parseColor(text);
382
+ parseColor(inputValue);
378
383
  isValid = true;
379
384
  } catch (e) {
380
385
  isValid = false;
381
386
  }
382
387
 
383
388
  if (eventType == "blur" || eventType == "enter") {
384
- let value = text || widget.emptyValue;
389
+ let value = inputValue || widget.emptyValue;
385
390
  if (isValid && value !== data.value) instance.set("value", value);
386
391
 
387
392
  instance.setState({
@@ -1,275 +1,275 @@
1
- //@if cx-call-once("cx/widgets/checker-background") {
2
- // %cx-checker-bg {
3
- // background-repeat: repeat;
4
- // background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuOWwzfk4AAAAfSURBVChTY9i5Y89/dAwEDOh4SCjEJohN8+BXuOc/AOttNBKJWD4sAAAAAElFTkSuQmCC");
5
- // }
6
- //}
7
-
8
- @mixin cx-checker-background($tile-size: 4px, $color: rgba(gray, 0.5)) {
9
- background-image: linear-gradient(45deg, $color 25%, transparent 25%),
10
- linear-gradient(-45deg, $color 25%, transparent 25%), linear-gradient(45deg, transparent 75%, $color 75%),
11
- linear-gradient(-45deg, transparent 75%, $color 75%);
12
- background-size: 2 * $tile-size 2 * $tile-size;
13
- background-position: 0 0, 0 $tile-size, $tile-size -#{$tile-size}, -#{$tile-size} 0px;
14
- }
15
-
16
- @mixin cx-colorpicker(
17
- $name: "colorpicker",
18
- $state-style-map: $cx-colorpicker-state-style-map,
19
- $placeholder: $cx-input-placeholder,
20
- $besm: $cx-besm
21
- ) {
22
- $block: map-get($besm, block);
23
- $element: map-get($besm, element);
24
- $state: map-get($besm, state);
25
-
26
- $size: 220px;
27
-
28
- .#{$block}#{$name} {
29
- $styles: cx-deep-map-merge(
30
- $state-style-map,
31
- (
32
- default: (
33
- padding: 4px,
34
- ),
35
- )
36
- );
37
-
38
- @include cx-add-state-rules($styles, default);
39
-
40
- display: inline-flex;
41
- flex-direction: column;
42
-
43
- @media screen and (min-width: 500px) {
44
- flex-direction: row;
45
- }
46
-
47
- &:hover {
48
- @include cx-add-state-rules($state-style-map, hover);
49
- }
50
-
51
- input {
52
- @include cxe-field-input(
53
- $besm,
54
- $state-style-map,
55
- $placeholder: $placeholder,
56
- $input: false,
57
- $overrides: (
58
- default: (
59
- line-height: 14px,
60
- font-size: 11px,
61
- font-family: $cx-default-colorpicker-font-family,
62
- )
63
- )
64
- );
65
- }
66
- }
67
-
68
- .#{$element}#{$name}-picker {
69
- width: $size;
70
- height: $size;
71
- margin: 4px;
72
- //cursor: crosshair;
73
- position: relative;
74
- touch-action: none;
75
-
76
- background: -webkit-linear-gradient(
77
- top,
78
- hsl(0, 0%, 100%) 0%,
79
- hsla(0, 0%, 100%, 0) 50%,
80
- hsla(0, 0%, 0%, 0) 50%,
81
- hsl(0, 0%, 0%) 100%
82
- ),
83
- -webkit-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
84
- background: -moz-linear-gradient(
85
- top,
86
- hsl(0, 0%, 100%) 0%,
87
- hsla(0, 0%, 100%, 0) 50%,
88
- hsla(0, 0%, 0%, 0) 50%,
89
- hsl(0, 0%, 0%) 100%
90
- ),
91
- -moz-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
92
- background: -ms-linear-gradient(
93
- top,
94
- hsl(0, 0%, 100%) 0%,
95
- hsla(0, 0%, 100%, 0) 50%,
96
- hsla(0, 0%, 0%, 0) 50%,
97
- hsl(0, 0%, 0%) 100%
98
- ),
99
- -ms-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
100
- background: -o-linear-gradient(
101
- top,
102
- hsl(0, 0%, 100%) 0%,
103
- hsla(0, 0%, 100%, 0) 50%,
104
- hsla(0, 0%, 0%, 0) 50%,
105
- hsl(0, 0%, 0%) 100%
106
- ),
107
- -o-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
108
- }
109
-
110
- .#{$element}#{$name}-indicator {
111
- position: absolute;
112
- border: 2px solid rgba(255, 255, 255, 0.8);
113
- border-radius: 50%;
114
- box-sizing: border-box;
115
- width: 9px;
116
- height: 9px;
117
- left: calc(50% - 5px);
118
- top: calc(50% - 5px);
119
- }
120
-
121
- .#{$element}#{$name}-hue {
122
- height: 15px;
123
- position: relative;
124
- background: -moz-linear-gradient(
125
- left,
126
- #f00 0%,
127
- #ff0 16.66%,
128
- #0f0 33.33%,
129
- #0ff 50%,
130
- #00f 66.66%,
131
- #f0f 83.33%,
132
- #f00 100%
133
- );
134
- background: -webkit-linear-gradient(
135
- left,
136
- #f00 0%,
137
- #ff0 16.66%,
138
- #0f0 33.33%,
139
- #0ff 50%,
140
- #00f 66.66%,
141
- #f0f 83.33%,
142
- #f00 100%
143
- );
144
- background: -ms-linear-gradient(
145
- left,
146
- #f00 0%,
147
- #ff0 16.66%,
148
- #0f0 33.33%,
149
- #0ff 50%,
150
- #00f 66.66%,
151
- #f0f 83.33%,
152
- #f00 100%
153
- );
154
- background: -o-linear-gradient(
155
- left,
156
- #f00 0%,
157
- #ff0 16.66%,
158
- #0f0 33.33%,
159
- #0ff 50%,
160
- #00f 66.66%,
161
- #f0f 83.33%,
162
- #f00 100%
163
- );
164
- touch-action: none;
165
-
166
- .#{$element}#{$name}-indicator {
167
- border-color: rgba(0, 0, 0, 0.5);
168
- height: calc(100% + 4px);
169
- border-radius: 2px;
170
- width: 4px;
171
- top: -2px;
172
- }
173
- }
174
-
175
- .#{$element}#{$name}-alpha {
176
- height: 16px;
177
- //@extend %cx-checker-bg;
178
- @include cx-checker-background();
179
- position: relative;
180
- touch-action: none;
181
-
182
- & > div:first-child {
183
- width: 100%;
184
- height: 100%;
185
- }
186
-
187
- .#{$element}#{$name}-indicator {
188
- border-color: rgba(0, 0, 0, 0.5);
189
- top: -2px;
190
- height: calc(100% + 4px);
191
- border-radius: 2px;
192
- width: 4px;
193
- }
194
- }
195
-
196
- .#{$element}#{$name}-details {
197
- width: $size;
198
- min-height: 170px;
199
- margin: 4px;
200
- display: flex;
201
- flex-direction: column;
202
- justify-content: space-between;
203
- }
204
-
205
- .#{$element}#{$name}-inputs {
206
- label {
207
- width: 25%;
208
- display: inline-block;
209
- text-align: right;
210
-
211
- input {
212
- margin-left: 2px;
213
- width: 60%;
214
- text-align: center;
215
- }
216
- }
217
- }
218
-
219
- .#{$element}#{$name}-pixel-picker {
220
- display: flex;
221
- width: 20px;
222
- height: 20px;
223
- flex-shrink: 0;
224
- align-items: center;
225
- margin-top: 4px;
226
-
227
- svg path {
228
- fill: currentColor;
229
- }
230
-
231
- &:hover {
232
- cursor: pointer;
233
-
234
- svg path {
235
- fill: currentColor;
236
- opacity: 0.5;
237
- }
238
- }
239
- }
240
-
241
- .#{$element}#{$name}-preview {
242
- display: flex;
243
- }
244
-
245
- .#{$element}#{$name}-color {
246
- @include cx-checker-background();
247
- height: 64px;
248
- width: 64px;
249
- border-radius: 4px;
250
- align-self: flex-end;
251
-
252
- & > div {
253
- width: 100%;
254
- height: 100%;
255
- }
256
- }
257
-
258
- .#{$element}#{$name}-values {
259
- flex-grow: 1;
260
- margin: 0 8px;
261
-
262
- input {
263
- width: 100%;
264
- display: block;
265
- }
266
-
267
- input:not(:last-child) {
268
- margin: 0 0 4px 0;
269
- }
270
- }
271
- }
272
-
273
- @if (cx-should-include("cx/widgets/ColorPicker")) {
274
- @include cx-colorpicker();
275
- }
1
+ //@if cx-call-once("cx/widgets/checker-background") {
2
+ // %cx-checker-bg {
3
+ // background-repeat: repeat;
4
+ // background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuOWwzfk4AAAAfSURBVChTY9i5Y89/dAwEDOh4SCjEJohN8+BXuOc/AOttNBKJWD4sAAAAAElFTkSuQmCC");
5
+ // }
6
+ //}
7
+
8
+ @mixin cx-checker-background($tile-size: 4px, $color: rgba(gray, 0.5)) {
9
+ background-image: linear-gradient(45deg, $color 25%, transparent 25%),
10
+ linear-gradient(-45deg, $color 25%, transparent 25%), linear-gradient(45deg, transparent 75%, $color 75%),
11
+ linear-gradient(-45deg, transparent 75%, $color 75%);
12
+ background-size: 2 * $tile-size 2 * $tile-size;
13
+ background-position: 0 0, 0 $tile-size, $tile-size -#{$tile-size}, -#{$tile-size} 0px;
14
+ }
15
+
16
+ @mixin cx-colorpicker(
17
+ $name: "colorpicker",
18
+ $state-style-map: $cx-colorpicker-state-style-map,
19
+ $placeholder: $cx-input-placeholder,
20
+ $besm: $cx-besm
21
+ ) {
22
+ $block: map-get($besm, block);
23
+ $element: map-get($besm, element);
24
+ $state: map-get($besm, state);
25
+
26
+ $size: 220px;
27
+
28
+ .#{$block}#{$name} {
29
+ $styles: cx-deep-map-merge(
30
+ $state-style-map,
31
+ (
32
+ default: (
33
+ padding: 4px,
34
+ ),
35
+ )
36
+ );
37
+
38
+ @include cx-add-state-rules($styles, default);
39
+
40
+ display: inline-flex;
41
+ flex-direction: column;
42
+
43
+ @media screen and (min-width: 500px) {
44
+ flex-direction: row;
45
+ }
46
+
47
+ &:hover {
48
+ @include cx-add-state-rules($state-style-map, hover);
49
+ }
50
+
51
+ input {
52
+ @include cxe-field-input(
53
+ $besm,
54
+ $state-style-map,
55
+ $placeholder: $placeholder,
56
+ $input: false,
57
+ $overrides: (
58
+ default: (
59
+ line-height: 14px,
60
+ font-size: 11px,
61
+ font-family: $cx-default-colorpicker-font-family,
62
+ )
63
+ )
64
+ );
65
+ }
66
+ }
67
+
68
+ .#{$element}#{$name}-picker {
69
+ width: $size;
70
+ height: $size;
71
+ margin: 4px;
72
+ //cursor: crosshair;
73
+ position: relative;
74
+ touch-action: none;
75
+
76
+ background: -webkit-linear-gradient(
77
+ top,
78
+ hsl(0, 0%, 100%) 0%,
79
+ hsla(0, 0%, 100%, 0) 50%,
80
+ hsla(0, 0%, 0%, 0) 50%,
81
+ hsl(0, 0%, 0%) 100%
82
+ ),
83
+ -webkit-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
84
+ background: -moz-linear-gradient(
85
+ top,
86
+ hsl(0, 0%, 100%) 0%,
87
+ hsla(0, 0%, 100%, 0) 50%,
88
+ hsla(0, 0%, 0%, 0) 50%,
89
+ hsl(0, 0%, 0%) 100%
90
+ ),
91
+ -moz-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
92
+ background: -ms-linear-gradient(
93
+ top,
94
+ hsl(0, 0%, 100%) 0%,
95
+ hsla(0, 0%, 100%, 0) 50%,
96
+ hsla(0, 0%, 0%, 0) 50%,
97
+ hsl(0, 0%, 0%) 100%
98
+ ),
99
+ -ms-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
100
+ background: -o-linear-gradient(
101
+ top,
102
+ hsl(0, 0%, 100%) 0%,
103
+ hsla(0, 0%, 100%, 0) 50%,
104
+ hsla(0, 0%, 0%, 0) 50%,
105
+ hsl(0, 0%, 0%) 100%
106
+ ),
107
+ -o-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
108
+ }
109
+
110
+ .#{$element}#{$name}-indicator {
111
+ position: absolute;
112
+ border: 2px solid rgba(255, 255, 255, 0.8);
113
+ border-radius: 50%;
114
+ box-sizing: border-box;
115
+ width: 9px;
116
+ height: 9px;
117
+ left: calc(50% - 5px);
118
+ top: calc(50% - 5px);
119
+ }
120
+
121
+ .#{$element}#{$name}-hue {
122
+ height: 15px;
123
+ position: relative;
124
+ background: -moz-linear-gradient(
125
+ left,
126
+ #f00 0%,
127
+ #ff0 16.66%,
128
+ #0f0 33.33%,
129
+ #0ff 50%,
130
+ #00f 66.66%,
131
+ #f0f 83.33%,
132
+ #f00 100%
133
+ );
134
+ background: -webkit-linear-gradient(
135
+ left,
136
+ #f00 0%,
137
+ #ff0 16.66%,
138
+ #0f0 33.33%,
139
+ #0ff 50%,
140
+ #00f 66.66%,
141
+ #f0f 83.33%,
142
+ #f00 100%
143
+ );
144
+ background: -ms-linear-gradient(
145
+ left,
146
+ #f00 0%,
147
+ #ff0 16.66%,
148
+ #0f0 33.33%,
149
+ #0ff 50%,
150
+ #00f 66.66%,
151
+ #f0f 83.33%,
152
+ #f00 100%
153
+ );
154
+ background: -o-linear-gradient(
155
+ left,
156
+ #f00 0%,
157
+ #ff0 16.66%,
158
+ #0f0 33.33%,
159
+ #0ff 50%,
160
+ #00f 66.66%,
161
+ #f0f 83.33%,
162
+ #f00 100%
163
+ );
164
+ touch-action: none;
165
+
166
+ .#{$element}#{$name}-indicator {
167
+ border-color: rgba(0, 0, 0, 0.5);
168
+ height: calc(100% + 4px);
169
+ border-radius: 2px;
170
+ width: 4px;
171
+ top: -2px;
172
+ }
173
+ }
174
+
175
+ .#{$element}#{$name}-alpha {
176
+ height: 16px;
177
+ //@extend %cx-checker-bg;
178
+ @include cx-checker-background();
179
+ position: relative;
180
+ touch-action: none;
181
+
182
+ & > div:first-child {
183
+ width: 100%;
184
+ height: 100%;
185
+ }
186
+
187
+ .#{$element}#{$name}-indicator {
188
+ border-color: rgba(0, 0, 0, 0.5);
189
+ top: -2px;
190
+ height: calc(100% + 4px);
191
+ border-radius: 2px;
192
+ width: 4px;
193
+ }
194
+ }
195
+
196
+ .#{$element}#{$name}-details {
197
+ width: $size;
198
+ min-height: 170px;
199
+ margin: 4px;
200
+ display: flex;
201
+ flex-direction: column;
202
+ justify-content: space-between;
203
+ }
204
+
205
+ .#{$element}#{$name}-inputs {
206
+ label {
207
+ width: 25%;
208
+ display: inline-block;
209
+ text-align: right;
210
+
211
+ input {
212
+ margin-left: 2px;
213
+ width: 60%;
214
+ text-align: center;
215
+ }
216
+ }
217
+ }
218
+
219
+ .#{$element}#{$name}-pixel-picker {
220
+ display: flex;
221
+ width: 20px;
222
+ height: 20px;
223
+ flex-shrink: 0;
224
+ align-items: center;
225
+ margin-top: 4px;
226
+
227
+ svg path {
228
+ fill: currentColor;
229
+ }
230
+
231
+ &:hover {
232
+ cursor: pointer;
233
+
234
+ svg path {
235
+ fill: currentColor;
236
+ opacity: 0.5;
237
+ }
238
+ }
239
+ }
240
+
241
+ .#{$element}#{$name}-preview {
242
+ display: flex;
243
+ }
244
+
245
+ .#{$element}#{$name}-color {
246
+ @include cx-checker-background();
247
+ height: 64px;
248
+ width: 64px;
249
+ border-radius: 4px;
250
+ align-self: flex-end;
251
+
252
+ & > div {
253
+ width: 100%;
254
+ height: 100%;
255
+ }
256
+ }
257
+
258
+ .#{$element}#{$name}-values {
259
+ flex-grow: 1;
260
+ margin: 0 8px;
261
+
262
+ input {
263
+ width: 100%;
264
+ display: block;
265
+ }
266
+
267
+ input:not(:last-child) {
268
+ margin: 0 0 4px 0;
269
+ }
270
+ }
271
+ }
272
+
273
+ @if (cx-should-include("cx/widgets/ColorPicker")) {
274
+ @include cx-colorpicker();
275
+ }