pwa-auth 3.0.5 → 3.1.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 (127) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +53 -42
  3. package/demonstration/compiled/pwa-auth.js +34 -34
  4. package/demonstration/compiled/pwa-auth.js.map +1 -1
  5. package/demonstration/compiled/pwa-helpers-BN4uXXdl.js +8 -0
  6. package/demonstration/compiled/pwa-helpers-BN4uXXdl.js.map +1 -0
  7. package/demonstration/compiled/pwa-helpers.js +8 -0
  8. package/demonstration/compiled/pwa-helpers.js.map +1 -0
  9. package/package.json +16 -3
  10. package/src/compiled/pwa-auth.js +34 -34
  11. package/src/compiled/pwa-auth.js.map +1 -1
  12. package/src/compiled/pwa-helpers-BN4uXXdl.js +8 -0
  13. package/src/compiled/pwa-helpers-BN4uXXdl.js.map +1 -0
  14. package/src/compiled/pwa-helpers.js +8 -0
  15. package/src/compiled/pwa-helpers.js.map +1 -0
  16. package/src/pwa-auth.js +0 -1
  17. package/src/pwa-helpers.js +1 -0
  18. package/src-classes/pwa-auth.js +3 -0
  19. package/src-compiled/pwa-auth.js +881 -0
  20. package/src-compiled/pwa-auth.js.map +1 -0
  21. package/src-compiled/pwa-helpers-BN4uXXdl.js +8 -0
  22. package/src-compiled/pwa-helpers-BN4uXXdl.js.map +1 -0
  23. package/src-compiled/pwa-helpers.js +8 -0
  24. package/src-compiled/pwa-helpers.js.map +1 -0
  25. package/src-export/pwa-auth.ts +3 -0
  26. package/src-export/pwa-helpers.ts +1 -0
  27. package/src-export/tsconfig.production.json +53 -0
  28. package/src-functions/pwa-helpers.js +1 -0
  29. package/src-typescript/development/helpers-array.ts +0 -0
  30. package/transpiled/src-export/pwa-auth.d.ts +4 -0
  31. package/transpiled/src-export/pwa-auth.d.ts.map +1 -0
  32. package/transpiled/src-export/pwa-auth.js +3 -0
  33. package/transpiled/src-export/pwa-helpers.d.ts +2 -0
  34. package/transpiled/src-export/pwa-helpers.d.ts.map +1 -0
  35. package/transpiled/src-export/pwa-helpers.js +1 -0
  36. package/transpiled/src-typescript/css/form/button.d.ts +3 -0
  37. package/transpiled/src-typescript/css/form/button.d.ts.map +1 -0
  38. package/transpiled/src-typescript/css/form/button.js +54 -0
  39. package/transpiled/src-typescript/css/form/input.d.ts +3 -0
  40. package/transpiled/src-typescript/css/form/input.d.ts.map +1 -0
  41. package/transpiled/src-typescript/css/form/input.js +24 -0
  42. package/transpiled/src-typescript/css/form/label.d.ts +3 -0
  43. package/transpiled/src-typescript/css/form/label.d.ts.map +1 -0
  44. package/transpiled/src-typescript/css/form/label.js +22 -0
  45. package/transpiled/src-typescript/css/form/list.d.ts +3 -0
  46. package/transpiled/src-typescript/css/form/list.d.ts.map +1 -0
  47. package/transpiled/src-typescript/css/form/list.js +22 -0
  48. package/transpiled/src-typescript/css/svg.d.ts +4 -0
  49. package/transpiled/src-typescript/css/svg.d.ts.map +1 -0
  50. package/transpiled/src-typescript/css/svg.js +4 -0
  51. package/transpiled/src-typescript/css/toggle.d.ts +2 -0
  52. package/transpiled/src-typescript/css/toggle.d.ts.map +1 -0
  53. package/transpiled/src-typescript/css/toggle.js +8 -0
  54. package/transpiled/src-typescript/firebase/authentication.d.ts +11 -0
  55. package/transpiled/src-typescript/firebase/authentication.d.ts.map +1 -0
  56. package/transpiled/src-typescript/firebase/authentication.js +10 -0
  57. package/transpiled/src-typescript/firebase/interface.d.ts +5 -0
  58. package/transpiled/src-typescript/firebase/interface.d.ts.map +1 -0
  59. package/transpiled/src-typescript/firebase/interface.js +79 -0
  60. package/transpiled/src-typescript/redux/backend.d.ts +16 -0
  61. package/transpiled/src-typescript/redux/backend.d.ts.map +1 -0
  62. package/transpiled/src-typescript/redux/backend.js +43 -0
  63. package/transpiled/src-typescript/redux/drawer.d.ts +20 -0
  64. package/transpiled/src-typescript/redux/drawer.d.ts.map +1 -0
  65. package/transpiled/src-typescript/redux/drawer.js +21 -0
  66. package/transpiled/src-typescript/redux/frontend.d.ts +17 -0
  67. package/transpiled/src-typescript/redux/frontend.d.ts.map +1 -0
  68. package/transpiled/src-typescript/redux/frontend.js +67 -0
  69. package/transpiled/src-typescript/redux/object.d.ts +24 -0
  70. package/transpiled/src-typescript/redux/object.d.ts.map +1 -0
  71. package/transpiled/src-typescript/redux/object.js +1 -0
  72. package/transpiled/src-typescript/store.d.ts +19 -0
  73. package/transpiled/src-typescript/store.d.ts.map +1 -0
  74. package/transpiled/src-typescript/store.js +13 -0
  75. package/transpiled/src-typescript/webcomponents/drawer/css/drawer.d.ts +3 -0
  76. package/transpiled/src-typescript/webcomponents/drawer/css/drawer.d.ts.map +1 -0
  77. package/transpiled/src-typescript/webcomponents/drawer/css/drawer.js +55 -0
  78. package/transpiled/src-typescript/webcomponents/drawer/css/exit.d.ts +3 -0
  79. package/transpiled/src-typescript/webcomponents/drawer/css/exit.d.ts.map +1 -0
  80. package/transpiled/src-typescript/webcomponents/drawer/css/exit.js +48 -0
  81. package/transpiled/src-typescript/webcomponents/drawer/css/link.d.ts +3 -0
  82. package/transpiled/src-typescript/webcomponents/drawer/css/link.d.ts.map +1 -0
  83. package/transpiled/src-typescript/webcomponents/drawer/css/link.js +12 -0
  84. package/transpiled/src-typescript/webcomponents/drawer/css/paragraph.d.ts +3 -0
  85. package/transpiled/src-typescript/webcomponents/drawer/css/paragraph.d.ts.map +1 -0
  86. package/transpiled/src-typescript/webcomponents/drawer/css/paragraph.js +10 -0
  87. package/transpiled/src-typescript/webcomponents/drawer/css/toggle.d.ts +3 -0
  88. package/transpiled/src-typescript/webcomponents/drawer/css/toggle.d.ts.map +1 -0
  89. package/transpiled/src-typescript/webcomponents/drawer/css/toggle.js +18 -0
  90. package/transpiled/src-typescript/webcomponents/drawer/drawer.d.ts +37 -0
  91. package/transpiled/src-typescript/webcomponents/drawer/drawer.d.ts.map +1 -0
  92. package/transpiled/src-typescript/webcomponents/drawer/drawer.js +138 -0
  93. package/transpiled/src-typescript/webcomponents/drawer/input/login.d.ts +20 -0
  94. package/transpiled/src-typescript/webcomponents/drawer/input/login.d.ts.map +1 -0
  95. package/transpiled/src-typescript/webcomponents/drawer/input/login.js +134 -0
  96. package/transpiled/src-typescript/webcomponents/drawer/input/sign-up.d.ts +20 -0
  97. package/transpiled/src-typescript/webcomponents/drawer/input/sign-up.d.ts.map +1 -0
  98. package/transpiled/src-typescript/webcomponents/drawer/input/sign-up.js +144 -0
  99. package/transpiled/src-typescript/webcomponents/icon/css/icon.d.ts +2 -0
  100. package/transpiled/src-typescript/webcomponents/icon/css/icon.d.ts.map +1 -0
  101. package/transpiled/src-typescript/webcomponents/icon/css/icon.js +59 -0
  102. package/transpiled/src-typescript/webcomponents/icon/icon.d.ts +33 -0
  103. package/transpiled/src-typescript/webcomponents/icon/icon.d.ts.map +1 -0
  104. package/transpiled/src-typescript/webcomponents/icon/icon.js +81 -0
  105. package/transpiled/src-typescript/webcomponents/settings/css/navigation.d.ts +2 -0
  106. package/transpiled/src-typescript/webcomponents/settings/css/navigation.d.ts.map +1 -0
  107. package/transpiled/src-typescript/webcomponents/settings/css/navigation.js +51 -0
  108. package/transpiled/src-typescript/webcomponents/settings/input/delete.d.ts +34 -0
  109. package/transpiled/src-typescript/webcomponents/settings/input/delete.d.ts.map +1 -0
  110. package/transpiled/src-typescript/webcomponents/settings/input/delete.js +92 -0
  111. package/transpiled/src-typescript/webcomponents/settings/input/email.d.ts +34 -0
  112. package/transpiled/src-typescript/webcomponents/settings/input/email.d.ts.map +1 -0
  113. package/transpiled/src-typescript/webcomponents/settings/input/email.js +104 -0
  114. package/transpiled/src-typescript/webcomponents/settings/input/name.d.ts +33 -0
  115. package/transpiled/src-typescript/webcomponents/settings/input/name.d.ts.map +1 -0
  116. package/transpiled/src-typescript/webcomponents/settings/input/name.js +95 -0
  117. package/transpiled/src-typescript/webcomponents/settings/input/password.d.ts +36 -0
  118. package/transpiled/src-typescript/webcomponents/settings/input/password.d.ts.map +1 -0
  119. package/transpiled/src-typescript/webcomponents/settings/input/password.js +151 -0
  120. package/transpiled/src-typescript/webcomponents/settings/input/uploader.d.ts +37 -0
  121. package/transpiled/src-typescript/webcomponents/settings/input/uploader.d.ts.map +1 -0
  122. package/transpiled/src-typescript/webcomponents/settings/input/uploader.js +235 -0
  123. package/transpiled/src-typescript/webcomponents/settings/settings.d.ts +37 -0
  124. package/transpiled/src-typescript/webcomponents/settings/settings.d.ts.map +1 -0
  125. package/transpiled/src-typescript/webcomponents/settings/settings.js +204 -0
  126. package/pwa-auth.js +0 -4
  127. /package/src-typescript/development/{object.ts → utilities-object.ts} +0 -0
