@rio-m3e/vue 0.4.0 → 0.6.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.
Files changed (78) hide show
  1. package/NOTICE +6 -0
  2. package/dist/button/Button.vue.d.ts +3 -2
  3. package/dist/button/Button.vue.js +14 -8
  4. package/dist/checkbox/Checkbox.vue.d.ts +1 -0
  5. package/dist/checkbox/Checkbox.vue.js +8 -11
  6. package/dist/chip/AssistChip.vue.d.ts +25 -0
  7. package/dist/chip/AssistChip.vue.js +50 -0
  8. package/dist/chip/ChipSet.vue.d.ts +23 -0
  9. package/dist/chip/ChipSet.vue.js +53 -0
  10. package/dist/chip/FilterChip.vue.d.ts +33 -0
  11. package/dist/chip/FilterChip.vue.js +68 -0
  12. package/dist/chip/InputChip.vue.d.ts +37 -0
  13. package/dist/chip/InputChip.vue.js +82 -0
  14. package/dist/chip/SuggestionChip.vue.d.ts +24 -0
  15. package/dist/chip/SuggestionChip.vue.js +50 -0
  16. package/dist/chip/context.js +17 -0
  17. package/dist/corner-morph/corner-morph.js +19 -0
  18. package/dist/date-picker/DatePicker.vue.d.ts +67 -0
  19. package/dist/date-picker/DatePicker.vue.js +239 -0
  20. package/dist/date-picker/DatePickerCalendar.vue.js +146 -0
  21. package/dist/date-picker/DatePickerDialog.vue.d.ts +58 -0
  22. package/dist/date-picker/DatePickerDialog.vue.js +191 -0
  23. package/dist/date-picker/DateRangeCalendar.vue.js +89 -0
  24. package/dist/date-picker/DateRangePickerDialog.vue.d.ts +56 -0
  25. package/dist/date-picker/DateRangePickerDialog.vue.js +208 -0
  26. package/dist/dialog/Dialog.vue.js +12 -13
  27. package/dist/icon-button/IconButton.vue.d.ts +3 -2
  28. package/dist/icon-button/IconButton.vue.js +10 -4
  29. package/dist/index.d.ts +41 -17
  30. package/dist/index.js +41 -17
  31. package/dist/list/List.vue.d.ts +23 -0
  32. package/dist/list/List.vue.js +61 -0
  33. package/dist/list/ListItem.vue.d.ts +49 -0
  34. package/dist/list/ListItem.vue.js +106 -0
  35. package/dist/list/context.js +12 -0
  36. package/dist/loading-indicator/LoadingIndicator.vue.d.ts +5 -0
  37. package/dist/loading-indicator/LoadingIndicator.vue.js +45 -0
  38. package/dist/locale/LocaleProvider.vue.d.ts +16 -0
  39. package/dist/locale/LocaleProvider.vue.js +14 -0
  40. package/dist/locale/locale.d.ts +16 -0
  41. package/dist/locale/locale.js +27 -0
  42. package/dist/menu/Menu.vue.js +9 -4
  43. package/dist/menu/SubMenu.vue.js +36 -17
  44. package/dist/overlay/presses.js +9 -0
  45. package/dist/progress/CircularProgress.vue.d.ts +5 -0
  46. package/dist/progress/CircularProgress.vue.js +54 -0
  47. package/dist/progress/LinearProgress.vue.d.ts +4 -0
  48. package/dist/progress/LinearProgress.vue.js +62 -0
  49. package/dist/radio/Radio.vue.d.ts +3 -2
  50. package/dist/radio/Radio.vue.js +17 -16
  51. package/dist/rio/rio.d.ts +32 -0
  52. package/dist/rio/rio.js +32 -0
  53. package/dist/ripple/ripple.js +14 -1
  54. package/dist/scroll-field/ScrollField.vue.d.ts +19 -0
  55. package/dist/scroll-field/ScrollField.vue.js +121 -0
  56. package/dist/select/Select.vue.d.ts +46 -0
  57. package/dist/select/Select.vue.js +179 -0
  58. package/dist/select/SelectOption.vue.d.ts +30 -0
  59. package/dist/select/SelectOption.vue.js +58 -0
  60. package/dist/select/context.js +3 -0
  61. package/dist/slider/RangeSlider.vue.d.ts +17 -0
  62. package/dist/slider/RangeSlider.vue.js +92 -0
  63. package/dist/slider/Slider.vue.d.ts +25 -0
  64. package/dist/slider/Slider.vue.js +102 -0
  65. package/dist/split-button/SplitButton.vue.d.ts +3 -2
  66. package/dist/split-button/SplitButton.vue.js +4 -3
  67. package/dist/switch/Switch.vue.js +33 -8
  68. package/dist/text-field/TextField.vue.js +8 -11
  69. package/dist/time-picker/TimeInput.vue.d.ts +26 -0
  70. package/dist/time-picker/TimeInput.vue.js +73 -0
  71. package/dist/time-picker/TimePickerBody.vue.js +72 -0
  72. package/dist/time-picker/TimePickerDialog.vue.d.ts +51 -0
  73. package/dist/time-picker/TimePickerDialog.vue.js +137 -0
  74. package/dist/time-picker/TimeScroll.vue.d.ts +38 -0
  75. package/dist/time-picker/TimeScroll.vue.js +81 -0
  76. package/dist/tooltip/Tooltip.vue.js +10 -22
  77. package/package.json +4 -4
  78. package/dist/shape-morph/shape-morph.js +0 -18
