@rio-m3e/vue 0.3.0 → 0.4.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,11 @@
1
+ import { CheckboxProps } from "@rio-m3e/core";
2
+ import "@rio-m3e/styles/base/reduced-motion.css";
3
+ import "@rio-m3e/styles/base/ripple.css";
4
+ import "@rio-m3e/styles/checkbox.css";
5
+ declare const __VLS_export: import("vue").DefineComponent<CheckboxProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:selected": (selected: boolean) => any;
7
+ }, string, import("vue").PublicProps, Readonly<CheckboxProps> & Readonly<{
8
+ "onUpdate:selected"?: ((selected: boolean) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export { _default as default };
@@ -0,0 +1,71 @@
1
+ import { createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, nextTick, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, unref, useTemplateRef } from "vue";
2
+ import { attachCheckable, attachRipple, createCheckbox } from "@rio-m3e/core";
3
+ import "@rio-m3e/styles/base/reduced-motion.css";
4
+ import "@rio-m3e/styles/base/ripple.css";
5
+ import "@rio-m3e/styles/checkbox.css";
6
+ // src/checkbox/Checkbox.vue
7
+ const _sfc_main = /*@__PURE__*/ defineComponent({
8
+ inheritAttrs: false,
9
+ __name: "Checkbox",
10
+ props: {
11
+ selected: { type: Boolean },
12
+ indeterminate: { type: Boolean },
13
+ error: { type: Boolean },
14
+ disabled: { type: Boolean },
15
+ softDisabled: { type: Boolean }
16
+ },
17
+ emits: ["update:selected"],
18
+ setup(__props, { emit: __emit }) {
19
+ const emit = __emit;
20
+ const checkbox = createCheckbox({ props: () => ({
21
+ selected: __props.selected,
22
+ indeterminate: __props.indeterminate,
23
+ error: __props.error,
24
+ disabled: __props.disabled,
25
+ softDisabled: __props.softDisabled
26
+ }) });
27
+ const input = useTemplateRef("input");
28
+ const state = useTemplateRef("state");
29
+ let checkable;
30
+ let ripple;
31
+ onMounted(() => {
32
+ checkable = attachCheckable(input.value, {
33
+ checked: () => !!__props.selected,
34
+ indeterminate: () => !!__props.indeterminate,
35
+ blocked: checkbox.blocked,
36
+ onChange(checked) {
37
+ emit("update:selected", checkbox.next(checked));
38
+ nextTick(() => checkable?.sync());
39
+ }
40
+ });
41
+ ripple = attachRipple(input.value, { surface: state.value });
42
+ });
43
+ onUpdated(() => checkable?.sync());
44
+ onBeforeUnmount(() => {
45
+ checkable?.detach();
46
+ ripple?.detach();
47
+ });
48
+ return (_ctx, _cache) => {
49
+ return openBlock(), createElementBlock("span", mergeProps(unref(checkbox).parts.root(), {
50
+ class: _ctx.$attrs.class,
51
+ style: _ctx.$attrs.style
52
+ }), [
53
+ createElementVNode("input", mergeProps({
54
+ ref_key: "input",
55
+ ref: input
56
+ }, {
57
+ ..._ctx.$attrs,
58
+ class: void 0,
59
+ style: void 0,
60
+ ...unref(checkbox).parts.input()
61
+ }), null, 16),
62
+ createElementVNode("span", mergeProps({
63
+ ref_key: "state",
64
+ ref: state
65
+ }, unref(checkbox).parts.state()), null, 16),
66
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(checkbox).parts.container())), [createElementVNode("span", normalizeProps(guardReactiveProps(unref(checkbox).parts.icon())), null, 16)], 16)
67
+ ], 16);
68
+ };
69
+ }
70
+ });
71
+ export { _sfc_main as default };
@@ -1,4 +1,4 @@
1
- import { Fragment, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, ref, renderSlot, toDisplayString, unref, useId, useModel, useSlots, useTemplateRef, watch } from "vue";
1
+ import { Fragment, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, ref, renderSlot, toDisplayString, unref, useId, useModel, useSlots, useTemplateRef, watch, withModifiers } from "vue";
2
2
  import { attachDialog, createDialog } from "@rio-m3e/core";
