@drumee/ui-toolkit 0.0.8 → 0.0.9

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.
@@ -0,0 +1,178 @@
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
+ &.full-width {
146
+ width: 100%;
147
+ }
148
+
149
+ &.secondary {
150
+ justify-content: center;
151
+ background-color: var(--neutral-200);
152
+
153
+ .icon.svg-wrapper {
154
+ height: 32px;
155
+ width: 32px;
156
+ color: var(--neutral-900);
157
+ border-radius: 50%;
158
+ padding: 6px;
159
+ }
160
+ }
161
+
162
+ svg {
163
+ width: 100%;
164
+ height: 100%;
165
+ }
166
+ }
167
+
168
+ &__button.btn {
169
+ width: auto;
170
+ height: 100%;
171
+ align-content: center;
172
+ display: flex;
173
+ flex-wrap: wrap;
174
+ justify-content: center;
175
+ line-height: 20px;
176
+ }
177
+
178
+ }
@@ -0,0 +1,167 @@
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
+ justify-content: start;
28
+ align-items: center;
29
+ width: 100%;
30
+ max-width: 480px;
31
+ border-width: 1px;
32
+ gap: var(--spacer-8);
33
+ background-color: var(--white);
34
+ border: 1px solid var(--neutral-200);
35
+ padding: var(--spacer-7);
36
+ border-radius: var(--corner-radius-6);
37
+ }
38
+
39
+
40
+ &__logo {
41
+ &-container {
42
+ align-content: center;
43
+ justify-content: center;
44
+ align-items: center;
45
+ flex-wrap: wrap;
46
+ }
47
+
48
+ &-content {
49
+ width: 80px;
50
+ height: 64px;
51
+ align-content: center;
52
+ justify-content: start;
53
+ align-items: start;
54
+ flex-wrap: wrap;
55
+
56
+ svg {
57
+ width: 100%;
58
+ height: 100%;
59
+ }
60
+ }
61
+ }
62
+
63
+ &__title {
64
+ font-weight: bold;
65
+ font-size: 32px;
66
+ line-height: 40px;
67
+ text-align: center;
68
+ }
69
+
70
+ &__tips {
71
+ font-weight: 400;
72
+ font-style: normal;
73
+ font-size: 16px;
74
+ line-height: 26px;
75
+ letter-spacing: 1px;
76
+ text-align: center;
77
+ }
78
+
79
+ &__message {
80
+ font-weight: 400;
81
+ font-style: normal;
82
+ font-size: 14px;
83
+ line-height: 22px;
84
+ text-align: center;
85
+ letter-spacing: 1px;
86
+
87
+ span {
88
+ font-weight: bold;
89
+ cursor: pointer;
90
+ }
91
+ }
92
+
93
+ }
94
+
95
+ @mixin dtk-butler-button {
96
+
97
+ &__buttons {
98
+ gap: var(--spacer-6);
99
+ width: 100%;
100
+ }
101
+
102
+
103
+ &__button-main {
104
+ height: 48px;
105
+ opacity: 1;
106
+ gap: var(--spacer-4);
107
+ border-radius: var(--corner-radius-max);
108
+ padding-top: 8px;
109
+ padding-right: 16px;
110
+ padding-bottom: 8px;
111
+ padding-left: 16px;
112
+ cursor: pointer;
113
+
114
+ &[data-haptic="1"] {
115
+ opacity: .6;
116
+ pointer-events: none;
117
+ }
118
+
119
+ &.primary {
120
+ padding-right: 3px;
121
+ justify-content: center;
122
+ grid-template-columns: 1fr 40px;
123
+ background: var(--primary-500);
124
+ color: var(--white);
125
+ align-content: center;
126
+ flex-wrap: wrap;
127
+
128
+ .icon.svg-wrapper {
129
+ height: 38px;
130
+ width: 38px;
131
+ color: var(--primary-500);
132
+ background-color: white;
133
+ border-radius: 50%;
134
+ padding: 9px;
135
+ }
136
+ }
137
+
138
+ &.secondary {
139
+ justify-content: center;
140
+ background-color: var(--neutral-200);
141
+
142
+ .icon.svg-wrapper {
143
+ height: 32px;
144
+ width: 32px;
145
+ color: var(--neutral-900);
146
+ border-radius: 50%;
147
+ padding: 6px;
148
+ }
149
+ }
150
+
151
+ svg {
152
+ width: 100%;
153
+ height: 100%;
154
+ }
155
+ }
156
+
157
+ &__button.btn {
158
+ width: auto;
159
+ height: 100%;
160
+ align-content: center;
161
+ display: flex;
162
+ flex-wrap: wrap;
163
+ justify-content: center;
164
+ line-height: 20px;
165
+ }
166
+
167
+ }
@@ -0,0 +1,41 @@
1
+
2
+ /**
3
+ * Class representing signup page in Welcome module.
4
+ * @class __welcome_signup
5
+ * @extends __welcome_interact
6
+ */
7
+ require('./skin');
8
+ const { dtk_common } = require("..")
9
+ export default class dtk_butler_dialog extends dtk_common {
10
+
11
+ /**
12
+ ** @param {object} opt
13
+ */
14
+ initialize(opt = {}) {
15
+ super.initialize(opt);
16
+ this.declareHandlers();
17
+ this.mset({ flow: _a.y })
18
+ }
19
+
20
+ /**
21
+ *
22
+ */
23
+ onDomRefresh() {
24
+ this.feed(require('./skeleton').default(this));
25
+ }
26
+
27
+ /**
28
+ * @param {LetcBox} cmd
29
+ * @param {any} args
30
+ */
31
+ onUiEvent(cmd, args = {}) {
32
+ const service = args.service || cmd.mget(_a.service);
33
+ this.debug(`onUiEvent service = ${service}`, cmd, this);
34
+
35
+ switch (service) {
36
+ default:
37
+ this.triggerHandlers({ service })
38
+ }
39
+ }
40
+
41
+ }
@@ -0,0 +1,27 @@
1
+ const { header } = require("../../../skeletons")
2
+
3
+ export default function (ui) {
4
+ const fig = ui.fig.family
5
+ const { title, message, buttons, body } = ui.model.toJSON()
6
+ let Buttons = null;
7
+ if (buttons) {
8
+ Buttons = Skeletons.Box.X({
9
+ className: `${fig}__buttons`,
10
+ kids: buttons
11
+ })
12
+ }
13
+ if (message == null) message = '';
14
+ let a = Skeletons.Box.Y({
15
+ className: `${fig}__main`,
16
+ debug: __filename,
17
+ kids: [
18
+ header(ui, title),
19
+ Skeletons.Element({ className: `${fig}__message`, content: message }),
20
+ body,
21
+ Buttons
22
+ ]
23
+ })
24
+
25
+ return a;
26
+
27
+ }
@@ -0,0 +1,22 @@
1
+ @use '@drumee/ui-styles/src/mixins';
2
+ @use '../../../skin' as *;
3
+
4
+ .dtk-butler-dialog {
5
+ @include dtk-butler-main;
6
+ @include dtk-butler-button;
7
+
8
+ &__message {
9
+ font-weight: 400;
10
+ font-style: normal;
11
+ font-size: 14px;
12
+ line-height: 22px;
13
+ text-align: center;
14
+ letter-spacing: 1px;
15
+
16
+ span {
17
+ font-weight: bold;
18
+ cursor: pointer;
19
+ }
20
+ }
21
+
22
+ }
@@ -0,0 +1,30 @@
1
+
2
+ /**
3
+ * Common class
4
+ */
5
+ export class dtk_common extends LetcBox {
6
+
7
+ /**
8
+ *
9
+ */
10
+ setItemState(pn, s = 0) {
11
+ this.ensurePart(pn).then((p) => { setTimeout(() => { p.setState(s) }, 100) })
12
+ }
13
+
14
+ /**
15
+ *
16
+ */
17
+ setItemStatus(pn, s = 0, attr = _a.status) {
18
+ this.ensurePart(pn).then((p) => { setTimeout(() => { p.el.dataset[attr] = s }, 100) })
19
+ }
20
+
21
+
22
+ /**
23
+ *
24
+ * @param {*} xhr
25
+ */
26
+ onServerComplain(xhr) {
27
+ this.warn(xhr)
28
+ }
29
+ }
30
+
@@ -0,0 +1,148 @@
1
+
2
+ require('./skin');
3
+ const { dtk_common } = require("..")
4
+ export default class dtk_otp extends dtk_common {
5
+
6
+ /**
7
+ ** @param {object} opt
8
+ */
9
+ initialize(opt = {}) {
10
+ super.initialize(opt);
11
+ this.declareHandlers();
12
+ this.mset({ flow: _a.y })
13
+ }
14
+
15
+ /**
16
+ *
17
+ */
18
+ bindPasteEvent() {
19
+ this.ensurePart("digits").then(async (p) => {
20
+ await Kind.waitFor('entry');
21
+ for (let c of p.children.toArray()) {
22
+ c.once("input:ready", () => {
23
+ c._input[0].onpaste = (e) => {
24
+ setTimeout(() => {
25
+ let value = c.getValue() || '';
26
+ if (!/[0-9]{1,6}/.test(value)) {
27
+ c.setValue("")
28
+ return
29
+ }
30
+ let digits = value.split('');
31
+ let i = c.getIndex();
32
+ for (let d of digits) {
33
+ if (!p.children._views[i]) continue;
34
+ p.children._views[i].setValue(d);
35
+ i++;
36
+ }
37
+ this.checkForm()
38
+ }, 300)
39
+ }
40
+ })
41
+ }
42
+ })
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param {*} msg
48
+ */
49
+ displayMessage(msg, error = 0) {
50
+ this.__tipsText.set({ content: msg });
51
+ this.__tipsText.el.dataset.error = error;
52
+ setTimeout(() => {
53
+ this.__tipsText.set({ content: '' });
54
+ this.__tipsText.el.dataset.error = error;
55
+ }, 3000)
56
+ }
57
+
58
+ /**
59
+ *
60
+ */
61
+ checkForm() {
62
+ this.ensurePart("digits").then((p) => {
63
+ let res = [];
64
+ for (let c of p.children.toArray()) {
65
+ let v = c.getValue()
66
+ if (/[0-9]/.test(v)) {
67
+ res.push(v)
68
+ }
69
+ }
70
+ let api = this.mget(_a.api)
71
+ let payload = this.mget('payload')
72
+ if (res.length >= 6) {
73
+ if (api) {
74
+ return this.postService(api, { ...payload, code: res.join('') }, { async: 1 }).then((data) => {
75
+ if(data.error){
76
+ return this.displayMessage(LOCALE.INVALID_CODE, 1)
77
+ }
78
+ let service = this.mget(_a.service) || 'otp-verified';
79
+ this.triggerHandlers({ data, service })
80
+ }).catch((e) => {
81
+ this.warn("[checkForm] OTP verify error", e)
82
+ this.displayMessage(LOCALE.INVALID_CODE, 1)
83
+ })
84
+ }
85
+ }
86
+ })
87
+ }
88
+
89
+ /**
90
+ *
91
+ */
92
+ onDomRefresh() {
93
+ this.feed(require("./skeleton").default(this));
94
+ this.bindPasteEvent();
95
+ }
96
+
97
+
98
+ /**
99
+ * @param {LetcBox} cmd
100
+ * @param {any} args
101
+ */
102
+ onUiEvent(cmd, args = {}) {
103
+ const service = args.service || cmd.get(_a.service);
104
+ let status = cmd.status;
105
+ switch (service) {
106
+ case _a.input:
107
+ cmd.focus();
108
+ if (status == _e.click) {
109
+ cmd.setValue('');
110
+ return;
111
+ }
112
+ let res = [];
113
+ this.ensurePart("digits").then((p) => {
114
+ let i = cmd.getIndex() + 1;
115
+ let value = cmd.getValue();
116
+ for (let c of p.children.toArray()) {
117
+ if (c.getIndex() < i) {
118
+ continue;
119
+ } else {
120
+ if (/[0-9]/.test(value) && /[0-9]/.test(status)) {
121
+ c.focus();
122
+ c.setValue('')
123
+ } else {
124
+ cmd.setValue('');
125
+ }
126
+ break;
127
+ }
128
+ }
129
+ this.checkForm()
130
+ })
131
+ break;
132
+ case "resend-code":
133
+ let { email } = this.mget('payload')
134
+ this.postService(SERVICE.otp.send, { email }).then((data) => {
135
+ this.mset({ payload: data })
136
+ this.displayMessage(LOCALE.NEW_CODE_RESENT)
137
+ }).catch((e) => {
138
+ this.displayMessage(LOCALE.UNKNOWN_ERROR, 1)
139
+ this.warn("AAA:104 Error sending OTP", e)
140
+ })
141
+ break;
142
+ default:
143
+ this.triggerHandlers({ ...args, service })
144
+ }
145
+ }
146
+
147
+
148
+ }
@@ -0,0 +1,85 @@
1
+ const { header } = require("../../../skeletons");
2
+
3
+ function __skl_welcome_signup(ui) {
4
+ const fig = ui.fig.family
5
+ let digits = []
6
+ let { title, message } = ui.model.toJSON()
7
+ for (let i = 0; i < 6; i++) {
8
+ digits.push(
9
+ Skeletons.Entry({
10
+ name: `digit-${i}`,
11
+ service: _a.input
12
+ })
13
+ )
14
+ }
15
+ const code = Skeletons.Box.X({
16
+ kidsOpt: {
17
+ className: `${fig}__digit`,
18
+ placeholder: "",
19
+ min: 0,
20
+ max: 9,
21
+ maxlength: 6,
22
+ interactive: 1
23
+ },
24
+ className: `${fig}__digits`,
25
+ sys_pn: "digits",
26
+ kids: digits
27
+ })
28
+
29
+ const resend = Skeletons.Box.X({
30
+ className: `${fig}__resend`,
31
+ kidsOpt: {
32
+ tagName: _K.tag.span,
33
+ },
34
+ kids: [
35
+ Skeletons.Element({
36
+ className: `${fig}__resend-text`,
37
+ content: `${LOCALE.DIDNT_GET_EMAIL} ${LOCALE.OR}`
38
+ }),
39
+ Skeletons.Element({
40
+ className: `${fig}__resend-text resend`,
41
+ content: LOCALE.RESEND_CODE,
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`,
56
+ }),
57
+ ]
58
+ })
59
+
60
+ if (_.isString(message)) {
61
+ message = Skeletons.Box.X({
62
+ className: `${fig}__message`,
63
+ kids: [
64
+ Skeletons.Element({
65
+ className: `${fig}__message-text`,
66
+ content: message
67
+ })
68
+ ]
69
+ });
70
+ }
71
+ return Skeletons.Box.Y({
72
+ className: `${fig}__main`,
73
+ debug: __filename,
74
+ kids: [
75
+ header(ui, title || LOCALE.VALIDATION_SENT_TO),
76
+ message,
77
+ code,
78
+ tips,
79
+ resend
80
+ ]
81
+ })
82
+
83
+ }
84
+
85
+ export default __skl_welcome_signup