@drumee/ui-toolkit 0.0.16 → 0.0.17

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/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
 
2
-
2
+ let loaded = 0;
3
3
  function start() {
4
+ if (loaded) return;
4
5
  Kind.registerAddons({
5
6
  'dtk_otp': import('./widgets/otp'),
6
7
  'dtk_dialog': import('./widgets/dialog'),
7
8
  'dtk_pwsetter': import('./widgets/pwsetter'),
8
9
  })
10
+ loaded = 1;
9
11
  }
10
12
 
11
13
 
@@ -25,4 +27,5 @@ export function loadWidgets() {
25
27
  }
26
28
 
27
29
  export * from './utils/index';
28
- export * from './utils/validator';
30
+ export * from './utils/validator';
31
+ export * from './utils/contextmenu';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drumee/ui-toolkit",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "repository": {
@@ -45,6 +45,7 @@
45
45
  "sass-resources-loader": "^2.2.5",
46
46
  "shelljs": "^0.8.5",
47
47
  "style-loader": "^3.3.1",
48
+ "svg-sprite": "^2.0.4",
48
49
  "terser-webpack-plugin": "^5.3.9",
49
50
  "ts-loader": "^9.4.1",
50
51
  "typescript": "^4.8.3",
@@ -58,7 +59,6 @@
58
59
  },
59
60
  "dependencies": {
60
61
  "@drumee/ui-styles": "^1.0.1",
61
- "autolinker": "^4.1.5",
62
62
  "filesize": "^11.0.13",
63
63
  "qrcode": "^1.5.4"
64
64
  }
