@windwalker-io/unicorn-next 0.1.7 → 0.1.8

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 (125) hide show
  1. package/.editorconfig +18 -18
  2. package/.gulp.json +7 -7
  3. package/bin/release.mjs +47 -47
  4. package/dist/chunks/button-radio.js.map +1 -1
  5. package/dist/chunks/checkboxes-multi-select.js.map +1 -1
  6. package/dist/chunks/field-cascade-select.js.map +1 -1
  7. package/dist/chunks/field-file-drag.js.map +1 -1
  8. package/dist/chunks/field-flatpickr.js.map +1 -1
  9. package/dist/chunks/field-modal-select.js.map +1 -1
  10. package/dist/chunks/field-modal-tree.js +2 -2
  11. package/dist/chunks/field-modal-tree.js.map +1 -1
  12. package/dist/chunks/field-multi-uploader.js.map +1 -1
  13. package/dist/chunks/field-repeatable.js.map +1 -1
  14. package/dist/chunks/field-single-image-drag.js.map +1 -1
  15. package/dist/chunks/form.js.map +1 -1
  16. package/dist/chunks/grid.js.map +1 -1
  17. package/dist/chunks/http-client.js.map +1 -1
  18. package/dist/chunks/iframe-modal.js.map +1 -1
  19. package/dist/chunks/keep-tab.js.map +1 -1
  20. package/dist/chunks/legacy.js.map +1 -1
  21. package/dist/chunks/list-dependent.js.map +1 -1
  22. package/dist/chunks/s3-multipart-uploader.js +23 -2
  23. package/dist/chunks/s3-multipart-uploader.js.map +1 -1
  24. package/dist/chunks/s3-uploader.js.map +1 -1
  25. package/dist/chunks/show-on.js.map +1 -1
  26. package/dist/chunks/tinymce.js.map +1 -1
  27. package/dist/chunks/ui-bootstrap5.js.map +1 -1
  28. package/dist/chunks/unicorn.js.map +1 -1
  29. package/dist/chunks/validation.js.map +1 -1
  30. package/dist/index.d.ts +29 -13
  31. package/fusionfile.mjs +155 -155
  32. package/package.json +104 -104
  33. package/scss/bootstrap/multi-level-menu.scss +121 -121
  34. package/scss/editor.scss +116 -116
  35. package/scss/field/file-drag.scss +102 -102
  36. package/scss/field/single-image-drag.scss +88 -88
  37. package/scss/field/vue-drag-uploader.scss +160 -160
  38. package/scss/switcher.scss +156 -156
  39. package/src/app.ts +128 -128
  40. package/src/bootstrap/button-radio.ts +208 -208
  41. package/src/bootstrap/keep-tab.ts +155 -155
  42. package/src/composable/index.ts +22 -22
  43. package/src/composable/useCheckboxesMultiSelect.ts +22 -22
  44. package/src/composable/useFieldCascadeSelect.ts +9 -9
  45. package/src/composable/useFieldFileDrag.ts +9 -9
  46. package/src/composable/useFieldFlatpickr.ts +3 -3
  47. package/src/composable/useFieldModalSelect.ts +6 -6
  48. package/src/composable/useFieldModalTree.ts +3 -3
  49. package/src/composable/useFieldMultiUploader.ts +9 -9
  50. package/src/composable/useFieldRepeatable.ts +9 -9
  51. package/src/composable/useFieldSingleImageDrag.ts +9 -9
  52. package/src/composable/useForm.ts +43 -43
  53. package/src/composable/useGrid.ts +57 -57
  54. package/src/composable/useHttp.ts +9 -9
  55. package/src/composable/useIframeModal.ts +10 -10
  56. package/src/composable/useListDependent.ts +26 -26
  57. package/src/composable/useQueue.ts +13 -13
  58. package/src/composable/useS3Uploader.ts +32 -32
  59. package/src/composable/useShowOn.ts +9 -9
  60. package/src/composable/useStack.ts +13 -13
  61. package/src/composable/useTinymce.ts +29 -29
  62. package/src/composable/useTomSelect.ts +72 -72
  63. package/src/composable/useUIBootstrap5.ts +48 -48
  64. package/src/composable/useUniDirective.ts +43 -43
  65. package/src/composable/useValidation.ts +50 -50
  66. package/src/data.ts +34 -34
  67. package/src/events.ts +82 -82
  68. package/src/legacy/legacy.ts +190 -190
  69. package/src/legacy/loader.ts +125 -125
  70. package/src/module/checkboxes-multi-select.ts +54 -54
  71. package/src/module/field-cascade-select.ts +292 -292
  72. package/src/module/field-file-drag.ts +295 -295
  73. package/src/module/field-flatpickr.ts +130 -130
  74. package/src/module/field-modal-select.ts +179 -179
  75. package/src/module/field-modal-tree.ts +31 -31
  76. package/src/module/field-multi-uploader.ts +368 -368
  77. package/src/module/field-repeatable.ts +202 -202
  78. package/src/module/field-single-image-drag.ts +477 -477
  79. package/src/module/form.ts +223 -223
  80. package/src/module/grid.ts +479 -479
  81. package/src/module/http-client.ts +248 -248
  82. package/src/module/iframe-modal.ts +170 -170
  83. package/src/module/list-dependent.ts +321 -321
  84. package/src/module/s3-multipart-uploader.ts +330 -300
  85. package/src/module/s3-uploader.ts +234 -234
  86. package/src/module/show-on.ts +175 -175
  87. package/src/module/tinymce.ts +276 -276
  88. package/src/module/ui-bootstrap5.ts +116 -116
  89. package/src/module/validation.ts +1046 -1046
  90. package/src/plugin/index.ts +1 -1
  91. package/src/plugin/php-adapter.ts +72 -72
  92. package/src/polyfill/form-request-submit.ts +31 -31
  93. package/src/polyfill/index.ts +9 -9
  94. package/src/service/animate.ts +58 -58
  95. package/src/service/crypto.ts +27 -27
  96. package/src/service/dom-watcher.ts +62 -62
  97. package/src/service/dom.ts +265 -265
  98. package/src/service/helper.ts +48 -48
  99. package/src/service/index.ts +10 -10
  100. package/src/service/lang.ts +122 -122
  101. package/src/service/loader.ts +152 -152
  102. package/src/service/router.ts +118 -118
  103. package/src/service/ui.ts +525 -525
  104. package/src/service/uri.ts +106 -106
  105. package/src/types/base.ts +9 -9
  106. package/src/types/index.ts +4 -4
  107. package/src/types/modal-tree.ts +12 -12
  108. package/src/types/plugin.ts +6 -6
  109. package/src/types/shims.d.ts +18 -18
  110. package/src/types/ui.ts +6 -6
  111. package/src/unicorn.ts +79 -79
  112. package/src/utilities/arr.ts +25 -25
  113. package/src/utilities/base.ts +9 -9
  114. package/src/utilities/data.ts +48 -48
  115. package/src/utilities/index.ts +5 -5
  116. package/src/utilities/tree.ts +20 -20
  117. package/src/vue/components/ModalTree/ModalTreeApp.vue +175 -175
  118. package/src/vue/components/ModalTree/TreeItem.vue +262 -262
  119. package/src/vue/components/ModalTree/TreeModal.vue +225 -225
  120. package/tests/test.js +4 -4
  121. package/tsconfig.js.json +25 -25
  122. package/tsconfig.json +17 -17
  123. package/vite.assets.config.ts +61 -61
  124. package/vite.config.test.ts +36 -36
  125. package/vite.config.ts +112 -112
