@rio-m3e/vue 0.4.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.
@@ -0,0 +1,199 @@
1
+ import _sfc_main$1 from "../button/Button.vue.js";
2
+ import _sfc_main$2 from "../icon-button/IconButton.vue.js";
3
+ import { useLocale, useMessages } from "../locale/locale.js";
4
+ import _sfc_main$3 from "../text-field/TextField.vue.js";
5
+ import _sfc_main$4 from "./DatePickerCalendar.vue.js";
6
+ import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, nextTick, normalizeProps, onBeforeUnmount, onMounted, openBlock, reactive, ref, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef, watch, withCtx, withModifiers } from "vue";
7
+ import { attachDialog, createDatePickerDialog, initialPickerState } from "@rio-m3e/core";
8
+ import "@rio-m3e/styles/base/focus-ring.css";
9
+ import "@rio-m3e/styles/base/reduced-motion.css";
10
+ import "@rio-m3e/styles/base/state-layer.css";
11
+ import "@rio-m3e/styles/date-picker.css";
12
+ import "@rio-m3e/styles/dialog.css";
13
+ // src/date-picker/DatePickerDialog.vue
14
+ const _sfc_main = /*@__PURE__*/ defineComponent({
15
+ __name: "DatePickerDialog",
16
+ props: /*@__PURE__*/ mergeModels({
17
+ min: {},
18
+ max: {},
19
+ isDateDisabled: { type: Function },
20
+ locale: {},
21
+ firstDayOfWeek: {},
22
+ messages: {},
23
+ initialMode: {},
24
+ clearable: { type: Boolean }
25
+ }, {
26
+ "modelValue": {},
27
+ "modelModifiers": {},
28
+ "open": {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ "openModifiers": {}
33
+ }),
34
+ emits: ["update:modelValue", "update:open"],
35
+ setup(__props) {
36
+ const props = __props;
37
+ /** The chosen date, `YYYY-MM-DD`, with `v-model`. It changes on OK. */
38
+ const model = useModel(__props, "modelValue");
39
+ /** Whether the dialog is shown, with `v-model:open`. */
40
+ const open = useModel(__props, "open");
41
+ const locale = useLocale(() => props.locale);
42
+ const messages = useMessages("datePicker", locale, () => props.messages);
43
+ const state = reactive(initialPickerState(model.value, locale.value, props));
44
+ const rendered = ref(open.value);
45
+ const id = useId();
46
+ const dialog = createDatePickerDialog({
47
+ props: () => ({
48
+ value: model.value,
49
+ open: open.value,
50
+ min: props.min,
51
+ max: props.max,
52
+ locale: locale.value,
53
+ clearable: props.clearable,
54
+ initialMode: props.initialMode,
55
+ rendered: rendered.value
56
+ }),
57
+ isDateDisabled: (date) => !!props.isDateDisabled?.(date),
58
+ messages: () => messages.value,
59
+ state: () => state,
60
+ ids: {
61
+ title: `${id}-title`,
62
+ headline: `${id}-headline`
63
+ },
64
+ onChange: (next) => model.value = next,
65
+ onOpenChange: (next) => open.value = next,
66
+ onStateChange: (next) => Object.assign(state, next)
67
+ });
68
+ if (open.value) dialog.opened();
69
+ watch(open, (next) => {
70
+ if (!next) return;
71
+ dialog.opened();
72
+ rendered.value = true;
73
+ });
74
+ const root = useTemplateRef("root");
75
+ const calendar = useTemplateRef("calendar");
76
+ let handle;
77
+ onMounted(() => {
78
+ handle = attachDialog(root.value, {
79
+ onOpenChange: (next) => open.value = next,
80
+ onClosed: () => {
81
+ if (!open.value) rendered.value = false;
82
+ },
83
+ initialFocus: () => root.value?.querySelector(state.mode === "calendar" ? "[data-date][tabindex=\"0\"]" : "input")
84
+ });
85
+ handle.sync(open.value);
86
+ });
87
+ watch(open, (next) => handle?.sync(next), { flush: "post" });
88
+ watch(() => state.mode, async (next) => {
89
+ await nextTick();
90
+ if (!open.value) return;
91
+ if (next === "calendar") calendar.value?.focus();
92
+ else root.value?.querySelector("input")?.focus();
93
+ });
94
+ onBeforeUnmount(() => handle?.detach());
95
+ return (_ctx, _cache) => {
96
+ return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" Clicks and presses stay in the dialog, as in RioDialog. "), createElementVNode("dialog", mergeProps({
97
+ ref_key: "root",
98
+ ref: root
99
+ }, unref(dialog).parts.root(), {
100
+ onClick: _cache[4] || (_cache[4] = withModifiers(() => {}, ["stop"])),
101
+ onAuxclick: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"])),
102
+ onDblclick: _cache[6] || (_cache[6] = withModifiers(() => {}, ["stop"])),
103
+ onPointerdown: _cache[7] || (_cache[7] = withModifiers(() => {}, ["stop"])),
104
+ onPointerup: _cache[8] || (_cache[8] = withModifiers(() => {}, ["stop"])),
105
+ onMousedown: _cache[9] || (_cache[9] = withModifiers(() => {}, ["stop"])),
106
+ onMouseup: _cache[10] || (_cache[10] = withModifiers(() => {}, ["stop"])),
107
+ onContextmenu: _cache[11] || (_cache[11] = withModifiers(() => {}, ["stop"]))
108
+ }), [rendered.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
109
+ createElementVNode("div", normalizeProps(guardReactiveProps(unref(dialog).parts.header())), [
110
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(dialog).parts.title())), toDisplayString(unref(messages).title), 17),
111
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(dialog).parts.headline())), toDisplayString(unref(dialog).headline()), 17),
112
+ createVNode(_sfc_main$2, {
113
+ variant: "standard",
114
+ label: unref(dialog).modeButtonLabel(),
115
+ onClick: unref(dialog).switchMode
116
+ }, {
117
+ default: withCtx(() => [state.mode === "calendar" ? renderSlot(_ctx.$slots, "edit-icon", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "calendar-icon", {}, void 0, void 0, 1)]),
118
+ _: 3
119
+ }, 8, ["label", "onClick"])
120
+ ], 16),
121
+ createElementVNode("div", normalizeProps(guardReactiveProps(unref(dialog).parts.divider())), null, 16),
122
+ unref(dialog).calendarMode() ? (openBlock(), createBlock(_sfc_main$4, {
123
+ key: 0,
124
+ ref_key: "calendar",
125
+ ref: calendar,
126
+ month: state.month,
127
+ "onUpdate:month": _cache[0] || (_cache[0] = ($event) => state.month = $event),
128
+ focused: state.focused,
129
+ "onUpdate:focused": _cache[1] || (_cache[1] = ($event) => state.focused = $event),
130
+ view: state.view,
131
+ "onUpdate:view": _cache[2] || (_cache[2] = ($event) => state.view = $event),
132
+ variant: "modal",
133
+ selected: state.draft,
134
+ min: __props.min,
135
+ max: __props.max,
136
+ locale: unref(locale),
137
+ "first-day-of-week": __props.firstDayOfWeek,
138
+ "is-date-disabled": __props.isDateDisabled,
139
+ messages: unref(messages),
140
+ onSelect: unref(dialog).select
141
+ }, {
142
+ "previous-icon": withCtx(() => [renderSlot(_ctx.$slots, "previous-icon")]),
143
+ "next-icon": withCtx(() => [renderSlot(_ctx.$slots, "next-icon")]),
144
+ "dropdown-icon": withCtx(() => [renderSlot(_ctx.$slots, "dropdown-icon")]),
145
+ _: 3
146
+ }, 8, [
147
+ "month",
148
+ "focused",
149
+ "view",
150
+ "selected",
151
+ "min",
152
+ "max",
153
+ "locale",
154
+ "first-day-of-week",
155
+ "is-date-disabled",
156
+ "messages",
157
+ "onSelect"
158
+ ])) : createCommentVNode("v-if", true),
159
+ unref(dialog).inputMode() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 1 }, unref(dialog).parts.input())), [createVNode(_sfc_main$3, mergeProps(unref(dialog).field(), {
160
+ "model-value": state.text,
161
+ variant: "outlined",
162
+ label: unref(messages).fieldLabel,
163
+ autocomplete: "off",
164
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = (text) => unref(dialog).textInput(String(text))),
165
+ onKeydown: unref(dialog).handleFieldKeydown
166
+ }), null, 16, [
167
+ "model-value",
168
+ "label",
169
+ "onKeydown"
170
+ ])], 16)) : createCommentVNode("v-if", true),
171
+ createElementVNode("div", normalizeProps(guardReactiveProps(unref(dialog).parts.actions())), [
172
+ unref(dialog).showsClear() ? (openBlock(), createBlock(_sfc_main$1, {
173
+ key: 0,
174
+ variant: "text",
175
+ onClick: unref(dialog).clear
176
+ }, {
177
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).clear), 1)]),
178
+ _: 1
179
+ }, 8, ["onClick"])) : createCommentVNode("v-if", true),
180
+ createVNode(_sfc_main$1, {
181
+ variant: "text",
182
+ onClick: unref(dialog).cancel
183
+ }, {
184
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).cancel), 1)]),
185
+ _: 1
186
+ }, 8, ["onClick"]),
187
+ createVNode(_sfc_main$1, {
188
+ variant: "text",
189
+ onClick: unref(dialog).confirm
190
+ }, {
191
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).ok), 1)]),
192
+ _: 1
193
+ }, 8, ["onClick"])
194
+ ], 16)
195
+ ], 64)) : createCommentVNode("v-if", true)], 16)], 2112);
196
+ };
197
+ }
198
+ });
199
+ export { _sfc_main as default };
@@ -1,7 +1,7 @@
1
1
  import { useButtonGroupItem } from "../button-group/context.js";
