pwa-auth 2.0.8 → 3.0.2

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.
Files changed (188) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +37 -18
  3. package/demonstration/compiled/pwa-auth.js +880 -0
  4. package/{demo → demonstration}/index.html +1 -1
  5. package/package.json +8 -7
  6. package/pwa-auth.js +4 -3
  7. package/{website → src}/THIRD_PARTY_LICENSES.txt +56 -56
  8. package/src/compiled/pwa-auth.js +871 -0
  9. package/src-typescript/css/toggle.ts +9 -0
  10. package/src-typescript/development/junk/firebase-object.ts +49 -0
  11. package/src-typescript/development/junk/notes.md +96 -0
  12. package/src-typescript/development/junk/phone.ts +146 -0
  13. package/src-typescript/development/junk/photo.ts +440 -0
  14. package/src-typescript/development/junk/telephone.ts +282 -0
  15. package/{source/firebase/firebase-login.ts → src-typescript/development/login.ts} +1 -1
  16. package/{source/firebase/firebase.ts → src-typescript/development/object.ts} +1 -1
  17. package/src-typescript/firebase/authentication.ts +11 -0
  18. package/{source/firebase/start.ts → src-typescript/firebase/interface.ts} +35 -64
  19. package/{source/custom-elements → src-typescript/webcomponents}/drawer/drawer.ts +2 -2
  20. package/{source/custom-elements → src-typescript/webcomponents}/drawer/input/forgot.ts +1 -1
  21. package/{source/custom-elements → src-typescript/webcomponents}/drawer/input/login.ts +1 -1
  22. package/{source/custom-elements → src-typescript/webcomponents}/drawer/input/sign-up.ts +2 -1
  23. package/{deploy/custom-elements/icon/css/icon.js → src-typescript/webcomponents/icon/css/icon.ts} +4 -3
  24. package/{source/custom-elements → src-typescript/webcomponents}/icon/icon.ts +2 -21
  25. package/{source/custom-elements → src-typescript/webcomponents}/settings/input/delete.ts +1 -1
  26. package/{source/custom-elements → src-typescript/webcomponents}/settings/input/email.ts +1 -1
  27. package/{source/custom-elements → src-typescript/webcomponents}/settings/input/images.ts +1 -1
  28. package/{source/custom-elements → src-typescript/webcomponents}/settings/input/name.ts +1 -1
  29. package/{source/custom-elements → src-typescript/webcomponents}/settings/input/password.ts +1 -1
  30. package/{source/custom-elements → src-typescript/webcomponents}/settings/input/uploader.ts +1 -1
  31. package/{source/custom-elements → src-typescript/webcomponents}/settings/settings.ts +2 -2
  32. package/deploy/css/default.d.ts +0 -5
  33. package/deploy/css/default.d.ts.map +0 -1
  34. package/deploy/css/default.js +0 -99
  35. package/deploy/css/font.d.ts +0 -2
  36. package/deploy/css/font.d.ts.map +0 -1
  37. package/deploy/css/font.js +0 -16
  38. package/deploy/css/form/button.d.ts +0 -3
  39. package/deploy/css/form/button.d.ts.map +0 -1
  40. package/deploy/css/form/button.js +0 -54
  41. package/deploy/css/form/input.d.ts +0 -3
  42. package/deploy/css/form/input.d.ts.map +0 -1
  43. package/deploy/css/form/input.js +0 -24
  44. package/deploy/css/form/label.d.ts +0 -3
  45. package/deploy/css/form/label.d.ts.map +0 -1
  46. package/deploy/css/form/label.js +0 -22
  47. package/deploy/css/form/list.d.ts +0 -3
  48. package/deploy/css/form/list.d.ts.map +0 -1
  49. package/deploy/css/form/list.js +0 -22
  50. package/deploy/css/svg.d.ts +0 -4
  51. package/deploy/css/svg.d.ts.map +0 -1
  52. package/deploy/css/svg.js +0 -4
  53. package/deploy/css/toggle.d.ts +0 -2
  54. package/deploy/css/toggle.d.ts.map +0 -1
  55. package/deploy/css/toggle.js +0 -8
  56. package/deploy/custom-elements/drawer/css/drawer.d.ts +0 -3
  57. package/deploy/custom-elements/drawer/css/drawer.d.ts.map +0 -1
  58. package/deploy/custom-elements/drawer/css/drawer.js +0 -55
  59. package/deploy/custom-elements/drawer/css/exit.d.ts +0 -3
  60. package/deploy/custom-elements/drawer/css/exit.d.ts.map +0 -1
  61. package/deploy/custom-elements/drawer/css/exit.js +0 -48
  62. package/deploy/custom-elements/drawer/css/link.d.ts +0 -3
  63. package/deploy/custom-elements/drawer/css/link.d.ts.map +0 -1
  64. package/deploy/custom-elements/drawer/css/link.js +0 -12
  65. package/deploy/custom-elements/drawer/css/paragraph.d.ts +0 -3
  66. package/deploy/custom-elements/drawer/css/paragraph.d.ts.map +0 -1
  67. package/deploy/custom-elements/drawer/css/paragraph.js +0 -10
  68. package/deploy/custom-elements/drawer/css/toggle.d.ts +0 -3
  69. package/deploy/custom-elements/drawer/css/toggle.d.ts.map +0 -1
  70. package/deploy/custom-elements/drawer/css/toggle.js +0 -18
  71. package/deploy/custom-elements/drawer/drawer.d.ts +0 -37
  72. package/deploy/custom-elements/drawer/drawer.d.ts.map +0 -1
  73. package/deploy/custom-elements/drawer/drawer.js +0 -128
  74. package/deploy/custom-elements/drawer/input/forgot.d.ts +0 -16
  75. package/deploy/custom-elements/drawer/input/forgot.d.ts.map +0 -1
  76. package/deploy/custom-elements/drawer/input/forgot.js +0 -60
  77. package/deploy/custom-elements/drawer/input/login.d.ts +0 -20
  78. package/deploy/custom-elements/drawer/input/login.d.ts.map +0 -1
  79. package/deploy/custom-elements/drawer/input/login.js +0 -128
  80. package/deploy/custom-elements/drawer/input/sign-up.d.ts +0 -20
  81. package/deploy/custom-elements/drawer/input/sign-up.d.ts.map +0 -1
  82. package/deploy/custom-elements/drawer/input/sign-up.js +0 -137
  83. package/deploy/custom-elements/icon/css/icon.d.ts +0 -2
  84. package/deploy/custom-elements/icon/css/icon.d.ts.map +0 -1
  85. package/deploy/custom-elements/icon/icon.d.ts +0 -33
  86. package/deploy/custom-elements/icon/icon.d.ts.map +0 -1
  87. package/deploy/custom-elements/icon/icon.js +0 -72
  88. package/deploy/custom-elements/settings/css/navigation.d.ts +0 -2
  89. package/deploy/custom-elements/settings/css/navigation.d.ts.map +0 -1
  90. package/deploy/custom-elements/settings/css/navigation.js +0 -51
  91. package/deploy/custom-elements/settings/input/delete.d.ts +0 -34
  92. package/deploy/custom-elements/settings/input/delete.d.ts.map +0 -1
  93. package/deploy/custom-elements/settings/input/delete.js +0 -87
  94. package/deploy/custom-elements/settings/input/email.d.ts +0 -34
  95. package/deploy/custom-elements/settings/input/email.d.ts.map +0 -1
  96. package/deploy/custom-elements/settings/input/email.js +0 -98
  97. package/deploy/custom-elements/settings/input/images.d.ts +0 -2
  98. package/deploy/custom-elements/settings/input/images.d.ts.map +0 -1
  99. package/deploy/custom-elements/settings/input/images.js +0 -22
  100. package/deploy/custom-elements/settings/input/name.d.ts +0 -33
  101. package/deploy/custom-elements/settings/input/name.d.ts.map +0 -1
  102. package/deploy/custom-elements/settings/input/name.js +0 -90
  103. package/deploy/custom-elements/settings/input/password.d.ts +0 -36
  104. package/deploy/custom-elements/settings/input/password.d.ts.map +0 -1
  105. package/deploy/custom-elements/settings/input/password.js +0 -145
  106. package/deploy/custom-elements/settings/input/uploader.d.ts +0 -37
  107. package/deploy/custom-elements/settings/input/uploader.d.ts.map +0 -1
  108. package/deploy/custom-elements/settings/input/uploader.js +0 -225
  109. package/deploy/custom-elements/settings/settings.d.ts +0 -37
  110. package/deploy/custom-elements/settings/settings.d.ts.map +0 -1
  111. package/deploy/custom-elements/settings/settings.js +0 -197
  112. package/deploy/firebase/firebase-login.d.ts +0 -21
  113. package/deploy/firebase/firebase-login.d.ts.map +0 -1
  114. package/deploy/firebase/firebase-login.js +0 -85
  115. package/deploy/firebase/firebase.d.ts +0 -20
  116. package/deploy/firebase/firebase.d.ts.map +0 -1
  117. package/deploy/firebase/firebase.js +0 -76
  118. package/deploy/firebase/start.d.ts +0 -14
  119. package/deploy/firebase/start.d.ts.map +0 -1
  120. package/deploy/firebase/start.js +0 -86
  121. package/deploy/lazy-loader.d.ts +0 -11
  122. package/deploy/lazy-loader.d.ts.map +0 -1
  123. package/deploy/lazy-loader.js +0 -20
  124. package/deploy/redux/backend.d.ts +0 -16
  125. package/deploy/redux/backend.d.ts.map +0 -1
  126. package/deploy/redux/backend.js +0 -43
  127. package/deploy/redux/drawer.d.ts +0 -18
  128. package/deploy/redux/drawer.d.ts.map +0 -1
  129. package/deploy/redux/drawer.js +0 -21
  130. package/deploy/redux/frontend.d.ts +0 -17
  131. package/deploy/redux/frontend.d.ts.map +0 -1
  132. package/deploy/redux/frontend.js +0 -67
  133. package/deploy/redux/object.d.ts +0 -24
  134. package/deploy/redux/object.d.ts.map +0 -1
  135. package/deploy/redux/object.js +0 -1
  136. package/deploy/store.d.ts +0 -19
  137. package/deploy/store.d.ts.map +0 -1
  138. package/deploy/store.js +0 -13
  139. package/npm/THIRD_PARTY_LICENSES.txt +0 -303
  140. package/npm/pwa-auth.js +0 -306
  141. package/source/css/toggle.ts +0 -9
  142. package/source/custom-elements/icon/css/icon.ts +0 -70
  143. package/website/404.html +0 -33
  144. package/website/css/pwa-styles.css +0 -36
  145. package/website/css/styles.css +0 -48
  146. package/website/images/empty.jpg +0 -0
  147. package/website/images/favicon.ico +0 -0
  148. package/website/images/manifest/logo-144.png +0 -0
  149. package/website/images/manifest/logo-192.png +0 -0
  150. package/website/images/manifest/logo-48.png +0 -0
  151. package/website/images/manifest/logo-512.png +0 -0
  152. package/website/images/manifest/logo-72.png +0 -0
  153. package/website/images/manifest/logo-96.png +0 -0
  154. package/website/images/manifest/maskable_icon_x128.png +0 -0
  155. package/website/images/manifest/maskable_icon_x192.png +0 -0
  156. package/website/images/manifest/maskable_icon_x384.png +0 -0
  157. package/website/images/manifest/maskable_icon_x48.png +0 -0
  158. package/website/images/manifest/maskable_icon_x512.png +0 -0
  159. package/website/images/manifest/maskable_icon_x72.png +0 -0
  160. package/website/images/manifest/maskable_icon_x96.png +0 -0
  161. package/website/index.html +0 -69
  162. package/website/js/images/empty.jpg +0 -0
  163. package/website/js/pwa-auth.js +0 -306
  164. package/website/sitemap.xml +0 -11
  165. /package/{demo → demonstration}/css/pwa-styles.css +0 -0
  166. /package/{demo → demonstration}/css/styles.css +0 -0
  167. /package/{demo → demonstration}/images/empty.jpg +0 -0
  168. /package/{npm → src}/empty.jpg +0 -0
  169. /package/{npm → src}/pwa-styles.css +0 -0
  170. /package/{source → src-typescript}/css/default.ts +0 -0
  171. /package/{source → src-typescript}/css/font.ts +0 -0
  172. /package/{source → src-typescript}/css/form/button.ts +0 -0
  173. /package/{source → src-typescript}/css/form/input.ts +0 -0
  174. /package/{source → src-typescript}/css/form/label.ts +0 -0
  175. /package/{source → src-typescript}/css/form/list.ts +0 -0
  176. /package/{source → src-typescript}/css/svg.ts +0 -0
  177. /package/{source → src-typescript}/lazy-loader.ts +0 -0
  178. /package/{source → src-typescript}/redux/backend.ts +0 -0
  179. /package/{source → src-typescript}/redux/drawer.ts +0 -0
  180. /package/{source → src-typescript}/redux/frontend.ts +0 -0
  181. /package/{source → src-typescript}/redux/object.ts +0 -0
  182. /package/{source → src-typescript}/store.ts +0 -0
  183. /package/{source/custom-elements → src-typescript/webcomponents}/drawer/css/drawer.ts +0 -0
  184. /package/{source/custom-elements → src-typescript/webcomponents}/drawer/css/exit.ts +0 -0
  185. /package/{source/custom-elements → src-typescript/webcomponents}/drawer/css/link.ts +0 -0
  186. /package/{source/custom-elements → src-typescript/webcomponents}/drawer/css/paragraph.ts +0 -0
  187. /package/{source/custom-elements → src-typescript/webcomponents}/drawer/css/toggle.ts +0 -0
  188. /package/{source/custom-elements → src-typescript/webcomponents}/settings/css/navigation.ts +0 -0
