@subiz/widget-v4 4.1.137 → 4.1.138
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/assets/less/form-page.less +11 -3
- package/compiled_src/form/FormPage.js +14 -6
- package/compiled_src/form.js +9 -1
- package/package.json +1 -1
- package/src/form/FormPage.js +8 -5
- package/src/form.js +25 -10
|
@@ -41,9 +41,6 @@ body div#sbz92 {
|
|
|
41
41
|
@import 'base.less';
|
|
42
42
|
|
|
43
43
|
* {
|
|
44
|
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
45
|
-
-webkit-tap-highlight-color: transparent;
|
|
46
|
-
|
|
47
44
|
font-family: @font-family-sans-serif;
|
|
48
45
|
font-size: @font-size-base;
|
|
49
46
|
|
|
@@ -306,5 +303,16 @@ body div#sbz92 {
|
|
|
306
303
|
height: 40px;
|
|
307
304
|
}
|
|
308
305
|
|
|
306
|
+
.form-page-preview-noti {
|
|
307
|
+
background: #fef7e0;
|
|
308
|
+
text-align: center;
|
|
309
|
+
border-radius: 6px;
|
|
310
|
+
margin-top: 10px;
|
|
311
|
+
margin-left: 15px;
|
|
312
|
+
margin-right: 15px;
|
|
313
|
+
padding: 8px 12px;
|
|
314
|
+
color: #202122;
|
|
315
|
+
}
|
|
316
|
+
|
|
309
317
|
@import 'form.less';
|
|
310
318
|
}
|
|
@@ -27,7 +27,6 @@ class FormPage extends _common.Com {
|
|
|
27
27
|
if (document.fonts.check('normal 16px ' + fonts[i])) {
|
|
28
28
|
ready[fonts[i]] = true;
|
|
29
29
|
}
|
|
30
|
-
console.log('ready', ready, Object.keys(ready), fonts.length, Object.keys(ready) === fonts.length);
|
|
31
30
|
if (_index.default.size(Object.keys(ready)) === fonts.length) {
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
@@ -79,12 +78,16 @@ class FormPage extends _common.Com {
|
|
|
79
78
|
let chatbox = _index.default.find(this.props.store.matchPlugin(), plugin => plugin.type === 'chatbox') || {};
|
|
80
79
|
chatbox = chatbox.chatbox || {};
|
|
81
80
|
if (this.props.previewJson) {
|
|
81
|
+
this.setState({
|
|
82
|
+
loading: true
|
|
83
|
+
});
|
|
82
84
|
let json = atob(this.props.previewJson);
|
|
83
85
|
json = decodeURIComponent(json);
|
|
84
86
|
json = _index.default.parseJSON(json);
|
|
85
87
|
await this.insertCss(chatbox, json);
|
|
86
88
|
this.setState({
|
|
87
|
-
formSetting: json
|
|
89
|
+
formSetting: json,
|
|
90
|
+
loading: false
|
|
88
91
|
});
|
|
89
92
|
return;
|
|
90
93
|
}
|
|
@@ -172,14 +175,16 @@ class FormPage extends _common.Com {
|
|
|
172
175
|
} = this.state;
|
|
173
176
|
if (loading && !loadError) {
|
|
174
177
|
return (0, _preact.h)("div", {
|
|
175
|
-
class: "h-full w-full d-flex justify-content-center align-items-center"
|
|
178
|
+
class: "h-full w-full d-flex justify-content-center align-items-center",
|
|
179
|
+
key: "loading"
|
|
176
180
|
}, (0, _preact.h)("div", {
|
|
177
181
|
class: "text-muted text-xl"
|
|
178
182
|
}, this.props.t('loading_data'), " ..."));
|
|
179
183
|
}
|
|
180
184
|
if (loadError) {
|
|
181
185
|
return (0, _preact.h)("div", {
|
|
182
|
-
class: "h-full w-full d-flex justify-content-center align-items-center"
|
|
186
|
+
class: "h-full w-full d-flex justify-content-center align-items-center",
|
|
187
|
+
key: "error"
|
|
183
188
|
}, (0, _preact.h)("div", {
|
|
184
189
|
class: "text-center"
|
|
185
190
|
}, (0, _preact.h)("div", {
|
|
@@ -193,8 +198,11 @@ class FormPage extends _common.Com {
|
|
|
193
198
|
}
|
|
194
199
|
let brandLogo = _index.default.get(formSetting, 'logo.url');
|
|
195
200
|
return (0, _preact.h)("div", {
|
|
196
|
-
class: "form-page-body"
|
|
197
|
-
|
|
201
|
+
class: "form-page-body",
|
|
202
|
+
key: "form"
|
|
203
|
+
}, this.props.previewJson && (0, _preact.h)("div", {
|
|
204
|
+
class: "form-page-preview-noti"
|
|
205
|
+
}, 'Form ở trạng thái xem thử, không ghi nhận phản hồi'), (0, _preact.h)("div", {
|
|
198
206
|
class: "form-page"
|
|
199
207
|
}, (0, _preact.h)("div", {
|
|
200
208
|
class: "form-page-logo-wrapper"
|
package/compiled_src/form.js
CHANGED
|
@@ -18,13 +18,21 @@ async function renderForm(form, chatbox, $div) {
|
|
|
18
18
|
(0, _preact.render)((0, _preact.h)("div", null, "Loading"), $div);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
+
const LANG = {
|
|
22
|
+
no_select: 'Chưa chọn',
|
|
23
|
+
cannot_be_empty: 'không thể để trống',
|
|
24
|
+
you_have_submitted_info_successfully: 'Form được gửi thành công',
|
|
25
|
+
no_info_input: 'Chưa nhập'
|
|
26
|
+
};
|
|
21
27
|
(0, _preact.render)((0, _preact.h)(_Form.default, {
|
|
22
28
|
mode: "attachment",
|
|
29
|
+
onChangeFormValues: () => {},
|
|
30
|
+
onSubmit: () => {},
|
|
23
31
|
formSetting: form,
|
|
24
32
|
submission: {
|
|
25
33
|
values: []
|
|
26
34
|
},
|
|
27
|
-
t:
|
|
35
|
+
t: key => LANG[key]
|
|
28
36
|
}), $div);
|
|
29
37
|
}
|
|
30
38
|
async function initCss(chatbox) {
|
package/package.json
CHANGED
package/src/form/FormPage.js
CHANGED
|
@@ -35,7 +35,6 @@ export default class FormPage extends Com {
|
|
|
35
35
|
if (document.fonts.check('normal 16px ' + fonts[i])) {
|
|
36
36
|
ready[fonts[i]] = true
|
|
37
37
|
}
|
|
38
|
-
console.log('ready', ready, Object.keys(ready), fonts.length, Object.keys(ready) === fonts.length)
|
|
39
38
|
if (sb.size(Object.keys(ready)) === fonts.length) {
|
|
40
39
|
return
|
|
41
40
|
}
|
|
@@ -95,11 +94,12 @@ export default class FormPage extends Com {
|
|
|
95
94
|
chatbox = chatbox.chatbox || {}
|
|
96
95
|
|
|
97
96
|
if (this.props.previewJson) {
|
|
97
|
+
this.setState({loading: true})
|
|
98
98
|
let json = atob(this.props.previewJson)
|
|
99
99
|
json = decodeURIComponent(json)
|
|
100
100
|
json = sb.parseJSON(json)
|
|
101
101
|
await this.insertCss(chatbox, json)
|
|
102
|
-
this.setState({formSetting: json})
|
|
102
|
+
this.setState({formSetting: json, loading: false})
|
|
103
103
|
return
|
|
104
104
|
}
|
|
105
105
|
if (this.state.loading) return
|
|
@@ -148,14 +148,14 @@ export default class FormPage extends Com {
|
|
|
148
148
|
const {formSetting, loading, loadError, submission, errorMessage, isSubmited, submiting} = this.state
|
|
149
149
|
if (loading && !loadError) {
|
|
150
150
|
return (
|
|
151
|
-
<div class='h-full w-full d-flex justify-content-center align-items-center'>
|
|
151
|
+
<div class='h-full w-full d-flex justify-content-center align-items-center' key='loading'>
|
|
152
152
|
<div class='text-muted text-xl'>{this.props.t('loading_data')} ...</div>
|
|
153
153
|
</div>
|
|
154
154
|
)
|
|
155
155
|
}
|
|
156
156
|
if (loadError) {
|
|
157
157
|
return (
|
|
158
|
-
<div class='h-full w-full d-flex justify-content-center align-items-center'>
|
|
158
|
+
<div class='h-full w-full d-flex justify-content-center align-items-center' key='error'>
|
|
159
159
|
<div class='text-center'>
|
|
160
160
|
<div class='text-danger text-lg mb-2'>{this.props.t('error_occurs_when_load_data')}</div>
|
|
161
161
|
<br />
|
|
@@ -169,7 +169,10 @@ export default class FormPage extends Com {
|
|
|
169
169
|
|
|
170
170
|
let brandLogo = sb.get(formSetting, 'logo.url')
|
|
171
171
|
return (
|
|
172
|
-
<div class='form-page-body'>
|
|
172
|
+
<div class='form-page-body' key='form'>
|
|
173
|
+
{this.props.previewJson && (
|
|
174
|
+
<div class='form-page-preview-noti'>{'Form ở trạng thái xem thử, không ghi nhận phản hồi'}</div>
|
|
175
|
+
)}
|
|
173
176
|
<div class='form-page'>
|
|
174
177
|
<div class='form-page-logo-wrapper'>
|
|
175
178
|
<a href={formSetting.brand_url || 'javascript:;'}>
|
package/src/form.js
CHANGED
|
@@ -5,18 +5,33 @@ import sb from './util/index.js'
|
|
|
5
5
|
|
|
6
6
|
let loadStatus = ''
|
|
7
7
|
export default async function renderForm(form, chatbox, $div) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
initCss(chatbox)
|
|
9
|
+
if (loadStatus !== 'done') {
|
|
10
|
+
render(<div>Loading</div>, $div)
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
const LANG = {
|
|
14
|
+
no_select: 'Chưa chọn',
|
|
15
|
+
cannot_be_empty: 'không thể để trống',
|
|
16
|
+
you_have_submitted_info_successfully: 'Form được gửi thành công',
|
|
17
|
+
no_info_input: 'Chưa nhập',
|
|
18
|
+
}
|
|
19
|
+
render(
|
|
20
|
+
<Form
|
|
21
|
+
mode='attachment'
|
|
22
|
+
onChangeFormValues={() => {}}
|
|
23
|
+
onSubmit={() => {}}
|
|
24
|
+
formSetting={form}
|
|
25
|
+
submission={{values: []}}
|
|
26
|
+
t={(key) => LANG[key]}
|
|
27
|
+
/>,
|
|
28
|
+
$div,
|
|
29
|
+
)
|
|
15
30
|
}
|
|
16
31
|
|
|
17
32
|
async function initCss(chatbox) {
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
if (loadStatus) return
|
|
34
|
+
loadStatus = 'loadiing'
|
|
20
35
|
let css = (await promiseMainCSS).default.default.toString()
|
|
21
36
|
let outcss = sb.replaceCssVariable(css, chatbox)
|
|
22
37
|
|
|
@@ -26,5 +41,5 @@ async function initCss(chatbox) {
|
|
|
26
41
|
$cssStyleDiv.id = 'subiz-style-for-form'
|
|
27
42
|
|
|
28
43
|
sb.setCss('form', $cssStyleDiv, outcss)
|
|
29
|
-
|
|
44
|
+
loadStatus = 'done'
|
|
30
45
|
}
|