@eldrajs/ui 0.2.1 → 0.2.3
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/CHANGELOG.md +10 -0
- package/README.md +150 -3
- package/dist/{VariantPicker-CKw8hmxt.js → VariantPicker-CqDAtSju.js} +208 -167
- package/dist/componentNames.d.ts +1 -1
- package/dist/components/drawer/Drawer.vue.d.ts +5 -3
- package/dist/components/image/Image.vue.d.ts +8 -6
- package/dist/components/image/types.d.ts +22 -5
- package/dist/components/nav-menu/NavMenu.vue.d.ts +62 -0
- package/dist/components/nav-menu/NavMenuPanel.vue.d.ts +27 -0
- package/dist/components/nav-menu/navLinks.d.ts +27 -0
- package/dist/components/nav-menu/navMenuKeys.d.ts +17 -0
- package/dist/components/nav-menu/types.d.ts +87 -0
- package/dist/components.css +5485 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1227 -263
- package/dist/messages/en-US.d.ts +8 -0
- package/dist/messages/is-IS.js +4 -0
- package/dist/resolver.js +1 -0
- package/dist/style.css +569 -205
- package/dist/tailwind.css +221 -117
- package/dist/utils/ratio.d.ts +3 -2
- package/dist/utils/sizes.d.ts +4 -0
- package/dist/vee-validate.js +1 -1
- package/package.json +3 -2
|
@@ -27,6 +27,19 @@ export interface ImageMedia {
|
|
|
27
27
|
/** Renders a `<video>` instead of an `<img>`. Defaults to `'image'`. */
|
|
28
28
|
type?: 'image' | 'video';
|
|
29
29
|
}
|
|
30
|
+
/** One art-directed crop: where `media` matches, its fields replace the instance's own. */
|
|
31
|
+
export interface ImageCrop {
|
|
32
|
+
/** A media condition, as in `sizes`: `(max-width: 640px)`. The first crop that matches wins. */
|
|
33
|
+
media: string;
|
|
34
|
+
ratio?: ImageRatio | number;
|
|
35
|
+
focal?: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
};
|
|
39
|
+
zoom?: number;
|
|
40
|
+
/** `sizes` for the frame under this condition, scaled by this crop's zoom like the instance's. */
|
|
41
|
+
sizes?: string;
|
|
42
|
+
}
|
|
30
43
|
/** The parts a consumer can restyle through `classes`, named as the spec's anatomy names them. */
|
|
31
44
|
export type ImagePart = 'root' | 'frame' | 'media' | 'placeholder' | 'caption' | 'skeleton';
|
|
32
45
|
export interface ImageProps {
|
|
@@ -40,9 +53,9 @@ export interface ImageProps {
|
|
|
40
53
|
/** Renders `alt=""` (and hides the live placeholder from assistive technology) regardless of
|
|
41
54
|
* `alt`/`media.alt`. */
|
|
42
55
|
decorative?: boolean;
|
|
43
|
-
/** The frame's aspect preset. See `ImageRatio`. Defaults to
|
|
44
|
-
* passes `'4x5'` itself, per the spec's own per-context default. */
|
|
45
|
-
ratio?: ImageRatio;
|
|
56
|
+
/** The frame's aspect preset, or its width ÷ height (`6 / 5`). See `ImageRatio`. Defaults to
|
|
57
|
+
* `'4x3'` — a product-card caller passes `'4x5'` itself, per the spec's own per-context default. */
|
|
58
|
+
ratio?: ImageRatio | number;
|
|
46
59
|
/**
|
|
47
60
|
* How the media fills its frame: `'cover'` (default) crops to fill, matching the spec's own
|
|
48
61
|
* "the frame always crops; it never stretches" rule for every card/grid context this component
|
|
@@ -61,15 +74,19 @@ export interface ImageProps {
|
|
|
61
74
|
x: number;
|
|
62
75
|
y: number;
|
|
63
76
|
};
|
|
64
|
-
/** Static crop scale (1
|
|
77
|
+
/** Static crop scale (≥ 1) around `focal`, applied as `transform: scale(zoom)`. Never animated —
|
|
65
78
|
* a static crop, not a hover effect (spec "Image" → Behaviour & motion). Defaults to `1`. */
|
|
66
79
|
zoom?: number;
|
|
80
|
+
/** Where `zoom` scales from: `'band'` (default) as the page builder frames, `'focal'` exactly. */
|
|
81
|
+
zoomOrigin?: 'band' | 'focal';
|
|
82
|
+
/** Art direction: a ratio, focal point, zoom and `sizes` per media condition, on one `<img>`. */
|
|
83
|
+
crops?: ImageCrop[];
|
|
67
84
|
/** Frame corner radius: `none` (default), `lg` (`radius-lg`) or `xl` (`radius-xl`). */
|
|
68
85
|
rounded?: 'none' | 'lg' | 'xl';
|
|
69
86
|
/** Renders a `<figcaption>` under the frame and makes the root a `<figure>`. `null`/omitted
|
|
70
87
|
* renders neither. */
|
|
71
88
|
caption?: string | null;
|
|
72
|
-
/** Responsive `sizes` for the `
|
|
89
|
+
/** Responsive `sizes` for the frame, scaled by `zoom` under `cover`. Overrides `media.sizes`. */
|
|
73
90
|
sizes?: string;
|
|
74
91
|
/** The first hero image: `loading="eager"` + `fetchpriority="high"`. Every other image is
|
|
75
92
|
* `loading="lazy"` (the default). */
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { NavMenuCollapse, NavMenuGroupHeadingSlotProps, NavMenuItem, NavMenuPanelItemSlotProps, NavMenuProps, NavMenuVariant } from './types.js';
|
|
2
|
+
type __VLS_Slots = {
|
|
3
|
+
/** The inside of one panel entry, in the bar or the drawer; the link around it stays the menu's. */
|
|
4
|
+
panelItem?: (props: NavMenuPanelItemSlotProps) => unknown;
|
|
5
|
+
/** A column heading's text, in the bar or the drawer. */
|
|
6
|
+
groupHeading?: (props: NavMenuGroupHeadingSlotProps) => unknown;
|
|
7
|
+
/** Extra content at the foot of every panel. */
|
|
8
|
+
panelFooter?: (props: {
|
|
9
|
+
item: NavMenuItem;
|
|
10
|
+
index: number;
|
|
11
|
+
close: () => void;
|
|
12
|
+
}) => unknown;
|
|
13
|
+
/** A panel button's icon, replacing the chevron; it turns over while the panel is open. */
|
|
14
|
+
triggerIcon?: (props: {
|
|
15
|
+
item: NavMenuItem;
|
|
16
|
+
open: boolean;
|
|
17
|
+
}) => unknown;
|
|
18
|
+
/** The menu button's inside, replacing the icon. */
|
|
19
|
+
toggle?: (props: {
|
|
20
|
+
open: boolean;
|
|
21
|
+
}) => unknown;
|
|
22
|
+
/** The drawer's header row, before its close button: a logo, a call to action. */
|
|
23
|
+
drawerHeader?: (props: {
|
|
24
|
+
close: () => void;
|
|
25
|
+
}) => unknown;
|
|
26
|
+
/** The drawer's fixed footer. */
|
|
27
|
+
drawerFooter?: (props: {
|
|
28
|
+
close: () => void;
|
|
29
|
+
}) => unknown;
|
|
30
|
+
};
|
|
31
|
+
/** Closes the open panel and the drawer, for a router's navigation hook. */
|
|
32
|
+
declare function close(): void;
|
|
33
|
+
declare const __VLS_base: import('vue').DefineComponent<NavMenuProps, {
|
|
34
|
+
close: typeof close;
|
|
35
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
36
|
+
"update:modelValue": (index: number | null) => any;
|
|
37
|
+
"update:drawerOpen": (open: boolean) => any;
|
|
38
|
+
}, string, import('vue').PublicProps, Readonly<NavMenuProps> & Readonly<{
|
|
39
|
+
"onUpdate:modelValue"?: ((index: number | null) => any) | undefined;
|
|
40
|
+
"onUpdate:drawerOpen"?: ((open: boolean) => any) | undefined;
|
|
41
|
+
}>, {
|
|
42
|
+
classes: Partial<Record<import('./types.js').NavMenuPart, string>>;
|
|
43
|
+
modelValue: number | null;
|
|
44
|
+
variant: NavMenuVariant;
|
|
45
|
+
linkAs: string | import('vue').Component;
|
|
46
|
+
ariaLabel: string;
|
|
47
|
+
messages: Partial<import('../../index.js').UiMessages>;
|
|
48
|
+
drawerOpen: boolean;
|
|
49
|
+
collapseBelow: NavMenuCollapse;
|
|
50
|
+
drawerSide: import('../../index.js').DrawerSide;
|
|
51
|
+
drawerLayout: import('./types.js').NavMenuDrawerLayout;
|
|
52
|
+
drawerItems: readonly NavMenuItem[];
|
|
53
|
+
openOnHover: boolean;
|
|
54
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
55
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
56
|
+
declare const _default: typeof __VLS_export;
|
|
57
|
+
export default _default;
|
|
58
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
59
|
+
new (): {
|
|
60
|
+
$slots: S;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { UiMessages } from '../../composables/useMessages.js';
|
|
3
|
+
import { NavMenuGroupHeadingSlotProps, NavMenuItem, NavMenuPanelItemSlotProps, NavMenuPart, NavMenuPlacement, NavMenuVariant } from './types.js';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
item: NavMenuItem;
|
|
6
|
+
idPrefix: string;
|
|
7
|
+
placement: NavMenuPlacement;
|
|
8
|
+
variant: NavMenuVariant;
|
|
9
|
+
messages: UiMessages;
|
|
10
|
+
linkAs?: string | Component;
|
|
11
|
+
classes?: Partial<Record<NavMenuPart, string>>;
|
|
12
|
+
/** Names a list that has no group heading of its own, such as a drawer section's. */
|
|
13
|
+
labelledBy?: string;
|
|
14
|
+
};
|
|
15
|
+
type __VLS_Slots = {
|
|
16
|
+
panelItem?: (props: NavMenuPanelItemSlotProps) => unknown;
|
|
17
|
+
groupHeading?: (props: NavMenuGroupHeadingSlotProps) => unknown;
|
|
18
|
+
};
|
|
19
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|
|
23
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
24
|
+
new (): {
|
|
25
|
+
$slots: S;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { NavMenuItem, NavMenuLink, NavMenuPanelLayout } from './types.js';
|
|
3
|
+
/** How the page the visitor is on is marked, on every kind of link the menu draws. */
|
|
4
|
+
export declare const CURRENT_PAGE = "aria-[current=page]:underline aria-[current=page]:decoration-2 aria-[current=page]:underline-offset-[0.2em]";
|
|
5
|
+
/** A run of panel entries under one column heading; `group` is `null` for entries without one. */
|
|
6
|
+
export interface NavMenuGroup {
|
|
7
|
+
group: string | null;
|
|
8
|
+
links: NavMenuLink[];
|
|
9
|
+
}
|
|
10
|
+
/** Whether an entry has visible text to render. */
|
|
11
|
+
export declare function isRenderableLink(link: NavMenuLink): boolean;
|
|
12
|
+
/** The entries a panel draws, without the ones that have nothing to show. */
|
|
13
|
+
export declare function panelLinks(item: NavMenuItem): NavMenuLink[];
|
|
14
|
+
/** Whether a top-level entry opens a panel rather than being a plain link. */
|
|
15
|
+
export declare function hasPanel(item: NavMenuItem): boolean;
|
|
16
|
+
/** Groups entries by their `group`, keeping the order each group first appears in. */
|
|
17
|
+
export declare function groupLinks(links: readonly NavMenuLink[]): NavMenuGroup[];
|
|
18
|
+
/** The panel's layout: the item's own, else `mega` when its entries are grouped into columns. */
|
|
19
|
+
export declare function panelLayout(item: NavMenuItem): NavMenuPanelLayout;
|
|
20
|
+
/** Whether the item, or an entry in its panel, is the page the visitor is on. */
|
|
21
|
+
export declare function containsCurrent(item: NavMenuItem): boolean;
|
|
22
|
+
/** Whether an entry goes somewhere; one without a destination renders as plain text. */
|
|
23
|
+
export declare function hasHref(link: NavMenuLink): boolean;
|
|
24
|
+
/** The element an entry renders as: `linkAs` (or `a`) with a destination, else `span`. */
|
|
25
|
+
export declare function navLinkTag(link: NavMenuLink, linkAs?: string | Component): string | Component;
|
|
26
|
+
/** An entry's link attributes; a component `linkAs` takes the destination as `to`. */
|
|
27
|
+
export declare function navLinkAttrs(link: NavMenuLink, linkAs?: string | Component): Record<string, unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export interface NavMenuKeysOptions {
|
|
3
|
+
/** The bar's `<ul>`, one `<li>` per rendered entry. */
|
|
4
|
+
list: Ref<HTMLElement | null>;
|
|
5
|
+
/** The `items` index of the entry rendered at `position` in the list. */
|
|
6
|
+
indexAt: (position: number) => number;
|
|
7
|
+
/** The entry's panel, or `null` when it has none. */
|
|
8
|
+
panel: (index: number) => HTMLElement | null;
|
|
9
|
+
openIndex: Ref<number | null>;
|
|
10
|
+
open: (index: number) => void;
|
|
11
|
+
close: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The arrow keys of the APG disclosure navigation pattern, over the bar's own DOM: Left/Right and
|
|
15
|
+
* Home/End along the bar, Down/Up into and through a panel. Clamped, never wrapping.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useNavMenuKeys(options: NavMenuKeysOptions): (event: KeyboardEvent) => void;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { UiMessages } from '../../composables/useMessages.js';
|
|
3
|
+
import { DrawerSide } from '../drawer/types.js';
|
|
4
|
+
/** One entry; `@eldrajs/theme-core`'s `ResolvedLink` (a resolved Studio link tree) fits it as is. */
|
|
5
|
+
export interface NavMenuLink {
|
|
6
|
+
/** The visible text. An entry with no label (`null` or empty) is not rendered. */
|
|
7
|
+
label: string | null;
|
|
8
|
+
/** The destination. Without one the entry renders as plain text, never a dead link. */
|
|
9
|
+
href?: string | null;
|
|
10
|
+
/** Opens in a new tab, with the hidden "opens in a new tab" text. */
|
|
11
|
+
newTab?: boolean;
|
|
12
|
+
/** A second line under the label, for a mega panel. */
|
|
13
|
+
description?: string | null;
|
|
14
|
+
/** A short tag after the label, such as "Coming soon". */
|
|
15
|
+
badge?: string | null;
|
|
16
|
+
/** The column heading this entry sits under; entries sharing one form a column. */
|
|
17
|
+
group?: string | null;
|
|
18
|
+
/** Marks the page the visitor is on (`aria-current="page"`). */
|
|
19
|
+
current?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** `dropdown` hangs a compact panel under its trigger; `mega` spans the menu's positioning box. */
|
|
22
|
+
export type NavMenuPanelLayout = 'dropdown' | 'mega';
|
|
23
|
+
/** One top-level entry: a link when it has no children, a button opening a panel when it has. */
|
|
24
|
+
export interface NavMenuItem extends NavMenuLink {
|
|
25
|
+
/** The panel's entries, one level deep. */
|
|
26
|
+
children?: readonly NavMenuLink[];
|
|
27
|
+
/** Default `mega` when any child has a `group`, else `dropdown`. */
|
|
28
|
+
layout?: NavMenuPanelLayout;
|
|
29
|
+
}
|
|
30
|
+
/** Below which viewport (`md`…) or nearest-container (`@tablet`…) breakpoint the bar becomes a menu button. */
|
|
31
|
+
export type NavMenuCollapse = 'md' | 'lg' | 'xl' | '@tablet' | '@content' | '@wide' | 'never' | 'always';
|
|
32
|
+
/** `ghost` fills an entry on hover, as `Button`'s ghost variant does; `muted` is `Link`'s muted tone. */
|
|
33
|
+
export type NavMenuVariant = 'ghost' | 'muted';
|
|
34
|
+
/** `accordion` folds each panel into a row that opens; `sections` lists every panel's links open under its heading. */
|
|
35
|
+
export type NavMenuDrawerLayout = 'accordion' | 'sections';
|
|
36
|
+
/** Where a panel's content is drawn: under the bar, or in the narrow-screen drawer. */
|
|
37
|
+
export type NavMenuPlacement = 'bar' | 'drawer';
|
|
38
|
+
/** The parts of a panel's content; in the drawer each one is named with a `drawer` prefix. */
|
|
39
|
+
export type NavMenuPanelPart = 'overview' | 'columns' | 'group' | 'groupHeading' | 'panelList' | 'panelItem' | 'panelLink' | 'panelLabel' | 'description' | 'badge';
|
|
40
|
+
/** A panel part as the drawer names it: `panelLink` is `drawerPanelLink`. */
|
|
41
|
+
export type NavMenuDrawerPanelPart = `drawer${Capitalize<NavMenuPanelPart>}`;
|
|
42
|
+
/** What the `panelItem` slot is handed: the entry, the item whose panel holds it, and where it is drawn. */
|
|
43
|
+
export interface NavMenuPanelItemSlotProps {
|
|
44
|
+
link: NavMenuLink;
|
|
45
|
+
item: NavMenuItem;
|
|
46
|
+
placement: NavMenuPlacement;
|
|
47
|
+
}
|
|
48
|
+
/** What the `groupHeading` slot is handed: the heading, its entries, their item, and where it is drawn. */
|
|
49
|
+
export interface NavMenuGroupHeadingSlotProps {
|
|
50
|
+
group: string;
|
|
51
|
+
links: NavMenuLink[];
|
|
52
|
+
item: NavMenuItem;
|
|
53
|
+
placement: NavMenuPlacement;
|
|
54
|
+
}
|
|
55
|
+
/** The parts a consumer can restyle through `classes`. */
|
|
56
|
+
export type NavMenuPart = 'root' | 'nav' | 'list' | 'item' | 'link' | 'trigger' | 'triggerIcon' | 'panel' | 'content' | NavMenuPanelPart | 'footer' | 'toggle' | 'toggleIcon' | 'drawerRoot' | 'drawer' | 'drawerHeader' | 'drawerClose' | 'drawerBody' | 'drawerList' | 'drawerItem' | 'drawerLink' | 'drawerTrigger' | 'drawerPanel' | 'drawerSectionHeading' | NavMenuDrawerPanelPart | 'drawerFooter';
|
|
57
|
+
export interface NavMenuProps {
|
|
58
|
+
/** The top-level entries, in order. */
|
|
59
|
+
items: readonly NavMenuItem[];
|
|
60
|
+
/** The bar's and its panels' look: `ghost` (default) fills on hover and while open, `muted` is quiet text. */
|
|
61
|
+
variant?: NavMenuVariant;
|
|
62
|
+
/** The open panel's index in `items` (two-way); `null` when none is open. */
|
|
63
|
+
modelValue?: number | null;
|
|
64
|
+
/** Whether the narrow-screen drawer is open (two-way, `update:drawerOpen`). */
|
|
65
|
+
drawerOpen?: boolean;
|
|
66
|
+
/** The navigation landmark's accessible name. Defaults to `messages.navMenuLabel`. */
|
|
67
|
+
ariaLabel?: string;
|
|
68
|
+
/** Below this breakpoint the bar collapses into the drawer. Default `lg`. */
|
|
69
|
+
collapseBelow?: NavMenuCollapse;
|
|
70
|
+
/** The edge the drawer slides in from. Default `left`. */
|
|
71
|
+
drawerSide?: DrawerSide;
|
|
72
|
+
/** How the drawer shows a panel: `accordion` (default) rows that open, or `sections` listed open. */
|
|
73
|
+
drawerLayout?: NavMenuDrawerLayout;
|
|
74
|
+
/** The drawer's entries when they differ from the bar's. Defaults to `items`. */
|
|
75
|
+
drawerItems?: readonly NavMenuItem[];
|
|
76
|
+
/** Also open a panel when a mouse pointer rests 150ms on its trigger; leaving closes it again. */
|
|
77
|
+
openOnHover?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Render every link as a different tag or component, such as a router link. A string is used as
|
|
80
|
+
* the tag and keeps `href`; a component receives the destination as `to`.
|
|
81
|
+
*/
|
|
82
|
+
linkAs?: string | Component;
|
|
83
|
+
/** Message overrides. See `useMessages`. */
|
|
84
|
+
messages?: Partial<UiMessages>;
|
|
85
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
86
|
+
classes?: Partial<Record<NavMenuPart, string>>;
|
|
87
|
+
}
|