@cloudtower/eagle 4100.0.17 → 4100.0.19
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/dist/cjs/core/AccordionCard/index.js +1 -1
- package/dist/cjs/core/Alert/alert.style.js +2 -2
- package/dist/cjs/core/Antd5Tree/Antd5Tree.style.js +1 -1
- package/dist/cjs/core/Avatar/index.js +1 -1
- package/dist/cjs/core/Banner/banner.style.js +4 -4
- package/dist/cjs/core/BasicCTError/BasicCTError.style.js +1 -1
- package/dist/cjs/core/BlankState/style.js +1 -1
- package/dist/cjs/core/Breadcrumb/index.js +1 -1
- package/dist/cjs/core/Button/index.js +1 -1
- package/dist/cjs/core/ButtonGroup/index.js +2 -2
- package/dist/cjs/core/Card/CardBody.js +1 -1
- package/dist/cjs/core/Card/CardTitle.js +1 -1
- package/dist/cjs/core/Card/CardWrapper.js +2 -2
- package/dist/cjs/core/Cascader/cascader.style.js +11 -11
- package/dist/cjs/core/Checkbox/checkbox.style.js +1 -1
- package/dist/cjs/core/DetailCard/index.js +1 -1
- package/dist/cjs/core/DonutChart/index.js +2 -2
- package/dist/cjs/core/DropdownMenu/index.js +1 -1
- package/dist/cjs/core/ExpandableList/ExpandIcon.js +1 -1
- package/dist/cjs/core/ExpandableList/ExpandableContainer.js +1 -1
- package/dist/cjs/core/ExpandableList/ExpandableItem.js +2 -2
- package/dist/cjs/core/ExpandableList/RoundOrder.js +1 -1
- package/dist/cjs/core/FailedLoad/index.js +1 -1
- package/dist/cjs/core/FormItem/index.js +1 -1
- package/dist/cjs/core/Icon/index.js +1 -1
- package/dist/cjs/core/ImmersiveDialog/styles.js +14 -14
- package/dist/cjs/core/Input/index.js +1 -1
- package/dist/cjs/core/InputGroup/index.js +1 -1
- package/dist/cjs/core/InputInteger/index.js +1 -1
- package/dist/cjs/core/InputNumber/index.js +1 -1
- package/dist/cjs/core/InputPassword/index.js +1 -1
- package/dist/cjs/core/InputTagItem/index.js +1 -1
- package/dist/cjs/core/LegacySelect/select.style.js +1 -1
- package/dist/cjs/core/Legend/index.js +5 -5
- package/dist/cjs/core/LineChart/AreaHighlightLayer.js +122 -0
- package/dist/cjs/core/LineChart/ForecastLineLayer.js +134 -0
- package/dist/cjs/core/LineChart/LineChartActions.js +2 -2
- package/dist/cjs/core/LineChart/RenderChart.js +274 -20
- package/dist/cjs/core/LineChart/ThresholdIntersectionLayer.js +144 -0
- package/dist/cjs/core/LineChart/TooltipFormatter.js +44 -39
- package/dist/cjs/core/LineChart/areaHighlightUtils.js +89 -0
- package/dist/cjs/core/LineChart/index.js +20 -2
- package/dist/cjs/core/LineChart/lineChartDisplayUtils.js +32 -0
- package/dist/cjs/core/LineChart/lineSegments.js +90 -0
- package/dist/cjs/core/LineChart/styled.js +21 -9
- package/dist/cjs/core/LineChart/utils.js +93 -4
- package/dist/cjs/core/Link/index.js +1 -1
- package/dist/cjs/core/Loading/style.js +4 -4
- package/dist/cjs/core/LocalUpload/LocalUpload.hooks.js +5 -2
- package/dist/cjs/core/LocalUpload/LocalUpload.js +53 -45
- package/dist/cjs/core/LocalUpload/LocalUpload.style.js +2 -2
- package/dist/cjs/core/LocalUpload/LocalUpload.widget.js +156 -133
- package/dist/cjs/core/LogView/LogView.style.js +5 -5
- package/dist/cjs/core/MediumDialog/MediumDialog.js +1 -1
- package/dist/cjs/core/Metric/styled.js +8 -8
- package/dist/cjs/core/Nav/index.js +1 -1
- package/dist/cjs/core/Nav/style.js +2 -2
- package/dist/cjs/core/Overflow/index.js +2 -2
- package/dist/cjs/core/Pagination/index.js +2 -2
- package/dist/cjs/core/Progress/components.js +2 -2
- package/dist/cjs/core/Progress/index.js +2 -2
- package/dist/cjs/core/Progress/progress.style.js +4 -4
- package/dist/cjs/core/Progress/progress.widgets.js +2 -2
- package/dist/cjs/core/Radio/index.js +3 -3
- package/dist/cjs/core/SearchInput/SearchInput.style.js +5 -5
- package/dist/cjs/core/SegmentControl/index.js +4 -4
- package/dist/cjs/core/Select/select.style.js +4 -4
- package/dist/cjs/core/Select/select.widgets.js +3 -3
- package/dist/cjs/core/SimplePagination/index.js +2 -2
- package/dist/cjs/core/Skeleton/Content.js +1 -1
- package/dist/cjs/core/SmallDialog/SmallDialog.style.js +7 -7
- package/dist/cjs/core/StatusCapsule/index.js +2 -2
- package/dist/cjs/core/StepProgress/index.js +1 -1
- package/dist/cjs/core/Steps/style.js +5 -5
- package/dist/cjs/core/Styled/index.js +40 -40
- package/dist/cjs/core/Switch/index.js +2 -2
- package/dist/cjs/core/Tab/Tab.js +1 -1
- package/dist/cjs/core/Tab/Tab.style.js +4 -4
- package/dist/cjs/core/Table/TableSkeleton.js +1 -1
- package/dist/cjs/core/Table/TableWidget.js +1 -1
- package/dist/cjs/core/Table/index.js +3 -3
- package/dist/cjs/core/TableForm/Columns/FormItem.js +1 -1
- package/dist/cjs/core/TableForm/style.js +7 -7
- package/dist/cjs/core/Tag/SplitTag.js +1 -1
- package/dist/cjs/core/Tag/style.js +5 -5
- package/dist/cjs/core/Time/index.js +1 -1
- package/dist/cjs/core/TimeZoneSelect/index.js +7 -7
- package/dist/cjs/core/Timeline/Timeline.style.js +5 -5
- package/dist/cjs/core/Token/index.js +4 -4
- package/dist/cjs/core/Token/style.js +1 -1
- package/dist/cjs/core/Tooltip/EllipsisTooltipContent.js +1 -1
- package/dist/cjs/core/Tooltip/index.js +1 -1
- package/dist/cjs/core/Truncate/index.js +1 -1
- package/dist/cjs/core/Typo/index.js +58 -58
- package/dist/cjs/core/WizardDialog/styles.js +4 -4
- package/dist/cjs/coreX/BarChart/index.js +1 -1
- package/dist/cjs/coreX/BatchOperation/index.js +2 -2
- package/dist/cjs/coreX/ChartWithTooltip/index.js +6 -6
- package/dist/cjs/coreX/CheckPointList/checkpointlist.style.js +3 -3
- package/dist/cjs/coreX/CircleLoading/index.js +1 -1
- package/dist/cjs/coreX/CronCalendar/index.js +4 -4
- package/dist/cjs/coreX/CronPlan/index.js +4 -4
- package/dist/cjs/coreX/DateRangePicker/DateRangePicker.style.js +12 -12
- package/dist/cjs/coreX/DateRangePicker/RelativeTime.js +9 -6
- package/dist/cjs/coreX/DateRangePicker/common.js +104 -5
- package/dist/cjs/coreX/DateRangePicker/index.js +107 -47
- package/dist/cjs/coreX/Dialogs/DeleteDialog/DeleteDialog.js +2 -2
- package/dist/cjs/coreX/Dialogs/RejectDialog/RejectDialog.js +6 -6
- package/dist/cjs/coreX/GoBackButton/index.js +1 -1
- package/dist/cjs/coreX/I18nNameTag/index.js +1 -1
- package/dist/cjs/coreX/InfoRowList/InfoRow.js +1 -1
- package/dist/cjs/coreX/InfoRowList/InfoRowList.js +4 -4
- package/dist/cjs/coreX/KubeConfigModal/KubeConfigModal.style.js +8 -8
- package/dist/cjs/coreX/NamesTooltip/index.js +3 -3
- package/dist/cjs/coreX/OverflowTooltip/index.js +4 -4
- package/dist/cjs/coreX/Sider/index.js +3 -3
- package/dist/cjs/coreX/SummaryTable/index.js +5 -5
- package/dist/cjs/coreX/SwitchWithText/index.js +1 -1
- package/dist/cjs/coreX/TabMenu/index.js +2 -2
- package/dist/cjs/coreX/UnderlineTootip/index.js +1 -1
- package/dist/cjs/coreX/UnitWithChart/index.js +3 -3
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/stats1.html +1 -1
- package/dist/components.css +3935 -3863
- package/dist/esm/core/AccordionCard/index.js +1 -1
- package/dist/esm/core/Alert/alert.style.js +2 -2
- package/dist/esm/core/Antd5Tree/Antd5Tree.style.js +1 -1
- package/dist/esm/core/Avatar/index.js +1 -1
- package/dist/esm/core/Banner/banner.style.js +4 -4
- package/dist/esm/core/BasicCTError/BasicCTError.style.js +1 -1
- package/dist/esm/core/BlankState/style.js +1 -1
- package/dist/esm/core/Breadcrumb/index.js +1 -1
- package/dist/esm/core/Button/index.js +1 -1
- package/dist/esm/core/ButtonGroup/index.js +2 -2
- package/dist/esm/core/Card/CardBody.js +1 -1
- package/dist/esm/core/Card/CardTitle.js +1 -1
- package/dist/esm/core/Card/CardWrapper.js +2 -2
- package/dist/esm/core/Cascader/cascader.style.js +11 -11
- package/dist/esm/core/Checkbox/checkbox.style.js +1 -1
- package/dist/esm/core/DetailCard/index.js +1 -1
- package/dist/esm/core/DonutChart/index.js +2 -2
- package/dist/esm/core/DropdownMenu/index.js +1 -1
- package/dist/esm/core/ExpandableList/ExpandIcon.js +1 -1
- package/dist/esm/core/ExpandableList/ExpandableContainer.js +1 -1
- package/dist/esm/core/ExpandableList/ExpandableItem.js +2 -2
- package/dist/esm/core/ExpandableList/RoundOrder.js +1 -1
- package/dist/esm/core/FailedLoad/index.js +1 -1
- package/dist/esm/core/FormItem/index.js +1 -1
- package/dist/esm/core/Icon/index.js +1 -1
- package/dist/esm/core/ImmersiveDialog/styles.js +14 -14
- package/dist/esm/core/Input/index.js +1 -1
- package/dist/esm/core/InputGroup/index.js +1 -1
- package/dist/esm/core/InputInteger/index.js +1 -1
- package/dist/esm/core/InputNumber/index.js +1 -1
- package/dist/esm/core/InputPassword/index.js +1 -1
- package/dist/esm/core/InputTagItem/index.js +1 -1
- package/dist/esm/core/LegacySelect/select.style.js +1 -1
- package/dist/esm/core/Legend/index.js +5 -5
- package/dist/esm/core/LineChart/AreaHighlightLayer.js +115 -0
- package/dist/esm/core/LineChart/ForecastLineLayer.js +124 -0
- package/dist/esm/core/LineChart/LineChartActions.js +2 -2
- package/dist/esm/core/LineChart/RenderChart.js +276 -23
- package/dist/esm/core/LineChart/ThresholdIntersectionLayer.js +134 -0
- package/dist/esm/core/LineChart/TooltipFormatter.js +41 -39
- package/dist/esm/core/LineChart/areaHighlightUtils.js +87 -0
- package/dist/esm/core/LineChart/index.js +21 -3
- package/dist/esm/core/LineChart/lineChartDisplayUtils.js +26 -0
- package/dist/esm/core/LineChart/lineSegments.js +87 -0
- package/dist/esm/core/LineChart/styled.js +20 -10
- package/dist/esm/core/LineChart/utils.js +91 -5
- package/dist/esm/core/Link/index.js +1 -1
- package/dist/esm/core/Loading/style.js +4 -4
- package/dist/esm/core/LocalUpload/LocalUpload.hooks.js +6 -3
- package/dist/esm/core/LocalUpload/LocalUpload.js +52 -45
- package/dist/esm/core/LocalUpload/LocalUpload.style.js +2 -2
- package/dist/esm/core/LocalUpload/LocalUpload.widget.js +154 -131
- package/dist/esm/core/LogView/LogView.style.js +5 -5
- package/dist/esm/core/MediumDialog/MediumDialog.js +1 -1
- package/dist/esm/core/Metric/styled.js +8 -8
- package/dist/esm/core/Nav/index.js +1 -1
- package/dist/esm/core/Nav/style.js +2 -2
- package/dist/esm/core/Overflow/index.js +2 -2
- package/dist/esm/core/Pagination/index.js +2 -2
- package/dist/esm/core/Progress/components.js +2 -2
- package/dist/esm/core/Progress/index.js +2 -2
- package/dist/esm/core/Progress/progress.style.js +4 -4
- package/dist/esm/core/Progress/progress.widgets.js +2 -2
- package/dist/esm/core/Radio/index.js +3 -3
- package/dist/esm/core/SearchInput/SearchInput.style.js +5 -5
- package/dist/esm/core/SegmentControl/index.js +4 -4
- package/dist/esm/core/Select/select.style.js +4 -4
- package/dist/esm/core/Select/select.widgets.js +3 -3
- package/dist/esm/core/SimplePagination/index.js +2 -2
- package/dist/esm/core/Skeleton/Content.js +1 -1
- package/dist/esm/core/SmallDialog/SmallDialog.style.js +7 -7
- package/dist/esm/core/StatusCapsule/index.js +2 -2
- package/dist/esm/core/StepProgress/index.js +1 -1
- package/dist/esm/core/Steps/style.js +5 -5
- package/dist/esm/core/Styled/index.js +40 -40
- package/dist/esm/core/Switch/index.js +2 -2
- package/dist/esm/core/Tab/Tab.js +1 -1
- package/dist/esm/core/Tab/Tab.style.js +4 -4
- package/dist/esm/core/Table/TableSkeleton.js +1 -1
- package/dist/esm/core/Table/TableWidget.js +1 -1
- package/dist/esm/core/Table/index.js +3 -3
- package/dist/esm/core/TableForm/Columns/FormItem.js +1 -1
- package/dist/esm/core/TableForm/style.js +7 -7
- package/dist/esm/core/Tag/SplitTag.js +1 -1
- package/dist/esm/core/Tag/style.js +5 -5
- package/dist/esm/core/Time/index.js +1 -1
- package/dist/esm/core/TimeZoneSelect/index.js +7 -7
- package/dist/esm/core/Timeline/Timeline.style.js +5 -5
- package/dist/esm/core/Token/index.js +4 -4
- package/dist/esm/core/Token/style.js +1 -1
- package/dist/esm/core/Tooltip/EllipsisTooltipContent.js +1 -1
- package/dist/esm/core/Tooltip/index.js +1 -1
- package/dist/esm/core/Truncate/index.js +1 -1
- package/dist/esm/core/Typo/index.js +58 -58
- package/dist/esm/core/WizardDialog/styles.js +4 -4
- package/dist/esm/coreX/BarChart/index.js +1 -1
- package/dist/esm/coreX/BatchOperation/index.js +2 -2
- package/dist/esm/coreX/ChartWithTooltip/index.js +6 -6
- package/dist/esm/coreX/CheckPointList/checkpointlist.style.js +3 -3
- package/dist/esm/coreX/CircleLoading/index.js +1 -1
- package/dist/esm/coreX/CronCalendar/index.js +4 -4
- package/dist/esm/coreX/CronPlan/index.js +4 -4
- package/dist/esm/coreX/DateRangePicker/DateRangePicker.style.js +12 -12
- package/dist/esm/coreX/DateRangePicker/RelativeTime.js +10 -7
- package/dist/esm/coreX/DateRangePicker/common.js +99 -6
- package/dist/esm/coreX/DateRangePicker/index.js +108 -48
- package/dist/esm/coreX/Dialogs/DeleteDialog/DeleteDialog.js +2 -2
- package/dist/esm/coreX/Dialogs/RejectDialog/RejectDialog.js +6 -6
- package/dist/esm/coreX/GoBackButton/index.js +1 -1
- package/dist/esm/coreX/I18nNameTag/index.js +1 -1
- package/dist/esm/coreX/InfoRowList/InfoRow.js +1 -1
- package/dist/esm/coreX/InfoRowList/InfoRowList.js +4 -4
- package/dist/esm/coreX/KubeConfigModal/KubeConfigModal.style.js +8 -8
- package/dist/esm/coreX/NamesTooltip/index.js +3 -3
- package/dist/esm/coreX/OverflowTooltip/index.js +4 -4
- package/dist/esm/coreX/Sider/index.js +3 -3
- package/dist/esm/coreX/SummaryTable/index.js +5 -5
- package/dist/esm/coreX/SwitchWithText/index.js +1 -1
- package/dist/esm/coreX/TabMenu/index.js +2 -2
- package/dist/esm/coreX/UnderlineTootip/index.js +1 -1
- package/dist/esm/coreX/UnitWithChart/index.js +3 -3
- package/dist/esm/index.js +4 -1
- package/dist/esm/stats1.html +1 -1
- package/dist/linaria.merged.scss +4544 -4465
- package/dist/src/core/LineChart/AreaHighlightLayer.d.ts +31 -0
- package/dist/src/core/LineChart/ForecastLineLayer.d.ts +24 -0
- package/dist/src/core/LineChart/RenderChart.d.ts +5 -1
- package/dist/src/core/LineChart/ThresholdIntersectionLayer.d.ts +19 -0
- package/dist/src/core/LineChart/TooltipFormatter.d.ts +10 -0
- package/dist/src/core/LineChart/__test__/AreaHighlightLayer.test.d.ts +1 -0
- package/dist/src/core/LineChart/__test__/ForecastLineLayer.test.d.ts +1 -0
- package/dist/src/core/LineChart/__test__/utils.test.d.ts +1 -0
- package/dist/src/core/LineChart/areaHighlightUtils.d.ts +6 -0
- package/dist/src/core/LineChart/lineChartDisplayUtils.d.ts +7 -0
- package/dist/src/core/LineChart/lineSegments.d.ts +16 -0
- package/dist/src/core/LineChart/styled.d.ts +2 -0
- package/dist/src/core/LineChart/type.d.ts +94 -8
- package/dist/src/core/LineChart/utils.d.ts +31 -4
- package/dist/src/core/LocalUpload/LocalUpload.type.d.ts +12 -4
- package/dist/src/core/LocalUpload/LocalUpload.widget.d.ts +1 -0
- package/dist/src/core/LocalUpload/__test__/LocalUpload.test.d.ts +1 -0
- package/dist/src/coreX/DateRangePicker/__tests__/AbsoluteDate.test.d.ts +1 -0
- package/dist/src/coreX/DateRangePicker/__tests__/DateRangePicker.test.d.ts +1 -0
- package/dist/src/coreX/DateRangePicker/__tests__/RelativeTime.test.d.ts +1 -0
- package/dist/src/coreX/DateRangePicker/__tests__/common.test.d.ts +1 -0
- package/dist/src/coreX/DateRangePicker/common.d.ts +12 -3
- package/dist/src/coreX/DateRangePicker/dateRangePicker.type.d.ts +5 -1
- package/dist/stories/docs/core/LineChart.stories.d.ts +4 -0
- package/dist/stories/docs/core/LocalUpload.stories.d.ts +32 -13
- package/dist/stories/docs/coreX/DateRangePicker.stories.d.ts +1 -0
- package/dist/style.css +3936 -3864
- package/package.json +3 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
2
|
+
const getLineChartInterpolatedValue = (currentPoint, nextPoint, timestamp) => {
|
|
3
|
+
if (!isFiniteNumber(currentPoint.v) || !isFiniteNumber(nextPoint.v) || currentPoint.t === nextPoint.t) {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
if (timestamp === currentPoint.t) {
|
|
7
|
+
return currentPoint.v;
|
|
8
|
+
}
|
|
9
|
+
if (timestamp === nextPoint.t) {
|
|
10
|
+
return nextPoint.v;
|
|
11
|
+
}
|
|
12
|
+
const ratio = (timestamp - currentPoint.t) / (nextPoint.t - currentPoint.t);
|
|
13
|
+
return currentPoint.v + (nextPoint.v - currentPoint.v) * ratio;
|
|
14
|
+
};
|
|
15
|
+
const isSameAreaHighlightPoint = (prev, next) => {
|
|
16
|
+
if (!prev) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return Math.abs(prev.t - next.t) < 1e-6 && Math.abs(prev.value - next.value) < 1e-6;
|
|
20
|
+
};
|
|
21
|
+
const pushLineChartAreaHighlightPoint = (points, next) => {
|
|
22
|
+
if (!isSameAreaHighlightPoint(points[points.length - 1], next)) {
|
|
23
|
+
points.push(next);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const getLineChartAreaHighlightPointRuns = (points, range) => {
|
|
27
|
+
const runs = [];
|
|
28
|
+
let highlightedPoints = [];
|
|
29
|
+
const flushHighlightedPoints = () => {
|
|
30
|
+
if (highlightedPoints.length >= 2) {
|
|
31
|
+
runs.push(highlightedPoints);
|
|
32
|
+
}
|
|
33
|
+
highlightedPoints = [];
|
|
34
|
+
};
|
|
35
|
+
for (let index = 0; index < points.length - 1; index++) {
|
|
36
|
+
const currentPoint = points[index];
|
|
37
|
+
const nextPoint = points[index + 1];
|
|
38
|
+
if (!isFiniteNumber(currentPoint == null ? void 0 : currentPoint.t) || !isFiniteNumber(nextPoint == null ? void 0 : nextPoint.t) || !isFiniteNumber(currentPoint == null ? void 0 : currentPoint.v) || !isFiniteNumber(nextPoint == null ? void 0 : nextPoint.v) || currentPoint.t === nextPoint.t) {
|
|
39
|
+
flushHighlightedPoints();
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (nextPoint.t < range.start || currentPoint.t > range.end) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const segmentStart = Math.max(range.start, currentPoint.t);
|
|
46
|
+
const segmentEnd = Math.min(range.end, nextPoint.t);
|
|
47
|
+
if (segmentStart >= segmentEnd) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const startValue = getLineChartInterpolatedValue(
|
|
51
|
+
currentPoint,
|
|
52
|
+
nextPoint,
|
|
53
|
+
segmentStart
|
|
54
|
+
);
|
|
55
|
+
const endValue = getLineChartInterpolatedValue(
|
|
56
|
+
currentPoint,
|
|
57
|
+
nextPoint,
|
|
58
|
+
segmentEnd
|
|
59
|
+
);
|
|
60
|
+
if (!isFiniteNumber(startValue) || !isFiniteNumber(endValue)) {
|
|
61
|
+
flushHighlightedPoints();
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const startPoint = {
|
|
65
|
+
t: segmentStart,
|
|
66
|
+
value: startValue
|
|
67
|
+
};
|
|
68
|
+
const endPoint = {
|
|
69
|
+
t: segmentEnd,
|
|
70
|
+
value: endValue
|
|
71
|
+
};
|
|
72
|
+
if (highlightedPoints.length && isSameAreaHighlightPoint(
|
|
73
|
+
highlightedPoints[highlightedPoints.length - 1],
|
|
74
|
+
startPoint
|
|
75
|
+
)) {
|
|
76
|
+
pushLineChartAreaHighlightPoint(highlightedPoints, endPoint);
|
|
77
|
+
} else {
|
|
78
|
+
flushHighlightedPoints();
|
|
79
|
+
highlightedPoints = [startPoint, endPoint];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
flushHighlightedPoints();
|
|
83
|
+
return runs;
|
|
84
|
+
};
|
|
85
|
+
const getLineChartAreaHighlightRuns = (points, range) => getLineChartAreaHighlightPointRuns(points, range);
|
|
86
|
+
|
|
87
|
+
export { getLineChartAreaHighlightRuns };
|
|
@@ -3,8 +3,9 @@ import ErrorBoundary from '../ErrorBoundary/index.js';
|
|
|
3
3
|
import Pointer from './Pointer.js';
|
|
4
4
|
import RenderChart from './RenderChart.js';
|
|
5
5
|
import { LineChartWrapper } from './styled.js';
|
|
6
|
+
import useElementResize from '../../hooks/useElementResize.js';
|
|
6
7
|
import cs from 'classnames';
|
|
7
|
-
import React__default, { useState, useRef, useEffect } from 'react';
|
|
8
|
+
import React__default, { useState, useRef, useCallback, useEffect } from 'react';
|
|
8
9
|
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __defProps = Object.defineProperties;
|
|
@@ -37,15 +38,32 @@ const LineChart = React__default.forwardRef(
|
|
|
37
38
|
} = props;
|
|
38
39
|
const [width, setWidth] = useState(0);
|
|
39
40
|
const wrapperRef = useRef(null);
|
|
40
|
-
|
|
41
|
+
const syncWrapperWidth = useCallback(() => {
|
|
41
42
|
var _a;
|
|
42
43
|
setWidth(((_a = wrapperRef.current) == null ? void 0 : _a.offsetWidth) || 0);
|
|
43
44
|
}, []);
|
|
45
|
+
const setWrapperNode = useCallback(
|
|
46
|
+
(node) => {
|
|
47
|
+
wrapperRef.current = node;
|
|
48
|
+
if (typeof ref === "function") {
|
|
49
|
+
ref(node);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (ref) {
|
|
53
|
+
ref.current = node;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
[ref]
|
|
57
|
+
);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
syncWrapperWidth();
|
|
60
|
+
}, [syncWrapperWidth]);
|
|
61
|
+
useElementResize(wrapperRef, syncWrapperWidth, [showLegend, showXaxis, height]);
|
|
44
62
|
return /* @__PURE__ */ React__default.createElement(ErrorBoundary, { i18n: parrotI18n }, /* @__PURE__ */ React__default.createElement(
|
|
45
63
|
LineChartWrapper,
|
|
46
64
|
{
|
|
47
65
|
className: cs("metric-wrapper", !showXaxis && "hidden-xaxis"),
|
|
48
|
-
ref:
|
|
66
|
+
ref: setWrapperNode,
|
|
49
67
|
"data-testid": dataTestId,
|
|
50
68
|
style: { height: showLegend ? height + 30 : height }
|
|
51
69
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const DEFAULT_LINE_CHART_STROKE = "#3182bd";
|
|
2
|
+
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
3
|
+
const isFiniteNumericYAxisDomain = (domain) => {
|
|
4
|
+
if (!Array.isArray(domain) || domain.length !== 2) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return isFiniteNumber(domain[0]) && isFiniteNumber(domain[1]);
|
|
8
|
+
};
|
|
9
|
+
const getLineChartStreamStroke = (stream) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const color = (_a = stream.legend.color) != null ? _a : DEFAULT_LINE_CHART_STROKE;
|
|
12
|
+
return stream.legend.stroke ? `${color}1A` : color;
|
|
13
|
+
};
|
|
14
|
+
const getLineChartDefaultYAxisTicks = (domain) => {
|
|
15
|
+
if (!isFiniteNumericYAxisDomain(domain)) {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
const [, upper] = domain;
|
|
19
|
+
return [upper / 2, upper];
|
|
20
|
+
};
|
|
21
|
+
const getLineChartLegacyThresholdTooltipInfo = (info) => ({
|
|
22
|
+
current: info.formattedValue,
|
|
23
|
+
max: info.formattedThresholdValue
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { DEFAULT_LINE_CHART_STROKE, getLineChartDefaultYAxisTicks, getLineChartLegacyThresholdTooltipInfo, getLineChartStreamStroke, isFiniteNumber };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
2
|
+
const getLineChartLinePoint = (point) => {
|
|
3
|
+
if (!isFiniteNumber(point.t) || !isFiniteNumber(point.x) || !isFiniteNumber(point.y)) {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
t: point.t,
|
|
8
|
+
x: point.x,
|
|
9
|
+
y: point.y
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const getLineChartBoundaryPoint = (previous, next, timestamp) => {
|
|
13
|
+
const duration = next.t - previous.t;
|
|
14
|
+
if (!duration) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
const ratio = (timestamp - previous.t) / duration;
|
|
18
|
+
return {
|
|
19
|
+
t: timestamp,
|
|
20
|
+
x: previous.x + (next.x - previous.x) * ratio,
|
|
21
|
+
y: previous.y + (next.y - previous.y) * ratio
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const getLineChartLineSegments = (points, forecastStartTimestamp) => {
|
|
25
|
+
const segments = [];
|
|
26
|
+
const hasForecastStart = isFiniteNumber(forecastStartTimestamp);
|
|
27
|
+
let continuousPoints = [];
|
|
28
|
+
const flushContinuousPoints = () => {
|
|
29
|
+
if (continuousPoints.length < 2) {
|
|
30
|
+
continuousPoints = [];
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let segmentPoints = [continuousPoints[0]];
|
|
34
|
+
let dashed = Boolean(
|
|
35
|
+
hasForecastStart && continuousPoints[0].t >= forecastStartTimestamp
|
|
36
|
+
);
|
|
37
|
+
const pushSegment = () => {
|
|
38
|
+
if (segmentPoints.length >= 2) {
|
|
39
|
+
segments.push({ dashed, points: segmentPoints });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
for (let index = 1; index < continuousPoints.length; index += 1) {
|
|
43
|
+
const previous = continuousPoints[index - 1];
|
|
44
|
+
const next = continuousPoints[index];
|
|
45
|
+
const nextDashed = Boolean(
|
|
46
|
+
hasForecastStart && next.t >= forecastStartTimestamp
|
|
47
|
+
);
|
|
48
|
+
if (hasForecastStart && nextDashed !== dashed) {
|
|
49
|
+
const boundaryPoint = getLineChartBoundaryPoint(
|
|
50
|
+
previous,
|
|
51
|
+
next,
|
|
52
|
+
forecastStartTimestamp
|
|
53
|
+
);
|
|
54
|
+
if (boundaryPoint) {
|
|
55
|
+
segmentPoints.push(boundaryPoint);
|
|
56
|
+
pushSegment();
|
|
57
|
+
segmentPoints = [boundaryPoint];
|
|
58
|
+
if (boundaryPoint.t !== next.t) {
|
|
59
|
+
segmentPoints.push(next);
|
|
60
|
+
}
|
|
61
|
+
dashed = nextDashed;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
segmentPoints.push(next);
|
|
66
|
+
}
|
|
67
|
+
pushSegment();
|
|
68
|
+
continuousPoints = [];
|
|
69
|
+
};
|
|
70
|
+
points.forEach((point) => {
|
|
71
|
+
const linePoint = getLineChartLinePoint(point);
|
|
72
|
+
if (!linePoint) {
|
|
73
|
+
flushContinuousPoints();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
continuousPoints.push(linePoint);
|
|
77
|
+
});
|
|
78
|
+
flushContinuousPoints();
|
|
79
|
+
return segments;
|
|
80
|
+
};
|
|
81
|
+
const getLineChartLinePath = (points) => {
|
|
82
|
+
return points.map((point, index) => {
|
|
83
|
+
return `${index === 0 ? "M" : "L"}${point.x},${point.y}`;
|
|
84
|
+
}).join(" ");
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export { getLineChartLinePath, getLineChartLineSegments };
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
import { styled } from '@linaria/react';
|
|
2
2
|
|
|
3
|
-
const MetricLegendTabStyle = "
|
|
4
|
-
const LegendStyle = "
|
|
5
|
-
const LegendItemsStyle = "
|
|
6
|
-
const LegendItemsStyleDropdown = "
|
|
7
|
-
const ExtraResource = "
|
|
3
|
+
const MetricLegendTabStyle = "E_4100_0_19_mn7joto";
|
|
4
|
+
const LegendStyle = "E_4100_0_19_l1bifhon";
|
|
5
|
+
const LegendItemsStyle = "E_4100_0_19_ltthzck";
|
|
6
|
+
const LegendItemsStyleDropdown = "E_4100_0_19_l1mumj7o";
|
|
7
|
+
const ExtraResource = "E_4100_0_19_e45tc5l";
|
|
8
8
|
const LineChartWrapper = /*#__PURE__*/styled('div')({
|
|
9
9
|
name: "LineChartWrapper",
|
|
10
|
-
class: "
|
|
10
|
+
class: "E_4100_0_19_lqeaosa",
|
|
11
|
+
propsAsIs: false
|
|
12
|
+
});
|
|
13
|
+
const ChartContentWrapper = /*#__PURE__*/styled('div')({
|
|
14
|
+
name: "ChartContentWrapper",
|
|
15
|
+
class: "E_4100_0_19_c2pr38p",
|
|
16
|
+
propsAsIs: false
|
|
17
|
+
});
|
|
18
|
+
const ThresholdTooltipOverlay = /*#__PURE__*/styled('div')({
|
|
19
|
+
name: "ThresholdTooltipOverlay",
|
|
20
|
+
class: "E_4100_0_19_tecdsj7",
|
|
11
21
|
propsAsIs: false
|
|
12
22
|
});
|
|
13
23
|
const TooltipWrapper = /*#__PURE__*/styled('div')({
|
|
14
24
|
name: "TooltipWrapper",
|
|
15
|
-
class: "
|
|
25
|
+
class: "E_4100_0_19_tjhvvia",
|
|
16
26
|
propsAsIs: false
|
|
17
27
|
});
|
|
18
28
|
const TooltipColumn = /*#__PURE__*/styled('div')({
|
|
19
29
|
name: "TooltipColumn",
|
|
20
|
-
class: "
|
|
30
|
+
class: "E_4100_0_19_tuyrup3",
|
|
21
31
|
propsAsIs: false
|
|
22
32
|
});
|
|
23
|
-
const LineChartColorBlockStyle = "
|
|
33
|
+
const LineChartColorBlockStyle = "E_4100_0_19_lheyn3m";
|
|
24
34
|
|
|
25
|
-
export { ExtraResource, LegendItemsStyle, LegendItemsStyleDropdown, LegendStyle, LineChartColorBlockStyle, LineChartWrapper, MetricLegendTabStyle, TooltipColumn, TooltipWrapper };
|
|
35
|
+
export { ChartContentWrapper, ExtraResource, LegendItemsStyle, LegendItemsStyleDropdown, LegendStyle, LineChartColorBlockStyle, LineChartWrapper, MetricLegendTabStyle, ThresholdTooltipOverlay, TooltipColumn, TooltipWrapper };
|
|
@@ -89,10 +89,92 @@ function getLineChartXAxisDomain(dateRange, xaxisLastTime) {
|
|
|
89
89
|
const [startDate, endDate] = dateRange;
|
|
90
90
|
return [startDate.valueOf(), xaxisLastTime != null ? xaxisLastTime : endDate.valueOf()];
|
|
91
91
|
}
|
|
92
|
+
const getLineChartMetricPayloadMatches = (payload, legends = []) => {
|
|
93
|
+
if (!(payload == null ? void 0 : payload.length)) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
return payload.flatMap((item) => {
|
|
97
|
+
const legend = legends.find((_legend, index) => `v${index}` === item.name);
|
|
98
|
+
if (!legend) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
return [{ payload: item, legend }];
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const getLineChartAreaHighlightRanges = (ranges = [], xDomain) => {
|
|
105
|
+
const [domainStart, domainEnd] = xDomain;
|
|
106
|
+
return ranges.map((range) => __spreadProps(__spreadValues({}, range), {
|
|
107
|
+
start: Math.max(range.start, domainStart),
|
|
108
|
+
end: Math.min(range.end, domainEnd)
|
|
109
|
+
})).filter((range) => range.start < range.end);
|
|
110
|
+
};
|
|
92
111
|
const getLineChartRangeTimestamp = (dateRange) => {
|
|
93
112
|
const [startDate, endDate] = dateRange;
|
|
94
113
|
return endDate.valueOf() - startDate.valueOf();
|
|
95
114
|
};
|
|
115
|
+
const isSameIntersectionPoint = (prev, next) => {
|
|
116
|
+
if (!prev) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return prev.streamIndex === next.streamIndex && Math.abs(prev.timestamp - next.timestamp) < 1e-6 && Math.abs(prev.value - next.value) < 1e-6;
|
|
120
|
+
};
|
|
121
|
+
const pushLineChartIntersection = (intersections, next) => {
|
|
122
|
+
if (!isSameIntersectionPoint(intersections[intersections.length - 1], next)) {
|
|
123
|
+
intersections.push(next);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const isValidLineChartValue = (value) => {
|
|
127
|
+
return _.isNumber(value) && Number.isFinite(value);
|
|
128
|
+
};
|
|
129
|
+
const getLineChartThresholdIntersections = (streams, thresholdValue, xDomain) => {
|
|
130
|
+
const [domainStart, domainEnd] = xDomain != null ? xDomain : [-Infinity, Infinity];
|
|
131
|
+
return streams.flatMap((stream, streamIndex) => {
|
|
132
|
+
const intersections = [];
|
|
133
|
+
for (let index = 0; index < stream.points.length - 1; index++) {
|
|
134
|
+
const currentPoint = stream.points[index];
|
|
135
|
+
const nextPoint = stream.points[index + 1];
|
|
136
|
+
if (!isValidLineChartValue(currentPoint == null ? void 0 : currentPoint.v) || !isValidLineChartValue(nextPoint == null ? void 0 : nextPoint.v) || currentPoint.t === nextPoint.t) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const currentDiff = currentPoint.v - thresholdValue;
|
|
140
|
+
const nextDiff = nextPoint.v - thresholdValue;
|
|
141
|
+
if (currentDiff === 0 && nextDiff === 0) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (currentDiff === 0 && currentPoint.t >= domainStart && currentPoint.t <= domainEnd) {
|
|
145
|
+
pushLineChartIntersection(intersections, {
|
|
146
|
+
timestamp: currentPoint.t,
|
|
147
|
+
value: thresholdValue,
|
|
148
|
+
legend: stream.legend,
|
|
149
|
+
streamIndex
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (currentDiff * nextDiff < 0) {
|
|
153
|
+
const ratio = currentDiff / (currentDiff - nextDiff);
|
|
154
|
+
const timestamp = currentPoint.t + (nextPoint.t - currentPoint.t) * ratio;
|
|
155
|
+
if (timestamp >= domainStart && timestamp <= domainEnd) {
|
|
156
|
+
pushLineChartIntersection(intersections, {
|
|
157
|
+
timestamp,
|
|
158
|
+
value: thresholdValue,
|
|
159
|
+
legend: stream.legend,
|
|
160
|
+
streamIndex
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (nextDiff === 0 && nextPoint.t >= domainStart && nextPoint.t <= domainEnd) {
|
|
165
|
+
pushLineChartIntersection(intersections, {
|
|
166
|
+
timestamp: nextPoint.t,
|
|
167
|
+
value: thresholdValue,
|
|
168
|
+
legend: stream.legend,
|
|
169
|
+
streamIndex
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return intersections.filter(
|
|
174
|
+
(intersection) => intersection.timestamp >= domainStart && intersection.timestamp <= domainEnd
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
96
178
|
const getLineChartStep = (dateRange) => {
|
|
97
179
|
const [startDate, endDate] = dateRange;
|
|
98
180
|
const range = endDate.valueOf() - startDate.valueOf();
|
|
@@ -285,7 +367,7 @@ const UNIT_FORMATTER = {
|
|
|
285
367
|
[ILineChartMetricUnit.Temperature]: [formatTemperature, "\u2103"],
|
|
286
368
|
[ILineChartMetricUnit.Load]: [formatCount, ""]
|
|
287
369
|
};
|
|
288
|
-
const getLineChartYDataMax = (dataPoints, type) => {
|
|
370
|
+
const getLineChartYDataMax = (dataPoints, type, extraValues = []) => {
|
|
289
371
|
const values = dataPoints.map((p) => {
|
|
290
372
|
if (_.isNumber(p == null ? void 0 : p.v)) {
|
|
291
373
|
return p.v;
|
|
@@ -309,7 +391,11 @@ const getLineChartYDataMax = (dataPoints, type) => {
|
|
|
309
391
|
return max;
|
|
310
392
|
}
|
|
311
393
|
});
|
|
312
|
-
return Math.max(
|
|
394
|
+
return Math.max(
|
|
395
|
+
...values,
|
|
396
|
+
0,
|
|
397
|
+
...extraValues.filter((value) => Number.isFinite(value))
|
|
398
|
+
);
|
|
313
399
|
};
|
|
314
400
|
const getYAxisUpperBound = (max, type) => {
|
|
315
401
|
const DIVISOR = 2;
|
|
@@ -343,8 +429,8 @@ const getYAxisUpperBound = (max, type) => {
|
|
|
343
429
|
return 2;
|
|
344
430
|
}
|
|
345
431
|
};
|
|
346
|
-
const getYAxisDomain = (dataPoints, graphType, unitType) => {
|
|
347
|
-
const max = getLineChartYDataMax(dataPoints, graphType);
|
|
432
|
+
const getYAxisDomain = (dataPoints, graphType, unitType, extraValues = []) => {
|
|
433
|
+
const max = getLineChartYDataMax(dataPoints, graphType, extraValues);
|
|
348
434
|
if (!max) {
|
|
349
435
|
if (unitType === ILineChartMetricUnit.Ratio) {
|
|
350
436
|
return [0, 1];
|
|
@@ -366,4 +452,4 @@ function lineChartYaxisTickFormatter(value, unit) {
|
|
|
366
452
|
return `${_value} ${_unit}`;
|
|
367
453
|
}
|
|
368
454
|
|
|
369
|
-
export { UNIT_FORMATTER, addMissingDataWithZero, convertLineChartDataStruct, convertLineChartUnit, deletePointsOutOfRange, filterLineChartDataOverlapping, filterLineChartOverlappingMetric, filterLineChartPointsByDateRange, getFirstExpectedTimestamp, getLineChartRangeTimestamp, getLineChartStep, getLineChartXAxisDomain, getLineChartYDataMax, getYAxisDomain, getYAxisUpperBound, lineChartTickFormatter, lineChartXaxisCal, lineChartYaxisTickFormatter, parseLineChartRange };
|
|
455
|
+
export { UNIT_FORMATTER, addMissingDataWithZero, convertLineChartDataStruct, convertLineChartUnit, deletePointsOutOfRange, filterLineChartDataOverlapping, filterLineChartOverlappingMetric, filterLineChartPointsByDateRange, getFirstExpectedTimestamp, getLineChartAreaHighlightRanges, getLineChartMetricPayloadMatches, getLineChartRangeTimestamp, getLineChartStep, getLineChartThresholdIntersections, getLineChartXAxisDomain, getLineChartYDataMax, getYAxisDomain, getYAxisUpperBound, lineChartTickFormatter, lineChartXaxisCal, lineChartYaxisTickFormatter, parseLineChartRange };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const LoadingWrapper = "
|
|
2
|
-
const LoadingLine1 = "
|
|
3
|
-
const LoadingLine2 = "
|
|
4
|
-
const LoadingLine3 = "
|
|
1
|
+
const LoadingWrapper = "E_4100_0_19_lht19u8";
|
|
2
|
+
const LoadingLine1 = "E_4100_0_19_lk3gkp4";
|
|
3
|
+
const LoadingLine2 = "E_4100_0_19_ll4n94n";
|
|
4
|
+
const LoadingLine3 = "E_4100_0_19_l17lbdo6";
|
|
5
5
|
|
|
6
6
|
export { LoadingLine1, LoadingLine2, LoadingLine3, LoadingWrapper };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
const useFileValidation = ({
|
|
4
4
|
fileList,
|
|
@@ -6,13 +6,16 @@ const useFileValidation = ({
|
|
|
6
6
|
validate,
|
|
7
7
|
createNewFile = false
|
|
8
8
|
}) => {
|
|
9
|
+
const latestFileList = useRef(fileList);
|
|
9
10
|
useEffect(() => {
|
|
11
|
+
latestFileList.current = fileList;
|
|
10
12
|
if (!validate)
|
|
11
13
|
return;
|
|
12
14
|
const updateFile = (fileId, file) => {
|
|
13
|
-
const
|
|
15
|
+
const currentList = latestFileList.current;
|
|
16
|
+
const index = currentList.findIndex((f) => f.uid === fileId);
|
|
14
17
|
if (index !== -1) {
|
|
15
|
-
const newList = [...
|
|
18
|
+
const newList = [...currentList];
|
|
16
19
|
const fileToUpdate = createNewFile ? (() => {
|
|
17
20
|
const newFile = new File([file], file.name, { type: file.type });
|
|
18
21
|
Object.assign(newFile, file);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
|
|
2
|
+
import cs from 'classnames';
|
|
2
3
|
import React__default from 'react';
|
|
3
4
|
import { UploadWrapper } from './LocalUpload.style.js';
|
|
4
5
|
import { UploadLabel, UploadDescription, UploadButton, UploadDragger, UploadFileList, UploadFileInfo } from './LocalUpload.widget.js';
|
|
@@ -24,6 +25,7 @@ const UploadComp = React__default.forwardRef(
|
|
|
24
25
|
className,
|
|
25
26
|
"data-testid": dataTestId,
|
|
26
27
|
label,
|
|
28
|
+
labelPosition = "top",
|
|
27
29
|
description,
|
|
28
30
|
type = "dragger",
|
|
29
31
|
multiple = false,
|
|
@@ -35,66 +37,71 @@ const UploadComp = React__default.forwardRef(
|
|
|
35
37
|
setFileList,
|
|
36
38
|
validate,
|
|
37
39
|
buttonProps,
|
|
38
|
-
listType = "list",
|
|
39
40
|
disableRemoveList = false,
|
|
40
|
-
onRemove
|
|
41
|
+
onRemove,
|
|
42
|
+
error
|
|
41
43
|
}, ref) => {
|
|
42
44
|
const { t } = useParrotTranslation();
|
|
43
45
|
const removeFile = (id) => {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
fileList.splice(index, 1);
|
|
48
|
-
setFileList([...fileList]);
|
|
49
|
-
onRemove == null ? void 0 : onRemove(file);
|
|
46
|
+
const nextFileList = fileList.filter((file) => file.uid !== id);
|
|
47
|
+
if (nextFileList.length !== fileList.length) {
|
|
48
|
+
setFileList(nextFileList);
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
51
|
const _maxCount = multiple ? maxCount || Infinity : 1;
|
|
53
52
|
const isSingleSelect = _maxCount === 1;
|
|
53
|
+
const shouldShowDescriptionAbove = !!description && !!label && labelPosition === "top";
|
|
54
|
+
const shouldShowDescriptionBelow = !!description && !shouldShowDescriptionAbove;
|
|
55
|
+
const shouldDisableRemove = disabled || disableRemoveList;
|
|
56
|
+
const uploadContent = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, shouldShowDescriptionAbove ? /* @__PURE__ */ React__default.createElement(UploadComp.Description, null, description) : null, type === "button" ? /* @__PURE__ */ React__default.createElement(
|
|
57
|
+
UploadComp.Button,
|
|
58
|
+
__spreadValues({}, __spreadValues({
|
|
59
|
+
accept,
|
|
60
|
+
multiple,
|
|
61
|
+
disabled,
|
|
62
|
+
maxCount,
|
|
63
|
+
fileList,
|
|
64
|
+
setFileList,
|
|
65
|
+
validate,
|
|
66
|
+
error
|
|
67
|
+
}, buttonProps)),
|
|
68
|
+
t("components.select_file")
|
|
69
|
+
) : /* @__PURE__ */ React__default.createElement(
|
|
70
|
+
UploadComp.Dragger,
|
|
71
|
+
__spreadValues({}, {
|
|
72
|
+
accept,
|
|
73
|
+
multiple,
|
|
74
|
+
disabled,
|
|
75
|
+
maxCount,
|
|
76
|
+
fileList,
|
|
77
|
+
setFileList,
|
|
78
|
+
validate,
|
|
79
|
+
disableRemove: shouldDisableRemove,
|
|
80
|
+
onRemove,
|
|
81
|
+
error
|
|
82
|
+
})
|
|
83
|
+
), shouldShowDescriptionBelow ? /* @__PURE__ */ React__default.createElement(UploadComp.Description, { className: "description-below" }, description) : null, info, type === "button" || !isSingleSelect ? /* @__PURE__ */ React__default.createElement(
|
|
84
|
+
UploadComp.FileList,
|
|
85
|
+
{
|
|
86
|
+
fileList,
|
|
87
|
+
removeFile,
|
|
88
|
+
disableRemove: shouldDisableRemove,
|
|
89
|
+
onRemove
|
|
90
|
+
}
|
|
91
|
+
) : null);
|
|
54
92
|
return /* @__PURE__ */ React__default.createElement(
|
|
55
93
|
UploadComp.Wrapper,
|
|
56
94
|
{
|
|
57
|
-
className
|
|
95
|
+
className: cs(
|
|
96
|
+
className,
|
|
97
|
+
label && labelPosition === "left" ? "label-left" : "label-top",
|
|
98
|
+
!label && "no-label"
|
|
99
|
+
),
|
|
58
100
|
ref,
|
|
59
101
|
"data-testid": dataTestId
|
|
60
102
|
},
|
|
61
103
|
label ? /* @__PURE__ */ React__default.createElement(UploadComp.Label, null, label) : null,
|
|
62
|
-
|
|
63
|
-
type === "button" ? /* @__PURE__ */ React__default.createElement(
|
|
64
|
-
UploadComp.Button,
|
|
65
|
-
__spreadValues({}, __spreadValues({
|
|
66
|
-
accept,
|
|
67
|
-
multiple,
|
|
68
|
-
disabled,
|
|
69
|
-
maxCount,
|
|
70
|
-
fileList,
|
|
71
|
-
setFileList,
|
|
72
|
-
validate
|
|
73
|
-
}, buttonProps)),
|
|
74
|
-
t("components.select_file")
|
|
75
|
-
) : /* @__PURE__ */ React__default.createElement(
|
|
76
|
-
UploadComp.Dragger,
|
|
77
|
-
__spreadValues({}, {
|
|
78
|
-
accept,
|
|
79
|
-
multiple,
|
|
80
|
-
disabled,
|
|
81
|
-
maxCount,
|
|
82
|
-
fileList,
|
|
83
|
-
setFileList,
|
|
84
|
-
validate
|
|
85
|
-
})
|
|
86
|
-
),
|
|
87
|
-
info != null ? info : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null),
|
|
88
|
-
type === "button" || !isSingleSelect ? /* @__PURE__ */ React__default.createElement(
|
|
89
|
-
UploadComp.FileList,
|
|
90
|
-
{
|
|
91
|
-
fileList,
|
|
92
|
-
removeFile,
|
|
93
|
-
type: listType,
|
|
94
|
-
disableRemove: disableRemoveList,
|
|
95
|
-
onRemove
|
|
96
|
-
}
|
|
97
|
-
) : null
|
|
104
|
+
labelPosition === "left" && label ? /* @__PURE__ */ React__default.createElement("div", { className: "upload-main" }, uploadContent) : uploadContent
|
|
98
105
|
);
|
|
99
106
|
}
|
|
100
107
|
);
|
|
@@ -2,9 +2,9 @@ import { styled } from '@linaria/react';
|
|
|
2
2
|
|
|
3
3
|
const UploadWrapper = /*#__PURE__*/styled('div')({
|
|
4
4
|
name: "UploadWrapper",
|
|
5
|
-
class: "
|
|
5
|
+
class: "E_4100_0_19_u3l9ivi",
|
|
6
6
|
propsAsIs: false
|
|
7
7
|
});
|
|
8
|
-
const FileInfoWrapperStyle = "
|
|
8
|
+
const FileInfoWrapperStyle = "E_4100_0_19_ftdwz1g";
|
|
9
9
|
|
|
10
10
|
export { FileInfoWrapperStyle, UploadWrapper };
|