capibara 1.3.60 → 1.3.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capibara",
3
- "version": "1.3.60",
3
+ "version": "1.3.61",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,6 +60,44 @@
60
60
  margin: 0.3em 1em;
61
61
  }
62
62
 
63
+ &.is-section-label {
64
+ cursor: unset;
65
+ font-size: 0.7em;
66
+ padding: 0.3em 1em 0.1em;
67
+ text-transform: uppercase;
68
+ letter-spacing: 0.06em;
69
+ &:hover {
70
+ background: none;
71
+ }
72
+ }
73
+
74
+ &.has-children {
75
+ position: relative;
76
+
77
+ .cap-context-menu--submenu {
78
+ display: none;
79
+ position: absolute;
80
+ left: 100%;
81
+ top: 0;
82
+ min-width: 180px;
83
+ z-index: 3;
84
+ font-size: 1em;
85
+ }
86
+
87
+ &:hover {
88
+ > .cap-context-menu--submenu {
89
+ display: block;
90
+ }
91
+ }
92
+ }
93
+
94
+ &_chevron {
95
+ margin-left: auto;
96
+ padding-left: 0.5em;
97
+ font-size: 1.1em;
98
+ opacity: 0.7;
99
+ }
100
+
63
101
  &_icon {
64
102
  display: inline-block;
65
103
  flex: 0 0 auto;
@@ -84,6 +122,17 @@
84
122
  fill: mapGet($theme, color);
85
123
  }
86
124
  }
125
+ .cap-context-menu--submenu {
126
+ color: mapGet($theme, color);
127
+ border-color: mapGet($theme, detailDay, border);
128
+ background: mapGet($theme, detailDay, background);
129
+ }
130
+ .cap-context-menu_item.is-section-label {
131
+ color: rgba(mapGet($theme, color), 0.6);
132
+ }
133
+ .cap-context-menu_item.is-divider {
134
+ border-bottom-color: rgba(mapGet($theme, color), 0.2);
135
+ }
87
136
  }
88
137
  }
89
138
  }
@@ -4662,27 +4662,72 @@ export default {
4662
4662
  optionClassName += "is-divider ";
4663
4663
  }
4664
4664
 
4665
+ if (option.isSectionLabel) {
4666
+ isClickeable = false;
4667
+ optionClassName += "is-section-label ";
4668
+ }
4669
+
4665
4670
  if (option.label) {
4666
- label = `<span>${option.label}</span>`;
4671
+ label = "<span>" + option.label + "</span>";
4667
4672
  }
4668
4673
 
4669
4674
  if (option.icon) {
4670
- strIcon = `<div class="cap-context-menu_item_icon">
4671
- <svg viewBox="0 0 24 24">
4672
- <path d="${option.icon}" />
4673
- </svg>
4674
- </div>`;
4675
+ strIcon = "<div class=\"cap-context-menu_item_icon\"><svg viewBox=\"0 0 24 24\"><path d=\"" + option.icon + "\" /></svg></div>";
4675
4676
  }
4676
4677
 
4677
- let optionStrHtml = `
4678
- <div class="cap-context-menu_item ${optionClassName}">
4679
- ${strIcon}
4680
- ${label}
4681
- </div>`;
4678
+ var resolvedChildren = null;
4679
+ if (option.children) {
4680
+ resolvedChildren = typeof option.children === "function"
4681
+ ? option.children({ config: config, date: date, item: item, selected: selected, tabSelected: tabSelected, target: target })
4682
+ : option.children;
4683
+ }
4684
+
4685
+ var chevron = resolvedChildren && resolvedChildren.length > 0
4686
+ ? "<span class=\"cap-context-menu_item_chevron\">&#8250;</span>"
4687
+ : "";
4688
+
4689
+ var hasChildrenClass = resolvedChildren && resolvedChildren.length > 0 ? "has-children" : "";
4690
+
4691
+ let optionStrHtml = "<div class=\"cap-context-menu_item " + hasChildrenClass + " " + optionClassName + "\">" + strIcon + label + chevron + "</div>";
4682
4692
 
4683
4693
  let $option = dom.createElementFromHTML(optionStrHtml);
4684
4694
 
4685
- if (isEnabled && isClickeable) {
4695
+ if (resolvedChildren && resolvedChildren.length > 0) {
4696
+ var $submenu = document.createElement("div");
4697
+ $submenu.className = "cap-context-menu cap-context-menu--submenu";
4698
+
4699
+ resolvedChildren.forEach(function(child) {
4700
+ var childEnabled = true;
4701
+ if (child.enableIf) {
4702
+ childEnabled = child.enableIf({ config: config, date: date, item: item, selected: selected, tabSelected: tabSelected });
4703
+ }
4704
+ var childClassName = childEnabled ? "" : "is-disabled ";
4705
+ var childIcon = "";
4706
+ var childLabel = child.label ? "<span>" + child.label + "</span>" : "";
4707
+ if (child.icon) {
4708
+ childIcon = "<div class=\"cap-context-menu_item_icon\"><svg viewBox=\"0 0 24 24\"><path d=\"" + child.icon + "\" /></svg></div>";
4709
+ }
4710
+ var childHtml = "<div class=\"cap-context-menu_item " + childClassName + "\">" + childIcon + childLabel + "</div>";
4711
+ var $child = dom.createElementFromHTML(childHtml);
4712
+ if (childEnabled && child.onClick) {
4713
+ (function(c) {
4714
+ $child.addEventListener("click", function(evtClick) {
4715
+ c.onClick({ config: config, evt: evtClick, date: date, item: item, selected: selected, tabSelected: tabSelected, target: target });
4716
+ });
4717
+ })(child);
4718
+ } else {
4719
+ $child.addEventListener("click", function(evtClick) {
4720
+ evtClick.preventDefault();
4721
+ evtClick.stopPropagation();
4722
+ });
4723
+ }
4724
+ $submenu.appendChild($child);
4725
+ });
4726
+
4727
+ $option.appendChild($submenu);
4728
+ }
4729
+
4730
+ if (isEnabled && isClickeable && !(resolvedChildren && resolvedChildren.length > 0)) {
4686
4731
  $option.addEventListener("click", (evtClick) =>
4687
4732
  option.onClick({
4688
4733
  config,
@@ -4694,7 +4739,7 @@ export default {
4694
4739
  target,
4695
4740
  })
4696
4741
  );
4697
- } else {
4742
+ } else if (!(resolvedChildren && resolvedChildren.length > 0)) {
4698
4743
  $option.addEventListener("click", (evtClick) => {
4699
4744
  evtClick.preventDefault();
4700
4745
  evtClick.stopPropagation();