@webx-ui/core 0.35.0 → 0.36.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.
@@ -17,6 +17,9 @@ export declare const builtinIcons: {
17
17
  readonly trash: "<path d=\"M4 7h16M10 7V5.5A1.5 1.5 0 0 1 11.5 4h1A1.5 1.5 0 0 1 14 5.5V7M6.5 7l.8 11.6a2 2 0 0 0 2 1.9h5.4a2 2 0 0 0 2-1.9L17.5 7\"/><path d=\"M10 11v5.5M14 11v5.5\"/>";
18
18
  readonly copy: "<rect x=\"8.5\" y=\"8.5\" width=\"11\" height=\"11\" rx=\"2.2\"/><path d=\"M15.5 8.5v-2a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2\"/>";
19
19
  readonly search: "<circle cx=\"11\" cy=\"11\" r=\"6.5\"/><path d=\"m16 16 4.5 4.5\"/>";
20
+ readonly 'zoom-in': "<circle cx=\"11\" cy=\"11\" r=\"6.5\"/><path d=\"m16 16 4.5 4.5M8.5 11h5M11 8.5v5\"/>";
21
+ readonly 'zoom-out': "<circle cx=\"11\" cy=\"11\" r=\"6.5\"/><path d=\"m16 16 4.5 4.5M8.5 11h5\"/>";
22
+ readonly play: "<path d=\"M8 5.5v13a1 1 0 0 0 1.5.86l10.6-6.5a1 1 0 0 0 0-1.72L9.5 4.64A1 1 0 0 0 8 5.5Z\"/>";
20
23
  readonly filter: "<path d=\"M4 5.5h16l-6.2 7.2v5.1l-3.6 2v-7.1z\"/>";
21
24
  readonly crop: "<path d=\"M6.5 2.5v13a2 2 0 0 0 2 2h13\"/><path d=\"M2.5 6.5h13a2 2 0 0 1 2 2v13\"/>";
22
25
  readonly 'rotate-left': "<path d=\"M4.5 9.5A8 8 0 1 1 4 13.5\"/><path d=\"M9.5 9.5h-5v-5\"/>";
@@ -12,7 +12,9 @@ declare function __VLS_template(): {
12
12
  /** Shown instead of a picture that will not load. */
13
13
  error?: () => unknown;
14
14
  };
15
- refs: {};
15
+ refs: {
16
+ root: HTMLDivElement;
17
+ };
16
18
  rootEl: HTMLDivElement;
17
19
  };
18
20
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
@@ -32,8 +34,12 @@ declare const __VLS_component: import('vue').DefineComponent<ImageProps, {}, {},
32
34
  lazy: boolean;
33
35
  preview: boolean;
34
36
  radius: number | string;
37
+ previewList: import('..').LightboxSource[];
38
+ previewStart: number;
35
39
  previewLabel: string;
36
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
40
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
41
+ root: HTMLDivElement;
42
+ }, HTMLDivElement>;
37
43
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
38
44
  export default _default;
39
45
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -1,3 +1,4 @@
1
+ import { LightboxSource } from '../Lightbox/types';
1
2
  export type ImageFit = 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
