@webx-ui/core 0.7.0 → 0.9.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/Affix/Affix.d.ts +37 -0
- package/dist/components/Affix/index.d.ts +2 -0
- package/dist/components/Affix/types.d.ts +14 -0
- package/dist/components/Avatar/Avatar.d.ts +31 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/types.d.ts +30 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +8 -0
- package/dist/components/AvatarGroup/index.d.ts +2 -0
- package/dist/components/AvatarGroup/types.d.ts +12 -0
- package/dist/components/Backtop/Backtop.d.ts +31 -0
- package/dist/components/Backtop/index.d.ts +2 -0
- package/dist/components/Backtop/types.d.ts +19 -0
- package/dist/components/Cascader/Cascader.d.ts +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/dist/components/Container/Container.d.ts +1 -0
- package/dist/components/Container/types.d.ts +10 -0
- package/dist/components/Descriptions/Descriptions.d.ts +33 -0
- package/dist/components/Descriptions/context.d.ts +5 -0
- package/dist/components/Descriptions/index.d.ts +2 -0
- package/dist/components/Descriptions/types.d.ts +30 -0
- package/dist/components/DescriptionsItem/DescriptionsItem.d.ts +25 -0
- package/dist/components/DescriptionsItem/index.d.ts +1 -0
- package/dist/components/Empty/Empty.d.ts +38 -0
- package/dist/components/Empty/index.d.ts +2 -0
- package/dist/components/Empty/types.d.ts +20 -0
- package/dist/components/EntityCard/EntityCard.d.ts +1 -1
- package/dist/components/Form/Form.d.ts +1 -1
- package/dist/components/Image/Image.d.ts +43 -0
- package/dist/components/Image/index.d.ts +2 -0
- package/dist/components/Image/types.d.ts +26 -0
- package/dist/components/Indicator/Indicator.d.ts +1 -1
- package/dist/components/InputNumber/InputNumber.d.ts +2 -2
- package/dist/components/ListDetail/ListDetail.d.ts +73 -0
- package/dist/components/ListDetail/index.d.ts +2 -0
- package/dist/components/ListDetail/types.d.ts +19 -0
- package/dist/components/Loading/Loading.d.ts +34 -0
- package/dist/components/Loading/index.d.ts +2 -0
- package/dist/components/Loading/types.d.ts +25 -0
- package/dist/components/Menu/Menu.d.ts +8 -2
- package/dist/components/Menu/types.d.ts +10 -0
- package/dist/components/Popconfirm/Popconfirm.d.ts +69 -0
- package/dist/components/Popconfirm/index.d.ts +2 -0
- package/dist/components/Popconfirm/types.d.ts +33 -0
- package/dist/components/Progress/Progress.d.ts +41 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/Progress/types.d.ts +26 -0
- package/dist/components/Rate/Rate.d.ts +1 -1
- package/dist/components/Result/Result.d.ts +38 -0
- package/dist/components/Result/index.d.ts +2 -0
- package/dist/components/Result/types.d.ts +15 -0
- package/dist/components/Segmented/Segmented.d.ts +44 -0
- package/dist/components/Segmented/index.d.ts +2 -0
- package/dist/components/Segmented/types.d.ts +23 -0
- package/dist/components/SelectionArea/SelectionArea.d.ts +48 -0
- package/dist/components/SelectionArea/directive.d.ts +19 -0
- package/dist/components/SelectionArea/index.d.ts +3 -0
- package/dist/components/SelectionArea/types.d.ts +26 -0
- package/dist/components/Skeleton/Skeleton.d.ts +33 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Skeleton/types.d.ts +31 -0
- package/dist/components/SkeletonItem/SkeletonItem.d.ts +8 -0
- package/dist/components/SkeletonItem/index.d.ts +1 -0
- package/dist/components/Slider/Slider.d.ts +1 -1
- package/dist/components/SortableList/SortableList.d.ts +53 -0
- package/dist/components/SortableList/index.d.ts +2 -0
- package/dist/components/SortableList/types.d.ts +38 -0
- package/dist/components/Step/Step.d.ts +38 -0
- package/dist/components/Step/index.d.ts +1 -0
- package/dist/components/Steps/Steps.d.ts +31 -0
- package/dist/components/Steps/context.d.ts +5 -0
- package/dist/components/Steps/index.d.ts +2 -0
- package/dist/components/Steps/types.d.ts +44 -0
- package/dist/components/Table/types.d.ts +4 -3
- package/dist/components/Textarea/Textarea.d.ts +1 -1
- package/dist/components/Toaster/Toaster.d.ts +9 -0
- package/dist/components/Toaster/index.d.ts +2 -0
- package/dist/components/Toaster/types.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.d.ts +44 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/types.d.ts +25 -0
- package/dist/components/Upload/Upload.d.ts +74 -0
- package/dist/components/Upload/index.d.ts +2 -0
- package/dist/components/Upload/types.d.ts +54 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/composables/confirm.d.ts +23 -0
- package/dist/composables/useControlAttrs.d.ts +35 -0
- package/dist/composables/useElementWidth.d.ts +17 -0
- package/dist/composables/useModal.d.ts +68 -0
- package/dist/composables/useToast.d.ts +66 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6154 -3775
- package/dist/index.js.map +1 -1
- package/dist/internal/ConfirmDialog.d.ts +18 -0
- package/dist/internal/nodes.d.ts +30 -0
- package/dist/style.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { App, AppContext, Component, InjectionKey, Ref } from 'vue';
|
|
2
|
+
/** What a component opened from code can do about itself. */
|
|
3
|
+
export interface ModalHandle<T = unknown> {
|
|
4
|
+
/** `false` in a component that is being used declaratively. */
|
|
5
|
+
isModal: boolean;
|
|
6
|
+
/** Bind it to the panel: `<wx-dialog v-model:open="open">`. */
|
|
7
|
+
open: Ref<boolean>;
|
|
8
|
+
/** Settles the promise with a value, and closes. */
|
|
9
|
+
resolve: (value: T) => void;
|
|
10
|
+
/** Settles it with nothing, and closes. */
|
|
11
|
+
dismiss: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface ModalOptions {
|
|
14
|
+
/** Props for the component. */
|
|
15
|
+
props?: Record<string, unknown>;
|
|
16
|
+
/** Slots for it, as render functions. */
|
|
17
|
+
slots?: Record<string, (...args: unknown[]) => unknown>;
|
|
18
|
+
/** Events that settle the promise with their payload. Default: `resolve`. */
|
|
19
|
+
resolveOn?: string | string[];
|
|
20
|
+
/** Events that settle it with nothing. Default: `cancel` and `close`. */
|
|
21
|
+
dismissOn?: string | string[];
|
|
22
|
+
/** Where to mount. Default: a div at the end of `<body>`. */
|
|
23
|
+
container?: HTMLElement;
|
|
24
|
+
/** The app whose plugins and provides the component should see. */
|
|
25
|
+
appContext?: AppContext;
|
|
26
|
+
/** How long the closing animation is given before the node is taken away, in ms. */
|
|
27
|
+
duration?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ModalPromise<T> extends Promise<T | undefined> {
|
|
30
|
+
/** Closes it from outside — a route change, a timeout, a second thought. */
|
|
31
|
+
close: (value?: T) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const modalKey: InjectionKey<ModalHandle>;
|
|
34
|
+
export declare function connectModals(app: App): void;
|
|
35
|
+
/**
|
|
36
|
+
* Mounts a component outside the app and hands back a promise for its answer.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const product = await openModal<Product>(ProductBrowser, {
|
|
40
|
+
* props: { multiple: false },
|
|
41
|
+
* resolveOn: 'select',
|
|
42
|
+
* })
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* The promise settles the moment the answer is known and the node is taken away once the
|
|
46
|
+
* closing animation has had its time — so the caller is never waiting on an animation, and
|
|
47
|
+
* the panel is never cut off mid-fade.
|
|
48
|
+
*/
|
|
49
|
+
export declare function openModal<T = unknown>(component: Component, options?: ModalOptions): ModalPromise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Wraps a component in a function that opens it — the shape a browser or a picker is
|
|
52
|
+
* reached by everywhere else in an app.
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* export const productBrowser = createModal<Product, ProductBrowserProps>(ProductBrowser, {
|
|
56
|
+
* resolveOn: 'select',
|
|
57
|
+
* })
|
|
58
|
+
*
|
|
59
|
+
* const product = await productBrowser({ multiple: false })
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function createModal<T = unknown, P extends Record<string, unknown> = Record<string, never>>(component: Component, defaults?: ModalOptions): (props?: P, options?: ModalOptions) => ModalPromise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* The handle of the modal a component is being shown in. Outside one it answers all the
|
|
65
|
+
* same, with `isModal: false` and calls that do nothing — so a component can be written
|
|
66
|
+
* once and used both ways.
|
|
67
|
+
*/
|
|
68
|
+
export declare function useModal<T = unknown>(): ModalHandle<T>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DeepReadonly } from 'vue';
|
|
2
|
+
import { IconName } from '../components/Icon/types';
|
|
3
|
+
export type ToastType = 'default' | 'success' | 'warning' | 'danger' | 'info';
|
|
4
|
+
export interface ToastAction {
|
|
5
|
+
label: string;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface ToastOptions {
|
|
9
|
+
/** A headline. Without one the toast is a single line — a message rather than a card. */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** The message. This is what a one-line toast says. */
|
|
12
|
+
description?: string;
|
|
13
|
+
type?: ToastType;
|
|
14
|
+
/**
|
|
15
|
+
* How long it stays, in milliseconds. `0` keeps it until it is dismissed, which is
|
|
16
|
+
* what an error the reader has to act on wants.
|
|
17
|
+
*/
|
|
18
|
+
duration?: number;
|
|
19
|
+
/** Adds a ×. On by default for anything that does not leave on its own. */
|
|
20
|
+
closable?: boolean;
|
|
21
|
+
/** Glyph to draw instead of the one the type picks; `false` drops it. */
|
|
22
|
+
icon?: IconName | false;
|
|
23
|
+
/** One thing to do about it: Undo, Retry, View. */
|
|
24
|
+
action?: ToastAction;
|
|
25
|
+
}
|
|
26
|
+
export interface ToastRecord extends ToastOptions {
|
|
27
|
+
id: number;
|
|
28
|
+
/** Bound to the panel; set to false to start it leaving. */
|
|
29
|
+
open: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ToastHandle {
|
|
32
|
+
id: number;
|
|
33
|
+
dismiss: () => void;
|
|
34
|
+
}
|
|
35
|
+
/** What the `WxToaster` renders. Nothing else should be writing to it. */
|
|
36
|
+
export declare function toastQueue(): DeepReadonly<ToastRecord[]>;
|
|
37
|
+
/** Starts a toast leaving. It is taken off the queue once it has gone. */
|
|
38
|
+
export declare function dismissToast(id: number): void;
|
|
39
|
+
/** Takes a toast off the queue for good — called when its animation has finished. */
|
|
40
|
+
export declare function removeToast(id: number): void;
|
|
41
|
+
/** Clears everything on screen at once. */
|
|
42
|
+
export declare function clearToasts(): void;
|
|
43
|
+
export interface ToastApi {
|
|
44
|
+
(message: string | ToastOptions, options?: ToastOptions): ToastHandle;
|
|
45
|
+
success: (message: string | ToastOptions, options?: ToastOptions) => ToastHandle;
|
|
46
|
+
warning: (message: string | ToastOptions, options?: ToastOptions) => ToastHandle;
|
|
47
|
+
danger: (message: string | ToastOptions, options?: ToastOptions) => ToastHandle;
|
|
48
|
+
info: (message: string | ToastOptions, options?: ToastOptions) => ToastHandle;
|
|
49
|
+
dismiss: (id: number) => void;
|
|
50
|
+
clear: () => void;
|
|
51
|
+
}
|
|
52
|
+
declare const api: ToastApi;
|
|
53
|
+
/**
|
|
54
|
+
* Raises a toast from anywhere.
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* const toast = useToast()
|
|
58
|
+
* toast.success('Saved')
|
|
59
|
+
* toast.danger({ title: 'Could not save', description: response.message })
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* The same object is importable as `toast` for code that is not in a component at
|
|
63
|
+
* all — an interceptor, say. Put one `<wx-toaster />` on the page to show them.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useToast(): ToastApi;
|
|
66
|
+
export { api as toast };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
export { WebxUI, type WebxUiOptions } from './plugin';
|
|
3
3
|
export type { ControlSize, ControlStatus, ValidationErrors } from './composables/useFormField';
|
|
4
|
+
export { useControlAttrs, type ControlAttrs } from './composables/useControlAttrs';
|
|
5
|
+
export { useElementWidth } from './composables/useElementWidth';
|
|
6
|
+
export { useToast, toast, toastQueue, dismissToast, removeToast, clearToasts, type ToastApi, type ToastHandle, type ToastOptions, type ToastRecord, type ToastType, type ToastAction, } from './composables/useToast';
|
|
7
|
+
export { openModal, createModal, useModal, connectModals, modalKey, type ModalHandle, type ModalOptions, type ModalPromise, } from './composables/useModal';
|
|
8
|
+
export { confirm, type ConfirmOptions } from './composables/confirm';
|
|
4
9
|
export { useResponsiveShell, shellLayoutFor, type ResponsiveShell, type ResponsiveShellOptions, type ShellLayout, } from './composables/useResponsiveShell';
|