@riverty/web-components 5.7.0 → 6.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/CHANGELOG.md +128 -0
- package/custom-elements.json +152 -372
- package/dist/cjs/index-DJ4H_bFj.js +6 -10
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/r-accordion-panel.cjs.entry.js +1 -1
- package/dist/cjs/r-accordion-section.cjs.entry.js +1 -1
- package/dist/cjs/r-accordion-trigger.cjs.entry.js +5 -35
- package/dist/cjs/r-accordion.cjs.entry.js +3 -7
- package/dist/cjs/r-alert.cjs.entry.js +45 -14
- package/dist/cjs/r-badge.cjs.entry.js +1 -1
- package/dist/cjs/r-button.cjs.entry.js +2 -2
- package/dist/cjs/r-checkbox-group.cjs.entry.js +28 -24
- package/dist/cjs/r-checkbox.cjs.entry.js +97 -81
- package/dist/cjs/r-dialog.cjs.entry.js +3 -11
- package/dist/cjs/r-hint_2.cjs.entry.js +50 -0
- package/dist/cjs/{r-hint_3.cjs.entry.js → r-icon-button_2.cjs.entry.js} +64 -51
- package/dist/cjs/r-icon.cjs.entry.js +1 -1
- package/dist/cjs/r-input-code.cjs.entry.js +133 -25
- package/dist/cjs/r-input-date.cjs.entry.js +87 -23
- package/dist/cjs/r-input-password.cjs.entry.js +34 -13
- package/dist/cjs/r-input-phone-number.cjs.entry.js +30 -22
- package/dist/cjs/r-input.cjs.entry.js +108 -49
- package/dist/cjs/r-list-item.cjs.entry.js +5 -5
- package/dist/cjs/r-pagination.cjs.entry.js +1 -1
- package/dist/cjs/r-panel.cjs.entry.js +2 -2
- package/dist/cjs/r-popover-action.cjs.entry.js +2 -2
- package/dist/cjs/r-popover-content.cjs.entry.js +1 -1
- package/dist/cjs/r-popover-headline.cjs.entry.js +1 -1
- package/dist/cjs/r-popover-trigger.cjs.entry.js +1 -1
- package/dist/cjs/r-popover.cjs.entry.js +3 -3
- package/dist/cjs/r-progress-bar.cjs.entry.js +1 -1
- package/dist/cjs/r-radio-button-description.cjs.entry.js +1 -1
- package/dist/cjs/r-radio-button-leading.cjs.entry.js +1 -1
- package/dist/cjs/r-radio-button-title.cjs.entry.js +1 -1
- package/dist/cjs/r-radio-button-trailing.cjs.entry.js +1 -1
- package/dist/cjs/r-radio-button.cjs.entry.js +29 -12
- package/dist/cjs/r-radio-group.cjs.entry.js +32 -32
- package/dist/cjs/r-select-option.cjs.entry.js +1 -1
- package/dist/cjs/r-select.cjs.entry.js +116 -40
- package/dist/cjs/r-skip-link.cjs.entry.js +1 -1
- package/dist/cjs/r-stepper-item.cjs.entry.js +2 -2
- package/dist/cjs/r-stepper.cjs.entry.js +1 -1
- package/dist/cjs/r-tab-panel.cjs.entry.js +1 -1
- package/dist/cjs/r-tab.cjs.entry.js +1 -1
- package/dist/cjs/r-tabs-list.cjs.entry.js +1 -1
- package/dist/cjs/r-tabs.cjs.entry.js +1 -1
- package/dist/cjs/r-textarea.cjs.entry.js +24 -23
- package/dist/cjs/r-toast-group.cjs.entry.js +1 -1
- package/dist/cjs/r-toast.cjs.entry.js +51 -20
- package/dist/cjs/web-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +0 -1
- package/dist/collection/components/accordion/accordion.css +0 -2
- package/dist/collection/components/accordion/accordion.js +4 -8
- package/dist/collection/components/accordion/exports.js +1 -1
- package/dist/collection/components/accordion-panel/accordion-panel.js +1 -1
- package/dist/collection/components/accordion-section/accordion-section.js +1 -1
- package/dist/collection/components/accordion-trigger/accordion-trigger.css +0 -4
- package/dist/collection/components/accordion-trigger/accordion-trigger.js +4 -215
- package/dist/collection/components/alert/alert.css +58 -12
- package/dist/collection/components/alert/alert.js +92 -17
- package/dist/collection/components/alert/exports.js +1 -1
- package/dist/collection/components/badge/badge.js +1 -1
- package/dist/collection/components/button/button.css +6 -7
- package/dist/collection/components/button/button.js +1 -1
- package/dist/collection/components/checkbox/checkbox.js +121 -104
- package/dist/collection/components/checkbox-group/checkbox-group.js +48 -63
- package/dist/collection/components/dialog/dialog.css +1 -3
- package/dist/collection/components/dialog/dialog.js +2 -10
- package/dist/collection/components/hint/hint.js +2 -2
- package/dist/collection/components/icon/bundled-icons/riverty-kit.json +1 -1
- package/dist/collection/components/icon/riverty-kit.js +1 -1
- package/dist/collection/components/icon-button/icon-button.css +0 -7
- package/dist/collection/components/icon-button/icon-button.js +3 -3
- package/dist/collection/components/input/input.css +3 -0
- package/dist/collection/components/input/input.js +221 -378
- package/dist/collection/components/input-code/exports.js +2 -0
- package/dist/collection/components/input-code/input-code.js +335 -34
- package/dist/collection/components/input-date/input-date.js +237 -87
- package/dist/collection/components/input-password/exports.js +1 -0
- package/dist/collection/components/input-password/input-password.css +1 -0
- package/dist/collection/components/input-password/input-password.js +233 -75
- package/dist/collection/components/input-phone-number/input-phone-number.js +50 -85
- package/dist/collection/components/label/label.js +3 -113
- package/dist/collection/components/list-item/list-item/list-item.css +7 -7
- package/dist/collection/components/list-item/list-item/list-item.js +4 -26
- package/dist/collection/components/pagination/pagination.css +23 -23
- package/dist/collection/components/panel/panel.js +2 -2
- package/dist/collection/components/popover/exports.js +0 -1
- package/dist/collection/components/popover/popover.css +13 -13
- package/dist/collection/components/popover/popover.js +2 -55
- package/dist/collection/components/popover-action/popover-action.css +3 -5
- package/dist/collection/components/popover-action/popover-action.js +1 -1
- package/dist/collection/components/popover-content/popover-content.js +1 -1
- package/dist/collection/components/popover-headline/popover-headline.js +1 -1
- package/dist/collection/components/popover-trigger/popover-trigger.js +1 -1
- package/dist/collection/components/progress-bar/progress-bar.js +1 -1
- package/dist/collection/components/radio-button/radio-button.js +49 -12
- package/dist/collection/components/radio-button-description/radio-button-description.js +1 -1
- package/dist/collection/components/radio-button-leading/radio-button-leading.js +1 -1
- package/dist/collection/components/radio-button-title/radio-button-title.js +1 -1
- package/dist/collection/components/radio-button-trailing/radio-button-trailing.js +1 -1
- package/dist/collection/components/radio-group/radio-group.js +53 -135
- package/dist/collection/components/select/select.js +197 -349
- package/dist/collection/components/select-option/select-option.js +1 -1
- package/dist/collection/components/skip-link/skip-link.js +1 -1
- package/dist/collection/components/stepper/stepper.js +1 -1
- package/dist/collection/components/stepper-item/stepper-item.js +2 -2
- package/dist/collection/components/tab/tab.js +1 -1
- package/dist/collection/components/tab-panel/tab-panel.js +1 -1
- package/dist/collection/components/tabs/tabs.js +1 -1
- package/dist/collection/components/tabs-list/tabs-list.js +1 -1
- package/dist/collection/components/textarea/textarea.js +44 -163
- package/dist/collection/components/toast/toast.css +22 -14
- package/dist/collection/components/toast/toast.js +95 -43
- package/dist/collection/components/toast-group/toast-group.js +1 -1
- package/dist/collection/components/tooltip/tooltip.js +1 -1
- package/dist/esm/index-Da7qOBFr.js +6 -10
- package/dist/esm/loader.js +1 -1
- package/dist/esm/r-accordion-panel.entry.js +1 -1
- package/dist/esm/r-accordion-section.entry.js +1 -1
- package/dist/esm/r-accordion-trigger.entry.js +5 -35
- package/dist/esm/r-accordion.entry.js +3 -7
- package/dist/esm/r-alert.entry.js +45 -14
- package/dist/esm/r-badge.entry.js +1 -1
- package/dist/esm/r-button.entry.js +2 -2
- package/dist/esm/r-checkbox-group.entry.js +28 -24
- package/dist/esm/r-checkbox.entry.js +97 -81
- package/dist/esm/r-dialog.entry.js +3 -11
- package/dist/esm/r-hint_2.entry.js +47 -0
- package/dist/esm/{r-hint_3.entry.js → r-icon-button_2.entry.js} +65 -51
- package/dist/esm/r-icon.entry.js +1 -1
- package/dist/esm/r-input-code.entry.js +133 -25
- package/dist/esm/r-input-date.entry.js +87 -23
- package/dist/esm/r-input-password.entry.js +34 -13
- package/dist/esm/r-input-phone-number.entry.js +30 -22
- package/dist/esm/r-input.entry.js +108 -49
- package/dist/esm/r-list-item.entry.js +5 -5
- package/dist/esm/r-pagination.entry.js +1 -1
- package/dist/esm/r-panel.entry.js +2 -2
- package/dist/esm/r-popover-action.entry.js +2 -2
- package/dist/esm/r-popover-content.entry.js +1 -1
- package/dist/esm/r-popover-headline.entry.js +1 -1
- package/dist/esm/r-popover-trigger.entry.js +1 -1
- package/dist/esm/r-popover.entry.js +3 -3
- package/dist/esm/r-progress-bar.entry.js +1 -1
- package/dist/esm/r-radio-button-description.entry.js +1 -1
- package/dist/esm/r-radio-button-leading.entry.js +1 -1
- package/dist/esm/r-radio-button-title.entry.js +1 -1
- package/dist/esm/r-radio-button-trailing.entry.js +1 -1
- package/dist/esm/r-radio-button.entry.js +29 -12
- package/dist/esm/r-radio-group.entry.js +32 -32
- package/dist/esm/r-select-option.entry.js +1 -1
- package/dist/esm/r-select.entry.js +116 -40
- package/dist/esm/r-skip-link.entry.js +1 -1
- package/dist/esm/r-stepper-item.entry.js +2 -2
- package/dist/esm/r-stepper.entry.js +1 -1
- package/dist/esm/r-tab-panel.entry.js +1 -1
- package/dist/esm/r-tab.entry.js +1 -1
- package/dist/esm/r-tabs-list.entry.js +1 -1
- package/dist/esm/r-tabs.entry.js +1 -1
- package/dist/esm/r-textarea.entry.js +24 -23
- package/dist/esm/r-toast-group.entry.js +1 -1
- package/dist/esm/r-toast.entry.js +51 -20
- package/dist/esm/web-components.js +1 -1
- package/dist/types/components/accordion/accordion.d.ts +1 -5
- package/dist/types/components/accordion/exports.d.ts +1 -1
- package/dist/types/components/accordion-trigger/accordion-trigger.d.ts +0 -36
- package/dist/types/components/alert/alert.d.ts +9 -1
- package/dist/types/components/alert/exports.d.ts +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +29 -34
- package/dist/types/components/checkbox-group/checkbox-group.d.ts +6 -11
- package/dist/types/components/dialog/dialog.d.ts +0 -2
- package/dist/types/components/input/input.d.ts +35 -72
- package/dist/types/components/input-code/exports.d.ts +4 -0
- package/dist/types/components/input-code/input-code.d.ts +54 -7
- package/dist/types/components/input-date/input-date.d.ts +30 -16
- package/dist/types/components/input-password/exports.d.ts +1 -0
- package/dist/types/components/input-password/input-password.d.ts +53 -16
- package/dist/types/components/input-phone-number/input-phone-number.d.ts +5 -16
- package/dist/types/components/label/label.d.ts +0 -18
- package/dist/types/components/list-item/list-item/list-item.d.ts +0 -6
- package/dist/types/components/popover/exports.d.ts +0 -2
- package/dist/types/components/popover/popover.d.ts +1 -14
- package/dist/types/components/radio-button/radio-button.d.ts +5 -0
- package/dist/types/components/radio-group/radio-group.d.ts +6 -28
- package/dist/types/components/select/select.d.ts +34 -52
- package/dist/types/components/textarea/textarea.d.ts +5 -32
- package/dist/types/components/toast/toast.d.ts +10 -7
- package/dist/types/components.d.ts +347 -647
- package/dist/web-components/bundled-icons/riverty-kit.json +1 -1
- package/dist/web-components/p-0347feff.entry.js +1 -0
- package/dist/web-components/p-05738503.entry.js +1 -0
- package/dist/web-components/p-0e4c8bf1.entry.js +1 -0
- package/dist/web-components/p-1da75540.entry.js +1 -0
- package/dist/web-components/p-26ef77d6.entry.js +1 -0
- package/dist/web-components/p-3884c6e7.entry.js +1 -0
- package/dist/web-components/p-3a5a67e7.entry.js +1 -0
- package/dist/web-components/p-3f60c6c0.entry.js +1 -0
- package/dist/web-components/p-4254a383.entry.js +1 -0
- package/dist/web-components/{p-87f39749.entry.js → p-4595fa8e.entry.js} +1 -1
- package/dist/web-components/{p-4e3df002.entry.js → p-4cc58c6a.entry.js} +1 -1
- package/dist/web-components/p-5441b746.entry.js +1 -0
- package/dist/web-components/{p-72fa1fd1.entry.js → p-550e2237.entry.js} +1 -1
- package/dist/web-components/p-589baaf9.entry.js +1 -0
- package/dist/web-components/p-60341de2.entry.js +1 -0
- package/dist/web-components/{p-4bd3e077.entry.js → p-60ca994e.entry.js} +1 -1
- package/dist/web-components/{p-44ae9f33.entry.js → p-62b788bf.entry.js} +1 -1
- package/dist/web-components/{p-2b2f581a.entry.js → p-6303b9fe.entry.js} +1 -1
- package/dist/web-components/p-63fd817d.entry.js +1 -0
- package/dist/web-components/{p-e0e2f2b2.entry.js → p-673dbfd0.entry.js} +1 -1
- package/dist/web-components/p-67fa3f84.entry.js +1 -0
- package/dist/web-components/p-6a4f3836.entry.js +1 -0
- package/dist/web-components/p-6cc2ea2c.entry.js +1 -0
- package/dist/web-components/p-70784685.entry.js +1 -0
- package/dist/web-components/{p-429213ea.entry.js → p-7fed6f4d.entry.js} +1 -1
- package/dist/web-components/p-8a66d20c.entry.js +1 -0
- package/dist/web-components/{p-0bb04d79.entry.js → p-8b4d2448.entry.js} +1 -1
- package/dist/web-components/{p-c7f8e59b.entry.js → p-8c31cbd5.entry.js} +1 -1
- package/dist/web-components/p-8dac326b.entry.js +1 -0
- package/dist/web-components/{p-1c2497de.entry.js → p-9ef1bbee.entry.js} +1 -1
- package/dist/web-components/p-a0dbde7c.entry.js +1 -0
- package/dist/web-components/{p-755cc697.entry.js → p-a71485d8.entry.js} +1 -1
- package/dist/web-components/p-a7d22c76.entry.js +1 -0
- package/dist/web-components/{p-85a9af42.entry.js → p-ae251d2f.entry.js} +1 -1
- package/dist/web-components/{p-77155630.entry.js → p-b98ab649.entry.js} +1 -1
- package/dist/web-components/p-b9e3b3d6.entry.js +1 -0
- package/dist/web-components/p-c1e748f2.entry.js +1 -0
- package/dist/web-components/p-c478712b.entry.js +1 -0
- package/dist/web-components/{p-72c0c0d8.entry.js → p-d054eb4d.entry.js} +1 -1
- package/dist/web-components/p-d433a828.entry.js +1 -0
- package/dist/web-components/p-d7726e46.entry.js +1 -0
- package/dist/web-components/p-d819c8e5.entry.js +1 -0
- package/dist/web-components/p-e2188953.entry.js +1 -0
- package/dist/web-components/{p-3b4e3faf.entry.js → p-e5945c01.entry.js} +1 -1
- package/dist/web-components/{p-d1379ac6.entry.js → p-f9d5004c.entry.js} +1 -1
- package/dist/web-components/web-components.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/r-accordion-item.cjs.entry.js +0 -78
- package/dist/cjs/r-icon-button.cjs.entry.js +0 -81
- package/dist/collection/components/accordion-item/accordion-item.css +0 -121
- package/dist/collection/components/accordion-item/accordion-item.js +0 -138
- package/dist/esm/r-accordion-item.entry.js +0 -76
- package/dist/esm/r-icon-button.entry.js +0 -79
- package/dist/types/components/accordion-item/accordion-item.d.ts +0 -26
- package/dist/web-components/p-00ca474f.entry.js +0 -1
- package/dist/web-components/p-289eb4b0.entry.js +0 -1
- package/dist/web-components/p-2b8e12ae.entry.js +0 -1
- package/dist/web-components/p-2e2c8a5b.entry.js +0 -1
- package/dist/web-components/p-3a39932b.entry.js +0 -1
- package/dist/web-components/p-3bc93d65.entry.js +0 -1
- package/dist/web-components/p-44be9992.entry.js +0 -1
- package/dist/web-components/p-4652635a.entry.js +0 -1
- package/dist/web-components/p-51a5804b.entry.js +0 -1
- package/dist/web-components/p-63474b32.entry.js +0 -1
- package/dist/web-components/p-74d2a563.entry.js +0 -1
- package/dist/web-components/p-7ad8e78b.entry.js +0 -1
- package/dist/web-components/p-8028c2a9.entry.js +0 -1
- package/dist/web-components/p-96ddeb7f.entry.js +0 -1
- package/dist/web-components/p-9d898089.entry.js +0 -1
- package/dist/web-components/p-9e50120b.entry.js +0 -1
- package/dist/web-components/p-9eb1f262.entry.js +0 -1
- package/dist/web-components/p-a022f356.entry.js +0 -1
- package/dist/web-components/p-a7e7f8fa.entry.js +0 -1
- package/dist/web-components/p-b2f03016.entry.js +0 -1
- package/dist/web-components/p-c300c22f.entry.js +0 -1
- package/dist/web-components/p-c937bd92.entry.js +0 -1
- package/dist/web-components/p-cbcd7699.entry.js +0 -1
- package/dist/web-components/p-d93c240d.entry.js +0 -1
- package/dist/web-components/p-e4b66277.entry.js +0 -1
- package/dist/web-components/p-e6a31881.entry.js +0 -1
- package/dist/web-components/p-f6a92287.entry.js +0 -1
- package/dist/web-components/p-f770e22b.entry.js +0 -1
- package/dist/web-components/p-f952161b.entry.js +0 -1
|
@@ -2,18 +2,32 @@ import { h, Host } from "@stencil/core";
|
|
|
2
2
|
import { appendControlToFormData } from "../../utils/formData";
|
|
3
3
|
export class InputCode {
|
|
4
4
|
constructor() {
|
|
5
|
-
/** Specifies a name for an input for
|
|
5
|
+
/** Specifies a name for an input for submission within formData object. */
|
|
6
6
|
this.name = 'input-code';
|
|
7
|
-
/** Number of digits (typically 4–6)
|
|
7
|
+
/** Number of digits (typically 4–6).
|
|
8
|
+
* @default: 4
|
|
9
|
+
*/
|
|
8
10
|
this.length = 4;
|
|
9
|
-
/** Label for accessibility
|
|
11
|
+
/** Label for accessibility.
|
|
12
|
+
* @default: 'Verification code'
|
|
13
|
+
*/
|
|
10
14
|
this.label = 'Verification code';
|
|
11
|
-
/** Set custom message for `tooShort` property of a ValidityState object (set by `minlength`) within Constrain Validation API */
|
|
12
|
-
this.tooShortMessage = `All ${this.length} characters must be filled.`;
|
|
13
15
|
/** Defines initial value */
|
|
14
16
|
this.value = '';
|
|
17
|
+
/** Specifies the input mode for the virtual keyboard on mobile devices. Default is 'numeric' for OTP codes.
|
|
18
|
+
* @default: 'numeric'
|
|
19
|
+
*/
|
|
20
|
+
this.inputmode = 'numeric';
|
|
21
|
+
/** Specifies the enter key hint for the virtual keyboard. Default is 'done' for OTP completion.
|
|
22
|
+
* @default: 'done'
|
|
23
|
+
*/
|
|
24
|
+
this.enterkeyhint = 'done';
|
|
25
|
+
/** Specifies the autocomplete behavior. Default is 'one-time-code' for SMS OTP autofill.
|
|
26
|
+
* @default: 'one-time-code'
|
|
27
|
+
*/
|
|
28
|
+
this.autocomplete = 'one-time-code';
|
|
15
29
|
/** Holds the current values of each input box */
|
|
16
|
-
this.values =
|
|
30
|
+
this.values = [];
|
|
17
31
|
/** Validity state passed from validateFormElement function after validation */
|
|
18
32
|
this.validityState = '';
|
|
19
33
|
/** Validity message passed from validateFormElement function after validation */
|
|
@@ -98,24 +112,33 @@ export class InputCode {
|
|
|
98
112
|
this.uniqueId = `r-input-code-${Date.now().toString(32)}${Math.random().toString(32)}`.replace(/\./g, '');
|
|
99
113
|
this.nativeElement = null;
|
|
100
114
|
this.getValidityStateData = (element) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
let validityState = '';
|
|
116
|
+
let validityMessage = '';
|
|
117
|
+
if (!element) {
|
|
118
|
+
validityState = 'valid';
|
|
119
|
+
return { validityState, validityMessage };
|
|
120
|
+
}
|
|
121
|
+
if (this.required && element.value.length === 0) {
|
|
122
|
+
validityState = 'valueMissing';
|
|
123
|
+
validityMessage = this.valueMissingMessage;
|
|
124
|
+
return { validityState, validityMessage };
|
|
105
125
|
}
|
|
106
126
|
if (element.value.length > 0 && element.value.length < this.length) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return;
|
|
127
|
+
validityState = 'tooShort';
|
|
128
|
+
validityMessage = this.tooShortMessage || `All ${this.length} characters must be filled.`;
|
|
129
|
+
return { validityState, validityMessage };
|
|
110
130
|
}
|
|
111
|
-
|
|
131
|
+
validityState = 'valid';
|
|
132
|
+
return { validityState, validityMessage };
|
|
112
133
|
};
|
|
113
134
|
this.validateFormElement = (element) => {
|
|
114
135
|
if (element === null)
|
|
115
136
|
return;
|
|
116
137
|
if (this.isNoValidate)
|
|
117
138
|
return;
|
|
118
|
-
this.getValidityStateData(element);
|
|
139
|
+
const { validityState, validityMessage } = this.getValidityStateData(element);
|
|
140
|
+
this.validityState = validityState;
|
|
141
|
+
this.validityMessage = validityMessage;
|
|
119
142
|
const isValid = this.validityState === 'valid';
|
|
120
143
|
this.valid = isValid;
|
|
121
144
|
this.invalid = !isValid;
|
|
@@ -127,7 +150,7 @@ export class InputCode {
|
|
|
127
150
|
this.onResetForm = async () => {
|
|
128
151
|
if (this.readonly)
|
|
129
152
|
return;
|
|
130
|
-
this.reset();
|
|
153
|
+
await this.reset();
|
|
131
154
|
this.validityState = null;
|
|
132
155
|
this.validityMessage = null;
|
|
133
156
|
this.invalid = null;
|
|
@@ -150,6 +173,19 @@ export class InputCode {
|
|
|
150
173
|
appendControlToFormData(this.nativeElement || this.host, event.formData);
|
|
151
174
|
};
|
|
152
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Validates segment index and throws descriptive errors if invalid.
|
|
178
|
+
* @param index - The index to validate
|
|
179
|
+
* @throws Error if index is not an integer or out of bounds
|
|
180
|
+
*/
|
|
181
|
+
validateSegmentIndex(index) {
|
|
182
|
+
if (typeof index !== 'number' || !Number.isInteger(index)) {
|
|
183
|
+
throw new Error('Index must be an integer');
|
|
184
|
+
}
|
|
185
|
+
if (index < 0 || index >= this.length) {
|
|
186
|
+
throw new Error(`Index out of bounds: must be between 0 and ${this.length - 1}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
153
189
|
/**
|
|
154
190
|
* Gets the current complete code value by joining all individual digit values.
|
|
155
191
|
* @returns Promise that resolves to the complete code string
|
|
@@ -177,12 +213,83 @@ export class InputCode {
|
|
|
177
213
|
return;
|
|
178
214
|
}
|
|
179
215
|
const valueArray = Array.from(value).slice(0, this.length).map(char => String(char));
|
|
216
|
+
// Pad with empty strings if value is shorter than length
|
|
217
|
+
while (valueArray.length < this.length) {
|
|
218
|
+
valueArray.push('');
|
|
219
|
+
}
|
|
180
220
|
this.values = valueArray;
|
|
181
221
|
this.rChange.emit({ value: this.values.join('') });
|
|
182
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Validates the input code without triggering UI and returns a boolean indicating its validity.
|
|
225
|
+
* @returns A boolean indicating whether the input code is valid.
|
|
226
|
+
*/
|
|
227
|
+
async checkValidity() {
|
|
228
|
+
const { validityState } = this.getValidityStateData(this.nativeElement);
|
|
229
|
+
return validityState === 'valid';
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Focuses a specific segment (input) by index.
|
|
233
|
+
* @param index - The zero-based index of the segment to focus (0 to length-1)
|
|
234
|
+
* @returns Promise that resolves when focus is set, or rejects if index is invalid
|
|
235
|
+
*/
|
|
236
|
+
async focusSegment(index) {
|
|
237
|
+
this.validateSegmentIndex(index);
|
|
238
|
+
const input = this.inputs[index];
|
|
239
|
+
if (input) {
|
|
240
|
+
input.focus();
|
|
241
|
+
// Select the content if it exists
|
|
242
|
+
if (this.values[index]) {
|
|
243
|
+
setTimeout(() => {
|
|
244
|
+
// Check if setSelectionRange exists (not available in some test environments)
|
|
245
|
+
if (typeof input.setSelectionRange === 'function') {
|
|
246
|
+
input.setSelectionRange(0, 1);
|
|
247
|
+
}
|
|
248
|
+
}, 0);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Gets the value of a specific segment by index.
|
|
254
|
+
* @param index - The zero-based index of the segment (0 to length-1)
|
|
255
|
+
* @returns Promise that resolves to the segment value (single character string or empty string)
|
|
256
|
+
*/
|
|
257
|
+
async getSegmentValue(index) {
|
|
258
|
+
this.validateSegmentIndex(index);
|
|
259
|
+
return this.values[index] || '';
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Sets the value of a specific segment by index.
|
|
263
|
+
* @param index - The zero-based index of the segment (0 to length-1)
|
|
264
|
+
* @param value - The value to set (will be truncated to first character if longer)
|
|
265
|
+
*/
|
|
266
|
+
async setSegmentValue(index, value) {
|
|
267
|
+
this.validateSegmentIndex(index);
|
|
268
|
+
// Take only the first character, or empty string if value is empty
|
|
269
|
+
const newValue = value ? value.charAt(0) : '';
|
|
270
|
+
this.values[index] = newValue;
|
|
271
|
+
this.values = [...this.values];
|
|
272
|
+
// Update the input element's value to reflect the change
|
|
273
|
+
const input = this.inputs[index];
|
|
274
|
+
if (input) {
|
|
275
|
+
input.value = newValue;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
183
278
|
handleValuesChange() {
|
|
184
279
|
this.value = this.values.join('');
|
|
185
280
|
}
|
|
281
|
+
handleLengthChange(newLength) {
|
|
282
|
+
// Adjust values array when length changes
|
|
283
|
+
if (this.values.length !== newLength) {
|
|
284
|
+
const newValues = new Array(newLength).fill('');
|
|
285
|
+
// Copy existing values up to the new length
|
|
286
|
+
for (let i = 0; i < Math.min(this.values.length, newLength); i++) {
|
|
287
|
+
newValues[i] = this.values[i];
|
|
288
|
+
}
|
|
289
|
+
this.values = newValues;
|
|
290
|
+
this.inputs = [];
|
|
291
|
+
}
|
|
292
|
+
}
|
|
186
293
|
get firstEmptyInput() {
|
|
187
294
|
return this.inputs.find(input => !input.value) || null;
|
|
188
295
|
}
|
|
@@ -195,7 +302,7 @@ export class InputCode {
|
|
|
195
302
|
return null;
|
|
196
303
|
}
|
|
197
304
|
return (this.validityState && this.validityState !== 'valid' ?
|
|
198
|
-
(this.customErrorMessage || this.validityMessage)
|
|
305
|
+
(this.customErrorMessage || this.validityMessage || `All ${this.length} characters must be filled.`)
|
|
199
306
|
: null);
|
|
200
307
|
}
|
|
201
308
|
get ariaDescribedBy() {
|
|
@@ -273,15 +380,15 @@ export class InputCode {
|
|
|
273
380
|
id: `${uniqueId}-label`,
|
|
274
381
|
fieldIndicator
|
|
275
382
|
} : {};
|
|
276
|
-
return (h(Host, { key: '
|
|
383
|
+
return (h(Host, { key: '4d744320f4bf03760e4b11dd38934c0f7ce05223', value: this.value, onClick: this.onHostClick }, h("div", { key: 'f047f6669b243f301a2a462188d24721ccb565a5', class: "r-input-code--label-container" }, h("label", { key: 'a5acdd7308cca3981a78619c480d79c499ebc58a', htmlFor: uniqueId }, label ?
|
|
277
384
|
h("r-label", Object.assign({}, labelAttr), label)
|
|
278
385
|
:
|
|
279
|
-
h("slot", { name: "label" })), h("slot", { key: '
|
|
280
|
-
h("r-hint", { key: '
|
|
281
|
-
h("r-icon", { key: '
|
|
282
|
-
h("slot", { key: '
|
|
283
|
-
h("r-icon", { key: '
|
|
284
|
-
h("r-hint", { key: '
|
|
386
|
+
h("slot", { name: "label" })), h("slot", { key: '696554954e2b29b49a8d639aa79d80abeaa6a729', name: "popover" })), hint &&
|
|
387
|
+
h("r-hint", { key: '58b3e011e49b4a3bd4dd31050ab554483fba0fc4', id: `${uniqueId}-hint`, role: "note" }, hint), h("div", { key: '6f4668b5bda975b59ff269759e2d3ae3306b09c4', class: "r-input-code--container", role: "group", "aria-labelledby": `${uniqueId}-label`, "aria-describedby": this.groupDescribedby }, h("slot", { key: '59206e0ed6e335735b610c44a925ea70b137ffe0', name: "leading" }), Array.from({ length: this.length }).map((_, i) => (h("input", { class: "r-input-code--input", key: i, id: `${uniqueId}-input-section-${i}`, "aria-label": `${this.ariaCharacterLabel || 'Character'}: ${i + 1}`, "aria-invalid": `${this.invalid || false}`, value: this.values[i], ref: el => this.inputs[i] = el, maxlength: 1, disabled: this.disabled, required: this.required, readonly: readonly, inputmode: this.inputmode, enterkeyhint: this.enterkeyhint, autocomplete: this.autocomplete, onInput: this.createInputHandler(i), onKeyDown: this.createKeyDownHandler(i), onPaste: this.handlePaste }))), h("input", Object.assign({ key: '815da7a7566b0cefdbdfda32c990637385eba304', type: "hidden" }, inputAttrs, { value: this.values.join(''), ref: el => this.nativeElement = el })), h("div", { key: 'b03d7e03bd6c91d441f4377d53bb7d845edf498d', class: "r-input-code--trailing" }, this.readonly &&
|
|
388
|
+
h("r-icon", { key: '53796d1b572ff2eac8297a0fad8e22d3a95f1bee', class: "r-input-code--readonly-icon", name: "pen-disabled", size: "s" }), this.hasTrailingSlot &&
|
|
389
|
+
h("slot", { key: '9becd49e7d79f824fcd79e7afbc3040a1b0f33a3', name: "trailing" }, valid &&
|
|
390
|
+
h("r-icon", { key: 'a31379d7e8eb6ad66bbf1567d4cd4f9526962226', name: "circled-check", size: "s", color: "var(--r-status-success-regular)" })))), h("slot", { key: 'a38ac5d9dda2017a443ec2b58cffbdd0db952239', name: "message" }, this.hasMessage &&
|
|
391
|
+
h("r-hint", { key: '39e47e0fdf23b1ebab5a0384447a965a8890d77f', "aria-live": "polite", id: `${uniqueId}-message`, variant: "error" }, this.message))));
|
|
285
392
|
}
|
|
286
393
|
static get is() { return "r-input-code"; }
|
|
287
394
|
static get encapsulation() { return "shadow"; }
|
|
@@ -329,7 +436,7 @@ export class InputCode {
|
|
|
329
436
|
"optional": false,
|
|
330
437
|
"docs": {
|
|
331
438
|
"tags": [],
|
|
332
|
-
"text": "Specifies a name for an input for
|
|
439
|
+
"text": "Specifies a name for an input for submission within formData object."
|
|
333
440
|
},
|
|
334
441
|
"getter": false,
|
|
335
442
|
"setter": false,
|
|
@@ -348,8 +455,11 @@ export class InputCode {
|
|
|
348
455
|
"required": false,
|
|
349
456
|
"optional": false,
|
|
350
457
|
"docs": {
|
|
351
|
-
"tags": [
|
|
352
|
-
|
|
458
|
+
"tags": [{
|
|
459
|
+
"name": "default",
|
|
460
|
+
"text": ": 4"
|
|
461
|
+
}],
|
|
462
|
+
"text": "Number of digits (typically 4\u20136)."
|
|
353
463
|
},
|
|
354
464
|
"getter": false,
|
|
355
465
|
"setter": false,
|
|
@@ -444,8 +554,11 @@ export class InputCode {
|
|
|
444
554
|
"required": false,
|
|
445
555
|
"optional": false,
|
|
446
556
|
"docs": {
|
|
447
|
-
"tags": [
|
|
448
|
-
|
|
557
|
+
"tags": [{
|
|
558
|
+
"name": "default",
|
|
559
|
+
"text": ": 'Verification code'"
|
|
560
|
+
}],
|
|
561
|
+
"text": "Label for accessibility."
|
|
449
562
|
},
|
|
450
563
|
"getter": false,
|
|
451
564
|
"setter": false,
|
|
@@ -557,15 +670,14 @@ export class InputCode {
|
|
|
557
670
|
"references": {}
|
|
558
671
|
},
|
|
559
672
|
"required": false,
|
|
560
|
-
"optional":
|
|
673
|
+
"optional": true,
|
|
561
674
|
"docs": {
|
|
562
675
|
"tags": [],
|
|
563
676
|
"text": "Set custom message for `tooShort` property of a ValidityState object (set by `minlength`) within Constrain Validation API"
|
|
564
677
|
},
|
|
565
678
|
"getter": false,
|
|
566
679
|
"setter": false,
|
|
567
|
-
"reflect": false
|
|
568
|
-
"defaultValue": "`All ${this.length} characters must be filled.`"
|
|
680
|
+
"reflect": false
|
|
569
681
|
},
|
|
570
682
|
"customErrorMessage": {
|
|
571
683
|
"type": "string",
|
|
@@ -662,6 +774,87 @@ export class InputCode {
|
|
|
662
774
|
"setter": false,
|
|
663
775
|
"reflect": true,
|
|
664
776
|
"defaultValue": "''"
|
|
777
|
+
},
|
|
778
|
+
"inputmode": {
|
|
779
|
+
"type": "string",
|
|
780
|
+
"attribute": "inputmode",
|
|
781
|
+
"mutable": false,
|
|
782
|
+
"complexType": {
|
|
783
|
+
"original": "InputMode",
|
|
784
|
+
"resolved": "\"decimal\" | \"email\" | \"none\" | \"numeric\" | \"search\" | \"tel\" | \"text\" | \"url\"",
|
|
785
|
+
"references": {
|
|
786
|
+
"InputMode": {
|
|
787
|
+
"location": "import",
|
|
788
|
+
"path": "./exports",
|
|
789
|
+
"id": "src/components/input-code/exports.ts::InputMode"
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
"required": false,
|
|
794
|
+
"optional": true,
|
|
795
|
+
"docs": {
|
|
796
|
+
"tags": [{
|
|
797
|
+
"name": "default",
|
|
798
|
+
"text": ": 'numeric'"
|
|
799
|
+
}],
|
|
800
|
+
"text": "Specifies the input mode for the virtual keyboard on mobile devices. Default is 'numeric' for OTP codes."
|
|
801
|
+
},
|
|
802
|
+
"getter": false,
|
|
803
|
+
"setter": false,
|
|
804
|
+
"reflect": false,
|
|
805
|
+
"defaultValue": "'numeric'"
|
|
806
|
+
},
|
|
807
|
+
"enterkeyhint": {
|
|
808
|
+
"type": "string",
|
|
809
|
+
"attribute": "enterkeyhint",
|
|
810
|
+
"mutable": false,
|
|
811
|
+
"complexType": {
|
|
812
|
+
"original": "EnterKeyHint",
|
|
813
|
+
"resolved": "\"done\" | \"enter\" | \"go\" | \"next\" | \"previous\" | \"search\" | \"send\"",
|
|
814
|
+
"references": {
|
|
815
|
+
"EnterKeyHint": {
|
|
816
|
+
"location": "import",
|
|
817
|
+
"path": "./exports",
|
|
818
|
+
"id": "src/components/input-code/exports.ts::EnterKeyHint"
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
"required": false,
|
|
823
|
+
"optional": true,
|
|
824
|
+
"docs": {
|
|
825
|
+
"tags": [{
|
|
826
|
+
"name": "default",
|
|
827
|
+
"text": ": 'done'"
|
|
828
|
+
}],
|
|
829
|
+
"text": "Specifies the enter key hint for the virtual keyboard. Default is 'done' for OTP completion."
|
|
830
|
+
},
|
|
831
|
+
"getter": false,
|
|
832
|
+
"setter": false,
|
|
833
|
+
"reflect": false,
|
|
834
|
+
"defaultValue": "'done'"
|
|
835
|
+
},
|
|
836
|
+
"autocomplete": {
|
|
837
|
+
"type": "string",
|
|
838
|
+
"attribute": "autocomplete",
|
|
839
|
+
"mutable": false,
|
|
840
|
+
"complexType": {
|
|
841
|
+
"original": "string",
|
|
842
|
+
"resolved": "string",
|
|
843
|
+
"references": {}
|
|
844
|
+
},
|
|
845
|
+
"required": false,
|
|
846
|
+
"optional": true,
|
|
847
|
+
"docs": {
|
|
848
|
+
"tags": [{
|
|
849
|
+
"name": "default",
|
|
850
|
+
"text": ": 'one-time-code'"
|
|
851
|
+
}],
|
|
852
|
+
"text": "Specifies the autocomplete behavior. Default is 'one-time-code' for SMS OTP autofill."
|
|
853
|
+
},
|
|
854
|
+
"getter": false,
|
|
855
|
+
"setter": false,
|
|
856
|
+
"reflect": false,
|
|
857
|
+
"defaultValue": "'one-time-code'"
|
|
665
858
|
}
|
|
666
859
|
};
|
|
667
860
|
}
|
|
@@ -769,10 +962,10 @@ export class InputCode {
|
|
|
769
962
|
},
|
|
770
963
|
"setValue": {
|
|
771
964
|
"complexType": {
|
|
772
|
-
"signature": "(value:
|
|
965
|
+
"signature": "(value: string | null) => Promise<void>",
|
|
773
966
|
"parameters": [{
|
|
774
967
|
"name": "value",
|
|
775
|
-
"type": "
|
|
968
|
+
"type": "string",
|
|
776
969
|
"docs": ""
|
|
777
970
|
}],
|
|
778
971
|
"references": {
|
|
@@ -787,6 +980,111 @@ export class InputCode {
|
|
|
787
980
|
"text": "Sets provided value.",
|
|
788
981
|
"tags": []
|
|
789
982
|
}
|
|
983
|
+
},
|
|
984
|
+
"checkValidity": {
|
|
985
|
+
"complexType": {
|
|
986
|
+
"signature": "() => Promise<boolean>",
|
|
987
|
+
"parameters": [],
|
|
988
|
+
"references": {
|
|
989
|
+
"Promise": {
|
|
990
|
+
"location": "global",
|
|
991
|
+
"id": "global::Promise"
|
|
992
|
+
}
|
|
993
|
+
},
|
|
994
|
+
"return": "Promise<boolean>"
|
|
995
|
+
},
|
|
996
|
+
"docs": {
|
|
997
|
+
"text": "Validates the input code without triggering UI and returns a boolean indicating its validity.",
|
|
998
|
+
"tags": [{
|
|
999
|
+
"name": "returns",
|
|
1000
|
+
"text": "A boolean indicating whether the input code is valid."
|
|
1001
|
+
}]
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
"focusSegment": {
|
|
1005
|
+
"complexType": {
|
|
1006
|
+
"signature": "(index: number) => Promise<void>",
|
|
1007
|
+
"parameters": [{
|
|
1008
|
+
"name": "index",
|
|
1009
|
+
"type": "number",
|
|
1010
|
+
"docs": "- The zero-based index of the segment to focus (0 to length-1)"
|
|
1011
|
+
}],
|
|
1012
|
+
"references": {
|
|
1013
|
+
"Promise": {
|
|
1014
|
+
"location": "global",
|
|
1015
|
+
"id": "global::Promise"
|
|
1016
|
+
}
|
|
1017
|
+
},
|
|
1018
|
+
"return": "Promise<void>"
|
|
1019
|
+
},
|
|
1020
|
+
"docs": {
|
|
1021
|
+
"text": "Focuses a specific segment (input) by index.",
|
|
1022
|
+
"tags": [{
|
|
1023
|
+
"name": "param",
|
|
1024
|
+
"text": "index - The zero-based index of the segment to focus (0 to length-1)"
|
|
1025
|
+
}, {
|
|
1026
|
+
"name": "returns",
|
|
1027
|
+
"text": "Promise that resolves when focus is set, or rejects if index is invalid"
|
|
1028
|
+
}]
|
|
1029
|
+
}
|
|
1030
|
+
},
|
|
1031
|
+
"getSegmentValue": {
|
|
1032
|
+
"complexType": {
|
|
1033
|
+
"signature": "(index: number) => Promise<string>",
|
|
1034
|
+
"parameters": [{
|
|
1035
|
+
"name": "index",
|
|
1036
|
+
"type": "number",
|
|
1037
|
+
"docs": "- The zero-based index of the segment (0 to length-1)"
|
|
1038
|
+
}],
|
|
1039
|
+
"references": {
|
|
1040
|
+
"Promise": {
|
|
1041
|
+
"location": "global",
|
|
1042
|
+
"id": "global::Promise"
|
|
1043
|
+
}
|
|
1044
|
+
},
|
|
1045
|
+
"return": "Promise<string>"
|
|
1046
|
+
},
|
|
1047
|
+
"docs": {
|
|
1048
|
+
"text": "Gets the value of a specific segment by index.",
|
|
1049
|
+
"tags": [{
|
|
1050
|
+
"name": "param",
|
|
1051
|
+
"text": "index - The zero-based index of the segment (0 to length-1)"
|
|
1052
|
+
}, {
|
|
1053
|
+
"name": "returns",
|
|
1054
|
+
"text": "Promise that resolves to the segment value (single character string or empty string)"
|
|
1055
|
+
}]
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
"setSegmentValue": {
|
|
1059
|
+
"complexType": {
|
|
1060
|
+
"signature": "(index: number, value: string) => Promise<void>",
|
|
1061
|
+
"parameters": [{
|
|
1062
|
+
"name": "index",
|
|
1063
|
+
"type": "number",
|
|
1064
|
+
"docs": "- The zero-based index of the segment (0 to length-1)"
|
|
1065
|
+
}, {
|
|
1066
|
+
"name": "value",
|
|
1067
|
+
"type": "string",
|
|
1068
|
+
"docs": "- The value to set (will be truncated to first character if longer)"
|
|
1069
|
+
}],
|
|
1070
|
+
"references": {
|
|
1071
|
+
"Promise": {
|
|
1072
|
+
"location": "global",
|
|
1073
|
+
"id": "global::Promise"
|
|
1074
|
+
}
|
|
1075
|
+
},
|
|
1076
|
+
"return": "Promise<void>"
|
|
1077
|
+
},
|
|
1078
|
+
"docs": {
|
|
1079
|
+
"text": "Sets the value of a specific segment by index.",
|
|
1080
|
+
"tags": [{
|
|
1081
|
+
"name": "param",
|
|
1082
|
+
"text": "index - The zero-based index of the segment (0 to length-1)"
|
|
1083
|
+
}, {
|
|
1084
|
+
"name": "param",
|
|
1085
|
+
"text": "value - The value to set (will be truncated to first character if longer)"
|
|
1086
|
+
}]
|
|
1087
|
+
}
|
|
790
1088
|
}
|
|
791
1089
|
};
|
|
792
1090
|
}
|
|
@@ -795,6 +1093,9 @@ export class InputCode {
|
|
|
795
1093
|
return [{
|
|
796
1094
|
"propName": "values",
|
|
797
1095
|
"methodName": "handleValuesChange"
|
|
1096
|
+
}, {
|
|
1097
|
+
"propName": "length",
|
|
1098
|
+
"methodName": "handleLengthChange"
|
|
798
1099
|
}];
|
|
799
1100
|
}
|
|
800
1101
|
}
|