@geotab/zenith 3.18.0 → 3.19.0-beta.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/README.md +9 -0
- package/dist/chart/accessibleChart/accessibleChartTable.d.ts +1 -1
- package/dist/chart/accessibleChart/accessibleChartTable.js +29 -6
- package/dist/chart/accessibleChart/interfaces.d.ts +8 -2
- package/dist/chart/barChart.d.ts +3 -1
- package/dist/chart/barChart.js +5 -3
- package/dist/chart/lineChart.d.ts +3 -1
- package/dist/chart/lineChart.js +5 -3
- package/dist/chart/pieChart.d.ts +3 -1
- package/dist/chart/pieChart.js +5 -3
- package/dist/chart/utils/isEmptyDataPoint.d.ts +1 -0
- package/dist/chart/utils/isEmptyDataPoint.js +5 -0
- package/dist/dataGrid/columns/mainColumn/mainColumnWrapper.d.ts +2 -0
- package/dist/dataGrid/columns/mainColumn/mainColumnWrapper.js +2 -2
- package/dist/fileUpload/components/filePreview.d.ts +15 -0
- package/dist/fileUpload/components/filePreview.js +272 -0
- package/dist/fileUpload/components/previewableFile.d.ts +16 -0
- package/dist/fileUpload/components/previewableFile.js +48 -0
- package/dist/fileUpload/components/resolveFileActions.d.ts +10 -0
- package/dist/fileUpload/components/resolveFileActions.js +11 -0
- package/dist/fileUpload/components/uploadedFilesSection.d.ts +9 -1
- package/dist/fileUpload/components/uploadedFilesSection.js +91 -16
- package/dist/fileUpload/components/useFilePreview.d.ts +12 -0
- package/dist/fileUpload/components/useFilePreview.js +85 -0
- package/dist/fileUpload/fileUpload.d.ts +1 -1
- package/dist/fileUpload/fileUpload.js +63 -2
- package/dist/fileUpload/fileUploadType.d.ts +35 -0
- package/dist/filtersBar/components/filtersBarSearch/filtersBarSearch.d.ts +1 -1
- package/dist/formSection/components/formSectionCard.js +1 -1
- package/dist/icons/iconEngine.d.ts +3 -0
- package/dist/icons/iconEngine.js +12 -0
- package/dist/index.css +74 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -10
- package/dist/inputAdornments/inputAdornments.d.ts +3 -1
- package/dist/inputAdornments/inputAdornments.js +2 -2
- package/dist/lineChartMini/lineChartMini.d.ts +3 -1
- package/dist/lineChartMini/lineChartMini.js +5 -3
- package/dist/modal/modal.d.ts +2 -0
- package/dist/primaryIcon/primaryIcon.d.ts +3 -1
- package/dist/primaryIcon/primaryIcon.js +3 -3
- package/dist/searchInputRaw/searchInputRaw.js +4 -2
- package/dist/searchInputRaw/types.d.ts +2 -0
- package/dist/textInputRaw/textInputRaw.js +1 -1
- package/dist/textInputRaw/types.d.ts +2 -0
- package/esm/chart/accessibleChart/accessibleChartTable.d.ts +1 -1
- package/esm/chart/accessibleChart/accessibleChartTable.js +29 -6
- package/esm/chart/accessibleChart/interfaces.d.ts +8 -2
- package/esm/chart/barChart.d.ts +3 -1
- package/esm/chart/barChart.js +5 -3
- package/esm/chart/lineChart.d.ts +3 -1
- package/esm/chart/lineChart.js +5 -3
- package/esm/chart/pieChart.d.ts +3 -1
- package/esm/chart/pieChart.js +5 -3
- package/esm/chart/utils/isEmptyDataPoint.d.ts +1 -0
- package/esm/chart/utils/isEmptyDataPoint.js +1 -0
- package/esm/dataGrid/columns/mainColumn/mainColumnWrapper.d.ts +2 -0
- package/esm/dataGrid/columns/mainColumn/mainColumnWrapper.js +2 -2
- package/esm/fileUpload/components/filePreview.d.ts +15 -0
- package/esm/fileUpload/components/filePreview.js +263 -0
- package/esm/fileUpload/components/previewableFile.d.ts +16 -0
- package/esm/fileUpload/components/previewableFile.js +43 -0
- package/esm/fileUpload/components/resolveFileActions.d.ts +10 -0
- package/esm/fileUpload/components/resolveFileActions.js +7 -0
- package/esm/fileUpload/components/uploadedFilesSection.d.ts +9 -1
- package/esm/fileUpload/components/uploadedFilesSection.js +91 -16
- package/esm/fileUpload/components/useFilePreview.d.ts +12 -0
- package/esm/fileUpload/components/useFilePreview.js +81 -0
- package/esm/fileUpload/fileUpload.d.ts +1 -1
- package/esm/fileUpload/fileUpload.js +63 -2
- package/esm/fileUpload/fileUploadType.d.ts +35 -0
- package/esm/filtersBar/components/filtersBarSearch/filtersBarSearch.d.ts +1 -1
- package/esm/formSection/components/formSectionCard.js +1 -1
- package/esm/icons/iconEngine.d.ts +3 -0
- package/esm/icons/iconEngine.js +8 -0
- package/esm/index.d.ts +3 -1
- package/esm/index.js +1 -0
- package/esm/inputAdornments/inputAdornments.d.ts +3 -1
- package/esm/inputAdornments/inputAdornments.js +2 -2
- package/esm/lineChartMini/lineChartMini.d.ts +3 -1
- package/esm/lineChartMini/lineChartMini.js +5 -3
- package/esm/modal/modal.d.ts +2 -0
- package/esm/primaryIcon/primaryIcon.d.ts +3 -1
- package/esm/primaryIcon/primaryIcon.js +3 -3
- package/esm/searchInputRaw/searchInputRaw.js +4 -2
- package/esm/searchInputRaw/types.d.ts +2 -0
- package/esm/textInputRaw/textInputRaw.js +1 -1
- package/esm/textInputRaw/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,15 @@ Zenith library provides components defined in Zenith Design System. It includes
|
|
|
47
47
|
|
|
48
48
|
## Change log
|
|
49
49
|
|
|
50
|
+
### 3.19.0
|
|
51
|
+
|
|
52
|
+
- Add View and Download actions to `FileUpload`, with a built-in image and PDF preview
|
|
53
|
+
- Use `focus-visible` for the `Tabs` item highlight
|
|
54
|
+
- Let `FormSection` cards shrink with their form layout column
|
|
55
|
+
- Add the `Engine` icon
|
|
56
|
+
- Add `dataAnalyticsId` to the search input, `PrimaryIcon` and the `MainColumn` icon
|
|
57
|
+
- Add `accessibility.renderTableCell` to customize chart accessible table cells
|
|
58
|
+
|
|
50
59
|
### 3.18.0
|
|
51
60
|
|
|
52
61
|
- Add opt-in `fill` prop to `MiniTabs` so the tabs fill the available width
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IAccessibleChart } from "./interfaces";
|
|
2
|
-
export declare const AccessibleChartTable: ({ type, data, options }: IAccessibleChart) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const AccessibleChartTable: ({ type, data, options, accessibility }: IAccessibleChart) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,6 +14,7 @@ const userFormatContext_1 = require("../../utils/userFormat/userFormatContext");
|
|
|
14
14
|
const formatDate_1 = require("../../utils/formatDate");
|
|
15
15
|
const resampleArrayEvenly_1 = require("../utils/resampleArrayEvenly");
|
|
16
16
|
const isDateString_1 = require("../utils/isDateString");
|
|
17
|
+
const isEmptyDataPoint_1 = require("../utils/isEmptyDataPoint");
|
|
17
18
|
const getFormattedLabel_1 = require("../utils/getFormattedLabel");
|
|
18
19
|
const truncateDecimals_1 = require("../../utils/truncateDecimals");
|
|
19
20
|
const calculateMinTruncationPrecision_1 = require("../utils/calculateMinTruncationPrecision");
|
|
@@ -215,8 +216,10 @@ const getYLabels = (type, data) => {
|
|
|
215
216
|
const AccessibleChartTable = ({
|
|
216
217
|
type,
|
|
217
218
|
data,
|
|
218
|
-
options
|
|
219
|
+
options,
|
|
220
|
+
accessibility
|
|
219
221
|
}) => {
|
|
222
|
+
const renderTableCell = accessibility === null || accessibility === void 0 ? void 0 : accessibility.renderTableCell;
|
|
220
223
|
const {
|
|
221
224
|
translate
|
|
222
225
|
} = (0, useLanguage_1.useLanguage)();
|
|
@@ -293,11 +296,20 @@ const AccessibleChartTable = ({
|
|
|
293
296
|
const dsXKey = ds.x instanceof Date ? ds.x.toISOString() : ds.x.toString();
|
|
294
297
|
return dsXKey === yLabel.toString();
|
|
295
298
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
299
|
+
if (!matchingDataPoint) {
|
|
300
|
+
return (0, jsx_runtime_1.jsx)("td", {
|
|
301
|
+
children: "-"
|
|
302
|
+
}, dsIndex);
|
|
300
303
|
}
|
|
304
|
+
if (renderTableCell) {
|
|
305
|
+
// Same index the tooltip uses: trend datasets stay in the count, filteredDatasets drops them
|
|
306
|
+
const datasetIndex = data.datasets.indexOf(dataset);
|
|
307
|
+
return (0, jsx_runtime_1.jsx)("td", {
|
|
308
|
+
children: (0, isEmptyDataPoint_1.isEmptyDataPoint)(matchingDataPoint.y) ? "-" : renderTableCell(matchingDataPoint, datasetIndex, dataset)
|
|
309
|
+
}, dsIndex);
|
|
310
|
+
}
|
|
311
|
+
const yValue = matchingDataPoint.y;
|
|
312
|
+
const cellContent = typeof yValue === "number" ? (0, truncateDecimals_1.truncateDecimals)(yValue, datasetDecimalPlaces) : yValue;
|
|
301
313
|
return (0, jsx_runtime_1.jsx)("td", {
|
|
302
314
|
children: cellContent
|
|
303
315
|
}, dsIndex);
|
|
@@ -309,6 +321,11 @@ const AccessibleChartTable = ({
|
|
|
309
321
|
}), data.datasets.map((dataset, dsIndex) => {
|
|
310
322
|
const yValue = dataset.data[yIndex];
|
|
311
323
|
const datasetDecimalPlaces = decimalPlacesPerDataset.get(dsIndex);
|
|
324
|
+
if (renderTableCell) {
|
|
325
|
+
return (0, jsx_runtime_1.jsx)("td", {
|
|
326
|
+
children: (0, isEmptyDataPoint_1.isEmptyDataPoint)(yValue) ? "" : renderTableCell(yValue, dsIndex, dataset)
|
|
327
|
+
}, dsIndex);
|
|
328
|
+
}
|
|
312
329
|
return (0, jsx_runtime_1.jsx)("td", {
|
|
313
330
|
children: typeof yValue === "number" ? (0, truncateDecimals_1.truncateDecimals)(yValue, datasetDecimalPlaces) : yValue
|
|
314
331
|
}, dsIndex);
|
|
@@ -319,8 +336,14 @@ const AccessibleChartTable = ({
|
|
|
319
336
|
children: yLabel.toString()
|
|
320
337
|
}), data.datasets.map((dataset, dsIndex) => {
|
|
321
338
|
var _a;
|
|
322
|
-
const y = (_a = dataset.data[yIndex]) === null || _a === void 0 ? void 0 : _a.y;
|
|
323
339
|
const datasetDecimalPlaces = decimalPlacesPerDataset.get(dsIndex);
|
|
340
|
+
if (renderTableCell) {
|
|
341
|
+
const dataPoint = dataset.data[yIndex];
|
|
342
|
+
return (0, jsx_runtime_1.jsx)("td", {
|
|
343
|
+
children: (0, isEmptyDataPoint_1.isEmptyDataPoint)(dataPoint) ? "" : renderTableCell(dataPoint, dsIndex, dataset)
|
|
344
|
+
}, dsIndex);
|
|
345
|
+
}
|
|
346
|
+
const y = (_a = dataset.data[yIndex]) === null || _a === void 0 ? void 0 : _a.y;
|
|
324
347
|
const yValue = typeof y === "number" ? (0, truncateDecimals_1.truncateDecimals)(y, datasetDecimalPlaces) : y || "";
|
|
325
348
|
return (0, jsx_runtime_1.jsx)("td", {
|
|
326
349
|
children: yValue
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { ChartData, ChartDataset } from "chart.js";
|
|
2
3
|
import { IBarChartData, IBarChartDataset, IBarChartOptions, IBarChartPoint } from "../barChart/interfaces";
|
|
3
4
|
import { ILineChartData, ILineChartDataset, ILineChartOptions, ILineChartPoint } from "../lineChart/interfaces";
|
|
4
|
-
import { IPieChartData } from "../pieChart/interfaces";
|
|
5
|
+
import { IPieChartData, IPieChartDataset } from "../pieChart/interfaces";
|
|
5
6
|
import { BarChartType, LineChartType, PieChartType } from "../chart";
|
|
6
7
|
export type AccessibleChartData = ILineChartData | IBarChartData | IPieChartData | ChartData<"line">;
|
|
7
8
|
export type AccessibleChartType = LineChartType | BarChartType | PieChartType | "line-mini";
|
|
8
|
-
export type AccessibleChartDataset = ILineChartDataset | IBarChartDataset | ChartDataset<"line"
|
|
9
|
+
export type AccessibleChartDataset = ILineChartDataset | IBarChartDataset | ChartDataset<"line"> | IPieChartDataset;
|
|
10
|
+
export type AccessibleTableCellRenderer = (dataPoint: ILineChartPoint | IBarChartPoint | number, datasetIndex: number, dataset: AccessibleChartDataset) => ReactNode;
|
|
11
|
+
export interface IChartAccessibilityOptions {
|
|
12
|
+
renderTableCell?: AccessibleTableCellRenderer;
|
|
13
|
+
}
|
|
9
14
|
export interface IAccessibleChart {
|
|
10
15
|
data: AccessibleChartData;
|
|
11
16
|
type: AccessibleChartType;
|
|
12
17
|
options?: ILineChartOptions | IBarChartOptions;
|
|
13
18
|
narrativeId?: string;
|
|
19
|
+
accessibility?: IChartAccessibilityOptions;
|
|
14
20
|
}
|
|
15
21
|
export interface IChartTrend {
|
|
16
22
|
trendDirection: "increases" | "decreases" | "flat" | "complex" | "undefined";
|
package/dist/chart/barChart.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ILegendOptions } from "./plugins/legend/interfaces";
|
|
|
8
8
|
import { ITooltipOptions } from "./plugins/tooltip/interfaces";
|
|
9
9
|
import { IChartInsight } from "./chartInsight/chartInsight";
|
|
10
10
|
import { IChartSummary } from "./interfaces";
|
|
11
|
+
import { IChartAccessibilityOptions } from "./accessibleChart/interfaces";
|
|
11
12
|
export interface IBarChart extends IZenComponentProps {
|
|
12
13
|
data: IBarChartData;
|
|
13
14
|
options?: IBarChartOptions;
|
|
@@ -17,5 +18,6 @@ export interface IBarChart extends IZenComponentProps {
|
|
|
17
18
|
insight?: IChartInsight | false;
|
|
18
19
|
summary?: IChartSummary | false;
|
|
19
20
|
plugins?: Plugin<"bar">[];
|
|
21
|
+
accessibility?: IChartAccessibilityOptions;
|
|
20
22
|
}
|
|
21
|
-
export declare const BarChart: ({ data, options, axis, insight, summary, legend, tooltip, plugins, className, ...rest }: IBarChart) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const BarChart: ({ data, options, axis, insight, summary, legend, tooltip, plugins, className, accessibility, ...rest }: IBarChart) => import("react/jsx-runtime").JSX.Element;
|
package/dist/chart/barChart.js
CHANGED
|
@@ -86,9 +86,10 @@ const BarChart = _a => {
|
|
|
86
86
|
legend,
|
|
87
87
|
tooltip,
|
|
88
88
|
plugins,
|
|
89
|
-
className
|
|
89
|
+
className,
|
|
90
|
+
accessibility
|
|
90
91
|
} = _a,
|
|
91
|
-
rest = __rest(_a, ["data", "options", "axis", "insight", "summary", "legend", "tooltip", "plugins", "className"]);
|
|
92
|
+
rest = __rest(_a, ["data", "options", "axis", "insight", "summary", "legend", "tooltip", "plugins", "className", "accessibility"]);
|
|
92
93
|
const {
|
|
93
94
|
translate
|
|
94
95
|
} = (0, useLanguage_1.useLanguage)();
|
|
@@ -177,7 +178,8 @@ const BarChart = _a => {
|
|
|
177
178
|
type: "bar",
|
|
178
179
|
data: chartData,
|
|
179
180
|
options: chartOptions,
|
|
180
|
-
narrativeId: narrativeId
|
|
181
|
+
narrativeId: narrativeId,
|
|
182
|
+
accessibility: accessibility
|
|
181
183
|
})]
|
|
182
184
|
});
|
|
183
185
|
};
|
|
@@ -8,6 +8,7 @@ import { ILegendOptions } from "./plugins/legend/interfaces";
|
|
|
8
8
|
import { ILineOptions } from "./plugins/linePlugin/interfaces";
|
|
9
9
|
import { IChartInsight } from "./chartInsight/chartInsight";
|
|
10
10
|
import { IChartSummary } from "./interfaces";
|
|
11
|
+
import { IChartAccessibilityOptions } from "./accessibleChart/interfaces";
|
|
11
12
|
export interface ILineChart extends IZenComponentProps {
|
|
12
13
|
data: ILineChartData;
|
|
13
14
|
options?: ILineChartOptions;
|
|
@@ -17,5 +18,6 @@ export interface ILineChart extends IZenComponentProps {
|
|
|
17
18
|
summary?: IChartSummary | false;
|
|
18
19
|
tooltip?: ILineOptions | false;
|
|
19
20
|
plugins?: Plugin<"line">[];
|
|
21
|
+
accessibility?: IChartAccessibilityOptions;
|
|
20
22
|
}
|
|
21
|
-
export declare const LineChart: ({ data, options, axis, insight, summary, legend, tooltip, plugins, className, ...rest }: ILineChart) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const LineChart: ({ data, options, axis, insight, summary, legend, tooltip, plugins, className, accessibility, ...rest }: ILineChart) => import("react/jsx-runtime").JSX.Element;
|
package/dist/chart/lineChart.js
CHANGED
|
@@ -89,9 +89,10 @@ const LineChart = _a => {
|
|
|
89
89
|
legend,
|
|
90
90
|
tooltip,
|
|
91
91
|
plugins,
|
|
92
|
-
className
|
|
92
|
+
className,
|
|
93
|
+
accessibility
|
|
93
94
|
} = _a,
|
|
94
|
-
rest = __rest(_a, ["data", "options", "axis", "insight", "summary", "legend", "tooltip", "plugins", "className"]);
|
|
95
|
+
rest = __rest(_a, ["data", "options", "axis", "insight", "summary", "legend", "tooltip", "plugins", "className", "accessibility"]);
|
|
95
96
|
const {
|
|
96
97
|
translate
|
|
97
98
|
} = (0, useLanguage_1.useLanguage)();
|
|
@@ -195,7 +196,8 @@ const LineChart = _a => {
|
|
|
195
196
|
type: "line",
|
|
196
197
|
data: chartData,
|
|
197
198
|
options: chartOptions,
|
|
198
|
-
narrativeId: narrativeId
|
|
199
|
+
narrativeId: narrativeId,
|
|
200
|
+
accessibility: accessibility
|
|
199
201
|
})]
|
|
200
202
|
});
|
|
201
203
|
};
|
package/dist/chart/pieChart.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { IPieChartData, IPieChartOptions, IPieLegendOptions } from "./pieChart/i
|
|
|
7
7
|
import { ITooltipOptions } from "./plugins/tooltip/interfaces";
|
|
8
8
|
import { IChartInsight } from "./chartInsight/chartInsight";
|
|
9
9
|
import { IChartSummary } from "./interfaces";
|
|
10
|
+
import { IChartAccessibilityOptions } from "./accessibleChart/interfaces";
|
|
10
11
|
export interface IPieChart extends IZenComponentProps {
|
|
11
12
|
data: IPieChartData;
|
|
12
13
|
options?: IPieChartOptions;
|
|
@@ -15,5 +16,6 @@ export interface IPieChart extends IZenComponentProps {
|
|
|
15
16
|
legend?: IPieLegendOptions | false;
|
|
16
17
|
tooltip?: ITooltipOptions | false;
|
|
17
18
|
plugins?: Plugin<"pie">[];
|
|
19
|
+
accessibility?: IChartAccessibilityOptions;
|
|
18
20
|
}
|
|
19
|
-
export declare const PieChart: ({ data, options, insight, summary, legend, tooltip, plugins, className, ...rest }: IPieChart) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const PieChart: ({ data, options, insight, summary, legend, tooltip, plugins, className, accessibility, ...rest }: IPieChart) => import("react/jsx-runtime").JSX.Element;
|
package/dist/chart/pieChart.js
CHANGED
|
@@ -81,9 +81,10 @@ const PieChart = _a => {
|
|
|
81
81
|
legend,
|
|
82
82
|
tooltip,
|
|
83
83
|
plugins,
|
|
84
|
-
className
|
|
84
|
+
className,
|
|
85
|
+
accessibility
|
|
85
86
|
} = _a,
|
|
86
|
-
rest = __rest(_a, ["data", "options", "insight", "summary", "legend", "tooltip", "plugins", "className"]);
|
|
87
|
+
rest = __rest(_a, ["data", "options", "insight", "summary", "legend", "tooltip", "plugins", "className", "accessibility"]);
|
|
87
88
|
const {
|
|
88
89
|
isHorizontal
|
|
89
90
|
} = options;
|
|
@@ -194,7 +195,8 @@ const PieChart = _a => {
|
|
|
194
195
|
}), (0, jsx_runtime_1.jsx)(accessibleChart_1.AccessibleChart, {
|
|
195
196
|
type: "pie",
|
|
196
197
|
data: data,
|
|
197
|
-
narrativeId: narrativeId
|
|
198
|
+
narrativeId: narrativeId,
|
|
199
|
+
accessibility: accessibility
|
|
198
200
|
})]
|
|
199
201
|
});
|
|
200
202
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isEmptyDataPoint: (value: unknown) => value is null | undefined;
|
|
@@ -9,6 +9,8 @@ interface IActionIcon<T> {
|
|
|
9
9
|
createSize?: (entity: T) => TIconSize;
|
|
10
10
|
createTitle?: (entity: T, isNested: boolean) => string | undefined;
|
|
11
11
|
createLink?: (entity: T, isNested: boolean) => string | undefined;
|
|
12
|
+
/** Value for `data-analytics-id` on the icon button or link */
|
|
13
|
+
createDataAnalyticsId?: (entity: T, isNested: boolean) => string | undefined;
|
|
12
14
|
condition?: (entity: T, isNested: boolean) => boolean;
|
|
13
15
|
onClick?: TOnClick<T>;
|
|
14
16
|
className?: string | undefined;
|
|
@@ -45,7 +45,7 @@ class MainColumnWrapper {
|
|
|
45
45
|
return title;
|
|
46
46
|
}
|
|
47
47
|
renderIcon(entity, isNested) {
|
|
48
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
49
49
|
const Icon = this.options.icon ? this.options.icon.createIcon(entity, isNested) : null;
|
|
50
50
|
if (!Icon) {
|
|
51
51
|
return null;
|
|
@@ -61,7 +61,7 @@ class MainColumnWrapper {
|
|
|
61
61
|
const link = (_d = (_c = this.options.icon) === null || _c === void 0 ? void 0 : _c.createLink) === null || _d === void 0 ? void 0 : _d.call(_c, entity, isNested);
|
|
62
62
|
const title = (_f = (_e = this.options.icon) === null || _e === void 0 ? void 0 : _e.createTitle) === null || _f === void 0 ? void 0 : _f.call(_e, entity, isNested);
|
|
63
63
|
const iconClassName = (_g = this.options.icon) === null || _g === void 0 ? void 0 : _g.className;
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)(primaryIcon_1.PrimaryIcon, { icon: Icon, className: iconClassName, style: isNested ? "secondary" : undefined, onClick: handleOnClick, link: link, title: title, disabled: isDisabled }));
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)(primaryIcon_1.PrimaryIcon, { icon: Icon, className: iconClassName, style: isNested ? "secondary" : undefined, onClick: handleOnClick, link: link, title: title, disabled: isDisabled, dataAnalyticsId: (_j = (_h = this.options.icon) === null || _h === void 0 ? void 0 : _h.createDataAnalyticsId) === null || _j === void 0 ? void 0 : _j.call(_h, entity, isNested) }));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
exports.MainColumnWrapper = MainColumnWrapper;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IUploadedFile } from "../fileUploadType";
|
|
2
|
+
import { IPreviewState } from "./previewableFile";
|
|
3
|
+
interface IFilePreviewProps {
|
|
4
|
+
/** Base for `data-analytics-id` on the preview buttons */
|
|
5
|
+
analyticsBase: string;
|
|
6
|
+
preview: IPreviewState | null;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
/** When provided, a Download action is shown in the preview (modal footer or inline header) */
|
|
9
|
+
onDownload?: (file: IUploadedFile) => void;
|
|
10
|
+
/** Disables the Open in new tab and Download actions, mirroring the row buttons while uploading or when the component is disabled */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
translate: (key: string) => string;
|
|
13
|
+
}
|
|
14
|
+
export declare const FilePreview: ({ analyticsBase, preview, onClose, onDownload, disabled, translate }: IFilePreviewProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
injectString
|
|
5
|
+
} = require("../../utils/localization/translationsDictionary");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.FilePreview = void 0;
|
|
10
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const modal_1 = require("../../modal/modal");
|
|
13
|
+
const textIconButton_1 = require("../../textIconButton/textIconButton");
|
|
14
|
+
const buttonType_1 = require("../../button/buttonType");
|
|
15
|
+
const svgIconSize_1 = require("../../svgIcon/svgIconSize");
|
|
16
|
+
const iconArrowLeft_1 = require("../../icons/iconArrowLeft");
|
|
17
|
+
const iconDownload_1 = require("../../icons/iconDownload");
|
|
18
|
+
const iconOpen_1 = require("../../icons/iconOpen");
|
|
19
|
+
const zen_1 = require("../../utils/zen");
|
|
20
|
+
const waiting_1 = require("../../waiting/waiting");
|
|
21
|
+
injectString("cs", "Loading", "Na\u010D\xEDt\xE1n\xED");
|
|
22
|
+
injectString("da-DK", "Loading", "Indl\xE6ser");
|
|
23
|
+
injectString("de", "Loading", "Wird geladen");
|
|
24
|
+
injectString("en", "Loading", "Loading");
|
|
25
|
+
injectString("es", "Loading", "Cargando");
|
|
26
|
+
injectString("fi-FI", "Loading", "Ladataan");
|
|
27
|
+
injectString("fr", "Loading", "Chargement en cours");
|
|
28
|
+
injectString("fr-FR", "Loading", "En cours de chargement");
|
|
29
|
+
injectString("hu-HU", "Loading", "Bet\xF6lt\xE9s");
|
|
30
|
+
injectString("id", "Loading", "Memuat");
|
|
31
|
+
injectString("it", "Loading", "Caricamento in corso");
|
|
32
|
+
injectString("ja", "Loading", "\u8AAD\u307F\u8FBC\u307F\u4E2D");
|
|
33
|
+
injectString("ko-KR", "Loading", "\uB85C\uB4DC \uC911");
|
|
34
|
+
injectString("ms", "Loading", "Memuatkan");
|
|
35
|
+
injectString("nb-NO", "Loading", "Laster");
|
|
36
|
+
injectString("nl", "Loading", "Laden");
|
|
37
|
+
injectString("pl", "Loading", "\u0141adowanie");
|
|
38
|
+
injectString("pt-BR", "Loading", "Carregando");
|
|
39
|
+
injectString("pt-PT", "Loading", "A carregar");
|
|
40
|
+
injectString("sk-SK", "Loading", "Na\u010D\xEDtanie");
|
|
41
|
+
injectString("sv", "Loading", "Laddar");
|
|
42
|
+
injectString("th", "Loading", "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14");
|
|
43
|
+
injectString("tr", "Loading", "Y\xFCkleniyor");
|
|
44
|
+
injectString("zh-Hans", "Loading", "\u6B63\u5728\u52A0\u8F7D");
|
|
45
|
+
injectString("zh-TW", "Loading", "\u8F09\u5165\u4E2D");
|
|
46
|
+
injectString("ro-RO", "Loading", "Se \xEEncarc\u0103");
|
|
47
|
+
injectString("ar-001", "Loading", "\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644");
|
|
48
|
+
injectString("lt-LT", "Loading", "\u012Ekeliama");
|
|
49
|
+
injectString("lv-LV", "Loading", "Iel\u0101d\u0113");
|
|
50
|
+
injectString("ka-GE", "Loading", "\u10E9\u10D0\u10E2\u10D5\u10D8\u10E0\u10D7\u10D5\u10D0");
|
|
51
|
+
injectString("el-GR", "Loading", "\u03A6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7");
|
|
52
|
+
injectString("et-EE", "Loading", "Laadimine");
|
|
53
|
+
injectString("bg-BG", "Loading", "\u0417\u0430\u0440\u0435\u0436\u0434\u0430\u043D\u0435");
|
|
54
|
+
injectString("cs", "Back", "Zp\u011Bt");
|
|
55
|
+
injectString("da-DK", "Back", "Tilbage");
|
|
56
|
+
injectString("de", "Back", "Zur\xFCck");
|
|
57
|
+
injectString("en", "Back", "Back");
|
|
58
|
+
injectString("es", "Back", "Regresar");
|
|
59
|
+
injectString("fi-FI", "Back", "Takaisin");
|
|
60
|
+
injectString("fr", "Back", "Retour");
|
|
61
|
+
injectString("fr-FR", "Back", "Retour");
|
|
62
|
+
injectString("hu-HU", "Back", "Vissza");
|
|
63
|
+
injectString("id", "Back", "Kembali");
|
|
64
|
+
injectString("it", "Back", "Indietro");
|
|
65
|
+
injectString("ja", "Back", "\u623B\u308B");
|
|
66
|
+
injectString("ko-KR", "Back", "\uB4A4\uB85C");
|
|
67
|
+
injectString("ms", "Back", "Kembali");
|
|
68
|
+
injectString("nb-NO", "Back", "Tilbake");
|
|
69
|
+
injectString("nl", "Back", "Terug");
|
|
70
|
+
injectString("pl", "Back", "Wstecz");
|
|
71
|
+
injectString("pt-BR", "Back", "Voltar");
|
|
72
|
+
injectString("pt-PT", "Back", "Voltar");
|
|
73
|
+
injectString("sk-SK", "Back", "Sp\xE4\u0165");
|
|
74
|
+
injectString("sv", "Back", "Tillbaka");
|
|
75
|
+
injectString("th", "Back", "\u0E01\u0E25\u0E31\u0E1A");
|
|
76
|
+
injectString("tr", "Back", "Geri");
|
|
77
|
+
injectString("zh-Hans", "Back", "\u8FD4\u56DE");
|
|
78
|
+
injectString("zh-TW", "Back", "\u8FD4\u56DE");
|
|
79
|
+
injectString("ro-RO", "Back", "\xCEnapoi");
|
|
80
|
+
injectString("ar-001", "Back", "\u0631\u062C\u0648\u0639");
|
|
81
|
+
injectString("lt-LT", "Back", "Atgal");
|
|
82
|
+
injectString("lv-LV", "Back", "Atpaka\u013C");
|
|
83
|
+
injectString("ka-GE", "Back", "\u10E3\u10D9\u10D0\u10DC");
|
|
84
|
+
injectString("el-GR", "Back", "\u03A0\u03AF\u03C3\u03C9");
|
|
85
|
+
injectString("et-EE", "Back", "Tagasi");
|
|
86
|
+
injectString("bg-BG", "Back", "\u041D\u0430\u0437\u0430\u0434");
|
|
87
|
+
injectString("en", "Open in new tab", "Open in new tab");
|
|
88
|
+
injectString("cs", "Download", "St\xE1hnout");
|
|
89
|
+
injectString("da-DK", "Download", "Download");
|
|
90
|
+
injectString("de", "Download", "Herunterladen");
|
|
91
|
+
injectString("en", "Download", "Download");
|
|
92
|
+
injectString("es", "Download", "Descargar");
|
|
93
|
+
injectString("fi-FI", "Download", "Lataa");
|
|
94
|
+
injectString("fr", "Download", "T\xE9l\xE9charger");
|
|
95
|
+
injectString("fr-FR", "Download", "T\xE9l\xE9charger");
|
|
96
|
+
injectString("hu-HU", "Download", "Let\xF6lt\xE9s");
|
|
97
|
+
injectString("id", "Download", "Unduh");
|
|
98
|
+
injectString("it", "Download", "Scaricare");
|
|
99
|
+
injectString("ja", "Download", "\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9");
|
|
100
|
+
injectString("ko-KR", "Download", "\uB2E4\uC6B4\uB85C\uB4DC");
|
|
101
|
+
injectString("ms", "Download", "Muat Turun");
|
|
102
|
+
injectString("nb-NO", "Download", "Last ned");
|
|
103
|
+
injectString("nl", "Download", "Downloaden");
|
|
104
|
+
injectString("pl", "Download", "Pobierz");
|
|
105
|
+
injectString("pt-BR", "Download", "Download");
|
|
106
|
+
injectString("pt-PT", "Download", "Download");
|
|
107
|
+
injectString("sk-SK", "Download", "Stiahni");
|
|
108
|
+
injectString("sv", "Download", "Ladda ned");
|
|
109
|
+
injectString("th", "Download", "\u0E14\u0E32\u0E27\u0E19\u0E4C\u0E42\u0E2B\u0E25\u0E14");
|
|
110
|
+
injectString("tr", "Download", "\u0130ndir");
|
|
111
|
+
injectString("zh-Hans", "Download", "\u4E0B\u8F7D");
|
|
112
|
+
injectString("zh-TW", "Download", "\u4E0B\u8F09");
|
|
113
|
+
injectString("ro-RO", "Download", "Desc\u0103rca\u021Bi");
|
|
114
|
+
injectString("ar-001", "Download", "\u062A\u0646\u0632\u064A\u0644");
|
|
115
|
+
injectString("lt-LT", "Download", "Atsisi\u0173sti");
|
|
116
|
+
injectString("lv-LV", "Download", "Lejupiel\u0101d\u0113t");
|
|
117
|
+
injectString("ka-GE", "Download", "\u10E9\u10D0\u10DB\u10DD\u10E2\u10D5\u10D8\u10E0\u10D7\u10D5\u10D0");
|
|
118
|
+
injectString("el-GR", "Download", "\u039B\u03AE\u03C8\u03B7");
|
|
119
|
+
injectString("et-EE", "Download", "Laadi alla");
|
|
120
|
+
injectString("bg-BG", "Download", "\u0418\u0437\u0442\u0435\u0433\u043B\u044F\u043D\u0435");
|
|
121
|
+
const PreviewBody = ({
|
|
122
|
+
fileName,
|
|
123
|
+
kind,
|
|
124
|
+
url,
|
|
125
|
+
translate
|
|
126
|
+
}) => (0, jsx_runtime_1.jsxs)("div", {
|
|
127
|
+
className: "zen-file-upload__preview-body",
|
|
128
|
+
children: [url ? kind === "pdf" ? (0, jsx_runtime_1.jsx)("iframe", {
|
|
129
|
+
className: "zen-file-upload__preview-pdf",
|
|
130
|
+
src: url,
|
|
131
|
+
title: fileName
|
|
132
|
+
}) : (0, jsx_runtime_1.jsx)("img", {
|
|
133
|
+
className: "zen-file-upload__preview-image",
|
|
134
|
+
src: url,
|
|
135
|
+
alt: fileName
|
|
136
|
+
}) : (0, jsx_runtime_1.jsx)(waiting_1.Waiting, {
|
|
137
|
+
isLoading: true,
|
|
138
|
+
delay: 0,
|
|
139
|
+
hideOverlay: true
|
|
140
|
+
}), (0, jsx_runtime_1.jsx)("span", {
|
|
141
|
+
className: "zen-visually-hidden",
|
|
142
|
+
role: "status",
|
|
143
|
+
children: url ? "" : translate("Loading")
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
const InlinePreview = ({
|
|
147
|
+
analyticsBase,
|
|
148
|
+
fileName,
|
|
149
|
+
kind,
|
|
150
|
+
url,
|
|
151
|
+
disabled,
|
|
152
|
+
onClose,
|
|
153
|
+
onOpenInNewTab,
|
|
154
|
+
onDownload,
|
|
155
|
+
translate
|
|
156
|
+
}) => {
|
|
157
|
+
const backButtonRef = (0, react_1.useRef)(null);
|
|
158
|
+
// Activating View unmounts the focused row button, so focus would fall back to the page body. Move it into the preview
|
|
159
|
+
// once, as soon as the preview opens (while the bytes are still pending), so the keyboard user lands on Back. The effect
|
|
160
|
+
// runs on mount only, never on URL resolution, and closing still restores focus to the View button.
|
|
161
|
+
(0, react_1.useEffect)(() => {
|
|
162
|
+
var _a;
|
|
163
|
+
(_a = backButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
164
|
+
}, []);
|
|
165
|
+
return (0, jsx_runtime_1.jsxs)("section", {
|
|
166
|
+
className: "zen-file-upload__preview-inline",
|
|
167
|
+
"aria-label": fileName,
|
|
168
|
+
children: [(0, jsx_runtime_1.jsxs)("div", {
|
|
169
|
+
className: "zen-file-upload__preview-header",
|
|
170
|
+
children: [(0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, {
|
|
171
|
+
icon: iconArrowLeft_1.IconArrowLeft,
|
|
172
|
+
iconSize: svgIconSize_1.SvgIconSize.Bigger,
|
|
173
|
+
type: buttonType_1.ButtonType.TertiaryBlack,
|
|
174
|
+
ref: backButtonRef,
|
|
175
|
+
onClick: onClose,
|
|
176
|
+
dataAnalyticsId: `${analyticsBase}-preview-back`,
|
|
177
|
+
ariaLabel: `${translate("Back")} ${fileName}`
|
|
178
|
+
}), (0, jsx_runtime_1.jsx)("span", {
|
|
179
|
+
className: "zen-file-upload__preview-title",
|
|
180
|
+
children: fileName
|
|
181
|
+
}), (0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, {
|
|
182
|
+
icon: iconOpen_1.IconOpen,
|
|
183
|
+
iconSize: svgIconSize_1.SvgIconSize.Bigger,
|
|
184
|
+
type: buttonType_1.ButtonType.TertiaryBlack,
|
|
185
|
+
onClick: onOpenInNewTab,
|
|
186
|
+
dataAnalyticsId: `${analyticsBase}-preview-open-in-new-tab`,
|
|
187
|
+
disabled: disabled || !url,
|
|
188
|
+
ariaLabel: `${translate("Open in new tab")} ${fileName}`
|
|
189
|
+
}), onDownload && (0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, {
|
|
190
|
+
icon: iconDownload_1.IconDownload,
|
|
191
|
+
iconSize: svgIconSize_1.SvgIconSize.Bigger,
|
|
192
|
+
type: buttonType_1.ButtonType.TertiaryBlack,
|
|
193
|
+
onClick: onDownload,
|
|
194
|
+
dataAnalyticsId: `${analyticsBase}-preview-download`,
|
|
195
|
+
disabled: disabled,
|
|
196
|
+
ariaLabel: `${translate("Download")} ${fileName}`
|
|
197
|
+
})]
|
|
198
|
+
}), (0, jsx_runtime_1.jsx)(PreviewBody, {
|
|
199
|
+
fileName: fileName,
|
|
200
|
+
kind: kind,
|
|
201
|
+
url: url,
|
|
202
|
+
translate: translate
|
|
203
|
+
})]
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
const FilePreview = ({
|
|
207
|
+
analyticsBase,
|
|
208
|
+
preview,
|
|
209
|
+
onClose,
|
|
210
|
+
onDownload,
|
|
211
|
+
disabled = false,
|
|
212
|
+
translate
|
|
213
|
+
}) => {
|
|
214
|
+
if (!preview) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
const {
|
|
218
|
+
file,
|
|
219
|
+
fileName,
|
|
220
|
+
kind,
|
|
221
|
+
url,
|
|
222
|
+
mode
|
|
223
|
+
} = preview;
|
|
224
|
+
const handleDownload = onDownload ? () => onDownload(file) : undefined;
|
|
225
|
+
const handleOpenInNewTab = () => {
|
|
226
|
+
var _a;
|
|
227
|
+
return url && ((_a = zen_1.zen.open) === null || _a === void 0 ? void 0 : _a.call(zen_1.zen, url, "_blank", "noopener"));
|
|
228
|
+
};
|
|
229
|
+
if (mode === "modal") {
|
|
230
|
+
return (0, jsx_runtime_1.jsxs)(modal_1.Modal, {
|
|
231
|
+
isOpen: true,
|
|
232
|
+
onClose: onClose,
|
|
233
|
+
title: fileName,
|
|
234
|
+
closeOnClickOutside: true,
|
|
235
|
+
maxWidth: "800px",
|
|
236
|
+
children: [(0, jsx_runtime_1.jsx)(PreviewBody, {
|
|
237
|
+
fileName: fileName,
|
|
238
|
+
kind: kind,
|
|
239
|
+
url: url,
|
|
240
|
+
translate: translate
|
|
241
|
+
}), (0, jsx_runtime_1.jsx)(modal_1.Modal.SecondaryButton, {
|
|
242
|
+
icon: iconOpen_1.IconOpen,
|
|
243
|
+
dataAnalyticsId: `${analyticsBase}-preview-open-in-new-tab`,
|
|
244
|
+
onClick: handleOpenInNewTab,
|
|
245
|
+
disabled: disabled || !url,
|
|
246
|
+
title: `${translate("Open in new tab")} ${fileName}`,
|
|
247
|
+
children: translate("Open in new tab")
|
|
248
|
+
}), handleDownload && (0, jsx_runtime_1.jsx)(modal_1.Modal.PrimaryButton, {
|
|
249
|
+
icon: iconDownload_1.IconDownload,
|
|
250
|
+
dataAnalyticsId: `${analyticsBase}-preview-download`,
|
|
251
|
+
onClick: handleDownload,
|
|
252
|
+
disabled: disabled,
|
|
253
|
+
title: `${translate("Download")} ${fileName}`,
|
|
254
|
+
children: translate("Download")
|
|
255
|
+
})]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
// Inline: rendered in place inside the host container (for example a modal), so no second modal is stacked.
|
|
259
|
+
// Keyed by file so a different file always starts with focus on its own Back button.
|
|
260
|
+
return (0, jsx_runtime_1.jsx)(InlinePreview, {
|
|
261
|
+
analyticsBase: analyticsBase,
|
|
262
|
+
fileName: fileName,
|
|
263
|
+
kind: kind,
|
|
264
|
+
url: url,
|
|
265
|
+
disabled: disabled,
|
|
266
|
+
onClose: onClose,
|
|
267
|
+
onOpenInNewTab: handleOpenInNewTab,
|
|
268
|
+
onDownload: handleDownload,
|
|
269
|
+
translate: translate
|
|
270
|
+
}, file.id);
|
|
271
|
+
};
|
|
272
|
+
exports.FilePreview = FilePreview;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IUploadedFile, TFilePreviewMode } from "../fileUploadType";
|
|
2
|
+
export type TPreviewKind = "image" | "pdf";
|
|
3
|
+
export interface IPreviewState {
|
|
4
|
+
file: IUploadedFile;
|
|
5
|
+
fileName: string;
|
|
6
|
+
kind: TPreviewKind;
|
|
7
|
+
/** undefined while the URL is still being resolved */
|
|
8
|
+
url?: string;
|
|
9
|
+
mode: TFilePreviewMode;
|
|
10
|
+
}
|
|
11
|
+
export declare const getPreviewKind: (file: IUploadedFile) => TPreviewKind | null;
|
|
12
|
+
/**
|
|
13
|
+
* The MIME type the preview bytes are labelled with. It is derived from the file kind (and the file's own metadata),
|
|
14
|
+
* never from the Blob the consumer returned, so bytes labelled `text/html` can never be rendered as a web page.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getPreviewMimeType: (file: IUploadedFile, kind: TPreviewKind) => string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPreviewMimeType = exports.getPreviewKind = void 0;
|
|
4
|
+
const IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp"];
|
|
5
|
+
const IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
6
|
+
const IMAGE_MIME_BY_EXTENSION = {
|
|
7
|
+
png: "image/png",
|
|
8
|
+
jpg: "image/jpeg",
|
|
9
|
+
jpeg: "image/jpeg",
|
|
10
|
+
gif: "image/gif",
|
|
11
|
+
webp: "image/webp"
|
|
12
|
+
};
|
|
13
|
+
const getPreviewKind = (file) => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const mimeType = (_a = file.type) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
16
|
+
if (mimeType === "application/pdf") {
|
|
17
|
+
return "pdf";
|
|
18
|
+
}
|
|
19
|
+
if (mimeType && IMAGE_MIME_TYPES.includes(mimeType)) {
|
|
20
|
+
return "image";
|
|
21
|
+
}
|
|
22
|
+
const extension = (_b = file.name.split(".").pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
23
|
+
if (extension === "pdf") {
|
|
24
|
+
return "pdf";
|
|
25
|
+
}
|
|
26
|
+
if (extension && IMAGE_EXTENSIONS.includes(extension)) {
|
|
27
|
+
return "image";
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
exports.getPreviewKind = getPreviewKind;
|
|
32
|
+
/**
|
|
33
|
+
* The MIME type the preview bytes are labelled with. It is derived from the file kind (and the file's own metadata),
|
|
34
|
+
* never from the Blob the consumer returned, so bytes labelled `text/html` can never be rendered as a web page.
|
|
35
|
+
*/
|
|
36
|
+
const getPreviewMimeType = (file, kind) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (kind === "pdf") {
|
|
39
|
+
return "application/pdf";
|
|
40
|
+
}
|
|
41
|
+
const mimeType = (_a = file.type) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
42
|
+
if (mimeType && IMAGE_MIME_TYPES.includes(mimeType)) {
|
|
43
|
+
return mimeType;
|
|
44
|
+
}
|
|
45
|
+
const extension = (_b = file.name.split(".").pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
46
|
+
return (extension && IMAGE_MIME_BY_EXTENSION[extension]) || "image/png";
|
|
47
|
+
};
|
|
48
|
+
exports.getPreviewMimeType = getPreviewMimeType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IFileUpload } from "../fileUploadType";
|
|
2
|
+
type TActionProps = Pick<IFileUpload, "id" | "dataAnalyticsId" | "showViewButton" | "showDownloadButton" | "onView" | "getPreviewBlob" | "onDownload">;
|
|
3
|
+
/** An action button is only shown when it is switched on and the consumer provided something for it to do. */
|
|
4
|
+
/** Which action buttons are shown, and the base for their `data-analytics-id` (defaults to the component id). */
|
|
5
|
+
export declare const resolveFileActions: ({ id, dataAnalyticsId, showViewButton, showDownloadButton, onView, getPreviewBlob, onDownload }: TActionProps) => {
|
|
6
|
+
analyticsBase: string;
|
|
7
|
+
canView: boolean;
|
|
8
|
+
canDownload: boolean;
|
|
9
|
+
};
|
|
10
|
+
export {};
|