2
3
  export interface ImageProps {
3
4
  src?: string;
@@ -15,8 +16,15 @@ export interface ImageProps {
15
16
  lazy?: boolean;
16
17
  /** A tiny picture — or a colour — shown while the real one arrives. */
17
18
  placeholder?: string;
18
- /** Opens the picture full size when it is clicked. */
19
+ /**
20
+ * Opens the picture full size, in a lightbox, when it is clicked. Inside a `WxImageGroup`
21
+ * the lightbox is the whole group's.
22
+ */
19
23
  preview?: boolean;
24
+ /** What the lightbox shows instead of this one picture: the cover of a gallery opens all of it. */
25
+ previewList?: LightboxSource[];
26
+ /** The item of `previewList` to open on. Default: the one whose address is `src`, or the first. */
27
+ previewStart?: number;
20
28
  /** Accessible name of the button that opens the preview. */
21
29
  previewLabel?: string;
22
30
  }
@@ -38,6 +38,7 @@ declare const _default: import('vue').DefineComponent<ImageEditorProps, {
38
38
  filters: boolean;
39
39
  resizable: boolean;
40
40
  minSize: number;
41
+ originalLabel: string;
41
42
  saveLabel: string;
42
43
  cancelLabel: string;
43
44
  ratio: ImageEditorRatio;
@@ -65,7 +66,6 @@ declare const _default: import('vue').DefineComponent<ImageEditorProps, {
65
66
  saturationLabel: string;
66
67
  monoLabel: string;
67
68
  freeLabel: string;
68
- originalLabel: string;
69
69
  errorText: string;
70
70
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
71
71
  stage: HTMLDivElement;
@@ -0,0 +1,20 @@
1
+ import { ImageGroupProps } from './types';
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: {
5
+ default?(_: {}): any;
6
+ };
7
+ refs: {};
8
+ rootEl: any;
9
+ };
10
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
11
+ declare const __VLS_component: import('vue').DefineComponent<ImageGroupProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ImageGroupProps> & Readonly<{}>, {
12
+ tag: string;
13
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
15
+ export default _default;
16
+ type __VLS_WithTemplateSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
@@ -0,0 +1,2 @@
1
+ export { default as WxImageGroup } from './ImageGroup';
2
+ export type * from './types';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `WxImageGroup`'s own props. Everything else — `loop`, `thumbnails`, the labels — goes to
3
+ * the lightbox it opens, except `class` and `style`, which stay on the group's element.
4
+ */
5
+ export interface ImageGroupProps {
6
+ /** The element the group renders as. */
7
+ tag?: string;
8
+ }
@@ -0,0 +1,35 @@
1
+ import { LightboxProps } from './types';
2
+ type __VLS_Props = LightboxProps;
3
+ type __VLS_PublicProps = {
4
+ 'open'?: boolean;
5
+ 'index'?: number;
6
+ } & __VLS_Props;
7
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ change: (index: number) => any;
9
+ "update:open": (value: boolean) => any;
10
+ "update:index": (value: number) => any;
11
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
+ onChange?: ((index: number) => any) | undefined;
13
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
14
+ "onUpdate:index"?: ((value: number) => any) | undefined;
15
+ }>, {
16
+ ariaLabel: string;
17
+ closeLabel: string;
18
+ loop: boolean;
19
+ thumbnails: boolean;
20
+ maxZoom: number;
21
+ original: boolean;
22
+ prevLabel: string;
23
+ nextLabel: string;
24
+ zoomInLabel: string;
25
+ zoomOutLabel: string;
26
+ originalLabel: string;
27
+ playLabel: string;
28
+ counterText: string | ((index: number, total: number) => string);
29
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
30
+ root: HTMLDivElement;
31
+ stage: HTMLDivElement;
32
+ picture: HTMLImageElement;
33
+ thumbs: HTMLDivElement;
34
+ }, any>;
35
+ export default _default;
@@ -0,0 +1,3 @@
1
+ export { default as WxLightbox } from './Lightbox';
2
+ export { youTubeId } from './items';
3
+ export type * from './types';
@@ -0,0 +1,22 @@
1
+ import { LightboxSource } from './types';
2
+ /** What the lightbox plays: a file in a `<video>`, or an address in an `<iframe>`. */
3
+ export type ResolvedVideo = {
4
+ kind: 'file';
5
+ src: string;
6
+ } | {
7
+ kind: 'embed';
8
+ src: string;
9
+ };
10
+ /** An item with every default filled in, so the template asks no questions. */
11
+ export interface ResolvedItem {
12
+ src: string;
13
+ alt: string;
14
+ caption: string;
15
+ thumb: string;
16
+ original: string | undefined;
17
+ video: ResolvedVideo | undefined;
18
+ }
19
+ /** The id of a YouTube video in any form of its address — watch, short link, shorts, embed — or `null`. */
20
+ export declare function youTubeId(address: string): string | null;
21
+ export declare function resolveItem(source: LightboxSource): ResolvedItem;
22
+ export declare function counter(text: string | ((index: number, total: number) => string), index: number, total: number): string;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * A video on a gallery item. The item's own picture is its poster, and nothing is fetched
3
+ * from the video's host until somebody presses play.
4
+ */
5
+ export interface LightboxVideo {
6
+ /** A file the browser plays itself — MP4 or WebM. */
7
+ src?: string;
8
+ /** An address for an iframe: a YouTube embed, or anything else that plays in one. Wins over `src`. */
9
+ embed?: string;
10
+ }
11
+ export interface LightboxItem {
12
+ /** The picture shown — and, when there is a `video`, its poster. */
13
+ src?: string;
14
+ /** Alternative text, and the caption when there is no `caption`. */
15
+ alt?: string;
16
+ /** Text under the picture. */
17
+ caption?: string;
18
+ /** Where "Open the original" goes: a bigger file than the one shown. Default: `src`. */
19
+ original?: string;
20
+ /** A small version, for the strip and for the moment before `src` arrives. Default: `src`. */
21
+ thumb?: string;
22
+ /**
23
+ * Makes the item a video. A string is a YouTube link (any of its forms) or a file;
24
+ * an object says which it is.
25
+ */
26
+ video?: string | LightboxVideo;
27
+ }
28
+ /** An item, or just the address of a picture. */
29
+ export type LightboxSource = string | LightboxItem;
30
+ export interface LightboxProps {
31
+ items: LightboxSource[];
32
+ /** Going past the last item comes back to the first. */
33
+ loop?: boolean;
34
+ /** A strip of thumbnails along the bottom. Default: on when there is more than one item. */
35
+ thumbnails?: boolean;
36
+ /** How far a picture can be enlarged, as a multiple of its size on screen. */
37
+ maxZoom?: number;
38
+ /** The "Open the original" link. */
39
+ original?: boolean;
40
+ /** Accessible name of the gallery. */
41
+ ariaLabel?: string;
42
+ prevLabel?: string;
43
+ nextLabel?: string;
44
+ closeLabel?: string;
45
+ zoomInLabel?: string;
46
+ zoomOutLabel?: string;
47
+ originalLabel?: string;
48
+ playLabel?: string;
49
+ /** `{index}` and `{total}` are replaced; a function is given both. */
50
+ counterText?: string | ((index: number, total: number) => string);
51
+ }
52
+ export interface LightboxEmits {
53
+ /** The item on screen changed — by an arrow, a key, a swipe or a thumbnail. */
54
+ change: [index: number];
55
+ }
56
+ /** What `openLightbox` takes besides the items. */
57
+ export interface OpenLightboxOptions extends Omit<LightboxProps, 'items'> {
58
+ /** The item to open on. */
59
+ start?: number;
60
+ }
@@ -29,8 +29,8 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
29
29
  size: import('../..').ControlSize;
30
30
  disabled: boolean;
31
31
  ariaLabel: string;
32
- paginator: import('..').Paginated<unknown> | null;
33
32
  total: number;
33
+ paginator: import('..').Paginated<unknown> | null;
34
34
  lastPage: number;
35
35
  siblings: number;
36
36
  perPageOptions: number[];
@@ -46,10 +46,12 @@ export * from './Icon';
46
46
  export * from './IconPicker';
47
47
  export * from './Image';
48
48
  export * from './ImageEditor';
49
+ export * from './ImageGroup';
49
50
  export * from './Indicator';
50
51
  export * from './Input';
51
52
  export * from './InputNumber';
52
53
  export * from './Kanban';
54
+ export * from './Lightbox';
53
55
  export * from './Link';
54
56
  export * from './Locales';
55
57
  export * from './ListDetail';
@@ -0,0 +1,14 @@
1
+ import { ModalOptions, ModalPromise } from './useModal';
2
+ import { LightboxSource, OpenLightboxOptions } from '../components/Lightbox/types';
3
+ /**
4
+ * Opens a gallery over the page, from anywhere:
5
+ *
6
+ * ```ts
7
+ * openLightbox(product.images, 2)
8
+ * openLightbox(['/a.jpg', '/b.jpg'], { start: 1, loop: true })
9
+ * ```
10
+ *
11
+ * It answers nothing — the promise settles, with `undefined`, when the lightbox is closed —
12
+ * and carries `close()` for a gallery that should not outlive something else.
13
+ */
14
+ export declare function openLightbox(items: LightboxSource[], options?: number | OpenLightboxOptions, modal?: ModalOptions): ModalPromise<void>;
@@ -0,0 +1,16 @@
1
+ import { InjectionKey } from 'vue';
2
+ import { LightboxItem } from '../components/Lightbox/types';
3
+ /** One picture in a group: where it is on the page, and what it opens as. */
4
+ export interface ImageGroupEntry {
5
+ el: () => Element | null;
6
+ item: () => LightboxItem;
7
+ }
8
+ export interface ImageGroupContext {
9
+ /** Joins the group; the answer leaves it. */
10
+ register: (entry: ImageGroupEntry) => () => void;
11
+ /** Opens the group's lightbox on this picture. */
12
+ open: (entry: ImageGroupEntry) => void;
13
+ }
14
+ export declare const imageGroupKey: InjectionKey<ImageGroupContext>;
15
+ /** The `WxImageGroup` around this component, if there is one. */
16
+ export declare function useImageGroup(): ImageGroupContext | null;
package/dist/index.d.ts CHANGED
@@ -11,4 +11,6 @@ export { useToast, toast, toastQueue, dismissToast, removeToast, clearToasts, ty
11
11
  export { openModal, createModal, useModal, connectModals, modalKey, type ModalHandle, type ModalOptions, type ModalPromise, } from './composables/useModal';
12
12
  export { confirm, type ConfirmOptions } from './composables/confirm';
13
13
  export { openImageEditor } from './composables/imageEditor';
14
+ export { openLightbox } from './composables/lightbox';
15
+ export { useImageGroup, imageGroupKey, type ImageGroupContext, type ImageGroupEntry, } from './composables/useImageGroup';
14
16
  export { useResponsiveShell, shellLayoutFor, type ResponsiveShell, type ResponsiveShellOptions, type ShellLayout, } from './composables/useResponsiveShell';