@windwalker-io/unicorn-next 0.1.18 → 0.1.21

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.
Files changed (108) hide show
  1. package/dist/chunks/_arrayPush.js +325 -108
  2. package/dist/chunks/_arrayPush.js.map +1 -1
  3. package/dist/chunks/_baseRest.js +155 -60
  4. package/dist/chunks/_baseRest.js.map +1 -1
  5. package/dist/chunks/_baseUnary.js +463 -0
  6. package/dist/chunks/_baseUnary.js.map +1 -0
  7. package/dist/chunks/_getPrototype.js +292 -100
  8. package/dist/chunks/_getPrototype.js.map +1 -1
  9. package/dist/chunks/alert-adapter.js +29 -0
  10. package/dist/chunks/alert-adapter.js.map +1 -0
  11. package/dist/chunks/alert.js +21 -0
  12. package/dist/chunks/alert.js.map +1 -0
  13. package/dist/chunks/arr.js +24 -0
  14. package/dist/chunks/arr.js.map +1 -0
  15. package/dist/chunks/button-radio.js +127 -145
  16. package/dist/chunks/button-radio.js.map +1 -1
  17. package/dist/chunks/checkboxes-multi-select.js +44 -43
  18. package/dist/chunks/checkboxes-multi-select.js.map +1 -1
  19. package/dist/chunks/chunk.js +24 -0
  20. package/dist/chunks/cloneDeep.js +679 -212
  21. package/dist/chunks/cloneDeep.js.map +1 -1
  22. package/dist/chunks/cropper.min.js +6 -5
  23. package/dist/chunks/cropper.min.js.map +1 -1
  24. package/dist/chunks/crypto.js +26 -0
  25. package/dist/chunks/crypto.js.map +1 -0
  26. package/dist/chunks/data.js +49 -0
  27. package/dist/chunks/data.js.map +1 -0
  28. package/dist/chunks/dom.js +128 -0
  29. package/dist/chunks/dom.js.map +1 -0
  30. package/dist/chunks/events.js +270 -0
  31. package/dist/chunks/events.js.map +1 -0
  32. package/dist/chunks/field-cascade-select.js +207 -250
  33. package/dist/chunks/field-cascade-select.js.map +1 -1
  34. package/dist/chunks/field-file-drag.js +175 -209
  35. package/dist/chunks/field-file-drag.js.map +1 -1
  36. package/dist/chunks/field-flatpickr.js +94 -898
  37. package/dist/chunks/field-flatpickr.js.map +1 -1
  38. package/dist/chunks/field-modal-select.js +728 -467
  39. package/dist/chunks/field-modal-select.js.map +1 -1
  40. package/dist/chunks/field-modal-tree.js +771 -766
  41. package/dist/chunks/field-modal-tree.js.map +1 -1
  42. package/dist/chunks/field-multi-uploader.js +249 -256
  43. package/dist/chunks/field-multi-uploader.js.map +1 -1
  44. package/dist/chunks/field-repeatable.js +111 -127
  45. package/dist/chunks/field-repeatable.js.map +1 -1
  46. package/dist/chunks/field-single-image-drag.js +286 -338
  47. package/dist/chunks/field-single-image-drag.js.map +1 -1
  48. package/dist/chunks/form.js +146 -159
  49. package/dist/chunks/form.js.map +1 -1
  50. package/dist/chunks/grid.js +349 -418
  51. package/dist/chunks/grid.js.map +1 -1
  52. package/dist/chunks/helper.js +39 -0
  53. package/dist/chunks/helper.js.map +1 -0
  54. package/dist/chunks/http-client.js +221 -211
  55. package/dist/chunks/http-client.js.map +1 -1
  56. package/dist/chunks/iframe-modal.js +95 -115
  57. package/dist/chunks/iframe-modal.js.map +1 -1
  58. package/dist/chunks/keep-tab.js +92 -101
  59. package/dist/chunks/keep-tab.js.map +1 -1
  60. package/dist/chunks/lang.js +250 -0
  61. package/dist/chunks/lang.js.map +1 -0
  62. package/dist/chunks/legacy.js +197 -201
  63. package/dist/chunks/legacy.js.map +1 -1
  64. package/dist/chunks/list-dependent.js +195 -228
  65. package/dist/chunks/list-dependent.js.map +1 -1
  66. package/dist/chunks/loader.js +106 -0
  67. package/dist/chunks/loader.js.map +1 -0
  68. package/dist/chunks/monthSelect.js +251 -0
  69. package/dist/chunks/monthSelect.js.map +1 -0
  70. package/dist/chunks/router.js +111 -0
  71. package/dist/chunks/router.js.map +1 -0
  72. package/dist/chunks/s3-multipart-uploader.js +183 -210
  73. package/dist/chunks/s3-multipart-uploader.js.map +1 -1
  74. package/dist/chunks/s3-uploader.js +106 -128
  75. package/dist/chunks/s3-uploader.js.map +1 -1
  76. package/dist/chunks/show-on.js +358 -205
  77. package/dist/chunks/show-on.js.map +1 -1
  78. package/dist/chunks/timing.js +10 -0
  79. package/dist/chunks/timing.js.map +1 -0
  80. package/dist/chunks/tinymce.js +153 -203
  81. package/dist/chunks/tinymce.js.map +1 -1
  82. package/dist/chunks/ui-bootstrap5.js +58 -72
  83. package/dist/chunks/ui-bootstrap5.js.map +1 -1
  84. package/dist/chunks/ui.js +320 -0
  85. package/dist/chunks/ui.js.map +1 -0
  86. package/dist/chunks/unicorn.js.map +1 -1
  87. package/dist/chunks/useQueue.js +111 -0
  88. package/dist/chunks/useQueue.js.map +1 -0
  89. package/dist/chunks/useStack.js +76 -0
  90. package/dist/chunks/useStack.js.map +1 -0
  91. package/dist/chunks/validation.js +761 -853
  92. package/dist/chunks/validation.js.map +1 -1
  93. package/dist/editor.css +1 -1
  94. package/dist/index.d.ts +27 -15
  95. package/dist/multi-level-menu.css +1 -1
  96. package/dist/switcher.css +1 -1
  97. package/dist/unicorn.js +805 -130
  98. package/dist/unicorn.js.map +1 -1
  99. package/package.json +3 -3
  100. package/src/composable/useBsModalAlert.ts +92 -12
  101. package/src/composable/useHttp.ts +13 -1
  102. package/src/module/s3-uploader.ts +1 -1
  103. package/src/service/ui.ts +31 -15
  104. package/vite.config.ts +5 -1
  105. package/dist/chunks/_commonjsHelpers.js +0 -7
  106. package/dist/chunks/index.js +0 -314
  107. package/dist/chunks/isArguments.js +0 -146
  108. package/dist/chunks/unicorn.js +0 -2580