3
3
  import "@rio-m3e/styles/base/focus-ring.css";
4
4
  import "@rio-m3e/styles/base/reduced-motion.css";
@@ -58,15 +58,24 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
58
58
  onUpdated(() => handle?.update());
59
59
  onBeforeUnmount(() => handle?.detach());
60
60
  return (_ctx, _cache) => {
61
- return openBlock(), createElementBlock("dialog", mergeProps({
61
+ return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" Clicks and presses stay in the dialog, so a card or a row around it doesn't take them. Keys go\n on, for Escape. "), createElementVNode("dialog", mergeProps({
62
62
  ref_key: "root",
63
63
  ref: root
64
- }, unref(dialog).parts.root()), [rendered.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
64
+ }, unref(dialog).parts.root(), {
65
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"])),
66
+ onAuxclick: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"])),
67
+ onDblclick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"])),
68
+ onPointerdown: _cache[3] || (_cache[3] = withModifiers(() => {}, ["stop"])),
69
+ onPointerup: _cache[4] || (_cache[4] = withModifiers(() => {}, ["stop"])),
70
+ onMousedown: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"])),
71
+ onMouseup: _cache[6] || (_cache[6] = withModifiers(() => {}, ["stop"])),
72
+ onContextmenu: _cache[7] || (_cache[7] = withModifiers(() => {}, ["stop"]))
73
+ }), [rendered.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
65
74
  unref(dialog).showsIcon() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(dialog).parts.icon())), [renderSlot(_ctx.$slots, "icon")], 16)) : createCommentVNode("v-if", true),
66
75
  unref(dialog).showsHeadline() ? (openBlock(), createElementBlock("h2", normalizeProps(mergeProps({ key: 1 }, unref(dialog).parts.headline())), toDisplayString(__props.headline), 17)) : createCommentVNode("v-if", true),
67
76
  createElementVNode("div", normalizeProps(guardReactiveProps(unref(dialog).parts.content())), [renderSlot(_ctx.$slots, "default")], 16),
68
77
  unref(dialog).showsActions() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 2 }, unref(dialog).parts.actions())), [renderSlot(_ctx.$slots, "actions")], 16)) : createCommentVNode("v-if", true)
69
- ], 64)) : createCommentVNode("v-if", true)], 16);
78
+ ], 64)) : createCommentVNode("v-if", true)], 16)], 2112);
70
79
  };
71
80
  }
72
81
  });
package/dist/index.d.ts CHANGED
@@ -1,14 +1,18 @@
1
1
  import _default from "./button/Button.vue.js";
2
2
  import _default$1 from "./button-group/ButtonGroup.vue.js";
3
- import _default$2 from "./dialog/Dialog.vue.js";
4
- import _default$3 from "./icon-button/IconButton.vue.js";
5
- import _default$4 from "./menu/Menu.vue.js";
6
- import _default$5 from "./menu/MenuDivider.vue.js";
7
- import _default$6 from "./menu/MenuGroup.vue.js";
8
- import _default$7 from "./menu/MenuItem.vue.js";
9
- import _default$9 from "./menu/SubMenu.vue.js";
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";
10
13
  import { vRipple } from "./ripple/ripple.js";
11
- import _default$8 from "./split-button/SplitButton.vue.js";
12
- import _default$10 from "./switch/Switch.vue.js";
13
- import _default$11 from "./tooltip/Tooltip.vue.js";
14
- export { _default as RioButton, _default$1 as RioButtonGroup, _default$2 as RioDialog, _default$3 as RioIconButton, _default$4 as RioMenu, _default$5 as RioMenuDivider, _default$6 as RioMenuGroup, _default$7 as RioMenuItem, _default$8 as RioSplitButton, _default$9 as RioSubMenu, _default$10 as RioSwitch, _default$11 as RioTooltip, vRipple };
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 };
package/dist/index.js CHANGED
@@ -1,14 +1,18 @@
1
1
  import _sfc_main from "./button/Button.vue.js";
2
2
  import _sfc_main$1 from "./button-group/ButtonGroup.vue.js";
