quasar-ui-danx 0.2.24 → 0.2.25

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -39,6 +39,66 @@ yarn add quasar-ui-danx quasar
39
39
  yarn add -D sass vite-svg-loader tailwindcss eslint eslint-plugin-import autoprefixer
40
40
  ```
41
41
 
42
+ ### Setup PHPStorm
43
+
44
+ * Disable Typescript language service
45
+ * Setup node_modules directory as a library
46
+ * Configure `tsconfig.json`
47
+
48
+ ```json
49
+ {
50
+ "include": [
51
+ "node_modules/quasar-ui-danx/**/*"
52
+ ]
53
+ }
54
+ ```
55
+
56
+ * Configure `vite.config.ts`
57
+
58
+ ```ts
59
+ export default ({ command }) => {
60
+ // For development w/ HMR, load the danx library + styles directly from the directory
61
+ // NOTE: These are the paths relative to the mounted quasar-ui-danx directory inside the mva docker container
62
+ const danx = (command === "serve" ? {
63
+ "quasar-ui-danx": resolve(__dirname, "../quasar-ui-danx/ui/src"),
64
+ "quasar-ui-danx-styles": resolve(__dirname, "../quasar-ui-danx/src/styles/index.scss")
65
+ } : {
66
+ // Import from quasar-ui-danx module for production
67
+ "quasar-ui-danx-styles": "quasar-ui-danx/dist/style.css"
68
+ });
69
+
70
+ return defineConfig({
71
+ resolve: {
72
+ alias: {
73
+ ...danx
74
+ }
75
+ },
76
+ });
77
+ }
78
+ ```
79
+
80
+ * Add node_modules as a library in PHPStorm
81
+ * Settings -> Directories -> Add
82
+ * Create a new directory w/ name node_modules and set the directory to the node_modules directory in your project
83
+ * Symlink Danx UI library
84
+ * copy/paste and run `./danx-local.sh`
85
+ * (or manually symlink node_modules/quasar-ui-danx to ../../quasar-ui-danx/ui/src)
86
+ * Directory structure of your project relative to quasar-ui-danx:
87
+
88
+ ```
89
+ - parent-directory
90
+ - your-app
91
+ - tsconfig.json
92
+ - vite.config.ts
93
+ - src
94
+ - node_modules
95
+ - quasar-ui-danx -> (symlink) ../../quasar-ui-danx/ui/src
96
+ - quasar-ui-danx
97
+ - ui
98
+ - src
99
+ - tests
100
+ ```
101
+
42
102
  ### Setup Tailwind
43
103
 
44
104
  Initialize config files for tailwind
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -2,8 +2,8 @@ import { QNotifyCreateOptions } from "quasar";
2
2
 
3
3
  export interface DanxFileUploadOptions {
4
4
  directory?: string;
5
- presignedUploadUrl?: string | null;
6
- uploadCompletedUrl?: string | null;
5
+ presignedUploadUrl?: Function | null;
6
+ uploadCompletedUrl?: Function | null;
7
7
  }
8
8
 
9
9
  export interface DanxOptions {
@@ -37,8 +37,8 @@ export class FlashMessages {
37
37
  classes: "bg-gray-500 text-white",
38
38
  position: "top",
39
39
  closeBtn: "X",
40
- ...options,
41
- ...danxOptions.flashMessages.default
40
+ ...danxOptions.flashMessages.default,
41
+ ...options
42
42
  });
43
43
  }
44
44
  }
@@ -0,0 +1,59 @@
1
+ import { Ref, ref } from "vue";
2
+
3
+ interface HotkeyListener {
4
+ id?: string,
5
+ name: string,
6
+ callback: Function
7
+ }
8
+
9
+ interface Hotkey {
10
+ name: string,
11
+ ctrl?: boolean,
12
+ alt?: boolean,
13
+ shift?: boolean,
14
+ type: "keyup" | "keydown",
15
+ key: string | string[] | number | number[],
16
+ }
17
+
18
+ const hotkeys: Ref<Hotkey[]> = ref([]);
19
+ const listeners: Ref<HotkeyListener[]> = ref([]);
20
+
21
+ export function addHotkey(key: Hotkey) {
22
+ hotkeys.value = [...hotkeys.value, key];
23
+ }
24
+
25
+ export function listen(name: string, callback: Function, id?: string) {
26
+ listeners.value.push({ id, name, callback });
27
+ }
28
+
29
+ export function unlisten(id: string) {
30
+ listeners.value = listeners.value.filter(listener => listener.id !== id);
31
+ }
32
+
33
+ function triggerEvent(type: "keydown" | "keyup", key: string | number, e: KeyboardEvent) {
34
+ for (let hotkey of hotkeys.value) {
35
+ if (hotkey.type === type && hotkey.key === key && e.ctrlKey === !!hotkey.ctrl && e.altKey === !!hotkey.alt && e.shiftKey === !!hotkey.shift) {
36
+ for (let listener of listeners.value) {
37
+ if (listener.name === hotkey.name) {
38
+ listener.callback(e);
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ function getKey(e: KeyboardEvent) {
46
+ return e.key ? ("" + e.key).toLowerCase() : e.keyCode;
47
+ }
48
+
49
+ export function registerHotkeys(keys: Hotkey[]) {
50
+ hotkeys.value = keys;
51
+
52
+ window.addEventListener("keydown", e => {
53
+ triggerEvent("keydown", getKey(e), e);
54
+ });
55
+
56
+ window.addEventListener("keyup", e => {
57
+ triggerEvent("keyup", getKey(e), e);
58
+ });
59
+ }
@@ -8,9 +8,10 @@ export * from "./files";
8
8
  export * from "./FileUpload";
9
9
  export * from "./FlashMessages";
10
10
  export * from "./formats";
11
+ export * from "./hotkeys";
11
12
  export * from "./multiFileUpload";
13
+ export * from "./request";
12
14
  export * from "./singleFileUpload";
13
15
  export * from "./storage";
14
16
  export * from "./styles";
15
17
  export * from "./utils";
16
- export * from "./request";
@@ -1,10 +1,10 @@
1
- import { ref, Ref, UnwrapRef } from "vue";
1
+ import { ref, Ref } from "vue";
2
2
 
3
3
  interface RequestOptions {
4
4
  baseUrl: string;
5
5
  }
6
6
 
7
- const requestOptions: Ref<UnwrapRef<RequestOptions>> = ref({
7
+ const requestOptions: Ref<RequestOptions> = ref({
8
8
  baseUrl: ""
9
9
  });
10
10
  /**