cx 26.4.1 → 26.4.3
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/build/charts/shapes.d.ts.map +1 -1
- package/build/charts/shapes.js +14 -7
- package/build/jsx-dev-runtime.d.ts +1 -0
- package/build/jsx-dev-runtime.d.ts.map +1 -1
- package/build/jsx-dev-runtime.js +1 -0
- package/build/widgets/overlay/ContextMenu.d.ts.map +1 -1
- package/build/widgets/overlay/ContextMenu.js +1 -0
- package/build/widgets/overlay/Dropdown.d.ts +11 -3
- package/build/widgets/overlay/Dropdown.d.ts.map +1 -1
- package/build/widgets/overlay/Dropdown.js +52 -25
- package/build/widgets/overlay/Overlay.d.ts.map +1 -1
- package/build/widgets/overlay/Overlay.js +1 -1
- package/dist/charts.js +80 -45
- package/dist/manifest.js +704 -704
- package/dist/widgets.css +13 -12
- package/dist/widgets.js +215 -85
- package/package.json +1 -1
- package/src/charts/shapes.tsx +14 -7
- package/src/jsx-dev-runtime.ts +1 -0
- package/src/widgets/overlay/ContextMenu.ts +1 -0
- package/src/widgets/overlay/Dropdown.scss +7 -6
- package/src/widgets/overlay/Dropdown.tsx +59 -16
- package/src/widgets/overlay/Overlay.tsx +1 -0
package/src/jsx-dev-runtime.ts
CHANGED
|
@@ -20,6 +20,7 @@ ContextMenu.prototype.offset = 0;
|
|
|
20
20
|
ContextMenu.prototype.autoFocus = true;
|
|
21
21
|
ContextMenu.prototype.autoFocusFirstChild = false;
|
|
22
22
|
ContextMenu.prototype.focusable = true;
|
|
23
|
+
ContextMenu.prototype.alignArrow = true;
|
|
23
24
|
|
|
24
25
|
Localization.registerPrototype("cx/widgets/ContextMenu", ContextMenu);
|
|
25
26
|
|
|
@@ -96,11 +96,11 @@
|
|
|
96
96
|
.#{$state}place-right-down,
|
|
97
97
|
.#{$state}place-left-down {
|
|
98
98
|
& > .#{$element}#{$name}-arrow-fill {
|
|
99
|
-
top:
|
|
99
|
+
top: var(--cx-scss-dropdown-arrow-offset);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
& > .#{$element}#{$name}-arrow-border {
|
|
103
|
-
top:
|
|
103
|
+
top: var(--cx-scss-dropdown-arrow-offset);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
.#{$state}place-left-up {
|
|
109
109
|
& > .#{$element}#{$name}-arrow-fill,
|
|
110
110
|
& > .#{$element}#{$name}-arrow-border {
|
|
111
|
-
top:
|
|
111
|
+
top: calc(100% - var(--cx-scss-dropdown-arrow-offset));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -156,18 +156,18 @@
|
|
|
156
156
|
.#{$state}place-up-right {
|
|
157
157
|
& > .#{$element}#{$name}-arrow-fill,
|
|
158
158
|
& > .#{$element}#{$name}-arrow-border {
|
|
159
|
-
left:
|
|
159
|
+
left: var(--cx-scss-dropdown-arrow-offset);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
.#{$state}place-down-left,
|
|
164
164
|
.#{$state}place-up-left {
|
|
165
165
|
& > .#{$element}#{$name}-arrow-fill {
|
|
166
|
-
left:
|
|
166
|
+
left: calc(100% - var(--cx-scss-dropdown-arrow-offset));
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
& > .#{$element}#{$name}-arrow-border {
|
|
170
|
-
left:
|
|
170
|
+
left: calc(100% - var(--cx-scss-dropdown-arrow-offset));
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -187,6 +187,7 @@
|
|
|
187
187
|
display: block;
|
|
188
188
|
left: -10000px;
|
|
189
189
|
top: -10000px;
|
|
190
|
+
--cx-scss-dropdown-arrow-offset: var(--cx-js-dropdown-arrow-offset, #{$cx-default-dropdown-arrow-offset});
|
|
190
191
|
|
|
191
192
|
@include cx-add-rules($styles);
|
|
192
193
|
|
|
@@ -52,6 +52,12 @@ export interface DropdownConfig extends OverlayConfig {
|
|
|
52
52
|
/** Show an arrow pointing to the trigger element. */
|
|
53
53
|
arrow?: boolean;
|
|
54
54
|
|
|
55
|
+
/** Shift the dropdown so the arrow tip lines up with the target point (e.g. the mouse cursor for context menus). Only applies when `arrow` is also set. */
|
|
56
|
+
alignArrow?: boolean;
|
|
57
|
+
|
|
58
|
+
/** Distance of the arrow tip from the dropdown's edge, in pixels. Override for the theme's default. */
|
|
59
|
+
arrowOffset?: number;
|
|
60
|
+
|
|
55
61
|
/** Add padding around the dropdown. */
|
|
56
62
|
pad?: boolean;
|
|
57
63
|
|
|
@@ -131,6 +137,8 @@ export class DropdownBase<
|
|
|
131
137
|
declare positioning?: string;
|
|
132
138
|
declare touchFriendly?: boolean;
|
|
133
139
|
declare arrow?: boolean;
|
|
140
|
+
declare alignArrow?: boolean;
|
|
141
|
+
declare arrowOffset?: number;
|
|
134
142
|
declare elementExplode?: number;
|
|
135
143
|
declare screenPadding: number;
|
|
136
144
|
declare firstChildDefinesHeight?: boolean;
|
|
@@ -174,6 +182,16 @@ export class DropdownBase<
|
|
|
174
182
|
super.initInstance(context, instance);
|
|
175
183
|
}
|
|
176
184
|
|
|
185
|
+
prepareData(context: RenderingContext, instance: InstanceType): void {
|
|
186
|
+
super.prepareData(context, instance);
|
|
187
|
+
if (this.arrowOffset != null) {
|
|
188
|
+
instance.data.style = {
|
|
189
|
+
...instance.data.style,
|
|
190
|
+
"--cx-js-dropdown-arrow-offset": `${this.arrowOffset}px`,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
177
195
|
explore(context: RenderingContext, instance: InstanceType): void {
|
|
178
196
|
context.push("lastDropdown", instance);
|
|
179
197
|
super.explore(context, instance);
|
|
@@ -318,6 +336,8 @@ export class DropdownBase<
|
|
|
318
336
|
component.lastPlacement,
|
|
319
337
|
);
|
|
320
338
|
|
|
339
|
+
var arrowAdjust = this.getArrowAdjust(component);
|
|
340
|
+
|
|
321
341
|
this.applyPositioningPlacementStyles(
|
|
322
342
|
style,
|
|
323
343
|
placement,
|
|
@@ -325,6 +345,7 @@ export class DropdownBase<
|
|
|
325
345
|
parentBounds,
|
|
326
346
|
el,
|
|
327
347
|
false,
|
|
348
|
+
arrowAdjust,
|
|
328
349
|
);
|
|
329
350
|
component.setCustomStyle(style);
|
|
330
351
|
this.setDirectionClass(component, placement);
|
|
@@ -344,6 +365,7 @@ export class DropdownBase<
|
|
|
344
365
|
parentBounds,
|
|
345
366
|
el,
|
|
346
367
|
true,
|
|
368
|
+
arrowAdjust,
|
|
347
369
|
);
|
|
348
370
|
component.setCustomStyle(newStyle);
|
|
349
371
|
}
|
|
@@ -369,6 +391,19 @@ export class DropdownBase<
|
|
|
369
391
|
instance.positionChangeSubscribers.notify();
|
|
370
392
|
}
|
|
371
393
|
|
|
394
|
+
getArrowAdjust(component: any): number {
|
|
395
|
+
if (!this.alignArrow || !this.arrow) return 0;
|
|
396
|
+
if (component.cachedArrowOffset != null) return component.cachedArrowOffset;
|
|
397
|
+
if (!component.el) return 0;
|
|
398
|
+
let raw = getComputedStyle(component.el)
|
|
399
|
+
.getPropertyValue("--cx-scss-dropdown-arrow-offset")
|
|
400
|
+
.trim();
|
|
401
|
+
let parsed = parseFloat(raw);
|
|
402
|
+
if (!isFinite(parsed)) return 0;
|
|
403
|
+
component.cachedArrowOffset = parsed;
|
|
404
|
+
return parsed;
|
|
405
|
+
}
|
|
406
|
+
|
|
372
407
|
applyFixedPositioningPlacementStyles(
|
|
373
408
|
style: any,
|
|
374
409
|
placement: string,
|
|
@@ -376,6 +411,7 @@ export class DropdownBase<
|
|
|
376
411
|
rel: any,
|
|
377
412
|
el: HTMLElement,
|
|
378
413
|
noAuto: boolean,
|
|
414
|
+
arrowAdjust: number = 0,
|
|
379
415
|
): void {
|
|
380
416
|
let viewport = getViewportRect(this.screenPadding);
|
|
381
417
|
style.position = "fixed";
|
|
@@ -410,11 +446,11 @@ export class DropdownBase<
|
|
|
410
446
|
|
|
411
447
|
case "down-right":
|
|
412
448
|
style.right = "auto";
|
|
413
|
-
style.left = `${rel.left}px`;
|
|
449
|
+
style.left = `${rel.left - arrowAdjust}px`;
|
|
414
450
|
break;
|
|
415
451
|
|
|
416
452
|
case "down-left":
|
|
417
|
-
style.right = `${document.documentElement.offsetWidth - rel.right}px`;
|
|
453
|
+
style.right = `${document.documentElement.offsetWidth - rel.right - arrowAdjust}px`;
|
|
418
454
|
style.left = "auto";
|
|
419
455
|
break;
|
|
420
456
|
|
|
@@ -426,11 +462,11 @@ export class DropdownBase<
|
|
|
426
462
|
|
|
427
463
|
case "up-right":
|
|
428
464
|
style.right = "auto";
|
|
429
|
-
style.left = `${rel.left}px`;
|
|
465
|
+
style.left = `${rel.left - arrowAdjust}px`;
|
|
430
466
|
break;
|
|
431
467
|
|
|
432
468
|
case "up-left":
|
|
433
|
-
style.right = `${document.documentElement.offsetWidth - rel.right}px`;
|
|
469
|
+
style.right = `${document.documentElement.offsetWidth - rel.right - arrowAdjust}px`;
|
|
434
470
|
style.left = "auto";
|
|
435
471
|
break;
|
|
436
472
|
|
|
@@ -443,7 +479,7 @@ export class DropdownBase<
|
|
|
443
479
|
break;
|
|
444
480
|
|
|
445
481
|
case "right-down":
|
|
446
|
-
style.top = `${rel.top}px`;
|
|
482
|
+
style.top = `${rel.top - arrowAdjust}px`;
|
|
447
483
|
style.right = "auto";
|
|
448
484
|
style.bottom = "auto";
|
|
449
485
|
style.left = `${rel.right + this.offset}px`;
|
|
@@ -452,7 +488,7 @@ export class DropdownBase<
|
|
|
452
488
|
case "right-up":
|
|
453
489
|
style.top = "auto";
|
|
454
490
|
style.right = "auto";
|
|
455
|
-
style.bottom = `${document.documentElement.offsetHeight - rel.bottom}px`;
|
|
491
|
+
style.bottom = `${document.documentElement.offsetHeight - rel.bottom - arrowAdjust}px`;
|
|
456
492
|
style.left = `${rel.right + this.offset}px`;
|
|
457
493
|
break;
|
|
458
494
|
|
|
@@ -465,7 +501,7 @@ export class DropdownBase<
|
|
|
465
501
|
break;
|
|
466
502
|
|
|
467
503
|
case "left-down":
|
|
468
|
-
style.top = `${rel.top}px`;
|
|
504
|
+
style.top = `${rel.top - arrowAdjust}px`;
|
|
469
505
|
style.right = `${document.documentElement.offsetWidth - rel.left + this.offset}px`;
|
|
470
506
|
style.bottom = "auto";
|
|
471
507
|
style.left = "auto";
|
|
@@ -474,7 +510,7 @@ export class DropdownBase<
|
|
|
474
510
|
case "left-up":
|
|
475
511
|
style.top = "auto";
|
|
476
512
|
style.right = `${document.documentElement.offsetWidth - rel.left + this.offset}px`;
|
|
477
|
-
style.bottom = `${document.documentElement.offsetHeight - rel.bottom}px`;
|
|
513
|
+
style.bottom = `${document.documentElement.offsetHeight - rel.bottom - arrowAdjust}px`;
|
|
478
514
|
style.left = "auto";
|
|
479
515
|
break;
|
|
480
516
|
|
|
@@ -502,6 +538,7 @@ export class DropdownBase<
|
|
|
502
538
|
rel: any,
|
|
503
539
|
el: HTMLElement,
|
|
504
540
|
noAuto: boolean,
|
|
541
|
+
arrowAdjust: number = 0,
|
|
505
542
|
): void {
|
|
506
543
|
var viewport = getViewportRect(this.screenPadding);
|
|
507
544
|
|
|
@@ -532,11 +569,11 @@ export class DropdownBase<
|
|
|
532
569
|
|
|
533
570
|
case "down-right":
|
|
534
571
|
style.right = "auto";
|
|
535
|
-
style.left =
|
|
572
|
+
style.left = `${-arrowAdjust}px`;
|
|
536
573
|
break;
|
|
537
574
|
|
|
538
575
|
case "down-left":
|
|
539
|
-
style.right =
|
|
576
|
+
style.right = `${-arrowAdjust}px`;
|
|
540
577
|
style.left = "auto";
|
|
541
578
|
break;
|
|
542
579
|
|
|
@@ -548,11 +585,11 @@ export class DropdownBase<
|
|
|
548
585
|
|
|
549
586
|
case "up-right":
|
|
550
587
|
style.right = "auto";
|
|
551
|
-
style.left =
|
|
588
|
+
style.left = `${-arrowAdjust}px`;
|
|
552
589
|
break;
|
|
553
590
|
|
|
554
591
|
case "up-left":
|
|
555
|
-
style.right =
|
|
592
|
+
style.right = `${-arrowAdjust}px`;
|
|
556
593
|
style.left = "auto";
|
|
557
594
|
break;
|
|
558
595
|
|
|
@@ -565,7 +602,7 @@ export class DropdownBase<
|
|
|
565
602
|
break;
|
|
566
603
|
|
|
567
604
|
case "right-down":
|
|
568
|
-
style.top =
|
|
605
|
+
style.top = `${-arrowAdjust}px`;
|
|
569
606
|
style.right = "auto";
|
|
570
607
|
style.bottom = "auto";
|
|
571
608
|
style.left = `${rel.right - rel.left + this.offset}px`;
|
|
@@ -574,7 +611,7 @@ export class DropdownBase<
|
|
|
574
611
|
case "right-up":
|
|
575
612
|
style.top = "auto";
|
|
576
613
|
style.right = "auto";
|
|
577
|
-
style.bottom =
|
|
614
|
+
style.bottom = `${-arrowAdjust}px`;
|
|
578
615
|
style.left = `${rel.right - rel.left + this.offset}px`;
|
|
579
616
|
break;
|
|
580
617
|
|
|
@@ -587,7 +624,7 @@ export class DropdownBase<
|
|
|
587
624
|
break;
|
|
588
625
|
|
|
589
626
|
case "left-down":
|
|
590
|
-
style.top =
|
|
627
|
+
style.top = `${-arrowAdjust}px`;
|
|
591
628
|
style.right = `${rel.right - rel.left + this.offset}px`;
|
|
592
629
|
style.bottom = "auto";
|
|
593
630
|
style.left = "auto";
|
|
@@ -596,7 +633,7 @@ export class DropdownBase<
|
|
|
596
633
|
case "left-up":
|
|
597
634
|
style.top = "auto";
|
|
598
635
|
style.right = `${rel.right - rel.left + this.offset}px`;
|
|
599
|
-
style.bottom =
|
|
636
|
+
style.bottom = `${-arrowAdjust}px`;
|
|
600
637
|
style.left = "auto";
|
|
601
638
|
break;
|
|
602
639
|
}
|
|
@@ -609,6 +646,7 @@ export class DropdownBase<
|
|
|
609
646
|
parentBounds: any,
|
|
610
647
|
el: HTMLElement,
|
|
611
648
|
noAuto: boolean,
|
|
649
|
+
arrowAdjust: number = 0,
|
|
612
650
|
): void {
|
|
613
651
|
switch (this.positioning) {
|
|
614
652
|
case "absolute":
|
|
@@ -619,6 +657,7 @@ export class DropdownBase<
|
|
|
619
657
|
parentBounds,
|
|
620
658
|
el,
|
|
621
659
|
noAuto,
|
|
660
|
+
arrowAdjust,
|
|
622
661
|
);
|
|
623
662
|
break;
|
|
624
663
|
|
|
@@ -631,6 +670,7 @@ export class DropdownBase<
|
|
|
631
670
|
parentBounds,
|
|
632
671
|
el,
|
|
633
672
|
noAuto,
|
|
673
|
+
arrowAdjust,
|
|
634
674
|
);
|
|
635
675
|
else
|
|
636
676
|
this.applyFixedPositioningPlacementStyles(
|
|
@@ -640,6 +680,7 @@ export class DropdownBase<
|
|
|
640
680
|
parentBounds,
|
|
641
681
|
el,
|
|
642
682
|
noAuto,
|
|
683
|
+
arrowAdjust,
|
|
643
684
|
);
|
|
644
685
|
break;
|
|
645
686
|
|
|
@@ -651,6 +692,7 @@ export class DropdownBase<
|
|
|
651
692
|
parentBounds,
|
|
652
693
|
el,
|
|
653
694
|
noAuto,
|
|
695
|
+
arrowAdjust,
|
|
654
696
|
);
|
|
655
697
|
break;
|
|
656
698
|
}
|
|
@@ -914,6 +956,7 @@ DropdownBase.prototype.constrain = false;
|
|
|
914
956
|
DropdownBase.prototype.positioning = "fixed";
|
|
915
957
|
DropdownBase.prototype.touchFriendly = false;
|
|
916
958
|
DropdownBase.prototype.arrow = false;
|
|
959
|
+
DropdownBase.prototype.alignArrow = false;
|
|
917
960
|
DropdownBase.prototype.pad = false;
|
|
918
961
|
DropdownBase.prototype.elementExplode = 0;
|
|
919
962
|
DropdownBase.prototype.closeOnScrollDistance = 50;
|