@@ -1,7 +1,7 @@
1
1
  import { vRipple } from "../ripple/ripple.js";
2
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";
3
+ import { Fragment, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, provide, ref, renderSlot, toDisplayString, unref, useId, useSlots, useTemplateRef, watch, withDirectives } from "vue";
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";
@@ -23,6 +23,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
23
23
  const slots = useSlots();
24
24
  const parent = inject(menuKey, void 0);
25
25
  const open = ref(false);
26
+ const inactive = ref(false);
27
+ const id = useId();
26
28
  const sub = createSubMenu({
27
29
  props: () => ({
28
30
  label: __props.label,
@@ -39,7 +41,9 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
39
41
  menu: () => parent,
40
42
  open: () => open.value,
41
43
  onChange: (selected) => emit("update:modelValue", selected),
42
- onOpenChange: (next) => open.value = next
44
+ onOpenChange: (next) => open.value = next,
45
+ ids: { menu: `${id}-menu` },
46
+ inactive: () => inactive.value
43
47
  });
44
48
  const { item } = sub;
45
49
  provide(menuKey, menuContextOf(sub.menu));
@@ -47,25 +51,40 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
47
51
  const root = useTemplateRef("root");
48
52
  let handle;
49
53
  onMounted(() => {
50
- handle = attachSubMenu(itemElement.value, root.value, { onOpenChange: (next) => open.value = next });
54
+ handle = attachSubMenu(itemElement.value, root.value, {
55
+ onOpenChange: (next) => open.value = next,
56
+ onInactiveChange: (next) => inactive.value = next
57
+ });
51
58
  handle.sync(open.value);
52
59
  });
53
60
  watch(open, (next) => handle?.sync(next), { flush: "post" });
54
61
  onBeforeUnmount(() => handle?.detach());
55
62
  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);
63
+ return openBlock(), createElementBlock(Fragment, null, [
64
+ withDirectives((openBlock(), createElementBlock("button", mergeProps({
65
+ ref_key: "itemElement",
66
+ ref: itemElement
67
+ }, unref(mergePartAttrs)({
68
+ ..._ctx.$attrs,
69
+ class: void 0,
70
+ style: void 0
71
+ }, unref(item).parts.root()), {
72
+ class: _ctx.$attrs.class,
73
+ style: _ctx.$attrs.style,
74
+ onClick: _cache[0] || (_cache[0] = (...args) => unref(item).handleClick && unref(item).handleClick(...args))
75
+ }), [
76
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(item).parts.touch())), null, 16),
77
+ unref(item).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(item).parts.icon())), [renderSlot(_ctx.$slots, "icon")], 16)) : createCommentVNode("v-if", true),
78
+ 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),
79
+ unref(item).showsTrailingText() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(item).parts.trailingText())), [renderSlot(_ctx.$slots, "trailing-text")], 16)) : createCommentVNode("v-if", true),
80
+ unref(item).showsTrailingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 2 }, unref(item).parts.trailingIcon())), [renderSlot(_ctx.$slots, "trailing-icon")], 16)) : createCommentVNode("v-if", true)
81
+ ], 16)), [[unref(vRipple)]]),
82
+ createCommentVNode(" Inside the menu's own element, which keeps clicks and presses in. "),
83
+ createElementVNode("div", mergeProps({
84
+ ref_key: "root",
85
+ ref: root
86
+ }, unref(sub).menu.parts.root()), [renderSlot(_ctx.$slots, "default")], 16)
87
+ ], 64);
69
88
  };
