@esportsplus/ui 0.0.77 → 0.0.79

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.
@@ -198,6 +198,32 @@ declare const _default: {
198
198
  type: string;
199
199
  values: never[];
200
200
  };
201
+ textarea: (data: {
202
+ class?: string | undefined;
203
+ mask?: {
204
+ class?: string | undefined;
205
+ content?: any;
206
+ style?: string | undefined;
207
+ } | undefined;
208
+ name?: string | undefined;
209
+ placeholder?: string | undefined;
210
+ style?: string | undefined;
211
+ tag?: {
212
+ class?: string | undefined;
213
+ } | undefined;
214
+ textarea?: boolean | undefined;
215
+ type?: string | undefined;
216
+ value?: unknown;
217
+ } & {
218
+ description?: string | undefined;
219
+ } & {
220
+ required?: boolean | undefined;
221
+ title?: string | undefined;
222
+ }) => {
223
+ content: string;
224
+ type: string;
225
+ values: never[];
226
+ };
201
227
  text: (data: {
202
228
  class?: string | undefined;
203
229
  mask?: {
@@ -3,5 +3,6 @@ import file from './file';
3
3
  import optional from './optional';
4
4
  import select from './select';
5
5
  import s from './switch';
6
+ import textarea from './textarea';
6
7
  import text from './text';
7
- export default { checkbox, file, optional, select, switch: s, text };
8
+ export default { checkbox, file, optional, select, switch: s, textarea, text };
@@ -2,6 +2,18 @@ import { reactive } from '@esportsplus/reactivity';
2
2
  import { html } from '@esportsplus/template';
3
3
  import { root } from '../../components';
4
4
  import menu from './menu';
5
+ let queue = [], running = false, scheduled = false;
6
+ async function frame() {
7
+ if (running) {
8
+ return;
9
+ }
10
+ running = true;
11
+ let items = queue.splice(0);
12
+ for (let i = 0, n = items.length; i < n; i++) {
13
+ await items[i]();
14
+ }
15
+ running = false;
16
+ }
5
17
  const onclick = (data = {}) => {
6
18
  let content, state = reactive({
7
19
  active: data.active || false,
@@ -16,13 +28,21 @@ const onclick = (data = {}) => {
16
28
  return `tooltip ${state.active ? '--active' : ''}`;
17
29
  },
18
30
  onclick: function (e) {
19
- let active = true;
20
- if (data.toggle && e.target && this.isSameNode(e.target)) {
31
+ let active = true, node = e.target;
32
+ if (data.toggle && (this.contains(node) || this.isSameNode(node))) {
21
33
  active = !state.active;
22
34
  }
35
+ frame();
23
36
  state.active = active;
24
37
  if (active) {
25
- root.queue.onclick(() => state.active = false);
38
+ queue.push(() => state.active = false);
39
+ }
40
+ if (!scheduled) {
41
+ scheduled = true;
42
+ root.queue.onclick(() => {
43
+ frame();
44
+ scheduled = false;
45
+ });
26
46
  }
27
47
  }
28
48
  }),
package/package.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "prepublishOnly": "npm run build"
23
23
  },
24
24
  "types": "build/index.d.ts",
25
- "version": "0.0.77"
25
+ "version": "0.0.79"
26
26
  }
@@ -3,7 +3,8 @@ import file from './file';
3
3
  import optional from './optional';
4
4
  import select from './select';
5
5
  import s from './switch';
6
+ import textarea from './textarea';
6
7
  import text from './text';
7
8
 
8
9
 
9
- export default { checkbox, file, optional, select, switch: s, text };
10
+ export default { checkbox, file, optional, select, switch: s, textarea, text };
@@ -4,6 +4,28 @@ import { root } from '~/components';
4
4
  import menu from './menu';
5
5
 
6
6
 
7
+ let queue: VoidFunction[] = [],
8
+ running = false,
9
+ scheduled = false;
10
+
11
+
12
+ async function frame() {
13
+ if (running) {
14
+ return;
15
+ }
16
+
17
+ running = true;
18
+
19
+ let items = queue.splice(0);
20
+
21
+ for (let i = 0, n = items.length; i < n; i++) {
22
+ await items[i]();
23
+ }
24
+
25
+ running = false;
26
+ }
27
+
28
+
7
29
  const onclick = (data: { active?: boolean, menu?: Parameters<typeof menu>[0], toggle?: boolean } = {}) => {
8
30
  let content,
9
31
  state = reactive({
@@ -21,16 +43,26 @@ const onclick = (data: { active?: boolean, menu?: Parameters<typeof menu>[0], to
21
43
  return `tooltip ${state.active ? '--active' : ''}`;
22
44
  },
23
45
  onclick: function(this: HTMLElement, e: Event) {
24
- let active = true;
46
+ let active = true,
47
+ node = e.target as Node | null;
25
48
 
26
- if (data.toggle && e.target && this.isSameNode(e.target as Node)) {
49
+ if (data.toggle && ( this.contains(node) || this.isSameNode(node) )) {
27
50
  active = !state.active;
28
51
  }
29
52
 
53
+ frame();
30
54
  state.active = active;
31
55
 
32
56
  if (active) {
33
- root.queue.onclick(() => state.active = false);
57
+ queue.push(() => state.active = false);
58
+ }
59
+
60
+ if (!scheduled) {
61
+ scheduled = true;
62
+ root.queue.onclick(() => {
63
+ frame();
64
+ scheduled = false;
65
+ });
34
66
  }
35
67
  }
36
68
  }),