inviton-powerduck 0.0.331 → 0.0.333

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.
@@ -37,6 +37,7 @@ export interface IPowerduckSystemResources {
37
37
  fileDownloadTitle: string;
38
38
  imageCrop: string;
39
39
  uploadImage: string;
40
+ uploadFailed: string;
40
41
  copyToClipboard: string;
41
42
  copyToClipboardSuccess: string;
42
43
  loginExpired: string;
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable func-style */
2
+ import { Temporal } from '@js-temporal/polyfill';
2
3
  import PowerduckState from '../../app/powerduck-state';
3
4
 
4
5
  export const toDisplayString = Symbol('toDisplayString');
@@ -3,16 +3,32 @@ import PowerduckState from '../../app/powerduck-state';
3
3
  import { AppHttpProvider } from '../api-http';
4
4
  import { DomainHelper } from './domain-helper';
5
5
 
6
+ const ABSOLUTE_URL_RE = /^https?:\/\//i;
7
+ const LEADING_SLASH_ABSOLUTE_RE = /^\/https?:\/\//i;
8
+
6
9
  export default class FileHelper {
7
10
  static getFullPath(file: Photo) {
8
- if (file == null) {
11
+ if (file == null || file.path == null) {
9
12
  return null;
10
13
  }
11
14
 
15
+ const rawPath = file.path.trim();
16
+
17
+ // 1. Already-absolute URL (Bunny CDN, S3, data:, protocol-relative) — return as-is.
18
+ if (ABSOLUTE_URL_RE.test(rawPath) || rawPath.startsWith('//') || rawPath.startsWith('data:')) {
19
+ return rawPath;
20
+ }
21
+
22
+ // 2. Stray leading-slash before scheme ("/https://..."): strip the slash.
23
+ if (LEADING_SLASH_ABSOLUTE_RE.test(rawPath)) {
24
+ return rawPath.slice(1);
25
+ }
26
+
27
+ // 3. Legacy relative path (e.g. "/photos/resorts/file.png") — resolve against backend domain.
12
28
  if (AppHttpProvider.enforceDomain == '/') {
13
- return PowerduckState.getCdnPath() + PowerduckState.getFilesPath() + file.path;
29
+ return PowerduckState.getCdnPath() + PowerduckState.getFilesPath() + rawPath;
14
30
  }
15
31
 
16
- return DomainHelper.getDomainFromUrl(AppHttpProvider.enforceDomain, true) + PowerduckState.getFilesPath() + file.path;
32
+ return DomainHelper.getDomainFromUrl(AppHttpProvider.enforceDomain, true) + PowerduckState.getFilesPath() + rawPath;
17
33
  }
18
34
  }
@@ -1,3 +1,4 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
1
2
  import { isNullOrEmpty } from './is-null-or-empty';
2
3
 
3
4
  const isDigit = (c: string): boolean => c >= '0' && c <= '9';
@@ -1,6 +1,7 @@
1
1
  import type { ImageResponse, OnUploadImageResponse } from '../../data/image';
2
2
  import { globalState } from '../../app/global-state';
3
3
  import PowerduckState from '../../app/powerduck-state';
4
+ import NotificationProvider from '../../components/ui/notification';
4
5
  import { AppHttpProvider } from '../api-http';
5
6
  import { BrowserImageCompression } from './broswer-image-compression';
6
7
  import { isNullOrEmpty } from './is-null-or-empty';
@@ -25,7 +26,7 @@ export class UploadImageHelper {
25
26
  disableCompression: boolean = false,
26
27
  compressionMaxMb: number = 0.5,
27
28
  url?: string,
28
- ): Promise<ImageResponse> {
29
+ ): Promise<ImageResponse | null> {
29
30
  if (!(disableCompression || file.type == 'image/svg+xml')) {
30
31
  file = await BrowserImageCompression.compress(file, {
31
32
  maxSizeMB: compressionMaxMb,
@@ -49,6 +50,12 @@ export class UploadImageHelper {
49
50
  credentials: UploadImageHelperConfig.includeCredentials ? PowerduckState.getIsDebugMode() ? 'include' : 'same-origin' : 'omit',
50
51
  });
51
52
 
53
+ if (!response.ok) {
54
+ NotificationProvider.showErrorMessage(PowerduckState.getResourceValue('uploadFailed'));
55
+
56
+ return null;
57
+ }
58
+
52
59
  return (await response.json()) as ImageResponse;
53
60
  }
54
61
 
@@ -10,7 +10,11 @@
10
10
  position: relative;
11
11
  }
12
12
 
13
- .dt-table.dt-table-mode table {
13
+ /* Direct-child selector — without `>`, this rule leaks into any nested
14
+ <table> inside a cell (e.g. the date-range picker's month tables), forcing
15
+ them to min-width: 100% of the DataTable container and breaking their
16
+ layout. Only the DataTable's own root <table> needs this styling. */
17
+ .dt-table.dt-table-mode > table {
14
18
  position: relative;
15
19
  border-collapse: collapse;
16
20
  min-width: 100%;