@variamosple/variamos-components 0.4.0 → 0.4.1
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,96 +1,101 @@
|
|
|
1
1
|
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Modal as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { useState as o, useEffect as x } from "react";
|
|
3
|
+
import { Modal as i, Form as r, Alert as k, Button as B } from "react-bootstrap";
|
|
4
|
+
import { bugFormErrors as F, TITLE_MAX_LENGTH as D } from "./bugFormErrors.js";
|
|
5
|
+
const A = ({
|
|
6
|
+
show: c,
|
|
7
|
+
onHide: p,
|
|
8
|
+
onSubmit: N,
|
|
9
|
+
categories: s,
|
|
10
|
+
isSubmitting: u,
|
|
11
|
+
errorMessage: h
|
|
11
12
|
}) => {
|
|
12
|
-
const [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, [
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const [n, m] = o(""), [a, b] = o(""), [g, v] = o(""), [I, f] = o(null), [L, C] = o(!1), d = L ? F({ title: n, description: a }) : {};
|
|
14
|
+
x(() => {
|
|
15
|
+
c && (m(""), b(""), v(s[0] || "Other"), f(null), C(!1));
|
|
16
|
+
}, [c, s]);
|
|
17
|
+
const T = (t) => {
|
|
18
|
+
t.preventDefault(), C(!0);
|
|
19
|
+
const y = F({ title: n, description: a });
|
|
20
|
+
if (y.title || y.description) {
|
|
21
|
+
t.stopPropagation();
|
|
19
22
|
return;
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
N({ title: n, description: a, category: g }, I ?? void 0);
|
|
22
25
|
};
|
|
23
26
|
return /* @__PURE__ */ l(
|
|
24
|
-
|
|
27
|
+
i,
|
|
25
28
|
{
|
|
26
|
-
show:
|
|
27
|
-
onHide:
|
|
29
|
+
show: c,
|
|
30
|
+
onHide: p,
|
|
28
31
|
backdrop: "static",
|
|
29
32
|
keyboard: !1,
|
|
30
33
|
centered: !0,
|
|
31
34
|
children: [
|
|
32
|
-
/* @__PURE__ */ e(
|
|
33
|
-
/* @__PURE__ */ l(
|
|
34
|
-
/* @__PURE__ */ l(
|
|
35
|
-
|
|
36
|
-
/* @__PURE__ */ l(
|
|
37
|
-
/* @__PURE__ */ e(
|
|
35
|
+
/* @__PURE__ */ e(i.Header, { closeButton: !0, children: /* @__PURE__ */ e(i.Title, { children: "Report a New Bug" }) }),
|
|
36
|
+
/* @__PURE__ */ l(r, { noValidate: !0, onSubmit: T, children: [
|
|
37
|
+
/* @__PURE__ */ l(i.Body, { children: [
|
|
38
|
+
h ? /* @__PURE__ */ e(k, { variant: "danger", role: "alert", children: h }) : null,
|
|
39
|
+
/* @__PURE__ */ l(r.Group, { className: "mb-3", controlId: "bugTitle", children: [
|
|
40
|
+
/* @__PURE__ */ e(r.Label, { children: "Title *" }),
|
|
38
41
|
/* @__PURE__ */ e(
|
|
39
|
-
|
|
42
|
+
r.Control,
|
|
40
43
|
{
|
|
41
44
|
required: !0,
|
|
42
45
|
type: "text",
|
|
43
46
|
placeholder: "e.g. Build error on auth routes",
|
|
44
|
-
value:
|
|
45
|
-
onChange: (
|
|
46
|
-
maxLength:
|
|
47
|
+
value: n,
|
|
48
|
+
onChange: (t) => m(t.target.value),
|
|
49
|
+
maxLength: D,
|
|
50
|
+
isInvalid: !!d.title
|
|
47
51
|
}
|
|
48
52
|
),
|
|
49
|
-
/* @__PURE__ */ e(
|
|
53
|
+
/* @__PURE__ */ e(r.Control.Feedback, { type: "invalid", children: d.title })
|
|
50
54
|
] }),
|
|
51
|
-
/* @__PURE__ */ l(
|
|
52
|
-
/* @__PURE__ */ e(
|
|
55
|
+
/* @__PURE__ */ l(r.Group, { className: "mb-3", controlId: "bugDescription", children: [
|
|
56
|
+
/* @__PURE__ */ e(r.Label, { children: "Description *" }),
|
|
53
57
|
/* @__PURE__ */ e(
|
|
54
|
-
|
|
58
|
+
r.Control,
|
|
55
59
|
{
|
|
56
60
|
required: !0,
|
|
57
61
|
as: "textarea",
|
|
58
62
|
rows: 4,
|
|
59
63
|
placeholder: "Describe step-by-step how to reproduce the bug...",
|
|
60
|
-
value:
|
|
61
|
-
onChange: (
|
|
64
|
+
value: a,
|
|
65
|
+
onChange: (t) => b(t.target.value),
|
|
66
|
+
isInvalid: !!d.description
|
|
62
67
|
}
|
|
63
68
|
),
|
|
64
|
-
/* @__PURE__ */ e(
|
|
69
|
+
/* @__PURE__ */ e(r.Control.Feedback, { type: "invalid", children: d.description })
|
|
65
70
|
] }),
|
|
66
|
-
/* @__PURE__ */ e("div", { className: "row", children: /* @__PURE__ */ e("div", { className: "col-md-12", children: /* @__PURE__ */ l(
|
|
67
|
-
/* @__PURE__ */ e(
|
|
71
|
+
/* @__PURE__ */ e("div", { className: "row", children: /* @__PURE__ */ e("div", { className: "col-md-12", children: /* @__PURE__ */ l(r.Group, { className: "mb-3", controlId: "bugCategory", children: [
|
|
72
|
+
/* @__PURE__ */ e(r.Label, { children: "Category *" }),
|
|
68
73
|
/* @__PURE__ */ e(
|
|
69
|
-
|
|
74
|
+
r.Select,
|
|
70
75
|
{
|
|
71
76
|
required: !0,
|
|
72
77
|
value: g,
|
|
73
|
-
onChange: (
|
|
74
|
-
children:
|
|
78
|
+
onChange: (t) => v(t.target.value),
|
|
79
|
+
children: s.map((t) => /* @__PURE__ */ e("option", { value: t, children: t }, t))
|
|
75
80
|
}
|
|
76
81
|
)
|
|
77
82
|
] }) }) }),
|
|
78
|
-
/* @__PURE__ */ l(
|
|
79
|
-
/* @__PURE__ */ e(
|
|
83
|
+
/* @__PURE__ */ l(r.Group, { className: "mb-3", controlId: "bugFile", children: [
|
|
84
|
+
/* @__PURE__ */ e(r.Label, { children: "Attachment (Optional)" }),
|
|
80
85
|
/* @__PURE__ */ e(
|
|
81
|
-
|
|
86
|
+
r.Control,
|
|
82
87
|
{
|
|
83
88
|
type: "file",
|
|
84
|
-
onChange: (
|
|
85
|
-
|
|
89
|
+
onChange: (t) => {
|
|
90
|
+
t.target.files && t.target.files.length > 0 && f(t.target.files[0]);
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
)
|
|
89
94
|
] })
|
|
90
95
|
] }),
|
|
91
|
-
/* @__PURE__ */ l(
|
|
92
|
-
/* @__PURE__ */ e(
|
|
93
|
-
/* @__PURE__ */ e(
|
|
96
|
+
/* @__PURE__ */ l(i.Footer, { children: [
|
|
97
|
+
/* @__PURE__ */ e(B, { variant: "secondary", onClick: p, disabled: u, children: "Cancel" }),
|
|
98
|
+
/* @__PURE__ */ e(B, { variant: "primary", type: "submit", disabled: u, children: u ? "Creating..." : "Report Bug" })
|
|
94
99
|
] })
|
|
95
100
|
] })
|
|
96
101
|
]
|
|
@@ -98,5 +103,5 @@ const G = ({
|
|
|
98
103
|
);
|
|
99
104
|
};
|
|
100
105
|
export {
|
|
101
|
-
|
|
106
|
+
A as BugFormModal
|
|
102
107
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface BugFormFields {
|
|
2
|
+
title: string;
|
|
3
|
+
description: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const TITLE_MAX_LENGTH = 100;
|
|
6
|
+
/**
|
|
7
|
+
* The message of each invalid field, or nothing for a valid one. The form
|
|
8
|
+
* shows them only after a submission attempt, and writes no message text
|
|
9
|
+
* otherwise, so that no style of the host application can show it early.
|
|
10
|
+
*/
|
|
11
|
+
export declare function bugFormErrors({ title, description, }: BugFormFields): Partial<Record<keyof BugFormFields, string>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const t = 100;
|
|
2
|
+
function T({
|
|
3
|
+
title: i,
|
|
4
|
+
description: e
|
|
5
|
+
}) {
|
|
6
|
+
const r = {};
|
|
7
|
+
return (i.trim() === "" || i.length > 100) && (r.title = "Title is required (max 100 characters)"), e.trim() === "" && (r.description = "Description is required"), r;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
t as TITLE_MAX_LENGTH,
|
|
11
|
+
T as bugFormErrors
|
|
12
|
+
};
|