@rio-m3e/vue 0.2.0 → 0.4.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 +2 -0
- package/dist/button/Button.vue.d.ts +2 -2
- package/dist/checkbox/Checkbox.vue.d.ts +11 -0
- package/dist/checkbox/Checkbox.vue.js +71 -0
- package/dist/dialog/Dialog.vue.d.ts +37 -0
- package/dist/dialog/Dialog.vue.js +82 -0
- package/dist/icon-button/IconButton.vue.d.ts +4 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +15 -4
- package/dist/menu/Menu.vue.d.ts +35 -0
- package/dist/menu/Menu.vue.js +76 -0
- package/dist/menu/MenuDivider.vue.d.ts +4 -0
- package/dist/menu/MenuDivider.vue.js +14 -0
- package/dist/menu/MenuGroup.vue.d.ts +15 -0
- package/dist/menu/MenuGroup.vue.js +15 -0
- package/dist/menu/MenuItem.vue.d.ts +34 -0
- package/dist/menu/MenuItem.vue.js +45 -0
- package/dist/menu/SubMenu.vue.d.ts +38 -0
- package/dist/menu/SubMenu.vue.js +72 -0
- package/dist/menu/context.js +12 -0
- package/dist/radio/Radio.vue.d.ts +11 -0
- package/dist/radio/Radio.vue.js +71 -0
- package/dist/radio/RadioGroup.vue.d.ts +29 -0
- package/dist/radio/RadioGroup.vue.js +45 -0
- package/dist/radio/context.js +3 -0
- package/dist/text-field/TextField.vue.d.ts +32 -0
- package/dist/text-field/TextField.vue.js +126 -0
- package/dist/tooltip/Tooltip.vue.d.ts +40 -0
- package/dist/tooltip/Tooltip.vue.js +95 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -8,4 +8,6 @@ pnpm add @rio-m3e/vue @rio-m3e/tokens
|
|
|
8
8
|
|
|
9
9
|
Apply the theme from `@rio-m3e/tokens` once, then use the components. Each component imports its own styles. See the [README](https://github.com/LegenLee/rio#usage) for setup and [docs/components](https://github.com/LegenLee/rio/tree/main/docs/components) for each component.
|
|
10
10
|
|
|
11
|
+
You can see the document page in [here](https://legenlee.github.io/rio/).
|
|
12
|
+
|
|
11
13
|
Licensed under the Apache License 2.0.
|
|
@@ -10,11 +10,11 @@ type __VLS_Slots = {
|
|
|
10
10
|
icon?: () => unknown;
|
|
11
11
|
};
|
|
12
12
|
declare const __VLS_base: import("vue").DefineComponent<ButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
-
"update:selected": (selected: boolean) => any;
|
|
14
13
|
click: (event: MouseEvent) => any;
|
|
14
|
+
"update:selected": (selected: boolean) => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<ButtonProps> & Readonly<{
|
|
16
|
-
"onUpdate:selected"?: ((selected: boolean) => any) | undefined;
|
|
17
16
|
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
17
|
+
"onUpdate:selected"?: ((selected: boolean) => any) | undefined;
|
|
18
18
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
19
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
20
20
|
declare const _default: typeof __VLS_export;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CheckboxProps } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
3
|
+
import "@rio-m3e/styles/base/ripple.css";
|
|
4
|
+
import "@rio-m3e/styles/checkbox.css";
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<CheckboxProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
"update:selected": (selected: boolean) => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<CheckboxProps> & Readonly<{
|
|
8
|
+
"onUpdate:selected"?: ((selected: boolean) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export { _default as default };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, nextTick, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, unref, useTemplateRef } from "vue";
|
|
2
|
+
import { attachCheckable, attachRipple, createCheckbox } from "@rio-m3e/core";
|
|
3
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
4
|
+
import "@rio-m3e/styles/base/ripple.css";
|
|
5
|
+
import "@rio-m3e/styles/checkbox.css";
|
|
6
|
+
// src/checkbox/Checkbox.vue
|
|
7
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
__name: "Checkbox",
|
|
10
|
+
props: {
|
|
11
|
+
selected: { type: Boolean },
|
|
12
|
+
indeterminate: { type: Boolean },
|
|
13
|
+
error: { type: Boolean },
|
|
14
|
+
disabled: { type: Boolean },
|
|
15
|
+
softDisabled: { type: Boolean }
|
|
16
|
+
},
|
|
17
|
+
emits: ["update:selected"],
|
|
18
|
+
setup(__props, { emit: __emit }) {
|
|
19
|
+
const emit = __emit;
|
|
20
|
+
const checkbox = createCheckbox({ props: () => ({
|
|
21
|
+
selected: __props.selected,
|
|
22
|
+
indeterminate: __props.indeterminate,
|
|
23
|
+
error: __props.error,
|
|
24
|
+
disabled: __props.disabled,
|
|
25
|
+
softDisabled: __props.softDisabled
|
|
26
|
+
}) });
|
|
27
|
+
const input = useTemplateRef("input");
|
|
28
|
+
const state = useTemplateRef("state");
|
|
29
|
+
let checkable;
|
|
30
|
+
let ripple;
|
|
31
|
+
onMounted(() => {
|
|
32
|
+
checkable = attachCheckable(input.value, {
|
|
33
|
+
checked: () => !!__props.selected,
|
|
34
|
+
indeterminate: () => !!__props.indeterminate,
|
|
35
|
+
blocked: checkbox.blocked,
|
|
36
|
+
onChange(checked) {
|
|
37
|
+
emit("update:selected", checkbox.next(checked));
|
|
38
|
+
nextTick(() => checkable?.sync());
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
ripple = attachRipple(input.value, { surface: state.value });
|
|
42
|
+
});
|
|
43
|
+
onUpdated(() => checkable?.sync());
|
|
44
|
+
onBeforeUnmount(() => {
|
|
45
|
+
checkable?.detach();
|
|
46
|
+
ripple?.detach();
|
|
47
|
+
});
|
|
48
|
+
return (_ctx, _cache) => {
|
|
49
|
+
return openBlock(), createElementBlock("span", mergeProps(unref(checkbox).parts.root(), {
|
|
50
|
+
class: _ctx.$attrs.class,
|
|
51
|
+
style: _ctx.$attrs.style
|
|
52
|
+
}), [
|
|
53
|
+
createElementVNode("input", mergeProps({
|
|
54
|
+
ref_key: "input",
|
|
55
|
+
ref: input
|
|
56
|
+
}, {
|
|
57
|
+
..._ctx.$attrs,
|
|
58
|
+
class: void 0,
|
|
59
|
+
style: void 0,
|
|
60
|
+
...unref(checkbox).parts.input()
|
|
61
|
+
}), null, 16),
|
|
62
|
+
createElementVNode("span", mergeProps({
|
|
63
|
+
ref_key: "state",
|
|
64
|
+
ref: state
|
|
65
|
+
}, unref(checkbox).parts.state()), null, 16),
|
|
66
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(checkbox).parts.container())), [createElementVNode("span", normalizeProps(guardReactiveProps(unref(checkbox).parts.icon())), null, 16)], 16)
|
|
67
|
+
], 16);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DialogCancelEvent, DialogProps } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/focus-ring.css";
|
|
3
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
4
|
+
import "@rio-m3e/styles/dialog.css";
|
|
5
|
+
interface Props extends Omit<DialogProps, 'open'> {
|
|
6
|
+
/** States what the dialog is for, and names it. Without it, give the dialog an `aria-label`. */
|
|
7
|
+
headline?: string;
|
|
8
|
+
}
|
|
9
|
+
type __VLS_Props = Props;
|
|
10
|
+
type __VLS_Slots = {
|
|
11
|
+
/** The supporting text, or a list or a form */
|
|
12
|
+
default?: () => unknown;
|
|
13
|
+
/** An icon above the headline, which centers both */
|
|
14
|
+
icon?: () => unknown;
|
|
15
|
+
/** Up to two buttons: the dismissing one first, then the confirming one. */
|
|
16
|
+
actions?: () => unknown;
|
|
17
|
+
};
|
|
18
|
+
type __VLS_ModelProps = {
|
|
19
|
+
/** Whether the dialog is shown, with `v-model:open`. */
|
|
20
|
+
'open'?: boolean;
|
|
21
|
+
};
|
|
22
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
23
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
+
"update:open": (value: boolean) => any;
|
|
25
|
+
cancel: (event: DialogCancelEvent) => any;
|
|
26
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
27
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
28
|
+
onCancel?: ((event: DialogCancelEvent) => any) | undefined;
|
|
29
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
30
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
33
|
+
new (): {
|
|
34
|
+
$slots: S;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export { _default as default };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Fragment, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, ref, renderSlot, toDisplayString, unref, useId, useModel, useSlots, useTemplateRef, watch, withModifiers } from "vue";
|
|
2
|
+
import { attachDialog, createDialog } from "@rio-m3e/core";
|
|
3
|
+
import "@rio-m3e/styles/base/focus-ring.css";
|
|
4
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
5
|
+
import "@rio-m3e/styles/dialog.css";
|
|
6
|
+
// src/dialog/Dialog.vue
|
|
7
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
8
|
+
__name: "Dialog",
|
|
9
|
+
props: /*@__PURE__*/ mergeModels({
|
|
10
|
+
headline: {},
|
|
11
|
+
role: {}
|
|
12
|
+
}, {
|
|
13
|
+
"open": {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false
|
|
16
|
+
},
|
|
17
|
+
"openModifiers": {}
|
|
18
|
+
}),
|
|
19
|
+
emits: /*@__PURE__*/ mergeModels(["cancel"], ["update:open"]),
|
|
20
|
+
setup(__props, { emit: __emit }) {
|
|
21
|
+
/** Whether the dialog is shown, with `v-model:open`. */
|
|
22
|
+
const open = useModel(__props, "open");
|
|
23
|
+
const emit = __emit;
|
|
24
|
+
const slots = useSlots();
|
|
25
|
+
const id = useId();
|
|
26
|
+
const dialog = createDialog({
|
|
27
|
+
props: () => ({
|
|
28
|
+
open: open.value,
|
|
29
|
+
role: __props.role
|
|
30
|
+
}),
|
|
31
|
+
content: () => ({
|
|
32
|
+
icon: !!slots.icon,
|
|
33
|
+
headline: !!__props.headline,
|
|
34
|
+
actions: !!slots.actions
|
|
35
|
+
}),
|
|
36
|
+
ids: {
|
|
37
|
+
headline: `${id}-headline`,
|
|
38
|
+
content: `${id}-content`
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const rendered = ref(open.value);
|
|
42
|
+
watch(open, (next) => {
|
|
43
|
+
if (next) rendered.value = true;
|
|
44
|
+
});
|
|
45
|
+
const root = useTemplateRef("root");
|
|
46
|
+
let handle;
|
|
47
|
+
onMounted(() => {
|
|
48
|
+
handle = attachDialog(root.value, {
|
|
49
|
+
onCancel: (event) => emit("cancel", event),
|
|
50
|
+
onOpenChange: (next) => open.value = next,
|
|
51
|
+
onClosed: () => {
|
|
52
|
+
if (!open.value) rendered.value = false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
handle.sync(open.value);
|
|
56
|
+
});
|
|
57
|
+
watch(open, (next) => handle?.sync(next), { flush: "post" });
|
|
58
|
+
onUpdated(() => handle?.update());
|
|
59
|
+
onBeforeUnmount(() => handle?.detach());
|
|
60
|
+
return (_ctx, _cache) => {
|
|
61
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" Clicks and presses stay in the dialog, so a card or a row around it doesn't take them. Keys go\n on, for Escape. "), createElementVNode("dialog", mergeProps({
|
|
62
|
+
ref_key: "root",
|
|
63
|
+
ref: root
|
|
64
|
+
}, unref(dialog).parts.root(), {
|
|
65
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"])),
|
|
66
|
+
onAuxclick: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"])),
|
|
67
|
+
onDblclick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"])),
|
|
68
|
+
onPointerdown: _cache[3] || (_cache[3] = withModifiers(() => {}, ["stop"])),
|
|
69
|
+
onPointerup: _cache[4] || (_cache[4] = withModifiers(() => {}, ["stop"])),
|
|
70
|
+
onMousedown: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"])),
|
|
71
|
+
onMouseup: _cache[6] || (_cache[6] = withModifiers(() => {}, ["stop"])),
|
|
72
|
+
onContextmenu: _cache[7] || (_cache[7] = withModifiers(() => {}, ["stop"]))
|
|
73
|
+
}), [rendered.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
74
|
+
unref(dialog).showsIcon() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(dialog).parts.icon())), [renderSlot(_ctx.$slots, "icon")], 16)) : createCommentVNode("v-if", true),
|
|
75
|
+
unref(dialog).showsHeadline() ? (openBlock(), createElementBlock("h2", normalizeProps(mergeProps({ key: 1 }, unref(dialog).parts.headline())), toDisplayString(__props.headline), 17)) : createCommentVNode("v-if", true),
|
|
76
|
+
createElementVNode("div", normalizeProps(guardReactiveProps(unref(dialog).parts.content())), [renderSlot(_ctx.$slots, "default")], 16),
|
|
77
|
+
unref(dialog).showsActions() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 2 }, unref(dialog).parts.actions())), [renderSlot(_ctx.$slots, "actions")], 16)) : createCommentVNode("v-if", true)
|
|
78
|
+
], 64)) : createCommentVNode("v-if", true)], 16)], 2112);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
export { _sfc_main as default };
|
|
@@ -8,17 +8,17 @@ type __VLS_Slots = {
|
|
|
8
8
|
/** The icon. Hidden from assistive technology; `label` names the button. */
|
|
9
9
|
default?: () => unknown;
|
|
10
10
|
/**
|
|
11
|
-
* The icon while a toggle button is on, typically the filled version of the default icon
|
|
12
|
-
*
|
|
11
|
+
* The icon while a toggle button is on, typically the filled version of the default icon, so
|
|
12
|
+
* the selection shows in more than color alone.
|
|
13
13
|
*/
|
|
14
14
|
'selected-icon'?: () => unknown;
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_base: import("vue").DefineComponent<IconButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
-
"update:selected": (selected: boolean) => any;
|
|
18
17
|
click: (event: MouseEvent) => any;
|
|
18
|
+
"update:selected": (selected: boolean) => any;
|
|
19
19
|
}, string, import("vue").PublicProps, Readonly<IconButtonProps> & Readonly<{
|
|
20
|
-
"onUpdate:selected"?: ((selected: boolean) => any) | undefined;
|
|
21
20
|
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
21
|
+
"onUpdate:selected"?: ((selected: boolean) => any) | undefined;
|
|
22
22
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
23
23
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
24
24
|
declare const _default: typeof __VLS_export;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import _default from "./button/Button.vue.js";
|
|
2
2
|
import _default$1 from "./button-group/ButtonGroup.vue.js";
|
|
3
|
-
import _default$2 from "./
|
|
3
|
+
import _default$2 from "./checkbox/Checkbox.vue.js";
|
|
4
|
+
import _default$3 from "./dialog/Dialog.vue.js";
|
|
5
|
+
import _default$4 from "./icon-button/IconButton.vue.js";
|
|
6
|
+
import _default$5 from "./menu/Menu.vue.js";
|
|
7
|
+
import _default$6 from "./menu/MenuDivider.vue.js";
|
|
8
|
+
import _default$7 from "./menu/MenuGroup.vue.js";
|
|
9
|
+
import _default$8 from "./menu/MenuItem.vue.js";
|
|
10
|
+
import _default$12 from "./menu/SubMenu.vue.js";
|
|
11
|
+
import _default$9 from "./radio/Radio.vue.js";
|
|
12
|
+
import _default$10 from "./radio/RadioGroup.vue.js";
|
|
4
13
|
import { vRipple } from "./ripple/ripple.js";
|
|
5
|
-
import _default$
|
|
6
|
-
import _default$
|
|
7
|
-
|
|
14
|
+
import _default$11 from "./split-button/SplitButton.vue.js";
|
|
15
|
+
import _default$13 from "./switch/Switch.vue.js";
|
|
16
|
+
import _default$14 from "./text-field/TextField.vue.js";
|
|
17
|
+
import _default$15 from "./tooltip/Tooltip.vue.js";
|
|
18
|
+
export { _default as RioButton, _default$1 as RioButtonGroup, _default$2 as RioCheckbox, _default$3 as RioDialog, _default$4 as RioIconButton, _default$5 as RioMenu, _default$6 as RioMenuDivider, _default$7 as RioMenuGroup, _default$8 as RioMenuItem, _default$9 as RioRadio, _default$10 as RioRadioGroup, _default$11 as RioSplitButton, _default$12 as RioSubMenu, _default$13 as RioSwitch, _default$14 as RioTextField, _default$15 as RioTooltip, vRipple };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import _sfc_main from "./button/Button.vue.js";
|
|
2
2
|
import _sfc_main$1 from "./button-group/ButtonGroup.vue.js";
|
|
3
|
-
import _sfc_main$2 from "./
|
|
3
|
+
import _sfc_main$2 from "./checkbox/Checkbox.vue.js";
|
|
4
|
+
import _sfc_main$3 from "./dialog/Dialog.vue.js";
|
|
5
|
+
import _sfc_main$4 from "./icon-button/IconButton.vue.js";
|
|
6
|
+
import _sfc_main$5 from "./menu/Menu.vue.js";
|
|
7
|
+
import _sfc_main$6 from "./menu/MenuDivider.vue.js";
|
|
8
|
+
import _sfc_main$7 from "./menu/MenuGroup.vue.js";
|
|
9
|
+
import _sfc_main$8 from "./menu/MenuItem.vue.js";
|
|
10
|
+
import _sfc_main$12 from "./menu/SubMenu.vue.js";
|
|
11
|
+
import _sfc_main$9 from "./radio/Radio.vue.js";
|
|
12
|
+
import _sfc_main$10 from "./radio/RadioGroup.vue.js";
|
|
4
13
|
import { vRipple } from "./ripple/ripple.js";
|
|
5
|
-
import _sfc_main$
|
|
6
|
-
import _sfc_main$
|
|
7
|
-
|
|
14
|
+
import _sfc_main$11 from "./split-button/SplitButton.vue.js";
|
|
15
|
+
import _sfc_main$13 from "./switch/Switch.vue.js";
|
|
16
|
+
import _sfc_main$14 from "./text-field/TextField.vue.js";
|
|
17
|
+
import _sfc_main$15 from "./tooltip/Tooltip.vue.js";
|
|
18
|
+
export { _sfc_main as RioButton, _sfc_main$1 as RioButtonGroup, _sfc_main$2 as RioCheckbox, _sfc_main$3 as RioDialog, _sfc_main$4 as RioIconButton, _sfc_main$5 as RioMenu, _sfc_main$6 as RioMenuDivider, _sfc_main$7 as RioMenuGroup, _sfc_main$8 as RioMenuItem, _sfc_main$9 as RioRadio, _sfc_main$10 as RioRadioGroup, _sfc_main$11 as RioSplitButton, _sfc_main$12 as RioSubMenu, _sfc_main$13 as RioSwitch, _sfc_main$14 as RioTextField, _sfc_main$15 as RioTooltip, vRipple };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MenuAnchorPoint, MenuProps, MenuSelected } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
3
|
+
import "@rio-m3e/styles/base/anchored-position.css";
|
|
4
|
+
import "@rio-m3e/styles/menu.css";
|
|
5
|
+
interface Props extends Omit<MenuProps, 'selected'> {
|
|
6
|
+
/**
|
|
7
|
+
* What the menu opens from: an element or a component, such as the button that opens it (its
|
|
8
|
+
* template ref), or a point in viewport coordinates, for a context menu. Give the point the
|
|
9
|
+
* `element` it is on, and the menu keeps to that spot on it as it scrolls.
|
|
10
|
+
*/
|
|
11
|
+
anchor?: HTMLElement | {
|
|
12
|
+
readonly $el: unknown;
|
|
13
|
+
} | MenuAnchorPoint | null;
|
|
14
|
+
/** The selected value (`single`) or values (`multiple`), with `v-model`. */
|
|
15
|
+
modelValue?: MenuSelected;
|
|
16
|
+
}
|
|
17
|
+
type __VLS_Slots = {
|
|
18
|
+
/** `RioMenuItem`s, `RioMenuDivider`s, and `RioMenuGroup`s */
|
|
19
|
+
default?: () => unknown;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
22
|
+
"update:modelValue": (selected: MenuSelected) => any;
|
|
23
|
+
"update:open": (open: boolean) => any;
|
|
24
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
25
|
+
"onUpdate:modelValue"?: ((selected: MenuSelected) => any) | undefined;
|
|
26
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
31
|
+
new (): {
|
|
32
|
+
$slots: S;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export { _default as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { menuContextOf, menuKey } from "./context.js";
|
|
2
|
+
import { createElementBlock, defineComponent, mergeProps, onBeforeUnmount, onMounted, openBlock, provide, renderSlot, unref, useTemplateRef, watch } from "vue";
|
|
3
|
+
import { attachMenu, createMenu } from "@rio-m3e/core";
|
|
4
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
5
|
+
import "@rio-m3e/styles/base/anchored-position.css";
|
|
6
|
+
import "@rio-m3e/styles/menu.css";
|
|
7
|
+
// src/menu/Menu.vue
|
|
8
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
9
|
+
__name: "Menu",
|
|
10
|
+
props: {
|
|
11
|
+
anchor: {},
|
|
12
|
+
modelValue: {},
|
|
13
|
+
open: { type: Boolean },
|
|
14
|
+
variant: {},
|
|
15
|
+
selection: {},
|
|
16
|
+
label: {},
|
|
17
|
+
side: {},
|
|
18
|
+
align: {},
|
|
19
|
+
offset: {},
|
|
20
|
+
instant: { type: Boolean }
|
|
21
|
+
},
|
|
22
|
+
emits: ["update:open", "update:modelValue"],
|
|
23
|
+
setup(__props, { emit: __emit }) {
|
|
24
|
+
const emit = __emit;
|
|
25
|
+
const menu = createMenu({
|
|
26
|
+
props: () => ({
|
|
27
|
+
open: __props.open,
|
|
28
|
+
variant: __props.variant,
|
|
29
|
+
selection: __props.selection,
|
|
30
|
+
selected: __props.modelValue,
|
|
31
|
+
label: __props.label,
|
|
32
|
+
side: __props.side,
|
|
33
|
+
align: __props.align,
|
|
34
|
+
offset: __props.offset,
|
|
35
|
+
instant: __props.instant
|
|
36
|
+
}),
|
|
37
|
+
onChange: (selected) => emit("update:modelValue", selected),
|
|
38
|
+
onOpenChange: (next) => emit("update:open", next)
|
|
39
|
+
});
|
|
40
|
+
provide(menuKey, menuContextOf(menu));
|
|
41
|
+
/** A component's root element, or the element or point itself */
|
|
42
|
+
const anchorTarget = () => __props.anchor && "$el" in __props.anchor ? __props.anchor.$el : __props.anchor ?? void 0;
|
|
43
|
+
const root = useTemplateRef("root");
|
|
44
|
+
let handle;
|
|
45
|
+
onMounted(() => {
|
|
46
|
+
handle = attachMenu(root.value, {
|
|
47
|
+
anchor: anchorTarget,
|
|
48
|
+
props: () => ({
|
|
49
|
+
side: __props.side,
|
|
50
|
+
align: __props.align,
|
|
51
|
+
offset: __props.offset
|
|
52
|
+
}),
|
|
53
|
+
onClose: () => emit("update:open", false)
|
|
54
|
+
});
|
|
55
|
+
handle.sync(!!__props.open);
|
|
56
|
+
});
|
|
57
|
+
watch(() => __props.open, (next) => handle?.sync(!!next), { flush: "post" });
|
|
58
|
+
const pointOf = () => {
|
|
59
|
+
const target = anchorTarget();
|
|
60
|
+
return target && "x" in target && "y" in target && !("getBoundingClientRect" in target) ? target : void 0;
|
|
61
|
+
};
|
|
62
|
+
const anchorKey = () => {
|
|
63
|
+
const point = pointOf();
|
|
64
|
+
return point ? `${point.x},${point.y}` : anchorTarget();
|
|
65
|
+
};
|
|
66
|
+
watch([anchorKey, () => pointOf()?.element], () => handle?.update(), { flush: "post" });
|
|
67
|
+
onBeforeUnmount(() => handle?.detach());
|
|
68
|
+
return (_ctx, _cache) => {
|
|
69
|
+
return openBlock(), createElementBlock("div", mergeProps({
|
|
70
|
+
ref_key: "root",
|
|
71
|
+
ref: root
|
|
72
|
+
}, unref(menu).parts.root()), [renderSlot(_ctx.$slots, "default")], 16);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "@rio-m3e/styles/menu.css";
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export { _default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElementBlock, defineComponent, guardReactiveProps, normalizeProps, openBlock, unref } from "vue";
|
|
2
|
+
import { createMenuDivider } from "@rio-m3e/core";
|
|
3
|
+
import "@rio-m3e/styles/menu.css";
|
|
4
|
+
// src/menu/MenuDivider.vue
|
|
5
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
|
+
__name: "MenuDivider",
|
|
7
|
+
setup(__props) {
|
|
8
|
+
const divider = createMenuDivider();
|
|
9
|
+
return (_ctx, _cache) => {
|
|
10
|
+
return openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(unref(divider).parts.root())), null, 16);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MenuGroupProps } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/menu.css";
|
|
3
|
+
type __VLS_Slots = {
|
|
4
|
+
/** The group's `RioMenuItem`s */
|
|
5
|
+
default?: () => unknown;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<MenuGroupProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MenuGroupProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export { _default as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderSlot, toDisplayString, unref } from "vue";
|
|
2
|
+
import { createMenuGroup } from "@rio-m3e/core";
|
|
3
|
+
import "@rio-m3e/styles/menu.css";
|
|
4
|
+
// src/menu/MenuGroup.vue
|
|
5
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
|
+
__name: "MenuGroup",
|
|
7
|
+
props: { label: {} },
|
|
8
|
+
setup(__props) {
|
|
9
|
+
const group = createMenuGroup({ props: () => ({ label: __props.label }) });
|
|
10
|
+
return (_ctx, _cache) => {
|
|
11
|
+
return openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(unref(group).parts.root())), [unref(group).showsLabel() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(group).parts.label())), toDisplayString(__props.label), 17)) : createCommentVNode("v-if", true), createElementVNode("div", normalizeProps(guardReactiveProps(unref(group).parts.items())), [renderSlot(_ctx.$slots, "default")], 16)], 16);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MenuItemProps } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/focus-ring.css";
|
|
3
|
+
import "@rio-m3e/styles/base/state-layer.css";
|
|
4
|
+
import "@rio-m3e/styles/menu.css";
|
|
5
|
+
type __VLS_Slots = {
|
|
6
|
+
/** The label */
|
|
7
|
+
default?: () => unknown;
|
|
8
|
+
/**
|
|
9
|
+
* A leading icon, hidden from assistive technology. In a selecting menu, `selected` lets it show
|
|
10
|
+
* a check mark next to the color and shape.
|
|
11
|
+
*/
|
|
12
|
+
icon?: (props: {
|
|
13
|
+
selected: boolean;
|
|
14
|
+
}) => unknown;
|
|
15
|
+
/** Supporting text under the label */
|
|
16
|
+
'supporting-text'?: () => unknown;
|
|
17
|
+
/** Trailing text, such as a keyboard shortcut */
|
|
18
|
+
'trailing-text'?: () => unknown;
|
|
19
|
+
/** A trailing icon, hidden from assistive technology */
|
|
20
|
+
'trailing-icon'?: () => unknown;
|
|
21
|
+
};
|
|
22
|
+
declare const __VLS_base: import("vue").DefineComponent<MenuItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
23
|
+
click: (event: MouseEvent) => any;
|
|
24
|
+
}, string, import("vue").PublicProps, Readonly<MenuItemProps> & Readonly<{
|
|
25
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
26
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
30
|
+
new (): {
|
|
31
|
+
$slots: S;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export { _default as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { vRipple } from "../ripple/ripple.js";
|
|
2
|
+
import { menuKey } from "./context.js";
|
|
3
|
+
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, openBlock, renderSlot, unref, useSlots, withDirectives } from "vue";
|
|
4
|
+
import { createMenuItem } from "@rio-m3e/core";
|
|
5
|
+
import "@rio-m3e/styles/base/focus-ring.css";
|
|
6
|
+
import "@rio-m3e/styles/base/state-layer.css";
|
|
7
|
+
import "@rio-m3e/styles/menu.css";
|
|
8
|
+
// src/menu/MenuItem.vue
|
|
9
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
10
|
+
__name: "MenuItem",
|
|
11
|
+
props: {
|
|
12
|
+
value: {},
|
|
13
|
+
disabled: { type: Boolean }
|
|
14
|
+
},
|
|
15
|
+
emits: ["click"],
|
|
16
|
+
setup(__props, { emit: __emit }) {
|
|
17
|
+
const emit = __emit;
|
|
18
|
+
const slots = useSlots();
|
|
19
|
+
const menu = inject(menuKey, void 0);
|
|
20
|
+
const item = createMenuItem({
|
|
21
|
+
props: () => ({
|
|
22
|
+
value: __props.value,
|
|
23
|
+
disabled: __props.disabled
|
|
24
|
+
}),
|
|
25
|
+
content: () => ({
|
|
26
|
+
icon: !!slots.icon,
|
|
27
|
+
supportingText: !!slots["supporting-text"],
|
|
28
|
+
trailingText: !!slots["trailing-text"],
|
|
29
|
+
trailingIcon: !!slots["trailing-icon"]
|
|
30
|
+
}),
|
|
31
|
+
menu: () => menu,
|
|
32
|
+
onClick: (event) => emit("click", event)
|
|
33
|
+
});
|
|
34
|
+
return (_ctx, _cache) => {
|
|
35
|
+
return withDirectives((openBlock(), createElementBlock("button", mergeProps(unref(item).parts.root(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(item).handleClick && unref(item).handleClick(...args)) }), [
|
|
36
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.touch())), null, 16),
|
|
37
|
+
unref(item).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(item).parts.icon())), [renderSlot(_ctx.$slots, "icon", { selected: unref(item).selected() })], 16)) : createCommentVNode("v-if", true),
|
|
38
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.text())), [createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.label())), [renderSlot(_ctx.$slots, "default")], 16), unref(item).showsSupportingText() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(item).parts.supportingText())), [renderSlot(_ctx.$slots, "supporting-text")], 16)) : createCommentVNode("v-if", true)], 16),
|
|
39
|
+
unref(item).showsTrailingText() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(item).parts.trailingText())), [renderSlot(_ctx.$slots, "trailing-text")], 16)) : createCommentVNode("v-if", true),
|
|
40
|
+
unref(item).showsTrailingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 2 }, unref(item).parts.trailingIcon())), [renderSlot(_ctx.$slots, "trailing-icon")], 16)) : createCommentVNode("v-if", true)
|
|
41
|
+
], 16)), [[unref(vRipple)]]);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MenuSelected, SubMenuProps } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/focus-ring.css";
|
|
3
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
4
|
+
import "@rio-m3e/styles/base/state-layer.css";
|
|
5
|
+
import "@rio-m3e/styles/base/anchored-position.css";
|
|
6
|
+
import "@rio-m3e/styles/menu.css";
|
|
7
|
+
interface Props extends Omit<SubMenuProps, 'selected'> {
|
|
8
|
+
/** The selected value (`single`) or values (`multiple`), with `v-model`. */
|
|
9
|
+
modelValue?: MenuSelected;
|
|
10
|
+
}
|
|
11
|
+
type __VLS_Slots = {
|
|
12
|
+
/** The submenu's `RioMenuItem`s, `RioMenuDivider`s, `RioMenuGroup`s, and `RioSubMenu`s */
|
|
13
|
+
default?: () => unknown;
|
|
14
|
+
/** A leading icon on the item, hidden from assistive technology */
|
|
15
|
+
icon?: () => unknown;
|
|
16
|
+
/** Supporting text under the item's label */
|
|
17
|
+
'supporting-text'?: () => unknown;
|
|
18
|
+
/** Trailing text on the item */
|
|
19
|
+
'trailing-text'?: () => unknown;
|
|
20
|
+
/**
|
|
21
|
+
* A trailing icon on the item, hidden from assistive technology, such as an arrow pointing to the
|
|
22
|
+
* submenu. Rio ships no icons.
|
|
23
|
+
*/
|
|
24
|
+
'trailing-icon'?: () => unknown;
|
|
25
|
+
};
|
|
26
|
+
declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
27
|
+
"update:modelValue": (selected: MenuSelected) => any;
|
|
28
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
29
|
+
"onUpdate:modelValue"?: ((selected: MenuSelected) => any) | undefined;
|
|
30
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
34
|
+
new (): {
|
|
35
|
+
$slots: S;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export { _default as default };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { vRipple } from "../ripple/ripple.js";
|
|
2
|
+
import { menuContextOf, menuKey } from "./context.js";
|
|
3
|
+
import { Fragment, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, provide, ref, renderSlot, toDisplayString, unref, useSlots, useTemplateRef, watch, withDirectives } from "vue";
|
|
4
|
+
import { attachSubMenu, createSubMenu } from "@rio-m3e/core";
|
|
5
|
+
import "@rio-m3e/styles/base/focus-ring.css";
|
|
6
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
7
|
+
import "@rio-m3e/styles/base/state-layer.css";
|
|
8
|
+
import "@rio-m3e/styles/base/anchored-position.css";
|
|
9
|
+
import "@rio-m3e/styles/menu.css";
|
|
10
|
+
// src/menu/SubMenu.vue
|
|
11
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
__name: "SubMenu",
|
|
14
|
+
props: {
|
|
15
|
+
modelValue: {},
|
|
16
|
+
label: {},
|
|
17
|
+
disabled: { type: Boolean },
|
|
18
|
+
selection: {}
|
|
19
|
+
},
|
|
20
|
+
emits: ["update:modelValue"],
|
|
21
|
+
setup(__props, { emit: __emit }) {
|
|
22
|
+
const emit = __emit;
|
|
23
|
+
const slots = useSlots();
|
|
24
|
+
const parent = inject(menuKey, void 0);
|
|
25
|
+
const open = ref(false);
|
|
26
|
+
const sub = createSubMenu({
|
|
27
|
+
props: () => ({
|
|
28
|
+
label: __props.label,
|
|
29
|
+
disabled: __props.disabled,
|
|
30
|
+
selection: __props.selection,
|
|
31
|
+
selected: __props.modelValue
|
|
32
|
+
}),
|
|
33
|
+
content: () => ({
|
|
34
|
+
icon: !!slots.icon,
|
|
35
|
+
supportingText: !!slots["supporting-text"],
|
|
36
|
+
trailingText: !!slots["trailing-text"],
|
|
37
|
+
trailingIcon: !!slots["trailing-icon"]
|
|
38
|
+
}),
|
|
39
|
+
menu: () => parent,
|
|
40
|
+
open: () => open.value,
|
|
41
|
+
onChange: (selected) => emit("update:modelValue", selected),
|
|
42
|
+
onOpenChange: (next) => open.value = next
|
|
43
|
+
});
|
|
44
|
+
const { item } = sub;
|
|
45
|
+
provide(menuKey, menuContextOf(sub.menu));
|
|
46
|
+
const itemElement = useTemplateRef("itemElement");
|
|
47
|
+
const root = useTemplateRef("root");
|
|
48
|
+
let handle;
|
|
49
|
+
onMounted(() => {
|
|
50
|
+
handle = attachSubMenu(itemElement.value, root.value, { onOpenChange: (next) => open.value = next });
|
|
51
|
+
handle.sync(open.value);
|
|
52
|
+
});
|
|
53
|
+
watch(open, (next) => handle?.sync(next), { flush: "post" });
|
|
54
|
+
onBeforeUnmount(() => handle?.detach());
|
|
55
|
+
return (_ctx, _cache) => {
|
|
56
|
+
return openBlock(), createElementBlock(Fragment, null, [withDirectives((openBlock(), createElementBlock("button", mergeProps({
|
|
57
|
+
ref_key: "itemElement",
|
|
58
|
+
ref: itemElement
|
|
59
|
+
}, mergeProps(_ctx.$attrs, unref(item).parts.root()), { onClick: _cache[0] || (_cache[0] = (...args) => unref(item).handleClick && unref(item).handleClick(...args)) }), [
|
|
60
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.touch())), null, 16),
|
|
61
|
+
unref(item).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(item).parts.icon())), [renderSlot(_ctx.$slots, "icon")], 16)) : createCommentVNode("v-if", true),
|
|
62
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.text())), [createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.label())), toDisplayString(__props.label), 17), unref(item).showsSupportingText() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(item).parts.supportingText())), [renderSlot(_ctx.$slots, "supporting-text")], 16)) : createCommentVNode("v-if", true)], 16),
|
|
63
|
+
unref(item).showsTrailingText() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(item).parts.trailingText())), [renderSlot(_ctx.$slots, "trailing-text")], 16)) : createCommentVNode("v-if", true),
|
|
64
|
+
unref(item).showsTrailingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 2 }, unref(item).parts.trailingIcon())), [renderSlot(_ctx.$slots, "trailing-icon")], 16)) : createCommentVNode("v-if", true)
|
|
65
|
+
], 16)), [[unref(vRipple)]]), createElementVNode("div", mergeProps({
|
|
66
|
+
ref_key: "root",
|
|
67
|
+
ref: root
|
|
68
|
+
}, unref(sub).menu.parts.root()), [renderSlot(_ctx.$slots, "default")], 16)], 64);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/menu/context.ts
|
|
2
|
+
/** The parts of a core menu API that its items and submenus read */
|
|
3
|
+
const menuContextOf = (menu) => ({
|
|
4
|
+
selection: menu.selection,
|
|
5
|
+
isSelected: menu.isSelected,
|
|
6
|
+
choose: menu.choose,
|
|
7
|
+
close: menu.close,
|
|
8
|
+
variant: menu.variant,
|
|
9
|
+
instant: menu.instant
|
|
10
|
+
});
|
|
11
|
+
const menuKey = Symbol("RioMenu");
|
|
12
|
+
export { menuContextOf, menuKey };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RadioProps, RadioValue } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
3
|
+
import "@rio-m3e/styles/base/ripple.css";
|
|
4
|
+
import "@rio-m3e/styles/radio.css";
|
|
5
|
+
interface Props extends Omit<RadioProps, 'selected'> {
|
|
6
|
+
/** The group's `v-model` takes this value when the radio button is selected. */
|
|
7
|
+
value: RadioValue;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export { _default as default };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { radioGroupKey } from "./context.js";
|
|
2
|
+
import { createElementBlock, createElementVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, unref, useTemplateRef } from "vue";
|
|
3
|
+
import { attachCheckable, attachRipple, createRadio } from "@rio-m3e/core";
|
|
4
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
5
|
+
import "@rio-m3e/styles/base/ripple.css";
|
|
6
|
+
import "@rio-m3e/styles/radio.css";
|
|
7
|
+
// src/radio/Radio.vue
|
|
8
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
__name: "Radio",
|
|
11
|
+
props: {
|
|
12
|
+
value: {},
|
|
13
|
+
disabled: { type: Boolean },
|
|
14
|
+
softDisabled: { type: Boolean }
|
|
15
|
+
},
|
|
16
|
+
setup(__props) {
|
|
17
|
+
const group = inject(radioGroupKey);
|
|
18
|
+
if (!group) throw new Error("RioRadio has to be inside a RioRadioGroup.");
|
|
19
|
+
const radio = createRadio({
|
|
20
|
+
props: () => ({
|
|
21
|
+
selected: group.isSelected(__props.value),
|
|
22
|
+
disabled: __props.disabled,
|
|
23
|
+
softDisabled: __props.softDisabled
|
|
24
|
+
}),
|
|
25
|
+
name: group.name,
|
|
26
|
+
value: () => String(__props.value)
|
|
27
|
+
});
|
|
28
|
+
const input = useTemplateRef("input");
|
|
29
|
+
const state = useTemplateRef("state");
|
|
30
|
+
let checkable;
|
|
31
|
+
let ripple;
|
|
32
|
+
let unregister;
|
|
33
|
+
onMounted(() => {
|
|
34
|
+
checkable = attachCheckable(input.value, {
|
|
35
|
+
checked: () => group.isSelected(__props.value),
|
|
36
|
+
blocked: radio.blocked,
|
|
37
|
+
onChange: (checked) => checked && group.select(__props.value)
|
|
38
|
+
});
|
|
39
|
+
unregister = group.register(checkable);
|
|
40
|
+
ripple = attachRipple(input.value, { surface: state.value });
|
|
41
|
+
});
|
|
42
|
+
onUpdated(() => checkable?.sync());
|
|
43
|
+
onBeforeUnmount(() => {
|
|
44
|
+
unregister?.();
|
|
45
|
+
checkable?.detach();
|
|
46
|
+
ripple?.detach();
|
|
47
|
+
});
|
|
48
|
+
return (_ctx, _cache) => {
|
|
49
|
+
return openBlock(), createElementBlock("span", mergeProps(unref(radio).parts.root(), {
|
|
50
|
+
class: _ctx.$attrs.class,
|
|
51
|
+
style: _ctx.$attrs.style
|
|
52
|
+
}), [
|
|
53
|
+
createElementVNode("input", mergeProps({
|
|
54
|
+
ref_key: "input",
|
|
55
|
+
ref: input
|
|
56
|
+
}, {
|
|
57
|
+
..._ctx.$attrs,
|
|
58
|
+
class: void 0,
|
|
59
|
+
style: void 0,
|
|
60
|
+
...unref(radio).parts.input()
|
|
61
|
+
}), null, 16),
|
|
62
|
+
createElementVNode("span", mergeProps({
|
|
63
|
+
ref_key: "state",
|
|
64
|
+
ref: state
|
|
65
|
+
}, unref(radio).parts.state()), null, 16),
|
|
66
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(radio).parts.icon())), null, 16)
|
|
67
|
+
], 16);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RadioGroupProps, RadioValue } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/radio.css";
|
|
3
|
+
interface Props extends RadioGroupProps {
|
|
4
|
+
/** The `name` the radio buttons submit their value under. Defaults to a unique one. */
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
type __VLS_Props = Props;
|
|
8
|
+
type __VLS_Slots = {
|
|
9
|
+
/** `RioRadio`s, each in a `<label>` with its text */
|
|
10
|
+
default?: () => unknown;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_ModelProps = {
|
|
13
|
+
/** The selected radio button's value, with `v-model`. */
|
|
14
|
+
modelValue?: RadioValue | undefined;
|
|
15
|
+
};
|
|
16
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
17
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
"update:modelValue": (value: RadioValue | undefined) => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
20
|
+
"onUpdate:modelValue"?: ((value: RadioValue | undefined) => any) | undefined;
|
|
21
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
23
|
+
declare const _default: typeof __VLS_export;
|
|
24
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
25
|
+
new (): {
|
|
26
|
+
$slots: S;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export { _default as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { radioGroupKey } from "./context.js";
|
|
2
|
+
import { createElementBlock, defineComponent, mergeModels, mergeProps, nextTick, onBeforeUnmount, onMounted, openBlock, provide, renderSlot, unref, useId, useModel, useTemplateRef, watch } from "vue";
|
|
3
|
+
import { attachRadioGroup, createRadioGroup } from "@rio-m3e/core";
|
|
4
|
+
import "@rio-m3e/styles/radio.css";
|
|
5
|
+
// src/radio/RadioGroup.vue
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
__name: "RadioGroup",
|
|
8
|
+
props: /*@__PURE__*/ mergeModels({
|
|
9
|
+
name: {},
|
|
10
|
+
label: {}
|
|
11
|
+
}, {
|
|
12
|
+
"modelValue": {},
|
|
13
|
+
"modelModifiers": {}
|
|
14
|
+
}),
|
|
15
|
+
emits: ["update:modelValue"],
|
|
16
|
+
setup(__props) {
|
|
17
|
+
/** The selected radio button's value, with `v-model`. */
|
|
18
|
+
const model = useModel(__props, "modelValue");
|
|
19
|
+
const group = createRadioGroup({ props: () => ({ label: __props.label }) });
|
|
20
|
+
const id = useId();
|
|
21
|
+
const inputs = /* @__PURE__ */ new Set();
|
|
22
|
+
const resync = () => void nextTick(() => inputs.forEach((input) => input.sync()));
|
|
23
|
+
watch(model, resync);
|
|
24
|
+
provide(radioGroupKey, {
|
|
25
|
+
name: () => __props.name ?? `${id}-radio`,
|
|
26
|
+
isSelected: (value) => model.value === value,
|
|
27
|
+
select: (value) => model.value = value,
|
|
28
|
+
register(input) {
|
|
29
|
+
inputs.add(input);
|
|
30
|
+
return () => inputs.delete(input);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const root = useTemplateRef("root");
|
|
34
|
+
let handle;
|
|
35
|
+
onMounted(() => handle = attachRadioGroup(root.value));
|
|
36
|
+
onBeforeUnmount(() => handle?.detach());
|
|
37
|
+
return (_ctx, _cache) => {
|
|
38
|
+
return openBlock(), createElementBlock("div", mergeProps({
|
|
39
|
+
ref_key: "root",
|
|
40
|
+
ref: root
|
|
41
|
+
}, unref(group).parts.root(), { onChange: resync }), [renderSlot(_ctx.$slots, "default")], 16);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TextFieldProps } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
3
|
+
import "@rio-m3e/styles/text-field.css";
|
|
4
|
+
type Props = Omit<TextFieldProps, 'value'>;
|
|
5
|
+
type __VLS_Props = Props;
|
|
6
|
+
type __VLS_Slots = {
|
|
7
|
+
/** An icon before the text, such as a search icon */
|
|
8
|
+
'leading-icon'?: () => unknown;
|
|
9
|
+
/** An icon or an icon button after the text, such as a clear button or an error icon */
|
|
10
|
+
'trailing-icon'?: () => unknown;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_ModelProps = {
|
|
13
|
+
/**
|
|
14
|
+
* The text in the field, with `v-model`. With `type="number"` it is a number, as Vue's `v-model`
|
|
15
|
+
* on an input makes it.
|
|
16
|
+
*/
|
|
17
|
+
modelValue?: string | number;
|
|
18
|
+
};
|
|
19
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
20
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
"update:modelValue": (value: string | number) => any;
|
|
22
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
23
|
+
"onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
|
|
24
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export { _default as default };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, renderSlot, toDisplayString, unref, useAttrs, useId, useModel, useSlots, useTemplateRef, vModelDynamic, vModelText, withDirectives } from "vue";
|
|
2
|
+
import { attachTextField, createTextField } from "@rio-m3e/core";
|
|
3
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
4
|
+
import "@rio-m3e/styles/text-field.css";
|
|
5
|
+
// src/text-field/TextField.vue
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
__name: "TextField",
|
|
9
|
+
props: /*@__PURE__*/ mergeModels({
|
|
10
|
+
variant: {},
|
|
11
|
+
label: {},
|
|
12
|
+
multiline: { type: Boolean },
|
|
13
|
+
rows: {},
|
|
14
|
+
prefix: {},
|
|
15
|
+
suffix: {},
|
|
16
|
+
supportingText: {},
|
|
17
|
+
error: { type: Boolean },
|
|
18
|
+
errorText: {},
|
|
19
|
+
maxlength: {},
|
|
20
|
+
required: { type: Boolean },
|
|
21
|
+
disabled: { type: Boolean },
|
|
22
|
+
readonly: { type: Boolean }
|
|
23
|
+
}, {
|
|
24
|
+
"modelValue": { default: "" },
|
|
25
|
+
"modelModifiers": {}
|
|
26
|
+
}),
|
|
27
|
+
emits: ["update:modelValue"],
|
|
28
|
+
setup(__props) {
|
|
29
|
+
/**
|
|
30
|
+
* The text in the field, with `v-model`. With `type="number"` it is a number, as Vue's `v-model`
|
|
31
|
+
* on an input makes it.
|
|
32
|
+
*/
|
|
33
|
+
const model = useModel(__props, "modelValue");
|
|
34
|
+
const slots = useSlots();
|
|
35
|
+
const id = useId();
|
|
36
|
+
const attrs = useAttrs();
|
|
37
|
+
const field = createTextField({
|
|
38
|
+
props: () => ({
|
|
39
|
+
variant: __props.variant,
|
|
40
|
+
label: __props.label,
|
|
41
|
+
value: String(model.value),
|
|
42
|
+
multiline: __props.multiline,
|
|
43
|
+
rows: __props.rows,
|
|
44
|
+
prefix: __props.prefix,
|
|
45
|
+
suffix: __props.suffix,
|
|
46
|
+
supportingText: __props.supportingText,
|
|
47
|
+
error: __props.error,
|
|
48
|
+
errorText: __props.errorText,
|
|
49
|
+
maxlength: __props.maxlength,
|
|
50
|
+
required: __props.required,
|
|
51
|
+
disabled: __props.disabled,
|
|
52
|
+
readonly: __props.readonly
|
|
53
|
+
}),
|
|
54
|
+
content: () => ({
|
|
55
|
+
leadingIcon: !!slots["leading-icon"],
|
|
56
|
+
trailingIcon: !!slots["trailing-icon"]
|
|
57
|
+
}),
|
|
58
|
+
ids: {
|
|
59
|
+
get input() {
|
|
60
|
+
return typeof attrs.id === "string" && attrs.id ? attrs.id : `${id}-input`;
|
|
61
|
+
},
|
|
62
|
+
prefix: `${id}-prefix`,
|
|
63
|
+
suffix: `${id}-suffix`,
|
|
64
|
+
supportingText: `${id}-supporting`,
|
|
65
|
+
counter: `${id}-counter`
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const container = useTemplateRef("container");
|
|
69
|
+
const input = useTemplateRef("input");
|
|
70
|
+
let handle;
|
|
71
|
+
onMounted(() => handle = attachTextField(container.value, () => input.value));
|
|
72
|
+
onUpdated(() => handle?.update());
|
|
73
|
+
onBeforeUnmount(() => handle?.detach());
|
|
74
|
+
return (_ctx, _cache) => {
|
|
75
|
+
return openBlock(), createElementBlock("div", mergeProps(unref(field).parts.root(), {
|
|
76
|
+
class: _ctx.$attrs.class,
|
|
77
|
+
style: _ctx.$attrs.style
|
|
78
|
+
}), [createElementVNode("div", normalizeProps(guardReactiveProps(unref(field).parts.frame())), [
|
|
79
|
+
unref(field).showsOutline() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.outline())), [
|
|
80
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(field).parts.outlineStart())), null, 16),
|
|
81
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(field).parts.outlineNotch())), toDisplayString(unref(field).labelText()), 17),
|
|
82
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(field).parts.outlineEnd())), null, 16)
|
|
83
|
+
], 16)) : createCommentVNode("v-if", true),
|
|
84
|
+
unref(field).showsLabel() ? (openBlock(), createElementBlock("label", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.label())), toDisplayString(unref(field).labelText()), 17)) : createCommentVNode("v-if", true),
|
|
85
|
+
createElementVNode("div", mergeProps({
|
|
86
|
+
ref_key: "container",
|
|
87
|
+
ref: container
|
|
88
|
+
}, unref(field).parts.container()), [
|
|
89
|
+
unref(field).showsLeadingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.leadingIcon())), [renderSlot(_ctx.$slots, "leading-icon")], 16)) : createCommentVNode("v-if", true),
|
|
90
|
+
createElementVNode("div", normalizeProps(guardReactiveProps(unref(field).parts.content())), [
|
|
91
|
+
unref(field).showsPrefix() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.prefix())), toDisplayString(__props.prefix), 17)) : createCommentVNode("v-if", true),
|
|
92
|
+
createCommentVNode(" v-model, not :value and @input: it waits for an IME to finish composing. "),
|
|
93
|
+
unref(field).singleLine() ? withDirectives((openBlock(), createElementBlock("input", mergeProps({
|
|
94
|
+
key: 1,
|
|
95
|
+
ref_key: "input",
|
|
96
|
+
ref: input,
|
|
97
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event)
|
|
98
|
+
}, {
|
|
99
|
+
..._ctx.$attrs,
|
|
100
|
+
class: void 0,
|
|
101
|
+
style: void 0,
|
|
102
|
+
...unref(field).parts.input()
|
|
103
|
+
}), null, 16)), [[vModelDynamic, model.value]]) : withDirectives((openBlock(), createElementBlock("textarea", mergeProps({
|
|
104
|
+
key: 2,
|
|
105
|
+
ref_key: "input",
|
|
106
|
+
ref: input,
|
|
107
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => model.value = $event)
|
|
108
|
+
}, {
|
|
109
|
+
..._ctx.$attrs,
|
|
110
|
+
class: void 0,
|
|
111
|
+
style: void 0,
|
|
112
|
+
...unref(field).parts.textarea()
|
|
113
|
+
}), null, 16)), [[vModelText, model.value]]),
|
|
114
|
+
unref(field).showsSuffix() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 3 }, unref(field).parts.suffix())), toDisplayString(__props.suffix), 17)) : createCommentVNode("v-if", true)
|
|
115
|
+
], 16),
|
|
116
|
+
unref(field).showsTrailingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.trailingIcon())), [renderSlot(_ctx.$slots, "trailing-icon")], 16)) : createCommentVNode("v-if", true)
|
|
117
|
+
], 16)
|
|
118
|
+
], 16), unref(field).showsSupporting() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.supporting())), [
|
|
119
|
+
createCommentVNode(" A new element for the error text, so it arrives with its alert role. "),
|
|
120
|
+
unref(field).showsSupportingText() ? (openBlock(), createElementBlock("span", mergeProps({ key: unref(field).showsErrorText() ? "error" : "supporting" }, unref(field).parts.supportingText()), toDisplayString(unref(field).supportingTextNow()), 17)) : createCommentVNode("v-if", true),
|
|
121
|
+
unref(field).showsCounter() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.counter())), toDisplayString(unref(field).counterText()), 17)) : createCommentVNode("v-if", true)
|
|
122
|
+
], 16)) : createCommentVNode("v-if", true)], 16);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TooltipProps } from "@rio-m3e/core";
|
|
2
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
3
|
+
import "@rio-m3e/styles/base/anchored-position.css";
|
|
4
|
+
import "@rio-m3e/styles/tooltip.css";
|
|
5
|
+
interface Props extends Omit<TooltipProps, 'open'> {
|
|
6
|
+
/** The tooltip's text. The `content` slot takes richer content instead. */
|
|
7
|
+
text?: string;
|
|
8
|
+
/** A subhead above the text (rich only) */
|
|
9
|
+
subhead?: string;
|
|
10
|
+
}
|
|
11
|
+
type __VLS_Props = Props;
|
|
12
|
+
type __VLS_Slots = {
|
|
13
|
+
/** The element the tooltip is for, such as a button. One element. */
|
|
14
|
+
default?: () => unknown;
|
|
15
|
+
/** The tooltip's text, in place of the `text` prop */
|
|
16
|
+
content?: () => unknown;
|
|
17
|
+
/** Up to two text buttons (rich only). They make the tooltip a non-modal dialog. */
|
|
18
|
+
actions?: () => unknown;
|
|
19
|
+
};
|
|
20
|
+
type __VLS_ModelProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Whether the tooltip is shown, with `v-model:open`. Without it the tooltip keeps the state
|
|
23
|
+
* itself; with it, the app can open a persistent tooltip as the page loads.
|
|
24
|
+
*/
|
|
25
|
+
'open'?: boolean;
|
|
26
|
+
};
|
|
27
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
28
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
29
|
+
"update:open": (value: boolean) => any;
|
|
30
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
31
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
32
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
33
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
34
|
+
declare const _default: typeof __VLS_export;
|
|
35
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
36
|
+
new (): {
|
|
37
|
+
$slots: S;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export { _default as default };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, renderSlot, toDisplayString, unref, useId, useModel, useSlots, useTemplateRef, watch, withModifiers } from "vue";
|
|
2
|
+
import { attachTooltip, createTooltip } from "@rio-m3e/core";
|
|
3
|
+
import "@rio-m3e/styles/base/reduced-motion.css";
|
|
4
|
+
import "@rio-m3e/styles/base/anchored-position.css";
|
|
5
|
+
import "@rio-m3e/styles/tooltip.css";
|
|
6
|
+
// src/tooltip/Tooltip.vue
|
|
7
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
8
|
+
__name: "Tooltip",
|
|
9
|
+
props: /*@__PURE__*/ mergeModels({
|
|
10
|
+
text: {},
|
|
11
|
+
subhead: {},
|
|
12
|
+
variant: {},
|
|
13
|
+
persistent: { type: Boolean },
|
|
14
|
+
side: {},
|
|
15
|
+
align: {},
|
|
16
|
+
offset: {}
|
|
17
|
+
}, {
|
|
18
|
+
"open": {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: false
|
|
21
|
+
},
|
|
22
|
+
"openModifiers": {}
|
|
23
|
+
}),
|
|
24
|
+
emits: ["update:open"],
|
|
25
|
+
setup(__props) {
|
|
26
|
+
/**
|
|
27
|
+
* Whether the tooltip is shown, with `v-model:open`. Without it the tooltip keeps the state
|
|
28
|
+
* itself; with it, the app can open a persistent tooltip as the page loads.
|
|
29
|
+
*/
|
|
30
|
+
const open = useModel(__props, "open");
|
|
31
|
+
const slots = useSlots();
|
|
32
|
+
const id = useId();
|
|
33
|
+
const tooltip = createTooltip({
|
|
34
|
+
props: () => ({
|
|
35
|
+
variant: __props.variant,
|
|
36
|
+
persistent: __props.persistent,
|
|
37
|
+
open: open.value,
|
|
38
|
+
side: __props.side,
|
|
39
|
+
align: __props.align,
|
|
40
|
+
offset: __props.offset
|
|
41
|
+
}),
|
|
42
|
+
content: () => ({
|
|
43
|
+
subhead: !!__props.subhead,
|
|
44
|
+
actions: !!slots.actions
|
|
45
|
+
}),
|
|
46
|
+
ids: {
|
|
47
|
+
root: `${id}-tooltip`,
|
|
48
|
+
subhead: `${id}-subhead`,
|
|
49
|
+
supportingText: `${id}-text`
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const trigger = useTemplateRef("trigger");
|
|
53
|
+
const root = useTemplateRef("root");
|
|
54
|
+
let handle;
|
|
55
|
+
onMounted(() => {
|
|
56
|
+
handle = attachTooltip(trigger.value, root.value, {
|
|
57
|
+
placement: tooltip.placement,
|
|
58
|
+
persistent: tooltip.persistent,
|
|
59
|
+
interactive: tooltip.interactive,
|
|
60
|
+
onOpenChange: (next) => open.value = next
|
|
61
|
+
});
|
|
62
|
+
handle.sync(open.value);
|
|
63
|
+
});
|
|
64
|
+
watch(open, (next) => handle?.sync(next), { flush: "post" });
|
|
65
|
+
onUpdated(() => handle?.update());
|
|
66
|
+
onBeforeUnmount(() => handle?.detach());
|
|
67
|
+
return (_ctx, _cache) => {
|
|
68
|
+
return openBlock(), createElementBlock("span", mergeProps({
|
|
69
|
+
ref_key: "trigger",
|
|
70
|
+
ref: trigger
|
|
71
|
+
}, unref(tooltip).parts.trigger()), [
|
|
72
|
+
renderSlot(_ctx.$slots, "default"),
|
|
73
|
+
createCommentVNode(" Clicks and presses stay in the tooltip, so a card or a row around its element doesn't take\n them. Keys go on, for Escape. "),
|
|
74
|
+
createElementVNode("span", mergeProps({
|
|
75
|
+
ref_key: "root",
|
|
76
|
+
ref: root
|
|
77
|
+
}, unref(tooltip).parts.root(), {
|
|
78
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"])),
|
|
79
|
+
onAuxclick: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"])),
|
|
80
|
+
onDblclick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"])),
|
|
81
|
+
onPointerdown: _cache[3] || (_cache[3] = withModifiers(() => {}, ["stop"])),
|
|
82
|
+
onPointerup: _cache[4] || (_cache[4] = withModifiers(() => {}, ["stop"])),
|
|
83
|
+
onMousedown: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"])),
|
|
84
|
+
onMouseup: _cache[6] || (_cache[6] = withModifiers(() => {}, ["stop"])),
|
|
85
|
+
onContextmenu: _cache[7] || (_cache[7] = withModifiers(() => {}, ["stop"]))
|
|
86
|
+
}), [
|
|
87
|
+
unref(tooltip).showsSubhead() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(tooltip).parts.subhead())), toDisplayString(__props.subhead), 17)) : createCommentVNode("v-if", true),
|
|
88
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(tooltip).parts.supportingText())), [renderSlot(_ctx.$slots, "content", {}, () => [createTextVNode(toDisplayString(__props.text), 1)])], 16),
|
|
89
|
+
unref(tooltip).showsActions() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(tooltip).parts.actions())), [renderSlot(_ctx.$slots, "actions")], 16)) : createCommentVNode("v-if", true)
|
|
90
|
+
], 16)
|
|
91
|
+
], 16);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
export { _sfc_main as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rio-m3e/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Vue components for Rio, a Material 3 Expressive implementation",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "LegenLee",
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@rio-m3e/core": "^0.
|
|
31
|
-
"@rio-m3e/styles": "^0.
|
|
30
|
+
"@rio-m3e/core": "^0.4.0",
|
|
31
|
+
"@rio-m3e/styles": "^0.4.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@fontsource/roboto": "^5.3.0",
|
|
35
35
|
"@mdi/js": "^7.4.47",
|
|
36
|
-
"@rio-m3e/
|
|
36
|
+
"@rio-m3e/testing": "^0.0.0",
|
|
37
|
+
"@rio-m3e/tokens": "^0.4.0",
|
|
37
38
|
"tsdown": "0.23.7",
|
|
38
39
|
"typescript": "~6.0.3",
|
|
39
40
|
"unplugin-vue": "^8.0.1",
|