@getpara/core-components 2.0.0-fc.3 → 2.0.0
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-f2393be6.js → p-05ec9ce7.js} +2 -2
- package/dist/capsule/{p-f2393be6.js.map → p-05ec9ce7.js.map} +1 -1
- package/dist/capsule/p-1e8a62c5.entry.js +2 -0
- package/dist/capsule/{p-75685be8.entry.js → p-380ece1c.entry.js} +2 -2
- package/dist/capsule/{p-de2a16e4.entry.js → p-77a9fdca.entry.js} +2 -2
- package/dist/capsule/{p-c9e61114.entry.js → p-822cb3ee.entry.js} +2 -2
- package/dist/capsule/{p-d4bdb369.entry.js → p-8da9205d.entry.js} +2 -2
- package/dist/capsule/{p-34a09932.entry.js → p-905a0742.entry.js} +2 -2
- package/dist/capsule/p-d34794ba.entry.js +28 -0
- package/dist/capsule/p-d34794ba.entry.js.map +1 -0
- package/dist/capsule/{p-5cd62456.entry.js → p-e63ae2dd.entry.js} +2 -2
- package/dist/capsule/{p-3719bb1e.entry.js → p-f9274763.entry.js} +2 -2
- package/dist/cjs/capsule.cjs.js +1 -1
- package/dist/cjs/{constants-9b1b01bb.js → constants-1de558ea.js} +3 -3
- package/dist/cjs/{constants-9b1b01bb.js.map → constants-1de558ea.js.map} +1 -1
- package/dist/cjs/cpsl-alert_34.cjs.entry.js +266 -84
- package/dist/cjs/cpsl-alert_34.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-col.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-grid.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-hero.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-identicon.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-info-box.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-modal-v2.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-nav-button.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-row.cjs.entry.js +1 -1
- package/dist/cjs/index.cjs.js +6 -3
- 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/arrow-up-down.svg +4 -0
- package/dist/collection/assets/icons/coins.svg +1 -0
- package/dist/collection/assets/icons/dots-square.svg +13 -0
- package/dist/collection/assets/icons/external-link.svg +3 -0
- package/dist/collection/assets/icons/index.js +20 -0
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/assets/icons/para-arrow.svg +3 -0
- package/dist/collection/assets/icons/phantom.svg +8 -6
- package/dist/collection/assets/icons/shuffle.svg +3 -0
- package/dist/collection/assets/icons/user-01.svg +3 -0
- package/dist/collection/assets/icons/wallet-02.svg +3 -0
- package/dist/collection/assets/icons/zap.svg +3 -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-button/cpsl-button.js +21 -2
- package/dist/collection/components/cpsl-button/cpsl-button.js.map +1 -1
- package/dist/collection/components/cpsl-button-group/cpsl-button-group.js +1 -1
- package/dist/collection/components/cpsl-card/cpsl-card.js +1 -1
- package/dist/collection/components/cpsl-checkbox/cpsl-checkbox.js +1 -1
- 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-col/cpsl-col.js +1 -1
- package/dist/collection/components/cpsl-divider/cpsl-divider.js +1 -1
- package/dist/collection/components/cpsl-drawer/cpsl-drawer.js +2 -2
- package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js +1 -1
- package/dist/collection/components/cpsl-file-upload/cpsl-file-upload.js +1 -1
- package/dist/collection/components/cpsl-grid/cpsl-grid.js +2 -2
- package/dist/collection/components/cpsl-hero/cpsl-hero.js +2 -2
- 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-icon-group/cpsl-icon-group.js +1 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.js +1 -1
- package/dist/collection/components/cpsl-info-box/cpsl-info-box.js +1 -1
- package/dist/collection/components/cpsl-input/cpsl-input.js +2 -2
- package/dist/collection/components/cpsl-modal-v2/cpsl-modal-v2.js +1 -1
- package/dist/collection/components/cpsl-nav-button/cpsl-nav-button.js +1 -1
- package/dist/collection/components/cpsl-nav-button-group/cpsl-nav-button-group.js +1 -1
- package/dist/collection/components/cpsl-overlay/cpsl-overlay.css +1 -1
- package/dist/collection/components/cpsl-overlay/cpsl-overlay.js +1 -1
- package/dist/collection/components/cpsl-pagination/cpsl-pagination.js +1 -1
- package/dist/collection/components/cpsl-pill/cpsl-pill.js +1 -1
- package/dist/collection/components/cpsl-popover/cpsl-popover.js +42 -15
- package/dist/collection/components/cpsl-popover/cpsl-popover.js.map +1 -1
- package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js +2 -2
- package/dist/collection/components/cpsl-radio/cpsl-radio.js +1 -1
- package/dist/collection/components/cpsl-row/cpsl-row.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 +7 -2
- 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 +3 -3
- package/dist/collection/components/cpsl-spinner/cpsl-spinner.js +2 -2
- package/dist/collection/components/cpsl-switch/cpsl-switch.js +1 -1
- package/dist/collection/components/cpsl-tab/cpsl-tab.js +1 -1
- package/dist/collection/components/cpsl-table/cpsl-table.js +1 -1
- package/dist/collection/components/cpsl-tabs/cpsl-tabs.js +1 -1
- package/dist/collection/components/cpsl-text/cpsl-text.css +12 -0
- package/dist/collection/components/cpsl-text/cpsl-text.js +22 -1
- 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/constants.js +2 -2
- package/dist/collection/constants.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/{constants-fce138fa.js → constants-fefad927.js} +3 -3
- package/dist/esm/{constants-fce138fa.js.map → constants-fefad927.js.map} +1 -1
- package/dist/esm/cpsl-alert_34.entry.js +266 -84
- package/dist/esm/cpsl-alert_34.entry.js.map +1 -1
- package/dist/esm/cpsl-col.entry.js +1 -1
- package/dist/esm/cpsl-grid.entry.js +2 -2
- package/dist/esm/cpsl-hero.entry.js +2 -2
- package/dist/esm/cpsl-identicon.entry.js +1 -1
- package/dist/esm/cpsl-info-box.entry.js +1 -1
- package/dist/esm/cpsl-modal-v2.entry.js +1 -1
- package/dist/esm/cpsl-nav-button.entry.js +1 -1
- package/dist/esm/cpsl-row.entry.js +1 -1
- package/dist/esm/index.js +6 -3
- 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 +10 -0
- package/dist/types/components/cpsl-button/cpsl-button.d.ts +5 -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-popover/cpsl-popover.d.ts +5 -0
- package/dist/types/components/cpsl-select/cpsl-select.d.ts +6 -1
- package/dist/types/components/cpsl-text/cpsl-text.d.ts +6 -0
- package/dist/types/components/cpsl-tile-button/cpsl-tile-button.d.ts +5 -0
- package/dist/types/components.d.ts +74 -2
- 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 +2 -2
- package/dist/capsule/p-834c1ee9.entry.js +0 -28
- package/dist/capsule/p-834c1ee9.entry.js.map +0 -1
- package/dist/capsule/p-e424993a.entry.js +0 -2
- /package/dist/capsule/{p-e424993a.entry.js.map → p-1e8a62c5.entry.js.map} +0 -0
- /package/dist/capsule/{p-75685be8.entry.js.map → p-380ece1c.entry.js.map} +0 -0
- /package/dist/capsule/{p-de2a16e4.entry.js.map → p-77a9fdca.entry.js.map} +0 -0
- /package/dist/capsule/{p-c9e61114.entry.js.map → p-822cb3ee.entry.js.map} +0 -0
- /package/dist/capsule/{p-d4bdb369.entry.js.map → p-8da9205d.entry.js.map} +0 -0
- /package/dist/capsule/{p-34a09932.entry.js.map → p-905a0742.entry.js.map} +0 -0
- /package/dist/capsule/{p-5cd62456.entry.js.map → p-e63ae2dd.entry.js.map} +0 -0
- /package/dist/capsule/{p-3719bb1e.entry.js.map → p-f9274763.entry.js.map} +0 -0
- /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
|
@@ -3,6 +3,7 @@ export class CpslButton {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
this.as = 'button';
|
|
5
5
|
this.disabled = false;
|
|
6
|
+
this.pending = false;
|
|
6
7
|
this.fullWidth = false;
|
|
7
8
|
this.href = undefined;
|
|
8
9
|
this.size = 'medium';
|
|
@@ -11,7 +12,7 @@ export class CpslButton {
|
|
|
11
12
|
this.variant = 'primary';
|
|
12
13
|
}
|
|
13
14
|
render() {
|
|
14
|
-
return (h(Host, { key: '
|
|
15
|
+
return (h(Host, { key: '8f65c32aa3f0bcfcdf621ea1c1b4b4b383b28850', class: {
|
|
15
16
|
// VARIANTS
|
|
16
17
|
'primary': this.variant === 'primary',
|
|
17
18
|
'secondary': this.variant === 'secondary',
|
|
@@ -25,7 +26,7 @@ export class CpslButton {
|
|
|
25
26
|
'xSmall': this.size === 'xSmall',
|
|
26
27
|
'small': this.size === 'small',
|
|
27
28
|
'medium': this.size === 'medium',
|
|
28
|
-
} }, h(this.as, { key: '
|
|
29
|
+
} }, h(this.as, { key: '1079c5db34801176d0aa51aaa02613a2357494fb', href: this.href, target: this.target, part: "button-native", class: "button-native", type: this.type, disabled: this.disabled || this.pending }, h("slot", { key: 'f5eaff65f6243b2506557e0cc2797217baa31db7', name: "start" }), this.pending ? h("cpsl-spinner", { size: 19 }) : h("slot", null), h("slot", { key: '257554b7f318af94ac762003129aa13f3b446767', name: "end" }))));
|
|
29
30
|
}
|
|
30
31
|
static get is() { return "cpsl-button"; }
|
|
31
32
|
static get encapsulation() { return "shadow"; }
|
|
@@ -77,6 +78,24 @@ export class CpslButton {
|
|
|
77
78
|
"reflect": true,
|
|
78
79
|
"defaultValue": "false"
|
|
79
80
|
},
|
|
81
|
+
"pending": {
|
|
82
|
+
"type": "boolean",
|
|
83
|
+
"mutable": false,
|
|
84
|
+
"complexType": {
|
|
85
|
+
"original": "boolean",
|
|
86
|
+
"resolved": "boolean",
|
|
87
|
+
"references": {}
|
|
88
|
+
},
|
|
89
|
+
"required": false,
|
|
90
|
+
"optional": true,
|
|
91
|
+
"docs": {
|
|
92
|
+
"tags": [],
|
|
93
|
+
"text": "If the button is pending.\nDefault is: false."
|
|
94
|
+
},
|
|
95
|
+
"attribute": "pending",
|
|
96
|
+
"reflect": false,
|
|
97
|
+
"defaultValue": "false"
|
|
98
|
+
},
|
|
80
99
|
"fullWidth": {
|
|
81
100
|
"type": "boolean",
|
|
82
101
|
"mutable": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpsl-button.js","sourceRoot":"","sources":["../../../../src/components/cpsl-button/cpsl-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAOzD,MAAM,OAAO,UAAU;;kBAMS,QAAQ;wBAMQ,KAAK;
|
|
1
|
+
{"version":3,"file":"cpsl-button.js","sourceRoot":"","sources":["../../../../src/components/cpsl-button/cpsl-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAOzD,MAAM,OAAO,UAAU;;kBAMS,QAAQ;wBAMQ,KAAK;uBAMvB,KAAK;yBAMH,KAAK;;oBAYY,QAAQ;;oBAUR,QAAQ;uBAO6C,SAAS;;IAE7G,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,qDACH,KAAK,EAAE;gBACL,WAAW;gBACX,SAAS,EAAE,IAAI,CAAC,OAAO,KAAK,SAAS;gBACrC,WAAW,EAAE,IAAI,CAAC,OAAO,KAAK,WAAW;gBACzC,UAAU,EAAE,IAAI,CAAC,OAAO,KAAK,UAAU;gBACvC,OAAO,EAAE,IAAI,CAAC,OAAO,KAAK,OAAO;gBACjC,aAAa,EAAE,IAAI,CAAC,OAAO,KAAK,aAAa;gBAC7C,QAAQ;gBACR,UAAU,EAAE,IAAI,CAAC,QAAQ;gBACzB,YAAY,EAAE,IAAI,CAAC,SAAS;gBAC5B,QAAQ;gBACR,QAAQ,EAAE,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAChC,OAAO,EAAE,IAAI,CAAC,IAAI,KAAK,OAAO;gBAC9B,QAAQ,EAAE,IAAI,CAAC,IAAI,KAAK,QAAQ;aACjC;YAED,EAAC,IAAI,CAAC,EAAE,qDAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAC,eAAe,EAAC,KAAK,EAAC,eAAe,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO;gBAChJ,6DAAM,IAAI,EAAC,OAAO,GAAQ;gBACzB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAc,IAAI,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,eAAa;gBAC1D,6DAAM,IAAI,EAAC,KAAK,GAAQ,CAChB,CACL,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'cpsl-button',\n styleUrl: 'cpsl-button.scss',\n shadow: true,\n})\nexport class CpslButton {\n /**\n * The tag for the button.\n * Options are: `\"button\"`, `\"a\".\n * Default is: `\"button\"`.\n */\n @Prop() as?: 'button' | 'a' = 'button';\n\n /**\n * If the button is disabled.\n * Default is: false.\n */\n @Prop({ reflect: true }) disabled?: boolean = false;\n\n /**\n * If the button is pending.\n * Default is: false.\n */\n @Prop() pending?: boolean = false;\n\n /**\n * Whether the button takes the full width of it's container.\n * Default is: false.\n */\n @Prop() fullWidth?: boolean = false;\n\n /**\n * href to use when using a link.\n */\n @Prop() href?: string;\n\n /**\n * The size of the button.\n * Options are: `\"small\"`, `\"medium\".\n * Default is: `\"medium\"`.\n */\n @Prop() size?: 'xSmall' | 'small' | 'medium' = 'medium';\n\n /**\n * target to use when using a link.\n */\n @Prop() target?: string;\n\n /**\n * The type of the button.\n */\n @Prop() type?: 'button' | 'submit' | 'reset' = 'button';\n\n /**\n * The variant of the button.\n * Options are: `\"primary\"`, `\"secondary\", `\"tertiary\", `\"ghost\"`, `\"destructive\"`.\n * Default is: `\"primary\"`.\n */\n @Prop({ reflect: true }) variant?: 'primary' | 'secondary' | 'tertiary' | 'ghost' | 'destructive' = 'primary';\n\n render() {\n return (\n <Host\n class={{\n // VARIANTS\n 'primary': this.variant === 'primary',\n 'secondary': this.variant === 'secondary',\n 'tertiary': this.variant === 'tertiary',\n 'ghost': this.variant === 'ghost',\n 'destructive': this.variant === 'destructive',\n // STATE\n 'disabled': this.disabled,\n 'full-width': this.fullWidth,\n // SIZES\n 'xSmall': this.size === 'xSmall',\n 'small': this.size === 'small',\n 'medium': this.size === 'medium',\n }}\n >\n <this.as href={this.href} target={this.target} part=\"button-native\" class=\"button-native\" type={this.type} disabled={this.disabled || this.pending}>\n <slot name=\"start\"></slot>\n {this.pending ? <cpsl-spinner size={19} /> : <slot></slot>}\n <slot name=\"end\"></slot>\n </this.as>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -32,7 +32,7 @@ export class CpslButtonGroup {
|
|
|
32
32
|
return this.el.querySelectorAll('&> *:not(cpsl-button)');
|
|
33
33
|
}
|
|
34
34
|
render() {
|
|
35
|
-
return (h(Host, { key: '
|
|
35
|
+
return (h(Host, { key: '13009bfa07a89c5bd9412683b8bc8338e9455dee' }, h("slot", { key: '308767ba6d3d3147f1ab60bcc98aa7ca1d1a2c28' })));
|
|
36
36
|
}
|
|
37
37
|
static get is() { return "cpsl-button-group"; }
|
|
38
38
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
export class CpslCard {
|
|
3
3
|
render() {
|
|
4
|
-
return (h(Host, { key: '
|
|
4
|
+
return (h(Host, { key: 'f0b2545bd8c71dad45cdacc819695a7778bb9fcc' }, h("div", { key: '6c49feb59a958cc196d0c12a73839445353d44e7', class: { card: true }, part: "card-container" }, h("slot", { key: '04b3ecd54d97ea584a96b915d262a3d357d26fe4' }))));
|
|
5
5
|
}
|
|
6
6
|
static get is() { return "cpsl-card"; }
|
|
7
7
|
static get encapsulation() { return "shadow"; }
|
|
@@ -7,7 +7,7 @@ export class CpslCheckbox {
|
|
|
7
7
|
this.checked = undefined;
|
|
8
8
|
}
|
|
9
9
|
render() {
|
|
10
|
-
return (h(Host, { key: '
|
|
10
|
+
return (h(Host, { key: '48249b9fb66fd8acff7fb444f39f1b6b86243b81' }, h("input", { key: 'adfca3d8961b8c5ca7d3b3616101772607cb4ee4', type: "checkbox", checked: this.checked }), h("span", { key: '0f4004593d47c1b6d36215eda48959770e99252e', onClick: this.handleCheckboxClick, class: { container: true, checked: this.checked } }, h("cpsl-icon", { key: '31395afa9b4b9cdcbe74fbccd9ec9abd2f03e441', icon: "check" }))));
|
|
11
11
|
}
|
|
12
12
|
static get is() { return "cpsl-checkbox"; }
|
|
13
13
|
static get encapsulation() { return "shadow"; }
|
|
@@ -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: '16e16cc803f099963c784ed7bbd688afb7b8a59f' }, h("div", { key: 'b3f3a0ba95daf12f4e504bf91e9d8e57b3d97b44', 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: '8f01ee92d99bbdde0f0b501640bb3136e4e134f8', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("cpsl-icon", { key: '52a8d308da8c4fad19eec139510df8439a39b6d7', icon: this.errorText ? 'alertCircle' : 'infoCircle' }), h("span", { key: '2d87ea9d774e51055774e76f71074e0eb0d60b10' }, (_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,I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I,0CAAG,CAAC,CAAC,MAAK,SAAS,EAAE,EAC1G,EAAE,EAAE,cAAc,CAAC,EAAE,EACrB,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC,EAC1C,OAAO,EAAE,EAAE,CAAC,EAAE,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,EAA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C,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, 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"]}
|
|
@@ -108,7 +108,7 @@ export class CpslCol {
|
|
|
108
108
|
}
|
|
109
109
|
render() {
|
|
110
110
|
const isRTL = document.dir === 'rtl';
|
|
111
|
-
return (h(Host, { key: '
|
|
111
|
+
return (h(Host, { key: 'eac2e429c731259f9a8419cc831b415b3ea072e9', style: Object.assign(Object.assign(Object.assign(Object.assign({}, this.calculateOffset(isRTL)), this.calculatePull(isRTL)), this.calculatePush(isRTL)), this.calculateSize()) }, h("slot", { key: '597831d03acde0ce70a87ba538ae8e555effd248' })));
|
|
112
112
|
}
|
|
113
113
|
static get is() { return "cpsl-col"; }
|
|
114
114
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
export class CpslDivider {
|
|
3
3
|
render() {
|
|
4
|
-
return (h(Host, { key: '
|
|
4
|
+
return (h(Host, { key: 'cffec64f3c150902ccff40b2362ce76dda41e32d' }, h("div", { key: '3ae8f787af8f4f112f0f3c51aa102b89fd7d8529' }), h("slot", { key: '1a6a2a37cd1966ec492e95b0d5cb718f484cc821' }), h("div", { key: '3fbe5d32823ad65a5404a6419d5ea26a73a03290' })));
|
|
5
5
|
}
|
|
6
6
|
static get is() { return "cpsl-divider"; }
|
|
7
7
|
static get encapsulation() { return "shadow"; }
|
|
@@ -33,12 +33,12 @@ export class CpslDrawer {
|
|
|
33
33
|
const setHeight = this.anchor === 'top' || this.anchor === 'bottom';
|
|
34
34
|
const startingAnchor = (_a = `${this.anchorPosition}px`) !== null && _a !== void 0 ? _a : '0px';
|
|
35
35
|
const size = this.size === 'auto' ? 'auto' : `${this.size}px`;
|
|
36
|
-
return (h(Host, { key: '
|
|
36
|
+
return (h(Host, { key: '8e9be7d905e533ffe26c5a13841c7b6770633414', style: Object.assign({ width: setHeight ? '100vw' : size, height: setHeight ? size : '100vh', transitionDuration: `${this.showTransition ? this.transitionDuration : 0}s`, transitionTimingFunction: `${this.transitionFunction}`, [this.anchor]: this.open || this.variant === 'permanent' ? startingAnchor : this.closedAnchorPosition, opacity: this.closedAnchorPosition === undefined ? '0' : '1' }, (this.zIndexOverride ? { zIndex: `${this.zIndexOverride}` } : {})), class: {
|
|
37
37
|
top: this.anchor === 'top',
|
|
38
38
|
bottom: this.anchor === 'bottom',
|
|
39
39
|
left: this.anchor === 'left',
|
|
40
40
|
right: this.anchor === 'right',
|
|
41
|
-
} }, this.variant === 'temporary' && !this.noOverlay && h("cpsl-overlay", { key: '
|
|
41
|
+
} }, this.variant === 'temporary' && !this.noOverlay && h("cpsl-overlay", { key: 'b661c385794ab39eb87a304455da85602fadd349', open: this.open, zIndexOverride: DEFAULT_Z_INDICES.modal + 1 }), h("div", { key: '1ad94f53ce752f518568139cd33e2aa11caa6d58', id: "container", class: "container", part: "container" }, h("slot", { key: '2bd9efb1ed55c388fd4c34e43900a7807f32a0ff' }))));
|
|
42
42
|
}
|
|
43
43
|
static get is() { return "cpsl-drawer"; }
|
|
44
44
|
static get encapsulation() { return "shadow"; }
|
|
@@ -96,7 +96,7 @@ export class CpslDropdown {
|
|
|
96
96
|
}
|
|
97
97
|
render() {
|
|
98
98
|
var _a, _b, _c;
|
|
99
|
-
return (h(Host, { key: '
|
|
99
|
+
return (h(Host, { key: '76f4d93f5c0d4fddca26a8d7dc381d8c9b22119c' }, h("button", { key: '7186e6bedbeac44d8bc8b95de5acafeea999d2f2', class: "dropdown-button", onClick: this.toggleDropdown }, `${((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.selectedLabel) || ((_b = this.selectedItem) === null || _b === void 0 ? void 0 : _b.label)} ${(_c = this.selectedItem) === null || _c === void 0 ? void 0 : _c.value}`, h("div", { key: 'b5ef03a1a7bf5b37aa35ee30ce6233d7b19dc33e', class: `chevron ${this.isOpen ? '' : 'closed'}`, innerHTML: Icons['chevronUp'] })), h("ul", { key: 'b0d9227ed1d360405a0294efbd4fe2a25926b7d2', class: { 'dropdown-options': true, 'open': this.isOpen }, style: { width: this.width } }, this.hasCpslSearch && (h("li", { key: '0a7100d5c60114bf63583a2d808a7cb677053346', class: "search-bar" }, h("input", { key: '098d19346facb88c51674db9005354da36079820', type: "text", placeholder: "Search...", value: this.searchQuery, onInput: this.handleSearchQueryChange }))), this.filteredItems.map(item => (h("li", { onClick: this.handleItemSelect(item) }, h("span", { innerHTML: Icons[item.icon] }), item.label, " ", h("span", { class: "dropdown-value" }, item.value)))))));
|
|
100
100
|
}
|
|
101
101
|
static get is() { return "cpsl-dropdown"; }
|
|
102
102
|
static get encapsulation() { return "shadow"; }
|
|
@@ -116,7 +116,7 @@ export class CpslFileUpload {
|
|
|
116
116
|
}
|
|
117
117
|
render() {
|
|
118
118
|
var _a, _b, _c;
|
|
119
|
-
return (h(Host, { key: '
|
|
119
|
+
return (h(Host, { key: '16d9e9ac3a79cbaab554cd9b8901f2b5a930327d' }, this.label && (h("label", { key: 'a0d3cba9de77959cc1fa9d415e943800997fa1db', class: "label", htmlFor: this.inputId }, this.label, this.required ? '*' : ' ', !this.required && this.showOptionalLabel ? h("span", { class: "optional-label" }, "(optional)") : '')), h("slot", { key: '2ae7b7de344204f341ce8aa8044908bdc183cee1', name: "label" }), h("div", { key: 'd4ba3206869ed403217e37b20e9557784f98cfd2', class: { 'container': true, 'error': Boolean(this.errorText), 'drag': this.dragOver, 'drag-error': this.dragError } }, h("div", { key: '7f344b81e11e07b00e8cdbee5a89cc4300e02b4b', class: { 'label-container': true } }, h("slot", { key: 'c187ed9574eab9e21669a04d6a9d663adabcab75', name: "left-content" })), h("div", { key: '6bc08c41c298577cf71ca7f7209764d62fc42641', class: { 'file-container': true } }, this.FileContent), h("input", { key: '1696d38e71235671341b9e4388fa2a8478d5b259', id: this.inputId, type: "file", accept: (_b = (_a = this.fileTypes) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : '*', files: this.file ? [this.file] : undefined, onDrop: this.handleDrop, onDragEnter: this.handleDragEnter, onDragLeave: this.handleDragLeave, onChange: this.handleInputChange, disabled: this.disabled })), (this.errorText || this.helperText) && (h("div", { key: 'f2c25a388395daf16082856e8135d952e4166247', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("span", { key: 'd6af4e67851048e79f3342156e35b87928dbef7c' }, (_c = this.errorText) !== null && _c !== void 0 ? _c : this.helperText)))));
|
|
120
120
|
}
|
|
121
121
|
static get is() { return "cpsl-file-upload"; }
|
|
122
122
|
static get encapsulation() { return "shadow"; }
|
|
@@ -4,9 +4,9 @@ export class CpslGrid {
|
|
|
4
4
|
this.fixed = false;
|
|
5
5
|
}
|
|
6
6
|
render() {
|
|
7
|
-
return (h(Host, { key: '
|
|
7
|
+
return (h(Host, { key: '72e5d85f46e36e4feea4f0cbb9dd9fbfab730d2a', class: {
|
|
8
8
|
'grid-fixed': this.fixed,
|
|
9
|
-
} }, h("slot", { key: '
|
|
9
|
+
} }, h("slot", { key: 'a42dd16ac733d55025b5309ec2db375622f5d763' })));
|
|
10
10
|
}
|
|
11
11
|
static get is() { return "cpsl-grid"; }
|
|
12
12
|
static get encapsulation() { return "shadow"; }
|
|
@@ -11,7 +11,7 @@ export class CpslHero {
|
|
|
11
11
|
}
|
|
12
12
|
render() {
|
|
13
13
|
var _a;
|
|
14
|
-
return (h(Host, { key: '
|
|
14
|
+
return (h(Host, { key: '0f43804725a20f7b26328249edbc8c8e466e61c3', class: {
|
|
15
15
|
// VARIANTS
|
|
16
16
|
connection: this.variant === 'connection',
|
|
17
17
|
pending: this.variant === 'pending' || this.variant === 'customContent',
|
|
@@ -19,7 +19,7 @@ export class CpslHero {
|
|
|
19
19
|
add: this.variant === 'add',
|
|
20
20
|
failed: this.variant === 'failed',
|
|
21
21
|
externalWalletConnection: this.variant === 'externalWalletConnection',
|
|
22
|
-
} }, h("div", { key: '
|
|
22
|
+
} }, h("div", { key: '7ff260b7fa83024f5f473f1488d2d129cfaba6ba', class: "backgroundContainer", style: { height: `${(_a = this.height) !== null && _a !== void 0 ? _a : 180}px` } }, h("div", { key: 'fef56a7132d376cc21dc151b5aef05d462f79098', class: { background: true, defaultTheme: this.withDefaultTheme } }, h("div", { key: 'f2537306c466e77e6c044ec988f12157611ccdba', class: "ring ring3" }), h("div", { key: '02d4ea64b5f0a359279534da8cbbc71d892c7c4b', class: "ring ring2" }), h("div", { key: 'd5785d9cea769365b4d6fd4d6aca0041ff340e4e', class: "ring ring1" }), h("div", { key: '5f1ecc0b9f2daddce44c0879eba58342f914bd52', class: "ring ring0" }), h("div", { key: '73869ae81871c12c46cc9e36353bf26b62e6db49', class: { ringCenter: true, defaultTheme: this.withDefaultTheme } }, this.variant === 'connection' && (h(Fragment, { key: 'e550ac0bd65a38d443fa11a1d54ac2c6f72706e3' }, h("img", { key: '9ec51a9adca669f8a7ddb3f6c08f25eb5ffa15b1', class: "connectionImage", src: Images.heroDefault }), h("div", { key: 'a28d1d2782c5b779e1cabd3c186110ed5c6e78e1', class: "connectDiagramContainer" }, h("slot", { key: '6aa0a2d54f8d3b26fc27ef4c65dd8c3bfad38e81', name: "connectionLeft" }), h("slot", { key: '23f377aa071e196c25ddef031b57d00161901e02', name: "connectionRight" })))), this.variant === 'pending' && h("img", { key: '83ad71da3389c06c2eb189a2a23deb9b34656bdd', class: "pendingImage", src: Images.heroPending }), this.variant === 'approved' && (h(Fragment, { key: '764ce09b8e297b9b5ff4a8f4352ab9e972d8a600' }, !this.withDefaultTheme && h("img", { key: '8cb1a0eb314cfed91a8494dd9ddd2f6b62a62ed1', class: "approvedImage", src: Images.heroSuccess }), h("cpsl-icon", { key: 'e58d74c4368b774583a665c582cb0f785771eda7', class: "centerIcon", icon: this.withDefaultTheme ? 'heroCheckmark' : 'heroCheckmarkCapsule' }))), this.variant === 'add' && (h(Fragment, { key: 'd572bc623cbdaa16fa166cdb886d168c208f48cb' }, h("cpsl-icon", { key: 'd3a890b7022c1c70d423e32a4450cbc558f070d7', class: "centerIcon", icon: this.withDefaultTheme ? 'heroPlusCircle' : 'heroPlusCircleCapsule' }))), this.variant === 'failed' && h("cpsl-icon", { key: '45bd42ce47c082a137f4139626e308c3e507af6f', class: "centerIcon", icon: "heroAlertCircle" }), this.variant === 'externalWalletConnection' && (h(Fragment, { key: '6a8f0b2d2da82f78360a3da00409e1081da9b2dd' }, h("cpsl-icon", { key: '4d1e2ef2ce1ce98060da43de7b8e8a4e0ce79444', class: "externalConnectionIcon", icon: "heroExternalConnection" }), h("div", { key: '8083965b97a8588a4ec559f9a9a141b453c95d09', class: "connectDiagramContainer" }, h("slot", { key: 'fe069b38214ae56c2153792e1d631537d317f2ae', name: "connectionLeft" }), h("slot", { key: 'c67db85969032ddfc059c6be9d6fcaa40b765f49', name: "connectionRight" })))), this.variant === 'customContent' && (h("div", { key: '68117dc4a67a80f3e25ec0b76a0fdbe60bd9fbd2', class: "customImageContainer" }, h("slot", { key: '6d135752545becd4207091d393b0fd811439eff3', name: "image" })))), !this.hideFadeOut && (h(Fragment, { key: '6e2066f90038a297e77bb57b446ecfb82bd2d38b' }, h("div", { key: 'e916258f80da97a6544f88ca710b02b50f848cd7', class: "fadeOut" }), h("div", { key: 'f5f2bbe26653d030dbbdace587937f5e20d204c4', class: "cover" }))))), h("cpsl-text", { key: '759de2b27dd9a0c5171df86564e961da6e3d4ea4', variant: "headingXS", color: "primary", weight: "semiBold" }, this.title), this.subtitle && (h("cpsl-text", { key: '36d2fb45d985206a128b44346bc535b564460a01', variant: "bodyS", weight: "medium", color: "secondary" }, this.subtitle))));
|
|
23
23
|
}
|
|
24
24
|
static get is() { return "cpsl-hero"; }
|
|
25
25
|
static get encapsulation() { return "shadow"; }
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
--height: 24px;
|
|
60
60
|
--width: 24px;
|
|
61
61
|
--inset: 0px;
|
|
62
|
-
--
|
|
63
|
-
--
|
|
64
|
-
--icon-color: currentColor;
|
|
65
|
-
--icon-fill-color: currentColor;
|
|
66
|
-
--icon-stroke-color: currentColor;
|
|
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));
|
|
67
67
|
width: var(--width);
|
|
68
68
|
height: var(--height);
|
|
69
69
|
}
|
|
@@ -82,13 +82,18 @@
|
|
|
82
82
|
align-items: center;
|
|
83
83
|
width: 100%;
|
|
84
84
|
height: 100%;
|
|
85
|
+
border: var(--icon-border, auto);
|
|
86
|
+
border-radius: var(--icon-border-radius, 0);
|
|
87
|
+
background: var(--icon-background, transparent);
|
|
85
88
|
color: var(--icon-color);
|
|
89
|
+
box-sizing: border-box;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
:host svg {
|
|
89
|
-
width: var(--
|
|
90
|
-
height: var(--
|
|
93
|
+
width: var(--computed-width, "100%");
|
|
94
|
+
height: var(--computed-height, "100%");
|
|
91
95
|
filter: var(--filter);
|
|
96
|
+
border-radius: var(--icon-border-radius, 0);
|
|
92
97
|
}
|
|
93
98
|
:host svg .background-16 {
|
|
94
99
|
fill: var(--cpsl-color-background-16);
|
|
@@ -104,7 +109,9 @@
|
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
:host img {
|
|
107
|
-
width: 100
|
|
108
|
-
height: 100
|
|
112
|
+
width: var(--computed-width, 100%);
|
|
113
|
+
height: var(--computed-height, 100%);
|
|
114
|
+
max-width: 100%;
|
|
115
|
+
max-height: 100%;
|
|
109
116
|
object-fit: contain;
|
|
110
117
|
}
|