@rio-m3e/vue 0.1.0 → 0.2.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.
@@ -10,21 +10,12 @@ type __VLS_Slots = {
10
10
  icon?: () => unknown;
11
11
  };
12
12
  declare const __VLS_base: import("vue").DefineComponent<ButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
- click: (event: MouseEvent) => any;
14
13
  "update:selected": (selected: boolean) => any;
14
+ click: (event: MouseEvent) => any;
15
15
  }, string, import("vue").PublicProps, Readonly<ButtonProps> & Readonly<{
16
- onClick?: ((event: MouseEvent) => any) | undefined;
17
16
  "onUpdate:selected"?: ((selected: boolean) => any) | undefined;
18
- }>, {
19
- variant: "filled" | "tonal" | "outlined" | "elevated" | "text";
20
- size: "small" | "xsmall" | "medium" | "large" | "xlarge";
21
- shape: import("@rio-m3e/core").ButtonShape;
22
- toggle: boolean;
23
- selected: boolean;
24
- disabled: boolean;
25
- softDisabled: boolean;
26
- type: "button" | "submit" | "reset";
27
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ onClick?: ((event: MouseEvent) => any) | undefined;
18
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
19
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
20
  declare const _default: typeof __VLS_export;
30
21
  type __VLS_WithSlots<T, S> = T & {
@@ -1,21 +1,16 @@
1
+ import { useButtonGroupItem } from "../button-group/context.js";
1
2
  import { vRipple } from "../ripple/ripple.js";
2
3
  import { vShapeMorph } from "../shape-morph/shape-morph.js";
3
- import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeDefaults, mergeProps, openBlock, renderSlot, unref, withDirectives } from "vue";
4
- import { buttonDefaults, createButton } from "@rio-m3e/core";
4
+ import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderSlot, unref, useSlots, withDirectives } from "vue";
5
+ import { createButton } from "@rio-m3e/core";
5
6
  import "@rio-m3e/styles/base/focus-ring.css";
6
7
  import "@rio-m3e/styles/base/reduced-motion.css";
7
8
  import "@rio-m3e/styles/base/state-layer.css";
8
9
  import "@rio-m3e/styles/button.css";
9
10
  // src/button/Button.vue
10
- const _hoisted_1 = {
11
- key: 0,
12
- class: "rio-button__icon",
13
- "aria-hidden": "true"
14
- };
15
- const _hoisted_2 = { class: "rio-button__label" };
16
11
  const _sfc_main = /*@__PURE__*/ defineComponent({
17
12
  __name: "Button",
18
- props: /*@__PURE__*/ mergeDefaults({
13
+ props: {
19
14
  variant: {},
20
15
  size: {},
21
16
  shape: {},
@@ -23,25 +18,35 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
23
18
  selected: { type: Boolean },
24
19
  disabled: { type: Boolean },
25
20
  softDisabled: { type: Boolean },
26
- type: {}
27
- }, buttonDefaults),
21
+ type: {},
22
+ value: {}
23
+ },
28
24
  emits: ["click", "update:selected"],
29
25
  setup(__props, { emit: __emit }) {
30
- const props = __props;
31
26
  const emit = __emit;
27
+ const slots = useSlots();
28
+ const item = useButtonGroupItem(() => ({
29
+ variant: __props.variant,
30
+ size: __props.size,
31
+ shape: __props.shape,
32
+ toggle: __props.toggle,
33
+ selected: __props.selected,
34
+ disabled: __props.disabled,
35
+ softDisabled: __props.softDisabled,
36
+ type: __props.type,
37
+ value: __props.value
38
+ }), (next) => emit("update:selected", next));
32
39
  const button = createButton({
33
- props: () => props,
40
+ props: item.props,
41
+ content: () => ({ icon: !!slots.icon }),
34
42
  onClick: (event) => emit("click", event),
35
- onSelectedChange: (selected) => emit("update:selected", selected)
43
+ onChange: item.onChange
36
44
  });
37
45
  return (_ctx, _cache) => {
38
- return withDirectives((openBlock(), createElementBlock("button", mergeProps({ class: "rio-button rio-state-layer rio-focus-ring" }, unref(button).rootAttrs(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(button).handleClick && unref(button).handleClick(...args)) }), [
39
- _cache[1] || (_cache[1] = createElementVNode("span", {
40
- class: "rio-button__touch",
41
- "aria-hidden": "true"
42
- }, null, -1)),
43
- _ctx.$slots.icon ? (openBlock(), createElementBlock("span", _hoisted_1, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true),
44
- createElementVNode("span", _hoisted_2, [renderSlot(_ctx.$slots, "default")])
46
+ return withDirectives((openBlock(), createElementBlock("button", mergeProps(unref(button).parts.root(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(button).handleClick && unref(button).handleClick(...args)) }), [
47
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(button).parts.touch())), null, 16),
48
+ unref(button).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(button).parts.icon())), [renderSlot(_ctx.$slots, "icon")], 16)) : createCommentVNode("v-if", true),
49
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(button).parts.label())), [renderSlot(_ctx.$slots, "default")], 16)
45
50
  ], 16)), [[unref(vRipple)], [unref(vShapeMorph)]]);
