@webx-ui/core 0.8.0 → 0.10.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/README.md +21 -3
- 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/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/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/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/Table.d.ts +3 -2
- package/dist/components/Table/types.d.ts +61 -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/Transfer/Transfer.d.ts +57 -0
- package/dist/components/Transfer/index.d.ts +2 -0
- package/dist/components/Transfer/types.d.ts +40 -0
- package/dist/components/Tree/Tree.d.ts +79 -0
- package/dist/components/Tree/index.d.ts +2 -0
- package/dist/components/Tree/types.d.ts +99 -0
- package/dist/components/TreeSelect/TreeSelect.d.ts +47 -0
- package/dist/components/TreeSelect/index.d.ts +2 -0
- package/dist/components/TreeSelect/types.d.ts +76 -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 +25 -0
- package/dist/composables/confirm.d.ts +23 -0
- package/dist/composables/useModal.d.ts +68 -0
- package/dist/composables/useToast.d.ts +66 -0
- package/dist/composables/useTreeNodes.d.ts +96 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7297 -4056
- package/dist/index.js.map +1 -1
- package/dist/internal/ConfirmDialog.d.ts +18 -0
- package/dist/{components/Menu → internal}/nodes.d.ts +6 -6
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TreeNode } from '../Tree/types';
|
|
2
|
+
import { TreeSelectProps, TreeSelectValue } from './types';
|
|
3
|
+
declare const _default: <T extends TreeNode>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
5
|
+
readonly onChange?: ((value: TreeSelectValue, nodes: T[]) => any) | undefined;
|
|
6
|
+
readonly "onUpdate:modelValue"?: ((value: TreeSelectValue) => any) | undefined;
|
|
7
|
+
readonly onClose?: (() => any) | undefined;
|
|
8
|
+
readonly onOpen?: (() => any) | undefined;
|
|
9
|
+
readonly onClear?: (() => any) | undefined;
|
|
10
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onChange" | "onUpdate:modelValue" | "onOpen" | "onClose" | "onClear"> & ({
|
|
11
|
+
modelValue?: TreeSelectValue;
|
|
12
|
+
} & TreeSelectProps<T>) & Partial<{}>> & import('vue').PublicProps;
|
|
13
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
14
|
+
attrs: any;
|
|
15
|
+
slots: Readonly<{
|
|
16
|
+
/** One node in the panel. */
|
|
17
|
+
node?: (props: {
|
|
18
|
+
node: T;
|
|
19
|
+
depth: number;
|
|
20
|
+
expanded: boolean;
|
|
21
|
+
selected: boolean;
|
|
22
|
+
}) => unknown;
|
|
23
|
+
/** What the field shows instead of the labels. */
|
|
24
|
+
value?: (props: {
|
|
25
|
+
nodes: T[];
|
|
26
|
+
}) => unknown;
|
|
27
|
+
}> & {
|
|
28
|
+
/** One node in the panel. */
|
|
29
|
+
node?: (props: {
|
|
30
|
+
node: T;
|
|
31
|
+
depth: number;
|
|
32
|
+
expanded: boolean;
|
|
33
|
+
selected: boolean;
|
|
34
|
+
}) => unknown;
|
|
35
|
+
/** What the field shows instead of the labels. */
|
|
36
|
+
value?: (props: {
|
|
37
|
+
nodes: T[];
|
|
38
|
+
}) => unknown;
|
|
39
|
+
};
|
|
40
|
+
emit: (((evt: "change", value: TreeSelectValue, nodes: T[]) => void) & ((evt: "close") => void) & ((evt: "open") => void) & ((evt: "clear") => void)) & ((evt: "update:modelValue", value: TreeSelectValue) => void);
|
|
41
|
+
}>) => import('vue').VNode & {
|
|
42
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
43
|
+
};
|
|
44
|
+
export default _default;
|
|
45
|
+
type __VLS_PrettifyLocal<T> = {
|
|
46
|
+
[K in keyof T]: T[K];
|
|
47
|
+
} & {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ControlSize, ControlStatus } from '../../composables/useFormField';
|
|
2
|
+
import { TreeKey, TreeNode } from '../Tree/types';
|
|
3
|
+
export type { TreeKey, TreeNode };
|
|
4
|
+
/** One key, several of them with `multiple`, or nothing chosen. */
|
|
5
|
+
export type TreeSelectValue = TreeKey | TreeKey[] | null;
|
|
6
|
+
export interface TreeSelectProps<T = TreeNode> {
|
|
7
|
+
/** The tree to choose from — the same shape `WxTree` takes. */
|
|
8
|
+
nodes?: T[];
|
|
9
|
+
/** Adds checkboxes and turns the model into an array. */
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* With `multiple`, a tick stays where it was made instead of running down into the
|
|
13
|
+
* children and up into the parent. The model then holds exactly what was ticked,
|
|
14
|
+
* which is usually what a form wants to send.
|
|
15
|
+
*/
|
|
16
|
+
checkStrictly?: boolean;
|
|
17
|
+
/** Field holding the identity of a node. */
|
|
18
|
+
nodeKey?: string;
|
|
19
|
+
/** Field holding the text of a node. */
|
|
20
|
+
labelKey?: string;
|
|
21
|
+
/** Field holding the array of children. */
|
|
22
|
+
childrenKey?: string;
|
|
23
|
+
/** Field that, when true, makes a node unchoosable. */
|
|
24
|
+
disabledKey?: string;
|
|
25
|
+
/** Field that says a node has no children to fetch. Only read when `lazy`. */
|
|
26
|
+
leafKey?: string;
|
|
27
|
+
/** Open every branch when the panel is first built. */
|
|
28
|
+
defaultExpandAll?: boolean;
|
|
29
|
+
/** Children are fetched when a branch first opens. Requires `load`. */
|
|
30
|
+
lazy?: boolean;
|
|
31
|
+
/** Fetches the children of one node. */
|
|
32
|
+
load?: (node: T) => T[] | Promise<T[]>;
|
|
33
|
+
/**
|
|
34
|
+
* The path to what is chosen — the ancestors and the node itself — for a tree that
|
|
35
|
+
* has not fetched it yet. A lazy field has no other way to name the value it holds,
|
|
36
|
+
* or to know which branches to open in order to show it. One path, or an array of
|
|
37
|
+
* them with `multiple`.
|
|
38
|
+
*
|
|
39
|
+
* A backend that knows the record knows its ancestors, so this is the same query the
|
|
40
|
+
* form already makes.
|
|
41
|
+
*/
|
|
42
|
+
selectedPath?: T[] | T[][];
|
|
43
|
+
/** Adds the search field above the tree. */
|
|
44
|
+
filterable?: boolean;
|
|
45
|
+
filterPlaceholder?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Shows the whole path in the field — `Engine / Pistons` — rather than the label
|
|
48
|
+
* alone. Worth it wherever the same name appears under two parents.
|
|
49
|
+
*/
|
|
50
|
+
showPath?: boolean;
|
|
51
|
+
/** What goes between the steps of a path. */
|
|
52
|
+
separator?: string;
|
|
53
|
+
/** How tall the tree inside the panel may get before it scrolls. */
|
|
54
|
+
panelHeight?: number | string;
|
|
55
|
+
/** Shows a button that empties the selection. */
|
|
56
|
+
clearable?: boolean;
|
|
57
|
+
placeholder?: string;
|
|
58
|
+
/** Shown in the panel when there is nothing to choose from. */
|
|
59
|
+
emptyText?: string;
|
|
60
|
+
/** Render the panel in a portal so it escapes `overflow: hidden`. */
|
|
61
|
+
teleport?: boolean;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
size?: ControlSize;
|
|
64
|
+
status?: ControlStatus;
|
|
65
|
+
id?: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
/** Accessible label used when there is no visible `<label>`. */
|
|
68
|
+
ariaLabel?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface TreeSelectEmits<T = TreeNode> {
|
|
71
|
+
/** The selection changed. The nodes come with it, since an id alone rarely is it. */
|
|
72
|
+
change: [value: TreeSelectValue, nodes: T[]];
|
|
73
|
+
clear: [];
|
|
74
|
+
open: [];
|
|
75
|
+
close: [];
|
|
76
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { UploadFile, UploadProps } from './types';
|
|
2
|
+
type __VLS_Props = UploadProps;
|
|
3
|
+
type __VLS_PublicProps = {
|
|
4
|
+
modelValue?: UploadFile[];
|
|
5
|
+
} & __VLS_Props;
|
|
6
|
+
declare function __VLS_template(): {
|
|
7
|
+
attrs: Partial<{}>;
|
|
8
|
+
slots: Readonly<{
|
|
9
|
+
/** Replaces the inside of the drop zone. */
|
|
10
|
+
default?: (props: {
|
|
11
|
+
open: () => void;
|
|
12
|
+
dragging: boolean;
|
|
13
|
+
}) => unknown;
|
|
14
|
+
/** Replaces the row a file is shown as. */
|
|
15
|
+
file?: (props: {
|
|
16
|
+
file: UploadFile;
|
|
17
|
+
remove: () => void;
|
|
18
|
+
}) => unknown;
|
|
19
|
+
/** Under the zone: a note about formats or sizes. */
|
|
20
|
+
footer?: () => unknown;
|
|
21
|
+
}> & {
|
|
22
|
+
/** Replaces the inside of the drop zone. */
|
|
23
|
+
default?: (props: {
|
|
24
|
+
open: () => void;
|
|
25
|
+
dragging: boolean;
|
|
26
|
+
}) => unknown;
|
|
27
|
+
/** Replaces the row a file is shown as. */
|
|
28
|
+
file?: (props: {
|
|
29
|
+
file: UploadFile;
|
|
30
|
+
remove: () => void;
|
|
31
|
+
}) => unknown;
|
|
32
|
+
/** Under the zone: a note about formats or sizes. */
|
|
33
|
+
footer?: () => unknown;
|
|
34
|
+
};
|
|
35
|
+
refs: {
|
|
36
|
+
input: HTMLInputElement;
|
|
37
|
+
};
|
|
38
|
+
rootEl: HTMLDivElement;
|
|
39
|
+
};
|
|
40
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
41
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
42
|
+
"update:modelValue": (value: UploadFile[]) => any;
|
|
43
|
+
select: (file: UploadFile) => any;
|
|
44
|
+
add: (files: UploadFile[]) => any;
|
|
45
|
+
remove: (file: UploadFile) => any;
|
|
46
|
+
reject: (file: File, reason: "size" | "type" | "count" | "rejected") => any;
|
|
47
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
48
|
+
"onUpdate:modelValue"?: ((value: UploadFile[]) => any) | undefined;
|
|
49
|
+
onSelect?: ((file: UploadFile) => any) | undefined;
|
|
50
|
+
onAdd?: ((files: UploadFile[]) => any) | undefined;
|
|
51
|
+
onRemove?: ((file: UploadFile) => any) | undefined;
|
|
52
|
+
onReject?: ((file: File, reason: "size" | "type" | "count" | "rejected") => any) | undefined;
|
|
53
|
+
}>, {
|
|
54
|
+
multiple: boolean;
|
|
55
|
+
disabled: boolean;
|
|
56
|
+
max: number;
|
|
57
|
+
accept: string;
|
|
58
|
+
maxSize: number;
|
|
59
|
+
buttonOnly: boolean;
|
|
60
|
+
buttonText: string;
|
|
61
|
+
hint: string;
|
|
62
|
+
gallery: boolean;
|
|
63
|
+
removable: boolean;
|
|
64
|
+
beforeAdd: (file: File) => boolean | Promise<boolean>;
|
|
65
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
66
|
+
input: HTMLInputElement;
|
|
67
|
+
}, HTMLDivElement>;
|
|
68
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
69
|
+
export default _default;
|
|
70
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
71
|
+
new (): {
|
|
72
|
+
$slots: S;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Where a file has got to. */
|
|
2
|
+
export type UploadStatus = 'ready' | 'uploading' | 'done' | 'error';
|
|
3
|
+
export interface UploadFile {
|
|
4
|
+
/** Stable across the file's whole life, including a retry. */
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
/** In bytes. `0` for a file that arrived as a URL rather than from disk. */
|
|
8
|
+
size: number;
|
|
9
|
+
type: string;
|
|
10
|
+
status: UploadStatus;
|
|
11
|
+
/** How far along, 0–100. Meaningful while `uploading`. */
|
|
12
|
+
progress: number;
|
|
13
|
+
/** What went wrong, for a file that failed. */
|
|
14
|
+
error?: string;
|
|
15
|
+
/** Where it ended up, once the caller knows. */
|
|
16
|
+
url?: string;
|
|
17
|
+
/** The file itself, for anything picked from disk. */
|
|
18
|
+
raw?: File;
|
|
19
|
+
}
|
|
20
|
+
export interface UploadProps {
|
|
21
|
+
/** What the file input accepts, e.g. `image/*,.pdf`. */
|
|
22
|
+
accept?: string;
|
|
23
|
+
multiple?: boolean;
|
|
24
|
+
/** Largest file, in bytes. Anything over it is refused before it is added. */
|
|
25
|
+
maxSize?: number;
|
|
26
|
+
/** Largest number of files. */
|
|
27
|
+
max?: number;
|
|
28
|
+
/** Drops the drop zone and leaves a button. */
|
|
29
|
+
buttonOnly?: boolean;
|
|
30
|
+
/** Label of the button. */
|
|
31
|
+
buttonText?: string;
|
|
32
|
+
/** The line inside the drop zone. */
|
|
33
|
+
hint?: string;
|
|
34
|
+
/** Shows each file as a thumbnail rather than a row. For pictures. */
|
|
35
|
+
gallery?: boolean;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** Whether a file can be taken off the list once it is there. */
|
|
38
|
+
removable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Asked about every file before it joins the list. Return `false` — or a rejected
|
|
41
|
+
* promise — to refuse it. This is where a caller checks dimensions, or renames.
|
|
42
|
+
*/
|
|
43
|
+
beforeAdd?: (file: File) => boolean | Promise<boolean>;
|
|
44
|
+
}
|
|
45
|
+
export interface UploadEmits {
|
|
46
|
+
/** Files that passed the checks and joined the list. */
|
|
47
|
+
add: [files: UploadFile[]];
|
|
48
|
+
/** A file was taken off the list. */
|
|
49
|
+
remove: [file: UploadFile];
|
|
50
|
+
/** A file was refused, and why. */
|
|
51
|
+
reject: [file: File, reason: 'size' | 'count' | 'type' | 'rejected'];
|
|
52
|
+
/** A file in the list was chosen — to preview it, usually. */
|
|
53
|
+
select: [file: UploadFile];
|
|
54
|
+
}
|
|
@@ -2,9 +2,13 @@ export * from './Accordion';
|
|
|
2
2
|
export * from './AccordionItem';
|
|
3
3
|
export * from './Action';
|
|
4
4
|
export * from './Actions';
|
|
5
|
+
export * from './Affix';
|
|
5
6
|
export * from './Alert';
|
|
6
7
|
export * from './Aside';
|
|
7
8
|
export * from './Autocomplete';
|
|
9
|
+
export * from './Avatar';
|
|
10
|
+
export * from './AvatarGroup';
|
|
11
|
+
export * from './Backtop';
|
|
8
12
|
export * from './Badge';
|
|
9
13
|
export * from './Breadcrumb';
|
|
10
14
|
export * from './BreadcrumbItem';
|
|
@@ -21,11 +25,14 @@ export * from './Countdown';
|
|
|
21
25
|
export * from './DatePicker';
|
|
22
26
|
export * from './DateRangePicker';
|
|
23
27
|
export * from './DateTimePicker';
|
|
28
|
+
export * from './Descriptions';
|
|
29
|
+
export * from './DescriptionsItem';
|
|
24
30
|
export * from './Dialog';
|
|
25
31
|
export * from './Divider';
|
|
26
32
|
export * from './Drawer';
|
|
27
33
|
export * from './Dropdown';
|
|
28
34
|
export * from './DropdownItem';
|
|
35
|
+
export * from './Empty';
|
|
29
36
|
export * from './EntityCard';
|
|
30
37
|
export * from './Footer';
|
|
31
38
|
export * from './Form';
|
|
@@ -33,29 +40,41 @@ export * from './FormItem';
|
|
|
33
40
|
export * from './Header';
|
|
34
41
|
export * from './Heading';
|
|
35
42
|
export * from './Icon';
|
|
43
|
+
export * from './Image';
|
|
36
44
|
export * from './Indicator';
|
|
37
45
|
export * from './Input';
|
|
38
46
|
export * from './InputNumber';
|
|
39
47
|
export * from './Kanban';
|
|
40
48
|
export * from './Link';
|
|
41
49
|
export * from './ListDetail';
|
|
50
|
+
export * from './Loading';
|
|
42
51
|
export * from './Main';
|
|
43
52
|
export * from './Menu';
|
|
44
53
|
export * from './MenuGroup';
|
|
45
54
|
export * from './MenuItem';
|
|
46
55
|
export * from './Pagination';
|
|
56
|
+
export * from './Popconfirm';
|
|
47
57
|
export * from './Popover';
|
|
58
|
+
export * from './Progress';
|
|
48
59
|
export * from './Prose';
|
|
49
60
|
export * from './Radio';
|
|
50
61
|
export * from './RadioGroup';
|
|
51
62
|
export * from './Rate';
|
|
63
|
+
export * from './Result';
|
|
52
64
|
export * from './RichText';
|
|
53
65
|
export * from './Row';
|
|
54
66
|
export * from './Scrollbar';
|
|
67
|
+
export * from './Segmented';
|
|
55
68
|
export * from './Select';
|
|
69
|
+
export * from './SelectionArea';
|
|
70
|
+
export * from './Skeleton';
|
|
71
|
+
export * from './SkeletonItem';
|
|
56
72
|
export * from './Slider';
|
|
73
|
+
export * from './SortableList';
|
|
57
74
|
export * from './Space';
|
|
58
75
|
export * from './Statistic';
|
|
76
|
+
export * from './Step';
|
|
77
|
+
export * from './Steps';
|
|
59
78
|
export * from './Submenu';
|
|
60
79
|
export * from './Switch';
|
|
61
80
|
export * from './Tab';
|
|
@@ -67,3 +86,9 @@ export * from './Textarea';
|
|
|
67
86
|
export * from './Timeline';
|
|
68
87
|
export * from './TimelineItem';
|
|
69
88
|
export * from './TimePicker';
|
|
89
|
+
export * from './Toaster';
|
|
90
|
+
export * from './Tooltip';
|
|
91
|
+
export * from './Transfer';
|
|
92
|
+
export * from './Tree';
|
|
93
|
+
export * from './TreeSelect';
|
|
94
|
+
export * from './Upload';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ButtonType } from '../components/Button/types';
|
|
2
|
+
export interface ConfirmOptions {
|
|
3
|
+
/** The question, as the heading. Defaults to "Are you sure?" */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** What is at stake, under the question. */
|
|
6
|
+
message?: string;
|
|
7
|
+
confirmText?: string;
|
|
8
|
+
cancelText?: string;
|
|
9
|
+
/** Colour of the confirming button. `danger` for anything that destroys something. */
|
|
10
|
+
tone?: ButtonType;
|
|
11
|
+
width?: number | string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Asks, and answers `true` or `false`.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* if (await confirm('Delete this product?')) remove(product)
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* It never rejects. A question that throws when the answer is no turns every call site
|
|
21
|
+
* into a `try` block, and a forgotten `catch` into an unhandled rejection.
|
|
22
|
+
*/
|
|
23
|
+
export declare function confirm(message?: string | ConfirmOptions, options?: ConfirmOptions): Promise<boolean>;
|
|
@@ -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 };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
export type TreeKey = string | number;
|
|
3
|
+
/** Where a dragged node lands relative to the one it was dropped on. */
|
|
4
|
+
export type TreeDropZone = 'before' | 'after' | 'inside';
|
|
5
|
+
/**
|
|
6
|
+
* How to read one node. Everything else here works through these four, which is what
|
|
7
|
+
* lets the same machinery drive a tree of its own and a table whose rows happen to
|
|
8
|
+
* nest: neither has to agree with the other on what a node looks like.
|
|
9
|
+
*/
|
|
10
|
+
export interface TreeAccessors<T> {
|
|
11
|
+
key: (node: T, path: number[]) => TreeKey;
|
|
12
|
+
children: (node: T) => T[] | undefined;
|
|
13
|
+
/** Called when a branch that had no `children` array needs one. */
|
|
14
|
+
setChildren: (node: T, children: T[]) => void;
|
|
15
|
+
label?: (node: T) => string;
|
|
16
|
+
disabled?: (node: T) => boolean;
|
|
17
|
+
/** Says a node has nothing under it — only needed with `lazy`, where an empty
|
|
18
|
+
* `children` cannot tell "not loaded yet" from "nothing there". */
|
|
19
|
+
leaf?: (node: T) => boolean;
|
|
20
|
+
}
|
|
21
|
+
/** One node and everything about where it sits, kept for the whole tree. */
|
|
22
|
+
export interface TreeEntry<T> {
|
|
23
|
+
node: T;
|
|
24
|
+
key: TreeKey;
|
|
25
|
+
depth: number;
|
|
26
|
+
/** The array this node currently lives in — moving is a splice on it. */
|
|
27
|
+
siblings: T[];
|
|
28
|
+
index: number;
|
|
29
|
+
parent: T | null;
|
|
30
|
+
parentKey: TreeKey | null;
|
|
31
|
+
children: T[];
|
|
32
|
+
}
|
|
33
|
+
/** A node as the screen shows it: visible, in order, at a depth. */
|
|
34
|
+
export interface TreeRow<T> extends TreeEntry<T> {
|
|
35
|
+
expandable: boolean;
|
|
36
|
+
expanded: boolean;
|
|
37
|
+
loading: boolean;
|
|
38
|
+
disabled: boolean;
|
|
39
|
+
/** Matched the filter itself, as opposed to merely leading to a match. */
|
|
40
|
+
matched: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface UseTreeNodesOptions<T> {
|
|
43
|
+
/**
|
|
44
|
+
* The tree. A getter or a plain array is enough for a tree that is only read; a
|
|
45
|
+
* `ref` is what a tree that can be rearranged wants, since a move splices the array
|
|
46
|
+
* the caller is holding.
|
|
47
|
+
*/
|
|
48
|
+
nodes: MaybeRefOrGetter<T[]>;
|
|
49
|
+
accessors: TreeAccessors<T>;
|
|
50
|
+
/** Keys of the open branches. Owned by the caller, so `v-model:expanded` works. */
|
|
51
|
+
expanded: Ref<TreeKey[]>;
|
|
52
|
+
/** Only branches matching this, and the branches leading to them, are shown. */
|
|
53
|
+
filter?: MaybeRefOrGetter<string | undefined>;
|
|
54
|
+
/** Opening a branch closes the others at its level. */
|
|
55
|
+
accordion?: MaybeRefOrGetter<boolean>;
|
|
56
|
+
/** Children arrive when a branch opens. Requires `load`. */
|
|
57
|
+
lazy?: MaybeRefOrGetter<boolean>;
|
|
58
|
+
load?: (node: T) => T[] | Promise<T[]>;
|
|
59
|
+
/** Vetoes a move before it happens. */
|
|
60
|
+
allowDrop?: (drag: T, drop: T, zone: TreeDropZone) => boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The parts of a tree that have nothing to do with how it looks: what is where, what is
|
|
64
|
+
* open, what a filter leaves standing, and what a move does to the arrays underneath.
|
|
65
|
+
*/
|
|
66
|
+
export declare function useTreeNodes<T>(options: UseTreeNodesOptions<T>): {
|
|
67
|
+
rows: import('vue').ComputedRef<TreeRow<T>[]>;
|
|
68
|
+
entries: import('vue').ComputedRef<Map<TreeKey, TreeEntry<T>>>;
|
|
69
|
+
entry: (key: TreeKey) => TreeEntry<T> | undefined;
|
|
70
|
+
keyOf: (node: T, path?: number[]) => TreeKey;
|
|
71
|
+
filtered: import('vue').ComputedRef<{
|
|
72
|
+
keep: Set<TreeKey>;
|
|
73
|
+
matched: Set<TreeKey>;
|
|
74
|
+
} | null>;
|
|
75
|
+
isExpanded: (key: TreeKey) => boolean;
|
|
76
|
+
expand: (key: TreeKey) => Promise<void>;
|
|
77
|
+
collapse: (key: TreeKey) => void;
|
|
78
|
+
toggle: (key: TreeKey) => void | Promise<void>;
|
|
79
|
+
expandAll: () => void;
|
|
80
|
+
collapseAll: () => void;
|
|
81
|
+
reveal: (key: TreeKey) => void;
|
|
82
|
+
openPath: (keys: TreeKey[]) => Promise<boolean>;
|
|
83
|
+
ancestors: (key: TreeKey) => TreeEntry<T>[];
|
|
84
|
+
path: (key: TreeKey) => TreeEntry<T>[];
|
|
85
|
+
descendants: (key: TreeKey) => TreeEntry<T>[];
|
|
86
|
+
isAncestorOf: (key: TreeKey, other: TreeKey) => boolean;
|
|
87
|
+
canDrop: (dragKey: TreeKey, dropKey: TreeKey, zone: TreeDropZone) => boolean;
|
|
88
|
+
move: (dragKey: TreeKey, dropKey: TreeKey, zone: TreeDropZone) => {
|
|
89
|
+
node: T;
|
|
90
|
+
parent: T | null;
|
|
91
|
+
siblings: T[];
|
|
92
|
+
index: number;
|
|
93
|
+
} | null;
|
|
94
|
+
loading: Ref<Set<TreeKey> & Omit<Set<TreeKey>, keyof Set<any>>, Set<TreeKey> | (Set<TreeKey> & Omit<Set<TreeKey>, keyof Set<any>>)>;
|
|
95
|
+
};
|
|
96
|
+
export type UseTreeNodes<T> = ReturnType<typeof useTreeNodes<T>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,7 @@ export { WebxUI, type WebxUiOptions } from './plugin';
|
|
|
3
3
|
export type { ControlSize, ControlStatus, ValidationErrors } from './composables/useFormField';
|
|
4
4
|
export { useControlAttrs, type ControlAttrs } from './composables/useControlAttrs';
|
|
5
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';
|
|
6
9
|
export { useResponsiveShell, shellLayoutFor, type ResponsiveShell, type ResponsiveShellOptions, type ShellLayout, } from './composables/useResponsiveShell';
|