ngx-promise-buttons 1.0.1 → 1.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 (53) hide show
  1. package/fesm2022/ngx-promise-buttons.mjs +243 -0
  2. package/fesm2022/ngx-promise-buttons.mjs.map +1 -0
  3. package/package.json +38 -87
  4. package/types/ngx-promise-buttons.d.ts +76 -0
  5. package/.editorconfig +0 -13
  6. package/.github/FUNDING.yml +0 -12
  7. package/.travis.yml +0 -21
  8. package/CHANGELOG.md +0 -0
  9. package/CONTRIBUTING.md +0 -36
  10. package/angular.json +0 -180
  11. package/e2e/protractor.conf.js +0 -32
  12. package/e2e/src/app.e2e-spec.ts +0 -23
  13. package/e2e/src/app.po.ts +0 -11
  14. package/e2e/tsconfig.json +0 -13
  15. package/logo.png +0 -0
  16. package/projects/ngx-promise-buttons/karma.conf.js +0 -32
  17. package/projects/ngx-promise-buttons/ng-package.json +0 -10
  18. package/projects/ngx-promise-buttons/package.json +0 -26
  19. package/projects/ngx-promise-buttons/src/default-promise-btn-config.ts +0 -10
  20. package/projects/ngx-promise-buttons/src/index.ts +0 -2
  21. package/projects/ngx-promise-buttons/src/promise-btn-config.ts +0 -7
  22. package/projects/ngx-promise-buttons/src/promise-btn.directive.spec.ts +0 -597
  23. package/projects/ngx-promise-buttons/src/promise-btn.directive.ts +0 -247
  24. package/projects/ngx-promise-buttons/src/provider.ts +0 -14
  25. package/projects/ngx-promise-buttons/src/test.ts +0 -16
  26. package/projects/ngx-promise-buttons/src/user-cfg.ts +0 -3
  27. package/projects/ngx-promise-buttons/tsconfig.lib.json +0 -27
  28. package/projects/ngx-promise-buttons/tsconfig.lib.prod.json +0 -10
  29. package/projects/ngx-promise-buttons/tsconfig.spec.json +0 -17
  30. package/projects/ngx-promise-buttons/tslint.json +0 -25
  31. package/projects/ngx-promise-buttons/yarn.lock +0 -9
  32. package/projects/ngx-promise-buttons-demo/e2e/protractor.conf.js +0 -30
  33. package/projects/ngx-promise-buttons-demo/e2e/tsconfig.json +0 -14
  34. package/projects/ngx-promise-buttons-demo/karma.conf.js +0 -56
  35. package/projects/ngx-promise-buttons-demo/src/app/app.component.css +0 -6
  36. package/projects/ngx-promise-buttons-demo/src/app/app.component.html +0 -109
  37. package/projects/ngx-promise-buttons-demo/src/app/app.component.spec.ts +0 -29
  38. package/projects/ngx-promise-buttons-demo/src/app/app.component.ts +0 -208
  39. package/projects/ngx-promise-buttons-demo/src/assets/.gitkeep +0 -0
  40. package/projects/ngx-promise-buttons-demo/src/environments/environment.prod.ts +0 -3
  41. package/projects/ngx-promise-buttons-demo/src/environments/environment.ts +0 -8
  42. package/projects/ngx-promise-buttons-demo/src/favicon.ico +0 -0
  43. package/projects/ngx-promise-buttons-demo/src/index.html +0 -72
  44. package/projects/ngx-promise-buttons-demo/src/main.ts +0 -11
  45. package/projects/ngx-promise-buttons-demo/src/polyfills.ts +0 -63
  46. package/projects/ngx-promise-buttons-demo/src/styles.scss +0 -135
  47. package/projects/ngx-promise-buttons-demo/tsconfig.app.json +0 -14
  48. package/projects/ngx-promise-buttons-demo/tsconfig.spec.json +0 -18
  49. package/projects/ngx-promise-buttons-demo/tslint.json +0 -156
  50. package/scripts/copy-readme-to-demo.js +0 -15
  51. package/tsconfig.build-lib.json +0 -32
  52. package/tsconfig.json +0 -41
  53. package/wallaby.js +0 -90