70
89
  }
71
90
  });
@@ -0,0 +1,9 @@
1
+ import { OVERLAY_PRESS_EVENTS } from "@rio-m3e/core";
2
+ // src/overlay/presses.ts
3
+ const stop = (event) => event.stopPropagation();
4
+ /**
5
+ * Listeners for an overlay's root, bound with `v-on`: they stop core's `OVERLAY_PRESS_EVENTS`, so
6
+ * clicks and presses stay in the overlay. Keys go on.
7
+ */
8
+ const keepPresses = Object.fromEntries(OVERLAY_PRESS_EVENTS.map((name) => [name, stop]));
9
+ export { keepPresses };
@@ -0,0 +1,5 @@
1
+ import { CircularProgressProps } from "@rio-m3e/core";
2
+ import "@rio-m3e/styles/progress.css";
3
+ declare const __VLS_export: import("vue").DefineComponent<CircularProgressProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CircularProgressProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
4
+ declare const _default: typeof __VLS_export;
5
+ export { _default as default };
@@ -0,0 +1,54 @@
1
+ import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, unref, useTemplateRef } from "vue";
2
+ import { attachCircularProgress, createCircularProgress } from "@rio-m3e/core";
3
+ import "@rio-m3e/styles/progress.css";
4
+ // src/progress/CircularProgress.vue
5
+ const _sfc_main = /*@__PURE__*/ defineComponent({
6
+ __name: "CircularProgress",
7
+ props: {
8
+ size: {},
9
+ value: {},
10
+ max: {},
11
+ wavy: { type: Boolean },
12
+ thickness: {}
13
+ },
14
+ setup(__props) {
15
+ const progress = createCircularProgress({ props: () => ({
16
+ value: __props.value,
17
+ max: __props.max,
18
+ wavy: __props.wavy,
19
+ thickness: __props.thickness,
20
+ size: __props.size
21
+ }) });
22
+ const root = useTemplateRef("root");
23
+ const indicator = useTemplateRef("indicator");
24
+ const wave = useTemplateRef("wave");
25
+ let handle;
26
+ onMounted(() => {
27
+ handle = attachCircularProgress(root.value, {
28
+ wavy: progress.showsWave,
29
+ indicator: () => indicator.value,
30
+ wave: () => wave.value
31
+ });
32
+ });
33
+ onUpdated(() => handle?.sync());
34
+ onBeforeUnmount(() => handle?.detach());
35
+ return (_ctx, _cache) => {
36
+ return openBlock(), createElementBlock("div", mergeProps({
37
+ ref_key: "root",
38
+ ref: root
39
+ }, unref(progress).parts.root()), [(openBlock(), createElementBlock("svg", normalizeProps(guardReactiveProps(unref(progress).parts.svg())), [
40
+ createElementVNode("circle", normalizeProps(guardReactiveProps(unref(progress).parts.track())), null, 16),
41
+ createElementVNode("circle", mergeProps({
42
+ ref_key: "indicator",
43
+ ref: indicator
44
+ }, unref(progress).parts.indicator()), null, 16),
45
+ unref(progress).showsWave() ? (openBlock(), createElementBlock("path", mergeProps({
46
+ key: 0,
47
+ ref_key: "wave",
48
+ ref: wave
49
+ }, unref(progress).parts.indicatorWave()), null, 16)) : createCommentVNode("v-if", true)
50
+ ], 16))], 16);
51
+ };
52
+ }
53
+ });
54
+ export { _sfc_main as default };
@@ -0,0 +1,4 @@
1
+ import "@rio-m3e/styles/progress.css";
2
+ declare const __VLS_export: import("vue").DefineComponent<import("@rio-m3e/core").ProgressCommonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("@rio-m3e/core").ProgressCommonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
+ declare const _default: typeof __VLS_export;
4
+ export { _default as default };
@@ -0,0 +1,62 @@
1
+ import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, unref, useTemplateRef } from "vue";
2
+ import { attachLinearProgress, createLinearProgress } from "@rio-m3e/core";
3
+ import "@rio-m3e/styles/progress.css";
4
+ // src/progress/LinearProgress.vue
5
+ const _sfc_main = /*@__PURE__*/ defineComponent({
6
+ __name: "LinearProgress",
7
+ props: {
8
+ value: {},
9
+ max: {},
10
+ wavy: { type: Boolean },
11
+ thickness: {}
12
+ },
13
+ setup(__props) {
14
+ const progress = createLinearProgress({ props: () => ({
15
+ value: __props.value,
16
+ max: __props.max,
17
+ wavy: __props.wavy,
18
+ thickness: __props.thickness
19
+ }) });
20
+ const root = useTemplateRef("root");
21
+ const indicator = useTemplateRef("indicator");
22
+ const indicatorLower = useTemplateRef("indicatorLower");
23
+ const wave = useTemplateRef("wave");
24
+ const waveLower = useTemplateRef("waveLower");
25
+ let handle;
26
+ onMounted(() => {
27
+ handle = attachLinearProgress(root.value, {
28
+ wavy: progress.showsWave,
29
+ indicators: () => [indicator.value, indicatorLower.value],
30
+ waves: () => [wave.value, waveLower.value]
31
+ });
32
+ });
33
+ onUpdated(() => handle?.sync());
34
+ onBeforeUnmount(() => handle?.detach());
35
+ return (_ctx, _cache) => {
36
+ return openBlock(), createElementBlock("div", mergeProps({
37
+ ref_key: "root",
38
+ ref: root
39
+ }, unref(progress).parts.root()), [
40
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(progress).parts.trackLower())), null, 16),
41
+ createElementVNode("span", mergeProps({
42
+ ref_key: "indicatorLower",
43
+ ref: indicatorLower
44
+ }, unref(progress).parts.indicatorLower()), null, 16),
45
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(progress).parts.trackMiddle())), null, 16),
46
+ createElementVNode("span", mergeProps({
47
+ ref_key: "indicator",
48
+ ref: indicator
49
+ }, unref(progress).parts.indicator()), null, 16),
50
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(progress).parts.trackUpper())), null, 16),
51
+ unref(progress).showsWave() ? (openBlock(), createElementBlock("svg", normalizeProps(mergeProps({ key: 0 }, unref(progress).parts.wave())), [createElementVNode("path", mergeProps({
52
+ ref_key: "waveLower",
53
+ ref: waveLower
54
+ }, unref(progress).parts.indicatorLowerWave()), null, 16), createElementVNode("path", mergeProps({
55
+ ref_key: "wave",
56
+ ref: wave
57
+ }, unref(progress).parts.indicatorWave()), null, 16)], 16)) : createCommentVNode("v-if", true)
58
+ ], 16);
59
+ };
60
+ }
61
+ });
62
+ export { _sfc_main as default };
@@ -1,10 +1,11 @@
1
1
  import { RadioProps, RadioValue } from "@rio-m3e/core";
