@rio-m3e/vue 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button/Button.vue.js +12 -7
- package/dist/checkbox/Checkbox.vue.d.ts +11 -0
- package/dist/checkbox/Checkbox.vue.js +70 -0
- package/dist/date-picker/DatePicker.vue.d.ts +67 -0
- package/dist/date-picker/DatePicker.vue.js +238 -0
- package/dist/date-picker/DatePickerCalendar.vue.js +146 -0
- package/dist/date-picker/DatePickerDialog.vue.d.ts +58 -0
- package/dist/date-picker/DatePickerDialog.vue.js +199 -0
- package/dist/dialog/Dialog.vue.js +13 -4
- package/dist/icon-button/IconButton.vue.js +8 -3
- package/dist/index.d.ts +24 -11
- package/dist/index.js +24 -11
- package/dist/locale/LocaleProvider.vue.d.ts +16 -0
- package/dist/locale/LocaleProvider.vue.js +14 -0
- package/dist/locale/locale.d.ts +16 -0
- package/dist/locale/locale.js +27 -0
- package/dist/menu/SubMenu.vue.js +10 -2
- package/dist/radio/Radio.vue.d.ts +11 -0
- package/dist/radio/Radio.vue.js +70 -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/rio/rio.d.ts +37 -0
- package/dist/rio/rio.js +44 -0
- package/dist/select/Select.vue.d.ts +46 -0
- package/dist/select/Select.vue.js +178 -0
- package/dist/select/SelectOption.vue.d.ts +30 -0
- package/dist/select/SelectOption.vue.js +58 -0
- package/dist/select/context.js +3 -0
- package/dist/text-field/TextField.vue.d.ts +32 -0
- package/dist/text-field/TextField.vue.js +124 -0
- package/dist/time-picker/TimeInput.vue.d.ts +25 -0
- package/dist/time-picker/TimeInput.vue.js +71 -0
- package/dist/time-picker/TimePickerBody.vue.js +46 -0
- package/dist/time-picker/TimePickerDialog.vue.d.ts +46 -0
- package/dist/time-picker/TimePickerDialog.vue.js +142 -0
- package/dist/tooltip/Tooltip.vue.js +22 -9
- package/package.json +4 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { App, MaybeRefOrGetter } from "vue";
|
|
2
|
+
import { PartialMessages } from "@rio-m3e/core";
|
|
3
|
+
import { ThemeColorScheme, ThemeOptions } from "@rio-m3e/tokens";
|
|
4
|
+
export interface RioThemeOptions extends ThemeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The root's `color-scheme`, which picks each color's light or dark value. `false` leaves it to
|
|
7
|
+
* the app. Defaults to `'light dark'`, which follows the system.
|
|
8
|
+
*/
|
|
9
|
+
colorScheme?: ThemeColorScheme;
|
|
10
|
+
}
|
|
11
|
+
export interface RioOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The theme, written as `--rio-*` variables on the document's root as the app installs Rio,
|
|
14
|
+
* before it mounts. A ref or a getter writes it again when it changes.
|
|
15
|
+
*/
|
|
16
|
+
theme?: MaybeRefOrGetter<RioThemeOptions | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* The app's language, such as `ko` or `en-GB`. A ref or a getter changes it later. Without one,
|
|
19
|
+
* the document's, then the browser's, then English.
|
|
20
|
+
*/
|
|
21
|
+
locale?: MaybeRefOrGetter<string | undefined>;
|
|
22
|
+
/** For a language Rio has no table for, the language whose messages fill in. Defaults to `'en'`. */
|
|
23
|
+
fallbackLocale?: MaybeRefOrGetter<string | undefined>;
|
|
24
|
+
/** Message tables by language tag: languages Rio has no table for, or messages that replace Rio's. */
|
|
25
|
+
messages?: MaybeRefOrGetter<Record<string, PartialMessages> | undefined>;
|
|
26
|
+
}
|
|
27
|
+
/** A Vue plugin, for `app.use` */
|
|
28
|
+
export interface RioPlugin {
|
|
29
|
+
install(app: App): void;
|
|
30
|
+
/** The theme as a stylesheet, for server rendering: put it in the page's `<head>`. Empty without a theme. */
|
|
31
|
+
readonly css: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rio for a whole app: `app.use(createRio({ theme: { sourceColor: '#6750a4' }, locale: 'ko' }))`.
|
|
35
|
+
* A `RioLocaleProvider` inside, or a component's own `locale`, takes over the language from it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createRio(options?: RioOptions): RioPlugin;
|
package/dist/rio/rio.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { localeKey, messagesKey } from "../locale/locale.js";
|
|
2
|
+
import { computed, effectScope, toRef, toValue, watchEffect } from "vue";
|
|
3
|
+
import { createThemeCss, createThemeVariables } from "@rio-m3e/tokens";
|
|
4
|
+
// src/rio/rio.ts
|
|
5
|
+
/**
|
|
6
|
+
* Rio for a whole app: `app.use(createRio({ theme: { sourceColor: '#6750a4' }, locale: 'ko' }))`.
|
|
7
|
+
* A `RioLocaleProvider` inside, or a component's own `locale`, takes over the language from it.
|
|
8
|
+
*/
|
|
9
|
+
function createRio(options = {}) {
|
|
10
|
+
return {
|
|
11
|
+
get css() {
|
|
12
|
+
const theme = toValue(options.theme);
|
|
13
|
+
return theme ? createThemeCss(theme) : "";
|
|
14
|
+
},
|
|
15
|
+
install(app) {
|
|
16
|
+
app.provide(localeKey, toRef(options.locale));
|
|
17
|
+
app.provide(messagesKey, computed(() => ({
|
|
18
|
+
messages: toValue(options.messages),
|
|
19
|
+
fallbackLocale: toValue(options.fallbackLocale)
|
|
20
|
+
})));
|
|
21
|
+
if (options.theme === void 0 || typeof document === "undefined") return;
|
|
22
|
+
const root = document.documentElement;
|
|
23
|
+
let written = /* @__PURE__ */ new Set();
|
|
24
|
+
const scope = effectScope(true);
|
|
25
|
+
scope.run(() => watchEffect(() => {
|
|
26
|
+
const theme = toValue(options.theme);
|
|
27
|
+
const next = /* @__PURE__ */ new Map();
|
|
28
|
+
if (theme) {
|
|
29
|
+
const { colorScheme = "light dark", ...rest } = theme;
|
|
30
|
+
for (const [name, value] of Object.entries(createThemeVariables(rest))) next.set(name, value);
|
|
31
|
+
if (colorScheme) next.set("color-scheme", colorScheme);
|
|
32
|
+
}
|
|
33
|
+
for (const name of written) if (!next.has(name)) root.style.removeProperty(name);
|
|
34
|
+
for (const [name, value] of next) root.style.setProperty(name, value);
|
|
35
|
+
written = new Set(next.keys());
|
|
36
|
+
}));
|
|
37
|
+
app.onUnmount(() => {
|
|
38
|
+
scope.stop();
|
|
39
|
+
for (const name of written) root.style.removeProperty(name);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export { createRio };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SelectProps, SelectSelected, SelectValue } 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/text-field.css";
|
|
5
|
+
import "@rio-m3e/styles/menu.css";
|
|
6
|
+
import "@rio-m3e/styles/select.css";
|
|
7
|
+
type Props = Omit<SelectProps, 'selected' | 'open'>;
|
|
8
|
+
type __VLS_Props = Props;
|
|
9
|
+
type __VLS_Slots = {
|
|
10
|
+
/** `RioSelectOption`s */
|
|
11
|
+
default?: () => unknown;
|
|
12
|
+
/** An icon before the selection */
|
|
13
|
+
'leading-icon'?: () => unknown;
|
|
14
|
+
/** The dropdown arrow, such as arrow_drop_down. It turns over while the list is open. */
|
|
15
|
+
'dropdown-icon'?: () => unknown;
|
|
16
|
+
/**
|
|
17
|
+
* The selection as the field shows it, in place of the selected options' labels separated by
|
|
18
|
+
* commas. `labels` are in the order of the options.
|
|
19
|
+
*/
|
|
20
|
+
value?: (props: {
|
|
21
|
+
selected: SelectValue[];
|
|
22
|
+
labels: string[];
|
|
23
|
+
}) => unknown;
|
|
24
|
+
};
|
|
25
|
+
type __VLS_ModelProps = {
|
|
26
|
+
/** The selected value, or with `multiple`, the selected values, with `v-model`. */
|
|
27
|
+
modelValue?: SelectSelected;
|
|
28
|
+
/** Whether the list is open, with `v-model:open`. The select keeps it when it isn't bound. */
|
|
29
|
+
'open'?: boolean;
|
|
30
|
+
};
|
|
31
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
32
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
33
|
+
"update:open": (value: boolean) => any;
|
|
34
|
+
"update:modelValue": (value: SelectSelected) => any;
|
|
35
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
36
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
37
|
+
"onUpdate:modelValue"?: ((value: SelectSelected) => any) | undefined;
|
|
38
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
39
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
40
|
+
declare const _default: typeof __VLS_export;
|
|
41
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
42
|
+
new (): {
|
|
43
|
+
$slots: S;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export { _default as default };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { selectKey } from "./context.js";
|
|
2
|
+
import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, provide, renderList, renderSlot, shallowReactive, toDisplayString, unref, useAttrs, useId, useModel, useSlots, useTemplateRef, watch } from "vue";
|
|
3
|
+
import { attachSelect, createSelect, mergePartAttrs } 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/text-field.css";
|
|
7
|
+
import "@rio-m3e/styles/menu.css";
|
|
8
|
+
import "@rio-m3e/styles/select.css";
|
|
9
|
+
// src/select/Select.vue
|
|
10
|
+
const _hoisted_1 = {
|
|
11
|
+
key: 0,
|
|
12
|
+
value: ""
|
|
13
|
+
};
|
|
14
|
+
const _hoisted_2 = ["value"];
|
|
15
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
__name: "Select",
|
|
18
|
+
props: /*@__PURE__*/ mergeModels({
|
|
19
|
+
variant: {},
|
|
20
|
+
label: {},
|
|
21
|
+
multiple: { type: Boolean },
|
|
22
|
+
supportingText: {},
|
|
23
|
+
error: { type: Boolean },
|
|
24
|
+
errorText: {},
|
|
25
|
+
required: { type: Boolean },
|
|
26
|
+
disabled: { type: Boolean },
|
|
27
|
+
name: {},
|
|
28
|
+
autocomplete: {},
|
|
29
|
+
menuVariant: {},
|
|
30
|
+
instant: { type: Boolean }
|
|
31
|
+
}, {
|
|
32
|
+
"modelValue": {},
|
|
33
|
+
"modelModifiers": {},
|
|
34
|
+
"open": {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
"openModifiers": {}
|
|
39
|
+
}),
|
|
40
|
+
emits: ["update:modelValue", "update:open"],
|
|
41
|
+
setup(__props) {
|
|
42
|
+
/** The selected value, or with `multiple`, the selected values, with `v-model`. */
|
|
43
|
+
const model = useModel(__props, "modelValue");
|
|
44
|
+
/** Whether the list is open, with `v-model:open`. The select keeps it when it isn't bound. */
|
|
45
|
+
const open = useModel(__props, "open");
|
|
46
|
+
const slots = useSlots();
|
|
47
|
+
const entries = shallowReactive([]);
|
|
48
|
+
/** The options, in the order they appear once rendered */
|
|
49
|
+
const options = () => {
|
|
50
|
+
const sorted = [...entries];
|
|
51
|
+
if (sorted.every((entry) => entry.element())) sorted.sort((a, b) => a.element().compareDocumentPosition(b.element()) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
52
|
+
return sorted.map((entry) => ({
|
|
53
|
+
value: entry.value(),
|
|
54
|
+
label: entry.label()
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
const id = useId();
|
|
58
|
+
const attrs = useAttrs();
|
|
59
|
+
const select = createSelect({
|
|
60
|
+
props: () => ({
|
|
61
|
+
variant: __props.variant,
|
|
62
|
+
label: __props.label,
|
|
63
|
+
multiple: __props.multiple,
|
|
64
|
+
selected: model.value,
|
|
65
|
+
open: open.value,
|
|
66
|
+
supportingText: __props.supportingText,
|
|
67
|
+
error: __props.error,
|
|
68
|
+
errorText: __props.errorText,
|
|
69
|
+
required: __props.required,
|
|
70
|
+
disabled: __props.disabled,
|
|
71
|
+
name: __props.name,
|
|
72
|
+
autocomplete: __props.autocomplete,
|
|
73
|
+
menuVariant: __props.menuVariant,
|
|
74
|
+
instant: __props.instant
|
|
75
|
+
}),
|
|
76
|
+
options,
|
|
77
|
+
content: () => ({ leadingIcon: !!slots["leading-icon"] }),
|
|
78
|
+
ids: {
|
|
79
|
+
get field() {
|
|
80
|
+
return typeof attrs.id === "string" && attrs.id ? attrs.id : `${id}-field`;
|
|
81
|
+
},
|
|
82
|
+
label: `${id}-label`,
|
|
83
|
+
listbox: `${id}-listbox`,
|
|
84
|
+
supportingText: `${id}-supporting`
|
|
85
|
+
},
|
|
86
|
+
appName: () => ({
|
|
87
|
+
label: typeof attrs["aria-label"] === "string" ? attrs["aria-label"] : void 0,
|
|
88
|
+
labelledBy: typeof attrs["aria-labelledby"] === "string" ? attrs["aria-labelledby"] : void 0
|
|
89
|
+
}),
|
|
90
|
+
onChange: (next) => model.value = next,
|
|
91
|
+
onOpenChange: (next) => open.value = next
|
|
92
|
+
});
|
|
93
|
+
provide(selectKey, {
|
|
94
|
+
isSelected: select.isSelected,
|
|
95
|
+
choose: select.choose,
|
|
96
|
+
register(entry) {
|
|
97
|
+
entries.push(entry);
|
|
98
|
+
return () => {
|
|
99
|
+
const index = entries.indexOf(entry);
|
|
100
|
+
if (index >= 0) entries.splice(index, 1);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const container = useTemplateRef("container");
|
|
105
|
+
const field = useTemplateRef("field");
|
|
106
|
+
const listbox = useTemplateRef("listbox");
|
|
107
|
+
const native = useTemplateRef("native");
|
|
108
|
+
let handle;
|
|
109
|
+
onMounted(() => {
|
|
110
|
+
handle = attachSelect({
|
|
111
|
+
container: container.value,
|
|
112
|
+
field: field.value,
|
|
113
|
+
listbox: listbox.value,
|
|
114
|
+
native: native.value
|
|
115
|
+
}, {
|
|
116
|
+
disabled: () => !!__props.disabled,
|
|
117
|
+
selected: () => select.selectedValues().map(select.nativeValue),
|
|
118
|
+
onOpenChange: select.setOpen,
|
|
119
|
+
onNativeChange: select.nativeChanged
|
|
120
|
+
});
|
|
121
|
+
handle.sync(open.value);
|
|
122
|
+
});
|
|
123
|
+
watch(() => open.value, (next) => handle?.sync(next), { flush: "post" });
|
|
124
|
+
watch(() => __props.disabled, (next) => next && select.setOpen(false));
|
|
125
|
+
onUpdated(() => handle?.update());
|
|
126
|
+
onBeforeUnmount(() => handle?.detach());
|
|
127
|
+
return (_ctx, _cache) => {
|
|
128
|
+
return openBlock(), createElementBlock("div", mergeProps(unref(select).parts.root(), {
|
|
129
|
+
class: _ctx.$attrs.class,
|
|
130
|
+
style: _ctx.$attrs.style
|
|
131
|
+
}), [
|
|
132
|
+
createElementVNode("div", normalizeProps(guardReactiveProps(unref(select).parts.frame())), [
|
|
133
|
+
unref(select).showsOutline() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(select).parts.outline())), [
|
|
134
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(select).parts.outlineStart())), null, 16),
|
|
135
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(select).parts.outlineNotch())), toDisplayString(unref(select).labelText()), 17),
|
|
136
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(select).parts.outlineEnd())), null, 16)
|
|
137
|
+
], 16)) : createCommentVNode("v-if", true),
|
|
138
|
+
unref(select).showsLabel() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(select).parts.label())), toDisplayString(unref(select).labelText()), 17)) : createCommentVNode("v-if", true),
|
|
139
|
+
createElementVNode("div", mergeProps({
|
|
140
|
+
ref_key: "container",
|
|
141
|
+
ref: container
|
|
142
|
+
}, unref(select).parts.container()), [
|
|
143
|
+
unref(select).showsLeadingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(select).parts.leadingIcon())), [renderSlot(_ctx.$slots, "leading-icon")], 16)) : createCommentVNode("v-if", true),
|
|
144
|
+
createElementVNode("div", normalizeProps(guardReactiveProps(unref(select).parts.content())), [createElementVNode("div", mergeProps({
|
|
145
|
+
ref_key: "field",
|
|
146
|
+
ref: field
|
|
147
|
+
}, unref(mergePartAttrs)({
|
|
148
|
+
..._ctx.$attrs,
|
|
149
|
+
class: void 0,
|
|
150
|
+
style: void 0
|
|
151
|
+
}, unref(select).parts.field())), [createElementVNode("span", normalizeProps(guardReactiveProps(unref(select).parts.value())), [renderSlot(_ctx.$slots, "value", {
|
|
152
|
+
selected: unref(select).selectedValues(),
|
|
153
|
+
labels: unref(select).selectedLabels()
|
|
154
|
+
}, () => [createTextVNode(toDisplayString(unref(select).valueText()), 1)])], 16), createElementVNode("span", normalizeProps(guardReactiveProps(unref(select).parts.sizer())), [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(select).sizerTexts(), (text, index) => {
|
|
155
|
+
return openBlock(), createElementBlock("span", { key: index }, toDisplayString(text), 1);
|
|
156
|
+
}), 128))], 16)], 16)], 16),
|
|
157
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(select).parts.arrow())), [renderSlot(_ctx.$slots, "dropdown-icon")], 16),
|
|
158
|
+
createElementVNode("select", mergeProps({
|
|
159
|
+
ref_key: "native",
|
|
160
|
+
ref: native
|
|
161
|
+
}, unref(select).parts.native()), [!unref(select).multiple() ? (openBlock(), createElementBlock("option", _hoisted_1)) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(options(), (option) => {
|
|
162
|
+
return openBlock(), createElementBlock("option", {
|
|
163
|
+
key: unref(select).nativeValue(option.value),
|
|
164
|
+
value: unref(select).nativeValue(option.value)
|
|
165
|
+
}, toDisplayString(option.label), 9, _hoisted_2);
|
|
166
|
+
}), 128))], 16)
|
|
167
|
+
], 16)
|
|
168
|
+
], 16),
|
|
169
|
+
unref(select).showsSupporting() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(select).parts.supporting())), [createCommentVNode(" A new element for the error text, so it arrives with its alert role. "), (openBlock(), createElementBlock("span", mergeProps({ key: unref(select).showsErrorText() ? "error" : "supporting" }, unref(select).parts.supportingText()), toDisplayString(unref(select).supportingTextNow()), 17))], 16)) : createCommentVNode("v-if", true),
|
|
170
|
+
createElementVNode("div", mergeProps({
|
|
171
|
+
ref_key: "listbox",
|
|
172
|
+
ref: listbox
|
|
173
|
+
}, unref(select).parts.listbox()), [renderSlot(_ctx.$slots, "default")], 16)
|
|
174
|
+
], 16);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SelectOptionProps } 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, which the field shows while the option is selected */
|
|
7
|
+
default?: () => unknown;
|
|
8
|
+
/**
|
|
9
|
+
* A leading icon, hidden from assistive technology. `selected` lets it show a check mark next to
|
|
10
|
+
* 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 */
|
|
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<SelectOptionProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SelectOptionProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
23
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
26
|
+
new (): {
|
|
27
|
+
$slots: S;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export { _default as default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { vRipple } from "../ripple/ripple.js";
|
|
2
|
+
import { selectKey } from "./context.js";
|
|
3
|
+
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, ref, renderSlot, unref, useSlots, useTemplateRef, withDirectives } from "vue";
|
|
4
|
+
import { createSelectOption } 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/select/SelectOption.vue
|
|
9
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
10
|
+
__name: "SelectOption",
|
|
11
|
+
props: {
|
|
12
|
+
value: {},
|
|
13
|
+
disabled: { type: Boolean }
|
|
14
|
+
},
|
|
15
|
+
setup(__props) {
|
|
16
|
+
const slots = useSlots();
|
|
17
|
+
const select = inject(selectKey, void 0);
|
|
18
|
+
if (!select) throw new Error("RioSelectOption has to be inside a RioSelect.");
|
|
19
|
+
const option = createSelectOption({
|
|
20
|
+
props: () => ({
|
|
21
|
+
value: __props.value,
|
|
22
|
+
disabled: __props.disabled
|
|
23
|
+
}),
|
|
24
|
+
content: () => ({
|
|
25
|
+
icon: !!slots.icon,
|
|
26
|
+
supportingText: !!slots["supporting-text"],
|
|
27
|
+
trailingText: !!slots["trailing-text"],
|
|
28
|
+
trailingIcon: !!slots["trailing-icon"]
|
|
29
|
+
}),
|
|
30
|
+
select: () => select
|
|
31
|
+
});
|
|
32
|
+
const root = useTemplateRef("root");
|
|
33
|
+
const labelElement = useTemplateRef("label");
|
|
34
|
+
const text = ref("");
|
|
35
|
+
const read = () => text.value = labelElement.value?.textContent?.trim() ?? "";
|
|
36
|
+
const unregister = select.register({
|
|
37
|
+
value: () => __props.value,
|
|
38
|
+
label: () => text.value,
|
|
39
|
+
element: () => root.value
|
|
40
|
+
});
|
|
41
|
+
onMounted(read);
|
|
42
|
+
onUpdated(read);
|
|
43
|
+
onBeforeUnmount(unregister);
|
|
44
|
+
return (_ctx, _cache) => {
|
|
45
|
+
return withDirectives((openBlock(), createElementBlock("button", mergeProps({
|
|
46
|
+
ref_key: "root",
|
|
47
|
+
ref: root
|
|
48
|
+
}, unref(option).parts.root(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(option).handleClick && unref(option).handleClick(...args)) }), [
|
|
49
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(option).parts.touch())), null, 16),
|
|
50
|
+
unref(option).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(option).parts.icon())), [renderSlot(_ctx.$slots, "icon", { selected: unref(option).selected() })], 16)) : createCommentVNode("v-if", true),
|
|
51
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(option).parts.text())), [createElementVNode("span", mergeProps({ ref: "label" }, unref(option).parts.label()), [renderSlot(_ctx.$slots, "default")], 16), unref(option).showsSupportingText() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(option).parts.supportingText())), [renderSlot(_ctx.$slots, "supporting-text")], 16)) : createCommentVNode("v-if", true)], 16),
|
|
52
|
+
unref(option).showsTrailingText() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(option).parts.trailingText())), [renderSlot(_ctx.$slots, "trailing-text")], 16)) : createCommentVNode("v-if", true),
|
|
53
|
+
unref(option).showsTrailingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 2 }, unref(option).parts.trailingIcon())), [renderSlot(_ctx.$slots, "trailing-icon")], 16)) : createCommentVNode("v-if", true)
|
|
54
|
+
], 16)), [[unref(vRipple)]]);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
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,124 @@
|
|
|
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, mergePartAttrs } 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
|
+
}, unref(mergePartAttrs)({
|
|
99
|
+
..._ctx.$attrs,
|
|
100
|
+
class: void 0,
|
|
101
|
+
style: void 0
|
|
102
|
+
}, unref(field).parts.input())), null, 16)), [[vModelDynamic, model.value]]) : withDirectives((openBlock(), createElementBlock("textarea", mergeProps({
|
|
103
|
+
key: 2,
|
|
104
|
+
ref_key: "input",
|
|
105
|
+
ref: input,
|
|
106
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => model.value = $event)
|
|
107
|
+
}, unref(mergePartAttrs)({
|
|
108
|
+
..._ctx.$attrs,
|
|
109
|
+
class: void 0,
|
|
110
|
+
style: void 0
|
|
111
|
+
}, unref(field).parts.textarea())), null, 16)), [[vModelText, model.value]]),
|
|
112
|
+
unref(field).showsSuffix() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 3 }, unref(field).parts.suffix())), toDisplayString(__props.suffix), 17)) : createCommentVNode("v-if", true)
|
|
113
|
+
], 16),
|
|
114
|
+
unref(field).showsTrailingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.trailingIcon())), [renderSlot(_ctx.$slots, "trailing-icon")], 16)) : createCommentVNode("v-if", true)
|
|
115
|
+
], 16)
|
|
116
|
+
], 16), unref(field).showsSupporting() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.supporting())), [
|
|
117
|
+
createCommentVNode(" A new element for the error text, so it arrives with its alert role. "),
|
|
118
|
+
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),
|
|
119
|
+
unref(field).showsCounter() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.counter())), toDisplayString(unref(field).counterText()), 17)) : createCommentVNode("v-if", true)
|
|
120
|
+
], 16)) : createCommentVNode("v-if", true)], 16);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HourCycle, TimePickerMessages } 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/time-picker.css";
|
|
6
|
+
type __VLS_Props = {
|
|
7
|
+
/** A language tag. Without it, the one provided, or the document's, or the browser's. */
|
|
8
|
+
locale?: string;
|
|
9
|
+
/** Overrides the language's clock: 12 hours with AM and PM, or 24. */
|
|
10
|
+
hourCycle?: HourCycle;
|
|
11
|
+
/** Replaces any of the text the picker shows. */
|
|
12
|
+
messages?: Partial<TimePickerMessages>;
|
|
13
|
+
};
|
|
14
|
+
type __VLS_ModelProps = {
|
|
15
|
+
/** The time, `HH:MM` on a 24-hour clock, with `v-model`. */
|
|
16
|
+
modelValue?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
19
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
"update:modelValue": (value: string | undefined) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
|
+
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export { _default as default };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useLocale, useMessages } from "../locale/locale.js";
|
|
2
|
+
import _sfc_main$1 from "./TimePickerBody.vue.js";
|
|
3
|
+
import { createCommentVNode, createElementBlock, createVNode, defineComponent, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, reactive, toDisplayString, unref, useId, useModel, useTemplateRef, watch } from "vue";
|
|
4
|
+
import { attachTimePicker, createTimePicker, initialTimeState } 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/time-picker.css";
|
|
9
|
+
// src/time-picker/TimeInput.vue
|
|
10
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
11
|
+
__name: "TimeInput",
|
|
12
|
+
props: /*@__PURE__*/ mergeModels({
|
|
13
|
+
locale: {},
|
|
14
|
+
hourCycle: {},
|
|
15
|
+
messages: {}
|
|
16
|
+
}, {
|
|
17
|
+
"modelValue": {},
|
|
18
|
+
"modelModifiers": {}
|
|
19
|
+
}),
|
|
20
|
+
emits: ["update:modelValue"],
|
|
21
|
+
setup(__props) {
|
|
22
|
+
const props = __props;
|
|
23
|
+
/** The time, `HH:MM` on a 24-hour clock, with `v-model`. */
|
|
24
|
+
const model = useModel(__props, "modelValue");
|
|
25
|
+
const locale = useLocale(() => props.locale);
|
|
26
|
+
const messages = useMessages("timePicker", locale, () => props.messages);
|
|
27
|
+
const state = reactive({
|
|
28
|
+
...initialTimeState(model.value),
|
|
29
|
+
mode: "input"
|
|
30
|
+
});
|
|
31
|
+
const id = useId();
|
|
32
|
+
const picker = createTimePicker({
|
|
33
|
+
variant: "inline",
|
|
34
|
+
props: () => ({
|
|
35
|
+
value: model.value,
|
|
36
|
+
locale: locale.value,
|
|
37
|
+
hourCycle: props.hourCycle
|
|
38
|
+
}),
|
|
39
|
+
messages: () => messages.value,
|
|
40
|
+
state: () => state,
|
|
41
|
+
ids: { error: `${id}-error` },
|
|
42
|
+
onChange: (next) => model.value = next,
|
|
43
|
+
onStateChange: (next) => Object.assign(state, next)
|
|
44
|
+
});
|
|
45
|
+
picker.valueChanged();
|
|
46
|
+
watch([
|
|
47
|
+
model,
|
|
48
|
+
locale,
|
|
49
|
+
() => props.hourCycle
|
|
50
|
+
], () => picker.valueChanged());
|
|
51
|
+
const root = useTemplateRef("root");
|
|
52
|
+
let handle;
|
|
53
|
+
onMounted(() => {
|
|
54
|
+
handle = attachTimePicker(root.value, {
|
|
55
|
+
selection: () => state.selection,
|
|
56
|
+
hourCycle: picker.hourCycle,
|
|
57
|
+
onPick: picker.dialPick,
|
|
58
|
+
onPeriod: picker.selectPeriod
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
watch(state, () => handle?.sync(), { flush: "post" });
|
|
62
|
+
onBeforeUnmount(() => handle?.detach());
|
|
63
|
+
return (_ctx, _cache) => {
|
|
64
|
+
return openBlock(), createElementBlock("div", mergeProps({
|
|
65
|
+
ref_key: "root",
|
|
66
|
+
ref: root
|
|
67
|
+
}, unref(picker).parts.root()), [createVNode(_sfc_main$1, { picker: unref(picker) }, null, 8, ["picker"]), unref(picker).showsError() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(picker).parts.error())), toDisplayString(unref(picker).error()), 17)) : createCommentVNode("v-if", true)], 16);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
export { _sfc_main as default };
|