inviton-powerduck 0.0.207 → 0.0.209

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.
@@ -1812,7 +1812,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1812
1812
  }
1813
1813
 
1814
1814
  getMobileBehavior(): DataTableMobileBehavior {
1815
- return this.currentMobileBehavior ?? DataTableConfig.defaultMobileBehavior;
1815
+ return this.currentMobileBehavior ?? (DataTableConfig.defaultMobileBehavior as DataTableMobileBehavior);
1816
1816
  }
1817
1817
 
1818
1818
  getVisibleColumns(): TableColumn[] {
@@ -121,12 +121,21 @@ interface NotificationDisplayArgs {
121
121
  };
122
122
  }
123
123
 
124
- const NotificationUtils = (function () {
125
- function getArgs(
124
+ const isMobileViewport = (): boolean => typeof window !== 'undefined' && window.innerWidth < 768;
125
+
126
+ const applyMobileCenterOffset = (element: any, offsetX: number): void => {
127
+ element?.css({
128
+ left: `${offsetX}px`,
129
+ right: `${offsetX}px`,
130
+ });
131
+ };
132
+
133
+ const NotificationUtils = (() => {
134
+ const getArgs = (
126
135
  messageOrArgs: string | NotificationDisplayArgs,
127
136
  icon?: string,
128
137
  title?: string,
129
- ): NotificationDisplayArgs {
138
+ ): NotificationDisplayArgs => {
130
139
  const args = messageOrArgs as NotificationDisplayArgs;
131
140
  if (args.messageHtml != null) {
132
141
  return args;
@@ -137,13 +146,13 @@ const NotificationUtils = (function () {
137
146
  icon,
138
147
  title,
139
148
  };
140
- }
149
+ };
141
150
 
142
- function getPlacement(args: NotificationDisplayArgs): any {
143
- const placement = args.placement || NotificationPlacement.TopCenter;
151
+ const getPlacement = (args: NotificationDisplayArgs): any => {
152
+ const placement = typeof args.placement === 'number' ? args.placement : NotificationPlacement.TopCenter;
144
153
  const placementEnd = (<number>placement).toString();
145
154
  const lastNumber = Number(placementEnd.substring(placementEnd.length - 1));
146
- const from = placement < 10 ? 'top' : 'bottom';
155
+ const from = placement >= NotificationPlacement.BottomLeft ? 'bottom' : 'top';
147
156
  let align;
148
157
 
149
158
  if (lastNumber == 0) {
@@ -154,41 +163,77 @@ const NotificationUtils = (function () {
154
163
  align = 'right';
155
164
  }
156
165
 
166
+ if (isMobileViewport() && (from === 'bottom' || from === 'top')) {
167
+ align = 'center';
168
+ }
169
+
157
170
  return {
158
171
  from,
159
172
  align,
160
173
  };
161
- }
174
+ };
162
175
 
163
- function show(
176
+ const buildTemplate = (containerClass: string): string => `<div data-notify="container" class="${containerClass} alert alert-{0}" role="alert" style="z-index:999999">
177
+ <button type="button" class="btn-close" data-notify="dismiss" aria-label="Close"></button>
178
+ <span data-notify="icon"></span>
179
+ <span data-notify="title">{1}</span>
180
+ <span data-notify="message">{2}</span>
181
+ <div class="progress" data-notify="progressbar">
182
+ <div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%;"></div>
183
+ </div>
184
+ <a href="{3}" target="{4}" data-notify="url"></a>
185
+ </div>`.replace(/\s{2,}/g, ' ').trim();
186
+
187
+ const show = (
164
188
  messageOrArgs: string | NotificationDisplayArgs,
165
189
  icon?: string,
166
190
  title?: string,
167
- ): void {
191
+ ): void => {
168
192
  const args = getArgs(
169
193
  messageOrArgs,
170
194
  icon,
171
195
  title,
172
196
  );
173
197
 
198
+ const containerClass = args.cssClasses?.containerClass || 'col-xs-11 col-sm-4';
199
+ const timerValue = typeof args.timeout === 'number' ? args.timeout : NotificationProviderConfig.defaultTimeout;
200
+ const delayValue = typeof args.delay === 'number' ? args.delay : NotificationProviderConfig.defaultDelay;
201
+ const placementOptions = getPlacement(args);
202
+ const defaultEnterAnimation = placementOptions.from === 'bottom' ? NotificationAnimation.FadeInUp : NotificationAnimation.FadeInDown;
203
+ const defaultExitAnimation = placementOptions.from === 'bottom' ? NotificationAnimation.FadeOutDown : NotificationAnimation.FadeOutUp;
204
+ const offsetOptions = {
205
+ x: 20,
206
+ y: 20,
207
+ };
208
+
209
+ const shouldForceMobileCenter = isMobileViewport() && placementOptions.align === 'center';
210
+ const onShowHandler = shouldForceMobileCenter
211
+ ? function (this: any) {
212
+ applyMobileCenterOffset(this, offsetOptions.x);
213
+ }
214
+ : undefined;
215
+
174
216
  (jQuery as any).notify({
175
217
  icon: args.icon,
176
218
  message: args.messageHtml,
177
219
  title: args.title,
178
220
  }, {
179
- type: args.type || 'primary',
180
- timer: args.timeout > -1 ? args.timeout : NotificationProviderConfig.defaultTimeout,
181
- delay: args.delay > -1 ? args.delay : NotificationProviderConfig.defaultDelay,
182
- placement: getPlacement(args),
221
+ type: args.type || NotificationType.Primary,
222
+ timer: timerValue,
223
+ delay: delayValue,
224
+ placement: placementOptions,
183
225
  z_index: 99999,
184
- newest_on_top: (args.newestTop || false),
226
+ newest_on_top: args.newestTop ?? false,
227
+ icon_type: 'class',
185
228
  animate: {
186
- enter: (args.animation?.enter || 'animate__animated animate__fadeInDown'),
187
- exit: (args.animation?.exit || 'animate__animated animate__fadeOutUp'),
229
+ enter: args.animation?.enter || defaultEnterAnimation,
230
+ exit: args.animation?.exit || defaultExitAnimation,
188
231
  },
189
- template: `<div data-notify="container" class="${args.cssClasses?.containerClass ? args.cssClasses.containerClass : 'col-xs-11 col-sm-4'} alert alert-{0}" role="alert" style="z-index:999999"><div type="button" aria-hidden="true" class="btn-close close" data-notify="dismiss"></div><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>`,
232
+ offset: offsetOptions,
233
+ template: buildTemplate(containerClass),
234
+ onShow: onShowHandler,
190
235
  });
191
- }
236
+ };
192
237
 
193
238
  return {
194
239
  show,
@@ -236,24 +281,33 @@ export default class NotificationProvider {
236
281
  }
237
282
 
238
283
  /**
239
- * Displays error message
284
+ * Displays danger\error message
240
285
  *
241
- * @param message Error message
286
+ * @param message Danger\Error message
242
287
  */
243
- static showErrorMessage(message: string): void;
288
+ static showErrorMessage(message: string, placement?: NotificationPlacement): void;
289
+ static showErrorMessage(message: string, title?: string, placement?: NotificationPlacement): void;
244
290
 
245
291
  /**
246
- * Displays error message
292
+ * Displays danger\error message
247
293
  *
248
- * @param messageHtml Error message
294
+ * @param messageHtml Danger\Error message
249
295
  * @param title Title of the message
250
296
  */
251
- static showErrorMessage(messageHtml: string, title?: string): void {
297
+ static showErrorMessage(
298
+ messageHtml: string,
299
+ titleOrPlacement?: string | NotificationPlacement,
300
+ placement?: NotificationPlacement,
301
+ ): void {
302
+ const resolvedTitle = typeof titleOrPlacement === 'string' ? titleOrPlacement : undefined;
303
+ const resolvedPlacement = typeof titleOrPlacement === 'number' ? titleOrPlacement : placement;
304
+
252
305
  NotificationUtils.show({
253
306
  messageHtml,
254
- title,
307
+ title: resolvedTitle,
255
308
  icon: NotificationIcon.Exclamation,
256
- type: NotificationType.Error,
309
+ type: NotificationType.Danger,
310
+ placement: resolvedPlacement ?? NotificationPlacement.TopCenter,
257
311
  });
258
312
  }
259
313
 
@@ -261,8 +315,10 @@ export default class NotificationProvider {
261
315
  * Displays success message
262
316
  *
263
317
  * @param message Success message
318
+ //
264
319
  */
265
- static showSuccessMessage(message: string): void;
320
+ static showSuccessMessage(message: string, placement?: NotificationPlacement): void;
321
+ static showSuccessMessage(message: string, title?: string, placement?: NotificationPlacement): void;
266
322
 
267
323
  /**
268
324
  * Displays success message
@@ -270,12 +326,45 @@ export default class NotificationProvider {
270
326
  * @param messageHtml Success message
271
327
  * @param title Title of the message
272
328
  */
273
- static showSuccessMessage(messageHtml: string, title?: string): void {
329
+ static showSuccessMessage(
330
+ messageHtml: string,
331
+ titleOrPlacement?: string | NotificationPlacement,
332
+ placement?: NotificationPlacement,
333
+ ): void {
334
+ const resolvedTitle = typeof titleOrPlacement === 'string' ? titleOrPlacement : undefined;
335
+ const resolvedPlacement = typeof titleOrPlacement === 'number' ? titleOrPlacement : placement;
336
+
274
337
  NotificationUtils.show({
275
338
  messageHtml,
276
- title,
339
+ title: resolvedTitle,
277
340
  icon: NotificationIcon.Checkmark,
278
341
  type: NotificationType.Success,
342
+ placement: resolvedPlacement ?? NotificationPlacement.TopCenter,
343
+ });
344
+ }
345
+
346
+ /**
347
+ * Displays warning message
348
+ *
349
+ * @param messageHtml Success message
350
+ * @param title Title of the message
351
+ */
352
+ static showWarningMessage(message: string, placement?: NotificationPlacement): void;
353
+ static showWarningMessage(message: string, title?: string, placement?: NotificationPlacement): void;
354
+ static showWarningMessage(
355
+ messageHtml: string,
356
+ titleOrPlacement?: string | NotificationPlacement,
357
+ placement?: NotificationPlacement,
358
+ ): void {
359
+ const resolvedTitle = typeof titleOrPlacement === 'string' ? titleOrPlacement : undefined;
360
+ const resolvedPlacement = typeof titleOrPlacement === 'number' ? titleOrPlacement : placement;
361
+
362
+ NotificationUtils.show({
363
+ messageHtml,
364
+ title: resolvedTitle,
365
+ icon: NotificationIcon.Exclamation,
366
+ type: NotificationType.Warning,
367
+ placement: resolvedPlacement ?? NotificationPlacement.TopRight,
279
368
  });
280
369
  }
281
370
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.207",
4
+ "version": "0.0.209",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",