neo.mjs 4.6.2 → 4.6.4

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,212 +0,0 @@
1
- import Base from './Base.mjs';
2
- import ToastManager from '../manager/Toast.mjs';
3
-
4
- /**
5
- * @class Neo.dialog.Toast
6
- * @extends Neo.dialog.Base
7
- *
8
- * @example
9
- Neo.toast({
10
- // mandatory
11
- appName : this.component.appName,
12
- msg : 'Alarm was set to 11:30 for journey into Neo development',
13
- // optional defaults
14
- closable : true, // false
15
- iconCls : 'fa fa-bell', // null
16
- maxWidth : 300, // 250
17
- position : 'br', // 'tr'
18
- slideDirection : 'right', // 'down'
19
- title : 'Alarm Clock' // null
20
- })
21
- */
22
- class Toast extends Base {
23
- /**
24
- * If true makes the toast sticky and show a close icon
25
- * @member {Boolean} closable=false
26
- */
27
- closable = false
28
- /**
29
- * Change to use your own fade out animation
30
- * @member {String} fadeOutCls='neo-toast-fade-out'
31
- */
32
- fadeOutCls = 'neo-toast-fade-out'
33
- /**
34
- * If set, it shows this icon in front of the text
35
- * e.g. 'fa fa-cog'
36
- * @member {String|null} iconCls=null
37
- */
38
- iconCls = null
39
- /**
40
- * Used by the ToastManager
41
- * @member {Boolean} running=false
42
- * @private
43
- */
44
- running = false
45
- /**
46
- * Change the complete styling with custom cls
47
- * @member {String} toastCls='neo-toast-'
48
- */
49
- toastCls = 'neo-toast-'
50
- /**
51
- * Used by the ToastManager
52
- * @member {String|null} toastManagerId=null
53
- * @private
54
- */
55
- toastManagerId = null
56
-
57
- static getConfig() {return {
58
- /**
59
- * @member {String} className='Neo.dialog.Toast'
60
- * @protected
61
- */
62
- className: 'Neo.dialog.Toast',
63
- /**
64
- * @member {String} ntype='toast'
65
- * @protected
66
- */
67
- ntype: 'toast',
68
- /**
69
- * The Toast should not be moved
70
- * @member {Boolean} draggable=false
71
- */
72
- draggable: false,
73
- /**
74
- * Header is not meant to be shown.
75
- * @member {Object} headerConfig={hidden:true}
76
- */
77
- headerConfig: {
78
- hidden: true
79
- },
80
- /**
81
- * Limits the width of the Toast
82
- * @member {Number} maxWidth=250
83
- */
84
- maxWidth: 250,
85
- /**
86
- * Sets the minimum height of the Toast
87
- * @member {Number} minHeight=50
88
- */
89
- minHeight: 50,
90
- /**
91
- * Your message. You can also pass in an iconCls
92
- * @member {String|null} msg_=null
93
- */
94
- msg_: null,
95
- /**
96
- * Describes the position of the toast, e.g. bl=bottom-left
97
- * This creates a cls `toastCls + position`
98
- * @member {'tl'|'tc'|'tr'|'bl'|'bc'|'br'} position='tr'
99
- */
100
- position_: 'tr',
101
- /**
102
- * @member {Boolean} resizable=false
103
- */
104
- resizable: false,
105
- /**
106
- * Describes which direction from which side the toasts slides-in
107
- * This creates a cls `toastCls + slide- + direction + in`
108
- * @member {'down'|'up'|'left'|'right'} slideDirection_=null
109
- */
110
- slideDirection_: 'down',
111
- /**
112
- * Timeout in ms after which the toast is removed
113
- * @member {Number} timeout_=3000
114
- */
115
- timeout_: 3000,
116
- /**
117
- * @member {String|null} title=null
118
- */
119
- title: null,
120
- /**
121
- * @member {Function} itemTpl
122
- */
123
- itemTpl: data => {
124
- let cls = data.cls;
125
-
126
- return [
127
- {cls: [`${cls}icon`, data.iconCls], removeDom: !data.iconCls},
128
- {cls: `${cls}text`, cn: [
129
- {cls: `${cls}title`, innerHTML: `${data.title}`, removeDom: !data.title},
130
- {cls: `${cls}msg`, innerHTML: `${data.msg}`}
131
- ]},
132
- {cls: `${cls}close fa fa-close`, removeDom: !data.closable}
133
- ]}
134
- }}
135
-
136
- /**
137
- * Using the afterSetMsg to trigger the setup of the dom
138
- * A new container is added as an item.
139
- * We cannot use the vdom here.
140
- *
141
- * @param {String|null} value
142
- * @param {String|null} oldValue
143
- */
144
- afterSetMsg(value, oldValue) {
145
- let me = this,
146
- toastCls = me.toastCls,
147
- data = {closable: me.closable, cls: toastCls, iconCls: me.iconCls, msg: me.msg, title: me.title},
148
- titleCls = (me.title && me.iconCls) ? `${toastCls}has-title` : '',
149
- vdom = {cn: me.itemTpl(data)};
150
-
151
- me.add({
152
- cls: [`${toastCls}inner`, titleCls],
153
- vdom
154
- });
155
-
156
- // if closable add a listener to the close-element
157
- me.closable && me.addDomListeners([
158
- {click: {fn: me.unregister, delegate: `.${me.toastCls}close`, scope: me}}
159
- ])
160
- }
161
-
162
- /**
163
- * Apply a cls, based on the position
164
- * @param {String} value
165
- * @param {String} oldValue
166
- */
167
- afterSetPosition(value, oldValue) {
168
- value && this.addCls(`${this.toastCls}${value}`)
169
- }
170
-
171
- /**
172
- * Apply a cls, based on the slideDirection
173
- * @param {String} value
174
- * @param {String} oldValue
175
- */
176
- afterSetSlideDirection(value, oldValue) {
177
- value && this.addCls(`${this.toastCls}slide-${value}-in`)
178
- }
179
-
180
- /**
181
- * Close the toast after the timeout if not closable
182
- * @param {Number} value
183
- * @param {Number} oldValue
184
- */
185
- async afterSetTimeout(value, oldValue) {
186
- if (!this.closable && value) {
187
- await Neo.timeout(value);
188
- this.unregister();
189
- }
190
- }
191
-
192
- /**
193
- * After the close-click or timeout, we unregister the toast
194
- * from the ToastManager
195
- */
196
- unregister() {
197
- let me = this;
198
-
199
- me.addDomListeners({
200
- animationend: function () {
201
- ToastManager.removeToast(me.toastManagerId);
202
- me.destroy(true);
203
- }
204
- })
205
-
206
- me.addCls(me.fadeOutCls);
207
- }
208
- }
209
-
210
- Neo.applyClassConfig(Toast);
211
-
212
- export default Toast;