3
- import _sfc_main$2 from "./dialog/Dialog.vue.js";
4
- import _sfc_main$3 from "./icon-button/IconButton.vue.js";
5
- import _sfc_main$4 from "./menu/Menu.vue.js";
6
- import _sfc_main$5 from "./menu/MenuDivider.vue.js";
7
- import _sfc_main$6 from "./menu/MenuGroup.vue.js";
8
- import _sfc_main$7 from "./menu/MenuItem.vue.js";
9
- import _sfc_main$9 from "./menu/SubMenu.vue.js";
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";
10
13
  import { vRipple } from "./ripple/ripple.js";
11
- import _sfc_main$8 from "./split-button/SplitButton.vue.js";
12
- import _sfc_main$10 from "./switch/Switch.vue.js";
13
- import _sfc_main$11 from "./tooltip/Tooltip.vue.js";
14
- export { _sfc_main as RioButton, _sfc_main$1 as RioButtonGroup, _sfc_main$2 as RioDialog, _sfc_main$3 as RioIconButton, _sfc_main$4 as RioMenu, _sfc_main$5 as RioMenuDivider, _sfc_main$6 as RioMenuGroup, _sfc_main$7 as RioMenuItem, _sfc_main$8 as RioSplitButton, _sfc_main$9 as RioSubMenu, _sfc_main$10 as RioSwitch, _sfc_main$11 as RioTooltip, vRipple };
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,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:open": (open: boolean) => any;
23
22
  "update:modelValue": (selected: MenuSelected) => any;
23
+ "update:open": (open: boolean) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
25
- "onUpdate:open"?: ((open: boolean) => any) | undefined;
26
25
  "onUpdate:modelValue"?: ((selected: MenuSelected) => any) | undefined;
