@mittwald/flow-react-components 0.1.0-alpha.76 → 0.1.0-alpha.77

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,50 +1,50 @@
1
1
  "use client"
2
2
  /* */
3
3
  var S = Object.defineProperty;
4
- var b = (e, t, o) => t in e ? S(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
5
- var r = (e, t, o) => (b(e, typeof t != "symbol" ? t + "" : t, o), o);
6
- import A, { useRef as M } from "react";
4
+ var A = (e, t, o) => t in e ? S(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
5
+ var d = (e, t, o) => (A(e, typeof t != "symbol" ? t + "" : t, o), o);
6
+ import b, { useRef as M } from "react";
7
7
  import "./propsContext-CauylOgH.js";
8
- import { P } from "./PropsContextProvider-DZvwqHLP.js";
8
+ import { P as y } from "./PropsContextProvider-DZvwqHLP.js";
9
9
  import "@react-aria/utils";
10
10
  import "remeda";
11
11
  import "dot-prop";
12
- import { u as C } from "./useProps-Dx3m8kCJ.js";
13
- import { u as F } from "./index-ViVxK7d1.js";
14
- import { makeObservable as k, observable as y, runInAction as x } from "mobx";
12
+ import { u as P } from "./useProps-Dx3m8kCJ.js";
13
+ import { u as C } from "./index-ViVxK7d1.js";
14
+ import { makeObservable as F, observable as k, runInAction as x } from "mobx";
15
15
  import { u as I } from "./useSelector-DpU7_HMO.js";
16
16
  const v = () => {
17
17
  }, w = (e) => {
18
- const t = F();
18
+ const t = C();
19
19
  return (e == null ? void 0 : e.type) === "function" ? e.fn : (e == null ? void 0 : e.type) === "toggleModal" ? t.toggle : (e == null ? void 0 : e.type) === "openModal" ? t.open : (e == null ? void 0 : e.type) === "closeModal" ? t.close : v;
20
- }, m = (e, t) => {
20
+ }, g = (e, t) => {
21
21
  const o = [...t];
22
22
  let s;
23
23
  for (; o.length > 0; )
24
24
  if (s = o.shift(), s) {
25
25
  const i = s(...e);
26
26
  if (i instanceof Promise)
27
- return i.then(() => m(e, o));
27
+ return i.then(() => g(e, o));
28
28
  }
29
29
  }, p = {
30
30
  pending: 1e3,
31
31
  succeeded: 1500,
32
32
  failed: 2e3
33
33
  };
34
- class h {
34
+ class f {
35
35
  constructor(t = {}) {
36
- r(this, "feedback");
37
- r(this, "executionCount", 0);
38
- r(this, "state", "isIdle");
36
+ d(this, "feedback");
37
+ d(this, "executionCount", 0);
38
+ d(this, "state", "isIdle");
39
39
  const { feedback: o = !1 } = t;
40
- this.feedback = o, k(this, {
41
- state: y
40
+ this.feedback = o, F(this, {
41
+ state: k
42
42
  });
43
43
  }
44
44
  static useNew(t) {
45
- return M(new h(t)).current;
45
+ return M(new f(t)).current;
46
46
  }
47
- onStart() {
47
+ onAsyncStart() {
48
48
  const t = ++this.executionCount;
49
49
  this.updateState("isExecuting"), setTimeout(() => this.startPending(t), p.pending);
50
50
  }
@@ -60,31 +60,34 @@ class h {
60
60
  });
61
61
  }
62
62
  startFailedFeedback() {
63
- this.feedback && (this.updateState("isFailed"), setTimeout(() => this.updateState("isIdle"), p.failed));
63
+ this.updateState("isFailed"), setTimeout(() => this.updateState("isIdle"), p.failed);
64
64
  }
65
65
  startSucceededFeedback() {
66
- this.feedback && (this.updateState("isSucceeded"), setTimeout(() => this.updateState("isIdle"), p.succeeded));
66
+ this.updateState("isSucceeded"), setTimeout(() => this.updateState("isIdle"), p.succeeded);
67
67
  }
68
68
  onDone(t) {
69
+ if (!this.feedback) {
70
+ this.updateState("isIdle");
71
+ return;
72
+ }
69
73
  t ? this.startSucceededFeedback() : this.startFailedFeedback();
70
74
  }
71
75
  startPending(t) {
72
- this.state !== "isIdle" && t === this.executionCount && this.updateState("isPending");
76
+ this.state === "isExecuting" && t === this.executionCount && this.updateState("isPending");
73
77
  }
74
78
  useState() {
75
79
  return I(() => this.state, [this]);
76
80
  }
77
81
  }
78
82
  const W = (e, t) => {
79
- const { action: o } = C("Action", {}), s = w(e), i = (...c) => m(c, [s, o]), n = h.useNew(t);
83
+ const { action: o } = P("Action", {}), s = w(e), i = (...c) => g(c, [s, o]), n = f.useNew(t);
80
84
  return {
81
85
  callAction: i,
82
86
  callActionWithStateHandling: (...c) => {
83
87
  try {
84
- n.onStart();
85
88
  const a = i(...c);
86
89
  if (a instanceof Promise)
87
- return a.then(() => n.onSucceeded()).catch(() => n.onFailed());
90
+ return n.onAsyncStart(), a.then(() => n.onSucceeded()).catch(() => n.onFailed());
88
91
  n.onSucceeded();
89
92
  } catch {
90
93
  n.onFailed();
@@ -93,25 +96,25 @@ const W = (e, t) => {
93
96
  state: n
94
97
  };
95
98
  };
96
- function f(e) {
99
+ function h(e) {
97
100
  return typeof e == "boolean" ? void 0 : e;
98
101
  }
99
- const d = {
102
+ const r = {
100
103
  fn: (e) => ({
101
104
  type: "function",
102
105
  fn: e
103
106
  }),
104
107
  openModal: (e) => ({
105
108
  type: "openModal",
106
- controller: f(e)
109
+ controller: h(e)
107
110
  }),
108
111
  closeModal: (e) => ({
109
112
  type: "closeModal",
110
- controller: f(e)
113
+ controller: h(e)
111
114
  }),
112
115
  toggleModal: (e) => ({
113
116
  type: "toggleModal",
114
- controller: f(e)
117
+ controller: h(e)
115
118
  })
116
119
  }, G = (e) => {
117
120
  const {
@@ -121,9 +124,9 @@ const d = {
121
124
  toggleModal: i,
122
125
  openModal: n,
123
126
  closeModal: u
124
- } = e, c = s ? d.fn(s) : i ? d.toggleModal(i) : n ? d.openModal(n) : u ? d.closeModal(u) : void 0, a = W(c, {
127
+ } = e, c = s ? r.fn(s) : i ? r.toggleModal(i) : n ? r.openModal(n) : u ? r.closeModal(u) : void 0, a = W(c, {
125
128
  feedback: o
126
- }), l = a.state.useState(), g = {
129
+ }), l = a.state.useState(), m = {
127
130
  Button: {
128
131
  onPress: a.callActionWithStateHandling,
129
132
  isPending: l === "isPending",
@@ -135,11 +138,11 @@ const d = {
135
138
  action: a.callAction
136
139
  }
137
140
  };
138
- return /* @__PURE__ */ A.createElement(
139
- P,
141
+ return /* @__PURE__ */ b.createElement(
142
+ y,
140
143
  {
141
144
  mergeInParentContext: !0,
142
- props: g,
145
+ props: m,
143
146
  dependencies: [l]
144
147
  },
145
148
  t
package/dist/Action.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
  /* */
3
- import { A as t } from "./Action-DFbRza4T.js";
3
+ import { A as t } from "./Action-DdvvHPkT.js";
4
4
  export {
5
5
  t as Action,
6
6
  t as default
@@ -15,7 +15,7 @@ import "@react-aria/utils";
15
15
  import "remeda";
16
16
  import "dot-prop";
17
17
  import { f as C } from "./flowComponent-BuF0s2uG.js";
18
- import { A as E } from "./Action-DFbRza4T.js";
18
+ import { A as E } from "./Action-DdvvHPkT.js";
19
19
  const B = {
20
20
  "de-DE": {
21
21
  "copyButton.copy": "Kopieren"