capibara 1.3.61 → 1.3.63
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/dist/index.js +182 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/scss/layout/_contextMenu.scss +4 -4
- package/src/util/tableElements.js +105 -23
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
.cap-context-menu {
|
|
17
17
|
position: absolute;
|
|
18
|
-
min-width:
|
|
18
|
+
min-width: 270px;
|
|
19
19
|
z-index: 2;
|
|
20
20
|
border-radius: 5px;
|
|
21
21
|
border: 1px solid grey;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
0 3px 5px -1px rgba(0, 0, 0, 0.2),
|
|
25
25
|
0 6px 10px 0 rgba(0, 0, 0, 0.14),
|
|
26
26
|
0 1px 18px 0 rgba(0, 0, 0, 0.12);
|
|
27
|
-
font-size:
|
|
27
|
+
font-size: 13px;
|
|
28
28
|
transition: all 0.1s linear;
|
|
29
29
|
visibility: visible;
|
|
30
30
|
opacity: 1;
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
|
|
63
63
|
&.is-section-label {
|
|
64
64
|
cursor: unset;
|
|
65
|
-
font-size:
|
|
65
|
+
font-size: 13px;
|
|
66
66
|
padding: 0.3em 1em 0.1em;
|
|
67
67
|
text-transform: uppercase;
|
|
68
68
|
letter-spacing: 0.06em;
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
background: mapGet($theme, detailDay, background);
|
|
129
129
|
}
|
|
130
130
|
.cap-context-menu_item.is-section-label {
|
|
131
|
-
color: rgba(mapGet($theme, color), 0.6);
|
|
131
|
+
color: rgba(mapGet($theme, color), if($nameTheme == "", 0.85, 0.6));
|
|
132
132
|
}
|
|
133
133
|
.cap-context-menu_item.is-divider {
|
|
134
134
|
border-bottom-color: rgba(mapGet($theme, color), 0.2);
|
|
@@ -4631,22 +4631,28 @@ export default {
|
|
|
4631
4631
|
let $contextMenu = $contextMenuContainer.querySelector(".cap-context-menu");
|
|
4632
4632
|
let hasSomeoption = false;
|
|
4633
4633
|
|
|
4634
|
-
config
|
|
4634
|
+
var ctx = { config: config, date: date, item: item, selected: selected, tabSelected: tabSelected, target: target, name: name };
|
|
4635
|
+
|
|
4636
|
+
function renderContextMenuItem(option, $menu) {
|
|
4635
4637
|
if (option.showIf) {
|
|
4636
|
-
let show = option.showIf({ item, date, selected, name, tabSelected });
|
|
4638
|
+
let show = option.showIf({ item: ctx.item, date: ctx.date, selected: ctx.selected, name: ctx.name, tabSelected: ctx.tabSelected });
|
|
4637
4639
|
if (!show) return;
|
|
4638
4640
|
}
|
|
4639
4641
|
|
|
4642
|
+
// isGroup: llama getItems() e inserta cada resultado como item independiente
|
|
4643
|
+
if (option.isGroup && option.getItems) {
|
|
4644
|
+
var groupItems = option.getItems({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target });
|
|
4645
|
+
if (groupItems && groupItems.length > 0) {
|
|
4646
|
+
groupItems.forEach(function(gItem) { renderContextMenuItem(gItem, $menu); });
|
|
4647
|
+
hasSomeoption = true;
|
|
4648
|
+
}
|
|
4649
|
+
return;
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4640
4652
|
let isEnabled = true;
|
|
4641
4653
|
let isClickeable = true;
|
|
4642
4654
|
if (option.enableIf) {
|
|
4643
|
-
isEnabled = option.enableIf({
|
|
4644
|
-
item,
|
|
4645
|
-
date,
|
|
4646
|
-
selected,
|
|
4647
|
-
name,
|
|
4648
|
-
tabSelected,
|
|
4649
|
-
});
|
|
4655
|
+
isEnabled = option.enableIf({ item: ctx.item, date: ctx.date, selected: ctx.selected, name: ctx.name, tabSelected: ctx.tabSelected });
|
|
4650
4656
|
}
|
|
4651
4657
|
|
|
4652
4658
|
let optionClassName = "";
|
|
@@ -4668,7 +4674,10 @@ export default {
|
|
|
4668
4674
|
}
|
|
4669
4675
|
|
|
4670
4676
|
if (option.label) {
|
|
4671
|
-
|
|
4677
|
+
var resolvedLabel = typeof option.label === "function"
|
|
4678
|
+
? option.label({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target })
|
|
4679
|
+
: option.label;
|
|
4680
|
+
label = "<span>" + resolvedLabel + "</span>";
|
|
4672
4681
|
}
|
|
4673
4682
|
|
|
4674
4683
|
if (option.icon) {
|
|
@@ -4678,7 +4687,7 @@ export default {
|
|
|
4678
4687
|
var resolvedChildren = null;
|
|
4679
4688
|
if (option.children) {
|
|
4680
4689
|
resolvedChildren = typeof option.children === "function"
|
|
4681
|
-
? option.children({ config: config, date: date, item: item, selected: selected, tabSelected: tabSelected, target: target })
|
|
4690
|
+
? option.children({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target })
|
|
4682
4691
|
: option.children;
|
|
4683
4692
|
}
|
|
4684
4693
|
|
|
@@ -4699,23 +4708,77 @@ export default {
|
|
|
4699
4708
|
resolvedChildren.forEach(function(child) {
|
|
4700
4709
|
var childEnabled = true;
|
|
4701
4710
|
if (child.enableIf) {
|
|
4702
|
-
childEnabled = child.enableIf({ config: config, date: date, item: item, selected: selected, tabSelected: tabSelected });
|
|
4711
|
+
childEnabled = child.enableIf({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected });
|
|
4703
4712
|
}
|
|
4704
4713
|
var childClassName = childEnabled ? "" : "is-disabled ";
|
|
4705
4714
|
var childIcon = "";
|
|
4706
|
-
var childLabel = child.label
|
|
4715
|
+
var childLabel = child.label
|
|
4716
|
+
? "<span>" + (typeof child.label === "function" ? child.label({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target }) : child.label) + "</span>"
|
|
4717
|
+
: "";
|
|
4707
4718
|
if (child.icon) {
|
|
4708
4719
|
childIcon = "<div class=\"cap-context-menu_item_icon\"><svg viewBox=\"0 0 24 24\"><path d=\"" + child.icon + "\" /></svg></div>";
|
|
4709
4720
|
}
|
|
4710
|
-
|
|
4721
|
+
|
|
4722
|
+
var childResolvedChildren = null;
|
|
4723
|
+
if (child.children) {
|
|
4724
|
+
childResolvedChildren = typeof child.children === "function"
|
|
4725
|
+
? child.children({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target })
|
|
4726
|
+
: child.children;
|
|
4727
|
+
}
|
|
4728
|
+
var childChevron = childResolvedChildren && childResolvedChildren.length > 0
|
|
4729
|
+
? "<span class=\"cap-context-menu_item_chevron\">›</span>"
|
|
4730
|
+
: "";
|
|
4731
|
+
var childHasChildrenClass = childResolvedChildren && childResolvedChildren.length > 0 ? "has-children" : "";
|
|
4732
|
+
|
|
4733
|
+
var childHtml = "<div class=\"cap-context-menu_item " + childHasChildrenClass + " " + childClassName + "\">" + childIcon + childLabel + childChevron + "</div>";
|
|
4711
4734
|
var $child = dom.createElementFromHTML(childHtml);
|
|
4735
|
+
|
|
4736
|
+
if (childResolvedChildren && childResolvedChildren.length > 0) {
|
|
4737
|
+
var $childSubmenu = document.createElement("div");
|
|
4738
|
+
$childSubmenu.className = "cap-context-menu cap-context-menu--submenu";
|
|
4739
|
+
childResolvedChildren.forEach(function(grandchild) {
|
|
4740
|
+
var gcEnabled = !grandchild.enableIf || grandchild.enableIf({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected });
|
|
4741
|
+
var gcLabel = grandchild.label
|
|
4742
|
+
? "<span>" + (typeof grandchild.label === "function" ? grandchild.label({ config: ctx.config, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target }) : grandchild.label) + "</span>"
|
|
4743
|
+
: "";
|
|
4744
|
+
var gcIcon = grandchild.icon
|
|
4745
|
+
? "<div class=\"cap-context-menu_item_icon\"><svg viewBox=\"0 0 24 24\"><path d=\"" + grandchild.icon + "\" /></svg></div>"
|
|
4746
|
+
: "";
|
|
4747
|
+
var $gc = dom.createElementFromHTML("<div class=\"cap-context-menu_item " + (gcEnabled ? "" : "is-disabled ") + "\">" + gcIcon + gcLabel + "</div>");
|
|
4748
|
+
if (gcEnabled && grandchild.onClick) {
|
|
4749
|
+
(function(gc) {
|
|
4750
|
+
$gc.addEventListener("click", function(evtClick) {
|
|
4751
|
+
gc.onClick({ config: ctx.config, evt: evtClick, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target });
|
|
4752
|
+
});
|
|
4753
|
+
})(grandchild);
|
|
4754
|
+
}
|
|
4755
|
+
$childSubmenu.appendChild($gc);
|
|
4756
|
+
});
|
|
4757
|
+
$child.appendChild($childSubmenu);
|
|
4758
|
+
(function(el, sub) {
|
|
4759
|
+
el.addEventListener("mouseenter", function() {
|
|
4760
|
+
var elRect = el.getBoundingClientRect();
|
|
4761
|
+
var vh = window.innerHeight;
|
|
4762
|
+
sub.style.transform = "";
|
|
4763
|
+
sub.style.top = "0";
|
|
4764
|
+
sub.style.bottom = "auto";
|
|
4765
|
+
if (elRect.top > vh * 4 / 6) {
|
|
4766
|
+
sub.style.top = "auto";
|
|
4767
|
+
sub.style.bottom = "0";
|
|
4768
|
+
} else if (elRect.top > vh * 2 / 6) {
|
|
4769
|
+
sub.style.transform = "translateY(-50%)";
|
|
4770
|
+
}
|
|
4771
|
+
});
|
|
4772
|
+
})($child, $childSubmenu);
|
|
4773
|
+
}
|
|
4774
|
+
|
|
4712
4775
|
if (childEnabled && child.onClick) {
|
|
4713
4776
|
(function(c) {
|
|
4714
4777
|
$child.addEventListener("click", function(evtClick) {
|
|
4715
|
-
c.onClick({ config: config, evt: evtClick, date: date, item: item, selected: selected, tabSelected: tabSelected, target: target });
|
|
4778
|
+
c.onClick({ config: ctx.config, evt: evtClick, date: ctx.date, item: ctx.item, selected: ctx.selected, tabSelected: ctx.tabSelected, target: ctx.target });
|
|
4716
4779
|
});
|
|
4717
4780
|
})(child);
|
|
4718
|
-
} else {
|
|
4781
|
+
} else if (!(childResolvedChildren && childResolvedChildren.length > 0)) {
|
|
4719
4782
|
$child.addEventListener("click", function(evtClick) {
|
|
4720
4783
|
evtClick.preventDefault();
|
|
4721
4784
|
evtClick.stopPropagation();
|
|
@@ -4725,18 +4788,33 @@ export default {
|
|
|
4725
4788
|
});
|
|
4726
4789
|
|
|
4727
4790
|
$option.appendChild($submenu);
|
|
4791
|
+
(function(el, sub) {
|
|
4792
|
+
el.addEventListener("mouseenter", function() {
|
|
4793
|
+
var elRect = el.getBoundingClientRect();
|
|
4794
|
+
var vh = window.innerHeight;
|
|
4795
|
+
sub.style.transform = "";
|
|
4796
|
+
sub.style.top = "0";
|
|
4797
|
+
sub.style.bottom = "auto";
|
|
4798
|
+
if (elRect.top > vh * 4 / 6) {
|
|
4799
|
+
sub.style.top = "auto";
|
|
4800
|
+
sub.style.bottom = "0";
|
|
4801
|
+
} else if (elRect.top > vh * 2 / 6) {
|
|
4802
|
+
sub.style.transform = "translateY(-50%)";
|
|
4803
|
+
}
|
|
4804
|
+
});
|
|
4805
|
+
})($option, $submenu);
|
|
4728
4806
|
}
|
|
4729
4807
|
|
|
4730
4808
|
if (isEnabled && isClickeable && !(resolvedChildren && resolvedChildren.length > 0)) {
|
|
4731
4809
|
$option.addEventListener("click", (evtClick) =>
|
|
4732
4810
|
option.onClick({
|
|
4733
|
-
config,
|
|
4811
|
+
config: ctx.config,
|
|
4734
4812
|
evt: evtClick,
|
|
4735
|
-
date,
|
|
4736
|
-
item,
|
|
4737
|
-
selected,
|
|
4738
|
-
tabSelected,
|
|
4739
|
-
target,
|
|
4813
|
+
date: ctx.date,
|
|
4814
|
+
item: ctx.item,
|
|
4815
|
+
selected: ctx.selected,
|
|
4816
|
+
tabSelected: ctx.tabSelected,
|
|
4817
|
+
target: ctx.target,
|
|
4740
4818
|
})
|
|
4741
4819
|
);
|
|
4742
4820
|
} else if (!(resolvedChildren && resolvedChildren.length > 0)) {
|
|
@@ -4746,8 +4824,12 @@ export default {
|
|
|
4746
4824
|
});
|
|
4747
4825
|
}
|
|
4748
4826
|
|
|
4749
|
-
$
|
|
4827
|
+
$menu.append($option);
|
|
4750
4828
|
hasSomeoption = true;
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4831
|
+
config.timeline.contextMenu.options.forEach((option) => {
|
|
4832
|
+
renderContextMenuItem(option, $contextMenu);
|
|
4751
4833
|
});
|
|
4752
4834
|
|
|
4753
4835
|
return {
|