@@ -0,0 +1,111 @@
1
+ //#region ../../../../node_modules/@lyrasoft/ts-toolkit/src/generic/queue.ts
2
+ var TaskQueue = class {
3
+ items = [];
4
+ currentRunning = 0;
5
+ running = false;
6
+ observers = [];
7
+ constructor(maxRunning = 1) {
8
+ this.maxRunning = maxRunning;
9
+ }
10
+ push(callback) {
11
+ const p = new Promise((resolve, reject) => {
12
+ this.items.push(() => {
13
+ return Promise.resolve(callback()).then(resolve).catch(reject);
14
+ });
15
+ });
16
+ this.run();
17
+ return p;
18
+ }
19
+ run() {
20
+ if (!this.running) this.running = true;
21
+ this.pop();
22
+ }
23
+ async pop() {
24
+ const callback = this.items.shift();
25
+ if (!callback) {
26
+ this.running = false;
27
+ return Promise.resolve();
28
+ }
29
+ if (this.currentRunning >= this.maxRunning) {
30
+ this.items.unshift(callback);
31
+ return Promise.resolve();
32
+ }
33
+ this.currentRunning++;
34
+ this.notice();
35
+ try {
36
+ return await callback();
37
+ } catch (e) {
38
+ throw e;
39
+ } finally {
40
+ this.endPop();
41
+ }
42
+ }
43
+ endPop() {
44
+ this.currentRunning--;
45
+ this.notice();
46
+ this.pop();
47
+ }
48
+ clear() {
49
+ this.items = [];
50
+ this.notice();
51
+ return this;
52
+ }
53
+ isEmpty() {
54
+ return this.items.length === 0;
55
+ }
56
+ get length() {
57
+ return this.items.length;
58
+ }
59
+ peek() {
60
+ return this.items;
61
+ }
62
+ observe(handler, options = {}) {
63
+ this.observers.push({
64
+ handler,
65
+ once: options.once || false
66
+ });
67
+ return () => {
68
+ this.off(handler);
69
+ };
70
+ }
71
+ once(handler, options = {}) {
72
+ options.once = true;
73
+ return this.observe(handler, options);
74
+ }
75
+ onEnd(callback, options = {}) {
76
+ return this.observe((queue, length, running) => {
77
+ if (length === 0 && running === 0) callback(queue, length, running);
78
+ }, options);
79
+ }
80
+ notice() {
81
+ this.observers.forEach((observer) => {
82
+ observer.handler(this, this.length, this.currentRunning);
83
+ });
84
+ this.observers = this.observers.filter((observer) => !observer.once);
85
+ return this;
86
+ }
87
+ off(callback) {
88
+ if (callback == null) {
89
+ this.observers = [];
90
+ return this;
91
+ }
92
+ this.observers = this.observers.filter((observer) => observer.handler !== callback);
93
+ return this;
94
+ }
95
+ };
96
+ function queue(maxRunning = 1) {
97
+ return new TaskQueue(maxRunning);
98
+ }
99
+ //#endregion
100
+ //#region src/composable/useQueue.ts
101
+ var queues = {};
102
+ function useQueue(name = "default", maxRunning = 1) {
103
+ return queues[name] ??= createQueue(maxRunning);
104
+ }
105
+ function createQueue(maxRunning = 1) {
106
+ return queue(maxRunning);
107
+ }
108
+ //#endregion
109
+ export { useQueue as n, createQueue as t };
110
+
111
+ //# sourceMappingURL=useQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQueue.js","names":[],"sources":["../../../../../../node_modules/@lyrasoft/ts-toolkit/src/generic/queue.ts","../../src/composable/useQueue.ts"],"sourcesContent":["export class TaskQueue {\n items: (() => Promise<any>)[] = [];\n\n currentRunning = 0;\n\n running = false;\n\n observers: {\n handler: Function;\n once: boolean;\n }[] = [];\n\n constructor(public maxRunning = 1) {\n //\n }\n\n push<T extends ((...args: any[]) => any)>(callback: T): Promise<Awaited<ReturnType<T>>> {\n const p = new Promise<Awaited<ReturnType<T>>>((resolve, reject) => {\n this.items.push(() => {\n return Promise.resolve(callback()).then(resolve).catch(reject);\n });\n });\n\n this.run();\n\n return p;\n }\n\n run(): void {\n if (!this.running) {\n this.running = true;\n }\n\n this.pop();\n }\n\n async pop() {\n const callback = this.items.shift();\n\n // If empty, stop running.\n if (!callback) {\n this.running = false;\n return Promise.resolve();\n }\n\n // If current running full, set back to queue and leave.\n if (this.currentRunning >= this.maxRunning) {\n this.items.unshift(callback);\n return Promise.resolve();\n }\n\n this.currentRunning++;\n\n this.notice();\n\n try {\n return await callback();\n } catch (e) {\n throw e;\n } finally {\n this.endPop();\n }\n }\n\n endPop() {\n this.currentRunning--;\n this.notice();\n this.pop();\n }\n\n clear() {\n this.items = [];\n\n this.notice();\n\n return this;\n }\n\n isEmpty(): boolean {\n return this.items.length === 0;\n }\n\n get length(): number {\n return this.items.length;\n }\n\n peek() {\n return this.items;\n }\n\n observe(handler: ObserverFunction, options: { once?: boolean } = {}): () => void {\n this.observers.push({\n handler,\n once: options.once || false,\n });\n\n return () => {\n this.off(handler);\n };\n }\n\n once(handler: ObserverFunction, options: { once?: boolean } = {}): () => void {\n options.once = true;\n\n return this.observe(handler, options);\n }\n\n onEnd(callback: ObserverFunction, options: { once?: boolean } = {}) {\n return this.observe((queue, length, running) => {\n if (length === 0 && running === 0) {\n callback(queue, length, running);\n }\n }, options);\n }\n\n notice() {\n this.observers.forEach((observer) => {\n observer.handler(this, this.length, this.currentRunning);\n });\n\n this.observers = this.observers.filter((observer) => !observer.once);\n\n return this;\n }\n\n off(callback?: Function) {\n if (callback == null) {\n this.observers = [];\n return this;\n }\n\n this.observers = this.observers.filter((observer) => observer.handler !== callback);\n return this;\n }\n}\n\ndeclare type ObserverFunction = (queue: TaskQueue, length: number, running: number) => void\n\nexport function queue(maxRunning: number = 1) {\n return new TaskQueue(maxRunning);\n}\n","import { Dictionary } from '../types';\nimport { TaskQueue, queue } from '@lyrasoft/ts-toolkit/generic';\n\nconst queues: Dictionary<TaskQueue> = {};\n\nexport function useQueue(name: string = 'default', maxRunning = 1): TaskQueue {\n return queues[name] ??= createQueue(maxRunning);\n}\n\nexport function createQueue(maxRunning = 1): TaskQueue {\n return queue(maxRunning);\n}\n\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAa,YAAb,MAAuB;CACrB,QAAgC,EAAE;CAElC,iBAAiB;CAEjB,UAAU;CAEV,YAGM,EAAE;CAER,YAAY,aAAoB,GAAG;AAAhB,OAAA,aAAA;;CAInB,KAA0C,UAA8C;EACtF,MAAM,IAAI,IAAI,SAAiC,SAAS,WAAW;AACjE,QAAK,MAAM,WAAW;AACpB,WAAO,QAAQ,QAAQ,UAAU,CAAC,CAAC,KAAK,QAAQ,CAAC,MAAM,OAAO;KAC9D;IACF;AAEF,OAAK,KAAK;AAEV,SAAO;;CAGT,MAAY;AACV,MAAI,CAAC,KAAK,QACR,MAAK,UAAU;AAGjB,OAAK,KAAK;;CAGZ,MAAM,MAAM;EACV,MAAM,WAAW,KAAK,MAAM,OAAO;AAGnC,MAAI,CAAC,UAAU;AACb,QAAK,UAAU;AACf,UAAO,QAAQ,SAAS;;AAI1B,MAAI,KAAK,kBAAkB,KAAK,YAAY;AAC1C,QAAK,MAAM,QAAQ,SAAS;AAC5B,UAAO,QAAQ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OAAe,WAAW,aAAa,GAAc;AAC5E,QAAO,OAAO,UAAU,YAAY,WAAW;;AAGjD,SAAgB,YAAY,aAAa,GAAc;AACrD,QAAO,MAAM,WAAW"}
@@ -0,0 +1,76 @@
1
+ //#region ../../../../node_modules/@lyrasoft/ts-toolkit/src/generic/stack.ts
2
+ var Stack = class {
3
+ observers = [];
4
+ constructor(store = []) {
5
+ this.store = store;
6
+ }
7
+ push(value) {
8
+ const r = this.store.push(value ?? true);
9
+ this.notice();
10
+ return r;
11
+ }
12
+ pop() {
13
+ const r = this.store.pop();
14
+ this.notice();
15
+ return r;
16
+ }
17
+ clear() {
18
+ this.store = [];
19
+ this.notice();
20
+ return this;
21
+ }
22
+ isEmpty() {
23
+ return this.store.length === 0;
24
+ }
25
+ get length() {
26
+ return this.store.length;
27
+ }
28
+ peek() {
29
+ return this.store;
30
+ }
31
+ observe(handler) {
32
+ this.observers.push({
33
+ handler,
34
+ once: false
35
+ });
36
+ return () => {
37
+ this.off(handler);
38
+ };
39
+ }
40
+ once(handler) {
41
+ this.observers.push({
42
+ handler,
43
+ once: true
44
+ });
45
+ return () => {
46
+ this.off(handler);
47
+ };
48
+ }
49
+ notice() {
50
+ this.observers.forEach((observer) => {
51
+ observer.handler(this, this.length);
52
+ });
53
+ this.observers = this.observers.filter((observer) => observer.once !== true);
54
+ return this;
55
+ }
56
+ off(callback) {
57
+ this.observers = this.observers.filter((observer) => observer.handler !== callback);
58
+ return this;
59
+ }
60
+ };
61
+ function stack(store = []) {
62
+ return new Stack(store);
63
+ }
64
+ //#endregion
65
+ //#region src/composable/useStack.ts
66
+ var stacks = {};
67
+ function useStack(name = "default", store = []) {
68
+ return stacks[name] ??= createStack(store);
69
+ }
70
+ function createStack(store = []) {
71
+ return stack(store);
72
+ }
73
+ //#endregion
74
+ export { useStack as n, createStack as t };
75
+
76
+ //# sourceMappingURL=useStack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStack.js","names":[],"sources":["../../../../../../node_modules/@lyrasoft/ts-toolkit/src/generic/stack.ts","../../src/composable/useStack.ts"],"sourcesContent":["declare type StackHandler<T> = (stack: Stack<T>, length: number) => void;\n\ndeclare type StackValue<V> = V | true;\n\nexport class Stack<T = any> {\n observers: { handler: StackHandler<T>, once: boolean }[] = [];\n\n constructor(protected store: StackValue<T>[] = []) {\n //\n }\n\n push(value?: T): number {\n const r = this.store.push(value ?? true);\n\n this.notice();\n\n return r;\n }\n\n pop(): T | true | undefined {\n const r = this.store.pop();\n\n this.notice();\n\n return r;\n }\n\n clear(): this {\n this.store = [];\n\n this.notice();\n\n return this;\n }\n\n isEmpty(): boolean {\n return this.store.length === 0;\n }\n\n get length() {\n return this.store.length;\n }\n\n peek(): StackValue<T>[] {\n return this.store;\n }\n\n observe(handler: (stack: Stack, length: number) => void): () => void {\n this.observers.push({\n handler,\n once: false\n });\n\n return () => {\n this.off(handler);\n };\n }\n\n once(handler: StackHandler<T>): () => void {\n this.observers.push({\n handler,\n once: true\n });\n\n return () => {\n this.off(handler);\n };\n }\n\n notice(): this {\n this.observers.forEach((observer) => {\n observer.handler(this, this.length);\n });\n\n this.observers = this.observers.filter((observer) => observer.once !== true);\n\n return this;\n }\n\n off(callback?: StackHandler<T>): this {\n this.observers = this.observers.filter((observer) => observer.handler !== callback);\n return this;\n }\n}\n\nexport function stack<T = any>(store: any[] = []) {\n return new Stack<T>(store);\n}\n","\nimport { Dictionary } from '../types';\nimport { Stack, stack } from '@lyrasoft/ts-toolkit/generic';\n\nconst stacks: Dictionary<Stack> = {};\n\nexport function useStack<T = any>(name: string = 'default', store: any[] = []): Stack<T> {\n return stacks[name] ??= createStack<T>(store);\n}\n\nexport function createStack<T = any>(store: any[] = []): Stack<T> {\n return stack<T>(store);\n}\n"],"x_google_ignoreList":[0],"mappings":";AAIA,IAAa,QAAb,MAA4B;CAC1B,YAA2D,EAAE;CAE7D,YAAY,QAAmC,EAAE,EAAE;AAA7B,OAAA,QAAA;;CAItB,KAAK,OAAmB;EACtB,MA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