@xds/vue 1.0.1 → 1.2.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/Banner.vue_vue_type_script_setup_true_lang.js +4 -2
- package/dist/Breadcrumb.js +4 -0
- package/dist/Breadcrumb.vue.d.ts +6 -0
- package/dist/Breadcrumb.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/Button.vue.d.ts +9 -1
- package/dist/Button.vue_vue_type_script_setup_true_lang.js +18 -5
- package/dist/Checkbox.vue.d.ts +13 -10
- package/dist/Checkbox.vue_vue_type_script_setup_true_lang.js +42 -22
- package/dist/Combobox.js +4 -0
- package/dist/Combobox.vue.d.ts +22 -0
- package/dist/Combobox.vue_vue_type_script_setup_true_lang.js +140 -0
- package/dist/DatePicker.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/DateRangePicker.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/Dialog.vue.d.ts +5 -2
- package/dist/Dialog.vue_vue_type_script_setup_true_lang.js +6 -5
- package/dist/IconButton.vue.d.ts +9 -1
- package/dist/IconButton.vue_vue_type_script_setup_true_lang.js +18 -5
- package/dist/Labels.vue.d.ts +17 -0
- package/dist/Labels.vue_vue_type_script_setup_true_lang.js +14 -0
- package/dist/Labels2.js +4 -0
- package/dist/Link.js +4 -0
- package/dist/Link.vue.d.ts +27 -0
- package/dist/Link.vue_vue_type_script_setup_true_lang.js +62 -0
- package/dist/Menu.vue.d.ts +4 -1
- package/dist/Menu.vue_vue_type_script_setup_true_lang.js +5 -4
- package/dist/Pagination.js +4 -0
- package/dist/Pagination.vue.d.ts +9 -0
- package/dist/Pagination.vue_vue_type_script_setup_true_lang.js +74 -0
- package/dist/Popover.js +4 -0
- package/dist/Popover.vue.d.ts +26 -0
- package/dist/Popover.vue_vue_type_script_setup_true_lang.js +81 -0
- package/dist/RadioGroup.vue_vue_type_script_setup_true_lang.js +13 -7
- package/dist/SearchField.vue.d.ts +11 -8
- package/dist/SearchField.vue_vue_type_script_setup_true_lang.js +40 -22
- package/dist/SegmentedControl.vue.d.ts +3 -7
- package/dist/SegmentedControl.vue_vue_type_script_setup_true_lang.js +13 -14
- package/dist/Select.vue.d.ts +3 -1
- package/dist/Select.vue_vue_type_script_setup_true_lang.js +47 -18
- package/dist/Slider.vue.d.ts +3 -8
- package/dist/Slider.vue_vue_type_script_setup_true_lang.js +11 -10
- package/dist/Switch.vue.d.ts +13 -10
- package/dist/Switch.vue_vue_type_script_setup_true_lang.js +33 -21
- package/dist/Table.js +4 -0
- package/dist/Table.vue.d.ts +10 -0
- package/dist/Table.vue_vue_type_script_setup_true_lang.js +61 -0
- package/dist/Tabs.vue.d.ts +3 -5
- package/dist/Tabs.vue_vue_type_script_setup_true_lang.js +10 -9
- package/dist/TextField.vue.d.ts +11 -8
- package/dist/TextField.vue_vue_type_script_setup_true_lang.js +26 -13
- package/dist/TimePicker.js +4 -0
- package/dist/TimePicker.vue.d.ts +10 -0
- package/dist/TimePicker.vue_vue_type_script_setup_true_lang.js +168 -0
- package/dist/Toast.vue_vue_type_script_setup_true_lang.js +5 -11
- package/dist/ToastQueue.js +4 -0
- package/dist/ToastQueue.vue.d.ts +9 -0
- package/dist/ToastQueue.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/TooltipOverlay.vue.d.ts +1 -0
- package/dist/TooltipOverlay.vue_vue_type_script_setup_true_lang.js +6 -5
- package/dist/base.d.ts +13 -0
- package/dist/base.js +14 -0
- package/dist/controlled.d.ts +46 -0
- package/dist/controlled.js +64 -2
- package/dist/index.d.ts +14 -3
- package/dist/index.js +11 -1
- package/dist/labels.d.ts +9 -0
- package/dist/labels.js +17 -0
- package/dist/preview.d.ts +20 -3
- package/dist/preview.js +37 -7
- package/dist/trigger.d.ts +7 -0
- package/dist/trigger.js +13 -1
- package/eject/files/Accordion.vue +89 -0
- package/eject/files/AccordionPanel.vue +47 -0
- package/eject/files/Avatar.vue +41 -0
- package/eject/files/AvatarStack.vue +46 -0
- package/eject/files/Badge.vue +29 -0
- package/eject/files/Banner.vue +65 -0
- package/eject/files/Breadcrumb.vue +43 -0
- package/eject/files/Button.vue +93 -0
- package/eject/files/Card.vue +85 -0
- package/eject/files/Checkbox.vue +104 -0
- package/eject/files/Chip.vue +32 -0
- package/eject/files/ChipBar.vue +25 -0
- package/eject/files/Combobox.vue +175 -0
- package/eject/files/CountBadge.vue +45 -0
- package/eject/files/DatePicker.vue +223 -0
- package/eject/files/DateRangePicker.vue +317 -0
- package/eject/files/Dialog.vue +105 -0
- package/eject/files/Divider.vue +15 -0
- package/eject/files/EmptyState.vue +28 -0
- package/eject/files/Icon.vue +34 -0
- package/eject/files/IconButton.vue +71 -0
- package/eject/files/Link.vue +48 -0
- package/eject/files/ListRow.vue +33 -0
- package/eject/files/MediaCard.vue +109 -0
- package/eject/files/Menu.vue +181 -0
- package/eject/files/Pagination.vue +88 -0
- package/eject/files/PlaceRow.vue +54 -0
- package/eject/files/Popover.vue +119 -0
- package/eject/files/ProgressBar.vue +34 -0
- package/eject/files/RadioGroup.vue +126 -0
- package/eject/files/SearchField.vue +129 -0
- package/eject/files/SectionHeader.vue +37 -0
- package/eject/files/SegmentedControl.vue +81 -0
- package/eject/files/Select.vue +269 -0
- package/eject/files/Sidebar.vue +101 -0
- package/eject/files/SidebarRailButton.vue +31 -0
- package/eject/files/Skeleton.vue +27 -0
- package/eject/files/Slider.vue +126 -0
- package/eject/files/Spinner.vue +36 -0
- package/eject/files/Switch.vue +88 -0
- package/eject/files/Table.vue +77 -0
- package/eject/files/Tabs.vue +72 -0
- package/eject/files/Text.vue +22 -0
- package/eject/files/TextField.vue +190 -0
- package/eject/files/Thumbnail.vue +62 -0
- package/eject/files/TimePicker.vue +224 -0
- package/eject/files/Toast.vue +83 -0
- package/eject/files/ToastQueue.vue +54 -0
- package/eject/files/Tooltip.vue +28 -0
- package/eject/files/TooltipOverlay.vue +86 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +71 -0
- package/eject/files/base.css +38 -0
- package/eject/files/breadcrumb.css +51 -0
- package/eject/files/breadcrumb.ts +42 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +52 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/combobox.css +269 -0
- package/eject/files/combobox.ts +85 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +375 -0
- package/eject/files/date-picker.ts +280 -0
- package/eject/files/date-range-picker.ts +338 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/link.css +64 -0
- package/eject/files/link.ts +63 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +192 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/overlay.css +40 -0
- package/eject/files/pagination.css +106 -0
- package/eject/files/pagination.ts +68 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/popover.css +101 -0
- package/eject/files/popover.ts +37 -0
- package/eject/files/progress-bar.ts +26 -0
- package/eject/files/radio-group.css +184 -0
- package/eject/files/radio-group.ts +30 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +33 -0
- package/eject/files/select.css +347 -0
- package/eject/files/select.ts +77 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +160 -0
- package/eject/files/slider.ts +80 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +45 -0
- package/eject/files/table.css +107 -0
- package/eject/files/table.ts +84 -0
- package/eject/files/tabs.css +120 -0
- package/eject/files/tabs.ts +37 -0
- package/eject/files/text-field.css +225 -0
- package/eject/files/text-field.ts +64 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/time-picker.ts +113 -0
- package/eject/files/toast-queue.ts +64 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +111 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +1122 -0
- package/package.json +11 -4
- package/styles.css +1135 -167
- package/tailwind.css +1295 -218
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
// An icon from design/icons. It takes the color of the text around it. An arrow or a chevron
|
|
7
|
+
// mirrors itself in a right-to-left layout when given `rtl:-scale-x-100` in `class`, which
|
|
8
|
+
// falls through to the drawing.
|
|
9
|
+
import { icons, useDefaults } from "@xds/vue/base";
|
|
10
|
+
import { type IconBaseProps, iconClass } from "./icon.ts";
|
|
11
|
+
import { classes, rootPart } from "./parts.ts";
|
|
12
|
+
|
|
13
|
+
export type IconProps = IconBaseProps;
|
|
14
|
+
|
|
15
|
+
const { name, size, filled = false, label } = defineProps<IconProps>();
|
|
16
|
+
const options = useDefaults("Icon", () => ({ size }));
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<svg
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
:fill="filled ? 'currentColor' : 'none'"
|
|
23
|
+
stroke="currentColor"
|
|
24
|
+
stroke-width="2"
|
|
25
|
+
stroke-linecap="round"
|
|
26
|
+
stroke-linejoin="round"
|
|
27
|
+
:class="classes(rootPart('Icon'), iconClass(options.size))"
|
|
28
|
+
:role="label ? 'img' : undefined"
|
|
29
|
+
:aria-label="label || undefined"
|
|
30
|
+
:aria-hidden="label ? undefined : 'true'"
|
|
31
|
+
>
|
|
32
|
+
<path v-for="(path, index) in icons[name]" :key="index" :d="path" />
|
|
33
|
+
</svg>
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { focusable, useDefaults, useTrigger, withAttributes } from "@xds/vue/base";
|
|
7
|
+
import { type ButtonHTMLAttributes, useTemplateRef } from "vue";
|
|
8
|
+
// A button that holds only an icon, in Button's variants, sizes and states. It is a square as
|
|
9
|
+
// tall as a Button of its size, and its pressable area is never smaller than the minimum
|
|
10
|
+
// target, even when the square is. Like Button, it opens a Menu or a Tooltip it is the trigger
|
|
11
|
+
// of.
|
|
12
|
+
import { buttonClass, ICON_BUTTON_BOX, type IconButtonBaseProps, isHeld } from "./button.ts";
|
|
13
|
+
import Icon from "./Icon.vue";
|
|
14
|
+
import Spinner from "./Spinner.vue";
|
|
15
|
+
|
|
16
|
+
// The app's attributes are bound with the trigger's: see withAttributes.
|
|
17
|
+
defineOptions({ inheritAttrs: false });
|
|
18
|
+
export type IconButtonProps = IconButtonBaseProps;
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
icon,
|
|
22
|
+
label,
|
|
23
|
+
variant,
|
|
24
|
+
size,
|
|
25
|
+
// Undefined unless given, so that only a toggle says whether it is pressed.
|
|
26
|
+
selected = undefined,
|
|
27
|
+
disabled = false,
|
|
28
|
+
loading = false,
|
|
29
|
+
} = defineProps<IconButtonProps>();
|
|
30
|
+
const emit = defineEmits<{
|
|
31
|
+
press: [];
|
|
32
|
+
focus: [event: FocusEvent];
|
|
33
|
+
blur: [event: FocusEvent];
|
|
34
|
+
}>();
|
|
35
|
+
const button = useTemplateRef<HTMLButtonElement>("button");
|
|
36
|
+
defineExpose(focusable(() => button.value));
|
|
37
|
+
const options = useDefaults("IconButton", () => ({ variant, size }), {
|
|
38
|
+
variant: "ghost",
|
|
39
|
+
size: "md",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const attributes = useTrigger(
|
|
43
|
+
(): ButtonHTMLAttributes & { "data-pending"?: "" } => ({
|
|
44
|
+
type: "button",
|
|
45
|
+
class: buttonClass({ ...options.value, iconButton: true }),
|
|
46
|
+
disabled,
|
|
47
|
+
"aria-disabled": loading ? "true" : undefined,
|
|
48
|
+
"data-pending": loading ? "" : undefined,
|
|
49
|
+
"aria-pressed": selected === undefined ? undefined : selected ? "true" : "false",
|
|
50
|
+
"aria-label": label,
|
|
51
|
+
onFocus: (event: FocusEvent) => emit("focus", event),
|
|
52
|
+
onBlur: (event: FocusEvent) => emit("blur", event),
|
|
53
|
+
onClick: () => {
|
|
54
|
+
if (!loading) emit("press");
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
() => loading,
|
|
58
|
+
);
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<button ref="button" v-bind="withAttributes(attributes, $attrs)">
|
|
63
|
+
<span v-if="loading" :class="ICON_BUTTON_BOX[options.size]"><Spinner size="sm" /></span>
|
|
64
|
+
<Icon
|
|
65
|
+
v-else
|
|
66
|
+
:name="icon"
|
|
67
|
+
:size="options.size"
|
|
68
|
+
:filled="isHeld({ variant: options.variant, selected, disabled })"
|
|
69
|
+
/>
|
|
70
|
+
</button>
|
|
71
|
+
</template>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { focusable } from "@xds/vue/base";
|
|
7
|
+
import { computed, useTemplateRef } from "vue";
|
|
8
|
+
import Icon from "./Icon.vue";
|
|
9
|
+
// Text that takes the person somewhere, in the type of the text around it. It is underlined, so
|
|
10
|
+
// it does not depend on color. With `href` it is a native link; without one, a button that
|
|
11
|
+
// assistive technology hears as a link.
|
|
12
|
+
import { LINK_ICON, LINK_PARTS, type LinkBaseProps, linkElement } from "./link.ts";
|
|
13
|
+
import { rootPart } from "./parts.ts";
|
|
14
|
+
|
|
15
|
+
export type LinkProps = LinkBaseProps;
|
|
16
|
+
|
|
17
|
+
const { href, external = false, disabled = false } = defineProps<LinkProps>();
|
|
18
|
+
/** `press` comes before the browser follows `href`. A disabled link never sends it. */
|
|
19
|
+
const emit = defineEmits<{ press: []; focus: [event: FocusEvent]; blur: [event: FocusEvent] }>();
|
|
20
|
+
const root = useTemplateRef<HTMLElement>("root");
|
|
21
|
+
defineExpose(focusable(() => root.value));
|
|
22
|
+
defineSlots<{
|
|
23
|
+
/** The text, which names the link. */
|
|
24
|
+
default(): unknown;
|
|
25
|
+
}>();
|
|
26
|
+
const element = computed(() => linkElement({ href, external, disabled }));
|
|
27
|
+
|
|
28
|
+
function press() {
|
|
29
|
+
if (!disabled) emit("press");
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<component
|
|
35
|
+
:is="element.tag"
|
|
36
|
+
ref="root"
|
|
37
|
+
v-bind="element.attributes"
|
|
38
|
+
:class="rootPart('Link')"
|
|
39
|
+
@click="press"
|
|
40
|
+
@focus="emit('focus', $event)"
|
|
41
|
+
@blur="emit('blur', $event)"
|
|
42
|
+
><slot /><Icon
|
|
43
|
+
v-if="external"
|
|
44
|
+
:name="LINK_ICON.name"
|
|
45
|
+
:size="LINK_ICON.size"
|
|
46
|
+
:class="LINK_PARTS.icon"
|
|
47
|
+
/></component>
|
|
48
|
+
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
// One line of a list or a settings screen. Separate rows with a Divider.
|
|
7
|
+
import type { ListRowBaseProps } from "./list-row.ts";
|
|
8
|
+
import { rootPart } from "./parts.ts";
|
|
9
|
+
import PlaceRow from "./PlaceRow.vue";
|
|
10
|
+
|
|
11
|
+
export type ListRowProps = ListRowBaseProps & {
|
|
12
|
+
/**
|
|
13
|
+
* Makes the whole row a button. Do not put another control in `trailing` then. A prop rather
|
|
14
|
+
* than an event, since whether there is one decides what is drawn.
|
|
15
|
+
*/
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const props = defineProps<ListRowProps>();
|
|
20
|
+
defineSlots<{
|
|
21
|
+
/** In front of the title: an avatar or an icon. */
|
|
22
|
+
leading?(): unknown;
|
|
23
|
+
/** At the far end: a value, a badge or a switch. */
|
|
24
|
+
trailing?(): unknown;
|
|
25
|
+
}>();
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<PlaceRow v-bind="props" current="true" :class="rootPart('ListRow')">
|
|
30
|
+
<template v-if="$slots.leading" #leading><slot name="leading" /></template>
|
|
31
|
+
<template v-if="$slots.trailing" #trailing><slot name="trailing" /></template>
|
|
32
|
+
</PlaceRow>
|
|
33
|
+
</template>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { useDefaults } from "@xds/vue/base";
|
|
7
|
+
import { computed, useId } from "vue";
|
|
8
|
+
import {
|
|
9
|
+
MEDIA_CARD_PARTS,
|
|
10
|
+
type MediaCardBaseProps,
|
|
11
|
+
mediaCardContentClass,
|
|
12
|
+
mediaCardIds,
|
|
13
|
+
mediaCardThumbnailClass,
|
|
14
|
+
} from "./media-card.ts";
|
|
15
|
+
// A thumbnail with its title and details: a video in a feed, an article in a list.
|
|
16
|
+
//
|
|
17
|
+
// With `onPress` the whole card is one button with no surface at rest: under a pointer and
|
|
18
|
+
// while pressed it takes the card's fills, and it has a focus ring. The button is named by the
|
|
19
|
+
// title followed by the details. `action` is a separate control beside it, so pressing it does
|
|
20
|
+
// not press the card.
|
|
21
|
+
import { classes, rootPart } from "./parts.ts";
|
|
22
|
+
import Thumbnail from "./Thumbnail.vue";
|
|
23
|
+
|
|
24
|
+
export type MediaCardProps = MediaCardBaseProps & {
|
|
25
|
+
/**
|
|
26
|
+
* Makes the whole card one button. A prop rather than an event, since whether there is one
|
|
27
|
+
* decides what is drawn.
|
|
28
|
+
*/
|
|
29
|
+
onPress?: () => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
title,
|
|
34
|
+
meta,
|
|
35
|
+
layout,
|
|
36
|
+
src,
|
|
37
|
+
alt = "",
|
|
38
|
+
// The card's own ratio, not one the app gives its other thumbnails.
|
|
39
|
+
ratio = "16:9",
|
|
40
|
+
badge,
|
|
41
|
+
progress,
|
|
42
|
+
onPress,
|
|
43
|
+
} = defineProps<MediaCardProps>();
|
|
44
|
+
const slots = defineSlots<{
|
|
45
|
+
/** Before the text in the vertical layout, such as an Avatar. */
|
|
46
|
+
leading?(): unknown;
|
|
47
|
+
/** At the end of the text: an IconButton or a Menu. It stays a control of its own. */
|
|
48
|
+
action?(): unknown;
|
|
49
|
+
}>();
|
|
50
|
+
|
|
51
|
+
const id = useId();
|
|
52
|
+
const ids = computed(() => mediaCardIds(id, meta));
|
|
53
|
+
const options = useDefaults("MediaCard", () => ({ layout }), { layout: "vertical" });
|
|
54
|
+
const horizontal = computed(() => options.value.layout === "horizontal");
|
|
55
|
+
const pressable = computed(() => onPress !== undefined);
|
|
56
|
+
// On a pressable card the button says all of this, so the parts are hidden from assistive
|
|
57
|
+
// technology and only the action is left beside it.
|
|
58
|
+
const hidden = computed(() => (pressable.value ? "true" : undefined));
|
|
59
|
+
// A group, not a fieldset, when it is not pressable: a fieldset groups form controls, and sizes
|
|
60
|
+
// itself to its content, which would undo the ellipses.
|
|
61
|
+
const root = computed(() =>
|
|
62
|
+
pressable.value
|
|
63
|
+
? { class: classes(rootPart("MediaCard"), MEDIA_CARD_PARTS.pressable) }
|
|
64
|
+
: {
|
|
65
|
+
role: "group",
|
|
66
|
+
"aria-labelledby": ids.value.names,
|
|
67
|
+
class: classes(rootPart("MediaCard"), MEDIA_CARD_PARTS.group),
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<div v-bind="root">
|
|
74
|
+
<button
|
|
75
|
+
v-if="pressable"
|
|
76
|
+
type="button"
|
|
77
|
+
:aria-labelledby="ids.names"
|
|
78
|
+
:class="MEDIA_CARD_PARTS.button"
|
|
79
|
+
@click="onPress?.()"
|
|
80
|
+
/>
|
|
81
|
+
<div :class="mediaCardContentClass({ horizontal, pressable })">
|
|
82
|
+
<span :aria-hidden="hidden" :class="mediaCardThumbnailClass(horizontal)">
|
|
83
|
+
<Thumbnail :src="src" :alt="alt" :ratio="ratio" :badge="badge" :progress="progress" />
|
|
84
|
+
</span>
|
|
85
|
+
<div :class="MEDIA_CARD_PARTS.body">
|
|
86
|
+
<span
|
|
87
|
+
v-if="!horizontal && slots.leading"
|
|
88
|
+
:aria-hidden="hidden"
|
|
89
|
+
:class="MEDIA_CARD_PARTS.leading"
|
|
90
|
+
>
|
|
91
|
+
<slot name="leading" />
|
|
92
|
+
</span>
|
|
93
|
+
<span :aria-hidden="hidden" :class="MEDIA_CARD_PARTS.text">
|
|
94
|
+
<span :id="ids.title" :class="MEDIA_CARD_PARTS.title">{{ title }}</span>
|
|
95
|
+
<!-- Two details may read the same, so they are told apart by their position. -->
|
|
96
|
+
<span
|
|
97
|
+
v-for="(line, index) in meta"
|
|
98
|
+
:id="ids.details[index]"
|
|
99
|
+
:key="index"
|
|
100
|
+
:class="MEDIA_CARD_PARTS.meta"
|
|
101
|
+
>
|
|
102
|
+
{{ line }}
|
|
103
|
+
</span>
|
|
104
|
+
</span>
|
|
105
|
+
<div v-if="slots.action" :class="MEDIA_CARD_PARTS.action"><slot name="action" /></div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
// A list of actions that opens from a control. Choosing an item calls its `onSelect` and
|
|
7
|
+
// closes the menu; a press outside or Escape closes it too, and focus goes back to the
|
|
8
|
+
// trigger.
|
|
9
|
+
//
|
|
10
|
+
// The trigger reports that it opens a menu and whether the menu is open. The arrow keys move
|
|
11
|
+
// the highlight and Enter chooses.
|
|
12
|
+
import {
|
|
13
|
+
keepListKeys,
|
|
14
|
+
leaveEscapeToFields,
|
|
15
|
+
Portal,
|
|
16
|
+
readCssPx,
|
|
17
|
+
space,
|
|
18
|
+
type TriggerProps,
|
|
19
|
+
TriggerScope,
|
|
20
|
+
underlayLayerStyle,
|
|
21
|
+
useModalPopover,
|
|
22
|
+
usePresence,
|
|
23
|
+
} from "@xds/vue/base";
|
|
24
|
+
import * as menu from "@zag-js/menu";
|
|
25
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/vue";
|
|
26
|
+
import { computed, useId, useTemplateRef } from "vue";
|
|
27
|
+
import Icon from "./Icon.vue";
|
|
28
|
+
import {
|
|
29
|
+
firstMenuValue,
|
|
30
|
+
layoutRect,
|
|
31
|
+
type MenuBaseProps,
|
|
32
|
+
menuItemClass,
|
|
33
|
+
opensOnPress,
|
|
34
|
+
} from "./menu.ts";
|
|
35
|
+
|
|
36
|
+
export type { MenuItem } from "./menu.ts";
|
|
37
|
+
|
|
38
|
+
export type MenuProps = MenuBaseProps;
|
|
39
|
+
|
|
40
|
+
// What the app puts on the root (its class, style, id and `data-*` attributes) goes on the menu
|
|
41
|
+
// itself: the root is the trigger and a Teleport, with no element of the menu's own.
|
|
42
|
+
defineOptions({ inheritAttrs: false });
|
|
43
|
+
// The app's id is the surface's, which Zag names too: the machine is given it, so that what
|
|
44
|
+
// points at the surface points at that id.
|
|
45
|
+
const { label, items, align = "start", id: appId } = defineProps<MenuProps & { id?: string }>();
|
|
46
|
+
defineSlots<{
|
|
47
|
+
/** The control that opens the menu: a Button or an IconButton. */
|
|
48
|
+
trigger(): unknown;
|
|
49
|
+
}>();
|
|
50
|
+
|
|
51
|
+
const id = useId();
|
|
52
|
+
const service = useMachine(
|
|
53
|
+
menu.machine,
|
|
54
|
+
computed((): menu.Props => ({
|
|
55
|
+
id,
|
|
56
|
+
ids: { content: appId },
|
|
57
|
+
"aria-label": label,
|
|
58
|
+
positioning: {
|
|
59
|
+
placement: `bottom-${align}`,
|
|
60
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
61
|
+
getAnchorRect: (anchor) => (anchor instanceof HTMLElement ? layoutRect(anchor) : null),
|
|
62
|
+
},
|
|
63
|
+
onSelect: (details) => {
|
|
64
|
+
// The values are positions, because two items may have the same label.
|
|
65
|
+
const item = items[Number(details.value)];
|
|
66
|
+
if (item && item !== "separator") item.onSelect();
|
|
67
|
+
},
|
|
68
|
+
onEscapeKeyDown: leaveEscapeToFields,
|
|
69
|
+
// The arrow keys go round from the last item to the first, as in a native menu.
|
|
70
|
+
loopFocus: true,
|
|
71
|
+
})),
|
|
72
|
+
);
|
|
73
|
+
const api = computed(() => menu.connect(service, normalizeProps));
|
|
74
|
+
|
|
75
|
+
// Whether the last press on the trigger opened the menu, which its click must then not do.
|
|
76
|
+
let pressOpened = false;
|
|
77
|
+
const trigger = computed(() => {
|
|
78
|
+
// Zag's handler for a press is left out: it keeps the press from focusing the trigger, so
|
|
79
|
+
// the focus would reach the menu, and come back to the trigger as the menu closes, only
|
|
80
|
+
// from a script, which the browser marks with the keyboard ring.
|
|
81
|
+
const { onPointerdown: _onPointerdown, ...rest } = api.value.getTriggerProps() as TriggerProps;
|
|
82
|
+
return mergeProps(rest, {
|
|
83
|
+
// Added to the control's own class; the trigger looks pressed while its menu is open.
|
|
84
|
+
class: "{{prefix}}-menu__trigger",
|
|
85
|
+
// A mouse opens the menu as its button goes down; touch and pen open it on the click, as
|
|
86
|
+
// Zag does.
|
|
87
|
+
onPointerdown: (event: PointerEvent) => {
|
|
88
|
+
pressOpened = opensOnPress(event) && !api.value.open;
|
|
89
|
+
if (pressOpened) api.value.setOpen(true);
|
|
90
|
+
},
|
|
91
|
+
onClick: (event: MouseEvent) => {
|
|
92
|
+
// A click with no pointer behind it comes from a screen reader or a script.
|
|
93
|
+
const pointer = event.detail !== 0;
|
|
94
|
+
// The press opened the menu already. This handler runs before Zag's, which skips a
|
|
95
|
+
// handled click. Not told by the click's pointer type: a browser may send the click as a
|
|
96
|
+
// plain mouse event.
|
|
97
|
+
if (pressOpened && pointer) {
|
|
98
|
+
pressOpened = false;
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (pointer) return;
|
|
103
|
+
// After the machine has opened the menu.
|
|
104
|
+
requestAnimationFrame(() => {
|
|
105
|
+
if (!api.value.open) return;
|
|
106
|
+
const first = firstMenuValue(items);
|
|
107
|
+
if (first !== undefined) api.value.setHighlightedValue(first);
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
}) as TriggerProps;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const positioner = useTemplateRef<HTMLDivElement>("positioner");
|
|
114
|
+
const surface = useTemplateRef<HTMLDivElement>("surface");
|
|
115
|
+
useModalPopover(
|
|
116
|
+
() => api.value.open,
|
|
117
|
+
() => positioner.value,
|
|
118
|
+
);
|
|
119
|
+
const present = usePresence(
|
|
120
|
+
() => api.value.open,
|
|
121
|
+
() => [surface.value],
|
|
122
|
+
);
|
|
123
|
+
const content = computed(() =>
|
|
124
|
+
mergeProps(api.value.getContentProps(), {
|
|
125
|
+
// This handler runs before Zag's.
|
|
126
|
+
onKeydown: (event: KeyboardEvent) =>
|
|
127
|
+
keepListKeys(event, surface.value, ".{{prefix}}-menu__item:not([data-disabled])", (value) =>
|
|
128
|
+
api.value.setHighlightedValue(value),
|
|
129
|
+
),
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<template>
|
|
135
|
+
<TriggerScope :trigger="trigger"><slot name="trigger" /></TriggerScope>
|
|
136
|
+
<Portal>
|
|
137
|
+
<!-- Nothing inside opens an overlay from a control outside it. -->
|
|
138
|
+
<TriggerScope :trigger="null">
|
|
139
|
+
<!-- Takes a press outside, which then only closes the menu. The focus stays in the menu
|
|
140
|
+
until the menu hands it back to the trigger. -->
|
|
141
|
+
<div
|
|
142
|
+
v-if="api.open"
|
|
143
|
+
class="{{prefix}}-menu__underlay"
|
|
144
|
+
:style="underlayLayerStyle(api.getPositionerProps().style)"
|
|
145
|
+
@mousedown.prevent
|
|
146
|
+
/>
|
|
147
|
+
<div ref="positioner" v-bind="api.getPositionerProps()" class="{{prefix}}-menu__positioner">
|
|
148
|
+
<!-- Shown until its exit animation ends; Zag would hide it as it closes. -->
|
|
149
|
+
<div
|
|
150
|
+
v-bind="mergeProps(content, $attrs)"
|
|
151
|
+
ref="surface"
|
|
152
|
+
:hidden="!present"
|
|
153
|
+
class="{{prefix}}-menu"
|
|
154
|
+
>
|
|
155
|
+
<template v-for="(item, index) in items" :key="index">
|
|
156
|
+
<div
|
|
157
|
+
v-if="item === 'separator'"
|
|
158
|
+
v-bind="api.getSeparatorProps()"
|
|
159
|
+
class="{{prefix}}-menu__separator"
|
|
160
|
+
/>
|
|
161
|
+
<div
|
|
162
|
+
v-else
|
|
163
|
+
v-bind="api.getItemProps({ value: String(index), disabled: item.disabled })"
|
|
164
|
+
:class="menuItemClass(item.danger)"
|
|
165
|
+
>
|
|
166
|
+
<Icon
|
|
167
|
+
v-if="item.icon"
|
|
168
|
+
:name="item.icon"
|
|
169
|
+
size="sm"
|
|
170
|
+
class="{{prefix}}-menu__item-icon"
|
|
171
|
+
/>
|
|
172
|
+
<span class="flex-1">{{ item.label }}</span>
|
|
173
|
+
<!-- Named, so a screen reader hears the state that the check shows. -->
|
|
174
|
+
<Icon v-if="item.selected" name="check" size="sm" label="Selected" />
|
|
175
|
+
</div>
|
|
176
|
+
</template>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</TriggerScope>
|
|
180
|
+
</Portal>
|
|
181
|
+
</template>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { useControllable, useLabels } from "@xds/vue/base";
|
|
7
|
+
import { computed } from "vue";
|
|
8
|
+
import Icon from "./Icon.vue";
|
|
9
|
+
// Moves through a list split into pages: a step back, the first and the last pages, the page
|
|
10
|
+
// shown with an ellipsis for those left out, and a step on. A navigation landmark; the page
|
|
11
|
+
// shown is marked as the current page. Without `value` it keeps its own, from `defaultValue`.
|
|
12
|
+
import {
|
|
13
|
+
clampPage,
|
|
14
|
+
PAGINATION_PARTS,
|
|
15
|
+
PAGINATION_STEPS,
|
|
16
|
+
type PaginationBaseProps,
|
|
17
|
+
paginationEntries,
|
|
18
|
+
} from "./pagination.ts";
|
|
19
|
+
import { rootPart } from "./parts.ts";
|
|
20
|
+
|
|
21
|
+
export type PaginationProps = PaginationBaseProps;
|
|
22
|
+
|
|
23
|
+
// `v-model:value`, written out rather than with defineModel: see useControllable.
|
|
24
|
+
const {
|
|
25
|
+
value: given,
|
|
26
|
+
defaultValue,
|
|
27
|
+
count,
|
|
28
|
+
label,
|
|
29
|
+
previousLabel,
|
|
30
|
+
nextLabel,
|
|
31
|
+
} = defineProps<PaginationProps>();
|
|
32
|
+
const emit = defineEmits<{ "update:value": [value: number] }>();
|
|
33
|
+
const { value, set } = useControllable(
|
|
34
|
+
"value",
|
|
35
|
+
() => given,
|
|
36
|
+
() => defaultValue ?? 1,
|
|
37
|
+
(next) => emit("update:value", next),
|
|
38
|
+
);
|
|
39
|
+
const labels = useLabels();
|
|
40
|
+
const page = computed(() => clampPage(value.value ?? 1, count));
|
|
41
|
+
const last = computed(() => Math.max(1, Math.floor(count)));
|
|
42
|
+
const entries = computed(() => paginationEntries(page.value, count));
|
|
43
|
+
const go = (next: number) => {
|
|
44
|
+
if (next !== page.value && next >= 1 && next <= last.value) set(next);
|
|
45
|
+
};
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<nav :class="rootPart('Pagination')" :aria-label="label ?? labels.pagination">
|
|
50
|
+
<ul :class="PAGINATION_PARTS.list">
|
|
51
|
+
<li>
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
:class="PAGINATION_PARTS.step"
|
|
55
|
+
:aria-label="previousLabel ?? labels.previousPage"
|
|
56
|
+
:aria-disabled="page <= 1 ? true : undefined"
|
|
57
|
+
@click="go(page - 1)"
|
|
58
|
+
>
|
|
59
|
+
<Icon :name="PAGINATION_STEPS.previous" :size="PAGINATION_STEPS.size" />
|
|
60
|
+
</button>
|
|
61
|
+
</li>
|
|
62
|
+
<!-- A gap is known by where it is; a page by its number. -->
|
|
63
|
+
<li v-for="(entry, index) in entries" :key="entry === 'gap' ? `gap-${index}` : entry">
|
|
64
|
+
<span v-if="entry === 'gap'" :class="PAGINATION_PARTS.gap" aria-hidden="true">…</span>
|
|
65
|
+
<button
|
|
66
|
+
v-else
|
|
67
|
+
type="button"
|
|
68
|
+
:class="PAGINATION_PARTS.page"
|
|
69
|
+
:aria-current="entry === page ? 'page' : undefined"
|
|
70
|
+
@click="go(entry)"
|
|
71
|
+
>
|
|
72
|
+
{{ entry }}
|
|
73
|
+
</button>
|
|
74
|
+
</li>
|
|
75
|
+
<li>
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
:class="PAGINATION_PARTS.step"
|
|
79
|
+
:aria-label="nextLabel ?? labels.nextPage"
|
|
80
|
+
:aria-disabled="page >= last ? true : undefined"
|
|
81
|
+
@click="go(page + 1)"
|
|
82
|
+
>
|
|
83
|
+
<Icon :name="PAGINATION_STEPS.next" :size="PAGINATION_STEPS.size" />
|
|
84
|
+
</button>
|
|
85
|
+
</li>
|
|
86
|
+
</ul>
|
|
87
|
+
</nav>
|
|
88
|
+
</template>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/vue` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed } from "vue";
|
|
7
|
+
import Icon from "./Icon.vue";
|
|
8
|
+
// A ListRow that says what kind of current item its selected state is. A Sidebar's rows are the
|
|
9
|
+
// places of an app, so its selected row is the current page. Only for this package's own
|
|
10
|
+
// components: the index does not export it.
|
|
11
|
+
import {
|
|
12
|
+
LIST_ROW_PARTS,
|
|
13
|
+
type ListRowBaseProps,
|
|
14
|
+
listRowClass,
|
|
15
|
+
listRowDescriptionClass,
|
|
16
|
+
listRowTitleClass,
|
|
17
|
+
} from "./list-row.ts";
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
title,
|
|
21
|
+
description,
|
|
22
|
+
chevron = false,
|
|
23
|
+
selected = false,
|
|
24
|
+
compact = false,
|
|
25
|
+
disabled = false,
|
|
26
|
+
onPress,
|
|
27
|
+
current,
|
|
28
|
+
} = defineProps<ListRowBaseProps & { onPress?: () => void; current: "true" | "page" }>();
|
|
29
|
+
defineSlots<{ leading?(): unknown; trailing?(): unknown }>();
|
|
30
|
+
|
|
31
|
+
const pressable = computed(() => onPress !== undefined);
|
|
32
|
+
const row = computed(() =>
|
|
33
|
+
pressable.value
|
|
34
|
+
? { type: "button", disabled, onClick: () => onPress?.() }
|
|
35
|
+
: ({} as Record<string, never>),
|
|
36
|
+
);
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<component
|
|
41
|
+
:is="pressable ? 'button' : 'div'"
|
|
42
|
+
v-bind="row"
|
|
43
|
+
:aria-current="selected ? current : undefined"
|
|
44
|
+
:class="listRowClass({ compact, selected, pressable })"
|
|
45
|
+
>
|
|
46
|
+
<slot name="leading" />
|
|
47
|
+
<span :class="LIST_ROW_PARTS.text">
|
|
48
|
+
<span :class="listRowTitleClass({ compact, selected, disabled })">{{ title }}</span>
|
|
49
|
+
<span v-if="description" :class="listRowDescriptionClass(compact)">{{ description }}</span>
|
|
50
|
+
</span>
|
|
51
|
+
<slot name="trailing" />
|
|
52
|
+
<Icon v-if="chevron" name="chevron-right" size="sm" :class="LIST_ROW_PARTS.chevron" />
|
|
53
|
+
</component>
|
|
54
|
+
</template>
|