wj-elements 0.1.76 → 0.1.77

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
@@ -399,7 +399,7 @@
399
399
  --wje-orgchart-item-hover-background: var(--wje-color-contrast-3);
400
400
  --wje-orgchart-item-highlight-border: 1px solid blue;
401
401
  --wje-orgchart-item-hover-border: 1px solid red;
402
- --wje-orgchart-item-expander-size: 0.75rem;
402
+ --wje-orgchart-item-expander-size: .75rem;
403
403
 
404
404
  /* Orgchart - Group */
405
405
  --wje-orgchart-group-width: auto;
@@ -161,16 +161,36 @@ class UniversalService {
161
161
  }
162
162
  class WjePermissionsApi {
163
163
  constructor() {
164
+ this._permissionKey = "permissions";
164
165
  }
166
+ static set permissionKey(value) {
167
+ this._permissionKey = value || "permissions";
168
+ }
169
+ static get permissionKey() {
170
+ return this._permissionKey;
171
+ }
172
+ static set permissions(value) {
173
+ window.localStorage.setItem(this._permissionKey, value);
174
+ }
175
+ /**
176
+ * Returns the permissions.
177
+ * @returns {*}
178
+ */
165
179
  static get permissions() {
166
- return [
167
- ...intranet.storage().getItem("permissions", "settings") || [],
168
- ...intranet.storage().getItem("globalPermissions", "settings") || []
169
- ];
180
+ return window.localStorage.getItem(this._permissionKey) || [];
170
181
  }
182
+ /**
183
+ * Checks if the permission is included.
184
+ * @param key
185
+ * @returns {*}
186
+ */
171
187
  static includesKey(key) {
172
188
  return WjePermissionsApi.permissions.includes(key);
173
189
  }
190
+ /**
191
+ * Returns the keys for the permission check.
192
+ * @returns {*[]}
193
+ */
174
194
  static getKeys() {
175
195
  let key = [];
176
196
  if (this.hasAttribute("permission-check")) {
@@ -178,9 +198,17 @@ class WjePermissionsApi {
178
198
  }
179
199
  return key;
180
200
  }
201
+ /**
202
+ * Checks if the component should be shown.
203
+ * @returns {*}
204
+ */
181
205
  static shouldShow() {
182
206
  return this.hasAttribute("show") && JSON.parse(this.getAttribute("show"));
183
207
  }
208
+ /**
209
+ * Checks if the permission is fulfilled.
210
+ * @returns {*}
211
+ */
184
212
  static isPermissionFulfilled() {
185
213
  return WjePermissionsApi.getKeys.bind(this)().some((perm) => WjePermissionsApi.permissions.includes(perm)) || WjePermissionsApi.shouldShow.bind(this)();
186
214
  }
@@ -5,6 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import WJElement, { event } from "./wje-element.js";
8
+ import { WjePermissionsApi } from "./wje-element.js";
8
9
  import { defaultStoreActions, store } from "./wje-store.js";
9
10
  import { b, w } from "./router-links-F7MJWhZi.js";
10
11
  import { fetchAndParseCSS } from "./wje-fetchAndParseCSS.js";
@@ -5360,6 +5361,7 @@ export {
5360
5361
  default84 as Tooltip,
5361
5362
  default85 as VisuallyHidden,
5362
5363
  WJElement,
5364
+ WjePermissionsApi,
5363
5365
  b as bindRouterLinks,
5364
5366
  defaultStoreActions,
5365
5367
  event,
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import WJElement from "./wje-element.js";
7
+ import WJElement, { event } from "./wje-element.js";
8
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: var(--wje-orgchart-group-padding);\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
  /**
@@ -57,8 +57,23 @@ class OrgchartGroup extends WJElement {
57
57
  card.appendChild(items);
58
58
  native.appendChild(card);
59
59
  fragment.appendChild(native);
60
+ this.card = card;
60
61
  return fragment;
61
62
  }
63
+ /**
64
+ * After Draws the component.
65
+ *
66
+ * @param {Object} context - The context for drawing.
67
+ * @param {Object} store - The store for drawing.
68
+ * @param {Object} params - The parameters for drawing.
69
+ * @returns {DocumentFragment}
70
+ */
71
+ afterDraw(context, store, params) {
72
+ this.card.addEventListener("click", (e) => {
73
+ e.stopPropagation();
74
+ event.dispatchCustomEvent(this.card, "wje-orgchart-group:click", { target: this });
75
+ });
76
+ }
62
77
  }
63
78
  OrgchartGroup.define("wje-orgchart-group", OrgchartGroup);
64
79
  export {
@@ -41,7 +41,7 @@ const styles = `:host {
41
41
  font-size: 8px;
42
42
  line-height: 1;
43
43
  box-sizing: border-box;
44
- transform: translate(-50%, 6px);
44
+ transform: translate(-50%, calc(var(--wje-orgchart-item-expander-size) / 2));
45
45
  padding-bottom: 1px;
46
46
  cursor: pointer;
47
47
  z-index: 999;
@@ -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 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";
8
+ const styles = "* {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 justify-content: center;\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.76",
4
+ "version": "0.1.77",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",