@majoo-ui/react 2.0.1 → 2.1.0-rc.1
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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
function useMapSearch({
|
|
5
|
+
initialCenter = {
|
|
6
|
+
lat: -6.175392,
|
|
7
|
+
lng: 106.827153
|
|
8
|
+
},
|
|
9
|
+
showSelectButton = true,
|
|
10
|
+
onChange
|
|
11
|
+
}) {
|
|
12
|
+
const [center, setCenter] = useState(initialCenter);
|
|
13
|
+
const [places, setPlaces] = useState([]);
|
|
14
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
15
|
+
const [searchResult, setSearchResult] = useState([]);
|
|
16
|
+
// Track if component is mounted to prevent state updates after unmount
|
|
17
|
+
const isMountedRef = useRef(true);
|
|
18
|
+
// AbortController to cancel pending fetch requests
|
|
19
|
+
const abortControllerRef = useRef(null);
|
|
20
|
+
// Cleanup on unmount
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
isMountedRef.current = true;
|
|
23
|
+
return () => {
|
|
24
|
+
var _a;
|
|
25
|
+
isMountedRef.current = false;
|
|
26
|
+
// Abort any pending fetch requests
|
|
27
|
+
(_a = abortControllerRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
const getFullAddress = useCallback((latLng, signal) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
try {
|
|
32
|
+
const res = yield fetch(`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${Number(latLng.lat)}&lon=${Number(latLng.lng)}&accept-language=id`, {
|
|
33
|
+
signal
|
|
34
|
+
});
|
|
35
|
+
const location = yield res.json();
|
|
36
|
+
return location;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.name === 'AbortError') {
|
|
39
|
+
return null; // Request was cancelled, return null
|
|
40
|
+
}
|
|
41
|
+
throw new Error('Failed to search address');
|
|
42
|
+
}
|
|
43
|
+
}), []);
|
|
44
|
+
const handleSelect = useCallback(({
|
|
45
|
+
lat,
|
|
46
|
+
lon,
|
|
47
|
+
display_name,
|
|
48
|
+
place_id,
|
|
49
|
+
address
|
|
50
|
+
}) => {
|
|
51
|
+
// Only update state if component is still mounted
|
|
52
|
+
if (!isMountedRef.current) return;
|
|
53
|
+
setCenter({
|
|
54
|
+
lat: Number(lat),
|
|
55
|
+
lng: Number(lon)
|
|
56
|
+
});
|
|
57
|
+
setPlaces([{
|
|
58
|
+
lat,
|
|
59
|
+
lon,
|
|
60
|
+
place_id,
|
|
61
|
+
display_name,
|
|
62
|
+
address
|
|
63
|
+
}]);
|
|
64
|
+
setSearchQuery('');
|
|
65
|
+
setSearchResult([]);
|
|
66
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
67
|
+
place_id: place_id,
|
|
68
|
+
lat: Number(lat),
|
|
69
|
+
lng: Number(lon),
|
|
70
|
+
formatted_address: display_name,
|
|
71
|
+
address_components: address
|
|
72
|
+
}, !showSelectButton);
|
|
73
|
+
}, [onChange, showSelectButton]);
|
|
74
|
+
const handleSearchSelect = useCallback(item => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
var _a;
|
|
76
|
+
// Cancel any previous pending request
|
|
77
|
+
(_a = abortControllerRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
78
|
+
abortControllerRef.current = new AbortController();
|
|
79
|
+
const fullAddress = yield getFullAddress({
|
|
80
|
+
lat: Number(item.lat),
|
|
81
|
+
lng: Number(item.lon)
|
|
82
|
+
}, abortControllerRef.current.signal);
|
|
83
|
+
// getFullAddress returns null if aborted
|
|
84
|
+
if (fullAddress) {
|
|
85
|
+
handleSelect(fullAddress);
|
|
86
|
+
}
|
|
87
|
+
}), [getFullAddress, handleSelect]);
|
|
88
|
+
const handleSearchLatLng = useCallback(latLng => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
var _b;
|
|
90
|
+
// Cancel any previous pending request
|
|
91
|
+
(_b = abortControllerRef.current) === null || _b === void 0 ? void 0 : _b.abort();
|
|
92
|
+
abortControllerRef.current = new AbortController();
|
|
93
|
+
const fullAddress = yield getFullAddress(latLng, abortControllerRef.current.signal);
|
|
94
|
+
// getFullAddress returns null if aborted
|
|
95
|
+
if (fullAddress) {
|
|
96
|
+
const {
|
|
97
|
+
lat,
|
|
98
|
+
lon,
|
|
99
|
+
display_name,
|
|
100
|
+
place_id,
|
|
101
|
+
address
|
|
102
|
+
} = fullAddress;
|
|
103
|
+
handleSelect({
|
|
104
|
+
lat,
|
|
105
|
+
lon,
|
|
106
|
+
display_name,
|
|
107
|
+
place_id,
|
|
108
|
+
address
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}), [getFullAddress, handleSelect]);
|
|
112
|
+
const handleSearch = useCallback((query, signal) => __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
try {
|
|
114
|
+
const res = yield fetch(`https://nominatim.openstreetmap.org/search.php?q=${query}&polygon_geojson=1&format=jsonv2`, {
|
|
115
|
+
signal
|
|
116
|
+
});
|
|
117
|
+
const result = yield res.json();
|
|
118
|
+
// Only update state if component is still mounted
|
|
119
|
+
if (isMountedRef.current) {
|
|
120
|
+
setSearchResult(result);
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (error.name === 'AbortError') {
|
|
124
|
+
return; // Request was cancelled, do nothing
|
|
125
|
+
}
|
|
126
|
+
throw new Error('Failed to search address');
|
|
127
|
+
}
|
|
128
|
+
}), []);
|
|
129
|
+
// Debounced search effect
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
let timeoutId = setTimeout(() => ({}), 1000);
|
|
132
|
+
const searchAbortController = new AbortController();
|
|
133
|
+
clearTimeout(timeoutId);
|
|
134
|
+
timeoutId = setTimeout(() => {
|
|
135
|
+
if (searchQuery) {
|
|
136
|
+
handleSearch(searchQuery, searchAbortController.signal);
|
|
137
|
+
}
|
|
138
|
+
}, 1000);
|
|
139
|
+
return () => {
|
|
140
|
+
clearTimeout(timeoutId);
|
|
141
|
+
searchAbortController.abort();
|
|
142
|
+
};
|
|
143
|
+
}, [searchQuery, handleSearch]);
|
|
144
|
+
const handleSearchChange = useCallback(e => {
|
|
145
|
+
const val = e.target.value;
|
|
146
|
+
setSearchQuery(val);
|
|
147
|
+
}, []);
|
|
148
|
+
return {
|
|
149
|
+
center,
|
|
150
|
+
setCenter,
|
|
151
|
+
places,
|
|
152
|
+
searchQuery,
|
|
153
|
+
searchResult,
|
|
154
|
+
handleSearchChange,
|
|
155
|
+
handleSearchSelect,
|
|
156
|
+
handleSearchLatLng,
|
|
157
|
+
getFullAddress
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { useMapSearch };
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import 'core-js/modules/es.iterator.constructor.js';
|
|
2
|
+
import 'core-js/modules/es.iterator.find.js';
|
|
3
|
+
import 'core-js/modules/es.iterator.to-array.js';
|
|
4
|
+
import { __rest } from 'tslib';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
import React__default, { useCallback } from 'react';
|
|
7
|
+
import { styled } from '../../config/stitches.config.esm.js';
|
|
8
|
+
import Box from '../../layout/box/Box.esm.js';
|
|
9
|
+
import Dialog, { DialogContent, DialogTrigger, DialogPortal, DialogTitle, DialogClose } from '../dialog/Dialog.esm.js';
|
|
10
|
+
import Heading from '../heading/Heading.esm.js';
|
|
11
|
+
import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
|
|
12
|
+
import { CloseOutline } from '@majoo-ui/icons';
|
|
13
|
+
import { useThemeProvider } from '@majoo-ui/helpers';
|
|
14
|
+
|
|
15
|
+
const ModalDialogFooter = styled('div');
|
|
16
|
+
ModalDialogFooter.displayName = 'ModalDialogFooter';
|
|
17
|
+
const ModalDialogTitle = styled('div');
|
|
18
|
+
ModalDialogTitle.displayName = 'ModalDialogTitle';
|
|
19
|
+
const ModalDialogContent = styled('div');
|
|
20
|
+
ModalDialogContent.displayName = 'ModalDialogContent';
|
|
21
|
+
const ModalDialogTrigger = styled('div');
|
|
22
|
+
ModalDialogTrigger.displayName = 'ModalDialogTrigger';
|
|
23
|
+
const StyledContent = styled(DialogContent, {
|
|
24
|
+
top: 'auto',
|
|
25
|
+
bottom: 0,
|
|
26
|
+
left: 0,
|
|
27
|
+
transform: 'translate(0,0)',
|
|
28
|
+
'& > div': {
|
|
29
|
+
borderBottomRightRadius: 0,
|
|
30
|
+
borderBottomLeftRadius: 0
|
|
31
|
+
},
|
|
32
|
+
'@md': {
|
|
33
|
+
top: '50%',
|
|
34
|
+
left: '50%',
|
|
35
|
+
bottom: 'unset',
|
|
36
|
+
transform: 'translate(-50%, -50%)',
|
|
37
|
+
'& > div': {
|
|
38
|
+
borderBottomRightRadius: '$lg',
|
|
39
|
+
borderBottomLeftRadius: '$lg'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
variants: {
|
|
43
|
+
isMobile: {
|
|
44
|
+
true: {
|
|
45
|
+
top: 'auto',
|
|
46
|
+
bottom: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
transform: 'translate(0,0)',
|
|
49
|
+
maxWidth: 'unset',
|
|
50
|
+
'& > div': {
|
|
51
|
+
borderBottomRightRadius: 0,
|
|
52
|
+
borderBottomLeftRadius: 0
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
false: {
|
|
56
|
+
top: '50%',
|
|
57
|
+
left: '50%',
|
|
58
|
+
bottom: 'unset',
|
|
59
|
+
transform: 'translate(-50%, -50%)',
|
|
60
|
+
'& > div': {
|
|
61
|
+
borderBottomRightRadius: '$lg',
|
|
62
|
+
borderBottomLeftRadius: '$lg'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const StyledOverlay = styled(Box, {
|
|
69
|
+
backgroundColor: '$bgDimmer',
|
|
70
|
+
position: 'fixed',
|
|
71
|
+
inset: 0
|
|
72
|
+
});
|
|
73
|
+
const findNodeChild = (array, displayName) => {
|
|
74
|
+
const result = array.find(child => {
|
|
75
|
+
if (/*#__PURE__*/React__default.isValidElement(child)) {
|
|
76
|
+
const reactElement = child;
|
|
77
|
+
if (typeof reactElement.type !== 'string') {
|
|
78
|
+
const reactFC = reactElement.type;
|
|
79
|
+
if (reactFC.displayName === displayName) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
});
|
|
86
|
+
return result;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* ModalDialog are used to focus and display content that contains one specific task that requires interaction from the user and is separate from the main page.
|
|
90
|
+
* https://react-majoo-ui.mangkujagat.com/?path=/story/core-components-pagedialog--default
|
|
91
|
+
* @param size - default fullsize
|
|
92
|
+
* @param layer - z-index default 1400
|
|
93
|
+
* @param isMobile - force mobile/desktop view, default is responsive
|
|
94
|
+
* @param onOpenAutoFocus - set default open behaviour
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* // Uncontrolled Example
|
|
98
|
+
* <ModalDialog>
|
|
99
|
+
* <ModalDialogTrigger>Button Trigger</ModalDialogTrigger>
|
|
100
|
+
* <ModalDialogTitle>Title</ModalDialogTitle>
|
|
101
|
+
* <ModalDialogContent>Content</ModalDialogContent>
|
|
102
|
+
* <ModalDialogFooter>Footer</ModalDialogFooter>
|
|
103
|
+
* </ModalDialog>
|
|
104
|
+
* @component
|
|
105
|
+
*/
|
|
106
|
+
const ModalDialog = props => {
|
|
107
|
+
const {
|
|
108
|
+
children,
|
|
109
|
+
size,
|
|
110
|
+
css,
|
|
111
|
+
layer,
|
|
112
|
+
isMobile,
|
|
113
|
+
width,
|
|
114
|
+
onOpenAutoFocus,
|
|
115
|
+
disabledCloseButton,
|
|
116
|
+
onPointerDownOutside,
|
|
117
|
+
onCloseClick,
|
|
118
|
+
theme
|
|
119
|
+
} = props,
|
|
120
|
+
rest = __rest(props, ["children", "size", "css", "layer", "isMobile", "width", "onOpenAutoFocus", "disabledCloseButton", "onPointerDownOutside", "onCloseClick", "theme"]);
|
|
121
|
+
const childArray = React__default.Children.toArray(children);
|
|
122
|
+
const modalDialogFooter = findNodeChild(childArray, 'ModalDialogFooter');
|
|
123
|
+
const modalDialogTitle = findNodeChild(childArray, 'ModalDialogTitle');
|
|
124
|
+
const modalDialogContent = findNodeChild(childArray, 'ModalDialogContent');
|
|
125
|
+
const modalDialogTrigger = findNodeChild(childArray, 'ModalDialogTrigger');
|
|
126
|
+
const themeProvider = useThemeProvider(theme);
|
|
127
|
+
const ref = useCallback(node => {
|
|
128
|
+
const appElement = document.getElementById('app');
|
|
129
|
+
if (appElement) {
|
|
130
|
+
if (node !== null) {
|
|
131
|
+
appElement.classList.add('noscroll');
|
|
132
|
+
} else {
|
|
133
|
+
appElement.classList.remove('noscroll');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}, []);
|
|
137
|
+
return jsxs(Dialog, Object.assign({}, rest, {
|
|
138
|
+
children: [modalDialogTrigger && jsx(DialogTrigger, Object.assign({}, modalDialogTrigger.props)), jsxs(DialogPortal, {
|
|
139
|
+
children: [jsx(StyledOverlay, {
|
|
140
|
+
css: {
|
|
141
|
+
zIndex: layer
|
|
142
|
+
}
|
|
143
|
+
}), jsx(StyledContent, {
|
|
144
|
+
className: (themeProvider === null || themeProvider === void 0 ? void 0 : themeProvider.theme) || '',
|
|
145
|
+
size: size,
|
|
146
|
+
css: Object.assign(Object.assign({}, css), {
|
|
147
|
+
zIndex: layer,
|
|
148
|
+
width: width,
|
|
149
|
+
maxWidth: width && 'unset'
|
|
150
|
+
}),
|
|
151
|
+
ref: ref,
|
|
152
|
+
isMobile: isMobile,
|
|
153
|
+
onOpenAutoFocus: e => {
|
|
154
|
+
if (!onOpenAutoFocus) {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
} else {
|
|
157
|
+
onOpenAutoFocus(e);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
onPointerDownOutside: e => onPointerDownOutside === null || onPointerDownOutside === void 0 ? void 0 : onPointerDownOutside(e),
|
|
161
|
+
children: jsxs(Box, {
|
|
162
|
+
css: {
|
|
163
|
+
backgroundColor: '$bgWhite',
|
|
164
|
+
display: 'flex',
|
|
165
|
+
flexDirection: 'column',
|
|
166
|
+
borderRadius: '$lg'
|
|
167
|
+
},
|
|
168
|
+
children: [modalDialogTitle && jsx(Box, {
|
|
169
|
+
css: Object.assign({
|
|
170
|
+
padding: '16px 24px',
|
|
171
|
+
display: 'block',
|
|
172
|
+
alignItems: 'center',
|
|
173
|
+
position: 'relative',
|
|
174
|
+
borderBottom: '1px solid $gray150',
|
|
175
|
+
'@md': {
|
|
176
|
+
padding: '24px 24px 19px 24px'
|
|
177
|
+
}
|
|
178
|
+
}, modalDialogTitle.props.containerCss),
|
|
179
|
+
children: jsxs(Box, {
|
|
180
|
+
css: {
|
|
181
|
+
justifyContent: 'space-between',
|
|
182
|
+
display: 'flex',
|
|
183
|
+
alignItems: 'center',
|
|
184
|
+
gap: '$compact',
|
|
185
|
+
marginRight: 0
|
|
186
|
+
},
|
|
187
|
+
children: [jsx(DialogTitle, {
|
|
188
|
+
css: {
|
|
189
|
+
margin: 0
|
|
190
|
+
},
|
|
191
|
+
children: jsx(Heading, Object.assign({
|
|
192
|
+
as: "p",
|
|
193
|
+
heading: "pageTitle"
|
|
194
|
+
}, modalDialogTitle.props))
|
|
195
|
+
}), !props.hideCloseButton && jsx(ConditionalWrapper, {
|
|
196
|
+
condition: !disabledCloseButton,
|
|
197
|
+
wrapper: children => jsx(DialogClose, {
|
|
198
|
+
asChild: true,
|
|
199
|
+
disabled: disabledCloseButton,
|
|
200
|
+
onClick: () => {
|
|
201
|
+
if (onCloseClick) onCloseClick();
|
|
202
|
+
},
|
|
203
|
+
children: children
|
|
204
|
+
}),
|
|
205
|
+
children: jsx(Box, {
|
|
206
|
+
css: {
|
|
207
|
+
display: 'flex',
|
|
208
|
+
justifyContent: 'center',
|
|
209
|
+
alignItems: 'center',
|
|
210
|
+
cursor: disabledCloseButton ? 'not-allowed' : 'pointer',
|
|
211
|
+
marginRight: 4
|
|
212
|
+
},
|
|
213
|
+
children: jsx(CloseOutline, {
|
|
214
|
+
size: "22"
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
})]
|
|
218
|
+
})
|
|
219
|
+
}), modalDialogContent && jsx(Box, Object.assign({}, modalDialogContent.props, {
|
|
220
|
+
css: Object.assign({
|
|
221
|
+
flexGrow: 1,
|
|
222
|
+
maxHeight: 'calc(100vh - 64px - 56px)',
|
|
223
|
+
padding: '16px 24px'
|
|
224
|
+
}, modalDialogContent.props.css)
|
|
225
|
+
})), modalDialogFooter && jsx(Box, Object.assign({}, modalDialogFooter.props, {
|
|
226
|
+
css: Object.assign({
|
|
227
|
+
borderTop: '1px solid $gray150',
|
|
228
|
+
padding: '16px 24px',
|
|
229
|
+
display: 'flex',
|
|
230
|
+
justifyContent: 'flex-end'
|
|
231
|
+
}, modalDialogFooter.props.css)
|
|
232
|
+
}))]
|
|
233
|
+
})
|
|
234
|
+
})]
|
|
235
|
+
})]
|
|
236
|
+
}));
|
|
237
|
+
};
|
|
238
|
+
ModalDialog.Trigger = ModalDialogTrigger;
|
|
239
|
+
ModalDialog.Title = ModalDialogTitle;
|
|
240
|
+
ModalDialog.Content = ModalDialogContent;
|
|
241
|
+
ModalDialog.Footer = ModalDialogFooter;
|
|
242
|
+
ModalDialog.defaultProps = {
|
|
243
|
+
size: 'md',
|
|
244
|
+
layer: '$modal'
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export { ModalDialogContent, ModalDialogFooter, ModalDialogTitle, ModalDialogTrigger, ModalDialog as default };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { styled } from '../../config/stitches.config.esm.js';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const NotificationBadgeRootStyle = styled('span', {
|
|
7
|
+
position: 'relative',
|
|
8
|
+
display: 'inline-flex',
|
|
9
|
+
verticalAlign: 'middle',
|
|
10
|
+
flexShrink: 0
|
|
11
|
+
});
|
|
12
|
+
const NotificationBadgeStyle = styled('span', {
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
padding: '3px 5px 3px 5px',
|
|
15
|
+
borderRadius: 50,
|
|
16
|
+
fontWeight: 600,
|
|
17
|
+
fontStyle: 'normal',
|
|
18
|
+
fontSize: 12,
|
|
19
|
+
textAlign: 'center',
|
|
20
|
+
variants: {
|
|
21
|
+
variant: {
|
|
22
|
+
info: {
|
|
23
|
+
backgroundColor: '$blue500',
|
|
24
|
+
color: '$white'
|
|
25
|
+
},
|
|
26
|
+
important: {
|
|
27
|
+
backgroundColor: '$red500',
|
|
28
|
+
color: '$white'
|
|
29
|
+
},
|
|
30
|
+
warning: {
|
|
31
|
+
backgroundColor: '$secondary500'
|
|
32
|
+
},
|
|
33
|
+
success: {
|
|
34
|
+
backgroundColor: '$green500'
|
|
35
|
+
},
|
|
36
|
+
alpha: {
|
|
37
|
+
backgroundColor: 'rgba(0, 0, 0, .2)',
|
|
38
|
+
color: '$textWhite'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
dot: {
|
|
42
|
+
true: {
|
|
43
|
+
minWidth: 8,
|
|
44
|
+
height: 8,
|
|
45
|
+
border: '1px solid #FFFFFF',
|
|
46
|
+
padding: 0
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
overlap: {
|
|
50
|
+
circular: {
|
|
51
|
+
top: '14%',
|
|
52
|
+
right: '14%'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
anchorVertical: {
|
|
56
|
+
top: {
|
|
57
|
+
top: 0
|
|
58
|
+
},
|
|
59
|
+
bottom: {
|
|
60
|
+
bottom: 0
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
anchorHorizontal: {
|
|
64
|
+
right: {
|
|
65
|
+
right: 0
|
|
66
|
+
},
|
|
67
|
+
left: {
|
|
68
|
+
left: 0
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
compoundVariants: [{
|
|
73
|
+
anchorVertical: 'top',
|
|
74
|
+
anchorHorizontal: 'right',
|
|
75
|
+
css: {
|
|
76
|
+
transform: 'scale(1) translate(50%, -50%)'
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
anchorVertical: 'top',
|
|
80
|
+
anchorHorizontal: 'left',
|
|
81
|
+
css: {
|
|
82
|
+
transform: 'scale(1) translate(-50%, -50%)'
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
anchorVertical: 'bottom',
|
|
86
|
+
anchorHorizontal: 'left',
|
|
87
|
+
css: {
|
|
88
|
+
transform: 'scale(1) translate(-50%, 50%)'
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
anchorVertical: 'bottom',
|
|
92
|
+
anchorHorizontal: 'right',
|
|
93
|
+
css: {
|
|
94
|
+
transform: 'scale(1) translate(50%, 50%)'
|
|
95
|
+
}
|
|
96
|
+
}],
|
|
97
|
+
defaultVariants: {
|
|
98
|
+
anchorVertical: 'top',
|
|
99
|
+
anchorHorizontal: 'right'
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const NotificationBadge = ({
|
|
103
|
+
children,
|
|
104
|
+
variantIcon,
|
|
105
|
+
...props
|
|
106
|
+
}) => {
|
|
107
|
+
const getIcon = () => {
|
|
108
|
+
const isLeading = variantIcon === 'leading';
|
|
109
|
+
return {
|
|
110
|
+
max: isLeading ? '+99' : '99+',
|
|
111
|
+
min: isLeading ? -99 : '99-'
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
const getValue = () => {
|
|
115
|
+
let value = props?.value;
|
|
116
|
+
const isTrailing = variantIcon === 'trailing';
|
|
117
|
+
if (typeof value === 'number' || parseInt(value)) {
|
|
118
|
+
if (Math.sign(value) === 1 || Math.sign(value) === 0) {
|
|
119
|
+
return value > 99 ? getIcon().max : value;
|
|
120
|
+
} else {
|
|
121
|
+
return value < -99 ? getIcon().min : isTrailing ? Math.abs(value) + '-' : value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return /*#__PURE__*/jsxs(NotificationBadgeRootStyle, {
|
|
126
|
+
children: [children, /*#__PURE__*/jsx(NotificationBadgeStyle, {
|
|
127
|
+
...props,
|
|
128
|
+
children: props.value && getValue()
|
|
129
|
+
})]
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
NotificationBadge.defaultProps = {
|
|
133
|
+
anchorHorizontal: 'right',
|
|
134
|
+
anchorVertical: 'top',
|
|
135
|
+
variant: 'important',
|
|
136
|
+
variantIcon: 'trailing',
|
|
137
|
+
value: undefined,
|
|
138
|
+
dot: false
|
|
139
|
+
};
|
|
140
|
+
NotificationBadge.propTypes = {
|
|
141
|
+
anchorHorizontal: PropTypes.oneOf(['left', 'right']),
|
|
142
|
+
anchorVertical: PropTypes.oneOf(['top', 'bottom']),
|
|
143
|
+
variant: PropTypes.oneOf(['info', 'important', 'warning', 'success', 'alpha']),
|
|
144
|
+
variantIcon: PropTypes.oneOf(['leading', 'trailing']),
|
|
145
|
+
value: PropTypes.number,
|
|
146
|
+
dot: PropTypes.bool
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { NotificationBadge as default };
|