26
+ "onUpdate:open"?: ((open: boolean) => 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;
@@ -0,0 +1,11 @@
1
+ import { RadioProps, RadioValue } from "@rio-m3e/core";
2
+ import "@rio-m3e/styles/base/reduced-motion.css";
3
+ import "@rio-m3e/styles/base/ripple.css";
4
+ import "@rio-m3e/styles/radio.css";
5
+ interface Props extends Omit<RadioProps, 'selected'> {
6
+ /** The group's `v-model` takes this value when the radio button is selected. */
7
+ value: RadioValue;
8
+ }
9
+ 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
+ declare const _default: typeof __VLS_export;
11
+ export { _default as default };
@@ -0,0 +1,71 @@
1
+ import { radioGroupKey } from "./context.js";
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";
4
+ import "@rio-m3e/styles/base/reduced-motion.css";
5
+ import "@rio-m3e/styles/base/ripple.css";
6
+ import "@rio-m3e/styles/radio.css";
7
+ // src/radio/Radio.vue
8
+ const _sfc_main = /*@__PURE__*/ defineComponent({
9
+ inheritAttrs: false,
10
+ __name: "Radio",
11
+ props: {
12
+ value: {},
13
+ disabled: { type: Boolean },
14
+ softDisabled: { type: Boolean }
15
+ },
16
+ setup(__props) {
17
+ const group = inject(radioGroupKey);
18
+ if (!group) throw new Error("RioRadio has to be inside a RioRadioGroup.");
19
+ const radio = createRadio({
20
+ props: () => ({
21
+ selected: group.isSelected(__props.value),
22
+ disabled: __props.disabled,
23
+ softDisabled: __props.softDisabled
24
+ }),
25
+ name: group.name,
26
+ value: () => String(__props.value)
27
+ });
28
+ const input = useTemplateRef("input");
29
+ const state = useTemplateRef("state");
30
+ let checkable;
31
+ let ripple;
32
+ let unregister;
33
+ onMounted(() => {
34
+ checkable = attachCheckable(input.value, {
35
+ checked: () => group.isSelected(__props.value),
36
+ blocked: radio.blocked,
37
+ onChange: (checked) => checked && group.select(__props.value)
38
+ });
39
+ unregister = group.register(checkable);
40
+ ripple = attachRipple(input.value, { surface: state.value });
41
+ });
42
+ onUpdated(() => checkable?.sync());
43
+ onBeforeUnmount(() => {
44
+ unregister?.();
45
+ checkable?.detach();
46
+ ripple?.detach();
47
+ });
48
+ return (_ctx, _cache) => {
49
+ return openBlock(), createElementBlock("span", mergeProps(unref(radio).parts.root(), {
50
+ class: _ctx.$attrs.class,
51
+ style: _ctx.$attrs.style
52
+ }), [
53
+ createElementVNode("input", mergeProps({
54
+ ref_key: "input",
55
+ ref: input
56
+ }, {
57
+ ..._ctx.$attrs,
58
+ class: void 0,
59
+ style: void 0,
60
+ ...unref(radio).parts.input()
61
+ }), null, 16),
62
+ createElementVNode("span", mergeProps({
63
+ ref_key: "state",
64
+ ref: state
65
+ }, unref(radio).parts.state()), null, 16),
66
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(radio).parts.icon())), null, 16)
67
+ ], 16);
68
+ };
69
+ }
70
+ });
71
+ export { _sfc_main as default };
@@ -0,0 +1,29 @@
1
+ import { RadioGroupProps, RadioValue } from "@rio-m3e/core";
2
+ import "@rio-m3e/styles/radio.css";
3
+ interface Props extends RadioGroupProps {
4
+ /** The `name` the radio buttons submit their value under. Defaults to a unique one. */
5
+ name?: string;
6
+ }
7
+ type __VLS_Props = Props;
8
+ type __VLS_Slots = {
9
+ /** `RioRadio`s, each in a `<label>` with its text */
10
+ default?: () => unknown;
11
+ };
12
+ type __VLS_ModelProps = {
13
+ /** The selected radio button's value, with `v-model`. */
14
+ modelValue?: RadioValue | undefined;
15
+ };
16
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
17
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ "update:modelValue": (value: RadioValue | undefined) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
+ "onUpdate:modelValue"?: ((value: RadioValue | undefined) => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
23
+ declare const _default: typeof __VLS_export;
24
+ type __VLS_WithSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
29
+ export { _default as default };
@@ -0,0 +1,45 @@
1
+ import { radioGroupKey } from "./context.js";
2
+ import { createElementBlock, defineComponent, mergeModels, mergeProps, nextTick, onBeforeUnmount, onMounted, openBlock, provide, renderSlot, unref, useId, useModel, useTemplateRef, watch } from "vue";
3
+ import { attachRadioGroup, createRadioGroup } from "@rio-m3e/core";
4
+ import "@rio-m3e/styles/radio.css";
5
+ // src/radio/RadioGroup.vue
6
+ const _sfc_main = /*@__PURE__*/ defineComponent({
7
+ __name: "RadioGroup",
8
+ props: /*@__PURE__*/ mergeModels({
9
+ name: {},
10
+ label: {}
11
+ }, {
12
+ "modelValue": {},
13
+ "modelModifiers": {}
14
+ }),
15
+ emits: ["update:modelValue"],
16
+ setup(__props) {
17
+ /** The selected radio button's value, with `v-model`. */
18
+ const model = useModel(__props, "modelValue");
19
+ const group = createRadioGroup({ props: () => ({ label: __props.label }) });
20
+ const id = useId();
21
+ const inputs = /* @__PURE__ */ new Set();
22
+ const resync = () => void nextTick(() => inputs.forEach((input) => input.sync()));
23
+ watch(model, resync);
24
+ provide(radioGroupKey, {
25
+ name: () => __props.name ?? `${id}-radio`,
26
+ isSelected: (value) => model.value === value,
27
+ select: (value) => model.value = value,
28
+ register(input) {
29
+ inputs.add(input);
30
+ return () => inputs.delete(input);
31
+ }
32
+ });
33
+ const root = useTemplateRef("root");
34
+ let handle;
35
+ onMounted(() => handle = attachRadioGroup(root.value));
36
+ onBeforeUnmount(() => handle?.detach());
37
+ return (_ctx, _cache) => {
38
+ return openBlock(), createElementBlock("div", mergeProps({
39
+ ref_key: "root",
40
+ ref: root
41
+ }, unref(group).parts.root(), { onChange: resync }), [renderSlot(_ctx.$slots, "default")], 16);
42
+ };
43
+ }
44
+ });
45
+ export { _sfc_main as default };
@@ -0,0 +1,3 @@
1
+ // src/radio/context.ts
2
+ const radioGroupKey = Symbol("rio-radio-group");
3
+ export { radioGroupKey };
@@ -19,11 +19,11 @@ declare const __VLS_base: import("vue").DefineComponent<SplitButtonProps, {
19
19
  leading: Readonly<import("vue").ShallowRef<HTMLButtonElement | null>>;
20
20
  trailing: Readonly<import("vue").ShallowRef<HTMLButtonElement | null>>;
21
21
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
- "update:open": (open: boolean) => any;
23
22
  click: (event: MouseEvent) => any;
23
+ "update:open": (open: boolean) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<SplitButtonProps> & Readonly<{
25
- "onUpdate:open"?: ((open: boolean) => any) | undefined;
26
25
  onClick?: ((event: MouseEvent) => any) | undefined;
26
+ "onUpdate:open"?: ((open: boolean) => 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;
@@ -0,0 +1,32 @@
1
+ import { TextFieldProps } from "@rio-m3e/core";
2
+ import "@rio-m3e/styles/base/reduced-motion.css";
3
+ import "@rio-m3e/styles/text-field.css";
4
+ type Props = Omit<TextFieldProps, 'value'>;
5
+ type __VLS_Props = Props;
6
+ type __VLS_Slots = {
7
+ /** An icon before the text, such as a search icon */
8
+ 'leading-icon'?: () => unknown;
9
+ /** An icon or an icon button after the text, such as a clear button or an error icon */
10
+ 'trailing-icon'?: () => unknown;
11
+ };
12
+ type __VLS_ModelProps = {
13
+ /**
14
+ * The text in the field, with `v-model`. With `type="number"` it is a number, as Vue's `v-model`
15
+ * on an input makes it.
16
+ */
17
+ modelValue?: string | number;
18
+ };
19
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
20
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
21
+ "update:modelValue": (value: string | number) => any;
22
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
23
+ "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
24
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
26
+ declare const _default: typeof __VLS_export;
27
+ type __VLS_WithSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
32
+ export { _default as default };
@@ -0,0 +1,126 @@
1
+ import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, renderSlot, toDisplayString, unref, useAttrs, useId, useModel, useSlots, useTemplateRef, vModelDynamic, vModelText, withDirectives } from "vue";
2
+ import { attachTextField, createTextField } from "@rio-m3e/core";
3
+ import "@rio-m3e/styles/base/reduced-motion.css";
4
+ import "@rio-m3e/styles/text-field.css";
5
+ // src/text-field/TextField.vue
6
+ const _sfc_main = /*@__PURE__*/ defineComponent({
7
+ inheritAttrs: false,
8
+ __name: "TextField",
9
+ props: /*@__PURE__*/ mergeModels({
10
+ variant: {},
11
+ label: {},
12
+ multiline: { type: Boolean },
13
+ rows: {},
14
+ prefix: {},
15
+ suffix: {},
16
+ supportingText: {},
17
+ error: { type: Boolean },
18
+ errorText: {},
19
+ maxlength: {},
20
+ required: { type: Boolean },
21
+ disabled: { type: Boolean },
22
+ readonly: { type: Boolean }
23
+ }, {
24
+ "modelValue": { default: "" },
25
+ "modelModifiers": {}
26
+ }),
27
+ emits: ["update:modelValue"],
28
+ setup(__props) {
29
+ /**
30
+ * The text in the field, with `v-model`. With `type="number"` it is a number, as Vue's `v-model`
31
+ * on an input makes it.
32
+ */
33
+ const model = useModel(__props, "modelValue");
34
+ const slots = useSlots();
35
+ const id = useId();
36
+ const attrs = useAttrs();
37
+ const field = createTextField({
38
+ props: () => ({
39
+ variant: __props.variant,
40
+ label: __props.label,
41
+ value: String(model.value),
42
+ multiline: __props.multiline,
43
+ rows: __props.rows,
44
+ prefix: __props.prefix,
45
+ suffix: __props.suffix,
46
+ supportingText: __props.supportingText,
47
+ error: __props.error,
48
+ errorText: __props.errorText,
49
+ maxlength: __props.maxlength,
50
+ required: __props.required,
51
+ disabled: __props.disabled,
52
+ readonly: __props.readonly
53
+ }),
54
+ content: () => ({
55
+ leadingIcon: !!slots["leading-icon"],
56
+ trailingIcon: !!slots["trailing-icon"]
57
+ }),
58
+ ids: {
59
+ get input() {
60
+ return typeof attrs.id === "string" && attrs.id ? attrs.id : `${id}-input`;
61
+ },
62
+ prefix: `${id}-prefix`,
63
+ suffix: `${id}-suffix`,
64
+ supportingText: `${id}-supporting`,
65
+ counter: `${id}-counter`
66
+ }
67
+ });
68
+ const container = useTemplateRef("container");
69
+ const input = useTemplateRef("input");
70
+ let handle;
71
+ onMounted(() => handle = attachTextField(container.value, () => input.value));
72
+ onUpdated(() => handle?.update());
73
+ onBeforeUnmount(() => handle?.detach());
74
+ return (_ctx, _cache) => {
75
+ return openBlock(), createElementBlock("div", mergeProps(unref(field).parts.root(), {
76
+ class: _ctx.$attrs.class,
77
+ style: _ctx.$attrs.style
78
+ }), [createElementVNode("div", normalizeProps(guardReactiveProps(unref(field).parts.frame())), [
79
+ unref(field).showsOutline() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.outline())), [
80
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(field).parts.outlineStart())), null, 16),
81
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(field).parts.outlineNotch())), toDisplayString(unref(field).labelText()), 17),
82
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(field).parts.outlineEnd())), null, 16)
83
+ ], 16)) : createCommentVNode("v-if", true),
84
+ unref(field).showsLabel() ? (openBlock(), createElementBlock("label", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.label())), toDisplayString(unref(field).labelText()), 17)) : createCommentVNode("v-if", true),
85
+ createElementVNode("div", mergeProps({
86
+ ref_key: "container",
87
+ ref: container
88
+ }, unref(field).parts.container()), [
89
+ unref(field).showsLeadingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.leadingIcon())), [renderSlot(_ctx.$slots, "leading-icon")], 16)) : createCommentVNode("v-if", true),
90
+ createElementVNode("div", normalizeProps(guardReactiveProps(unref(field).parts.content())), [
91
+ unref(field).showsPrefix() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.prefix())), toDisplayString(__props.prefix), 17)) : createCommentVNode("v-if", true),
92
+ createCommentVNode(" v-model, not :value and @input: it waits for an IME to finish composing. "),
93
+ unref(field).singleLine() ? withDirectives((openBlock(), createElementBlock("input", mergeProps({
94
+ key: 1,
95
+ ref_key: "input",
96
+ ref: input,
97
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event)
98
+ }, {
99
+ ..._ctx.$attrs,
100
+ class: void 0,
101
+ style: void 0,
102
+ ...unref(field).parts.input()
103
+ }), null, 16)), [[vModelDynamic, model.value]]) : withDirectives((openBlock(), createElementBlock("textarea", mergeProps({
104
+ key: 2,
105
+ ref_key: "input",
106
+ ref: input,
107
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => model.value = $event)
108
+ }, {
109
+ ..._ctx.$attrs,
110
+ class: void 0,
111
+ style: void 0,
112
+ ...unref(field).parts.textarea()
113
+ }), null, 16)), [[vModelText, model.value]]),
114
+ unref(field).showsSuffix() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 3 }, unref(field).parts.suffix())), toDisplayString(__props.suffix), 17)) : createCommentVNode("v-if", true)
115
+ ], 16),
116
+ unref(field).showsTrailingIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.trailingIcon())), [renderSlot(_ctx.$slots, "trailing-icon")], 16)) : createCommentVNode("v-if", true)
117
+ ], 16)
118
+ ], 16), unref(field).showsSupporting() ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, unref(field).parts.supporting())), [
119
+ createCommentVNode(" A new element for the error text, so it arrives with its alert role. "),
120
+ unref(field).showsSupportingText() ? (openBlock(), createElementBlock("span", mergeProps({ key: unref(field).showsErrorText() ? "error" : "supporting" }, unref(field).parts.supportingText()), toDisplayString(unref(field).supportingTextNow()), 17)) : createCommentVNode("v-if", true),
121
+ unref(field).showsCounter() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(field).parts.counter())), toDisplayString(unref(field).counterText()), 17)) : createCommentVNode("v-if", true)
122
+ ], 16)) : createCommentVNode("v-if", true)], 16);
123
+ };
124
+ }
125
+ });
126
+ export { _sfc_main as default };
@@ -1,4 +1,4 @@
1
- import { createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, renderSlot, toDisplayString, unref, useId, useModel, useSlots, useTemplateRef, watch } from "vue";
1
+ import { createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, onBeforeUnmount, onMounted, onUpdated, openBlock, renderSlot, toDisplayString, unref, useId, useModel, useSlots, useTemplateRef, watch, withModifiers } from "vue";
2
2
  import { attachTooltip, createTooltip } from "@rio-m3e/core";
