ublo-lib 1.12.24 → 1.12.26
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.
- package/es/common/components/custom-contact-form/attachment.js +50 -51
- package/es/common/components/custom-contact-form/custom-contact-form.js +17 -17
- package/es/common/components/custom-contact-form/field.js +122 -121
- package/es/common/components/custom-contact-form/icons.js +18 -16
- package/es/common/components/custom-contact-form/messages.js +2 -2
- package/es/common/components/custom-contact-form/utils.js +53 -51
- package/package.json +1 -1
|
@@ -2,51 +2,18 @@ import * as React from "react";
|
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import * as Messages from "./messages";
|
|
4
4
|
import * as Icons from "./icons";
|
|
5
|
-
import styles from "./attachment.module.css";
|
|
6
5
|
import { convertToFileList } from "./utils";
|
|
6
|
+
import css from "./attachment.module.css";
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
const splittedName = format.split("/");
|
|
11
|
-
return splittedName[splittedName.length - 1];
|
|
12
|
-
};
|
|
13
|
-
const Item = ({
|
|
14
|
-
item,
|
|
15
|
-
removeItem
|
|
16
|
-
}) => {
|
|
17
|
-
const {
|
|
18
|
-
name
|
|
19
|
-
} = item;
|
|
20
|
-
const onRemoveClick = e => {
|
|
21
|
-
e.stopPropagation();
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
removeItem(name);
|
|
24
|
-
};
|
|
25
|
-
return _jsxs("div", {
|
|
26
|
-
className: styles.item,
|
|
27
|
-
onClick: undefined,
|
|
28
|
-
children: [_jsx("button", {
|
|
29
|
-
className: styles.itemRemove,
|
|
30
|
-
onClick: onRemoveClick,
|
|
31
|
-
children: _jsx(Icons.Bin, {
|
|
32
|
-
className: styles.itemRemoveIcon
|
|
33
|
-
})
|
|
34
|
-
}), _jsx(Icons.File, {
|
|
35
|
-
className: styles.itemIcon
|
|
36
|
-
}), _jsx("span", {
|
|
37
|
-
className: styles.itemName,
|
|
38
|
-
children: name
|
|
39
|
-
})]
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
const Attachment = ({
|
|
9
|
+
export default function Attachment({
|
|
43
10
|
lang,
|
|
44
11
|
name,
|
|
45
12
|
label,
|
|
46
13
|
settings,
|
|
47
14
|
data,
|
|
48
15
|
setData
|
|
49
|
-
})
|
|
16
|
+
}) {
|
|
50
17
|
const ref = React.useRef();
|
|
51
18
|
const [dragging, setDragging] = React.useState(false);
|
|
52
19
|
const [error, setError] = React.useState(false);
|
|
@@ -156,41 +123,41 @@ const Attachment = ({
|
|
|
156
123
|
}
|
|
157
124
|
}, [onDragIn, onDragOut, onDrop]);
|
|
158
125
|
const overlayMessage = error || dragging && Messages.get(lang, "attachmentOverlay");
|
|
159
|
-
const
|
|
160
|
-
[
|
|
126
|
+
const attachmentcss = classNames(css.attachment, {
|
|
127
|
+
[css.attachmentDragging]: dragging
|
|
161
128
|
});
|
|
162
|
-
const
|
|
163
|
-
[
|
|
129
|
+
const overlaycss = classNames(css.inputOverlay, {
|
|
130
|
+
[css.inputOverlayError]: error
|
|
164
131
|
});
|
|
165
132
|
if (!attachmentAllowed) return null;
|
|
166
133
|
return _jsxs("div", {
|
|
167
|
-
className:
|
|
134
|
+
className: attachmentcss,
|
|
168
135
|
children: [_jsxs("label", {
|
|
169
|
-
className:
|
|
136
|
+
className: css.label,
|
|
170
137
|
htmlFor: name,
|
|
171
138
|
children: [label && _jsx("span", {
|
|
172
139
|
children: label
|
|
173
140
|
}), _jsxs("div", {
|
|
174
141
|
ref: ref,
|
|
175
|
-
className:
|
|
142
|
+
className: css.input,
|
|
176
143
|
children: [items.length ? _jsx("div", {
|
|
177
|
-
className:
|
|
144
|
+
className: css.items,
|
|
178
145
|
children: Array.from(items).map((item, i) => _jsx(Item, {
|
|
179
146
|
item: item,
|
|
180
147
|
removeItem: removeItem
|
|
181
148
|
}, i))
|
|
182
149
|
}) : _jsxs("div", {
|
|
183
|
-
className:
|
|
150
|
+
className: css.placeholder,
|
|
184
151
|
children: [_jsx(Icons.Upload, {
|
|
185
|
-
className:
|
|
152
|
+
className: css.placeholderIcon
|
|
186
153
|
}), Messages.get(lang, "attachmentPlaceholder")]
|
|
187
154
|
}), (error || dragging) && _jsx("div", {
|
|
188
|
-
className:
|
|
155
|
+
className: overlaycss,
|
|
189
156
|
children: overlayMessage
|
|
190
157
|
})]
|
|
191
158
|
}), _jsx("input", {
|
|
192
159
|
id: name,
|
|
193
|
-
className:
|
|
160
|
+
className: css.uploadInput,
|
|
194
161
|
type: "file",
|
|
195
162
|
accept: attachmentAuthorizedFormats,
|
|
196
163
|
disabled: !attachmentAllowed,
|
|
@@ -198,7 +165,7 @@ const Attachment = ({
|
|
|
198
165
|
multiple: attachmentMaxFiles > 1
|
|
199
166
|
})]
|
|
200
167
|
}), _jsxs("div", {
|
|
201
|
-
className:
|
|
168
|
+
className: css.helper,
|
|
202
169
|
children: [_jsx("b", {
|
|
203
170
|
children: attachmentMaxFiles
|
|
204
171
|
}), " ", Messages.get(lang, "attachmentHelper1"), ".", " ", _jsx("b", {
|
|
@@ -208,5 +175,37 @@ const Attachment = ({
|
|
|
208
175
|
}), "."]
|
|
209
176
|
})]
|
|
210
177
|
});
|
|
211
|
-
}
|
|
212
|
-
|
|
178
|
+
}
|
|
179
|
+
function Item({
|
|
180
|
+
item,
|
|
181
|
+
removeItem
|
|
182
|
+
}) {
|
|
183
|
+
const {
|
|
184
|
+
name
|
|
185
|
+
} = item;
|
|
186
|
+
const onRemoveClick = e => {
|
|
187
|
+
e.stopPropagation();
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
removeItem(name);
|
|
190
|
+
};
|
|
191
|
+
return _jsxs("div", {
|
|
192
|
+
className: css.item,
|
|
193
|
+
onClick: undefined,
|
|
194
|
+
children: [_jsx("button", {
|
|
195
|
+
className: css.itemRemove,
|
|
196
|
+
onClick: onRemoveClick,
|
|
197
|
+
children: _jsx(Icons.Bin, {
|
|
198
|
+
className: css.itemRemoveIcon
|
|
199
|
+
})
|
|
200
|
+
}), _jsx(Icons.File, {
|
|
201
|
+
className: css.itemIcon
|
|
202
|
+
}), _jsx("span", {
|
|
203
|
+
className: css.itemName,
|
|
204
|
+
children: name
|
|
205
|
+
})]
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function getFormatName(format) {
|
|
209
|
+
const splittedName = format.split("/");
|
|
210
|
+
return splittedName[splittedName.length - 1];
|
|
211
|
+
}
|
|
@@ -8,18 +8,19 @@ import * as Messages from "./messages";
|
|
|
8
8
|
import * as Icons from "./icons";
|
|
9
9
|
import * as DTIcons from "dt-design-system/es/icons";
|
|
10
10
|
import * as Plausible from "../plausible";
|
|
11
|
-
import styles from "./custom-contact-form.module.css";
|
|
12
11
|
import { getInitialFormState, getSettings, send } from "./utils";
|
|
12
|
+
import css from "./custom-contact-form.module.css";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
|
|
15
|
+
export default React.memo(CustomContactFormWithSnackbar);
|
|
16
|
+
function CustomContactFormWithSnackbar(props) {
|
|
16
17
|
return _jsx(SnackbarProvider, {
|
|
17
18
|
children: _jsx(CustomContactForm, {
|
|
18
19
|
...props
|
|
19
20
|
})
|
|
20
21
|
});
|
|
21
|
-
}
|
|
22
|
-
|
|
22
|
+
}
|
|
23
|
+
function CustomContactForm({
|
|
23
24
|
kind,
|
|
24
25
|
title,
|
|
25
26
|
fields,
|
|
@@ -29,7 +30,7 @@ const CustomContactForm = ({
|
|
|
29
30
|
subject,
|
|
30
31
|
onSubmit,
|
|
31
32
|
customSend
|
|
32
|
-
})
|
|
33
|
+
}) {
|
|
33
34
|
const [data, setData] = React.useState(getInitialFormState(fields, presets?.values));
|
|
34
35
|
const [sending, setSending] = React.useState(false);
|
|
35
36
|
const [ready, setReady] = React.useState(false);
|
|
@@ -103,15 +104,15 @@ const CustomContactForm = ({
|
|
|
103
104
|
React.useEffect(() => {
|
|
104
105
|
setData(currentData => getInitialFormState(fields, presets?.values, currentData.subject?.value));
|
|
105
106
|
}, [fields, presets?.values]);
|
|
106
|
-
const classes = classNames(
|
|
107
|
-
const innerClasses = classNames(
|
|
107
|
+
const classes = classNames(css.root, className);
|
|
108
|
+
const innerClasses = classNames(css.inner, {
|
|
108
109
|
[innerClassName]: innerClassName
|
|
109
110
|
});
|
|
110
111
|
const showSendingOverlay = !!settings?.attachmentAllowed && sending;
|
|
111
112
|
if (!ready) return null;
|
|
112
113
|
if (ready && !settings) {
|
|
113
114
|
return _jsx("div", {
|
|
114
|
-
className:
|
|
115
|
+
className: css.root,
|
|
115
116
|
children: Messages.get(lang, "NO_SETTINGS_FOUND")
|
|
116
117
|
});
|
|
117
118
|
}
|
|
@@ -119,7 +120,7 @@ const CustomContactForm = ({
|
|
|
119
120
|
return _jsxs("div", {
|
|
120
121
|
className: classes,
|
|
121
122
|
children: [title && _jsx("div", {
|
|
122
|
-
className:
|
|
123
|
+
className: css.title,
|
|
123
124
|
children: title
|
|
124
125
|
}), _jsx("div", {
|
|
125
126
|
className: innerClasses,
|
|
@@ -133,28 +134,27 @@ const CustomContactForm = ({
|
|
|
133
134
|
presets: presets?.values
|
|
134
135
|
}, key))
|
|
135
136
|
}), _jsxs("div", {
|
|
136
|
-
className:
|
|
137
|
+
className: css.bottom,
|
|
137
138
|
children: [presets?.allowReset && _jsx(Button, {
|
|
138
|
-
className:
|
|
139
|
+
className: css.resetButton,
|
|
139
140
|
disabled: sending,
|
|
140
141
|
onClick: resetForm,
|
|
141
142
|
children: Messages.get(lang, "reset")
|
|
142
143
|
}), _jsxs(Button, {
|
|
143
|
-
className:
|
|
144
|
+
className: css.submitButton,
|
|
144
145
|
disabled: !isFormValid || sending,
|
|
145
146
|
onClick: sendForm,
|
|
146
147
|
onPointerEnter: blurForm,
|
|
147
148
|
children: [Messages.get(lang, "send"), _jsx(DTIcons.Mail, {})]
|
|
148
149
|
})]
|
|
149
150
|
}), showSendingOverlay && _jsxs("div", {
|
|
150
|
-
className:
|
|
151
|
+
className: css.sendingOverlay,
|
|
151
152
|
children: [_jsx(Icons.Spinner, {
|
|
152
|
-
className:
|
|
153
|
+
className: css.sendingIcon
|
|
153
154
|
}), _jsx("span", {
|
|
154
|
-
className:
|
|
155
|
+
className: css.sendingMessage,
|
|
155
156
|
children: Messages.get(lang, "sending")
|
|
156
157
|
})]
|
|
157
158
|
})]
|
|
158
159
|
}, formKey);
|
|
159
|
-
}
|
|
160
|
-
export default React.memo(CustomContactFormWithSnackbar);
|
|
160
|
+
}
|
|
@@ -11,70 +11,68 @@ import NumberPicker from "dt-design-system/es/number-picker";
|
|
|
11
11
|
import * as Fetcher from "../../utils/fetcher";
|
|
12
12
|
import { FIELD_TESTS_ERROR_CODES, validate } from "./utils";
|
|
13
13
|
import * as Messages from "./messages";
|
|
14
|
-
import
|
|
14
|
+
import css from "./field.module.css";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
className,
|
|
35
|
-
value: data[name].value,
|
|
36
|
-
placeholder,
|
|
16
|
+
export default function Field({
|
|
17
|
+
kind,
|
|
18
|
+
name,
|
|
19
|
+
field,
|
|
20
|
+
data,
|
|
21
|
+
setData,
|
|
22
|
+
settings,
|
|
23
|
+
presets
|
|
24
|
+
}) {
|
|
25
|
+
const {
|
|
26
|
+
lang,
|
|
27
|
+
config
|
|
28
|
+
} = useUbloContext();
|
|
29
|
+
const {
|
|
30
|
+
type,
|
|
31
|
+
label,
|
|
32
|
+
hidden,
|
|
33
|
+
fullWidth,
|
|
37
34
|
required
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (type === "number") {
|
|
61
|
-
return {
|
|
62
|
-
withInput: true,
|
|
63
|
-
onChange,
|
|
64
|
-
...commonProps
|
|
65
|
-
};
|
|
35
|
+
} = field;
|
|
36
|
+
const [activated, setActivated] = React.useState(false);
|
|
37
|
+
const [valid, setValid] = React.useState(!required || false);
|
|
38
|
+
const disabled = presets && Object.keys(presets).includes(name);
|
|
39
|
+
const isTitle = type === "title";
|
|
40
|
+
const classes = classNames({
|
|
41
|
+
[css.fieldFullWidth]: isTitle || fullWidth,
|
|
42
|
+
[css.fieldHidden]: hidden
|
|
43
|
+
});
|
|
44
|
+
if (isTitle) return _jsx("div", {
|
|
45
|
+
className: css.title,
|
|
46
|
+
children: label
|
|
47
|
+
});
|
|
48
|
+
if (type === "attachment") {
|
|
49
|
+
return _jsx(Attachment, {
|
|
50
|
+
lang: lang,
|
|
51
|
+
name: name,
|
|
52
|
+
label: label,
|
|
53
|
+
data: data,
|
|
54
|
+
setData: setData,
|
|
55
|
+
settings: settings
|
|
56
|
+
});
|
|
66
57
|
}
|
|
67
|
-
return {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
return _jsx(Inner, {
|
|
59
|
+
site: config.site,
|
|
60
|
+
kind: kind,
|
|
61
|
+
label: label,
|
|
62
|
+
lang: lang,
|
|
63
|
+
name: name,
|
|
64
|
+
classes: classes,
|
|
65
|
+
field: field,
|
|
66
|
+
data: data,
|
|
67
|
+
setData: setData,
|
|
68
|
+
disabled: disabled,
|
|
69
|
+
activated: activated,
|
|
70
|
+
setActivated: setActivated,
|
|
71
|
+
valid: valid,
|
|
72
|
+
setValid: setValid
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function Inner({
|
|
78
76
|
site,
|
|
79
77
|
lang,
|
|
80
78
|
label,
|
|
@@ -89,8 +87,9 @@ const Inner = ({
|
|
|
89
87
|
setActivated,
|
|
90
88
|
valid,
|
|
91
89
|
setValid
|
|
92
|
-
})
|
|
90
|
+
}) {
|
|
93
91
|
const {
|
|
92
|
+
icon,
|
|
94
93
|
type,
|
|
95
94
|
className,
|
|
96
95
|
options: fieldOptions = [],
|
|
@@ -166,6 +165,7 @@ const Inner = ({
|
|
|
166
165
|
const isInputValid = required && activated && valid;
|
|
167
166
|
const errorMessage = required && activated && !valid && Messages.get(lang, FIELD_TESTS_ERROR_CODES[type]);
|
|
168
167
|
return _jsx(Tag, {
|
|
168
|
+
icon: icon,
|
|
169
169
|
label: fieldLabel,
|
|
170
170
|
options: options,
|
|
171
171
|
disabled: disabled,
|
|
@@ -174,64 +174,65 @@ const Inner = ({
|
|
|
174
174
|
onBlur: onBlur,
|
|
175
175
|
...props
|
|
176
176
|
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
177
|
+
}
|
|
178
|
+
function getTag(type) {
|
|
179
|
+
switch (type) {
|
|
180
|
+
case "textarea":
|
|
181
|
+
return Textarea;
|
|
182
|
+
case "multiple-select":
|
|
183
|
+
return MultipleSelect;
|
|
184
|
+
case "select":
|
|
185
|
+
return Select;
|
|
186
|
+
case "checkbox":
|
|
187
|
+
return Checkbox;
|
|
188
|
+
case "number":
|
|
189
|
+
return NumberPicker;
|
|
190
|
+
default:
|
|
191
|
+
return Input;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function getProps(type, name, className, data, required, placeholder, autoSizing, onChange) {
|
|
195
|
+
const commonProps = {
|
|
196
|
+
className,
|
|
197
|
+
value: data[name].value,
|
|
198
|
+
placeholder,
|
|
196
199
|
required
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
[styles.fieldHidden]: hidden
|
|
205
|
-
});
|
|
206
|
-
if (isTitle) return _jsx("div", {
|
|
207
|
-
className: styles.title,
|
|
208
|
-
children: label
|
|
209
|
-
});
|
|
210
|
-
if (type === "attachment") {
|
|
211
|
-
return _jsx(Attachment, {
|
|
212
|
-
lang: lang,
|
|
213
|
-
name: name,
|
|
214
|
-
label: label,
|
|
215
|
-
data: data,
|
|
216
|
-
setData: setData,
|
|
217
|
-
settings: settings
|
|
218
|
-
});
|
|
200
|
+
};
|
|
201
|
+
if (type === "textarea") {
|
|
202
|
+
return {
|
|
203
|
+
onValueChange: onChange,
|
|
204
|
+
autoSizing,
|
|
205
|
+
...commonProps
|
|
206
|
+
};
|
|
219
207
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
208
|
+
if (type === "multiple-select") {
|
|
209
|
+
return {
|
|
210
|
+
onChange,
|
|
211
|
+
...commonProps,
|
|
212
|
+
values: commonProps.value,
|
|
213
|
+
onBlur: undefined
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
if (type === "select") {
|
|
217
|
+
return {
|
|
218
|
+
onValueChange: onChange,
|
|
219
|
+
...commonProps
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (type === "number") {
|
|
223
|
+
return {
|
|
224
|
+
withInput: true,
|
|
225
|
+
onChange,
|
|
226
|
+
...commonProps
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
type,
|
|
231
|
+
onValueChange: onChange,
|
|
232
|
+
...commonProps
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function getLabel(lang, label, required) {
|
|
236
|
+
if (!required) return `${label} (${Messages.get(lang, "optionnal")})`;
|
|
237
|
+
return label;
|
|
238
|
+
}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
|
|
5
|
-
children,
|
|
6
|
-
...props
|
|
7
|
-
}) => _jsx("svg", {
|
|
8
|
-
viewBox: "0 0 24 24",
|
|
9
|
-
...props,
|
|
10
|
-
children: children
|
|
11
|
-
});
|
|
12
|
-
export const Upload = props => {
|
|
4
|
+
export function Upload(props) {
|
|
13
5
|
return _jsxs(Icon, {
|
|
14
6
|
...props,
|
|
15
7
|
children: [_jsx("path", {
|
|
@@ -22,8 +14,8 @@ export const Upload = props => {
|
|
|
22
14
|
d: "M11.3 11.3a1 1 0 0 1 1.4 0l4 4a1 1 0 0 1-1.4 1.4L12 13.42l-3.3 3.3a1 1 0 0 1-1.4-1.42l4-4Z"
|
|
23
15
|
})]
|
|
24
16
|
});
|
|
25
|
-
}
|
|
26
|
-
export
|
|
17
|
+
}
|
|
18
|
+
export function File(props) {
|
|
27
19
|
return _jsxs(Icon, {
|
|
28
20
|
...props,
|
|
29
21
|
children: [_jsx("path", {
|
|
@@ -32,8 +24,8 @@ export const File = props => {
|
|
|
32
24
|
d: "M13 1a1 1 0 0 1 1 1v6h6a1 1 0 1 1 0 2h-7a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1Z"
|
|
33
25
|
})]
|
|
34
26
|
});
|
|
35
|
-
}
|
|
36
|
-
export
|
|
27
|
+
}
|
|
28
|
+
export function Bin(props) {
|
|
37
29
|
return _jsxs(Icon, {
|
|
38
30
|
...props,
|
|
39
31
|
children: [_jsx("path", {
|
|
@@ -46,12 +38,22 @@ export const Bin = props => {
|
|
|
46
38
|
d: "M10 10a1 1 0 011 1v6a1 1 0 11-2 0v-6a1 1 0 011-1zM14 10a1 1 0 011 1v6a1 1 0 11-2 0v-6a1 1 0 011-1z"
|
|
47
39
|
})]
|
|
48
40
|
});
|
|
49
|
-
}
|
|
50
|
-
export
|
|
41
|
+
}
|
|
42
|
+
export function Spinner(props) {
|
|
51
43
|
return _jsx(Icon, {
|
|
52
44
|
...props,
|
|
53
45
|
children: _jsx("path", {
|
|
54
46
|
d: "M10.7 3V1.4a1.3 1.3 0 012.6 0V3c0 .7-.6 1.3-1.3 1.3-.7 0-1.3-.6-1.3-1.3zM10.7 22.7V21a1.3 1.3 0 012.6 0v1.8c0 .7-.6 1.3-1.3 1.3-.7 0-1.3-.6-1.3-1.3zM17.4 6.6c-.5-.5-.5-1.3 0-1.8l1.3-1.3a1.3 1.3 0 111.8 1.8l-1.3 1.3a1.3 1.3 0 01-1.8 0zM3.5 20.5c-.5-.5-.5-1.3 0-1.8l1.3-1.3a1.3 1.3 0 011.8 1.8l-1.3 1.3a1.3 1.3 0 01-1.8 0zM21 13.3a1.3 1.3 0 110-2.6h1.7c.7 0 1.3.6 1.3 1.3 0 .7-.6 1.3-1.3 1.3H21zM1.3 13.3a1.3 1.3 0 110-2.6H3a1.3 1.3 0 010 2.6H1.3zM18.7 20.5l-1.3-1.3a1.3 1.3 0 011.8-1.8l1.3 1.3a1.3 1.3 0 01-1 2.2l-.8-.4zM4.8 6.6L3.5 5.3a1.3 1.3 0 011.8-1.8l1.3 1.3a1.3 1.3 0 01-1.8 1.8z"
|
|
55
47
|
})
|
|
56
48
|
});
|
|
57
|
-
}
|
|
49
|
+
}
|
|
50
|
+
function Icon({
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}) {
|
|
54
|
+
return _jsx("svg", {
|
|
55
|
+
viewBox: "0 0 24 24",
|
|
56
|
+
...props,
|
|
57
|
+
children: children
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -73,8 +73,8 @@ const locales = {
|
|
|
73
73
|
optionnal: "optionnal"
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
export
|
|
76
|
+
export function get(lang, id) {
|
|
77
77
|
const _lang = lang === "fr" ? "fr" : "en";
|
|
78
78
|
if (!locales || !locales[_lang]) return id;
|
|
79
79
|
return locales[_lang][id] || locales.fr[id] || `??${id}??`;
|
|
80
|
-
}
|
|
80
|
+
}
|
|
@@ -17,45 +17,55 @@ export const FIELD_TESTS_ERROR_CODES = {
|
|
|
17
17
|
"multiple-select": "TESTS_MULTIPLE_SELECT_ERROR"
|
|
18
18
|
};
|
|
19
19
|
const IGNORED_FIELDS = ["title", "subject", "attachment", "checkbox"];
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
20
|
+
export function getInitialFormState(fields, presets, existingSubject) {
|
|
21
|
+
return Object.keys(fields).reduce((acc, key) => {
|
|
22
|
+
const field = fields[key];
|
|
23
|
+
const {
|
|
24
|
+
required,
|
|
25
|
+
type
|
|
26
|
+
} = field;
|
|
27
|
+
if (type === "title") return acc;
|
|
28
|
+
if (key === "subject") {
|
|
29
|
+
const value = (existingSubject || presets?.[key]) ?? "";
|
|
30
|
+
return {
|
|
31
|
+
...acc,
|
|
32
|
+
[key]: {
|
|
33
|
+
value,
|
|
34
|
+
valid: true
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (type === "checkbox") {
|
|
39
|
+
const value = presets?.[key] ?? false;
|
|
40
|
+
return {
|
|
41
|
+
...acc,
|
|
42
|
+
[key]: {
|
|
43
|
+
value,
|
|
44
|
+
valid: validate(type, value, required)
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (type === "number") {
|
|
49
|
+
const value = presets?.[key] ?? 0;
|
|
50
|
+
return {
|
|
51
|
+
...acc,
|
|
52
|
+
[key]: {
|
|
53
|
+
value,
|
|
54
|
+
valid: validate(type, value, required)
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (type === "multiple-select") {
|
|
59
|
+
const value = presets?.[key].length || [];
|
|
60
|
+
return {
|
|
61
|
+
...acc,
|
|
62
|
+
[key]: {
|
|
63
|
+
value,
|
|
64
|
+
valid: validate(type, value, required)
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const value = presets?.[key] ?? "";
|
|
59
69
|
return {
|
|
60
70
|
...acc,
|
|
61
71
|
[key]: {
|
|
@@ -63,16 +73,8 @@ export const getInitialFormState = (fields, presets, existingSubject) => Object.
|
|
|
63
73
|
valid: validate(type, value, required)
|
|
64
74
|
}
|
|
65
75
|
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
...acc,
|
|
70
|
-
[key]: {
|
|
71
|
-
value,
|
|
72
|
-
valid: validate(type, value, required)
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}, {});
|
|
76
|
+
}, {});
|
|
77
|
+
}
|
|
76
78
|
export const validate = (type, value, required) => {
|
|
77
79
|
if (IGNORED_FIELDS.includes(type) || !required) return true;
|
|
78
80
|
if (type === "multiple-select") return value.length > 0;
|
|
@@ -127,7 +129,7 @@ export const send = async ({
|
|
|
127
129
|
const json = response.json();
|
|
128
130
|
return json;
|
|
129
131
|
};
|
|
130
|
-
export
|
|
132
|
+
export async function getSettings(site) {
|
|
131
133
|
const endpoint = `https://contacts.valraiso.net/api/settings/${site}`;
|
|
132
134
|
try {
|
|
133
135
|
const response = await Fetcher.get(endpoint);
|
|
@@ -135,4 +137,4 @@ export const getSettings = async site => {
|
|
|
135
137
|
} catch (e) {
|
|
136
138
|
return undefined;
|
|
137
139
|
}
|
|
138
|
-
}
|
|
140
|
+
}
|