@drawbridge/components 0.1.16 → 0.1.17

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.
@@ -43,10 +43,10 @@ var import_missions = require("@drawbridge/drawbridge-utils/missions");
43
43
  var import_button = __toESM(require("../shared/button"));
44
44
  var import_copy_to_clipboard = __toESM(require("../shared/copy-to-clipboard"));
45
45
  var import_error = __toESM(require("../shared/error"));
46
+ var import_form = __toESM(require("../shared/form"));
46
47
  var import_check = __toESM(require("../icons/check"));
47
48
  var import_chevron_left = __toESM(require("../icons/chevron-left"));
48
49
  var import_chevron_right = __toESM(require("../icons/chevron-right"));
49
- var import_loader = __toESM(require("../icons/loader"));
50
50
  var import_input_group = __toESM(require("../input-group"));
51
51
  var import_input_code = __toESM(require("../input-code"));
52
52
  var import_share_button = __toESM(require("./share-button"));
@@ -131,29 +131,54 @@ const Strong = ({ children, className }) => /* @__PURE__ */ (0, import_jsx_runti
131
131
  children
132
132
  }
133
133
  );
134
- const CodeStep = ({ disabled, error, onComplete, style }) => {
134
+ const CodeStep = ({ busy, error, onSubmit, style }) => {
135
135
  const [code, setCode] = (0, import_react.useState)("");
136
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
- import_input_group.default,
136
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
137
+ import_form.default,
138
138
  {
139
139
  ...{
140
- error,
141
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
- import_input_code.default,
140
+ className: "space-y-6",
141
+ onSubmit: (event) => {
142
+ event.preventDefault();
143
+ onSubmit(code);
144
+ }
145
+ },
146
+ children: [
147
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
148
+ import_input_group.default,
143
149
  {
144
150
  ...{
145
- autoFocus: true,
146
- disabled,
147
- onChange: setCode,
148
- onComplete,
149
- style,
150
- value: code
151
+ error,
152
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
+ import_input_code.default,
154
+ {
155
+ ...{
156
+ autoFocus: true,
157
+ disabled: busy,
158
+ onChange: setCode,
159
+ style,
160
+ value: code
161
+ }
162
+ }
163
+ ),
164
+ label: "Verification code",
165
+ style
151
166
  }
152
167
  }
153
168
  ),
154
- label: "Verification code",
155
- style
156
- }
169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
170
+ import_button.default,
171
+ {
172
+ ...{
173
+ disabled: code.length !== 6,
174
+ loading: busy,
175
+ style,
176
+ type: "submit"
177
+ },
178
+ children: "Confirm"
179
+ }
180
+ )
181
+ ]
157
182
  }
158
183
  );
159
184
  };
@@ -288,30 +313,14 @@ const FormSubdomainMissions = ({
288
313
  CodeStep,
289
314
  {
290
315
  ...{
291
- disabled: busy,
316
+ busy,
292
317
  error,
293
- onComplete: confirm,
318
+ onSubmit: confirm,
294
319
  style
295
320
  }
296
321
  },
297
322
  attempt
298
323
  ),
299
- busy && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
300
- "div",
301
- {
302
- ...{
303
- className: "flex justify-center"
304
- },
305
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
306
- import_loader.default,
307
- {
308
- ...{
309
- className: "w-5 h-5 animate-spin"
310
- }
311
- }
312
- )
313
- }
314
- ),
315
324
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
316
325
  "p",
317
326
  {
@@ -6,10 +6,10 @@ import { CODE_CHANNELS, COMPLETIONS, entriesText, missions as manifests } from "
6
6
  import Button from "../shared/button.mjs";
7
7
  import CopyToClipboard from "../shared/copy-to-clipboard.mjs";
8
8
  import Error from "../shared/error.mjs";
9
+ import Form from "../shared/form.mjs";
9
10
  import Check from "../icons/check.mjs";
10
11
  import ChevronLeft from "../icons/chevron-left.mjs";
11
12
  import ChevronRight from "../icons/chevron-right.mjs";
12
- import Loader from "../icons/loader.mjs";
13
13
  import InputGroup from "../input-group.mjs";
14
14
  import InputCode from "../input-code.mjs";
15
15
  import ShareButton from "./share-button.mjs";
@@ -94,29 +94,54 @@ const Strong = ({ children, className }) => /* @__PURE__ */ jsx(
94
94
  children
95
95
  }
96
96
  );