@@ -0,0 +1,243 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, makeEnvironmentProviders, HostListener, Input, Optional, Inject, Directive } from '@angular/core';
3
+ import { Observable, Subscription } from 'rxjs';
4
+
5
+ const DEFAULT_CFG = {
6
+ spinnerTpl: '<span class="btn-spinner"></span>',
7
+ disableBtn: true,
8
+ btnLoadingClass: 'is-loading',
9
+ handleCurrentBtnOnly: false,
10
+ minDuration: null,
11
+ };
12
+
13
+ const USER_CFG = new InjectionToken('Promise Button Config');
14
+ const DEFAULT_CONFIG = {
15
+ // default values
16
+ };
17
+ function provideNgxPromiseButtons(config = DEFAULT_CONFIG) {
18
+ return makeEnvironmentProviders([
19
+ { provide: USER_CFG, useValue: { ...DEFAULT_CONFIG, ...config } }
20
+ ]);
21
+ }
22
+
23
+ class PromiseBtnDirective {
24
+ // this is added to fix the overriding of the disabled state by the loading indicator button.
25
+ set isDisabledFromTheOutsideSetter(v) {
26
+ this.isDisabledFromTheOutside = v;
27
+ if (v) {
28
+ // disabled means always disabled
29
+ this.btnEl.setAttribute('disabled', 'disabled');
30
+ }
31
+ else if (this.isPromiseDone || this.isPromiseDone === undefined) {
32
+ this.btnEl.removeAttribute('disabled');
33
+ }
34
+ // else the button is loading, so do not change the disabled loading state.
35
+ }
36
+ constructor(el, cfg) {
37
+ // provide configuration
38
+ this.cfg = Object.assign({}, DEFAULT_CFG, cfg);
39
+ // save element
40
+ this.btnEl = el.nativeElement;
41
+ }
42
+ set promiseBtn(passedValue) {
43
+ const isObservable = passedValue instanceof Observable;
44
+ const isSubscription = passedValue instanceof Subscription;
45
+ const isBoolean = typeof passedValue === 'boolean';
46
+ const isPromise = passedValue instanceof Promise || (passedValue !== null &&
47
+ typeof passedValue === 'object' &&
48
+ typeof passedValue.then === 'function' &&
49
+ typeof passedValue.catch === 'function');
50
+ if (isObservable) {
51
+ throw new TypeError('promiseBtn must be an instance of Subscription, instance of Observable given');
52
+ }
53
+ else if (isSubscription) {
54
+ const sub = passedValue;
55
+ if (!sub.closed) {
56
+ this.promise = new Promise((resolve) => {
57
+ sub.add(resolve);
58
+ });
59
+ }
60
+ }
61
+ else if (isPromise) {
62
+ this.promise = passedValue;
63
+ }
64
+ else if (isBoolean) {
65
+ this.promise = this.createPromiseFromBoolean(passedValue);
66
+ }
67
+ this.checkAndInitPromiseHandler(this.btnEl);
68
+ }
69
+ ngAfterContentInit() {
70
+ this.prepareBtnEl(this.btnEl);
71
+ // trigger changes once to handle initial promises
72
+ this.checkAndInitPromiseHandler(this.btnEl);
73
+ }
74
+ ngOnDestroy() {
75
+ // cleanup
76
+ if (this.minDurationTimeout) {
77
+ clearTimeout(this.minDurationTimeout);
78
+ }
79
+ }
80
+ createPromiseFromBoolean(val) {
81
+ if (val) {
82
+ return new Promise((resolve) => {
83
+ this._fakePromiseResolve = resolve;
84
+ });
85
+ }
86
+ else {
87
+ if (this._fakePromiseResolve) {
88
+ this._fakePromiseResolve();
89
+ }
90
+ return this.promise;
91
+ }
92
+ }
93
+ /**
94
+ * Initializes all html and event handlers
95
+ */
96
+ prepareBtnEl(btnEl) {
97
+ // handle promises passed via promiseBtn attribute
98
+ this.appendSpinnerTpl(btnEl);
99
+ }
100
+ /**
101
+ * Checks if all required parameters are there and inits the promise handler
102
+ */
103
+ checkAndInitPromiseHandler(btnEl) {
104
+ // check if element and promise is set
105
+ if (btnEl && this.promise) {
106
+ this.initPromiseHandler(btnEl);
107
+ }
108
+ }
109
+ /**
110
+ * Helper FN to add class
111
+ */
112
+ addLoadingClass(el) {
113
+ if (typeof this.cfg.btnLoadingClass === 'string') {
114
+ el.classList.add(this.cfg.btnLoadingClass);
115
+ }
116
+ }
117
+ /**
118
+ * Helper FN to remove classes
119
+ */
120
+ removeLoadingClass(el) {
121
+ if (typeof this.cfg.btnLoadingClass === 'string') {
122
+ el.classList.remove(this.cfg.btnLoadingClass);
123
+ }
124
+ }
125
+ /**
126
+ * Handles everything to be triggered when the button is set
127
+ * to loading state.
128
+ */
129
+ initLoadingState(btnEl) {
130
+ this.addLoadingClass(btnEl);
131
+ this.disableBtn(btnEl);
132
+ }
133
+ /**
134
+ * Handles everything to be triggered when loading is finished
135
+ */
136
+ cancelLoadingStateIfPromiseAndMinDurationDone(btnEl) {
137
+ if ((!this.cfg.minDuration || this.isMinDurationTimeoutDone) && this.isPromiseDone) {
138
+ this.removeLoadingClass(btnEl);
139
+ this.enableBtn(btnEl);
140
+ }
141
+ }
142
+ disableBtn(btnEl) {
143
+ if (this.cfg.disableBtn) {
144
+ btnEl.setAttribute('disabled', 'disabled');
145
+ }
146
+ }
147
+ enableBtn(btnEl) {
148
+ if (this.cfg.disableBtn) {
149
+ if (this.isDisabledFromTheOutside) {
150
+ btnEl.setAttribute('disabled', 'disabled');
151
+ }
152
+ else {
153
+ btnEl.removeAttribute('disabled');
154
+ }
155
+ }
156
+ }
157
+ /**
158
+ * Initializes a watcher for the promise. Also takes
159
+ * this.cfg.minDuration into account if given.
160
+ */
161
+ initPromiseHandler(btnEl) {
162
+ const promise = this.promise;
163
+ // watch promise to resolve or fail
164
+ this.isMinDurationTimeoutDone = false;
165
+ this.isPromiseDone = false;
166
+ // create timeout if option is set
167
+ if (this.cfg.minDuration) {
168
+ this.minDurationTimeout = window.setTimeout(() => {
169
+ this.isMinDurationTimeoutDone = true;
170
+ this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);
171
+ }, this.cfg.minDuration);
172
+ }
173
+ const resolveLoadingState = () => {
174
+ this.isPromiseDone = true;
175
+ this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);
176
+ };
177
+ if (!this.cfg.handleCurrentBtnOnly) {
178
+ this.initLoadingState(btnEl);
179
+ }
180
+ // native Promise doesn't have finally
181
+ if (promise.finally) {
182
+ promise.finally(resolveLoadingState);
183
+ }
184
+ else {
185
+ promise
186
+ .then(resolveLoadingState)
187
+ .catch(resolveLoadingState);
188
+ }
189
+ }
190
+ /**
191
+ * $compile and append the spinner template to the button.
192
+ */
193
+ appendSpinnerTpl(btnEl) {
194
+ // TODO add some kind of compilation later on
195
+ btnEl.insertAdjacentHTML('beforeend', this.cfg.spinnerTpl);
196
+ }
197
+ /**
198
+ * Limit loading state to show only for the currently clicked button.
199
+ * Executed only if this.cfg.handleCurrentBtnOnly is set
200
+ */
201
+ handleCurrentBtnOnly() {
202
+ if (!this.cfg.handleCurrentBtnOnly) {
203
+ return true; // return true for testing
204
+ }
205
+ // Click triggers @Input update
206
+ // We need to use timeout to wait for @Input to update
207
+ window.setTimeout(() => {
208
+ // return if something else than a promise is passed
209
+ if (!this.promise) {
210
+ return;
211
+ }
212
+ this.initLoadingState(this.btnEl);
213
+ }, 0);
214
+ }
215
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: PromiseBtnDirective, deps: [{ token: i0.ElementRef }, { token: USER_CFG, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
216
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: PromiseBtnDirective, isStandalone: true, selector: "[promiseBtn]", inputs: { isDisabledFromTheOutsideSetter: ["disabled", "isDisabledFromTheOutsideSetter"], promiseBtn: "promiseBtn" }, host: { listeners: { "click": "handleCurrentBtnOnly()" } }, ngImport: i0 }); }
217
+ }
218
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: PromiseBtnDirective, decorators: [{
219
+ type: Directive,
220
+ args: [{
221
+ selector: '[promiseBtn]',
222
+ }]
223
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: undefined, decorators: [{
224
+ type: Optional
225
+ }, {
226
+ type: Inject,
227
+ args: [USER_CFG]
228
+ }] }], propDecorators: { isDisabledFromTheOutsideSetter: [{
229
+ type: Input,
230
+ args: ['disabled']
231
+ }], promiseBtn: [{
232
+ type: Input
233
+ }], handleCurrentBtnOnly: [{
234
+ type: HostListener,
235
+ args: ['click']
236
+ }] } });
237
+
238
+ /**
239
+ * Generated bundle index. Do not edit.
240
+ */
241
+
242
+ export { DEFAULT_CONFIG, PromiseBtnDirective, USER_CFG, provideNgxPromiseButtons };
243
+ //# sourceMappingURL=ngx-promise-buttons.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-promise-buttons.mjs","sources":["../../../projects/ngx-promise-buttons/src/default-promise-btn-config.ts","../../../projects/ngx-promise-buttons/src/provider.ts","../../../projects/ngx-promise-buttons/src/promise-btn.directive.ts","../../../projects/ngx-promise-buttons/src/ngx-promise-buttons.ts"],"sourcesContent":["import {PromiseBtnConfig} from './promise-btn-config';\r\n\r\nexport const DEFAULT_CFG: PromiseBtnConfig = {\r\n spinnerTpl: '<span class=\"btn-spinner\"></span>',\r\n disableBtn: true,\r\n btnLoadingClass: 'is-loading',\r\n handleCurrentBtnOnly: false,\r\n minDuration: null,\r\n};\r\n\r\n","import { InjectionToken, EnvironmentProviders, makeEnvironmentProviders, Optional, SkipSelf, inject } from '@angular/core';\r\nimport { PromiseBtnConfig } from './promise-btn-config';\r\n\r\nexport const USER_CFG = new InjectionToken<PromiseBtnConfig>('Promise Button Config');\r\n\r\nexport const DEFAULT_CONFIG: PromiseBtnConfig = {\r\n // default values\r\n};\r\n\r\nexport function provideNgxPromiseButtons(config: PromiseBtnConfig = DEFAULT_CONFIG): EnvironmentProviders {\r\n return makeEnvironmentProviders([\r\n { provide: USER_CFG, useValue: { ...DEFAULT_CONFIG, ...config } }\r\n ]);\r\n}\r\n","import {AfterContentInit, Directive, ElementRef, HostListener, Inject, Input, OnDestroy, Optional} from '@angular/core';\r\nimport {Observable, Subscription} from 'rxjs';\r\nimport {DEFAULT_CFG} from './default-promise-btn-config';\r\nimport {PromiseBtnConfig} from './promise-btn-config';\r\nimport {USER_CFG} from \"./provider\";\r\n\r\n@Directive({\r\n selector: '[promiseBtn]',\r\n})\r\n\r\nexport class PromiseBtnDirective implements OnDestroy, AfterContentInit {\r\n cfg: PromiseBtnConfig;\r\n // the timeout used for min duration display\r\n minDurationTimeout: number;\r\n // boolean to determine minDurationTimeout state\r\n isMinDurationTimeoutDone: boolean;\r\n // boolean to determine if promise was resolved\r\n isPromiseDone: boolean;\r\n // the promise button button element\r\n btnEl: HTMLElement;\r\n // the promise itself or a function expression\r\n // NOTE: we need the type any here as we might deal with custom promises like bluebird\r\n promise: any;\r\n\r\n // this is added to fix the overriding of the disabled state by the loading indicator button.\r\n @Input('disabled')\r\n set isDisabledFromTheOutsideSetter(v: boolean) {\r\n this.isDisabledFromTheOutside = v;\r\n if (v) {\r\n // disabled means always disabled\r\n this.btnEl.setAttribute('disabled', 'disabled');\r\n } else if (this.isPromiseDone || this.isPromiseDone === undefined) {\r\n this.btnEl.removeAttribute('disabled');\r\n }\r\n // else the button is loading, so do not change the disabled loading state.\r\n }\r\n\r\n isDisabledFromTheOutside: boolean;\r\n\r\n private _fakePromiseResolve: (value: void) => void;\r\n\r\n constructor(el: ElementRef,\r\n @Optional() @Inject(USER_CFG) cfg?: PromiseBtnConfig) {\r\n // provide configuration\r\n this.cfg = Object.assign({}, DEFAULT_CFG, cfg);\r\n\r\n // save element\r\n this.btnEl = el.nativeElement;\r\n }\r\n\r\n @Input()\r\n set promiseBtn(passedValue: any) {\r\n const isObservable: boolean = passedValue instanceof Observable;\r\n const isSubscription: boolean = passedValue instanceof Subscription;\r\n const isBoolean: boolean = typeof passedValue === 'boolean';\r\n const isPromise: boolean = passedValue instanceof Promise || (\r\n passedValue !== null &&\r\n typeof passedValue === 'object' &&\r\n typeof passedValue.then === 'function' &&\r\n typeof passedValue.catch === 'function'\r\n );\r\n\r\n if (isObservable) {\r\n throw new TypeError('promiseBtn must be an instance of Subscription, instance of Observable given');\r\n } else if (isSubscription) {\r\n const sub: Subscription = passedValue;\r\n if (!sub.closed) {\r\n this.promise = new Promise((resolve) => {\r\n sub.add(resolve);\r\n });\r\n }\r\n } else if (isPromise) {\r\n this.promise = passedValue;\r\n } else if (isBoolean) {\r\n this.promise = this.createPromiseFromBoolean(passedValue);\r\n }\r\n\r\n this.checkAndInitPromiseHandler(this.btnEl);\r\n }\r\n\r\n ngAfterContentInit() {\r\n this.prepareBtnEl(this.btnEl);\r\n // trigger changes once to handle initial promises\r\n this.checkAndInitPromiseHandler(this.btnEl);\r\n }\r\n\r\n ngOnDestroy() {\r\n // cleanup\r\n if (this.minDurationTimeout) {\r\n clearTimeout(this.minDurationTimeout);\r\n }\r\n }\r\n\r\n createPromiseFromBoolean(val: boolean): Promise<any> {\r\n if (val) {\r\n return new Promise((resolve) => {\r\n this._fakePromiseResolve = resolve;\r\n });\r\n } else {\r\n if (this._fakePromiseResolve) {\r\n this._fakePromiseResolve();\r\n }\r\n return this.promise;\r\n }\r\n }\r\n\r\n /**\r\n * Initializes all html and event handlers\r\n */\r\n prepareBtnEl(btnEl: HTMLElement) {\r\n // handle promises passed via promiseBtn attribute\r\n this.appendSpinnerTpl(btnEl);\r\n }\r\n\r\n /**\r\n * Checks if all required parameters are there and inits the promise handler\r\n */\r\n checkAndInitPromiseHandler(btnEl: HTMLElement) {\r\n // check if element and promise is set\r\n if (btnEl && this.promise) {\r\n this.initPromiseHandler(btnEl);\r\n }\r\n }\r\n\r\n /**\r\n * Helper FN to add class\r\n */\r\n addLoadingClass(el: any) {\r\n if (typeof this.cfg.btnLoadingClass === 'string') {\r\n el.classList.add(this.cfg.btnLoadingClass);\r\n }\r\n }\r\n\r\n /**\r\n * Helper FN to remove classes\r\n */\r\n removeLoadingClass(el: any) {\r\n if (typeof this.cfg.btnLoadingClass === 'string') {\r\n el.classList.remove(this.cfg.btnLoadingClass);\r\n }\r\n }\r\n\r\n /**\r\n * Handles everything to be triggered when the button is set\r\n * to loading state.\r\n */\r\n initLoadingState(btnEl: HTMLElement) {\r\n this.addLoadingClass(btnEl);\r\n this.disableBtn(btnEl);\r\n }\r\n\r\n /**\r\n * Handles everything to be triggered when loading is finished\r\n */\r\n cancelLoadingStateIfPromiseAndMinDurationDone(btnEl: HTMLElement) {\r\n if ((!this.cfg.minDuration || this.isMinDurationTimeoutDone) && this.isPromiseDone) {\r\n this.removeLoadingClass(btnEl);\r\n this.enableBtn(btnEl);\r\n }\r\n }\r\n\r\n disableBtn(btnEl: HTMLElement) {\r\n if (this.cfg.disableBtn) {\r\n btnEl.setAttribute('disabled', 'disabled');\r\n }\r\n }\r\n\r\n enableBtn(btnEl: HTMLElement) {\r\n if (this.cfg.disableBtn) {\r\n if (this.isDisabledFromTheOutside) {\r\n btnEl.setAttribute('disabled', 'disabled');\r\n } else {\r\n btnEl.removeAttribute('disabled');\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Initializes a watcher for the promise. Also takes\r\n * this.cfg.minDuration into account if given.\r\n */\r\n\r\n initPromiseHandler(btnEl: HTMLElement) {\r\n const promise = this.promise;\r\n\r\n // watch promise to resolve or fail\r\n this.isMinDurationTimeoutDone = false;\r\n this.isPromiseDone = false;\r\n\r\n // create timeout if option is set\r\n if (this.cfg.minDuration) {\r\n this.minDurationTimeout = window.setTimeout(() => {\r\n this.isMinDurationTimeoutDone = true;\r\n this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);\r\n }, this.cfg.minDuration);\r\n }\r\n\r\n const resolveLoadingState = () => {\r\n this.isPromiseDone = true;\r\n this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);\r\n };\r\n\r\n if (!this.cfg.handleCurrentBtnOnly) {\r\n this.initLoadingState(btnEl);\r\n }\r\n // native Promise doesn't have finally\r\n if (promise.finally) {\r\n promise.finally(resolveLoadingState);\r\n } else {\r\n promise\r\n .then(resolveLoadingState)\r\n .catch(resolveLoadingState);\r\n }\r\n\r\n }\r\n\r\n\r\n /**\r\n * $compile and append the spinner template to the button.\r\n */\r\n appendSpinnerTpl(btnEl: HTMLElement) {\r\n // TODO add some kind of compilation later on\r\n btnEl.insertAdjacentHTML('beforeend', this.cfg.spinnerTpl as string);\r\n }\r\n\r\n /**\r\n * Limit loading state to show only for the currently clicked button.\r\n * Executed only if this.cfg.handleCurrentBtnOnly is set\r\n */\r\n @HostListener('click')\r\n handleCurrentBtnOnly() {\r\n if (!this.cfg.handleCurrentBtnOnly) {\r\n return true; // return true for testing\r\n }\r\n\r\n // Click triggers @Input update\r\n // We need to use timeout to wait for @Input to update\r\n window.setTimeout(() => {\r\n // return if something else than a promise is passed\r\n if (!this.promise) {\r\n return;\r\n }\r\n\r\n this.initLoadingState(this.btnEl);\r\n }, 0);\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAEO,MAAM,WAAW,GAAqB;AAC3C,IAAA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AS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE,cAAc;AAC3B,iBAAA;;0BAkCc;;0BAAY,MAAM;2BAAC,QAAQ;;sBAjBvC,KAAK;uBAAC,UAAU;;sBAyBhB;;sBAmLA,YAAY;uBAAC,OAAO;;;ACrOvB;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,87 +1,38 @@
1
- {
2
- "name": "ngx-promise-buttons",
3
- "version": "1.0.1",
4
- "license": "MIT",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+ssh://git@github.com/meysamsahragard/ngx-promise-buttons.git"
8
- },
9
- "scripts": {
10
- "ng": "ng",
11
- "start": "ng serve",
12
- "build": "ng build",
13
- "test": "ng test --browsers ChromeHeadless --watch=false",
14
- "lint": "ng lint",
15
- "e2e": "ng e2e",
16
- "demo": "run-s demo.build demo.copy-readme demo.gh-pages",
17
- "demo.build": "ng build --aot --configuration production --base-href='./'",
18
- "demo.copy-readme": "node scripts/copy-readme-to-demo.js",
19
- "demo.gh-pages": "gh-pages -d dist/demo",
20
- "lib": "run-s lib.build copy",
21
- "lib.build": "ng build --configuration production ngx-promise-buttons",
22
- "copy": "run-s copy.licence copy.readme",
23
- "copy.licence": "copyfiles ./LICENSE ./dist/ngx-promise-buttons",
24
- "copy.readme": "copyfiles ./README.md ./dist/ngx-promise-buttons",
25
- "pub": "run-s lib && cd ./dist/ngx-promise-buttons/ && npm publish && cd .. && cd ..",
26
- "patch": "npm version patch && cd ./projects/ngx-promise-buttons && npm version patch && cd .. && cd .. && git add . && git commit -am\"chore: update lib version\"",
27
- "patch-release_": "run-s lib demo patch pub",
28
- "patch-release": "npm run patch-release_",
29
- "major": "npm version major && cd ./projects/ngx-promise-buttons && npm version major && cd .. && cd .. && git add . && git commit -am\"chore: update lib version\"",
30
- "major-release_": "run-s lib demo major pub",
31
- "major-release": "npm run major-release_",
32
- "test-coverage": "ng test --browsers ChromeHeadless --code-coverage --watch=false",
33
- "coveralls": "YOURPACKAGE_COVERAGE=1 cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
34
- },
35
- "devDependencies": {
36
- "@angular-devkit/build-angular": "^21.0.4",
37
- "@angular/cli": "^21.0.4",
38
- "@angular/common": "^21.0.6",
39
- "@angular/compiler": "^21.0.6",
40
- "@angular/compiler-cli": "^21.0.6",
41
- "@angular/core": "^21.0.6",
42
- "@angular/forms": "^21.0.6",
43
- "@angular/platform-browser": "^21.0.6",
44
- "@angular/platform-browser-dynamic": "^21.0.6",
45
- "@angular/router": "^21.0.6",
46
- "@types/bluebird": "^3.5.29",
47
- "@types/core-js": "^2.5.2",
48
- "@types/jasmine": "~3.6.0",
49
- "@types/jquery": "^3.3.32",
50
- "@types/node": "^13.7.0",
51
- "angular2-template-loader": "^0.6.2",
52
- "bluebird": "^3.7.2",
53
- "bootstrap": "^4.4.1",
54
- "bootstrap-material-design": "^4.1.2",
55
- "codelyzer": "^6.0.0",
56
- "conventional-changelog-cli": "^2.0.31",
57
- "conventional-github-releaser": "^3.1.3",
58
- "copyfiles": "^2.2.0",
59
- "core-js": "^3.6.4",
60
- "coveralls": "^3.0.9",
61
- "gh-pages": "^2.2.0",
62
- "intl": "^1.2.5",
63
- "jasmine-core": "~3.10",
64
- "jasmine-spec-reporter": "~5.0.0",
65
- "jquery": "^3.5.0",
66
- "karma": "~6.3.16",
67
- "karma-chrome-launcher": "~3.1.0",
68
- "karma-cli": "~2.0.0",
69
- "karma-coverage-istanbul-reporter": "~3.0.2",
70
- "karma-jasmine": "~4.0.0",
71
- "karma-jasmine-html-reporter": "^1.5.0",
72
- "karma-phantomjs-launcher": "^1.0.4",
73
- "marked": "^2.0.0",
74
- "ng-packagr": "^21.0.1",
75
- "npm-run-all": "^4.1.5",
76
- "protractor": "~7.0.0",
77
- "reflect-metadata": "^0.1.13",
78
- "rxjs": "^6.5.4",
79
- "ts-node": "~8.6.2",
80
- "tslib": "^2.0.0",
81
- "tslint": "~6.1.0",
82
- "typescript": "~5.9.3",
83
- "wallaby-webpack": "3.9.15",
84
- "web-animations-js": "^2.3.2",
85
- "zone.js": "~0.15.1"
86
- }
87
- }
1
+ {
2
+ "name": "ngx-promise-buttons",
3
+ "version": "1.0.2",
4
+ "description": "Chilled loading buttons for angular",
5
+ "author": "meysamsahragard <contact@super-productivity.com> (http://super-productivity.com)",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+ssh://git@github.com/meysamsahragard/ngx-promise-buttons.git"
10
+ },
11
+ "keywords": [
12
+ "angular",
13
+ "javascript",
14
+ "typescript",
15
+ "button",
16
+ "promise",
17
+ "spinner"
18
+ ],
19
+ "dependencies": {
20
+ "tslib": "^2.0.0"
21
+ },
22
+ "peerDependencies": {
23
+ "@angular/common": ">=9.0.4",
24
+ "@angular/core": ">=9.0.4"
25
+ },
26
+ "module": "fesm2022/ngx-promise-buttons.mjs",
27
+ "typings": "types/ngx-promise-buttons.d.ts",
28
+ "exports": {
29
+ "./package.json": {
30
+ "default": "./package.json"
31
+ },
32
+ ".": {
33
+ "types": "./types/ngx-promise-buttons.d.ts",
34
+ "default": "./fesm2022/ngx-promise-buttons.mjs"
35
+ }
36
+ },
37
+ "sideEffects": false
38
+ }
@@ -0,0 +1,76 @@
1
+ import * as i0 from '@angular/core';
2
+ import { OnDestroy, AfterContentInit, ElementRef, InjectionToken, EnvironmentProviders } from '@angular/core';
3
+
4
+ interface PromiseBtnConfig {
5
+ spinnerTpl?: string;
6
+ disableBtn?: boolean;
7
+ btnLoadingClass?: boolean | string;
8
+ handleCurrentBtnOnly?: boolean;
9
+ minDuration?: number | null;
10
+ }
11
+
12
+ declare class PromiseBtnDirective implements OnDestroy, AfterContentInit {
13
+ cfg: PromiseBtnConfig;
14
+ minDurationTimeout: number;
15
+ isMinDurationTimeoutDone: boolean;
16
+ isPromiseDone: boolean;
17
+ btnEl: HTMLElement;
18
+ promise: any;
19
+ set isDisabledFromTheOutsideSetter(v: boolean);
20
+ isDisabledFromTheOutside: boolean;
21
+ private _fakePromiseResolve;
22
+ constructor(el: ElementRef, cfg?: PromiseBtnConfig);
23
+ set promiseBtn(passedValue: any);
24
+ ngAfterContentInit(): void;
25
+ ngOnDestroy(): void;
26
+ createPromiseFromBoolean(val: boolean): Promise<any>;
27
+ /**
28
+ * Initializes all html and event handlers
29
+ */
30
+ prepareBtnEl(btnEl: HTMLElement): void;
31
+ /**
32
+ * Checks if all required parameters are there and inits the promise handler
33
+ */
34
+ checkAndInitPromiseHandler(btnEl: HTMLElement): void;
35
+ /**
36
+ * Helper FN to add class
37
+ */
38
+ addLoadingClass(el: any): void;
39
+ /**
40
+ * Helper FN to remove classes
41
+ */
42
+ removeLoadingClass(el: any): void;
43
+ /**
44
+ * Handles everything to be triggered when the button is set
45
+ * to loading state.
46
+ */
47
+ initLoadingState(btnEl: HTMLElement): void;
48
+ /**
49
+ * Handles everything to be triggered when loading is finished
50
+ */
51
+ cancelLoadingStateIfPromiseAndMinDurationDone(btnEl: HTMLElement): void;
52
+ disableBtn(btnEl: HTMLElement): void;
53
+ enableBtn(btnEl: HTMLElement): void;
54
+ /**
55
+ * Initializes a watcher for the promise. Also takes
56
+ * this.cfg.minDuration into account if given.
57
+ */
58
+ initPromiseHandler(btnEl: HTMLElement): void;
59
+ /**
60
+ * $compile and append the spinner template to the button.
61
+ */
62
+ appendSpinnerTpl(btnEl: HTMLElement): void;
63
+ /**
64
+ * Limit loading state to show only for the currently clicked button.
65
+ * Executed only if this.cfg.handleCurrentBtnOnly is set
66
+ */
67
+ handleCurrentBtnOnly(): boolean;
68
+ static ɵfac: i0.ɵɵFactoryDeclaration<PromiseBtnDirective, [null, { optional: true; }]>;
69
+ static ɵdir: i0.ɵɵDirectiveDeclaration<PromiseBtnDirective, "[promiseBtn]", never, { "isDisabledFromTheOutsideSetter": { "alias": "disabled"; "required": false; }; "promiseBtn": { "alias": "promiseBtn"; "required": false; }; }, {}, never, never, true, never>;
70
+ }
71
+
72
+ declare const USER_CFG: InjectionToken<PromiseBtnConfig>;
73
+ declare const DEFAULT_CONFIG: PromiseBtnConfig;
74
+ declare function provideNgxPromiseButtons(config?: PromiseBtnConfig): EnvironmentProviders;
75
+
76
+ export { DEFAULT_CONFIG, PromiseBtnDirective, USER_CFG, provideNgxPromiseButtons };
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # Editor configuration, see http://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- charset = utf-8
6
- indent_style = space
7
- indent_size = 2
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
-
11
- [*.md]
12
- max_line_length = off
13
- trim_trailing_whitespace = false
@@ -1,12 +0,0 @@
1
- # These are supported funding model platforms
2
-
3
- github: [meysamsahragard] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
- patreon: # Replace with a single Patreon username
5
- open_collective: # Replace with a single Open Collective username
6
- ko_fi: # Replace with a single Ko-fi username
7
- tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
- community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
- liberapay: # Replace with a single Liberapay username
10
- issuehunt: # Replace with a single IssueHunt username
11
- otechie: # Replace with a single Otechie username
12
- custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
package/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "12"
4
-
5
- cache:
6
- yarn: true
7
-
8
-
9
- script:
10
- - yarn
11
- - yarn test-coverage
12
-
13
- addons:
14
- apt:
15
- sources:
16
- - ubuntu-toolchain-r-test
17
- # required by node-gyp to build some packages
18
- packages:
19
- - g++-4.8
20
-
21
- after_success: 'npm run coveralls'
package/CHANGELOG.md DELETED
File without changes
package/CONTRIBUTING.md DELETED
@@ -1,36 +0,0 @@
1
- # How to contribute to this repository
2
- Create a fork of this repository and check it out.
3
-
4
- To make everything work you need to symlink the src directory to the app folder once. You can do this manually or by running `npm run link-mod`.
5
-
6
- Once this is done you can run `npm start` to start the development server.
7
-
8
- If you implement a new feature it is always a good idea to also add an example of it to the demo application.
9
-
10
- ## Commit guidelines
11
- In general this repo tries to adhere to the [angular commit guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit).
12
-
13
- ## Dev tasks
14
- There are several scripts defined in the package.json
15
-
16
- `npm start`: Starts the development server.
17
-
18
- `npm run` **test-watch**: Runs the unit tests via karma.
19
-
20
- `npm run` **test**: Runs the unit tests once.
21
-
22
- `npm run` **test-coverage**: Runs the unit tests with a coverage report.
23
-
24
- `npm run` **build**: Creates a compiled version of your library inside the dist folder.
25
-
26
- `npm run` **demo.deploy**:
27
- Builds the demo app to demo/dist, copies the readme to it and publishes everything to github pages.
28
-
29
- `npm run` **release.changelog**:
30
- Creates a changelog based on the [angular commit conventions](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md).
31
-
32
- `npm run` **link-mod**: Creates a symlink to the module inside the demo/src folder. This is required for compiling the app with aot.
33
-
34
- `npm run` **lint**: Lints all demo and library files
35
-
36
- `npm run` **e2e**: Runs the end2end tests.