3
3
  import "@rio-m3e/styles/base/reduced-motion.css";
4
4
  import "@rio-m3e/styles/base/anchored-position.css";
@@ -68,14 +68,27 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
68
68
  return openBlock(), createElementBlock("span", mergeProps({
69
69
  ref_key: "trigger",
70
70
  ref: trigger
71
- }, unref(tooltip).parts.trigger()), [renderSlot(_ctx.$slots, "default"), createElementVNode("span", mergeProps({
72
- ref_key: "root",
73
- ref: root
74
- }, unref(tooltip).parts.root()), [
75
- unref(tooltip).showsSubhead() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(tooltip).parts.subhead())), toDisplayString(__props.subhead), 17)) : createCommentVNode("v-if", true),
76
- createElementVNode("span", normalizeProps(guardReactiveProps(unref(tooltip).parts.supportingText())), [renderSlot(_ctx.$slots, "content", {}, () => [createTextVNode(toDisplayString(__props.text), 1)])], 16),
77
- unref(tooltip).showsActions() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(tooltip).parts.actions())), [renderSlot(_ctx.$slots, "actions")], 16)) : createCommentVNode("v-if", true)
78
- ], 16)], 16);
71
+ }, unref(tooltip).parts.trigger()), [
72
+ renderSlot(_ctx.$slots, "default"),
73
+ createCommentVNode(" Clicks and presses stay in the tooltip, so a card or a row around its element doesn't take\n them. Keys go on, for Escape. "),
74
+ createElementVNode("span", mergeProps({
75
+ ref_key: "root",
76
+ ref: root
77
+ }, unref(tooltip).parts.root(), {
78
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"])),
79
+ onAuxclick: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"])),
80
+ onDblclick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"])),
81
+ onPointerdown: _cache[3] || (_cache[3] = withModifiers(() => {}, ["stop"])),
82
+ onPointerup: _cache[4] || (_cache[4] = withModifiers(() => {}, ["stop"])),
83
+ onMousedown: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"])),
84
+ onMouseup: _cache[6] || (_cache[6] = withModifiers(() => {}, ["stop"])),
85
+ onContextmenu: _cache[7] || (_cache[7] = withModifiers(() => {}, ["stop"]))
86
+ }), [
87
+ unref(tooltip).showsSubhead() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, unref(tooltip).parts.subhead())), toDisplayString(__props.subhead), 17)) : createCommentVNode("v-if", true),
88
+ createElementVNode("span", normalizeProps(guardReactiveProps(unref(tooltip).parts.supportingText())), [renderSlot(_ctx.$slots, "content", {}, () => [createTextVNode(toDisplayString(__props.text), 1)])], 16),
89
+ unref(tooltip).showsActions() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(tooltip).parts.actions())), [renderSlot(_ctx.$slots, "actions")], 16)) : createCommentVNode("v-if", true)
90
+ ], 16)
91
+ ], 16);
79
92
  };
80
93
  }
81
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rio-m3e/vue",
3
- "version": "0.3.0",
3
+ "version": "0.4.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.3.0",
31
- "@rio-m3e/styles": "^0.3.0"
30
+ "@rio-m3e/core": "^0.4.0",
31
+ "@rio-m3e/styles": "^0.4.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@fontsource/roboto": "^5.3.0",
35
35
  "@mdi/js": "^7.4.47",
36
36
  "@rio-m3e/testing": "^0.0.0",
37
- "@rio-m3e/tokens": "^0.3.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",