@@ -5,6 +5,7 @@ export const STATE = {
5
5
  yes: 1,
6
6
  true: 1,
7
7
  sms: 1,
8
+ email: 1,
8
9
  0: 0,
9
10
  off: 0,
10
11
  out: 0,
package/utils/index.js CHANGED
@@ -1,4 +1,3 @@
1
- const { Autolinker } = require("autolinker");
2
1
  const Filesize = require("filesize");
3
2
 
4
3
  let VERBOSITY = parseInt(localStorage.logLevel) || 0;
@@ -100,30 +99,40 @@ export function filesize(val, opt) {
100
99
 
101
100
  /**
102
101
  *
103
- * @param {*} data
102
+ * @param {*} text
104
103
  */
105
- export function copyToClipboard(data) {
104
+ export async function copyToClipboard(text) {
105
+ // Try using modern Clipboard API first
106
+ if (navigator.clipboard && navigator.clipboard.writeText) {
107
+ try {
108
+ // await navigator.clipboard.writeText(data);
109
+ // return true;
110
+ const blob = new Blob([text], { type: 'text/plain' });
111
+ // Create a ClipboardItem with the Blob
112
+ const clipboardItem = new ClipboardItem({ [blob.type]: blob });
113
+ // Write the item to the clipboard
114
+ await navigator.clipboard.write([clipboardItem]);
115
+ return true;
116
+ } catch (err) {
117
+ console.error('Clipboard API failed:', err);
118
+ // Fall back to execCommand method
119
+ }
120
+ }
121
+
122
+ // Fallback for older browsers
106
123
  const el = document.createElement("textarea");
107
- el.value = data;
124
+ el.value = text;
108
125
  el.setAttribute("readonly", "");
109
126
  el.style.position = "absolute";
110
127
  el.style.left = "-9999px";
111
-
112
128
  document.body.appendChild(el);
113
- const selected =
114
- document.getSelection().rangeCount > 0
115
- ? document.getSelection().getRangeAt(0)
116
- : false;
117
- el.select();
118
129
 
119
- document.execCommand("copy");
130
+ el.select();
131
+ const success = document.execCommand("copy");
120
132
  document.body.removeChild(el);
121
- if (selected) {
122
- document.getSelection().removeAllRanges();
123
- document.getSelection().addRange(selected);
124
- }
125
- }
126
133
 
134
+ return success;
135
+ }
127
136
  /**
128
137
  *
129
138
  * @param {*} val
@@ -205,10 +214,8 @@ export function dayOfTime(time, format) {
205
214
  * @returns
206
215
  */
207
216
  export function loadJS(url) {
208
- console.log("AAA:208 loding js from", url)
209
217
  const a = new Promise(function (resolve, reject) {
210
218
  const xhr = new XMLHttpRequest();
211
- // xhr.allowCORS(xhr, url);
212
219
  xhr.open("GET", url, true);
213
220
  xhr.onload = function (e) {
214
221
  const el = document.createElement(_a.script);
@@ -400,7 +407,7 @@ export function openUserMailAgent(msg) {
400
407
  let subject = msg.subject || msg.title || "";
401
408
  let body = msg.body || msg.message || "";
402
409
  subject = encodeURIComponent(subject);
403
- body = encodeURIComponent(Autolinker.link(body));
410
+ body = encodeURIComponent(body);
404
411
  var mailToLink = `?subject=${subject}&body=${body}`;
405
412
  if (msg.recipients) {
406
413
  if (_.isString(msg.recipients)) {
@@ -417,16 +424,22 @@ export function openUserMailAgent(msg) {
417
424
  a.setAttribute(_a.href, mailToLink);
418
425
  a.setAttribute(_a.target, "_blank");
419
426
  a.style.position = _a.absolute;
420
- a.style.display = _a.none;
427
+ a.style.opacity = 0;
428
+ a.style.width = "10px";
429
+ a.style.height = "10px";
421
430
  var clickHandler = () => {
422
431
  const f = () => {
423
432
  a.removeEventListener(_e.click, clickHandler);
424
433
  a.remove();
425
434
  };
426
- _.delay(f, 300);
435
+ setTimeout(f, 300);
427
436
  };
437
+ console.log("AAA:427", a)
438
+ window.CLIKK = a;
428
439
  a.addEventListener(_e.click, clickHandler, false);
429
- a.click();
440
+ setTimeout(() => {
441
+ a.click();
442
+ }, 300);
430
443
  }
431
444
 
432
445
 
@@ -631,23 +644,23 @@ export function createQrcode(opt) {
631
644
 
632
645
  export function createSafeObject(initial = {}) {
633
646
  const data = { ...initial };
634
-
647
+
635
648
  const handler = {
636
649
  get(target, prop) {
637
650
  // Handle method calls
638
651
  if (methods.hasOwnProperty(prop)) {
639
652
  return methods[prop].bind(proxy);
640
653
  }
641
-
654
+
642
655
  // Handle property access
643
656
  if (prop in data) {
644
657
  return data[prop];
645
658
  }
646
-
659
+
647
660
  // Return key as string for missing properties
648
661
  return String(prop);
649
662
  },
650
-
663
+
651
664
  set(target, prop, value) {
652
665
  // Don't allow overriding methods
653
666
  if (prop in methods) {
@@ -658,45 +671,45 @@ export function createSafeObject(initial = {}) {
658
671
  return true;
659
672
  }
660
673
  };
661
-
674
+
662
675
  // Built-in methods
663
676
  const methods = {
664
677
  set(key, value) {
665
678
  data[key] = value;
666
679
  return this;
667
680
  },
668
-
681
+
669
682
  get(key) {
670
683
  return key in data ? data[key] : String(key);
671
684
  },
672
-
685
+
673
686
  extend(newProps) {
674
687
  Object.assign(data, newProps);
675
688
  return this;
676
689
  },
677
-
690
+
678
691
  delete(key) {
679
692
  delete data[key];
680
693
  return this;
681
694
  },
682
-
695
+
683
696
  has(key) {
684
697
  return key in data;
685
698
  },
686
-
699
+
687
700
  keys() {
688
701
  return Object.keys(data);
689
702
  },
690
-
703
+
691
704
  values() {
692
705
  return Object.values(data);
693
706
  },
694
-
707
+
695
708
  toObject() {
696
709
  return { ...data };
697
710
  }
698
711
  };
699
-
712
+
700
713
  const proxy = new Proxy({}, handler);
701
714
  return proxy;
702
715
  }