inviton-powerduck 0.0.39 → 0.0.41

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.
@@ -0,0 +1,40 @@
1
+ import { toNative, Prop } from "vue-facing-decorator";
2
+ import TsxComponent, { Component } from "../../app/vuetsx";
3
+ import { BreakpointHandler } from "./ts/breakpoint-handler";
4
+ interface ContainerWithBreakpointsArgs {
5
+ cssClass?: string
6
+ }
7
+
8
+
9
+
10
+ @Component
11
+ class ContainerWithBreakpointsComponent extends TsxComponent<ContainerWithBreakpointsArgs> implements ContainerWithBreakpointsArgs {
12
+ @Prop() cssClass: string
13
+ breakpointClass: string = null;
14
+ _handler: any;
15
+
16
+
17
+ mounted() {
18
+ this._handler = () => {
19
+ const newClass = BreakpointHandler.getBreakpointsForElement(this.$el);
20
+ if (newClass != this.breakpointClass) {
21
+ this.breakpointClass = newClass;
22
+ }
23
+ }
24
+
25
+ BreakpointHandler.addResizeHandler(this._handler);
26
+ this._handler();
27
+ }
28
+
29
+ beforeUnmount() {
30
+ BreakpointHandler.removeResizeHandler(this._handler);
31
+ this._handler = null;
32
+ }
33
+
34
+ render(h) {
35
+ return <div class={`${this.cssClass != null ? this.cssClass + ' ' : ''}${this.breakpointClass}`}>{this.$slots.default?.()}</div>;
36
+ }
37
+ }
38
+
39
+ const ContainerWithBreakpoints = toNative(ContainerWithBreakpointsComponent)
40
+ export default ContainerWithBreakpoints
@@ -0,0 +1,68 @@
1
+ import { arrayRemove } from "../../../common/utils/array-remove";
2
+ import MemoryCache from "../../memory-cache";
3
+
4
+ export class BreakpointHandler {
5
+ private static _handlers: any[] = [];
6
+
7
+ static addResizeHandler(handler: () => any) {
8
+ BreakpointHandler.bindResizeHandler();
9
+ BreakpointHandler._handlers.push(handler);
10
+ }
11
+
12
+ static removeResizeHandler(handler: () => any) {
13
+ arrayRemove(BreakpointHandler._handlers, handler);
14
+ }
15
+
16
+ static bindResizeHandler() {
17
+ if (MemoryCache.getItem<boolean>('breakpointsBound') == true) {
18
+ return;
19
+ }
20
+
21
+ MemoryCache.setItem<boolean>('breakpointsBound', true);
22
+ window.addEventListener('resize', BreakpointHandler.onWindowHasResized);
23
+ BreakpointHandler.onWindowHasResized();
24
+ }
25
+
26
+ static getBreakpointsForElement(elem: Element): string {
27
+ var clientWidth = elem.clientWidth;
28
+ var newClass = 'inv-brkmax-max ';
29
+
30
+ if (clientWidth < 1201) {
31
+ newClass += 'inv-brkmax-1200 ';
32
+ }
33
+
34
+ //Ugly patch, but 992 should be included up..
35
+ if (clientWidth < 992) {
36
+ newClass += 'inv-brkmax-992 ';
37
+ }
38
+
39
+ //Ugly patch, but 768 should be included up..
40
+ if (clientWidth < 768) {
41
+ newClass += 'inv-brkmax-768 ';
42
+ }
43
+
44
+ if (clientWidth < 551) {
45
+ newClass += 'inv-brkmax-550 ';
46
+ }
47
+
48
+ if (clientWidth < 451) {
49
+ newClass += 'inv-brkmax-450 ';
50
+ }
51
+
52
+ if (clientWidth < 381) {
53
+ newClass += 'inv-brkmax-380 ';
54
+ }
55
+
56
+ return newClass;
57
+ }
58
+
59
+ private static onWindowHasResized() {
60
+ for (const handler of BreakpointHandler._handlers) {
61
+ try {
62
+ handler();
63
+ } catch (error) {
64
+ console.error(error);
65
+ }
66
+ }
67
+ }
68
+ }
@@ -123,5 +123,5 @@ export class DataTableStaticComponent extends TsxComponent<DataTableStaticArgs>
123
123
  }
124
124
  }
125
125
 
126
- const DataTableStatic = toNative(DataTableStaticComponent)
127
- export default DataTableStatic
126
+ const DataTableStatic = toNative(DataTableStaticComponent)
127
+ export default DataTableStatic
@@ -2257,4 +2257,4 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
2257
2257
 
2258
2258
  const DataTable = toNative(DataTableComponent);
2259
2259
  export const DataTableType = typeof DataTable.prototype;
2260
- export default DataTable;
2260
+ export default DataTable;
@@ -103,7 +103,9 @@ function raiseOnReorderedEvent() {
103
103
  }
104
104
 
105
105
  draggingItem.parentNode.childNodes.forEach((colHeader, i) => {
106
- sortOrder.push(colHeader.getAttribute("data-col-id"));
106
+ if (colHeader.getAttribute) {
107
+ sortOrder.push(colHeader.getAttribute("data-col-id"));
108
+ }
107
109
  });
108
110
 
109
111
  var ord = onReorder;
@@ -0,0 +1,27 @@
1
+ export class MemoryCacheConfig {
2
+ static windowRootName: string = 'powerduck'
3
+ static cacheObjectKey: string = '_cache';
4
+ }
5
+
6
+ function getCacheRoot(): any {
7
+ if ((window as any)[MemoryCacheConfig.windowRootName] == null) {
8
+ (window as any)[MemoryCacheConfig.windowRootName] = {};
9
+ }
10
+
11
+ if ((window as any)[MemoryCacheConfig.windowRootName][MemoryCacheConfig.cacheObjectKey] == null) {
12
+ (window as any)[MemoryCacheConfig.windowRootName][MemoryCacheConfig.cacheObjectKey] = {};
13
+ }
14
+
15
+ return (window as any)[MemoryCacheConfig.windowRootName][MemoryCacheConfig.cacheObjectKey];
16
+
17
+ }
18
+
19
+ export default class MemoryCache {
20
+ static getItem<T>(key: string): T {
21
+ return getCacheRoot()[key];
22
+ }
23
+
24
+ static setItem<T>(key: string, value: T): void {
25
+ getCacheRoot()[key] = value;
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": " vite build && vue-tsc --declaration --emitDeclarationOnly",