2
2
  import { vRipple } from "../ripple/ripple.js";
3
3
  import { vShapeMorph } from "../shape-morph/shape-morph.js";
4
- import { createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderSlot, unref, useSlots, withDirectives } from "vue";
4
+ import { createBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderSlot, resolveDynamicComponent, unref, useSlots, withCtx, withDirectives } from "vue";
5
5
  import { createIconButton } from "@rio-m3e/core";
6
6
  import "@rio-m3e/styles/base/focus-ring.css";
7
7
  import "@rio-m3e/styles/base/reduced-motion.css";
@@ -22,6 +22,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
22
22
  disabled: { type: Boolean },
23
23
  softDisabled: { type: Boolean },
24
24
  type: {},
25
+ href: {},
25
26
  value: {}
26
27
  },
27
28
  emits: ["click", "update:selected"],
@@ -39,7 +40,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
39
40
  disabled: __props.disabled,
40
41
  softDisabled: __props.softDisabled,
41
42
  type: __props.type,
42
- value: __props.value
43
+ value: __props.value,
44
+ href: __props.href
43
45
  }), (next) => emit("update:selected", next));
44
46
  const button = createIconButton({
45
47
  props: item.props,
@@ -48,7 +50,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
48
50
  onChange: item.onChange
49
51
  });