@@ -0,0 +1,33 @@
1
+ import { CSSResultArray, LitElement } from "lit";
2
+ import { AppState } from "../../../store";
3
+ declare const InputName_base: (new (...args: any[]) => {
4
+ _storeUnsubscribe: import("redux").Unsubscribe;
5
+ connectedCallback(): void;
6
+ disconnectedCallback(): void;
7
+ stateChanged(_state: {
8
+ frontend: import("../../../redux/object").frontendAuth;
9
+ drawer: {
10
+ drawer: boolean;
11
+ };
12
+ backend: import("../../../redux/object").backendAuth;
13
+ }): void;
14
+ readonly isConnected: boolean;
15
+ }) & typeof LitElement;
16
+ export declare class InputName extends InputName_base {
17
+ value: string;
18
+ private login;
19
+ constructor();
20
+ stateChanged(state: AppState): void;
21
+ static get styles(): CSSResultArray;
22
+ render(): import("lit-html").TemplateResult<1>;
23
+ private default;
24
+ private handleInput;
25
+ private alertProfile;
26
+ }
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'input-name': InputName;
30
+ }
31
+ }
32
+ export {};
33
+ //# sourceMappingURL=name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../../../../src-typescript/webcomponents/settings/input/name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5D,OAAO,EAAS,QAAQ,EAAE,MAAS,gBAAgB,CAAC;;;;;;;;;;;;;;AAQpD,qBAAa,SAAU,SAAQ,cAA0B;IAGN,KAAK,SAAM;IAEnD,OAAO,CAAC,KAAK,CAAmB;;IAIzC,YAAY,CAAC,KAAK,EAAE,QAAQ;IAK5B,MAAM,KAAK,MAAM,IAAI,cAAc,CAQ3B;IAER,MAAM;IA6BN,OAAO,CAAC,OAAO,CAEd;IAGD,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,YAAY,CAWnB;CAKF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
@@ -0,0 +1,95 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { LitElement, css, html } from "lit";
11
+ import { property, state } from "lit/decorators.js";
12
+ import { connect } from "pwa-helpers";
13
+ import { store } from "../../../store";
14
+ import { updateProfile } from "firebase/auth";
15
+ import { accName } from "../../../redux/backend";
16
+ import { auth } from "../../../firebase/authentication";
17
+ import { labelStyle } from "../../../css/form/label";
18
+ import { inputStyle } from "../../../css/form/input";
19
+ import { buttonStyle } from "../../../css/form/button";
20
+ export class InputName extends connect(store)(LitElement) {
21
+ constructor() {
22
+ super();
23
+ this.value = '';
24
+ this.login = false;
25
+ this.default = (e) => {
26
+ e.preventDefault();
27
+ };
28
+ this.alertProfile = async () => {
29
+ if (auth.currentUser) {
30
+ await updateProfile(auth.currentUser, { displayName: this.value })
31
+ .then(() => { store.dispatch(accName(this.value)); })
32
+ .then(() => { alert('updated name:' + this.value); });
33
+ }
34
+ else {
35
+ alert('Please Login');
36
+ }
37
+ };
38
+ }
39
+ stateChanged(state) {
40
+ this.login = state.frontend.login;
41
+ this.value = state.backend.name;
42
+ }
43
+ static get styles() {
44
+ return [
45
+ labelStyle,
46
+ inputStyle,
47
+ buttonStyle,
48
+ css `
49
+
50
+ :host, form { display: grid; }
51
+
52
+ `
53
+ ];
54
+ }
55
+ render() {
56
+ return html `
57
+
58
+ <form
59
+ @submit="${this.default}">
60
+
61
+ <label
62
+ for="pwa-name"><span>Name:</span></label>
63
+
64
+ <input
65
+ id = "pwa-name"
66
+ name = "username"
67
+ type = "text"
68
+ data-label = "Contact Name"
69
+ @input = "${this.handleInput}"
70
+ .value = "${this.value}" />
71
+
72
+ <!-- Save to Database -->
73
+ <button
74
+ class="action-button save"
75
+ @click="${this.alertProfile}"
76
+ ?disabled="${this.login === false}">Update</button>
77
+
78
+ </form>
79
+
80
+ `;
81
+ }
82
+ handleInput(event) {
83
+ const input = event.target;
84
+ this.value = input.value;
85
+ }
86
+ }
87
+ __decorate([
88
+ property({ type: String, reflect: true }),
89
+ __metadata("design:type", Object)
90
+ ], InputName.prototype, "value", void 0);
91
+ __decorate([
92
+ state(),
93
+ __metadata("design:type", Boolean)
94
+ ], InputName.prototype, "login", void 0);
95
+ customElements.define('input-name', InputName);
@@ -0,0 +1,36 @@
1
+ import { CSSResultArray, LitElement } from "lit";
2
+ import { AppState } from "../../../store";
3
+ declare const InputPassword_base: (new (...args: any[]) => {
4
+ _storeUnsubscribe: import("redux").Unsubscribe;
5
+ connectedCallback(): void;
6
+ disconnectedCallback(): void;
7
+ stateChanged(_state: {
8
+ frontend: import("../../../redux/object").frontendAuth;
9
+ drawer: {
10
+ drawer: boolean;
11
+ };
12
+ backend: import("../../../redux/object").backendAuth;
13
+ }): void;
14
+ readonly isConnected: boolean;
15
+ }) & typeof LitElement;
16
+ export declare class InputPassword extends InputPassword_base {
17
+ private message;
18
+ private password;
19
+ private login;
20
+ constructor();
21
+ protected firstUpdated(): void;
22
+ stateChanged(state: AppState): void;
23
+ private handleInputChange;
24
+ static get styles(): CSSResultArray;
25
+ render(): import("lit-html").TemplateResult<1>;
26
+ private default;
27
+ private alertPassword;
28
+ private updatePass;
29
+ }
30
+ declare global {
31
+ interface HTMLElementTagNameMap {
32
+ 'input-password': InputPassword;
33
+ }
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=password.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../../../src-typescript/webcomponents/settings/input/password.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5D,OAAc,EAAE,QAAQ,EAAE,MAAO,gBAAgB,CAAC;;;;;;;;;;;;;;AAOlD,qBAAa,aAAc,SAAQ,kBAA0B;IAElD,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,KAAK,CAA0B;;IAIhD,SAAS,CAAC,YAAY;IAQrB,YAAY,CAAC,KAAK,EAAE,QAAQ;IAK7B,OAAO,CAAC,iBAAiB;IAKzB,MAAM,KAAK,MAAM,IAAI,cAAc,CAc3B;IAER,MAAM;IAkDN,OAAO,CAAC,OAAO,CAEd;IAGD,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,UAAU,CAWjB;CAEF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
@@ -0,0 +1,151 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { LitElement, css, html } from "lit";
11
+ import { state } from "lit/decorators.js";
12
+ import { connect } from "pwa-helpers";
13
+ import store from "../../../store";
14
+ import { auth } from "../../../firebase/authentication";
15
+ import { labelStyle } from "../../../css/form/label";
16
+ import { inputStyle } from "../../../css/form/input";
17
+ import { buttonStyle } from "../../../css/form/button";
18
+ import { updatePassword } from "firebase/auth";
19
+ export class InputPassword extends connect(store)(LitElement) {
20
+ constructor() {
21
+ super();
22
+ this.message = '';
23
+ this.password = '';
24
+ this.login = false;
25
+ this.default = (e) => {
26
+ e.preventDefault();
27
+ };
28
+ this.updatePass = async (newPassword) => {
29
+ if (auth.currentUser) {
30
+ await updatePassword(auth.currentUser, newPassword)
31
+ .then(() => { console.log("Password successful!"); })
32
+ .catch((error) => { console.log("Problem: " + error.messge); });
33
+ }
34
+ else {
35
+ alert('Please Login');
36
+ }
37
+ };
38
+ }
39
+ firstUpdated() {
40
+ this.shadowRoot.querySelector('.pass').addEventListener('click', () => {
41
+ this.alertPassword();
42
+ });
43
+ }
44
+ stateChanged(state) {
45
+ this.login = state.frontend.login;
46
+ }
47
+ handleInputChange(event) {
48
+ const input = event.target;
49
+ this.password = input.value;
50
+ }
51
+ static get styles() {
52
+ return [
53
+ labelStyle,
54
+ inputStyle,
55
+ buttonStyle,
56
+ css `
57
+
58
+ :host{
59
+ display: grid;
60
+ }
61
+
62
+ form { display: grid; }
63
+
64
+ p.error { color: red; }
65
+
66
+ `
67
+ ];
68
+ }
69
+ render() {
70
+ return html `
71
+
72
+ <form
73
+ autocomplete="off"
74
+ @submit="${this.default}">
75
+
76
+ <!-- Input - 1 -->
77
+ <label for="pwa-new-password">New Password</label>
78
+
79
+ <input
80
+ id = "pwa-new-password"
81
+ name = "new_password"
82
+ type = "password"
83
+ .value = "${this.password}"
84
+ @input = "${this.handleInputChange}"
85
+ aria-describedby = "password-help">
86
+
87
+ <!-- Input - 2 -->
88
+ <label for="pwa-verify-password">Verify Password</label>
89
+
90
+ <input
91
+ id = "pwa-verify-password"
92
+ name = "verify_password"
93
+ type = "password">
94
+
95
+ <!-- Submit -->
96
+ <button
97
+ class="action-button pass"
98
+ ?disabled="${this.login === false}">Update</button>
99
+
100
+ ${this.message ? html `
101
+
102
+ <p
103
+ class=${this.message.includes('Password entered') ? '' : 'error'}
104
+ aria-live="polite">
105
+
106
+ ${this.message}
107
+
108
+ </p>
109
+
110
+ ` : ''}
111
+
112
+ </form>
113
+
114
+ `;
115
+ }
116
+ alertPassword() {
117
+ if (!this.password) {
118
+ this.message = 'Please enter a password';
119
+ }
120
+ else if (this.password.length < 8) {
121
+ this.message = 'Password must be at least 8 characters long';
122
+ }
123
+ else {
124
+ this.message = `Password entered:`;
125
+ if (!/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/.test(this.password)) {
126
+ this.message = 'Password must include letters, numbers, and be 8+ characters';
127
+ }
128
+ else {
129
+ if (auth.currentUser) {
130
+ this.updatePass(this.password);
131
+ }
132
+ else {
133
+ alert('Please Login');
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ __decorate([
140
+ state(),
141
+ __metadata("design:type", String)
142
+ ], InputPassword.prototype, "message", void 0);
143
+ __decorate([
144
+ state(),
145
+ __metadata("design:type", String)
146
+ ], InputPassword.prototype, "password", void 0);
147
+ __decorate([
148
+ state(),
149
+ __metadata("design:type", Boolean)
150
+ ], InputPassword.prototype, "login", void 0);
151
+ customElements.define('input-password', InputPassword);
@@ -0,0 +1,37 @@
1
+ import { LitElement, CSSResultArray } from 'lit';
2
+ import { AppState } from '../../../store';
3
+ declare const ContactPhoto_base: (new (...args: any[]) => {
4
+ _storeUnsubscribe: import("redux").Unsubscribe;
5
+ connectedCallback(): void;
6
+ disconnectedCallback(): void;
7
+ stateChanged(_state: {
8
+ frontend: import("../../../redux/object").frontendAuth;
9
+ drawer: {
10
+ drawer: boolean;
11
+ };
12
+ backend: import("../../../redux/object").backendAuth;
13
+ }): void;
14
+ readonly isConnected: boolean;
15
+ }) & typeof LitElement;
16
+ export declare class ContactPhoto extends ContactPhoto_base {
17
+ photo: string | void | any;
18
+ emptyArtwork: string;
19
+ private user;
20
+ private login;
21
+ private progress;
22
+ private error;
23
+ private status;
24
+ constructor();
25
+ stateChanged(state: AppState): void;
26
+ static get styles(): CSSResultArray;
27
+ protected render(): import("lit-html").TemplateResult<1>;
28
+ private saveImage;
29
+ private dispatchPhoto;
30
+ }
31
+ declare global {
32
+ interface HTMLElementTagNameMap {
33
+ 'contact-photo': ContactPhoto;
34
+ }
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=uploader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../../../src-typescript/webcomponents/settings/input/uploader.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAQ,KAAK,CAAC;AAE9D,OAAO,EAAS,QAAQ,EAAE,MAAe,gBAAgB,CAAC;;;;;;;;;;;;;;AAQ1D,qBAAa,YAAa,SAAQ,iBAA0B;IAGvC,KAAK,EAAG,MAAM,GAAG,IAAI,GAAG,GAAG,CAAM;IAGJ,YAAY,SAAM;IAEzD,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,KAAK,CAAmB;IAIhC,OAAO,CAAC,QAAQ,CAAa;IAE7B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAc;;IAWrC,YAAY,CAAC,KAAK,EAAE,QAAQ;IAU5B,MAAM,KAAK,MAAM,IAAG,cAAc,CAwBjC;IAED,SAAS,CAAC,MAAM;YA8FF,SAAS;IA0IvB,OAAO,CAAC,aAAa,CAYpB;CAEF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC3B,eAAe,EAAE,YAAY,CAAC;KACjC;CACF"}
@@ -0,0 +1,235 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { html, css, LitElement } from 'lit';
11
+ import { property, state } from 'lit/decorators.js';
12
+ import { store } from '../../../store';
13
+ import { connect } from 'pwa-helpers';
14
+ import { auth, storage, user } from '../../../firebase/authentication';
15
+ import { updateProfile } from 'firebase/auth';
16
+ import { accImage } from '../../../redux/backend';
17
+ import { ref, updateMetadata, getDownloadURL, uploadBytesResumable } from "@firebase/storage";
18
+ import { labelStyle } from '../../../css/form/label';
19
+ export class ContactPhoto extends connect(store)(LitElement) {
20
+ constructor() {
21
+ super();
22
+ this.photo = '';
23
+ this.emptyArtwork = '';
24
+ this.user = '';
25
+ this.login = false;
26
+ this.progress = 0;
27
+ this.error = '';
28
+ this.status = '';
29
+ this.dispatchPhoto = async (url) => {
30
+ if (auth.currentUser) {
31
+ await updateProfile(auth.currentUser, { photoURL: url }).catch((error) => { console.log(error); });
32
+ store.dispatch(accImage(url));
33
+ }
34
+ };
35
+ this.progress = 0;
36
+ this.error = '';
37
+ this.status = '';
38
+ }
39
+ stateChanged(state) {
40
+ this.login = state.frontend.login;
41
+ this.user = state.backend.userId;
42
+ this.photo = state.backend.photoURL;
43
+ }
44
+ static get styles() {
45
+ return [
46
+ labelStyle,
47
+ css `
48
+
49
+ :host {
50
+ box-sizing: border-box;
51
+ -webkit-box-sizing: border-box;
52
+ display: grid;
53
+ grid-template-columns: 1fr;
54
+ grid-gap: 4px;
55
+ width: 100%;
56
+ }
57
+
58
+ input[type=file] {
59
+ border-radius: 50%;
60
+ overflow: hidden;
61
+ margin: auto;
62
+ border: 2px solid #303030;
63
+ box-shadow: 1px 1px 2px black, 0 0 25px grey, 0 0 5px #fff;
64
+ }
65
+
66
+ `
67
+ ];
68
+ }
69
+ render() {
70
+ return html `
71
+ <label
72
+ for="pwa-uploader"
73
+ style="
74
+ grid-template-columns: auto 1fr;
75
+ grid-gap:16px;
76
+ padding: 0 16px;
77
+ ">Upload:
78
+ <progress
79
+ id ="pwa-uploader"
80
+ class ="uploader"
81
+ value ="0"
82
+ max ="100"
83
+ style="
84
+ height: 24px;
85
+ width: 100%;
86
+ margin: auto;
87
+ "></label>
88
+
89
+
90
+
91
+ <!-- Input - Upload Image -->
92
+ <input
93
+ id ="photoURL"
94
+ type ="file"
95
+ name ="photoURL"
96
+ class ="contractorPhoto"
97
+ accept ="image/*"
98
+ @change ="${this.saveImage}"
99
+ ?disabled="${this.login === false}"
100
+ style ="
101
+ display: none;
102
+ cursor: pointer;
103
+ position: absolute;
104
+ z-index: -1;
105
+ "/></progress>
106
+
107
+ <label
108
+ style="
109
+ border: 2px dashed;
110
+ border-radius: 6px;
111
+ overflow: hidden;
112
+ margin: 0 16px;
113
+ padding: 0 16px 16px 16px;
114
+ "
115
+ for ="photoURL">Photo:
116
+
117
+ <!-- Output - Retrieved Image -->
118
+ <canvas
119
+ style="
120
+ margin: auto;
121
+ height: 200px;
122
+ width: 100%;
123
+ background-image: url(${this.photo ? this.photo : this.emptyArtwork});
124
+ background-size: contain;
125
+ background-repeat: no-repeat;
126
+ background-position: center;
127
+ cursor: pointer;
128
+ overflow: hidden;
129
+ box-sizing: border-box;
130
+ ">
131
+ </canvas>
132
+
133
+ </label>
134
+
135
+ <p style="text-align:center;">${this.status}${this.error}</p>
136
+ `;
137
+ }
138
+ async saveImage() {
139
+ const uploader = this.shadowRoot.querySelector('.uploader');
140
+ if (auth.currentUser) {
141
+ this.error = '';
142
+ this.status = 'Uploading...';
143
+ const file = this.shadowRoot.querySelector('#photoURL');
144
+ if (!file) {
145
+ console.error('No file selected');
146
+ return;
147
+ }
148
+ const location = ref(storage, "/" +
149
+ "pwa-auth" +
150
+ "/" +
151
+ this.user +
152
+ "/" +
153
+ file.files[0].name);
154
+ const newMetadata = {
155
+ cacheControl: 'public,max-age=300',
156
+ contentType: file.files[0].type
157
+ };
158
+ const uploadTask = uploadBytesResumable(location, file.files[0], newMetadata);
159
+ uploadTask.on('state_changed', (snapshot) => {
160
+ this.progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
161
+ this.status = `Upload is ${Math.round(this.progress)}% done`;
162
+ switch (snapshot.state) {
163
+ case 'paused':
164
+ this.status = 'Upload is paused';
165
+ break;
166
+ case 'running':
167
+ this.status = `Upload is running (${Math.round(this.progress)}%)`;
168
+ break;
169
+ }
170
+ let progress = 0;
171
+ if (snapshot.totalBytes > 0) {
172
+ progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
173
+ }
174
+ if (isFinite(progress)) {
175
+ uploader.value = progress;
176
+ uploader.textContent = `${Math.round(progress)}%`;
177
+ }
178
+ else {
179
+ uploader.value = 0;
180
+ uploader.textContent = '0%';
181
+ }
182
+ }, (error) => {
183
+ this.error = `Upload failed: ${error.message}`;
184
+ this.status = '';
185
+ console.error('Upload failed:', error);
186
+ uploader.value = 0;
187
+ uploader.textContent = 'Error';
188
+ }, async () => {
189
+ await getDownloadURL(uploadTask.snapshot.ref)
190
+ .then((url) => {
191
+ updateMetadata(location, newMetadata)
192
+ .then(() => { }).catch((error) => { console.log("error: ", error); });
193
+ if (user) {
194
+ updateProfile(user, { photoURL: url })
195
+ .then(() => {
196
+ uploader.value = 100;
197
+ uploader.textContent = 'Complete';
198
+ });
199
+ this.status = 'User profile updated successfully!';
200
+ this.dispatchPhoto(url);
201
+ }
202
+ }).catch(() => { });
203
+ });
204
+ }
205
+ }
206
+ }
207
+ __decorate([
208
+ property(),
209
+ __metadata("design:type", Object)
210
+ ], ContactPhoto.prototype, "photo", void 0);
211
+ __decorate([
212
+ property({ type: String, reflect: true }),
213
+ __metadata("design:type", Object)
214
+ ], ContactPhoto.prototype, "emptyArtwork", void 0);
215
+ __decorate([
216
+ state(),
217
+ __metadata("design:type", Object)
218
+ ], ContactPhoto.prototype, "user", void 0);
219
+ __decorate([
220
+ state(),
221
+ __metadata("design:type", Boolean)
222
+ ], ContactPhoto.prototype, "login", void 0);
223
+ __decorate([
224
+ state(),
225
+ __metadata("design:type", Number)
226
+ ], ContactPhoto.prototype, "progress", void 0);
227
+ __decorate([
228
+ state(),
229
+ __metadata("design:type", String)
230
+ ], ContactPhoto.prototype, "error", void 0);
231
+ __decorate([
232
+ state(),
233
+ __metadata("design:type", String)
234
+ ], ContactPhoto.prototype, "status", void 0);
235
+ customElements.define('contact-photo', ContactPhoto);
@@ -0,0 +1,37 @@
1
+ import { CSSResultArray, LitElement } from 'lit';
2
+ import { AppState } from '../../store';
3
+ import './input/uploader';
4
+ import './input/name';
5
+ import './input/email';
6
+ import './input/password';
7
+ import './input/delete';
8
+ declare const UserSettings_base: (new (...args: any[]) => {
9
+ _storeUnsubscribe: import("redux").Unsubscribe;
10
+ connectedCallback(): void;
11
+ disconnectedCallback(): void;
12
+ stateChanged(_state: {
13
+ frontend: import("../../redux/object").frontendAuth;
14
+ drawer: {
15
+ drawer: boolean;
16
+ };
17
+ backend: import("../../redux/object").backendAuth;
18
+ }): void;
19
+ readonly isConnected: boolean;
20
+ }) & typeof LitElement;
21
+ export declare class UserSettings extends UserSettings_base {
22
+ emptyArtwork: string;
23
+ private profileTopic;
24
+ private name;
25
+ constructor();
26
+ protected firstUpdated(): void;
27
+ stateChanged(state: AppState): void;
28
+ static get styles(): CSSResultArray;
29
+ protected render(): import("lit-html").TemplateResult<1>;
30
+ }
31
+ declare global {
32
+ interface HTMLElementTagNameMap {
33
+ 'user-settings': UserSettings;
34
+ }
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../../src-typescript/webcomponents/settings/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAQ,UAAU,EAAE,MAAe,KAAK,CAAC;AAGrE,OAAO,EAAS,QAAQ,EAAE,MAAqB,aAAa,CAAC;AAG7D,OAAO,kBAAkB,CAAC;AAC1B,OAAO,cAAc,CAAC;AACtB,OAAO,eAAe,CAAC;AACvB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,gBAAgB,CAAC;;;;;;;;;;;;;;AAGxB,qBACa,YAAa,SAAQ,iBAA0B;IAGV,YAAY,SAAM;IAEzD,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,IAAI,CAAM;;IAI3B,SAAS,CAAC,YAAY;IA8BtB,YAAY,CAAC,KAAK,EAAE,QAAQ;IAK5B,MAAM,KAAK,MAAM,IAAG,cAAc,CAyC5B;IAEN,SAAS,CAAC,MAAM;CA6FjB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC3B,eAAe,EAAE,YAAY,CAAC;KACjC;CACF"}