@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,142 @@
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 "./TimePickerBody.vue.js";
5
+ import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, reactive, ref, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef, watch, withCtx, withModifiers } from "vue";
6
+ import { attachDialog, attachTimePicker, createTimePicker, initialTimeState } from "@rio-m3e/core";
7
+ import "@rio-m3e/styles/base/focus-ring.css";
8
+ import "@rio-m3e/styles/base/reduced-motion.css";
9
+ import "@rio-m3e/styles/base/state-layer.css";
10
+ import "@rio-m3e/styles/dialog.css";
11
+ import "@rio-m3e/styles/time-picker.css";
12
+ // src/time-picker/TimePickerDialog.vue
13
+ const _sfc_main = /*@__PURE__*/ defineComponent({
14
+ __name: "TimePickerDialog",
15
+ props: /*@__PURE__*/ mergeModels({
16
+ locale: {},
17
+ hourCycle: {},
18
+ layout: {},
19
+ initialMode: {},
20
+ messages: {}
21
+ }, {
22
+ "modelValue": {},
23
+ "modelModifiers": {},
24
+ "open": {
25
+ type: Boolean,
26
+ default: false
27
+ },
28
+ "openModifiers": {}
29
+ }),
30
+ emits: ["update:modelValue", "update:open"],
31
+ setup(__props) {
32
+ const props = __props;
33
+ /** The time, `HH:MM` on a 24-hour clock, with `v-model`. It changes on OK. */
34
+ const model = useModel(__props, "modelValue");
35
+ /** Whether the dialog is shown, with `v-model:open`. */
36
+ const open = useModel(__props, "open");
37
+ const locale = useLocale(() => props.locale);
38
+ const messages = useMessages("timePicker", locale, () => props.messages);
39
+ const state = reactive(initialTimeState(model.value));
40
+ const rendered = ref(open.value);
41
+ const id = useId();
42
+ const picker = createTimePicker({
43
+ variant: "dialog",
44
+ props: () => ({
45
+ value: model.value,
46
+ open: open.value,
47
+ locale: locale.value,
48
+ hourCycle: props.hourCycle,
49
+ layout: props.layout,
50
+ initialMode: props.initialMode,
51
+ rendered: rendered.value
52
+ }),
53
+ messages: () => messages.value,
54
+ state: () => state,
55
+ ids: { error: `${id}-error` },
56
+ onChange: (next) => model.value = next,
57
+ onOpenChange: (next) => open.value = next,
58
+ onStateChange: (next) => Object.assign(state, next)
59
+ });
60
+ if (open.value) picker.opened();
61
+ watch(open, (next) => {
62
+ if (!next) return;
63
+ picker.opened();
64
+ rendered.value = true;
65
+ });
66
+ const root = useTemplateRef("root");
67
+ let dialogHandle;
68
+ let handle;
69
+ onMounted(() => {
70
+ dialogHandle = attachDialog(root.value, {
71
+ onOpenChange: (next) => open.value = next,
72
+ onClosed: () => {
73
+ if (!open.value) rendered.value = false;
74
+ },
75
+ initialFocus: () => root.value?.querySelector(".rio-time-picker__field")
76
+ });
77
+ dialogHandle.sync(open.value);
78
+ handle = attachTimePicker(root.value, {
79
+ selection: () => state.selection,
80
+ hourCycle: picker.hourCycle,
81
+ onPick: picker.dialPick,
82
+ onPeriod: picker.selectPeriod
83
+ });
84
+ });
85
+ watch(open, (next) => dialogHandle?.sync(next), { flush: "post" });
86
+ watch(state, () => handle?.sync(), { flush: "post" });
87
+ onBeforeUnmount(() => {
88
+ dialogHandle?.detach();
89
+ handle?.detach();
90
+ });
91
+ const onKeydown = (event) => {
92
+ if (event.key !== "Enter" || state.mode !== "input") return;
93
+ if (!event.target.matches("input")) return;
94
+ event.preventDefault();
95
+ picker.confirm();
96
+ };
97
+ return (_ctx, _cache) => {
98
+ return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" Clicks and presses stay in the dialog, as in RioDialog. "), createElementVNode("dialog", mergeProps({
99
+ ref_key: "root",
100
+ ref: root
101
+ }, unref(picker).parts.root(), {
102
+ onKeydown,
103
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"])),
104
+ onAuxclick: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"])),
105
+ onDblclick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"])),
106
+ onPointerdown: _cache[3] || (_cache[3] = withModifiers(() => {}, ["stop"])),
107
+ onPointerup: _cache[4] || (_cache[4] = withModifiers(() => {}, ["stop"])),
108
+ onMousedown: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"])),
109
+ onMouseup: _cache[6] || (_cache[6] = withModifiers(() => {}, ["stop"])),
110
+ onContextmenu: _cache[7] || (_cache[7] = withModifiers(() => {}, ["stop"]))
111
+ }), [rendered.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
112
+ createVNode(_sfc_main$3, { picker: unref(picker) }, null, 8, ["picker"]),
113
+ unref(picker).showsError() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(picker).parts.error())), toDisplayString(unref(picker).error()), 17)) : createCommentVNode("v-if", true),
114
+ createElementVNode("div", normalizeProps(guardReactiveProps(unref(picker).parts.actions())), [
115
+ createVNode(_sfc_main$2, {
116
+ variant: "standard",
117
+ label: unref(picker).modeButtonLabel(),
118
+ onClick: unref(picker).switchMode
119
+ }, {
120
+ default: withCtx(() => [state.mode === "dial" ? renderSlot(_ctx.$slots, "keyboard-icon", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "clock-icon", {}, void 0, void 0, 1)]),
121
+ _: 3
122
+ }, 8, ["label", "onClick"]),
123
+ createVNode(_sfc_main$1, {
124
+ variant: "text",
125
+ onClick: unref(picker).cancel
126
+ }, {
127
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).cancel), 1)]),
128
+ _: 1
129
+ }, 8, ["onClick"]),
130
+ createVNode(_sfc_main$1, {
131
+ variant: "text",
132
+ onClick: unref(picker).confirm
133
+ }, {
134
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).ok), 1)]),
135
+ _: 1
136
+ }, 8, ["onClick"])
137
+ ], 16)
138
+ ], 64)) : createCommentVNode("v-if", true)], 16)], 2112);
139
+ };
140
+ }
141
+ });
142
+ export { _sfc_main as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rio-m3e/vue",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Vue components for Rio, a Material 3 Expressive implementation",
5
5
  "license": "Apache-2.0",
6
6
  "author": "LegenLee",
@@ -27,14 +27,14 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@rio-m3e/core": "^0.4.0",
31
- "@rio-m3e/styles": "^0.4.0"
30
+ "@rio-m3e/core": "^0.5.0",
31
+ "@rio-m3e/styles": "^0.5.0",
32
+ "@rio-m3e/tokens": "^0.5.0"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@fontsource/roboto": "^5.3.0",
35
36
  "@mdi/js": "^7.4.47",
36
37
  "@rio-m3e/testing": "^0.0.0",
37
- "@rio-m3e/tokens": "^0.4.0",
38
38
  "tsdown": "0.23.7",
39
39
  "typescript": "~6.0.3",
40
40
  "unplugin-vue": "^8.0.1",