@vizejs/ui 0.443.0 → 0.454.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/accordion.d.mts +1 -1
- package/dist/action-sheet.d.mts +1 -1
- package/dist/alert-dialog.d.mts +1 -1
- package/dist/{announcer-D0bFq-HV.d.mts → announcer-DcI680jo.d.mts} +3351 -2952
- package/dist/announcer.d.mts +1 -1
- package/dist/autocomplete.d.mts +1 -1
- package/dist/avatar.d.mts +1 -1
- package/dist/badge.d.mts +1 -1
- package/dist/banner.d.mts +1 -1
- package/dist/block-ui.d.mts +1 -1
- package/dist/blockquote.d.mts +1 -1
- package/dist/{breadcrumb-DJIZ3zDG.d.mts → breadcrumb-Cdyh20z-.d.mts} +1 -1
- package/dist/breadcrumb.d.mts +1 -1
- package/dist/{calendar-C_ihbcsR.mjs → calendar-BaK_yoKC.mjs} +3 -3
- package/dist/{calendar-root-Dy3WPuNT.mjs → calendar-root-Bl1sv8qy.mjs} +2 -2
- package/dist/calendar.d.mts +1 -1
- package/dist/calendar.mjs +2 -2
- package/dist/callout.d.mts +1 -1
- package/dist/card.d.mts +1 -1
- package/dist/catalog.d.mts +47 -1
- package/dist/catalog.mjs +234 -119
- package/dist/chart.d.mts +1 -1
- package/dist/checkbox.d.mts +1 -1
- package/dist/code.d.mts +1 -1
- package/dist/collapsible.d.mts +1 -1
- package/dist/color-picker.d.mts +1 -1
- package/dist/combobox.d.mts +1 -1
- package/dist/command-palette.d.mts +1 -1
- package/dist/confirm.d.mts +1 -1
- package/dist/context-menu.d.mts +1 -1
- package/dist/copy-button.d.mts +1 -1
- package/dist/{date-picker-Bwt03r8S.mjs → date-picker-BsYXMErN.mjs} +1 -1
- package/dist/date-picker.mjs +1 -1
- package/dist/{date-range-picker-BBHrOLAU.mjs → date-range-picker-H2q9rFOA.mjs} +1 -1
- package/dist/date-range-picker.d.mts +1 -1
- package/dist/date-range-picker.mjs +1 -1
- package/dist/dialog.d.mts +1 -1
- package/dist/direction.d.mts +1 -1
- package/dist/drawer.d.mts +1 -1
- package/dist/dropdown-menu.d.mts +1 -1
- package/dist/{duration-field-BmykCKTC.mjs → duration-field-DowlJQvz.mjs} +3 -3
- package/dist/duration-field.d.mts +1 -1
- package/dist/duration-field.mjs +1 -1
- package/dist/empty-state.d.mts +1 -1
- package/dist/fieldset.d.mts +1 -1
- package/dist/file-upload.d.mts +1 -1
- package/dist/floating-action-button.d.mts +1 -1
- package/dist/focus-visible.d.mts +1 -1
- package/dist/fullscreen-button.d.mts +1 -1
- package/dist/heading.d.mts +1 -1
- package/dist/hover-card.d.mts +1 -1
- package/dist/icon-button.d.mts +1 -1
- package/dist/icon.d.mts +1 -1
- package/dist/{image-D9CEf8uD.d.mts → image-DCQeTHqi.d.mts} +2 -2
- package/dist/{image-cropper-BJsgLDjH.d.mts → image-cropper-BPAHa995.d.mts} +2 -2
- package/dist/image-cropper.d.mts +1 -1
- package/dist/image.d.mts +1 -1
- package/dist/index.d.mts +55 -55
- package/dist/index.mjs +14 -12
- package/dist/{input-C0fgeRnS.d.mts → input-D4Zvmf67.d.mts} +2 -2
- package/dist/input.d.mts +1 -1
- package/dist/kbd.d.mts +1 -1
- package/dist/landmark.d.mts +1 -1
- package/dist/list.d.mts +1 -1
- package/dist/listbox.d.mts +1 -1
- package/dist/locale.d.mts +1 -1
- package/dist/media-preferences.d.mts +1 -1
- package/dist/menu.d.mts +1 -1
- package/dist/menubar.d.mts +1 -1
- package/dist/{meter-ZZIKQTLX.mjs → meter-CxHgTYvs.mjs} +3 -2
- package/dist/{meter-B3m17_8g.d.mts → meter-LxMMvjjK.d.mts} +8 -1
- package/dist/meter.d.mts +1 -1
- package/dist/meter.mjs +1 -1
- package/dist/month-picker.d.mts +1 -1
- package/dist/native-select.d.mts +1 -1
- package/dist/navigation-rail-BBg5bin7.mjs +246 -0
- package/dist/navigation-rail.d.mts +2 -0
- package/dist/navigation-rail.mjs +2 -0
- package/dist/notification-center.d.mts +1 -1
- package/dist/pager.d.mts +1 -1
- package/dist/pagination.d.mts +1 -1
- package/dist/popconfirm.d.mts +1 -1
- package/dist/popover.d.mts +1 -1
- package/dist/print-button.d.mts +1 -1
- package/dist/{progress-bar-lXHO-U8x.mjs → progress-bar-DsH4Jgn2.mjs} +3 -1
- package/dist/progress-bar.d.mts +1 -1
- package/dist/progress-bar.mjs +1 -1
- package/dist/radio-group.d.mts +1 -1
- package/dist/{range-calendar-DL_eKx8L.d.mts → range-calendar-DInfduyf.d.mts} +2 -2
- package/dist/{range-calendar-root-CEhaPJAd.mjs → range-calendar-root-D9ZoZkWc.mjs} +2 -2
- package/dist/range-calendar.d.mts +1 -1
- package/dist/range-calendar.mjs +1 -1
- package/dist/resolver.d.mts +23 -1
- package/dist/resolver.mjs +23 -1
- package/dist/scroll-area.d.mts +1 -1
- package/dist/{search-field-zyMCYvZ2.d.mts → search-field-DzW31UHM.d.mts} +4 -4
- package/dist/search-field.d.mts +1 -1
- package/dist/select.d.mts +1 -1
- package/dist/share-button.d.mts +1 -1
- package/dist/sidebar.d.mts +1 -1
- package/dist/split-button-Cff_lsza.mjs +339 -0
- package/dist/split-button.d.mts +2 -0
- package/dist/split-button.mjs +3 -0
- package/dist/splitter.d.mts +1 -1
- package/dist/status-light.d.mts +1 -1
- package/dist/stepper.d.mts +1 -1
- package/dist/surface.d.mts +1 -1
- package/dist/switch.d.mts +1 -1
- package/dist/tabs.d.mts +1 -1
- package/dist/tags-input.d.mts +1 -1
- package/dist/text.d.mts +1 -1
- package/dist/{textarea-4eIDNcvv.d.mts → textarea-D7V5lLPX.d.mts} +2 -2
- package/dist/textarea.d.mts +1 -1
- package/dist/toggle.d.mts +1 -1
- package/dist/tooltip.d.mts +1 -1
- package/dist/tour.d.mts +1 -1
- package/dist/tree.d.mts +1 -1
- package/dist/{week-picker-BUduCITx.mjs → week-picker-Ce2qvuBO.mjs} +2 -2
- package/dist/week-picker.d.mts +1 -1
- package/dist/week-picker.mjs +1 -1
- package/package.json +16 -5
- package/registry/files/families/actions/split-button/examples/split-button-basic.vue +35 -0
- package/registry/files/families/actions/split-button/split-button-action.vue +102 -0
- package/registry/files/families/actions/split-button/split-button-context.ts +17 -0
- package/registry/files/families/actions/split-button/split-button-root.vue +191 -0
- package/registry/files/families/actions/split-button/split-button-trigger.vue +140 -0
- package/registry/files/families/actions/split-button/split-button-types.ts +40 -0
- package/registry/files/families/actions/split-button/split-button.ts +40 -0
- package/registry/files/families/date-time/calendar/calendar-multiple-root.vue +2 -2
- package/registry/files/families/date-time/calendar/calendar-root.vue +2 -2
- package/registry/files/families/date-time/duration-field/duration-field.vue +3 -3
- package/registry/files/families/date-time/range-calendar/range-calendar-root.vue +2 -2
- package/registry/files/families/date-time/week-picker/week-picker-root.vue +2 -2
- package/registry/files/families/feedback/meter/meter-state.ts +10 -2
- package/registry/files/families/feedback/meter/meter-types.ts +4 -1
- package/registry/files/families/feedback/meter/meter.vue +2 -0
- package/registry/files/families/feedback/progress-bar/progress-bar-state.ts +11 -1
- package/registry/files/families/feedback/progress-bar/progress-bar-types.ts +6 -2
- package/registry/files/families/feedback/progress-bar/progress-bar.vue +6 -1
- package/registry/files/families/menus/menu/menu-types.ts +1 -1
- package/registry/files/families/navigation/navigation-rail/examples/navigation-rail-basic.vue +21 -0
- package/registry/files/families/navigation/navigation-rail/navigation-rail-context.ts +17 -0
- package/registry/files/families/navigation/navigation-rail/navigation-rail-item.vue +89 -0
- package/registry/files/families/navigation/navigation-rail/navigation-rail-toggle.vue +50 -0
- package/registry/files/families/navigation/navigation-rail/navigation-rail-types.ts +23 -0
- package/registry/files/families/navigation/navigation-rail/navigation-rail.ts +11 -0
- package/registry/files/families/navigation/navigation-rail/navigation-rail.vue +156 -0
- package/registry/registry.json +398 -238
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useTemplateRef } from "vue";
|
|
3
|
+
|
|
4
|
+
import { menuLevelContext, menuTreeContext } from "../../menus/menu/menu-context.ts";
|
|
5
|
+
import { splitButtonContext } from "./split-button-context.ts";
|
|
6
|
+
import type { SplitButtonActionExpose, SplitButtonSlotState } from "./split-button-types.ts";
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
type = "button",
|
|
10
|
+
disabled = false,
|
|
11
|
+
ariaLabel = undefined,
|
|
12
|
+
} = defineProps<{
|
|
13
|
+
/**
|
|
14
|
+
* Native button submission behavior.
|
|
15
|
+
*
|
|
16
|
+
* @default "button"
|
|
17
|
+
*/
|
|
18
|
+
readonly type?: "button" | "reset" | "submit";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Disable the primary action while the trigger stays available.
|
|
22
|
+
*
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
readonly disabled?: boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Accessible name when no visible label supplies one.
|
|
29
|
+
*
|
|
30
|
+
* @default undefined
|
|
31
|
+
*/
|
|
32
|
+
readonly ariaLabel?: string;
|
|
33
|
+
}>();
|
|
34
|
+
|
|
35
|
+
const emit = defineEmits<{
|
|
36
|
+
/** Fired after user activation reaches the enabled primary action. */
|
|
37
|
+
press: [nativeEvent: MouseEvent];
|
|
38
|
+
/** Fired before keyboard handling; call `preventDefault()` to skip the built-in keys. */
|
|
39
|
+
keydown: [nativeEvent: KeyboardEvent];
|
|
40
|
+
}>();
|
|
41
|
+
|
|
42
|
+
defineSlots<{
|
|
43
|
+
/** Primary action contents. Receives the menu open state and availability. */
|
|
44
|
+
default(props: SplitButtonSlotState): unknown;
|
|
45
|
+
}>();
|
|
46
|
+
|
|
47
|
+
const tree = menuTreeContext.use();
|
|
48
|
+
const level = menuLevelContext.use();
|
|
49
|
+
const splitButton = splitButtonContext.use();
|
|
50
|
+
const element = useTemplateRef<HTMLButtonElement>("element");
|
|
51
|
+
const disabledState = computed(() => disabled || splitButton.disabled.value);
|
|
52
|
+
|
|
53
|
+
function onClick(event: MouseEvent): void {
|
|
54
|
+
if (!disabledState.value) emit("press", event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onKeydown(event: KeyboardEvent): void {
|
|
58
|
+
if (disabledState.value) return;
|
|
59
|
+
emit("keydown", event);
|
|
60
|
+
if (event.defaultPrevented) return;
|
|
61
|
+
// Platform split buttons open their menu from the primary action with Alt+ArrowDown.
|
|
62
|
+
if (event.altKey && event.key === "ArrowDown") {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
splitButton.openFromAction(element.value, event);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function focus(options?: FocusOptions): void {
|
|
69
|
+
element.value?.focus(options);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
defineExpose({ element, focus } satisfies Omit<SplitButtonActionExpose, "element"> & {
|
|
73
|
+
readonly element: typeof element;
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<button
|
|
79
|
+
ref="element"
|
|
80
|
+
:type
|
|
81
|
+
:disabled="disabledState"
|
|
82
|
+
:aria-label
|
|
83
|
+
data-vize-ui="split-button-action"
|
|
84
|
+
part="action"
|
|
85
|
+
:data-state="level.state.value"
|
|
86
|
+
:data-disabled="disabledState ? 'true' : undefined"
|
|
87
|
+
@click="onClick"
|
|
88
|
+
@keydown="onKeydown"
|
|
89
|
+
>
|
|
90
|
+
<slot
|
|
91
|
+
:dir="tree.dir.value"
|
|
92
|
+
:disabled="disabledState"
|
|
93
|
+
:modal="tree.modal.value"
|
|
94
|
+
:open="level.open.value"
|
|
95
|
+
:state="level.state.value"
|
|
96
|
+
/>
|
|
97
|
+
</button>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
<style scoped>
|
|
101
|
+
/* Headless by design. Native CSS remains entirely consumer-owned. */
|
|
102
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
import { createContext } from "../../foundations/context/context.ts";
|
|
4
|
+
|
|
5
|
+
/** Coordination between SplitButtonRoot and its primary action. */
|
|
6
|
+
export interface SplitButtonContextValue {
|
|
7
|
+
/** Whether the whole split button is disabled. */
|
|
8
|
+
readonly disabled: ComputedRef<boolean>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Open the menu on behalf of the primary action. Focus returns to `origin`
|
|
12
|
+
* instead of the trigger when the menu closes.
|
|
13
|
+
*/
|
|
14
|
+
readonly openFromAction: (origin: HTMLElement | null, event: Event) => boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const splitButtonContext = createContext<SplitButtonContextValue>("SplitButton");
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, shallowRef, useTemplateRef } from "vue";
|
|
3
|
+
import type { ComputedRef } from "vue";
|
|
4
|
+
|
|
5
|
+
import { useResolvedDirection } from "../../i18n/direction/direction-runtime.ts";
|
|
6
|
+
import { useMenuRoot } from "../../menus/menu/menu-root-runtime.ts";
|
|
7
|
+
import type { MenuRootSetupExpose } from "../../menus/menu/menu-root-runtime.ts";
|
|
8
|
+
import type { MenuDirection } from "../../menus/menu/menu-types.ts";
|
|
9
|
+
import { splitButtonContext } from "./split-button-context.ts";
|
|
10
|
+
import type { SplitButtonContextValue } from "./split-button-context.ts";
|
|
11
|
+
import type { SplitButtonAnchor, SplitButtonSlotState } from "./split-button-types.ts";
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
id = undefined,
|
|
15
|
+
open = undefined,
|
|
16
|
+
defaultOpen = false,
|
|
17
|
+
modal = true,
|
|
18
|
+
dir = undefined,
|
|
19
|
+
loop = false,
|
|
20
|
+
disabled = false,
|
|
21
|
+
anchor = "group",
|
|
22
|
+
ariaLabel = undefined,
|
|
23
|
+
ariaLabelledby = undefined,
|
|
24
|
+
ariaDescribedby = undefined,
|
|
25
|
+
} = defineProps<{
|
|
26
|
+
/**
|
|
27
|
+
* Consumer-owned base id. `null` and `undefined` select a deterministic fallback.
|
|
28
|
+
*
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
readonly id?: string | null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Controlled open state of the menu. `undefined` selects uncontrolled behavior.
|
|
35
|
+
*
|
|
36
|
+
* @default undefined
|
|
37
|
+
*/
|
|
38
|
+
readonly open?: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Initial open state for uncontrolled use.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
readonly defaultOpen?: boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Make outside content inert and lock document scroll while the menu is open.
|
|
49
|
+
*
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
readonly modal?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Reading direction: flips submenu arrow keys and submenu placement. `undefined` inherits `DirectionProvider`/`LocaleProvider`, then `"ltr"`.
|
|
56
|
+
*
|
|
57
|
+
* @default undefined
|
|
58
|
+
*/
|
|
59
|
+
readonly dir?: MenuDirection;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Wrap arrow-key navigation from the last item to the first and back.
|
|
63
|
+
*
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
readonly loop?: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Disable the primary action and the trigger, and close the menu when it becomes disabled.
|
|
70
|
+
*
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
readonly disabled?: boolean;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Element the menu is positioned against: the whole group or only the trigger.
|
|
77
|
+
*
|
|
78
|
+
* @default "group"
|
|
79
|
+
*/
|
|
80
|
+
readonly anchor?: SplitButtonAnchor;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Accessible name of the group when no `aria-labelledby` supplies one.
|
|
84
|
+
*
|
|
85
|
+
* @default undefined
|
|
86
|
+
*/
|
|
87
|
+
readonly ariaLabel?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Space-separated ids that label the group.
|
|
91
|
+
*
|
|
92
|
+
* @default undefined
|
|
93
|
+
*/
|
|
94
|
+
readonly ariaLabelledby?: string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Space-separated ids that describe the group.
|
|
98
|
+
*
|
|
99
|
+
* @default undefined
|
|
100
|
+
*/
|
|
101
|
+
readonly ariaDescribedby?: string;
|
|
102
|
+
}>();
|
|
103
|
+
|
|
104
|
+
const dirState = useResolvedDirection(() => dir);
|
|
105
|
+
|
|
106
|
+
const emit = defineEmits<{
|
|
107
|
+
/** Fired with the requested open value (supports `v-model:open`). */
|
|
108
|
+
"update:open": [value: boolean];
|
|
109
|
+
/** Fired after any distinct open-state request with the previous value and native event. */
|
|
110
|
+
"open-change": [value: boolean, previous: boolean, nativeEvent: Event | null];
|
|
111
|
+
}>();
|
|
112
|
+
|
|
113
|
+
defineSlots<{
|
|
114
|
+
/** Primary action, trigger, and content. Receives the menu open state and availability. */
|
|
115
|
+
default(props: SplitButtonSlotState): unknown;
|
|
116
|
+
}>();
|
|
117
|
+
|
|
118
|
+
const element = useTemplateRef<HTMLDivElement>("element");
|
|
119
|
+
const disabledState = computed(() => disabled);
|
|
120
|
+
// Element that requested the current open state, when it was not the trigger.
|
|
121
|
+
const restoreElement = shallowRef<HTMLElement | null>(null);
|
|
122
|
+
let pendingOrigin: HTMLElement | null = null;
|
|
123
|
+
|
|
124
|
+
const menu = useMenuRoot({
|
|
125
|
+
kind: "split-button",
|
|
126
|
+
hint: "split-button",
|
|
127
|
+
id: () => id,
|
|
128
|
+
open: () => open,
|
|
129
|
+
defaultOpen: () => defaultOpen,
|
|
130
|
+
modal: () => modal,
|
|
131
|
+
dir: () => dirState.value,
|
|
132
|
+
loop: () => loop,
|
|
133
|
+
disabled: () => disabled,
|
|
134
|
+
reference: () => (anchor === "group" ? element.value : menu.level.triggerElement.value),
|
|
135
|
+
restoreTarget: () => restoreElement.value ?? menu.level.triggerElement.value,
|
|
136
|
+
onOpenChange: (value, previous, event) => {
|
|
137
|
+
if (value) restoreElement.value = pendingOrigin;
|
|
138
|
+
emit("update:open", value);
|
|
139
|
+
emit("open-change", value, previous, event);
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
const level = menu.level;
|
|
143
|
+
|
|
144
|
+
function openFromAction(origin: HTMLElement | null, event: Event): boolean {
|
|
145
|
+
pendingOrigin = origin;
|
|
146
|
+
try {
|
|
147
|
+
return level.setOpen(true, event, "first");
|
|
148
|
+
} finally {
|
|
149
|
+
pendingOrigin = null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
splitButtonContext.provide({
|
|
154
|
+
disabled: disabledState,
|
|
155
|
+
openFromAction,
|
|
156
|
+
} satisfies SplitButtonContextValue);
|
|
157
|
+
const slotState = computed<SplitButtonSlotState>(() => ({
|
|
158
|
+
...menu.slotState.value,
|
|
159
|
+
disabled: disabledState.value,
|
|
160
|
+
}));
|
|
161
|
+
|
|
162
|
+
defineExpose({
|
|
163
|
+
...menu.expose,
|
|
164
|
+
disabled: disabledState,
|
|
165
|
+
element,
|
|
166
|
+
} satisfies MenuRootSetupExpose & {
|
|
167
|
+
readonly disabled: ComputedRef<boolean>;
|
|
168
|
+
readonly element: typeof element;
|
|
169
|
+
});
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<template>
|
|
173
|
+
<div
|
|
174
|
+
ref="element"
|
|
175
|
+
role="group"
|
|
176
|
+
:aria-label
|
|
177
|
+
:aria-labelledby
|
|
178
|
+
:aria-describedby
|
|
179
|
+
:aria-disabled="disabledState ? 'true' : undefined"
|
|
180
|
+
data-vize-ui="split-button"
|
|
181
|
+
part="root"
|
|
182
|
+
:data-state="level.state.value"
|
|
183
|
+
:data-disabled="disabledState ? 'true' : undefined"
|
|
184
|
+
>
|
|
185
|
+
<slot v-bind="slotState" />
|
|
186
|
+
</div>
|
|
187
|
+
</template>
|
|
188
|
+
|
|
189
|
+
<style scoped>
|
|
190
|
+
/* Headless by design. Native CSS remains entirely consumer-owned. */
|
|
191
|
+
</style>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onMounted, onUnmounted, useTemplateRef } from "vue";
|
|
3
|
+
|
|
4
|
+
import { menuLevelContext, menuTreeContext } from "../../menus/menu/menu-context.ts";
|
|
5
|
+
import type { SplitButtonSlotState, SplitButtonTriggerExpose } from "./split-button-types.ts";
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
disabled = false,
|
|
9
|
+
ariaLabel = undefined,
|
|
10
|
+
openOn = "pointerdown",
|
|
11
|
+
} = defineProps<{
|
|
12
|
+
/**
|
|
13
|
+
* Remove the trigger from activation and sequential keyboard focus.
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
readonly disabled?: boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Accessible name of the menu button. Required when the trigger renders only an icon.
|
|
21
|
+
*
|
|
22
|
+
* @default undefined
|
|
23
|
+
*/
|
|
24
|
+
readonly ariaLabel?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Primary mouse button event that toggles the menu. `pointerdown` opens on
|
|
28
|
+
* press (native menu feel, press-drag-release selection); `click` waits for release.
|
|
29
|
+
*
|
|
30
|
+
* @default "pointerdown"
|
|
31
|
+
*/
|
|
32
|
+
readonly openOn?: "click" | "pointerdown";
|
|
33
|
+
}>();
|
|
34
|
+
|
|
35
|
+
const emit = defineEmits<{
|
|
36
|
+
/** Fired before a primary-button pointer-down toggles the menu; preventable. */
|
|
37
|
+
pointerdown: [nativeEvent: PointerEvent];
|
|
38
|
+
/** Fired before keyboard handling; call `preventDefault()` to skip the built-in keys. */
|
|
39
|
+
keydown: [nativeEvent: KeyboardEvent];
|
|
40
|
+
}>();
|
|
41
|
+
|
|
42
|
+
defineSlots<{
|
|
43
|
+
/** Trigger contents. Receives the menu open state and availability. */
|
|
44
|
+
default(props: SplitButtonSlotState): unknown;
|
|
45
|
+
}>();
|
|
46
|
+
|
|
47
|
+
const tree = menuTreeContext.use();
|
|
48
|
+
const level = menuLevelContext.use();
|
|
49
|
+
const element = useTemplateRef<HTMLButtonElement>("element");
|
|
50
|
+
level.hasTrigger.value = true;
|
|
51
|
+
const disabledState = computed(() => disabled || level.disabled.value);
|
|
52
|
+
|
|
53
|
+
onMounted(() => {
|
|
54
|
+
level.triggerElement.value = element.value;
|
|
55
|
+
});
|
|
56
|
+
onUnmounted(() => {
|
|
57
|
+
if (level.triggerElement.value === element.value) level.triggerElement.value = null;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
let touchPress = false;
|
|
61
|
+
|
|
62
|
+
function onPointerdown(event: PointerEvent): void {
|
|
63
|
+
if (disabledState.value || openOn !== "pointerdown") return;
|
|
64
|
+
if (event.button !== 0 || event.ctrlKey || event.pointerType === "touch") return;
|
|
65
|
+
emit("pointerdown", event);
|
|
66
|
+
if (event.defaultPrevented) return;
|
|
67
|
+
const opening = !level.open.value;
|
|
68
|
+
level.setOpen(opening, event, "content");
|
|
69
|
+
// Keep the trigger from taking focus so the opening content owns it.
|
|
70
|
+
if (opening) event.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function onClick(event: MouseEvent): void {
|
|
74
|
+
if (disabledState.value) return;
|
|
75
|
+
// Mouse presses already toggled on pointer-down; touch, pen taps and
|
|
76
|
+
// keyboard/assistive-technology clicks (`detail === 0`) toggle here.
|
|
77
|
+
const handledByPointerdown = openOn === "pointerdown" && event.detail > 0 && !touchPress;
|
|
78
|
+
touchPress = false;
|
|
79
|
+
if (handledByPointerdown) return;
|
|
80
|
+
level.setOpen(!level.open.value, event, event.detail === 0 ? "first" : "content");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function onPointerup(event: PointerEvent): void {
|
|
84
|
+
touchPress = event.pointerType === "touch";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function onKeydown(event: KeyboardEvent): void {
|
|
88
|
+
if (disabledState.value) return;
|
|
89
|
+
emit("keydown", event);
|
|
90
|
+
if (event.defaultPrevented) return;
|
|
91
|
+
if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown") {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
level.setOpen(true, event, "first");
|
|
94
|
+
} else if (event.key === "ArrowUp") {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
level.setOpen(true, event, "last");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function focus(options?: FocusOptions): void {
|
|
101
|
+
element.value?.focus(options);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
defineExpose({ element, focus } satisfies Omit<SplitButtonTriggerExpose, "element"> & {
|
|
105
|
+
readonly element: typeof element;
|
|
106
|
+
});
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<button
|
|
111
|
+
:id="level.triggerId.value"
|
|
112
|
+
ref="element"
|
|
113
|
+
type="button"
|
|
114
|
+
:disabled="disabledState"
|
|
115
|
+
:aria-label
|
|
116
|
+
aria-haspopup="menu"
|
|
117
|
+
:aria-expanded="level.open.value ? 'true' : 'false'"
|
|
118
|
+
:aria-controls="level.open.value ? level.contentId.value : undefined"
|
|
119
|
+
data-vize-ui="split-button-trigger"
|
|
120
|
+
part="trigger"
|
|
121
|
+
:data-state="level.state.value"
|
|
122
|
+
:data-disabled="disabledState ? 'true' : undefined"
|
|
123
|
+
@click="onClick"
|
|
124
|
+
@keydown="onKeydown"
|
|
125
|
+
@pointerdown="onPointerdown"
|
|
126
|
+
@pointerup="onPointerup"
|
|
127
|
+
>
|
|
128
|
+
<slot
|
|
129
|
+
:dir="tree.dir.value"
|
|
130
|
+
:disabled="disabledState"
|
|
131
|
+
:modal="tree.modal.value"
|
|
132
|
+
:open="level.open.value"
|
|
133
|
+
:state="level.state.value"
|
|
134
|
+
/>
|
|
135
|
+
</button>
|
|
136
|
+
</template>
|
|
137
|
+
|
|
138
|
+
<style scoped>
|
|
139
|
+
/* Headless by design. Native CSS remains entirely consumer-owned. */
|
|
140
|
+
</style>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MenuRootExpose,
|
|
3
|
+
MenuSlotState,
|
|
4
|
+
MenuTriggerExpose,
|
|
5
|
+
} from "../../menus/menu/menu-types.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Element the menu content is positioned against.
|
|
9
|
+
*
|
|
10
|
+
* - `group`: the whole split button, so the menu lines up with the primary action.
|
|
11
|
+
* - `trigger`: the menu trigger only.
|
|
12
|
+
*/
|
|
13
|
+
export type SplitButtonAnchor = "group" | "trigger";
|
|
14
|
+
|
|
15
|
+
/** State exposed to SplitButton slots. */
|
|
16
|
+
export interface SplitButtonSlotState extends MenuSlotState {
|
|
17
|
+
/** Whether the split button suppresses the primary action and refuses to open. */
|
|
18
|
+
readonly disabled: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Imperative surface exposed by SplitButtonRoot. */
|
|
22
|
+
export interface SplitButtonRootExpose extends MenuRootExpose {
|
|
23
|
+
/** Whether the split button suppresses the primary action and refuses to open. */
|
|
24
|
+
readonly disabled: boolean;
|
|
25
|
+
|
|
26
|
+
/** Rendered `role="group"` element. */
|
|
27
|
+
readonly element: HTMLDivElement | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Imperative surface exposed by SplitButtonAction. */
|
|
31
|
+
export interface SplitButtonActionExpose {
|
|
32
|
+
/** Rendered native button. */
|
|
33
|
+
readonly element: HTMLButtonElement | null;
|
|
34
|
+
|
|
35
|
+
/** Move focus to the primary action. */
|
|
36
|
+
readonly focus: (options?: FocusOptions) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Imperative surface exposed by SplitButtonTrigger. */
|
|
40
|
+
export type SplitButtonTriggerExpose = MenuTriggerExpose;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessible, unstyled SplitButton: a primary action paired with a menu button
|
|
3
|
+
* (WAI-ARIA APG) that opens related actions. Items, groups, radio/checkbox
|
|
4
|
+
* items, and submenus are the shared Menu parts re-exported under SplitButton
|
|
5
|
+
* names.
|
|
6
|
+
*/
|
|
7
|
+
export { default as SplitButton, default as SplitButtonRoot } from "./split-button-root.vue";
|
|
8
|
+
export { default as SplitButtonAction } from "./split-button-action.vue";
|
|
9
|
+
export { default as SplitButtonTrigger } from "./split-button-trigger.vue";
|
|
10
|
+
export {
|
|
11
|
+
MenuArrow as SplitButtonArrow,
|
|
12
|
+
MenuCheckboxItem as SplitButtonCheckboxItem,
|
|
13
|
+
MenuContent as SplitButtonContent,
|
|
14
|
+
MenuGroup as SplitButtonGroup,
|
|
15
|
+
MenuItem as SplitButtonItem,
|
|
16
|
+
MenuItemIndicator as SplitButtonItemIndicator,
|
|
17
|
+
MenuLabel as SplitButtonLabel,
|
|
18
|
+
MenuRadioGroup as SplitButtonRadioGroup,
|
|
19
|
+
MenuRadioItem as SplitButtonRadioItem,
|
|
20
|
+
MenuSeparator as SplitButtonSeparator,
|
|
21
|
+
MenuSub as SplitButtonSub,
|
|
22
|
+
MenuSubContent as SplitButtonSubContent,
|
|
23
|
+
MenuSubTrigger as SplitButtonSubTrigger,
|
|
24
|
+
} from "../../menus/menu/menu.ts";
|
|
25
|
+
export type {
|
|
26
|
+
MenuCheckedState as SplitButtonCheckedState,
|
|
27
|
+
MenuContentExpose as SplitButtonContentExpose,
|
|
28
|
+
MenuContentSlotState as SplitButtonContentSlotState,
|
|
29
|
+
MenuDirection as SplitButtonDirection,
|
|
30
|
+
MenuItemExpose as SplitButtonItemExpose,
|
|
31
|
+
MenuSelectEvent as SplitButtonSelectEvent,
|
|
32
|
+
MenuState as SplitButtonState,
|
|
33
|
+
} from "../../menus/menu/menu.ts";
|
|
34
|
+
export type {
|
|
35
|
+
SplitButtonActionExpose,
|
|
36
|
+
SplitButtonAnchor,
|
|
37
|
+
SplitButtonRootExpose,
|
|
38
|
+
SplitButtonSlotState,
|
|
39
|
+
SplitButtonTriggerExpose,
|
|
40
|
+
} from "./split-button-types.ts";
|
|
@@ -101,7 +101,7 @@ const selection = useMultipleCalendarSelection({
|
|
|
101
101
|
const core = useCalendarCore(props, selection.adapter, root, (date) =>
|
|
102
102
|
emit("update:focusedDate", date),
|
|
103
103
|
);
|
|
104
|
-
const { id, headingId, slotState, direction, state } = core;
|
|
104
|
+
const { id: resolvedId, headingId, slotState, direction, state } = core;
|
|
105
105
|
const isoValues = computed(() => selection.value.value.map((date) => formatIsoDate(date)));
|
|
106
106
|
|
|
107
107
|
type CalendarMultipleRootSetupExpose = {
|
|
@@ -124,7 +124,7 @@ defineExpose(exposed);
|
|
|
124
124
|
|
|
125
125
|
<template>
|
|
126
126
|
<div
|
|
127
|
-
:id
|
|
127
|
+
:id="resolvedId"
|
|
128
128
|
ref="root"
|
|
129
129
|
role="group"
|
|
130
130
|
:dir="direction"
|
|
@@ -94,7 +94,7 @@ const selection = useSingleCalendarSelection({
|
|
|
94
94
|
const core = useCalendarCore(props, selection.adapter, root, (date) =>
|
|
95
95
|
emit("update:focusedDate", date),
|
|
96
96
|
);
|
|
97
|
-
const { id, headingId, slotState, direction, state } = core;
|
|
97
|
+
const { id: resolvedId, headingId, slotState, direction, state } = core;
|
|
98
98
|
const isoValue = computed(() =>
|
|
99
99
|
selection.value.value ? formatIsoDate(selection.value.value) : "",
|
|
100
100
|
);
|
|
@@ -118,7 +118,7 @@ defineExpose(exposed);
|
|
|
118
118
|
|
|
119
119
|
<template>
|
|
120
120
|
<div
|
|
121
|
-
:id
|
|
121
|
+
:id="resolvedId"
|
|
122
122
|
ref="root"
|
|
123
123
|
role="group"
|
|
124
124
|
:dir="direction"
|
|
@@ -67,7 +67,7 @@ defineSlots<{
|
|
|
67
67
|
const root = useTemplateRef<HTMLDivElement>("root");
|
|
68
68
|
const input = useTemplateRef<HTMLInputElement>("input");
|
|
69
69
|
const field = useDurationField(props, emit, root);
|
|
70
|
-
const { id, direction, isoValue, slotState, exposed, segmentId } = field;
|
|
70
|
+
const { id: resolvedId, direction, isoValue, slotState, exposed, segmentId } = field;
|
|
71
71
|
const validation = useFieldValidationInput({
|
|
72
72
|
input,
|
|
73
73
|
invalid: () => false,
|
|
@@ -96,7 +96,7 @@ defineExpose(exposed);
|
|
|
96
96
|
|
|
97
97
|
<template>
|
|
98
98
|
<div
|
|
99
|
-
:id
|
|
99
|
+
:id="resolvedId"
|
|
100
100
|
ref="root"
|
|
101
101
|
part="root"
|
|
102
102
|
role="group"
|
|
@@ -171,7 +171,7 @@ defineExpose(exposed);
|
|
|
171
171
|
:required="slotState.required"
|
|
172
172
|
:disabled="slotState.disabled"
|
|
173
173
|
tabindex="-1"
|
|
174
|
-
:aria-labelledby="
|
|
174
|
+
:aria-labelledby="resolvedId"
|
|
175
175
|
autocomplete="off"
|
|
176
176
|
data-vize-ui="duration-field-input"
|
|
177
177
|
:style="fieldValidationInputStyle"
|
|
@@ -104,7 +104,7 @@ const selection = useRangeCalendarSelection({
|
|
|
104
104
|
const core = useCalendarCore(props, selection.adapter, root, (date) =>
|
|
105
105
|
emit("update:focusedDate", date),
|
|
106
106
|
);
|
|
107
|
-
const { id, headingId, slotState, direction, state } = core;
|
|
107
|
+
const { id: resolvedId, headingId, slotState, direction, state } = core;
|
|
108
108
|
const isoStart = computed(() =>
|
|
109
109
|
selection.value.value ? formatIsoDate(selection.value.value.start) : "",
|
|
110
110
|
);
|
|
@@ -135,7 +135,7 @@ defineExpose(exposed);
|
|
|
135
135
|
|
|
136
136
|
<template>
|
|
137
137
|
<div
|
|
138
|
-
:id
|
|
138
|
+
:id="resolvedId"
|
|
139
139
|
ref="root"
|
|
140
140
|
role="group"
|
|
141
141
|
:dir="direction"
|
|
@@ -106,7 +106,7 @@ const core = useCalendarCore(props, selection.adapter, root, (date) =>
|
|
|
106
106
|
emit("update:focusedDate", date),
|
|
107
107
|
);
|
|
108
108
|
resolveWeekStart = () => core.exposed.weekStartsOn.value;
|
|
109
|
-
const { id, headingId, slotState, direction, state } = core;
|
|
109
|
+
const { id: resolvedId, headingId, slotState, direction, state } = core;
|
|
110
110
|
const isoStart = computed(() =>
|
|
111
111
|
selection.value.value ? formatIsoDate(selection.value.value.start) : "",
|
|
112
112
|
);
|
|
@@ -137,7 +137,7 @@ defineExpose(exposed);
|
|
|
137
137
|
|
|
138
138
|
<template>
|
|
139
139
|
<div
|
|
140
|
-
:id
|
|
140
|
+
:id="resolvedId"
|
|
141
141
|
ref="root"
|
|
142
142
|
role="group"
|
|
143
143
|
:dir="direction"
|
|
@@ -24,6 +24,8 @@ export interface MeterStateOptions {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Raw maximum. Values less than or equal to `min` are repaired to `min + 1`.
|
|
27
|
+
* If that addition rounds back to `min`, retain the finite collapsed range
|
|
28
|
+
* with zero percent and mark it invalid.
|
|
27
29
|
*
|
|
28
30
|
* @default METER_DEFAULT_MAX
|
|
29
31
|
*/
|
|
@@ -95,8 +97,8 @@ export function getMeterState(options: MeterStateOptions = {}): MeterSlotState {
|
|
|
95
97
|
if (finite(options.max) && options.max > min) {
|
|
96
98
|
max = options.max;
|
|
97
99
|
} else {
|
|
98
|
-
invalid = invalid || options.max != null;
|
|
99
100
|
max = min + 1;
|
|
101
|
+
invalid = invalid || options.max != null || max === min;
|
|
100
102
|
}
|
|
101
103
|
const value = finite(options.value) ? clamp(options.value, min, max) : min;
|
|
102
104
|
invalid =
|
|
@@ -114,7 +116,13 @@ export function getMeterState(options: MeterStateOptions = {}): MeterSlotState {
|
|
|
114
116
|
[low, high] = [high, low];
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
const
|
|
119
|
+
const span = max - min;
|
|
120
|
+
const percent =
|
|
121
|
+
max === min
|
|
122
|
+
? 0
|
|
123
|
+
: (Number.isFinite(span)
|
|
124
|
+
? (value - min) / span
|
|
125
|
+
: (value / 2 - min / 2) / (max / 2 - min / 2)) * 100;
|
|
118
126
|
const range = rangeFor(value, low, high);
|
|
119
127
|
const optimumRange =
|
|
120
128
|
optimumResult.value === null ? null : rangeFor(optimumResult.value, low, high);
|
|
@@ -12,7 +12,10 @@ export interface MeterSlotState {
|
|
|
12
12
|
/** Finite lower bound. */
|
|
13
13
|
readonly min: number;
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Finite upper bound. Equals `min` only when a repaired `min + 1` rounds
|
|
17
|
+
* back to `min`; that collapsed range reports zero percent and invalid state.
|
|
18
|
+
*/
|
|
16
19
|
readonly max: number;
|
|
17
20
|
|
|
18
21
|
/** Optional low threshold clamped to the normalized range. */
|