46
51
  };
47
52
  }
@@ -0,0 +1,23 @@
1
+ import { ButtonGroupProps, ButtonGroupSelected } from "@rio-m3e/core";
2
+ import "@rio-m3e/styles/button-group.css";
3
+ interface Props extends Omit<ButtonGroupProps, 'selected'> {
4
+ /** The selected value (`single`) or values (`multiple`), with `v-model`. */
5
+ modelValue?: ButtonGroupSelected;
6
+ }
7
+ type __VLS_Slots = {
8
+ /** `RioButton`s and `RioIconButton`s. They take the group's size and shape unless they set their own. */
9
+ default?: () => unknown;
10
+ };
11
+ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ "update:modelValue": (selected: ButtonGroupSelected) => any;
13
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
14
+ "onUpdate:modelValue"?: ((selected: ButtonGroupSelected) => any) | undefined;
15
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
17
+ declare const _default: typeof __VLS_export;
18
+ type __VLS_WithSlots<T, S> = T & {
19
+ new (): {
20
+ $slots: S;
21
+ };
22
+ };
23
+ export { _default as default };
@@ -0,0 +1,51 @@
1
+ import { buttonGroupKey } from "./context.js";
2
+ import { createElementBlock, defineComponent, mergeProps, onBeforeUnmount, onMounted, openBlock, provide, renderSlot, unref, useTemplateRef } from "vue";
3
+ import { attachButtonGroup, createButtonGroup } from "@rio-m3e/core";
4
+ import "@rio-m3e/styles/button-group.css";
5
+ // src/button-group/ButtonGroup.vue
6
+ const _sfc_main = /*@__PURE__*/ defineComponent({
7
+ __name: "ButtonGroup",
8
+ props: {
9
+ modelValue: {},
10
+ variant: {},
11
+ size: {},
12
+ shape: {},
13
+ selection: {},
14
+ required: { type: Boolean }
15
+ },
16
+ emits: ["update:modelValue"],
17
+ setup(__props, { emit: __emit }) {
18
+ const emit = __emit;
19
+ const group = createButtonGroup({
20
+ props: () => ({
21
+ variant: __props.variant,
22
+ size: __props.size,
23
+ shape: __props.shape,
24
+ selection: __props.selection,
25
+ required: __props.required,
26
+ selected: __props.modelValue
27
+ }),
28
+ onChange: (selected) => emit("update:modelValue", selected)
29
+ });
30
+ provide(buttonGroupKey, {
31
+ size: group.size,
32
+ shape: group.shape,
33
+ selection: group.selection,
34
+ isSelected: group.isSelected,
35
+ select: group.select
36
+ });
37
+ const root = useTemplateRef("root");
38
+ let handle;
39
+ onMounted(() => {
40
+ handle = attachButtonGroup(root.value);
41
+ });
42
+ onBeforeUnmount(() => handle?.detach());
43
+ return (_ctx, _cache) => {
44
+ return openBlock(), createElementBlock("div", mergeProps({
45
+ ref_key: "root",
46
+ ref: root
47
+ }, unref(group).parts.root()), [renderSlot(_ctx.$slots, "default")], 16);
48
+ };
49
+ }
50
+ });
51
+ export { _sfc_main as default };
@@ -0,0 +1,33 @@
1
+ import { inject } from "vue";
2
+ // src/button-group/context.ts
3
+ const buttonGroupKey = Symbol("RioButtonGroup");
4
+ /**
5
+ * For `RioButton` and `RioIconButton`: takes the size and shape of the button group around the
6
+ * button unless the button sets its own, and, in a group that keeps a selection, makes a button
7
+ * with a `value` a toggle whose state the group owns. Outside a group it changes nothing.
8
+ */
9
+ function useButtonGroupItem(props, emitChange) {
10
+ const group = inject(buttonGroupKey, null);
11
+ const grouped = () => !!group && group.selection() !== "none" && props().value !== void 0;
12
+ return {
13
+ /** The props to pass to core, with the group's values filled in. */
14
+ props: () => {
15
+ const own = props();
16
+ return {
17
+ ...own,
18
+ size: own.size ?? group?.size(),
19
+ shape: own.shape ?? group?.shape(),
20
+ ...grouped() ? {
21
+ toggle: true,
22
+ selected: group.isSelected(own.value)
23
+ } : {}
24
+ };
25
+ },
26
+ /** The `onChange` to pass to core: to the group if it owns the state, otherwise to the app. */
27
+ onChange(selected) {
28
+ if (grouped()) group.select(props().value, selected);
29
+ else emitChange(selected);
30
+ }
31
+ };
32
+ }
33
+ export { buttonGroupKey, useButtonGroupItem };
@@ -14,22 +14,12 @@ type __VLS_Slots = {
14
14
  'selected-icon'?: () => unknown;
15
15
  };