2
+ import "@rio-m3e/styles/base/focus-ring.css";
2
3
  import "@rio-m3e/styles/base/reduced-motion.css";
3
4
  import "@rio-m3e/styles/base/ripple.css";
4
5
  import "@rio-m3e/styles/radio.css";
5
- interface Props extends Omit<RadioProps, 'selected'> {
6
+ interface Props extends RadioProps {
6
7
  /** The group's `v-model` takes this value when the radio button is selected. */
7
- value: RadioValue;
8
+ value?: RadioValue;
8
9
  }
9
10
  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
11
  declare const _default: typeof __VLS_export;
@@ -1,6 +1,8 @@
1
+ import { useRipple } from "../ripple/ripple.js";
1
2
  import { radioGroupKey } from "./context.js";
2
3
  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 { attachCheckable, createRadio, mergePartAttrs } from "@rio-m3e/core";
5
+ import "@rio-m3e/styles/base/focus-ring.css";
4
6
  import "@rio-m3e/styles/base/reduced-motion.css";
5
7
  import "@rio-m3e/styles/base/ripple.css";
6
8
  import "@rio-m3e/styles/radio.css";
@@ -10,40 +12,40 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
10
12
  __name: "Radio",
11
13
  props: {
12
14
  value: {},
15
+ selected: { type: Boolean },
13
16
  disabled: { type: Boolean },
14
17
  softDisabled: { type: Boolean }
15
18
  },
16
19
  setup(__props) {
17
- const group = inject(radioGroupKey);
18
- if (!group) throw new Error("RioRadio has to be inside a RioRadioGroup.");
20
+ const group = inject(radioGroupKey, null);
21
+ if (group && __props.value === void 0) throw new Error("RioRadio in a RioRadioGroup needs a value.");
22
+ const isSelected = () => group ? group.isSelected(__props.value) : !!__props.selected;
19
23
  const radio = createRadio({
20
24
  props: () => ({
21
- selected: group.isSelected(__props.value),
25
+ selected: isSelected(),
22
26
  disabled: __props.disabled,
23
27
  softDisabled: __props.softDisabled
24
28
  }),
25
- name: group.name,
26
- value: () => String(__props.value)
29
+ name: () => group?.name() ?? "",
30
+ value: () => String(__props.value ?? "")
27
31
  });
28
32
  const input = useTemplateRef("input");
29
33
  const state = useTemplateRef("state");
34
+ useRipple(input, state);
30
35
  let checkable;
31
- let ripple;
32
36
  let unregister;
33
37
  onMounted(() => {
34
38
  checkable = attachCheckable(input.value, {
35
- checked: () => group.isSelected(__props.value),
39
+ checked: isSelected,
36
40
  blocked: radio.blocked,
37
- onChange: (checked) => checked && group.select(__props.value)
41
+ onChange: (checked) => group ? checked && group.select(__props.value) : checkable?.sync()
38
42
  });
39
- unregister = group.register(checkable);
40
- ripple = attachRipple(input.value, { surface: state.value });
43
+ unregister = group?.register(checkable);
41
44
  });
42
45
  onUpdated(() => checkable?.sync());
43
46
  onBeforeUnmount(() => {
44
47
  unregister?.();
45
48
  checkable?.detach();
46
- ripple?.detach();
47
49
  });
48
50
  return (_ctx, _cache) => {
49
51
  return openBlock(), createElementBlock("span", mergeProps(unref(radio).parts.root(), {
@@ -53,12 +55,11 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
53
55
  createElementVNode("input", mergeProps({
54
56
  ref_key: "input",
55
57
  ref: input
56
- }, {
58
+ }, unref(mergePartAttrs)({
57
59
  ..._ctx.$attrs,
58
60
  class: void 0,
59
- style: void 0,
60
- ...unref(radio).parts.input()
61
- }), null, 16),
61
+ style: void 0
62
+ }, unref(radio).parts.input())), null, 16),
62
63
  createElementVNode("span", mergeProps({
63
64
  ref_key: "state",
64
65
  ref: state
@@ -0,0 +1,32 @@
1
+ import { App, MaybeRefOrGetter } from "vue";
2
+ import { PartialMessages } from "@rio-m3e/core";
3
+ import { ThemeOptions } from "@rio-m3e/tokens";
4
+ /** The theme: `@rio-m3e/tokens`' options, with the `color-scheme` written with it */
5
+ export type RioThemeOptions = ThemeOptions;
6
+ export interface RioOptions {
7
+ /**
8
+ * The theme, written as `--rio-*` variables on the document's root as the app installs Rio,
9
+ * before it mounts. A ref or a getter writes it again when it changes.
10
+ */
11
+ theme?: MaybeRefOrGetter<RioThemeOptions | undefined>;
12
+ /**
13
+ * The app's language, such as `ko` or `en-GB`. A ref or a getter changes it later. Without one,
14
+ * the document's, then the browser's, then English.
15
+ */
16
+ locale?: MaybeRefOrGetter<string | undefined>;
17
+ /** For a language Rio has no table for, the language whose messages fill in. Defaults to `'en'`. */
18
+ fallbackLocale?: MaybeRefOrGetter<string | undefined>;
19
+ /** Message tables by language tag: languages Rio has no table for, or messages that replace Rio's. */
20
+ messages?: MaybeRefOrGetter<Record<string, PartialMessages> | undefined>;
21
+ }
22
+ /** A Vue plugin, for `app.use` */
23
+ export interface RioPlugin {
24
+ install(app: App): void;
25
+ /** The theme as a stylesheet, for server rendering: put it in the page's `<head>`. Empty without a theme. */
26
+ readonly css: string;
27
+ }
28
+ /**
29
+ * Rio for a whole app: `app.use(createRio({ theme: { sourceColor: '#6750a4' }, locale: 'ko' }))`.
30
+ * A `RioLocaleProvider` inside, or a component's own `locale`, takes over the language from it.
31
+ */
32
+ export declare function createRio(options?: RioOptions): RioPlugin;
@@ -0,0 +1,32 @@
1
+ import { localeKey, messagesKey } from "../locale/locale.js";
2
+ import { computed, effectScope, toRef, toValue, watchEffect } from "vue";
3
+ import { attachTheme, createThemeCss } 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 theme = attachTheme(document.documentElement);
23
+ const scope = effectScope(true);
24
+ scope.run(() => watchEffect(() => theme.update(toValue(options.theme))));
25
+ app.onUnmount(() => {
26
+ scope.stop();
27
+ theme.detach();
28
+ });
29
+ }
30
+ };
31
+ }
32
+ export { createRio };
@@ -1,3 +1,4 @@
1
+ import { watch } from "vue";
1
2
  import { attachRipple } from "@rio-m3e/core";
2
3
  import "@rio-m3e/styles/base/ripple.css";
3
4
  // src/ripple/ripple.ts
@@ -29,4 +30,16 @@ const vRipple = {
29
30
  sync(el, false);
30
31
  }
31
32
  };
32
- export { vRipple };
33
+ /**
34
+ * For a component whose presses ripple on one of its parts: presses on `element` ripple on
35
+ * `surface`, as on a checkbox's input and its state part. Attaches again when either element is
36
+ * replaced, as when a chip turns into a link, and detaches as the component unmounts.
37
+ */
38
+ function useRipple(element, surface) {
39
+ watch([element, surface], ([el, state], _, onCleanup) => {
40
+ if (!el || !state) return;
41
+ const ripple = attachRipple(el, { surface: state });
42
+ onCleanup(() => ripple.detach());
43
+ }, { flush: "post" });
44
+ }
45
+ export { useRipple, vRipple };
@@ -0,0 +1,19 @@
1
+ import { ScrollFieldProps, ScrollFieldValue } 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/scroll-field.css";
5
+ type __VLS_Props = Omit<ScrollFieldProps, 'value'> & {
6
+ /** The value in the middle, with `v-model`. */
7
+ modelValue?: ScrollFieldValue;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ "update:modelValue": (value: ScrollFieldValue) => any;
11
+ "update:editing": (editing: boolean) => any;
12
+ "update:invalid": (invalid: boolean) => any;
13
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ "onUpdate:modelValue"?: ((value: ScrollFieldValue) => any) | undefined;
15
+ "onUpdate:editing"?: ((editing: boolean) => any) | undefined;
16
+ "onUpdate:invalid"?: ((invalid: boolean) => any) | undefined;
17
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export { _default as default };
@@ -0,0 +1,121 @@
1
+ import { useLocale } from "../locale/locale.js";
2
+ import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, isMemoSame, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, ref, renderList, toDisplayString, unref, useId, useModel, useTemplateRef } from "vue";
3
+ import { attachScrollField, createScrollField } from "@rio-m3e/core";
4
+ import "@rio-m3e/styles/base/focus-ring.css";
5
+ import "@rio-m3e/styles/base/reduced-motion.css";
6
+ import "@rio-m3e/styles/scroll-field.css";
7
+ // src/scroll-field/ScrollField.vue
8
+ const _sfc_main = /*@__PURE__*/ defineComponent({
9
+ __name: "ScrollField",
10
+ props: {
11
+ min: {},
12
+ max: {},
13
+ step: {},
14
+ options: {},
15
+ format: { type: Function },
16
+ label: {},
17
+ loop: { type: Boolean },
18
+ size: {},
19
+ editing: { type: Boolean },
20
+ invalid: { type: Boolean },
21
+ locale: {},
22
+ name: {},
23
+ disabled: { type: Boolean },
24
+ softDisabled: { type: Boolean },
25
+ modelValue: {}
26
+ },
27
+ emits: [
28
+ "update:modelValue",
29
+ "update:editing",
30
+ "update:invalid"
31
+ ],
32
+ setup(__props) {
33
+ const props = __props;
34
+ const model = useModel(props, "modelValue");
35
+ const editing = useModel(props, "editing");
36
+ const invalid = useModel(props, "invalid");
37
+ const locale = useLocale(() => props.locale);
38
+ const center = ref();
39
+ const id = useId();
40
+ const field = createScrollField({
41
+ props: () => ({
42
+ value: model.value,
43
+ min: props.min,
44
+ max: props.max,
45
+ step: props.step,
46
+ options: props.options,
47
+ format: props.format,
48
+ label: props.label,
49
+ loop: props.loop,
50
+ size: props.size,
51
+ editing: editing.value,
52
+ invalid: invalid.value,
53
+ locale: locale.value,
54
+ name: props.name,
55
+ disabled: props.disabled,
56
+ softDisabled: props.softDisabled
57
+ }),
58
+ ids: { options: `${id}-option` },
59
+ center: () => center.value,
60
+ onChange: (next) => model.value = next,
61
+ onEditingChange: (next) => editing.value = next
62
+ });
63
+ const centerItem = computed(() => field.centerIndex());
64
+ const valueItem = computed(() => field.targetIndex());
65
+ const itemCount = computed(() => field.items().length);
66
+ const root = useTemplateRef("root");
67
+ const viewport = useTemplateRef("viewport");
68
+ const input = useTemplateRef("input");
69
+ let handle;
70
+ onMounted(() => {
71
+ handle = attachScrollField(root.value, {
72
+ viewport: () => viewport.value,
73
+ input: () => input.value,
74
+ targetIndex: field.targetIndex,
75
+ readText: field.readText,
76
+ completeText: field.completeText,
77
+ onCenterChange(index, byPerson) {
78
+ center.value = index;
79
+ if (byPerson) field.selectItem(index);
80
+ },
81
+ onChange: (next) => model.value = next,
82
+ value: field.value,
83
+ valueText: field.valueText,
84
+ onEditingChange: (next) => editing.value = next,
85
+ onInvalidChange: (next) => invalid.value = next,
86
+ onStep: field.step
87
+ });
88
+ });
89
+ onUpdated(() => handle?.sync());
90
+ onBeforeUnmount(() => handle?.detach());
91
+ return (_ctx, _cache) => {
92
+ return openBlock(), createElementBlock("div", mergeProps({
93
+ ref_key: "root",
94
+ ref: root
95
+ }, unref(field).parts.root(), { onKeydown: _cache[2] || (_cache[2] = (...args) => unref(field).handleKeydown && unref(field).handleKeydown(...args)) }), [
96
+ createElementVNode("div", mergeProps({
97
+ ref_key: "viewport",
98
+ ref: viewport
99
+ }, unref(field).parts.viewport()), [createCommentVNode(" An item renders again only when its text changes, whether it is in the middle, whether it\n is the value's option, or the number of items. "), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(field).items(), (item, __, ___, _cached) => {
100
+ const _memo = [
101
+ unref(field).itemText(item),
102
+ item === centerItem.value,
103
+ item === valueItem.value,
104
+ itemCount.value
105
+ ];
106
+ if (_cached && _cached.el && _cached.key === item && isMemoSame(_cached, _memo)) return _cached;
107
+ const _item = (openBlock(), createElementBlock("div", mergeProps({ key: item }, { ref_for: true }, unref(field).parts.item(item), { onClick: ($event) => unref(field).selectItem(item) }), [createTextVNode(toDisplayString(unref(field).itemText(item)), 1)], 16, ["onClick"]));
108
+ _item.memo = _memo;
109
+ return _item;
110
+ }, _cache, 0), 128))], 16),
111
+ unref(field).showsInput() ? (openBlock(), createElementBlock("input", mergeProps({
112
+ key: 0,
113
+ ref_key: "input",
114
+ ref: input
115
+ }, unref(field).parts.input()), null, 16)) : createCommentVNode("v-if", true),
116
+ unref(field).showsHiddenInput() ? (openBlock(), createElementBlock("input", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.hiddenInput())), null, 16)) : createCommentVNode("v-if", true)
117
+ ], 16);
118
+ };
119
+ }
120
+ });
121
+ export { _sfc_main as default };
@@ -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:modelValue": (value: SelectSelected) => any;
34
+ "update:open": (value: boolean) => any;
35
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
36
+ "onUpdate:modelValue"?: ((value: SelectSelected) => any) | undefined;
37
+ "onUpdate:open"?: ((value: boolean) => 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 };