97
- const CodeStep = ({ disabled, error, onComplete, style }) => {
97
+ const CodeStep = ({ busy, error, onSubmit, style }) => {
98
98
  const [code, setCode] = useState("");
99
- return /* @__PURE__ */ jsx(
100
- InputGroup,
99
+ return /* @__PURE__ */ jsxs(
100
+ Form,
101
101
  {
102
102
  ...{
103
- error,
104
- input: /* @__PURE__ */ jsx(
105
- InputCode,
103
+ className: "space-y-6",
104
+ onSubmit: (event) => {
105
+ event.preventDefault();
106
+ onSubmit(code);
107
+ }
108
+ },
109
+ children: [
110
+ /* @__PURE__ */ jsx(
111
+ InputGroup,
106
112
  {
107
113
  ...{
108
- autoFocus: true,
109
- disabled,
110
- onChange: setCode,
111
- onComplete,
112
- style,
113
- value: code
114
+ error,
115
+ input: /* @__PURE__ */ jsx(
116
+ InputCode,
117
+ {
118
+ ...{
119
+ autoFocus: true,
120
+ disabled: busy,
121
+ onChange: setCode,
122
+ style,
123
+ value: code
124
+ }
125
+ }
126
+ ),
127
+ label: "Verification code",
128
+ style
114
129
  }
115
130
  }
116
131
  ),
117
- label: "Verification code",
118
- style
119
- }
132
+ /* @__PURE__ */ jsx(
133
+ Button,
134
+ {
135
+ ...{
136
+ disabled: code.length !== 6,
137
+ loading: busy,
138
+ style,
139
+ type: "submit"
140
+ },
141
+ children: "Confirm"
142
+ }
143
+ )
144
+ ]
120
145
  }
121
146
  );
122
147
  };
@@ -251,30 +276,14 @@ const FormSubdomainMissions = ({
251
276
  CodeStep,
252
277
  {
253
278
  ...{
254
- disabled: busy,
279
+ busy,
255
280
  error,
256
- onComplete: confirm,
281
+ onSubmit: confirm,
257
282
  style
258
283
  }
259
284
  },
260
285
  attempt
261
286
  ),
262
- busy && /* @__PURE__ */ jsx(
263
- "div",
264
- {
265
- ...{
266
- className: "flex justify-center"
267
- },
268
- children: /* @__PURE__ */ jsx(
269
- Loader,
270
- {
271
- ...{
272
- className: "w-5 h-5 animate-spin"
273
- }
274
- }
275
- )
276
- }
277
- ),
278
287
  /* @__PURE__ */ jsxs(
279
288
  "p",
280
289
  {
@@ -64,7 +64,7 @@ const FormOrganizationCampaignAgreement = ({
64
64
  params
65
65
  }) => {
66
66
  const ids = Object.keys(agreements);
67
- const { control, handleSubmit, formState, reset } = (0, import_form.useForm)({
67
+ const { control, getValues, handleSubmit, formState, reset } = (0, import_form.useForm)({
68
68
  defaultValues: Object.fromEntries(ids.map((id) => {
69
69
  var _a;
70
70
  return [id, ((_a = agreements[id]) == null ? void 0 : _a.values) || {}];
@@ -106,7 +106,7 @@ const FormOrganizationCampaignAgreement = ({
106
106
  });
107
107
  }
108
108
  ;
109
- reset(values);
109
+ reset(getValues());
110
110
  if (response) onSuccess(response);
111
111
  } catch (error) {
112
112
  onError(error);
@@ -32,7 +32,7 @@ const FormOrganizationCampaignAgreement = ({
32
32
  params
33
33
  }) => {
34
34
  const ids = Object.keys(agreements);
35
- const { control, handleSubmit, formState, reset } = useForm({
35
+ const { control, getValues, handleSubmit, formState, reset } = useForm({
36
36
  defaultValues: Object.fromEntries(ids.map((id) => {
37
37
  var _a;
38
38
  return [id, ((_a = agreements[id]) == null ? void 0 : _a.values) || {}];
@@ -74,7 +74,7 @@ const FormOrganizationCampaignAgreement = ({
74
74
  });
75
75
  }
76
76
  ;
77
- reset(values);
77
+ reset(getValues());
78
78
  if (response) onSuccess(response);
79
79
  } catch (error) {
80
80
  onError(error);