@effect-app/vue-components 4.0.0-beta.181 → 4.0.0-beta.183

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,5 @@
1
- import type { CommandBase } from "@effect-app/vue";
1
+ import type { CommandBase, Progress } from "@effect-app/vue";
2
+ import type * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
2
3
  import type { VBtn } from "vuetify/components";
3
4
  export type VBtnProps = VBtn["$props"];
4
5
  export interface ButtonProps extends /* @vue-ignore */ VBtnProps {
@@ -18,6 +19,7 @@ declare const __VLS_export: <I = never>(__VLS_props: NonNullable<Awaited<typeof
18
19
  }) & {
19
20
  disabled?: ButtonProps["disabled"];
20
21
  title?: string;
22
+ mapProgress?: (result: AsyncResult.AsyncResult<any, any>) => Progress | undefined;
21
23
  } & ButtonProps> & (typeof globalThis extends {
22
24
  __VLS_PROPS_FALLBACK: infer P;
23
25
  } ? P : {});
@@ -7,28 +7,35 @@ var m = { class: "ml-2" }, h = { class: "ml-2" }, g = /* @__PURE__ */ s({
7
7
  command: {},
8
8
  empty: { type: Boolean },
9
9
  disabled: {},
10
- title: {}
10
+ title: {},
11
+ mapProgress: { type: Function }
11
12
  },
12
13
  setup(s) {
13
14
  let g = s, _ = e(() => g.command.blocked || g.disabled), v = e(() => {
14
- let e = g.command.progress;
15
- if (e !== void 0) return typeof e == "string" ? e : e.text;
15
+ if (g.mapProgress) {
16
+ let e = g.command.result;
17
+ return e === void 0 ? void 0 : g.mapProgress(e);
18
+ }
19
+ return g.command.progress;
16
20
  }), y = e(() => {
17
- let e = g.command.progress;
21
+ let e = v.value;
22
+ if (e !== void 0) return typeof e == "string" ? e : e.text;
23
+ }), b = e(() => {
24
+ let e = v.value;
18
25
  return typeof e == "object" && e ? e.percentage : void 0;
19
- }), b = () => {
26
+ }), x = () => {
20
27
  if (_.value) return;
21
28
  let e = "input" in g && g.input ? g.input : void 0, t = g.command.handle;
22
29
  t(e);
23
30
  };
24
31
  return (e, g) => {
25
- let x = d("v-progress-circular"), S = d("v-btn");
32
+ let v = d("v-progress-circular"), S = d("v-btn");
26
33
  return s.command.allowed && !s.empty ? (l(), t(S, c({ key: 0 }, e.$attrs, {
27
34
  loading: s.command.waiting,
28
35
  "aria-disabled": _.value,
29
36
  title: s.title ?? s.command.action,
30
37
  class: { "v-btn--disabled": _.value },
31
- onClick: b
38
+ onClick: x
32
39
  }), i({
33
40
  default: p(() => [u(e.$slots, "default", {
34
41
  loading: s.command.waiting,
@@ -37,14 +44,14 @@ var m = { class: "ml-2" }, h = { class: "ml-2" }, g = /* @__PURE__ */ s({
37
44
  title: s.title ?? s.command.action
38
45
  }, () => [a(f(s.command.label), 1)])]),
39
46
  _: 2
40
- }, [v.value === void 0 ? void 0 : {
47
+ }, [y.value === void 0 ? void 0 : {
41
48
  name: "loader",
42
- fn: p(() => [o(x, {
43
- indeterminate: y.value === void 0,
44
- "model-value": y.value,
49
+ fn: p(() => [o(v, {
50
+ indeterminate: b.value === void 0,
51
+ "model-value": b.value,
45
52
  size: "20",
46
53
  width: "2"
47
- }, null, 8, ["indeterminate", "model-value"]), r("span", m, f(v.value), 1)]),
54
+ }, null, 8, ["indeterminate", "model-value"]), r("span", m, f(y.value), 1)]),
48
55
  key: "0"
49
56
  }]), 1040, [
50
57
  "loading",
@@ -56,15 +63,15 @@ var m = { class: "ml-2" }, h = { class: "ml-2" }, g = /* @__PURE__ */ s({
56
63
  "aria-disabled": _.value,
57
64
  title: s.title ?? s.command.action,
58
65
  class: { "v-btn--disabled": _.value },
59
- onClick: b
60
- }), i({ _: 2 }, [v.value === void 0 ? void 0 : {
66
+ onClick: x
67
+ }), i({ _: 2 }, [y.value === void 0 ? void 0 : {
61
68
  name: "loader",
62
- fn: p(() => [o(x, {
63
- indeterminate: y.value === void 0,
64
- "model-value": y.value,
69
+ fn: p(() => [o(v, {
70
+ indeterminate: b.value === void 0,
71
+ "model-value": b.value,
65
72
  size: "20",
66
73
  width: "2"
67
- }, null, 8, ["indeterminate", "model-value"]), r("span", h, f(v.value), 1)]),
74
+ }, null, 8, ["indeterminate", "model-value"]), r("span", h, f(y.value), 1)]),
68
75
  key: "0"
69
76
  }]), 1040, [
70
77
  "loading",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "4.0.0-beta.181",
3
+ "version": "4.0.0-beta.183",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^4.0.0-beta.59",
@@ -57,8 +57,8 @@
57
57
  "highlight.js": "^11.11.1",
58
58
  "mitt": "^3.0.1",
59
59
  "vue3-highlightjs": "^1.0.5",
60
- "@effect-app/vue": "4.0.0-beta.181",
61
- "effect-app": "4.0.0-beta.181"
60
+ "@effect-app/vue": "4.0.0-beta.183",
61
+ "effect-app": "4.0.0-beta.183"
62
62
  },
63
63
  "scripts": {
64
64
  "check": "vue-tsc",
@@ -3,7 +3,8 @@
3
3
  lang="ts"
4
4
  generic="I = never"
5
5
  >
6
- import type { CommandBase } from "@effect-app/vue"
6
+ import type { CommandBase, Progress } from "@effect-app/vue"
7
+ import type * as AsyncResult from "effect/unstable/reactivity/AsyncResult"
7
8
  import { computed } from "vue"
8
9
  import type { VBtn } from "vuetify/components"
9
10
 
@@ -26,20 +27,29 @@ const props = defineProps<
26
27
  & {
27
28
  disabled?: ButtonProps["disabled"]
28
29
  title?: string // why isn't it part of VBtnProps??
30
+ mapProgress?: (result: AsyncResult.AsyncResult<any, any>) => Progress | undefined
29
31
  }
30
32
  & ButtonProps
31
33
  >()
32
34
 
33
35
  const isDisabled = computed(() => props.command.blocked || props.disabled)
34
36
 
37
+ const resolvedProgress = computed(() => {
38
+ if (props.mapProgress) {
39
+ const result = props.command.result
40
+ return result !== undefined ? props.mapProgress(result) : undefined
41
+ }
42
+ return props.command.progress
43
+ })
44
+
35
45
  const progressText = computed(() => {
36
- const p = props.command.progress
46
+ const p = resolvedProgress.value
37
47
  if (p === undefined) return undefined
38
48
  return typeof p === "string" ? p : p.text
39
49
  })
40
50
 
41
51
  const progressPercentage = computed(() => {
42
- const p = props.command.progress
52
+ const p = resolvedProgress.value
43
53
  return typeof p === "object" && p !== null ? p.percentage : undefined
44
54
  })
45
55