@drumee/ui-toolkit 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Drumee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # ui-toolkit
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@drumee/ui-toolkit",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": ".",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:drumee/package.json.git"
9
+ },
10
+ "keywords": [
11
+ "Drumee UI toolkit"
12
+ ],
13
+ "scripts": {
14
+ "release": "git push && npm publish --access public && npm version patch"
15
+ },
16
+ "author": "Somanos Sar <somanos.sar@drumee.com>",
17
+ "devDependencies": {
18
+ "@babel/core": "^7.19.1",
19
+ "@babel/preset-env": "^7.19.1",
20
+ "@unocss/preset-wind4": "^66.3.3",
21
+ "@unocss/webpack": "^66.3.3",
22
+ "argparse": "^2.0.1",
23
+ "autoprefixer": "^10.4.21",
24
+ "babel-loader": "^8.2.5",
25
+ "babel-plugin-syntax-dynamic-import": "^6.18.0",
26
+ "clean-webpack-plugin": "^4.0.0",
27
+ "css-loader": "^6.7.1",
28
+ "cssnano": "^5.1.13",
29
+ "extract-css-chunks-webpack-plugin": "^4.9.0",
30
+ "file-loader": "^6.2.0",
31
+ "inspectpack": "^4.7.1",
32
+ "json-loader": "^0.5.7",
33
+ "json2md": "^2.0.3",
34
+ "jsonfile": "^6.1.0",
35
+ "mini-css-extract-plugin": "^2.6.1",
36
+ "minimist": "^1.2.6",
37
+ "postcss": "^8.4.16",
38
+ "postcss-cli": "^10.0.0",
39
+ "postcss-loader": "^7.3.4",
40
+ "postcss-preset-env": "^7.8.2",
41
+ "postcss-scss": "^4.0.9",
42
+ "raw-loader": "^4.0.2",
43
+ "sass": "^1.93.3",
44
+ "sass-loader": "^16.0.6",
45
+ "sass-resources-loader": "^2.2.5",
46
+ "shelljs": "^0.8.5",
47
+ "style-loader": "^3.3.1",
48
+ "terser-webpack-plugin": "^5.3.9",
49
+ "ts-loader": "^9.4.1",
50
+ "typescript": "^4.8.3",
51
+ "underscore-template-loader": "^1.1.0",
52
+ "unocss": "^66.3.3",
53
+ "url-loader": "^4.1.1",
54
+ "walkdir": "^0.4.1",
55
+ "webpack": "^5.82.0",
56
+ "webpack-cli": "^5.1.1",
57
+ "webpack-stats-plugin": "^1.1.1"
58
+ },
59
+ "dependencies": {
60
+ "@drumee/ui-styles": "^1.0.1"
61
+ }
62
+ }
@@ -0,0 +1,168 @@
1
+ /**
2
+ *
3
+ * @param {*} ui
4
+ * @param {*} opt
5
+ * @returns
6
+ */
7
+ export function button(ui, opt) {
8
+ let { label, ico, service, sys_pn, className, priority = "primary", type, haptic } = opt;
9
+ const pfx = className || `${ui.fig.group}__button`;
10
+ let kids = []
11
+ if (label) kids.push(
12
+ Skeletons.Element({
13
+ className: `${pfx} btn`,
14
+ content: label,
15
+ tagName: _K.tag.span,
16
+ })
17
+ )
18
+ let main = Skeletons.Box.G;
19
+ if (ico) {
20
+ let el = Skeletons.Button.Svg({
21
+ className: `${pfx} icon`,
22
+ ico,
23
+ })
24
+ if ([_a.api].includes(type)) {
25
+ kids.unshift(el);
26
+ main = Skeletons.Box.X;
27
+ } else if ([_a.row].includes(type)) {
28
+ kids.push(el)
29
+ main = Skeletons.Box.X;
30
+ } else {
31
+ kids.push(el)
32
+ main = Skeletons.Box.G;
33
+ }
34
+ }
35
+
36
+ return main({
37
+ className: `${pfx}-main ${priority}`,
38
+ partHandler: [ui],
39
+ uiHandler: [ui],
40
+ sys_pn,
41
+ service,
42
+ haptic,
43
+ kidsOpt: {
44
+ active: 0,
45
+ },
46
+ kids
47
+ })
48
+ }
49
+
50
+ /**
51
+ *
52
+ * @param {*} ui
53
+ * @returns
54
+ */
55
+ export function header(ui, content, tips) {
56
+ const fig = ui.fig.family;
57
+ let kids = [
58
+ Skeletons.Box.X({
59
+ className: `${fig}__logo-container`,
60
+ kids: [
61
+ Skeletons.Button.Svg({
62
+ ico: "raw-logo-drumee-icon",
63
+ className: `${fig}__logo-content`,
64
+ })
65
+ ]
66
+ }),
67
+
68
+ Skeletons.Box.Y({
69
+ className: `${fig}__text-container`,
70
+ kids: [
71
+ Skeletons.Note({
72
+ className: `${fig}__title`,
73
+ content
74
+ }),
75
+ ]
76
+ })
77
+
78
+ ]
79
+
80
+ if (tips) {
81
+ kids.push(Skeletons.Box.Y({
82
+ className: `${fig}__text-container`,
83
+ kids: [
84
+ Skeletons.Note({
85
+ className: `${fig}__tips`,
86
+ tips
87
+ }),
88
+ ]
89
+ }))
90
+ }
91
+
92
+ let a = Skeletons.Box.Y({
93
+ className: `${ui.fig.family}__header`,
94
+ debug: __filename,
95
+ kids
96
+ })
97
+ return a;
98
+ }
99
+
100
+ /**
101
+ *
102
+ * @param {*} ui
103
+ * @param {*} opt
104
+ * @returns
105
+ */
106
+ export function entry(ui, opt) {
107
+ let { value, name, placeholder, label, sys_pn, service = _a.input, autocomplete } = opt;
108
+ autocomplete = autocomplete || name;
109
+ const pfx = `${ui.fig.family}__entry`;
110
+ let args = {
111
+ className: `${pfx}-input`,
112
+ name,
113
+ value,
114
+ formItem: name,
115
+ innerClass: name,
116
+ mode: _a.interactive,
117
+ service,
118
+ placeholder,
119
+ uiHandler: [ui],
120
+ autocomplete,
121
+ radio: ui._id
122
+ }
123
+ if (sys_pn) {
124
+ args.sys_pn = sys_pn;
125
+ args.partHandler = [ui];
126
+ }
127
+ return Skeletons.Box.Y({
128
+ className: `${pfx}-main`,
129
+ kids: [
130
+ Skeletons.Note({
131
+ className: `${pfx}-label ${name}`,
132
+ content: label,
133
+ }),
134
+ Skeletons.Entry(args)
135
+ ]
136
+ })
137
+ }
138
+
139
+ /**
140
+ *
141
+ * @param {*} ui
142
+ * @param {*} cn
143
+ * @param {*} passmeter
144
+ * @returns
145
+ */
146
+ export function password(ui, opt) {
147
+ const { placeholder, interactive = 1, name, service, sys_pn } = opt;
148
+ const pfx = `${ui.fig.family}__entry`;
149
+ return Skeletons.Box.X({
150
+ className: `${pfx}-main`,
151
+ sys_pn: 'wrapper-pw',
152
+ partHandler: [ui],
153
+ kids: [
154
+ Skeletons.EntryBox({
155
+ uiHandler: [ui],
156
+ type: _a.password,
157
+ className: `${pfx}-input`,
158
+ service: service || _e.submit,
159
+ name,
160
+ placeholder,
161
+ interactive,
162
+ sys_pn,
163
+ shower: 1
164
+ })
165
+ ]
166
+ });
167
+ }
168
+
package/skin/skin.scss ADDED
@@ -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,42 @@
1
+
2
+ /**
3
+ * Class representing signup page in Welcome module.
4
+ * @class __welcome_signup
5
+ * @extends __welcome_interact
6
+ */
7
+ const Common = require("..")
8
+ require('./skin');
9
+
10
+ export class dtk_butler_dialog extends Common {
11
+
12
+ /**
13
+ ** @param {object} opt
14
+ */
15
+ initialize(opt = {}) {
16
+ super.initialize(opt);
17
+ this.declareHandlers();
18
+ this.mset({ flow: _a.y })
19
+ }
20
+
21
+ /**
22
+ *
23
+ */
24
+ onDomRefresh() {
25
+ this.feed(require('./skeleton').default(this));
26
+ }
27
+
28
+ /**
29
+ * @param {LetcBox} cmd
30
+ * @param {any} args
31
+ */
32
+ onUiEvent(cmd, args = {}) {
33
+ const service = args.service || cmd.mget(_a.service);
34
+ this.debug(`onUiEvent service = ${service}`, cmd, this);
35
+
36
+ switch (service) {
37
+ default:
38
+ this.triggerHandlers({ service })
39
+ }
40
+ }
41
+
42
+ }
@@ -0,0 +1,23 @@
1
+ const { header } = require("../../../skeletons")
2
+
3
+ export default function (ui) {
4
+ const fig = ui.fig.family
5
+ const { title, message, buttons } = ui.model.toJSON()
6
+ const Buttons = Skeletons.Box.X({
7
+ className: `${fig}__buttons`,
8
+ kids: buttons
9
+ })
10
+
11
+ let a = Skeletons.Box.Y({
12
+ className: `${fig}__main`,
13
+ debug: __filename,
14
+ kids: [
15
+ header(ui, title),
16
+ Skeletons.Element({ className: `${fig}__message`, content: message || LOCALE.ERROR_SERVER }),
17
+ Buttons
18
+ ]
19
+ })
20
+
21
+ return a;
22
+
23
+ }
@@ -0,0 +1,22 @@
1
+ @use '@drumee/ui-styles/src/mixins';
2
+ @use '../../toolkit/skin' as *;
3
+
4
+ .dtk-butler-dialog {
5
+ @include dtk-butler-main;
6
+
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,31 @@
1
+
2
+ /**
3
+ * Common class
4
+ */
5
+ class signup_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
+
31
+ module.exports = signup_common
@@ -0,0 +1,114 @@
1
+
2
+ require('./skin');
3
+ const Common = require("..")
4
+ export class dtk_otp extends 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
+ this.debug("OM ZZZ PASTE", e, c.getValue())
26
+ let value = c.getValue() || '';
27
+ if (!/[0-9]{1,6}/.test(value)) {
28
+ c.setValue("")
29
+ return
30
+ }
31
+ let digits = value.split('');
32
+ let i = c.getIndex();
33
+ for (let d of digits) {
34
+ if (!p.children._views[i]) continue;
35
+ p.children._views[i].setValue(d);
36
+ i++;
37
+ }
38
+ this.checkForm()
39
+ }, 300)
40
+ }
41
+ })
42
+ }
43
+ })
44
+ }
45
+
46
+ /**
47
+ *
48
+ */
49
+ checkForm(api) {
50
+ this.ensurePart("digits").then((p) => {
51
+ let res = [];
52
+ for (let c of p.children.toArray()) {
53
+ let v = c.getValue()
54
+ if (/[0-9]/.test(v)) {
55
+ res.push(v)
56
+ }
57
+ }
58
+ if (res.length >= 6) {
59
+ if (api) {
60
+ return this.postService(api, { otp: res.join('') }, { async: 1 })
61
+ }
62
+ }
63
+ })
64
+ }
65
+
66
+ /**
67
+ *
68
+ */
69
+ onDomRefresh() {
70
+ this.feed(require("./skeleton").default(this));
71
+ this.bindPasteEvent();
72
+ }
73
+
74
+
75
+ /**
76
+ * @param {LetcBox} cmd
77
+ * @param {any} args
78
+ */
79
+ onUiEvent(cmd, args = {}) {
80
+ const service = args.service || cmd.get(_a.service);
81
+ let status = cmd.status;
82
+ this.debug(`onUiEvent service = ${service}`, args, status, cmd);
83
+ switch (service) {
84
+ case _a.input:
85
+ cmd.focus();
86
+ if (status == _e.click) {
87
+ cmd.setValue('');
88
+ return;
89
+ }
90
+ let res = [];
91
+ this.ensurePart("digits").then((p) => {
92
+ let i = cmd.getIndex() + 1;
93
+ let value = cmd.getValue();
94
+ for (let c of p.children.toArray()) {
95
+ if (c.getIndex() < i) {
96
+ continue;
97
+ } else {
98
+ if (/[0-9]/.test(value) && /[0-9]/.test(status)) {
99
+ c.focus();
100
+ c.setValue('')
101
+ } else {
102
+ cmd.setValue('');
103
+ }
104
+ break;
105
+ }
106
+ }
107
+ this.checkForm()
108
+ })
109
+ break;
110
+ }
111
+ }
112
+
113
+
114
+ }
@@ -0,0 +1,71 @@
1
+ const { header } = require("../../toolkit/skeleton")
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: _a.resend
43
+ }),
44
+ ]
45
+ })
46
+
47
+ if (_.isString(message)) {
48
+ message = Skeletons.Box.X({
49
+ className: `${fig}__message`,
50
+ kids: [
51
+ Skeletons.Element({
52
+ className: `${fig}__message-text`,
53
+ content: message
54
+ })
55
+ ]
56
+ });
57
+ }
58
+ return Skeletons.Box.Y({
59
+ className: `${fig}__main`,
60
+ debug: __filename,
61
+ kids: [
62
+ header(ui, title || LOCALE.VALIDATION_SENT_TO),
63
+ message,
64
+ code,
65
+ resend
66
+ ]
67
+ })
68
+
69
+ }
70
+
71
+ export default __skl_welcome_signup
@@ -0,0 +1,67 @@
1
+ @use '../../toolkit/skin' as *;
2
+
3
+ .dtk-otp {
4
+ @include dtk-butler-main;
5
+
6
+ &__digits {
7
+ width: 100%;
8
+ justify-content: center;
9
+ height: 78px;
10
+ gap: var(--spacer-6);
11
+ }
12
+
13
+ &__digit {
14
+ width: 52px;
15
+ height: 72px;
16
+ opacity: 1;
17
+ gap: 16px;
18
+ border-radius: var(--corner-radius-max);
19
+ padding-top: 8px;
20
+ padding-right: 16px;
21
+ padding-bottom: 8px;
22
+ padding-left: 16px;
23
+ border: 1px var(--neutral-200) solid;
24
+
25
+ input {
26
+ width: 100%;
27
+ width: 100%;
28
+ font-weight: 400;
29
+ font-style: normal;
30
+ font-size: 32px;
31
+ line-height: 40px;
32
+ text-align: center;
33
+ vertical-align: middle;
34
+
35
+ &:focus {
36
+ background: var(--primary-100);
37
+ color: var(--primary-500);
38
+ }
39
+ }
40
+
41
+ &:focus-within {
42
+ border: 1px solid var(--primary-500);
43
+ background: var(--primary-100);
44
+ }
45
+ }
46
+
47
+ &__resend {
48
+ width: 100%;
49
+ justify-content: start;
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
+ &.resend {
61
+ color: var(--primary-500);
62
+ font-weight: bold;
63
+ cursor: pointer;
64
+ }
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,80 @@
1
+
2
+
3
+ require('./skin');
4
+
5
+ export class dtk_pwmeter extends LetcBox {
6
+
7
+ /**
8
+ ** @param {object} opt
9
+ */
10
+ initialize(opt = {}) {
11
+ super.initialize(opt);
12
+ this.declareHandlers();
13
+ this.mset({ flow: _a.y })
14
+ }
15
+
16
+ /**
17
+ *
18
+ */
19
+ onDomRefresh() {
20
+ this.feed(require('./skeleton').default(this));
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @param {*} pw
26
+ */
27
+ check(pw) {
28
+ let rate = 100 * (pw.length / 20) + 5;
29
+ if (rate > 100) rate = 100;
30
+ this.__strengthGrade.el.style.width = `${rate}%`;
31
+ let min = 6;
32
+ this._isValid = 0;
33
+ if (pw.length < min) {
34
+ this.__strengthState.set({ content: LOCALE.WEAK })
35
+ this.__strengthGrade.el.dataset.strenght = "0";
36
+ this.__errorMessage.set({ content: LOCALE.PASSWORD_AT_LEAST.format(min) })
37
+ } else if (pw.length <= 10) {
38
+ this.__strengthState.set({ content: LOCALE.STRONG })
39
+ this.__strengthGrade.el.dataset.strenght = "1";
40
+ this.__errorMessage.set({ content: "" })
41
+ this._isValid = 1;
42
+ } else {
43
+ this.__strengthGrade.el.dataset.strenght = "2";
44
+ this.__strengthState.set({ content: LOCALE.VERY_STRONG })
45
+ this.__errorMessage.set({ content: "" });
46
+ this._isValid = 1;
47
+ }
48
+ }
49
+
50
+ /**
51
+ *
52
+ * @returns
53
+ */
54
+ isValid(){
55
+ return this._isValid
56
+ }
57
+
58
+ /**
59
+ *
60
+ * @param {*} pw
61
+ */
62
+ message(content) {
63
+ this.__errorMessage.set({ content })
64
+ }
65
+
66
+ /**
67
+ * @param {LetcBox} cmd
68
+ * @param {any} args
69
+ */
70
+ onUiEvent(cmd, args = {}) {
71
+ const service = args.service || cmd.mget(_a.service);
72
+ this.debug(`onUiEvent service = ${service}`, cmd, this);
73
+
74
+ switch (service) {
75
+ default:
76
+ this.triggerHandlers({ service })
77
+ }
78
+ }
79
+
80
+ }
@@ -0,0 +1,48 @@
1
+
2
+ /**
3
+ *
4
+ * @param {*} ui
5
+ * @param {*} opt
6
+ * @returns
7
+ */
8
+ function passmeter(ui, opt) {
9
+ let fig = `${ui.fig.family}`
10
+ return Skeletons.Box.Y({
11
+ className: `${fig}__main`,
12
+ kids: [
13
+ Skeletons.Box.X({
14
+ className: `${fig}__dashboard`,
15
+ kids: [
16
+ Skeletons.Element({
17
+ className: `${fig}__topic`,
18
+ content: LOCALE.PASSWORD_STRENGTH
19
+ }),
20
+ Skeletons.Note({
21
+ className: `${fig}__strength-state`,
22
+ content: "",
23
+ sys_pn: "strength-state"
24
+ }),
25
+ Skeletons.Box.X({
26
+ className: `${fig}__strength-container`,
27
+ kids: [
28
+ Skeletons.Element({
29
+ className: `${fig}__strength-content`,
30
+ sys_pn: "strength-grade"
31
+ }),
32
+ ]
33
+ })
34
+ ]
35
+ }),
36
+ Skeletons.Note({
37
+ className: `${fig}__error`,
38
+ content: "",
39
+ sys_pn: "error-message"
40
+ }),
41
+ ]
42
+ })
43
+ };
44
+
45
+
46
+
47
+
48
+ export default passmeter
@@ -0,0 +1,58 @@
1
+ .dtk-pwsetter {
2
+ &__ui {
3
+ width: 100%;
4
+ }
5
+
6
+ &__main {
7
+ font-weight: 400;
8
+ width: 100%;
9
+ font-style: normal;
10
+ font-size: 14px;
11
+ line-height: 22px;
12
+ text-align: center;
13
+ letter-spacing: 1px;
14
+ color: var(--neutral-600);
15
+ }
16
+
17
+ &__topic {
18
+ margin-right: auto;
19
+ }
20
+
21
+ &__strength-state {
22
+ min-width: 40px;
23
+ }
24
+
25
+ &__dashboard {
26
+ gap: 10px;
27
+ }
28
+
29
+ &__strength-container {
30
+ width: 48px;
31
+ align-content: center;
32
+ flex-wrap: wrap;
33
+ gap: 10px;
34
+ }
35
+
36
+ &__strength-content {
37
+ height: 4px;
38
+ width: 0;
39
+ border-radius: var(--corner-radius-max);
40
+
41
+ &[data-strenght="0"] {
42
+ background-color: var(--red-500);
43
+ }
44
+
45
+ &[data-strenght="1"] {
46
+ background-color: var(--green-200);
47
+ }
48
+
49
+ &[data-strenght="2"] {
50
+ background-color: var(--green-400);
51
+ }
52
+ }
53
+
54
+ &__error {
55
+ color: var(--red-500);
56
+ }
57
+
58
+ }