@nexdom/uimed-vue 2.0.0-beta.43 → 2.0.0-beta.44

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.
@@ -1,4 +1,4 @@
1
- import { t as ButtonProps } from "./types-CjaJ2WAC.js";
1
+ import { t as ButtonProps } from "./types-BbWo6RIy.js";
2
2
  import { RouteLocationRaw } from "vue-router";
3
3
  //#region src/components/app-bar/types.d.ts
4
4
  /**
@@ -463,8 +463,8 @@ declare const __VLS_export$16: import("vue", { with: { "resolution-mode": "impor
463
463
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
464
464
  }>, {
465
465
  variant: TextFieldVariant;
466
- clearable: boolean;
467
466
  type: TextFieldType;
467
+ clearable: boolean;
468
468
  }, {}, {}, {}, string, import("vue", { with: { "resolution-mode": "import" } }).ComponentProvideOptions, false, {}, any>;
469
469
  //#endregion
470
470
  //#region src/components/inputs/checkbox/types.d.ts
@@ -924,13 +924,31 @@ function useButtonVariant(variant) {
924
924
  return variantValue ? buttonVariantToVuetifyVariant[variantValue] : buttonVariantToVuetifyVariant.primary;
925
925
  });
926
926
  }
927
- function useButtonType(type) {
927
+ /**
928
+ * The route the button navigates to, or `undefined` while it's blocked, so a `disabled` or
929
+ * `loading` button is rendered as a disabled `<button>` instead of a link that the keyboard,
930
+ * assistive technologies or `element.click()` could still follow.
931
+ */
932
+ function useButtonRoute(route, blocked) {
933
+ return computed(() => toValue(blocked) ? void 0 : toValue(route));
934
+ }
935
+ /**
936
+ * The button's `type`. It doesn't apply to a button with a `route`, which is `undefined` while
937
+ * rendered as a link, and `"button"` while blocked, so the disabled `<button>` it's rendered as
938
+ * isn't a submit button.
939
+ */
940
+ function useButtonType(type, route, blocked) {
928
941
  return computed(() => {
929
- return toValue(type) ?? "button";
942
+ if (!toValue(route)) return toValue(type) ?? "button";
943
+ return toValue(blocked) ? "button" : void 0;
930
944
  });
931
945
  }
932
- function useButtonForm(form) {
933
- return computed(() => toValue(form));
946
+ /**
947
+ * The button's `form`, or `undefined` when it has a `route`, even while blocked, since `form`
948
+ * doesn't apply to it.
949
+ */
950
+ function useButtonForm(form, route) {
951
+ return computed(() => toValue(route) ? void 0 : toValue(form));
934
952
  }
935
953
  //#endregion
936
954
  //#region src/components/button/button.vue
@@ -966,6 +984,10 @@ var button_default = /* @__PURE__ */ defineComponent({
966
984
  type: String,
967
985
  required: false
968
986
  },
987
+ route: {
988
+ type: null,
989
+ required: false
990
+ },
969
991
  dataTestid: {
970
992
  type: String,
971
993
  required: false
@@ -977,15 +999,16 @@ var button_default = /* @__PURE__ */ defineComponent({
977
999
  const emit = __emit;
978
1000
  const variant = useButtonVariant(() => props.variant);
979
1001
  const color = useVuetifyColor(() => props.color);
980
- const type = useButtonType(() => props.type);
981
- const form = useButtonForm(() => props.form);
982
1002
  const widthClass = useFullWidth(() => props.fullWidth);
983
1003
  const isDisabled = computed(() => props.disabled || props.loading);
1004
+ const routeProps = useRouteProps(useButtonRoute(() => props.route, isDisabled));
1005
+ const type = useButtonType(() => props.type, () => props.route, isDisabled);
1006
+ const form = useButtonForm(() => props.form, () => props.route);
984
1007
  function onClick(event) {
985
1008
  emit("click", event);
986
1009
  }
987
1010
  return (_ctx, _cache) => {
988
- return openBlock(), createBlock(unref(VBtn), {
1011
+ return openBlock(), createBlock(unref(VBtn), mergeProps({
989
1012
  disabled: isDisabled.value,
990
1013
  loading: props.loading,
991
1014
  "data-testid": props.dataTestid,
@@ -993,9 +1016,11 @@ var button_default = /* @__PURE__ */ defineComponent({
993
1016
  color: unref(color),
994
1017
  type: unref(type),
995
1018
  form: unref(form),
996
- class: normalizeClass(unref(widthClass)),
1019
+ class: unref(widthClass)
1020
+ }, unref(routeProps), {
1021
+ active: false,
997
1022
  onClick
998
- }, {
1023
+ }), {
999
1024
  loader: withCtx(() => [createVNode(unref(VProgressCircular), {
1000
1025
  indeterminate: "",
1001
1026
  width: "2",
@@ -1003,7 +1028,7 @@ var button_default = /* @__PURE__ */ defineComponent({
1003
1028
  })]),
1004
1029
  default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
1005
1030
  _: 3
1006
- }, 8, [
1031
+ }, 16, [
1007
1032
  "disabled",
1008
1033
  "loading",
1009
1034
  "data-testid",
@@ -1,4 +1,4 @@
1
- import { i as FeedbackColorVariant, n as ButtonVariant, r as ColorVariant } from "./types-CjaJ2WAC.js";
1
+ import { i as FeedbackColorVariant, n as ButtonVariant, r as ColorVariant } from "./types-BbWo6RIy.js";
2
2
  import { ComputedRef, MaybeRefOrGetter } from "vue";
3
3
  //#region src/composables/dialogs/types.d.ts
4
4
  interface ToastOptions {
@@ -1,3 +1,4 @@
1
+ import { RouteLocationRaw } from "vue-router";
1
2
  //#region src/composables/colors/types.d.ts
2
3
  type ColorVariant = "primary" | "secondary" | FeedbackColorVariant;
3
4
  type FeedbackColorVariant = "positive" | "informative" | "caution" | "danger";
@@ -16,7 +17,7 @@ type ButtonProps = {
16
17
  variant?: ButtonVariant;
17
18
  /**
18
19
  * Applies a distinct behavior to the button.
19
- * One of `button` or `submit`.
20
+ * One of `button` or `submit`. Ignored when `route` is set.
20
21
  * @default "button"
21
22
  */
22
23
  type?: "submit" | "button";
@@ -49,8 +50,16 @@ type ButtonProps = {
49
50
  fullWidth?: boolean;
50
51
  /**
51
52
  * Associated [form](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/form) id.
53
+ * Ignored when `route` is set.
52
54
  */
53
55
  form?: string;
56
+ /**
57
+ * Where the button goes when clicked, rendering it as a link with the button's look. A route
58
+ * inside the app (`"/patients"`, `{ name: "patient", params: { id } }`) navigates through the
59
+ * app's router; a URL starting with `http` navigates through the browser, in the same tab. While
60
+ * `disabled` or `loading`, the button doesn't navigate and is rendered as a disabled button.
61
+ */
62
+ route?: RouteLocationRaw;
54
63
  /**
55
64
  * Component id to use on automated tests.
56
65
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexdom/uimed-vue",
3
- "version": "2.0.0-beta.43",
3
+ "version": "2.0.0-beta.44",
4
4
  "description": "A ui framework for NEXDOM applications.",
5
5
  "keywords": [
6
6
  "lib",