@things-factory/shell 7.0.1-alpha.4 → 7.0.1-alpha.5

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.
@@ -1,4 +1,3 @@
1
1
  export * from './oops-note'
2
2
  export * from './oops-spinner'
3
3
  export * from './oops-progress'
4
- export * from './custom-alert'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/shell",
3
- "version": "7.0.1-alpha.4",
3
+ "version": "7.0.1-alpha.5",
4
4
  "description": "Core module for framework",
5
5
  "bin": {
6
6
  "things-factory": "bin/things-factory",
@@ -118,7 +118,6 @@
118
118
  "reselect": "^4.0.0",
119
119
  "sass": "^1.50.1",
120
120
  "scrollbooster": "^3.0.2",
121
- "sweetalert2": "^11.7.3",
122
121
  "type-graphql": "^2.0.0-beta.6",
123
122
  "typeorm": "^0.3.19",
124
123
  "uuid": "^3.4.0",
@@ -134,5 +133,5 @@
134
133
  "pg": "^8.7.3",
135
134
  "sqlite3": "^5.0.8"
136
135
  },
137
- "gitHead": "41b951d71135f4e9ae936a85a3cd7a374c5664cc"
136
+ "gitHead": "3a1ceb942521a89f14c4b16a323b506ff676d349"
138
137
  }
@@ -1,120 +0,0 @@
1
- import Swal from 'sweetalert2'
2
-
3
- /**
4
- * Custom Alert utilized sweetalert2 to produce a simple pop-up message box.
5
- * *Side note: Did not fully utilize sweet alert capability, just added some common usage.
6
- * @param {string} type - ['success', 'error', 'warning', 'info', 'question']
7
- * @param {string} icon - ['success', 'error', 'warning', 'info', 'question']
8
- * @param {string} title - Title for the message box.
9
- * @param {string} text - Description for the message box. Input can be in html format.
10
- * @param {string} footer - Footer message. Input can be in html format
11
- * @param {string} [position = 'center'] - Position of the message box. ['top', 'top-start', 'top-end', 'center', 'center-start', 'center-end', 'bottom', 'bottom-start', 'bottom-end']
12
- * @param {boolean} toast - Set to 'True' to display as toast.
13
- * @param {object} confirmButton - Confirm button is an object type. The text and color of the button can be changed by adding 'text' or 'color' property into the object.
14
- * text is the required field of the object. When the object is populated, the confirm button will automatically shown.
15
- * @param {object} cancelButton - Cancel button is an object type. The text and color of the button can be changed by adding 'text' or 'color' property into the object.
16
- * text is the required field of the object. When the object is populated, the cancel button will automatically shown.
17
- * @param {boolean} [invertButton = false] - Invert button to swap the position of the buttons.
18
- * eg. Confirm button on the right, Cancel button on the left.
19
- * @param {function} callback - Accepts a function with an input parameter. Will invoked after swal.fire. It is a promise chaining function.
20
- * @param {function} onBeforeOpen - Accepts a function with no parameter. Function to run when modal built, but not shown yet. Provides modal DOM element as the first argument.
21
- * @param {function} onOpen - Accepts a function with no parameter. Function to run when modal opens, provides modal DOM element as the first argument.
22
- * @param {function} onRender - Accepts a function with no parameter. Function to run after modal DOM has been updated. eg. After Swal.fire() or Swal.update()
23
- * @param {function} onClose - Accepts a function with no parameter. Function to run when modal closes, provides modal DOM element as the first argument.
24
- * @param {function} onAfterClose - Accepts a function with no parameter. Function to run after modal has been disposed.
25
- * @param {boolean} [debug = false] - Check all parameters are set properly. When set to 'true', simple checking will be done on the input parameters to verify the type.
26
- */
27
-
28
- export async function CustomAlert({
29
- type = 'info',
30
- icon,
31
- title,
32
- text,
33
- allowOutsideClick = true,
34
- allowEscapeKey = true,
35
- footer,
36
- position = 'center',
37
- toast,
38
- timer,
39
- confirmButton = {},
40
- cancelButton = {},
41
- invertButton = false,
42
- callback,
43
- onBeforeOpen,
44
- onOpen,
45
- onRender,
46
- onClose,
47
- onAfterClose,
48
- debug = false
49
- }) {
50
- try {
51
- if (debug) {
52
- let arrTypes = ['success', 'error', 'warning', 'info', 'question']
53
- let err = ''
54
- if (!arrTypes.includes(type)) {
55
- err = err + 'Invalid Alert Type.\n'
56
- }
57
-
58
- if (title && typeof title !== 'string') err = err + 'Invalid Title.\n'
59
- if (text && typeof text !== 'string') err = err + 'Invalid Text.\n'
60
- if (footer && typeof text !== 'string') err = err + 'Invalid Footer.\n'
61
- if (typeof position !== 'string') err = err + 'Invalid Position.\n'
62
- if (toast && typeof toast !== 'boolean') err = err + 'Invalid Footer.\n'
63
- if (
64
- Object.keys(confirmButton).length > 0 &&
65
- (typeof confirmButton !== 'object' || !confirmButton.hasOwnProperty('text'))
66
- )
67
- err = err + 'Invalid Confirm Button.\n'
68
- if (
69
- Object.keys(cancelButton).length > 0 &&
70
- (typeof cancelButton !== 'object' || !cancelButton.hasOwnProperty('text'))
71
- )
72
- err = err + 'Invalid Cancel Button.\n'
73
-
74
- if (err !== '') throw new Error(err)
75
- }
76
-
77
- const result = await Swal.fire({
78
- icon: icon || type,
79
- title: title,
80
- text: text,
81
- timer: timer ? timer:0,
82
- timerProgressBar: timer ? true : 0,
83
- allowOutsideClick: allowOutsideClick,
84
- allowEscapeKey: allowEscapeKey,
85
- footer: footer,
86
- position: position,
87
- showConfirmButton: Object.keys(confirmButton).length > 0 ? true : false,
88
- showCancelButton: Object.keys(cancelButton).length > 0 ? true : false,
89
- confirmButtonText: confirmButton.hasOwnProperty('text') ? confirmButton.text : 'confirm',
90
- cancelButtonText: cancelButton.hasOwnProperty('text') ? cancelButton.text : 'cancel',
91
- confirmButtonColor: confirmButton.hasOwnProperty('color') ? confirmButton.color : '#22a6a7',
92
- cancelButtonColor: cancelButton.hasOwnProperty('color') ? cancelButton.color : '#cfcfcf',
93
- toast: toast,
94
- reverseButtons: invertButton,
95
- willOpen: () => {
96
- onBeforeOpen ? onBeforeOpen() : undefined
97
- },
98
- didOpen: () => {
99
- onOpen ? onOpen() : undefined
100
- },
101
- didRender: () => {
102
- onRender ? onRender() : undefined
103
- },
104
- willClose: () => {
105
- onClose ? onClose() : undefined
106
- },
107
- didClose: () => {
108
- onAfterClose ? onAfterClose() : undefined
109
- }
110
- })
111
-
112
- if (callback && typeof callback === 'function') {
113
- callback(result)
114
- } else {
115
- return Promise.resolve(result)
116
- }
117
- } catch (error) {
118
- console.log('%c(Custom-Alert)\n' + error, 'color:Red')
119
- }
120
- }