16
16
  declare const __VLS_base: import("vue").DefineComponent<IconButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
- click: (event: MouseEvent) => any;
18
17
  "update:selected": (selected: boolean) => any;
18
+ click: (event: MouseEvent) => any;
19
19
  }, string, import("vue").PublicProps, Readonly<IconButtonProps> & Readonly<{
20
- onClick?: ((event: MouseEvent) => any) | undefined;
21
20
  "onUpdate:selected"?: ((selected: boolean) => any) | undefined;
22
- }>, {
23
- variant: "filled" | "tonal" | "outlined" | "standard";
24
- size: "small" | "xsmall" | "medium" | "large" | "xlarge";
25
- shape: import("@rio-m3e/core").ButtonShape;
26
- toggle: boolean;
27
- selected: boolean;
28
- disabled: boolean;
29
- softDisabled: boolean;
30
- type: "button" | "submit" | "reset";
31
- width: "default" | "narrow" | "wide";
32
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ onClick?: ((event: MouseEvent) => any) | undefined;
22
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
23
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
34
24
  declare const _default: typeof __VLS_export;
35
25
  type __VLS_WithSlots<T, S> = T & {
@@ -1,20 +1,17 @@
1
+ import { useButtonGroupItem } from "../button-group/context.js";
1
2
  import { vRipple } from "../ripple/ripple.js";
2
3
  import { vShapeMorph } from "../shape-morph/shape-morph.js";
3
- import { createElementBlock, createElementVNode, defineComponent, mergeDefaults, mergeProps, openBlock, renderSlot, unref, useSlots, withDirectives } from "vue";
4
- import { createIconButton, iconButtonDefaults } from "@rio-m3e/core";
4
+ import { createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderSlot, unref, useSlots, withDirectives } from "vue";
5
+ import { createIconButton } from "@rio-m3e/core";
5
6
  import "@rio-m3e/styles/base/focus-ring.css";
6
7
  import "@rio-m3e/styles/base/reduced-motion.css";
7
8
  import "@rio-m3e/styles/base/state-layer.css";
8
9
  import "@rio-m3e/styles/button.css";
9
10
  import "@rio-m3e/styles/icon-button.css";
10
11
  // src/icon-button/IconButton.vue
11
- const _hoisted_1 = {
12
- class: "rio-button__icon",
13
- "aria-hidden": "true"
14
- };
15
12
  const _sfc_main = /*@__PURE__*/ defineComponent({
16
13
  __name: "IconButton",
17
- props: /*@__PURE__*/ mergeDefaults({
14
+ props: {
18
15
  label: {},
19
16
  variant: {},
20
17
  size: {},
@@ -24,23 +21,34 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
24
21
  selected: { type: Boolean },
25
22
  disabled: { type: Boolean },
26
23
  softDisabled: { type: Boolean },
27
- type: {}
28
- }, iconButtonDefaults),
24
+ type: {},
25
+ value: {}
26
+ },
29
27
  emits: ["click", "update:selected"],
30
28
  setup(__props, { emit: __emit }) {
31
- const props = __props;
32
29
  const emit = __emit;
33
30
  const slots = useSlots();
31
+ const item = useButtonGroupItem(() => ({
32
+ label: __props.label,
33
+ variant: __props.variant,
34
+ size: __props.size,
35
+ width: __props.width,
36
+ shape: __props.shape,
37
+ toggle: __props.toggle,
38
+ selected: __props.selected,
39
+ disabled: __props.disabled,
40
+ softDisabled: __props.softDisabled,
41
+ type: __props.type,
42
+ value: __props.value
43
+ }), (next) => emit("update:selected", next));
34
44
  const button = createIconButton({
35
- props: () => props,
45
+ props: item.props,
46
+ content: () => ({ selectedIcon: !!slots["selected-icon"] }),
36
47
  onClick: (event) => emit("click", event),
37
- onSelectedChange: (selected) => emit("update:selected", selected)
48
+ onChange: item.onChange
38
49
  });
39
50
  return (_ctx, _cache) => {
40
- return withDirectives((openBlock(), createElementBlock("button", mergeProps({ class: "rio-button rio-icon-button rio-state-layer rio-focus-ring" }, unref(button).rootAttrs(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(button).handleClick && unref(button).handleClick(...args)) }), [_cache[1] || (_cache[1] = createElementVNode("span", {
41
- class: "rio-button__touch",
42
- "aria-hidden": "true"
43
- }, null, -1)), createElementVNode("span", _hoisted_1, [props.toggle && props.selected && slots["selected-icon"] ? renderSlot(_ctx.$slots, "selected-icon", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 1)])], 16)), [[unref(vRipple)], [unref(vShapeMorph)]]);
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)]]);
44
52
  };
