@drumee/ui-toolkit 0.0.1 → 0.0.2

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/index.js ADDED
@@ -0,0 +1,19 @@
1
+
2
+
3
+ function start() {
4
+ Kind.registerAddons({
5
+ 'dtk_otp': import('./widgets/otp'),
6
+ 'dtk_dialog': import('./widgets/dialog'),
7
+ 'dtk_pwsetter': import('./widgets/pwsetter'),
8
+ })
9
+ }
10
+
11
+ if (document.readyState == 'complete') {
12
+ start()
13
+ } else {
14
+ if (location.hash) {
15
+ document.addEventListener('drumee:plugins:ready', start);
16
+ } else {
17
+ document.addEventListener('drumee:router:ready', start);
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drumee/ui-toolkit",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "main": ".",
6
6
  "repository": {
@@ -59,4 +59,4 @@
59
59
  "dependencies": {
60
60
  "@drumee/ui-styles": "^1.0.1"
61
61
  }
62
- }
62
+ }
@@ -1,3 +1,5 @@
1
+ const haptic = 3000;
2
+
1
3
  /**
2
4
  *
3
5
  * @param {*} ui
@@ -136,6 +138,7 @@ export function entry(ui, opt) {
136
138
  })
137
139
  }
138
140
 
141
+
139
142
  /**
140
143
  *
141
144
  * @param {*} ui
@@ -166,3 +169,76 @@ export function password(ui, opt) {
166
169
  });
167
170
  }
168
171
 
172
+
173
+ /**
174
+ *
175
+ * @param {*} ui
176
+ * @param {*} cn
177
+ * @param {*} passmeter
178
+ * @returns
179
+ */
180
+ export function password_box(ui, opt) {
181
+ const fig = ui.fig.family
182
+ return Skeletons.Box.Y({
183
+ className: `${fig}__form`,
184
+ kids: [
185
+ entry(ui, {
186
+ placeholder: LOCALE.EMAIL,
187
+ name: _a.email,
188
+ sys_pn: _a.email,
189
+ service: _a.input,
190
+ value: ui.mget(_a.email) || ""
191
+ }),
192
+ password(ui, {
193
+ placeholder: LOCALE.PASSWORD,
194
+ name: _a.password,
195
+ sys_pn: _a.password,
196
+ interactive: 1,
197
+ service: 'password-input'
198
+ }),
199
+ password(ui, {
200
+ placeholder: LOCALE.PASSWORD_CONFIRM,
201
+ name: "password2",
202
+ sys_pn: "password2",
203
+ }),
204
+ { kind: 'dtk_pwsetter', sys_pn: 'pwsetter' },
205
+ button(ui, {
206
+ label: LOCALE.CREATE_ACCOUNT,
207
+ service: 'create-account',
208
+ type: _a.email,
209
+ sys_pn: "commit-button",
210
+ haptic
211
+ }),
212
+ ]
213
+ })
214
+ }
215
+
216
+ /**
217
+ *
218
+ * @param {*} ui
219
+ * @param {*} opt
220
+ * @returns
221
+ */
222
+ export function dialog_box(ui, opt) {
223
+ const fig = ui.fig.family
224
+ const { title, message, buttons, content } = opt;
225
+ const Buttons = Skeletons.Box.X({
226
+ className: `${fig}__buttons`,
227
+ kids: buttons
228
+ })
229
+
230
+ return Skeletons.Box.Y({
231
+ className: `${fig}__main`,
232
+ debug: __filename,
233
+ kids: [
234
+ header(ui, title),
235
+ Skeletons.Element({ className: `${fig}__message`, content: message || LOCALE.ERROR_SERVER }),
236
+ content,
237
+ Buttons
238
+ ]
239
+ })
240
+
241
+ }
242
+
243
+
244
+
@@ -0,0 +1,174 @@
1
+ @use '@drumee/ui-styles/src/mixins';
2
+
3
+ @mixin dtk-butler-main {
4
+
5
+ &__ui {
6
+ width: 100vw;
7
+ height: 100vh;
8
+ align-content: center;
9
+ align-items: center;
10
+ justify-content: start;
11
+ background-color: var(--neutral-100);
12
+ overflow: auto;
13
+ font-family: var(--font-main);
14
+ flex-wrap: wrap;
15
+ padding: var(--spacer-7);
16
+ gap: var(--spacer-8);
17
+ flex-shrink: 0;
18
+
19
+ &[data-device="mobile"] {
20
+ padding: 10px;
21
+ height: auto;
22
+ }
23
+ }
24
+
25
+ &__main {
26
+ top: 180px;
27
+
28
+ &[data-device="mobile"] {
29
+ top: 0;
30
+ gap: var(--spacer-3);
31
+ }
32
+
33
+ justify-content: start;
34
+ align-items: center;
35
+ width: 100%;
36
+ max-width: 480px;
37
+ border-width: 1px;
38
+ gap: var(--spacer-5);
39
+ background-color: var(--white);
40
+ border: 1px solid var(--neutral-200);
41
+ padding: var(--spacer-7);
42
+ border-radius: var(--corner-radius-6);
43
+ }
44
+
45
+
46
+ &__logo {
47
+ &-container {
48
+ align-content: center;
49
+ justify-content: center;
50
+ align-items: center;
51
+ flex-wrap: wrap;
52
+ }
53
+
54
+ &-content {
55
+ width: 80px;
56
+ height: 64px;
57
+ align-content: center;
58
+ justify-content: start;
59
+ align-items: start;
60
+ flex-wrap: wrap;
61
+
62
+ svg {
63
+ width: 100%;
64
+ height: 100%;
65
+ }
66
+ }
67
+ }
68
+
69
+ &__title {
70
+ font-weight: bold;
71
+ font-size: 32px;
72
+ line-height: 40px;
73
+ text-align: center;
74
+ }
75
+
76
+ &__tips {
77
+ font-weight: 400;
78
+ font-style: normal;
79
+ font-size: 16px;
80
+ line-height: 26px;
81
+ letter-spacing: 1px;
82
+ text-align: center;
83
+ }
84
+
85
+ &__message {
86
+ font-weight: 400;
87
+ font-style: normal;
88
+ font-size: 14px;
89
+ line-height: 22px;
90
+ text-align: center;
91
+ letter-spacing: 1px;
92
+
93
+ span {
94
+ font-weight: bold;
95
+ cursor: pointer;
96
+ }
97
+ }
98
+
99
+ }
100
+
101
+ @mixin dtk-butler-button {
102
+
103
+ &__buttons {
104
+ gap: var(--spacer-6);
105
+ width: 100%;
106
+ justify-content: center;
107
+ }
108
+
109
+
110
+ &__button-main {
111
+ height: 48px;
112
+ opacity: 1;
113
+ gap: var(--spacer-4);
114
+ border-radius: var(--corner-radius-max);
115
+ padding-top: 8px;
116
+ padding-right: 16px;
117
+ padding-bottom: 8px;
118
+ padding-left: 16px;
119
+ cursor: pointer;
120
+
121
+ &[data-haptic="1"] {
122
+ opacity: .6;
123
+ pointer-events: none;
124
+ }
125
+
126
+ &.primary {
127
+ padding-right: 3px;
128
+ justify-content: center;
129
+ grid-template-columns: 1fr 40px;
130
+ background: var(--primary-500);
131
+ color: var(--white);
132
+ align-content: center;
133
+ flex-wrap: wrap;
134
+
135
+ .icon.svg-wrapper {
136
+ height: 38px;
137
+ width: 38px;
138
+ color: var(--primary-500);
139
+ background-color: white;
140
+ border-radius: 50%;
141
+ padding: 9px;
142
+ }
143
+ }
144
+
145
+ &.secondary {
146
+ justify-content: center;
147
+ background-color: var(--neutral-200);
148
+
149
+ .icon.svg-wrapper {
150
+ height: 32px;
151
+ width: 32px;
152
+ color: var(--neutral-900);
153
+ border-radius: 50%;
154
+ padding: 6px;
155
+ }
156
+ }
157
+
158
+ svg {
159
+ width: 100%;
160
+ height: 100%;
161
+ }
162
+ }
163
+
164
+ &__button.btn {
165
+ width: auto;
166
+ height: 100%;
167
+ align-content: center;
168
+ display: flex;
169
+ flex-wrap: wrap;
170
+ justify-content: center;
171
+ line-height: 20px;
172
+ }
173
+
174
+ }
@@ -4,10 +4,9 @@
4
4
  * @class __welcome_signup
5
5
  * @extends __welcome_interact
6
6
  */
7
- const Common = require("..")
8
7
  require('./skin');
9
-
10
- export class dtk_butler_dialog extends Common {
8
+ const { dtk_common } = require("..")
9
+ export default class dtk_butler_dialog extends dtk_common {
11
10
 
12
11
  /**
13
12
  ** @param {object} opt
@@ -2,18 +2,19 @@ const { header } = require("../../../skeletons")
2
2
 
3
3
  export default function (ui) {
4
4
  const fig = ui.fig.family
5
- const { title, message, buttons } = ui.model.toJSON()
5
+ const { title, message, buttons, body } = ui.model.toJSON()
6
6
  const Buttons = Skeletons.Box.X({
7
7
  className: `${fig}__buttons`,
8
8
  kids: buttons
9
9
  })
10
-
10
+ if (message == null) message = '';
11
11
  let a = Skeletons.Box.Y({
12
12
  className: `${fig}__main`,
13
13
  debug: __filename,
14
14
  kids: [
15
15
  header(ui, title),
16
- Skeletons.Element({ className: `${fig}__message`, content: message || LOCALE.ERROR_SERVER }),
16
+ Skeletons.Element({ className: `${fig}__message`, content: message }),
17
+ body,
17
18
  Buttons
18
19
  ]
19
20
  })
@@ -1,9 +1,9 @@
1
1
  @use '@drumee/ui-styles/src/mixins';
2
- @use '../../toolkit/skin' as *;
2
+ @use '../../../skin' as *;
3
3
 
4
4
  .dtk-butler-dialog {
5
5
  @include dtk-butler-main;
6
-
6
+ @include dtk-butler-button;
7
7
 
8
8
  &__message {
9
9
  font-weight: 400;
package/widgets/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Common class
4
4
  */
5
- class signup_common extends LetcBox {
5
+ export class dtk_common extends LetcBox {
6
6
 
7
7
  /**
8
8
  *
@@ -28,4 +28,3 @@ class signup_common extends LetcBox {
28
28
  }
29
29
  }
30
30
 
31
- module.exports = signup_common
@@ -1,7 +1,7 @@
1
1
 
2
2
  require('./skin');
3
- const Common = require("..")
4
- export class dtk_otp extends Common {
3
+ const { dtk_common } = require("..")
4
+ export default class dtk_otp extends dtk_common {
5
5
 
6
6
  /**
7
7
  ** @param {object} opt
@@ -45,8 +45,21 @@ export class dtk_otp extends Common {
45
45
 
46
46
  /**
47
47
  *
48
+ * @param {*} msg
48
49
  */
49
- checkForm(api) {
50
+ displayMessage(msg, error = 0) {
51
+ this.__tipsText.set({ content: msg });
52
+ this.__tipsText.el.dataset.error = error;
53
+ setTimeout(() => {
54
+ this.__tipsText.set({ content: '' });
55
+ this.__tipsText.el.dataset.error = error;
56
+ }, 3000)
57
+ }
58
+
59
+ /**
60
+ *
61
+ */
62
+ checkForm() {
50
63
  this.ensurePart("digits").then((p) => {
51
64
  let res = [];
52
65
  for (let c of p.children.toArray()) {
@@ -55,9 +68,19 @@ export class dtk_otp extends Common {
55
68
  res.push(v)
56
69
  }
57
70
  }
71
+ let api = this.mget(_a.api)
72
+ let payload = this.mget('payload')
73
+ this.debug("AAA:59 checkForm", payload, res, api)
58
74
  if (res.length >= 6) {
59
75
  if (api) {
60
- return this.postService(api, { otp: res.join('') }, { async: 1 })
76
+ return this.postService(api, { ...payload, code: res.join('') }, { async: 1 }).then((data) => {
77
+ this.debug("AAA:153 OTP verified", data)
78
+ let service = this.mget(_a.service) || 'otp-verified';
79
+ this.triggerHandlers({ data, service })
80
+ }).catch((e) => {
81
+ this.warn("AAA:157 OTP verify error", e)
82
+ this.triggerHandlers({ service: 'otp-failed', error: e })
83
+ })
61
84
  }
62
85
  }
63
86
  })
@@ -107,6 +130,18 @@ export class dtk_otp extends Common {
107
130
  this.checkForm()
108
131
  })
109
132
  break;
133
+ case "resend-code":
134
+ let { email } = this.mget('payload')
135
+ this.postService(SERVICE.otp.send, { email }).then((data) => {
136
+ this.mset({ payload: data })
137
+ this.displayMessage(LOCALE.NEW_CODE_RESENT)
138
+ }).catch((e) => {
139
+ this.displayMessage(LOCALE.UNKNOWN_ERROR, 1)
140
+ this.warn("AAA:104 Error sending OTP", e)
141
+ })
142
+ break;
143
+ default:
144
+ this.triggerHandlers({ ...args, service })
110
145
  }
111
146
  }
112
147
 
@@ -1,4 +1,4 @@
1
- const { header } = require("../../toolkit/skeleton")
1
+ const { header } = require("../../../skeletons");
2
2
 
3
3
  function __skl_welcome_signup(ui) {
4
4
  const fig = ui.fig.family
@@ -39,7 +39,20 @@ function __skl_welcome_signup(ui) {
39
39
  Skeletons.Element({
40
40
  className: `${fig}__resend-text resend`,
41
41
  content: LOCALE.RESEND_CODE,
42
- service: _a.resend
42
+ service: "resend-code"
43
+ }),
44
+ ]
45
+ })
46
+
47
+ const tips = Skeletons.Box.X({
48
+ className: `${fig}__tips`,
49
+ kidsOpt: {
50
+ tagName: _K.tag.span,
51
+ },
52
+ kids: [
53
+ Skeletons.Note({
54
+ sys_pn: "tips-text",
55
+ className: `${fig}__tips-text`,
43
56
  }),
44
57
  ]
45
58
  })
@@ -62,6 +75,7 @@ function __skl_welcome_signup(ui) {
62
75
  header(ui, title || LOCALE.VALIDATION_SENT_TO),
63
76
  message,
64
77
  code,
78
+ tips,
65
79
  resend
66
80
  ]
67
81
  })
@@ -1,4 +1,4 @@
1
- @use '../../toolkit/skin' as *;
1
+ @use '../../../skin' as *;
2
2
 
3
3
  .dtk-otp {
4
4
  @include dtk-butler-main;
@@ -44,6 +44,27 @@
44
44
  }
45
45
  }
