@pallasoft/ps-file-components 2.4.1 → 2.4.2
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.
|
@@ -21,6 +21,7 @@ const PsFilePicker = ({ accept, acceptLabel, className, disabled = false, dropLa
|
|
|
21
21
|
const rowLabels = { ...ps_upload_labels_1.PsUploadLabels, ...uploadLabels };
|
|
22
22
|
const details = [acceptLabel, maxSizeLabel].filter((value) => value !== undefined && value !== '');
|
|
23
23
|
const chooseLabel = multiple ? text.choose : text.chooseOne;
|
|
24
|
+
const dragHint = multiple ? text.dragHint : text.dragHintOne;
|
|
24
25
|
const scanLabel = scan === undefined ? undefined : text.scan;
|
|
25
26
|
if (isLoading)
|
|
26
27
|
return ((0, jsx_runtime_1.jsx)("span", { "aria-busy": 'true', className: ps_design_system_1.PallasoftClassNameService.merge('ps-skeleton block min-h-48 w-full rounded-ps-control', className), role: 'status' }));
|
|
@@ -67,6 +68,6 @@ const PsFilePicker = ({ accept, acceptLabel, className, disabled = false, dropLa
|
|
|
67
68
|
select(event.dataTransfer.files);
|
|
68
69
|
}, children: [(0, jsx_runtime_1.jsx)("span", { "aria-hidden": 'true', className: ps_design_system_1.PallasoftClassNameService.merge('flex size-12 items-center justify-center rounded-full transition-colors duration-200', isDragging
|
|
69
70
|
? 'bg-primary text-[color:var(--ps-color-primary-contrast)]'
|
|
70
|
-
: 'bg-primary-soft text-primary'), children: (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { className: 'size-6', iconKey: ps_icons_1.PsIconKey.Upload }) }), (0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col gap-1', children: [(0, jsx_runtime_1.jsx)("p", { className: 'text-base font-semibold text-ink', children: isDragging ? (text.dropActive) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: touchLabel === undefined ? '' : '[@media(pointer:coarse)]:hidden', children: dropLabel }), touchLabel === undefined ? null : ((0, jsx_runtime_1.jsx)("span", { className: 'hidden [@media(pointer:coarse)]:inline', children: touchLabel }))] })) }), (0, jsx_runtime_1.jsx)("p", { className: 'text-sm text-ink/60 [@media(pointer:coarse)]:hidden', children:
|
|
71
|
+
: 'bg-primary-soft text-primary'), children: (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { className: 'size-6', iconKey: ps_icons_1.PsIconKey.Upload }) }), (0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col gap-1', children: [(0, jsx_runtime_1.jsx)("p", { className: 'text-base font-semibold text-ink', children: isDragging ? (text.dropActive) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: touchLabel === undefined ? '' : '[@media(pointer:coarse)]:hidden', children: dropLabel }), touchLabel === undefined ? null : ((0, jsx_runtime_1.jsx)("span", { className: 'hidden [@media(pointer:coarse)]:inline', children: touchLabel }))] })) }), dragHint === '' ? null : ((0, jsx_runtime_1.jsx)("p", { className: 'text-sm text-ink/60 [@media(pointer:coarse)]:hidden', children: dragHint }))] }), (0, jsx_runtime_1.jsx)(ps_file_picker_actions_1.PsFilePickerActions, { chooseLabel: chooseLabel, className: 'flex [@media(pointer:coarse)]:hidden', disabled: disabled, isTouch: false, onChoose: browse, onScan: openScan, scanLabel: scanLabel }), (0, jsx_runtime_1.jsx)(ps_file_picker_actions_1.PsFilePickerActions, { chooseLabel: chooseLabel, className: 'hidden [@media(pointer:coarse)]:flex', disabled: disabled, isTouch: true, onChoose: browse, onScan: openScan, scanLabel: scanLabel }), details.length > 0 ? (0, jsx_runtime_1.jsx)("p", { className: 'text-xs text-muted', children: details.join(' · ') }) : null, (0, jsx_runtime_1.jsx)("input", { accept: acceptAttr, "aria-hidden": 'true', className: 'sr-only', disabled: disabled, multiple: multiple, onChange: onChange, onClick: (event) => event.stopPropagation(), ref: input, tabIndex: -1, type: 'file' })] }), queue === undefined || queue.items.length === 0 ? null : ((0, jsx_runtime_1.jsx)("ul", { "aria-label": rowLabels.title, className: 'flex flex-col gap-2', children: queue.items.map((item) => ((0, jsx_runtime_1.jsx)(ps_upload_row_1.PsUploadRow, { item: item, labels: rowLabels, onCancel: () => queue.cancel(item.id), onRemove: () => queue.remove(item.id), onRetry: () => queue.retry(item.id) }, item.id))) })), scan === undefined ? null : ((0, jsx_runtime_1.jsx)(ps_document_scanner_1.PsDocumentScanner, { ...scan, fileName: scanName === null ? ps_scan_config_1.PsScanConfig.defaultFileName : scanName, isOpen: scanName !== null, onClose: () => setScanName(null), onComplete: select }))] }));
|
|
71
72
|
};
|
|
72
73
|
exports.PsFilePicker = PsFilePicker;
|
|
@@ -18,6 +18,7 @@ export const PsFilePicker = ({ accept, acceptLabel, className, disabled = false,
|
|
|
18
18
|
const rowLabels = { ...PsUploadLabels, ...uploadLabels };
|
|
19
19
|
const details = [acceptLabel, maxSizeLabel].filter((value) => value !== undefined && value !== '');
|
|
20
20
|
const chooseLabel = multiple ? text.choose : text.chooseOne;
|
|
21
|
+
const dragHint = multiple ? text.dragHint : text.dragHintOne;
|
|
21
22
|
const scanLabel = scan === undefined ? undefined : text.scan;
|
|
22
23
|
if (isLoading)
|
|
23
24
|
return (_jsx("span", { "aria-busy": 'true', className: PallasoftClassNameService.merge('ps-skeleton block min-h-48 w-full rounded-ps-control', className), role: 'status' }));
|
|
@@ -64,5 +65,5 @@ export const PsFilePicker = ({ accept, acceptLabel, className, disabled = false,
|
|
|
64
65
|
select(event.dataTransfer.files);
|
|
65
66
|
}, children: [_jsx("span", { "aria-hidden": 'true', className: PallasoftClassNameService.merge('flex size-12 items-center justify-center rounded-full transition-colors duration-200', isDragging
|
|
66
67
|
? 'bg-primary text-[color:var(--ps-color-primary-contrast)]'
|
|
67
|
-
: 'bg-primary-soft text-primary'), children: _jsx(PsIcon, { className: 'size-6', iconKey: PsIconKey.Upload }) }), _jsxs("div", { className: 'flex flex-col gap-1', children: [_jsx("p", { className: 'text-base font-semibold text-ink', children: isDragging ? (text.dropActive) : (_jsxs(_Fragment, { children: [_jsx("span", { className: touchLabel === undefined ? '' : '[@media(pointer:coarse)]:hidden', children: dropLabel }), touchLabel === undefined ? null : (_jsx("span", { className: 'hidden [@media(pointer:coarse)]:inline', children: touchLabel }))] })) }), _jsx("p", { className: 'text-sm text-ink/60 [@media(pointer:coarse)]:hidden', children:
|
|
68
|
+
: 'bg-primary-soft text-primary'), children: _jsx(PsIcon, { className: 'size-6', iconKey: PsIconKey.Upload }) }), _jsxs("div", { className: 'flex flex-col gap-1', children: [_jsx("p", { className: 'text-base font-semibold text-ink', children: isDragging ? (text.dropActive) : (_jsxs(_Fragment, { children: [_jsx("span", { className: touchLabel === undefined ? '' : '[@media(pointer:coarse)]:hidden', children: dropLabel }), touchLabel === undefined ? null : (_jsx("span", { className: 'hidden [@media(pointer:coarse)]:inline', children: touchLabel }))] })) }), dragHint === '' ? null : (_jsx("p", { className: 'text-sm text-ink/60 [@media(pointer:coarse)]:hidden', children: dragHint }))] }), _jsx(PsFilePickerActions, { chooseLabel: chooseLabel, className: 'flex [@media(pointer:coarse)]:hidden', disabled: disabled, isTouch: false, onChoose: browse, onScan: openScan, scanLabel: scanLabel }), _jsx(PsFilePickerActions, { chooseLabel: chooseLabel, className: 'hidden [@media(pointer:coarse)]:flex', disabled: disabled, isTouch: true, onChoose: browse, onScan: openScan, scanLabel: scanLabel }), details.length > 0 ? _jsx("p", { className: 'text-xs text-muted', children: details.join(' · ') }) : null, _jsx("input", { accept: acceptAttr, "aria-hidden": 'true', className: 'sr-only', disabled: disabled, multiple: multiple, onChange: onChange, onClick: (event) => event.stopPropagation(), ref: input, tabIndex: -1, type: 'file' })] }), queue === undefined || queue.items.length === 0 ? null : (_jsx("ul", { "aria-label": rowLabels.title, className: 'flex flex-col gap-2', children: queue.items.map((item) => (_jsx(PsUploadRow, { item: item, labels: rowLabels, onCancel: () => queue.cancel(item.id), onRemove: () => queue.remove(item.id), onRetry: () => queue.retry(item.id) }, item.id))) })), scan === undefined ? null : (_jsx(PsDocumentScanner, { ...scan, fileName: scanName === null ? PsScanConfig.defaultFileName : scanName, isOpen: scanName !== null, onClose: () => setScanName(null), onComplete: select }))] }));
|
|
68
69
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Common } from '@pallasoft/ps-utilities';
|
|
1
2
|
import { PsUploadMessages } from '../constants/ps-upload-messages';
|
|
2
3
|
export class PsXhrUploadService {
|
|
3
4
|
static parse(text) {
|
|
@@ -36,7 +37,7 @@ export class PsXhrUploadService {
|
|
|
36
37
|
if (xhr.status >= 200 && xhr.status < 300)
|
|
37
38
|
resolve({ body, contentType: xhr.getResponseHeader('content-type'), status: xhr.status });
|
|
38
39
|
else
|
|
39
|
-
reject(
|
|
40
|
+
reject(Common.ErrorResponseService.create(PsXhrUploadService.errorMessage(body), xhr.status));
|
|
40
41
|
};
|
|
41
42
|
xhr.onerror = () => reject(new Error(PsUploadMessages.failed));
|
|
42
43
|
xhr.onabort = () => reject(new Error(PsUploadMessages.cancelled));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PsXhrUploadService = void 0;
|
|
4
|
+
const ps_utilities_1 = require("@pallasoft/ps-utilities");
|
|
4
5
|
const ps_upload_messages_1 = require("../constants/ps-upload-messages");
|
|
5
6
|
class PsXhrUploadService {
|
|
6
7
|
static parse(text) {
|
|
@@ -39,7 +40,7 @@ class PsXhrUploadService {
|
|
|
39
40
|
if (xhr.status >= 200 && xhr.status < 300)
|
|
40
41
|
resolve({ body, contentType: xhr.getResponseHeader('content-type'), status: xhr.status });
|
|
41
42
|
else
|
|
42
|
-
reject(
|
|
43
|
+
reject(ps_utilities_1.Common.ErrorResponseService.create(PsXhrUploadService.errorMessage(body), xhr.status));
|
|
43
44
|
};
|
|
44
45
|
xhr.onerror = () => reject(new Error(ps_upload_messages_1.PsUploadMessages.failed));
|
|
45
46
|
xhr.onabort = () => reject(new Error(ps_upload_messages_1.PsUploadMessages.cancelled));
|