@windwalker-io/unicorn-next 0.1.1 → 0.1.2
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/dist/chunks/button-radio.js +1 -1
- package/dist/chunks/field-cascade-select.js +1 -1
- package/dist/chunks/field-file-drag.js +1 -1
- package/dist/chunks/field-flatpickr.js +2 -2
- package/dist/chunks/field-flatpickr.js.map +1 -1
- package/dist/chunks/field-modal-select.js +1 -1
- package/dist/chunks/field-modal-tree.js +1 -1
- package/dist/chunks/field-multi-uploader.js +1 -1
- package/dist/chunks/field-repeatable.js +1 -1
- package/dist/chunks/field-single-image-drag.js +1 -1
- package/dist/chunks/form.js +1 -1
- package/dist/chunks/grid.js +1 -1
- package/dist/chunks/http-client.js +1 -1
- package/dist/chunks/iframe-modal.js +1 -1
- package/dist/chunks/iframe-modal.js.map +1 -1
- package/dist/chunks/keep-tab.js +1 -1
- package/dist/chunks/legacy.js +5 -3
- package/dist/chunks/legacy.js.map +1 -1
- package/dist/chunks/list-dependent.js +1 -1
- package/dist/chunks/s3-multipart-uploader.js +1 -1
- package/dist/chunks/s3-uploader.js +1 -1
- package/dist/chunks/show-on.js +3 -2
- package/dist/chunks/show-on.js.map +1 -1
- package/dist/chunks/tinymce.js +14 -14
- package/dist/chunks/tinymce.js.map +1 -1
- package/dist/chunks/unicorn.js +77 -72
- package/dist/chunks/unicorn.js.map +1 -1
- package/dist/chunks/validation.js +10 -8
- package/dist/chunks/validation.js.map +1 -1
- package/dist/index.d.ts +29 -18
- package/dist/unicorn.js +68 -68
- package/package.json +2 -1
- package/src/composable/useIframeModal.ts +3 -2
- package/src/composable/useValidation.ts +2 -2
- package/src/legacy/legacy.ts +8 -4
- package/src/module/field-flatpickr.ts +1 -1
- package/src/module/iframe-modal.ts +1 -1
- package/src/module/show-on.ts +4 -2
- package/src/module/tinymce.ts +14 -17
- package/src/module/validation.ts +15 -8
- package/src/plugin/php-adapter.ts +7 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IFrameModalModule } from '../module/iframe-modal';
|
|
2
|
+
export type { IFrameModalElement } from '../module/iframe-modal';
|
|
2
3
|
|
|
3
|
-
export async function useIframeModal(): Promise<
|
|
4
|
+
export async function useIframeModal(): Promise<IFrameModalModule> {
|
|
4
5
|
const module = await import('../module/iframe-modal');
|
|
5
6
|
|
|
6
7
|
await module.ready;
|
|
@@ -17,10 +17,10 @@ export async function useFormValidation(selector?: string | Element): Promise<an
|
|
|
17
17
|
return module;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
return
|
|
20
|
+
return useFormValidationInstance(selector);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function
|
|
23
|
+
export function useFormValidationInstance(selector: string | Element): UnicornFormValidation | null {
|
|
24
24
|
return getBoundedInstance<UnicornFormValidation>(selector, 'form.validation');
|
|
25
25
|
}
|
|
26
26
|
|
package/src/legacy/legacy.ts
CHANGED
|
@@ -2,13 +2,15 @@ import { numberFormat } from '@lyrasoft/ts-toolkit/generic';
|
|
|
2
2
|
import { sprintf, vsprintf } from 'sprintf-js';
|
|
3
3
|
import {
|
|
4
4
|
addGlobalValidator,
|
|
5
|
+
useBs5ButtonRadio,
|
|
6
|
+
useBs5KeepTab,
|
|
5
7
|
useBs5Tooltip,
|
|
6
8
|
useCheckboxesMultiSelect,
|
|
7
9
|
useFieldValidationSync,
|
|
8
10
|
useForm,
|
|
9
11
|
useFormAsync,
|
|
10
12
|
useFormValidation,
|
|
11
|
-
|
|
13
|
+
useFormValidationInstance,
|
|
12
14
|
useGrid,
|
|
13
15
|
useGridAsync,
|
|
14
16
|
useHttpClient,
|
|
@@ -39,7 +41,6 @@ import {
|
|
|
39
41
|
loadAlpine,
|
|
40
42
|
mark,
|
|
41
43
|
module,
|
|
42
|
-
simpleNotify,
|
|
43
44
|
prepareAlpine,
|
|
44
45
|
renderMessage,
|
|
45
46
|
route,
|
|
@@ -48,6 +49,7 @@ import {
|
|
|
48
49
|
serial,
|
|
49
50
|
simpleAlert,
|
|
50
51
|
simpleConfirm,
|
|
52
|
+
simpleNotify,
|
|
51
53
|
slideDown,
|
|
52
54
|
slideToggle,
|
|
53
55
|
slideUp,
|
|
@@ -97,7 +99,7 @@ export async function useLegacyMethods(app: any) {
|
|
|
97
99
|
|
|
98
100
|
app.formValidation = useFormValidation;
|
|
99
101
|
app.$validation = {
|
|
100
|
-
get:
|
|
102
|
+
get: useFormValidationInstance,
|
|
101
103
|
getField: useFieldValidationSync,
|
|
102
104
|
addGlobalValidator: addGlobalValidator,
|
|
103
105
|
import: () => useFormValidation()
|
|
@@ -173,7 +175,9 @@ function handleUI(app: any) {
|
|
|
173
175
|
app.$ui.checkboxesMultiSelect = useCheckboxesMultiSelect;
|
|
174
176
|
app.$ui.keepAlive = useKeepAlive;
|
|
175
177
|
app.$ui.bootstrap = {
|
|
176
|
-
tooltip: useBs5Tooltip
|
|
178
|
+
tooltip: useBs5Tooltip,
|
|
179
|
+
buttonRadio: useBs5ButtonRadio,
|
|
180
|
+
keepTab: useBs5KeepTab,
|
|
177
181
|
};
|
|
178
182
|
}
|
|
179
183
|
|
|
@@ -92,7 +92,7 @@ class FlatpickrElement extends HTMLElement {
|
|
|
92
92
|
|
|
93
93
|
private async handleLocale(options: Record<string, any>) {
|
|
94
94
|
if (this.locale) {
|
|
95
|
-
await useImport(
|
|
95
|
+
await useImport(`@flatpickr/l10n/${this.locale}.js`);
|
|
96
96
|
|
|
97
97
|
options.locale = this.locale.replace(/-/, '_');
|
|
98
98
|
}
|
package/src/module/show-on.ts
CHANGED
|
@@ -11,7 +11,7 @@ export class ShowOn {
|
|
|
11
11
|
input!: HTMLInputTypes;
|
|
12
12
|
conditions: Conditions = {};
|
|
13
13
|
targets = {};
|
|
14
|
-
defaultReadonly =
|
|
14
|
+
defaultReadonly: boolean | null = null;
|
|
15
15
|
initialDisplay!: string;
|
|
16
16
|
|
|
17
17
|
constructor(el: HTMLElement, conditions: Conditions) {
|
|
@@ -63,7 +63,7 @@ export class ShowOn {
|
|
|
63
63
|
}, duration + 30);
|
|
64
64
|
} else {
|
|
65
65
|
if (this.input) {
|
|
66
|
-
this.defaultReadonly
|
|
66
|
+
this.defaultReadonly ??= this.input.hasAttribute('readonly');
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
fadeOut(this.el, duration);
|
|
@@ -74,6 +74,8 @@ export class ShowOn {
|
|
|
74
74
|
if (!this.defaultReadonly) {
|
|
75
75
|
this.input.removeAttribute('readonly');
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
this.defaultReadonly = null;
|
|
77
79
|
} else {
|
|
78
80
|
this.input.setAttribute('readonly', 'readonly');
|
|
79
81
|
}
|
package/src/module/tinymce.ts
CHANGED
|
@@ -6,8 +6,7 @@ import { mergeDeep } from '../utilities';
|
|
|
6
6
|
|
|
7
7
|
const instances: Dictionary<TinymceController> = {};
|
|
8
8
|
let hooks: ((tinymce: TinyMCE) => MaybePromise<any>)[] = [];
|
|
9
|
-
|
|
10
|
-
let imported = false;
|
|
9
|
+
let imported: Promise<TinyMCE>;
|
|
11
10
|
|
|
12
11
|
declare type UploadHandlerParams = Parameters<NonNullable<EditorOptions['images_upload_handler']>>;
|
|
13
12
|
|
|
@@ -47,18 +46,16 @@ export function clearHooks() {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
async function loadTinymce(): Promise<TinyMCE> {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
imported = true;
|
|
61
|
-
return tinymce;
|
|
49
|
+
return imported ??= new Promise((resolve) => {
|
|
50
|
+
useScriptImport('@tinymce').then(() => {
|
|
51
|
+
for (const hook of hooks) {
|
|
52
|
+
hook(tinymce);
|
|
53
|
+
}
|
|
54
|
+
registerDragPlugin(tinymce).then(() => {
|
|
55
|
+
resolve(tinymce);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
const defaultOptions: Record<string, any> = {};
|
|
@@ -68,8 +65,6 @@ export class TinymceController {
|
|
|
68
65
|
options: Record<string, any> = {};
|
|
69
66
|
|
|
70
67
|
constructor(protected tinymce: TinyMCE, public element: HTMLElement, options: Record<string, any>) {
|
|
71
|
-
options.target = element;
|
|
72
|
-
|
|
73
68
|
this.options = mergeDeep(
|
|
74
69
|
{
|
|
75
70
|
unicorn: {
|
|
@@ -80,7 +75,9 @@ export class TinymceController {
|
|
|
80
75
|
this.prepareOptions(options, tinymce.majorVersion),
|
|
81
76
|
);
|
|
82
77
|
|
|
83
|
-
|
|
78
|
+
this.options.target = element;
|
|
79
|
+
|
|
80
|
+
tinymce.init(this.options).then((editor) => {
|
|
84
81
|
this.editor = editor[0];
|
|
85
82
|
});
|
|
86
83
|
}
|
package/src/module/validation.ts
CHANGED
|
@@ -402,14 +402,21 @@ export class UnicornFieldValidation {
|
|
|
402
402
|
if (this.isInputOptions) {
|
|
403
403
|
const $input = this.$input as any;
|
|
404
404
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
$input
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
405
|
+
if (
|
|
406
|
+
!($input instanceof HTMLInputElement)
|
|
407
|
+
&& !($input instanceof HTMLSelectElement)
|
|
408
|
+
&& !($input instanceof HTMLTextAreaElement)
|
|
409
|
+
) {
|
|
410
|
+
$input.validationMessage = '';
|
|
411
|
+
|
|
412
|
+
$input.setCustomValidity = (msg: string) => {
|
|
413
|
+
$input.validationMessage = String(msg);
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
$input.checkValidity = () => {
|
|
417
|
+
return this.checkInputOptionsValidity();
|
|
418
|
+
};
|
|
419
|
+
}
|
|
413
420
|
}
|
|
414
421
|
}
|
|
415
422
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { UnicornApp } from '../app';
|
|
2
2
|
import {
|
|
3
|
+
useBs5ButtonRadio, useBs5KeepTab,
|
|
4
|
+
useBs5Tooltip,
|
|
3
5
|
useFieldCascadeSelect,
|
|
4
6
|
useFieldFileDrag,
|
|
5
7
|
useFieldFlatpickr,
|
|
@@ -52,6 +54,11 @@ const methods = {
|
|
|
52
54
|
modalTree: useFieldModalTree,
|
|
53
55
|
multiUploader: useFieldMultiUploader,
|
|
54
56
|
tomSelect: useTomSelect,
|
|
57
|
+
bootstrap: {
|
|
58
|
+
tooltip: useBs5Tooltip,
|
|
59
|
+
buttonRadio: useBs5ButtonRadio,
|
|
60
|
+
keepTab: useBs5KeepTab,
|
|
61
|
+
}
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
export class UnicornPhpAdapter {
|