@majoo-ui/react 2.0.0 → 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 +16 -5
- 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,964 @@
|
|
|
1
|
+
import 'core-js/modules/es.array.includes.js';
|
|
2
|
+
import 'core-js/modules/es.array.push.js';
|
|
3
|
+
import 'core-js/modules/es.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/es.iterator.filter.js';
|
|
5
|
+
import 'core-js/modules/es.iterator.find.js';
|
|
6
|
+
import 'core-js/modules/es.iterator.map.js';
|
|
7
|
+
import 'core-js/modules/es.iterator.reduce.js';
|
|
8
|
+
import { __rest, __awaiter } from 'tslib';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useState, useRef, useEffect, createElement } from 'react';
|
|
11
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
|
+
import { renderToString } from 'react-dom/server';
|
|
13
|
+
import Downshift from 'downshift';
|
|
14
|
+
import { CircleInfoOutline, SearchOutline, CloseFilled, CaretDownOutline } from '@majoo-ui/icons';
|
|
15
|
+
import isFunction from 'lodash/isFunction';
|
|
16
|
+
import { styled, colors } from '../../../../config/stitches.config.esm.js';
|
|
17
|
+
import Text from '../../../text/Text.esm.js';
|
|
18
|
+
import { InputGroup } from '../InputGroup/InputGroup.esm.js';
|
|
19
|
+
import Box from '../../../../layout/box/Box.esm.js';
|
|
20
|
+
import Flex from '../../../../layout/flex/Flex.esm.js';
|
|
21
|
+
import { InputLeftElement, InputRightElement } from '../InputElement/InputElement.esm.js';
|
|
22
|
+
import InputSearchbox from '../InputSearchbox/InputSearchbox.esm.js';
|
|
23
|
+
import InfiniteScroll from 'react-infinite-scroller';
|
|
24
|
+
import { ConditionalWrapper } from '../../../../wrapper/ConditionalWrapper.esm.js';
|
|
25
|
+
import debounce from 'lodash.debounce';
|
|
26
|
+
import { useTranslation } from 'react-i18next';
|
|
27
|
+
import { Portal } from '@majoo-ui/helpers';
|
|
28
|
+
import { foundations } from '@majoo-ui/core';
|
|
29
|
+
import ModalDialog, { ModalDialogTitle, ModalDialogContent } from '../../../modalDialog/ModalDialog.esm.js';
|
|
30
|
+
import Paragraph from '../../../paragraph/Paragraph.esm.js';
|
|
31
|
+
import { extractStringFromHTML } from '../../../../utils/strings.esm.js';
|
|
32
|
+
import { Popover, PopoverTrigger, PopoverContent, PopoverClose } from '../../../popover/Popover.esm.js';
|
|
33
|
+
import Tooltip from '../../../tooltip/Tooltip.esm.js';
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
zIndices
|
|
37
|
+
} = foundations;
|
|
38
|
+
const SelectContainer = styled('div', {
|
|
39
|
+
margin: 0,
|
|
40
|
+
flexDirection: 'column',
|
|
41
|
+
display: 'block',
|
|
42
|
+
position: 'relative',
|
|
43
|
+
fontFamily: 'inherit',
|
|
44
|
+
fontVariantNumeric: 'tabular-nums',
|
|
45
|
+
fontSize: '$short-content-regular',
|
|
46
|
+
fontWeight: '400',
|
|
47
|
+
textAlign: 'left',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
letterSpacing: '$short-content-regular',
|
|
50
|
+
lineHeight: '$short-content-regular',
|
|
51
|
+
color: '$textPrimary',
|
|
52
|
+
width: '100%',
|
|
53
|
+
variants: {
|
|
54
|
+
mobileOnly: {
|
|
55
|
+
true: {
|
|
56
|
+
'@lg': {
|
|
57
|
+
display: 'none !important'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
desktopOnly: {
|
|
62
|
+
true: {
|
|
63
|
+
display: 'none !important',
|
|
64
|
+
'@lg': {
|
|
65
|
+
display: 'block !important'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const SelectBox = styled(Flex, {
|
|
72
|
+
margin: 0,
|
|
73
|
+
position: 'relative',
|
|
74
|
+
appearance: 'none',
|
|
75
|
+
background: 'none',
|
|
76
|
+
boxSizing: 'border-box',
|
|
77
|
+
border: '1px solid $bgOutline',
|
|
78
|
+
borderRadius: '$lg',
|
|
79
|
+
outline: 'none',
|
|
80
|
+
'&:focus-within': {
|
|
81
|
+
border: '1px solid $primary400'
|
|
82
|
+
},
|
|
83
|
+
'&:hover': {
|
|
84
|
+
border: '1px solid $primary600'
|
|
85
|
+
},
|
|
86
|
+
variants: {
|
|
87
|
+
size: {
|
|
88
|
+
sm: {
|
|
89
|
+
height: 32
|
|
90
|
+
},
|
|
91
|
+
lg: {
|
|
92
|
+
height: 40
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
disabled: {
|
|
96
|
+
true: {
|
|
97
|
+
backgroundColor: '$formDisable',
|
|
98
|
+
color: '$textDisable',
|
|
99
|
+
cursor: 'not-allowed',
|
|
100
|
+
'&:hover': {
|
|
101
|
+
border: '1px solid $bgOutline'
|
|
102
|
+
},
|
|
103
|
+
'&:focus-within': {
|
|
104
|
+
border: '1px solid $bgOutline'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
readOnly: {
|
|
109
|
+
true: {
|
|
110
|
+
backgroundColor: '$formDisable',
|
|
111
|
+
color: '$textPrimary',
|
|
112
|
+
'&:hover': {
|
|
113
|
+
border: '1px solid $bgOutline'
|
|
114
|
+
},
|
|
115
|
+
'&:focus-within': {
|
|
116
|
+
border: '1px solid $bgOutline'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
isInvalid: {
|
|
121
|
+
true: {
|
|
122
|
+
border: '1px solid $formError',
|
|
123
|
+
'&:focus-within': {
|
|
124
|
+
border: '1px solid $formError'
|
|
125
|
+
},
|
|
126
|
+
'&:hover': {
|
|
127
|
+
border: '1px solid $formError'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const Button = styled('button', {
|
|
134
|
+
display: 'flex',
|
|
135
|
+
width: '100%',
|
|
136
|
+
height: '100%',
|
|
137
|
+
flex: 1,
|
|
138
|
+
minWidth: 0,
|
|
139
|
+
background: 'none',
|
|
140
|
+
outline: 'none',
|
|
141
|
+
border: 'none',
|
|
142
|
+
cursor: 'pointer',
|
|
143
|
+
color: '$textContent',
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
'&:disabled': {
|
|
146
|
+
cursor: 'not-allowed',
|
|
147
|
+
color: '$textDisable'
|
|
148
|
+
},
|
|
149
|
+
variants: {
|
|
150
|
+
size: {
|
|
151
|
+
sm: {
|
|
152
|
+
padding: '5px 16px'
|
|
153
|
+
},
|
|
154
|
+
lg: {
|
|
155
|
+
padding: '11px 16px 12px'
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
readOnly: {
|
|
159
|
+
true: {
|
|
160
|
+
color: '$textPrimary'
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const Input = styled('input', {
|
|
166
|
+
marginLeft: '$spacing-05',
|
|
167
|
+
display: 'flex',
|
|
168
|
+
width: '100%',
|
|
169
|
+
height: '100%',
|
|
170
|
+
background: 'none',
|
|
171
|
+
outline: 'none',
|
|
172
|
+
border: 'none',
|
|
173
|
+
cursor: 'text',
|
|
174
|
+
color: '$textPrimary',
|
|
175
|
+
textOverflow: 'ellipsis',
|
|
176
|
+
whiteSpace: 'nowrap',
|
|
177
|
+
overflow: 'hidden',
|
|
178
|
+
'&:disabled': {
|
|
179
|
+
cursor: 'not-allowed',
|
|
180
|
+
color: '$textDisable'
|
|
181
|
+
},
|
|
182
|
+
'&::placeholder': {
|
|
183
|
+
color: '$textDisable',
|
|
184
|
+
opacity: 1
|
|
185
|
+
},
|
|
186
|
+
variants: {
|
|
187
|
+
isReadOnly: {
|
|
188
|
+
true: {
|
|
189
|
+
color: '$textPrimary'
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const IconContainer = styled('div', {
|
|
195
|
+
flex: ' 0 0 auto',
|
|
196
|
+
width: 'auto',
|
|
197
|
+
display: 'flex',
|
|
198
|
+
alignItems: 'center',
|
|
199
|
+
paddingRight: '$spacing-05',
|
|
200
|
+
cursor: 'pointer',
|
|
201
|
+
variants: {
|
|
202
|
+
disabled: {
|
|
203
|
+
true: {
|
|
204
|
+
cursor: 'not-allowed'
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
const OptionWrapper = styled('div', {
|
|
210
|
+
display: 'none',
|
|
211
|
+
overflow: 'auto',
|
|
212
|
+
fontFamily: 'inherit',
|
|
213
|
+
fontVariantNumeric: 'tabular-nums',
|
|
214
|
+
fontSize: '$short-content-regular',
|
|
215
|
+
fontWeight: '400',
|
|
216
|
+
textAlign: 'left',
|
|
217
|
+
zIndex: 1,
|
|
218
|
+
borderRadius: '$sm',
|
|
219
|
+
backgroundColor: '$bgWhite',
|
|
220
|
+
boxShadow: '0px 2px 12px #00000014',
|
|
221
|
+
width: '100%',
|
|
222
|
+
maxHeight: '300px',
|
|
223
|
+
position: 'absolute',
|
|
224
|
+
float: 'left',
|
|
225
|
+
top: '100%',
|
|
226
|
+
left: '0',
|
|
227
|
+
variants: {
|
|
228
|
+
placement: {
|
|
229
|
+
bottom: {
|
|
230
|
+
top: '100%',
|
|
231
|
+
left: '0',
|
|
232
|
+
transform: 'none'
|
|
233
|
+
},
|
|
234
|
+
top: {
|
|
235
|
+
top: '0',
|
|
236
|
+
left: '0',
|
|
237
|
+
transform: 'translate(0, -100%)'
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
withFooter: {
|
|
241
|
+
true: {
|
|
242
|
+
maxHeight: 'calc(100vh - 64px - 96px)'
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
isMobile: {
|
|
246
|
+
true: {
|
|
247
|
+
display: 'block',
|
|
248
|
+
position: 'unset',
|
|
249
|
+
boxShadow: 'none',
|
|
250
|
+
inset: 'unset',
|
|
251
|
+
borderRadius: 'unset',
|
|
252
|
+
maxHeight: 'calc(100vh - 64px - 56px)'
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
defaultVariants: {
|
|
257
|
+
placement: 'bottom'
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
const SelectOption = styled('div', {
|
|
261
|
+
flexDirection: 'column',
|
|
262
|
+
display: 'block',
|
|
263
|
+
borderRadius: '$lg',
|
|
264
|
+
padding: '12px 16px',
|
|
265
|
+
overflowY: 'auto',
|
|
266
|
+
minHeight: '40px',
|
|
267
|
+
height: '100%'
|
|
268
|
+
});
|
|
269
|
+
const SelectItem = styled('div', {
|
|
270
|
+
overflow: 'hidden',
|
|
271
|
+
padding: '$spacing-05 0',
|
|
272
|
+
backgroundColor: 'rgb(235, 245, 255)',
|
|
273
|
+
cursor: 'pointer',
|
|
274
|
+
lineHeight: '20px',
|
|
275
|
+
'&:not(:last-child)': {
|
|
276
|
+
borderBottom: '1px solid $bgBorder'
|
|
277
|
+
},
|
|
278
|
+
variants: {
|
|
279
|
+
hasGroup: {
|
|
280
|
+
true: {
|
|
281
|
+
paddingLeft: '$spacing-06'
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
isGroup: {
|
|
285
|
+
true: {
|
|
286
|
+
padding: '$spacing-03 0',
|
|
287
|
+
borderBottom: 'none !important'
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
const StyledFooter = styled('div', {
|
|
293
|
+
position: 'sticky',
|
|
294
|
+
bottom: 0,
|
|
295
|
+
left: 0,
|
|
296
|
+
right: 0,
|
|
297
|
+
backgroundColor: '$bgWhite',
|
|
298
|
+
boxShadow: '0px 4px 6px #00000014',
|
|
299
|
+
borderTop: '1px solid $bgBorder',
|
|
300
|
+
pointerEvents: 'auto'
|
|
301
|
+
});
|
|
302
|
+
const StyledDiv = styled('div', {
|
|
303
|
+
color: '$textDisable',
|
|
304
|
+
display: 'flex',
|
|
305
|
+
alignItems: 'center'
|
|
306
|
+
});
|
|
307
|
+
const StyledText = {
|
|
308
|
+
whiteSpace: 'nowrap',
|
|
309
|
+
overflow: 'hidden',
|
|
310
|
+
textOverflow: 'ellipsis'
|
|
311
|
+
};
|
|
312
|
+
const SelectInputSearch = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
|
|
313
|
+
var {
|
|
314
|
+
showLeadingIcon = false,
|
|
315
|
+
showClearIcon = true,
|
|
316
|
+
disabled,
|
|
317
|
+
placeholder,
|
|
318
|
+
readOnly,
|
|
319
|
+
inputProps,
|
|
320
|
+
handleInputValue,
|
|
321
|
+
noStyling,
|
|
322
|
+
onChange
|
|
323
|
+
} = _a,
|
|
324
|
+
props = __rest(_a, ["showLeadingIcon", "showClearIcon", "disabled", "placeholder", "readOnly", "inputProps", "handleInputValue", "noStyling", "onChange"]);
|
|
325
|
+
const inputRef = React.useRef(null);
|
|
326
|
+
return jsxs(InputGroup, {
|
|
327
|
+
css: !noStyling && {
|
|
328
|
+
height: '100%',
|
|
329
|
+
border: 'none',
|
|
330
|
+
'&:hover': {
|
|
331
|
+
border: 'none'
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
disabled: disabled,
|
|
335
|
+
children: [jsx(InputLeftElement, {
|
|
336
|
+
children: showLeadingIcon && jsx(SearchOutline, {}),
|
|
337
|
+
css: !showLeadingIcon ? {
|
|
338
|
+
width: '$spacing-05',
|
|
339
|
+
padding: 0
|
|
340
|
+
} : undefined
|
|
341
|
+
}), jsx(Input, Object.assign({}, inputProps, props, {
|
|
342
|
+
placeholder: placeholder,
|
|
343
|
+
readOnly: readOnly,
|
|
344
|
+
isReadOnly: readOnly,
|
|
345
|
+
ref: forwardedRef,
|
|
346
|
+
disabled: disabled,
|
|
347
|
+
css: {
|
|
348
|
+
marginLeft: 0,
|
|
349
|
+
height: 'fit-content'
|
|
350
|
+
}
|
|
351
|
+
})), showClearIcon ? jsx(InputRightElement, {
|
|
352
|
+
children: showClearIcon && (inputProps.value || '').length > 0 && !disabled ? jsx(CloseFilled, {}) : jsx("div", {}),
|
|
353
|
+
onClick: e => {
|
|
354
|
+
if (!disabled) {
|
|
355
|
+
inputProps.onChange(Object.assign(Object.assign({}, e), {
|
|
356
|
+
target: Object.assign(Object.assign({}, e.target), {
|
|
357
|
+
value: ''
|
|
358
|
+
})
|
|
359
|
+
}));
|
|
360
|
+
if (handleInputValue) handleInputValue('');
|
|
361
|
+
if (inputRef.current) inputRef.current.focus();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}) : null]
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
function isHTMLElement(element) {
|
|
368
|
+
return 'offsetTop' in element;
|
|
369
|
+
}
|
|
370
|
+
const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
371
|
+
var {
|
|
372
|
+
option,
|
|
373
|
+
onChange,
|
|
374
|
+
value,
|
|
375
|
+
placeholder,
|
|
376
|
+
searchPlaceholder,
|
|
377
|
+
embedSearch = false,
|
|
378
|
+
size = 'lg',
|
|
379
|
+
disabled = false,
|
|
380
|
+
search = false,
|
|
381
|
+
iconColor = 'currentColor',
|
|
382
|
+
hideArrowicon = false,
|
|
383
|
+
showLeadingIcon,
|
|
384
|
+
placement = 'bottom',
|
|
385
|
+
disabledOptions,
|
|
386
|
+
textSelector = 'name',
|
|
387
|
+
valueSelector = 'value',
|
|
388
|
+
readOnly = false,
|
|
389
|
+
isInvalid = false,
|
|
390
|
+
noOptionIcon = false,
|
|
391
|
+
fetchData,
|
|
392
|
+
onSearch,
|
|
393
|
+
isLoading = false,
|
|
394
|
+
showTooltip = false,
|
|
395
|
+
css,
|
|
396
|
+
renderFooter,
|
|
397
|
+
optionCss,
|
|
398
|
+
emptyDataMessage,
|
|
399
|
+
mobileOnly,
|
|
400
|
+
desktopOnly,
|
|
401
|
+
onStateChange,
|
|
402
|
+
isMobile = false,
|
|
403
|
+
mobileTitle,
|
|
404
|
+
withDebounce = true,
|
|
405
|
+
renderAsLabel = true
|
|
406
|
+
} = _a,
|
|
407
|
+
props = __rest(_a, ["option", "onChange", "value", "placeholder", "searchPlaceholder", "embedSearch", "size", "disabled", "search", "iconColor", "hideArrowicon", "showLeadingIcon", "placement", "disabledOptions", "textSelector", "valueSelector", "readOnly", "isInvalid", "noOptionIcon", "fetchData", "onSearch", "isLoading", "showTooltip", "css", "renderFooter", "optionCss", "emptyDataMessage", "mobileOnly", "desktopOnly", "onStateChange", "isMobile", "mobileTitle", "withDebounce", "renderAsLabel"]);
|
|
408
|
+
const {
|
|
409
|
+
t
|
|
410
|
+
} = useTranslation(['MajooUI/inputSelect', 'translation']);
|
|
411
|
+
const [options, setOptions] = useState([]);
|
|
412
|
+
const [item, setItem] = useState([]);
|
|
413
|
+
const [groupedItems, setGroupedItems] = useState([]);
|
|
414
|
+
const [selectedValue, setSelectedValue] = useState(value);
|
|
415
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
416
|
+
const [query, setQuery] = useState();
|
|
417
|
+
const [openOptions, setOpenOptions] = useState(false);
|
|
418
|
+
const [open, setOpen] = useState(false);
|
|
419
|
+
const selectBoxRef = useRef(null);
|
|
420
|
+
const scrollerRef = useRef(null);
|
|
421
|
+
useEffect(() => {
|
|
422
|
+
var _a;
|
|
423
|
+
if (search && Boolean(query)) {
|
|
424
|
+
(_a = scrollerRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
425
|
+
top: 0
|
|
426
|
+
});
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const scrollToSelectedElement = () => {
|
|
430
|
+
const element = document.querySelector(`[data-index="${selectedIndex}"]`);
|
|
431
|
+
const scrollContainer = scrollerRef.current;
|
|
432
|
+
if (element && isHTMLElement(element) && scrollContainer) {
|
|
433
|
+
const elementPosition = element.offsetTop - scrollContainer.offsetTop;
|
|
434
|
+
scrollContainer.scrollTop = elementPosition;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
scrollToSelectedElement();
|
|
438
|
+
}, [query, search, openOptions, open, selectedIndex]);
|
|
439
|
+
const handleInputValue = (value, isReset = false) => {
|
|
440
|
+
if (onSearch && !isReset) onSearch(value);
|
|
441
|
+
if (fetchData) return;
|
|
442
|
+
if (value === '') {
|
|
443
|
+
return setItem(options);
|
|
444
|
+
} else {
|
|
445
|
+
setItem(options.filter(item => {
|
|
446
|
+
const nameIsIncluded = item.name.toLowerCase().includes(value.toLocaleLowerCase());
|
|
447
|
+
if (item.render && isFunction(item.render)) {
|
|
448
|
+
const extractedString = item.render() ? extractStringFromHTML(renderToString(item.render())).join(',') : '';
|
|
449
|
+
return nameIsIncluded || extractedString.toLowerCase().includes(value.toLocaleLowerCase());
|
|
450
|
+
}
|
|
451
|
+
return nameIsIncluded;
|
|
452
|
+
}));
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
const generateOptions = (data, valueSelector = '', textSelector = '') => {
|
|
456
|
+
return data.map(option => {
|
|
457
|
+
if (typeof option === 'object') {
|
|
458
|
+
const name = textSelector ? option[textSelector] : Object.values(option)[0];
|
|
459
|
+
const value = valueSelector ? option[valueSelector] : Object.values(option)[1];
|
|
460
|
+
return {
|
|
461
|
+
name,
|
|
462
|
+
value,
|
|
463
|
+
isDisabled: option.isDisabled === undefined && disabledOptions && disabledOptions.length > 0 ? disabledOptions.includes(value) : option.isDisabled,
|
|
464
|
+
render: option.render,
|
|
465
|
+
group: option.group
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
name: option,
|
|
470
|
+
value: option,
|
|
471
|
+
isDisabled: disabledOptions && disabledOptions.includes(option),
|
|
472
|
+
render: option.render,
|
|
473
|
+
group: option.group
|
|
474
|
+
};
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
const debouncedSearch = React.useRef(debounce(query => __awaiter(void 0, void 0, void 0, function* () {
|
|
478
|
+
setQuery(query);
|
|
479
|
+
if (onSearch) onSearch(query);
|
|
480
|
+
}), 1000)).current;
|
|
481
|
+
useEffect(() => {
|
|
482
|
+
var _a;
|
|
483
|
+
(_a = scrollerRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
484
|
+
top: 0
|
|
485
|
+
});
|
|
486
|
+
}, [query]);
|
|
487
|
+
useEffect(() => {
|
|
488
|
+
setSelectedValue(value);
|
|
489
|
+
}, [value]);
|
|
490
|
+
useEffect(() => {
|
|
491
|
+
if (groupedItems && value) {
|
|
492
|
+
const itemIndex = (groupedItems.length > 0 ? groupedItems : item !== null && item !== void 0 ? item : []).findIndex(val => String(val.value) === String(value.value));
|
|
493
|
+
if (itemIndex >= 0) {
|
|
494
|
+
setSelectedIndex(itemIndex);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}, [value, groupedItems, item]);
|
|
498
|
+
useEffect(() => {
|
|
499
|
+
const generatedOption = generateOptions(option, valueSelector, textSelector);
|
|
500
|
+
setItem(generatedOption);
|
|
501
|
+
setOptions(generatedOption);
|
|
502
|
+
}, [option, disabledOptions, valueSelector, textSelector]);
|
|
503
|
+
useEffect(() => {
|
|
504
|
+
return () => {
|
|
505
|
+
debouncedSearch.cancel();
|
|
506
|
+
};
|
|
507
|
+
}, [debouncedSearch]);
|
|
508
|
+
useEffect(() => {
|
|
509
|
+
setGroupedItems(item.sort(function (a, b) {
|
|
510
|
+
const nameA = (typeof a.group === 'string' ? a.group.toUpperCase() : a.group) || ''; // ignore upper and lowercase
|
|
511
|
+
const nameB = (typeof b.group === 'string' ? b.group.toUpperCase() : b.group) || ''; // ignore upper and lowercase
|
|
512
|
+
if (!a.group) return 1;
|
|
513
|
+
if (!b.group) return -1;
|
|
514
|
+
if (nameA < nameB) {
|
|
515
|
+
return -1;
|
|
516
|
+
}
|
|
517
|
+
if (nameA > nameB) {
|
|
518
|
+
return 1;
|
|
519
|
+
}
|
|
520
|
+
return 0;
|
|
521
|
+
}).reduce((prev, current) => {
|
|
522
|
+
let addedGroupItems = [];
|
|
523
|
+
if (prev) addedGroupItems = [...prev];
|
|
524
|
+
const group = current.group;
|
|
525
|
+
if ((!prev || !prev.find(val => val.value === `#group#${group}#`)) && group) {
|
|
526
|
+
addedGroupItems.push({
|
|
527
|
+
name: group,
|
|
528
|
+
value: `#group#${group}#`,
|
|
529
|
+
isGroup: true,
|
|
530
|
+
render: () => jsx(Paragraph, {
|
|
531
|
+
color: "primary",
|
|
532
|
+
paragraph: "shortContentBold",
|
|
533
|
+
children: group
|
|
534
|
+
})
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
addedGroupItems.push(current);
|
|
538
|
+
return addedGroupItems;
|
|
539
|
+
}, []));
|
|
540
|
+
}, [item]);
|
|
541
|
+
const stateReducer = (_, changes) => {
|
|
542
|
+
switch (changes.type) {
|
|
543
|
+
case Downshift.stateChangeTypes.blurButton:
|
|
544
|
+
return {
|
|
545
|
+
isOpen: true
|
|
546
|
+
};
|
|
547
|
+
default:
|
|
548
|
+
return changes;
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
return jsx(Downshift, Object.assign({}, props, {
|
|
552
|
+
onChange: onChange,
|
|
553
|
+
itemToString: item => item ? item.name : '',
|
|
554
|
+
selectedItem: selectedValue !== undefined ? selectedValue : null,
|
|
555
|
+
onSelect: (selectedItem, _) => setSelectedValue(selectedItem),
|
|
556
|
+
onStateChange: state => {
|
|
557
|
+
if (state && (state.type === '__autocomplete_mouseup__' || String(state.type) === '1') && 'inputValue' in state) {
|
|
558
|
+
handleInputValue(String(state.inputValue ? state.inputValue : '').toLowerCase());
|
|
559
|
+
}
|
|
560
|
+
if (!('isOpen' in state)) return;
|
|
561
|
+
if (state.isOpen && embedSearch) handleInputValue('', true);
|
|
562
|
+
if (!state.isOpen && fetchData && query && query.length > 0 && onSearch) {
|
|
563
|
+
onSearch('');
|
|
564
|
+
setQuery('');
|
|
565
|
+
}
|
|
566
|
+
if (onStateChange) onStateChange(state);
|
|
567
|
+
},
|
|
568
|
+
stateReducer: stateReducer,
|
|
569
|
+
children: ({
|
|
570
|
+
getRootProps,
|
|
571
|
+
getToggleButtonProps,
|
|
572
|
+
getMenuProps,
|
|
573
|
+
getInputProps,
|
|
574
|
+
getItemProps,
|
|
575
|
+
isOpen,
|
|
576
|
+
selectedItem,
|
|
577
|
+
highlightedIndex
|
|
578
|
+
}) => {
|
|
579
|
+
var _a, _b;
|
|
580
|
+
const handleDownOption = () => {
|
|
581
|
+
if (hideArrowicon || noOptionIcon) {
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
return jsx(IconContainer, Object.assign({}, getToggleButtonProps({
|
|
585
|
+
disabled: disabled || readOnly
|
|
586
|
+
}), {
|
|
587
|
+
disabled: disabled,
|
|
588
|
+
readOnly: readOnly,
|
|
589
|
+
children: jsx(CaretDownOutline, {
|
|
590
|
+
color: readOnly ? colors.gray300 : iconColor
|
|
591
|
+
})
|
|
592
|
+
}));
|
|
593
|
+
};
|
|
594
|
+
setOpen(isOpen);
|
|
595
|
+
return !isMobile ? jsx(Popover, {
|
|
596
|
+
open: openOptions,
|
|
597
|
+
onOpenChange: setOpenOptions,
|
|
598
|
+
placement: placement,
|
|
599
|
+
hideOnScroll: true,
|
|
600
|
+
children: jsxs(SelectContainer, {
|
|
601
|
+
css: css,
|
|
602
|
+
ref: selectBoxRef,
|
|
603
|
+
mobileOnly: mobileOnly,
|
|
604
|
+
desktopOnly: desktopOnly,
|
|
605
|
+
children: [jsx(ConditionalWrapper, {
|
|
606
|
+
condition: showTooltip && selectedValue,
|
|
607
|
+
wrapper: children => jsx(Tooltip, {
|
|
608
|
+
color: "dark",
|
|
609
|
+
label: selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.name,
|
|
610
|
+
children: children
|
|
611
|
+
}),
|
|
612
|
+
children: jsx(PopoverTrigger, {
|
|
613
|
+
children: jsxs(SelectBox, Object.assign({}, getRootProps({
|
|
614
|
+
refKey: 'ref'
|
|
615
|
+
}, {
|
|
616
|
+
suppressRefError: true
|
|
617
|
+
}), {
|
|
618
|
+
size: size,
|
|
619
|
+
disabled: disabled,
|
|
620
|
+
readOnly: readOnly,
|
|
621
|
+
isInvalid: isInvalid,
|
|
622
|
+
children: [search && !disabled && !readOnly ? jsx(Box, {
|
|
623
|
+
style: {
|
|
624
|
+
width: '100%',
|
|
625
|
+
flex: 1
|
|
626
|
+
},
|
|
627
|
+
children: jsx(SelectInputSearch, {
|
|
628
|
+
ref: ref,
|
|
629
|
+
showLeadingIcon: showLeadingIcon,
|
|
630
|
+
showClearIcon: hideArrowicon,
|
|
631
|
+
disabled: disabled,
|
|
632
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('placeholder', 'Pilih Item'),
|
|
633
|
+
readOnly: readOnly,
|
|
634
|
+
handleInputValue: !fetchData ? handleInputValue : query => {
|
|
635
|
+
if (onSearch) onSearch(query);
|
|
636
|
+
setQuery(query);
|
|
637
|
+
},
|
|
638
|
+
inputProps: getInputProps({
|
|
639
|
+
onChange: event => {
|
|
640
|
+
setOpenOptions(true);
|
|
641
|
+
if (event.type !== 'change') return;
|
|
642
|
+
const query = event.target.value;
|
|
643
|
+
if (!fetchData) handleInputValue(query);else debouncedSearch(query);
|
|
644
|
+
},
|
|
645
|
+
disabled
|
|
646
|
+
}),
|
|
647
|
+
onClick: !isOpen ? getToggleButtonProps({
|
|
648
|
+
disabled: disabled || readOnly
|
|
649
|
+
}).onClick : undefined
|
|
650
|
+
})
|
|
651
|
+
}) : jsx(Button, Object.assign({
|
|
652
|
+
ref: ref
|
|
653
|
+
}, getToggleButtonProps({
|
|
654
|
+
disabled: disabled || readOnly
|
|
655
|
+
}), {
|
|
656
|
+
disabled: disabled,
|
|
657
|
+
size: size,
|
|
658
|
+
readOnly: readOnly,
|
|
659
|
+
type: "button",
|
|
660
|
+
children: selectedItem ? selectedItem.render && renderAsLabel ? selectedItem.render(selectedItem) : jsx(Text, {
|
|
661
|
+
color: disabled ? 'disable' : 'primary',
|
|
662
|
+
css: StyledText,
|
|
663
|
+
children: selectedItem.name
|
|
664
|
+
}) : jsx(Text, {
|
|
665
|
+
color: "disable",
|
|
666
|
+
css: StyledText,
|
|
667
|
+
children: placeholder !== null && placeholder !== void 0 ? placeholder : t('placeholder', 'Pilih Item')
|
|
668
|
+
})
|
|
669
|
+
})), handleDownOption()]
|
|
670
|
+
}))
|
|
671
|
+
})
|
|
672
|
+
}), jsx(Portal, {
|
|
673
|
+
children: jsx(PopoverContent, {
|
|
674
|
+
style: {
|
|
675
|
+
width: (_b = (_a = selectBoxRef === null || selectBoxRef === void 0 ? void 0 : selectBoxRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0,
|
|
676
|
+
zIndex: zIndices.tooltip
|
|
677
|
+
},
|
|
678
|
+
children: jsxs(Fragment, {
|
|
679
|
+
children: [isOpen && isLoading && jsx(Flex, {
|
|
680
|
+
justify: "center",
|
|
681
|
+
align: "center",
|
|
682
|
+
css: {
|
|
683
|
+
position: 'absolute',
|
|
684
|
+
inset: 0,
|
|
685
|
+
zIndex: '$tooltip',
|
|
686
|
+
top: item.length > 0 ? '0px' : placement === 'top' ? '-20px' : '20px',
|
|
687
|
+
// bottom: '80px',
|
|
688
|
+
width: '100%',
|
|
689
|
+
height: scrollerRef.current ? scrollerRef.current.clientHeight : '40px',
|
|
690
|
+
backgroundColor: '$bgWhite',
|
|
691
|
+
opacity: 0.8,
|
|
692
|
+
transform: placement === 'top' ? 'translate(0, -100%)' : 'none'
|
|
693
|
+
},
|
|
694
|
+
children: jsx(Text, {
|
|
695
|
+
variant: "caption",
|
|
696
|
+
children: "Loading...."
|
|
697
|
+
})
|
|
698
|
+
}), jsx(ConditionalWrapper, {
|
|
699
|
+
condition: renderFooter && typeof renderFooter === 'function',
|
|
700
|
+
wrapper: child => jsxs(Box, {
|
|
701
|
+
css: {
|
|
702
|
+
position: 'absolute',
|
|
703
|
+
float: 'left',
|
|
704
|
+
display: isOpen ? 'block' : 'none',
|
|
705
|
+
zIndex: '$popover',
|
|
706
|
+
width: '100%'
|
|
707
|
+
},
|
|
708
|
+
children: [child, renderFooter && typeof renderFooter === 'function' && jsx(StyledFooter, {
|
|
709
|
+
children: renderFooter === null || renderFooter === void 0 ? void 0 : renderFooter()
|
|
710
|
+
})]
|
|
711
|
+
}),
|
|
712
|
+
children: jsxs(OptionWrapper, Object.assign({}, getMenuProps({
|
|
713
|
+
ref: scrollerRef
|
|
714
|
+
}, {
|
|
715
|
+
suppressRefError: true
|
|
716
|
+
}), {
|
|
717
|
+
css: Object.assign({
|
|
718
|
+
display: isOpen ? 'block' : 'none',
|
|
719
|
+
zIndex: '$popover',
|
|
720
|
+
pointerEvents: 'auto'
|
|
721
|
+
}, optionCss),
|
|
722
|
+
withFooter: renderFooter && typeof renderFooter === 'function',
|
|
723
|
+
placement: placement,
|
|
724
|
+
children: [!search && embedSearch && isOpen && jsx(SelectContainer, {
|
|
725
|
+
css: {
|
|
726
|
+
position: 'sticky',
|
|
727
|
+
top: 0,
|
|
728
|
+
zIndex: '$sticky',
|
|
729
|
+
padding: '$spacing-04 $spacing-05 0',
|
|
730
|
+
backgroundColor: '$bgWhite'
|
|
731
|
+
},
|
|
732
|
+
children: jsx(InputSearchbox, {
|
|
733
|
+
size: 'sm',
|
|
734
|
+
onChange: handleInputValue,
|
|
735
|
+
placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...'),
|
|
736
|
+
withDebounce: withDebounce
|
|
737
|
+
})
|
|
738
|
+
}), item.length > 0 || isLoading ? jsx(ConditionalWrapper, {
|
|
739
|
+
condition: !!fetchData && item.length > 0,
|
|
740
|
+
wrapper: children => jsx(InfiniteScroll, {
|
|
741
|
+
loadMore: _ => {
|
|
742
|
+
if (!isLoading && fetchData) fetchData({
|
|
743
|
+
query
|
|
744
|
+
});
|
|
745
|
+
},
|
|
746
|
+
hasMore: true,
|
|
747
|
+
threshold: 5,
|
|
748
|
+
useWindow: false,
|
|
749
|
+
children: children
|
|
750
|
+
}),
|
|
751
|
+
children: jsx(PopoverClose, {
|
|
752
|
+
css: {
|
|
753
|
+
display: 'block !important'
|
|
754
|
+
},
|
|
755
|
+
children: jsx(SelectOption, {
|
|
756
|
+
children: (groupedItems.length > 0 ? groupedItems : item).map((item, index) => {
|
|
757
|
+
var _a;
|
|
758
|
+
return /*#__PURE__*/createElement(SelectItem, Object.assign({}, getItemProps({
|
|
759
|
+
item,
|
|
760
|
+
disabled: item.isDisabled || item.isGroup,
|
|
761
|
+
onClick: () => setSelectedIndex(index)
|
|
762
|
+
}), {
|
|
763
|
+
key: (_a = item.value) !== null && _a !== void 0 ? _a : index,
|
|
764
|
+
hasGroup: !!item.group,
|
|
765
|
+
isGroup: item.isGroup,
|
|
766
|
+
"data-index": index,
|
|
767
|
+
css: Object.assign({}, !item.isGroup ? item.isDisabled ? {
|
|
768
|
+
backgroundColor: 'unset',
|
|
769
|
+
cursor: 'not-allowed',
|
|
770
|
+
color: '$textDisable'
|
|
771
|
+
} : {
|
|
772
|
+
backgroundColor: highlightedIndex === index ? '$bgGray' : 'white',
|
|
773
|
+
fontWeight: 'normal',
|
|
774
|
+
color: selectedItem && selectedItem.value === item.value ? '$textBrand' : '$textPrimary'
|
|
775
|
+
} : {
|
|
776
|
+
backgroundColor: 'unset',
|
|
777
|
+
cursor: 'default'
|
|
778
|
+
})
|
|
779
|
+
}), item.render ? item.render(selectedItem) : item.name);
|
|
780
|
+
})
|
|
781
|
+
})
|
|
782
|
+
})
|
|
783
|
+
}) : jsx(SelectOption, {
|
|
784
|
+
children: jsxs(StyledDiv, {
|
|
785
|
+
children: [jsx("div", {
|
|
786
|
+
style: {
|
|
787
|
+
marginRight: '6px'
|
|
788
|
+
},
|
|
789
|
+
children: jsx(CircleInfoOutline, {
|
|
790
|
+
size: "16px",
|
|
791
|
+
color: colors.iconDisable,
|
|
792
|
+
style: {
|
|
793
|
+
verticalAlign: 'text-bottom'
|
|
794
|
+
}
|
|
795
|
+
})
|
|
796
|
+
}), emptyDataMessage || t('noItemPlaceholder', 'Item tidak ditemukan')]
|
|
797
|
+
})
|
|
798
|
+
})]
|
|
799
|
+
}))
|
|
800
|
+
})]
|
|
801
|
+
})
|
|
802
|
+
})
|
|
803
|
+
})]
|
|
804
|
+
})
|
|
805
|
+
}) : jsx(SelectContainer, {
|
|
806
|
+
css: css,
|
|
807
|
+
ref: selectBoxRef,
|
|
808
|
+
mobileOnly: mobileOnly,
|
|
809
|
+
desktopOnly: desktopOnly,
|
|
810
|
+
children: jsxs(ConditionalWrapper, {
|
|
811
|
+
condition: showTooltip && selectedValue,
|
|
812
|
+
wrapper: children => jsx(Tooltip, {
|
|
813
|
+
color: "dark",
|
|
814
|
+
label: selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.name,
|
|
815
|
+
children: children
|
|
816
|
+
}),
|
|
817
|
+
children: [jsxs(SelectBox, Object.assign({}, getRootProps({
|
|
818
|
+
refKey: 'ref'
|
|
819
|
+
}, {
|
|
820
|
+
suppressRefError: true
|
|
821
|
+
}), {
|
|
822
|
+
size: size,
|
|
823
|
+
disabled: disabled,
|
|
824
|
+
readOnly: readOnly,
|
|
825
|
+
isInvalid: isInvalid,
|
|
826
|
+
children: [jsx(Button, Object.assign({
|
|
827
|
+
ref: ref
|
|
828
|
+
}, getToggleButtonProps({
|
|
829
|
+
disabled: disabled || readOnly
|
|
830
|
+
}), {
|
|
831
|
+
disabled: disabled,
|
|
832
|
+
size: size,
|
|
833
|
+
readOnly: readOnly,
|
|
834
|
+
type: "button",
|
|
835
|
+
children: selectedItem ? selectedItem.render && renderAsLabel ? selectedItem.render(selectedItem) : jsx(Text, {
|
|
836
|
+
color: disabled ? 'disable' : 'primary',
|
|
837
|
+
css: StyledText,
|
|
838
|
+
children: selectedItem.name
|
|
839
|
+
}) : jsx(Text, {
|
|
840
|
+
color: "disable",
|
|
841
|
+
css: StyledText,
|
|
842
|
+
children: placeholder !== null && placeholder !== void 0 ? placeholder : t('placeholder', 'Pilih Item')
|
|
843
|
+
})
|
|
844
|
+
})), handleDownOption()]
|
|
845
|
+
})), jsxs(ModalDialog, {
|
|
846
|
+
isMobile: true,
|
|
847
|
+
open: isOpen,
|
|
848
|
+
children: [jsx(ModalDialogTitle, {
|
|
849
|
+
children: mobileTitle || placeholder || t('placeholder', 'Pilih Item')
|
|
850
|
+
}), jsx(ModalDialogContent, {
|
|
851
|
+
css: {
|
|
852
|
+
padding: 0,
|
|
853
|
+
maxHeight: 'unset',
|
|
854
|
+
position: 'relative'
|
|
855
|
+
},
|
|
856
|
+
children: jsxs(Fragment, {
|
|
857
|
+
children: [isOpen && isLoading && jsx(Flex, {
|
|
858
|
+
justify: "center",
|
|
859
|
+
align: "center",
|
|
860
|
+
css: {
|
|
861
|
+
position: 'absolute',
|
|
862
|
+
inset: 0,
|
|
863
|
+
zIndex: '$tooltip',
|
|
864
|
+
top: item.length > 0 ? '0px' : placement === 'top' ? '-20px' : '20px',
|
|
865
|
+
// bottom: '80px',
|
|
866
|
+
width: '100%',
|
|
867
|
+
height: scrollerRef.current ? scrollerRef.current.clientHeight : '40px',
|
|
868
|
+
backgroundColor: '$bgWhite',
|
|
869
|
+
opacity: 0.8
|
|
870
|
+
},
|
|
871
|
+
children: jsx(Text, {
|
|
872
|
+
variant: "caption",
|
|
873
|
+
children: "Loading...."
|
|
874
|
+
})
|
|
875
|
+
}), jsxs(OptionWrapper, Object.assign({}, getMenuProps({
|
|
876
|
+
ref: scrollerRef
|
|
877
|
+
}, {
|
|
878
|
+
suppressRefError: true
|
|
879
|
+
}), {
|
|
880
|
+
css: Object.assign({
|
|
881
|
+
pointerEvents: 'auto'
|
|
882
|
+
}, optionCss),
|
|
883
|
+
withFooter: renderFooter && typeof renderFooter === 'function',
|
|
884
|
+
isMobile: true,
|
|
885
|
+
children: [(search || embedSearch) && isOpen && jsx(SelectContainer, {
|
|
886
|
+
css: {
|
|
887
|
+
position: 'sticky',
|
|
888
|
+
top: 0,
|
|
889
|
+
zIndex: '$sticky',
|
|
890
|
+
padding: '$spacing-04 $spacing-05 0',
|
|
891
|
+
backgroundColor: '$bgWhite'
|
|
892
|
+
},
|
|
893
|
+
children: jsx(InputSearchbox, {
|
|
894
|
+
size: 'sm',
|
|
895
|
+
onChange: handleInputValue,
|
|
896
|
+
placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...'),
|
|
897
|
+
withDebounce: withDebounce
|
|
898
|
+
})
|
|
899
|
+
}), item.length > 0 || isLoading ? jsx(ConditionalWrapper, {
|
|
900
|
+
condition: !!fetchData && item.length > 0,
|
|
901
|
+
wrapper: children => jsx(InfiniteScroll, {
|
|
902
|
+
loadMore: _ => {
|
|
903
|
+
if (!isLoading && fetchData) fetchData({
|
|
904
|
+
query
|
|
905
|
+
});
|
|
906
|
+
},
|
|
907
|
+
hasMore: true,
|
|
908
|
+
threshold: 5,
|
|
909
|
+
useWindow: false,
|
|
910
|
+
children: children
|
|
911
|
+
}),
|
|
912
|
+
children: jsx(SelectOption, {
|
|
913
|
+
children: (groupedItems.length > 0 ? groupedItems : item).map((item, index) => {
|
|
914
|
+
var _a;
|
|
915
|
+
return /*#__PURE__*/createElement(SelectItem, Object.assign({}, getItemProps({
|
|
916
|
+
item,
|
|
917
|
+
disabled: item.isDisabled || item.isGroup
|
|
918
|
+
}), {
|
|
919
|
+
key: (_a = item.value) !== null && _a !== void 0 ? _a : index,
|
|
920
|
+
isGroup: item.isGroup,
|
|
921
|
+
css: Object.assign({}, !item.isGroup ? item.isDisabled ? {
|
|
922
|
+
backgroundColor: 'unset',
|
|
923
|
+
cursor: 'not-allowed',
|
|
924
|
+
color: '$textDisable'
|
|
925
|
+
} : {
|
|
926
|
+
backgroundColor: highlightedIndex === index ? '$bgGray' : 'white',
|
|
927
|
+
fontWeight: 'normal',
|
|
928
|
+
color: selectedItem && selectedItem.value === item.value ? '$textBrand' : '$textPrimary'
|
|
929
|
+
} : {
|
|
930
|
+
backgroundColor: 'unset',
|
|
931
|
+
cursor: 'default'
|
|
932
|
+
})
|
|
933
|
+
}), item.render ? item.render(selectedItem) : item.name);
|
|
934
|
+
})
|
|
935
|
+
})
|
|
936
|
+
}) : jsx(SelectOption, {
|
|
937
|
+
children: jsxs(StyledDiv, {
|
|
938
|
+
children: [jsx("div", {
|
|
939
|
+
style: {
|
|
940
|
+
marginRight: '6px'
|
|
941
|
+
},
|
|
942
|
+
children: jsx(CircleInfoOutline, {
|
|
943
|
+
size: "16px",
|
|
944
|
+
color: colors.iconDisable,
|
|
945
|
+
style: {
|
|
946
|
+
verticalAlign: 'text-bottom'
|
|
947
|
+
}
|
|
948
|
+
})
|
|
949
|
+
}), emptyDataMessage || t('noItemPlaceholder', 'Item tidak ditemukan')]
|
|
950
|
+
})
|
|
951
|
+
}), renderFooter && typeof renderFooter === 'function' && jsx(StyledFooter, {
|
|
952
|
+
children: renderFooter()
|
|
953
|
+
})]
|
|
954
|
+
}))]
|
|
955
|
+
})
|
|
956
|
+
})]
|
|
957
|
+
})]
|
|
958
|
+
})
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
}));
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
export { IconContainer, Input, InputSelect, OptionWrapper, SelectBox, SelectContainer, SelectItem, SelectOption, InputSelect as default };
|