50
52
  return (_ctx, _cache) => {
51
- return withDirectives((openBlock(), createElementBlock("button", mergeProps(unref(button).parts.root(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(button).handleClick && unref(button).handleClick(...args)) }), [createElementVNode("span", normalizeProps(guardReactiveProps(unref(button).parts.touch())), null, 16), createElementVNode("span", normalizeProps(guardReactiveProps(unref(button).parts.icon())), [unref(button).showsSelectedIcon() ? renderSlot(_ctx.$slots, "selected-icon", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 1)], 16)], 16)), [[unref(vRipple)], [unref(vShapeMorph)]]);
53
+ return withDirectives((openBlock(), createBlock(resolveDynamicComponent(unref(button).isLink() ? "a" : "button"), mergeProps(unref(button).parts.root(), { onClick: unref(button).handleClick }), {
54
+ default: withCtx(() => [createElementVNode("span", normalizeProps(guardReactiveProps(unref(button).parts.touch())), null, 16), createElementVNode("span", normalizeProps(guardReactiveProps(unref(button).parts.icon())), [unref(button).showsSelectedIcon() ? renderSlot(_ctx.$slots, "selected-icon", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 1)], 16)]),
55
+ _: 3
56
+ }, 16, ["onClick"])), [[unref(vRipple)], [unref(vShapeMorph)]]);
52
57
  };
53
58
  }
54
59
  });
package/dist/index.d.ts CHANGED
@@ -1,18 +1,27 @@
1
1
  import _default from "./button/Button.vue.js";
2
2
  import _default$1 from "./button-group/ButtonGroup.vue.js";
