@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.
Files changed (202) hide show
  1. package/charts.esm.js +3 -1453
  2. package/colors/Colors.esm.js +93 -0
  3. package/components/accordion/Accordion.esm.js +109 -0
  4. package/components/alertDialog/AlertDialog.esm.js +440 -0
  5. package/components/avatar/Avatar.esm.js +83 -0
  6. package/components/badge/Badge.esm.js +255 -0
  7. package/components/banner/Banner.esm.js +341 -0
  8. package/components/barChart/BarChart.esm.js +212 -0
  9. package/components/breadcrumb/Breadcrumb.esm.js +65 -0
  10. package/components/breadcrumb/index.esm.js +19 -0
  11. package/components/button/Button.esm.js +331 -0
  12. package/components/buttonGroup/ButtonGroup.esm.js +350 -0
  13. package/components/card/Card.esm.js +236 -0
  14. package/components/chart/assets/data_kosong.png.esm.js +3 -0
  15. package/components/chart/lineChart/LineChart.esm.js +358 -0
  16. package/components/chart/lineChart/components/Comparator.esm.js +82 -0
  17. package/components/chart/lineChart/components/ComparatorController.esm.js +112 -0
  18. package/components/chart/lineChart/components/ComparatorItem.esm.js +104 -0
  19. package/components/chart/lineChart/components/ProductList.esm.js +78 -0
  20. package/components/chart/lineChart/components/TitleLegend.esm.js +107 -0
  21. package/components/chart/lineChart/components/Tooltip.esm.js +90 -0
  22. package/components/chart/utils/index.esm.js +109 -0
  23. package/components/checkboxTable/CheckboxTable.esm.js +287 -0
  24. package/components/colorPicker/ColorPicker.esm.js +342 -0
  25. package/components/colorPicker/InputColorPicker.esm.js +120 -0
  26. package/components/colorPicker/assets/img_colormap.gif.esm.js +3 -0
  27. package/components/colorPicker/components/ColorFields.esm.js +144 -0
  28. package/components/colorPicker/components/ColorMap.esm.js +1188 -0
  29. package/components/contentEditor/ContentEditor.esm.js +251 -0
  30. package/components/contentEditor/assets/Inline-code-outline.svg.esm.js +3 -0
  31. package/components/contentEditor/assets/Link-outline.svg.esm.js +3 -0
  32. package/components/contentEditor/assets/List-bulleted-outline.svg.esm.js +3 -0
  33. package/components/contentEditor/assets/List-numbered-outline.svg.esm.js +3 -0
  34. package/components/contentEditor/assets/Redo-outline.svg.esm.js +3 -0
  35. package/components/contentEditor/assets/Text-bold-filled.svg.esm.js +3 -0
  36. package/components/contentEditor/assets/Text-clear-format-outline.svg.esm.js +3 -0
  37. package/components/contentEditor/assets/Text-italic-outline.svg.esm.js +3 -0
  38. package/components/contentEditor/assets/Text-strikethrough-outline.svg.esm.js +3 -0
  39. package/components/contentEditor/assets/Text-underline-outline.svg.esm.js +3 -0
  40. package/components/contentEditor/assets/Undo-outline.svg.esm.js +3 -0
  41. package/components/contextMenu/ContextMenu.esm.js +298 -0
  42. package/components/datePicker/AdvancedOption.esm.js +37 -0
  43. package/components/datePicker/CustomDatePicker.esm.js +121 -0
  44. package/components/datePicker/DatePicker.esm.js +244 -0
  45. package/components/datePicker/DatePickerMulti.esm.js +70 -0
  46. package/components/datePicker/InputDatePicker.esm.js +290 -0
  47. package/components/datePicker/InputDateRangePicker.esm.js +174 -0
  48. package/components/datePicker/components/Calendar.esm.js +654 -0
  49. package/components/datePicker/components/CalendarMulti.esm.js +407 -0
  50. package/components/datePicker/components/CalendarTimePicker.esm.js +104 -0
  51. package/components/datePicker/components/DateNumber.esm.js +89 -0
  52. package/components/datePicker/components/MobileCalendar.esm.js +522 -0
  53. package/components/datePicker/state/reducer.esm.js +286 -0
  54. package/components/datePicker/timePicker/InputTimePicker.esm.js +205 -0
  55. package/components/datePicker/timePicker/TimePicker.esm.js +481 -0
  56. package/components/devicePreview/DevicePreview.esm.js +631 -0
  57. package/components/devicePreview/deviceFrame/android-transparant.png.esm.js +3 -0
  58. package/components/devicePreview/deviceFrame/android-wide-transparant.png.esm.js +3 -0
  59. package/components/devicePreview/deviceFrame/bg-email.png.esm.js +3 -0
  60. package/components/devicePreview/deviceFrame/bg-notification.png.esm.js +3 -0
  61. package/components/devicePreview/deviceFrame/bg-sms.png.esm.js +3 -0
  62. package/components/devicePreview/deviceFrame/bg-whatsapp.png.esm.js +3 -0
  63. package/components/devicePreview/deviceFrame/desktop-transparant.png.esm.js +3 -0
  64. package/components/devicePreview/deviceFrame/ic-majoo-profpic.png.esm.js +3 -0
  65. package/components/devicePreview/deviceFrame/iphone-transparant.png.esm.js +3 -0
  66. package/components/dialog/Dialog.esm.js +106 -0
  67. package/components/drawer/Drawer.esm.js +294 -0
  68. package/components/dropdownMenu/DropdownMenu.esm.js +281 -0
  69. package/components/editableTable/EditableMobile.esm.js +361 -0
  70. package/components/editableTable/EditableTable.esm.js +618 -0
  71. package/components/editableTable/transition.esm.js +37 -0
  72. package/components/form/components/FormGroup/FormGroup.esm.js +142 -0
  73. package/components/form/components/FormHelper/Helper.esm.js +50 -0
  74. package/components/form/components/FormLabel/Label.esm.js +90 -0
  75. package/components/form/components/InputAddon/InputAddon.esm.js +105 -0
  76. package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +60 -0
  77. package/components/form/components/InputCheckbox/InputCheckbox.esm.js +129 -0
  78. package/components/form/components/InputCheckbox/icon/CheckOutline.esm.js +33 -0
  79. package/components/form/components/InputCheckbox/icon/MinusOutline.esm.js +33 -0
  80. package/components/form/components/InputCombobox/InputCombobox.esm.js +169 -0
  81. package/components/form/components/InputCounter/InputCounter.esm.js +226 -0
  82. package/components/form/components/InputCreatable/InputCreatable.esm.js +229 -0
  83. package/components/form/components/InputDateRange/InputDateRange.esm.js +46 -0
  84. package/components/form/components/InputElement/InputElement.esm.js +35 -0
  85. package/components/form/components/InputGroup/InputGroup.esm.js +188 -0
  86. package/components/form/components/InputLetter/InputLetter.esm.js +68 -0
  87. package/components/form/components/InputNumber/InputNumber.esm.js +248 -0
  88. package/components/form/components/InputNumber/NumberFormat.esm.js +1263 -0
  89. package/components/form/components/InputOTP/InputOTP.esm.js +70 -0
  90. package/components/form/components/InputRadio/InputRadio.esm.js +273 -0
  91. package/components/form/components/InputRadio/InputRadioGroup.esm.js +35 -0
  92. package/components/form/components/InputRadio/context.esm.js +5 -0
  93. package/components/form/components/InputResourceList/InputResourceList.esm.js +429 -0
  94. package/components/form/components/InputSearchbox/CloseFilled.esm.js +34 -0
  95. package/components/form/components/InputSearchbox/InputSearchbox.esm.js +90 -0
  96. package/components/form/components/InputSearchbox/SearchOutline.esm.js +26 -0
  97. package/components/form/components/InputSelect/InputSelect.esm.js +964 -0
  98. package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +1388 -0
  99. package/components/form/components/InputSelectCheck/OptionGroupItem.esm.js +39 -0
  100. package/components/form/components/InputSelectCheck/icon/CheckOutline.esm.js +33 -0
  101. package/components/form/components/InputSelectTag/InputSelectTag.esm.js +62 -0
  102. package/components/form/components/InputSignature/InputSignature.esm.js +122 -0
  103. package/components/form/components/InputSignature/SignatureModal.esm.js +67 -0
  104. package/components/form/components/InputSwitch/InputSwitch.esm.js +96 -0
  105. package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +136 -0
  106. package/components/form/components/InputTags/InputTags.esm.js +268 -0
  107. package/components/form/components/InputText/InputText.esm.js +197 -0
  108. package/components/form/components/InputTextArea/InputTextArea.esm.js +77 -0
  109. package/components/heading/Heading.esm.js +64 -0
  110. package/components/iconButton/IconButton.esm.js +71 -0
  111. package/components/image/Image.esm.js +141 -0
  112. package/components/link/Link.esm.js +59 -0
  113. package/components/loadingBar/LoadingBar.esm.js +113 -0
  114. package/components/mapPicker/InputMapPicker.esm.js +160 -0
  115. package/components/mapPicker/MapPicker.esm.js +122 -0
  116. package/components/mapPicker/MapPicker.styles.esm.js +70 -0
  117. package/components/mapPicker/assets/images/Mapsicle.png.esm.js +3 -0
  118. package/components/mapPicker/components/AddressCard.esm.js +25 -0
  119. package/components/mapPicker/components/ButtonSelect.esm.js +46 -0
  120. package/components/mapPicker/components/ChangeView.esm.js +20 -0
  121. package/components/mapPicker/components/InputSearch.esm.js +74 -0
  122. package/components/mapPicker/components/MarkerIcon.esm.js +22 -0
  123. package/components/mapPicker/components/MarkerSvg.esm.js +62 -0
  124. package/components/mapPicker/components/ZoomControls.esm.js +36 -0
  125. package/components/mapPicker/hooks/useMapSearch.esm.js +161 -0
  126. package/components/modalDialog/ModalDialog.esm.js +247 -0
  127. package/components/notificationBadge/NotificationBadge.esm.js +149 -0
  128. package/components/pageDialog/PageDialog.esm.js +291 -0
  129. package/components/pageDialog/logo.svg.esm.js +3 -0
  130. package/components/pagination/Pagination.esm.js +94 -0
  131. package/components/pagination/PaginationButton.esm.js +346 -0
  132. package/components/pagination/PaginationInfo.esm.js +146 -0
  133. package/components/paper/Paper.esm.js +76 -0
  134. package/components/paragraph/Paragraph.esm.js +52 -0
  135. package/components/pieChart/PieChart.esm.js +287 -0
  136. package/components/popover/Popover.esm.js +142 -0
  137. package/components/progress/Progress.esm.js +170 -0
  138. package/components/progressIndicator/ProgressIndicator.esm.js +287 -0
  139. package/components/scrollSync/ScrollSync.esm.js +172 -0
  140. package/components/scrollSync/ScrollSyncNode.esm.js +87 -0
  141. package/components/scrollSync/utils.esm.js +9 -0
  142. package/components/separator/Separator.esm.js +43 -0
  143. package/components/skeleton/Skeleton.esm.js +131 -0
  144. package/components/slider/Slider.esm.js +345 -0
  145. package/components/stepWizard/StepWizard.esm.js +451 -0
  146. package/components/stepWizard/index.esm.js +14 -0
  147. package/components/table/MobileTable.esm.js +415 -0
  148. package/components/table/Table.esm.js +1472 -0
  149. package/components/table/components/columns/DateColumn.esm.js +26 -0
  150. package/components/table/components/columns/DecimalColumn.esm.js +36 -0
  151. package/components/table/components/columns/PriceColumn.esm.js +57 -0
  152. package/components/table/components/columns/RowDraggableColumn.esm.js +24 -0
  153. package/components/table/components/columns/RowExpanderColumn.esm.js +32 -0
  154. package/components/table/components/columns/RowExpanderMultipleColumn.esm.js +24 -0
  155. package/components/table/components/columns/RowMenuColumn.esm.js +101 -0
  156. package/components/table/components/columns/RowSelectionCallbackColumn.esm.js +38 -0
  157. package/components/table/components/columns/RowSelectionColumn.esm.js +34 -0
  158. package/components/table/images/img-emptydata.webp.esm.js +3 -0
  159. package/components/table/images/img-emptysearchdata.webp.esm.js +3 -0
  160. package/components/tableOfContent/TableOfContent.esm.js +267 -0
  161. package/components/tableOfContent/index.esm.js +18 -0
  162. package/components/tableOfContent/transition.esm.js +38 -0
  163. package/components/tabs/Tabs.esm.js +282 -0
  164. package/components/tag/Tag.esm.js +161 -0
  165. package/components/tagList/TagList.esm.js +90 -0
  166. package/components/tagStatus/TagStatus.esm.js +134 -0
  167. package/components/text/Text.esm.js +140 -0
  168. package/components/toast/Toast.esm.js +297 -0
  169. package/components/toast/ToastContainer.esm.js +73 -0
  170. package/components/toast/context/ToastContext.esm.js +5 -0
  171. package/components/toast/context/ToastProvider.esm.js +96 -0
  172. package/components/tooltip/Tooltip.esm.js +175 -0
  173. package/components/upload/Upload.esm.js +1103 -0
  174. package/components/upload/utils/canvasPreview.esm.js +39 -0
  175. package/components/upload/utils/imgPreview.esm.js +21 -0
  176. package/config/stitches.config.esm.js +216 -0
  177. package/editor.esm.js +1 -264
  178. package/hooks/useListOption/useListOption.esm.js +56 -0
  179. package/hooks/useToggle/useToggle.esm.js +8 -0
  180. package/index.esm.js +106 -42293
  181. package/layout/box/Box.esm.js +24 -0
  182. package/layout/flex/Flex.esm.js +135 -0
  183. package/layout/grid/Grid.esm.js +270 -0
  184. package/layout/pageContainer/PageContainer.esm.js +60 -0
  185. package/majoo-provider/MajooProvider.esm.js +42 -0
  186. package/majoo-provider/ThemeProvider.esm.js +41 -0
  187. package/majoo-provider/globalStyles.esm.js +242 -0
  188. package/majoo-provider/styles/modern-normalize.esm.js +95 -0
  189. package/map.esm.js +2 -734
  190. package/package.json +8 -4
  191. package/utils/calendar.esm.js +26 -0
  192. package/utils/element.esm.js +21 -0
  193. package/utils/object.esm.js +12 -0
  194. package/utils/request.esm.js +74 -0
  195. package/utils/strings.esm.js +6 -0
  196. package/{useMediaQuery.esm.js → utils/useMediaQuery.esm.js} +1 -1
  197. package/utils/useNavigatorOnline.esm.js +19 -0
  198. package/utils/variant.esm.js +12 -0
  199. package/wrapper/ConditionalWrapper.esm.js +9 -0
  200. package/ModalDialog.esm.js +0 -2669
  201. package/Separator.esm.js +0 -3002
  202. package/stitches.config.esm.js +0 -2284
