@xds/vue 1.1.0 → 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/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/Checkbox.vue_vue_type_script_setup_true_lang.js +11 -3
- 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/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/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/Select.vue.d.ts +3 -1
- package/dist/Select.vue_vue_type_script_setup_true_lang.js +41 -17
- 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/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/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/base.d.ts +13 -0
- package/dist/base.js +14 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +10 -1
- package/dist/preview.d.ts +20 -3
- package/dist/preview.js +29 -6
- 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 +1066 -168
- package/tailwind.css +1295 -218
package/dist/preview.js
CHANGED
|
@@ -7,10 +7,13 @@ import Spinner_default from "./Spinner.js";
|
|
|
7
7
|
import Button_default from "./Button.js";
|
|
8
8
|
import IconButton_default from "./IconButton.js";
|
|
9
9
|
import Banner_default from "./Banner.js";
|
|
10
|
+
import Link_default from "./Link.js";
|
|
11
|
+
import Breadcrumb_default from "./Breadcrumb.js";
|
|
10
12
|
import Card_default from "./Card.js";
|
|
11
13
|
import Checkbox_default from "./Checkbox.js";
|
|
12
14
|
import Chip_default from "./Chip.js";
|
|
13
15
|
import ChipBar_default from "./ChipBar.js";
|
|
16
|
+
import Combobox_default from "./Combobox.js";
|
|
14
17
|
import CountBadge_default from "./CountBadge.js";
|
|
15
18
|
import DatePicker_default from "./DatePicker.js";
|
|
16
19
|
import DateRangePicker_default from "./DateRangePicker.js";
|
|
@@ -23,6 +26,8 @@ import ListRow_default from "./ListRow.js";
|
|
|
23
26
|
import Thumbnail_default from "./Thumbnail.js";
|
|
24
27
|
import MediaCard_default from "./MediaCard.js";
|
|
25
28
|
import Menu_default from "./Menu.js";
|
|
29
|
+
import Pagination_default from "./Pagination.js";
|
|
30
|
+
import Popover_default from "./Popover.js";
|
|
26
31
|
import ProgressBar_default from "./ProgressBar.js";
|
|
27
32
|
import RadioGroup_default from "./RadioGroup.js";
|
|
28
33
|
import SearchField_default from "./SearchField.js";
|
|
@@ -33,10 +38,13 @@ import Sidebar_default from "./Sidebar.js";
|
|
|
33
38
|
import Skeleton_default from "./Skeleton.js";
|
|
34
39
|
import Slider_default from "./Slider.js";
|
|
35
40
|
import Switch_default from "./Switch.js";
|
|
41
|
+
import Table_default from "./Table.js";
|
|
36
42
|
import Tabs_default from "./Tabs.js";
|
|
37
43
|
import Text_default from "./Text.js";
|
|
38
44
|
import TextField_default from "./TextField.js";
|
|
45
|
+
import TimePicker_default from "./TimePicker.js";
|
|
39
46
|
import Toast_default from "./Toast.js";
|
|
47
|
+
import ToastQueue_default from "./ToastQueue.js";
|
|
40
48
|
import Tooltip_default from "./Tooltip.js";
|
|
41
49
|
import "./index.js";
|
|
42
50
|
import { camelize, defineComponent, h, inject, onBeforeUnmount, onMounted, provide, shallowReactive } from "vue";
|
|
@@ -48,24 +56,29 @@ var COMPONENTS = {
|
|
|
48
56
|
AvatarStack: AvatarStack_default,
|
|
49
57
|
Badge: Badge_default,
|
|
50
58
|
Banner: Banner_default,
|
|
59
|
+
Breadcrumb: Breadcrumb_default,
|
|
51
60
|
Button: Button_default,
|
|
52
61
|
Card: Card_default,
|
|
53
62
|
Checkbox: Checkbox_default,
|
|
54
63
|
Chip: Chip_default,
|
|
55
64
|
ChipBar: ChipBar_default,
|
|
65
|
+
Combobox: Combobox_default,
|
|
56
66
|
CountBadge: CountBadge_default,
|
|
57
67
|
DatePicker: DatePicker_default,
|
|
58
68
|
DateRangePicker: DateRangePicker_default,
|
|
59
69
|
Defaults: Defaults_default,
|
|
60
|
-
Labels: Labels_default,
|
|
61
70
|
Dialog: Dialog_default,
|
|
62
71
|
Divider: Divider_default,
|
|
63
72
|
EmptyState: EmptyState_default,
|
|
64
73
|
Icon: Icon_default,
|
|
65
74
|
IconButton: IconButton_default,
|
|
75
|
+
Labels: Labels_default,
|
|
76
|
+
Link: Link_default,
|
|
66
77
|
ListRow: ListRow_default,
|
|
67
78
|
MediaCard: MediaCard_default,
|
|
68
79
|
Menu: Menu_default,
|
|
80
|
+
Pagination: Pagination_default,
|
|
81
|
+
Popover: Popover_default,
|
|
69
82
|
ProgressBar: ProgressBar_default,
|
|
70
83
|
RadioGroup: RadioGroup_default,
|
|
71
84
|
SearchField: SearchField_default,
|
|
@@ -77,11 +90,14 @@ var COMPONENTS = {
|
|
|
77
90
|
Slider: Slider_default,
|
|
78
91
|
Spinner: Spinner_default,
|
|
79
92
|
Switch: Switch_default,
|
|
93
|
+
Table: Table_default,
|
|
80
94
|
Tabs: Tabs_default,
|
|
81
95
|
Text: Text_default,
|
|
82
96
|
TextField: TextField_default,
|
|
83
97
|
Thumbnail: Thumbnail_default,
|
|
98
|
+
TimePicker: TimePicker_default,
|
|
84
99
|
Toast: Toast_default,
|
|
100
|
+
ToastQueue: ToastQueue_default,
|
|
85
101
|
Tooltip: Tooltip_default
|
|
86
102
|
};
|
|
87
103
|
var MODELS = [
|
|
@@ -109,12 +125,19 @@ var Part = defineComponent({
|
|
|
109
125
|
}
|
|
110
126
|
});
|
|
111
127
|
var Preview = defineComponent({
|
|
112
|
-
props: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
128
|
+
props: {
|
|
129
|
+
screen: {
|
|
130
|
+
type: Object,
|
|
131
|
+
required: true
|
|
132
|
+
},
|
|
133
|
+
components: {
|
|
134
|
+
type: Object,
|
|
135
|
+
default: void 0
|
|
136
|
+
}
|
|
137
|
+
},
|
|
116
138
|
setup(props) {
|
|
117
139
|
const screen = props.screen;
|
|
140
|
+
const components = props.components;
|
|
118
141
|
const state = shallowReactive({ ...screen.state });
|
|
119
142
|
const host = {
|
|
120
143
|
state,
|
|
@@ -130,7 +153,7 @@ var Preview = defineComponent({
|
|
|
130
153
|
return h(slot.tag, attributes, slot.children.map(host.draw));
|
|
131
154
|
},
|
|
132
155
|
part: ({ name, props: given, children }) => {
|
|
133
|
-
const type = COMPONENTS[name];
|
|
156
|
+
const type = components?.[name] ?? COMPONENTS[name];
|
|
134
157
|
const declared = new Set(Object.keys(type.props ?? {}));
|
|
135
158
|
const props = {};
|
|
136
159
|
const slots = {};
|
|
@@ -0,0 +1,89 @@
|
|
|
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" generic="Value extends string = string">
|
|
6
|
+
import * as accordion from "@zag-js/accordion";
|
|
7
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/vue";
|
|
8
|
+
import { computed, useId } from "vue";
|
|
9
|
+
// Items whose bodies open and close under their titles, separated by hairlines. The chevron
|
|
10
|
+
// turns over when an item is open, so the state does not depend on color. Opening and closing
|
|
11
|
+
// animate the height, and do not for people who ask for less motion.
|
|
12
|
+
//
|
|
13
|
+
// Each title is a heading holding a button that says whether its body is expanded and which
|
|
14
|
+
// body it controls. A closed body is hidden, but the browser's find in page still opens it.
|
|
15
|
+
import {
|
|
16
|
+
ACCORDION_PARTS,
|
|
17
|
+
type AccordionBaseProps,
|
|
18
|
+
type AccordionItemBase,
|
|
19
|
+
focusTitleOnClick,
|
|
20
|
+
} from "./accordion.ts";
|
|
21
|
+
import AccordionPanel from "./AccordionPanel.vue";
|
|
22
|
+
import Icon from "./Icon.vue";
|
|
23
|
+
|
|
24
|
+
export type AccordionItem<Value extends string = string> = AccordionItemBase<Value> & {
|
|
25
|
+
/** The body, shown under the title while the item is open. */
|
|
26
|
+
content: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type AccordionProps<Value extends string = string> = AccordionBaseProps<Value> & {
|
|
30
|
+
items: readonly AccordionItem<Value>[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// `v-model:expanded`, written out rather than with defineModel: it takes a list it does not
|
|
34
|
+
// change, and hands back a new one, which the owner may change.
|
|
35
|
+
const { expanded, items, multiple = false } = defineProps<AccordionProps<Value>>();
|
|
36
|
+
const emit = defineEmits<{ "update:expanded": [expanded: Value[]] }>();
|
|
37
|
+
|
|
38
|
+
const id = useId();
|
|
39
|
+
const service = useMachine(
|
|
40
|
+
accordion.machine,
|
|
41
|
+
computed(() => ({
|
|
42
|
+
id,
|
|
43
|
+
value: [...expanded],
|
|
44
|
+
onValueChange: (details: accordion.ValueChangeDetails) =>
|
|
45
|
+
emit("update:expanded", details.value as Value[]),
|
|
46
|
+
multiple,
|
|
47
|
+
collapsible: true,
|
|
48
|
+
hiddenUntilFound: true,
|
|
49
|
+
})),
|
|
50
|
+
);
|
|
51
|
+
const api = computed(() => accordion.connect(service, normalizeProps));
|
|
52
|
+
const trigger = (value: Value) =>
|
|
53
|
+
// Runs before Zag's handler.
|
|
54
|
+
mergeProps(api.value.getItemTriggerProps({ value }), { onClick: focusTitleOnClick });
|
|
55
|
+
const body = (value: Value) => {
|
|
56
|
+
// The panel hides itself once it has finished closing.
|
|
57
|
+
const { hidden: _hidden, ...attributes } = api.value.getItemContentProps({ value });
|
|
58
|
+
return attributes;
|
|
59
|
+
};
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<div v-bind="api.getRootProps()" class="{{prefix}}-accordion">
|
|
64
|
+
<div
|
|
65
|
+
v-for="item in items"
|
|
66
|
+
:key="item.value"
|
|
67
|
+
v-bind="api.getItemProps({ value: item.value })"
|
|
68
|
+
class="{{prefix}}-accordion__item"
|
|
69
|
+
>
|
|
70
|
+
<h3
|
|
71
|
+
v-bind="api.getItemHeaderProps({ value: item.value })"
|
|
72
|
+
class="{{prefix}}-accordion__heading"
|
|
73
|
+
>
|
|
74
|
+
<button v-bind="trigger(item.value)" class="{{prefix}}-accordion__trigger group">
|
|
75
|
+
<span :class="ACCORDION_PARTS.text">
|
|
76
|
+
<span :class="ACCORDION_PARTS.title">{{ item.title }}</span>
|
|
77
|
+
<span v-if="item.description" :class="ACCORDION_PARTS.description">
|
|
78
|
+
{{ item.description }}
|
|
79
|
+
</span>
|
|
80
|
+
</span>
|
|
81
|
+
<Icon name="chevron-down" size="sm" :class="ACCORDION_PARTS.chevron" />
|
|
82
|
+
</button>
|
|
83
|
+
</h3>
|
|
84
|
+
<AccordionPanel :attributes="body(item.value)" :open="api.value.includes(item.value)">
|
|
85
|
+
{{ item.content }}
|
|
86
|
+
</AccordionPanel>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { onMounted, useTemplateRef, watch } from "vue";
|
|
7
|
+
// An item's body. Its height moves between zero and the height of what it holds, and it is
|
|
8
|
+
// hidden only once it has finished closing. Only for Accordion: the index does not export it.
|
|
9
|
+
import { setPanelOpen } from "./accordion.ts";
|
|
10
|
+
|
|
11
|
+
// Zag's attributes come first, so that the panel's own role and aria-hidden win.
|
|
12
|
+
const { open, attributes } = defineProps<{ open: boolean; attributes: Record<string, unknown> }>();
|
|
13
|
+
defineSlots<{ default(): unknown }>();
|
|
14
|
+
const panel = useTemplateRef<HTMLDivElement>("panel");
|
|
15
|
+
// A page rendered on the server shows the panel before onMounted can run, so a closed one starts
|
|
16
|
+
// hidden. Read once so setPanelOpen owns `hidden` from then on.
|
|
17
|
+
const closedAtFirst = !open;
|
|
18
|
+
|
|
19
|
+
// Set before the browser paints, so a closed panel never shows for a frame. Only a change
|
|
20
|
+
// animates.
|
|
21
|
+
onMounted(() => panel.value && setPanelOpen(panel.value, open, false));
|
|
22
|
+
watch(
|
|
23
|
+
() => open,
|
|
24
|
+
(isOpen, _, onCleanup) => {
|
|
25
|
+
// The next toggle takes over from this one.
|
|
26
|
+
if (panel.value) onCleanup(setPanelOpen(panel.value, isOpen, true));
|
|
27
|
+
},
|
|
28
|
+
{ flush: "post" },
|
|
29
|
+
);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<!-- A group: a region is a landmark, and a page of accordions would fill the list of
|
|
34
|
+
landmarks. A closed one is left out of the accessibility tree as soon as it starts
|
|
35
|
+
closing; `hidden="until-found"` alone leaves the empty group in it. A group, not a
|
|
36
|
+
fieldset: it is the body of a disclosure, not a set of form fields. -->
|
|
37
|
+
<div
|
|
38
|
+
v-bind="attributes"
|
|
39
|
+
ref="panel"
|
|
40
|
+
:hidden="closedAtFirst || undefined"
|
|
41
|
+
role="group"
|
|
42
|
+
:aria-hidden="open ? undefined : 'true'"
|
|
43
|
+
class="{{prefix}}-accordion__panel"
|
|
44
|
+
>
|
|
45
|
+
<div class="{{prefix}}-accordion__body"><slot /></div>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
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, usePicture } from "@xds/vue/base";
|
|
7
|
+
// Stands for a person or a team by a picture, or by their initials when there is none.
|
|
8
|
+
// Assistive technology gets the full name either way. The small size has room for one letter.
|
|
9
|
+
import { type AvatarBaseProps, avatarClass, avatarInitials, pictureClass } from "./avatar.ts";
|
|
10
|
+
import { classes, rootPart } from "./parts.ts";
|
|
11
|
+
|
|
12
|
+
export type { AvatarSize } from "./avatar.ts";
|
|
13
|
+
|
|
14
|
+
export type AvatarProps = AvatarBaseProps;
|
|
15
|
+
|
|
16
|
+
const { name, src, size } = defineProps<AvatarProps>();
|
|
17
|
+
const options = useDefaults("Avatar", () => ({ size }));
|
|
18
|
+
// The picture has no name of its own: the name is on the avatar itself, and a second one
|
|
19
|
+
// would be read twice.
|
|
20
|
+
const picture = usePicture(() => src);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<span
|
|
25
|
+
role="img"
|
|
26
|
+
:aria-label="name"
|
|
27
|
+
:class="classes(rootPart('Avatar'), avatarClass(options.size))"
|
|
28
|
+
>
|
|
29
|
+
{{ avatarInitials(name, options.size)
|
|
30
|
+
}}<img
|
|
31
|
+
v-if="picture.loaded.value !== false && src"
|
|
32
|
+
:ref="(el) => picture.sync(el, src)"
|
|
33
|
+
:src="src"
|
|
34
|
+
alt=""
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
:class="pictureClass(picture.loaded.value === true)"
|
|
37
|
+
@load="picture.onLoad(src)"
|
|
38
|
+
@error="picture.onError(src)"
|
|
39
|
+
/>
|
|
40
|
+
</span>
|
|
41
|
+
</template>
|
|
@@ -0,0 +1,46 @@
|
|
|
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 } from "vue";
|
|
8
|
+
// Several people in the room of one. Assistive technology gets one image named after
|
|
9
|
+
// everyone in it, including those who did not fit.
|
|
10
|
+
import {
|
|
11
|
+
type AvatarStackBaseProps,
|
|
12
|
+
avatarStack,
|
|
13
|
+
avatarStackClass,
|
|
14
|
+
avatarStackItemClass,
|
|
15
|
+
avatarStackRestClass,
|
|
16
|
+
} from "./avatar-stack.ts";
|
|
17
|
+
import Avatar from "./Avatar.vue";
|
|
18
|
+
import { classes, rootPart } from "./parts.ts";
|
|
19
|
+
|
|
20
|
+
export type AvatarStackProps = AvatarStackBaseProps;
|
|
21
|
+
|
|
22
|
+
const { people, max, size, label } = defineProps<AvatarStackProps>();
|
|
23
|
+
const stack = computed(() => avatarStack(people, max, label));
|
|
24
|
+
// A size, always: the avatars are drawn at the stack's, not at an Avatar default around it.
|
|
25
|
+
const options = useDefaults("AvatarStack", () => ({ size }), { size: "md" });
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<span
|
|
30
|
+
role="img"
|
|
31
|
+
:aria-label="stack.name"
|
|
32
|
+
:class="classes(rootPart('AvatarStack'), avatarStackClass)"
|
|
33
|
+
>
|
|
34
|
+
<span
|
|
35
|
+
v-for="(person, index) in stack.shown"
|
|
36
|
+
:key="index"
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
:class="avatarStackItemClass(options.size)"
|
|
39
|
+
>
|
|
40
|
+
<Avatar :name="person.name" :src="person.src" :size="options.size" />
|
|
41
|
+
</span>
|
|
42
|
+
<span v-if="stack.rest > 0" aria-hidden="true" :class="avatarStackRestClass(options.size)"
|
|
43
|
+
>+{{ stack.rest }}</span
|
|
44
|
+
>
|
|
45
|
+
</span>
|
|
46
|
+
</template>
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
// A short status or category. The words carry the meaning; the color only reinforces it, so a
|
|
8
|
+
// badge still reads for someone who cannot tell the tones apart. `dot` adds a small mark for
|
|
9
|
+
// live states such as "connected", and `icon` a drawing in front of the words.
|
|
10
|
+
import { type BadgeBaseProps, badgeClass, badgeDotClass } from "./badge.ts";
|
|
11
|
+
import Icon from "./Icon.vue";
|
|
12
|
+
import { classes, rootPart } from "./parts.ts";
|
|
13
|
+
|
|
14
|
+
export type { BadgeTone } from "./badge.ts";
|
|
15
|
+
|
|
16
|
+
export type BadgeProps = BadgeBaseProps;
|
|
17
|
+
|
|
18
|
+
const { tone, dot = false, icon } = defineProps<BadgeProps>();
|
|
19
|
+
defineSlots<{ default(): unknown }>();
|
|
20
|
+
const options = useDefaults("Badge", () => ({ tone }));
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<span :class="classes(rootPart('Badge'), badgeClass(options.tone))">
|
|
25
|
+
<span v-if="dot" aria-hidden="true" :class="badgeDotClass" />
|
|
26
|
+
<Icon v-if="icon" :name="icon" size="xs" />
|
|
27
|
+
<slot />
|
|
28
|
+
</span>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,65 @@
|
|
|
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, useLabels } from "@xds/vue/base";
|
|
7
|
+
// A message about the whole view or a section of it. Each tone has its own icon shape, so the
|
|
8
|
+
// tone does not depend on color. Problems (`warning`, `danger`) interrupt a screen reader;
|
|
9
|
+
// `info` and `success` wait their turn.
|
|
10
|
+
import {
|
|
11
|
+
BANNER_PARTS,
|
|
12
|
+
type BannerBaseProps,
|
|
13
|
+
bannerClass,
|
|
14
|
+
bannerIconClass,
|
|
15
|
+
bannerIconPath,
|
|
16
|
+
bannerRole,
|
|
17
|
+
} from "./banner.ts";
|
|
18
|
+
import Button from "./Button.vue";
|
|
19
|
+
import IconButton from "./IconButton.vue";
|
|
20
|
+
import { classes, rootPart } from "./parts.ts";
|
|
21
|
+
|
|
22
|
+
export type { BannerTone } from "./banner.ts";
|
|
23
|
+
|
|
24
|
+
export type BannerProps = BannerBaseProps & {
|
|
25
|
+
/** What the person can do about the message. Drawn under it as a small secondary button. */
|
|
26
|
+
action?: { label: string; onPress: () => void };
|
|
27
|
+
/**
|
|
28
|
+
* Shows a close control. The banner does not hide itself: the handler decides what happens
|
|
29
|
+
* to it. A prop rather than an event, since whether there is one decides what is drawn.
|
|
30
|
+
*/
|
|
31
|
+
onDismiss?: () => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { tone, title, dismissLabel, action, onDismiss } = defineProps<BannerProps>();
|
|
35
|
+
defineSlots<{ default(): unknown }>();
|
|
36
|
+
const options = useDefaults("Banner", () => ({ tone }));
|
|
37
|
+
const labels = useLabels();
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div
|
|
42
|
+
:role="bannerRole(options.tone)"
|
|
43
|
+
:class="classes(rootPart('Banner'), bannerClass(options.tone))"
|
|
44
|
+
>
|
|
45
|
+
<svg viewBox="0 0 24 24" aria-hidden="true" :class="bannerIconClass(options.tone)">
|
|
46
|
+
<path fill="currentColor" :d="bannerIconPath(options.tone)" />
|
|
47
|
+
</svg>
|
|
48
|
+
<div :class="BANNER_PARTS.body">
|
|
49
|
+
<p v-if="title" :class="BANNER_PARTS.title">{{ title }}</p>
|
|
50
|
+
<div><slot /></div>
|
|
51
|
+
<div v-if="action" :class="BANNER_PARTS.action">
|
|
52
|
+
<Button variant="secondary" size="sm" @press="action.onPress()">{{ action.label }}</Button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div v-if="onDismiss" :class="BANNER_PARTS.dismiss">
|
|
56
|
+
<IconButton
|
|
57
|
+
icon="x"
|
|
58
|
+
:label="dismissLabel ?? labels.dismiss"
|
|
59
|
+
variant="ghost"
|
|
60
|
+
size="sm"
|
|
61
|
+
@press="onDismiss()"
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { useLabels } from "@xds/vue/base";
|
|
7
|
+
// Where the current view sits in the app: the places above it, each a link, then the view
|
|
8
|
+
// itself. A navigation landmark; the current place is marked as the page.
|
|
9
|
+
import { BREADCRUMB_PARTS, BREADCRUMB_SEPARATOR, type BreadcrumbBaseProps } from "./breadcrumb.ts";
|
|
10
|
+
import Icon from "./Icon.vue";
|
|
11
|
+
import Link from "./Link.vue";
|
|
12
|
+
import { rootPart } from "./parts.ts";
|
|
13
|
+
|
|
14
|
+
export type { BreadcrumbItem } from "./breadcrumb.ts";
|
|
15
|
+
export type BreadcrumbProps = BreadcrumbBaseProps;
|
|
16
|
+
|
|
17
|
+
const { items, label } = defineProps<BreadcrumbProps>();
|
|
18
|
+
const labels = useLabels();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<nav :class="rootPart('Breadcrumb')" :aria-label="label ?? labels.breadcrumb">
|
|
23
|
+
<ol :class="BREADCRUMB_PARTS.list">
|
|
24
|
+
<!-- Two places of a trail can share a label, so a place is known by where it is. -->
|
|
25
|
+
<li v-for="(item, index) in items" :key="index" :class="BREADCRUMB_PARTS.item">
|
|
26
|
+
<span
|
|
27
|
+
v-if="index === items.length - 1"
|
|
28
|
+
aria-current="page"
|
|
29
|
+
:class="BREADCRUMB_PARTS.current"
|
|
30
|
+
>{{ item.label }}</span
|
|
31
|
+
>
|
|
32
|
+
<template v-else>
|
|
33
|
+
<Link :href="item.href" @press="item.onPress?.()">{{ item.label }}</Link>
|
|
34
|
+
<Icon
|
|
35
|
+
:name="BREADCRUMB_SEPARATOR.name"
|
|
36
|
+
:size="BREADCRUMB_SEPARATOR.size"
|
|
37
|
+
:class="BREADCRUMB_PARTS.separator"
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
40
|
+
</li>
|
|
41
|
+
</ol>
|
|
42
|
+
</nav>
|
|
43
|
+
</template>
|
|
@@ -0,0 +1,93 @@
|
|
|
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, computed, useTemplateRef } from "vue";
|
|
8
|
+
// A native button. It also opens a Menu or a Tooltip it is the trigger of: their props reach
|
|
9
|
+
// it through provide and inject.
|
|
10
|
+
import { BUTTON_ICON, type ButtonBaseProps, buttonClass, isHeld } from "./button.ts";
|
|
11
|
+
import Icon from "./Icon.vue";
|
|
12
|
+
import Spinner from "./Spinner.vue";
|
|
13
|
+
|
|
14
|
+
// `aria-label` is declared as `ariaLabel`: Vue keeps a prop under its camelized name, and a
|
|
15
|
+
// template still writes `aria-label`.
|
|
16
|
+
|
|
17
|
+
// The app's attributes are bound with the trigger's: see withAttributes.
|
|
18
|
+
defineOptions({ inheritAttrs: false });
|
|
19
|
+
export type ButtonProps = Omit<ButtonBaseProps, "aria-label"> & { ariaLabel?: string };
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
variant,
|
|
23
|
+
size,
|
|
24
|
+
iconStart,
|
|
25
|
+
iconEnd,
|
|
26
|
+
// Undefined unless given, so that only a toggle says whether it is pressed.
|
|
27
|
+
selected = undefined,
|
|
28
|
+
disabled = false,
|
|
29
|
+
loading = false,
|
|
30
|
+
fullWidth = false,
|
|
31
|
+
type = "button",
|
|
32
|
+
ariaLabel,
|
|
33
|
+
} = defineProps<ButtonProps>();
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
press: [];
|
|
36
|
+
focus: [event: FocusEvent];
|
|
37
|
+
blur: [event: FocusEvent];
|
|
38
|
+
}>();
|
|
39
|
+
const button = useTemplateRef<HTMLButtonElement>("button");
|
|
40
|
+
defineExpose(focusable(() => button.value));
|
|
41
|
+
const slots = defineSlots<{
|
|
42
|
+
/** Leave it out for a button that holds only an icon, and name that one with `aria-label`. */
|
|
43
|
+
default?(): unknown;
|
|
44
|
+
}>();
|
|
45
|
+
|
|
46
|
+
const options = useDefaults("Button", () => ({ variant, size }), {
|
|
47
|
+
variant: "secondary",
|
|
48
|
+
size: "md",
|
|
49
|
+
});
|
|
50
|
+
const icon = computed(() => BUTTON_ICON[options.value.size]);
|
|
51
|
+
const held = computed(() => isHeld({ variant: options.value.variant, selected, disabled }));
|
|
52
|
+
const attributes = useTrigger(
|
|
53
|
+
(): ButtonHTMLAttributes & { "data-pending"?: "" } => ({
|
|
54
|
+
type,
|
|
55
|
+
class: buttonClass({
|
|
56
|
+
variant: options.value.variant,
|
|
57
|
+
size: options.value.size,
|
|
58
|
+
iconOnly: !slots.default && (iconStart !== undefined || iconEnd !== undefined),
|
|
59
|
+
fullWidth,
|
|
60
|
+
}),
|
|
61
|
+
disabled,
|
|
62
|
+
// Loading keeps the button focusable, so focus is not lost while it waits.
|
|
63
|
+
"aria-disabled": loading ? "true" : undefined,
|
|
64
|
+
"data-pending": loading ? "" : undefined,
|
|
65
|
+
"aria-pressed": selected === undefined ? undefined : selected ? "true" : "false",
|
|
66
|
+
"aria-label": ariaLabel,
|
|
67
|
+
onFocus: (event: FocusEvent) => emit("focus", event),
|
|
68
|
+
onBlur: (event: FocusEvent) => emit("blur", event),
|
|
69
|
+
onClick: (event: MouseEvent) => {
|
|
70
|
+
// The press was taken already: block keyboard Enter/Space form submit or reset too.
|
|
71
|
+
if (loading) {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
emit("press");
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
() => loading,
|
|
79
|
+
);
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<button ref="button" v-bind="withAttributes(attributes, $attrs)">
|
|
84
|
+
<template v-if="loading">
|
|
85
|
+
<!-- Where the icon was, so the button keeps its width. -->
|
|
86
|
+
<span v-if="iconStart" :class="icon.box"><Spinner size="sm" /></span>
|
|
87
|
+
<Spinner v-else size="sm" />
|
|
88
|
+
</template>
|
|
89
|
+
<Icon v-else-if="iconStart" :name="iconStart" :size="icon.size" :filled="held" />
|
|
90
|
+
<slot />
|
|
91
|
+
<Icon v-if="iconEnd" :name="iconEnd" :size="icon.size" />
|
|
92
|
+
</button>
|
|
93
|
+
</template>
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { Wrap } from "@xds/vue/base";
|
|
7
|
+
import { computed } from "vue";
|
|
8
|
+
// A surface that groups related content. A hairline outline and a trace of shadow lift it off
|
|
9
|
+
// the page; in dark mode, where shadows barely show, the lighter fill does that. `title`
|
|
10
|
+
// renders as a heading; `actions` sit across from it.
|
|
11
|
+
import { CARD_PARTS, type CardBaseProps, cardClass, cardMediaClass } from "./card.ts";
|
|
12
|
+
import { classes, rootPart } from "./parts.ts";
|
|
13
|
+
|
|
14
|
+
export type CardProps = CardBaseProps & {
|
|
15
|
+
/**
|
|
16
|
+
* Makes the whole card one button. Put no other control inside it then. A prop rather than
|
|
17
|
+
* an event, since whether there is one decides what is drawn.
|
|
18
|
+
*/
|
|
19
|
+
onPress?: () => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
flush = false,
|
|
26
|
+
// Undefined unless given, so that only a toggle says whether it is pressed.
|
|
27
|
+
selected = undefined,
|
|
28
|
+
onPress,
|
|
29
|
+
} = defineProps<CardProps>();
|
|
30
|
+
const slots = defineSlots<{
|
|
31
|
+
/** Sit across from the title. A pressable card takes none: it is one button already. */
|
|
32
|
+
actions?(): unknown;
|
|
33
|
+
/** A picture or a drawing at the top, running edge to edge above the padding. */
|
|
34
|
+
media?(): unknown;
|
|
35
|
+
default?(): unknown;
|
|
36
|
+
}>();
|
|
37
|
+
|
|
38
|
+
const pressable = computed(() => onPress !== undefined);
|
|
39
|
+
// A button may hold only phrasing content, so inside one the parts are spans. Its heading
|
|
40
|
+
// would not be reachable as a heading anyway: a button reads as its text.
|
|
41
|
+
const tags = computed(() =>
|
|
42
|
+
pressable.value
|
|
43
|
+
? { header: "span", box: "span", title: "span", line: "span" }
|
|
44
|
+
: { header: "header", box: "div", title: "h2", line: "p" },
|
|
45
|
+
);
|
|
46
|
+
const surface = computed(() =>
|
|
47
|
+
pressable.value
|
|
48
|
+
? {
|
|
49
|
+
type: "button",
|
|
50
|
+
"aria-pressed": selected === undefined ? undefined : selected ? "true" : "false",
|
|
51
|
+
onClick: () => onPress?.(),
|
|
52
|
+
}
|
|
53
|
+
: { "aria-current": selected ? "true" : undefined },
|
|
54
|
+
);
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<component
|
|
59
|
+
:is="pressable ? 'button' : 'section'"
|
|
60
|
+
v-bind="surface"
|
|
61
|
+
:class="classes(rootPart('Card'), cardClass({ selected, flush, pressable }))"
|
|
62
|
+
>
|
|
63
|
+
<Wrap :when="flush" :tag="tags.box" :wrapper="CARD_PARTS.flush">
|
|
64
|
+
<component :is="tags.box" v-if="slots.media" :class="cardMediaClass(flush)">
|
|
65
|
+
<slot name="media" />
|
|
66
|
+
</component>
|
|
67
|
+
<component
|
|
68
|
+
:is="tags.header"
|
|
69
|
+
v-if="title || description || (slots.actions && !pressable)"
|
|
70
|
+
:class="CARD_PARTS.header"
|
|
71
|
+
>
|
|
72
|
+
<component :is="tags.box" :class="CARD_PARTS.heading">
|
|
73
|
+
<component :is="tags.title" v-if="title" :class="CARD_PARTS.title">{{ title }}</component>
|
|
74
|
+
<component :is="tags.line" v-if="description" :class="CARD_PARTS.description">
|
|
75
|
+
{{ description }}
|
|
76
|
+
</component>
|
|
77
|
+
</component>
|
|
78
|
+
<div v-if="slots.actions && !pressable" :class="CARD_PARTS.actions">
|
|
79
|
+
<slot name="actions" />
|
|
80
|
+
</div>
|
|
81
|
+
</component>
|
|
82
|
+
<slot />
|
|
83
|
+
</Wrap>
|
|
84
|
+
</component>
|
|
85
|
+
</template>
|