wj-elements 0.1.72 → 0.1.74

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/light.css CHANGED
@@ -387,6 +387,20 @@
387
387
  --wje-option-padding-bottom: var(--wje-spacing-x-small);
388
388
  --wje-option-highlighted: var(--wje-color-contrast-3);
389
389
 
390
+ /* Orgchart */
391
+ --wje-orgchart-height-line: 10px;
392
+ --wje-orgchart-border-radius: var(--wje-border-radius-large);
393
+
394
+ /* Orgchart - Item */
395
+ --wje-orgchart-item-width: 75px;
396
+ --wje-orgchart-item-border-radius: var(--wje-border-radius-large);
397
+ --wje-orgchart-item-height-line: 10px;
398
+
399
+ /* Orgchart - Group */
400
+ --wje-orgchart-group-width: auto;
401
+ --wje-orgchart-group-border-radius: var(--wje-border-radius-large);
402
+ --wje-orgchart-group-height-line: 10px;
403
+
390
404
  /* Rate */
391
405
  --wje-rate-gap: .25rem;
392
406
 
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import WJElement from "./wje-element.js";
8
- const styles = ":host {\n --wje-orgchart-group-width: auto;\n --wje-orgchart-group-border-radius: var(--wje-border-radius-large);\n --wje-orgchart-group-height-line: 10px;\n text-align: center;\n list-style-type: none;\n position: relative;\n padding: var(--wje-orgchart-group-height-line) 0 0 0;\n transition: all 0.5s;\n\n &::before, &::after {\n content: '';\n position: absolute;\n top: 0;\n right: 50%;\n border-top: 1px solid var(--wje-border-color);\n width: 50%;\n height: var(--wje-orgchart-group-height-line);\n }\n\n &::after {\n right: auto;\n left: 50%;\n border-left: 1px solid var(--wje-border-color);\n }\n\n wje-card::part(native) {\n box-sizing: border-box;\n padding: .25rem 0;\n }\n\n wje-card h4 {\n margin: 0;\n }\n wje-card .items {\n display: flex;\n }\n\n .orgchart-group {\n display: flex;\n flex-direction: column;\n wje-card {\n margin: 0 auto;\n width: var(--wje-orgchart-group-width);\n }\n }\n}\n\n:host(:only-child)::after, :host(:only-child)::before {\n display: none;\n}\n\n:host(:only-child) {\n padding-top: 0;\n}\n\n:host(:first-child)::before,\n:host(:last-child)::after {\n border: 0 none;\n}\n\n:host(:last-child)::before {\n border-right: 1px solid var(--wje-border-color);\n border-radius: 0 var(--wje-orgchart-group-border-radius) 0 0;\n}\n\n:host(:first-child)::after {\n border-radius: var(--wje-orgchart-group-border-radius) 0 0 0;\n}";
8
+ const styles = ":host {\n text-align: center;\n list-style-type: none;\n position: relative;\n padding: var(--wje-orgchart-group-height-line) 0 0 0;\n transition: all 0.5s;\n\n &::before, &::after {\n content: '';\n position: absolute;\n top: 0;\n right: 50%;\n border-top: 1px solid var(--wje-border-color);\n width: 50%;\n height: var(--wje-orgchart-group-height-line);\n }\n\n &::after {\n right: auto;\n left: 50%;\n border-left: 1px solid var(--wje-border-color);\n }\n\n wje-card::part(native) {\n box-sizing: border-box;\n padding: .25rem 0;\n }\n\n wje-card h4 {\n margin: 0;\n }\n wje-card .items {\n display: flex;\n }\n\n .orgchart-group {\n display: flex;\n flex-direction: column;\n wje-card {\n margin: 0 auto;\n width: var(--wje-orgchart-group-width);\n }\n }\n}\n\n:host(:only-child)::after, :host(:only-child)::before {\n display: none;\n}\n\n:host(:only-child) {\n padding-top: 0;\n}\n\n:host(:first-child)::before,\n:host(:last-child)::after {\n border: 0 none;\n}\n\n:host(:last-child)::before {\n border-right: 1px solid var(--wje-border-color);\n border-radius: 0 var(--wje-orgchart-group-border-radius) 0 0;\n}\n\n:host(:first-child)::after {\n border-radius: var(--wje-orgchart-group-border-radius) 0 0 0;\n}";
9
9
  class OrgchartGroup extends WJElement {
10
10
  /**
11
11
  * Creates an instance of OrgchartGroup.
@@ -5,7 +5,133 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import WJElement from "./wje-element.js";
8
- const styles = ":host {\n --wje-orgchart-item-width: 75px;\n --wje-orgchart-item-border-radius: var(--wje-border-radius-large);\n --wje-orgchart-item-height-line: 10px;\n width: var(--wje-orgchart-item-width);\n box-sizing: border-box;\n\n .orgchart-item {\n display: flex;\n flex-direction: column;\n\n wje-card {\n margin: 0 auto;\n padding-inline: .25rem;\n width: var(--wje-orgchart-item-width);\n box-sizing: border-box;\n &::part(native) {\n border-radius: var(--wje-orgchart-border-radius) !important;\n box-sizing: border-box;\n }\n }\n }\n}\n\n/* ak nie je parent-group */\n:host(:not(.parent-group)) {\n text-align: center;\n list-style-type: none;\n position: relative;\n padding: var(--wje-orgchart-item-height-line) 0 0 0;\n transition: all 0.5s;\n width: auto;\n\n &::before, &::after {\n content: '';\n position: absolute;\n top: 0;\n right: 50%;\n border-top: 1px solid var(--wje-border-color);\n width: 50%;\n height: var(--wje-orgchart-item-height-line);\n }\n\n &::after {\n right: auto;\n left: 50%;\n border-left: 1px solid var(--wje-border-color);\n }\n\n wje-card::part(native) {\n box-sizing: border-box;\n }\n}\n\n:host(:hover){\n wje-card::part(native) {\n background: var(--wje-color-contrast-3);\n /*color: #000;*/\n }\n}\n\n:host(.highlight){\n wje-card::part(native) {\n background: var(--wje-color-complete-2);\n /*color: #000;*/\n }\n}\n\n\n:host(:only-child)::after, :host(:only-child)::before {\n display: none;\n}\n\n:host(:only-child) {\n padding-top: 0;\n}\n\n:host(:first-child)::before,\n:host(:last-child)::after {\n border: 0 none;\n}\n\n:host(:last-child)::before {\n border-right: 1px solid var(--wje-border-color);\n border-radius: 0 var(--wje-orgchart-item-border-radius) 0 0;\n}\n\n:host(:first-child)::after {\n border-radius: var(--wje-orgchart-item-border-radius) 0 0 0;\n}";
8
+ const styles = `:host {
9
+ width: var(--wje-orgchart-item-width);
10
+ box-sizing: border-box;
11
+
12
+ .orgchart-item {
13
+ display: flex;
14
+ flex-direction: column;
15
+
16
+ wje-card {
17
+ margin: 0 auto;
18
+ padding-inline: .25rem;
19
+ width: var(--wje-orgchart-item-width);
20
+ box-sizing: border-box;
21
+ &::part(native) {
22
+ border-radius: var(--wje-orgchart-border-radius) !important;
23
+ box-sizing: border-box;
24
+ overflow: visible;
25
+ padding-block: .125rem;
26
+ }
27
+ }
28
+ }
29
+
30
+ .expander {
31
+ position: absolute;
32
+ left: calc(50% + 1px / 2);
33
+ border: 1px solid var(--wje-border-color);
34
+ border-radius: 50%;
35
+ width: 12px;
36
+ height: 12px;
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ background: var(--wje-color-contrast-0);
41
+ font-size: 8px;
42
+ line-height: 1;
43
+ box-sizing: border-box;
44
+ transform: translate(-50%, 6px);
45
+ padding-bottom: 1px;
46
+ cursor: pointer;
47
+ z-index: 999;
48
+ bottom: 0;
49
+ &.collapse {
50
+ content: "+";
51
+ wje-orgchart {
52
+ display: none;
53
+ }
54
+ }
55
+ &:hover {
56
+ background: var(--wje-color-contrast-1);
57
+ }
58
+ }
59
+ }
60
+
61
+ :host(.collapse) {
62
+ .expander {
63
+ content: "+";
64
+ }
65
+ slot[name=child] {
66
+ display: none;
67
+ }
68
+ }
69
+ /* ak nie je parent-group */
70
+ :host(:not(.parent-group)) {
71
+ text-align: center;
72
+ list-style-type: none;
73
+ position: relative;
74
+ padding: var(--wje-orgchart-item-height-line) 0 0 0;
75
+ transition: all 0.5s;
76
+ width: auto;
77
+
78
+ &::before, &::after {
79
+ content: '';
80
+ position: absolute;
81
+ top: 0;
82
+ right: 50%;
83
+ border-top: 1px solid var(--wje-border-color);
84
+ width: 50%;
85
+ height: var(--wje-orgchart-item-height-line);
86
+ }
87
+
88
+ &::after {
89
+ right: auto;
90
+ left: 50%;
91
+ border-left: 1px solid var(--wje-border-color);
92
+ }
93
+
94
+ wje-card::part(native) {
95
+ box-sizing: border-box;
96
+ }
97
+ }
98
+
99
+ :host(:hover){
100
+ wje-card::part(native) {
101
+ background: var(--wje-color-contrast-3);
102
+ /*color: #000;*/
103
+ }
104
+ }
105
+
106
+ :host(.highlight){
107
+ wje-card::part(native) {
108
+ background: var(--wje-color-complete-2);
109
+ /*color: #000;*/
110
+ }
111
+ }
112
+
113
+
114
+ :host(:only-child)::after, :host(:only-child)::before {
115
+ display: none;
116
+ }
117
+
118
+ :host(:only-child) {
119
+ padding-top: 0;
120
+ }
121
+
122
+ :host(:first-child)::before,
123
+ :host(:last-child)::after {
124
+ border: 0 none;
125
+ }
126
+
127
+ :host(:last-child)::before {
128
+ border-right: 1px solid var(--wje-border-color);
129
+ border-radius: 0 var(--wje-orgchart-item-border-radius) 0 0;
130
+ }
131
+
132
+ :host(:first-child)::after {
133
+ border-radius: var(--wje-orgchart-item-border-radius) 0 0 0;
134
+ }`;
9
135
  class OrgchartItem extends WJElement {
10
136
  /**
11
137
  * Creates an instance of OrgchartItem.
@@ -15,6 +141,14 @@ class OrgchartItem extends WJElement {
15
141
  constructor() {
16
142
  super();
17
143
  __publicField(this, "className", "OrgchartItem");
144
+ /**
145
+ * Toggles the children of the orgchart item.
146
+ * @param e - The event object.
147
+ */
148
+ __publicField(this, "toggleChildren", (e) => {
149
+ this.classList.toggle("collapse");
150
+ this.classList.contains("collapse") ? e.target.innerHTML = "+" : e.target.innerHTML = "-";
151
+ });
18
152
  }
19
153
  /**
20
154
  * Returns the CSS styles for the component.
@@ -53,12 +187,30 @@ class OrgchartItem extends WJElement {
53
187
  let slot = document.createElement("slot");
54
188
  let child = document.createElement("slot");
55
189
  child.setAttribute("name", "child");
190
+ let expander = document.createElement("div");
191
+ expander.setAttribute("part", "expander");
192
+ expander.classList.add("expander");
193
+ expander.innerHTML = "-";
56
194
  card.appendChild(slot);
195
+ if (this.children.length > 0)
196
+ card.appendChild(expander);
57
197
  native.appendChild(card);
58
198
  native.appendChild(child);
59
199
  fragment.appendChild(native);
200
+ this.expander = expander;
60
201
  return fragment;
61
202
  }
203
+ /**
204
+ * After Draws the component.
205
+ *
206
+ * @param {Object} context - The context for drawing.
207
+ * @param {Object} store - The store for drawing.
208
+ * @param {Object} params - The parameters for drawing.
209
+ * @returns {DocumentFragment}
210
+ */
211
+ afterDraw(context, store, params) {
212
+ this.expander.addEventListener("click", this.toggleChildren);
213
+ }
62
214
  }