@@ -0,0 +1,1388 @@
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.for-each.js';
7
+ import 'core-js/modules/es.iterator.map.js';
8
+ import 'core-js/modules/es.iterator.reduce.js';
9
+ import 'core-js/modules/es.iterator.some.js';
10
+ import 'core-js/modules/es.json.stringify.js';
11
+ import 'core-js/modules/es.map.get-or-insert.js';
12
+ import 'core-js/modules/es.map.get-or-insert-computed.js';
13
+ import 'core-js/modules/es.set.difference.v2.js';
14
+ import 'core-js/modules/es.set.intersection.v2.js';
15
+ import 'core-js/modules/es.set.is-disjoint-from.v2.js';
16
+ import 'core-js/modules/es.set.is-subset-of.v2.js';
17
+ import 'core-js/modules/es.set.is-superset-of.v2.js';
18
+ import 'core-js/modules/es.set.symmetric-difference.v2.js';
19
+ import 'core-js/modules/es.set.union.v2.js';
20
+ import React__default, { forwardRef, useMemo, useRef, useCallback, useEffect } from 'react';
21
+ import { useMultipleSelection, useCombobox } from 'downshift';
22
+ import Box from '../../../../layout/box/Box.esm.js';
23
+ import Flex from '../../../../layout/flex/Flex.esm.js';
24
+ import Paragraph from '../../../paragraph/Paragraph.esm.js';
25
+ import { Separator } from '../../../separator/Separator.esm.js';
26
+ import Text from '../../../text/Text.esm.js';
27
+ import { Tag } from '../../../tag/Tag.esm.js';
28
+ import { ChevronUpOutline, ChevronDownOutline, CircleInfoOutline, CaretDownOutline } from '@majoo-ui/icons';
29
+ import { colors, styled } from '../../../../config/stitches.config.esm.js';
30
+ import CheckOutline from './icon/CheckOutline.esm.js';
31
+ import PropTypes from 'prop-types';
32
+ import { useTranslation } from 'react-i18next';
33
+ import debounce from 'lodash.debounce';
34
+ import InfiniteScroll from 'react-infinite-scroller';
35
+ import { ConditionalWrapper } from '../../../../wrapper/ConditionalWrapper.esm.js';
36
+ import OptionGroupItem from './OptionGroupItem.esm.js';
37
+ import { useMountedLayoutEffect } from 'react-table';
38
+ import { useVirtual } from 'react-virtual';
39
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
40
+
41
+ const startTransition = React__default.startTransition || (callback => {
42
+ // For React 17, use setTimeout to defer updates
43
+ setTimeout(callback, 0);
44
+ });
45
+ const Wrapper = styled('div', {
46
+ margin: 0,
47
+ flexDirection: 'column',
48
+ display: 'block',
49
+ position: 'relative',
50
+ fontFamily: 'inherit',
51
+ fontVariantNumeric: 'tabular-nums',
52
+ fontSize: '$short-content-regular',
53
+ fontWeight: '400',
54
+ textAlign: 'left',
55
+ alignItems: 'center',
56
+ letterSpacing: '$short-content-regular',
57
+ lineHeight: '$short-content-regular',
58
+ color: '$textDisable',
59
+ width: '100%',
60
+ variants: {
61
+ mobileOnly: {
62
+ true: {
63
+ '@lg': {
64
+ display: 'none !important'
65
+ }
66
+ }
67
+ },
68
+ desktopOnly: {
69
+ true: {
70
+ display: 'none !important',
71
+ '@lg': {
72
+ display: 'block !important'
73
+ }
74
+ }
75
+ }
76
+ }
77
+ });
78
+ const Select = styled('div', {
79
+ margin: 0,
80
+ display: 'flex',
81
+ position: 'relative',
82
+ width: '100%',
83
+ appearance: 'none',
84
+ background: 'none',
85
+ boxSizing: 'border-box',
86
+ border: '1px solid $bgOutline',
87
+ borderRadius: '$md',
88
+ outline: 'none',
89
+ '&:focus-within': {
90
+ border: '1px solid $primary400'
91
+ },
92
+ '&:hover': {
93
+ border: '1px solid $primary400'
94
+ },
95
+ variants: {
96
+ size: {
97
+ sm: {
98
+ height: 32,
99
+ maxHeight: 32,
100
+ padding: '2px 16px'
101
+ },
102
+ lg: {
103
+ height: 40,
104
+ maxHeight: 40,
105
+ padding: '8px 16px'
106
+ }
107
+ },
108
+ disabled: {
109
+ true: {
110
+ backgroundColor: '$formDisable',
111
+ color: '$textDisable',
112
+ cursor: 'not-allowed',
113
+ '&:hover': {
114
+ border: '1px solid $bgOutline'
115
+ },
116
+ '&:focus-within': {
117
+ border: '1px solid $bgOutline'
118
+ }
119
+ }
120
+ },
121
+ isInvalid: {
122
+ true: {
123
+ border: '1px solid $formError',
124
+ '&:focus-within': {
125
+ border: '1px solid $formError'
126
+ },
127
+ '&:hover': {
128
+ border: '1px solid $formError'
129
+ }
130
+ }
131
+ }
132
+ }
133
+ });
134
+ const InputWrapper = styled('div', {
135
+ display: 'flex',
136
+ position: 'relative',
137
+ flex: 'auto',
138
+ flexWrap: 'wrap',
139
+ maxWidth: '100%',
140
+ cursor: 'pointer',
141
+ variants: {
142
+ disabled: {
143
+ true: {
144
+ cursor: 'not-allowed',
145
+ color: '$textDisable'
146
+ }
147
+ }
148
+ }
149
+ });
150
+ const Input = styled('input', {
151
+ width: '100%',
152
+ textAlign: 'left',
153
+ background: 'unset',
154
+ outline: 'none',
155
+ border: 'none',
156
+ cursor: 'text',
157
+ color: '$textPrimary',
158
+ '&::placeholder': {
159
+ color: '$textDisable'
160
+ },
161
+ '&:disabled': {
162
+ cursor: 'not-allowed'
163
+ },
164
+ variants: {
165
+ hidden: {
166
+ true: {
167
+ display: 'none'
168
+ }
169
+ }
170
+ }
171
+ });
172
+ const Button = styled('button', {
173
+ background: 'none',
174
+ outline: 'none',
175
+ border: 'none',
176
+ color: '$textDisable',
177
+ cursor: 'pointer',
178
+ width: '100%',
179
+ textAlign: 'left',
180
+ '&:disabled': {
181
+ cursor: 'not-allowed'
182
+ },
183
+ variants: {
184
+ hidden: {
185
+ true: {
186
+ display: 'none'
187
+ }
188
+ },
189
+ withLabel: {
190
+ true: {
191
+ color: '$textPrimary'
192
+ }
193
+ }
194
+ }
195
+ });
196
+ const IconWrapper = styled('div', {
197
+ flex: ' 0 0 auto',
198
+ width: 'auto',
199
+ display: 'flex',
200
+ alignItems: 'center',
201
+ cursor: 'pointer',
202
+ variants: {
203
+ disabled: {
204
+ true: {
205
+ cursor: 'not-allowed'
206
+ }
207
+ },
208
+ readOnly: {
209
+ true: {
210
+ cursor: 'not-allowed'
211
+ }
212
+ }
213
+ }
214
+ });
215
+ const IconCaretDown = styled(CaretDownOutline, {
216
+ size: '24px'
217
+ });
218
+ const TagWrapper = styled(Box, {
219
+ display: 'flex',
220
+ position: 'relative',
221
+ flexWrap: 'wrap',
222
+ maxWidth: '100%',
223
+ margin: '10px 0',
224
+ gap: '5px'
225
+ });
226
+ const OptionWrapper = styled('div', {
227
+ display: 'none',
228
+ overflow: 'hidden',
229
+ zIndex: 12,
230
+ borderRadius: '$sm',
231
+ backgroundColor: '$bgWhite',
232
+ boxShadow: '0px 2px 12px #00000014',
233
+ width: '100%',
234
+ // height: '160px',
235
+ position: 'absolute',
236
+ float: 'left',
237
+ // top: '40px',
238
+ left: '0px',
239
+ color: '$textPrimary',
240
+ variants: {
241
+ placement: {
242
+ bottom: {
243
+ top: '100%',
244
+ left: '0',
245
+ transform: 'none'
246
+ },
247
+ top: {
248
+ top: '0',
249
+ left: '0',
250
+ transform: 'translate(0, -100%)'
251
+ }
252
+ }
253
+ }
254
+ });
255
+ const Option = styled('div', {
256
+ flexDirection: 'column',
257
+ display: 'block',
258
+ borderRadius: '$lg',
259
+ overflowY: 'auto',
260
+ padding: '8px 16px',
261
+ maxHeight: '160px',
262
+ height: 'auto',
263
+ '@sm': {
264
+ borderRadius: 'unset'
265
+ }
266
+ });
267
+ const ItemWrapper = styled(Box, {
268
+ display: 'flex',
269
+ position: 'relative',
270
+ flex: 'auto',
271
+ maxWidth: '100%',
272
+ cursor: 'pointer',
273
+ alignItems: 'center',
274
+ borderBottom: '1px solid $bgBorder'
275
+ });
276
+ const Item = styled('div', {
277
+ overflow: 'hidden',
278
+ backgroundColor: '$bgWhite',
279
+ lineHeight: '20px',
280
+ marginLeft: '10px',
281
+ padding: '12px 0'
282
+ });
283
+ const StyledDiv = styled('div', {
284
+ padding: '6px 0',
285
+ color: '$textDisable',
286
+ display: 'inline-flex'
287
+ });
288
+ const IndeterminateFilled = styled('div', {
289
+ width: 16,
290
+ height: 16,
291
+ background: '$primary500',
292
+ color: '$textWhite',
293
+ borderRadius: 3,
294
+ fontSize: 14,
295
+ display: 'flex',
296
+ justifyContent: 'center',
297
+ alignItems: 'center'
298
+ });
299
+ const InputSelectCheck = /*#__PURE__*/forwardRef(({
300
+ placeholder,
301
+ option,
302
+ value,
303
+ defaultValue,
304
+ size,
305
+ disabled,
306
+ onChange,
307
+ search,
308
+ readOnly,
309
+ placement,
310
+ disabledOptions,
311
+ disabledSortChecked,
312
+ textEmptyItem,
313
+ onRemoveItem,
314
+ isInvalid,
315
+ sortBy,
316
+ showSelectAll,
317
+ showTagSelectAll,
318
+ selectAllLabel,
319
+ showSelectedTag,
320
+ unremovableTags,
321
+ helperText,
322
+ css,
323
+ showCounter,
324
+ labelCounter,
325
+ collapsible,
326
+ toggleInput,
327
+ fetchData,
328
+ onSearch,
329
+ isLoading,
330
+ maxSelectedItem,
331
+ mobileOnly,
332
+ desktopOnly,
333
+ label,
334
+ tagCss,
335
+ checkBoxCss,
336
+ optionListCss,
337
+ showCollapsibleCounter,
338
+ collapsibleLimit,
339
+ pageIndex,
340
+ onSelectAllChecked,
341
+ totalOptions,
342
+ clearSearchOnSelect,
343
+ onItemClick,
344
+ virtualized,
345
+ virtualizedThreshold,
346
+ ...props
347
+ }, ref) => {
348
+ const {
349
+ t,
350
+ i18n: {
351
+ language
352
+ }
353
+ } = useTranslation(['MajooUI/inputSelectCheck', 'translation']);
354
+ const [initItem, setInitItems] = React__default.useState(option); //init filter selectedItems on useMultipleSelection
355
+ const [items, setItems] = React__default.useState([]);
356
+ const [selectedValue, setSelectedValue] = React__default.useState([]);
357
+ const [inputValue, setInputValue] = React__default.useState('');
358
+ const [showAllTags, setShowAllTags] = React__default.useState(false);
359
+ const [inputSelectValue, setInputSelectValue] = React__default.useState(defaultValue || []);
360
+ const [query, setQuery] = React__default.useState('');
361
+ const scrollerRef = React__default.useRef(null);
362
+ const isShowSelectAll = showSelectAll && !maxSelectedItem;
363
+
364
+ // Use Set for O(1) lookup performance with large datasets
365
+ const selectedValueSet = useMemo(() => new Set(selectedValue), [selectedValue]);
366
+
367
+ // Calculate total item count efficiently without creating full array
368
+ const totalItemCount = useMemo(() => {
369
+ return items.reduce((count, item) => {
370
+ if (item?.children) {
371
+ return count + 1 + item.children.length; // parent + children
372
+ }
373
+ return count + 1;
374
+ }, 0);
375
+ }, [items]);
376
+
377
+ // Batched onChange to prevent multiple rapid calls
378
+ const onChangeTimeoutRef = useRef(null);
379
+ const batchedOnChange = useCallback(values => {
380
+ // Clear any pending onChange calls
381
+ if (onChangeTimeoutRef.current) {
382
+ clearTimeout(onChangeTimeoutRef.current);
383
+ }
384
+
385
+ // For large datasets, batch the onChange call to prevent freezing
386
+ if (totalItemCount > 10000) {
387
+ onChangeTimeoutRef.current = setTimeout(() => {
388
+ onChange?.(values);
389
+ }, 0);
390
+ } else {
391
+ // For smaller datasets, call immediately
392
+ onChange?.(values);
393
+ }
394
+ }, [onChange, totalItemCount]);
395
+
396
+ // Determine if virtualization should be enabled
397
+ const shouldVirtualize = virtualized && totalItemCount >= virtualizedThreshold;
398
+
399
+ // Lazy item lookup function - only compute when needed
400
+ const getItemAtIndex = useCallback(index => {
401
+ let currentIndex = 0;
402
+ for (let i = 0; i < items.length; i++) {
403
+ const item = items[i];
404
+ if (item?.children) {
405
+ // Check if index is the group header
406
+ if (currentIndex === index) {
407
+ return {
408
+ type: 'group',
409
+ item,
410
+ originalIndex: i
411
+ };
412
+ }
413
+ currentIndex++;
414
+
415
+ // Check if index is within children
416
+ for (let j = 0; j < item.children.length; j++) {
417
+ if (currentIndex === index) {
418
+ return {
419
+ type: 'child',
420
+ item: item.children[j],
421
+ originalIndex: i,
422
+ childIndex: j
423
+ };
424
+ }
425
+ currentIndex++;
426
+ }
427
+ } else {
428
+ // Regular item
429
+ if (currentIndex === index) {
430
+ return {
431
+ type: 'item',
432
+ item,
433
+ originalIndex: i
434
+ };
435
+ }
436
+ currentIndex++;
437
+ }
438
+ }
439
+ return null;
440
+ }, [items]);
441
+
442
+ // Dynamic overscan based on dataset size
443
+ const overscanCount = useMemo(() => {
444
+ if (totalItemCount > 10000) return 5;
445
+ if (totalItemCount > 1000) return 8;
446
+ return 10;
447
+ }, [totalItemCount]);
448
+
449
+ // Setup virtualization
450
+ const rowVirtualizer = useVirtual({
451
+ size: totalItemCount,
452
+ parentRef: scrollerRef,
453
+ estimateSize: useCallback(() => 44, []),
454
+ // Estimated height of each item
455
+ overscan: overscanCount
456
+ });
457
+ useMountedLayoutEffect(() => {
458
+ scrollerRef.current?.scrollTo({
459
+ top: 0
460
+ });
461
+ }, [query]);
462
+ useEffect(() => {
463
+ if (defaultValue?.length) {
464
+ if (value?.length) {
465
+ setInputSelectValue(value);
466
+ }
467
+ } else {
468
+ setInputSelectValue(value);
469
+ }
470
+ }, [value, defaultValue]);
471
+ const sortValue = selectedValue.length > 0 && disabledOptions.length === 0 ? inputSelectValue.reduce((res, id, i, {
472
+ [i + 1]: next
473
+ }) => {
474
+ let sortData = option.find(option => option.id === id);
475
+ if (sortData) res.push(sortData); // if exist in option
476
+ if (next) return res;else {
477
+ let filterOption = option.filter(option => !res.some(item => item.id === option.id));
478
+ return [...res, ...filterOption]; // add the missing elements
479
+ }
480
+ }, []) : option;
481
+ const sortDisabled = disabledOptions.length > 0 && !disabledSortChecked ? disabledOptions.reduce((res, id, i, {
482
+ [i + 1]: next
483
+ }) => {
484
+ let sortData = option.find(option => option.id === id);
485
+ if (sortData) res.push(sortData); // if exist in option
486
+ if (next) return res;else {
487
+ let filterOption = option.filter(option => !res.some(item => item.id === option.id));
488
+ return [...res, ...filterOption]; // add the missing elements
489
+ }
490
+ }, []) : option;
491
+
492
+ // Create a fast lookup map for item names (for large datasets)
493
+ const itemLookupMap = useMemo(() => {
494
+ if (initItem?.length <= 10000) return null;
495
+ const map = new Map();
496
+ for (let i = 0; i < initItem.length; i++) {
497
+ const item = initItem[i];
498
+ map.set(item.id, item);
499
+ if (item.children) {
500
+ for (let j = 0; j < item.children.length; j++) {
501
+ const child = item.children[j];
502
+ map.set(child.id, child);
503
+ }
504
+ }
505
+ }
506
+ return map;
507
+ }, [initItem]);
508
+
509
+ // Memoize selected items to prevent expensive recalculation on every render
510
+ const memoizedSelectedItems = useMemo(() => {
511
+ if (selectedValue.length === 0) return [];
512
+
513
+ // For very large datasets, use lookup map for O(1) access
514
+ if (initItem?.length > 10000 && itemLookupMap) {
515
+ return selectedValue.map(id => {
516
+ const item = itemLookupMap.get(id);
517
+ return item || {
518
+ id,
519
+ name: id
520
+ }; // Fallback to id as name if not found
521
+ });
522
+ }
523
+
524
+ // For smaller datasets, do the full flatten and filter
525
+ return initItem?.reduce((acc, item) => [...acc, item, ...(item.children ? item.children : [])], [])?.filter(item => selectedValueSet.has(item.id)) || [];
526
+ }, [selectedValue, initItem, selectedValueSet, itemLookupMap]);
527
+ const {
528
+ getSelectedItemProps,
529
+ getDropdownProps,
530
+ addSelectedItem,
531
+ removeSelectedItem,
532
+ selectedItems
533
+ } = useMultipleSelection({
534
+ selectedItems: memoizedSelectedItems
535
+ });
536
+ const generateOptions = data => {
537
+ return data.map(option => {
538
+ if (typeof option === 'object') {
539
+ const {
540
+ id
541
+ } = option;
542
+ let children = option?.children;
543
+ let isDisabled = disabledOptions.length > 0 ? disabledOptions.includes(id) : false;
544
+ if (children && Array.isArray(children)) {
545
+ children = generateOptions(children);
546
+ if (children.length === children.filter(child => child.isDisabled).length) isDisabled = true;
547
+ }
548
+ return {
549
+ ...option,
550
+ children,
551
+ isDisabled
552
+ };
553
+ }
554
+ return {
555
+ name: option,
556
+ value: option,
557
+ isDisabled: disabledOptions.includes(option)
558
+ };
559
+ });
560
+ };
561
+ const debouncedSearch = React__default.useRef(debounce(async query => {
562
+ setQuery(query);
563
+ onSearch?.(query);
564
+ }, 1000)).current;
565
+ React__default.useEffect(() => {
566
+ return () => {
567
+ debouncedSearch.cancel();
568
+ };
569
+ }, [debouncedSearch]);
570
+ const handleInputValue = input => {
571
+ onSearch?.(input);
572
+ if (input === '') {
573
+ if (disabledOptions.length > 0) {
574
+ const options = generateOptions(sortDisabled);
575
+ setItems(isShowSelectAll ? [{
576
+ id: '!all',
577
+ name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
578
+ }, ...options] : options);
579
+ } else {
580
+ setItems(isShowSelectAll ? [{
581
+ id: '!all',
582
+ name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
583
+ }, ...option] : option);
584
+ }
585
+ } else {
586
+ let filterItems = option?.filter(item => item?.name?.toLowerCase()?.includes?.(input?.toLocaleLowerCase?.()));
587
+ setItems(filterItems);
588
+ }
589
+ };
590
+ const removeItem = selected => {
591
+ if (disabled || readOnly) {
592
+ return selectedValue;
593
+ } else {
594
+ if (selected?.id === 'counter') {
595
+ setSelectedValue([]);
596
+ setInputSelectValue([]);
597
+ batchedOnChange([]);
598
+ for (let i = 0; i < selectedValue.length; i++) {
599
+ removeSelectedItem(selectedValue[i]);
600
+ }
601
+ } else {
602
+ const filterItems = selectedValue.filter(val => val !== selected.id && val !== '!all');
603
+ removeSelectedItem(selected);
604
+ setSelectedValue(filterItems);
605
+ setInputSelectValue(filterItems);
606
+ if (selected.id !== '!all') {
607
+ batchedOnChange(filterItems);
608
+ }
609
+ }
610
+ }
611
+ };
612
+
613
+ // Memoize flattened items for useCombobox to prevent recalculation on every render
614
+ const flattenedItemsForCombobox = useMemo(() => {
615
+ // We need all items for selection to work properly, even for large datasets
616
+ // Optimize by using for loops instead of reduce/spread for better performance
617
+ const result = [];
618
+ for (let i = 0; i < items.length; i++) {
619
+ const item = items[i];
620
+ result.push(item);
621
+ if (item.children) {
622
+ for (let j = 0; j < item.children.length; j++) {
623
+ result.push(item.children[j]);
624
+ }
625
+ }
626
+ }
627
+ return result;
628
+ }, [items]);
629
+ const {
630
+ getToggleButtonProps,
631
+ getMenuProps,
632
+ getInputProps,
633
+ getComboboxProps,
634
+ getItemProps,
635
+ selectItem,
636
+ highlightedIndex,
637
+ isOpen
638
+ } = useCombobox({
639
+ inputValue,
640
+ items: flattenedItemsForCombobox,
641
+ selectedItem: selectedValue,
642
+ itemToString: item => item ? item.name : '',
643
+ onStateChange: ({
644
+ inputValue,
645
+ type,
646
+ selectedItem
647
+ }) => {
648
+ switch (type) {
649
+ case useCombobox.stateChangeTypes.InputChange:
650
+ setInputValue(inputValue);
651
+ if (fetchData) debouncedSearch(inputValue);else handleInputValue(inputValue);
652
+ break;
653
+ case useCombobox.stateChangeTypes.ItemClick:
654
+ {
655
+ if (clearSearchOnSelect) setInputValue('');
656
+ }
657
+ case useCombobox.stateChangeTypes.InputKeyDownEnter:
658
+ case useCombobox.stateChangeTypes.InputBlur:
659
+ if (selectedItem) {
660
+ if (selectedItems.length !== 0 && selectedValue.includes(selectedItem.id)) {
661
+ if (disabled === false && readOnly === false) {
662
+ if (selectedItem.id === '!all') {
663
+ items.forEach(item => {
664
+ if (item?.children?.length) {
665
+ item?.children?.forEach(item => {
666
+ removeSelectedItem(item);
667
+ });
668
+ } else {
669
+ removeSelectedItem(item);
670
+ }
671
+ });
672
+
673
+ // Use startTransition for non-urgent state updates
674
+ startTransition(() => {
675
+ setSelectedValue([]);
676
+ setInputSelectValue([]);
677
+ });
678
+ batchedOnChange([]);
679
+ } else {
680
+ removeItem(selectedItem);
681
+ }
682
+ selectItem(null);
683
+ }
684
+ } else {
685
+ if (selectedItem.id === '!all') {
686
+ // Optimized select all - batch operations instead of individual calls
687
+ const itemIds = [];
688
+ const itemsToAdd = [];
689
+ items.filter(item => !item.isDisabled).forEach(item => {
690
+ if (item?.children?.length) {
691
+ item.children.filter(child => !child.isDisabled).forEach(child => {
692
+ itemsToAdd.push(child);
693
+ itemIds.push(child.id);
694
+ });
695
+ } else {
696
+ itemsToAdd.push(item);
697
+ itemIds.push(item.id);
698
+ }
699
+ });
700
+
701
+ // Batch add all items at once instead of one by one
702
+ itemsToAdd.forEach(item => addSelectedItem(item));
703
+
704
+ // Use startTransition for non-urgent state updates
705
+ startTransition(() => {
706
+ setSelectedValue(itemIds);
707
+ setInputSelectValue(itemIds);
708
+ });
709
+ if (onSelectAllChecked) {
710
+ onSelectAllChecked(itemIds.slice(1));
711
+ } else {
712
+ batchedOnChange(itemIds.slice(1));
713
+ }
714
+ } else {
715
+ //start check if item have children (option group)
716
+ if (selectedItem?.children?.length) {
717
+ const itemIdsSelect = [];
718
+ const itemIdsUnSelect = [];
719
+ const itemsToAdd = [];
720
+ const itemsToRemove = [];
721
+ selectedItem?.children?.filter(item => !item.isDisabled).forEach(item => {
722
+ if (selectedValueSet.has(item.id)) {
723
+ itemsToRemove.push(item);
724
+ itemIdsUnSelect.push(item.id);
725
+ } else {
726
+ itemsToAdd.push(item);
727
+ itemIdsSelect.push(item.id);
728
+ }
729
+ });
730
+
731
+ // Batch add/remove operations
732
+ itemsToAdd.forEach(item => addSelectedItem(item));
733
+ itemsToRemove.forEach(item => removeSelectedItem(item));
734
+
735
+ //select all child in one of the option groups
736
+ if (itemIdsSelect.length) {
737
+ const newSelectedValue = [...selectedValue, ...itemIdsSelect];
738
+
739
+ // Use startTransition for non-urgent updates
740
+ startTransition(() => {
741
+ setSelectedValue(newSelectedValue);
742
+ setInputSelectValue(newSelectedValue);
743
+ });
744
+ const filteredSelectedValues = newSelectedValue.filter(val => val !== '!all');
745
+ batchedOnChange(filteredSelectedValues);
746
+ }
747
+
748
+ //unselect all child in one of the option groups
749
+ if (itemIdsUnSelect.length) {
750
+ // Use Set for O(1) lookup instead of nested filter
751
+ const unSelectSet = new Set(itemIdsUnSelect);
752
+ const newSelectedValue = selectedValue.filter(selId => !unSelectSet.has(selId) && selId);
753
+
754
+ // Use startTransition for non-urgent updates
755
+ startTransition(() => {
756
+ setSelectedValue(newSelectedValue);
757
+ setInputSelectValue(newSelectedValue);
758
+ });
759
+ const filteredSelectedValues = newSelectedValue.filter(val => val !== '!all');
760
+ batchedOnChange(filteredSelectedValues);
761
+ }
762
+ return;
763
+ }
764
+ //end check if item have children (option group)
765
+
766
+ //start check the child from one of the option groups
767
+ if (selectedValue.includes(selectedItem.id)) {
768
+ removeItem(selectedItem);
769
+ return;
770
+ }
771
+ //end check the child from one of the option groups
772
+
773
+ addSelectedItem(selectedItem);
774
+ const newSelectedValue = [...selectedValue, selectedItem.id];
775
+
776
+ // Use startTransition for non-urgent updates
777
+ startTransition(() => {
778
+ setSelectedValue(newSelectedValue);
779
+ setInputSelectValue(newSelectedValue);
780
+ });
781
+ const filteredSelectedValues = selectedValue.filter(val => val !== '!all');
782
+ batchedOnChange([...filteredSelectedValues, selectedItem.id]);
783
+ }
784
+ selectItem(null);
785
+ }
786
+ }
787
+ break;
788
+ case useCombobox.stateChangeTypes.MenuMouseLeave:
789
+ }
790
+ },
791
+ stateReducer: (state, actionAndChanges) => {
792
+ const {
793
+ changes,
794
+ type
795
+ } = actionAndChanges;
796
+ switch (type) {
797
+ case useCombobox.stateChangeTypes.InputKeyDownEnter:
798
+ case useCombobox.stateChangeTypes.ItemClick:
799
+ return {
800
+ ...changes,
801
+ isOpen: true,
802
+ // keep menu open after selection.
803
+ highlightedIndex: state.highlightedIndex
804
+ };
805
+ case useCombobox.stateChangeTypes.InputBlur:
806
+ if (changes.inputValue) {
807
+ return {
808
+ ...changes
809
+ // isOpen: true, // keep menu open after selection.
810
+ };
811
+ }
812
+ return changes;
813
+ default:
814
+ return changes;
815
+ }
816
+ }
817
+ });
818
+ const memoOptions = useMemo(() => {
819
+ // Skip expensive operations for very large datasets
820
+ const isVeryLarge = option?.length > 10000;
821
+
822
+ // For very large datasets, skip sorting and copying to improve performance
823
+ if (isVeryLarge && !maxSelectedItem) {
824
+ return option || [];
825
+ }
826
+ const optionsCopy = option ? [...option] : [];
827
+ if (sortBy === 'id' && !isVeryLarge) {
828
+ optionsCopy.sort((a, b) => {
829
+ const idA = typeof a.id === 'string' ? a.id.toUpperCase() : a.id;
830
+ const idB = typeof b.id === 'string' ? b.id.toUpperCase() : b.id;
831
+ if (a.id === '!all') return -1;
832
+ if (b.id === '!all') return 1;
833
+ if (idA < idB) return -1;
834
+ if (idA > idB) return 1;
835
+ return 0;
836
+ });
837
+ } else if (sortBy === 'name' && !isVeryLarge) {
838
+ optionsCopy.sort((a, b) => {
839
+ const nameA = typeof a.name === 'string' ? a.name.toUpperCase() : a.name;
840
+ const nameB = typeof b.name === 'string' ? b.name.toUpperCase() : b.name;
841
+ if (a.id === '!all') return -1;
842
+ if (b.id === '!all') return 1;
843
+ if (nameA < nameB) return -1;
844
+ if (nameA > nameB) return 1;
845
+ return 0;
846
+ });
847
+ }
848
+ return maxSelectedItem ? optionsCopy.map(item => {
849
+ const isMaxSelectedItem = maxSelectedItem && selectedValue?.length >= maxSelectedItem;
850
+ if (isMaxSelectedItem && !selectedValue?.includes(item.id)) {
851
+ item.hideCheck = true;
852
+ item.isDisabled = true;
853
+ } else {
854
+ item.hideCheck = false;
855
+ item.isDisabled = false;
856
+ }
857
+ return item;
858
+ }) : optionsCopy;
859
+ }, [maxSelectedItem, option, selectedValue, sortBy]);
860
+ const memoOptionsString = useMemo(() => {
861
+ // For very large datasets, skip JSON.stringify as it's expensive
862
+ if (memoOptions?.length > 10000) {
863
+ return `${memoOptions.length}-${Date.now()}`;
864
+ }
865
+ return JSON.stringify(memoOptions);
866
+ }, [memoOptions]);
867
+
868
+ // Optimize itemsLength calculation - avoid creating arrays
869
+ const itemsLength = useMemo(() => {
870
+ return items?.reduce((count, item) => {
871
+ return count + (item.children ? item.children.length : 1);
872
+ }, 0) || 0;
873
+ }, [items]);
874
+ useEffect(() => {
875
+ if (!inputValue || fetchData) {
876
+ setItems(isShowSelectAll ? [{
877
+ id: '!all',
878
+ name: selectAllLabel ?? (language === 'en' ? 'Select All' : 'Pilih Semua')
879
+ }, ...memoOptions] : memoOptions);
880
+ setInitItems(isShowSelectAll ? [{
881
+ id: '!all',
882
+ name: selectAllLabel ?? (language === 'en' ? 'Select All' : 'Pilih Semua')
883
+ }, ...memoOptions] : memoOptions);
884
+ }
885
+ }, [isShowSelectAll, selectAllLabel, language, memoOptionsString, inputValue, sortBy]);
886
+ useEffect(() => {
887
+ if (selectedValue.length > 0 && disabledOptions.length === 0) {
888
+ setInitItems(sortValue);
889
+ setItems(sortValue);
890
+ }
891
+ }, []);
892
+ useEffect(() => {
893
+ if (disabledOptions.length > 0) {
894
+ const options = generateOptions(sortDisabled);
895
+ setItems(isShowSelectAll ? [{
896
+ id: '!all',
897
+ name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
898
+ }, ...options] : options);
899
+ setInitItems(isShowSelectAll ? [{
900
+ id: '!all',
901
+ name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
902
+ }, ...options] : options);
903
+ }
904
+ }, [disabledOptions, isShowSelectAll]);
905
+ useMountedLayoutEffect(() => {
906
+ const selectedVal = itemsLength > 0 && inputSelectValue.length === itemsLength - 1 ? ['!all', ...inputSelectValue] : inputSelectValue;
907
+ setSelectedValue(selectedVal);
908
+ }, [inputSelectValue, items]);
909
+ useEffect(() => {
910
+ if (!!label && label !== '') {
911
+ setInputValue(label);
912
+ }
913
+ }, [label, isOpen]);
914
+ const toggleCollapsible = () => setShowAllTags(!showAllTags);
915
+ const handleRemoveAllItem = () => {
916
+ onChange?.([]);
917
+ setSelectedValue([]);
918
+ setInputSelectValue([]);
919
+ for (let i = 0; i < selectedValue.length; i++) {
920
+ removeSelectedItem(selectedValue[i]);
921
+ }
922
+ };
923
+ const isShowTagSelectAll = showTagSelectAll && selectedItems?.length > option?.length;
924
+ const renderOptionItem = (item, index, asChild) => {
925
+ const itemProps = getItemProps({
926
+ item,
927
+ index,
928
+ disabled: item.isDisabled
929
+ });
930
+ return /*#__PURE__*/jsxs(ItemWrapper, {
931
+ ...itemProps,
932
+ onClick: e => {
933
+ if (itemProps && itemProps.onClick && typeof itemProps.onClick === 'function') {
934
+ itemProps.onClick(e);
935
+ }
936
+ onItemClick({
937
+ item,
938
+ isSelected: !selectedValueSet.has(item.id)
939
+ });
940
+ },
941
+ css: {
942
+ backgroundColor: highlightedIndex === index ? '$bgGray' : '$bgWhite',
943
+ cursor: item.isDisabled ? 'not-allowed' : 'pointer',
944
+ color: item.isDisabled ? '$textDisable' : 'textPrimary',
945
+ padding: asChild ? '0px $spacing-05' : 0
946
+ },
947
+ children: [/*#__PURE__*/jsxs(IconWrapper, {
948
+ css: {
949
+ width: '16px',
950
+ height: '16px',
951
+ border: '1px solid $iconDisable',
952
+ cursor: item.isDisabled ? 'not-allowed' : 'pointer',
953
+ borderRadius: '$sm',
954
+ ...checkBoxCss
955
+ },
956
+ children: [!item?.hideCheck && (item.isDisabled ? /*#__PURE__*/jsx(CheckOutline, {
957
+ color: colors.iconDisable
958
+ }) : selectedValueSet.has(item.id) && (item.isDisabled === false || item.isDisabled === undefined) && /*#__PURE__*/jsx(CheckOutline, {
959
+ color: colors.iconBrand
960
+ })), isShowSelectAll && item?.id === '!all' && selectedValue?.length && selectedValue?.length < itemsLength && !selectedValueSet.has('!all') ? /*#__PURE__*/jsx(IndeterminateFilled, {
961
+ children: "-"
962
+ }) : /*#__PURE__*/jsx("div", {})]
963
+ }), /*#__PURE__*/jsx(Item, {
964
+ css: {
965
+ backgroundColor: 'unset',
966
+ width: '100%'
967
+ },
968
+ children: item.render ? item.render?.(item.name) : item.name
969
+ })]
970
+ }, item.id);
971
+ };
972
+ let lastGroupIndex = showSelectAll ? 1 : 0;
973
+ const renderOptionGroupItem = (item, index) => {
974
+ // const groupIndex = (index > (showSelectAll ? 1 : 0)) ? lastGroupIndex : 0;
975
+ const groupIndex = lastGroupIndex;
976
+ lastGroupIndex += (item?.children?.length || 0) + 1;
977
+ const filterSelectedChild = item?.children?.filter(e => selectedValueSet.has(e.id) && !e.isDisabled);
978
+ return /*#__PURE__*/jsx(OptionGroupItem, {
979
+ item: /*#__PURE__*/jsxs(ItemWrapper, {
980
+ ...getItemProps({
981
+ item,
982
+ index: groupIndex,
983
+ disabled: item.isDisabled
984
+ }),
985
+ css: {
986
+ backgroundColor: highlightedIndex === groupIndex ? '$bgGray' : '$bgWhite',
987
+ cursor: item.isDisabled ? 'not-allowed' : 'pointer',
988
+ color: item.isDisabled ? '$textDisable' : 'textPrimary'
989
+ },
990
+ children: [/*#__PURE__*/jsx(IconWrapper, {
991
+ css: {
992
+ width: '16px',
993
+ height: '16px',
994
+ border: '1px solid $bgBorder',
995
+ cursor: item.isDisabled ? 'not-allowed' : 'pointer',
996
+ ...checkBoxCss
997
+ },
998
+ children: !item?.hideCheck && item.isDisabled ? /*#__PURE__*/jsx(CheckOutline, {
999
+ color: colors.iconDisable
1000
+ }) : filterSelectedChild?.length === item?.children?.filter(e => !e.isDisabled)?.length ? /*#__PURE__*/jsx(CheckOutline, {
1001
+ color: colors.iconBrand
1002
+ }) : filterSelectedChild?.length > 0 ? /*#__PURE__*/jsx(IndeterminateFilled, {
1003
+ children: "-"
1004
+ }) : null
1005
+ }), /*#__PURE__*/jsx(Item, {
1006
+ css: {
1007
+ backgroundColor: 'unset',
1008
+ width: '100%'
1009
+ },
1010
+ children: item.render ? item.render?.(item.name) : item.name
1011
+ })]
1012
+ }, item.id),
1013
+ children: item?.children?.map((optItem, optIndex) => renderOptionItem(optItem, groupIndex + optIndex + 1, true))
1014
+ });
1015
+ };
1016
+ return /*#__PURE__*/jsxs(Wrapper, {
1017
+ css: css,
1018
+ ...props,
1019
+ mobileOnly: mobileOnly,
1020
+ desktopOnly: desktopOnly,
1021
+ children: [/*#__PURE__*/jsxs(Select, {
1022
+ size: size,
1023
+ disabled: disabled || readOnly,
1024
+ isInvalid: isInvalid,
1025
+ children: [/*#__PURE__*/jsxs(InputWrapper, {
1026
+ ...getComboboxProps(getDropdownProps({
1027
+ preventKeyAction: isOpen,
1028
+ disabled: disabled || readOnly
1029
+ }, {
1030
+ suppressRefError: true
1031
+ }), {
1032
+ suppressRefError: true
1033
+ }),
1034
+ disabled: disabled || readOnly,
1035
+ children: [/*#__PURE__*/jsx(Input, {
1036
+ ...getInputProps({
1037
+ disabled: disabled || readOnly,
1038
+ refKey: 'ref',
1039
+ ref
1040
+ }, {
1041
+ suppressRefError: true
1042
+ }),
1043
+ ...(toggleInput && getToggleButtonProps({
1044
+ disabled: disabled || readOnly
1045
+ })),
1046
+ placeholder: placeholder ?? t('placeholder', 'Pilih Item'),
1047
+ disabled: disabled || readOnly,
1048
+ hidden: !search
1049
+ }), /*#__PURE__*/jsx(Button, {
1050
+ ...getToggleButtonProps({
1051
+ disabled: disabled || readOnly
1052
+ }),
1053
+ disabled: disabled || readOnly,
1054
+ size: size,
1055
+ type: "button",
1056
+ hidden: search,
1057
+ withLabel: !!label,
1058
+ children: label ?? placeholder ?? t('placeholder', 'Pilih Item')
1059
+ })]
1060
+ }), /*#__PURE__*/jsx(IconWrapper, {
1061
+ ...getToggleButtonProps({
1062
+ disabled: disabled || readOnly
1063
+ }),
1064
+ disabled: disabled,
1065
+ readOnly: readOnly,
1066
+ children: /*#__PURE__*/jsx(IconCaretDown, {
1067
+ color: disabled || readOnly ? colors.iconDisable : colors.iconPrimary
1068
+ })
1069
+ })]
1070
+ }), helperText && /*#__PURE__*/jsx(Paragraph, {
1071
+ shortContentRegular: true,
1072
+ css: {
1073
+ paddingTop: 8,
1074
+ fontSize: 12,
1075
+ color: '$textSecondary'
1076
+ },
1077
+ children: helperText
1078
+ }), showSelectedTag && !showCounter && selectedItems.length !== 0 && /*#__PURE__*/jsxs(Fragment, {
1079
+ children: [/*#__PURE__*/jsx(TagWrapper, {
1080
+ disabled: disabled,
1081
+ children: isShowTagSelectAll ? /*#__PURE__*/jsx(Tag, {
1082
+ disabled: disabled,
1083
+ isRemovable: readOnly || disabled || unremovableTags.includes('!all') ? false : true,
1084
+ size: "lg",
1085
+ readOnly: readOnly,
1086
+ ...getSelectedItemProps({
1087
+ selectedItem: {
1088
+ id: '!all',
1089
+ name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
1090
+ },
1091
+ index: 0
1092
+ }),
1093
+ onRemove: handleRemoveAllItem,
1094
+ css: tagCss,
1095
+ children: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
1096
+ }, `selected-item-!all`) : selectedItems?.filter(item => item?.id !== '!all')?.filter((_, idx) => {
1097
+ if (showAllTags || !collapsible) {
1098
+ return true;
1099
+ } else {
1100
+ return idx < 5;
1101
+ }
1102
+ })?.map((selectedItem, index) => /*#__PURE__*/jsx(Tag, {
1103
+ disabled: disabled,
1104
+ isRemovable: readOnly || disabled || unremovableTags.includes(selectedItem.id) ? false : true,
1105
+ size: "lg",
1106
+ readOnly: readOnly,
1107
+ ...getSelectedItemProps({
1108
+ selectedItem,
1109
+ index
1110
+ }),
1111
+ onRemove: event => {
1112
+ if (onRemoveItem) {
1113
+ return onRemoveItem(selectedItem);
1114
+ } else {
1115
+ event.stopPropagation();
1116
+ removeItem(selectedItem);
1117
+ }
1118
+ },
1119
+ css: tagCss,
1120
+ children: selectedItem.name
1121
+ }, `selected-item-${index}`))
1122
+ }), collapsible && !isShowTagSelectAll && selectedItems?.length > collapsibleLimit && /*#__PURE__*/jsxs(Flex, {
1123
+ direction: "column",
1124
+ gap: 4,
1125
+ children: [/*#__PURE__*/jsxs(Flex, {
1126
+ align: "center",
1127
+ justify: "center",
1128
+ onClick: toggleCollapsible,
1129
+ children: [/*#__PURE__*/jsx(Separator, {}), /*#__PURE__*/jsxs(Flex, {
1130
+ align: "center",
1131
+ justify: "center",
1132
+ css: {
1133
+ cursor: 'pointer',
1134
+ userSelect: 'none',
1135
+ padding: '0px 8px'
1136
+ },
1137
+ children: [showAllTags ? /*#__PURE__*/jsx(ChevronUpOutline, {
1138
+ color: colors.iconSecondary
1139
+ }) : /*#__PURE__*/jsx(ChevronDownOutline, {
1140
+ color: colors.iconSecondary
1141
+ }), /*#__PURE__*/jsx(Paragraph, {
1142
+ css: {
1143
+ fontWeight: 600,
1144
+ whiteSpace: 'nowrap'
1145
+ },
1146
+ color: "secondary",
1147
+ children: showAllTags ? t('showSomeText', 'Tampilkan Sebagian') : t('showAllText', 'Tampilkan Semua')
1148
+ })]
1149
+ }), /*#__PURE__*/jsx(Separator, {})]
1150
+ }), showCollapsibleCounter && /*#__PURE__*/jsx(Paragraph, {
1151
+ css: {
1152
+ fontSize: '$label'
1153
+ },
1154
+ color: "brand",
1155
+ children: `${totalOptions ? totalOptions : selectedItems?.filter(item => item?.id !== '!all')?.length} ${labelCounter || t('labelCounterText', 'Item terpilih')}`
1156
+ })]
1157
+ })]
1158
+ }), showCounter && !isShowTagSelectAll && Boolean(selectedItems?.length) && /*#__PURE__*/jsx(Paragraph, {
1159
+ css: {
1160
+ fontSize: '$label',
1161
+ marginTop: '$spacing-01'
1162
+ },
1163
+ color: "brand",
1164
+ children: `${totalOptions ? totalOptions : selectedItems?.filter(item => item?.id !== '!all')?.length} ${labelCounter || t('labelCounterText', 'Item terpilih')}`
1165
+ }), /*#__PURE__*/jsxs(OptionWrapper, {
1166
+ placement: placement,
1167
+ css: {
1168
+ display: isOpen && disabled === false ? 'block' : 'none',
1169
+ top: size === 'lg' ? '45px' : '35px',
1170
+ minHeight: isLoading ? 40 : 0
1171
+ },
1172
+ children: [isLoading && /*#__PURE__*/jsx(Flex, {
1173
+ justify: "center",
1174
+ align: "center",
1175
+ css: {
1176
+ position: 'absolute',
1177
+ inset: 0,
1178
+ zIndex: '$tooltip',
1179
+ top: items.length > 0 ? '0px' : placement === 'top' ? '-20px' : '0px',
1180
+ // bottom: '80px',
1181
+ width: '100%',
1182
+ minHeight: 40,
1183
+ height: scrollerRef.current ? scrollerRef.current.clientHeight : '40px',
1184
+ backgroundColor: '$bgWhite',
1185
+ opacity: 0.8,
1186
+ transform: placement === 'top' ? 'translate(0, -100%)' : 'none'
1187
+ },
1188
+ children: /*#__PURE__*/jsx(Text, {
1189
+ variant: "caption",
1190
+ children: "Loading...."
1191
+ })
1192
+ }), items.length > 0 || isLoading ? /*#__PURE__*/jsx(Option, {
1193
+ ...getMenuProps({
1194
+ ref: scrollerRef
1195
+ }, {
1196
+ suppressRefError: true
1197
+ }),
1198
+ css: optionListCss,
1199
+ children: /*#__PURE__*/jsx(ConditionalWrapper, {
1200
+ condition: !!fetchData && items.length > 0,
1201
+ wrapper: child => /*#__PURE__*/jsx(InfiniteScroll, {
1202
+ loadMore: () => {
1203
+ if (!isLoading) {
1204
+ if (scrollerRef.current) {
1205
+ scrollerRef.current.scrollBy(0, -5);
1206
+ }
1207
+ fetchData?.({
1208
+ query
1209
+ });
1210
+ }
1211
+ },
1212
+ hasMore: true,
1213
+ threshold: 0,
1214
+ useWindow: false,
1215
+ children: child
1216
+ }, isLoading),
1217
+ children: isOpen && shouldVirtualize ?
1218
+ /*#__PURE__*/
1219
+ // Virtualized rendering for large lists
1220
+ jsx(Fragment, {
1221
+ children: /*#__PURE__*/jsx("div", {
1222
+ style: {
1223
+ height: `${rowVirtualizer.totalSize}px`,
1224
+ position: 'relative',
1225
+ width: '100%'
1226
+ },
1227
+ children: rowVirtualizer.virtualItems.map(virtualRow => {
1228
+ const virtualItem = getItemAtIndex(virtualRow.index);
1229
+ if (!virtualItem) return null;
1230
+ const {
1231
+ type,
1232
+ item
1233
+ } = virtualItem;
1234
+ return /*#__PURE__*/jsx("div", {
1235
+ style: {
1236
+ position: 'absolute',
1237
+ top: 0,
1238
+ left: 0,
1239
+ width: '100%',
1240
+ transform: `translateY(${virtualRow.start}px)`
1241
+ },
1242
+ children: type === 'group' ?
1243
+ /*#__PURE__*/
1244
+ // Render option group header (without children, as they're rendered separately)
1245
+ jsxs(ItemWrapper, {
1246
+ ...getItemProps({
1247
+ item,
1248
+ index: virtualRow.index,
1249
+ disabled: item.isDisabled
1250
+ }),
1251
+ css: {
1252
+ backgroundColor: highlightedIndex === virtualRow.index ? '$bgGray' : '$bgWhite',
1253
+ cursor: item.isDisabled ? 'not-allowed' : 'pointer',
1254
+ color: item.isDisabled ? '$textDisable' : 'textPrimary',
1255
+ fontWeight: 600
1256
+ },
1257
+ children: [/*#__PURE__*/jsx(IconWrapper, {
1258
+ css: {
1259
+ width: '16px',
1260
+ height: '16px',
1261
+ border: '1px solid $bgBorder',
1262
+ cursor: item.isDisabled ? 'not-allowed' : 'pointer',
1263
+ ...checkBoxCss
1264
+ },
1265
+ children: !item?.hideCheck && item.isDisabled ? /*#__PURE__*/jsx(CheckOutline, {
1266
+ color: colors.iconDisable
1267
+ }) : item?.children?.filter(e => selectedValueSet.has(e.id) && !e.isDisabled)?.length === item?.children?.filter(e => !e.isDisabled)?.length ? /*#__PURE__*/jsx(CheckOutline, {
1268
+ color: colors.iconBrand
1269
+ }) : item?.children?.filter(e => selectedValueSet.has(e.id) && !e.isDisabled)?.length > 0 ? /*#__PURE__*/jsx(IndeterminateFilled, {
1270
+ children: "-"
1271
+ }) : null
1272
+ }), /*#__PURE__*/jsx(Item, {
1273
+ css: {
1274
+ backgroundColor: 'unset',
1275
+ width: '100%'
1276
+ },
1277
+ children: item.render ? item.render?.(item.name) : item.name
1278
+ })]
1279
+ }) :
1280
+ // Render regular item or child item
1281
+ renderOptionItem(item, virtualRow.index, type === 'child')
1282
+ }, `${type}-${item.id}-${virtualRow.index}`);
1283
+ })
1284
+ })
1285
+ }) :
1286
+ // Non-virtualized rendering for small lists
1287
+ isOpen && items.map((item, index) => item?.children ? renderOptionGroupItem(item) : renderOptionItem(item, index))
1288
+ })
1289
+ }) : /*#__PURE__*/jsx(Option, {
1290
+ css: {
1291
+ height: 'auto'
1292
+ },
1293
+ ...getMenuProps({}, {
1294
+ suppressRefError: true
1295
+ }),
1296
+ children: /*#__PURE__*/jsxs(StyledDiv, {
1297
+ children: [/*#__PURE__*/jsx("div", {
1298
+ style: {
1299
+ marginRight: '6px'
1300
+ },
1301
+ children: /*#__PURE__*/jsx(CircleInfoOutline, {
1302
+ size: "16px",
1303
+ color: colors.iconDisable,
1304
+ style: {
1305
+ verticalAlign: 'text-bottom'
1306
+ }
1307
+ })
1308
+ }), textEmptyItem ?? t('emptyItemText', 'Item tidak ditemukan')]
1309
+ })
1310
+ })]
1311
+ })]
1312
+ });
1313
+ });
1314
+ InputSelectCheck.propTypes = {
1315
+ placeholder: PropTypes.string,
1316
+ option: PropTypes.array.isRequired,
1317
+ size: PropTypes.string,
1318
+ disabled: PropTypes.bool,
1319
+ readOnly: PropTypes.bool,
1320
+ isInvalid: PropTypes.bool,
1321
+ sortBy: PropTypes.string,
1322
+ value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)]),
1323
+ onChange: PropTypes.func,
1324
+ onRemoveItem: PropTypes.func,
1325
+ search: PropTypes.bool,
1326
+ placement: PropTypes.oneOf(['top', 'bottom']),
1327
+ disabledOptions: PropTypes.arrayOf(PropTypes.string),
1328
+ disabledSortChecked: PropTypes.bool,
1329
+ unremovableTags: PropTypes.arrayOf(PropTypes.string),
1330
+ textEmptyItem: PropTypes.string,
1331
+ showSelectAll: PropTypes.bool,
1332
+ selectAllLabel: PropTypes.string,
1333
+ showSelectedTag: PropTypes.bool,
1334
+ css: PropTypes.object,
1335
+ helperText: PropTypes.string,
1336
+ showCounter: PropTypes.bool,
1337
+ labelCounter: PropTypes.string,
1338
+ collapsible: PropTypes.bool,
1339
+ toggleInput: PropTypes.bool,
1340
+ defaultValue: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)]),
1341
+ fetchData: PropTypes.func,
1342
+ onSearch: PropTypes.func,
1343
+ isLoading: PropTypes.bool,
1344
+ showTagSelectAll: PropTypes.bool,
1345
+ maxSelectedItem: PropTypes.number,
1346
+ mobileOnly: PropTypes.bool,
1347
+ desktopOnly: PropTypes.bool,
1348
+ label: PropTypes.string,
1349
+ tagCss: PropTypes.object,
1350
+ checkBoxCss: PropTypes.object,
1351
+ optionListCss: PropTypes.object,
1352
+ showCollapsibleCounter: PropTypes.bool,
1353
+ collapsibleLimit: PropTypes.number,
1354
+ clearSearchOnSelect: PropTypes.bool,
1355
+ onItemClick: PropTypes.func,
1356
+ virtualized: PropTypes.bool,
1357
+ virtualizedThreshold: PropTypes.number
1358
+ };
1359
+ InputSelectCheck.defaultProps = {
1360
+ size: 'lg',
1361
+ disabled: false,
1362
+ readOnly: false,
1363
+ isInvalid: false,
1364
+ search: true,
1365
+ placement: 'bottom',
1366
+ value: [],
1367
+ disabledOptions: [],
1368
+ disabledSortChecked: false,
1369
+ unremovableTags: [],
1370
+ sortBy: 'name',
1371
+ showSelectAll: true,
1372
+ showCounter: false,
1373
+ collapsible: true,
1374
+ toggleInput: true,
1375
+ defaultValue: [],
1376
+ label: undefined,
1377
+ tagCss: {},
1378
+ checkBoxCss: {},
1379
+ optionListCss: {},
1380
+ showCollapsibleCounter: true,
1381
+ collapsibleLimit: 5,
1382
+ clearSearchOnSelect: true,
1383
+ onItemClick: () => {},
1384
+ virtualized: true,
1385
+ virtualizedThreshold: 100
1386
+ };
1387
+
1388
+ export { InputSelectCheck as default };