@majoo-ui/react 2.0.1 → 2.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/charts.esm.js +3 -1453
- package/colors/Colors.esm.js +93 -0
- package/components/accordion/Accordion.esm.js +109 -0
- package/components/alertDialog/AlertDialog.esm.js +440 -0
- package/components/avatar/Avatar.esm.js +83 -0
- package/components/badge/Badge.esm.js +255 -0
- package/components/banner/Banner.esm.js +341 -0
- package/components/barChart/BarChart.esm.js +212 -0
- package/components/breadcrumb/Breadcrumb.esm.js +65 -0
- package/components/breadcrumb/index.esm.js +19 -0
- package/components/button/Button.esm.js +331 -0
- package/components/buttonGroup/ButtonGroup.esm.js +350 -0
- package/components/card/Card.esm.js +236 -0
- package/components/chart/assets/data_kosong.png.esm.js +3 -0
- package/components/chart/lineChart/LineChart.esm.js +358 -0
- package/components/chart/lineChart/components/Comparator.esm.js +82 -0
- package/components/chart/lineChart/components/ComparatorController.esm.js +112 -0
- package/components/chart/lineChart/components/ComparatorItem.esm.js +104 -0
- package/components/chart/lineChart/components/ProductList.esm.js +78 -0
- package/components/chart/lineChart/components/TitleLegend.esm.js +107 -0
- package/components/chart/lineChart/components/Tooltip.esm.js +90 -0
- package/components/chart/utils/index.esm.js +109 -0
- package/components/checkboxTable/CheckboxTable.esm.js +287 -0
- package/components/colorPicker/ColorPicker.esm.js +342 -0
- package/components/colorPicker/InputColorPicker.esm.js +120 -0
- package/components/colorPicker/assets/img_colormap.gif.esm.js +3 -0
- package/components/colorPicker/components/ColorFields.esm.js +144 -0
- package/components/colorPicker/components/ColorMap.esm.js +1188 -0
- package/components/contentEditor/ContentEditor.esm.js +251 -0
- package/components/contentEditor/assets/Inline-code-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Link-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-bulleted-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-numbered-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Redo-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-bold-filled.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-clear-format-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-italic-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-strikethrough-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-underline-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Undo-outline.svg.esm.js +3 -0
- package/components/contextMenu/ContextMenu.esm.js +298 -0
- package/components/datePicker/AdvancedOption.esm.js +37 -0
- package/components/datePicker/CustomDatePicker.esm.js +121 -0
- package/components/datePicker/DatePicker.esm.js +244 -0
- package/components/datePicker/DatePickerMulti.esm.js +70 -0
- package/components/datePicker/InputDatePicker.esm.js +290 -0
- package/components/datePicker/InputDateRangePicker.esm.js +174 -0
- package/components/datePicker/components/Calendar.esm.js +654 -0
- package/components/datePicker/components/CalendarMulti.esm.js +407 -0
- package/components/datePicker/components/CalendarTimePicker.esm.js +104 -0
- package/components/datePicker/components/DateNumber.esm.js +89 -0
- package/components/datePicker/components/MobileCalendar.esm.js +522 -0
- package/components/datePicker/state/reducer.esm.js +286 -0
- package/components/datePicker/timePicker/InputTimePicker.esm.js +205 -0
- package/components/datePicker/timePicker/TimePicker.esm.js +481 -0
- package/components/devicePreview/DevicePreview.esm.js +631 -0
- package/components/devicePreview/deviceFrame/android-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/android-wide-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-email.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-notification.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-sms.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-whatsapp.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/desktop-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/ic-majoo-profpic.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/iphone-transparant.png.esm.js +3 -0
- package/components/dialog/Dialog.esm.js +106 -0
- package/components/drawer/Drawer.esm.js +294 -0
- package/components/dropdownMenu/DropdownMenu.esm.js +281 -0
- package/components/editableTable/EditableMobile.esm.js +361 -0
- package/components/editableTable/EditableTable.esm.js +618 -0
- package/components/editableTable/transition.esm.js +37 -0
- package/components/form/components/FormGroup/FormGroup.esm.js +142 -0
- package/components/form/components/FormHelper/Helper.esm.js +50 -0
- package/components/form/components/FormLabel/Label.esm.js +90 -0
- package/components/form/components/InputAddon/InputAddon.esm.js +105 -0
- package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +60 -0
- package/components/form/components/InputCheckbox/InputCheckbox.esm.js +129 -0
- package/components/form/components/InputCheckbox/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputCheckbox/icon/MinusOutline.esm.js +33 -0
- package/components/form/components/InputCombobox/InputCombobox.esm.js +169 -0
- package/components/form/components/InputCounter/InputCounter.esm.js +226 -0
- package/components/form/components/InputCreatable/InputCreatable.esm.js +229 -0
- package/components/form/components/InputDateRange/InputDateRange.esm.js +46 -0
- package/components/form/components/InputElement/InputElement.esm.js +35 -0
- package/components/form/components/InputGroup/InputGroup.esm.js +188 -0
- package/components/form/components/InputLetter/InputLetter.esm.js +68 -0
- package/components/form/components/InputNumber/InputNumber.esm.js +248 -0
- package/components/form/components/InputNumber/NumberFormat.esm.js +1263 -0
- package/components/form/components/InputOTP/InputOTP.esm.js +70 -0
- package/components/form/components/InputRadio/InputRadio.esm.js +273 -0
- package/components/form/components/InputRadio/InputRadioGroup.esm.js +35 -0
- package/components/form/components/InputRadio/context.esm.js +5 -0
- package/components/form/components/InputResourceList/InputResourceList.esm.js +429 -0
- package/components/form/components/InputSearchbox/CloseFilled.esm.js +34 -0
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +90 -0
- package/components/form/components/InputSearchbox/SearchOutline.esm.js +26 -0
- package/components/form/components/InputSelect/InputSelect.esm.js +964 -0
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +1388 -0
- package/components/form/components/InputSelectCheck/OptionGroupItem.esm.js +39 -0
- package/components/form/components/InputSelectCheck/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputSelectTag/InputSelectTag.esm.js +62 -0
- package/components/form/components/InputSignature/InputSignature.esm.js +122 -0
- package/components/form/components/InputSignature/SignatureModal.esm.js +67 -0
- package/components/form/components/InputSwitch/InputSwitch.esm.js +96 -0
- package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +136 -0
- package/components/form/components/InputTags/InputTags.esm.js +268 -0
- package/components/form/components/InputText/InputText.esm.js +197 -0
- package/components/form/components/InputTextArea/InputTextArea.esm.js +77 -0
- package/components/heading/Heading.esm.js +64 -0
- package/components/iconButton/IconButton.esm.js +71 -0
- package/components/image/Image.esm.js +141 -0
- package/components/link/Link.esm.js +59 -0
- package/components/loadingBar/LoadingBar.esm.js +113 -0
- package/components/mapPicker/InputMapPicker.esm.js +160 -0
- package/components/mapPicker/MapPicker.esm.js +122 -0
- package/components/mapPicker/MapPicker.styles.esm.js +70 -0
- package/components/mapPicker/assets/images/Mapsicle.png.esm.js +3 -0
- package/components/mapPicker/components/AddressCard.esm.js +25 -0
- package/components/mapPicker/components/ButtonSelect.esm.js +46 -0
- package/components/mapPicker/components/ChangeView.esm.js +20 -0
- package/components/mapPicker/components/InputSearch.esm.js +74 -0
- package/components/mapPicker/components/MarkerIcon.esm.js +22 -0
- package/components/mapPicker/components/MarkerSvg.esm.js +62 -0
- package/components/mapPicker/components/ZoomControls.esm.js +36 -0
- package/components/mapPicker/hooks/useMapSearch.esm.js +161 -0
- package/components/modalDialog/ModalDialog.esm.js +247 -0
- package/components/notificationBadge/NotificationBadge.esm.js +149 -0
- package/components/pageDialog/PageDialog.esm.js +291 -0
- package/components/pageDialog/logo.svg.esm.js +3 -0
- package/components/pagination/Pagination.esm.js +94 -0
- package/components/pagination/PaginationButton.esm.js +346 -0
- package/components/pagination/PaginationInfo.esm.js +146 -0
- package/components/paper/Paper.esm.js +76 -0
- package/components/paragraph/Paragraph.esm.js +52 -0
- package/components/pieChart/PieChart.esm.js +287 -0
- package/components/popover/Popover.esm.js +142 -0
- package/components/progress/Progress.esm.js +170 -0
- package/components/progressIndicator/ProgressIndicator.esm.js +287 -0
- package/components/scrollSync/ScrollSync.esm.js +172 -0
- package/components/scrollSync/ScrollSyncNode.esm.js +87 -0
- package/components/scrollSync/utils.esm.js +9 -0
- package/components/separator/Separator.esm.js +43 -0
- package/components/skeleton/Skeleton.esm.js +131 -0
- package/components/slider/Slider.esm.js +345 -0
- package/components/stepWizard/StepWizard.esm.js +451 -0
- package/components/stepWizard/index.esm.js +14 -0
- package/components/table/MobileTable.esm.js +415 -0
- package/components/table/Table.esm.js +1472 -0
- package/components/table/components/columns/DateColumn.esm.js +26 -0
- package/components/table/components/columns/DecimalColumn.esm.js +36 -0
- package/components/table/components/columns/PriceColumn.esm.js +57 -0
- package/components/table/components/columns/RowDraggableColumn.esm.js +24 -0
- package/components/table/components/columns/RowExpanderColumn.esm.js +32 -0
- package/components/table/components/columns/RowExpanderMultipleColumn.esm.js +24 -0
- package/components/table/components/columns/RowMenuColumn.esm.js +101 -0
- package/components/table/components/columns/RowSelectionCallbackColumn.esm.js +38 -0
- package/components/table/components/columns/RowSelectionColumn.esm.js +34 -0
- package/components/table/images/img-emptydata.webp.esm.js +3 -0
- package/components/table/images/img-emptysearchdata.webp.esm.js +3 -0
- package/components/tableOfContent/TableOfContent.esm.js +267 -0
- package/components/tableOfContent/index.esm.js +18 -0
- package/components/tableOfContent/transition.esm.js +38 -0
- package/components/tabs/Tabs.esm.js +282 -0
- package/components/tag/Tag.esm.js +161 -0
- package/components/tagList/TagList.esm.js +90 -0
- package/components/tagStatus/TagStatus.esm.js +134 -0
- package/components/text/Text.esm.js +140 -0
- package/components/toast/Toast.esm.js +297 -0
- package/components/toast/ToastContainer.esm.js +73 -0
- package/components/toast/context/ToastContext.esm.js +5 -0
- package/components/toast/context/ToastProvider.esm.js +96 -0
- package/components/tooltip/Tooltip.esm.js +175 -0
- package/components/upload/Upload.esm.js +1103 -0
- package/components/upload/utils/canvasPreview.esm.js +39 -0
- package/components/upload/utils/imgPreview.esm.js +21 -0
- package/config/stitches.config.esm.js +216 -0
- package/editor.esm.js +1 -264
- package/hooks/useListOption/useListOption.esm.js +56 -0
- package/hooks/useToggle/useToggle.esm.js +8 -0
- package/index.esm.js +106 -42293
- package/layout/box/Box.esm.js +24 -0
- package/layout/flex/Flex.esm.js +135 -0
- package/layout/grid/Grid.esm.js +270 -0
- package/layout/pageContainer/PageContainer.esm.js +60 -0
- package/majoo-provider/MajooProvider.esm.js +42 -0
- package/majoo-provider/ThemeProvider.esm.js +41 -0
- package/majoo-provider/globalStyles.esm.js +242 -0
- package/majoo-provider/styles/modern-normalize.esm.js +95 -0
- package/map.esm.js +2 -734
- package/package.json +8 -4
- package/utils/calendar.esm.js +26 -0
- package/utils/element.esm.js +21 -0
- package/utils/object.esm.js +12 -0
- package/utils/request.esm.js +74 -0
- package/utils/strings.esm.js +6 -0
- package/{useMediaQuery.esm.js → utils/useMediaQuery.esm.js} +1 -1
- package/utils/useNavigatorOnline.esm.js +19 -0
- package/utils/variant.esm.js +12 -0
- package/wrapper/ConditionalWrapper.esm.js +9 -0
- package/ModalDialog.esm.js +0 -2669
- package/Separator.esm.js +0 -3002
- package/stitches.config.esm.js +0 -2284
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import 'core-js/modules/es.array.push.js';
|
|
2
|
+
import 'core-js/modules/es.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/es.iterator.map.js';
|
|
4
|
+
import { ArrowLeftOutline, ArrowRightOutline } from '@majoo-ui/icons';
|
|
5
|
+
import debounce from 'lodash.debounce';
|
|
6
|
+
import { useRef, useState, useEffect, useCallback } from 'react';
|
|
7
|
+
import Box from '../../layout/box/Box.esm.js';
|
|
8
|
+
import Flex from '../../layout/flex/Flex.esm.js';
|
|
9
|
+
import { Button } from '../button/Button.esm.js';
|
|
10
|
+
import { InputNumber } from '../form/components/InputNumber/InputNumber.esm.js';
|
|
11
|
+
import ModalDialog, { ModalDialogTrigger, ModalDialogTitle, ModalDialogContent, ModalDialogFooter } from '../modalDialog/ModalDialog.esm.js';
|
|
12
|
+
import { Separator } from '../separator/Separator.esm.js';
|
|
13
|
+
import Text from '../text/Text.esm.js';
|
|
14
|
+
import { colors, styled } from '../../config/stitches.config.esm.js';
|
|
15
|
+
import useMediaQuery from '../../utils/useMediaQuery.esm.js';
|
|
16
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
17
|
+
import IconButton from '../iconButton/IconButton.esm.js';
|
|
18
|
+
|
|
19
|
+
const PrevNextButton = styled(Text, {
|
|
20
|
+
padding: '$spacing-01',
|
|
21
|
+
cursor: 'pointer',
|
|
22
|
+
userSelect: 'none',
|
|
23
|
+
borderRadius: '$md',
|
|
24
|
+
'&:hover': {
|
|
25
|
+
backgroundColor: '$primary50'
|
|
26
|
+
},
|
|
27
|
+
'&:active': {
|
|
28
|
+
backgroundColor: '$primary100'
|
|
29
|
+
},
|
|
30
|
+
variants: {
|
|
31
|
+
isDisabled: {
|
|
32
|
+
true: {
|
|
33
|
+
'&:hover': {
|
|
34
|
+
backgroundColor: 'transparent'
|
|
35
|
+
},
|
|
36
|
+
cursor: 'default'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const GoToPageBox = styled(Flex, {
|
|
42
|
+
height: 28,
|
|
43
|
+
width: 'fit-content',
|
|
44
|
+
minWidth: 28,
|
|
45
|
+
border: '1px solid $bgBorder',
|
|
46
|
+
borderRadius: 5,
|
|
47
|
+
boxShadow: '0px 4px 10px rgba(0, 0, 0, 0.07)',
|
|
48
|
+
fontSize: '$label',
|
|
49
|
+
cursor: 'pointer'
|
|
50
|
+
});
|
|
51
|
+
const PrevNextButtonIcon = ({
|
|
52
|
+
onClick,
|
|
53
|
+
iconType,
|
|
54
|
+
hidden
|
|
55
|
+
}) => {
|
|
56
|
+
const [isHover, setIsHover] = useState(false);
|
|
57
|
+
function handleEnter() {
|
|
58
|
+
setIsHover(true);
|
|
59
|
+
}
|
|
60
|
+
function handleLeave() {
|
|
61
|
+
setIsHover(false);
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/jsx(Button, {
|
|
64
|
+
css: {
|
|
65
|
+
height: 40,
|
|
66
|
+
width: 48,
|
|
67
|
+
minWidth: 48
|
|
68
|
+
},
|
|
69
|
+
hidden: hidden,
|
|
70
|
+
type: "button",
|
|
71
|
+
buttonType: "ghost",
|
|
72
|
+
onMouseEnter: handleEnter,
|
|
73
|
+
onMouseLeave: handleLeave,
|
|
74
|
+
onClick: onClick,
|
|
75
|
+
children: iconType === 'prev' ? /*#__PURE__*/jsx(ArrowLeftOutline, {
|
|
76
|
+
color: isHover ? colors.iconBrand : colors.iconPrimary
|
|
77
|
+
}) : /*#__PURE__*/jsx(ArrowRightOutline, {
|
|
78
|
+
color: isHover ? colors.iconBrand : colors.iconPrimary
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const PageButton = ({
|
|
83
|
+
isActive,
|
|
84
|
+
onClick,
|
|
85
|
+
...props
|
|
86
|
+
}) => {
|
|
87
|
+
return /*#__PURE__*/jsx(Button, {
|
|
88
|
+
type: "button",
|
|
89
|
+
onClick: onClick,
|
|
90
|
+
buttonType: !isActive ? 'ghost' : 'primary',
|
|
91
|
+
css: {
|
|
92
|
+
minWidth: 'initial',
|
|
93
|
+
width: 40,
|
|
94
|
+
height: 40,
|
|
95
|
+
padding: 0,
|
|
96
|
+
color: !isActive && '$textSecondary',
|
|
97
|
+
'@md': {
|
|
98
|
+
width: 28,
|
|
99
|
+
height: 28
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
...props
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const PaginationButton = ({
|
|
106
|
+
currentPage,
|
|
107
|
+
totalPages,
|
|
108
|
+
onSelect,
|
|
109
|
+
hideInputPageSection,
|
|
110
|
+
previousButton,
|
|
111
|
+
nextButton,
|
|
112
|
+
gotoPageText,
|
|
113
|
+
goToPagePlaceholder,
|
|
114
|
+
btnCancelText,
|
|
115
|
+
btnSubmitText
|
|
116
|
+
}) => {
|
|
117
|
+
const isLg = useMediaQuery('(max-width: 800px)');
|
|
118
|
+
const handleSelectPage = page => {
|
|
119
|
+
if (onSelect && page > 0 && page <= totalPages) {
|
|
120
|
+
onSelect(page);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const inputPageRef = useRef();
|
|
124
|
+
const dialogPageRef = useRef();
|
|
125
|
+
const [goToPage, setGoToPage] = useState();
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (inputPageRef.current) {
|
|
128
|
+
inputPageRef.current.value = '';
|
|
129
|
+
}
|
|
130
|
+
}, [currentPage]);
|
|
131
|
+
const debouncedGoToPage = useCallback(debounce(handleSelectPage, 1000), [totalPages]);
|
|
132
|
+
const generatePages = () => {
|
|
133
|
+
const maxButtons = isLg ? currentPage < 3 ? 3 : currentPage >= 4 ? currentPage > totalPages - 2 ? 3 : 1 : 2 : 5;
|
|
134
|
+
const pageButtons = [];
|
|
135
|
+
let startPage;
|
|
136
|
+
let endPage;
|
|
137
|
+
if (maxButtons < totalPages) {
|
|
138
|
+
startPage = Math.max(Math.min(currentPage - Math.floor(maxButtons / 2), totalPages - maxButtons + 1), 1);
|
|
139
|
+
endPage = startPage + maxButtons - 1;
|
|
140
|
+
} else {
|
|
141
|
+
startPage = 1;
|
|
142
|
+
endPage = totalPages;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// eslint-disable-next-line no-plusplus
|
|
146
|
+
for (let page = startPage; page <= endPage; ++page) {
|
|
147
|
+
pageButtons.push(page);
|
|
148
|
+
}
|
|
149
|
+
if (startPage > 1) {
|
|
150
|
+
if (startPage > 2) {
|
|
151
|
+
pageButtons.unshift('\u2026');
|
|
152
|
+
}
|
|
153
|
+
pageButtons.unshift(1);
|
|
154
|
+
}
|
|
155
|
+
if (endPage < totalPages) {
|
|
156
|
+
if (endPage < totalPages - 1) {
|
|
157
|
+
pageButtons.push('\u2026');
|
|
158
|
+
}
|
|
159
|
+
pageButtons.push(totalPages);
|
|
160
|
+
}
|
|
161
|
+
return pageButtons;
|
|
162
|
+
};
|
|
163
|
+
const isMobilePagination = useMediaQuery('(max-width: 767px)');
|
|
164
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
165
|
+
children: [/*#__PURE__*/jsxs(Flex, {
|
|
166
|
+
align: "center",
|
|
167
|
+
direction: isMobilePagination ? 'column' : 'row',
|
|
168
|
+
gap: isMobilePagination ? 2 : 0,
|
|
169
|
+
css: {
|
|
170
|
+
height: isMobilePagination ? 'unset' : 28
|
|
171
|
+
},
|
|
172
|
+
children: [/*#__PURE__*/jsxs(Flex, {
|
|
173
|
+
align: "center",
|
|
174
|
+
gap: 2,
|
|
175
|
+
children: [(currentPage > 1 || totalPages === 1) && /*#__PURE__*/jsxs(Fragment, {
|
|
176
|
+
children: [!isLg && /*#__PURE__*/jsx(IconButton, {
|
|
177
|
+
type: "button",
|
|
178
|
+
buttonType: "secondary",
|
|
179
|
+
disabled: currentPage === 1,
|
|
180
|
+
onClick: () => handleSelectPage(1),
|
|
181
|
+
css: {
|
|
182
|
+
color: '$iconPrimary'
|
|
183
|
+
},
|
|
184
|
+
children: /*#__PURE__*/jsx(ArrowLeftOutline, {
|
|
185
|
+
color: "currentColor"
|
|
186
|
+
})
|
|
187
|
+
}), isLg ? /*#__PURE__*/jsx(PrevNextButtonIcon, {
|
|
188
|
+
type: "button",
|
|
189
|
+
buttonType: "ghost",
|
|
190
|
+
iconType: "prev",
|
|
191
|
+
hidden: totalPages < 2,
|
|
192
|
+
onClick: () => handleSelectPage(currentPage - 1)
|
|
193
|
+
}) : /*#__PURE__*/jsx(PrevNextButton, {
|
|
194
|
+
variant: "caption",
|
|
195
|
+
isDisabled: currentPage === 1,
|
|
196
|
+
color: currentPage === 1 ? 'disable' : 'primary',
|
|
197
|
+
onClick: () => handleSelectPage(currentPage - 1),
|
|
198
|
+
children: previousButton || 'Sebelumnya'
|
|
199
|
+
})]
|
|
200
|
+
}), generatePages().map((page, index) => {
|
|
201
|
+
return /*#__PURE__*/jsx(PageButton, {
|
|
202
|
+
isActive: page === currentPage,
|
|
203
|
+
onClick: () => typeof page === 'number' ? handleSelectPage(page) : null,
|
|
204
|
+
children: page
|
|
205
|
+
}, index.toString());
|
|
206
|
+
}), (currentPage < totalPages || totalPages === 1) && /*#__PURE__*/jsxs(Fragment, {
|
|
207
|
+
children: [isLg ? /*#__PURE__*/jsx(PrevNextButtonIcon, {
|
|
208
|
+
type: "button",
|
|
209
|
+
buttonType: "ghost",
|
|
210
|
+
iconType: "next",
|
|
211
|
+
hidden: totalPages < 2,
|
|
212
|
+
onClick: () => handleSelectPage(currentPage + 1)
|
|
213
|
+
}) : /*#__PURE__*/jsx(PrevNextButton, {
|
|
214
|
+
variant: "caption",
|
|
215
|
+
isDisabled: currentPage === totalPages,
|
|
216
|
+
color: currentPage === totalPages ? 'disable' : 'primary',
|
|
217
|
+
onClick: () => handleSelectPage(currentPage + 1),
|
|
218
|
+
children: nextButton || 'Selanjutnya'
|
|
219
|
+
}), !isLg && /*#__PURE__*/jsx(IconButton, {
|
|
220
|
+
type: "button",
|
|
221
|
+
buttonType: "secondary",
|
|
222
|
+
disabled: currentPage === totalPages,
|
|
223
|
+
onClick: () => handleSelectPage(totalPages),
|
|
224
|
+
css: {
|
|
225
|
+
color: '$iconPrimary'
|
|
226
|
+
},
|
|
227
|
+
children: /*#__PURE__*/jsx(ArrowRightOutline, {
|
|
228
|
+
color: "currentColor"
|
|
229
|
+
})
|
|
230
|
+
})]
|
|
231
|
+
})]
|
|
232
|
+
}), !hideInputPageSection && totalPages > 1 && /*#__PURE__*/jsxs(Fragment, {
|
|
233
|
+
children: [/*#__PURE__*/jsx(Separator, {
|
|
234
|
+
orientation: "vertical",
|
|
235
|
+
css: {
|
|
236
|
+
height: '100%',
|
|
237
|
+
margin: '0 $spacing-03 0 $spacing-01',
|
|
238
|
+
display: isMobilePagination ? 'none' : 'inherit'
|
|
239
|
+
}
|
|
240
|
+
}), /*#__PURE__*/jsxs(Box, {
|
|
241
|
+
css: {
|
|
242
|
+
display: 'flex',
|
|
243
|
+
alignItems: 'center',
|
|
244
|
+
gap: 8,
|
|
245
|
+
flex: isMobilePagination ? 1 : 'unset'
|
|
246
|
+
},
|
|
247
|
+
children: [/*#__PURE__*/jsx(Text, {
|
|
248
|
+
variant: "caption",
|
|
249
|
+
css: {
|
|
250
|
+
fontSize: 12,
|
|
251
|
+
fontWeight: 400,
|
|
252
|
+
color: '$textPrimary',
|
|
253
|
+
...(isMobilePagination && {
|
|
254
|
+
backgroundColor: '$bgWhite',
|
|
255
|
+
padding: 4,
|
|
256
|
+
borderRadius: 4
|
|
257
|
+
})
|
|
258
|
+
},
|
|
259
|
+
children: gotoPageText || 'Ke Halaman'
|
|
260
|
+
}), isMobilePagination ? /*#__PURE__*/jsx(GoToPageBox, {
|
|
261
|
+
align: "center",
|
|
262
|
+
justify: "center",
|
|
263
|
+
onClick: () => dialogPageRef.current?.click(),
|
|
264
|
+
children: goToPage
|
|
265
|
+
}) : /*#__PURE__*/jsx(InputNumber, {
|
|
266
|
+
ref: inputPageRef,
|
|
267
|
+
isAllowed: ({
|
|
268
|
+
floatValue
|
|
269
|
+
}) => floatValue === undefined || floatValue > 0 && floatValue <= totalPages,
|
|
270
|
+
allowNegative: false,
|
|
271
|
+
onChange: e => {
|
|
272
|
+
if (e.target.value) {
|
|
273
|
+
debouncedGoToPage(Number(e.target.value));
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
css: {
|
|
277
|
+
width: 28,
|
|
278
|
+
height: 28,
|
|
279
|
+
padding: 0,
|
|
280
|
+
textAlign: 'center',
|
|
281
|
+
'&::-webkit-inner-spin-button': {
|
|
282
|
+
'-webkit-appearance': 'none',
|
|
283
|
+
margin: 0
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
})]
|
|
287
|
+
})]
|
|
288
|
+
})]
|
|
289
|
+
}), /*#__PURE__*/jsxs(ModalDialog, {
|
|
290
|
+
children: [/*#__PURE__*/jsx(ModalDialogTrigger, {
|
|
291
|
+
style: {
|
|
292
|
+
display: 'none'
|
|
293
|
+
},
|
|
294
|
+
children: /*#__PURE__*/jsx("div", {
|
|
295
|
+
ref: dialogPageRef
|
|
296
|
+
})
|
|
297
|
+
}), /*#__PURE__*/jsx(ModalDialogTitle, {
|
|
298
|
+
children: gotoPageText || 'Ke Halaman'
|
|
299
|
+
}), /*#__PURE__*/jsx(ModalDialogContent, {
|
|
300
|
+
children: /*#__PURE__*/jsx("form", {
|
|
301
|
+
onSubmit: () => {
|
|
302
|
+
debouncedGoToPage(Number(goToPage));
|
|
303
|
+
dialogPageRef.current?.click();
|
|
304
|
+
},
|
|
305
|
+
children: /*#__PURE__*/jsx(InputNumber, {
|
|
306
|
+
ref: inputPageRef,
|
|
307
|
+
placeholder: goToPagePlaceholder || 'Contoh: 10',
|
|
308
|
+
isAllowed: ({
|
|
309
|
+
floatValue
|
|
310
|
+
}) => floatValue === undefined || floatValue > 0 && floatValue <= totalPages,
|
|
311
|
+
allowNegative: false,
|
|
312
|
+
onChange: e => setGoToPage(e.target?.value)
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
}), /*#__PURE__*/jsx(ModalDialogFooter, {
|
|
316
|
+
children: /*#__PURE__*/jsxs(Flex, {
|
|
317
|
+
css: {
|
|
318
|
+
width: '100%'
|
|
319
|
+
},
|
|
320
|
+
gap: 4,
|
|
321
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
322
|
+
block: true,
|
|
323
|
+
type: "button",
|
|
324
|
+
buttonType: "ghost",
|
|
325
|
+
onClick: () => {
|
|
326
|
+
setGoToPage(null);
|
|
327
|
+
dialogPageRef.current?.click();
|
|
328
|
+
},
|
|
329
|
+
children: btnCancelText || 'Batal'
|
|
330
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
331
|
+
block: true,
|
|
332
|
+
type: "button",
|
|
333
|
+
buttonType: "primary",
|
|
334
|
+
onClick: () => {
|
|
335
|
+
debouncedGoToPage(Number(goToPage));
|
|
336
|
+
dialogPageRef.current?.click();
|
|
337
|
+
},
|
|
338
|
+
children: btnSubmitText || 'Lanjutkan'
|
|
339
|
+
})]
|
|
340
|
+
})
|
|
341
|
+
})]
|
|
342
|
+
})]
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
export { PaginationButton as default };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import 'core-js/modules/es.iterator.constructor.js';
|
|
2
|
+
import 'core-js/modules/es.iterator.map.js';
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import { ChevronDownOutline } from '@majoo-ui/icons';
|
|
5
|
+
import { colors, styled } from '../../config/stitches.config.esm.js';
|
|
6
|
+
import Box from '../../layout/box/Box.esm.js';
|
|
7
|
+
import Flex from '../../layout/flex/Flex.esm.js';
|
|
8
|
+
import Text from '../text/Text.esm.js';
|
|
9
|
+
import ModalDialog, { ModalDialogTrigger, ModalDialogTitle, ModalDialogContent } from '../modalDialog/ModalDialog.esm.js';
|
|
10
|
+
import useMediaQuery from '../../utils/useMediaQuery.esm.js';
|
|
11
|
+
import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
|
|
12
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
13
|
+
import { Popover, PopoverTrigger, PopoverContent, PopoverClose } from '../popover/Popover.esm.js';
|
|
14
|
+
|
|
15
|
+
const LimitContainer = styled(Flex, {
|
|
16
|
+
cursor: 'pointer'
|
|
17
|
+
});
|
|
18
|
+
const limitItemContainerStyle = selected => ({
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
width: '100%',
|
|
21
|
+
padding: '$spacing-02',
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
backgroundColor: selected ? '$primary100' : 'transparent',
|
|
24
|
+
'&:hover': {
|
|
25
|
+
backgroundColor: '$primary50'
|
|
26
|
+
},
|
|
27
|
+
'&:active': {
|
|
28
|
+
backgroundColor: '$primary100'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function PaginationInfo({
|
|
32
|
+
limits,
|
|
33
|
+
selectedLimit,
|
|
34
|
+
currentPage,
|
|
35
|
+
totalData,
|
|
36
|
+
onChange,
|
|
37
|
+
showingText,
|
|
38
|
+
showingCountText,
|
|
39
|
+
dialogShowingText,
|
|
40
|
+
...rest
|
|
41
|
+
}) {
|
|
42
|
+
const from = (currentPage - 1) * selectedLimit + 1;
|
|
43
|
+
const to = selectedLimit * currentPage < totalData ? selectedLimit * currentPage : totalData;
|
|
44
|
+
const dialogLimitRef = useRef();
|
|
45
|
+
const isMobilePagination = useMediaQuery('(max-width: 767px)');
|
|
46
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
47
|
+
children: [/*#__PURE__*/jsxs(Flex, {
|
|
48
|
+
align: "center",
|
|
49
|
+
gap: 3,
|
|
50
|
+
children: [/*#__PURE__*/jsx(Text, {
|
|
51
|
+
color: "secondary",
|
|
52
|
+
variant: "label",
|
|
53
|
+
children: showingText || 'Tampilkan:'
|
|
54
|
+
}), /*#__PURE__*/jsxs(Popover, {
|
|
55
|
+
children: [/*#__PURE__*/jsx(ConditionalWrapper, {
|
|
56
|
+
condition: !isMobilePagination,
|
|
57
|
+
wrapper: child => /*#__PURE__*/jsx(PopoverTrigger, {
|
|
58
|
+
children: child
|
|
59
|
+
}),
|
|
60
|
+
children: /*#__PURE__*/jsxs(LimitContainer, {
|
|
61
|
+
align: "center",
|
|
62
|
+
onClick: () => {
|
|
63
|
+
if (isMobilePagination) {
|
|
64
|
+
dialogLimitRef.current?.click();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
children: [/*#__PURE__*/jsx(Text, {
|
|
68
|
+
color: "primary",
|
|
69
|
+
variant: "status",
|
|
70
|
+
children: selectedLimit.toString()
|
|
71
|
+
}), /*#__PURE__*/jsx(ChevronDownOutline, {
|
|
72
|
+
color: colors.gray400
|
|
73
|
+
})]
|
|
74
|
+
})
|
|
75
|
+
}), /*#__PURE__*/jsx(PopoverContent, {
|
|
76
|
+
placement: "top",
|
|
77
|
+
children: /*#__PURE__*/jsx(Flex, {
|
|
78
|
+
direction: "column",
|
|
79
|
+
align: "center",
|
|
80
|
+
css: {
|
|
81
|
+
backgroundColor: '$bgWhite',
|
|
82
|
+
boxShadow: '$small'
|
|
83
|
+
},
|
|
84
|
+
children: limits?.map(limit => /*#__PURE__*/jsx(PopoverClose, {
|
|
85
|
+
css: limitItemContainerStyle(selectedLimit === limit),
|
|
86
|
+
onClick: () => onChange(limit),
|
|
87
|
+
children: /*#__PURE__*/jsx(Text, {
|
|
88
|
+
color: "primary",
|
|
89
|
+
variant: "status",
|
|
90
|
+
children: limit.toString()
|
|
91
|
+
})
|
|
92
|
+
}, limit))
|
|
93
|
+
})
|
|
94
|
+
})]
|
|
95
|
+
}), /*#__PURE__*/jsx(Text, {
|
|
96
|
+
color: "secondary",
|
|
97
|
+
variant: "label",
|
|
98
|
+
children: typeof showingCountText === 'function' ? showingCountText({
|
|
99
|
+
from,
|
|
100
|
+
to,
|
|
101
|
+
total: totalData
|
|
102
|
+
}) : showingCountText || `Ditampilkan ${from} - ${to} dari ${totalData} data`
|
|
103
|
+
})]
|
|
104
|
+
}), /*#__PURE__*/jsxs(ModalDialog, {
|
|
105
|
+
children: [/*#__PURE__*/jsx(ModalDialogTrigger, {
|
|
106
|
+
style: {
|
|
107
|
+
display: 'none'
|
|
108
|
+
},
|
|
109
|
+
children: /*#__PURE__*/jsx("div", {
|
|
110
|
+
ref: dialogLimitRef
|
|
111
|
+
})
|
|
112
|
+
}), /*#__PURE__*/jsx(ModalDialogTitle, {
|
|
113
|
+
children: dialogShowingText || 'Tampilkan Data'
|
|
114
|
+
}), /*#__PURE__*/jsx(ModalDialogContent, {
|
|
115
|
+
style: {
|
|
116
|
+
padding: 0
|
|
117
|
+
},
|
|
118
|
+
children: /*#__PURE__*/jsx(Box, {
|
|
119
|
+
css: {
|
|
120
|
+
padding: '$spacing-04 0px'
|
|
121
|
+
},
|
|
122
|
+
children: limits?.map(limit => /*#__PURE__*/jsx(Flex, {
|
|
123
|
+
css: {
|
|
124
|
+
height: 44,
|
|
125
|
+
width: '100%',
|
|
126
|
+
padding: '$spacing-03 $spacing-06',
|
|
127
|
+
cursor: 'pointer',
|
|
128
|
+
background: selectedLimit === limit && '$bgSelectedLight',
|
|
129
|
+
'&:hover': {
|
|
130
|
+
background: '$gray50'
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
align: "center",
|
|
134
|
+
onClick: () => {
|
|
135
|
+
onChange(limit);
|
|
136
|
+
dialogLimitRef.current?.click();
|
|
137
|
+
},
|
|
138
|
+
children: limit.toString()
|
|
139
|
+
}, limit))
|
|
140
|
+
})
|
|
141
|
+
})]
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { PaginationInfo as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import { styled } from '../../config/stitches.config.esm.js';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const PaperComponent = styled('div', {
|
|
7
|
+
padding: '20px',
|
|
8
|
+
height: 'auto',
|
|
9
|
+
width: 'auto',
|
|
10
|
+
borderRadius: '$lg',
|
|
11
|
+
backgroundColor: '$white',
|
|
12
|
+
boxShadow: '0px 2px 12px #00000014',
|
|
13
|
+
variants: {
|
|
14
|
+
responsive: {
|
|
15
|
+
true: {
|
|
16
|
+
backgroundColor: 'transparent',
|
|
17
|
+
boxShadow: 'none',
|
|
18
|
+
'@md': {
|
|
19
|
+
backgroundColor: '$white',
|
|
20
|
+
boxShadow: '0px 2px 12px #00000014'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
mobileOnly: {
|
|
25
|
+
true: {
|
|
26
|
+
'@lg': {
|
|
27
|
+
display: 'none !important'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
desktopOnly: {
|
|
32
|
+
true: {
|
|
33
|
+
display: 'none !important',
|
|
34
|
+
'@lg': {
|
|
35
|
+
display: 'block !important'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const Paper = ({
|
|
42
|
+
className,
|
|
43
|
+
children,
|
|
44
|
+
radius,
|
|
45
|
+
padding,
|
|
46
|
+
width,
|
|
47
|
+
height,
|
|
48
|
+
...props
|
|
49
|
+
}) => {
|
|
50
|
+
return /*#__PURE__*/jsx(PaperComponent, {
|
|
51
|
+
className: className,
|
|
52
|
+
css: {
|
|
53
|
+
width: width,
|
|
54
|
+
height: height,
|
|
55
|
+
padding: padding,
|
|
56
|
+
borderRadius: radius,
|
|
57
|
+
...props.css
|
|
58
|
+
},
|
|
59
|
+
...props,
|
|
60
|
+
children: children
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
Paper.propTypes = {
|
|
64
|
+
className: PropTypes.string,
|
|
65
|
+
radius: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
66
|
+
padding: PropTypes.string,
|
|
67
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
68
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
69
|
+
};
|
|
70
|
+
Paper.defaultProps = {
|
|
71
|
+
className: '',
|
|
72
|
+
radius: '$lg',
|
|
73
|
+
padding: '20px'
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { Paper, PaperComponent, Paper as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import { styled } from '../../config/stitches.config.esm.js';
|
|
3
|
+
import Text from '../text/Text.esm.js';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { seqNumberVariants } from '../../utils/variant.esm.js';
|
|
6
|
+
|
|
7
|
+
const Paragraph = styled(Text, {
|
|
8
|
+
variants: {
|
|
9
|
+
paragraph: {
|
|
10
|
+
shortContentBold: {
|
|
11
|
+
fontSize: '$short-content-bold',
|
|
12
|
+
lineHeight: '$short-content-bold',
|
|
13
|
+
letterSpacing: '$short-content-bold',
|
|
14
|
+
fontWeight: '600'
|
|
15
|
+
},
|
|
16
|
+
shortContentRegular: {
|
|
17
|
+
fontSize: '$short-content-regular',
|
|
18
|
+
lineHeight: '$short-content-regular',
|
|
19
|
+
letterSpacing: '$short-content-regular',
|
|
20
|
+
fontWeight: '400'
|
|
21
|
+
},
|
|
22
|
+
longContentRegular: {
|
|
23
|
+
fontSize: '$long-content-regular',
|
|
24
|
+
lineHeight: '$long-content-regular',
|
|
25
|
+
letterSpacing: '$long-content-regular',
|
|
26
|
+
fontWeight: '400'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
maxLine: seqNumberVariants(value => ({
|
|
30
|
+
'-webkit-line-clamp': `${value}`,
|
|
31
|
+
display: '-webkit-box',
|
|
32
|
+
'-webkit-box-orient': 'vertical',
|
|
33
|
+
overflow: 'hidden'
|
|
34
|
+
}), 10)
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
paragraph: 'shortContentRegular',
|
|
38
|
+
as: 'p'
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Paragraph.propTypes = {
|
|
42
|
+
paragraph: PropTypes.oneOf(['shortContentBold', 'shortContentRegular', 'longContentRegular']),
|
|
43
|
+
uppercase: PropTypes.bool,
|
|
44
|
+
isTruncated: PropTypes.bool
|
|
45
|
+
};
|
|
46
|
+
Paragraph.defaultProps = {
|
|
47
|
+
paragraph: 'shortContentRegular',
|
|
48
|
+
as: 'p'
|
|
49
|
+
};
|
|
50
|
+
Paragraph.displayName = 'Paragraph';
|
|
51
|
+
|
|
52
|
+
export { Paragraph as default };
|