45
53
  }
46
54
  });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import _default from "./button/Button.vue.js";
2
- import _default$1 from "./icon-button/IconButton.vue.js";
2
+ import _default$1 from "./button-group/ButtonGroup.vue.js";
3
+ import _default$2 from "./icon-button/IconButton.vue.js";
3
4
  import { vRipple } from "./ripple/ripple.js";
4
- import _default$2 from "./switch/Switch.vue.js";
5
- export { _default as RioButton, _default$1 as RioIconButton, _default$2 as RioSwitch, vRipple };
5
+ import _default$3 from "./split-button/SplitButton.vue.js";
6
+ import _default$4 from "./switch/Switch.vue.js";
7
+ export { _default as RioButton, _default$1 as RioButtonGroup, _default$2 as RioIconButton, _default$3 as RioSplitButton, _default$4 as RioSwitch, vRipple };
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import _sfc_main from "./button/Button.vue.js";
2
- import _sfc_main$1 from "./icon-button/IconButton.vue.js";
2
+ import _sfc_main$1 from "./button-group/ButtonGroup.vue.js";
3
+ import _sfc_main$2 from "./icon-button/IconButton.vue.js";
3
4
  import { vRipple } from "./ripple/ripple.js";
4
- import _sfc_main$2 from "./switch/Switch.vue.js";
5
- export { _sfc_main as RioButton, _sfc_main$1 as RioIconButton, _sfc_main$2 as RioSwitch, vRipple };
5
+ import _sfc_main$3 from "./split-button/SplitButton.vue.js";
6
+ import _sfc_main$4 from "./switch/Switch.vue.js";
7
+ export { _sfc_main as RioButton, _sfc_main$1 as RioButtonGroup, _sfc_main$2 as RioIconButton, _sfc_main$3 as RioSplitButton, _sfc_main$4 as RioSwitch, vRipple };
@@ -0,0 +1,35 @@
1
+ import { SplitButtonProps } 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/button.css";
6
+ import "@rio-m3e/styles/split-button.css";
7
+ type __VLS_Slots = {
8
+ /** The leading button's label. Without it, give the split button a `label`. */
9
+ default?: () => unknown;
10
+ /** The leading button's icon. Hidden from assistive technology. */
11
+ icon?: () => unknown;
12
+ /**
13
+ * The trailing button's icon: an expand icon pointing down, which turns when the menu opens.
14
+ * Rio ships no icons. Hidden from assistive technology; `menuLabel` names the button.
15
+ */
16
+ 'menu-icon'?: () => unknown;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<SplitButtonProps, {
19
+ leading: Readonly<import("vue").ShallowRef<HTMLButtonElement | null>>;
20
+ trailing: Readonly<import("vue").ShallowRef<HTMLButtonElement | null>>;
21
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ click: (event: MouseEvent) => any;
23
+ "update:open": (open: boolean) => any;
24
+ }, string, import("vue").PublicProps, Readonly<SplitButtonProps> & Readonly<{
25
+ onClick?: ((event: MouseEvent) => any) | undefined;
26
+ "onUpdate:open"?: ((open: boolean) => any) | undefined;
27
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
+ declare const _default: typeof __VLS_export;
30
+ type __VLS_WithSlots<T, S> = T & {
31
+ new (): {
32
+ $slots: S;
33
+ };
34
+ };
35
+ export { _default as default };
@@ -0,0 +1,73 @@
1
+ import { vRipple } from "../ripple/ripple.js";
2
+ import { vShapeMorph } from "../shape-morph/shape-morph.js";
3
+ import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, renderSlot, unref, useSlots, useTemplateRef, withDirectives } from "vue";
4
+ import { attachSplitButtonMenuIcon, createSplitButton } 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/button.css";
9
+ import "@rio-m3e/styles/split-button.css";
10
+ // src/split-button/SplitButton.vue
11
+ const _sfc_main = /*@__PURE__*/ defineComponent({
12
+ __name: "SplitButton",
13
+ props: {
14
+ menuLabel: {},
15
+ label: {},
16
+ variant: {},
17
+ size: {},
18
+ open: { type: Boolean },
19
+ popup: {},
20
+ disabled: { type: Boolean },
21
+ softDisabled: { type: Boolean },
22
+ type: {}
23
+ },
24
+ emits: ["click", "update:open"],
25
+ setup(__props, { expose: __expose, emit: __emit }) {
26
+ const emit = __emit;
27
+ const slots = useSlots();
28
+ const sb = createSplitButton({
29
+ props: () => ({
30
+ menuLabel: __props.menuLabel,
31
+ label: __props.label,
32
+ variant: __props.variant,
33
+ size: __props.size,
34
+ open: __props.open,
35
+ popup: __props.popup,
36
+ disabled: __props.disabled,
37
+ softDisabled: __props.softDisabled,
38
+ type: __props.type
39
+ }),
40
+ content: () => ({
41
+ icon: !!slots.icon,
42
+ label: !!slots.default
43
+ }),
44
+ onClick: (event) => emit("click", event),
45
+ onChange: (next) => emit("update:open", next)
46
+ });
47
+ const leading = useTemplateRef("leading");
48
+ const trailing = useTemplateRef("trailing");
49
+ __expose({
50
+ leading,
51
+ trailing
52
+ });
53
+ let handle;
54
+ onMounted(() => {
55
+ handle = attachSplitButtonMenuIcon(trailing.value);
56
+ });
57
+ onBeforeUnmount(() => handle?.detach());
58
+ return (_ctx, _cache) => {
59
+ return openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(unref(sb).parts.root())), [withDirectives((openBlock(), createElementBlock("button", mergeProps({
60
+ ref_key: "leading",
61
+ ref: leading
62
+ }, unref(sb).parts.leading(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(sb).handleLeadingClick && unref(sb).handleLeadingClick(...args)) }), [
63
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(sb).parts.touch())), null, 16),
64
+ unref(sb).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(sb).parts.icon())), [renderSlot(_ctx.$slots, "icon")], 16)) : createCommentVNode("v-if", true),
65
+ unref(sb).showsLabel() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(sb).parts.label())), [renderSlot(_ctx.$slots, "default")], 16)) : createCommentVNode("v-if", true)
66
+ ], 16)), [[unref(vRipple)], [unref(vShapeMorph)]]), withDirectives((openBlock(), createElementBlock("button", mergeProps({
67
+ ref_key: "trailing",
68
+ ref: trailing
69
+ }, unref(sb).parts.trailing(), { onClick: _cache[1] || (_cache[1] = (...args) => unref(sb).handleTrailingClick && unref(sb).handleTrailingClick(...args)) }), [createElementVNode("span", normalizeProps(guardReactiveProps(unref(sb).parts.touch())), null, 16), createElementVNode("span", normalizeProps(guardReactiveProps(unref(sb).parts.menuIcon())), [renderSlot(_ctx.$slots, "menu-icon")], 16)], 16)), [[unref(vRipple)], [unref(vShapeMorph)]])], 16);
70
+ };
71
+ }
72
+ });
73
+ export { _sfc_main as default };
@@ -13,11 +13,7 @@ declare const __VLS_base: import("vue").DefineComponent<SwitchProps, {}, {}, {},
13
13
  "update:selected": (selected: boolean) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<SwitchProps> & Readonly<{
15
15
  "onUpdate:selected"?: ((selected: boolean) => any) | undefined;
16
- }>, {
17
- selected: boolean;
18
- disabled: boolean;
19
- softDisabled: boolean;
20
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
17
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
22
18
  declare const _default: typeof __VLS_export;
23
19
  type __VLS_WithSlots<T, S> = T & {
@@ -1,68 +1,56 @@
1
- import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeDefaults, mergeProps, onBeforeUnmount, onMounted, openBlock, renderSlot, unref, useSlots, useTemplateRef } from "vue";
2
- import { attachRipple, attachSwitchHandle, createSwitch, switchDefaults } from "@rio-m3e/core";
1
+ import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, renderSlot, unref, useSlots, useTemplateRef } from "vue";
2
+ import { attachRipple, attachSwitchHandle, createSwitch } from "@rio-m3e/core";
3
3
  import "@rio-m3e/styles/base/focus-ring.css";
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/switch.css";
7
7
  // src/switch/Switch.vue