63
215
  OrgchartItem.define("wje-orgchart-item", OrgchartItem);
64
216
  export {
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import WJElement from "./wje-element.js";
8
- const styles = "\n\n* {margin: 0; padding: 0;}\n\n:host {\n --wje-orgchart-height-line: 10px;\n --wje-orgchart-border-radius: var(--wje-border-radius-large);\n\n position: relative;\n .native-orgchart {\n padding-top: var(--wje-orgchart-height-line);\n display: flex;\n /*column-gap: .5rem;*/\n }\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 50%;\n border-left: 1px solid var(--wje-border-color);\n width: 0;\n height: var(--wje-orgchart-height-line);\n }\n}\n\n";
8
+ const styles = "\n\n* {margin: 0; padding: 0;}\n\n:host {\n position: relative;\n .native-orgchart {\n padding-top: var(--wje-orgchart-height-line);\n display: flex;\n }\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 50%;\n border-left: 1px solid var(--wje-border-color);\n width: 0;\n height: var(--wje-orgchart-height-line);\n }\n}\n\n";
9
9
  class Orgchart extends WJElement {
10
10
  /**
11
11
  * Creates an instance of Orgchart.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wj-elements",
3
3
  "description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
4
- "version": "0.1.72",
4
+ "version": "0.1.74",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",