@pushwoosh/websdk-common 6.22.1 → 6.22.3

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,4 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import { type InboxCellPreviewProps } from './types';
3
- /** One inbox cell drawn the way the SDK of `platform` draws it; the web skin is the WebSDK widget cell itself. */
3
+ /** One inbox cell drawn the way the SDK of `platform` draws it; the web skin is the WebSDK widget cell itself. A known layout is kept as chosen, with placeholders for its missing media. */
4
4
  export declare function InboxCellPreview(props: InboxCellPreviewProps): ReactElement;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
- import { INBOX_WIDGET_CSS } from './constants';
4
- import { formatInboxMessageTime, getInboxEmptyLayout, getInboxHeroUrl, getInboxIconInitial, getInboxMobileTexts, getInboxValidSlides, isInboxContentEmpty, resolveInboxLayout, resolveInboxWidgetAppearance } from './helpers';
3
+ import { INBOX_KNOWN_LAYOUTS, INBOX_WIDGET_CSS } from './constants';
4
+ import { formatInboxMessageTime, getInboxHeroUrl, getInboxIconInitial, getInboxMobileTexts, getInboxValidSlides, isInboxContentEmpty, resolveInboxLayout, resolveInboxWidgetAppearance } from './helpers';
5
5
  import { InboxWebCell, inboxWidgetPreviewFrame } from './InboxWidgetReader';
6
6
  const MAIN = '#4B5057';
7
7
  const LOCKED = '#767C82';
@@ -195,12 +195,15 @@ function Carousel({
195
195
  })]
196
196
  });
197
197
  }
198
+ function hasMedia(content, layout) {
199
+ return layout === 'carousel' ? getInboxValidSlides(content.carousel).length > 0 : !!getInboxHeroUrl(content);
200
+ }
198
201
  function Media({
199
202
  content,
200
203
  layout,
201
204
  isEmpty
202
205
  }) {
203
- if (isEmpty) {
206
+ if (isEmpty || !hasMedia(content, layout)) {
204
207
  return _jsx("div", {
205
208
  style: {
206
209
  aspectRatio: '2 / 1',
@@ -252,24 +255,23 @@ function IOSCell(props) {
252
255
  children: [_jsxs("div", {
253
256
  style: {
254
257
  display: 'flex',
255
- alignItems: 'center'
258
+ alignItems: 'center',
259
+ gap: 4
256
260
  },
257
261
  children: [_jsx("div", {
258
262
  style: {
259
263
  ...TEXT.h5,
260
264
  ...ELLIPSIS,
265
+ flex: 1,
266
+ minWidth: 0,
261
267
  color: MAIN
262
268
  },
263
269
  children: title
264
- }), _jsx("div", {
265
- style: {
266
- flex: 1,
267
- minWidth: 4
268
- }
269
270
  }), _jsx("div", {
270
271
  style: {
271
272
  ...TEXT.footnote,
272
- ...ELLIPSIS,
273
+ flexShrink: 0,
274
+ whiteSpace: 'nowrap',
273
275
  color: LOCKED
274
276
  },
275
277
  children: dateLabel
@@ -277,7 +279,7 @@ function IOSCell(props) {
277
279
  }), !!body && _jsx("div", {
278
280
  style: {
279
281
  ...TEXT.footnote,
280
- ...clamp(layout === 'classic' ? 3 : 2),
282
+ ...(layout === 'classic' && clamp(3)),
281
283
  color: LOCKED
282
284
  },
283
285
  children: body
@@ -372,11 +374,20 @@ function AndroidCell(props) {
372
374
  children: [_jsxs("div", {
373
375
  style: {
374
376
  ...TEXT.footnote,
375
- ...ELLIPSIS,
376
- color: unread ? MAIN : LOCKED
377
+ display: 'flex',
378
+ gap: 4
377
379
  },
378
- children: [title, ' ', _jsx("span", {
380
+ children: [_jsx("span", {
379
381
  style: {
382
+ ...ELLIPSIS,
383
+ minWidth: 0,
384
+ color: unread ? MAIN : LOCKED
385
+ },
386
+ children: title
387
+ }), _jsx("span", {
388
+ style: {
389
+ flexShrink: 0,
390
+ whiteSpace: 'nowrap',
380
391
  color: LOCKED
381
392
  },
382
393
  children: dateLabel
@@ -416,7 +427,7 @@ function AndroidCell(props) {
416
427
  }), layout !== 'banner' && texts]
417
428
  });
418
429
  }
419
- /** One inbox cell drawn the way the SDK of `platform` draws it; the web skin is the WebSDK widget cell itself. */
430
+ /** One inbox cell drawn the way the SDK of `platform` draws it; the web skin is the WebSDK widget cell itself. A known layout is kept as chosen, with placeholders for its missing media. */
420
431
  export function InboxCellPreview(props) {
421
432
  const {
422
433
  platform = 'ios',
@@ -450,7 +461,13 @@ export function InboxCellPreview(props) {
450
461
  }
451
462
  const picked = content || {};
452
463
  const isEmpty = isInboxContentEmpty(picked);
453
- const layout = isEmpty ? getInboxEmptyLayout(picked) : resolveInboxLayout(picked);
464
+ const requested = picked.layoutType;
465
+ let layout = 'classic';
466
+ if (INBOX_KNOWN_LAYOUTS.includes(requested)) {
467
+ layout = requested;
468
+ } else if (!isEmpty) {
469
+ layout = resolveInboxLayout(picked);
470
+ }
454
471
  if (platform === 'web') {
455
472
  const appearance = resolveInboxWidgetAppearance(props.appearance);
456
473
  const widget = inboxWidgetPreviewFrame(appearance, 'pw-inbox-widget--cell');
@@ -472,7 +489,7 @@ export function InboxCellPreview(props) {
472
489
  isActionPerformed: !unread,
473
490
  isRead: !unread,
474
491
  layout: layout,
475
- placeholder: isEmpty,
492
+ placeholder: isEmpty || layout !== 'classic' && !hasMedia(picked, layout),
476
493
  timeLabel: formatInboxMessageTime(sendDate || new Date().toISOString()),
477
494
  title: isEmpty ? emptyTitle : picked.title
478
495
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/websdk-common",
3
- "version": "6.22.1",
3
+ "version": "6.22.3",
4
4
  "description": "Code shared by the Pushwoosh WebSDK and the Control Panel, one entry point per module (web-popups: web popup model and renderer; subscription-widget: push subscription widget model and renderer; inbox: web inbox widget and inbox cell previews)",
5
5
  "main": "index.js",
6
6
  "module": "index.js",