8
- const _hoisted_1 = ["data-icon"];
9
- const _hoisted_2 = {
10
- class: "rio-switch__handle",
11
- "aria-hidden": "true"
12
- };
13
- const _hoisted_3 = {
14
- key: 0,
15
- class: "rio-switch__icon"
16
- };
17
8
  const _sfc_main = /*@__PURE__*/ defineComponent({
18
9
  __name: "Switch",
19
- props: /*@__PURE__*/ mergeDefaults({
10
+ props: {
20
11
  selected: { type: Boolean },
21
12
  disabled: { type: Boolean },
22
13
  softDisabled: { type: Boolean }
23
- }, switchDefaults),
14
+ },
24
15
  emits: ["update:selected"],
25
16
  setup(__props, { emit: __emit }) {
26
- const props = __props;
27
17
  const emit = __emit;
28
18
  const slots = useSlots();
29
- const onSelectedChange = (selected) => emit("update:selected", selected);
19
+ const onChange = (next) => emit("update:selected", next);
30
20
  const sw = createSwitch({
31
- props: () => props,
32
- onSelectedChange
21
+ props: () => ({
22
+ selected: __props.selected,
23
+ disabled: __props.disabled,
24
+ softDisabled: __props.softDisabled
25
+ }),
26
+ content: () => ({
27
+ selectedIcon: !!slots["selected-icon"],
28
+ unselectedIcon: !!slots["unselected-icon"]
29
+ }),
30
+ onChange
33
31
  });
34
- const showsIcon = computed(() => !!(props.selected ? slots["selected-icon"] : slots["unselected-icon"]));
35
32
  const root = useTemplateRef("root");
36
33
  const state = useTemplateRef("state");
37
34
  let handles = [];
38
35
  onMounted(() => {
39
36
  handles = [attachRipple(root.value, { surface: state.value }), attachSwitchHandle(root.value, {
40
- selected: () => props.selected,
41
- onSelectedChange
37
+ selected: () => __props.selected,
38
+ onChange
42
39
  })];
43
40
  });
44
41
  onBeforeUnmount(() => handles.forEach((handle) => handle.detach()));
45
42
  return (_ctx, _cache) => {
46
43
  return openBlock(), createElementBlock("button", mergeProps({
47
44
  ref_key: "root",
48
- ref: root,
49
- class: "rio-switch rio-focus-ring"
50
- }, unref(sw).rootAttrs(), {
51
- "data-icon": showsIcon.value ? "" : void 0,
52
- onClick: _cache[0] || (_cache[0] = (...args) => unref(sw).handleClick && unref(sw).handleClick(...args))
53
- }), [
54
- _cache[1] || (_cache[1] = createElementVNode("span", {
55
- class: "rio-switch__touch",
56
- "aria-hidden": "true"
57
- }, null, -1)),
58
- createElementVNode("span", {
45
+ ref: root
46
+ }, unref(sw).parts.root(), { onClick: _cache[0] || (_cache[0] = (...args) => unref(sw).handleClick && unref(sw).handleClick(...args)) }), [
47
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(sw).parts.touch())), null, 16),
48
+ createElementVNode("span", mergeProps({
59
49
  ref_key: "state",
60
- ref: state,
61
- class: "rio-switch__state",
62
- "aria-hidden": "true"
63
- }, null, 512),
64
- createElementVNode("span", _hoisted_2, [showsIcon.value ? (openBlock(), createElementBlock("span", _hoisted_3, [props.selected ? renderSlot(_ctx.$slots, "selected-icon", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "unselected-icon", {}, void 0, void 0, 1)])) : createCommentVNode("v-if", true)])
65
- ], 16, _hoisted_1);
50
+ ref: state
51
+ }, unref(sw).parts.state()), null, 16),
52
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(sw).parts.handle())), [unref(sw).showsIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(sw).parts.icon())), [unref(sw).showsSelectedIcon() ? renderSlot(_ctx.$slots, "selected-icon", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "unselected-icon", {}, void 0, void 0, 1)], 16)) : createCommentVNode("v-if", true)], 16)
53
+ ], 16);
66
54
  };
67
55
  }
68
56
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rio-m3e/vue",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Vue components for Rio, a Material 3 Expressive implementation",
5
5
  "license": "Apache-2.0",
6
6
  "author": "LegenLee",
@@ -27,10 +27,13 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@rio-m3e/core": "^0.1.0",
31
- "@rio-m3e/styles": "^0.1.0"
30
+ "@rio-m3e/core": "^0.2.0",
31
+ "@rio-m3e/styles": "^0.2.0"
32
32
  },
33
33
  "devDependencies": {
34
+ "@fontsource/roboto": "^5.3.0",
35
+ "@mdi/js": "^7.4.47",
36
+ "@rio-m3e/tokens": "^0.2.0",
34
37
  "tsdown": "0.23.7",
35
38
  "typescript": "~6.0.3",
36
39
  "unplugin-vue": "^8.0.1",