@majoo-ui/react 2.0.1 → 2.1.0-rc.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/charts.esm.js +3 -1453
- package/colors/Colors.esm.js +93 -0
- package/components/accordion/Accordion.esm.js +109 -0
- package/components/alertDialog/AlertDialog.esm.js +440 -0
- package/components/avatar/Avatar.esm.js +83 -0
- package/components/badge/Badge.esm.js +255 -0
- package/components/banner/Banner.esm.js +341 -0
- package/components/barChart/BarChart.esm.js +212 -0
- package/components/breadcrumb/Breadcrumb.esm.js +65 -0
- package/components/breadcrumb/index.esm.js +19 -0
- package/components/button/Button.esm.js +331 -0
- package/components/buttonGroup/ButtonGroup.esm.js +350 -0
- package/components/card/Card.esm.js +236 -0
- package/components/chart/assets/data_kosong.png.esm.js +3 -0
- package/components/chart/lineChart/LineChart.esm.js +358 -0
- package/components/chart/lineChart/components/Comparator.esm.js +82 -0
- package/components/chart/lineChart/components/ComparatorController.esm.js +112 -0
- package/components/chart/lineChart/components/ComparatorItem.esm.js +104 -0
- package/components/chart/lineChart/components/ProductList.esm.js +78 -0
- package/components/chart/lineChart/components/TitleLegend.esm.js +107 -0
- package/components/chart/lineChart/components/Tooltip.esm.js +90 -0
- package/components/chart/utils/index.esm.js +109 -0
- package/components/checkboxTable/CheckboxTable.esm.js +287 -0
- package/components/colorPicker/ColorPicker.esm.js +342 -0
- package/components/colorPicker/InputColorPicker.esm.js +120 -0
- package/components/colorPicker/assets/img_colormap.gif.esm.js +3 -0
- package/components/colorPicker/components/ColorFields.esm.js +144 -0
- package/components/colorPicker/components/ColorMap.esm.js +1188 -0
- package/components/contentEditor/ContentEditor.esm.js +251 -0
- package/components/contentEditor/assets/Inline-code-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Link-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-bulleted-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-numbered-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Redo-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-bold-filled.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-clear-format-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-italic-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-strikethrough-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-underline-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Undo-outline.svg.esm.js +3 -0
- package/components/contextMenu/ContextMenu.esm.js +298 -0
- package/components/datePicker/AdvancedOption.esm.js +37 -0
- package/components/datePicker/CustomDatePicker.esm.js +121 -0
- package/components/datePicker/DatePicker.esm.js +244 -0
- package/components/datePicker/DatePickerMulti.esm.js +70 -0
- package/components/datePicker/InputDatePicker.esm.js +290 -0
- package/components/datePicker/InputDateRangePicker.esm.js +174 -0
- package/components/datePicker/components/Calendar.esm.js +654 -0
- package/components/datePicker/components/CalendarMulti.esm.js +407 -0
- package/components/datePicker/components/CalendarTimePicker.esm.js +104 -0
- package/components/datePicker/components/DateNumber.esm.js +89 -0
- package/components/datePicker/components/MobileCalendar.esm.js +522 -0
- package/components/datePicker/state/reducer.esm.js +286 -0
- package/components/datePicker/timePicker/InputTimePicker.esm.js +205 -0
- package/components/datePicker/timePicker/TimePicker.esm.js +481 -0
- package/components/devicePreview/DevicePreview.esm.js +631 -0
- package/components/devicePreview/deviceFrame/android-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/android-wide-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-email.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-notification.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-sms.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-whatsapp.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/desktop-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/ic-majoo-profpic.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/iphone-transparant.png.esm.js +3 -0
- package/components/dialog/Dialog.esm.js +106 -0
- package/components/drawer/Drawer.esm.js +294 -0
- package/components/dropdownMenu/DropdownMenu.esm.js +281 -0
- package/components/editableTable/EditableMobile.esm.js +361 -0
- package/components/editableTable/EditableTable.esm.js +618 -0
- package/components/editableTable/transition.esm.js +37 -0
- package/components/form/components/FormGroup/FormGroup.esm.js +142 -0
- package/components/form/components/FormHelper/Helper.esm.js +50 -0
- package/components/form/components/FormLabel/Label.esm.js +90 -0
- package/components/form/components/InputAddon/InputAddon.esm.js +105 -0
- package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +60 -0
- package/components/form/components/InputCheckbox/InputCheckbox.esm.js +129 -0
- package/components/form/components/InputCheckbox/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputCheckbox/icon/MinusOutline.esm.js +33 -0
- package/components/form/components/InputCombobox/InputCombobox.esm.js +169 -0
- package/components/form/components/InputCounter/InputCounter.esm.js +226 -0
- package/components/form/components/InputCreatable/InputCreatable.esm.js +229 -0
- package/components/form/components/InputDateRange/InputDateRange.esm.js +46 -0
- package/components/form/components/InputElement/InputElement.esm.js +35 -0
- package/components/form/components/InputGroup/InputGroup.esm.js +188 -0
- package/components/form/components/InputLetter/InputLetter.esm.js +68 -0
- package/components/form/components/InputNumber/InputNumber.esm.js +248 -0
- package/components/form/components/InputNumber/NumberFormat.esm.js +1263 -0
- package/components/form/components/InputOTP/InputOTP.esm.js +70 -0
- package/components/form/components/InputRadio/InputRadio.esm.js +273 -0
- package/components/form/components/InputRadio/InputRadioGroup.esm.js +35 -0
- package/components/form/components/InputRadio/context.esm.js +5 -0
- package/components/form/components/InputResourceList/InputResourceList.esm.js +429 -0
- package/components/form/components/InputSearchbox/CloseFilled.esm.js +34 -0
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +90 -0
- package/components/form/components/InputSearchbox/SearchOutline.esm.js +26 -0
- package/components/form/components/InputSelect/InputSelect.esm.js +964 -0
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +1388 -0
- package/components/form/components/InputSelectCheck/OptionGroupItem.esm.js +39 -0
- package/components/form/components/InputSelectCheck/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputSelectTag/InputSelectTag.esm.js +62 -0
- package/components/form/components/InputSignature/InputSignature.esm.js +122 -0
- package/components/form/components/InputSignature/SignatureModal.esm.js +67 -0
- package/components/form/components/InputSwitch/InputSwitch.esm.js +96 -0
- package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +136 -0
- package/components/form/components/InputTags/InputTags.esm.js +268 -0
- package/components/form/components/InputText/InputText.esm.js +197 -0
- package/components/form/components/InputTextArea/InputTextArea.esm.js +77 -0
- package/components/heading/Heading.esm.js +64 -0
- package/components/iconButton/IconButton.esm.js +71 -0
- package/components/image/Image.esm.js +141 -0
- package/components/link/Link.esm.js +59 -0
- package/components/loadingBar/LoadingBar.esm.js +113 -0
- package/components/mapPicker/InputMapPicker.esm.js +160 -0
- package/components/mapPicker/MapPicker.esm.js +122 -0
- package/components/mapPicker/MapPicker.styles.esm.js +70 -0
- package/components/mapPicker/assets/images/Mapsicle.png.esm.js +3 -0
- package/components/mapPicker/components/AddressCard.esm.js +25 -0
- package/components/mapPicker/components/ButtonSelect.esm.js +46 -0
- package/components/mapPicker/components/ChangeView.esm.js +20 -0
- package/components/mapPicker/components/InputSearch.esm.js +74 -0
- package/components/mapPicker/components/MarkerIcon.esm.js +22 -0
- package/components/mapPicker/components/MarkerSvg.esm.js +62 -0
- package/components/mapPicker/components/ZoomControls.esm.js +36 -0
- package/components/mapPicker/hooks/useMapSearch.esm.js +161 -0
- package/components/modalDialog/ModalDialog.esm.js +247 -0
- package/components/notificationBadge/NotificationBadge.esm.js +149 -0
- package/components/pageDialog/PageDialog.esm.js +291 -0
- package/components/pageDialog/logo.svg.esm.js +3 -0
- package/components/pagination/Pagination.esm.js +94 -0
- package/components/pagination/PaginationButton.esm.js +346 -0
- package/components/pagination/PaginationInfo.esm.js +146 -0
- package/components/paper/Paper.esm.js +76 -0
- package/components/paragraph/Paragraph.esm.js +52 -0
- package/components/pieChart/PieChart.esm.js +287 -0
- package/components/popover/Popover.esm.js +142 -0
- package/components/progress/Progress.esm.js +170 -0
- package/components/progressIndicator/ProgressIndicator.esm.js +287 -0
- package/components/scrollSync/ScrollSync.esm.js +172 -0
- package/components/scrollSync/ScrollSyncNode.esm.js +87 -0
- package/components/scrollSync/utils.esm.js +9 -0
- package/components/separator/Separator.esm.js +43 -0
- package/components/skeleton/Skeleton.esm.js +131 -0
- package/components/slider/Slider.esm.js +345 -0
- package/components/stepWizard/StepWizard.esm.js +451 -0
- package/components/stepWizard/index.esm.js +14 -0
- package/components/table/MobileTable.esm.js +415 -0
- package/components/table/Table.esm.js +1472 -0
- package/components/table/components/columns/DateColumn.esm.js +26 -0
- package/components/table/components/columns/DecimalColumn.esm.js +36 -0
- package/components/table/components/columns/PriceColumn.esm.js +57 -0
- package/components/table/components/columns/RowDraggableColumn.esm.js +24 -0
- package/components/table/components/columns/RowExpanderColumn.esm.js +32 -0
- package/components/table/components/columns/RowExpanderMultipleColumn.esm.js +24 -0
- package/components/table/components/columns/RowMenuColumn.esm.js +101 -0
- package/components/table/components/columns/RowSelectionCallbackColumn.esm.js +38 -0
- package/components/table/components/columns/RowSelectionColumn.esm.js +34 -0
- package/components/table/images/img-emptydata.webp.esm.js +3 -0
- package/components/table/images/img-emptysearchdata.webp.esm.js +3 -0
- package/components/tableOfContent/TableOfContent.esm.js +267 -0
- package/components/tableOfContent/index.esm.js +18 -0
- package/components/tableOfContent/transition.esm.js +38 -0
- package/components/tabs/Tabs.esm.js +282 -0
- package/components/tag/Tag.esm.js +161 -0
- package/components/tagList/TagList.esm.js +90 -0
- package/components/tagStatus/TagStatus.esm.js +134 -0
- package/components/text/Text.esm.js +140 -0
- package/components/toast/Toast.esm.js +297 -0
- package/components/toast/ToastContainer.esm.js +73 -0
- package/components/toast/context/ToastContext.esm.js +5 -0
- package/components/toast/context/ToastProvider.esm.js +96 -0
- package/components/tooltip/Tooltip.esm.js +175 -0
- package/components/upload/Upload.esm.js +1103 -0
- package/components/upload/utils/canvasPreview.esm.js +39 -0
- package/components/upload/utils/imgPreview.esm.js +21 -0
- package/config/stitches.config.esm.js +216 -0
- package/editor.esm.js +1 -264
- package/hooks/useListOption/useListOption.esm.js +56 -0
- package/hooks/useToggle/useToggle.esm.js +8 -0
- package/index.esm.js +106 -42293
- package/layout/box/Box.esm.js +24 -0
- package/layout/flex/Flex.esm.js +135 -0
- package/layout/grid/Grid.esm.js +270 -0
- package/layout/pageContainer/PageContainer.esm.js +60 -0
- package/majoo-provider/MajooProvider.esm.js +42 -0
- package/majoo-provider/ThemeProvider.esm.js +41 -0
- package/majoo-provider/globalStyles.esm.js +242 -0
- package/majoo-provider/styles/modern-normalize.esm.js +95 -0
- package/map.esm.js +2 -734
- package/package.json +8 -4
- package/utils/calendar.esm.js +26 -0
- package/utils/element.esm.js +21 -0
- package/utils/object.esm.js +12 -0
- package/utils/request.esm.js +74 -0
- package/utils/strings.esm.js +6 -0
- package/{useMediaQuery.esm.js → utils/useMediaQuery.esm.js} +1 -1
- package/utils/useNavigatorOnline.esm.js +19 -0
- package/utils/variant.esm.js +12 -0
- package/wrapper/ConditionalWrapper.esm.js +9 -0
- package/ModalDialog.esm.js +0 -2669
- package/Separator.esm.js +0 -3002
- package/stitches.config.esm.js +0 -2284
- package/{index.esm.css → charts.esm.css} +4 -4
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import 'core-js/modules/es.iterator.constructor.js';
|
|
2
|
+
import 'core-js/modules/es.iterator.map.js';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import React__default, { useRef, useState } from 'react';
|
|
5
|
+
import { foundations } from '@majoo-ui/core';
|
|
6
|
+
import Box from '../../layout/box/Box.esm.js';
|
|
7
|
+
import Flex from '../../layout/flex/Flex.esm.js';
|
|
8
|
+
import Heading from '../heading/Heading.esm.js';
|
|
9
|
+
import Paragraph from '../paragraph/Paragraph.esm.js';
|
|
10
|
+
import { Separator } from '../separator/Separator.esm.js';
|
|
11
|
+
import Text from '../text/Text.esm.js';
|
|
12
|
+
import { ResponsiveContainer, PieChart as PieChart$1, Pie, Cell, LabelList, Tooltip, Legend, Sector } from 'recharts';
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
colors
|
|
16
|
+
} = foundations;
|
|
17
|
+
const renderActiveShape = (props, avatar, acronym, validAvatar, activeRef) => {
|
|
18
|
+
const {
|
|
19
|
+
cx,
|
|
20
|
+
cy,
|
|
21
|
+
innerRadius,
|
|
22
|
+
outerRadius,
|
|
23
|
+
startAngle,
|
|
24
|
+
endAngle,
|
|
25
|
+
fill
|
|
26
|
+
} = props;
|
|
27
|
+
const IMG_WIDHT = 75;
|
|
28
|
+
const IMG_HEIGHT = 75;
|
|
29
|
+
return jsx(React__default.Fragment, {
|
|
30
|
+
children: jsxs("g", {
|
|
31
|
+
children: [jsx("clipPath", {
|
|
32
|
+
id: "circleAvatar",
|
|
33
|
+
children: jsx("circle", {
|
|
34
|
+
cx: cx + 1,
|
|
35
|
+
cy: cy,
|
|
36
|
+
r: IMG_WIDHT / 2,
|
|
37
|
+
fill: "#FFFFFF"
|
|
38
|
+
})
|
|
39
|
+
}), validAvatar ? jsx("image", {
|
|
40
|
+
x: cx - IMG_WIDHT / 2,
|
|
41
|
+
y: cy - IMG_HEIGHT / 2,
|
|
42
|
+
width: IMG_WIDHT,
|
|
43
|
+
height: IMG_HEIGHT,
|
|
44
|
+
href: avatar,
|
|
45
|
+
clipPath: "url(#circleAvatar)"
|
|
46
|
+
}) : jsxs(React__default.Fragment, {
|
|
47
|
+
children: [jsx("circle", {
|
|
48
|
+
cx: cx,
|
|
49
|
+
cy: cy,
|
|
50
|
+
r: IMG_WIDHT / 2,
|
|
51
|
+
fill: foundations.colors.bgBorder
|
|
52
|
+
}), jsx("text", {
|
|
53
|
+
x: cx,
|
|
54
|
+
y: cy,
|
|
55
|
+
textAnchor: "middle",
|
|
56
|
+
alignmentBaseline: "middle",
|
|
57
|
+
fontFamily: "main",
|
|
58
|
+
fontWeight: "600",
|
|
59
|
+
children: acronym
|
|
60
|
+
})]
|
|
61
|
+
}), jsx(Sector, {
|
|
62
|
+
cx: cx,
|
|
63
|
+
cy: cy,
|
|
64
|
+
innerRadius: innerRadius,
|
|
65
|
+
outerRadius: activeRef.current ? outerRadius + 12 : outerRadius,
|
|
66
|
+
startAngle: startAngle,
|
|
67
|
+
endAngle: endAngle,
|
|
68
|
+
fill: fill,
|
|
69
|
+
style: {
|
|
70
|
+
outline: 'none'
|
|
71
|
+
}
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const renderLegend = (formattedData, legend, subtitle) => jsxs(Box, {
|
|
77
|
+
children: [jsx(Flex, {
|
|
78
|
+
css: {
|
|
79
|
+
marginTop: '$spacing-05',
|
|
80
|
+
height: 18
|
|
81
|
+
},
|
|
82
|
+
justify: "center",
|
|
83
|
+
children: subtitle && jsx(Heading, {
|
|
84
|
+
heading: "sectionTitle",
|
|
85
|
+
children: subtitle
|
|
86
|
+
})
|
|
87
|
+
}), formattedData.length > 0 && jsx(Flex, {
|
|
88
|
+
css: {
|
|
89
|
+
marginTop: '$spacing-06'
|
|
90
|
+
},
|
|
91
|
+
direction: "column",
|
|
92
|
+
gap: 5,
|
|
93
|
+
children: formattedData === null || formattedData === void 0 ? void 0 : formattedData.map((data, index) => {
|
|
94
|
+
var _a;
|
|
95
|
+
return jsxs(Box, {
|
|
96
|
+
children: [jsxs(Flex, {
|
|
97
|
+
justify: "between",
|
|
98
|
+
children: [jsxs(Flex, {
|
|
99
|
+
align: "center",
|
|
100
|
+
children: [jsx(Box, {
|
|
101
|
+
css: {
|
|
102
|
+
backgroundColor: data.color,
|
|
103
|
+
borderRadius: '50%',
|
|
104
|
+
height: 12,
|
|
105
|
+
width: 12,
|
|
106
|
+
display: 'inline-block',
|
|
107
|
+
marginRight: '$spacing-03'
|
|
108
|
+
}
|
|
109
|
+
}), jsx(Box, {
|
|
110
|
+
css: {
|
|
111
|
+
width: 120
|
|
112
|
+
},
|
|
113
|
+
children: jsx(Text, {
|
|
114
|
+
variant: "label",
|
|
115
|
+
color: "secondary",
|
|
116
|
+
children: data.name
|
|
117
|
+
})
|
|
118
|
+
})]
|
|
119
|
+
}), (legend === null || legend === void 0 ? void 0 : legend.showTotal) && jsx(Text, {
|
|
120
|
+
variant: "label",
|
|
121
|
+
color: "secondary",
|
|
122
|
+
children: (_a = formattedData[index]) === null || _a === void 0 ? void 0 : _a.total
|
|
123
|
+
})]
|
|
124
|
+
}), jsx(Separator, {
|
|
125
|
+
css: {
|
|
126
|
+
marginTop: '$spacing-03'
|
|
127
|
+
}
|
|
128
|
+
})]
|
|
129
|
+
}, index);
|
|
130
|
+
})
|
|
131
|
+
})]
|
|
132
|
+
});
|
|
133
|
+
const PieChart = ({
|
|
134
|
+
data,
|
|
135
|
+
css,
|
|
136
|
+
avatarURL,
|
|
137
|
+
avatarAcronym,
|
|
138
|
+
validAvatar,
|
|
139
|
+
legend,
|
|
140
|
+
isMobile,
|
|
141
|
+
tooltip,
|
|
142
|
+
title,
|
|
143
|
+
subtitle,
|
|
144
|
+
label,
|
|
145
|
+
outerRadius,
|
|
146
|
+
innerRadius
|
|
147
|
+
}) => {
|
|
148
|
+
var _a;
|
|
149
|
+
const emptyData = [{
|
|
150
|
+
id: '0',
|
|
151
|
+
name: '',
|
|
152
|
+
total: 1,
|
|
153
|
+
color: foundations.colors.chartLightGray
|
|
154
|
+
}];
|
|
155
|
+
const dataChart = data.map(item => Object.assign(Object.assign({}, item), {
|
|
156
|
+
total: Number(item.total)
|
|
157
|
+
}));
|
|
158
|
+
const activeRef = useRef();
|
|
159
|
+
const formattedData = data.length > 0 ? dataChart : emptyData;
|
|
160
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
161
|
+
const CONTAINER_HEIGHT = (legend === null || legend === void 0 ? void 0 : legend.position) === 'bottom' ? subtitle ? 420 : 380 : 230;
|
|
162
|
+
const CONTAINER_WIDTH = isMobile ? 350 : 450;
|
|
163
|
+
const CHART_HEIGHT = 150;
|
|
164
|
+
const CHART_WIDTH = 450;
|
|
165
|
+
const CustomTooltip = ({
|
|
166
|
+
payload = {},
|
|
167
|
+
active = false
|
|
168
|
+
}) => {
|
|
169
|
+
var _a;
|
|
170
|
+
if (active) {
|
|
171
|
+
const {
|
|
172
|
+
total,
|
|
173
|
+
name
|
|
174
|
+
} = payload[0].payload;
|
|
175
|
+
return jsxs(Box, {
|
|
176
|
+
css: {
|
|
177
|
+
backgroundColor: '$textContent',
|
|
178
|
+
color: '$white',
|
|
179
|
+
borderRadius: '$sm',
|
|
180
|
+
padding: '$spacing-02',
|
|
181
|
+
flexDirection: 'column'
|
|
182
|
+
},
|
|
183
|
+
children: [jsx(Text, {
|
|
184
|
+
variant: "placeholder",
|
|
185
|
+
color: "disable",
|
|
186
|
+
css: {
|
|
187
|
+
fontSize: 11
|
|
188
|
+
},
|
|
189
|
+
children: name
|
|
190
|
+
}), jsx(Paragraph, {
|
|
191
|
+
paragraph: "shortContentRegular",
|
|
192
|
+
css: {
|
|
193
|
+
color: '$white',
|
|
194
|
+
fontSize: 12
|
|
195
|
+
},
|
|
196
|
+
children: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.label) ? (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.label) === null || _a === void 0 ? void 0 : _a.call(tooltip, total) : total
|
|
197
|
+
})]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
};
|
|
202
|
+
return jsxs(Box, {
|
|
203
|
+
children: [title && jsx(Heading, {
|
|
204
|
+
heading: "sectionTitle",
|
|
205
|
+
children: title
|
|
206
|
+
}), jsx(Box, {
|
|
207
|
+
css: Object.assign({
|
|
208
|
+
position: 'relative',
|
|
209
|
+
width: CONTAINER_WIDTH,
|
|
210
|
+
height: CONTAINER_HEIGHT,
|
|
211
|
+
marginTop: '$spacing-07'
|
|
212
|
+
}, css),
|
|
213
|
+
children: jsx(ResponsiveContainer, {
|
|
214
|
+
width: "100%",
|
|
215
|
+
height: "100%",
|
|
216
|
+
children: jsxs(PieChart$1, {
|
|
217
|
+
width: CHART_WIDTH,
|
|
218
|
+
height: CHART_HEIGHT,
|
|
219
|
+
children: [jsxs(Pie, Object.assign({
|
|
220
|
+
activeIndex: activeIndex,
|
|
221
|
+
activeShape: shape => renderActiveShape(shape, avatarURL, avatarAcronym, validAvatar, activeRef),
|
|
222
|
+
data: formattedData,
|
|
223
|
+
cx: "50%",
|
|
224
|
+
cy: "50%",
|
|
225
|
+
innerRadius: innerRadius,
|
|
226
|
+
outerRadius: outerRadius,
|
|
227
|
+
dataKey: "total",
|
|
228
|
+
onMouseEnter: x => {
|
|
229
|
+
setActiveIndex(formattedData.findIndex(y => y.name === x.name));
|
|
230
|
+
activeRef.current = true;
|
|
231
|
+
},
|
|
232
|
+
onMouseLeave: () => activeRef.current = false,
|
|
233
|
+
blendStroke: true
|
|
234
|
+
}, (label === null || label === void 0 ? void 0 : label.show) && (label === null || label === void 0 ? void 0 : label.render) && {
|
|
235
|
+
label: e => {
|
|
236
|
+
var _a;
|
|
237
|
+
return (_a = label === null || label === void 0 ? void 0 : label.render) === null || _a === void 0 ? void 0 : _a.call(label, e);
|
|
238
|
+
},
|
|
239
|
+
labelLine: false
|
|
240
|
+
}, {
|
|
241
|
+
children: [formattedData.map(item => jsx(Cell, {
|
|
242
|
+
fill: item.color || colors.chartGreen
|
|
243
|
+
}, item.name)), (label === null || label === void 0 ? void 0 : label.show) && !label.render && jsx(LabelList, {
|
|
244
|
+
stroke: "0",
|
|
245
|
+
fill: colors.textWhite,
|
|
246
|
+
dataKey: (label === null || label === void 0 ? void 0 : label.dataKey) || 'total',
|
|
247
|
+
formatter: label === null || label === void 0 ? void 0 : label.formatter,
|
|
248
|
+
position: label === null || label === void 0 ? void 0 : label.position
|
|
249
|
+
})]
|
|
250
|
+
})), data.length > 0 && jsx(Tooltip, {
|
|
251
|
+
wrapperStyle: {
|
|
252
|
+
outline: 'none'
|
|
253
|
+
},
|
|
254
|
+
cursor: true,
|
|
255
|
+
content: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.render) ? (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.render) === null || _a === void 0 ? void 0 : _a.call(tooltip) : jsx(CustomTooltip, {})
|
|
256
|
+
}), Boolean(legend === null || legend === void 0 ? void 0 : legend.show) && jsx(Legend, Object.assign({
|
|
257
|
+
height: (legend === null || legend === void 0 ? void 0 : legend.height) || 210
|
|
258
|
+
}, (legend === null || legend === void 0 ? void 0 : legend.position) !== 'bottom' && {
|
|
259
|
+
verticalAlign: 'middle',
|
|
260
|
+
align: (legend === null || legend === void 0 ? void 0 : legend.position) || 'right',
|
|
261
|
+
layout: 'vertical'
|
|
262
|
+
}, {
|
|
263
|
+
content: renderLegend(formattedData, legend, subtitle)
|
|
264
|
+
}))]
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
})]
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
PieChart.defaultProps = {
|
|
271
|
+
data: [],
|
|
272
|
+
avatarURL: undefined,
|
|
273
|
+
avatarAcronym: '',
|
|
274
|
+
validAvatar: false,
|
|
275
|
+
legend: {
|
|
276
|
+
show: true,
|
|
277
|
+
showTotal: true,
|
|
278
|
+
data: [],
|
|
279
|
+
position: 'right',
|
|
280
|
+
height: 210
|
|
281
|
+
},
|
|
282
|
+
isMobile: false,
|
|
283
|
+
outerRadius: 100,
|
|
284
|
+
innerRadius: 70
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export { PieChart as default };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { useFloating, offset, shift, flip, useInteractions, useClick, useDismiss, FloatingFocusManager, FloatingPortal } from '@floating-ui/react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useState, useEffect, useContext, cloneElement, createContext } from 'react';
|
|
4
|
+
import Flex from '../../layout/flex/Flex.esm.js';
|
|
5
|
+
import { foundations } from '@majoo-ui/core';
|
|
6
|
+
import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
|
|
7
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
zIndices
|
|
11
|
+
} = foundations;
|
|
12
|
+
const PopoverContext = /*#__PURE__*/createContext();
|
|
13
|
+
const Popover = ({
|
|
14
|
+
children,
|
|
15
|
+
open = false,
|
|
16
|
+
onOpenChange,
|
|
17
|
+
placement,
|
|
18
|
+
sideOffset = 5,
|
|
19
|
+
hideOnScroll = false,
|
|
20
|
+
flip: flip$1 = true,
|
|
21
|
+
onClose
|
|
22
|
+
}) => {
|
|
23
|
+
const [openState, setOpenState] = useState(false);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setOpenState(open);
|
|
26
|
+
}, [open]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (onOpenChange) onOpenChange(openState);
|
|
29
|
+
}, [openState, onOpenChange]);
|
|
30
|
+
const floatingHook = useFloating({
|
|
31
|
+
open: openState,
|
|
32
|
+
middleware: [offset(sideOffset), shift(), flip$1 && flip()],
|
|
33
|
+
onOpenChange: isOpen => {
|
|
34
|
+
setOpenState(isOpen);
|
|
35
|
+
!isOpen && onClose?.();
|
|
36
|
+
},
|
|
37
|
+
placement
|
|
38
|
+
});
|
|
39
|
+
const {
|
|
40
|
+
getReferenceProps,
|
|
41
|
+
getFloatingProps
|
|
42
|
+
} = useInteractions([useClick(floatingHook.context, {
|
|
43
|
+
keyboardHandlers: false
|
|
44
|
+
}), useDismiss(floatingHook.context, {
|
|
45
|
+
ancestorScroll: hideOnScroll
|
|
46
|
+
})]);
|
|
47
|
+
const value = {
|
|
48
|
+
openState,
|
|
49
|
+
setOpenState,
|
|
50
|
+
floatingHook,
|
|
51
|
+
getReferenceProps,
|
|
52
|
+
getFloatingProps
|
|
53
|
+
};
|
|
54
|
+
return /*#__PURE__*/jsx(PopoverContext.Provider, {
|
|
55
|
+
value: value,
|
|
56
|
+
children: children
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const PopoverTrigger = ({
|
|
60
|
+
children,
|
|
61
|
+
disabled
|
|
62
|
+
}) => {
|
|
63
|
+
const {
|
|
64
|
+
floatingHook: {
|
|
65
|
+
refs
|
|
66
|
+
},
|
|
67
|
+
getReferenceProps
|
|
68
|
+
} = useContext(PopoverContext);
|
|
69
|
+
return disabled ? children : /*#__PURE__*/cloneElement(children, getReferenceProps({
|
|
70
|
+
ref: refs.setReference,
|
|
71
|
+
...children.props
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
const PopoverContent = ({
|
|
75
|
+
children,
|
|
76
|
+
isMobile,
|
|
77
|
+
style,
|
|
78
|
+
portalled
|
|
79
|
+
}) => {
|
|
80
|
+
const {
|
|
81
|
+
openState,
|
|
82
|
+
floatingHook: {
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
strategy,
|
|
86
|
+
context,
|
|
87
|
+
refs
|
|
88
|
+
},
|
|
89
|
+
getFloatingProps
|
|
90
|
+
} = useContext(PopoverContext);
|
|
91
|
+
return openState ? /*#__PURE__*/jsx(ConditionalWrapper, {
|
|
92
|
+
condition: portalled,
|
|
93
|
+
wrapper: child => /*#__PURE__*/jsx(FloatingPortal, {
|
|
94
|
+
children: child
|
|
95
|
+
}),
|
|
96
|
+
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
97
|
+
context: context,
|
|
98
|
+
modal: false,
|
|
99
|
+
order: ['reference', 'content'],
|
|
100
|
+
returnFocus: false,
|
|
101
|
+
children: /*#__PURE__*/jsx("div", {
|
|
102
|
+
...getFloatingProps({
|
|
103
|
+
ref: refs.setFloating,
|
|
104
|
+
style: {
|
|
105
|
+
position: strategy,
|
|
106
|
+
top: isMobile ? 0 : y ?? '',
|
|
107
|
+
left: isMobile ? 0 : x ?? '',
|
|
108
|
+
zIndex: zIndices.popover,
|
|
109
|
+
...style
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
children: children
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
}) : /*#__PURE__*/jsx(Fragment, {});
|
|
116
|
+
};
|
|
117
|
+
const PopoverClose = ({
|
|
118
|
+
children,
|
|
119
|
+
...props
|
|
120
|
+
}) => {
|
|
121
|
+
const {
|
|
122
|
+
setOpenState
|
|
123
|
+
} = useContext(PopoverContext);
|
|
124
|
+
return /*#__PURE__*/jsx(Flex, {
|
|
125
|
+
...props,
|
|
126
|
+
onClick: () => {
|
|
127
|
+
if (props.onClick) props.onClick();
|
|
128
|
+
setOpenState(false);
|
|
129
|
+
},
|
|
130
|
+
children: children
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
Popover.propTypes = {
|
|
134
|
+
open: PropTypes.bool,
|
|
135
|
+
onOpenChange: PropTypes.func,
|
|
136
|
+
placement: PropTypes.oneOf(['top', 'top-start', 'top-end', 'right', 'right-start', 'right-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end']),
|
|
137
|
+
sideOffset: PropTypes.number,
|
|
138
|
+
hideOnScroll: PropTypes.bool
|
|
139
|
+
};
|
|
140
|
+
Popover.displayName = 'Popover';
|
|
141
|
+
|
|
142
|
+
export { Popover, PopoverClose, PopoverContent, PopoverTrigger };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import { styled } from '@stitches/react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
const StyledProgress = styled(ProgressPrimitive.Root, {
|
|
8
|
+
position: 'relative',
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
background: '$chartLightBrand',
|
|
11
|
+
width: 'auto',
|
|
12
|
+
height: '12px',
|
|
13
|
+
variants: {
|
|
14
|
+
rounded: {
|
|
15
|
+
true: {
|
|
16
|
+
borderRadius: '100px'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
color: {
|
|
20
|
+
green: {
|
|
21
|
+
backgroundColor: '$chartLightGreen'
|
|
22
|
+
},
|
|
23
|
+
orange: {
|
|
24
|
+
backgroundColor: '$chartLightOrange'
|
|
25
|
+
},
|
|
26
|
+
blue: {
|
|
27
|
+
backgroundColor: '$chartLightBlue'
|
|
28
|
+
},
|
|
29
|
+
purple: {
|
|
30
|
+
backgroundColor: '$chartLightPurple'
|
|
31
|
+
},
|
|
32
|
+
yellow: {
|
|
33
|
+
backgroundColor: '$chartLightYellow'
|
|
34
|
+
},
|
|
35
|
+
red: {
|
|
36
|
+
backgroundColor: '$chartLightRed'
|
|
37
|
+
},
|
|
38
|
+
dark: {
|
|
39
|
+
backgroundColor: '$chartLightGray'
|
|
40
|
+
},
|
|
41
|
+
brand: {
|
|
42
|
+
backgroundColor: '$chartLightBrand'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
size: {
|
|
46
|
+
xs: {
|
|
47
|
+
height: '4px'
|
|
48
|
+
},
|
|
49
|
+
sm: {
|
|
50
|
+
height: '8px'
|
|
51
|
+
},
|
|
52
|
+
m: {
|
|
53
|
+
height: '12px'
|
|
54
|
+
},
|
|
55
|
+
l: {
|
|
56
|
+
height: '16px'
|
|
57
|
+
},
|
|
58
|
+
xl: {
|
|
59
|
+
height: '20px'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const StyledIndicator = styled(ProgressPrimitive.Indicator, {
|
|
65
|
+
backgroundColor: '$chartBrand',
|
|
66
|
+
height: '60%',
|
|
67
|
+
transition: 'width 660ms cubic-bezier(0.65, 0, 0.35, 1)',
|
|
68
|
+
variants: {
|
|
69
|
+
rounded: {
|
|
70
|
+
true: {
|
|
71
|
+
borderRadius: '100px'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
color: {
|
|
75
|
+
green: {
|
|
76
|
+
backgroundColor: '$chartGreen'
|
|
77
|
+
},
|
|
78
|
+
orange: {
|
|
79
|
+
backgroundColor: '$chartOrange'
|
|
80
|
+
},
|
|
81
|
+
blue: {
|
|
82
|
+
backgroundColor: '$chartBlue'
|
|
83
|
+
},
|
|
84
|
+
purple: {
|
|
85
|
+
backgroundColor: '$chartPurple'
|
|
86
|
+
},
|
|
87
|
+
yellow: {
|
|
88
|
+
backgroundColor: '$chartYellow'
|
|
89
|
+
},
|
|
90
|
+
red: {
|
|
91
|
+
backgroundColor: '$chartRed'
|
|
92
|
+
},
|
|
93
|
+
dark: {
|
|
94
|
+
backgroundColor: '$chartDark'
|
|
95
|
+
},
|
|
96
|
+
brand: {
|
|
97
|
+
backgroundColor: '$chartBrand'
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
size: {
|
|
101
|
+
xs: {
|
|
102
|
+
height: '100%'
|
|
103
|
+
},
|
|
104
|
+
sm: {
|
|
105
|
+
height: '100%'
|
|
106
|
+
},
|
|
107
|
+
m: {
|
|
108
|
+
margin: "2px 2px 0"
|
|
109
|
+
},
|
|
110
|
+
l: {
|
|
111
|
+
margin: "3px 3px 0"
|
|
112
|
+
},
|
|
113
|
+
xl: {
|
|
114
|
+
margin: "4px 4px 0"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
function Progress({
|
|
120
|
+
className,
|
|
121
|
+
value,
|
|
122
|
+
max,
|
|
123
|
+
getValueLabel,
|
|
124
|
+
color,
|
|
125
|
+
size,
|
|
126
|
+
rounded,
|
|
127
|
+
width,
|
|
128
|
+
...props
|
|
129
|
+
}) {
|
|
130
|
+
return /*#__PURE__*/jsx(StyledProgress, {
|
|
131
|
+
className: className,
|
|
132
|
+
value: value,
|
|
133
|
+
max: max,
|
|
134
|
+
getValueLabel: getValueLabel,
|
|
135
|
+
color: color,
|
|
136
|
+
size: size,
|
|
137
|
+
rounded: rounded,
|
|
138
|
+
css: {
|
|
139
|
+
width: width,
|
|
140
|
+
...props.css
|
|
141
|
+
},
|
|
142
|
+
...props,
|
|
143
|
+
children: /*#__PURE__*/jsx(StyledIndicator, {
|
|
144
|
+
color: color,
|
|
145
|
+
size: size,
|
|
146
|
+
rounded: rounded,
|
|
147
|
+
css: {
|
|
148
|
+
width: `${value}%`
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
Progress.propTypes = {
|
|
154
|
+
className: PropTypes.string,
|
|
155
|
+
value: PropTypes.number,
|
|
156
|
+
max: PropTypes.number,
|
|
157
|
+
getValueLabel: PropTypes.func,
|
|
158
|
+
color: PropTypes.string,
|
|
159
|
+
size: PropTypes.string,
|
|
160
|
+
rounded: PropTypes.bool,
|
|
161
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
162
|
+
};
|
|
163
|
+
Progress.defaultProps = {
|
|
164
|
+
max: 100,
|
|
165
|
+
color: 'brand',
|
|
166
|
+
size: 'm',
|
|
167
|
+
rounded: true
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export { Progress, Progress as default };
|