@@ -1,156 +1,156 @@
1
- /* The switch - the box around the slider */
2
- // @see https://www.w3schools.com/howto/howto_css_switch.asp
3
-
4
- $colors: 'primary', 'secondary', 'success', 'info', 'danger', 'warning', 'dark', 'light';
5
-
6
- .unicorn-switch {
7
- position: relative;
8
- display: inline-block;
9
- width: 60px;
10
- height: 34px;
11
- margin-bottom: 0;
12
-
13
- /* Hide default HTML checkbox */
14
- input {
15
- width: 0;
16
- height: 0;
17
- position: relative;
18
- left: 30px;
19
-
20
- &:focus {
21
- box-shadow: none !important;
22
- }
23
- }
24
-
25
- /* The slider */
26
- .switch-slider {
27
- position: absolute;
28
- cursor: pointer;
29
- top: 0;
30
- left: 0;
31
- right: 0;
32
- bottom: 0;
33
- -webkit-transition: .4s;
34
- transition: .4s;
35
-
36
- // BS variables
37
- background-color: var(--bs-btn-bg);
38
-
39
- &:hover {
40
- background-color: var(--bs-btn-hover-bg);
41
- }
42
-
43
- @each $color in $colors {
44
- &.btn-#{$color} {
45
- // BS variables
46
- background-color: var(--bs-btn-bg, var(--bs-#{$color}, var(--#{$color})));
47
-
48
- &:hover {
49
- background-color: var(--bs-btn-hover-bg, var(--bs-#{$color}, var(--#{$color})));
50
- }
51
- }
52
- }
53
- }
54
-
55
- input:focus + .switch-slider {
56
- box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
57
- }
58
-
59
- .switch-slider.bg-default {
60
- background-color: #ccc;
61
- }
62
-
63
- .switch-slider:before {
64
- position: absolute;
65
- content: "";
66
- height: 26px;
67
- width: 26px;
68
- left: 4px;
69
- bottom: 4px;
70
- background-color: white;
71
- -webkit-transition: .4s;
72
- transition: .25s;
73
- }
74
-
75
- input:checked + .switch-slider:before {
76
- transform: translateX(26px);
77
- }
78
-
79
- input:not(:checked) + .switch-slider {
80
- background-color: #ccc !important;
81
-
82
- &:hover {
83
- background-color: #aaa !important;
84
- }
85
- }
86
-
87
- input[disabled] + .switch-slider,
88
- input[readonly] + .switch-slider {
89
- opacity: .65;
90
- cursor: not-allowed;
91
- pointer-events: none;
92
- }
93
-
94
- /* Rounded sliders */
95
- .switch-slider.slider-round {
96
- border-radius: .25rem;
97
- }
98
-
99
- .switch-slider.slider-round:before {
100
- border-radius: .18rem;
101
- }
102
-
103
- // Circle sliders
104
- .switch-slider.slider-circle {
105
- border-radius: 50px;
106
- }
107
-
108
- .switch-slider.slider-circle:before {
109
- border-radius: 100px;
110
- }
111
-
112
- // Size
113
- &.switch-sm {
114
- width: 46px;
115
- height: 24px;
116
-
117
- .switch-slider:before {
118
- height: 18px;
119
- width: 18px;
120
- left: 3px;
121
- bottom: 3px;
122
- }
123
-
124
- input:checked + .switch-slider:before {
125
- transform: translateX(22px);
126
- }
127
-
128
- //.switch-slider.slider-round {
129
- // border-radius: .2rem;
130
- //}
131
- //
132
- //.switch-slider.slider-round:before {
133
- // border-radius: .15rem;
134
- //}
135
- }
136
-
137
- &.switch-lg {
138
- width: 100px;
139
- height: 34px;
140
-
141
- .switch-slider:before {
142
- height: 26px;
143
- width: 45px;
144
- left: 4px;
145
- bottom: 4px;
146
- }
147
-
148
- input:checked + .switch-slider:before {
149
- transform: translateX(47px);
150
- }
151
- }
152
- }
153
-
154
- .has-invalid .unicorn-switch .switch-slider {
155
- border: 1px solid #dc3545;
156
- }
1
+ /* The switch - the box around the slider */
2
+ // @see https://www.w3schools.com/howto/howto_css_switch.asp
3
+
4
+ $colors: 'primary', 'secondary', 'success', 'info', 'danger', 'warning', 'dark', 'light';
5
+
6
+ .unicorn-switch {
7
+ position: relative;
8
+ display: inline-block;
9
+ width: 60px;
10
+ height: 34px;
11
+ margin-bottom: 0;
12
+
13
+ /* Hide default HTML checkbox */
14
+ input {
15
+ width: 0;
16
+ height: 0;
17
+ position: relative;
18
+ left: 30px;
19
+
20
+ &:focus {
21
+ box-shadow: none !important;
22
+ }
23
+ }
24
+
25
+ /* The slider */
26
+ .switch-slider {
27
+ position: absolute;
28
+ cursor: pointer;
29
+ top: 0;
30
+ left: 0;
31
+ right: 0;
32
+ bottom: 0;
33
+ -webkit-transition: .4s;
34
+ transition: .4s;
35
+
36
+ // BS variables
37
+ background-color: var(--bs-btn-bg);
38
+
39
+ &:hover {
40
+ background-color: var(--bs-btn-hover-bg);
41
+ }
42
+
43
+ @each $color in $colors {
44
+ &.btn-#{$color} {
45
+ // BS variables
46
+ background-color: var(--bs-btn-bg, var(--bs-#{$color}, var(--#{$color})));
47
+
48
+ &:hover {
49
+ background-color: var(--bs-btn-hover-bg, var(--bs-#{$color}, var(--#{$color})));
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ input:focus + .switch-slider {
56
+ box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
57
+ }
58
+
59
+ .switch-slider.bg-default {
60
+ background-color: #ccc;
61
+ }
62
+
63
+ .switch-slider:before {
64
+ position: absolute;
65
+ content: "";
66
+ height: 26px;
67
+ width: 26px;
68
+ left: 4px;
69
+ bottom: 4px;
70
+ background-color: white;
71
+ -webkit-transition: .4s;
72
+ transition: .25s;
73
+ }
74
+
75
+ input:checked + .switch-slider:before {
76
+ transform: translateX(26px);
77
+ }
78
+
79
+ input:not(:checked) + .switch-slider {
80
+ background-color: #ccc !important;
81
+
82
+ &:hover {
83
+ background-color: #aaa !important;
84
+ }
85
+ }
86
+
87
+ input[disabled] + .switch-slider,
88
+ input[readonly] + .switch-slider {
89
+ opacity: .65;
90
+ cursor: not-allowed;
91
+ pointer-events: none;
92
+ }
93
+
94
+ /* Rounded sliders */
95
+ .switch-slider.slider-round {
96
+ border-radius: .25rem;
97
+ }
98
+
99
+ .switch-slider.slider-round:before {
100
+ border-radius: .18rem;
101
+ }
102
+
103
+ // Circle sliders
104
+ .switch-slider.slider-circle {
105
+ border-radius: 50px;
106
+ }
107
+
108
+ .switch-slider.slider-circle:before {
109
+ border-radius: 100px;
110
+ }
111
+
112
+ // Size
113
+ &.switch-sm {
114
+ width: 46px;
115
+ height: 24px;
116
+
117
+ .switch-slider:before {
118
+ height: 18px;
119
+ width: 18px;
120
+ left: 3px;
121
+ bottom: 3px;
122
+ }
123
+
124
+ input:checked + .switch-slider:before {
125
+ transform: translateX(22px);
126
+ }
127
+
128
+ //.switch-slider.slider-round {
129
+ // border-radius: .2rem;
130
+ //}
131
+ //
132
+ //.switch-slider.slider-round:before {
133
+ // border-radius: .15rem;
134
+ //}
135
+ }
136
+
137
+ &.switch-lg {
138
+ width: 100px;
139
+ height: 34px;
140
+
141
+ .switch-slider:before {
142
+ height: 26px;
143
+ width: 45px;
144
+ left: 4px;
145
+ bottom: 4px;
146
+ }
147
+
148
+ input:checked + .switch-slider:before {
149
+ transform: translateX(47px);
150
+ }
151
+ }
152
+ }
153
+
154
+ .has-invalid .unicorn-switch .switch-slider {
155
+ border: 1px solid #dc3545;
156
+ }
package/src/app.ts CHANGED
@@ -1,128 +1,128 @@
1
-
2
- import { Mixin } from 'ts-mixer';
3
- import { data } from './data';
4
- import { EventAwareInterface, EventMixin } from './events';
5
- import { domready } from './service';
6
- import { Constructor, UnicornPlugin } from './types';
7
-
8
- export type InjectionKey<T = any> = string | symbol | Constructor<T>;
9
-
10
- export interface UnicornApp extends EventAwareInterface {}
11
-
12
- export class UnicornApp extends Mixin(EventMixin) implements EventAwareInterface {
13
- registry = new Map();
14
- plugins = new Map();
15
- // _listeners = {};
16
- waits: Promise<any>[] = [];
17
- options: Record<string, any>;
18
- defaultOptions: Record<string, any> = {};
19
- domready = domready;
20
- data = data;
21
-
22
- constructor(options = {}) {
23
- super();
24
- this.options = Object.assign({}, this.defaultOptions, options);
25
-
26
- // Wait dom ready
27
- if (typeof document !== 'undefined') {
28
- this.wait((resolve: Function) => {
29
- document.addEventListener('DOMContentLoaded', () => resolve());
30
- });
31
-
32
- // Ready
33
- document.addEventListener('DOMContentLoaded', () => {
34
- this.completed().then(() => this.trigger('loaded'));
35
- });
36
- }
37
- }
38
-
39
- use(plugin: UnicornPlugin, options: Record<string, any> = {}) {
40
- if (Array.isArray(plugin)) {
41
- plugin.forEach(p => this.use(p));
42
- return this;
43
- }
44
-
45
- // if (plugin.is === undefined) {
46
- // throw new Error(`Plugin: ${plugin.name} must instance of : ${Plugin.name}`);
47
- // }
48
-
49
- plugin?.install?.(this, options);
50
-
51
- this.trigger('plugin.installed', plugin);
52
-
53
- this.plugins.set(plugin, plugin);
54
-
55
- return this;
56
- }
57
-
58
- detach(plugin: any) {
59
- if (plugin.uninstall) {
60
- plugin.uninstall(this);
61
- }
62
-
63
- this.trigger('plugin.uninstalled', plugin);
64
-
65
- return this;
66
- }
67
-
68
- inject<T>(id: InjectionKey<T>): T;
69
- inject<T>(id: InjectionKey<T>, def: T): T;
70
- inject<T>(id: InjectionKey<T>, def?: T): T;
71
- inject<T>(id: InjectionKey<T>, def?: T): T | undefined {
72
- if (!typeof this.registry.has(id)) {
73
- if (def !== undefined) {
74
- return def;
75
- }
76
-
77
- throw new Error(`Injectable: ${(id as any).name} not found.`);
78
- }
79
-
80
- return this.registry.get(id);
81
- }
82
-
83
- provide<T>(id: InjectionKey<T>, value: any) {
84
- this.registry.set(id, value);
85
-
86
- return this;
87
- }
88
-
89
- // trigger(event, ...args) {
90
- // return this.tap(super.trigger(event, ...args), () => {
91
- // if (this.data('windwalker.debug')) {
92
- // console.debug(`[Unicorn Event] ${event}`, args, this.listeners(event));
93
- // }
94
- // });
95
- // }
96
-
97
- wait(callback: Function): Promise<any> {
98
- const p = new Promise((resolve, reject) => {
99
- const promise = callback(resolve, reject);
100
-
101
- if (promise && 'then' in promise) {
102
- promise.then(resolve).catch(reject);
103
- }
104
- });
105
-
106
- this.waits.push(p);
107
-
108
- return p;
109
- }
110
-
111
- completed(): Promise<any[]> {
112
- const promise = Promise.all(this.waits);
113
-
114
- this.waits = [];
115
-
116
- return promise;
117
- }
118
-
119
- macro(name: string, prop: any) {
120
- if ((this as any)[name]) {
121
- throw new Error(`Macro: ${name} already exists.`);
122
- }
123
-
124
- (this as any)[name] = prop;
125
-
126
- return this;
127
- }
128
- }
1
+
2
+ import { Mixin } from 'ts-mixer';
3
+ import { data } from './data';
4
+ import { EventAwareInterface, EventMixin } from './events';
5
+ import { domready } from './service';
6
+ import { Constructor, UnicornPlugin } from './types';
7
+
8
+ export type InjectionKey<T = any> = string | symbol | Constructor<T>;
9
+
10
+ export interface UnicornApp extends EventAwareInterface {}
11
+
12
+ export class UnicornApp extends Mixin(EventMixin) implements EventAwareInterface {
13
+ registry = new Map();
14
+ plugins = new Map();
15
+ // _listeners = {};
16
+ waits: Promise<any>[] = [];
17
+ options: Record<string, any>;
18
+ defaultOptions: Record<string, any> = {};
19
+ domready = domready;
20
+ data = data;
21
+
22
+ constructor(options = {}) {
23
+ super();
24
+ this.options = Object.assign({}, this.defaultOptions, options);
25
+
26
+ // Wait dom ready
27
+ if (typeof document !== 'undefined') {
28
+ this.wait((resolve: Function) => {
29
+ document.addEventListener('DOMContentLoaded', () => resolve());
30
+ });
31
+
32
+ // Ready
33
+ document.addEventListener('DOMContentLoaded', () => {
34
+ this.completed().then(() => this.trigger('loaded'));
35
+ });
36
+ }
37
+ }
38
+
39
+ use(plugin: UnicornPlugin, options: Record<string, any> = {}) {
40
+ if (Array.isArray(plugin)) {
41
+ plugin.forEach(p => this.use(p));
42
+ return this;
43
+ }
44
+
45
+ // if (plugin.is === undefined) {
46
+ // throw new Error(`Plugin: ${plugin.name} must instance of : ${Plugin.name}`);
47
+ // }
48
+
49
+ plugin?.install?.(this, options);
50
+
51
+ this.trigger('plugin.installed', plugin);
52
+
53
+ this.plugins.set(plugin, plugin);
54
+
55
+ return this;
56
+ }
57
+
58
+ detach(plugin: any) {
59
+ if (plugin.uninstall) {
60
+ plugin.uninstall(this);
61
+ }
62
+
63
+ this.trigger('plugin.uninstalled', plugin);
64
+
65
+ return this;
66
+ }
67
+
68
+ inject<T>(id: InjectionKey<T>): T;
69
+ inject<T>(id: InjectionKey<T>, def: T): T;
70
+ inject<T>(id: InjectionKey<T>, def?: T): T;
71
+ inject<T>(id: InjectionKey<T>, def?: T): T | undefined {
72
+ if (!typeof this.registry.has(id)) {
73
+ if (def !== undefined) {
74
+ return def;
75
+ }
76
+
77
+ throw new Error(`Injectable: ${(id as any).name} not found.`);
78
+ }
79
+
80
+ return this.registry.get(id);
81
+ }
82
+
83
+ provide<T>(id: InjectionKey<T>, value: any) {
84
+ this.registry.set(id, value);
85
+
86
+ return this;
87
+ }
88
+
89
+ // trigger(event, ...args) {
90
+ // return this.tap(super.trigger(event, ...args), () => {
91
+ // if (this.data('windwalker.debug')) {
92
+ // console.debug(`[Unicorn Event] ${event}`, args, this.listeners(event));
93
+ // }
94
+ // });
95
+ // }
96
+
97
+ wait(callback: Function): Promise<any> {
98
+ const p = new Promise((resolve, reject) => {
99
+ const promise = callback(resolve, reject);
100
+
101
+ if (promise && 'then' in promise) {
102
+ promise.then(resolve).catch(reject);
103
+ }
104
+ });
105
+
106
+ this.waits.push(p);
107
+
108
+ return p;
109
+ }
110
+
111
+ completed(): Promise<any[]> {
112
+ const promise = Promise.all(this.waits);
113
+
114
+ this.waits = [];
115
+
116
+ return promise;
117
+ }
118
+
119
+ macro(name: string, prop: any) {
120
+ if ((this as any)[name]) {
121
+ throw new Error(`Macro: ${name} already exists.`);
122
+ }
123
+
124
+ (this as any)[name] = prop;
125
+
126
+ return this;
127
+ }
128
+ }