@jobber/components 6.56.0 → 6.57.0
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.
- package/Thumbnail.d.ts +1 -0
- package/Thumbnail.js +17 -0
- package/dist/DatePicker/DatePickerActivator.d.ts +3 -2
- package/dist/DatePicker-cjs.js +1 -2
- package/dist/DatePicker-es.js +2 -2
- package/dist/FormatFile/FormatFile.d.ts +40 -27
- package/dist/FormatFile/index.cjs +10 -7
- package/dist/FormatFile/index.d.ts +3 -0
- package/dist/FormatFile/index.mjs +9 -8
- package/dist/FormatFile/types.d.ts +27 -0
- package/dist/FormatFile/useFormatFile.d.ts +5 -0
- package/dist/FormatFile/useFormatFileStyles.d.ts +10 -0
- package/dist/FormatFile-cjs.js +94 -131
- package/dist/FormatFile-es.js +94 -132
- package/dist/Gallery/index.cjs +4 -3
- package/dist/Gallery/index.mjs +4 -3
- package/dist/Gallery-cjs.js +3 -1
- package/dist/Gallery-es.js +3 -1
- package/dist/InputDate/index.cjs +5 -9
- package/dist/InputDate/index.mjs +6 -10
- package/dist/Thumbnail/Thumbnail.d.ts +25 -0
- package/dist/Thumbnail/ThumbnailImage.d.ts +23 -0
- package/dist/Thumbnail/index.cjs +15 -0
- package/dist/Thumbnail/index.d.ts +1 -0
- package/dist/Thumbnail/index.mjs +9 -0
- package/dist/Thumbnail-cjs.js +103 -0
- package/dist/Thumbnail-es.js +100 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +2 -1
- package/dist/styles.css +1581 -1581
- package/dist/utils/meta/meta.json +8 -0
- package/package.json +7 -2
- package/dist/FormatFile/FormatFileDeleteButton.d.ts +0 -6
- package/dist/FormatFile/InternalThumbnail.d.ts +0 -8
- package/dist/FormatFile/InternalThumbnailImage.d.ts +0 -6
package/Thumbnail.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist/Thumbnail";
|
package/Thumbnail.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var Thumbnail = require("./dist/Thumbnail");
|
|
8
|
+
|
|
9
|
+
Object.keys(Thumbnail).forEach(function(key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
Object.defineProperty(exports, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return Thumbnail[key];
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { ChangeEvent, ReactElement } from "react";
|
|
2
|
-
import { ReactDatePickerProps } from "react-datepicker";
|
|
1
|
+
import React, { ChangeEvent, ReactElement, RefObject } from "react";
|
|
2
|
+
import ReactDatePicker, { ReactDatePickerProps } from "react-datepicker";
|
|
3
3
|
export interface DatePickerActivatorProps extends Pick<ReactDatePickerProps, "value" | "id" | "ariaDescribedBy" | "ariaInvalid" | "ariaLabelledBy" | "ariaRequired"> {
|
|
4
4
|
readonly activator?: ReactElement | ((props: DatePickerActivatorProps) => ReactElement);
|
|
5
5
|
readonly fullWidth?: boolean;
|
|
@@ -8,5 +8,6 @@ export interface DatePickerActivatorProps extends Pick<ReactDatePickerProps, "va
|
|
|
8
8
|
onClick?(): void;
|
|
9
9
|
onFocus?(): void;
|
|
10
10
|
onKeyDown?(): void;
|
|
11
|
+
readonly pickerRef: RefObject<ReactDatePicker>;
|
|
11
12
|
}
|
|
12
13
|
export declare const DatePickerActivator: React.ForwardRefExoticComponent<DatePickerActivatorProps & React.RefAttributes<HTMLElement>>;
|
package/dist/DatePicker-cjs.js
CHANGED
|
@@ -7317,7 +7317,7 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
|
|
|
7317
7317
|
React.useEffect(focusOnSelectedDate, [open]);
|
|
7318
7318
|
}
|
|
7319
7319
|
return (React.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated" },
|
|
7320
|
-
React.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
|
|
7320
|
+
React.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React.createElement(DatePickerActivator, { pickerRef: pickerRef, activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
|
|
7321
7321
|
dateFormat,
|
|
7322
7322
|
"P",
|
|
7323
7323
|
"PP",
|
|
@@ -7368,5 +7368,4 @@ function useEscapeKeyToCloseDatePicker(open, ref) {
|
|
|
7368
7368
|
}
|
|
7369
7369
|
|
|
7370
7370
|
exports.DatePicker = DatePicker;
|
|
7371
|
-
exports.format = format;
|
|
7372
7371
|
exports.isValid = isValid;
|
package/dist/DatePicker-es.js
CHANGED
|
@@ -7315,7 +7315,7 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
|
|
|
7315
7315
|
useEffect(focusOnSelectedDate, [open]);
|
|
7316
7316
|
}
|
|
7317
7317
|
return (React__default.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated" },
|
|
7318
|
-
React__default.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React__default.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
|
|
7318
|
+
React__default.createElement(Ht, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React__default.createElement(DatePickerActivator, { pickerRef: pickerRef, activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
|
|
7319
7319
|
dateFormat,
|
|
7320
7320
|
"P",
|
|
7321
7321
|
"PP",
|
|
@@ -7365,4 +7365,4 @@ function useEscapeKeyToCloseDatePicker(open, ref) {
|
|
|
7365
7365
|
};
|
|
7366
7366
|
}
|
|
7367
7367
|
|
|
7368
|
-
export { DatePicker as D,
|
|
7368
|
+
export { DatePicker as D, isValid as i };
|
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { FormatFileProps } from "./types";
|
|
2
3
|
import { FileUpload } from "../InputFile";
|
|
3
|
-
interface FormatFileProps {
|
|
4
|
-
/**
|
|
5
|
-
* File upload details object. (See FileUpload type.)
|
|
6
|
-
*/
|
|
7
|
-
readonly file: FileUpload;
|
|
8
|
-
/**
|
|
9
|
-
* To display as either a file row or thumbnail
|
|
10
|
-
*
|
|
11
|
-
* @default "expanded"
|
|
12
|
-
*/
|
|
13
|
-
readonly display?: "expanded" | "compact";
|
|
14
|
-
/**
|
|
15
|
-
* The base dimensions of the thumbnail
|
|
16
|
-
*
|
|
17
|
-
* @default "base"
|
|
18
|
-
*/
|
|
19
|
-
readonly displaySize?: "base" | "large";
|
|
20
|
-
/**
|
|
21
|
-
* Function to execute when format file is clicked
|
|
22
|
-
*/
|
|
23
|
-
onClick?(event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>): void;
|
|
24
|
-
/**
|
|
25
|
-
* onDelete callback - this function will be called when the delete action is triggered
|
|
26
|
-
*/
|
|
27
|
-
onDelete?(): void;
|
|
28
|
-
}
|
|
29
4
|
export declare function FormatFile({ file, display, displaySize, onDelete, onClick, }: FormatFileProps): JSX.Element;
|
|
30
|
-
export {
|
|
5
|
+
export declare namespace FormatFile {
|
|
6
|
+
var DeleteButtonContainer: ({ children, className, isHidden, }: {
|
|
7
|
+
readonly children: React.ReactNode;
|
|
8
|
+
readonly className?: string;
|
|
9
|
+
readonly isHidden?: boolean;
|
|
10
|
+
}) => JSX.Element | null;
|
|
11
|
+
var ProgressContainer: ({ isHidden, children, className, }: {
|
|
12
|
+
readonly children: React.ReactNode;
|
|
13
|
+
readonly className?: string;
|
|
14
|
+
readonly isHidden?: boolean;
|
|
15
|
+
}) => JSX.Element | null;
|
|
16
|
+
var ThumbnailContainer: ({ children, className, }: {
|
|
17
|
+
readonly children: React.ReactNode;
|
|
18
|
+
readonly className?: string;
|
|
19
|
+
}) => JSX.Element;
|
|
20
|
+
var Body: ({ children, className, type, onClick, tabIndex, ariaBusy, isComplete, }: {
|
|
21
|
+
readonly children: React.ReactNode;
|
|
22
|
+
readonly className?: string;
|
|
23
|
+
readonly type?: "button" | "submit" | "reset";
|
|
24
|
+
readonly onClick?: React.MouseEventHandler<HTMLButtonElement | HTMLDivElement>;
|
|
25
|
+
readonly tabIndex?: number;
|
|
26
|
+
readonly ariaBusy?: boolean;
|
|
27
|
+
readonly isComplete: boolean;
|
|
28
|
+
}) => JSX.Element;
|
|
29
|
+
var Expanded: ({ file, fileSize, isVisible, }: {
|
|
30
|
+
readonly file: FileUpload;
|
|
31
|
+
readonly fileSize: string;
|
|
32
|
+
readonly isVisible: boolean;
|
|
33
|
+
}) => JSX.Element | null;
|
|
34
|
+
var Wrapper: ({ children, className, }: {
|
|
35
|
+
readonly children: React.ReactNode;
|
|
36
|
+
readonly className?: string;
|
|
37
|
+
}) => JSX.Element;
|
|
38
|
+
var DeleteButton: ({ onDelete, size, children, }: {
|
|
39
|
+
readonly onDelete?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
40
|
+
readonly size?: "base" | "large";
|
|
41
|
+
readonly children?: React.ReactNode;
|
|
42
|
+
}) => JSX.Element;
|
|
43
|
+
}
|
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var FormatFile = require('../FormatFile-cjs.js');
|
|
4
4
|
require('react');
|
|
5
|
-
require('classnames');
|
|
6
5
|
require('filesize');
|
|
7
|
-
require('
|
|
8
|
-
require('
|
|
6
|
+
require('classnames');
|
|
7
|
+
require('../Thumbnail-cjs.js');
|
|
8
|
+
require('../Glimmer-cjs.js');
|
|
9
9
|
require('../tslib.es6-cjs.js');
|
|
10
|
+
require('../Content-cjs.js');
|
|
10
11
|
require('../Icon-cjs.js');
|
|
11
12
|
require('@jobber/design');
|
|
12
13
|
require('../Typography-cjs.js');
|
|
14
|
+
require('../Text-cjs.js');
|
|
15
|
+
require('../ProgressBar-cjs.js');
|
|
16
|
+
require('../Button-cjs.js');
|
|
17
|
+
require('react-router-dom');
|
|
13
18
|
require('../ConfirmationModal-cjs.js');
|
|
14
19
|
require('../useOnKeyDown-cjs.js');
|
|
15
20
|
require('../Modal/index.cjs');
|
|
@@ -32,14 +37,12 @@ require('../_baseFor-cjs.js');
|
|
|
32
37
|
require('../keysIn-cjs.js');
|
|
33
38
|
require('../_isIterateeCall-cjs.js');
|
|
34
39
|
require('../_setToString-cjs.js');
|
|
35
|
-
require('../Content-cjs.js');
|
|
36
40
|
require('../Markdown-cjs.js');
|
|
37
|
-
require('../Text-cjs.js');
|
|
38
41
|
require('../Emphasis-cjs.js');
|
|
39
42
|
require('../index-cjs.js');
|
|
40
|
-
require('../Glimmer-cjs.js');
|
|
41
|
-
require('../ProgressBar-cjs.js');
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
exports.FormatFile = FormatFile.FormatFile;
|
|
47
|
+
exports.useFormatFile = FormatFile.useFormatFile;
|
|
48
|
+
exports.useFormatFileStyles = FormatFile.useFormatFileStyles;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
export { F as FormatFile } from '../FormatFile-es.js';
|
|
1
|
+
export { F as FormatFile, u as useFormatFile, a as useFormatFileStyles } from '../FormatFile-es.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import 'classnames';
|
|
4
3
|
import 'filesize';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import 'classnames';
|
|
5
|
+
import '../Thumbnail-es.js';
|
|
6
|
+
import '../Glimmer-es.js';
|
|
7
7
|
import '../tslib.es6-es.js';
|
|
8
|
+
import '../Content-es.js';
|
|
8
9
|
import '../Icon-es.js';
|
|
9
10
|
import '@jobber/design';
|
|
10
11
|
import '../Typography-es.js';
|
|
12
|
+
import '../Text-es.js';
|
|
13
|
+
import '../ProgressBar-es.js';
|
|
14
|
+
import '../Button-es.js';
|
|
15
|
+
import 'react-router-dom';
|
|
11
16
|
import '../ConfirmationModal-es.js';
|
|
12
17
|
import '../useOnKeyDown-es.js';
|
|
13
18
|
import '../Modal/index.mjs';
|
|
@@ -30,10 +35,6 @@ import '../_baseFor-es.js';
|
|
|
30
35
|
import '../keysIn-es.js';
|
|
31
36
|
import '../_isIterateeCall-es.js';
|
|
32
37
|
import '../_setToString-es.js';
|
|
33
|
-
import '../Content-es.js';
|
|
34
38
|
import '../Markdown-es.js';
|
|
35
|
-
import '../Text-es.js';
|
|
36
39
|
import '../Emphasis-es.js';
|
|
37
40
|
import '../index-es.js';
|
|
38
|
-
import '../Glimmer-es.js';
|
|
39
|
-
import '../ProgressBar-es.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FileUpload } from "../InputFile";
|
|
2
|
+
export interface FormatFileProps {
|
|
3
|
+
/**
|
|
4
|
+
* File upload details object. (See FileUpload type.)
|
|
5
|
+
*/
|
|
6
|
+
readonly file: FileUpload;
|
|
7
|
+
/**
|
|
8
|
+
* To display as either a file row or thumbnail
|
|
9
|
+
*
|
|
10
|
+
* @default "expanded"
|
|
11
|
+
*/
|
|
12
|
+
readonly display?: "expanded" | "compact";
|
|
13
|
+
/**
|
|
14
|
+
* The base dimensions of the thumbnail
|
|
15
|
+
*
|
|
16
|
+
* @default "base"
|
|
17
|
+
*/
|
|
18
|
+
readonly displaySize?: "base" | "large";
|
|
19
|
+
/**
|
|
20
|
+
* Function to execute when format file is clicked
|
|
21
|
+
*/
|
|
22
|
+
onClick?(event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>): void;
|
|
23
|
+
/**
|
|
24
|
+
* onDelete callback - this function will be called when the delete action is triggered
|
|
25
|
+
*/
|
|
26
|
+
onDelete?(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormatFileProps } from "./types";
|
|
2
|
+
export declare const useFormatFileStyles: ({ display, displaySize, onClick, onDelete, isComplete, }: Pick<FormatFileProps, "display" | "onClick" | "onDelete" | "displaySize"> & {
|
|
3
|
+
isComplete: boolean;
|
|
4
|
+
}) => {
|
|
5
|
+
deleteButtonContainerClassNames: string;
|
|
6
|
+
detailsClassNames: string;
|
|
7
|
+
progressClassNames: string;
|
|
8
|
+
thumbnailContainerClassNames: string;
|
|
9
|
+
wrapperClassNames: string;
|
|
10
|
+
};
|
package/dist/FormatFile-cjs.js
CHANGED
|
@@ -1,145 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var classnames = require('classnames');
|
|
5
4
|
var getHumanReadableFileSize = require('filesize');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var Glimmer = require('./Glimmer-cjs.js');
|
|
9
|
-
var Icon = require('./Icon-cjs.js');
|
|
10
|
-
var Typography = require('./Typography-cjs.js');
|
|
5
|
+
var classnames = require('classnames');
|
|
6
|
+
var Thumbnail = require('./Thumbnail-cjs.js');
|
|
11
7
|
var Text = require('./Text-cjs.js');
|
|
12
8
|
var ProgressBar = require('./ProgressBar-cjs.js');
|
|
9
|
+
var Button = require('./Button-cjs.js');
|
|
10
|
+
var ConfirmationModal = require('./ConfirmationModal-cjs.js');
|
|
13
11
|
|
|
14
|
-
var styles
|
|
15
|
-
|
|
16
|
-
function FormatFileDeleteButton({ size, onDelete }) {
|
|
17
|
-
const buttonSize = size === "base" ? "small" : "base";
|
|
18
|
-
const [deleteConfirmationOpen, setDeleteConfirmationOpen] = React.useState(false);
|
|
19
|
-
return (React.createElement("div", { className: styles$2.deleteButton },
|
|
20
|
-
React.createElement(Button.Button, { onClick: () => setDeleteConfirmationOpen(true), variation: "destructive", type: "tertiary", icon: "trash", ariaLabel: "Delete File", size: buttonSize }),
|
|
21
|
-
React.createElement(ConfirmationModal.ConfirmationModal, { title: "Confirm Deletion", message: `Are you sure you want to delete this file?`, confirmLabel: "Delete", variation: "destructive", open: deleteConfirmationOpen, onConfirm: () => onDelete === null || onDelete === void 0 ? void 0 : onDelete(), onRequestClose: () => setDeleteConfirmationOpen(false) })));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var styles$1 = {"content":"GlvUe-y47J8-","hasName":"zxlhNVPlPfU-","large":"PLxm6a4dUeE-","fileName":"-HUnao9DHy4-","base":"HJGVBmS64DY-","spinning":"Svf9Lca4cus-"};
|
|
25
|
-
|
|
26
|
-
var styles = {"image":"YdEHf0kMqIk-","fadeIn":"qG9O-VWpfw0-","hidden":"NoE9wiIsC-A-","spinning":"fNFmp-zaYd4-"};
|
|
27
|
-
|
|
28
|
-
function InternalThumbnailImage({ file }) {
|
|
29
|
-
const { name, src } = file;
|
|
30
|
-
const [imageSource, setImageSource] = React.useState();
|
|
31
|
-
const [imageLoaded, setImageLoaded] = React.useState(false);
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
src().then(url => setImageSource(url));
|
|
34
|
-
}, []);
|
|
35
|
-
return (React.createElement(React.Fragment, null,
|
|
36
|
-
!imageLoaded && React.createElement(Glimmer.Glimmer, { size: "auto" }),
|
|
37
|
-
React.createElement("img", { src: imageSource, onError: file.onImageLoadError, onLoad: handleImageLoad, alt: name, "data-testid": "internalThumbnailImage", className: classnames(styles.image, { [styles.hidden]: !imageLoaded }) })));
|
|
38
|
-
function handleImageLoad() {
|
|
39
|
-
setImageLoaded(true);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// This function comes from MDN: https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator
|
|
44
|
-
function getClientBrowser(userAgent) {
|
|
45
|
-
// The order matters here, and this may report false positives for unlisted browsers.
|
|
46
|
-
if (userAgent.includes("Firefox")) {
|
|
47
|
-
// "Mozilla/5.0 (X11; Linux i686; rv:104.0) Gecko/20100101 Firefox/104.0"
|
|
48
|
-
return "Mozilla Firefox";
|
|
49
|
-
}
|
|
50
|
-
else if (userAgent.includes("SamsungBrowser")) {
|
|
51
|
-
// "Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G955F Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/9.4 Chrome/67.0.3396.87 Mobile Safari/537.36"
|
|
52
|
-
return "Samsung Internet";
|
|
53
|
-
}
|
|
54
|
-
else if (userAgent.includes("Opera") || userAgent.includes("OPR")) {
|
|
55
|
-
// "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_5_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36 OPR/90.0.4480.54"
|
|
56
|
-
return "Opera";
|
|
57
|
-
}
|
|
58
|
-
else if (userAgent.includes("Edge")) {
|
|
59
|
-
// "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
|
|
60
|
-
return "Microsoft Edge (Legacy)";
|
|
61
|
-
}
|
|
62
|
-
else if (userAgent.includes("Edg")) {
|
|
63
|
-
// "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36 Edg/104.0.1293.70"
|
|
64
|
-
return "Microsoft Edge (Chromium)";
|
|
65
|
-
}
|
|
66
|
-
else if (userAgent.includes("Chrome")) {
|
|
67
|
-
// "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
|
|
68
|
-
return "Google Chrome or Chromium";
|
|
69
|
-
}
|
|
70
|
-
else if (userAgent.includes("Safari")) {
|
|
71
|
-
// "Mozilla/5.0 (iPhone; CPU iPhone OS 15_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Mobile/15E148 Safari/604.1"
|
|
72
|
-
return "Apple Safari";
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return "unknown";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function isSafari(userAgent) {
|
|
79
|
-
return getClientBrowser(userAgent) === "Apple Safari";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function InternalThumbnail({ compact = false, size, file, }) {
|
|
83
|
-
const { name, type } = file;
|
|
84
|
-
const iconName = getIconNameFromType(type);
|
|
85
|
-
const hasName = Boolean(name) && compact;
|
|
86
|
-
if (type.startsWith("image/") && isSupportedImageType(file)) {
|
|
87
|
-
return React.createElement(InternalThumbnailImage, { file: file });
|
|
88
|
-
}
|
|
89
|
-
return (React.createElement("div", { className: classnames(styles$1.content, styles$1[size], {
|
|
90
|
-
[styles$1.hasName]: hasName,
|
|
91
|
-
}) },
|
|
92
|
-
React.createElement(Icon.Icon, { name: iconName, color: "greyBlue", size: size }),
|
|
93
|
-
hasName && (React.createElement("div", { className: styles$1.fileName },
|
|
94
|
-
React.createElement(Typography.Typography, { element: "span", textColor: "text", numberOfLines: 1 }, name)))));
|
|
95
|
-
}
|
|
96
|
-
function getIconNameFromType(mimeType) {
|
|
97
|
-
if (mimeType.startsWith("image/"))
|
|
98
|
-
return "image";
|
|
99
|
-
if (mimeType.startsWith("video/"))
|
|
100
|
-
return "video";
|
|
101
|
-
switch (mimeType) {
|
|
102
|
-
case "application/pdf":
|
|
103
|
-
return "pdf";
|
|
104
|
-
case "application/vnd.ms-excel":
|
|
105
|
-
return "excel";
|
|
106
|
-
default:
|
|
107
|
-
return "file";
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function isSupportedImageType(file) {
|
|
111
|
-
const userAgent = typeof document === "undefined" ? "" : window.navigator.userAgent;
|
|
112
|
-
const nonHeicImage = !file.type.startsWith("image/heic");
|
|
113
|
-
const nonSVGImage = !file.type.startsWith("image/svg");
|
|
114
|
-
return (nonHeicImage || isSafari(userAgent)) && nonSVGImage;
|
|
115
|
-
}
|
|
12
|
+
var styles = {"formatFile":"y9T1gWK9SHY-","expanded":"_6qcLC0nLki0-","compact":"cSm0ukEQcOU-","wrapper":"TEarBLxe1QY-","large":"rha7bX0NCtI-","base":"_7kv4ujgaxNk-","thumbnail":"Km0E9H-xb-M-","deleteButton":"d2l80-AKBiU-","clickable":"f7xR4ZcqlLo-","hoverable":"LxLX5kFFkfI-","progress":"_121nzRvOA-0-","contentBlock":"cyiC2EalTkQ-","deleteable":"qwQuqw4uODY-","spinning":"dR8gWEecWxc-"};
|
|
116
13
|
|
|
117
|
-
|
|
14
|
+
const useFormatFile = ({ file }) => {
|
|
118
15
|
const isComplete = file.progress >= 1;
|
|
119
16
|
const fileSize = getHumanReadableFileSize(file.size);
|
|
120
|
-
|
|
121
|
-
|
|
17
|
+
return {
|
|
18
|
+
isComplete,
|
|
19
|
+
fileSize,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const useFormatFileStyles = ({ display = "expanded", displaySize = "base", onClick, onDelete, isComplete, }) => {
|
|
24
|
+
const wrapperClassNames = classnames(styles[display], styles.formatFile, {
|
|
25
|
+
[styles[displaySize]]: display === "compact",
|
|
122
26
|
});
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
[styles
|
|
126
|
-
[styles
|
|
127
|
-
[styles
|
|
128
|
-
[styles$2.deleteable]: display === "compact",
|
|
27
|
+
const detailsClassNames = classnames(styles.wrapper, {
|
|
28
|
+
[styles[displaySize]]: display === "compact",
|
|
29
|
+
[styles.hoverable]: isHoverable({ display, isComplete, onClick, onDelete }),
|
|
30
|
+
[styles.clickable]: onClick,
|
|
31
|
+
[styles.deleteable]: display === "compact",
|
|
129
32
|
});
|
|
130
|
-
const thumbnailContainerClassNames = classnames(styles
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
React.createElement(Text.Text, { size: "small" }, fileSize)))),
|
|
140
|
-
isComplete && onDelete && (React.createElement("div", { className: styles$2.deleteButton },
|
|
141
|
-
React.createElement(FormatFileDeleteButton, { size: display === "expanded" ? "large" : displaySize, onDelete: onDelete })))));
|
|
142
|
-
}
|
|
33
|
+
const thumbnailContainerClassNames = classnames(styles.thumbnail, styles[displaySize]);
|
|
34
|
+
return {
|
|
35
|
+
deleteButtonContainerClassNames: styles.deleteButton,
|
|
36
|
+
detailsClassNames,
|
|
37
|
+
progressClassNames: styles.progress,
|
|
38
|
+
thumbnailContainerClassNames,
|
|
39
|
+
wrapperClassNames,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
143
42
|
function isHoverable({ display, isComplete, onClick, onDelete, }) {
|
|
144
43
|
if (display === "compact") {
|
|
145
44
|
return Boolean(isComplete && (onClick || onDelete));
|
|
@@ -150,5 +49,69 @@ function isHoverable({ display, isComplete, onClick, onDelete, }) {
|
|
|
150
49
|
return false;
|
|
151
50
|
}
|
|
152
51
|
|
|
52
|
+
function FormatFile({ file, display = "expanded", displaySize = "base", onDelete, onClick, }) {
|
|
53
|
+
const [deleteConfirmationOpen, setDeleteConfirmationOpen] = React.useState(false);
|
|
54
|
+
const { isComplete, fileSize } = useFormatFile({
|
|
55
|
+
file,
|
|
56
|
+
display,
|
|
57
|
+
displaySize,
|
|
58
|
+
onClick,
|
|
59
|
+
onDelete,
|
|
60
|
+
});
|
|
61
|
+
const { wrapperClassNames, detailsClassNames, progressClassNames, thumbnailContainerClassNames, deleteButtonContainerClassNames, } = useFormatFileStyles({
|
|
62
|
+
display,
|
|
63
|
+
displaySize,
|
|
64
|
+
isComplete,
|
|
65
|
+
onClick,
|
|
66
|
+
onDelete,
|
|
67
|
+
});
|
|
68
|
+
return (React.createElement(FormatFile.Wrapper, { className: wrapperClassNames },
|
|
69
|
+
React.createElement(FormatFile.Body, { type: "button", className: detailsClassNames, onClick: isComplete ? onClick : undefined, tabIndex: 0, ariaBusy: !isComplete, isComplete: isComplete },
|
|
70
|
+
React.createElement(FormatFile.ThumbnailContainer, { className: thumbnailContainerClassNames },
|
|
71
|
+
React.createElement(Thumbnail.Thumbnail, { key: file.key, compact: display === "compact", file: file, size: displaySize }),
|
|
72
|
+
React.createElement(FormatFile.ProgressContainer, { isHidden: isComplete, className: progressClassNames },
|
|
73
|
+
React.createElement(ProgressBar.ProgressBar, { size: "small", currentStep: file.progress * 100, totalSteps: 100 }))),
|
|
74
|
+
React.createElement(FormatFile.Expanded, { isVisible: display === "expanded", file: file, fileSize: fileSize })),
|
|
75
|
+
React.createElement(FormatFile.DeleteButtonContainer, { className: deleteButtonContainerClassNames, isHidden: !isComplete || onDelete === undefined },
|
|
76
|
+
React.createElement(FormatFile.DeleteButton, { onDelete: () => {
|
|
77
|
+
setDeleteConfirmationOpen(true);
|
|
78
|
+
} },
|
|
79
|
+
React.createElement(ConfirmationModal.ConfirmationModal, { title: "Confirm Deletion", message: `Are you sure you want to delete this file?`, confirmLabel: "Delete", variation: "destructive", open: deleteConfirmationOpen, onConfirm: () => onDelete === null || onDelete === void 0 ? void 0 : onDelete(), onRequestClose: () => setDeleteConfirmationOpen(false) })))));
|
|
80
|
+
}
|
|
81
|
+
FormatFile.DeleteButtonContainer = function FormatFileDeleteButtonContainer({ children, className, isHidden, }) {
|
|
82
|
+
if (isHidden)
|
|
83
|
+
return null;
|
|
84
|
+
return React.createElement("div", { className: className }, children);
|
|
85
|
+
};
|
|
86
|
+
FormatFile.ProgressContainer = function FormatFileProgressContainer({ isHidden, children, className, }) {
|
|
87
|
+
if (isHidden)
|
|
88
|
+
return null;
|
|
89
|
+
return React.createElement("div", { className: className }, children);
|
|
90
|
+
};
|
|
91
|
+
FormatFile.ThumbnailContainer = function FormatFileThumbnailContainer({ children, className, }) {
|
|
92
|
+
return React.createElement("div", { className: className }, children);
|
|
93
|
+
};
|
|
94
|
+
FormatFile.Body = function FormatFileBody({ children, className, type, onClick, tabIndex, ariaBusy, isComplete, }) {
|
|
95
|
+
const FormatFileBodyTag = isComplete && onClick ? "button" : "div";
|
|
96
|
+
return (React.createElement(FormatFileBodyTag, { type: type, className: className, onClick: onClick, tabIndex: tabIndex, "aria-busy": ariaBusy }, children));
|
|
97
|
+
};
|
|
98
|
+
FormatFile.Expanded = function FormatFileExpanded({ file, fileSize, isVisible, }) {
|
|
99
|
+
if (!isVisible)
|
|
100
|
+
return null;
|
|
101
|
+
return (React.createElement("div", { className: styles.contentBlock },
|
|
102
|
+
React.createElement(Text.Text, { size: "base" }, file.name),
|
|
103
|
+
React.createElement(Text.Text, { size: "small" }, fileSize)));
|
|
104
|
+
};
|
|
105
|
+
FormatFile.Wrapper = function FormatFileWrapper({ children, className, }) {
|
|
106
|
+
return React.createElement("div", { className: className }, children);
|
|
107
|
+
};
|
|
108
|
+
FormatFile.DeleteButton = function FormatFileDeleteButton({ onDelete, size = "base", children, }) {
|
|
109
|
+
const buttonSize = size === "base" ? "small" : "base";
|
|
110
|
+
return (React.createElement(React.Fragment, null,
|
|
111
|
+
React.createElement(Button.Button, { onClick: onDelete, variation: "destructive", type: "tertiary", icon: "trash", ariaLabel: "Delete File", size: buttonSize }),
|
|
112
|
+
children));
|
|
113
|
+
};
|
|
114
|
+
|
|
153
115
|
exports.FormatFile = FormatFile;
|
|
154
|
-
exports.
|
|
116
|
+
exports.useFormatFile = useFormatFile;
|
|
117
|
+
exports.useFormatFileStyles = useFormatFileStyles;
|