@getpara/core-components 2.0.0-alpha.7 → 2.0.0-alpha.71
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/dist/capsule/capsule.esm.js +1 -1
- package/dist/capsule/capsule.esm.js.map +1 -1
- package/dist/capsule/index.esm.js +1 -1
- package/dist/capsule/index.esm.js.map +1 -1
- package/dist/capsule/p-3719bb1e.entry.js +2 -0
- package/dist/capsule/p-3719bb1e.entry.js.map +1 -0
- package/dist/capsule/p-cc804d27.entry.js +28 -0
- package/dist/capsule/p-cc804d27.entry.js.map +1 -0
- package/dist/cjs/capsule.cjs.js +1 -1
- package/dist/cjs/cpsl-alert_34.cjs.entry.js +627 -77
- package/dist/cjs/cpsl-alert_34.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-identicon.cjs.entry.js +4 -2
- package/dist/cjs/cpsl-identicon.cjs.entry.js.map +1 -1
- package/dist/cjs/index.cjs.js +5 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/assets/icons/arrow-circle-down.svg +3 -0
- package/dist/collection/assets/icons/backpack.svg +8 -0
- package/dist/collection/assets/icons/bera-brand.svg +7 -0
- package/dist/collection/assets/icons/coinbase.svg +10 -0
- package/dist/collection/assets/icons/cosmos-circle.svg +4 -0
- package/dist/collection/assets/icons/cosmostation.svg +11 -0
- package/dist/collection/assets/icons/dots-square.svg +13 -0
- package/dist/collection/assets/icons/eth-circle.svg +9 -0
- package/dist/collection/assets/icons/glow.svg +15 -0
- package/dist/collection/assets/icons/haha.svg +15 -0
- package/dist/collection/assets/icons/index.js +60 -0
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/assets/icons/keplr.svg +30 -0
- package/dist/collection/assets/icons/leap.svg +20 -0
- package/dist/collection/assets/icons/metamask.svg +21 -0
- package/dist/collection/assets/icons/okx.svg +15 -0
- package/dist/collection/assets/icons/para-arrow.svg +3 -0
- package/dist/collection/assets/icons/phantom.svg +11 -0
- package/dist/collection/assets/icons/rabby.svg +24 -0
- package/dist/collection/assets/icons/rainbow.svg +54 -0
- package/dist/collection/assets/icons/safe.svg +7 -0
- package/dist/collection/assets/icons/shuffle.svg +3 -0
- package/dist/collection/assets/icons/solana-circle.svg +20 -0
- package/dist/collection/assets/icons/solflare.svg +11 -0
- package/dist/collection/assets/icons/star-05.svg +3 -0
- package/dist/collection/assets/icons/user-01.svg +3 -0
- package/dist/collection/assets/icons/user-plus.svg +3 -0
- package/dist/collection/assets/icons/valora.svg +25 -0
- package/dist/collection/assets/icons/wallet-02.svg +3 -0
- package/dist/collection/assets/icons/wallet-connect.svg +3 -0
- package/dist/collection/assets/icons/zap.svg +3 -0
- package/dist/collection/assets/icons/zerion.svg +15 -0
- package/dist/collection/components/cpsl-alert/cpsl-alert.css +14 -8
- package/dist/collection/components/cpsl-alert/cpsl-alert.js +1 -1
- package/dist/collection/components/cpsl-auth-modal/cpsl-auth-modal.css +4 -4
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.js +111 -22
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.js.map +1 -1
- package/dist/collection/components/cpsl-icon/cpsl-icon.css +16 -9
- package/dist/collection/components/cpsl-icon/cpsl-icon.js +75 -2
- package/dist/collection/components/cpsl-icon/cpsl-icon.js.map +1 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.css +2 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.js +21 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.js.map +1 -1
- package/dist/collection/components/cpsl-input/cpsl-input.js +1 -1
- package/dist/collection/components/cpsl-overlay/cpsl-overlay.css +1 -1
- package/dist/collection/components/cpsl-popover/cpsl-popover.js +44 -37
- package/dist/collection/components/cpsl-popover/cpsl-popover.js.map +1 -1
- package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js +1 -1
- package/dist/collection/components/cpsl-select/cpsl-select.css +5 -0
- package/dist/collection/components/cpsl-select/cpsl-select.js +23 -4
- package/dist/collection/components/cpsl-select/cpsl-select.js.map +1 -1
- package/dist/collection/components/cpsl-select-item/cpsl-select-item.css +0 -1
- package/dist/collection/components/cpsl-select-item/cpsl-select-item.js +9 -1
- package/dist/collection/components/cpsl-select-item/cpsl-select-item.js.map +1 -1
- package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js +2 -2
- package/dist/collection/components/cpsl-spinner/cpsl-spinner.css +10 -2
- package/dist/collection/components/cpsl-spinner/cpsl-spinner.js +7 -7
- package/dist/collection/components/cpsl-spinner/cpsl-spinner.js.map +1 -1
- package/dist/collection/components/cpsl-text/cpsl-text.css +25 -0
- package/dist/collection/components/cpsl-text/cpsl-text.js +25 -3
- package/dist/collection/components/cpsl-text/cpsl-text.js.map +1 -1
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.css +10 -0
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js +23 -2
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js.map +1 -1
- package/dist/collection/interface.js.map +1 -1
- package/dist/collection/utils/theme/generatePalette.js +3 -1
- package/dist/collection/utils/theme/generatePalette.js.map +1 -1
- package/dist/collection/utils/theme/generateTheme.js +2 -1
- package/dist/collection/utils/theme/generateTheme.js.map +1 -1
- package/dist/esm/capsule.js +1 -1
- package/dist/esm/cpsl-alert_34.entry.js +627 -77
- package/dist/esm/cpsl-alert_34.entry.js.map +1 -1
- package/dist/esm/cpsl-identicon.entry.js +4 -2
- package/dist/esm/cpsl-identicon.entry.js.map +1 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/scripts/appendLoaderExports.js +3 -3
- package/dist/scripts/appendLoaderExports.js.map +1 -1
- package/dist/types/assets/icons/index.d.ts +30 -0
- package/dist/types/components/cpsl-code-input/cpsl-code-input.d.ts +2 -0
- package/dist/types/components/cpsl-icon/cpsl-icon.d.ts +16 -0
- package/dist/types/components/cpsl-identicon/cpsl-identicon.d.ts +1 -0
- package/dist/types/components/cpsl-popover/cpsl-popover.d.ts +5 -0
- package/dist/types/components/cpsl-select/cpsl-select.d.ts +6 -1
- package/dist/types/components/cpsl-spinner/cpsl-spinner.d.ts +2 -2
- package/dist/types/components/cpsl-text/cpsl-text.d.ts +7 -1
- package/dist/types/components/cpsl-tile-button/cpsl-tile-button.d.ts +5 -0
- package/dist/types/components.d.ts +74 -8
- package/dist/types/interface.d.ts +1 -0
- package/dist/types/utils/theme/generatePalette.d.ts +1 -1
- package/dist/types/utils/theme/generateTheme.d.ts +1 -1
- package/package.json +36 -36
- package/dist/capsule/p-438442c7.entry.js +0 -2
- package/dist/capsule/p-438442c7.entry.js.map +0 -1
- package/dist/capsule/p-5049e2a1.entry.js +0 -28
- package/dist/capsule/p-5049e2a1.entry.js.map +0 -1
- /package/dist/types/Users/{keith/Documents/capsule → norwood/capsule-repos}/web-sdk/packages/core-components/.stencil/scripts/appendLoaderExports.d.ts +0 -0
- /package/dist/types/Users/{keith/Documents/capsule → norwood/capsule-repos}/web-sdk/packages/core-components/.stencil/scripts/buildAssets.d.ts +0 -0
|
@@ -2,7 +2,6 @@ import { Host, h } from "@stencil/core";
|
|
|
2
2
|
export class CpslCodeInput {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.handleInput = (ind, ev) => {
|
|
5
|
-
var _a;
|
|
6
5
|
const inputElements = this.inputs;
|
|
7
6
|
// If getting an insertFromPaste remove the last element value since the value setting is handled in the paste event
|
|
8
7
|
if (ev.inputType === 'insertFromPaste') {
|
|
@@ -11,36 +10,89 @@ export class CpslCodeInput {
|
|
|
11
10
|
}
|
|
12
11
|
if (ev.inputType === 'insertText') {
|
|
13
12
|
if (this.type === 'number' && isNaN(parseInt(ev.data))) {
|
|
13
|
+
ev.preventDefault();
|
|
14
14
|
inputElements[ind].value = '';
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Prevent the default behavior FIRST
|
|
18
|
+
ev.preventDefault();
|
|
19
|
+
// Build the new code from the current component state, not the DOM
|
|
20
|
+
const currentCode = this.code || '';
|
|
21
|
+
// Insert the new character at the focused position, not at the end
|
|
22
|
+
const beforeFocused = currentCode.substring(0, ind);
|
|
23
|
+
const afterFocused = currentCode.substring(ind + 1);
|
|
24
|
+
const newCode = beforeFocused + ev.data + afterFocused;
|
|
25
|
+
// Prevent input beyond the maximum length
|
|
26
|
+
if (newCode.length > this.length) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// Update the component state and emit event
|
|
19
30
|
this.cpslInput.emit({ value: newCode });
|
|
20
31
|
this.code = newCode;
|
|
32
|
+
// Update the specific input that was typed in
|
|
33
|
+
inputElements[ind].value = ev.data;
|
|
34
|
+
// Focus next input if not at the end
|
|
35
|
+
if (ind < this.length - 1) {
|
|
36
|
+
// Set flag to prevent handleFocus from interfering
|
|
37
|
+
this.isArrowNavigation = true;
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
inputElements[ind + 1].focus();
|
|
40
|
+
this.isArrowNavigation = false;
|
|
41
|
+
}, 0);
|
|
42
|
+
}
|
|
21
43
|
}
|
|
22
44
|
};
|
|
45
|
+
this.isArrowNavigation = false;
|
|
23
46
|
this.handleKeyDown = (ind, ev) => {
|
|
24
47
|
const inputElements = this.inputs;
|
|
25
48
|
switch (ev.key) {
|
|
26
49
|
case 'Backspace': {
|
|
27
50
|
let newCode;
|
|
28
51
|
if (!inputElements[ind].value) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
// If current input is empty, move to previous and clear it
|
|
53
|
+
if (ind > 0) {
|
|
54
|
+
inputElements[ind - 1].value = '';
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
inputElements[ind - 1].focus();
|
|
57
|
+
}, 0);
|
|
58
|
+
// Remove character at previous position
|
|
59
|
+
const currentCode = this.code || '';
|
|
60
|
+
newCode = currentCode.substring(0, ind - 1) + currentCode.substring(ind);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
newCode = this.code;
|
|
64
|
+
}
|
|
32
65
|
}
|
|
33
66
|
else {
|
|
34
|
-
|
|
67
|
+
// Clear current input and remove character at current position
|
|
68
|
+
inputElements[ind].value = '';
|
|
69
|
+
const currentCode = this.code || '';
|
|
70
|
+
newCode = currentCode.substring(0, ind) + currentCode.substring(ind + 1);
|
|
35
71
|
}
|
|
36
72
|
this.cpslInput.emit({ value: newCode });
|
|
37
73
|
this.code = newCode;
|
|
38
74
|
break;
|
|
39
75
|
}
|
|
40
76
|
case 'ArrowLeft': {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
77
|
+
ev.preventDefault();
|
|
78
|
+
if (ind > 0) {
|
|
79
|
+
this.isArrowNavigation = true;
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
inputElements[ind - 1].focus();
|
|
82
|
+
this.isArrowNavigation = false;
|
|
83
|
+
}, 0);
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'ArrowRight': {
|
|
88
|
+
ev.preventDefault();
|
|
89
|
+
if (ind < this.length - 1) {
|
|
90
|
+
this.isArrowNavigation = true;
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
inputElements[ind + 1].focus();
|
|
93
|
+
this.isArrowNavigation = false;
|
|
94
|
+
}, 0);
|
|
95
|
+
}
|
|
44
96
|
break;
|
|
45
97
|
}
|
|
46
98
|
default: {
|
|
@@ -50,6 +102,21 @@ export class CpslCodeInput {
|
|
|
50
102
|
};
|
|
51
103
|
this.handleFocus = (ind) => {
|
|
52
104
|
const inputElements = this.inputs;
|
|
105
|
+
// Don't interfere with arrow key navigation
|
|
106
|
+
if (this.isArrowNavigation) {
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
inputElements[ind].setSelectionRange(1, 1);
|
|
109
|
+
}, 0);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// If the focused input already has a value, allow it to stay focused (user clicked on it)
|
|
113
|
+
if (inputElements[ind].value) {
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
inputElements[ind].setSelectionRange(1, 1);
|
|
116
|
+
}, 0);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Otherwise, use the default focus logic (find first empty or go to last)
|
|
53
120
|
for (const input of inputElements) {
|
|
54
121
|
if (!input.value) {
|
|
55
122
|
input.focus();
|
|
@@ -66,21 +133,28 @@ export class CpslCodeInput {
|
|
|
66
133
|
};
|
|
67
134
|
this.handlePaste = (e) => {
|
|
68
135
|
const inputElements = this.inputs;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
136
|
+
let pastedCode = e.clipboardData.getData('text');
|
|
137
|
+
// Filter based on type
|
|
138
|
+
if (this.type === 'number') {
|
|
139
|
+
// Remove all non-numeric characters
|
|
140
|
+
pastedCode = pastedCode.replace(/\D/g, '');
|
|
141
|
+
// If no valid numbers remain, clear and return
|
|
142
|
+
if (!pastedCode) {
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
inputElements[0].value = '';
|
|
145
|
+
}, 0);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
76
148
|
}
|
|
149
|
+
// Truncate pasted code to match the expected length
|
|
150
|
+
const truncatedCode = pastedCode.substring(0, this.length);
|
|
77
151
|
this.cpslInput.emit({
|
|
78
|
-
value:
|
|
152
|
+
value: truncatedCode,
|
|
79
153
|
});
|
|
80
154
|
inputElements.forEach((input, index) => {
|
|
81
|
-
input.value =
|
|
155
|
+
input.value = truncatedCode.charAt(index) || '';
|
|
82
156
|
});
|
|
83
|
-
inputElements[Math.min(this.length - 1,
|
|
157
|
+
inputElements[Math.min(this.length - 1, truncatedCode.length)].focus();
|
|
84
158
|
};
|
|
85
159
|
this.code = undefined;
|
|
86
160
|
this.errorText = undefined;
|
|
@@ -88,15 +162,24 @@ export class CpslCodeInput {
|
|
|
88
162
|
this.length = undefined;
|
|
89
163
|
this.type = 'number';
|
|
90
164
|
}
|
|
165
|
+
watchCodeProp(newCode) {
|
|
166
|
+
// Update the input values when the code prop changes externally
|
|
167
|
+
const inputElements = this.inputs;
|
|
168
|
+
if (inputElements.length > 0) {
|
|
169
|
+
inputElements.forEach((input, index) => {
|
|
170
|
+
input.value = (newCode === null || newCode === void 0 ? void 0 : newCode[index]) || '';
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
91
174
|
get inputs() {
|
|
92
175
|
return Array.from(this.el.shadowRoot.querySelectorAll('input'));
|
|
93
176
|
}
|
|
94
177
|
render() {
|
|
95
178
|
var _a;
|
|
96
|
-
return (h(Host, { key: '
|
|
179
|
+
return (h(Host, { key: '82961090c1a837f782588d3acea703550b1b0a44' }, h("div", { key: '0dac1cc8d80b7fb67e334b995172b82c03443394', class: "code-container" }, new Array(this.length).fill(0).map((_, i) => {
|
|
97
180
|
var _a, _b;
|
|
98
181
|
return (h("input", { class: { 'code-input': true, 'error': Boolean(this.errorText), 'has-value': ((_a = this.code) === null || _a === void 0 ? void 0 : _a[i]) !== undefined }, id: `code-input-${i}`, onKeyDown: ev => this.handleKeyDown(i, ev), onInput: ev => this.handleInput(i, ev), onFocus: () => this.handleFocus(i), onPaste: this.handlePaste, min: 0, max: 9, value: (_b = this.code) === null || _b === void 0 ? void 0 : _b[i], inputMode: this.type === 'number' ? 'numeric' : 'text' }));
|
|
99
|
-
})), (this.errorText || this.helperText) && (h("div", { key: '
|
|
182
|
+
})), (this.errorText || this.helperText) && (h("div", { key: 'c3c2d5a629d0d2bbcc886386a5942477c735831d', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("cpsl-icon", { key: 'd75171ab8641592d939b0883ae5f686520dacff6', icon: this.errorText ? 'alertCircle' : 'infoCircle' }), h("span", { key: 'dc9808b19dadc26db49bb79b16b89020822b177b' }, (_a = this.errorText) !== null && _a !== void 0 ? _a : this.helperText)))));
|
|
100
183
|
}
|
|
101
184
|
static get is() { return "cpsl-code-input"; }
|
|
102
185
|
static get encapsulation() { return "shadow"; }
|
|
@@ -225,5 +308,11 @@ export class CpslCodeInput {
|
|
|
225
308
|
}];
|
|
226
309
|
}
|
|
227
310
|
static get elementRef() { return "el"; }
|
|
311
|
+
static get watchers() {
|
|
312
|
+
return [{
|
|
313
|
+
"propName": "code",
|
|
314
|
+
"methodName": "watchCodeProp"
|
|
315
|
+
}];
|
|
316
|
+
}
|
|
228
317
|
}
|
|
229
318
|
//# sourceMappingURL=cpsl-code-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpsl-code-input.js","sourceRoot":"","sources":["../../../../src/components/cpsl-code-input/cpsl-code-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAQvF,MAAM,OAAO,aAAa;;QAmChB,gBAAW,GAAG,CAAC,GAAW,EAAE,EAAc,EAAE,EAAE;;YACpD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;YAClC,oHAAoH;YACpH,IAAI,EAAE,CAAC,SAAS,KAAK,iBAAiB,EAAE,CAAC;gBACvC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBACzD,OAAO;YACT,CAAC;YACD,IAAI,EAAE,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;gBAClC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;oBACvD,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;oBAC9B,OAAO;gBACT,CAAC;gBACD,MAAM,OAAO,GAAG,GAAG,MAAA,IAAI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AE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,EACtC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,MAAA,IAAI,CAAC,IAAI,0CAAG,CAAC,CAAC,EACrB,SAAS,EAAE,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,GACtD,CACH,CAAA;aAAA,CAAC,CACE;YACL,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CACtC,4DAAK,KAAK,EAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAClF,kEAAW,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,GAAI;gBAClE,+DAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,UAAU,CAAQ,CAC5C,CACP,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, Element, Event, EventEmitter } from '@stencil/core';\nimport { CodeChangeEventDetail } from './code-change-interface.js';\n\n@Component({\n tag: 'cpsl-code-input',\n styleUrl: 'cpsl-code-input.scss',\n shadow: true,\n})\nexport class CpslCodeInput {\n @Element() el!: HTMLCpslCodeInputElement;\n\n /**\n * Value of the code.\n */\n\n @Prop({ mutable: true }) code: string;\n\n /**\n * Error text to show below the input. If this is provided the input will enter an error state.\n */\n @Prop() errorText?: string;\n\n /**\n * Helper text to show below the input. If `\"errorText\"` is provided that will take precedence.\n */\n @Prop() helperText?: string;\n\n /**\n * Length of the code.\n */\n @Prop() length: number;\n\n /**\n * Type of characters to accept in the code.\n * Defaults to number.\n */\n @Prop() type?: 'number' | 'string' = 'number';\n\n /**\n * The `cpslInput` event is fired each time the user modifies the input's value.\n */\n @Event() cpslInput!: EventEmitter<CodeChangeEventDetail>;\n\n private handleInput = (ind: number, ev: InputEvent) => {\n const inputElements = this.inputs;\n // If getting an insertFromPaste remove the last element value since the value setting is handled in the paste event\n if (ev.inputType === 'insertFromPaste') {\n inputElements[Math.min(this.length - 1, ind)].value = '';\n return;\n }\n if (ev.inputType === 'insertText') {\n if (this.type === 'number' && isNaN(parseInt(ev.data))) {\n inputElements[ind].value = '';\n return;\n }\n const newCode = `${this.code ?? ''}${ev.data}`;\n inputElements[Math.min(this.length - 1, newCode.length)].focus();\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n }\n };\n\n private handleKeyDown = (ind: number, ev: KeyboardEvent) => {\n const inputElements = this.inputs;\n\n switch (ev.key) {\n case 'Backspace': {\n let newCode;\n if (!inputElements[ind].value) {\n inputElements[Math.max(0, ind - 1)].value = '';\n inputElements[Math.max(0, ind - 1)].focus();\n newCode = this.code.substring(0, ind - 1);\n } else {\n newCode = this.code.substring(0, ind);\n }\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n break;\n }\n case 'ArrowLeft': {\n setTimeout(() => {\n this.inputs[ind].setSelectionRange(1, 1);\n }, 0);\n break;\n }\n default: {\n break;\n }\n }\n };\n\n private handleFocus = (ind: number) => {\n const inputElements = this.inputs;\n\n for (const input of inputElements) {\n if (!input.value) {\n input.focus();\n break;\n } else if (input.id === `code-input-${this.length - 1}`) {\n input.focus();\n break;\n }\n }\n\n setTimeout(() => {\n inputElements[ind].setSelectionRange(1, 1);\n }, 0);\n };\n\n private handlePaste = (e: ClipboardEvent) => {\n const inputElements = this.inputs;\n const pastedCode = e.clipboardData.getData('text');\n\n if (this.type === 'number' && isNaN(parseInt(pastedCode))) {\n // Remove illegal value from the first input. Not using a timeout here doesn't change the value properly.\n setTimeout(() => {\n inputElements[0].value = '';\n }, 0);\n return;\n }\n\n this.cpslInput.emit({\n value: pastedCode,\n });\n inputElements.forEach((input, index) => {\n input.value = pastedCode.charAt(index);\n });\n inputElements[Math.min(this.length - 1, pastedCode.length)].focus();\n };\n\n private get inputs() {\n return Array.from(this.el.shadowRoot.querySelectorAll('input'));\n }\n\n render() {\n return (\n <Host>\n <div class=\"code-container\">\n {new Array(this.length).fill(0).map((_, i) => (\n <input\n class={{ 'code-input': true, 'error': Boolean(this.errorText), 'has-value': this.code?.[i] !== undefined }}\n id={`code-input-${i}`}\n onKeyDown={ev => this.handleKeyDown(i, ev)}\n onInput={ev => this.handleInput(i, ev)}\n onFocus={() => this.handleFocus(i)}\n onPaste={this.handlePaste}\n min={0}\n max={9}\n value={this.code?.[i]}\n inputMode={this.type === 'number' ? 'numeric' : 'text'}\n />\n ))}\n </div>\n {(this.errorText || this.helperText) && (\n <div class={{ 'helper-text-container': true, 'error-text': Boolean(this.errorText) }}>\n <cpsl-icon icon={this.errorText ? 'alertCircle' : 'infoCircle'} />\n <span>{this.errorText ?? this.helperText}</span>\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cpsl-code-input.js","sourceRoot":"","sources":["../../../../src/components/cpsl-code-input/cpsl-code-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AAQ9F,MAAM,OAAO,aAAa;;QA8ChB,gBAAW,GAAG,CAAC,GAAW,EAAE,EAAc,EAAE,EAAE;YACpD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;YAElC,oHAAoH;YACpH,IAAI,EAAE,CAAC,SAAS,KA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AAA,CAAC,CACE;YACL,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CACtC,4DAAK,KAAK,EAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAClF,kEAAW,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,GAAI;gBAClE,+DAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,UAAU,CAAQ,CAC5C,CACP,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, Element, Event, EventEmitter, Watch } from '@stencil/core';\nimport { CodeChangeEventDetail } from './code-change-interface.js';\n\n@Component({\n tag: 'cpsl-code-input',\n styleUrl: 'cpsl-code-input.scss',\n shadow: true,\n})\nexport class CpslCodeInput {\n @Element() el!: HTMLCpslCodeInputElement;\n\n /**\n * Value of the code.\n */\n\n @Prop({ mutable: true }) code: string;\n\n /**\n * Error text to show below the input. If this is provided the input will enter an error state.\n */\n @Prop() errorText?: string;\n\n /**\n * Helper text to show below the input. If `\"errorText\"` is provided that will take precedence.\n */\n @Prop() helperText?: string;\n\n /**\n * Length of the code.\n */\n @Prop() length: number;\n\n /**\n * Type of characters to accept in the code.\n * Defaults to number.\n */\n @Prop() type?: 'number' | 'string' = 'number';\n\n /**\n * The `cpslInput` event is fired each time the user modifies the input's value.\n */\n @Event() cpslInput!: EventEmitter<CodeChangeEventDetail>;\n\n @Watch('code')\n watchCodeProp(newCode: string) {\n // Update the input values when the code prop changes externally\n const inputElements = this.inputs;\n if (inputElements.length > 0) {\n inputElements.forEach((input, index) => {\n input.value = newCode?.[index] || '';\n });\n }\n }\n\n private handleInput = (ind: number, ev: InputEvent) => {\n const inputElements = this.inputs;\n\n // If getting an insertFromPaste remove the last element value since the value setting is handled in the paste event\n if (ev.inputType === 'insertFromPaste') {\n inputElements[Math.min(this.length - 1, ind)].value = '';\n return;\n }\n\n if (ev.inputType === 'insertText') {\n if (this.type === 'number' && isNaN(parseInt(ev.data))) {\n ev.preventDefault();\n inputElements[ind].value = '';\n return;\n }\n\n // Prevent the default behavior FIRST\n ev.preventDefault();\n\n // Build the new code from the current component state, not the DOM\n const currentCode = this.code || '';\n\n // Insert the new character at the focused position, not at the end\n const beforeFocused = currentCode.substring(0, ind);\n const afterFocused = currentCode.substring(ind + 1);\n const newCode = beforeFocused + ev.data + afterFocused;\n\n // Prevent input beyond the maximum length\n if (newCode.length > this.length) {\n return;\n }\n\n // Update the component state and emit event\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n\n // Update the specific input that was typed in\n inputElements[ind].value = ev.data;\n\n // Focus next input if not at the end\n if (ind < this.length - 1) {\n // Set flag to prevent handleFocus from interfering\n this.isArrowNavigation = true;\n setTimeout(() => {\n inputElements[ind + 1].focus();\n this.isArrowNavigation = false;\n }, 0);\n }\n }\n };\n\n private isArrowNavigation = false;\n\n private handleKeyDown = (ind: number, ev: KeyboardEvent) => {\n const inputElements = this.inputs;\n\n switch (ev.key) {\n case 'Backspace': {\n let newCode;\n if (!inputElements[ind].value) {\n // If current input is empty, move to previous and clear it\n if (ind > 0) {\n inputElements[ind - 1].value = '';\n setTimeout(() => {\n inputElements[ind - 1].focus();\n }, 0);\n // Remove character at previous position\n const currentCode = this.code || '';\n newCode = currentCode.substring(0, ind - 1) + currentCode.substring(ind);\n } else {\n newCode = this.code;\n }\n } else {\n // Clear current input and remove character at current position\n inputElements[ind].value = '';\n const currentCode = this.code || '';\n newCode = currentCode.substring(0, ind) + currentCode.substring(ind + 1);\n }\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n break;\n }\n case 'ArrowLeft': {\n ev.preventDefault();\n if (ind > 0) {\n this.isArrowNavigation = true;\n setTimeout(() => {\n inputElements[ind - 1].focus();\n this.isArrowNavigation = false;\n }, 0);\n }\n break;\n }\n case 'ArrowRight': {\n ev.preventDefault();\n if (ind < this.length - 1) {\n this.isArrowNavigation = true;\n setTimeout(() => {\n inputElements[ind + 1].focus();\n this.isArrowNavigation = false;\n }, 0);\n }\n break;\n }\n default: {\n break;\n }\n }\n };\n\n private handleFocus = (ind: number) => {\n const inputElements = this.inputs;\n\n // Don't interfere with arrow key navigation\n if (this.isArrowNavigation) {\n setTimeout(() => {\n inputElements[ind].setSelectionRange(1, 1);\n }, 0);\n return;\n }\n\n // If the focused input already has a value, allow it to stay focused (user clicked on it)\n if (inputElements[ind].value) {\n setTimeout(() => {\n inputElements[ind].setSelectionRange(1, 1);\n }, 0);\n return;\n }\n\n // Otherwise, use the default focus logic (find first empty or go to last)\n for (const input of inputElements) {\n if (!input.value) {\n input.focus();\n break;\n } else if (input.id === `code-input-${this.length - 1}`) {\n input.focus();\n break;\n }\n }\n\n setTimeout(() => {\n inputElements[ind].setSelectionRange(1, 1);\n }, 0);\n };\n\n private handlePaste = (e: ClipboardEvent) => {\n const inputElements = this.inputs;\n let pastedCode = e.clipboardData.getData('text');\n\n // Filter based on type\n if (this.type === 'number') {\n // Remove all non-numeric characters\n pastedCode = pastedCode.replace(/\\D/g, '');\n\n // If no valid numbers remain, clear and return\n if (!pastedCode) {\n setTimeout(() => {\n inputElements[0].value = '';\n }, 0);\n return;\n }\n }\n\n // Truncate pasted code to match the expected length\n const truncatedCode = pastedCode.substring(0, this.length);\n\n this.cpslInput.emit({\n value: truncatedCode,\n });\n\n inputElements.forEach((input, index) => {\n input.value = truncatedCode.charAt(index) || '';\n });\n\n inputElements[Math.min(this.length - 1, truncatedCode.length)].focus();\n };\n\n private get inputs() {\n return Array.from(this.el.shadowRoot.querySelectorAll('input'));\n }\n\n render() {\n return (\n <Host>\n <div class=\"code-container\">\n {new Array(this.length).fill(0).map((_, i) => (\n <input\n class={{ 'code-input': true, 'error': Boolean(this.errorText), 'has-value': this.code?.[i] !== undefined }}\n id={`code-input-${i}`}\n onKeyDown={ev => this.handleKeyDown(i, ev)}\n onInput={ev => this.handleInput(i, ev)}\n onFocus={() => this.handleFocus(i)}\n onPaste={this.handlePaste}\n min={0}\n max={9}\n value={this.code?.[i]}\n inputMode={this.type === 'number' ? 'numeric' : 'text'}\n />\n ))}\n </div>\n {(this.errorText || this.helperText) && (\n <div class={{ 'helper-text-container': true, 'error-text': Boolean(this.errorText) }}>\n <cpsl-icon icon={this.errorText ? 'alertCircle' : 'infoCircle'} />\n <span>{this.errorText ?? this.helperText}</span>\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -58,11 +58,12 @@
|
|
|
58
58
|
--filter: auto;
|
|
59
59
|
--height: 24px;
|
|
60
60
|
--width: 24px;
|
|
61
|
-
--
|
|
62
|
-
--
|
|
63
|
-
--
|
|
64
|
-
--icon-
|
|
65
|
-
--icon-
|
|
61
|
+
--inset: 0px;
|
|
62
|
+
--computed-height: calc(var(--height) - (2 * var(--inset)));
|
|
63
|
+
--computed-width: calc(var(--width) - (2 * var(--inset)));
|
|
64
|
+
--icon-color: var(--icon-color, currentColor);
|
|
65
|
+
--icon-fill-color: var(--icon-fill-color, var(--icon-color, currentColor));
|
|
66
|
+
--icon-stroke-color: var(--icon-stroke-color, var(--icon-color, currentColor));
|
|
66
67
|
width: var(--width);
|
|
67
68
|
height: var(--height);
|
|
68
69
|
}
|
|
@@ -81,12 +82,16 @@
|
|
|
81
82
|
align-items: center;
|
|
82
83
|
width: 100%;
|
|
83
84
|
height: 100%;
|
|
85
|
+
border: var(--icon-border, auto);
|
|
86
|
+
border-radius: var(--icon-border-radius, 0);
|
|
87
|
+
background: var(--icon-background, transparent);
|
|
84
88
|
color: var(--icon-color);
|
|
89
|
+
box-sizing: border-box;
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
:host svg {
|
|
88
|
-
width: var(--
|
|
89
|
-
height: var(--
|
|
93
|
+
width: var(--computed-width, "100%");
|
|
94
|
+
height: var(--computed-height, "100%");
|
|
90
95
|
filter: var(--filter);
|
|
91
96
|
}
|
|
92
97
|
:host svg .background-16 {
|
|
@@ -103,7 +108,9 @@
|
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
:host img {
|
|
106
|
-
width: 100
|
|
107
|
-
height: 100
|
|
111
|
+
width: var(--computed-width, 100%);
|
|
112
|
+
height: var(--computed-height, 100%);
|
|
113
|
+
max-width: 100%;
|
|
114
|
+
max-height: 100%;
|
|
108
115
|
object-fit: contain;
|
|
109
116
|
}
|
|
@@ -7,9 +7,13 @@ export class CpslIcon {
|
|
|
7
7
|
this.invert = undefined;
|
|
8
8
|
this.inset = '0px';
|
|
9
9
|
this.icon = undefined;
|
|
10
|
+
this.radius = 'none';
|
|
11
|
+
this.background = undefined;
|
|
12
|
+
this.color = undefined;
|
|
13
|
+
this.border = undefined;
|
|
10
14
|
}
|
|
11
15
|
render() {
|
|
12
|
-
return (h(Host, { key: '
|
|
16
|
+
return (h(Host, { key: 'fda593bf99b0dedbd76080936d3c6ca40d4a3f39', part: "icon", role: "img", style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (this.inset ? { ['--inset']: this.inset } : {})), (this.size ? { ['--height']: this.size, ['--width']: this.size } : {})), (this.invert ? { ['--filter']: 'invert(100%)' } : {})), (this.radius === 'full' ? { ['--icon-border-radius']: '1000px' } : {})), (this.radius === 'theme' ? { ['--icon-border-radius']: 'var(--cpsl-border-radius-tile-button)' } : {})), (this.background ? { ['--icon-background']: this.background } : {})), (this.border ? { ['--icon-border']: this.border } : {})), (this.color ? { ['--icon-color']: this.color } : {})) }, this.src ? (h("div", null, h("img", { src: this.src }))) : (h("div", { innerHTML: Icons[this.icon] }))));
|
|
13
17
|
}
|
|
14
18
|
static get is() { return "cpsl-icon"; }
|
|
15
19
|
static get encapsulation() { return "shadow"; }
|
|
@@ -99,7 +103,7 @@ export class CpslIcon {
|
|
|
99
103
|
"mutable": false,
|
|
100
104
|
"complexType": {
|
|
101
105
|
"original": "IconType",
|
|
102
|
-
"resolved": "\"search\" | \"lg\" | \"alertCircle\" | \"alertTriangle\" | \"alignVerticalCenter\" | \"angelListBrand\" | \"angelList\" | \"appleBrand\" | \"apple\" | \"arbitrumBrand\" | \"arrowCircleBrokenDownLeft\" | \"arrowCircleDownFilled\" | \"arrowNarrow\" | \"arrow\" | \"asterisk\" | \"backupKit\" | \"bank\" | \"baseBrand\" | \"brush\" | \"celoBrand\" | \"checkCircleFilled\" | \"checkCircle\" | \"checkSquare\" | \"check\" | \"chevronDown\" | \"chevronRight\" | \"chevronSelectorVertical\" | \"chevronUp\" | \"clock\" | \"close\" | \"clubhouseBrand\" | \"clubhouse\" | \"code\" | \"copy07\" | \"copy\" | \"cosmos\" | \"creditCard02\" | \"creditCard\" | \"cube03\" | \"cubeOutline\" | \"cube\" | \"currencyDollar\" | \"decentBrand\" | \"decent\" | \"dell\" | \"discordBrand\" | \"discord\" | \"dot\" | \"dots\" | \"downloadCloud\" | \"download\" | \"dribbbleBrand\" | \"dribbble\" | \"earth\" | \"edit02\" | \"emptyCircle\" | \"ethereum\" | \"eyeOff\" | \"eye\" | \"facebookBrand\" | \"facebook\" | \"farcasterBrand\" | \"farcaster\" | \"figmaBrand\" | \"figma\" | \"file\" | \"folder\" | \"githubBrand\" | \"github\" | \"globe\" | \"googleBrand\" | \"google\" | \"gridDots\" | \"helpCircle\" | \"heroAlertCircle\" | \"heroCheckmarkCapsule\" | \"heroCheckmark\" | \"heroEmail\" | \"heroExternalConnection\" | \"heroLock\" | \"heroPasskey\" | \"heroPhone\" | \"heroPlusCircleCapsule\" | \"heroPlusCircle\" | \"heroWallet\" | \"home\" | \"hp\" | \"image\" | \"infoCircle\" | \"instagramBrand\" | \"instagram\" | \"key\" | \"laptop\" | \"lenovo\" | \"lightning01\" | \"lightning\" | \"linkExternal\" | \"linkedinBrand\" | \"linkedin\" | \"lockKeyholeCircle\" | \"logOut\" | \"mail\" | \"menu\" | \"monitor\" | \"moonpayBrand\" | \"moreLoginOptions\" | \"motorola\" | \"nobleBrand\" | \"optimismBrand\" | \"paraBlackBg\" | \"paraBrand\" | \"paraIconBrand\" | \"paraIconQr\" | \"paraIcon\" | \"paraLogo\" | \"paraRingsDark\" | \"paraRings\" | \"para\" | \"passcode\" | \"phone\" | \"pintrestBrand\" | \"pintrest\" | \"plusCircle\" | \"plus\" | \"polygonBrand\" | \"polygon\" | \"puzzlePiece\" | \"qrCode02\" | \"qrCode\" | \"rampNetworkBrand\" | \"rampNetwork\" | \"redditBrand\" | \"reddit\" | \"refresh\" | \"samsung\" | \"send\" | \"settings\" | \"share\" | \"shield\" | \"signalBrand\" | \"signal\" | \"sliders\" | \"snapchatBrand\" | \"snapchat\" | \"solana\" | \"spacingHeight\" | \"star04Filled\" | \"stars01Filled\" | \"stars02\" | \"stars\" | \"stopSquare\" | \"stripeBrand\" | \"telegramBrand\" | \"telegram\" | \"tetherBrand\" | \"tikTokBrand\" | \"tikTok\" | \"trash\" | \"tumblrBrand\" | \"tumblr\" | \"twitterBrand\" | \"twitter\" | \"usdcBrand\" | \"userCircle\" | \"user\" | \"wallet\" | \"x\" | \"youtubeBrand\" | \"youtube\" | \"AD\" | \"AE\" | \"AF\" | \"AG\" | \"AI\" | \"AL\" | \"AM\" | \"AO\" | \"AR\" | \"AS\" | \"AT\" | \"AU\" | \"AW\" | \"AX\" | \"AZ\" | \"BA\" | \"BB\" | \"BD\" | \"BE\" | \"BF\" | \"BG\" | \"BH\" | \"BI\" | \"BJ\" | \"BL\" | \"BM\" | \"BN\" | \"BO\" | \"BQ\" | \"BQ2\" | \"BQ3\" | \"BR\" | \"BS\" | \"BT\" | \"BW\" | \"BY\" | \"BZ\" | \"CA\" | \"CC\" | \"CD\" | \"CD2\" | \"CF\" | \"CH\" | \"CK\" | \"CL\" | \"CM\" | \"CN\" | \"CO\" | \"CR\" | \"CU\" | \"CW\" | \"CX\" | \"CY\" | \"CZ\" | \"DE\" | \"DJ\" | \"DK\" | \"DM\" | \"DO\" | \"DS\" | \"DZ\" | \"EC\" | \"EE\" | \"EG\" | \"EH\" | \"ER\" | \"ES\" | \"ET\" | \"FI\" | \"FJ\" | \"FK\" | \"FM\" | \"FO\" | \"FR\" | \"GA\" | \"GB2\" | \"GB\" | \"GD\" | \"GE\" | \"GG\" | \"GH\" | \"GI\" | \"GL\" | \"GM\" | \"GN\" | \"GQ\" | \"GR\" | \"GT\" | \"GU\" | \"GW\" | \"GY\" | \"HK\" | \"HN\" | \"HR\" | \"HT\" | \"HU\" | \"ID\" | \"IE\" | \"IL\" | \"IM\" | \"IN\" | \"IO\" | \"IQ\" | \"IR\" | \"IS\" | \"IT\" | \"JE\" | \"JM\" | \"JO\" | \"JP\" | \"KE\" | \"KG\" | \"KH\" | \"KI\" | \"KM\" | \"KN\" | \"KP\" | \"KR\" | \"KW\" | \"KY\" | \"KZ\" | \"LA\" | \"LB\" | \"LC\" | \"LI\" | \"LK\" | \"LR\" | \"LS\" | \"LT\" | \"LU\" | \"LV\" | \"LY\" | \"MA\" | \"MC\" | \"MD\" | \"ME\" | \"MG\" | \"MH\" | \"MK\" | \"ML\" | \"MM\" | \"MN\" | \"MO\" | \"MP\" | \"MQ\" | \"MR\" | \"MS\" | \"MT\" | \"MU\" | \"MV\" | \"MW\" | \"MX\" | \"MY\" | \"MZ\" | \"NA\" | \"NE\" | \"NF\" | \"NG\" | \"NI\" | \"NL\" | \"NO\" | \"NP\" | \"NR\" | \"NU\" | \"NZ\" | \"OM\" | \"PA\" | \"PE\" | \"PF\" | \"PG\" | \"PH\" | \"PK\" | \"PL\" | \"PN\" | \"PR\" | \"PS\" | \"PT\" | \"PW\" | \"PY\" | \"QA\" | \"RO\" | \"RS\" | \"RU\" | \"RW\" | \"SA\" | \"SB\" | \"SC\" | \"SE\" | \"SG\" | \"SI\" | \"SK\" | \"SL\" | \"SM\" | \"SN\" | \"SO\" | \"SR\" | \"SS\" | \"ST\" | \"SV\" | \"SX\" | \"SY\" | \"SZ\" | \"TC\" | \"TD\" | \"TG\" | \"TH\" | \"TJ\" | \"TK\" | \"TL\" | \"TM\" | \"TN\" | \"TO\" | \"TR\" | \"TT\" | \"TV\" | \"TW\" | \"TZ\" | \"UA\" | \"UG\" | \"US\" | \"UY\" | \"UZ\" | \"VC\" | \"VE\" | \"VG\" | \"VI\" | \"VN\" | \"VU\" | \"WS\" | \"YE\" | \"ZA\" | \"ZM\" | \"ZW\"",
|
|
106
|
+
"resolved": "\"search\" | \"lg\" | \"alertCircle\" | \"alertTriangle\" | \"alignVerticalCenter\" | \"angelListBrand\" | \"angelList\" | \"appleBrand\" | \"apple\" | \"arbitrumBrand\" | \"arrowCircleBrokenDownLeft\" | \"arrowCircleDownFilled\" | \"arrowCircleDown\" | \"arrowNarrow\" | \"arrow\" | \"asterisk\" | \"backpack\" | \"backupKit\" | \"bank\" | \"baseBrand\" | \"beraBrand\" | \"brush\" | \"celoBrand\" | \"checkCircleFilled\" | \"checkCircle\" | \"checkSquare\" | \"check\" | \"chevronDown\" | \"chevronRight\" | \"chevronSelectorVertical\" | \"chevronUp\" | \"clock\" | \"close\" | \"clubhouseBrand\" | \"clubhouse\" | \"code\" | \"coinbase\" | \"copy07\" | \"copy\" | \"cosmosCircle\" | \"cosmos\" | \"cosmostation\" | \"creditCard02\" | \"creditCard\" | \"cube03\" | \"cubeOutline\" | \"cube\" | \"currencyDollar\" | \"decentBrand\" | \"decent\" | \"dell\" | \"discordBrand\" | \"discord\" | \"dot\" | \"dotsSquare\" | \"dots\" | \"downloadCloud\" | \"download\" | \"dribbbleBrand\" | \"dribbble\" | \"earth\" | \"edit02\" | \"emptyCircle\" | \"ethCircle\" | \"ethereum\" | \"eyeOff\" | \"eye\" | \"facebookBrand\" | \"facebook\" | \"farcasterBrand\" | \"farcaster\" | \"figmaBrand\" | \"figma\" | \"file\" | \"folder\" | \"githubBrand\" | \"github\" | \"globe\" | \"glow\" | \"googleBrand\" | \"google\" | \"gridDots\" | \"haha\" | \"helpCircle\" | \"heroAlertCircle\" | \"heroCheckmarkCapsule\" | \"heroCheckmark\" | \"heroEmail\" | \"heroExternalConnection\" | \"heroLock\" | \"heroPasskey\" | \"heroPhone\" | \"heroPlusCircleCapsule\" | \"heroPlusCircle\" | \"heroWallet\" | \"home\" | \"hp\" | \"image\" | \"infoCircle\" | \"instagramBrand\" | \"instagram\" | \"keplr\" | \"key\" | \"laptop\" | \"leap\" | \"lenovo\" | \"lightning01\" | \"lightning\" | \"linkExternal\" | \"linkedinBrand\" | \"linkedin\" | \"lockKeyholeCircle\" | \"logOut\" | \"mail\" | \"menu\" | \"metamask\" | \"monitor\" | \"moonpayBrand\" | \"moreLoginOptions\" | \"motorola\" | \"nobleBrand\" | \"okx\" | \"optimismBrand\" | \"paraArrow\" | \"paraBlackBg\" | \"paraBrand\" | \"paraIconBrand\" | \"paraIconQr\" | \"paraIcon\" | \"paraLogo\" | \"paraRingsDark\" | \"paraRings\" | \"para\" | \"passcode\" | \"phantom\" | \"phone\" | \"pintrestBrand\" | \"pintrest\" | \"plusCircle\" | \"plus\" | \"polygonBrand\" | \"polygon\" | \"puzzlePiece\" | \"qrCode02\" | \"qrCode\" | \"rabby\" | \"rainbow\" | \"rampNetworkBrand\" | \"rampNetwork\" | \"redditBrand\" | \"reddit\" | \"refresh\" | \"safe\" | \"samsung\" | \"send\" | \"settings\" | \"share\" | \"shield\" | \"shuffle\" | \"signalBrand\" | \"signal\" | \"sliders\" | \"snapchatBrand\" | \"snapchat\" | \"solanaCircle\" | \"solana\" | \"solflare\" | \"spacingHeight\" | \"star04Filled\" | \"star05\" | \"stars01Filled\" | \"stars02\" | \"stars\" | \"stopSquare\" | \"stripeBrand\" | \"telegramBrand\" | \"telegram\" | \"tetherBrand\" | \"tikTokBrand\" | \"tikTok\" | \"trash\" | \"tumblrBrand\" | \"tumblr\" | \"twitterBrand\" | \"twitter\" | \"usdcBrand\" | \"user01\" | \"userCircle\" | \"userPlus\" | \"user\" | \"valora\" | \"wallet02\" | \"walletConnect\" | \"wallet\" | \"x\" | \"youtubeBrand\" | \"youtube\" | \"zap\" | \"zerion\" | \"AD\" | \"AE\" | \"AF\" | \"AG\" | \"AI\" | \"AL\" | \"AM\" | \"AO\" | \"AR\" | \"AS\" | \"AT\" | \"AU\" | \"AW\" | \"AX\" | \"AZ\" | \"BA\" | \"BB\" | \"BD\" | \"BE\" | \"BF\" | \"BG\" | \"BH\" | \"BI\" | \"BJ\" | \"BL\" | \"BM\" | \"BN\" | \"BO\" | \"BQ\" | \"BQ2\" | \"BQ3\" | \"BR\" | \"BS\" | \"BT\" | \"BW\" | \"BY\" | \"BZ\" | \"CA\" | \"CC\" | \"CD\" | \"CD2\" | \"CF\" | \"CH\" | \"CK\" | \"CL\" | \"CM\" | \"CN\" | \"CO\" | \"CR\" | \"CU\" | \"CW\" | \"CX\" | \"CY\" | \"CZ\" | \"DE\" | \"DJ\" | \"DK\" | \"DM\" | \"DO\" | \"DS\" | \"DZ\" | \"EC\" | \"EE\" | \"EG\" | \"EH\" | \"ER\" | \"ES\" | \"ET\" | \"FI\" | \"FJ\" | \"FK\" | \"FM\" | \"FO\" | \"FR\" | \"GA\" | \"GB2\" | \"GB\" | \"GD\" | \"GE\" | \"GG\" | \"GH\" | \"GI\" | \"GL\" | \"GM\" | \"GN\" | \"GQ\" | \"GR\" | \"GT\" | \"GU\" | \"GW\" | \"GY\" | \"HK\" | \"HN\" | \"HR\" | \"HT\" | \"HU\" | \"ID\" | \"IE\" | \"IL\" | \"IM\" | \"IN\" | \"IO\" | \"IQ\" | \"IR\" | \"IS\" | \"IT\" | \"JE\" | \"JM\" | \"JO\" | \"JP\" | \"KE\" | \"KG\" | \"KH\" | \"KI\" | \"KM\" | \"KN\" | \"KP\" | \"KR\" | \"KW\" | \"KY\" | \"KZ\" | \"LA\" | \"LB\" | \"LC\" | \"LI\" | \"LK\" | \"LR\" | \"LS\" | \"LT\" | \"LU\" | \"LV\" | \"LY\" | \"MA\" | \"MC\" | \"MD\" | \"ME\" | \"MG\" | \"MH\" | \"MK\" | \"ML\" | \"MM\" | \"MN\" | \"MO\" | \"MP\" | \"MQ\" | \"MR\" | \"MS\" | \"MT\" | \"MU\" | \"MV\" | \"MW\" | \"MX\" | \"MY\" | \"MZ\" | \"NA\" | \"NE\" | \"NF\" | \"NG\" | \"NI\" | \"NL\" | \"NO\" | \"NP\" | \"NR\" | \"NU\" | \"NZ\" | \"OM\" | \"PA\" | \"PE\" | \"PF\" | \"PG\" | \"PH\" | \"PK\" | \"PL\" | \"PN\" | \"PR\" | \"PS\" | \"PT\" | \"PW\" | \"PY\" | \"QA\" | \"RO\" | \"RS\" | \"RU\" | \"RW\" | \"SA\" | \"SB\" | \"SC\" | \"SE\" | \"SG\" | \"SI\" | \"SK\" | \"SL\" | \"SM\" | \"SN\" | \"SO\" | \"SR\" | \"SS\" | \"ST\" | \"SV\" | \"SX\" | \"SY\" | \"SZ\" | \"TC\" | \"TD\" | \"TG\" | \"TH\" | \"TJ\" | \"TK\" | \"TL\" | \"TM\" | \"TN\" | \"TO\" | \"TR\" | \"TT\" | \"TV\" | \"TW\" | \"TZ\" | \"UA\" | \"UG\" | \"US\" | \"UY\" | \"UZ\" | \"VC\" | \"VE\" | \"VG\" | \"VI\" | \"VN\" | \"VU\" | \"WS\" | \"YE\" | \"ZA\" | \"ZM\" | \"ZW\"",
|
|
103
107
|
"references": {
|
|
104
108
|
"IconType": {
|
|
105
109
|
"location": "import",
|
|
@@ -116,6 +120,75 @@ export class CpslIcon {
|
|
|
116
120
|
},
|
|
117
121
|
"attribute": "icon",
|
|
118
122
|
"reflect": false
|
|
123
|
+
},
|
|
124
|
+
"radius": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"mutable": false,
|
|
127
|
+
"complexType": {
|
|
128
|
+
"original": "'none' | 'theme' | 'full'",
|
|
129
|
+
"resolved": "\"full\" | \"none\" | \"theme\"",
|
|
130
|
+
"references": {}
|
|
131
|
+
},
|
|
132
|
+
"required": false,
|
|
133
|
+
"optional": true,
|
|
134
|
+
"docs": {
|
|
135
|
+
"tags": [],
|
|
136
|
+
"text": "Whether the icon should be rounded."
|
|
137
|
+
},
|
|
138
|
+
"attribute": "radius",
|
|
139
|
+
"reflect": false,
|
|
140
|
+
"defaultValue": "'none'"
|
|
141
|
+
},
|
|
142
|
+
"background": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"mutable": false,
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "string",
|
|
147
|
+
"resolved": "string",
|
|
148
|
+
"references": {}
|
|
149
|
+
},
|
|
150
|
+
"required": false,
|
|
151
|
+
"optional": true,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": "The background CSS property of the icon."
|
|
155
|
+
},
|
|
156
|
+
"attribute": "background",
|
|
157
|
+
"reflect": false
|
|
158
|
+
},
|
|
159
|
+
"color": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"mutable": false,
|
|
162
|
+
"complexType": {
|
|
163
|
+
"original": "string",
|
|
164
|
+
"resolved": "string",
|
|
165
|
+
"references": {}
|
|
166
|
+
},
|
|
167
|
+
"required": false,
|
|
168
|
+
"optional": true,
|
|
169
|
+
"docs": {
|
|
170
|
+
"tags": [],
|
|
171
|
+
"text": "The color of the icon."
|
|
172
|
+
},
|
|
173
|
+
"attribute": "color",
|
|
174
|
+
"reflect": false
|
|
175
|
+
},
|
|
176
|
+
"border": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"mutable": false,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "string",
|
|
181
|
+
"resolved": "string",
|
|
182
|
+
"references": {}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": true,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "The border CSS property of the icon."
|
|
189
|
+
},
|
|
190
|
+
"attribute": "border",
|
|
191
|
+
"reflect": false
|
|
119
192
|
}
|
|
120
193
|
};
|
|
121
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpsl-icon.js","sourceRoot":"","sources":["../../../../src/components/cpsl-icon/cpsl-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAOpD,MAAM,OAAO,QAAQ;;;;;qBAmBK,KAAK
|
|
1
|
+
{"version":3,"file":"cpsl-icon.js","sourceRoot":"","sources":["../../../../src/components/cpsl-icon/cpsl-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAOpD,MAAM,OAAO,QAAQ;;;;;qBAmBK,KAAK;;sBAUgB,MAAM;;;;;IAiBnD,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,qDACH,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,KAAK,EACV,KAAK,sHACA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAC/C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACtE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACrD,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACtE,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,uCAAuC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACtG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACnE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACvD,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAGxD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CACV;YACE,WAAK,GAAG,EAAE,IAAI,CAAC,GAAG,GAAI,CAClB,CACP,CAAC,CAAC,CAAC,CACF,WAAK,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAI,CACrC,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop } from '@stencil/core';\nimport { IconType } from '../../interface.js';\nimport { Icons } from '../../assets/icons/index.js';\n\n@Component({\n tag: 'cpsl-icon',\n styleUrl: 'cpsl-icon.scss',\n shadow: true,\n})\nexport class CpslIcon {\n /**\n * The external source of the icon. If both `icon` and `src` are provided, `icon` will be used.\n */\n @Prop() src?: string;\n\n /**\n * The CSS size of the icon.\n */\n @Prop() size?: string;\n\n /**\n * Whether to invert the icon's colors.\n */\n @Prop() invert?: boolean;\n\n /**\n * The CSS length to inset the icon.\n */\n @Prop() inset: string = '0px';\n\n /**\n * The name of the icon. If both `icon` and `src` are provided, `icon` will be used.\n */\n @Prop() icon?: IconType;\n\n /**\n * Whether the icon should be rounded.\n */\n @Prop() radius?: 'none' | 'theme' | 'full' = 'none';\n\n /**\n * The background CSS property of the icon.\n */\n @Prop() background?: string;\n\n /**\n * The color of the icon.\n */\n @Prop() color?: string;\n\n /**\n * The border CSS property of the icon.\n */\n @Prop() border?: string;\n\n render() {\n return (\n <Host\n part=\"icon\"\n role=\"img\"\n style={{\n ...(this.inset ? { ['--inset']: this.inset } : {}),\n ...(this.size ? { ['--height']: this.size, ['--width']: this.size } : {}),\n ...(this.invert ? { ['--filter']: 'invert(100%)' } : {}),\n ...(this.radius === 'full' ? { ['--icon-border-radius']: '1000px' } : {}),\n ...(this.radius === 'theme' ? { ['--icon-border-radius']: 'var(--cpsl-border-radius-tile-button)' } : {}),\n ...(this.background ? { ['--icon-background']: this.background } : {}),\n ...(this.border ? { ['--icon-border']: this.border } : {}),\n ...(this.color ? { ['--icon-color']: this.color } : {}),\n }}\n >\n {this.src ? (\n <div>\n <img src={this.src} />\n </div>\n ) : (\n <div innerHTML={Icons[this.icon]} />\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
--identicon-background-blue: linear-gradient(136deg, #476fff 6.86%, #47c8ff 93.78%);
|
|
7
7
|
--identicon-background-purple: linear-gradient(136deg, #9747ff 6.86%, #da47ff 93.78%);
|
|
8
8
|
--identicon-background-empty: linear-gradient(136deg, #aaaaaa 6.86%, #999999 93.78%);
|
|
9
|
+
--identicon-arc-width: 30%;
|
|
9
10
|
display: block;
|
|
10
11
|
aspect-ratio: 1;
|
|
11
12
|
border-radius: 25%;
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
:host > svg {
|
|
16
17
|
fill: rgba(255, 255, 255, 0.6);
|
|
17
18
|
position: absolute;
|
|
18
|
-
width:
|
|
19
|
+
width: var(--identicon-arc-width);
|
|
19
20
|
}
|
|
20
21
|
:host > svg.rotate90 {
|
|
21
22
|
transform: rotate(0.25turn);
|
|
@@ -54,13 +54,14 @@ export class CpslIdenticon {
|
|
|
54
54
|
this.hash = undefined;
|
|
55
55
|
this.size = '40px';
|
|
56
56
|
this.variant = 'default';
|
|
57
|
+
this.arcWidth = '30%';
|
|
57
58
|
}
|
|
58
59
|
render() {
|
|
59
60
|
let props;
|
|
60
61
|
const isEmpty = !this.hash;
|
|
61
62
|
if (!isEmpty)
|
|
62
63
|
props = getIdenticonProps(this.hash);
|
|
63
|
-
return (h(Host, { key: '
|
|
64
|
+
return (h(Host, { key: '36535b7eb44bb8ca146db1efde320268b78d5ad0', class: {
|
|
64
65
|
red: (props === null || props === void 0 ? void 0 : props.color) === 'red',
|
|
65
66
|
orange: (props === null || props === void 0 ? void 0 : props.color) === 'orange',
|
|
66
67
|
yellow: (props === null || props === void 0 ? void 0 : props.color) === 'yellow',
|
|
@@ -72,6 +73,7 @@ export class CpslIdenticon {
|
|
|
72
73
|
}, style: {
|
|
73
74
|
width: this.size,
|
|
74
75
|
height: this.size,
|
|
76
|
+
['--identicon-arc-width']: this.arcWidth,
|
|
75
77
|
} }, (props === null || props === void 0 ? void 0 : props.shapes) &&
|
|
76
78
|
(props === null || props === void 0 ? void 0 : props.rotations) &&
|
|
77
79
|
props.shapes.map((isDouble, index) => {
|
|
@@ -144,6 +146,24 @@ export class CpslIdenticon {
|
|
|
144
146
|
"attribute": "variant",
|
|
145
147
|
"reflect": false,
|
|
146
148
|
"defaultValue": "'default'"
|
|
149
|
+
},
|
|
150
|
+
"arcWidth": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"mutable": false,
|
|
153
|
+
"complexType": {
|
|
154
|
+
"original": "string",
|
|
155
|
+
"resolved": "string",
|
|
156
|
+
"references": {}
|
|
157
|
+
},
|
|
158
|
+
"required": false,
|
|
159
|
+
"optional": false,
|
|
160
|
+
"docs": {
|
|
161
|
+
"tags": [],
|
|
162
|
+
"text": ""
|
|
163
|
+
},
|
|
164
|
+
"attribute": "arc-width",
|
|
165
|
+
"reflect": false,
|
|
166
|
+
"defaultValue": "'30%'"
|
|
147
167
|
}
|
|
148
168
|
};
|
|
149
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpsl-identicon.js","sourceRoot":"","sources":["../../../../src/components/cpsl-identicon/cpsl-identicon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAS,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CACtC,WACE,KAAK,EAAE;QACL,QAAQ,EAAE,QAAQ,KAAK,CAAC;QACxB,SAAS,EAAE,QAAQ,KAAK,CAAC;QACzB,SAAS,EAAE,QAAQ,KAAK,CAAC;KAC1B,EACD,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,4BAA4B;IAElC,sBAAa,oBAAoB;QAC/B,yBACY,SAAS,eACT,SAAS,EACnB,CAAC,EAAC,oOAAoO,GACtO,CACA;IACJ;QACE,gBAAU,EAAE,EAAC,cAAc;YACzB,YAAM,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAG,CACtB,CACN,CACH,CACP,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CACtC,WACE,KAAK,EAAE;QACL,QAAQ,EAAE,QAAQ,KAAK,CAAC;Q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,EAAE,CAAC,EAAE,CAAC,CAAC;QACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACb;IACD;QACE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACb;IACD;QACE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACb;CACF,CAAC;AAOF,MAAM,OAAO,aAAa;;;oBAOD,MAAM;uBAEW,SAAS;;
|
|
1
|
+
{"version":3,"file":"cpsl-identicon.js","sourceRoot":"","sources":["../../../../src/components/cpsl-identicon/cpsl-identicon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAS,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CACtC,WACE,KAAK,EAAE;QACL,QAAQ,EAAE,QAAQ,KAAK,CAAC;QACxB,SAAS,EAAE,QAAQ,KAAK,CAAC;QACzB,SAAS,EAAE,QAAQ,KAAK,CAAC;KAC1B,EACD,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,4BAA4B;IAElC,sBAAa,oBAAoB;QAC/B,yBACY,SAAS,eACT,SAAS,EACnB,CAAC,EAAC,oOAAoO,GACtO,CACA;IACJ;QACE,gBAAU,EAAE,EAAC,cAAc;YACzB,YAAM,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAG,CACtB,CACN,CACH,CACP,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CACtC,WACE,KAAK,EAAE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C;IAClD,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpF,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC9C,OAAO,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAChG,CAAC,CAAC;QACF,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACpH,CAAC;AACJ,CAAC","sourcesContent":["import { Component, Host, Prop, h } from '@stencil/core';\nimport Prando from '../../lib/prando.js';\nimport { Color, COLORS } from '../../utils/prand.js';\n\nconst SingleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_66)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_66\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\nconst DoubleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_255)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 18C15.3137 18 18 15.3137 18 12C18 8.68629 15.3137 6 12 6C8.68629 6 6 8.68629 6 12C6 15.3137 8.68629 18 12 18ZM12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_255\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\nconst BASE_PATTERNS = [\n [\n [0, 0, 0, 0],\n [0, 1, 3, 2],\n ],\n [\n [1, 1, 0, 0],\n [0, 1, 3, 2],\n ],\n [\n [0, 1, 0, 1],\n [0, 1, 3, 2],\n ],\n [\n [0, 0, 1, 1],\n [0, 1, 3, 2],\n ],\n [\n [1, 0, 1, 0],\n [0, 1, 3, 2],\n ],\n [\n [1, 1, 1, 1],\n [0, 1, 3, 2],\n ],\n [\n [0, 0, 0, 0],\n [2, 3, 1, 0],\n ],\n [\n [1, 1, 1, 1],\n [2, 3, 1, 0],\n ],\n [\n [1, 1, 1, 1],\n [0, 1, 2, 3],\n ],\n];\n\n@Component({\n tag: 'cpsl-identicon',\n styleUrl: 'cpsl-identicon.scss',\n shadow: true,\n})\nexport class CpslIdenticon {\n @Prop() hash?: string | undefined;\n\n /**\n * The CSS width and height of the identicon.\n * Default is: 40px.\n */\n @Prop() size: string = '40px';\n\n @Prop() variant: 'default' | 'avatar' = 'default';\n\n @Prop() arcWidth: string = '30%';\n\n render() {\n let props;\n const isEmpty = !this.hash;\n if (!isEmpty) props = getIdenticonProps(this.hash);\n\n return (\n <Host\n class={{\n red: props?.color === 'red',\n orange: props?.color === 'orange',\n yellow: props?.color === 'yellow',\n green: props?.color === 'green',\n blue: props?.color === 'blue',\n purple: props?.color === 'purple',\n empty: !props?.color && !this.hash,\n avatar: this.variant === 'avatar',\n }}\n style={{\n width: this.size,\n height: this.size,\n ['--identicon-arc-width']: this.arcWidth,\n }}\n >\n {props?.shapes &&\n props?.rotations &&\n props.shapes.map((isDouble, index) => {\n return isDouble ? DoubleArc(props.rotations[index]) : SingleArc(props.rotations[index]);\n })}\n </Host>\n );\n }\n}\n\nconst PRANDO_INTS = [COLORS.length, BASE_PATTERNS.length, 16];\n\nfunction getIdenticonProps(seed: string): { color: Color; shapes: boolean[]; rotations: number[] } {\n const rng = new Prando(seed);\n\n const [iColor, iPattern, iDeviation] = PRANDO_INTS.map(len => rng.nextInt(0, len - 1));\n\n const deviationIndex = Math.floor(iDeviation / 4);\n const [isDeviateShape, isDeviateFlip] = [iDeviation % 2 === 1, iDeviation % 4 >= 2];\n\n return {\n color: COLORS[iColor],\n shapes: BASE_PATTERNS[iPattern][0].map((s, i) => {\n return i === deviationIndex ? (isDeviateShape ? (s === 1 ? false : true) : s === 1) : s === 1;\n }),\n rotations: BASE_PATTERNS[iPattern][1].map((r, i) => (i === deviationIndex ? (isDeviateFlip ? (r + 2) % 4 : r) : r)),\n };\n}\n"]}
|