46
46
 
47
+ &__tips {
48
+ width: 100%;
49
+ justify-content: center;
50
+ flex-wrap: wrap;
51
+
52
+ &-text {
53
+ font-weight: 400;
54
+ font-style: normal;
55
+ font-size: 16px;
56
+ line-height: 26px;
57
+ letter-spacing: 1px;
58
+ width: 100%;
59
+
60
+ &[data-error="1"] {
61
+ color: var(--red-500);
62
+ font-weight: bold;
63
+ cursor: pointer;
64
+ }
65
+ }
66
+ }
67
+
47
68
  &__resend {
48
69
  width: 100%;
49
70
  justify-content: start;
@@ -2,7 +2,7 @@
2
2
 
3
3
  require('./skin');
4
4
 
5
- export class dtk_pwmeter extends LetcBox {
5
+ export default class dtk_pwsetter extends LetcBox {
6
6
 
7
7
  /**
8
8
  ** @param {object} opt
@@ -22,28 +22,38 @@ export class dtk_pwmeter extends LetcBox {
22
22
 
23
23
  /**
24
24
  *
25
- * @param {*} pw
26
25
  */
27
- check(pw) {
28
- let rate = 100 * (pw.length / 20) + 5;
26
+ check() {
27
+ let { password, password2 } = this.getData()
28
+ let rate = 100 * (password.length / 20) + 5;
29
29
  if (rate > 100) rate = 100;
30
30
  this.__strengthGrade.el.style.width = `${rate}%`;
31
31
  let min = 6;
32
32
  this._isValid = 0;
33
- if (pw.length < min) {
33
+ if (password.length < min) {
34
34
  this.__strengthState.set({ content: LOCALE.WEAK })
35
35
  this.__strengthGrade.el.dataset.strenght = "0";
36
- this.__errorMessage.set({ content: LOCALE.PASSWORD_AT_LEAST.format(min) })
37
- } else if (pw.length <= 10) {
36
+ this.__messageText.set({ content: LOCALE.PASSWORD_AT_LEAST.format(min) });
37
+ this.__messageText.el.dataset.status = "error";
38
+ } else if (password.length <= 10) {
38
39
  this.__strengthState.set({ content: LOCALE.STRONG })
39
40
  this.__strengthGrade.el.dataset.strenght = "1";
40
- this.__errorMessage.set({ content: "" })
41
+ this.__messageText.set({ content: "" })
41
42
  this._isValid = 1;
43
+ this.__messageText.el.dataset.status = "normal";
42
44
  } else {
43
45
  this.__strengthGrade.el.dataset.strenght = "2";
44
46
  this.__strengthState.set({ content: LOCALE.VERY_STRONG })
45
- this.__errorMessage.set({ content: "" });
47
+ this.__messageText.set({ content: "" });
46
48
  this._isValid = 1;
49
+ this.__messageText.el.dataset.status = "normal";
50
+ }
51
+ this.debug("AAA:PWSETTER", { password, password2 })
52
+ if (password2 && password == password2) {
53
+ this.__messageIcon.el.dataset.state = "1";
54
+ this.__messageText.set({ content: LOCALE.PASSWORD_MATCH })
55
+ }else{
56
+ this.__messageIcon.el.dataset.state = "0";
47
57
  }
48
58
  }
49
59
 
@@ -51,16 +61,16 @@ export class dtk_pwmeter extends LetcBox {
51
61
  *
52
62
  * @returns
53
63
  */
54
- isValid(){
64
+ isValid() {
55
65
  return this._isValid
56
66
  }
57
-
67
+
58
68
  /**
59
69
  *
60
70
  * @param {*} pw
61
71
  */
62
72
  message(content) {
63
- this.__errorMessage.set({ content })
73
+ this.__messageText.set({ content })
64
74
  }
65
75
 
66
76
  /**
@@ -72,6 +82,9 @@ export class dtk_pwmeter extends LetcBox {
72
82
  this.debug(`onUiEvent service = ${service}`, cmd, this);
73
83
 
74
84
  switch (service) {
85
+ case 'password-input':
86
+ this.check()
87
+ break;
75
88
  default:
76
89
  this.triggerHandlers({ service })
77
90
  }
@@ -1,3 +1,4 @@
1
+ const { password } = require("../../../skeletons");
1
2
 
2
3
  /**
3
4
  *
@@ -7,9 +8,29 @@
7
8
  */
8
9
  function passmeter(ui, opt) {
9
10
  let fig = `${ui.fig.family}`
11
+ const form = Skeletons.Box.Y({
12
+ className: `${fig}__form`,
13
+ kids: [
14
+ password(ui, {
15
+ placeholder: LOCALE.PASSWORD,
16
+ name: _a.password,
17
+ sys_pn: _a.password,
18
+ interactive: 1,
19
+ service: 'password-input'
20
+ }),
21
+ password(ui, {
22
+ placeholder: LOCALE.PASSWORD_CONFIRM,
23
+ name: "password2",
24
+ sys_pn: "password2",
25
+ interactive: 1,
26
+ service: 'password-input'
27
+ }),
28
+ ]
29
+ })
10
30
  return Skeletons.Box.Y({
11
31
  className: `${fig}__main`,
12
32
  kids: [
33
+ form,
13
34
  Skeletons.Box.X({
14
35
  className: `${fig}__dashboard`,
15
36
  kids: [
@@ -33,11 +54,23 @@ function passmeter(ui, opt) {
33
54
  })
34
55
  ]
35
56
  }),
36
- Skeletons.Note({
37
- className: `${fig}__error`,
38
- content: "",
39
- sys_pn: "error-message"
40
- }),
57
+ Skeletons.Box.X({
58
+ className: `${fig}__dashboard`,
59
+ kids: [
60
+ Skeletons.Button.Svg({
61
+ ico: "checked-circle",
62
+ className: `${fig}__message-icon`,
63
+ content: "",
64
+ sys_pn: "message-icon",
65
+ state: 0
66
+ }),
67
+ Skeletons.Note({
68
+ className: `${fig}__message-text`,
69
+ content: "",
70
+ sys_pn: "message-text"
71
+ }),
72
+ ]
73
+ })
41
74
  ]
42
75
  })
43
76
  };
@@ -23,7 +23,12 @@
23
23
  }
24
24
 
25
25
  &__dashboard {
26
- gap: 10px;
26
+ padding-left: 16px;
27
+ padding-left: 16px;
28
+ height: 22px;
29
+ align-content: center;
30
+ flex-wrap: wrap;
31
+ gap: 8px;
27
32
  }
28
33
 
29
34
  &__strength-container {
@@ -51,8 +56,71 @@
51
56
  }
52
57
  }
53
58
 
54
- &__error {
55
- color: var(--red-500);
59
+ &__message-icon {
60
+ color: var(--green-400);
61
+ width: 16px;
62
+ height: 100%;
63
+
64
+ &[data-state="0"] {
65
+ display: none;
66
+ }
67
+ }
68
+
69
+ &__message-text {
70
+ align-content: center;
71
+ flex-wrap: wrap;
72
+
73
+ &[data-status="error"] {
74
+ color: var(--red-500);
75
+ }
76
+ }
77
+
78
+ &__buttons,
79
+ &__form {
80
+ gap: var(--spacer-4);
81
+ width: 100%;
82
+ margin-bottom: var(--spacer-4);
83
+ }
84
+
85
+ &__entry-main {
86
+ width: 100%;
87
+ height: 48px;
88
+ border-radius: 12px;
89
+ padding-right: 16px;
90
+ padding-left: 16px;
91
+ border-width: 1px;
92
+ justify-content: center;
93
+ align-content: center;
94
+ flex-wrap: wrap;
95
+ }
96
+
97
+ &__entry-input {
98
+ &[data-status="error"] {
99
+ input {
100
+ border: 1px var(--red-600) solid;
101
+ }
102
+ }
56
103
  }
57
104
 
105
+ &__entry-input {
106
+ input {
107
+ width: 100%;
108
+ gap: var(--spacer-4);
109
+ width: 100%;
110
+ border-radius: var(--spacer-4);
111
+ padding-top: 12px;
112
+ padding-right: 16px;
113
+ padding-bottom: 12px;
114
+ padding-left: 16px;
115
+ border: 1px var(--neutral-200) solid;
116
+ }
117
+
118
+ .entry-reminder__icon {
119
+ right: 5px;
120
+ position: absolute;
121
+ }
122
+
123
+ width: 100%;
124
+ height: 100%;
125
+ }
58
126
  }