3
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
+ import _default$3 from "./date-picker/DatePicker.vue.js";
5
+ import _default$4 from "./date-picker/DatePickerDialog.vue.js";
6
+ import _default$5 from "./dialog/Dialog.vue.js";
7
+ import _default$6 from "./icon-button/IconButton.vue.js";
8
+ import { localeKey, messagesKey, useLocale, useMessages } from "./locale/locale.js";
9
+ import { RioOptions, RioPlugin, RioThemeOptions, createRio } from "./rio/rio.js";
10
+ import _default$7 from "./locale/LocaleProvider.vue.js";
11
+ import _default$8 from "./menu/Menu.vue.js";
12
+ import _default$9 from "./menu/MenuDivider.vue.js";
13
+ import _default$10 from "./menu/MenuGroup.vue.js";
14
+ import _default$11 from "./menu/MenuItem.vue.js";
15
+ import _default$17 from "./menu/SubMenu.vue.js";
16
+ import _default$12 from "./radio/Radio.vue.js";
17
+ import _default$13 from "./radio/RadioGroup.vue.js";
13
18
  import { vRipple } from "./ripple/ripple.js";
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 };
19
+ import _default$14 from "./select/Select.vue.js";
20
+ import _default$15 from "./select/SelectOption.vue.js";
21
+ import _default$16 from "./split-button/SplitButton.vue.js";
22
+ import _default$18 from "./switch/Switch.vue.js";
23
+ import _default$19 from "./text-field/TextField.vue.js";
24
+ import _default$20 from "./time-picker/TimeInput.vue.js";
25
+ import _default$21 from "./time-picker/TimePickerDialog.vue.js";
26
+ import _default$22 from "./tooltip/Tooltip.vue.js";
27
+ export { _default as RioButton, _default$1 as RioButtonGroup, _default$2 as RioCheckbox, _default$3 as RioDatePicker, _default$4 as RioDatePickerDialog, _default$5 as RioDialog, _default$6 as RioIconButton, _default$7 as RioLocaleProvider, _default$8 as RioMenu, _default$9 as RioMenuDivider, _default$10 as RioMenuGroup, _default$11 as RioMenuItem, type RioOptions, type RioPlugin, _default$12 as RioRadio, _default$13 as RioRadioGroup, _default$14 as RioSelect, _default$15 as RioSelectOption, _default$16 as RioSplitButton, _default$17 as RioSubMenu, _default$18 as RioSwitch, _default$19 as RioTextField, type RioThemeOptions, _default$20 as RioTimeInput, _default$21 as RioTimePickerDialog, _default$22 as RioTooltip, createRio, localeKey, messagesKey, useLocale, useMessages, vRipple };
package/dist/index.js CHANGED
@@ -1,18 +1,27 @@
1
1
  import _sfc_main from "./button/Button.vue.js";
2
2
  import _sfc_main$1 from "./button-group/ButtonGroup.vue.js";