@@ -0,0 +1,9 @@
1
+ import { css } from "lit";
2
+
3
+ export const show = css`
4
+
5
+ /* Detailed Project Feature Service */
6
+ .spec[on] { display: grid; }
7
+ .spec { display: none; }
8
+
9
+ `;
@@ -0,0 +1,49 @@
1
+ /*
2
+
3
+ // Sign in-out
4
+ isSignInWithEmailLink(auth, emailLink) // Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink().
5
+ sendSignInLinkToEmail(auth, email, actionCodeSettings) // Sends a sign-in email link to the user with the specified email.
6
+ setPersistence(auth, persistence) // Changes the type of persistence on the Auth instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests.
7
+ signInAnonymously(auth) Asynchronously // signs in as an anonymous user.
8
+ signInWithCredential(auth, credential) // Asynchronously signs in with the given credentials.
9
+ signInWithCustomToken(auth, customToken) // Asynchronously signs in using a custom token.
10
+ signInWithEmailAndPassword(auth, email, password) // Asynchronously signs in using an email and password.
11
+ signInWithEmailLink(auth, email, emailLink) // Asynchronously signs in using an email and sign-in email link.
12
+ signInWithPhoneNumber(auth, phoneNumber, appVerifier) // Asynchronously signs in using a phone number.
13
+ signInWithPopup(auth, provider, resolver) // Authenticates a Firebase client using a popup-based OAuth authentication flow.
14
+ signInWithRedirect(auth, provider, resolver) // Authenticates a Firebase client using a full-page redirect flow.
15
+ signOut(auth) // Signs out the current user.
16
+
17
+ // Verify
18
+ updateCurrentUser(auth, user) // Asynchronously sets the provided user as Auth.currentUser on the Auth instance.
19
+ useDeviceLanguage(auth) // Sets the current language to the default device/browser preference.
20
+ validatePassword(auth, password) // Validates the password against the password policy configured for the project or tenant.
21
+ verifyPasswordResetCode(auth, code) // Checks a password reset code sent to the user by email or other out-of-band mechanism.
22
+
23
+ */
24
+
25
+
26
+
27
+ interface base3 {
28
+ }
29
+
30
+ interface base2 {
31
+ // isSignInWithEmailLink : any,
32
+ sendSignInLinkToEmail : any,
33
+ setPersistence : any,
34
+ signInAnonymously : any,
35
+ signInWithCredential : any,
36
+ signInWithCustomToken : any,
37
+ signInWithEmailAndPassword : any,
38
+ signInWithEmailLink : any,
39
+ signInWithPhoneNumber : any,
40
+ signInWithPopup : any,
41
+ signInWithRedirect : any,
42
+ signOut : any,
43
+ updateCurrentUser : any,
44
+ useDeviceLanguage : any,
45
+ validatePassword : any,
46
+ verifyPasswordResetCode : any,
47
+ handleRecoverEmail:any,
48
+ sendEmailVerification: any
49
+ }
@@ -0,0 +1,96 @@
1
+
2
+ ## firebase-messaging-sw.js Setup
3
+ ```javascript
4
+ // Initialize Firebase
5
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js");
6
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-auth.js");
7
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-storage.js");
8
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-firestore.js");
9
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js");
10
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-messaging.js");
11
+
12
+ let connect = {
13
+ apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
14
+ authDomain: "xxxxxxx.xxxxxxx.xxx",
15
+ databaseURL: "https://xxxxxxx.xxxxxxx.xxx",
16
+ projectId: "xxxxxxx",
17
+ storageBucket: "xxxxxxx.xxxxxxx.xxx",
18
+ messagingSenderId: "xxxxxxxxxxx",
19
+ appId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
20
+ measurementId: "xxxxxxxxxxx"
21
+ };
22
+
23
+ // REFERENCE TO SERVICES
24
+ firebase.initializeApp(admin);
25
+
26
+ // REFERENCE TO SERVICES
27
+ firebase.initializeApp(admin);
28
+ // firebase.messaging();
29
+ // const messaging = getMessaging(admin);
30
+
31
+ // Add the public key generated from the console.
32
+ firebase.messaging().usePublicVapidKey("xxxxxxxxx");
33
+ ```
34
+
35
+ ```javascript
36
+ // CORS
37
+ [
38
+ {
39
+ "origin": ["https://inmostfire.firestoreapp.com", "http://localhost:8000"],
40
+ "method": ["GET", "PUT", "POST", "DELETE"],
41
+ "responseHeader": [
42
+ "Content-Type",
43
+ "Authorization",
44
+ "x-goog-meta-*",
45
+ "x-goog-acl",
46
+ "x-goog-date",
47
+ "x-goog-content-sha256",
48
+ "x-goog-class"
49
+ ],
50
+ "maxAgeSeconds": 3600
51
+ }
52
+ ]
53
+ ```
54
+
55
+ ```javascript
56
+
57
+ // firebase-messaging-sw.js
58
+
59
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js");
60
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-auth.js");
61
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-storage.js");
62
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-firestore.js");
63
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js");
64
+ importScripts("https://www.gstatic.com/firebasejs/9.6.0/firebase-messaging.js");
65
+
66
+ // Dynamically import Firebase from CDN
67
+ // const firebaseApp = await import('https://www.gstatic.com/firebasejs/10.14.1/firebase-app.js');
68
+ // const firebaseAuth = await import('https://www.gstatic.com/firebasejs/10.14.1/firebase-auth.js');
69
+
70
+ const admin = {
71
+ apiKey: "AIzaSyC1ZNYC9RAjSAE3syUBNi47AiqbAqkx99w",
72
+ authDomain: "pwa-authentic.firebaseapp.com",
73
+ projectId: "pwa-authentic",
74
+ storageBucket: "pwa-authentic.firebasestorage.app",
75
+ messagingSenderId: "749233996232",
76
+ appId: "1:749233996232:web:bbc410d53b7d39bdfb80fd",
77
+ measurementId: "G-G1GYM1HBJ4"
78
+ } ;
79
+
80
+ // const messaging = getMessaging(admin);
81
+
82
+ // REFERENCE TO SERVICES
83
+ firebase.initializeApp(admin);
84
+ // firebase.messaging();
85
+
86
+ // Add the public key generated from the console.
87
+ // firebase.messaging().usePublicVapidKey("BAz2eUmJrgElexalB5GmQOXLxZ7yJC2Jp69fsUfnYM73hfGIhWkRxPi5PgRXr5oEWJ0yvJlQ7GVFGYP3AiIigl4");
88
+
89
+ // export const messaging = () => [] firebase.messaging();
90
+
91
+
92
+
93
+
94
+
95
+
96
+ ```
@@ -0,0 +1,146 @@
1
+ /*
2
+ import { LitElement, html, CSSResultArray, css } from 'lit';
3
+ import { property, state } from 'lit/decorators.js';
4
+ import { inputStyles, labelStyles } from '../src/custom-elements/change/css/styles';
5
+ import { connect } from 'pwa-helpers';
6
+ import { store, AppState } from '../store';
7
+
8
+ export class PhoneFormat extends connect(store)(LitElement) {
9
+
10
+ /** @attr value *
11
+ @property({ type: String }) public value: string = '';
12
+ @state() private phone: string = '';
13
+
14
+ constructor() { super(); }
15
+
16
+ stateChanged(state: AppState) {
17
+ this.phone = state.backend!.phone ;
18
+ }
19
+
20
+ connectedCallback() {
21
+ super.connectedCallback();
22
+ this.addFormResetListener();
23
+ }
24
+
25
+ static get styles() : CSSResultArray { return [ inputStyles, labelStyles,
26
+ css`
27
+
28
+ :host {
29
+ display: grid;
30
+ }
31
+
32
+ `
33
+ ]};
34
+
35
+ render() {
36
+ return html`
37
+ <label>Telephone:
38
+ <input
39
+ name="telephone"
40
+ type="text"
41
+ value="${this.value}"
42
+ @input="${this.onInput}"
43
+ @keydown="${this.onKeyDown}"
44
+ placeholder="${this.formatPhoneNumber(this.phone) || '(XXX) XXX-XXXX'}"
45
+ inputmode="numeric"
46
+ pattern="[0-9]*"
47
+ data-label="Phone Number"
48
+ />
49
+ </label>
50
+ `;
51
+ }
52
+
53
+ private onKeyDown(event: KeyboardEvent) {
54
+
55
+ // Allow backspace, delete, tab, escape, enter, and arrow keys
56
+ const allowedKeys = ['Backspace', 'Delete', 'Tab', 'Escape', 'Enter', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
57
+
58
+ if (allowedKeys.includes(event.key) || (event.key >= '0' && event.key <= '9') || (event.key >= 'Numpad0' && event.key <= 'Numpad9')) {
59
+ // Allow normal operation
60
+ } else {
61
+ // Prevent the default action (e.g., character input)
62
+ event.preventDefault();
63
+ }
64
+
65
+ }
66
+
67
+ private onInput(event: Event) {
68
+
69
+ const inputElement = event.target as HTMLInputElement;
70
+ const unformattedValue = this.unformatPhoneNumber(inputElement.value);
71
+
72
+ // Check the length of the unformatted phone number
73
+ if (unformattedValue.length <= 10) {
74
+ this.value = unformattedValue;
75
+ } else {
76
+ // If the length exceeds 10, reset the input value to the previously stored value
77
+ inputElement.value = this.formatPhoneNumber(this.value);
78
+ }
79
+ }
80
+
81
+ private formatPhoneNumber(phoneNumber: string): string {
82
+ const cleaned = ('' + phoneNumber).replace(/\D/g, '');
83
+ let formatted = '';
84
+
85
+ if (cleaned.length > 0) {
86
+ formatted = `(${cleaned.slice(0, 3)}`;
87
+ }
88
+ if (cleaned.length >= 3) {
89
+ formatted += `) ${cleaned.slice(3, 6)}`;
90
+ }
91
+ if (cleaned.length > 6) {
92
+ formatted += `-${cleaned.slice(6, 10)}`;
93
+ }
94
+
95
+ return formatted;
96
+ }
97
+
98
+ private unformatPhoneNumber(formattedPhoneNumber: string): string {
99
+ return formattedPhoneNumber.replace(/\D/g, '');
100
+ }
101
+
102
+ private addFormResetListener() {
103
+ const form = this.closest('form');
104
+ if (form) {
105
+ form.addEventListener('reset', () => this.resetInput());
106
+ }
107
+ }
108
+
109
+ private resetInput() {
110
+ this.value = '';
111
+ }
112
+
113
+ }
114
+
115
+
116
+
117
+ customElements.define('phone-format', PhoneFormat);
118
+
119
+ // Declare the global tag name
120
+ declare global {
121
+ interface HTMLElementTagNameMap {
122
+ 'phone-format': PhoneFormat;
123
+ }
124
+ }
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ /*
133
+ private formatPhoneNumber(phoneNumber: string): string {
134
+ const cleaned = ('' + phoneNumber).replace(/\D/g, '');
135
+ const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
136
+ if (match) {
137
+ return `${match[1]}-${match[2]}-${match[3]}`;
138
+ }
139
+ return phoneNumber;
140
+ }
141
+
142
+ private unformatPhoneNumber(formattedPhoneNumber: string): string {
143
+ return formattedPhoneNumber.replace(/\D/g, '');
144
+ }
145
+ }
146
+ */