@webx-ui/core 0.11.0 → 0.13.0
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/components/Actions/Actions.d.ts +8 -2
- package/dist/components/FileCard/FileCard.d.ts +322 -0
- package/dist/components/FileCard/files.d.ts +22 -0
- package/dist/components/FileCard/index.d.ts +3 -0
- package/dist/components/FileCard/types.d.ts +64 -0
- package/dist/components/Icon/icons.d.ts +80 -0
- package/dist/components/ImageEditor/ImageEditor.d.ts +67 -0
- package/dist/components/ImageEditor/crop.d.ts +46 -0
- package/dist/components/ImageEditor/index.d.ts +3 -0
- package/dist/components/ImageEditor/types.d.ts +128 -0
- package/dist/components/Kanban/Kanban.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Upload/Upload.d.ts +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/composables/imageEditor.d.ts +19 -0
- package/dist/composables/useModal.d.ts +4 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6404 -5337
- package/dist/index.js.map +1 -1
- package/dist/internal/ImageEditorDialog.d.ts +128 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** A rectangle of the picture, in the pixels of the image *after* its quarter turns. */
|
|
2
|
+
export interface ImageEditorCrop {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A ratio the crop can be locked to: a number (width ÷ height), `free` for no lock, or
|
|
10
|
+
* `original` for whatever the picture itself is.
|
|
11
|
+
*/
|
|
12
|
+
export type ImageEditorRatio = number | 'free' | 'original';
|
|
13
|
+
export interface ImageEditorRatioOption {
|
|
14
|
+
value: ImageEditorRatio;
|
|
15
|
+
/** Derived from the number when it is left out — `1.7778` reads as `16:9`. */
|
|
16
|
+
label?: string;
|
|
17
|
+
}
|
|
18
|
+
/** What the editor hands over. Nothing is uploaded; this is a blob and its measurements. */
|
|
19
|
+
export interface ImageEditorResult {
|
|
20
|
+
blob: Blob;
|
|
21
|
+
/** The same bytes named, ready to be posted straight to a server. */
|
|
22
|
+
file: File;
|
|
23
|
+
/** MIME type of the blob. */
|
|
24
|
+
type: string;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
/**
|
|
28
|
+
* The crop, in the pixels of the turned picture — turn by `rotation`, mirror by the
|
|
29
|
+
* flips, then cut this out, and a server arrives at the same picture.
|
|
30
|
+
*/
|
|
31
|
+
crop: ImageEditorCrop;
|
|
32
|
+
/** Quarter turns, clockwise: 0, 90, 180 or 270. */
|
|
33
|
+
rotation: number;
|
|
34
|
+
flipX: boolean;
|
|
35
|
+
flipY: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface ImageEditorProps {
|
|
38
|
+
/** The picture: a URL, or the `File` an upload field just handed you. */
|
|
39
|
+
src: string | Blob;
|
|
40
|
+
/**
|
|
41
|
+
* Name for the file in the result. Taken from `src` when it is a URL or a `File`, and
|
|
42
|
+
* its extension is put right to match the format actually written.
|
|
43
|
+
*/
|
|
44
|
+
fileName?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Locks the crop to one ratio and takes the picker away — `1` for an avatar. The
|
|
47
|
+
* ratios offered stay if `ratios` is given as well.
|
|
48
|
+
*/
|
|
49
|
+
aspect?: number;
|
|
50
|
+
/** The ratios offered. Empty hides the picker and leaves the crop free. */
|
|
51
|
+
ratios?: (ImageEditorRatio | ImageEditorRatioOption)[];
|
|
52
|
+
/** Which of them the editor opens on. Defaults to the first. */
|
|
53
|
+
ratio?: ImageEditorRatio;
|
|
54
|
+
/** Quarter turns, left and right. */
|
|
55
|
+
rotatable?: boolean;
|
|
56
|
+
/** Mirroring, across and down. */
|
|
57
|
+
flippable?: boolean;
|
|
58
|
+
/** Offers the output size — the field that scales the cut-out down before it is written. */
|
|
59
|
+
resizable?: boolean;
|
|
60
|
+
/** Largest output, in pixels. A bigger crop is scaled down to fit inside it. */
|
|
61
|
+
maxWidth?: number;
|
|
62
|
+
maxHeight?: number;
|
|
63
|
+
/** Smallest crop, in the picture's own pixels. */
|
|
64
|
+
minSize?: number;
|
|
65
|
+
/**
|
|
66
|
+
* What to write. `auto` keeps the source's format where it is one a browser can write
|
|
67
|
+
* (JPEG, PNG, WebP) and falls back to JPEG.
|
|
68
|
+
*/
|
|
69
|
+
format?: 'auto' | 'image/jpeg' | 'image/png' | 'image/webp';
|
|
70
|
+
/** 0 to 1, for the formats that have a quality. */
|
|
71
|
+
quality?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Painted behind the picture when the format has no transparency, since transparent
|
|
74
|
+
* turns black in a JPEG.
|
|
75
|
+
*/
|
|
76
|
+
background?: string;
|
|
77
|
+
/**
|
|
78
|
+
* `crossorigin` for the `<img>`. Anonymous by default: a canvas that has drawn a
|
|
79
|
+
* picture from a host which sent no CORS header cannot be read back, so the export
|
|
80
|
+
* would fail — this way it fails at loading, where it can be seen.
|
|
81
|
+
*/
|
|
82
|
+
crossOrigin?: 'anonymous' | 'use-credentials' | '';
|
|
83
|
+
/** The editor's own Cancel and Save. Off when the panel around it has its own. */
|
|
84
|
+
footer?: boolean;
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
saveLabel?: string;
|
|
87
|
+
cancelLabel?: string;
|
|
88
|
+
resetLabel?: string;
|
|
89
|
+
rotateLeftLabel?: string;
|
|
90
|
+
rotateRightLabel?: string;
|
|
91
|
+
flipHorizontalLabel?: string;
|
|
92
|
+
flipVerticalLabel?: string;
|
|
93
|
+
/** Accessible name of the ratio picker, and of the crop box itself. */
|
|
94
|
+
ratioLabel?: string;
|
|
95
|
+
cropLabel?: string;
|
|
96
|
+
/** The output-size field. */
|
|
97
|
+
widthLabel?: string;
|
|
98
|
+
freeLabel?: string;
|
|
99
|
+
originalLabel?: string;
|
|
100
|
+
/** Shown in place of the picture when it will not load. */
|
|
101
|
+
errorText?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface ImageEditorEmits {
|
|
104
|
+
/** The picture, cut and turned. */
|
|
105
|
+
save: [result: ImageEditorResult];
|
|
106
|
+
cancel: [];
|
|
107
|
+
/** The picture loaded, at this size. */
|
|
108
|
+
load: [size: {
|
|
109
|
+
width: number;
|
|
110
|
+
height: number;
|
|
111
|
+
}];
|
|
112
|
+
/** It did not load, or could not be written. */
|
|
113
|
+
error: [error: unknown];
|
|
114
|
+
/** The crop moved or was resized, in the pixels of the turned picture. */
|
|
115
|
+
crop: [crop: ImageEditorCrop];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* What `openImageEditor` takes: the editor's own props, and the panel it arrives in.
|
|
119
|
+
*
|
|
120
|
+
* A type rather than an interface so that it can be handed to `createModal`, which asks
|
|
121
|
+
* for something a bag of props can be made of.
|
|
122
|
+
*/
|
|
123
|
+
export type ImageEditorModalProps = ImageEditorProps & {
|
|
124
|
+
/** Heading of the panel. */
|
|
125
|
+
title?: string;
|
|
126
|
+
/** Width of the panel: a number in pixels, or any CSS length. */
|
|
127
|
+
width?: number | string;
|
|
128
|
+
};
|
|
@@ -6,7 +6,7 @@ declare const _default: <T extends KanbanCard = KanbanCard>(__VLS_props: NonNull
|
|
|
6
6
|
readonly "onUpdate:collapsed"?: ((value: KanbanId[]) => any) | undefined;
|
|
7
7
|
readonly "onColumn-move"?: ((move: import('./types').KanbanColumnMove<T>) => any) | undefined;
|
|
8
8
|
readonly "onAdd-column"?: (() => any) | undefined;
|
|
9
|
-
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "
|
|
9
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onMove" | "onAdd" | "onUpdate:collapsed" | "onColumn-move" | "onAdd-column"> & ({
|
|
10
10
|
collapsed?: KanbanId[];
|
|
11
11
|
} & KanbanProps<T>) & Partial<{}>> & import('vue').PublicProps;
|
|
12
12
|
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
@@ -31,9 +31,9 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
|
|
|
31
31
|
align: import('./types').TooltipAlign;
|
|
32
32
|
offset: number;
|
|
33
33
|
teleport: boolean;
|
|
34
|
+
arrow: boolean;
|
|
34
35
|
delay: number;
|
|
35
36
|
maxWidth: number | string;
|
|
36
|
-
arrow: boolean;
|
|
37
37
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
38
38
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
39
39
|
export default _default;
|
|
@@ -54,13 +54,13 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
|
|
|
54
54
|
multiple: boolean;
|
|
55
55
|
disabled: boolean;
|
|
56
56
|
max: number;
|
|
57
|
+
removable: boolean;
|
|
57
58
|
accept: string;
|
|
58
59
|
maxSize: number;
|
|
59
60
|
buttonOnly: boolean;
|
|
60
61
|
buttonText: string;
|
|
61
62
|
hint: string;
|
|
62
63
|
gallery: boolean;
|
|
63
|
-
removable: boolean;
|
|
64
64
|
beforeAdd: (file: File) => boolean | Promise<boolean>;
|
|
65
65
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
66
66
|
input: HTMLInputElement;
|
|
@@ -34,6 +34,7 @@ export * from './Dropdown';
|
|
|
34
34
|
export * from './DropdownItem';
|
|
35
35
|
export * from './Empty';
|
|
36
36
|
export * from './EntityCard';
|
|
37
|
+
export * from './FileCard';
|
|
37
38
|
export * from './Footer';
|
|
38
39
|
export * from './Form';
|
|
39
40
|
export * from './FormItem';
|
|
@@ -41,6 +42,7 @@ export * from './Header';
|
|
|
41
42
|
export * from './Heading';
|
|
42
43
|
export * from './Icon';
|
|
43
44
|
export * from './Image';
|
|
45
|
+
export * from './ImageEditor';
|
|
44
46
|
export * from './Indicator';
|
|
45
47
|
export * from './Input';
|
|
46
48
|
export * from './InputNumber';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ImageEditorModalProps, ImageEditorResult } from '../components/ImageEditor/types';
|
|
2
|
+
/**
|
|
3
|
+
* Opens the picture in a panel and answers with what came out of it.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* const edited = await openImageEditor({ src: file.url, aspect: 16 / 9 })
|
|
7
|
+
* if (!edited) return
|
|
8
|
+
* await upload(edited.file)
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Nothing is uploaded and nothing is replaced: the answer is a blob, its measurements and
|
|
12
|
+
* the crop it was cut from, and the screen that asked decides where all that goes. Closed
|
|
13
|
+
* without saving — the ✕, escape, Cancel — it answers `undefined`, which is not an error.
|
|
14
|
+
*
|
|
15
|
+
* It is [`createModal`](/guide/modals) over `WxImageEditor` in a dialog, and worth reading
|
|
16
|
+
* as the example: one line names the component, the type of its answer and the event that
|
|
17
|
+
* carries it, and every call site is a single `await`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const openImageEditor: (props?: ImageEditorModalProps | undefined, options?: import('./useModal').ModalOptions) => import('./useModal').ModalPromise<ImageEditorResult>;
|
|
@@ -58,8 +58,11 @@ export declare function openModal<T = unknown>(component: Component, options?: M
|
|
|
58
58
|
*
|
|
59
59
|
* const product = await productBrowser({ multiple: false })
|
|
60
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* `P` is any object — an `interface` of props included, which a `Record<string, unknown>`
|
|
63
|
+
* would have turned away for want of an index signature.
|
|
61
64
|
*/
|
|
62
|
-
export declare function createModal<T = unknown, P extends
|
|
65
|
+
export declare function createModal<T = unknown, P extends object = Record<string, never>>(component: Component, defaults?: ModalOptions): (props?: P, options?: ModalOptions) => ModalPromise<T>;
|
|
63
66
|
/**
|
|
64
67
|
* The handle of the modal a component is being shown in. Outside one it answers all the
|
|
65
68
|
* same, with `isModal: false` and calls that do nothing — so a component can be written
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { useElementWidth } from './composables/useElementWidth';
|
|
|
6
6
|
export { useToast, toast, toastQueue, dismissToast, removeToast, clearToasts, type ToastApi, type ToastHandle, type ToastOptions, type ToastRecord, type ToastType, type ToastAction, } from './composables/useToast';
|
|
7
7
|
export { openModal, createModal, useModal, connectModals, modalKey, type ModalHandle, type ModalOptions, type ModalPromise, } from './composables/useModal';
|
|
8
8
|
export { confirm, type ConfirmOptions } from './composables/confirm';
|
|
9
|
+
export { openImageEditor } from './composables/imageEditor';
|
|
9
10
|
export { useResponsiveShell, shellLayoutFor, type ResponsiveShell, type ResponsiveShellOptions, type ShellLayout, } from './composables/useResponsiveShell';
|