3
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
+ import _sfc_main$3 from "./date-picker/DatePicker.vue.js";
5
+ import _sfc_main$4 from "./date-picker/DatePickerDialog.vue.js";
6
+ import _sfc_main$5 from "./dialog/Dialog.vue.js";
7
+ import _sfc_main$6 from "./icon-button/IconButton.vue.js";
8
+ import { localeKey, messagesKey, useLocale, useMessages } from "./locale/locale.js";
9
+ import { createRio } from "./rio/rio.js";
10
+ import _sfc_main$7 from "./locale/LocaleProvider.vue.js";
11
+ import _sfc_main$8 from "./menu/Menu.vue.js";
12
+ import _sfc_main$9 from "./menu/MenuDivider.vue.js";
13
+ import _sfc_main$10 from "./menu/MenuGroup.vue.js";
14
+ import _sfc_main$11 from "./menu/MenuItem.vue.js";
15
+ import _sfc_main$17 from "./menu/SubMenu.vue.js";
16
+ import _sfc_main$12 from "./radio/Radio.vue.js";
17
+ import _sfc_main$13 from "./radio/RadioGroup.vue.js";
13
18
  import { vRipple } from "./ripple/ripple.js";
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 };
19
+ import _sfc_main$14 from "./select/Select.vue.js";
20
+ import _sfc_main$15 from "./select/SelectOption.vue.js";
21
+ import _sfc_main$16 from "./split-button/SplitButton.vue.js";
22
+ import _sfc_main$18 from "./switch/Switch.vue.js";
23
+ import _sfc_main$19 from "./text-field/TextField.vue.js";
24
+ import _sfc_main$20 from "./time-picker/TimeInput.vue.js";
25
+ import _sfc_main$21 from "./time-picker/TimePickerDialog.vue.js";
26
+ import _sfc_main$22 from "./tooltip/Tooltip.vue.js";
27
+ export { _sfc_main as RioButton, _sfc_main$1 as RioButtonGroup, _sfc_main$2 as RioCheckbox, _sfc_main$3 as RioDatePicker, _sfc_main$4 as RioDatePickerDialog, _sfc_main$5 as RioDialog, _sfc_main$6 as RioIconButton, _sfc_main$7 as RioLocaleProvider, _sfc_main$8 as RioMenu, _sfc_main$9 as RioMenuDivider, _sfc_main$10 as RioMenuGroup, _sfc_main$11 as RioMenuItem, _sfc_main$12 as RioRadio, _sfc_main$13 as RioRadioGroup, _sfc_main$14 as RioSelect, _sfc_main$15 as RioSelectOption, _sfc_main$16 as RioSplitButton, _sfc_main$17 as RioSubMenu, _sfc_main$18 as RioSwitch, _sfc_main$19 as RioTextField, _sfc_main$20 as RioTimeInput, _sfc_main$21 as RioTimePickerDialog, _sfc_main$22 as RioTooltip, createRio, localeKey, messagesKey, useLocale, useMessages, vRipple };
@@ -0,0 +1,16 @@
1
+ type __VLS_Props = {
2
+ /** A language tag, such as `ko` or `en-GB`, for Rio's components inside */
3
+ locale?: string;
4
+ };
5
+ type __VLS_Slots = {
6
+ default?: () => unknown;
7
+ };
8
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
10
+ declare const _default: typeof __VLS_export;
11
+ type __VLS_WithSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };
16
+ export { _default as default };
@@ -0,0 +1,14 @@
1
+ import { localeKey } from "./locale.js";
2
+ import { defineComponent, provide, renderSlot, toRef } from "vue";
3
+ // src/locale/LocaleProvider.vue
4
+ const _sfc_main = /*@__PURE__*/ defineComponent({
5
+ __name: "LocaleProvider",
6
+ props: { locale: {} },
7
+ setup(__props) {
8
+ provide(localeKey, toRef(() => __props.locale));
9
+ return (_ctx, _cache) => {
10
+ return renderSlot(_ctx.$slots, "default");
11
+ };
12
+ }
13
+ });
14
+ export { _sfc_main as default };
@@ -0,0 +1,16 @@
1
+ import { ComputedRef, InjectionKey, Ref } from "vue";
2
+ import { MessageOptions, RioMessages } from "@rio-m3e/core";
3
+ /** The language a `RioLocaleProvider` or `createRio` gives the components inside */
4
+ export declare const localeKey: InjectionKey<Ref<string | undefined>>;
5
+ /** The app's message tables and fallback language, from `createRio` */
6
+ export declare const messagesKey: InjectionKey<Ref<MessageOptions>>;
7
+ /**
8
+ * The language a component uses: its own `locale`, or the nearest one provided, or the document's,
9
+ * the browser's, or English (`resolveLocale`). Call it in `setup`.
10
+ */
11
+ export declare function useLocale(own: () => string | undefined): ComputedRef<string>;
12
+ /**
13
+ * A component's messages in its language: Rio's tables and the app's (`createRio`), with the
14
+ * component's own `messages` over them. Call it in `setup`.
15
+ */
16
+ export declare function useMessages<Group extends keyof RioMessages>(group: Group, locale: Ref<string>, own: () => Partial<RioMessages[Group]> | undefined): ComputedRef<RioMessages[Group]>;
@@ -0,0 +1,27 @@
1
+ import { computed, inject } from "vue";
2
+ import { messagesFor, resolveLocale } from "@rio-m3e/core";
3
+ // src/locale/locale.ts
4
+ /** The language a `RioLocaleProvider` or `createRio` gives the components inside */
5
+ const localeKey = Symbol("RioLocale");
6
+ /** The app's message tables and fallback language, from `createRio` */
7
+ const messagesKey = Symbol("RioMessages");
8
+ /**
9
+ * The language a component uses: its own `locale`, or the nearest one provided, or the document's,
10
+ * the browser's, or English (`resolveLocale`). Call it in `setup`.
11
+ */
12
+ function useLocale(own) {
13
+ const provided = inject(localeKey, void 0);
14
+ return computed(() => resolveLocale(own() ?? provided?.value));
15
+ }
16
+ /**
17
+ * A component's messages in its language: Rio's tables and the app's (`createRio`), with the
18
+ * component's own `messages` over them. Call it in `setup`.
19
+ */
20
+ function useMessages(group, locale, own) {
21
+ const options = inject(messagesKey, void 0);
22
+ return computed(() => ({
23
+ ...messagesFor(locale.value, options?.value)[group],
24
+ ...own()
25
+ }));
26
+ }
27
+ export { localeKey, messagesKey, useLocale, useMessages };
@@ -19,11 +19,11 @@ type __VLS_Slots = {
19
19
  default?: () => unknown;
20
20
  };
21
21
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
- "update:modelValue": (selected: MenuSelected) => any;
23
22
  "update:open": (open: boolean) => any;
23
+ "update:modelValue": (selected: MenuSelected) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
25
- "onUpdate:modelValue"?: ((selected: MenuSelected) => any) | undefined;
26
25
  "onUpdate:open"?: ((open: boolean) => any) | undefined;
26
+ "onUpdate:modelValue"?: ((selected: MenuSelected) => any) | undefined;
27
27
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
29
  declare const _default: typeof __VLS_export;
@@ -1,7 +1,7 @@
1
1
  import { vRipple } from "../ripple/ripple.js";
2
2
  import { menuContextOf, menuKey } from "./context.js";
3
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";
4
+ import { attachSubMenu, createSubMenu, mergePartAttrs } from "@rio-m3e/core";
5
5
  import "@rio-m3e/styles/base/focus-ring.css";
6
6
  import "@rio-m3e/styles/base/reduced-motion.css";
7
7
  import "@rio-m3e/styles/base/state-layer.css";
@@ -56,7 +56,15 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
56
56
  return openBlock(), createElementBlock(Fragment, null, [withDirectives((openBlock(), createElementBlock("button", mergeProps({
57
57
  ref_key: "itemElement",
58
58
  ref: itemElement
59
- }, mergeProps(_ctx.$attrs, unref(item).parts.root()), { onClick: _cache[0] || (_cache[0] = (...args) => unref(item).handleClick && unref(item).handleClick(...args)) }), [
59
+ }, unref(mergePartAttrs)({
60
+ ..._ctx.$attrs,
61
+ class: void 0,
62
+ style: void 0
63
+ }, unref(item).parts.root()), {
64
+ class: _ctx.$attrs.class,
65
+ style: _ctx.$attrs.style,
66
+ onClick: _cache[0] || (_cache[0] = (...args) => unref(item).handleClick && unref(item).handleClick(...args))
67
+ }), [
60
68
  createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.touch())), null, 16),
61
69
  unref(item).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(item).parts.icon())), [renderSlot(_ctx.$slots, "icon")], 16)) : createCommentVNode("v-if", true),
62
70
  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),
@@ -1,6 +1,6 @@
1
1
  import { radioGroupKey } from "./context.js";
2
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";
3
+ import { attachCheckable, attachRipple, createRadio, mergePartAttrs } from "@rio-m3e/core";
4
4
  import "@rio-m3e/styles/base/reduced-motion.css";
5
5
  import "@rio-m3e/styles/base/ripple.css";
6
6
  import "@rio-m3e/styles/radio.css";
@@ -53,12 +53,11 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
53
53
  createElementVNode("input", mergeProps({
54
54
  ref_key: "input",
55
55
  ref: input
56
- }, {
56
+ }, unref(mergePartAttrs)({
57
57
  ..._ctx.$attrs,
58
58
  class: void 0,
59
- style: void 0,
60
- ...unref(radio).parts.input()
61
- }), null, 16),
59
+ style: void 0
60
+ }, unref(radio).parts.input())), null, 16),
62
61
  createElementVNode("span", mergeProps({
63
62
  ref_key: "state",
64
63
  ref: state
@@ -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;
@@ -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 };